2021-03-15 23:00:00 +01:00
--- a/net/minecraft/world/item/ItemStack.java
+++ b/net/minecraft/world/item/ItemStack.java
2024-04-23 17:15:00 +02:00
@@ -92,6 +92,40 @@
import org.apache.commons.lang3.mutable.MutableBoolean;
2022-02-28 16:00:00 +01:00
import org.slf4j.Logger;
2014-11-25 22:32:16 +01:00
+// CraftBukkit start
2015-03-16 10:48:01 +01:00
+import java.util.Map;
2021-11-21 23:00:00 +01:00
+import java.util.Objects;
2021-03-15 23:00:00 +01:00
+import net.minecraft.core.EnumDirection;
+import net.minecraft.nbt.DynamicOpsNBT;
+import net.minecraft.network.protocol.game.PacketPlayOutBlockChange;
+import net.minecraft.server.level.WorldServer;
+import net.minecraft.sounds.SoundCategory;
2023-04-07 10:56:58 +02:00
+import net.minecraft.world.level.block.BlockBed;
+import net.minecraft.world.level.block.Blocks;
2021-03-15 23:00:00 +01:00
+import net.minecraft.world.level.block.BlockSapling;
2023-06-07 17:30:00 +02:00
+import net.minecraft.world.level.block.BlockSign;
2021-03-15 23:00:00 +01:00
+import net.minecraft.world.level.block.BlockTileEntity;
+import net.minecraft.world.level.block.BlockWitherSkull;
+import net.minecraft.world.level.block.SoundEffectType;
+import net.minecraft.world.level.block.entity.TileEntity;
2023-03-14 17:30:00 +01:00
+import net.minecraft.world.level.block.entity.TileEntityJukeBox;
2021-03-15 23:00:00 +01:00
+import net.minecraft.world.level.block.entity.TileEntitySign;
+import net.minecraft.world.level.block.entity.TileEntitySkull;
2023-03-14 17:30:00 +01:00
+import net.minecraft.world.level.gameevent.GameEvent;
2014-11-25 22:32:16 +01:00
+import org.bukkit.Location;
+import org.bukkit.TreeType;
+import org.bukkit.block.BlockState;
2024-01-27 04:59:22 +01:00
+import org.bukkit.craftbukkit.block.CapturedBlockState;
2018-07-26 12:44:09 +02:00
+import org.bukkit.craftbukkit.block.CraftBlock;
2014-11-25 22:32:16 +01:00
+import org.bukkit.craftbukkit.block.CraftBlockState;
2018-12-25 22:00:00 +01:00
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
2023-04-19 11:59:19 +02:00
+import org.bukkit.craftbukkit.util.CraftLocation;
2014-11-25 22:32:16 +01:00
+import org.bukkit.entity.Player;
2018-07-26 12:44:09 +02:00
+import org.bukkit.event.block.BlockFertilizeEvent;
2018-12-25 22:00:00 +01:00
+import org.bukkit.event.player.PlayerItemDamageEvent;
2014-11-25 22:32:16 +01:00
+import org.bukkit.event.world.StructureGrowEvent;
+// CraftBukkit end
+
2024-04-23 17:15:00 +02:00
public final class ItemStack implements DataComponentHolder {
2014-11-25 22:32:16 +01:00
2024-04-23 17:15:00 +02:00
public static final Codec<Holder<Item>> ITEM_NON_AIR_CODEC = BuiltInRegistries.ITEM.holderByNameCodec().validate((holder) -> {
@@ -100,14 +134,14 @@
}) : DataResult.success(holder);
});
public static final Codec<ItemStack> CODEC = Codec.lazyInitialized(() -> {
- return RecordCodecBuilder.create((instance) -> {
+ return RecordCodecBuilder.<ItemStack>create((instance) -> { // CraftBukkit - decompile error
return instance.group(ItemStack.ITEM_NON_AIR_CODEC.fieldOf("id").forGetter(ItemStack::getItemHolder), ExtraCodecs.POSITIVE_INT.fieldOf("count").orElse(1).forGetter(ItemStack::getCount), DataComponentPatch.CODEC.optionalFieldOf("components", DataComponentPatch.EMPTY).forGetter((itemstack) -> {
return itemstack.components.asPatch();
})).apply(instance, ItemStack::new);
});
});
public static final Codec<ItemStack> SINGLE_ITEM_CODEC = Codec.lazyInitialized(() -> {
- return RecordCodecBuilder.create((instance) -> {
+ return RecordCodecBuilder.<ItemStack>create((instance) -> { // CraftBukkit - decompile error
return instance.group(ItemStack.ITEM_NON_AIR_CODEC.fieldOf("id").forGetter(ItemStack::getItemHolder), DataComponentPatch.CODEC.optionalFieldOf("components", DataComponentPatch.EMPTY).forGetter((itemstack) -> {
return itemstack.components.asPatch();
})).apply(instance, (holder, datacomponentpatch) -> {
@@ -132,19 +166,25 @@
if (i <= 0) {
return ItemStack.EMPTY;
} else {
- Holder<Item> holder = (Holder) null.ITEM_STREAM_CODEC.decode(registryfriendlybytebuf);
+ Holder<Item> holder = (Holder) ITEM_STREAM_CODEC.decode(registryfriendlybytebuf); // CraftBukkit - decompile error
DataComponentPatch datacomponentpatch = (DataComponentPatch) DataComponentPatch.STREAM_CODEC.decode(registryfriendlybytebuf);
2016-11-17 02:41:03 +01:00
2024-04-23 17:15:00 +02:00
- return new ItemStack(holder, i, datacomponentpatch);
+ // CraftBukkit start
+ ItemStack itemstack = new ItemStack(holder, i, datacomponentpatch);
+ if (!datacomponentpatch.isEmpty()) {
+ CraftItemStack.setItemMeta(itemstack, CraftItemStack.getItemMeta(itemstack));
+ }
+ return itemstack;
+ // CraftBukkit end
}
}
2023-06-07 17:30:00 +02:00
2024-04-23 17:15:00 +02:00
public void encode(RegistryFriendlyByteBuf registryfriendlybytebuf, ItemStack itemstack) {
- if (itemstack.isEmpty()) {
+ if (itemstack.isEmpty() || itemstack.getItem() == null) { // CraftBukkit - NPE fix itemstack.getItem()
registryfriendlybytebuf.writeVarInt(0);
} else {
registryfriendlybytebuf.writeVarInt(itemstack.getCount());
- null.ITEM_STREAM_CODEC.encode(registryfriendlybytebuf, itemstack.getItemHolder());
+ ITEM_STREAM_CODEC.encode(registryfriendlybytebuf, itemstack.getItemHolder()); // CraftBukkit - decompile error
DataComponentPatch.STREAM_CODEC.encode(registryfriendlybytebuf, itemstack.components.asPatch());
}
}
@@ -188,7 +228,7 @@
2015-02-26 23:41:06 +01:00
2024-04-23 17:15:00 +02:00
return dataresult.isError() ? dataresult.map((unit) -> {
return itemstack;
- }) : (itemstack.getCount() > itemstack.getMaxStackSize() ? DataResult.error(() -> {
+ }) : (itemstack.getCount() > itemstack.getMaxStackSize() ? DataResult.<ItemStack>error(() -> { // CraftBukkit - decompile error
int i = itemstack.getCount();
return "Item stack with stack size of " + i + " was larger than maximum: " + itemstack.getMaxStackSize();
@@ -347,11 +387,191 @@
2018-07-15 02:00:00 +02:00
return EnumInteractionResult.PASS;
} else {
2023-07-29 02:06:05 +02:00
Item item = this.getItem();
- EnumInteractionResult enuminteractionresult = item.useOn(itemactioncontext);
2018-07-15 02:00:00 +02:00
+ // CraftBukkit start - handle all block place event logic here
2024-06-10 06:06:36 +02:00
+ DataComponentPatch oldData = this.components.asPatch();
2018-07-15 02:00:00 +02:00
+ int oldCount = this.getCount();
2021-11-21 23:00:00 +01:00
+ WorldServer world = (WorldServer) itemactioncontext.getLevel();
2018-07-15 02:00:00 +02:00
+
2023-07-29 02:06:05 +02:00
+ if (!(item instanceof ItemBucket || item instanceof SolidBucketItem)) { // if not bucket
2018-07-15 02:00:00 +02:00
+ world.captureBlockStates = true;
+ // special case bonemeal
2023-07-29 02:06:05 +02:00
+ if (item == Items.BONE_MEAL) {
2018-07-26 12:44:09 +02:00
+ world.captureTreeGeneration = true;
2014-11-25 22:32:16 +01:00
+ }
+ }
2023-07-29 02:06:05 +02:00
+ EnumInteractionResult enuminteractionresult;
+ try {
+ enuminteractionresult = item.useOn(itemactioncontext);
+ } finally {
+ world.captureBlockStates = false;
+ }
2024-06-10 06:06:36 +02:00
+ DataComponentPatch newData = this.components.asPatch();
2018-07-15 02:00:00 +02:00
+ int newCount = this.getCount();
+ this.setCount(oldCount);
2024-04-25 08:15:01 +02:00
+ this.restorePatch(oldData);
2021-11-21 23:00:00 +01:00
+ if (enuminteractionresult.consumesAction() && world.captureTreeGeneration && world.capturedBlockStates.size() > 0) {
2018-07-15 02:00:00 +02:00
+ world.captureTreeGeneration = false;
2023-04-19 11:59:19 +02:00
+ Location location = CraftLocation.toBukkit(blockposition, world.getWorld());
2018-07-15 02:00:00 +02:00
+ TreeType treeType = BlockSapling.treeType;
+ BlockSapling.treeType = null;
2023-01-31 09:44:37 +01:00
+ List<CraftBlockState> blocks = new java.util.ArrayList<>(world.capturedBlockStates.values());
2018-07-15 02:00:00 +02:00
+ world.capturedBlockStates.clear();
2018-07-26 12:44:09 +02:00
+ StructureGrowEvent structureEvent = null;
2018-07-15 02:00:00 +02:00
+ if (treeType != null) {
+ boolean isBonemeal = getItem() == Items.BONE_MEAL;
2023-01-31 09:44:37 +01:00
+ structureEvent = new StructureGrowEvent(location, treeType, isBonemeal, (Player) entityhuman.getBukkitEntity(), (List< BlockState>) (List<? extends BlockState>) blocks);
2018-07-26 12:44:09 +02:00
+ org.bukkit.Bukkit.getPluginManager().callEvent(structureEvent);
2014-11-25 22:32:16 +01:00
+ }
2018-07-26 12:44:09 +02:00
+
2023-01-31 09:44:37 +01:00
+ BlockFertilizeEvent fertilizeEvent = new BlockFertilizeEvent(CraftBlock.at(world, blockposition), (Player) entityhuman.getBukkitEntity(), (List< BlockState>) (List<? extends BlockState>) blocks);
2018-07-26 12:44:09 +02:00
+ fertilizeEvent.setCancelled(structureEvent != null && structureEvent.isCancelled());
+ org.bukkit.Bukkit.getPluginManager().callEvent(fertilizeEvent);
+
+ if (!fertilizeEvent.isCancelled()) {
2018-07-15 02:00:00 +02:00
+ // Change the stack to its new contents if it hasn't been tampered with.
2024-04-25 10:18:59 +02:00
+ if (this.getCount() == oldCount && Objects.equals(this.components.asPatch(), oldData)) {
2024-04-25 08:15:01 +02:00
+ this.restorePatch(newData);
2018-07-15 02:00:00 +02:00
+ this.setCount(newCount);
+ }
2023-01-31 09:44:37 +01:00
+ for (CraftBlockState blockstate : blocks) {
2024-01-27 04:59:22 +01:00
+ // SPIGOT-7572 - Move fix for SPIGOT-7248 to CapturedBlockState, to allow bees in bee nest
+ CapturedBlockState.setBlockState(blockstate);
2018-07-15 02:00:00 +02:00
+ }
2023-01-21 01:00:43 +01:00
+ entityhuman.awardStat(StatisticList.ITEM_USED.get(item)); // SPIGOT-7236 - award stat
2014-11-25 22:32:16 +01:00
+ }
+
2021-10-16 09:48:22 +02:00
+ ItemSign.openSign = null; // SPIGOT-6758 - Reset on early return
2018-07-15 02:00:00 +02:00
+ return enuminteractionresult;
2014-11-25 22:32:16 +01:00
+ }
2018-07-15 02:00:00 +02:00
+ world.captureTreeGeneration = false;
2024-04-23 17:15:00 +02:00
if (entityhuman != null && enuminteractionresult.indicateItemUse()) {
2021-11-21 23:00:00 +01:00
- entityhuman.awardStat(StatisticList.ITEM_USED.get(item));
2023-06-24 09:15:05 +02:00
+ EnumHand enumhand = itemactioncontext.getHand();
2018-07-15 02:00:00 +02:00
+ org.bukkit.event.block.BlockPlaceEvent placeEvent = null;
2020-01-27 23:48:28 +01:00
+ List<BlockState> blocks = new java.util.ArrayList<>(world.capturedBlockStates.values());
2018-07-15 02:00:00 +02:00
+ 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());
2016-11-23 23:30:01 +01:00
+ }
+
2018-07-15 02:00:00 +02:00
+ if (placeEvent != null && (placeEvent.isCancelled() || !placeEvent.canBuild())) {
+ enuminteractionresult = EnumInteractionResult.FAIL; // cancel placement
+ // PAIL: Remove this when MC-99075 fixed
+ placeEvent.getPlayer().updateInventory();
+ // revert back all captured blocks
2021-07-03 07:39:52 +02:00
+ world.preventPoiUpdated = true; // CraftBukkit - SPIGOT-5710
2018-07-15 02:00:00 +02:00
+ for (BlockState blockstate : blocks) {
+ blockstate.update(true, false);
+ }
2021-07-03 07:39:52 +02:00
+ world.preventPoiUpdated = false;
2018-08-03 03:34:26 +02:00
+
+ // Brute force all possible updates
+ BlockPosition placedPos = ((CraftBlock) placeEvent.getBlock()).getPosition();
+ for (EnumDirection dir : EnumDirection.values()) {
2021-11-21 23:00:00 +01:00
+ ((EntityPlayer) entityhuman).connection.send(new PacketPlayOutBlockChange(world, placedPos.relative(dir)));
2018-08-03 03:34:26 +02:00
+ }
2021-10-16 09:48:22 +02:00
+ ItemSign.openSign = null; // SPIGOT-6758 - Reset on early return
2018-07-15 02:00:00 +02:00
+ } else {
+ // Change the stack to its new contents if it hasn't been tampered with.
2024-04-25 10:18:59 +02:00
+ if (this.getCount() == oldCount && Objects.equals(this.components.asPatch(), oldData)) {
2024-04-25 08:15:01 +02:00
+ this.restorePatch(newData);
2018-07-15 02:00:00 +02:00
+ this.setCount(newCount);
+ }
2014-11-25 22:32:16 +01:00
+
2018-07-15 02:00:00 +02:00
+ for (Map.Entry<BlockPosition, TileEntity> e : world.capturedTileEntities.entrySet()) {
2021-11-21 23:00:00 +01:00
+ world.setBlockEntity(e.getValue());
2014-11-25 22:32:16 +01:00
+ }
+
2018-07-15 02:00:00 +02:00
+ for (BlockState blockstate : blocks) {
+ int updateFlag = ((CraftBlockState) blockstate).getFlag();
+ IBlockData oldBlock = ((CraftBlockState) blockstate).getHandle();
2018-12-22 01:32:11 +01:00
+ BlockPosition newblockposition = ((CraftBlockState) blockstate).getPosition();
2021-11-21 23:00:00 +01:00
+ IBlockData block = world.getBlockState(newblockposition);
2018-07-15 02:00:00 +02:00
+
+ if (!(block.getBlock() instanceof BlockTileEntity)) { // Containers get placed automatically
2024-04-23 17:15:00 +02:00
+ block.onPlace(world, newblockposition, oldBlock, true);
2018-07-15 02:00:00 +02:00
+ }
2015-02-02 22:55:33 +01:00
+
2021-11-21 23:00:00 +01:00
+ world.notifyAndUpdatePhysics(newblockposition, null, oldBlock, block, world.getBlockState(newblockposition), updateFlag, 512); // send null chunk as chunk.k() returns false by this point
2018-07-15 02:00:00 +02:00
+ }
2015-04-10 13:24:34 +02:00
+
2018-07-15 02:00:00 +02:00
+ // Special case juke boxes as they update their tile entity. Copied from ItemRecord.
+ // PAIL: checkme on updates.
+ if (this.item instanceof ItemRecord) {
2023-03-14 17:30:00 +01:00
+ TileEntity tileentity = world.getBlockEntity(blockposition);
+
+ if (tileentity instanceof TileEntityJukeBox) {
+ TileEntityJukeBox tileentityjukebox = (TileEntityJukeBox) tileentity;
+
+ // There can only be one
+ ItemStack record = this.copy();
+ if (!record.isEmpty()) {
+ record.setCount(1);
+ }
+
2023-12-05 17:40:00 +01:00
+ tileentityjukebox.setTheItem(record);
2023-03-14 17:30:00 +01:00
+ world.gameEvent(GameEvent.BLOCK_CHANGE, blockposition, GameEvent.a.of(entityhuman, world.getBlockState(blockposition)));
+ }
+
2021-11-21 23:00:00 +01:00
+ this.shrink(1);
+ entityhuman.awardStat(StatisticList.PLAY_RECORD);
2015-02-02 22:55:33 +01:00
+ }
2018-07-15 02:00:00 +02:00
+
+ if (this.item == Items.WITHER_SKELETON_SKULL) { // Special case skulls to allow wither spawns to be cancelled
2018-07-23 03:58:43 +02:00
+ BlockPosition bp = blockposition;
2023-06-07 17:30:00 +02:00
+ if (!world.getBlockState(blockposition).canBeReplaced()) {
+ if (!world.getBlockState(blockposition).isSolid()) {
2018-07-23 03:58:43 +02:00
+ bp = null;
+ } else {
2021-11-21 23:00:00 +01:00
+ bp = bp.relative(itemactioncontext.getClickedFace());
2018-07-23 03:58:43 +02:00
+ }
+ }
+ if (bp != null) {
2021-11-21 23:00:00 +01:00
+ TileEntity te = world.getBlockEntity(bp);
2018-07-23 03:58:43 +02:00
+ if (te instanceof TileEntitySkull) {
2021-11-21 23:00:00 +01:00
+ BlockWitherSkull.checkSpawn(world, bp, (TileEntitySkull) te);
2018-07-23 03:58:43 +02:00
+ }
2015-02-02 22:55:33 +01:00
+ }
+ }
+
2019-03-24 11:34:57 +01:00
+ // SPIGOT-4678
2019-04-25 01:55:41 +02:00
+ if (this.item instanceof ItemSign && ItemSign.openSign != null) {
+ try {
2023-06-08 00:03:24 +02:00
+ if (world.getBlockEntity(ItemSign.openSign) instanceof TileEntitySign tileentitysign) {
+ if (world.getBlockState(ItemSign.openSign).getBlock() instanceof BlockSign blocksign) {
2023-08-05 01:33:42 +02:00
+ blocksign.openTextEdit(entityhuman, tileentitysign, true, org.bukkit.event.player.PlayerSignOpenEvent.Cause.PLACE); // Craftbukkit
2023-06-07 17:30:00 +02:00
+ }
+ }
2019-04-25 01:55:41 +02:00
+ } finally {
+ ItemSign.openSign = null;
+ }
2019-03-24 11:34:57 +01:00
+ }
+
2023-04-07 10:56:58 +02:00
+ // SPIGOT-7315: Moved from BlockBed#setPlacedBy
+ if (placeEvent != null && this.item instanceof ItemBed) {
+ BlockPosition position = ((CraftBlock) placeEvent.getBlock()).getPosition();
+ IBlockData blockData = world.getBlockState(position);
+
+ if (blockData.getBlock() instanceof BlockBed) {
+ world.blockUpdated(position, Blocks.AIR);
+ blockData.updateNeighbourShapes(world, position, 3);
+ }
+ }
+
2018-07-15 02:00:00 +02:00
+ // SPIGOT-1288 - play sound stripped from ItemBlock
+ if (this.item instanceof ItemBlock) {
2023-06-13 11:05:00 +02:00
+ SoundEffectType soundeffecttype = ((ItemBlock) this.item).getBlock().defaultBlockState().getSoundType(); // TODO: not strictly correct, however currently only affects decorated pots
2021-01-16 02:00:00 +01:00
+ world.playSound(entityhuman, blockposition, soundeffecttype.getPlaceSound(), SoundCategory.BLOCKS, (soundeffecttype.getVolume() + 1.0F) / 2.0F, soundeffecttype.getPitch() * 0.8F);
2018-07-15 02:00:00 +02:00
+ }
2016-06-30 07:39:58 +02:00
+
2021-11-21 23:00:00 +01:00
+ entityhuman.awardStat(StatisticList.ITEM_USED.get(item));
2018-07-15 02:00:00 +02:00
+ }
}
+ world.capturedTileEntities.clear();
+ world.capturedBlockStates.clear();
+ // CraftBukkit end
2014-11-25 22:32:16 +01:00
2018-07-15 02:00:00 +02:00
return enuminteractionresult;
}
2024-04-23 17:15:00 +02:00
@@ -432,6 +652,21 @@
2018-12-25 22:00:00 +01:00
}
i -= k;
+ // CraftBukkit start
+ if (entityplayer != null) {
+ PlayerItemDamageEvent event = new PlayerItemDamageEvent(entityplayer.getBukkitEntity(), CraftItemStack.asCraftMirror(this), i);
+ event.getPlayer().getServer().getPluginManager().callEvent(event);
+
+ if (i != event.getDamage() || event.isCancelled()) {
+ event.getPlayer().updateInventory();
+ }
+ if (event.isCancelled()) {
2024-04-23 17:15:00 +02:00
+ return;
2018-12-25 22:00:00 +01:00
+ }
+
+ i = event.getDamage();
+ }
+ // CraftBukkit end
if (i <= 0) {
2024-04-23 17:15:00 +02:00
return;
2018-12-25 22:00:00 +01:00
}
2024-04-23 17:15:00 +02:00
@@ -474,6 +709,11 @@
this.hurtAndBreak(i, randomsource, entityplayer, () -> {
entityliving.broadcastBreakEvent(enumitemslot);
Item item = this.getItem();
+ // CraftBukkit start - Check for item breaking
+ if (this.count == 1 && entityliving instanceof EntityHuman) {
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerItemBreakEvent((EntityHuman) entityliving, this);
+ }
+ // CraftBukkit end
2018-07-15 02:00:00 +02:00
2024-04-23 17:15:00 +02:00
this.shrink(1);
if (entityliving instanceof EntityHuman) {
2024-04-25 08:15:01 +02:00
@@ -669,6 +909,12 @@
2024-04-23 17:15:00 +02:00
return this.getItem().useOnRelease(this);
2018-12-22 01:25:14 +01:00
}
+ // CraftBukkit start
2024-04-25 08:15:01 +02:00
+ public void restorePatch(DataComponentPatch datacomponentpatch) {
+ this.components.restorePatch(datacomponentpatch);
2018-12-22 01:25:14 +01:00
+ }
+ // CraftBukkit end
+
2024-04-23 17:15:00 +02:00
@Nullable
public <T> T set(DataComponentType<? super T> datacomponenttype, @Nullable T t0) {
return this.components.set(datacomponenttype, t0);
2024-04-25 08:15:01 +02:00
@@ -728,7 +974,7 @@
2024-04-23 17:15:00 +02:00
}
private <T extends TooltipProvider> void addToTooltip(DataComponentType<T> datacomponenttype, Item.b item_b, Consumer<IChatBaseComponent> consumer, TooltipFlag tooltipflag) {
- T t0 = (TooltipProvider) this.get(datacomponenttype);
+ T t0 = (T) this.get(datacomponenttype); // CraftBukkit - decompile error
if (t0 != null) {
t0.addToTooltip(item_b, consumer, tooltipflag);
2024-04-25 08:15:01 +02:00
@@ -955,6 +1201,13 @@
2024-04-23 17:15:00 +02:00
2014-11-25 22:32:16 +01:00
}
2018-07-15 02:00:00 +02:00
+ // CraftBukkit start
2016-11-17 02:41:03 +01:00
+ @Deprecated
+ public void setItem(Item item) {
+ this.item = item;
+ }
2018-07-15 02:00:00 +02:00
+ // CraftBukkit end
2016-11-17 02:41:03 +01:00
+
2021-11-21 23:00:00 +01:00
public IChatBaseComponent getDisplayName() {
2022-06-07 18:00:00 +02:00
IChatMutableComponent ichatmutablecomponent = IChatBaseComponent.empty().append(this.getHoverName());
2016-11-17 02:41:03 +01:00
2024-04-25 08:15:01 +02:00
@@ -1017,7 +1270,7 @@
2024-04-23 17:15:00 +02:00
}
public void consume(int i, @Nullable EntityLiving entityliving) {
- if (entityliving == null || !entityliving.hasInfiniteMaterials()) {
+ if ((entityliving == null || !entityliving.hasInfiniteMaterials()) && this != ItemStack.EMPTY) { // CraftBukkit
this.shrink(i);
}