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

Commit 67dfceb

Browse files
committed
Fix nitpicks with shearing code
1 parent 29abab7 commit 67dfceb

File tree

5 files changed

+23
-17
lines changed

5 files changed

+23
-17
lines changed

patchwork-dispatcher/src/main/java/com/patchworkmc/api/redirects/itemgroup/PatchworkItemGroup.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ private static int getNewArrayIndex() {
3737
return GROUPS.length - 1;
3838
}
3939

40-
/*// Note: uncomment this in dev
40+
// Note: uncomment this in dev
4141
public net.minecraft.item.ItemStack createIcon() {
4242
return method_7750();
4343
}
4444

4545
// TODO: Missing required classpath information in remapper!
46-
public abstract net.minecraft.item.ItemStack method_7750();*/
46+
public abstract net.minecraft.item.ItemStack method_7750();
4747
}

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.spongepowered.asm.mixin.Mixin;
2727
import org.spongepowered.asm.mixin.Shadow;
2828

29+
import net.minecraft.block.Block;
2930
import net.minecraft.entity.EntityType;
3031
import net.minecraft.entity.passive.CowEntity;
3132
import net.minecraft.entity.passive.MooshroomEntity;
@@ -52,7 +53,7 @@ public MixinMooshroomEntity(EntityType<? extends CowEntity> entityType, World wo
5253
}
5354

5455
@Override
55-
public boolean isShearable(ItemStack item, ViewableWorld world, net.minecraft.util.math.BlockPos pos) {
56+
public boolean isShearable(ItemStack item, ViewableWorld world, BlockPos pos) {
5657
return this.getBreedingAge() >= 0;
5758
}
5859

@@ -74,9 +75,11 @@ public List<ItemStack> onSheared(ItemStack item, IWorld world, BlockPos pos, int
7475
}
7576

7677
this.world.spawnEntity(cow);
78+
Block mushroom = this.getMooshroomType().getMushroomState().getBlock();
7779

78-
for (int i = 0; i < 5; ++i) { //Fixes forge bug where shearing brown mooshrooms always drop red mushrooms
79-
drops.add(new ItemStack(this.getMooshroomType().getMushroomState().getBlock()));
80+
// TODO: Fixes forge bug where shearing brown mooshrooms always drop red mushrooms (Fixed in 1.15)
81+
for (int i = 0; i < 5; ++i) {
82+
drops.add(new ItemStack(mushroom));
8083
}
8184

8285
this.playSound(SoundEvents.ENTITY_MOOSHROOM_SHEAR, 1.0F, 1.0F);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
import net.minecraft.block.VineBlock;
3232

3333
/**
34-
* Patches blocks to extend {@link IShearable}.
34+
* Patches blocks to implement {@link IShearable}.
3535
*
3636
* @author SuperCoder79
3737
*/

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import net.minecraft.util.DyeColor;
3939
import net.minecraft.util.Hand;
4040
import net.minecraft.util.math.BlockPos;
41+
import net.minecraft.world.IWorld;
4142
import net.minecraft.world.ViewableWorld;
4243
import net.minecraft.world.World;
4344

@@ -71,15 +72,17 @@ public boolean isShearable(ItemStack item, ViewableWorld world, BlockPos pos) {
7172
}
7273

7374
@Override
74-
public List<ItemStack> onSheared(ItemStack item, net.minecraft.world.IWorld world, BlockPos pos, int fortune) {
75+
public List<ItemStack> onSheared(ItemStack item, IWorld world, BlockPos pos, int fortune) {
7576
List<ItemStack> drops = new java.util.ArrayList<>();
7677

7778
if (!this.world.isClient) {
7879
this.setSheared(true);
80+
7981
int count = 1 + this.random.nextInt(3);
82+
ItemConvertible wool = DROPS.get(this.getColor());
8083

81-
for (int i = 0; i < count; ++i) {
82-
drops.add(new ItemStack(DROPS.get(this.getColor())));
84+
for (int i = 0; i < count; i++) {
85+
drops.add(new ItemStack(wool));
8386
}
8487
}
8588

patchwork-extensions-shearing/src/main/java/net/minecraftforge/common/IShearable.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,31 +31,31 @@
3131
* This allows for mods to create their own Shear-like items
3232
* and have them interact with entities without extra work.
3333
* Also, if your block/entity supports shears, this allows you
34-
* to support mod-shears as well.
34+
* to support modded shears as well.
3535
*/
3636
@Deprecated
3737
public interface IShearable {
3838
/**
3939
* Checks if the object is currently shearable.
40-
* Example: Sheep return false when they have no wool
40+
*
41+
* <p>Example: Sheep return false when they have no wool.</p>
4142
*
4243
* @param item The {@link ItemStack} that is being used, may be empty.
4344
* @param world The current world.
4445
* @param pos The current position in the world of the target block or entity.
45-
* @return If this block/entity is shearable, and if {@link #onSheared} should be called.
46+
* @return {@code true} if this block/entity is shearable, and if {@link #onSheared} should be called.
4647
*/
4748
default boolean isShearable(ItemStack item, ViewableWorld world, BlockPos pos) {
4849
return true;
4950
}
5051

5152
/**
5253
* Performs the shear function on this object.
53-
* This is called on both the client and the server.
54+
*
55+
* <p>This is called on both the client and the server.
5456
* The object should perform all actions related to being sheared,
5557
* except for dropping of the items, and removal of the block.
56-
* Those functions are handled by {@link net.minecraft.item.ShearsItem} itself.
57-
*
58-
* <p>Returns a list of items to be dropped as a result of the shearing process.</p>
58+
* Those functions are handled by {@link net.minecraft.item.ShearsItem} itself.</p>
5959
*
6060
* <p>For entities, they should trust their internal location information
6161
* over the values passed into this function.</p>
@@ -64,7 +64,7 @@ default boolean isShearable(ItemStack item, ViewableWorld world, BlockPos pos) {
6464
* @param world The current world.
6565
* @param pos If this is a block, the block's position in world.
6666
* @param fortune The fortune level of the shears being used.
67-
* @return A List containing all items from this shearing. May be empty.
67+
* @return a list of items to be dropped as a result of the shearing process.
6868
*/
6969
default List<ItemStack> onSheared(ItemStack item, IWorld world, BlockPos pos, int fortune) {
7070
return DefaultedList.of();

0 commit comments

Comments
 (0)