aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-spigotflower/net/minecraft/world/item/ItemStack.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/world/item/ItemStack.java.patch')
-rw-r--r--patch-remap/mache-spigotflower/net/minecraft/world/item/ItemStack.java.patch1314
1 files changed, 1314 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/world/item/ItemStack.java.patch b/patch-remap/mache-spigotflower/net/minecraft/world/item/ItemStack.java.patch
new file mode 100644
index 0000000000..d4e2ce6fd3
--- /dev/null
+++ b/patch-remap/mache-spigotflower/net/minecraft/world/item/ItemStack.java.patch
@@ -0,0 +1,1314 @@
+--- a/net/minecraft/world/item/ItemStack.java
++++ b/net/minecraft/world/item/ItemStack.java
+@@ -28,6 +28,7 @@
+ import net.minecraft.advancements.CriteriaTriggers;
+ import net.minecraft.commands.arguments.blocks.BlockStateParser;
+ import net.minecraft.core.BlockPos;
++import net.minecraft.core.Direction;
+ import net.minecraft.core.Holder;
+ import net.minecraft.core.HolderSet;
+ import net.minecraft.core.Registry;
+@@ -35,6 +36,7 @@
+ import net.minecraft.core.registries.Registries;
+ import net.minecraft.nbt.CompoundTag;
+ import net.minecraft.nbt.ListTag;
++import net.minecraft.nbt.NbtOps;
+ import net.minecraft.nbt.Tag;
+ import net.minecraft.nbt.TagParser;
+ import net.minecraft.network.chat.CommonComponents;
+@@ -43,27 +45,24 @@
+ import net.minecraft.network.chat.HoverEvent;
+ import net.minecraft.network.chat.MutableComponent;
+ import net.minecraft.network.chat.Style;
++import net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket;
+ import net.minecraft.resources.ResourceLocation;
+-import net.minecraft.server.level.ServerPlayer;
+-import net.minecraft.sounds.SoundEvent;
+-import net.minecraft.stats.Stats;
+ import net.minecraft.tags.TagKey;
+ import net.minecraft.util.ExtraCodecs;
+ import net.minecraft.util.RandomSource;
+-import net.minecraft.world.InteractionHand;
++import net.minecraft.world.EnumHand;
+ import net.minecraft.world.InteractionResult;
+ import net.minecraft.world.InteractionResultHolder;
+ import net.minecraft.world.entity.Entity;
++import net.minecraft.world.entity.EnumMonsterType;
+ import net.minecraft.world.entity.EquipmentSlot;
+ import net.minecraft.world.entity.LivingEntity;
+-import net.minecraft.world.entity.MobType;
+ import net.minecraft.world.entity.SlotAccess;
+ import net.minecraft.world.entity.ai.attributes.Attribute;
+ import net.minecraft.world.entity.ai.attributes.AttributeModifier;
+ import net.minecraft.world.entity.ai.attributes.Attributes;
+ import net.minecraft.world.entity.decoration.ItemFrame;
+ import net.minecraft.world.entity.item.ItemEntity;
+-import net.minecraft.world.entity.player.Player;
+ import net.minecraft.world.flag.FeatureFlagSet;
+ import net.minecraft.world.inventory.ClickAction;
+ import net.minecraft.world.inventory.Slot;
+@@ -74,13 +73,50 @@
+ import net.minecraft.world.item.enchantment.Enchantment;
+ import net.minecraft.world.item.enchantment.EnchantmentHelper;
+ import net.minecraft.world.item.enchantment.Enchantments;
+-import net.minecraft.world.level.ItemLike;
++import net.minecraft.world.level.IMaterial;
+ import net.minecraft.world.level.Level;
++import net.minecraft.world.level.block.BaseEntityBlock;
++import net.minecraft.world.level.block.BedBlock;
+ import net.minecraft.world.level.block.Block;
+-import net.minecraft.world.level.block.state.BlockState;
++import net.minecraft.world.level.block.state.IBlockData;
+ import net.minecraft.world.level.block.state.pattern.BlockInWorld;
+ import org.slf4j.Logger;
+
++// CraftBukkit start
++import com.mojang.serialization.Dynamic;
++import java.util.Map;
++import java.util.Objects;
++import net.minecraft.server.MinecraftServer;
++import net.minecraft.server.level.ServerLevel;
++import net.minecraft.server.level.ServerPlayer;
++import net.minecraft.sounds.SoundEvent;
++import net.minecraft.sounds.SoundSource;
++import net.minecraft.stats.Stats;
++import net.minecraft.util.datafix.fixes.DataConverterTypes;
++import net.minecraft.world.level.block.Blocks;
++import net.minecraft.world.level.block.SaplingBlock;
++import net.minecraft.world.level.block.SignBlock;
++import net.minecraft.world.level.block.SoundType;
++import net.minecraft.world.level.block.WitherSkullBlock;
++import net.minecraft.world.level.block.entity.BlockEntity;
++import net.minecraft.world.level.block.entity.JukeboxBlockEntity;
++import net.minecraft.world.level.block.entity.SignBlockEntity;
++import net.minecraft.world.level.block.entity.SkullBlockEntity;
++import net.minecraft.world.level.gameevent.GameEvent;
++import org.bukkit.Location;
++import org.bukkit.TreeType;
++import org.bukkit.block.BlockState;
++import org.bukkit.craftbukkit.block.CraftBlock;
++import org.bukkit.craftbukkit.block.CraftBlockState;
++import org.bukkit.craftbukkit.inventory.CraftItemStack;
++import org.bukkit.craftbukkit.util.CraftLocation;
++import org.bukkit.craftbukkit.util.CraftMagicNumbers;
++import org.bukkit.entity.Player;
++import org.bukkit.event.block.BlockFertilizeEvent;
++import org.bukkit.event.player.PlayerItemDamageEvent;
++import org.bukkit.event.world.StructureGrowEvent;
++// CraftBukkit end
++
+ public final class ItemStack {
+
+ public static final Codec<ItemStack> CODEC = RecordCodecBuilder.create((instance) -> {
+@@ -131,7 +167,7 @@
+ /** @deprecated */
+ @Deprecated
+ @Nullable
+- private final Item item;
++ private Item item;
+ @Nullable
+ private CompoundTag tag;
+ @Nullable
+@@ -145,26 +181,26 @@
+ return this.getItem().getTooltipImage(this);
+ }
+
+- public ItemStack(ItemLike itemlike) {
+- this(itemlike, 1);
++ public ItemStack(IMaterial item) {
++ this(item, 1);
+ }
+
+- public ItemStack(Holder<Item> holder) {
+- this((ItemLike) holder.value(), 1);
++ public ItemStack(Holder<Item> tag) {
++ this((IMaterial) tag.value(), 1);
+ }
+
+- public ItemStack(Holder<Item> holder, int i, Optional<CompoundTag> optional) {
+- this(holder, i);
++ public ItemStack(Holder<Item> item, int count, Optional<CompoundTag> optional) {
++ this(item, count);
+ optional.ifPresent(this::setTag);
+ }
+
+- public ItemStack(Holder<Item> holder, int i) {
+- this((ItemLike) holder.value(), i);
++ public ItemStack(Holder<Item> item, int count) {
++ this((IMaterial) item.value(), count);
+ }
+
+- public ItemStack(ItemLike itemlike, int i) {
+- this.item = itemlike.asItem();
+- this.count = i;
++ public ItemStack(IMaterial item, int count) {
++ this.item = item.asItem();
++ this.count = count;
+ if (this.item.canBeDepleted()) {
+ this.setDamageValue(this.getDamageValue());
+ }
+@@ -175,11 +211,22 @@
+ this.item = null;
+ }
+
+- private ItemStack(CompoundTag compoundtag) {
+- this.item = (Item) BuiltInRegistries.ITEM.get(new ResourceLocation(compoundtag.getString("id")));
+- this.count = compoundtag.getByte("Count");
+- if (compoundtag.contains("tag", 10)) {
+- this.tag = compoundtag.getCompound("tag").copy();
++ // Called to run this stack through the data converter to handle older storage methods and serialized items
++ public void convertStack(int version) {
++ if (0 < version && version < CraftMagicNumbers.INSTANCE.getDataVersion()) {
++ CompoundTag savedStack = new CompoundTag();
++ this.save(savedStack);
++ savedStack = (CompoundTag) MinecraftServer.getServer().fixerUpper.update(DataConverterTypes.ITEM_STACK, new Dynamic(NbtOps.INSTANCE, savedStack), version, CraftMagicNumbers.INSTANCE.getDataVersion()).getValue();
++ this.load(savedStack);
++ }
++ }
++
++ // CraftBukkit - break into own method
++ private void load(CompoundTag nbttagcompound) {
++ this.item = (Item) BuiltInRegistries.ITEM.get(new ResourceLocation(nbttagcompound.getString("id")));
++ this.count = nbttagcompound.getByte("Count");
++ if (nbttagcompound.contains("tag", 10)) {
++ this.tag = nbttagcompound.getCompound("tag").copy();
+ this.getItem().verifyTagAfterLoad(this.tag);
+ }
+
+@@ -189,11 +236,16 @@
+
+ }
+
+- public static ItemStack of(CompoundTag compoundtag) {
++ private ItemStack(CompoundTag compoundTag) {
++ this.load(compoundTag);
++ // CraftBukkit end
++ }
++
++ public static ItemStack of(CompoundTag compoundTag) {
+ try {
+- return new ItemStack(compoundtag);
++ return new ItemStack(compoundTag);
+ } catch (RuntimeException runtimeexception) {
+- ItemStack.LOGGER.debug("Tried to load invalid item: {}", compoundtag, runtimeexception);
++ ItemStack.LOGGER.debug("Tried to load invalid item: {}", compoundTag, runtimeexception);
+ return ItemStack.EMPTY;
+ }
+ }
+@@ -202,12 +254,12 @@
+ return this == ItemStack.EMPTY || this.item == Items.AIR || this.count <= 0;
+ }
+
+- public boolean isItemEnabled(FeatureFlagSet featureflagset) {
+- return this.isEmpty() || this.getItem().isEnabled(featureflagset);
++ public boolean isItemEnabled(FeatureFlagSet enabledFlags) {
++ return this.isEmpty() || this.getItem().isEnabled(enabledFlags);
+ }
+
+- public ItemStack split(int i) {
+- int j = Math.min(i, this.getCount());
++ public ItemStack split(int amount) {
++ int j = Math.min(amount, this.getCount());
+ ItemStack itemstack = this.copyWithCount(j);
+
+ this.shrink(j);
+@@ -233,20 +285,20 @@
+ return this.getItem().builtInRegistryHolder();
+ }
+
+- public boolean is(TagKey<Item> tagkey) {
+- return this.getItem().builtInRegistryHolder().is(tagkey);
++ public boolean is(TagKey<Item> tag) {
++ return this.getItem().builtInRegistryHolder().is(tag);
+ }
+
+ public boolean is(Item item) {
+ return this.getItem() == item;
+ }
+
+- public boolean is(Predicate<Holder<Item>> predicate) {
+- return predicate.test(this.getItem().builtInRegistryHolder());
++ public boolean is(Predicate<Holder<Item>> item) {
++ return item.test(this.getItem().builtInRegistryHolder());
+ }
+
+- public boolean is(Holder<Item> holder) {
+- return this.getItem().builtInRegistryHolder() == holder;
++ public boolean is(Holder<Item> item) {
++ return this.getItem().builtInRegistryHolder() == item;
+ }
+
+ public boolean is(HolderSet<Item> holderset) {
+@@ -257,47 +309,226 @@
+ return this.getItem().builtInRegistryHolder().tags();
+ }
+
+- public InteractionResult useOn(UseOnContext useoncontext) {
+- Player player = useoncontext.getPlayer();
+- BlockPos blockpos = useoncontext.getClickedPos();
+- BlockInWorld blockinworld = new BlockInWorld(useoncontext.getLevel(), blockpos, false);
++ public InteractionResult useOn(UseOnContext context) {
++ net.minecraft.world.entity.player.Player entityhuman = context.getPlayer();
++ BlockPos blockposition = context.getClickedPos();
++ BlockInWorld shapedetectorblock = new BlockInWorld(context.getLevel(), blockposition, false);
+
+- if (player != null && !player.getAbilities().mayBuild && !this.hasAdventureModePlaceTagForBlock(useoncontext.getLevel().registryAccess().registryOrThrow(Registries.BLOCK), blockinworld)) {
++ if (entityhuman != null && !entityhuman.getAbilities().mayBuild && !this.hasAdventureModePlaceTagForBlock(context.getLevel().registryAccess().registryOrThrow(Registries.BLOCK), shapedetectorblock)) {
+ return InteractionResult.PASS;
+ } else {
+ Item item = this.getItem();
+- InteractionResult interactionresult = item.useOn(useoncontext);
++ // CraftBukkit start - handle all block place event logic here
++ CompoundTag oldData = this.getTagClone();
++ int oldCount = this.getCount();
++ ServerLevel world = (ServerLevel) context.getLevel();
+
+- if (player != null && interactionresult.shouldAwardStats()) {
+- player.awardStat(Stats.ITEM_USED.get(item));
++ if (!(item instanceof BucketItem || item instanceof SolidBucketItem)) { // if not bucket
++ world.captureBlockStates = true;
++ // special case bonemeal
++ if (item == Items.BONE_MEAL) {
++ world.captureTreeGeneration = true;
++ }
+ }
++ InteractionResult enuminteractionresult;
++ try {
++ enuminteractionresult = item.useOn(context);
++ } finally {
++ world.captureBlockStates = false;
++ }
++ CompoundTag newData = this.getTagClone();
++ int newCount = this.getCount();
++ this.setCount(oldCount);
++ this.setTagClone(oldData);
++ if (enuminteractionresult.consumesAction() && world.captureTreeGeneration && world.capturedBlockStates.size() > 0) {
++ world.captureTreeGeneration = false;
++ Location location = CraftLocation.toBukkit(blockposition, world.getWorld());
++ TreeType treeType = SaplingBlock.treeType;
++ SaplingBlock.treeType = null;
++ List<CraftBlockState> blocks = new java.util.ArrayList<>(world.capturedBlockStates.values());
++ world.capturedBlockStates.clear();
++ StructureGrowEvent structureEvent = null;
++ if (treeType != null) {
++ boolean isBonemeal = getItem() == Items.BONE_MEAL;
++ structureEvent = new StructureGrowEvent(location, treeType, isBonemeal, (Player) entityhuman.getBukkitEntity(), (List< BlockState>) (List<? extends BlockState>) blocks);
++ org.bukkit.Bukkit.getPluginManager().callEvent(structureEvent);
++ }
+
+- return interactionresult;
++ BlockFertilizeEvent fertilizeEvent = new BlockFertilizeEvent(CraftBlock.at(world, blockposition), (Player) entityhuman.getBukkitEntity(), (List< BlockState>) (List<? extends BlockState>) blocks);
++ fertilizeEvent.setCancelled(structureEvent != null && structureEvent.isCancelled());
++ org.bukkit.Bukkit.getPluginManager().callEvent(fertilizeEvent);
++
++ if (!fertilizeEvent.isCancelled()) {
++ // Change the stack to its new contents if it hasn't been tampered with.
++ if (this.getCount() == oldCount && Objects.equals(this.tag, oldData)) {
++ this.setTag(newData);
++ this.setCount(newCount);
++ }
++ for (CraftBlockState blockstate : blocks) {
++ world.setBlock(blockstate.getPosition(),blockstate.getHandle(), blockstate.getFlag()); // SPIGOT-7248 - manual update to avoid physics where appropriate
++ }
++ entityhuman.awardStat(Stats.ITEM_USED.get(item)); // SPIGOT-7236 - award stat
++ }
++
++ SignItem.openSign = null; // SPIGOT-6758 - Reset on early return
++ return enuminteractionresult;
++ }
++ world.captureTreeGeneration = false;
++
++ if (entityhuman != null && enuminteractionresult.shouldAwardStats()) {
++ EnumHand enumhand = context.getHand();
++ org.bukkit.event.block.BlockPlaceEvent placeEvent = null;
++ List<BlockState> blocks = new java.util.ArrayList<>(world.capturedBlockStates.values());
++ world.capturedBlockStates.clear();
++ if (blocks.size() > 1) {
++ placeEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockMultiPlaceEvent(world, entityhuman, enumhand, blocks, blockposition.getX(), blockposition.getY(), blockposition.getZ());
++ } else if (blocks.size() == 1) {
++ placeEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPlaceEvent(world, entityhuman, enumhand, blocks.get(0), blockposition.getX(), blockposition.getY(), blockposition.getZ());
++ }
++
++ if (placeEvent != null && (placeEvent.isCancelled() || !placeEvent.canBuild())) {
++ enuminteractionresult = InteractionResult.FAIL; // cancel placement
++ // PAIL: Remove this when MC-99075 fixed
++ placeEvent.getPlayer().updateInventory();
++ // revert back all captured blocks
++ world.preventPoiUpdated = true; // CraftBukkit - SPIGOT-5710
++ for (BlockState blockstate : blocks) {
++ blockstate.update(true, false);
++ }
++ world.preventPoiUpdated = false;
++
++ // Brute force all possible updates
++ BlockPos placedPos = ((CraftBlock) placeEvent.getBlock()).getPosition();
++ for (Direction dir : Direction.values()) {
++ ((ServerPlayer) entityhuman).connection.send(new ClientboundBlockUpdatePacket(world, placedPos.relative(dir)));
++ }
++ SignItem.openSign = null; // SPIGOT-6758 - Reset on early return
++ } else {
++ // Change the stack to its new contents if it hasn't been tampered with.
++ if (this.getCount() == oldCount && Objects.equals(this.tag, oldData)) {
++ this.setTag(newData);
++ this.setCount(newCount);
++ }
++
++ for (Map.Entry<BlockPos, BlockEntity> e : world.capturedTileEntities.entrySet()) {
++ world.setBlockEntity(e.getValue());
++ }
++
++ for (BlockState blockstate : blocks) {
++ int updateFlag = ((CraftBlockState) blockstate).getFlag();
++ IBlockData oldBlock = ((CraftBlockState) blockstate).getHandle();
++ BlockPos newblockposition = ((CraftBlockState) blockstate).getPosition();
++ IBlockData block = world.getBlockState(newblockposition);
++
++ if (!(block.getBlock() instanceof BaseEntityBlock)) { // Containers get placed automatically
++ block.getBlock().onPlace(block, world, newblockposition, oldBlock, true);
++ }
++
++ world.notifyAndUpdatePhysics(newblockposition, null, oldBlock, block, world.getBlockState(newblockposition), updateFlag, 512); // send null chunk as chunk.k() returns false by this point
++ }
++
++ // Special case juke boxes as they update their tile entity. Copied from ItemRecord.
++ // PAIL: checkme on updates.
++ if (this.item instanceof RecordItem) {
++ BlockEntity tileentity = world.getBlockEntity(blockposition);
++
++ if (tileentity instanceof JukeboxBlockEntity) {
++ JukeboxBlockEntity tileentityjukebox = (JukeboxBlockEntity) tileentity;
++
++ // There can only be one
++ ItemStack record = this.copy();
++ if (!record.isEmpty()) {
++ record.setCount(1);
++ }
++
++ tileentityjukebox.setTheItem(record);
++ world.gameEvent(GameEvent.BLOCK_CHANGE, blockposition, GameEvent.Context.of(entityhuman, world.getBlockState(blockposition)));
++ }
++
++ this.shrink(1);
++ entityhuman.awardStat(Stats.PLAY_RECORD);
++ }
++
++ if (this.item == Items.WITHER_SKELETON_SKULL) { // Special case skulls to allow wither spawns to be cancelled
++ BlockPos bp = blockposition;
++ if (!world.getBlockState(blockposition).canBeReplaced()) {
++ if (!world.getBlockState(blockposition).isSolid()) {
++ bp = null;
++ } else {
++ bp = bp.relative(context.getClickedFace());
++ }
++ }
++ if (bp != null) {
++ BlockEntity te = world.getBlockEntity(bp);
++ if (te instanceof SkullBlockEntity) {
++ WitherSkullBlock.checkSpawn(world, bp, (SkullBlockEntity) te);
++ }
++ }
++ }
++
++ // SPIGOT-4678
++ if (this.item instanceof SignItem && SignItem.openSign != null) {
++ try {
++ if (world.getBlockEntity(SignItem.openSign) instanceof SignBlockEntity tileentitysign) {
++ if (world.getBlockState(SignItem.openSign).getBlock() instanceof SignBlock blocksign) {
++ blocksign.openTextEdit(entityhuman, tileentitysign, true, org.bukkit.event.player.PlayerSignOpenEvent.Cause.PLACE); // Craftbukkit
++ }
++ }
++ } finally {
++ SignItem.openSign = null;
++ }
++ }
++
++ // SPIGOT-7315: Moved from BlockBed#setPlacedBy
++ if (placeEvent != null && this.item instanceof BedItem) {
++ BlockPos position = ((CraftBlock) placeEvent.getBlock()).getPosition();
++ IBlockData blockData = world.getBlockState(position);
++
++ if (blockData.getBlock() instanceof BedBlock) {
++ world.blockUpdated(position, Blocks.AIR);
++ blockData.updateNeighbourShapes(world, position, 3);
++ }
++ }
++
++ // SPIGOT-1288 - play sound stripped from ItemBlock
++ if (this.item instanceof BlockItem) {
++ SoundType soundeffecttype = ((BlockItem) this.item).getBlock().defaultBlockState().getSoundType(); // TODO: not strictly correct, however currently only affects decorated pots
++ world.playSound(entityhuman, blockposition, soundeffecttype.getPlaceSound(), SoundSource.BLOCKS, (soundeffecttype.getVolume() + 1.0F) / 2.0F, soundeffecttype.getPitch() * 0.8F);
++ }
++
++ entityhuman.awardStat(Stats.ITEM_USED.get(item));
++ }
++ }
++ world.capturedTileEntities.clear();
++ world.capturedBlockStates.clear();
++ // CraftBukkit end
++
++ return enuminteractionresult;
+ }
+ }
+
+- public float getDestroySpeed(BlockState blockstate) {
+- return this.getItem().getDestroySpeed(this, blockstate);
++ public float getDestroySpeed(IBlockData state) {
++ return this.getItem().getDestroySpeed(this, state);
+ }
+
+- public InteractionResultHolder<ItemStack> use(Level level, Player player, InteractionHand interactionhand) {
+- return this.getItem().use(level, player, interactionhand);
++ public InteractionResultHolder<ItemStack> use(Level level, net.minecraft.world.entity.player.Player player, EnumHand usedHand) {
++ return this.getItem().use(level, player, usedHand);
+ }
+
+- public ItemStack finishUsingItem(Level level, LivingEntity livingentity) {
+- return this.getItem().finishUsingItem(this, level, livingentity);
++ public ItemStack finishUsingItem(Level level, LivingEntity livingEntity) {
++ return this.getItem().finishUsingItem(this, level, livingEntity);
+ }
+
+- public CompoundTag save(CompoundTag compoundtag) {
+- ResourceLocation resourcelocation = BuiltInRegistries.ITEM.getKey(this.getItem());
++ public CompoundTag save(CompoundTag compoundTag) {
++ ResourceLocation minecraftkey = BuiltInRegistries.ITEM.getKey(this.getItem());
+
+- compoundtag.putString("id", resourcelocation == null ? "minecraft:air" : resourcelocation.toString());
+- compoundtag.putByte("Count", (byte) this.count);
++ compoundTag.putString("id", minecraftkey == null ? "minecraft:air" : minecraftkey.toString());
++ compoundTag.putByte("Count", (byte) this.count);
+ if (this.tag != null) {
+- compoundtag.put("tag", this.tag.copy());
++ compoundTag.put("tag", this.tag.copy());
+ }
+
+- return compoundtag;
++ return compoundTag;
+ }
+
+ public int getMaxStackSize() {
+@@ -310,9 +541,9 @@
+
+ public boolean isDamageableItem() {
+ if (!this.isEmpty() && this.getItem().getMaxDamage() > 0) {
+- CompoundTag compoundtag = this.getTag();
++ CompoundTag nbttagcompound = this.getTag();
+
+- return compoundtag == null || !compoundtag.getBoolean("Unbreakable");
++ return nbttagcompound == null || !nbttagcompound.getBoolean("Unbreakable");
+ } else {
+ return false;
+ }
+@@ -326,56 +557,76 @@
+ return this.tag == null ? 0 : this.tag.getInt("Damage");
+ }
+
+- public void setDamageValue(int i) {
+- this.getOrCreateTag().putInt("Damage", Math.max(0, i));
++ public void setDamageValue(int damage) {
++ this.getOrCreateTag().putInt("Damage", Math.max(0, damage));
+ }
+
+ public int getMaxDamage() {
+ return this.getItem().getMaxDamage();
+ }
+
+- public boolean hurt(int i, RandomSource randomsource, @Nullable ServerPlayer serverplayer) {
++ public boolean hurt(int amount, RandomSource random, @Nullable ServerPlayer user) {
+ if (!this.isDamageableItem()) {
+ return false;
+ } else {
+ int j;
+
+- if (i > 0) {
++ if (amount > 0) {
+ j = EnchantmentHelper.getItemEnchantmentLevel(Enchantments.UNBREAKING, this);
+ int k = 0;
+
+- for (int l = 0; j > 0 && l < i; ++l) {
+- if (DigDurabilityEnchantment.shouldIgnoreDurabilityDrop(this, j, randomsource)) {
++ for (int l = 0; j > 0 && l < amount; ++l) {
++ if (DigDurabilityEnchantment.shouldIgnoreDurabilityDrop(this, j, random)) {
+ ++k;
+ }
+ }
+
+- i -= k;
+- if (i <= 0) {
++ amount -= k;
++ // CraftBukkit start
++ if (user != null) {
++ PlayerItemDamageEvent event = new PlayerItemDamageEvent(user.getBukkitEntity(), CraftItemStack.asCraftMirror(this), amount);
++ event.getPlayer().getServer().getPluginManager().callEvent(event);
++
++ if (amount != event.getDamage() || event.isCancelled()) {
++ event.getPlayer().updateInventory();
++ }
++ if (event.isCancelled()) {
++ return false;
++ }
++
++ amount = event.getDamage();
++ }
++ // CraftBukkit end
++ if (amount <= 0) {
+ return false;
+ }
+ }
+
+- if (serverplayer != null && i != 0) {
+- CriteriaTriggers.ITEM_DURABILITY_CHANGED.trigger(serverplayer, this, this.getDamageValue() + i);
++ if (user != null && amount != 0) {
++ CriteriaTriggers.ITEM_DURABILITY_CHANGED.trigger(user, this, this.getDamageValue() + amount);
+ }
+
+- j = this.getDamageValue() + i;
++ j = this.getDamageValue() + amount;
+ this.setDamageValue(j);
+ return j >= this.getMaxDamage();
+ }
+ }
+
+- public <T extends LivingEntity> void hurtAndBreak(int i, T t0, Consumer<T> consumer) {
+- if (!t0.level().isClientSide && (!(t0 instanceof Player) || !((Player) t0).getAbilities().instabuild)) {
++ public <T extends LivingEntity> void hurtAndBreak(int amount, T entity, Consumer<T> onBroken) {
++ if (!entity.level().isClientSide && (!(entity instanceof net.minecraft.world.entity.player.Player) || !((net.minecraft.world.entity.player.Player) entity).getAbilities().instabuild)) {
+ if (this.isDamageableItem()) {
+- if (this.hurt(i, t0.getRandom(), t0 instanceof ServerPlayer ? (ServerPlayer) t0 : null)) {
+- consumer.accept(t0);
++ if (this.hurt(amount, entity.getRandom(), entity instanceof ServerPlayer ? (ServerPlayer) entity : null)) {
++ onBroken.accept(entity);
+ Item item = this.getItem();
++ // CraftBukkit start - Check for item breaking
++ if (this.count == 1 && entity instanceof net.minecraft.world.entity.player.Player) {
++ org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerItemBreakEvent((net.minecraft.world.entity.player.Player) entity, this);
++ }
++ // CraftBukkit end
+
+ this.shrink(1);
+- if (t0 instanceof Player) {
+- ((Player) t0).awardStat(Stats.ITEM_BROKEN.get(item));
++ if (entity instanceof net.minecraft.world.entity.player.Player) {
++ ((net.minecraft.world.entity.player.Player) entity).awardStat(Stats.ITEM_BROKEN.get(item));
+ }
+
+ this.setDamageValue(0);
+@@ -397,38 +648,38 @@
+ return this.getItem().getBarColor(this);
+ }
+
+- public boolean overrideStackedOnOther(Slot slot, ClickAction clickaction, Player player) {
+- return this.getItem().overrideStackedOnOther(this, slot, clickaction, player);
++ public boolean overrideStackedOnOther(Slot slot, ClickAction action, net.minecraft.world.entity.player.Player player) {
++ return this.getItem().overrideStackedOnOther(this, slot, action, player);
+ }
+
+- public boolean overrideOtherStackedOnMe(ItemStack itemstack, Slot slot, ClickAction clickaction, Player player, SlotAccess slotaccess) {
+- return this.getItem().overrideOtherStackedOnMe(this, itemstack, slot, clickaction, player, slotaccess);
++ public boolean overrideOtherStackedOnMe(ItemStack stack, Slot slot, ClickAction action, net.minecraft.world.entity.player.Player player, SlotAccess access) {
++ return this.getItem().overrideOtherStackedOnMe(this, stack, slot, action, player, access);
+ }
+
+- public void hurtEnemy(LivingEntity livingentity, Player player) {
++ public void hurtEnemy(LivingEntity entity, net.minecraft.world.entity.player.Player player) {
+ Item item = this.getItem();
+
+- if (item.hurtEnemy(this, livingentity, player)) {
++ if (item.hurtEnemy(this, entity, player)) {
+ player.awardStat(Stats.ITEM_USED.get(item));
+ }
+
+ }
+
+- public void mineBlock(Level level, BlockState blockstate, BlockPos blockpos, Player player) {
++ public void mineBlock(Level level, IBlockData state, BlockPos pos, net.minecraft.world.entity.player.Player player) {
+ Item item = this.getItem();
+
+- if (item.mineBlock(this, level, blockstate, blockpos, player)) {
++ if (item.mineBlock(this, level, state, pos, player)) {
+ player.awardStat(Stats.ITEM_USED.get(item));
+ }
+
+ }
+
+- public boolean isCorrectToolForDrops(BlockState blockstate) {
+- return this.getItem().isCorrectToolForDrops(blockstate);
++ public boolean isCorrectToolForDrops(IBlockData state) {
++ return this.getItem().isCorrectToolForDrops(state);
+ }
+
+- public InteractionResult interactLivingEntity(Player player, LivingEntity livingentity, InteractionHand interactionhand) {
+- return this.getItem().interactLivingEntity(this, player, livingentity, interactionhand);
++ public InteractionResult interactLivingEntity(net.minecraft.world.entity.player.Player player, LivingEntity entity, EnumHand usedHand) {
++ return this.getItem().interactLivingEntity(this, player, entity, usedHand);
+ }
+
+ public ItemStack copy() {
+@@ -446,70 +697,69 @@
+ }
+ }
+
+- public ItemStack copyWithCount(int i) {
++ public ItemStack copyWithCount(int count) {
+ if (this.isEmpty()) {
+ return ItemStack.EMPTY;
+ } else {
+ ItemStack itemstack = this.copy();
+
+- itemstack.setCount(i);
++ itemstack.setCount(count);
+ return itemstack;
+ }
+ }
+
+- public static boolean matches(ItemStack itemstack, ItemStack itemstack1) {
+- return itemstack == itemstack1 ? true : (itemstack.getCount() != itemstack1.getCount() ? false : isSameItemSameTags(itemstack, itemstack1));
++ public static boolean matches(ItemStack stack, ItemStack other) {
++ return stack == other ? true : (stack.getCount() != other.getCount() ? false : isSameItemSameTags(stack, other));
+ }
+
+- public static boolean isSameItem(ItemStack itemstack, ItemStack itemstack1) {
+- return itemstack.is(itemstack1.getItem());
++ public static boolean isSameItem(ItemStack stack, ItemStack other) {
++ return stack.is(other.getItem());
+ }
+
+- public static boolean isSameItemSameTags(ItemStack itemstack, ItemStack itemstack1) {
+- return !itemstack.is(itemstack1.getItem()) ? false : (itemstack.isEmpty() && itemstack1.isEmpty() ? true : Objects.equals(itemstack.tag, itemstack1.tag));
++ public static boolean isSameItemSameTags(ItemStack stack, ItemStack other) {
++ return !stack.is(other.getItem()) ? false : (stack.isEmpty() && other.isEmpty() ? true : Objects.equals(stack.tag, other.tag));
+ }
+
+ public String getDescriptionId() {
+ return this.getItem().getDescriptionId(this);
+ }
+
+- @Override
+ public String toString() {
+ int i = this.getCount();
+
+ return i + " " + this.getItem();
+ }
+
+- public void inventoryTick(Level level, Entity entity, int i, boolean flag) {
++ public void inventoryTick(Level level, Entity entity, int inventorySlot, boolean isCurrentItem) {
+ if (this.popTime > 0) {
+ --this.popTime;
+ }
+
+ if (this.getItem() != null) {
+- this.getItem().inventoryTick(this, level, entity, i, flag);
++ this.getItem().inventoryTick(this, level, entity, inventorySlot, isCurrentItem);
+ }
+
+ }
+
+- public void onCraftedBy(Level level, Player player, int i) {
+- player.awardStat(Stats.ITEM_CRAFTED.get(this.getItem()), i);
++ public void onCraftedBy(Level level, net.minecraft.world.entity.player.Player player, int amount) {
++ player.awardStat(Stats.ITEM_CRAFTED.get(this.getItem()), amount);
+ this.getItem().onCraftedBy(this, level, player);
+ }
+
+- public void onCraftedBySystem(Level level) {
+- this.getItem().onCraftedPostProcess(this, level);
++ public void onCraftedBySystem(Level world) {
++ this.getItem().onCraftedPostProcess(this, world);
+ }
+
+ public int getUseDuration() {
+ return this.getItem().getUseDuration(this);
+ }
+
+- public UseAnim getUseAnimation() {
++ public EnumAnimation getUseAnimation() {
+ return this.getItem().getUseAnimation(this);
+ }
+
+- public void releaseUsing(Level level, LivingEntity livingentity, int i) {
+- this.getItem().releaseUsing(this, level, livingentity, i);
++ public void releaseUsing(Level level, LivingEntity livingEntity, int timeLeft) {
++ this.getItem().releaseUsing(this, level, livingEntity, timeLeft);
+ }
+
+ public boolean useOnRelease() {
+@@ -525,6 +775,17 @@
+ return this.tag;
+ }
+
++ // CraftBukkit start
++ @Nullable
++ private CompoundTag getTagClone() {
++ return this.tag == null ? null : this.tag.copy();
++ }
++
++ private void setTagClone(@Nullable CompoundTag nbtttagcompound) {
++ this.setTag(nbtttagcompound == null ? null : nbtttagcompound.copy());
++ }
++ // CraftBukkit end
++
+ public CompoundTag getOrCreateTag() {
+ if (this.tag == null) {
+ this.setTag(new CompoundTag());
+@@ -533,25 +794,25 @@
+ return this.tag;
+ }
+
+- public CompoundTag getOrCreateTagElement(String s) {
+- if (this.tag != null && this.tag.contains(s, 10)) {
+- return this.tag.getCompound(s);
++ public CompoundTag getOrCreateTagElement(String key) {
++ if (this.tag != null && this.tag.contains(key, 10)) {
++ return this.tag.getCompound(key);
+ } else {
+- CompoundTag compoundtag = new CompoundTag();
++ CompoundTag nbttagcompound = new CompoundTag();
+
+- this.addTagElement(s, compoundtag);
+- return compoundtag;
++ this.addTagElement(key, nbttagcompound);
++ return nbttagcompound;
+ }
+ }
+
+ @Nullable
+- public CompoundTag getTagElement(String s) {
+- return this.tag != null && this.tag.contains(s, 10) ? this.tag.getCompound(s) : null;
++ public CompoundTag getTagElement(String key) {
++ return this.tag != null && this.tag.contains(key, 10) ? this.tag.getCompound(key) : null;
+ }
+
+- public void removeTagKey(String s) {
+- if (this.tag != null && this.tag.contains(s)) {
+- this.tag.remove(s);
++ public void removeTagKey(String key) {
++ if (this.tag != null && this.tag.contains(key)) {
++ this.tag.remove(key);
+ if (this.tag.isEmpty()) {
+ this.tag = null;
+ }
+@@ -563,56 +824,56 @@
+ return this.tag != null ? this.tag.getList("Enchantments", 10) : new ListTag();
+ }
+
+- public void setTag(@Nullable CompoundTag compoundtag) {
+- this.tag = compoundtag;
++ public void setTag(@Nullable CompoundTag compoundTag) {
++ this.tag = compoundTag;
+ if (this.getItem().canBeDepleted()) {
+ this.setDamageValue(this.getDamageValue());
+ }
+
+- if (compoundtag != null) {
+- this.getItem().verifyTagAfterLoad(compoundtag);
++ if (compoundTag != null) {
++ this.getItem().verifyTagAfterLoad(compoundTag);
+ }
+
+ }
+
+ public Component getHoverName() {
+- CompoundTag compoundtag = this.getTagElement("display");
++ CompoundTag nbttagcompound = this.getTagElement("display");
+
+- if (compoundtag != null && compoundtag.contains("Name", 8)) {
++ if (nbttagcompound != null && nbttagcompound.contains("Name", 8)) {
+ try {
+- MutableComponent mutablecomponent = Component.Serializer.fromJson(compoundtag.getString("Name"));
++ MutableComponent ichatmutablecomponent = Component.Serializer.fromJson(nbttagcompound.getString("Name"));
+
+- if (mutablecomponent != null) {
+- return mutablecomponent;
++ if (ichatmutablecomponent != null) {
++ return ichatmutablecomponent;
+ }
+
+- compoundtag.remove("Name");
++ nbttagcompound.remove("Name");
+ } catch (Exception exception) {
+- compoundtag.remove("Name");
++ nbttagcompound.remove("Name");
+ }
+ }
+
+ return this.getItem().getName(this);
+ }
+
+- public ItemStack setHoverName(@Nullable Component component) {
+- CompoundTag compoundtag = this.getOrCreateTagElement("display");
++ public ItemStack setHoverName(@Nullable Component nameComponent) {
++ CompoundTag nbttagcompound = this.getOrCreateTagElement("display");
+
+- if (component != null) {
+- compoundtag.putString("Name", Component.Serializer.toJson(component));
++ if (nameComponent != null) {
++ nbttagcompound.putString("Name", Component.Serializer.toJson(nameComponent));
+ } else {
+- compoundtag.remove("Name");
++ nbttagcompound.remove("Name");
+ }
+
+ return this;
+ }
+
+ public void resetHoverName() {
+- CompoundTag compoundtag = this.getTagElement("display");
++ CompoundTag nbttagcompound = this.getTagElement("display");
+
+- if (compoundtag != null) {
+- compoundtag.remove("Name");
+- if (compoundtag.isEmpty()) {
++ if (nbttagcompound != null) {
++ nbttagcompound.remove("Name");
++ if (nbttagcompound.isEmpty()) {
+ this.removeTagKey("display");
+ }
+ }
+@@ -624,21 +885,21 @@
+ }
+
+ public boolean hasCustomHoverName() {
+- CompoundTag compoundtag = this.getTagElement("display");
++ CompoundTag nbttagcompound = this.getTagElement("display");
+
+- return compoundtag != null && compoundtag.contains("Name", 8);
++ return nbttagcompound != null && nbttagcompound.contains("Name", 8);
+ }
+
+- public List<Component> getTooltipLines(@Nullable Player player, TooltipFlag tooltipflag) {
++ public List<Component> getTooltipLines(@Nullable net.minecraft.world.entity.player.Player player, TooltipFlag isAdvanced) {
+ List<Component> list = Lists.newArrayList();
+- MutableComponent mutablecomponent = Component.empty().append(this.getHoverName()).withStyle(this.getRarity().color);
++ MutableComponent ichatmutablecomponent = Component.empty().append(this.getHoverName()).withStyle(this.getRarity().color);
+
+ if (this.hasCustomHoverName()) {
+- mutablecomponent.withStyle(ChatFormatting.ITALIC);
++ ichatmutablecomponent.withStyle(ChatFormatting.ITALIC);
+ }
+
+- list.add(mutablecomponent);
+- if (!tooltipflag.isAdvanced() && !this.hasCustomHoverName() && this.is(Items.FILLED_MAP)) {
++ list.add(ichatmutablecomponent);
++ if (!isAdvanced.isAdvanced() && !this.hasCustomHoverName() && this.is(Items.FILLED_MAP)) {
+ Integer integer = MapItem.getMapId(this);
+
+ if (integer != null) {
+@@ -648,46 +909,46 @@
+
+ int i = this.getHideFlags();
+
+- if (shouldShowInTooltip(i, ItemStack.TooltipPart.ADDITIONAL)) {
+- this.getItem().appendHoverText(this, player == null ? null : player.level(), list, tooltipflag);
++ if (shouldShowInTooltip(i, ItemStack.HideFlags.ADDITIONAL)) {
++ this.getItem().appendHoverText(this, player == null ? null : player.level(), list, isAdvanced);
+ }
+
+ int j;
+
+ if (this.hasTag()) {
+- if (shouldShowInTooltip(i, ItemStack.TooltipPart.UPGRADES) && player != null) {
++ if (shouldShowInTooltip(i, ItemStack.HideFlags.UPGRADES) && player != null) {
+ ArmorTrim.appendUpgradeHoverText(this, player.level().registryAccess(), list);
+ }
+
+- if (shouldShowInTooltip(i, ItemStack.TooltipPart.ENCHANTMENTS)) {
++ if (shouldShowInTooltip(i, ItemStack.HideFlags.ENCHANTMENTS)) {
+ appendEnchantmentNames(list, this.getEnchantmentTags());
+ }
+
+ if (this.tag.contains("display", 10)) {
+- CompoundTag compoundtag = this.tag.getCompound("display");
++ CompoundTag nbttagcompound = this.tag.getCompound("display");
+
+- if (shouldShowInTooltip(i, ItemStack.TooltipPart.DYE) && compoundtag.contains("color", 99)) {
+- if (tooltipflag.isAdvanced()) {
+- list.add(Component.translatable("item.color", String.format(Locale.ROOT, "#%06X", compoundtag.getInt("color"))).withStyle(ChatFormatting.GRAY));
++ if (shouldShowInTooltip(i, ItemStack.HideFlags.DYE) && nbttagcompound.contains("color", 99)) {
++ if (isAdvanced.isAdvanced()) {
++ list.add(Component.translatable("item.color", String.format(Locale.ROOT, "#%06X", nbttagcompound.getInt("color"))).withStyle(ChatFormatting.GRAY));
+ } else {
+ list.add(Component.translatable("item.dyed").withStyle(ChatFormatting.GRAY, ChatFormatting.ITALIC));
+ }
+ }
+
+- if (compoundtag.getTagType("Lore") == 9) {
+- ListTag listtag = compoundtag.getList("Lore", 8);
++ if (nbttagcompound.getTagType("Lore") == 9) {
++ ListTag nbttaglist = nbttagcompound.getList("Lore", 8);
+
+- for (j = 0; j < listtag.size(); ++j) {
+- String s = listtag.getString(j);
++ for (j = 0; j < nbttaglist.size(); ++j) {
++ String s = nbttaglist.getString(j);
+
+ try {
+- MutableComponent mutablecomponent1 = Component.Serializer.fromJson(s);
++ MutableComponent ichatmutablecomponent1 = Component.Serializer.fromJson(s);
+
+- if (mutablecomponent1 != null) {
+- list.add(ComponentUtils.mergeStyles(mutablecomponent1, ItemStack.LORE_STYLE));
++ if (ichatmutablecomponent1 != null) {
++ list.add(ComponentUtils.mergeStyles(ichatmutablecomponent1, ItemStack.LORE_STYLE));
+ }
+ } catch (Exception exception) {
+- compoundtag.remove("Lore");
++ nbttagcompound.remove("Lore");
+ }
+ }
+ }
+@@ -696,18 +957,18 @@
+
+ int k;
+
+- if (shouldShowInTooltip(i, ItemStack.TooltipPart.MODIFIERS)) {
+- EquipmentSlot[] aequipmentslot = EquipmentSlot.values();
++ if (shouldShowInTooltip(i, ItemStack.HideFlags.MODIFIERS)) {
++ EquipmentSlot[] aenumitemslot = EquipmentSlot.values();
+
+- k = aequipmentslot.length;
++ k = aenumitemslot.length;
+
+ for (j = 0; j < k; ++j) {
+- EquipmentSlot equipmentslot = aequipmentslot[j];
+- Multimap<Attribute, AttributeModifier> multimap = this.getAttributeModifiers(equipmentslot);
++ EquipmentSlot enumitemslot = aenumitemslot[j];
++ Multimap<Attribute, AttributeModifier> multimap = this.getAttributeModifiers(enumitemslot);
+
+ if (!multimap.isEmpty()) {
+ list.add(CommonComponents.EMPTY);
+- list.add(Component.translatable("item.modifiers." + equipmentslot.getName()).withStyle(ChatFormatting.GRAY));
++ list.add(Component.translatable("item.modifiers." + enumitemslot.getName()).withStyle(ChatFormatting.GRAY));
+ Iterator iterator = multimap.entries().iterator();
+
+ while (iterator.hasNext()) {
+@@ -719,7 +980,7 @@
+ if (player != null) {
+ if (attributemodifier.getId() == Item.BASE_ATTACK_DAMAGE_UUID) {
+ d0 += player.getAttributeBaseValue(Attributes.ATTACK_DAMAGE);
+- d0 += (double) EnchantmentHelper.getDamageBonus(this, MobType.UNDEFINED);
++ d0 += (double) EnchantmentHelper.getDamageBonus(this, EnumMonsterType.UNDEFINED);
+ flag = true;
+ } else if (attributemodifier.getId() == Item.BASE_ATTACK_SPEED_UUID) {
+ d0 += player.getAttributeBaseValue(Attributes.ATTACK_SPEED);
+@@ -753,38 +1014,38 @@
+ }
+
+ if (this.hasTag()) {
+- if (shouldShowInTooltip(i, ItemStack.TooltipPart.UNBREAKABLE) && this.tag.getBoolean("Unbreakable")) {
++ if (shouldShowInTooltip(i, ItemStack.HideFlags.UNBREAKABLE) && this.tag.getBoolean("Unbreakable")) {
+ list.add(Component.translatable("item.unbreakable").withStyle(ChatFormatting.BLUE));
+ }
+
+- ListTag listtag1;
++ ListTag nbttaglist1;
+
+- if (shouldShowInTooltip(i, ItemStack.TooltipPart.CAN_DESTROY) && this.tag.contains("CanDestroy", 9)) {
+- listtag1 = this.tag.getList("CanDestroy", 8);
+- if (!listtag1.isEmpty()) {
++ if (shouldShowInTooltip(i, ItemStack.HideFlags.CAN_DESTROY) && this.tag.contains("CanDestroy", 9)) {
++ nbttaglist1 = this.tag.getList("CanDestroy", 8);
++ if (!nbttaglist1.isEmpty()) {
+ list.add(CommonComponents.EMPTY);
+ list.add(Component.translatable("item.canBreak").withStyle(ChatFormatting.GRAY));
+
+- for (k = 0; k < listtag1.size(); ++k) {
+- list.addAll(expandBlockState(listtag1.getString(k)));
++ for (k = 0; k < nbttaglist1.size(); ++k) {
++ list.addAll(expandBlockState(nbttaglist1.getString(k)));
+ }
+ }
+ }
+
+- if (shouldShowInTooltip(i, ItemStack.TooltipPart.CAN_PLACE) && this.tag.contains("CanPlaceOn", 9)) {
+- listtag1 = this.tag.getList("CanPlaceOn", 8);
+- if (!listtag1.isEmpty()) {
++ if (shouldShowInTooltip(i, ItemStack.HideFlags.CAN_PLACE) && this.tag.contains("CanPlaceOn", 9)) {
++ nbttaglist1 = this.tag.getList("CanPlaceOn", 8);
++ if (!nbttaglist1.isEmpty()) {
+ list.add(CommonComponents.EMPTY);
+ list.add(Component.translatable("item.canPlace").withStyle(ChatFormatting.GRAY));
+
+- for (k = 0; k < listtag1.size(); ++k) {
+- list.addAll(expandBlockState(listtag1.getString(k)));
++ for (k = 0; k < nbttaglist1.size(); ++k) {
++ list.addAll(expandBlockState(nbttaglist1.getString(k)));
+ }
+ }
+ }
+ }
+
+- if (tooltipflag.isAdvanced()) {
++ if (isAdvanced.isAdvanced()) {
+ if (this.isDamaged()) {
+ list.add(Component.translatable("item.durability", this.getMaxDamage() - this.getDamageValue(), this.getMaxDamage()));
+ }
+@@ -802,37 +1063,37 @@
+ return list;
+ }
+
+- private static boolean shouldShowInTooltip(int i, ItemStack.TooltipPart itemstack_tooltippart) {
+- return (i & itemstack_tooltippart.getMask()) == 0;
++ private static boolean shouldShowInTooltip(int hideFlags, ItemStack.HideFlags part) {
++ return (hideFlags & part.getMask()) == 0;
+ }
+
+ private int getHideFlags() {
+ return this.hasTag() && this.tag.contains("HideFlags", 99) ? this.tag.getInt("HideFlags") : 0;
+ }
+
+- public void hideTooltipPart(ItemStack.TooltipPart itemstack_tooltippart) {
+- CompoundTag compoundtag = this.getOrCreateTag();
++ public void hideTooltipPart(ItemStack.HideFlags part) {
++ CompoundTag nbttagcompound = this.getOrCreateTag();
+
+- compoundtag.putInt("HideFlags", compoundtag.getInt("HideFlags") | itemstack_tooltippart.getMask());
++ nbttagcompound.putInt("HideFlags", nbttagcompound.getInt("HideFlags") | part.getMask());
+ }
+
+- public static void appendEnchantmentNames(List<Component> list, ListTag listtag) {
+- for (int i = 0; i < listtag.size(); ++i) {
+- CompoundTag compoundtag = listtag.getCompound(i);
++ public static void appendEnchantmentNames(List<Component> tooltipComponents, ListTag storedEnchantments) {
++ for (int i = 0; i < storedEnchantments.size(); ++i) {
++ CompoundTag nbttagcompound = storedEnchantments.getCompound(i);
+
+- BuiltInRegistries.ENCHANTMENT.getOptional(EnchantmentHelper.getEnchantmentId(compoundtag)).ifPresent((enchantment) -> {
+- list.add(enchantment.getFullname(EnchantmentHelper.getEnchantmentLevel(compoundtag)));
++ BuiltInRegistries.ENCHANTMENT.getOptional(EnchantmentHelper.getEnchantmentId(nbttagcompound)).ifPresent((enchantment) -> {
++ tooltipComponents.add(enchantment.getFullname(EnchantmentHelper.getEnchantmentLevel(nbttagcompound)));
+ });
+ }
+
+ }
+
+- private static Collection<Component> expandBlockState(String s) {
++ private static Collection<Component> expandBlockState(String stateString) {
+ try {
+- return (Collection) BlockStateParser.parseForTesting(BuiltInRegistries.BLOCK.asLookup(), s, true).map((blockstateparser_blockresult) -> {
+- return Lists.newArrayList(new Component[]{blockstateparser_blockresult.blockState().getBlock().getName().withStyle(ChatFormatting.DARK_GRAY)});
+- }, (blockstateparser_tagresult) -> {
+- return (List) blockstateparser_tagresult.tag().stream().map((holder) -> {
++ return (Collection) BlockStateParser.parseForTesting(BuiltInRegistries.BLOCK.asLookup(), stateString, true).map((argumentblock_a) -> {
++ return Lists.newArrayList(new Component[]{argumentblock_a.blockState().getBlock().getName().withStyle(ChatFormatting.DARK_GRAY)});
++ }, (argumentblock_b) -> {
++ return (List) argumentblock_b.tag().stream().map((holder) -> {
+ return ((Block) holder.value()).getName().withStyle(ChatFormatting.DARK_GRAY);
+ }).collect(Collectors.toList());
+ });
+@@ -853,23 +1114,23 @@
+ return !this.getItem().isEnchantable(this) ? false : !this.isEnchanted();
+ }
+
+- public void enchant(Enchantment enchantment, int i) {
++ public void enchant(Enchantment enchantment, int level) {
+ this.getOrCreateTag();
+ if (!this.tag.contains("Enchantments", 9)) {
+ this.tag.put("Enchantments", new ListTag());
+ }
+
+- ListTag listtag = this.tag.getList("Enchantments", 10);
++ ListTag nbttaglist = this.tag.getList("Enchantments", 10);
+
+- listtag.add(EnchantmentHelper.storeEnchantment(EnchantmentHelper.getEnchantmentId(enchantment), (byte) i));
++ nbttaglist.add(EnchantmentHelper.storeEnchantment(EnchantmentHelper.getEnchantmentId(enchantment), (byte) level));
+ }
+
+ public boolean isEnchanted() {
+ return this.tag != null && this.tag.contains("Enchantments", 9) ? !this.tag.getList("Enchantments", 10).isEmpty() : false;
+ }
+
+- public void addTagElement(String s, Tag tag) {
+- this.getOrCreateTag().put(s, tag);
++ public void addTagElement(String key, Tag tag) {
++ this.getOrCreateTag().put(key, tag);
+ }
+
+ public boolean isFramed() {
+@@ -894,30 +1155,30 @@
+ return this.hasTag() && this.tag.contains("RepairCost", 3) ? this.tag.getInt("RepairCost") : 0;
+ }
+
+- public void setRepairCost(int i) {
+- if (i > 0) {
+- this.getOrCreateTag().putInt("RepairCost", i);
++ public void setRepairCost(int cost) {
++ if (cost > 0) {
++ this.getOrCreateTag().putInt("RepairCost", cost);
+ } else {
+ this.removeTagKey("RepairCost");
+ }
+
+ }
+
+- public Multimap<Attribute, AttributeModifier> getAttributeModifiers(EquipmentSlot equipmentslot) {
++ public Multimap<Attribute, AttributeModifier> getAttributeModifiers(EquipmentSlot slot) {
+ Object object;
+
+ if (this.hasTag() && this.tag.contains("AttributeModifiers", 9)) {
+ object = HashMultimap.create();
+- ListTag listtag = this.tag.getList("AttributeModifiers", 10);
++ ListTag nbttaglist = this.tag.getList("AttributeModifiers", 10);
+
+- for (int i = 0; i < listtag.size(); ++i) {
+- CompoundTag compoundtag = listtag.getCompound(i);
++ for (int i = 0; i < nbttaglist.size(); ++i) {
++ CompoundTag nbttagcompound = nbttaglist.getCompound(i);
+
+- if (!compoundtag.contains("Slot", 8) || compoundtag.getString("Slot").equals(equipmentslot.getName())) {
+- Optional<Attribute> optional = BuiltInRegistries.ATTRIBUTE.getOptional(ResourceLocation.tryParse(compoundtag.getString("AttributeName")));
++ if (!nbttagcompound.contains("Slot", 8) || nbttagcompound.getString("Slot").equals(slot.getName())) {
++ Optional<Attribute> optional = BuiltInRegistries.ATTRIBUTE.getOptional(ResourceLocation.tryParse(nbttagcompound.getString("AttributeName")));
+
+ if (!optional.isEmpty()) {
+- AttributeModifier attributemodifier = AttributeModifier.load(compoundtag);
++ AttributeModifier attributemodifier = AttributeModifier.load(nbttagcompound);
+
+ if (attributemodifier != null && attributemodifier.getId().getLeastSignificantBits() != 0L && attributemodifier.getId().getMostSignificantBits() != 0L) {
+ ((Multimap) object).put((Attribute) optional.get(), attributemodifier);
+@@ -926,93 +1187,100 @@
+ }
+ }
+ } else {
+- object = this.getItem().getDefaultAttributeModifiers(equipmentslot);
++ object = this.getItem().getDefaultAttributeModifiers(slot);
+ }
+
+ return (Multimap) object;
+ }
+
+- public void addAttributeModifier(Attribute attribute, AttributeModifier attributemodifier, @Nullable EquipmentSlot equipmentslot) {
++ public void addAttributeModifier(Attribute attribute, AttributeModifier modifier, @Nullable EquipmentSlot slot) {
+ this.getOrCreateTag();
+ if (!this.tag.contains("AttributeModifiers", 9)) {
+ this.tag.put("AttributeModifiers", new ListTag());
+ }
+
+- ListTag listtag = this.tag.getList("AttributeModifiers", 10);
+- CompoundTag compoundtag = attributemodifier.save();
++ ListTag nbttaglist = this.tag.getList("AttributeModifiers", 10);
++ CompoundTag nbttagcompound = modifier.save();
+
+- compoundtag.putString("AttributeName", BuiltInRegistries.ATTRIBUTE.getKey(attribute).toString());
+- if (equipmentslot != null) {
+- compoundtag.putString("Slot", equipmentslot.getName());
++ nbttagcompound.putString("AttributeName", BuiltInRegistries.ATTRIBUTE.getKey(attribute).toString());
++ if (slot != null) {
++ nbttagcompound.putString("Slot", slot.getName());
+ }
+
+- listtag.add(compoundtag);
++ nbttaglist.add(nbttagcompound);
+ }
+
++ // CraftBukkit start
++ @Deprecated
++ public void setItem(Item item) {
++ this.item = item;
++ }
++ // CraftBukkit end
++
+ public Component getDisplayName() {
+- MutableComponent mutablecomponent = Component.empty().append(this.getHoverName());
++ MutableComponent ichatmutablecomponent = Component.empty().append(this.getHoverName());
+
+ if (this.hasCustomHoverName()) {
+- mutablecomponent.withStyle(ChatFormatting.ITALIC);
++ ichatmutablecomponent.withStyle(ChatFormatting.ITALIC);
+ }
+
+- MutableComponent mutablecomponent1 = ComponentUtils.wrapInSquareBrackets(mutablecomponent);
++ MutableComponent ichatmutablecomponent1 = ComponentUtils.wrapInSquareBrackets(ichatmutablecomponent);
+
+ if (!this.isEmpty()) {
+- mutablecomponent1.withStyle(this.getRarity().color).withStyle((style) -> {
+- return style.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_ITEM, new HoverEvent.ItemStackInfo(this)));
++ ichatmutablecomponent1.withStyle(this.getRarity().color).withStyle((chatmodifier) -> {
++ return chatmodifier.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_ITEM, new HoverEvent.ItemStackInfo(this)));
+ });
+ }
+
+- return mutablecomponent1;
++ return ichatmutablecomponent1;
+ }
+
+- public boolean hasAdventureModePlaceTagForBlock(Registry<Block> registry, BlockInWorld blockinworld) {
++ public boolean hasAdventureModePlaceTagForBlock(Registry<Block> blockRegistry, BlockInWorld block) {
+ if (this.adventurePlaceCheck == null) {
+ this.adventurePlaceCheck = new AdventureModeCheck("CanPlaceOn");
+ }
+
+- return this.adventurePlaceCheck.test(this, registry, blockinworld);
++ return this.adventurePlaceCheck.test(this, blockRegistry, block);
+ }
+
+- public boolean hasAdventureModeBreakTagForBlock(Registry<Block> registry, BlockInWorld blockinworld) {
++ public boolean hasAdventureModeBreakTagForBlock(Registry<Block> blockRegistry, BlockInWorld block) {
+ if (this.adventureBreakCheck == null) {
+ this.adventureBreakCheck = new AdventureModeCheck("CanDestroy");
+ }
+
+- return this.adventureBreakCheck.test(this, registry, blockinworld);
++ return this.adventureBreakCheck.test(this, blockRegistry, block);
+ }
+
+ public int getPopTime() {
+ return this.popTime;
+ }
+
+- public void setPopTime(int i) {
+- this.popTime = i;
++ public void setPopTime(int popTime) {
++ this.popTime = popTime;
+ }
+
+ public int getCount() {
+ return this.isEmpty() ? 0 : this.count;
+ }
+
+- public void setCount(int i) {
+- this.count = i;
++ public void setCount(int count) {
++ this.count = count;
+ }
+
+- public void grow(int i) {
+- this.setCount(this.getCount() + i);
++ public void grow(int increment) {
++ this.setCount(this.getCount() + increment);
+ }
+
+- public void shrink(int i) {
+- this.grow(-i);
++ public void shrink(int decrement) {
++ this.grow(-decrement);
+ }
+
+- public void onUseTick(Level level, LivingEntity livingentity, int i) {
+- this.getItem().onUseTick(level, livingentity, this, i);
++ public void onUseTick(Level level, LivingEntity livingEntity, int count) {
++ this.getItem().onUseTick(level, livingEntity, this, count);
+ }
+
+- public void onDestroyed(ItemEntity itementity) {
+- this.getItem().onDestroyed(itementity);
++ public void onDestroyed(ItemEntity itemEntity) {
++ this.getItem().onDestroyed(itemEntity);
+ }
+
+ public boolean isEdible() {
+@@ -1027,13 +1295,13 @@
+ return this.getItem().getEatingSound();
+ }
+
+- public static enum TooltipPart {
++ public static enum HideFlags {
+
+ ENCHANTMENTS, MODIFIERS, UNBREAKABLE, CAN_DESTROY, CAN_PLACE, ADDITIONAL, DYE, UPGRADES;
+
+ private final int mask = 1 << this.ordinal();
+
+- private TooltipPart() {}
++ private HideFlags() {}
+
+ public int getMask() {
+ return this.mask;