Skip to content
This repository was archived by the owner on Jun 3, 2024. It is now read-only.

Commit e48fd8b

Browse files
committed
No longer use IShearable for fully vanilla ShearsItem interactions, removing 2 of the 3 Overwrites.
1 parent 2fab8b4 commit e48fd8b

4 files changed

Lines changed: 14 additions & 29 deletions

File tree

patchwork-extensions-shearing/src/main/java/com/patchworkmc/mixin/extensions/shearing/MixinMooshroomEntity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
import net.minecraft.world.World;
4040

4141
/**
42-
* Patches MooshroomEntity to allow shearing when the mooshroom is an adult, dropping mushrooms. This patch cancels the vanilla shearing code.
42+
* Patches {@link MooshroomEntity} to allow using {@link IShearable} for shearing the mooshroom when it is an adult, dropping mushrooms.
4343
*
4444
* @author SuperCoder79
4545
*/

patchwork-extensions-shearing/src/main/java/com/patchworkmc/mixin/extensions/shearing/MixinShearsItem.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@
2222
import net.minecraftforge.common.IShearable;
2323
import org.spongepowered.asm.mixin.Mixin;
2424

25+
import net.minecraft.entity.EntityType;
2526
import net.minecraft.entity.LivingEntity;
2627
import net.minecraft.entity.player.PlayerEntity;
2728
import net.minecraft.item.Item;
2829
import net.minecraft.item.ItemStack;
30+
import net.minecraft.item.Items;
2931
import net.minecraft.item.ShearsItem;
3032
import net.minecraft.util.Hand;
3133
import net.minecraft.util.math.BlockPos;
@@ -49,6 +51,15 @@ public boolean useOnEntity(ItemStack stack, PlayerEntity playerIn, LivingEntity
4951
return false;
5052
}
5153

54+
// Avoid duplicating vanilla interactions
55+
if (this == Items.SHEARS) {
56+
EntityType<?> type = entity.getType();
57+
58+
if (type == EntityType.MOOSHROOM || type == EntityType.SHEEP || type == EntityType.SNOW_GOLEM) {
59+
return false;
60+
}
61+
}
62+
5263
if (entity instanceof IShearable) {
5364
IShearable target = (IShearable) entity;
5465
BlockPos pos = entity.getBlockPos();

patchwork-extensions-shearing/src/main/java/com/patchworkmc/mixin/extensions/shearing/MixinSheepEntity.java

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,22 @@
2525
import net.minecraftforge.common.IShearable;
2626
import org.spongepowered.asm.mixin.Final;
2727
import org.spongepowered.asm.mixin.Mixin;
28-
import org.spongepowered.asm.mixin.Overwrite;
2928
import org.spongepowered.asm.mixin.Shadow;
3029

3130
import net.minecraft.entity.EntityType;
3231
import net.minecraft.entity.passive.AnimalEntity;
3332
import net.minecraft.entity.passive.SheepEntity;
34-
import net.minecraft.entity.player.PlayerEntity;
3533
import net.minecraft.item.ItemConvertible;
3634
import net.minecraft.item.ItemStack;
3735
import net.minecraft.sound.SoundEvents;
3836
import net.minecraft.util.DyeColor;
39-
import net.minecraft.util.Hand;
4037
import net.minecraft.util.math.BlockPos;
4138
import net.minecraft.world.IWorld;
4239
import net.minecraft.world.ViewableWorld;
4340
import net.minecraft.world.World;
4441

4542
/**
46-
* Patches {@link SheepEntity} to use {@link IShearable} for dropping wool. This patch cancels the vanilla shearing code.
43+
* Patches {@link SheepEntity} to allow using {@link IShearable} for dropping wool.
4744
*
4845
* @author SuperCoder79
4946
*/
@@ -89,14 +86,4 @@ public List<ItemStack> onSheared(ItemStack item, IWorld world, BlockPos pos, int
8986
this.playSound(SoundEvents.ENTITY_SHEEP_SHEAR, 1.0F, 1.0F);
9087
return drops;
9188
}
92-
93-
/**
94-
* @reason The original patch only required a cancellation at the HEAD, but @Overwrite was chosen to make
95-
* mod incompatibility easier to find.
96-
* @author SuperCoder79
97-
*/
98-
@Overwrite
99-
public boolean interactMob(PlayerEntity player, Hand hand) {
100-
return false;
101-
}
10289
}

patchwork-extensions-shearing/src/main/java/com/patchworkmc/mixin/extensions/shearing/MixinSnowGolemEntity.java

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,16 @@
2424

2525
import net.minecraftforge.common.IShearable;
2626
import org.spongepowered.asm.mixin.Mixin;
27-
import org.spongepowered.asm.mixin.Overwrite;
2827
import org.spongepowered.asm.mixin.Shadow;
2928

3029
import net.minecraft.entity.passive.SnowGolemEntity;
31-
import net.minecraft.entity.player.PlayerEntity;
3230
import net.minecraft.item.ItemStack;
33-
import net.minecraft.util.Hand;
3431
import net.minecraft.util.math.BlockPos;
3532
import net.minecraft.world.IWorld;
3633
import net.minecraft.world.ViewableWorld;
3734

3835
/**
39-
* Patches {@link SnowGolemEntity} to use {@link IShearable} for removing its pumpkin. The pumpkin will not be dropped as an item. This patch cancels the vanilla shearing code.
36+
* Patches {@link SnowGolemEntity} to allow using {@link IShearable} for removing its pumpkin. The pumpkin will not be dropped as an item.
4037
*
4138
* @author SuperCoder79
4239
*/
@@ -59,14 +56,4 @@ public List<ItemStack> onSheared(ItemStack item, IWorld world, BlockPos pos, int
5956

6057
return new ArrayList<>();
6158
}
62-
63-
/**
64-
* @reason The original patch only required a cancellation at the HEAD, but @Overwrite was chosen to make
65-
* mod incompatibility easier to find.
66-
* @author SuperCoder79
67-
*/
68-
@Overwrite
69-
public boolean interactMob(PlayerEntity player, Hand hand) {
70-
return false;
71-
}
7259
}

0 commit comments

Comments
 (0)