From d90c7dae1b4c2d3ad7c3d83a5520d0ad4971e401 Mon Sep 17 00:00:00 2001 From: D-Cysteine <54219287+D-Cysteine@users.noreply.github.com> Date: Sat, 13 Apr 2024 09:06:16 -0600 Subject: [PATCH] Tweak teleport staff controls --- .../java/crazypants/enderio/config/Config.java | 10 ++++++++++ .../enderio/teleport/ItemTeleportStaff.java | 14 +++++++++++--- .../enderio/teleport/TravelController.java | 9 +++++++-- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/src/main/java/crazypants/enderio/config/Config.java b/src/main/java/crazypants/enderio/config/Config.java index a377ea0f..75c93ee4 100644 --- a/src/main/java/crazypants/enderio/config/Config.java +++ b/src/main/java/crazypants/enderio/config/Config.java @@ -174,6 +174,8 @@ public final class Config { * The distance travelled when no block is found within {@link #teleportStaffMaxBlinkDistance}. */ public static int teleportStaffFailedBlinkDistance = 64; + /** If true, don't invert the staff of teleportation controls. */ + public static boolean teleportStaffOriginalControls = false; public static int enderIoRange = 8; public static boolean enderIoMeAccessEnabled = true; @@ -1269,6 +1271,14 @@ public final class Config { "Number of blocks teleported when no block is being looked at.") .getInt(teleportStaffFailedBlinkDistance); + teleportStaffOriginalControls = config + .get( + sectionPersonal.name, + "teleportStaffOriginalControls", + teleportStaffOriginalControls, + "If true, the staff of teleportation will use its original controls: R-Click for teleport to look, Shift R-Click for teleport to anchor.") + .getBoolean(teleportStaffOriginalControls); + enderIoRange = config.get( sectionEfficiency.name, "enderIoRange", diff --git a/src/main/java/crazypants/enderio/teleport/ItemTeleportStaff.java b/src/main/java/crazypants/enderio/teleport/ItemTeleportStaff.java index a0d50c98..4723766c 100644 --- a/src/main/java/crazypants/enderio/teleport/ItemTeleportStaff.java +++ b/src/main/java/crazypants/enderio/teleport/ItemTeleportStaff.java @@ -2,6 +2,7 @@ package crazypants.enderio.teleport; import java.util.List; +import crazypants.enderio.config.Config; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; @@ -56,10 +57,17 @@ public class ItemTeleportStaff extends ItemTravelStaff { @Override public ItemStack onItemRightClick(ItemStack equipped, World world, EntityPlayer player) { if (world.isRemote) { - if (player.isSneaking()) { - TravelController.instance + if (Config.teleportStaffOriginalControls) { + if (player.isSneaking()) { + TravelController.instance .activateTravelAccessable(equipped, world, player, TravelSource.TELEPORT_STAFF); - } else { + } else { + TravelController.instance.doTeleport(player); + } + } else if ( + player.isSneaking() + || !TravelController.instance + .activateTravelAccessable(equipped, world, player, TravelSource.TELEPORT_STAFF)) { TravelController.instance.doTeleport(player); } } diff --git a/src/main/java/crazypants/enderio/teleport/TravelController.java b/src/main/java/crazypants/enderio/teleport/TravelController.java index 866e1449..9c054185 100644 --- a/src/main/java/crazypants/enderio/teleport/TravelController.java +++ b/src/main/java/crazypants/enderio/teleport/TravelController.java @@ -358,7 +358,7 @@ public class TravelController { double distanceIncrement = -2; // Special case: if the targeted block is too close, we'll try to teleport through it. - if (teleDistance < 3) { + if (teleDistance < 4) { distanceIncrement = 2; } @@ -527,7 +527,7 @@ public class TravelController { } onBlockCoord = getActiveTravelBlock(player); boolean onBlock = onBlockCoord != null; - showTargets = onBlock || isTravelItemActive(player, false); + showTargets = onBlock || (isTravelItemActive(player, false) && !shouldHideTargets(player)); if (showTargets) { updateSelectedTarget(player); } else { @@ -619,6 +619,11 @@ public class TravelController { return getTravelItemTravelSource(ep, checkInventoryAndBaubles) != null; } + public boolean shouldHideTargets(EntityPlayer ep) { + return getTravelItemTravelSource(ep, false) != TravelSource.TELEPORT_STAFF + || (!Config.teleportStaffOriginalControls && ep.isSneaking()); + } + /** Returns null if no travel item is in inventory/baubles. */ @Nullable public TravelSource getTravelItemTravelSource(EntityPlayer ep, boolean checkInventoryAndBaubles) {