Update PlayerControllerMPMixin.java

This commit is contained in:
kirillsaint 2024-01-13 14:25:10 +06:00 committed by GitHub
parent adb5fa6b1c
commit 133c2a80fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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_);