Skip to content

Commit

Permalink
Documentation cleanup and removal of a FQN
Browse files Browse the repository at this point in the history
  • Loading branch information
pupnewfster committed Jan 26, 2024
1 parent 7a7c510 commit 049ca55
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
17 changes: 13 additions & 4 deletions patches/net/minecraft/world/entity/Shearable.java.patch
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
--- a/net/minecraft/world/entity/Shearable.java
+++ b/net/minecraft/world/entity/Shearable.java
@@ -2,8 +_,11 @@
@@ -2,8 +_,20 @@

import net.minecraft.sounds.SoundSource;

-public interface Shearable {
+@Deprecated // Forge: Use IShearable
+/**
+ * @deprecated Neo: Use {@link net.neoforged.neoforge.common.IShearable} instead.
+ */
+@Deprecated
+public interface Shearable extends net.neoforged.neoforge.common.IShearable {
+ @Deprecated // Forge: Use IShearable
+ /**
+ * @deprecated Neo: Use {@link net.neoforged.neoforge.common.IShearable#onSheared(net.minecraft.world.entity.player.Player, net.minecraft.world.item.ItemStack, net.minecraft.world.level.Level, net.minecraft.core.BlockPos, int)} instead.
+ */
+ @Deprecated
void shear(SoundSource p_21749_);

+ @Deprecated // Forge: Use IShearable
+ /**
+ * @deprecated Neo: Use {@link net.neoforged.neoforge.common.IShearable#isShearable(net.minecraft.world.item.ItemStack, net.minecraft.world.level.Level, net.minecraft.core.BlockPos)} instead.
+ */
+ @Deprecated
boolean readyForShearing();
}
4 changes: 2 additions & 2 deletions patches/net/minecraft/world/item/ShearsItem.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
+ if (entity.level().isClientSide) return InteractionResult.CONSUME;
+ BlockPos pos = entity.blockPosition();
+ if (target.isShearable(stack, entity.level(), pos)) {
+ java.util.List<ItemStack> drops = target.onSheared(player, stack, entity.level(), pos, stack.getEnchantmentLevel(net.minecraft.world.item.enchantment.Enchantments.BLOCK_FORTUNE));
+ target.onSheared(player, stack, entity.level(), pos, stack.getEnchantmentLevel(net.minecraft.world.item.enchantment.Enchantments.BLOCK_FORTUNE))
+ .forEach(drop -> target.spawnShearedDrop(entity.level(), pos, drop));
+ entity.gameEvent(GameEvent.SHEAR, player);
+ drops.forEach(drop -> target.spawnShearedDrop(entity.level(), pos, drop));
+ stack.hurtAndBreak(1, player, e -> e.broadcastBreakEvent(hand));
+ }
+ return InteractionResult.SUCCESS;
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/net/neoforged/neoforge/common/IShearable.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ default boolean isShearable(ItemStack item, Level level, BlockPos pos) {
* except for dropping of the items, and removal of the block.
* As those are handled by ItemShears itself.
* <p>
* For entities, they should trust there internal location information
* over the values passed into this function.
* For entities, they should trust their internal location information over the values passed into this function.
*
* @param item The ItemStack that is being used, may be empty.
* @param level The current level.
Expand All @@ -74,7 +73,7 @@ default List<ItemStack> onSheared(@Nullable Player player, ItemStack item, Level
/**
* Performs the logic used to drop a shear result into the world at the correct position and with the proper movement.
* <br>
* For entities, they should trust there internal location information over the values passed into this function.
* For entities, they should trust their internal location information over the values passed into this function.
*
* @param level The current level.
* @param pos If this is a block, the block's position in level.
Expand All @@ -84,7 +83,7 @@ default void spawnShearedDrop(Level level, BlockPos pos, ItemStack drop) {
if (this instanceof SnowGolem golem) {
golem.spawnAtLocation(drop, 1.7F);
} else if (this instanceof MushroomCow cow) {
//Note: Vanilla uses addFreshEntity instead of spawnAtLocation for spawning mooshrooms drops
// Note: Vanilla uses addFreshEntity instead of spawnAtLocation for spawning mooshrooms drops
// In case a mod is capturing drops for the entity we instead do it the same way we patch in MushroomCow#shear
ItemEntity itemEntity = cow.spawnAtLocation(drop, cow.getBbHeight());
if (itemEntity != null) itemEntity.setNoPickUpDelay();
Expand Down

0 comments on commit 049ca55

Please sign in to comment.