Skip to content

Commit

Permalink
Remove useless parent class
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexProgrammerDE committed Dec 17, 2024
1 parent 017fa4d commit ee12f51
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
}
}

Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
}
Expand All @@ -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));
}
}
}
Expand All @@ -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));
}
}
}
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
}
}

Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

0 comments on commit ee12f51

Please sign in to comment.