Skip to content

Commit

Permalink
AutoDoors - Added an option to interact with fence gates.
Browse files Browse the repository at this point in the history
  • Loading branch information
0xTas committed Nov 7, 2024
1 parent bb9347a commit fbd81e1
Showing 1 changed file with 34 additions and 2 deletions.
36 changes: 34 additions & 2 deletions src/main/java/dev/stardust/modules/AutoDoors.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,14 @@ public enum MuteModes {
.build()
);

private final Setting<Boolean> useFenceGates = settings.getDefaultGroup().add(
new BoolSetting.Builder()
.name("Fence Gates")
.description("Interact with fence gates.")
.defaultValue(false)
.build()
);

private int tickCounter = 0;
private int ticksSinceInteracted = 0;
private Vec3d lastBlock = new Vec3d(0.0, 0.0, 0.0);
Expand Down Expand Up @@ -342,18 +350,31 @@ private void onPlayerMove(PlayerMoveEvent event) {
if (useTrapdoors.get() && doorInFront instanceof TrapdoorBlock && autoOpen.get()) {
try {
if (!frontState.get(TrapdoorBlock.OPEN)) {
this.interactDoor(frontPos, movementDirection);
interactDoor(frontPos, movementDirection);
return;
}
} catch (IllegalArgumentException ignored) {} // skill issue insurance
} else if (useTrapdoors.get() && mc.world.getBlockState(frontPos.down()).getBlock() instanceof TrapdoorBlock && autoOpen.get()) {
try {
if (!mc.world.getBlockState(frontPos.down()).get(TrapdoorBlock.OPEN)) {
this.interactDoor(frontPos.down(), Direction.DOWN);
interactDoor(frontPos.down(), Direction.DOWN);
return;
}
} catch (IllegalArgumentException ignored) {}
}
Block doorAboveFront = mc.world.getBlockState(frontPos.up()).getBlock();
Block doorAboveBack = mc.world.getBlockState(behindPos.up()).getBlock();
if (useFenceGates.get() && doorInFront instanceof FenceGateBlock || doorAboveFront instanceof FenceGateBlock && autoOpen.get()) {
try {
if (!frontState.get(FenceGateBlock.OPEN)) {
interactDoor(frontPos, movementDirection);
if (doorAboveFront instanceof FenceGateBlock && !mc.world.getBlockState(frontPos.up()).get(FenceGateBlock.OPEN)) {
interactDoor(frontPos.up(), movementDirection);
}
return;
}
}catch (IllegalArgumentException ignored) {}
}
if (doorInFront instanceof DoorBlock frontDoor && autoOpen.get()) {
if (useIronDoors.get() && frontDoor == Blocks.IRON_DOOR) {
if (this.ticksSinceInteracted >= interactDelay.get()) {
Expand Down Expand Up @@ -403,6 +424,17 @@ private void onPlayerMove(PlayerMoveEvent event) {
}
} catch (IllegalArgumentException ignored) {}
}
if (useFenceGates.get() && doorBehind instanceof FenceGateBlock || doorAboveBack instanceof FenceGateBlock) {
try {
if (behindState.get(FenceGateBlock.OPEN)) {
interactDoor(behindPos, movementDirection);
if (doorAboveBack instanceof FenceGateBlock && mc.world.getBlockState(behindPos.up()).get(FenceGateBlock.OPEN)) {
interactDoor(behindPos.up(), movementDirection);
}
return;
}
} catch (IllegalArgumentException ignored) {}
}
if (doorBehind instanceof DoorBlock behindDoor) {
if (useIronDoors.get() && behindDoor == Blocks.IRON_DOOR) {
if (this.ticksSinceInteracted >= interactDelay.get()) {
Expand Down

0 comments on commit fbd81e1

Please sign in to comment.