From 133c2a80fc1f19d116d199cab33aeb36f678f99b Mon Sep 17 00:00:00 2001 From: kirillsaint Date: Sat, 13 Jan 2024 14:25:10 +0600 Subject: [PATCH] Update PlayerControllerMPMixin.java --- .../mixin/mixins/PlayerControllerMPMixin.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/silentclient/client/mixin/mixins/PlayerControllerMPMixin.java b/src/main/java/net/silentclient/client/mixin/mixins/PlayerControllerMPMixin.java index e63c5b4..565ea8e 100644 --- a/src/main/java/net/silentclient/client/mixin/mixins/PlayerControllerMPMixin.java +++ b/src/main/java/net/silentclient/client/mixin/mixins/PlayerControllerMPMixin.java @@ -1,11 +1,15 @@ package net.silentclient.client.mixin.mixins; +import net.minecraft.block.*; +import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.PlayerControllerMP; import net.minecraft.client.network.NetHandlerPlayClient; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.network.Packet; +import net.minecraft.util.BlockPos; +import net.minecraft.util.MovingObjectPosition; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; @@ -16,7 +20,16 @@ public class PlayerControllerMPMixin { public void fixPacketSend(NetHandlerPlayClient instance, Packet p_147297_1_) { ItemStack itemstack = Minecraft.getMinecraft().thePlayer.inventory.getCurrentItem(); if(itemstack != null && (itemstack.getItem() == Items.diamond_sword || itemstack.getItem() == Items.stone_sword || itemstack.getItem() == Items.golden_sword || itemstack.getItem() == Items.iron_sword || itemstack.getItem() == Items.wooden_sword)) { - return; + if(Minecraft.getMinecraft().objectMouseOver != null && Minecraft.getMinecraft().objectMouseOver.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { + BlockPos pos = Minecraft.getMinecraft().objectMouseOver.getBlockPos(); + IBlockState state = Minecraft.getMinecraft().theWorld.getBlockState(pos); + Block block = state.getBlock(); + if(!(block instanceof BlockContainer || block instanceof BlockAnvil || block instanceof BlockWorkbench || block instanceof BlockBed || block instanceof BlockDoor || block instanceof BlockTrapDoor || block instanceof BlockButton || block instanceof BlockLever || block instanceof BlockRedstoneDiode)) { + return; + } + } else { + return; + } } instance.addToSendQueue(p_147297_1_);