diff --git a/src/main/java/crazypants/enderio/item/KeyTracker.java b/src/main/java/crazypants/enderio/item/KeyTracker.java index a7803b4bc8..672e3f2fd1 100644 --- a/src/main/java/crazypants/enderio/item/KeyTracker.java +++ b/src/main/java/crazypants/enderio/item/KeyTracker.java @@ -154,7 +154,8 @@ private void handleStaffOfTravelingTP() { if (player != null) { ItemStack travelItem = player.getHeldItem(); if (travelItem == null || travelItem.getItem() == null - || !(travelItem.getItem() instanceof IItemOfTravel)) { + || !(travelItem.getItem() instanceof IItemOfTravel) + || !((IItemOfTravel) travelItem.getItem()).isActive(player, travelItem)) { travelItem = TravelController.instance.findTravelItemInInventoryOrBaubles(player); } diff --git a/src/main/java/crazypants/enderio/item/darksteel/ItemDarkSteelSword.java b/src/main/java/crazypants/enderio/item/darksteel/ItemDarkSteelSword.java index f27d255306..c7d2916dcf 100644 --- a/src/main/java/crazypants/enderio/item/darksteel/ItemDarkSteelSword.java +++ b/src/main/java/crazypants/enderio/item/darksteel/ItemDarkSteelSword.java @@ -386,7 +386,15 @@ public ItemStack createItemStack() { @Override public boolean isActive(EntityPlayer ep, ItemStack equipped) { - return isTravelUpgradeActive(ep, equipped); + if (ep != null && equipped != null && isTravelUpgradeActive(ep, equipped)) { + // Only "active" if held while sneaking. But still "active" for the purposes of travel keybind if not held + if (isEquipped(ep)) { + return ep.isSneaking(); + } else { + return true; + } + } + return false; } @Override @@ -400,12 +408,12 @@ public int canExtractInternal(ItemStack equipped, int power) { } private boolean isTravelUpgradeActive(EntityPlayer ep, ItemStack equipped) { - return isEquipped(ep) && ep.isSneaking() && TravelUpgrade.loadFromItem(equipped) != null; + return ep != null && equipped != null && TravelUpgrade.loadFromItem(equipped) != null; } @Override public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { - if (isTravelUpgradeActive(player, stack)) { + if (isActive(player, stack)) { if (world.isRemote) { if (TravelController.instance.activateTravelAccessable(stack, world, player, TravelSource.STAFF)) { player.swingItem(); diff --git a/src/main/java/crazypants/enderio/teleport/ItemTeleportStaff.java b/src/main/java/crazypants/enderio/teleport/ItemTeleportStaff.java index 0331bcc6f6..9475a1bf5f 100644 --- a/src/main/java/crazypants/enderio/teleport/ItemTeleportStaff.java +++ b/src/main/java/crazypants/enderio/teleport/ItemTeleportStaff.java @@ -106,6 +106,12 @@ public int canExtractInternal(ItemStack equipped, int power) { return power; } + @Override + public int getEnergyStored(ItemStack item) { + // Has infinite energy, always report as being full of energy for any validation-code purposes. + return this.capacity; + } + @Override @SideOnly(Side.CLIENT) public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List par3List) { diff --git a/src/main/java/crazypants/enderio/teleport/TravelController.java b/src/main/java/crazypants/enderio/teleport/TravelController.java index 40f6927aca..9299e04d55 100644 --- a/src/main/java/crazypants/enderio/teleport/TravelController.java +++ b/src/main/java/crazypants/enderio/teleport/TravelController.java @@ -162,7 +162,8 @@ public String validatePacketTravelEvent(EntityPlayerMP toTp, int x, int y, int z case STAFF_BLINK: if (Config.travelStaffKeybindEnabled) { if (equippedItem == null || equippedItem.getItem() == null - || !(equippedItem.getItem() instanceof IItemOfTravel)) { + || !(equippedItem.getItem() instanceof IItemOfTravel) + || !((IItemOfTravel) equippedItem.getItem()).isActive(toTp, equippedItem)) { equippedItem = findTravelItemInInventoryOrBaubles(toTp); } } @@ -547,7 +548,8 @@ public TravelSource getTravelItemTravelSource(EntityPlayer ep, boolean checkInve ItemStack equipped = ep.getCurrentEquippedItem(); if (checkInventoryAndBaubles) { - if (equipped == null || !(equipped.getItem() instanceof IItemOfTravel)) { + if (equipped == null || !(equipped.getItem() instanceof IItemOfTravel) + || !((IItemOfTravel) equipped.getItem()).isActive(ep, equipped)) { equipped = findTravelItemInInventoryOrBaubles(ep); } } @@ -576,7 +578,8 @@ public ItemStack findTravelItemInInventoryOrBaubles(EntityPlayer ep) { ItemStack travelItem = null; for (int i = 0; i < ep.inventory.getSizeInventory(); i++) { ItemStack stack = ep.inventory.getStackInSlot(i); - if (stack != null && stack.getItem() instanceof IItemOfTravel) { + if (stack != null && stack.getItem() instanceof IItemOfTravel + && ((IItemOfTravel) stack.getItem()).isActive(ep, stack)) { travelItem = stack; break; } @@ -587,7 +590,8 @@ public ItemStack findTravelItemInInventoryOrBaubles(EntityPlayer ep) { if (baubles != null) { for (int i = 0; i < baubles.getSizeInventory(); i++) { ItemStack stack = baubles.getStackInSlot(i); - if (stack != null && stack.getItem() instanceof IItemOfTravel) { + if (stack != null && stack.getItem() instanceof IItemOfTravel + && ((IItemOfTravel) stack.getItem()).isActive(ep, stack)) { travelItem = stack; break; } @@ -611,7 +615,8 @@ public int findTravelItemSlotInInventoryOrBaubles(EntityPlayer ep) { int travelItemSlot = -1; for (int i = 0; i < ep.inventory.getSizeInventory(); i++) { ItemStack stack = ep.inventory.getStackInSlot(i); - if (stack != null && (stack.getItem() instanceof IItemOfTravel)) { + if (stack != null && stack.getItem() instanceof IItemOfTravel + && ((IItemOfTravel) stack.getItem()).isActive(ep, stack)) { travelItemSlot = i; break; } @@ -622,7 +627,8 @@ public int findTravelItemSlotInInventoryOrBaubles(EntityPlayer ep) { if (baubles != null) { for (int i = 0; i < baubles.getSizeInventory(); i++) { ItemStack stack = baubles.getStackInSlot(i); - if (stack != null && stack.getItem() instanceof IItemOfTravel) { + if (stack != null && stack.getItem() instanceof IItemOfTravel + && ((IItemOfTravel) stack.getItem()).isActive(ep, stack)) { travelItemSlot = -(i + 2); break; }