mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-10-26 14:24:40 +00:00
Render travel anchor when holding staff in offhand (#226)
This commit is contained in:
1 parent
267adc0a31
commit
181d48ac60
3 files changed
+41
-9
No files matched your search
@@ -12,6 +12,7 @@ dependencies {
|
||||
|
||||
devOnlyNonPublishable('com.github.GTNewHorizons:waila:1.19.22:dev') {transitive = false}
|
||||
runtimeOnlyNonPublishable('com.github.GTNewHorizons:WAILAPlugins:0.7.2:dev') {transitive = false}
|
||||
compileOnly("com.github.GTNewHorizons:Backhand:1.8.4:dev") { transitive = false }
|
||||
compileOnly('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-812-GTNH:api') {transitive = false}
|
||||
compileOnly('com.github.GTNewHorizons:Baubles-Expanded:2.2.6-GTNH:dev') {transitive = false}
|
||||
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.52.261:dev') {transitive = false}
|
||||
|
||||
@@ -15,6 +15,7 @@ import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
@@ -66,7 +67,9 @@ import crazypants.enderio.teleport.packet.PacketDrainStaff;
|
||||
import crazypants.enderio.teleport.packet.PacketLongDistanceTravelEvent;
|
||||
import crazypants.enderio.teleport.packet.PacketOpenAuthGui;
|
||||
import crazypants.enderio.teleport.packet.PacketTravelEvent;
|
||||
import crazypants.util.BackhandUtil;
|
||||
import crazypants.util.BaublesUtil;
|
||||
import xonin.backhand.api.core.BackhandUtils;
|
||||
|
||||
public class TravelController {
|
||||
|
||||
@@ -538,6 +541,21 @@ public class TravelController {
|
||||
return action < 2;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private TravelSource getTravelSource(final EntityPlayer ep, final ItemStack stack) {
|
||||
final Item item = stack.getItem();
|
||||
if (item instanceof ItemTeleportStaff) {
|
||||
if (((ItemTeleportStaff) item).isActive(ep, stack)) {
|
||||
return TravelSource.TELEPORT_STAFF;
|
||||
}
|
||||
} else if (item instanceof IItemOfTravel) {
|
||||
if (((IItemOfTravel) item).isActive(ep, stack)) {
|
||||
return TravelSource.STAFF;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Returns null if no travel item is in inventory/baubles. */
|
||||
@Nullable
|
||||
public TravelSource getTravelItemTravelSource(EntityPlayer ep, boolean checkInventoryAndBaubles) {
|
||||
@@ -545,6 +563,16 @@ public class TravelController {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (BackhandUtil.backhandLoaded) {
|
||||
final ItemStack offhand = BackhandUtils.getOffhandItem(ep);
|
||||
if (offhand != null && offhand.getItem() != null) {
|
||||
final TravelSource source = getTravelSource(ep, offhand);
|
||||
if (source != null) {
|
||||
return source;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ItemStack equipped = ep.getCurrentEquippedItem();
|
||||
if (checkInventoryAndBaubles) {
|
||||
if (equipped == null || !(equipped.getItem() instanceof IItemOfTravel)
|
||||
@@ -552,16 +580,9 @@ public class TravelController {
|
||||
equipped = findTravelItemInInventoryOrBaubles(ep);
|
||||
}
|
||||
}
|
||||
|
||||
if (equipped != null) {
|
||||
if (equipped.getItem() instanceof ItemTeleportStaff) {
|
||||
if (((ItemTeleportStaff) equipped.getItem()).isActive(ep, equipped)) {
|
||||
return TravelSource.TELEPORT_STAFF;
|
||||
}
|
||||
} else if (equipped.getItem() instanceof IItemOfTravel) {
|
||||
if (((IItemOfTravel) equipped.getItem()).isActive(ep, equipped)) {
|
||||
return TravelSource.STAFF;
|
||||
}
|
||||
}
|
||||
return getTravelSource(ep, equipped);
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -634,6 +655,7 @@ public class TravelController {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return travelItemSlot;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package crazypants.util;
|
||||
|
||||
import cpw.mods.fml.common.Loader;
|
||||
|
||||
public class BackhandUtil {
|
||||
|
||||
public final static boolean backhandLoaded = Loader.isModLoaded("backhand");
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user