From ee12f5125312d5f3e53cb042e5b8d93e887cde9a Mon Sep 17 00:00:00 2001 From: AlexProgrammerDE <40795980+AlexProgrammerDE@users.noreply.github.com> Date: Tue, 17 Dec 2024 15:08:41 +0100 Subject: [PATCH] Remove useless parent class --- .../graph/actions/DownMovement.java | 6 ++-- .../graph/actions/SimpleMovement.java | 12 +++---- .../pathfinding/graph/actions/UpMovement.java | 8 ++--- ...ckSafetyData.java => BlockSafetyType.java} | 31 +++++++++---------- 4 files changed, 27 insertions(+), 30 deletions(-) rename server/src/main/java/com/soulfiremc/server/pathfinding/graph/actions/movement/{BlockSafetyData.java => BlockSafetyType.java} (59%) diff --git a/server/src/main/java/com/soulfiremc/server/pathfinding/graph/actions/DownMovement.java b/server/src/main/java/com/soulfiremc/server/pathfinding/graph/actions/DownMovement.java index 283101ea..8d9c4d4e 100644 --- a/server/src/main/java/com/soulfiremc/server/pathfinding/graph/actions/DownMovement.java +++ b/server/src/main/java/com/soulfiremc/server/pathfinding/graph/actions/DownMovement.java @@ -25,7 +25,7 @@ import com.soulfiremc.server.pathfinding.graph.BlockFace; import com.soulfiremc.server.pathfinding.graph.GraphInstructions; import com.soulfiremc.server.pathfinding.graph.MinecraftGraph; -import com.soulfiremc.server.pathfinding.graph.actions.movement.BlockSafetyData; +import com.soulfiremc.server.pathfinding.graph.actions.movement.BlockSafetyType; import com.soulfiremc.server.pathfinding.graph.actions.movement.MovementMiningCost; import com.soulfiremc.server.pathfinding.graph.actions.movement.SkyDirection; import com.soulfiremc.server.util.SFBlockHelpers; @@ -86,7 +86,7 @@ private void registerCheckSafeMineBlocks(SubscriptionConsumer blockSubscribers) for (var skyDirection : SkyDirection.VALUES) { blockSubscribers.subscribe( skyDirection.offset(targetToMineBlock), - new MovementBreakSafetyCheckSubscription(BlockSafetyData.BlockSafetyType.FLUIDS)); + new MovementBreakSafetyCheckSubscription(BlockSafetyType.FLUIDS)); } } @@ -180,7 +180,7 @@ public MinecraftGraph.SubscriptionSingleResult processBlock(MinecraftGraph graph } } - private record MovementBreakSafetyCheckSubscription(BlockSafetyData.BlockSafetyType safetyType) implements DownMovementSubscription { + private record MovementBreakSafetyCheckSubscription(BlockSafetyType safetyType) implements DownMovementSubscription { @Override public MinecraftGraph.SubscriptionSingleResult processBlock(MinecraftGraph graph, SFVec3i key, DownMovement downMovement, LazyBoolean isFree, BlockState blockState, SFVec3i absoluteKey) { diff --git a/server/src/main/java/com/soulfiremc/server/pathfinding/graph/actions/SimpleMovement.java b/server/src/main/java/com/soulfiremc/server/pathfinding/graph/actions/SimpleMovement.java index cb4f2504..710ed937 100644 --- a/server/src/main/java/com/soulfiremc/server/pathfinding/graph/actions/SimpleMovement.java +++ b/server/src/main/java/com/soulfiremc/server/pathfinding/graph/actions/SimpleMovement.java @@ -124,11 +124,11 @@ private int registerRequiredFreeBlocks(SubscriptionConsumer blockSubscribers) { if (allowBlockActions) { blockSubscribers.subscribe(aboveHead.add(0, 1, 0), - new MovementBreakSafetyCheckSubscription(aboveHeadBlockIndex, BlockSafetyData.BlockSafetyType.FALLING_AND_FLUIDS)); + new MovementBreakSafetyCheckSubscription(aboveHeadBlockIndex, BlockSafetyType.FALLING_AND_FLUIDS)); for (var skyDirection : SkyDirection.VALUES) { blockSubscribers.subscribe(skyDirection.offset(aboveHead), - new MovementBreakSafetyCheckSubscription(aboveHeadBlockIndex, BlockSafetyData.BlockSafetyType.FLUIDS)); + new MovementBreakSafetyCheckSubscription(aboveHeadBlockIndex, BlockSafetyType.FLUIDS)); } } } @@ -154,12 +154,12 @@ private int registerRequiredFreeBlocks(SubscriptionConsumer blockSubscribers) { if (allowBlockActions) { if (bodyOffset == BodyPart.HEAD) { blockSubscribers.subscribe(block.add(0, 1, 0), - new MovementBreakSafetyCheckSubscription(blockIndex, BlockSafetyData.BlockSafetyType.FALLING_AND_FLUIDS)); + new MovementBreakSafetyCheckSubscription(blockIndex, BlockSafetyType.FALLING_AND_FLUIDS)); } for (var skyDirection : SkyDirection.VALUES) { blockSubscribers.subscribe(skyDirection.offset(block), - new MovementBreakSafetyCheckSubscription(blockIndex, BlockSafetyData.BlockSafetyType.FLUIDS)); + new MovementBreakSafetyCheckSubscription(blockIndex, BlockSafetyType.FLUIDS)); } } } @@ -177,7 +177,7 @@ private int registerRequiredFreeBlocks(SubscriptionConsumer blockSubscribers) { if (allowBlockActions) { for (var skyDirection : SkyDirection.VALUES) { blockSubscribers.subscribe(skyDirection.offset(fallFree), - new MovementBreakSafetyCheckSubscription(fallOneBlockIndex, BlockSafetyData.BlockSafetyType.FLUIDS)); + new MovementBreakSafetyCheckSubscription(fallOneBlockIndex, BlockSafetyType.FLUIDS)); } } } @@ -371,7 +371,7 @@ public MinecraftGraph.SubscriptionSingleResult processBlock(MinecraftGraph graph } } - private record MovementBreakSafetyCheckSubscription(int blockArrayIndex, BlockSafetyData.BlockSafetyType safetyType) implements SimpleMovementSubscription { + private record MovementBreakSafetyCheckSubscription(int blockArrayIndex, BlockSafetyType safetyType) implements SimpleMovementSubscription { @Override public MinecraftGraph.SubscriptionSingleResult processBlock(MinecraftGraph graph, SFVec3i key, SimpleMovement simpleMovement, LazyBoolean isFree, BlockState blockState, SFVec3i absoluteKey) { diff --git a/server/src/main/java/com/soulfiremc/server/pathfinding/graph/actions/UpMovement.java b/server/src/main/java/com/soulfiremc/server/pathfinding/graph/actions/UpMovement.java index af4f02d5..1a4c5861 100644 --- a/server/src/main/java/com/soulfiremc/server/pathfinding/graph/actions/UpMovement.java +++ b/server/src/main/java/com/soulfiremc/server/pathfinding/graph/actions/UpMovement.java @@ -27,7 +27,7 @@ import com.soulfiremc.server.pathfinding.graph.BlockFace; import com.soulfiremc.server.pathfinding.graph.GraphInstructions; import com.soulfiremc.server.pathfinding.graph.MinecraftGraph; -import com.soulfiremc.server.pathfinding.graph.actions.movement.BlockSafetyData; +import com.soulfiremc.server.pathfinding.graph.actions.movement.BlockSafetyType; import com.soulfiremc.server.pathfinding.graph.actions.movement.MovementMiningCost; import com.soulfiremc.server.pathfinding.graph.actions.movement.SkyDirection; import com.soulfiremc.server.protocol.bot.BotActionManager; @@ -76,11 +76,11 @@ private int registerRequiredFreeBlocks(SubscriptionConsumer blockSubscribers) { blockSubscribers.subscribe(aboveHead, new MovementFreeSubscription(aboveHeadBlockIndex, BlockFace.BOTTOM)); blockSubscribers.subscribe(aboveHead.add(0, 1, 0), - new MovementBreakSafetyCheckSubscription(aboveHeadBlockIndex, BlockSafetyData.BlockSafetyType.FALLING_AND_FLUIDS)); + new MovementBreakSafetyCheckSubscription(aboveHeadBlockIndex, BlockSafetyType.FALLING_AND_FLUIDS)); for (var skyDirection : SkyDirection.VALUES) { blockSubscribers.subscribe(skyDirection.offset(aboveHead), - new MovementBreakSafetyCheckSubscription(aboveHeadBlockIndex, BlockSafetyData.BlockSafetyType.FLUIDS)); + new MovementBreakSafetyCheckSubscription(aboveHeadBlockIndex, BlockSafetyType.FLUIDS)); } } @@ -208,7 +208,7 @@ public MinecraftGraph.SubscriptionSingleResult processBlock(MinecraftGraph graph } } - private record MovementBreakSafetyCheckSubscription(int blockArrayIndex, BlockSafetyData.BlockSafetyType safetyType) implements UpMovementSubscription { + private record MovementBreakSafetyCheckSubscription(int blockArrayIndex, BlockSafetyType safetyType) implements UpMovementSubscription { @Override public MinecraftGraph.SubscriptionSingleResult processBlock(MinecraftGraph graph, SFVec3i key, UpMovement upMovement, LazyBoolean isFree, BlockState blockState, SFVec3i absoluteKey) { diff --git a/server/src/main/java/com/soulfiremc/server/pathfinding/graph/actions/movement/BlockSafetyData.java b/server/src/main/java/com/soulfiremc/server/pathfinding/graph/actions/movement/BlockSafetyType.java similarity index 59% rename from server/src/main/java/com/soulfiremc/server/pathfinding/graph/actions/movement/BlockSafetyData.java rename to server/src/main/java/com/soulfiremc/server/pathfinding/graph/actions/movement/BlockSafetyType.java index 3c3f06fc..c180ac73 100644 --- a/server/src/main/java/com/soulfiremc/server/pathfinding/graph/actions/movement/BlockSafetyData.java +++ b/server/src/main/java/com/soulfiremc/server/pathfinding/graph/actions/movement/BlockSafetyType.java @@ -19,23 +19,20 @@ import com.soulfiremc.server.data.BlockState; import com.soulfiremc.server.data.FluidType; -import com.soulfiremc.server.pathfinding.SFVec3i; -public record BlockSafetyData(SFVec3i position, BlockSafetyType type) { - public enum BlockSafetyType { - FALLING_AND_FLUIDS { - @Override - public boolean isUnsafeBlock(BlockState state) { - return state.fluidState().type() != FluidType.EMPTY || state.blockType().fallingBlock(); - } - }, - FLUIDS { - @Override - public boolean isUnsafeBlock(BlockState state) { - return state.fluidState().type() != FluidType.EMPTY; - } - }; +public enum BlockSafetyType { + FALLING_AND_FLUIDS { + @Override + public boolean isUnsafeBlock(BlockState state) { + return state.fluidState().type() != FluidType.EMPTY || state.blockType().fallingBlock(); + } + }, + FLUIDS { + @Override + public boolean isUnsafeBlock(BlockState state) { + return state.fluidState().type() != FluidType.EMPTY; + } + }; - public abstract boolean isUnsafeBlock(BlockState state); - } + public abstract boolean isUnsafeBlock(BlockState state); }