Fix shears passing on a client when interacting with a shearable entity (#8597)

Caused the offhand item to also interact with the entity, possibly sending a packet to the server causing both hands to interact
This commit is contained in:
KnightMiner authored and GitHub committed 2022-05-02 10:46:58 -07:00
1 parent c531b2b5c7
commit c34094ea50
1 file changed
+3 -4
@@ -1,14 +1,13 @@
--- a/net/minecraft/world/item/ShearsItem.java
+++ b/net/minecraft/world/item/ShearsItem.java
@@ -48,6 +_,32 @@
@@ -48,6 +_,31 @@
}
}
+ @Override
+ public net.minecraft.world.InteractionResult m_6880_(ItemStack stack, net.minecraft.world.entity.player.Player playerIn, LivingEntity entity, net.minecraft.world.InteractionHand hand) {
+ if (entity.f_19853_.f_46443_) return net.minecraft.world.InteractionResult.PASS;
+ if (entity instanceof net.minecraftforge.common.IForgeShearable) {
+ net.minecraftforge.common.IForgeShearable target = (net.minecraftforge.common.IForgeShearable)entity;
+ if (entity instanceof net.minecraftforge.common.IForgeShearable target) {
+ if (entity.f_19853_.f_46443_) return net.minecraft.world.InteractionResult.SUCCESS;
+ BlockPos pos = new BlockPos(entity.m_20185_(), entity.m_20186_(), entity.m_20189_());
+ if (target.isShearable(stack, entity.f_19853_, pos)) {
+ java.util.List<ItemStack> drops = target.onSheared(playerIn, stack, entity.f_19853_, pos,