From cf53cbd5d5fd335402d28f08fb8ab9e3d83bb9f3 Mon Sep 17 00:00:00 2001 From: kirillsaint Date: Sat, 13 Jan 2024 14:24:09 +0600 Subject: [PATCH] fix --- src/main/java/net/silentclient/client/Client.java | 2 +- .../mixin/mixins/PlayerControllerMPMixin.java | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/silentclient/client/Client.java b/src/main/java/net/silentclient/client/Client.java index 2cecb30..d40dbbe 100644 --- a/src/main/java/net/silentclient/client/Client.java +++ b/src/main/java/net/silentclient/client/Client.java @@ -59,7 +59,7 @@ import java.util.List; public class Client { public static final Logger logger = LogManager.getLogger("SC"); - private final String version = "2.0.0"; + private final String version = "2.0.1"; private static final Client INSTANCE = new Client(); public static final Client getInstance() { 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 86dd05f..8abbd44 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_);