From cec4ce32ca83e0ee67df87ea275591124065bf90 Mon Sep 17 00:00:00 2001 From: TCLProject <62664720+TCLProject@users.noreply.github.com> Date: Tue, 26 Oct 2021 20:57:19 +0000 Subject: [PATCH] Updated to 1.1.1b Attempted to fix the following: Item duplication bug; Current slot being offset incorrectly when dying; Opening doors; Impossibility to destroy certain blocks in survival; --- README.md | 1 + .../BattlemodeHookContainerClass.java | 35 +++++--- .../battlegear2/api/core/BattlegearUtils.java | 10 +-- .../api/core/InventoryPlayerBattle.java | 14 ---- .../client/BattlegearClientTickHandeler.java | 5 ++ .../client/utils/BattlegearRenderHelper.java | 2 +- .../misc/OffhandEventHandler.java | 82 +++++++++++++++---- .../java/proxy/client/TOMClientProxy.java | 5 ++ .../java/proxy/server/TOMServerProxy.java | 5 ++ 9 files changed, 111 insertions(+), 48 deletions(-) diff --git a/README.md b/README.md index 00d550f..ac56e6c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # The Offhand Mod The Offhand Mod is a minecraft mod continued from the [Mine&Blade Battlegear 2](https://github.com/Mine-and-blade-admin/Battlegear2) mod for Minecraft Forge 1.7.10 that aims to change it's dual wielding mechanics to add a permanently playable and usable offhand mechanic to the game. +Please do note, that this mod does not perfectly work with multiplayer. It was made with multiplayer in mind, but I most likely have missed something (please do report multiplayer bugs if found). ## Changes diff --git a/src/main/java/mods/battlegear2/BattlemodeHookContainerClass.java b/src/main/java/mods/battlegear2/BattlemodeHookContainerClass.java index b11f139..2357e6a 100644 --- a/src/main/java/mods/battlegear2/BattlemodeHookContainerClass.java +++ b/src/main/java/mods/battlegear2/BattlemodeHookContainerClass.java @@ -3,6 +3,9 @@ import java.util.ArrayList; import java.util.List; +import static cpw.mods.fml.common.eventhandler.Event.Result.DEFAULT; +import static cpw.mods.fml.common.eventhandler.Event.Result.DENY; + import cpw.mods.fml.common.eventhandler.Event; import cpw.mods.fml.common.eventhandler.EventPriority; import cpw.mods.fml.common.eventhandler.SubscribeEvent; @@ -35,7 +38,15 @@ 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.ItemBlock; +import net.minecraft.item.ItemBucket; +import net.minecraft.item.ItemDoor; +import net.minecraft.item.ItemRedstone; +import net.minecraft.item.ItemReed; +import net.minecraft.item.ItemSeedFood; +import net.minecraft.item.ItemSign; +import net.minecraft.item.ItemSkull; import net.minecraft.item.ItemStack; import net.minecraft.network.play.client.C07PacketPlayerDigging; import net.minecraft.util.MathHelper; @@ -53,11 +64,8 @@ import net.minecraftforge.event.entity.player.PlayerEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.tclproject.mysteriumlib.asm.fixes.MysteriumPatchesFixesO; -import net.tclproject.mysteriumlib.network.OFFMagicNetwork; import net.tclproject.theoffhandmod.TheOffhandMod; import net.tclproject.theoffhandmod.misc.OffhandEventHandler; -import net.tclproject.theoffhandmod.packets.InteractWithSyncServer; -import net.tclproject.theoffhandmod.packets.OverrideSyncServer; public final class BattlemodeHookContainerClass { @@ -146,9 +154,15 @@ public void playerInteract(PlayerInteractEvent event) { ItemStack mainHandItem = event.entityPlayer.getCurrentEquippedItem(); ItemStack offhandItem = ((InventoryPlayerBattle) event.entityPlayer.inventory).getCurrentOffhandWeapon(); if (!MysteriumPatchesFixesO.shouldNotOverride) { - event.setCanceled(true); + PlayerInteractEvent.Result blk = event.useBlock; + PlayerInteractEvent.Result itm = event.useItem; + event.useBlock = PlayerInteractEvent.Result.DENY; MovingObjectPosition mop = getRaytraceBlock(event.entityPlayer); + if (TheOffhandMod.proxy.isRightClickHeld() && !MysteriumPatchesFixesO.leftclicked) { + event.setCanceled(true); + } if (mop != null) { + event.setCanceled(true); int i = mop.blockX, j = mop.blockY, @@ -158,13 +172,10 @@ public void playerInteract(PlayerInteractEvent event) { float f1 = (float)mop.hitVec.yCoord - j; float f2 = (float)mop.hitVec.zCoord - k; - if (!event.entityPlayer.isSneaking() && (event.entityPlayer.worldObj.getBlock(i, j, k).onBlockActivated(event.entityPlayer.worldObj, i, j, k, event.entityPlayer, side, f, f1, f2))) { + if (!event.entityPlayer.isSneaking() && !BattlegearUtils.reverseactionconfirmed && OffhandEventHandler.canBlockBeInteractedWith(event.entityPlayer.worldObj, i, j, k)) { event.setCanceled(false); - if (event.entityPlayer.worldObj.getTileEntity(i, j, k) instanceof IInventory) { - IInventory te = ((IInventory)event.entityPlayer.worldObj.getTileEntity(i, j, k)); - te.openInventory(); - tobeclosed.add(te); - } + event.useBlock = blk; + event.useItem = itm; } } if (event.entityPlayer.worldObj.isRemote && !(BattlegearUtils.reverseactionconfirmed && BattlegearUtils.usagePriorAttack(offhandItem))) sendOffSwingEvent(event, mainHandItem, offhandItem); @@ -192,6 +203,10 @@ public void playerInteract(PlayerInteractEvent event) { // used in hostwapping the item to dig with, to remember where to return the main slot to public static int prevOffhandOffset; + public static boolean isItemBlock(Item item) { + return item instanceof ItemBlock || item instanceof ItemDoor || item instanceof ItemSign || item instanceof ItemReed || item instanceof ItemSeedFood || item instanceof ItemRedstone || item instanceof ItemBucket || item instanceof ItemSkull; + } + @SideOnly(Side.CLIENT) public static void tryBreakBlockOffhand(MovingObjectPosition objectMouseOver, ItemStack offhandItem, ItemStack mainHandItem, PlayerTickEvent event) { Minecraft mcInstance = Minecraft.getMinecraft(); diff --git a/src/main/java/mods/battlegear2/api/core/BattlegearUtils.java b/src/main/java/mods/battlegear2/api/core/BattlegearUtils.java index 1dc4f60..75025a2 100644 --- a/src/main/java/mods/battlegear2/api/core/BattlegearUtils.java +++ b/src/main/java/mods/battlegear2/api/core/BattlegearUtils.java @@ -6,15 +6,14 @@ import com.google.common.io.ByteArrayDataInput; import com.google.common.io.ByteArrayDataOutput; -import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.eventhandler.EventBus; +import mods.battlegear2.BattlemodeHookContainerClass; import mods.battlegear2.api.IAllowItem; import mods.battlegear2.api.IOffhandDual; import mods.battlegear2.api.IUsableItem; import mods.battlegear2.api.shield.IShield; import mods.battlegear2.api.weapons.IBattlegearWeapon; import mods.battlegear2.api.weapons.WeaponRegistry; -import net.minecraft.client.Minecraft; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; @@ -28,10 +27,8 @@ import net.minecraft.item.Item; import net.minecraft.item.Item.ToolMaterial; import net.minecraft.item.ItemBed; -import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemBook; import net.minecraft.item.ItemBow; -import net.minecraft.item.ItemBucket; import net.minecraft.item.ItemEnderPearl; import net.minecraft.item.ItemHangingEntity; import net.minecraft.item.ItemHoe; @@ -52,9 +49,6 @@ import net.minecraftforge.event.ForgeEventFactory; import net.minecraftforge.event.entity.player.AttackEntityEvent; import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent; -import net.tclproject.mysteriumlib.network.OFFMagicNetwork; -import net.tclproject.theoffhandmod.packets.OverrideSyncServer; -import proxy.client.TOMClientProxy; /** * Store commonly used method, mostly for the {@link EntityPlayer} {@link ItemStack}s management @@ -229,7 +223,7 @@ else if(itemStack.getItemUseAction()==EnumAction.drink || itemStack.getItemUseAc * @return true if it is commonly usable */ public static boolean isCommonlyUsable(Item item){ - return isBow(item) || item.getClass().toString().equalsIgnoreCase("class D.f") || item instanceof ItemBed || item instanceof ItemHangingEntity || item instanceof ItemBook || item instanceof ItemBlock || item instanceof ItemHoe || item instanceof ItemBucket || item instanceof ItemSnowball || item instanceof ItemEnderPearl; + return isBow(item) || item.getClass().toString().equalsIgnoreCase("class D.f") || item instanceof ItemBed || item instanceof ItemHangingEntity || item instanceof ItemBook || BattlemodeHookContainerClass.isItemBlock(item) || item instanceof ItemHoe || item instanceof ItemSnowball || item instanceof ItemEnderPearl; } // item instanceof ItemCrossbow || item instanceof ItemMounter || item instanceof ItemTeleporter || item instanceof ItemElementalStaff || item instanceof ItemGun || item instanceof ItemNpcMovingPath || item instanceof ItemMachineGun || item instanceof ItemMusket || item instanceof ItemNpcCloner || item instanceof ItemNpcScripter || item instanceof SpellBase || item instanceof ItemNpcWand || item instanceof ItemShield || item instanceof ItemSlingshot || item instanceof ItemSoulstoneFilled || item instanceof ItemSoulstoneEmpty || item instanceof ItemStaff || item instanceof ItemThrowingWeapon || item instanceof ItemThrowingShuriken diff --git a/src/main/java/mods/battlegear2/api/core/InventoryPlayerBattle.java b/src/main/java/mods/battlegear2/api/core/InventoryPlayerBattle.java index ddd6dc3..307f651 100644 --- a/src/main/java/mods/battlegear2/api/core/InventoryPlayerBattle.java +++ b/src/main/java/mods/battlegear2/api/core/InventoryPlayerBattle.java @@ -445,20 +445,6 @@ public int getSizeInventory() { return this.mainInventory.length + this.armorInventory.length; } - /** - * Drop all slots content, and clear them - */ - @Override - public void dropAllItems() { - super.dropAllItems(); - for (int i = 0; i < this.extraItems.length; ++i) { - if (this.extraItems[i] != null) { - this.player.func_146097_a(this.extraItems[i], true, false); - this.extraItems[i] = null; - } - } - } - /** * UNUSED in vanilla for players, but let's pretend * Mark the inventory content as dirty to be send to the client diff --git a/src/main/java/mods/battlegear2/client/BattlegearClientTickHandeler.java b/src/main/java/mods/battlegear2/client/BattlegearClientTickHandeler.java index a8f13d9..f7f4719 100644 --- a/src/main/java/mods/battlegear2/client/BattlegearClientTickHandeler.java +++ b/src/main/java/mods/battlegear2/client/BattlegearClientTickHandeler.java @@ -40,6 +40,7 @@ import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.tclproject.mysteriumlib.asm.fixes.MysteriumPatchesFixesO; import net.tclproject.theoffhandmod.TheOffhandMod; +import net.tclproject.theoffhandmod.misc.OffhandEventHandler; public final class BattlegearClientTickHandeler { public static final int FLASH_MAX = 30; @@ -175,6 +176,10 @@ public void tickStart(EntityPlayer player) { @SideOnly(Side.CLIENT) public void tryCheckUseItem(ItemStack offhand, EntityPlayer player){ + MovingObjectPosition mop = BattlemodeHookContainerClass.getRaytraceBlock(player); + if (mop != null && OffhandEventHandler.canBlockBeInteractedWith(player.worldObj, mop.blockX, mop.blockY, mop.blockZ) && BattlegearUtils.reverseactionconfirmed) { + return; + } if(BattlegearUtils.usagePriorAttack(offhand) && !MysteriumPatchesFixesO.shouldNotOverride){ MovingObjectPosition mouseOver = mc.objectMouseOver; boolean flag = true; diff --git a/src/main/java/mods/battlegear2/client/utils/BattlegearRenderHelper.java b/src/main/java/mods/battlegear2/client/utils/BattlegearRenderHelper.java index 1931986..8d5af3e 100644 --- a/src/main/java/mods/battlegear2/client/utils/BattlegearRenderHelper.java +++ b/src/main/java/mods/battlegear2/client/utils/BattlegearRenderHelper.java @@ -311,7 +311,7 @@ public static void renderItemInFirstPerson(float frame, Minecraft mc, ItemRender } if(!BattlegearUtils.RENDER_BUS.post(new PreRenderPlayerElement(preRender, true, PlayerElementType.ItemOffhand, itemToRender))){ - if (!Minecraft.getMinecraft().gameSettings.keyBindAttack.getIsKeyPressed() && Minecraft.getMinecraft().gameSettings.keyBindUseItem.getIsKeyPressed() && ItemStack.areItemStacksEqual(((InventoryPlayerBattle)player.inventory).getCurrentOffhandWeapon(), Minecraft.getMinecraft().playerController.currentItemHittingBlock)) { + if (!Minecraft.getMinecraft().gameSettings.keyBindAttack.getIsKeyPressed() && Minecraft.getMinecraft().gameSettings.keyBindUseItem.getIsKeyPressed() && ItemStack.areItemStacksEqual(((InventoryPlayerBattle)player.inventory).getCurrentOffhandWeapon(), Minecraft.getMinecraft().playerController.currentItemHittingBlock) && Minecraft.getMinecraft().playerController.isHittingBlock) { GL11.glTranslatef(0F, 0.5F, 0F); if (ItemStack.areItemStacksEqual(((InventoryPlayerBattle)player.inventory).getCurrentOffhandWeapon(), ((InventoryPlayerBattle)player.inventory).getStackInSlot(((InventoryPlayerBattle)player.inventory).currentItem))) { GL11.glTranslatef(0.6F, -0.4F, 0.3F); diff --git a/src/main/java/net/tclproject/theoffhandmod/misc/OffhandEventHandler.java b/src/main/java/net/tclproject/theoffhandmod/misc/OffhandEventHandler.java index a52ea0c..b3cc396 100644 --- a/src/main/java/net/tclproject/theoffhandmod/misc/OffhandEventHandler.java +++ b/src/main/java/net/tclproject/theoffhandmod/misc/OffhandEventHandler.java @@ -12,6 +12,7 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import mods.battlegear2.BattlemodeHookContainerClass; +import mods.battlegear2.api.core.BattlegearTranslator; import mods.battlegear2.api.core.BattlegearUtils; import mods.battlegear2.api.core.IBattlePlayer; import mods.battlegear2.api.core.InventoryPlayerBattle; @@ -24,13 +25,19 @@ import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.settings.KeyBinding; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.init.Items; import net.minecraft.inventory.IInventory; import net.minecraft.item.EnumAction; +import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; +import net.minecraft.item.ItemSword; +import net.minecraft.item.ItemTool; +import net.minecraft.util.ChatComponentText; import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; import net.minecraftforge.client.event.MouseEvent; import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType; @@ -90,9 +97,9 @@ public void onClick(MouseEvent event) boolean shouldUndo = false; int leftclick = reversedAttack() ? 1 : 0; int rightclick = reversedUse() ? 0 : 1; - if(event.button == leftclick && event.buttonstate && !BattlegearUtils.reverseactionconfirmed && Minecraft.getMinecraft().thePlayer.inventory.getCurrentItem() != null && Minecraft.getMinecraft().thePlayer.inventory.getCurrentItem().getItem() instanceof ItemBlock) { + if(event.button == leftclick && event.buttonstate && !BattlegearUtils.reverseactionconfirmed && Minecraft.getMinecraft().thePlayer.inventory.getCurrentItem() != null && BattlemodeHookContainerClass.isItemBlock(Minecraft.getMinecraft().thePlayer.inventory.getCurrentItem().getItem())) { MovingObjectPosition mop = BattlemodeHookContainerClass.getRaytraceBlock(Minecraft.getMinecraft().thePlayer); - if (mop != null) { + if (mop != null && !canBlockBeInteractedWith(Minecraft.getMinecraft().theWorld, mop.blockX, mop.blockY, mop.blockZ)) { cancelone=true; boolean reversedIt = false; if (!MysteriumPatchesFixesO.shouldNotOverride) reversedIt = true; @@ -159,7 +166,7 @@ public void onUpdatePlayer(TickEvent.PlayerTickEvent event) ItemStack mainHandItem = event.player.getCurrentEquippedItem(); ItemStack offhandItem = ((InventoryPlayerBattle) event.player.inventory).getCurrentOffhandWeapon(); MovingObjectPosition mop = BattlemodeHookContainerClass.getRaytraceBlock(event.player); - if (offhandItem != null && offhandItem.getItem() instanceof ItemBlock) { + if (offhandItem != null && BattlemodeHookContainerClass.isItemBlock(offhandItem.getItem())) { if (!BattlegearUtils.usagePriorAttack(offhandItem) && mop != null) { BattlemodeHookContainerClass.tryBreakBlockOffhand(mop, offhandItem, mainHandItem, event); TheOffhandMod.proxy.setLeftClickCounter(10); @@ -167,17 +174,14 @@ public void onUpdatePlayer(TickEvent.PlayerTickEvent event) Minecraft.getMinecraft().playerController.resetBlockRemoving(); } } else { - System.out.println(mop); - System.out.println(Minecraft.getMinecraft()); - System.out.println(Minecraft.getMinecraft().playerController); - if (mop != null && (!Minecraft.getMinecraft().playerController.onPlayerRightClick(Minecraft.getMinecraft().thePlayer, Minecraft.getMinecraft().theWorld, offhandItem, mop.blockX, mop.blockY, mop.blockZ, mop.sideHit, mop.hitVec) || BattlegearUtils.reverseactionconfirmed)) { + if (mop != null && (!BattlegearUtils.usagePriorAttack(offhandItem) || BattlegearUtils.reverseactionconfirmed) && (!canBlockBeInteractedWith(Minecraft.getMinecraft().theWorld, mop.blockX, mop.blockY, mop.blockZ) || BattlegearUtils.reverseactionconfirmed)) { BattlemodeHookContainerClass.tryBreakBlockOffhand(mop, offhandItem, mainHandItem, event); TheOffhandMod.proxy.setLeftClickCounter(10); } else { Minecraft.getMinecraft().playerController.resetBlockRemoving(); } } - } else { + } else if (!TheOffhandMod.proxy.isLeftClickHeld()) { Minecraft.getMinecraft().playerController.resetBlockRemoving(); } } @@ -207,6 +211,47 @@ public void onUpdatePlayer(TickEvent.PlayerTickEvent event) } } } + + private static String[] activatedBlockMethodNames = { + BattlegearTranslator.getMapedMethodName("Block", "func_149727_a", "onBlockActivated"), + BattlegearTranslator.getMapedMethodName("Block", "func_149699_a", "onBlockClicked")}; + private static Class[][] activatedBlockMethodParams = { + new Class[]{World.class, int.class, int.class, int.class, EntityPlayer.class, int.class, float.class, float.class, float.class}, + new Class[]{World.class, int.class, int.class, int.class, EntityPlayer.class}}; + + @SuppressWarnings("unchecked") + public static boolean canBlockBeInteractedWith(World worldObj, int x, int y, int z) { + if (worldObj == null) return false; + Block block = worldObj.getBlock(x, y, z); + if (block == null) return false; + if (block.getClass().equals(Block.class)) return false; + try { + Class c = block.getClass(); + while (!(c.equals(Block.class))) { + try { + try { + c.getDeclaredMethod(activatedBlockMethodNames[0], activatedBlockMethodParams[0]); + return true; + } catch (NoSuchMethodException ignored) { + } + + try { + c.getDeclaredMethod(activatedBlockMethodNames[1], activatedBlockMethodParams[1]); + return true; + } catch (NoSuchMethodException ignored) { + } + } catch (NoClassDefFoundError ignored) { + + } + + c = c.getSuperclass(); + } + + return false; + } catch (NullPointerException e) { + return true; + } + } private void onFirstTick(EntityPlayer p) { @@ -215,8 +260,12 @@ private void onFirstTick(EntityPlayer p) { @SubscribeEvent public void onClonePlayer(Clone event) { ((InventoryPlayerBattle)event.entityPlayer.inventory).clearInventory(null, -1); + event.entityPlayer.inventory.markDirty(); event.entityPlayer.inventoryContainer.detectAndSendChanges(); + ((InventoryPlayerBattle)event.entityPlayer.inventory).currentItem = 150; TheOffhandMod.packetHandler.sendPacketToServer(new BattlegearSyncItemPacket(event.entityPlayer).generatePacket()); + TheOffhandMod.packetHandler.sendPacketToPlayer(new BattlegearSyncItemPacket(event.entityPlayer).generatePacket(), (EntityPlayerMP)event.entityPlayer); + Minecraft.getMinecraft().playerController.syncCurrentPlayItem(); } @SideOnly(Side.CLIENT) @@ -347,13 +396,16 @@ public void renderHotbarOverlay(RenderGameOverlayEvent event) Minecraft mc = Minecraft.getMinecraft(); if (Minecraft.getMinecraft().rightClickDelayTimer == 0 && Minecraft.getMinecraft().gameSettings.keyBindAttack.getIsKeyPressed() && !BattlegearUtils.reverseactionconfirmed && Minecraft.getMinecraft().thePlayer.inventory.getCurrentItem() != null && Minecraft.getMinecraft().thePlayer.inventory.getCurrentItem().getItem() instanceof ItemBlock) { // places blocks continuously if left click is held with block in hand - boolean reversedIt = false; - if (!MysteriumPatchesFixesO.shouldNotOverride) reversedIt = true; - MysteriumPatchesFixesO.shouldNotOverride = true; - OFFMagicNetwork.dispatcher.sendToServer(new OverrideSyncServer(Minecraft.getMinecraft().thePlayer)); - mc.func_147121_ag(); - if (reversedIt) MysteriumPatchesFixesO.shouldNotOverride = false; - OFFMagicNetwork.dispatcher.sendToServer(new OverrideSyncServer(Minecraft.getMinecraft().thePlayer)); + MovingObjectPosition mop = BattlemodeHookContainerClass.getRaytraceBlock(Minecraft.getMinecraft().thePlayer); + if (mop != null && !canBlockBeInteractedWith(Minecraft.getMinecraft().theWorld, mop.blockX, mop.blockY, mop.blockZ)) { + boolean reversedIt = false; + if (!MysteriumPatchesFixesO.shouldNotOverride) reversedIt = true; + MysteriumPatchesFixesO.shouldNotOverride = true; + OFFMagicNetwork.dispatcher.sendToServer(new OverrideSyncServer(Minecraft.getMinecraft().thePlayer)); + mc.func_147121_ag(); + if (reversedIt) MysteriumPatchesFixesO.shouldNotOverride = false; + OFFMagicNetwork.dispatcher.sendToServer(new OverrideSyncServer(Minecraft.getMinecraft().thePlayer)); + } } if (!((IBattlePlayer) mc.thePlayer).isBattlemode()) { diff --git a/src/main/java/proxy/client/TOMClientProxy.java b/src/main/java/proxy/client/TOMClientProxy.java index 5c4d852..9ef6122 100644 --- a/src/main/java/proxy/client/TOMClientProxy.java +++ b/src/main/java/proxy/client/TOMClientProxy.java @@ -267,6 +267,11 @@ public boolean isRightClickHeld() { return Minecraft.getMinecraft().gameSettings.keyBindUseItem.getIsKeyPressed(); } + @Override + public boolean isLeftClickHeld() { + return Minecraft.getMinecraft().gameSettings.keyBindAttack.getIsKeyPressed(); + } + @Override public int getLeftClickCounter() { return Minecraft.getMinecraft().leftClickCounter; diff --git a/src/main/java/proxy/server/TOMServerProxy.java b/src/main/java/proxy/server/TOMServerProxy.java index d88f724..22ed7e6 100644 --- a/src/main/java/proxy/server/TOMServerProxy.java +++ b/src/main/java/proxy/server/TOMServerProxy.java @@ -112,4 +112,9 @@ public int getLeftClickCounter() { // Should not be called on the server anyway public void setLeftClickCounter(int i) { } + + // Should not be called on the server anyway + public boolean isLeftClickHeld() { + return false; + } }