Skip to content

Commit

Permalink
Merge branch 'main' into document-allay-flay-cost
Browse files Browse the repository at this point in the history
  • Loading branch information
navarchus authored Aug 27, 2024
2 parents 7abeb32 + 7da86e1 commit 392e053
Show file tree
Hide file tree
Showing 13 changed files with 553 additions and 520 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import at.petrak.hexcasting.api.casting.ActionRegistryEntry;
import at.petrak.hexcasting.xplat.IXplatAbstractions;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey;
Expand Down Expand Up @@ -47,6 +45,8 @@ public static final class Blocks {
// Used to determine what blocks should be replaced with air by OpDestroyFluid
public static final TagKey<Block> WATER_PLANTS = create("water_plants");

public static final TagKey<Block> CHEAP_TO_BREAK_BLOCK = create("cheap_to_break_block");

public static TagKey<Block> create(String name) {
return TagKey.create(Registries.BLOCK, modLoc(name));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import at.petrak.hexcasting.api.casting.getVec3
import at.petrak.hexcasting.api.casting.iota.Iota
import at.petrak.hexcasting.api.misc.MediaConstants
import at.petrak.hexcasting.api.mod.HexConfig
import at.petrak.hexcasting.api.mod.HexTags
import at.petrak.hexcasting.xplat.IXplatAbstractions
import net.minecraft.core.BlockPos
import net.minecraft.server.level.ServerPlayer
Expand All @@ -18,16 +19,18 @@ object OpBreakBlock : SpellAction {
get() = 1

override fun execute(
args: List<Iota>,
env: CastingEnvironment
args: List<Iota>,
env: CastingEnvironment
): SpellAction.Result {
val vecPos = args.getVec3(0, argc)
val pos = BlockPos.containing(vecPos)
env.assertPosInRangeForEditing(pos)

val isCheap = env.world.getBlockState(pos).`is`(HexTags.Blocks.CHEAP_TO_BREAK_BLOCK)

return SpellAction.Result(
Spell(pos),
MediaConstants.DUST_UNIT / 8,
if (isCheap) MediaConstants.DUST_UNIT / 100 else MediaConstants.DUST_UNIT / 8,
listOf(ParticleSpray.burst(Vec3.atCenterOf(pos), 1.0))
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,36 @@ import at.petrak.hexcasting.api.casting.getPositiveDoubleUnderInclusive
import at.petrak.hexcasting.api.casting.getVec3
import at.petrak.hexcasting.api.casting.iota.Iota
import at.petrak.hexcasting.api.misc.MediaConstants
import at.petrak.hexcasting.common.casting.actions.selectors.OpGetEntitiesBy
import net.minecraft.core.BlockPos
import net.minecraft.util.Mth
import net.minecraft.world.level.Level
import net.minecraft.world.phys.AABB
import net.minecraft.world.phys.Vec3

class OpExplode(val fire: Boolean) : SpellAction {
override val argc: Int
get() = 2

override fun execute(
args: List<Iota>,
env: CastingEnvironment
args: List<Iota>,
env: CastingEnvironment
): SpellAction.Result {
val pos = args.getVec3(0, argc)
var pos = args.getVec3(0, argc)
val strength = args.getPositiveDoubleUnderInclusive(1, 10.0, argc)
env.assertVecInRange(pos)

// Prevent the footgun of explosions exactly at an entity's eye position not doing damage
val eps = 0.01;
val epsv = Vec3(eps, eps, eps)
val aabb = AABB(pos.subtract(epsv), pos.add(epsv))
val tooCloseToEyePos = env.world.getEntities(null, aabb) {
OpGetEntitiesBy.isReasonablySelectable(env, it)
}.any { it.eyePosition.distanceToSqr(pos) == 0.0 }
if (tooCloseToEyePos) {
pos = pos.add(0.0, 0.000001, 0.0)
}

val clampedStrength = Mth.clamp(strength, 0.0, 10.0)
val cost = MediaConstants.DUST_UNIT * (3 * clampedStrength + if (fire) 1.0 else 0.125)
return SpellAction.Result(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
public class HexBlockTagProvider extends PaucalBlockTagProvider {
public final IXplatTags xtags;

public HexBlockTagProvider(PackOutput output, CompletableFuture<HolderLookup.Provider> lookupProvider, IXplatTags xtags) {
public HexBlockTagProvider(PackOutput output, CompletableFuture<HolderLookup.Provider> lookupProvider,
IXplatTags xtags) {
super(output, lookupProvider);
this.xtags = xtags;
}
Expand Down Expand Up @@ -94,18 +95,17 @@ protected void addTags(HolderLookup.Provider provider) {
add(tag(BlockTags.STAIRS),
HexBlocks.EDIFIED_STAIRS);
add(tag(BlockTags.FENCES),
HexBlocks.EDIFIED_FENCE);
HexBlocks.EDIFIED_FENCE);
add(tag(BlockTags.WOODEN_FENCES),
HexBlocks.EDIFIED_FENCE);
HexBlocks.EDIFIED_FENCE);
add(tag(BlockTags.FENCE_GATES),
HexBlocks.EDIFIED_FENCE_GATE);
HexBlocks.EDIFIED_FENCE_GATE);
add(tag(BlockTags.UNSTABLE_BOTTOM_CENTER),
HexBlocks.EDIFIED_FENCE_GATE);

HexBlocks.EDIFIED_FENCE_GATE);


add(tag(BlockTags.WOODEN_FENCES),
HexBlocks.EDIFIED_FENCE);
HexBlocks.EDIFIED_FENCE);
add(tag(BlockTags.WOODEN_STAIRS),
HexBlocks.EDIFIED_STAIRS);
add(tag(BlockTags.DOORS),
Expand All @@ -127,6 +127,8 @@ protected void addTags(HolderLookup.Provider provider) {

add(tag(HexTags.Blocks.WATER_PLANTS),
Blocks.KELP, Blocks.KELP_PLANT, Blocks.SEAGRASS, Blocks.TALL_SEAGRASS);
add(tag(HexTags.Blocks.CHEAP_TO_BREAK_BLOCK),
HexBlocks.CONJURED_BLOCK, HexBlocks.CONJURED_LIGHT);
}

void add(TagAppender<Block> appender, Block... blocks) {
Expand Down
Loading

0 comments on commit 392e053

Please sign in to comment.