From 09bd3ff21fbc42f83817453ccb71be970f35fc37 Mon Sep 17 00:00:00 2001 From: Treetrain1 Date: Wed, 14 Feb 2024 17:49:26 -0600 Subject: [PATCH] Revert "24w07a" This reverts commit 7144fde3 --- .../wilderwild/entity/Firefly.java | 12 ++-- .../entity/ai/warden/WardenNavigation.java | 6 +- .../entity/ai/warden/WardenNodeEvaluator.java | 57 +++++++++---------- .../block/cactus/WalkNodeEvaluatorMixin.java | 11 +++- .../wilderwild/mixin/entity/ai/MobMixin.java | 6 +- .../mixin/warden/WardenSwimMixin.java | 8 +-- 6 files changed, 54 insertions(+), 46 deletions(-) diff --git a/src/main/java/net/frozenblock/wilderwild/entity/Firefly.java b/src/main/java/net/frozenblock/wilderwild/entity/Firefly.java index e50769dac7..0793a85f96 100644 --- a/src/main/java/net/frozenblock/wilderwild/entity/Firefly.java +++ b/src/main/java/net/frozenblock/wilderwild/entity/Firefly.java @@ -81,7 +81,7 @@ import net.minecraft.world.level.ServerLevelAccessor; import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.pathfinder.PathType; +import net.minecraft.world.level.pathfinder.BlockPathTypes; import net.minecraft.world.phys.Vec3; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -108,11 +108,11 @@ public class Firefly extends PathfinderMob implements FlyingAnimal { public Firefly(@NotNull EntityType entityType, @NotNull Level level) { super(entityType, level); - this.setPathfindingMalus(PathType.LAVA, -1F); - this.setPathfindingMalus(PathType.DANGER_FIRE, -1F); - this.setPathfindingMalus(PathType.WATER, -1F); - this.setPathfindingMalus(PathType.WATER_BORDER, 16F); - this.setPathfindingMalus(PathType.UNPASSABLE_RAIL, 0F); + this.setPathfindingMalus(BlockPathTypes.LAVA, -1F); + this.setPathfindingMalus(BlockPathTypes.DANGER_FIRE, -1F); + this.setPathfindingMalus(BlockPathTypes.WATER, -1F); + this.setPathfindingMalus(BlockPathTypes.WATER_BORDER, 16F); + this.setPathfindingMalus(BlockPathTypes.UNPASSABLE_RAIL, 0F); this.moveControl = new FlyingMoveControl(this, 20, true); this.setFlickers(this.random.nextInt(FLICKERS_CHANCE) == 0); this.setFlickerAge(this.random.nextIntBetweenInclusive(0, RANDOM_FLICKER_AGE_MAX)); diff --git a/src/main/java/net/frozenblock/wilderwild/entity/ai/warden/WardenNavigation.java b/src/main/java/net/frozenblock/wilderwild/entity/ai/warden/WardenNavigation.java index b698e41371..49f4b102d7 100644 --- a/src/main/java/net/frozenblock/wilderwild/entity/ai/warden/WardenNavigation.java +++ b/src/main/java/net/frozenblock/wilderwild/entity/ai/warden/WardenNavigation.java @@ -25,7 +25,7 @@ import net.minecraft.world.entity.ai.navigation.GroundPathNavigation; import net.minecraft.world.entity.monster.warden.Warden; import net.minecraft.world.level.Level; -import net.minecraft.world.level.pathfinder.PathType; +import net.minecraft.world.level.pathfinder.BlockPathTypes; import net.minecraft.world.level.pathfinder.Node; import net.minecraft.world.level.pathfinder.PathFinder; import net.minecraft.world.phys.Vec3; @@ -75,8 +75,8 @@ protected boolean canMoveDirectly(@NotNull Vec3 origin, @NotNull Vec3 target) { } @Override - protected boolean hasValidPathType(@NotNull PathType pathType) { - return EntityConfig.get().warden.wardenSwims ? pathType != PathType.OPEN : super.hasValidPathType(pathType); + protected boolean hasValidPathType(@NotNull BlockPathTypes pathType) { + return EntityConfig.get().warden.wardenSwims ? pathType != BlockPathTypes.OPEN : super.hasValidPathType(pathType); } @Override diff --git a/src/main/java/net/frozenblock/wilderwild/entity/ai/warden/WardenNodeEvaluator.java b/src/main/java/net/frozenblock/wilderwild/entity/ai/warden/WardenNodeEvaluator.java index 6ba30d6b57..eead5a9828 100644 --- a/src/main/java/net/frozenblock/wilderwild/entity/ai/warden/WardenNodeEvaluator.java +++ b/src/main/java/net/frozenblock/wilderwild/entity/ai/warden/WardenNodeEvaluator.java @@ -26,9 +26,8 @@ import net.minecraft.world.entity.Mob; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.PathNavigationRegion; -import net.minecraft.world.level.pathfinder.AmphibiousNodeEvaluator; +import net.minecraft.world.level.pathfinder.BlockPathTypes; import net.minecraft.world.level.pathfinder.Node; -import net.minecraft.world.level.pathfinder.PathType; import net.minecraft.world.level.pathfinder.Target; import net.minecraft.world.level.pathfinder.WalkNodeEvaluator; import org.jetbrains.annotations.NotNull; @@ -46,17 +45,17 @@ public WardenNodeEvaluator(boolean prefersShallowSwimming) { @Override public void prepare(@NotNull PathNavigationRegion level, @NotNull Mob mob) { super.prepare(level, mob); - mob.setPathfindingMalus(PathType.WATER, 0.0F); - this.oldWalkableCost = mob.getPathfindingMalus(PathType.WALKABLE); - mob.setPathfindingMalus(PathType.WALKABLE, 0.0F); - this.oldWaterBorderPenalty = mob.getPathfindingMalus(PathType.WATER_BORDER); - mob.setPathfindingMalus(PathType.WATER_BORDER, 4.0F); + mob.setPathfindingMalus(BlockPathTypes.WATER, 0.0F); + this.oldWalkableCost = mob.getPathfindingMalus(BlockPathTypes.WALKABLE); + mob.setPathfindingMalus(BlockPathTypes.WALKABLE, 0.0F); + this.oldWaterBorderPenalty = mob.getPathfindingMalus(BlockPathTypes.WATER_BORDER); + mob.setPathfindingMalus(BlockPathTypes.WATER_BORDER, 4.0F); } @Override public void done() { - this.mob.setPathfindingMalus(PathType.WALKABLE, this.oldWalkableCost); - this.mob.setPathfindingMalus(PathType.WATER_BORDER, this.oldWaterBorderPenalty); + this.mob.setPathfindingMalus(BlockPathTypes.WALKABLE, this.oldWalkableCost); + this.mob.setPathfindingMalus(BlockPathTypes.WATER_BORDER, this.oldWaterBorderPenalty); super.done(); } @@ -76,10 +75,10 @@ public Node getStart() { @Override @NotNull - public Target getTarget(double x, double y, double z) { + public Target getGoal(double x, double y, double z) { return !this.isEntitySubmergedInWaterOrLava(this.mob) - ? super.getTarget(x, y, z) - : this.getTargetNodeAt(x, y + 0.5, z); + ? super.getGoal(x, y, z) + : this.getTargetFromNode(this.getNode(Mth.floor(x), Mth.floor(y + 0.5), Mth.floor(z))); } @Override @@ -88,10 +87,10 @@ public int getNeighbors(Node @NotNull [] successors, @NotNull Node node) { return super.getNeighbors(successors, node); } else { int i = super.getNeighbors(successors, node); - PathType blockPathTypes = this.getCachedPathType(node.x, node.y + 1, node.z); - PathType blockPathTypes2 = this.getCachedPathType(node.x, node.y, node.z); + BlockPathTypes blockPathTypes = this.getCachedBlockType(this.mob, node.x, node.y + 1, node.z); + BlockPathTypes blockPathTypes2 = this.getCachedBlockType(this.mob, node.x, node.y, node.z); int j; - if (this.mob.getPathfindingMalus(blockPathTypes) >= 0.0F && blockPathTypes2 != PathType.STICKY_HONEY) { + if (this.mob.getPathfindingMalus(blockPathTypes) >= 0.0F && blockPathTypes2 != BlockPathTypes.STICKY_HONEY) { j = Mth.floor(Math.max(1.0F, this.mob.maxUpStep())); } else { j = 0; @@ -104,13 +103,13 @@ public int getNeighbors(Node @NotNull [] successors, @NotNull Node node) { successors[i++] = node2; } - if (this.isVerticalNeighborValid(node3, node) && blockPathTypes2 != PathType.TRAPDOOR) { + if (this.isVerticalNeighborValid(node3, node) && blockPathTypes2 != BlockPathTypes.TRAPDOOR) { successors[i++] = node3; } for (int k = 0; k < i; ++k) { Node node4 = successors[k]; - if (node4.type == PathType.WATER && this.prefersShallowSwimming && node4.y < this.mob.level().getSeaLevel() - 10) { + if (node4.type == BlockPathTypes.WATER && this.prefersShallowSwimming && node4.y < this.mob.level().getSeaLevel() - 10) { ++node4.costMalus; } } @@ -120,7 +119,7 @@ public int getNeighbors(Node @NotNull [] successors, @NotNull Node node) { } private boolean isVerticalNeighborValid(@Nullable Node node, @NotNull Node successor) { - return this.isNeighborValid(node, successor) && (node != null && node.type == PathType.WATER); + return this.isNeighborValid(node, successor) && (node != null && node.type == BlockPathTypes.WATER); } @Override @@ -128,26 +127,26 @@ protected boolean isAmphibious() { return true; } - @NotNull @Override - public PathType getPathType(BlockGetter blockGetter, int x, int y, int z) { + @NotNull + public BlockPathTypes getBlockPathType(@NotNull BlockGetter level, int x, int y, int z) { BlockPos.MutableBlockPos mutable = new BlockPos.MutableBlockPos(); - PathType pathNodeType = getPathTypeFromState(blockGetter, mutable.set(x, y, z)); - if (pathNodeType == PathType.WATER || pathNodeType == PathType.LAVA) { + BlockPathTypes pathNodeType = getBlockPathTypeRaw(level, mutable.set(x, y, z)); + if (pathNodeType == BlockPathTypes.WATER || pathNodeType == BlockPathTypes.LAVA) { for (Direction direction : Direction.values()) { - PathType pathNodeType2 = getPathTypeFromState(blockGetter, mutable.set(x, y, z).move(direction)); - if (pathNodeType2 == PathType.BLOCKED) { - return PathType.WATER_BORDER; + BlockPathTypes pathNodeType2 = getBlockPathTypeRaw(level, mutable.set(x, y, z).move(direction)); + if (pathNodeType2 == BlockPathTypes.BLOCKED) { + return BlockPathTypes.WATER_BORDER; } } - if (pathNodeType == PathType.WATER) { - return PathType.WATER; + if (pathNodeType == BlockPathTypes.WATER) { + return BlockPathTypes.WATER; } else { - return PathType.LAVA; + return BlockPathTypes.LAVA; } } else { - return getPathTypeStatic(blockGetter, mutable); + return getBlockPathTypeStatic(level, mutable); } } diff --git a/src/main/java/net/frozenblock/wilderwild/mixin/block/cactus/WalkNodeEvaluatorMixin.java b/src/main/java/net/frozenblock/wilderwild/mixin/block/cactus/WalkNodeEvaluatorMixin.java index e8dde309b6..00b798ec97 100644 --- a/src/main/java/net/frozenblock/wilderwild/mixin/block/cactus/WalkNodeEvaluatorMixin.java +++ b/src/main/java/net/frozenblock/wilderwild/mixin/block/cactus/WalkNodeEvaluatorMixin.java @@ -33,7 +33,16 @@ public class WalkNodeEvaluatorMixin { @WrapOperation( - method = "getPathTypeFromState", + method = "checkNeighbourBlocks", + at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/state/BlockState;is(Lnet/minecraft/world/level/block/Block;)Z", ordinal = 0), + slice = @Slice(from = @At(value = "FIELD", target = "Lnet/minecraft/world/level/block/Blocks;CACTUS:Lnet/minecraft/world/level/block/Block;", opcode = Opcodes.GETSTATIC)) + ) + private static boolean wilderWild$checkNeighbourBlocksWithPricklyPear(BlockState blockState, Block block, Operation operation) { + return operation.call(blockState, block) || operation.call(blockState, RegisterBlocks.PRICKLY_PEAR_CACTUS); + } + + @WrapOperation( + method = "getBlockPathTypeRaw", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/state/BlockState;is(Lnet/minecraft/world/level/block/Block;)Z", ordinal = 0), slice = @Slice(from = @At(value = "FIELD", target = "Lnet/minecraft/world/level/block/Blocks;CACTUS:Lnet/minecraft/world/level/block/Block;", opcode = Opcodes.GETSTATIC)) ) diff --git a/src/main/java/net/frozenblock/wilderwild/mixin/entity/ai/MobMixin.java b/src/main/java/net/frozenblock/wilderwild/mixin/entity/ai/MobMixin.java index 1fa2f74459..018e3f66e8 100644 --- a/src/main/java/net/frozenblock/wilderwild/mixin/entity/ai/MobMixin.java +++ b/src/main/java/net/frozenblock/wilderwild/mixin/entity/ai/MobMixin.java @@ -25,7 +25,7 @@ import net.minecraft.world.entity.monster.Slime; import net.minecraft.world.level.Level; import net.minecraft.world.level.LevelReader; -import net.minecraft.world.level.pathfinder.PathType; +import net.minecraft.world.level.pathfinder.BlockPathTypes; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -37,14 +37,14 @@ public class MobMixin { @Shadow - public void setPathfindingMalus(PathType pathType, float malus) { + public void setPathfindingMalus(BlockPathTypes nodeType, float malus) { throw new AssertionError("Mixin injection failed - Wilder Wild MobMixin."); } @Inject(method = "", at = @At("TAIL")) private void wilderWild$addUnpassableRail(EntityType entityType, Level level, CallbackInfo info) { if (EntityConfig.get().unpassableRail) { - this.setPathfindingMalus(PathType.UNPASSABLE_RAIL, 0.0F); + this.setPathfindingMalus(BlockPathTypes.UNPASSABLE_RAIL, 0.0F); } } diff --git a/src/main/java/net/frozenblock/wilderwild/mixin/warden/WardenSwimMixin.java b/src/main/java/net/frozenblock/wilderwild/mixin/warden/WardenSwimMixin.java index 2fbf7cad51..1f1332f719 100644 --- a/src/main/java/net/frozenblock/wilderwild/mixin/warden/WardenSwimMixin.java +++ b/src/main/java/net/frozenblock/wilderwild/mixin/warden/WardenSwimMixin.java @@ -43,7 +43,7 @@ import net.minecraft.world.entity.monster.warden.Warden; import net.minecraft.world.level.Level; import net.minecraft.world.level.material.Fluid; -import net.minecraft.world.level.pathfinder.PathType; +import net.minecraft.world.level.pathfinder.BlockPathTypes; import net.minecraft.world.phys.Vec3; import org.jetbrains.annotations.NotNull; import org.spongepowered.asm.mixin.Mixin; @@ -144,9 +144,9 @@ public void travel(@NotNull Vec3 travelVector) { @Inject(method = "", at = @At("TAIL")) private void wilderWild$wardenEntity(EntityType entityType, Level level, CallbackInfo ci) { Warden wardenEntity = Warden.class.cast(this); - wardenEntity.setPathfindingMalus(PathType.WATER, 0F); - wardenEntity.setPathfindingMalus(PathType.POWDER_SNOW, -1F); - wardenEntity.setPathfindingMalus(PathType.DANGER_POWDER_SNOW, -1F); + wardenEntity.setPathfindingMalus(BlockPathTypes.WATER, 0F); + wardenEntity.setPathfindingMalus(BlockPathTypes.POWDER_SNOW, -1F); + wardenEntity.setPathfindingMalus(BlockPathTypes.DANGER_POWDER_SNOW, -1F); this.moveControl = new WardenMoveControl(wardenEntity, 0.05F, 80F, 0.13F, 1F); this.lookControl = new WardenLookControl(wardenEntity, 10); }