diff --git a/src/main/java/ganymedes01/etfuturum/backhand/Backhand.java b/src/main/java/ganymedes01/etfuturum/backhand/Backhand.java index 39f73aea..900cf9a5 100644 --- a/src/main/java/ganymedes01/etfuturum/backhand/Backhand.java +++ b/src/main/java/ganymedes01/etfuturum/backhand/Backhand.java @@ -1,23 +1,27 @@ package ganymedes01.etfuturum.backhand; +import ganymedes01.etfuturum.api.backhand.BackhandExtendedProperty; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumAction; import net.minecraft.item.ItemStack; +import net.minecraft.item.ItemSword; +import net.minecraft.item.ItemTool; public class Backhand { public static Backhand INSTANCE = new Backhand(); - public static boolean OffhandAttack = false; - public static boolean EmptyOffhand = false; - public static boolean OffhandBreakBlocks = false; - public static boolean UseOffhandArrows = true; - public static boolean UseOffhandBow = true; - public static boolean OffhandTickHotswap = true; - public static int AlternateOffhandSlot = 9; - public static boolean UseInventorySlot = false; - public static String[] offhandBlacklist; - - public static boolean RenderEmptyOffhandAtRest = false; - - public static boolean isOffhandBlacklisted(ItemStack stack) { + public boolean OffhandAttack = false; + public boolean EmptyOffhand = false; + public boolean OffhandBreakBlocks = false; + public boolean UseOffhandArrows = true; + public boolean UseOffhandBow = true; + public boolean OffhandTickHotswap = true; + public int AlternateOffhandSlot = 9; + public boolean UseInventorySlot = false; + public String[] offhandBlacklist; + public boolean RenderEmptyOffhandAtRest = false; + + public boolean isOffhandBlacklisted(ItemStack stack) { if (stack == null) return false; @@ -28,4 +32,41 @@ public static boolean isOffhandBlacklisted(ItemStack stack) { } return false; } + + public void setPlayerOffhandItem(EntityPlayer player, ItemStack stack) { + if (!isOffhandBlacklisted(stack)) { + if (UseInventorySlot) { + player.inventory.setInventorySlotContents(AlternateOffhandSlot, stack); + } else { + getOffhandEP(player).setOffhandItem(stack); + } + } + } + + public ItemStack getOffhandItem(EntityPlayer player) { + if (UseInventorySlot) { + return player.inventory.getStackInSlot(AlternateOffhandSlot); + } else { + return getOffhandEP(player).getOffhandItem(); + } + } + + public void swapOffhandItem(EntityPlayer player) { + final ItemStack mainhandItem = player.getCurrentEquippedItem(); + final ItemStack offhandItem = getOffhandItem(player); + setPlayerCurrentItem(player, offhandItem); + setPlayerOffhandItem(player, mainhandItem); + } + + public static BackhandExtendedProperty getOffhandEP(EntityPlayer player) { + return ((BackhandExtendedProperty)player.getExtendedProperties("OffhandStorage")); + } + + public static boolean hasOffhandInventory(EntityPlayer player) { + return player.inventory instanceof InventoryPlayerBattle; + } + + public static void setPlayerCurrentItem(EntityPlayer player, ItemStack stack) { + player.inventory.setInventorySlotContents(player.inventory.currentItem, stack); + } } \ No newline at end of file diff --git a/src/main/java/ganymedes01/etfuturum/backhand/BackhandClientEventHandler.java b/src/main/java/ganymedes01/etfuturum/backhand/BackhandClientEventHandler.java index 222806db..156530aa 100644 --- a/src/main/java/ganymedes01/etfuturum/backhand/BackhandClientEventHandler.java +++ b/src/main/java/ganymedes01/etfuturum/backhand/BackhandClientEventHandler.java @@ -135,11 +135,11 @@ public void clientHelper(TickEvent.PlayerTickEvent event) { delay--; } - if (!Backhand.OffhandBreakBlocks) { + if (!Backhand.INSTANCE.OffhandBreakBlocks) { return; } - if (!Backhand.EmptyOffhand && BattlegearUtils.getOffhandItem(event.player) == null) { + if (!Backhand.INSTANCE.EmptyOffhand && BattlegearUtils.getOffhandItem(event.player) == null) { return; } @@ -292,7 +292,7 @@ public void resetPlayerLeftHand(RenderPlayerEvent.Post event){ @SubscribeEvent public void render3rdPersonOffhand(RenderPlayerEvent.Specials.Post event) { - if (!Backhand.EmptyOffhand && BattlegearUtils.getOffhandItem(event.entityPlayer) == null) { + if (!Backhand.INSTANCE.EmptyOffhand && BattlegearUtils.getOffhandItem(event.entityPlayer) == null) { return; } diff --git a/src/main/java/ganymedes01/etfuturum/backhand/BackhandEventHandler.java b/src/main/java/ganymedes01/etfuturum/backhand/BackhandEventHandler.java index 400ff6ab..8bfca160 100644 --- a/src/main/java/ganymedes01/etfuturum/backhand/BackhandEventHandler.java +++ b/src/main/java/ganymedes01/etfuturum/backhand/BackhandEventHandler.java @@ -14,6 +14,7 @@ import ganymedes01.etfuturum.backhand.client.renderer.RenderOffhandPlayer; import ganymedes01.etfuturum.backhand.packets.BackhandSwapPacket; import ganymedes01.etfuturum.backhand.packets.BackhandWorldHotswapPacket; +import ganymedes01.etfuturum.network.BackhandHandler; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityClientPlayerMP; import net.minecraft.client.gui.GuiIngame; @@ -60,9 +61,9 @@ public void onPlayerInteractNonVanilla(PlayerInteractEvent event) { if(event.action == PlayerInteractEvent.Action.RIGHT_CLICK_AIR) { EntityPlayer player = event.entityPlayer; ItemStack mainhandItem = player.getHeldItem(); - ItemStack offhandItem = BattlegearUtils.getOffhandItem(player); + ItemStack offhandItem = Backhand.INSTANCE.getOffhandItem(player); if((mainhandItem == null || mainhandItem.getItem() != Items.fireworks) && offhandItem != null && offhandItem.getItem() == Items.fireworks) { - BattlegearUtils.swapOffhandItem(player); + Backhand.INSTANCE.swapOffhandItem(player); fireworkHotSwapped = 1; } } @@ -74,10 +75,10 @@ public void onLivingDeath(LivingDeathEvent event) { return; EntityPlayer player = (EntityPlayer) event.entityLiving; - if (!BattlegearUtils.hasOffhandInventory(player)) { - ItemStack offhandItem = BattlegearUtils.getOffhandItem(player); + if (!Backhand.INSTANCE.hasOffhandInventory(player)) { + ItemStack offhandItem = Backhand.INSTANCE.getOffhandItem(player); player.func_146097_a(offhandItem, true, false); - BattlegearUtils.setPlayerOffhandItem(player,null); + Backhand.INSTANCE.setPlayerOffhandItem(player,null); } } @@ -89,14 +90,14 @@ public void onLivingHurt(LivingHurtEvent event) { Class totemItem = Class.forName("ganymedes01.etfuturum.items.ItemTotemUndying"); EntityPlayer player = (EntityPlayer) event.entityLiving; - ItemStack offhandItem = BattlegearUtils.getOffhandItem(player); + ItemStack offhandItem = Backhand.INSTANCE.getOffhandItem(player); ItemStack mainhandItem = player.getCurrentEquippedItem(); if (offhandItem == null) { return; } if (totemItem.isInstance(offhandItem.getItem()) && (mainhandItem == null || !totemItem.isInstance(mainhandItem.getItem()))) { - BattlegearUtils.swapOffhandItem(player); + Backhand.INSTANCE.swapOffhandItem(player); regularHotSwap = true; MinecraftForge.EVENT_BUS.post(event); } @@ -106,11 +107,11 @@ public void onLivingHurt(LivingHurtEvent event) { @SubscribeEvent public void onItemUseStart(PlayerUseItemEvent.Start event) { EntityPlayer player = event.entityPlayer; - ItemStack offhandItem = BattlegearUtils.getOffhandItem(player); + ItemStack offhandItem = Backhand.INSTANCE.getOffhandItem(player); ItemStack mainhandItem = player.getCurrentEquippedItem(); //boolean offHandUse = BattlegearUtils.checkForRightClickFunction(offhandItem); - boolean mainhandUse = BattlegearUtils.checkForRightClickFunction(mainhandItem); + boolean mainhandUse = Backhand.INSTANCE.checkForRightClickFunction(mainhandItem); if (offhandItem != null && !mainhandUse) { event.setCanceled(true); @@ -119,12 +120,12 @@ public void onItemUseStart(PlayerUseItemEvent.Start event) { @SubscribeEvent public void onArrowNock(ArrowNockEvent event) { - if (!Backhand.UseOffhandArrows) { + if (!Backhand.INSTANCE.UseOffhandArrows) { return; } boolean overrideWithOffhand = false; - ItemStack offhandItem = BattlegearUtils.getOffhandItem(event.entityPlayer); + ItemStack offhandItem = Backhand.INSTANCE.getOffhandItem(event.entityPlayer); if (offhandItem != null) { try { Class etFuturumArrow = Class.forName("ganymedes01.etfuturum.items.ItemArrowTipped"); @@ -147,14 +148,14 @@ public void onArrowNock(ArrowNockEvent event) { @SubscribeEvent public void onItemFinish(PlayerUseItemEvent.Finish event) { EntityPlayer player = event.entityPlayer; - ItemStack offhandItem = BattlegearUtils.getOffhandItem(player); + ItemStack offhandItem = Backhand.INSTANCE.getOffhandItem(player); ItemStack mainhandItem = player.getCurrentEquippedItem(); - boolean mainhandUse = BattlegearUtils.checkForRightClickFunction(mainhandItem); + boolean mainhandUse = Backhand.INSTANCE.checkForRightClickFunction(mainhandItem); if (offhandItem == null || mainhandUse) { return; } if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER && !ServerTickHandler.tickStartItems.containsKey(player.getUniqueID())) { - BattlegearUtils.swapOffhandItem(player); + Backhand.INSTANCE.swapOffhandItem(player); regularHotSwap = true; } } @@ -163,22 +164,22 @@ public void onItemFinish(PlayerUseItemEvent.Finish event) { public void onItemStop(PlayerUseItemEvent.Stop event) { EntityPlayer player = event.entityPlayer; ItemStack mainhandItem = player.getCurrentEquippedItem(); - boolean mainhandUse = BattlegearUtils.checkForRightClickFunction(mainhandItem); - if (BattlegearUtils.getOffhandItem(player) == null || mainhandUse) { + boolean mainhandUse = Backhand.INSTANCE.checkForRightClickFunction(mainhandItem); + if (Backhand.INSTANCE.getOffhandItem(player) == null || mainhandUse) { return; } if (!ServerTickHandler.tickStartItems.containsKey(player.getUniqueID()) && !regularHotSwap) { - BattlegearUtils.swapOffhandItem(player); + Backhand.INSTANCE.swapOffhandItem(player); regularHotSwap = true; } - if (!Backhand.UseOffhandArrows || !(event.item.getItem() instanceof ItemBow)) { + if (!Backhand.INSTANCE.UseOffhandArrows || !(event.item.getItem() instanceof ItemBow)) { return; } boolean overrideWithOffhand = false; - ItemStack offhandItem = BattlegearUtils.getOffhandItem(event.entityPlayer); + ItemStack offhandItem = Backhand.INSTANCE.getOffhandItem(event.entityPlayer); if (offhandItem != null) { try { Class etFuturumArrow = Class.forName("ganymedes01.etfuturum.items.ItemArrowTipped"); @@ -194,7 +195,7 @@ public void onItemStop(PlayerUseItemEvent.Stop event) { if (overrideWithOffhand) { arrowHotSwapped = true; if (offhandItem.getItem() != Items.arrow) { - BattlegearUtils.swapOffhandItem(event.entityPlayer); + Backhand.INSTANCE.swapOffhandItem(event.entityPlayer); } } } @@ -207,11 +208,11 @@ public void onUpdateWorld(TickEvent.WorldTickEvent event) { return; } - if (Backhand.OffhandTickHotswap) { + if (Backhand.INSTANCE.OffhandTickHotswap) { List players = event.world.playerEntities; for (EntityPlayer player : players) { ItemStack mainhand = player.getCurrentEquippedItem() == null ? null : player.getCurrentEquippedItem().copy(); - ItemStack offhand = BattlegearUtils.getOffhandItem(player) == null ? null : BattlegearUtils.getOffhandItem(player).copy(); + ItemStack offhand = Backhand.INSTANCE.getOffhandItem(player) == null ? null : Backhand.INSTANCE.getOffhandItem(player).copy(); if (offhand == null) { continue; } @@ -219,7 +220,7 @@ public void onUpdateWorld(TickEvent.WorldTickEvent event) { if (event.phase == TickEvent.Phase.START && !player.isUsingItem()) { if (!BattlegearUtils.checkForRightClickFunction(mainhand)) { if (!tickStartItems.containsKey(player.getUniqueID())) { - Backhand.packetHandler.sendPacketToPlayer( + Backhand.INSTANCE.packetHandler.sendPacketToPlayer( new BackhandWorldHotswapPacket(true).generatePacket(), (EntityPlayerMP) player ); } @@ -236,9 +237,9 @@ public void onUpdateWorld(TickEvent.WorldTickEvent event) { public static void resetTickingHotswap(EntityPlayer player) { if (tickStartItems.containsKey(player.getUniqueID())) { player.setCurrentItemOrArmor(0, tickStartItems.get(player.getUniqueID()).get(0)); - BattlegearUtils.setPlayerOffhandItem(player, tickStartItems.get(player.getUniqueID()).get(1)); + Backhand.INSTANCE.setPlayerOffhandItem(player, tickStartItems.get(player.getUniqueID()).get(1)); tickStartItems.remove(player.getUniqueID()); - Backhand.packetHandler.sendPacketToPlayer( + BackhandHandler.packetHandler.sendPacketToPlayer( new BackhandWorldHotswapPacket(false).generatePacket(), (EntityPlayerMP) player ); } @@ -252,27 +253,27 @@ public void onUpdatePlayer(TickEvent.PlayerTickEvent event) EntityPlayer player = event.player; if (FMLCommonHandler.instance().getEffectiveSide() != Side.SERVER) { if (ServerEventsHandler.regularHotSwap) { - BattlegearUtils.swapOffhandItem(player); + Backhand.INSTANCE.swapOffhandItem(player); ServerEventsHandler.regularHotSwap = false; } return; } - ItemStack offhand = BattlegearUtils.getOffhandItem(player); + ItemStack offhand = Backhand.INSTANCE.getOffhandItem(player); if (event.phase == TickEvent.Phase.END) { if (blacklistDelay > 0) { blacklistDelay--; } - if (Backhand.isOffhandBlacklisted(offhand)) { + if (Backhand.INSTANCE.isOffhandBlacklisted(offhand)) { if (!ItemStack.areItemStacksEqual(offhand,prevStackInSlot)) { blacklistDelay = 10; } else if (blacklistDelay == 0) { - BattlegearUtils.setPlayerOffhandItem(player,null); + Backhand.INSTANCE.setPlayerOffhandItem(player,null); boolean foundSlot = false; for (int i = 0; i < player.inventory.getSizeInventory() - 4; i++) { - if (i == Backhand.AlternateOffhandSlot) + if (i == Backhand.INSTANCE.AlternateOffhandSlot) continue; if (player.inventory.getStackInSlot(i) == null) { player.inventory.setInventorySlotContents(i,offhand); @@ -289,32 +290,32 @@ public void onUpdatePlayer(TickEvent.PlayerTickEvent event) prevStackInSlot = offhand; } - if (BattlegearUtils.getOffhandEP(player).syncOffhand) { + if (Backhand.INSTANCE.getOffhandEP(player).syncOffhand) { if (!tickStartItems.containsKey(player.getUniqueID())) { - Backhand.packetHandler.sendPacketToAll(new BattlegearSyncItemPacket(player).generatePacket()); + BackhandHandler.packetHandler.sendPacketToAll(new BattlegearSyncItemPacket(player).generatePacket()); } - BattlegearUtils.getOffhandEP(player).syncOffhand = false; + Backhand.INSTANCE.getOffhandEP(player).syncOffhand = false; } if (arrowHotSwapped) { if (offhand != null && offhand.getItem() != Items.arrow) { - BattlegearUtils.swapOffhandItem(player); + Backhand.INSTANCE.swapOffhandItem(player); } arrowHotSwapped = false; } if (regularHotSwap) { - BattlegearUtils.swapOffhandItem(player); + Backhand.INSTANCE.swapOffhandItem(player); regularHotSwap = false; } if (fireworkHotSwapped > 0) { fireworkHotSwapped--; } else if (fireworkHotSwapped == 0) { - BattlegearUtils.swapOffhandItem(player); + Backhand.INSTANCE.swapOffhandItem(player); fireworkHotSwapped--; MinecraftForge.EVENT_BUS.post(new PlayerInteractEvent(player, PlayerInteractEvent.Action.RIGHT_CLICK_AIR, (int)player.posX, (int)player.posY, (int)player.posZ, -1, player.worldObj)); - BattlegearUtils.swapOffhandItem(player); + Backhand.INSTANCE.swapOffhandItem(player); } } } diff --git a/src/main/java/ganymedes01/etfuturum/backhand/client/gui/BackhandConfigGui.java b/src/main/java/ganymedes01/etfuturum/backhand/client/gui/BackhandConfigGui.java index 423cdf8f..f11759a5 100644 --- a/src/main/java/ganymedes01/etfuturum/backhand/client/gui/BackhandConfigGui.java +++ b/src/main/java/ganymedes01/etfuturum/backhand/client/gui/BackhandConfigGui.java @@ -19,7 +19,7 @@ public BackhandConfigGui(GuiScreen parent) { @Override public void initGui() { this.buttonList.add(new GuiButton(1, this.width / 2 - 75, this.height - 38, I18n.format("gui.done"))); - this.buttonList.add(new GuiToggleButton(10, this.width / 2 - 75, this.height / 2 - 12, I18n.format("backhandconfig.offhandRest") + ":" + Backhand.RenderEmptyOffhandAtRest, this.fontRendererObj)); + this.buttonList.add(new GuiToggleButton(10, this.width / 2 - 75, this.height / 2 - 12, I18n.format("backhandconfig.offhandRest") + ":" + Backhand.INSTANCE.RenderEmptyOffhandAtRest, this.fontRendererObj)); for (Object obj : this.buttonList) { ((GuiButton)obj).xPosition = this.width/2 - ((GuiButton)obj).getButtonWidth()/2; @@ -33,7 +33,7 @@ protected void actionPerformed(GuiButton button) { FMLClientHandler.instance().showGuiScreen(parent); } if (button.id == 10) { - Backhand.RenderEmptyOffhandAtRest = !Backhand.RenderEmptyOffhandAtRest; + Backhand.INSTANCE.RenderEmptyOffhandAtRest = !Backhand.INSTANCE.RenderEmptyOffhandAtRest; } if(button instanceof GuiToggleButton){ ((GuiToggleButton) button).toggleDisplayString(); diff --git a/src/main/java/ganymedes01/etfuturum/backhand/packets/BackhandAttackPacket.java b/src/main/java/ganymedes01/etfuturum/backhand/packets/BackhandAttackPacket.java index e6df6f4c..5773a4b9 100644 --- a/src/main/java/ganymedes01/etfuturum/backhand/packets/BackhandAttackPacket.java +++ b/src/main/java/ganymedes01/etfuturum/backhand/packets/BackhandAttackPacket.java @@ -37,7 +37,7 @@ public void write(ByteBuf out) { @Override public void process(ByteBuf inputStream, EntityPlayer sender) { - if (!ganymedes01.etfuturum.backhand.Backhand.OffhandAttack) { + if (!ganymedes01.etfuturum.Backhand.INSTANCE.Backhand.INSTANCE.OffhandAttack) { return; } diff --git a/src/main/java/ganymedes01/etfuturum/backhand/packets/BackhandConfigSyncPacket.java b/src/main/java/ganymedes01/etfuturum/backhand/packets/BackhandConfigSyncPacket.java index 1d624bee..263c1dcc 100644 --- a/src/main/java/ganymedes01/etfuturum/backhand/packets/BackhandConfigSyncPacket.java +++ b/src/main/java/ganymedes01/etfuturum/backhand/packets/BackhandConfigSyncPacket.java @@ -1,4 +1,3 @@ - package ganymedes01.etfuturum.backhand.packets; import ganymedes01.etfuturum.backhand.Backhand; @@ -20,14 +19,14 @@ public BackhandConfigSyncPacket() {} @Override public void process(ByteBuf inputStream, EntityPlayer player) { - Backhand.OffhandAttack = inputStream.readBoolean(); - Backhand.EmptyOffhand = inputStream.readBoolean(); - Backhand.OffhandBreakBlocks = inputStream.readBoolean(); - Backhand.UseOffhandArrows = inputStream.readBoolean(); - Backhand.UseOffhandBow = inputStream.readBoolean(); - Backhand.OffhandTickHotswap = inputStream.readBoolean(); - Backhand.AlternateOffhandSlot = inputStream.readInt(); - Backhand.UseInventorySlot = inputStream.readBoolean(); + Backhand.INSTANCE.OffhandAttack = inputStream.readBoolean(); + Backhand.INSTANCE.EmptyOffhand = inputStream.readBoolean(); + Backhand.INSTANCE.OffhandBreakBlocks = inputStream.readBoolean(); + Backhand.INSTANCE.UseOffhandArrows = inputStream.readBoolean(); + Backhand.INSTANCE.UseOffhandBow = inputStream.readBoolean(); + Backhand.INSTANCE.OffhandTickHotswap = inputStream.readBoolean(); + Backhand.INSTANCE.AlternateOffhandSlot = inputStream.readInt(); + Backhand.INSTANCE.UseInventorySlot = inputStream.readBoolean(); MysteriumPatchesFixesO.receivedConfigs = true; } @@ -38,13 +37,13 @@ public String getChannel() { @Override public void write(ByteBuf out) { - out.writeBoolean(Backhand.OffhandAttack); - out.writeBoolean(Backhand.EmptyOffhand); - out.writeBoolean(Backhand.OffhandBreakBlocks); - out.writeBoolean(Backhand.UseOffhandArrows); - out.writeBoolean(Backhand.UseOffhandBow); - out.writeBoolean(Backhand.OffhandTickHotswap); - out.writeInt(Backhand.AlternateOffhandSlot); - out.writeBoolean(Backhand.UseInventorySlot); + out.writeBoolean(Backhand.INSTANCE.OffhandAttack); + out.writeBoolean(Backhand.INSTANCE.EmptyOffhand); + out.writeBoolean(Backhand.INSTANCE.OffhandBreakBlocks); + out.writeBoolean(Backhand.INSTANCE.UseOffhandArrows); + out.writeBoolean(Backhand.INSTANCE.UseOffhandBow); + out.writeBoolean(Backhand.INSTANCE.OffhandTickHotswap); + out.writeInt(Backhand.INSTANCE.AlternateOffhandSlot); + out.writeBoolean(Backhand.INSTANCE.UseInventorySlot); } } diff --git a/src/main/java/ganymedes01/etfuturum/backhand/packets/BackhandPlaceBlockPacket.java b/src/main/java/ganymedes01/etfuturum/backhand/packets/BackhandPlaceBlockPacket.java index edfd0022..fa8c569a 100644 --- a/src/main/java/ganymedes01/etfuturum/backhand/packets/BackhandPlaceBlockPacket.java +++ b/src/main/java/ganymedes01/etfuturum/backhand/packets/BackhandPlaceBlockPacket.java @@ -4,6 +4,7 @@ import cpw.mods.fml.common.eventhandler.Event; import cpw.mods.fml.common.network.ByteBufUtils; import cpw.mods.fml.relauncher.Side; +import ganymedes01.etfuturum.backhand.Backhand; import io.netty.buffer.ByteBuf; import mods.battlegear2.BattlemodeHookContainerClass; import mods.battlegear2.api.PlayerEventChild; @@ -137,15 +138,15 @@ public void process(ByteBuf in, EntityPlayer player) { } ((EntityPlayerMP) player).playerNetServerHandler.sendPacket(new S23PacketBlockChange(i, j, k, player.getEntityWorld())); } - offhandWeapon = BattlegearUtils.getOffhandItem(player); + offhandWeapon = Backhand.INSTANCE.getOffhandItem(player); if (offhandWeapon != null && BattlemodeHookContainerClass.isItemBlock(offhandWeapon.getItem())) { if (offhandWeapon.stackSize <= 0) { - BattlegearUtils.setPlayerOffhandItem(player, null); + Backhand.INSTANCE.setPlayerOffhandItem(player, null); offhandWeapon = null; } if (offhandWeapon == null || offhandWeapon.getMaxItemUseDuration() == 0) { ((EntityPlayerMP) player).isChangingQuantityOnly = true; - BattlegearUtils.setPlayerOffhandItem(player, ItemStack.copyItemStack(BattlegearUtils.getOffhandItem(player))); + Backhand.INSTANCE.setPlayerOffhandItem(player, ItemStack.copyItemStack(Backhand.INSTANCE.getOffhandItem(player))); player.openContainer.detectAndSendChanges(); ((EntityPlayerMP) player).isChangingQuantityOnly = false; } @@ -161,9 +162,9 @@ public boolean useItem(EntityPlayerMP playerMP, ItemStack itemStack, int x, int if (itemStack.getItem().onItemUseFirst(itemStack, playerMP, theWorld, x, y, z, side, xOffset, yOffset, zOffset)) { if (itemStack.stackSize <= 0) { ForgeEventFactory.onPlayerDestroyItem(playerMP, itemStack); - BattlegearUtils.setPlayerOffhandItem(playerMP, null); + Backhand.INSTANCE.setPlayerOffhandItem(playerMP, null); } else if (itemStack.getItemDamage() != meta) { - BattlegearUtils.setPlayerOffhandItem(playerMP, BattlegearUtils.getOffhandItem(playerMP)); + Backhand.INSTANCE.setPlayerOffhandItem(playerMP, Backhand.INSTANCE.getOffhandItem(playerMP)); } return true; } @@ -182,9 +183,9 @@ public boolean useItem(EntityPlayerMP playerMP, ItemStack itemStack, int x, int } if (itemStack.stackSize <= 0) { ForgeEventFactory.onPlayerDestroyItem(playerMP, itemStack); - BattlegearUtils.setPlayerOffhandItem(playerMP, null); + Backhand.INSTANCE.setPlayerOffhandItem(playerMP, null); } else if (itemStack.getItemDamage() != meta) { - BattlegearUtils.setPlayerOffhandItem(playerMP, itemStack); + Backhand.INSTANCE.setPlayerOffhandItem(playerMP, itemStack); } } return result; diff --git a/src/main/java/ganymedes01/etfuturum/backhand/packets/BackhandSwapClientPacket.java b/src/main/java/ganymedes01/etfuturum/backhand/packets/BackhandSwapClientPacket.java index 21456f8b..c1111bfc 100644 --- a/src/main/java/ganymedes01/etfuturum/backhand/packets/BackhandSwapClientPacket.java +++ b/src/main/java/ganymedes01/etfuturum/backhand/packets/BackhandSwapClientPacket.java @@ -1,4 +1,3 @@ - package ganymedes01.etfuturum.backhand.packets; import cpw.mods.fml.common.network.ByteBufUtils; @@ -7,7 +6,7 @@ import mods.battlegear2.api.core.InventoryPlayerBattle; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -import xonin.backhand.client.ClientTickHandler; +import xonin.Backhand.INSTANCE.client.ClientTickHandler; /** * User: nerd-boy diff --git a/src/main/java/ganymedes01/etfuturum/backhand/packets/BackhandSwapPacket.java b/src/main/java/ganymedes01/etfuturum/backhand/packets/BackhandSwapPacket.java index 47ab2d3a..aa0a21e6 100644 --- a/src/main/java/ganymedes01/etfuturum/backhand/packets/BackhandSwapPacket.java +++ b/src/main/java/ganymedes01/etfuturum/backhand/packets/BackhandSwapPacket.java @@ -1,12 +1,13 @@ package ganymedes01.etfuturum.backhand.packets; import cpw.mods.fml.common.network.ByteBufUtils; +import ganymedes01.etfuturum.network.BackhandHandler; import io.netty.buffer.ByteBuf; import mods.battlegear2.api.core.BattlegearUtils; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; -import xonin.backhand.Backhand; +import xonin.Backhand.INSTANCE.Backhand; public class BackhandSwapPacket extends BackhandBasePacket { public static final String packetName = "ETF|Swap"; @@ -36,13 +37,13 @@ public void process(ByteBuf inputStream, EntityPlayer player) { this.user = ByteBufUtils.readUTF8String(inputStream); this.player = player.worldObj.getPlayerEntityByName(user); if (this.player != null) { - ItemStack offhandItem = BattlegearUtils.getOffhandItem(this.player); - if (ganymedes01.etfuturum.backhand.Backhand.isOffhandBlacklisted(player.getCurrentEquippedItem()) || Backhand.isOffhandBlacklisted(offhandItem)) + ItemStack offhandItem = ganymedes01.etfuturum.Backhand.INSTANCE.Backhand.INSTANCE.getOffhandItem(this.player); + if (ganymedes01.etfuturum.Backhand.INSTANCE.Backhand.INSTANCE.isOffhandBlacklisted(player.getCurrentEquippedItem()) || ganymedes01.etfuturum.Backhand.INSTANCE.Backhand.INSTANCE.isOffhandBlacklisted(offhandItem)) return; - BattlegearUtils.setPlayerOffhandItem(this.player,this.player.getCurrentEquippedItem()); - BattlegearUtils.setPlayerCurrentItem(this.player,offhandItem); - Backhand.packetHandler.sendPacketToPlayer(new BackhandSwapClientPacket(this.player).generatePacket(), (EntityPlayerMP) player); + ganymedes01.etfuturum.Backhand.INSTANCE.Backhand.INSTANCE.setPlayerOffhandItem(this.player,this.player.getCurrentEquippedItem()); + ganymedes01.etfuturum.Backhand.INSTANCE.Backhand.INSTANCE.setPlayerCurrentItem(this.player,offhandItem); + BackhandHandler.INSTANCE.sendPacketToPlayer(new BackhandSwapClientPacket(this.player).generatePacket(), (EntityPlayerMP) player); } } } diff --git a/src/main/java/ganymedes01/etfuturum/backhand/packets/BackhandToServerPacket.java b/src/main/java/ganymedes01/etfuturum/backhand/packets/BackhandToServerPacket.java index 1e95a1d1..15bbb45d 100644 --- a/src/main/java/ganymedes01/etfuturum/backhand/packets/BackhandToServerPacket.java +++ b/src/main/java/ganymedes01/etfuturum/backhand/packets/BackhandToServerPacket.java @@ -1,6 +1,7 @@ package ganymedes01.etfuturum.backhand.packets; import cpw.mods.fml.common.network.ByteBufUtils; +import ganymedes01.etfuturum.backhand.Backhand; import io.netty.buffer.ByteBuf; import mods.battlegear2.api.core.BattlegearUtils; import net.minecraft.entity.player.EntityPlayer; @@ -38,7 +39,7 @@ public void process(ByteBuf inputStream, EntityPlayer player) { this.player = player.worldObj.getPlayerEntityByName(user); if (this.player != null) { ItemStack offhandItem = ByteBufUtils.readItemStack(inputStream); - BattlegearUtils.setPlayerOffhandItem(this.player,offhandItem); + Backhand.INSTANCE.INSTANCE.setPlayerOffhandItem(this.player,offhandItem); } } } diff --git a/src/main/java/ganymedes01/etfuturum/configuration/configs/ConfigMixins.java b/src/main/java/ganymedes01/etfuturum/configuration/configs/ConfigMixins.java index b76b4d46..223c79a3 100644 --- a/src/main/java/ganymedes01/etfuturum/configuration/configs/ConfigMixins.java +++ b/src/main/java/ganymedes01/etfuturum/configuration/configs/ConfigMixins.java @@ -99,7 +99,7 @@ protected void syncConfigOptions() { "\nModified Classes: net.minecraft.entity.EntityLivingBase net.minecraft.entity.player.EntityPlayer net.minecraft.entity.EntityTrackerEntry net.minecraft.network.NetHandlerPlayServer" + "\nModified Client Classes: net.minecraft.client.entity.AbstractClientPlayer net.minecraft.client.entity.EntityPlayerSP net.minecraft.client.model.ModelBiped net.minecraft.client.renderer.entity.RenderPlayer" + "\nModified Mod Classes: thaumcraft.common.lib.events.EventHandlerEntity"); - enableOffhand = getBoolean("enableOffhand", catBackport, true, "A port of Backhand. The original author of this is https://github.com/c0508383." + + enableOffhand = getBoolean("enableOffhand", catBackport, true, "A port of Backhand.INSTANCE. The original author of this is https://github.com/c0508383." + "\nModified Classes: tba" + "\nModified Client Classes: tba" + "\nModified Mod Classes: tba");