@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/item/ItemArmor.java
|
||||
+++ b/net/minecraft/world/item/ItemArmor.java
|
||||
@@ -27,6 +27,12 @@
|
||||
@@ -31,6 +31,12 @@
|
||||
import net.minecraft.world.level.block.BlockDispenser;
|
||||
import net.minecraft.world.phys.AxisAlignedBB;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
public class ItemArmor extends Item implements Equipable {
|
||||
|
||||
private static final EnumMap<ItemArmor.a, UUID> ARMOR_MODIFIER_UUID_PER_TYPE = (EnumMap) SystemUtils.make(new EnumMap(ItemArmor.a.class), (enummap) -> {
|
||||
@@ -58,8 +64,34 @@
|
||||
@@ -60,8 +66,34 @@
|
||||
EntityLiving entityliving = (EntityLiving) list.get(0);
|
||||
EnumItemSlot enumitemslot = EntityInsentient.getEquipmentSlotForItem(itemstack);
|
||||
ItemStack itemstack1 = itemstack.split(1);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/item/ItemBlock.java
|
||||
+++ b/net/minecraft/world/item/ItemBlock.java
|
||||
@@ -33,6 +33,13 @@
|
||||
@@ -32,6 +32,13 @@
|
||||
import net.minecraft.world.level.gameevent.GameEvent;
|
||||
import net.minecraft.world.phys.shapes.VoxelShapeCollision;
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
+
|
||||
public class ItemBlock extends Item {
|
||||
|
||||
public static final String BLOCK_ENTITY_TAG = "BlockEntityTag";
|
||||
@@ -71,6 +78,12 @@
|
||||
/** @deprecated */
|
||||
@@ -68,6 +75,12 @@
|
||||
return EnumInteractionResult.FAIL;
|
||||
} else {
|
||||
IBlockData iblockdata = this.getPlacementState(blockactioncontext1);
|
||||
@@ -27,9 +27,9 @@
|
||||
|
||||
if (iblockdata == null) {
|
||||
return EnumInteractionResult.FAIL;
|
||||
@@ -87,6 +100,19 @@
|
||||
iblockdata1 = this.updateBlockStateFromTag(blockposition, world, itemstack, iblockdata1);
|
||||
@@ -85,6 +98,19 @@
|
||||
this.updateCustomBlockEntityTag(blockposition, world, entityhuman, itemstack, iblockdata1);
|
||||
updateBlockEntityComponents(world, blockposition, itemstack);
|
||||
iblockdata1.getBlock().setPlacedBy(world, blockposition, iblockdata1, entityhuman, itemstack);
|
||||
+ // CraftBukkit start
|
||||
+ if (blockstate != null) {
|
||||
@@ -47,53 +47,16 @@
|
||||
if (entityhuman instanceof EntityPlayer) {
|
||||
CriterionTriggers.PLACED_BLOCK.trigger((EntityPlayer) entityhuman, blockposition, itemstack);
|
||||
}
|
||||
@@ -94,9 +120,9 @@
|
||||
@@ -92,7 +118,7 @@
|
||||
|
||||
SoundEffectType soundeffecttype = iblockdata1.getSoundType();
|
||||
|
||||
- world.playSound(entityhuman, blockposition, this.getPlaceSound(iblockdata1), SoundCategory.BLOCKS, (soundeffecttype.getVolume() + 1.0F) / 2.0F, soundeffecttype.getPitch() * 0.8F);
|
||||
+ // world.playSound(entityhuman, blockposition, this.getPlaceSound(iblockdata1), SoundCategory.BLOCKS, (soundeffecttype.getVolume() + 1.0F) / 2.0F, soundeffecttype.getPitch() * 0.8F);
|
||||
world.gameEvent(GameEvent.BLOCK_PLACE, blockposition, GameEvent.a.of(entityhuman, iblockdata1));
|
||||
- if (entityhuman == null || !entityhuman.getAbilities().instabuild) {
|
||||
+ if ((entityhuman == null || !entityhuman.getAbilities().instabuild) && itemstack != ItemStack.EMPTY) { // CraftBukkit
|
||||
itemstack.shrink(1);
|
||||
}
|
||||
|
||||
@@ -132,6 +158,21 @@
|
||||
|
||||
if (nbttagcompound != null) {
|
||||
NBTTagCompound nbttagcompound1 = nbttagcompound.getCompound("BlockStateTag");
|
||||
+ // CraftBukkit start
|
||||
+ iblockdata1 = getBlockState(iblockdata1, nbttagcompound1);
|
||||
+ }
|
||||
+
|
||||
+ if (iblockdata1 != iblockdata) {
|
||||
+ world.setBlock(blockposition, iblockdata1, 2);
|
||||
+ }
|
||||
+
|
||||
+ return iblockdata1;
|
||||
+ }
|
||||
+
|
||||
+ public static IBlockData getBlockState(IBlockData iblockdata, NBTTagCompound nbttagcompound1) {
|
||||
+ IBlockData iblockdata1 = iblockdata;
|
||||
+ {
|
||||
+ // CraftBukkit end
|
||||
BlockStateList<Block, IBlockData> blockstatelist = iblockdata.getBlock().getStateDefinition();
|
||||
Iterator iterator = nbttagcompound1.getAllKeys().iterator();
|
||||
|
||||
@@ -146,11 +187,6 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
-
|
||||
- if (iblockdata1 != iblockdata) {
|
||||
- world.setBlock(blockposition, iblockdata1, 2);
|
||||
- }
|
||||
-
|
||||
return iblockdata1;
|
||||
}
|
||||
|
||||
@@ -163,8 +199,15 @@
|
||||
world.gameEvent((Holder) GameEvent.BLOCK_PLACE, blockposition, GameEvent.a.of(entityhuman, iblockdata1));
|
||||
itemstack.consume(1, entityhuman);
|
||||
return EnumInteractionResult.sidedSuccess(world.isClientSide);
|
||||
@@ -150,8 +176,15 @@
|
||||
protected boolean canPlace(BlockActionContext blockactioncontext, IBlockData iblockdata) {
|
||||
EntityHuman entityhuman = blockactioncontext.getPlayer();
|
||||
VoxelShapeCollision voxelshapecollision = entityhuman == null ? VoxelShapeCollision.empty() : VoxelShapeCollision.of(entityhuman);
|
||||
@@ -110,12 +73,3 @@
|
||||
}
|
||||
|
||||
protected boolean mustSurvive() {
|
||||
@@ -239,7 +282,7 @@
|
||||
|
||||
if (nbttagcompound != null && nbttagcompound.contains("Items", 9)) {
|
||||
NBTTagList nbttaglist = nbttagcompound.getList("Items", 10);
|
||||
- Stream stream = nbttaglist.stream();
|
||||
+ Stream<net.minecraft.nbt.NBTBase> stream = nbttaglist.stream(); // CraftBukkit - decompile error
|
||||
|
||||
Objects.requireNonNull(NBTTagCompound.class);
|
||||
ItemLiquidUtil.onContainerDestroyed(entityitem, stream.map(NBTTagCompound.class::cast).map(ItemStack::of));
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/item/ItemBoat.java
|
||||
+++ b/net/minecraft/world/item/ItemBoat.java
|
||||
@@ -60,6 +60,13 @@
|
||||
@@ -61,6 +61,13 @@
|
||||
}
|
||||
|
||||
if (movingobjectpositionblock.getType() == MovingObjectPosition.EnumMovingObjectType.BLOCK) {
|
||||
@@ -14,7 +14,7 @@
|
||||
EntityBoat entityboat = this.getBoat(world, movingobjectpositionblock, itemstack, entityhuman);
|
||||
|
||||
entityboat.setVariant(this.type);
|
||||
@@ -68,7 +75,15 @@
|
||||
@@ -69,7 +76,15 @@
|
||||
return InteractionResultWrapper.fail(itemstack);
|
||||
} else {
|
||||
if (!world.isClientSide) {
|
||||
@@ -28,15 +28,15 @@
|
||||
+ return InteractionResultWrapper.pass(itemstack);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
world.gameEvent((Entity) entityhuman, GameEvent.ENTITY_PLACE, movingobjectpositionblock.getLocation());
|
||||
if (!entityhuman.getAbilities().instabuild) {
|
||||
itemstack.shrink(1);
|
||||
@@ -86,7 +101,7 @@
|
||||
world.gameEvent((Entity) entityhuman, (Holder) GameEvent.ENTITY_PLACE, movingobjectpositionblock.getLocation());
|
||||
itemstack.consume(1, entityhuman);
|
||||
}
|
||||
@@ -85,7 +100,7 @@
|
||||
|
||||
private EntityBoat getBoat(World world, MovingObjectPosition movingobjectposition, ItemStack itemstack, EntityHuman entityhuman) {
|
||||
Vec3D vec3d = movingobjectposition.getLocation();
|
||||
- Object object = this.hasChest ? new ChestBoat(world, vec3d.x, vec3d.y, vec3d.z) : new EntityBoat(world, vec3d.x, vec3d.y, vec3d.z);
|
||||
+ EntityBoat object = this.hasChest ? new ChestBoat(world, vec3d.x, vec3d.y, vec3d.z) : new EntityBoat(world, vec3d.x, vec3d.y, vec3d.z); // CraftBukkit - decompile error
|
||||
|
||||
if (world instanceof WorldServer) {
|
||||
WorldServer worldserver = (WorldServer) world;
|
||||
if (world instanceof WorldServer worldserver) {
|
||||
EntityTypes.createDefaultStackConfig(worldserver, itemstack, entityhuman).accept(object);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/item/ItemBoneMeal.java
|
||||
+++ b/net/minecraft/world/item/ItemBoneMeal.java
|
||||
@@ -34,13 +34,19 @@
|
||||
@@ -35,13 +35,19 @@
|
||||
|
||||
@Override
|
||||
public EnumInteractionResult useOn(ItemActionContext itemactioncontext) {
|
||||
@@ -18,15 +18,15 @@
|
||||
if (!world.isClientSide) {
|
||||
- itemactioncontext.getPlayer().gameEvent(GameEvent.ITEM_INTERACT_FINISH);
|
||||
+ if (itemactioncontext.getPlayer() != null) itemactioncontext.getPlayer().gameEvent(GameEvent.ITEM_INTERACT_FINISH); // CraftBukkit - SPIGOT-7518
|
||||
world.levelEvent(1505, blockposition, 0);
|
||||
world.levelEvent(1505, blockposition, 15);
|
||||
}
|
||||
|
||||
@@ -51,7 +57,7 @@
|
||||
@@ -52,7 +58,7 @@
|
||||
|
||||
if (flag && growWaterPlant(itemactioncontext.getItemInHand(), world, blockposition1, itemactioncontext.getClickedFace())) {
|
||||
if (!world.isClientSide) {
|
||||
- itemactioncontext.getPlayer().gameEvent(GameEvent.ITEM_INTERACT_FINISH);
|
||||
+ if (itemactioncontext.getPlayer() != null) itemactioncontext.getPlayer().gameEvent(GameEvent.ITEM_INTERACT_FINISH); // CraftBukkit - SPIGOT-7518
|
||||
world.levelEvent(1505, blockposition1, 0);
|
||||
world.levelEvent(1505, blockposition1, 15);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
--- a/net/minecraft/world/item/ItemBow.java
|
||||
+++ b/net/minecraft/world/item/ItemBow.java
|
||||
@@ -64,6 +64,14 @@
|
||||
if (EnchantmentManager.getItemEnchantmentLevel(Enchantments.FLAMING_ARROWS, itemstack) > 0) {
|
||||
entityarrow.setSecondsOnFire(100);
|
||||
}
|
||||
+ // CraftBukkit start
|
||||
+ org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(entityhuman, itemstack, itemstack1, entityarrow, entityhuman.getUsedItemHand(), f, !flag1);
|
||||
+ if (event.isCancelled()) {
|
||||
+ event.getProjectile().remove();
|
||||
+ return;
|
||||
+ }
|
||||
+ flag1 = !event.shouldConsumeItem();
|
||||
+ // CraftBukkit end
|
||||
|
||||
itemstack.hurtAndBreak(1, entityhuman, (entityhuman1) -> {
|
||||
entityhuman1.broadcastBreakEvent(entityhuman.getUsedItemHand());
|
||||
@@ -72,7 +80,16 @@
|
||||
entityarrow.pickup = EntityArrow.PickupStatus.CREATIVE_ONLY;
|
||||
}
|
||||
|
||||
- world.addFreshEntity(entityarrow);
|
||||
+ // CraftBukkit start
|
||||
+ if (event.getProjectile() == entityarrow.getBukkitEntity()) {
|
||||
+ if (!world.addFreshEntity(entityarrow)) {
|
||||
+ if (entityhuman instanceof net.minecraft.server.level.EntityPlayer) {
|
||||
+ ((net.minecraft.server.level.EntityPlayer) entityhuman).getBukkitEntity().updateInventory();
|
||||
+ }
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
world.playSound((EntityHuman) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.ARROW_SHOOT, SoundCategory.PLAYERS, 1.0F, 1.0F / (world.getRandom().nextFloat() * 0.4F + 1.2F) + f * 0.5F);
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/item/ItemBucket.java
|
||||
+++ b/net/minecraft/world/item/ItemBucket.java
|
||||
@@ -29,6 +29,16 @@
|
||||
@@ -30,6 +30,16 @@
|
||||
import net.minecraft.world.phys.MovingObjectPosition;
|
||||
import net.minecraft.world.phys.MovingObjectPositionBlock;
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
public class ItemBucket extends Item implements DispensibleContainerItem {
|
||||
|
||||
public final FluidType content;
|
||||
@@ -61,6 +71,17 @@
|
||||
@@ -62,6 +72,17 @@
|
||||
|
||||
if (block instanceof IFluidSource) {
|
||||
IFluidSource ifluidsource = (IFluidSource) block;
|
||||
@@ -35,16 +35,16 @@
|
||||
ItemStack itemstack1 = ifluidsource.pickupBlock(entityhuman, world, blockposition, iblockdata);
|
||||
|
||||
if (!itemstack1.isEmpty()) {
|
||||
@@ -69,7 +90,7 @@
|
||||
@@ -70,7 +91,7 @@
|
||||
entityhuman.playSound(soundeffect, 1.0F, 1.0F);
|
||||
});
|
||||
world.gameEvent((Entity) entityhuman, GameEvent.FLUID_PICKUP, blockposition);
|
||||
world.gameEvent((Entity) entityhuman, (Holder) GameEvent.FLUID_PICKUP, blockposition);
|
||||
- ItemStack itemstack2 = ItemLiquidUtil.createFilledResult(itemstack, entityhuman, itemstack1);
|
||||
+ ItemStack itemstack2 = ItemLiquidUtil.createFilledResult(itemstack, entityhuman, CraftItemStack.asNMSCopy(event.getItemStack())); // CraftBukkit
|
||||
|
||||
if (!world.isClientSide) {
|
||||
CriterionTriggers.FILLED_BUCKET.trigger((EntityPlayer) entityhuman, itemstack1);
|
||||
@@ -84,7 +105,7 @@
|
||||
@@ -85,7 +106,7 @@
|
||||
iblockdata = world.getBlockState(blockposition);
|
||||
BlockPosition blockposition2 = iblockdata.getBlock() instanceof IFluidContainer && this.content == FluidTypes.WATER ? blockposition : blockposition1;
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
this.checkExtraContent(entityhuman, world, itemstack, blockposition2);
|
||||
if (entityhuman instanceof EntityPlayer) {
|
||||
CriterionTriggers.PLACED_BLOCK.trigger((EntityPlayer) entityhuman, blockposition2, itemstack);
|
||||
@@ -111,6 +132,12 @@
|
||||
@@ -112,6 +133,12 @@
|
||||
|
||||
@Override
|
||||
public boolean emptyContents(@Nullable EntityHuman entityhuman, World world, BlockPosition blockposition, @Nullable MovingObjectPositionBlock movingobjectpositionblock) {
|
||||
@@ -65,8 +65,8 @@
|
||||
+ // CraftBukkit end
|
||||
FluidType fluidtype = this.content;
|
||||
|
||||
if (!(fluidtype instanceof FluidTypeFlowing)) {
|
||||
@@ -148,8 +175,18 @@
|
||||
if (!(fluidtype instanceof FluidTypeFlowing fluidtypeflowing)) {
|
||||
@@ -147,8 +174,18 @@
|
||||
|
||||
boolean flag2 = flag1;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/item/ItemChorusFruit.java
|
||||
+++ b/net/minecraft/world/item/ItemChorusFruit.java
|
||||
@@ -35,7 +35,16 @@
|
||||
@@ -36,7 +36,16 @@
|
||||
|
||||
Vec3D vec3d = entityliving.position();
|
||||
|
||||
@@ -15,6 +15,6 @@
|
||||
+
|
||||
+ if (status.get()) {
|
||||
+ // CraftBukkit end
|
||||
world.gameEvent(GameEvent.TELEPORT, vec3d, GameEvent.a.of((Entity) entityliving));
|
||||
world.gameEvent((Holder) GameEvent.TELEPORT, vec3d, GameEvent.a.of((Entity) entityliving));
|
||||
SoundEffect soundeffect;
|
||||
SoundCategory soundcategory;
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
--- a/net/minecraft/world/item/ItemCrossbow.java
|
||||
+++ b/net/minecraft/world/item/ItemCrossbow.java
|
||||
@@ -236,11 +236,27 @@
|
||||
|
||||
((IProjectile) object).shoot((double) vector3f.x(), (double) vector3f.y(), (double) vector3f.z(), f1, f2);
|
||||
}
|
||||
+ // CraftBukkit start
|
||||
+ org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(entityliving, itemstack, itemstack1, (Entity) object, entityliving.getUsedItemHand(), f, true);
|
||||
+ if (event.isCancelled()) {
|
||||
+ event.getProjectile().remove();
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
itemstack.hurtAndBreak(flag1 ? 3 : 1, entityliving, (entityliving1) -> {
|
||||
entityliving1.broadcastBreakEvent(enumhand);
|
||||
});
|
||||
- world.addFreshEntity((Entity) object);
|
||||
+ // CraftBukkit start
|
||||
+ if (event.getProjectile() == ((Entity) object).getBukkitEntity()) {
|
||||
+ if (!world.addFreshEntity((Entity) object)) {
|
||||
+ if (entityliving instanceof EntityPlayer) {
|
||||
+ ((EntityPlayer) entityliving).getBukkitEntity().updateInventory();
|
||||
+ }
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
world.playSound((EntityHuman) null, entityliving.getX(), entityliving.getY(), entityliving.getZ(), SoundEffects.CROSSBOW_SHOOT, SoundCategory.PLAYERS, 1.0F, f);
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@
|
||||
package net.minecraft.world.item;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -95,7 +96,7 @@
|
||||
@@ -92,7 +93,7 @@
|
||||
}
|
||||
|
||||
private static <T extends Comparable<T>> IBlockData cycleState(IBlockData iblockdata, IBlockState<T> iblockstate, boolean flag) {
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
public class ItemDye extends Item implements SignApplicator {
|
||||
|
||||
private static final Map<EnumColor, ItemDye> ITEM_BY_COLOR = Maps.newEnumMap(EnumColor.class);
|
||||
@@ -32,7 +34,17 @@
|
||||
@@ -30,7 +32,17 @@
|
||||
if (entitysheep.isAlive() && !entitysheep.isSheared() && entitysheep.getColor() != this.dyeColor) {
|
||||
entitysheep.level().playSound(entityhuman, (Entity) entitysheep, SoundEffects.DYE_USE, SoundCategory.PLAYERS, 1.0F, 1.0F);
|
||||
if (!entityhuman.level().isClientSide) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/item/ItemEgg.java
|
||||
+++ b/net/minecraft/world/item/ItemEgg.java
|
||||
@@ -19,14 +19,22 @@
|
||||
@@ -22,14 +22,22 @@
|
||||
public InteractionResultWrapper<ItemStack> use(World world, EntityHuman entityhuman, EnumHand enumhand) {
|
||||
ItemStack itemstack = entityhuman.getItemInHand(enumhand);
|
||||
|
||||
@@ -24,4 +24,4 @@
|
||||
+ world.playSound((EntityHuman) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.EGG_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F));
|
||||
|
||||
entityhuman.awardStat(StatisticList.ITEM_USED.get(this));
|
||||
if (!entityhuman.getAbilities().instabuild) {
|
||||
itemstack.consume(1, entityhuman);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/item/ItemEndCrystal.java
|
||||
+++ b/net/minecraft/world/item/ItemEndCrystal.java
|
||||
@@ -46,6 +46,11 @@
|
||||
@@ -47,6 +47,11 @@
|
||||
EntityEnderCrystal entityendercrystal = new EntityEnderCrystal(world, d0 + 0.5D, d1, d2 + 0.5D);
|
||||
|
||||
entityendercrystal.setShowBottom(false);
|
||||
@@ -10,5 +10,5 @@
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
world.addFreshEntity(entityendercrystal);
|
||||
world.gameEvent((Entity) itemactioncontext.getPlayer(), GameEvent.ENTITY_PLACE, blockposition1);
|
||||
world.gameEvent((Entity) itemactioncontext.getPlayer(), (Holder) GameEvent.ENTITY_PLACE, blockposition1);
|
||||
EnderDragonBattle enderdragonbattle = ((WorldServer) world).getDragonFight();
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
--- a/net/minecraft/world/item/ItemEnderEye.java
|
||||
+++ b/net/minecraft/world/item/ItemEnderEye.java
|
||||
@@ -89,7 +89,11 @@
|
||||
@@ -95,7 +95,11 @@
|
||||
entityendersignal.setItem(itemstack);
|
||||
entityendersignal.signalTo(blockposition);
|
||||
world.gameEvent(GameEvent.PROJECTILE_SHOOT, entityendersignal.position(), GameEvent.a.of((Entity) entityhuman));
|
||||
world.gameEvent((Holder) GameEvent.PROJECTILE_SHOOT, entityendersignal.position(), GameEvent.a.of((Entity) entityhuman));
|
||||
- world.addFreshEntity(entityendersignal);
|
||||
+ // CraftBukkit start
|
||||
+ if (!world.addFreshEntity(entityendersignal)) {
|
||||
|
||||
@@ -26,5 +26,5 @@
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
entityhuman.awardStat(StatisticList.ITEM_USED.get(this));
|
||||
if (!entityhuman.getAbilities().instabuild) {
|
||||
itemstack.shrink(1);
|
||||
itemstack.consume(1, entityhuman);
|
||||
return InteractionResultWrapper.sidedSuccess(itemstack, world.isClientSide());
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/item/ItemFireball.java
|
||||
+++ b/net/minecraft/world/item/ItemFireball.java
|
||||
@@ -33,12 +33,28 @@
|
||||
@@ -40,12 +40,28 @@
|
||||
if (!BlockCampfire.canLight(iblockdata) && !CandleBlock.canLight(iblockdata) && !CandleCakeBlock.canLight(iblockdata)) {
|
||||
blockposition = blockposition.relative(itemactioncontext.getClickedFace());
|
||||
if (BlockFireAbstract.canBePlacedAt(world, blockposition, itemactioncontext.getHorizontalDirection())) {
|
||||
@@ -14,7 +14,7 @@
|
||||
+ // CraftBukkit end
|
||||
this.playSound(world, blockposition);
|
||||
world.setBlockAndUpdate(blockposition, BlockFireAbstract.getState(world, blockposition));
|
||||
world.gameEvent((Entity) itemactioncontext.getPlayer(), GameEvent.BLOCK_PLACE, blockposition);
|
||||
world.gameEvent((Entity) itemactioncontext.getPlayer(), (Holder) GameEvent.BLOCK_PLACE, blockposition);
|
||||
flag = true;
|
||||
}
|
||||
} else {
|
||||
@@ -28,4 +28,4 @@
|
||||
+ // CraftBukkit end
|
||||
this.playSound(world, blockposition);
|
||||
world.setBlockAndUpdate(blockposition, (IBlockData) iblockdata.setValue(BlockProperties.LIT, true));
|
||||
world.gameEvent((Entity) itemactioncontext.getPlayer(), GameEvent.BLOCK_CHANGE, blockposition);
|
||||
world.gameEvent((Entity) itemactioncontext.getPlayer(), (Holder) GameEvent.BLOCK_CHANGE, blockposition);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/item/ItemFishingRod.java
|
||||
+++ b/net/minecraft/world/item/ItemFishingRod.java
|
||||
@@ -11,6 +11,11 @@
|
||||
@@ -12,6 +12,11 @@
|
||||
import net.minecraft.world.level.World;
|
||||
import net.minecraft.world.level.gameevent.GameEvent;
|
||||
|
||||
@@ -9,10 +9,10 @@
|
||||
+import org.bukkit.craftbukkit.CraftEquipmentSlot;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class ItemFishingRod extends Item implements ItemVanishable {
|
||||
public class ItemFishingRod extends Item {
|
||||
|
||||
public ItemFishingRod(Item.Info item_info) {
|
||||
@@ -33,12 +38,23 @@
|
||||
@@ -32,12 +37,23 @@
|
||||
world.playSound((EntityHuman) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.FISHING_BOBBER_RETRIEVE, SoundCategory.NEUTRAL, 1.0F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F));
|
||||
entityhuman.gameEvent(GameEvent.ITEM_INTERACT_FINISH);
|
||||
} else {
|
||||
|
||||
@@ -1,32 +1,28 @@
|
||||
--- a/net/minecraft/world/item/ItemFlintAndSteel.java
|
||||
+++ b/net/minecraft/world/item/ItemFlintAndSteel.java
|
||||
@@ -35,6 +35,14 @@
|
||||
@@ -37,6 +37,12 @@
|
||||
BlockPosition blockposition1 = blockposition.relative(itemactioncontext.getClickedFace());
|
||||
|
||||
if (BlockFireAbstract.canBePlacedAt(world, blockposition1, itemactioncontext.getHorizontalDirection())) {
|
||||
+ // CraftBukkit start - Store the clicked block
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition1, org.bukkit.event.block.BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL, entityhuman).isCancelled()) {
|
||||
+ itemactioncontext.getItemInHand().hurtAndBreak(1, entityhuman, (entityhuman1) -> {
|
||||
+ entityhuman1.broadcastBreakEvent(itemactioncontext.getHand());
|
||||
+ });
|
||||
+ itemactioncontext.getItemInHand().hurtAndBreak(1, entityhuman, EntityLiving.getSlotForHand(itemactioncontext.getHand()));
|
||||
+ return EnumInteractionResult.PASS;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
world.playSound(entityhuman, blockposition1, SoundEffects.FLINTANDSTEEL_USE, SoundCategory.BLOCKS, 1.0F, world.getRandom().nextFloat() * 0.4F + 0.8F);
|
||||
IBlockData iblockdata1 = BlockFireAbstract.getState(world, blockposition1);
|
||||
|
||||
@@ -54,6 +62,14 @@
|
||||
@@ -54,6 +60,12 @@
|
||||
return EnumInteractionResult.FAIL;
|
||||
}
|
||||
} else {
|
||||
+ // CraftBukkit start - Store the clicked block
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition, org.bukkit.event.block.BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL, entityhuman).isCancelled()) {
|
||||
+ itemactioncontext.getItemInHand().hurtAndBreak(1, entityhuman, (entityhuman1) -> {
|
||||
+ entityhuman1.broadcastBreakEvent(itemactioncontext.getHand());
|
||||
+ });
|
||||
+ itemactioncontext.getItemInHand().hurtAndBreak(1, entityhuman, EntityLiving.getSlotForHand(itemactioncontext.getHand()));
|
||||
+ return EnumInteractionResult.PASS;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
world.playSound(entityhuman, blockposition, SoundEffects.FLINTANDSTEEL_USE, SoundCategory.BLOCKS, 1.0F, world.getRandom().nextFloat() * 0.4F + 0.8F);
|
||||
world.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockProperties.LIT, true), 11);
|
||||
world.gameEvent((Entity) entityhuman, GameEvent.BLOCK_CHANGE, blockposition);
|
||||
world.gameEvent((Entity) entityhuman, (Holder) GameEvent.BLOCK_CHANGE, blockposition);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/item/ItemHanging.java
|
||||
+++ b/net/minecraft/world/item/ItemHanging.java
|
||||
@@ -22,6 +22,11 @@
|
||||
@@ -23,6 +23,11 @@
|
||||
import net.minecraft.world.level.World;
|
||||
import net.minecraft.world.level.gameevent.GameEvent;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
public class ItemHanging extends Item {
|
||||
|
||||
private static final IChatBaseComponent TOOLTIP_RANDOM_VARIANT = IChatBaseComponent.translatable("painting.random").withStyle(EnumChatFormat.GRAY);
|
||||
@@ -72,6 +77,19 @@
|
||||
@@ -73,6 +78,19 @@
|
||||
|
||||
if (((EntityHanging) object).survives()) {
|
||||
if (!world.isClientSide) {
|
||||
@@ -30,5 +30,5 @@
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
((EntityHanging) object).playPlacementSound();
|
||||
world.gameEvent((Entity) entityhuman, GameEvent.ENTITY_PLACE, ((EntityHanging) object).position());
|
||||
world.gameEvent((Entity) entityhuman, (Holder) GameEvent.ENTITY_PLACE, ((EntityHanging) object).position());
|
||||
world.addFreshEntity((Entity) object);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/item/ItemLeash.java
|
||||
+++ b/net/minecraft/world/item/ItemLeash.java
|
||||
@@ -15,6 +15,11 @@
|
||||
@@ -16,6 +16,11 @@
|
||||
import net.minecraft.world.level.gameevent.GameEvent;
|
||||
import net.minecraft.world.phys.AxisAlignedBB;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
public class ItemLeash extends Item {
|
||||
|
||||
public ItemLeash(Item.Info item_info) {
|
||||
@@ -31,7 +36,7 @@
|
||||
@@ -32,7 +37,7 @@
|
||||
EntityHuman entityhuman = itemactioncontext.getPlayer();
|
||||
|
||||
if (!world.isClientSide && entityhuman != null) {
|
||||
@@ -21,45 +21,49 @@
|
||||
}
|
||||
|
||||
return EnumInteractionResult.sidedSuccess(world.isClientSide);
|
||||
@@ -40,7 +45,7 @@
|
||||
@@ -41,7 +46,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
- public static EnumInteractionResult bindPlayerMobs(EntityHuman entityhuman, World world, BlockPosition blockposition) {
|
||||
+ public static EnumInteractionResult bindPlayerMobs(EntityHuman entityhuman, World world, BlockPosition blockposition, net.minecraft.world.EnumHand enumhand) { // CraftBukkit - Add EnumHand
|
||||
EntityLeash entityleash = null;
|
||||
boolean flag = false;
|
||||
double d0 = 7.0D;
|
||||
@@ -56,9 +61,26 @@
|
||||
if (entityinsentient.getLeashHolder() == entityhuman) {
|
||||
if (entityleash == null) {
|
||||
entityleash = EntityLeash.getOrCreateKnot(world, blockposition);
|
||||
+
|
||||
+ // CraftBukkit start - fire HangingPlaceEvent
|
||||
+ org.bukkit.inventory.EquipmentSlot hand = CraftEquipmentSlot.getHand(enumhand);
|
||||
+ HangingPlaceEvent event = new HangingPlaceEvent((org.bukkit.entity.Hanging) entityleash.getBukkitEntity(), entityhuman != null ? (org.bukkit.entity.Player) entityhuman.getBukkitEntity() : null, world.getWorld().getBlockAt(i, j, k), org.bukkit.block.BlockFace.SELF, hand);
|
||||
+ world.getCraftServer().getPluginManager().callEvent(event);
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
+ entityleash.discard(null); // CraftBukkit - add Bukkit remove cause
|
||||
+ return EnumInteractionResult.PASS;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
entityleash.playPlacementSound();
|
||||
}
|
||||
int i = blockposition.getX();
|
||||
@@ -54,12 +59,29 @@
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerLeashEntityEvent(entityinsentient, entityleash, entityhuman, enumhand).isCancelled()) {
|
||||
+ continue;
|
||||
EntityInsentient entityinsentient;
|
||||
|
||||
- for (Iterator iterator = list.iterator(); iterator.hasNext(); entityinsentient.setLeashedTo(entityleash, true)) {
|
||||
+ for (Iterator iterator = list.iterator(); iterator.hasNext();) { // CraftBukkit - handle setLeashedTo at end of loop
|
||||
entityinsentient = (EntityInsentient) iterator.next();
|
||||
if (entityleash == null) {
|
||||
entityleash = EntityLeash.getOrCreateKnot(world, blockposition);
|
||||
+
|
||||
+ // CraftBukkit start - fire HangingPlaceEvent
|
||||
+ org.bukkit.inventory.EquipmentSlot hand = CraftEquipmentSlot.getHand(enumhand);
|
||||
+ HangingPlaceEvent event = new HangingPlaceEvent((org.bukkit.entity.Hanging) entityleash.getBukkitEntity(), entityhuman != null ? (org.bukkit.entity.Player) entityhuman.getBukkitEntity() : null, world.getWorld().getBlockAt(i, j, k), org.bukkit.block.BlockFace.SELF, hand);
|
||||
+ world.getCraftServer().getPluginManager().callEvent(event);
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
+ entityleash.discard(null); // CraftBukkit - add Bukkit remove cause
|
||||
+ return EnumInteractionResult.PASS;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
entityinsentient.setLeashedTo(entityleash, true);
|
||||
flag = true;
|
||||
entityleash.playPlacementSound();
|
||||
}
|
||||
@@ -70,4 +92,10 @@
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerLeashEntityEvent(entityinsentient, entityleash, entityhuman, enumhand).isCancelled()) {
|
||||
+ entityinsentient.setLeashedTo(entityleash, true);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
return flag ? EnumInteractionResult.SUCCESS : EnumInteractionResult.PASS;
|
||||
if (!list.isEmpty()) {
|
||||
@@ -69,4 +91,10 @@
|
||||
return EnumInteractionResult.PASS;
|
||||
}
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
--- a/net/minecraft/world/item/ItemMilkBucket.java
|
||||
+++ b/net/minecraft/world/item/ItemMilkBucket.java
|
||||
@@ -31,7 +31,7 @@
|
||||
}
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
itemstack.consume(1, entityliving);
|
||||
if (!world.isClientSide) {
|
||||
- entityliving.removeAllEffects();
|
||||
+ entityliving.removeAllEffects(org.bukkit.event.entity.EntityPotionEffectEvent.Cause.MILK); // CraftBukkit
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/item/ItemMinecart.java
|
||||
+++ b/net/minecraft/world/item/ItemMinecart.java
|
||||
@@ -19,6 +19,12 @@
|
||||
@@ -20,6 +20,12 @@
|
||||
import net.minecraft.world.level.gameevent.GameEvent;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
public class ItemMinecart extends Item {
|
||||
|
||||
private static final IDispenseBehavior DISPENSE_ITEM_BEHAVIOR = new DispenseBehaviorItem() {
|
||||
@@ -58,10 +64,39 @@
|
||||
@@ -59,10 +65,39 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
@@ -100,7 +135,12 @@
|
||||
@@ -101,7 +136,12 @@
|
||||
|
||||
EntityMinecartAbstract entityminecartabstract = EntityMinecartAbstract.createMinecart(worldserver, (double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.0625D + d0, (double) blockposition.getZ() + 0.5D, this.type, itemstack, itemactioncontext.getPlayer());
|
||||
|
||||
@@ -67,6 +67,6 @@
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+ if (!worldserver.addFreshEntity(entityminecartabstract)) return EnumInteractionResult.PASS; // CraftBukkit
|
||||
worldserver.gameEvent(GameEvent.ENTITY_PLACE, blockposition, GameEvent.a.of(itemactioncontext.getPlayer(), worldserver.getBlockState(blockposition.below())));
|
||||
worldserver.gameEvent((Holder) GameEvent.ENTITY_PLACE, blockposition, GameEvent.a.of(itemactioncontext.getPlayer(), worldserver.getBlockState(blockposition.below())));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,18 +1,13 @@
|
||||
--- a/net/minecraft/world/item/ItemMonsterEgg.java
|
||||
+++ b/net/minecraft/world/item/ItemMonsterEgg.java
|
||||
@@ -180,7 +180,7 @@
|
||||
@@ -177,10 +177,10 @@
|
||||
return Optional.empty();
|
||||
} else {
|
||||
((EntityInsentient) object).moveTo(vec3d.x(), vec3d.y(), vec3d.z(), 0.0F, 0.0F);
|
||||
- worldserver.addFreshEntityWithPassengers((Entity) object);
|
||||
+ worldserver.addFreshEntityWithPassengers((Entity) object, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG); // CraftBukkit
|
||||
if (itemstack.hasCustomHoverName()) {
|
||||
((EntityInsentient) object).setCustomName(itemstack.getHoverName());
|
||||
}
|
||||
@@ -189,7 +189,7 @@
|
||||
itemstack.shrink(1);
|
||||
}
|
||||
|
||||
((EntityInsentient) object).setCustomName((IChatBaseComponent) itemstack.get(DataComponents.CUSTOM_NAME));
|
||||
itemstack.consume(1, entityhuman);
|
||||
- return Optional.of(object);
|
||||
+ return Optional.of((EntityInsentient) object); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
--- a/net/minecraft/world/item/ItemPotion.java
|
||||
+++ b/net/minecraft/world/item/ItemPotion.java
|
||||
@@ -60,7 +60,7 @@
|
||||
if (mobeffect.getEffect().isInstantenous()) {
|
||||
mobeffect.getEffect().applyInstantenousEffect(entityhuman, entityhuman, entityliving, mobeffect.getAmplifier(), 1.0D);
|
||||
@@ -62,7 +62,7 @@
|
||||
if (((MobEffectList) mobeffect.getEffect().value()).isInstantenous()) {
|
||||
((MobEffectList) mobeffect.getEffect().value()).applyInstantenousEffect(entityhuman, entityhuman, entityliving, mobeffect.getAmplifier(), 1.0D);
|
||||
} else {
|
||||
- entityliving.addEffect(new MobEffect(mobeffect));
|
||||
+ entityliving.addEffect(new MobEffect(mobeffect), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.POTION_DRINK); // CraftBukkit
|
||||
- entityliving.addEffect(mobeffect);
|
||||
+ entityliving.addEffect(mobeffect, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.POTION_DRINK); // CraftBukkit
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
--- a/net/minecraft/world/item/ItemProjectileWeapon.java
|
||||
+++ b/net/minecraft/world/item/ItemProjectileWeapon.java
|
||||
@@ -59,11 +59,28 @@
|
||||
float f6 = f4 + f5 * (float) ((i + 1) / 2) * f3;
|
||||
|
||||
f5 = -f5;
|
||||
- itemstack.hurtAndBreak(this.getDurabilityUse(itemstack1), entityliving, EntityLiving.getSlotForHand(enumhand));
|
||||
+ // itemstack.hurtAndBreak(this.getDurabilityUse(itemstack1), entityliving, EntityLiving.getSlotForHand(enumhand)); // CraftBukkit - moved down
|
||||
IProjectile iprojectile = this.createProjectile(world, entityliving, itemstack, itemstack1, flag);
|
||||
|
||||
this.shootProjectile(entityliving, iprojectile, i, f, f1, f6, entityliving1);
|
||||
- world.addFreshEntity(iprojectile);
|
||||
+ // CraftBukkit start
|
||||
+ org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(entityliving, itemstack, itemstack1, iprojectile, enumhand, f, true);
|
||||
+ if (event.isCancelled()) {
|
||||
+ event.getProjectile().remove();
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ itemstack.hurtAndBreak(this.getDurabilityUse(itemstack1), entityliving, EntityLiving.getSlotForHand(enumhand));
|
||||
+
|
||||
+ if (event.getProjectile() == iprojectile.getBukkitEntity()) {
|
||||
+ if (!world.addFreshEntity(iprojectile)) {
|
||||
+ if (entityliving instanceof net.minecraft.server.level.EntityPlayer) {
|
||||
+ ((net.minecraft.server.level.EntityPlayer) entityliving).getBukkitEntity().updateInventory();
|
||||
+ }
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/item/ItemRecord.java
|
||||
+++ b/net/minecraft/world/item/ItemRecord.java
|
||||
@@ -46,6 +46,7 @@
|
||||
@@ -47,6 +47,7 @@
|
||||
ItemStack itemstack = itemactioncontext.getItemInHand();
|
||||
|
||||
if (!world.isClientSide) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/item/ItemSnowball.java
|
||||
+++ b/net/minecraft/world/item/ItemSnowball.java
|
||||
@@ -19,19 +19,32 @@
|
||||
@@ -22,17 +22,25 @@
|
||||
public InteractionResultWrapper<ItemStack> use(World world, EntityHuman entityhuman, EnumHand enumhand) {
|
||||
ItemStack itemstack = entityhuman.getItemInHand(enumhand);
|
||||
|
||||
@@ -14,9 +14,7 @@
|
||||
entitysnowball.shootFromRotation(entityhuman, entityhuman.getXRot(), entityhuman.getYRot(), 0.0F, 1.5F, 1.0F);
|
||||
- world.addFreshEntity(entitysnowball);
|
||||
+ if (world.addFreshEntity(entitysnowball)) {
|
||||
+ if (!entityhuman.getAbilities().instabuild) {
|
||||
+ itemstack.shrink(1);
|
||||
+ }
|
||||
+ itemstack.consume(1, entityhuman);
|
||||
+
|
||||
+ world.playSound((EntityHuman) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F));
|
||||
+ } else if (entityhuman instanceof net.minecraft.server.level.EntityPlayer) {
|
||||
@@ -26,12 +24,8 @@
|
||||
+ // CraftBukkit end
|
||||
|
||||
entityhuman.awardStat(StatisticList.ITEM_USED.get(this));
|
||||
+ // CraftBukkit start - moved up
|
||||
+ /*
|
||||
if (!entityhuman.getAbilities().instabuild) {
|
||||
itemstack.shrink(1);
|
||||
}
|
||||
+ */
|
||||
|
||||
- itemstack.consume(1, entityhuman);
|
||||
+ // itemstack.consume(1, entityhuman); // CraftBukkit - moved up
|
||||
return InteractionResultWrapper.sidedSuccess(itemstack, world.isClientSide());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,20 +1,17 @@
|
||||
--- a/net/minecraft/world/item/ItemStack.java
|
||||
+++ b/net/minecraft/world/item/ItemStack.java
|
||||
@@ -81,6 +81,44 @@
|
||||
import net.minecraft.world.level.block.state.pattern.ShapeDetectorBlock;
|
||||
@@ -92,6 +92,40 @@
|
||||
import org.apache.commons.lang3.mutable.MutableBoolean;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import com.mojang.serialization.Dynamic;
|
||||
+import java.util.Map;
|
||||
+import java.util.Objects;
|
||||
+import net.minecraft.core.EnumDirection;
|
||||
+import net.minecraft.nbt.DynamicOpsNBT;
|
||||
+import net.minecraft.network.protocol.game.PacketPlayOutBlockChange;
|
||||
+import net.minecraft.server.MinecraftServer;
|
||||
+import net.minecraft.server.level.WorldServer;
|
||||
+import net.minecraft.sounds.SoundCategory;
|
||||
+import net.minecraft.util.datafix.fixes.DataConverterTypes;
|
||||
+import net.minecraft.world.level.block.BlockBed;
|
||||
+import net.minecraft.world.level.block.Blocks;
|
||||
+import net.minecraft.world.level.block.BlockSapling;
|
||||
@@ -35,55 +32,78 @@
|
||||
+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 final class ItemStack implements DataComponentHolder {
|
||||
|
||||
public static final Codec<ItemStack> CODEC = RecordCodecBuilder.create((instance) -> {
|
||||
@@ -175,7 +213,18 @@
|
||||
this.item = null;
|
||||
}
|
||||
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);
|
||||
|
||||
- private ItemStack(NBTTagCompound nbttagcompound) {
|
||||
+ // 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()) {
|
||||
+ NBTTagCompound savedStack = new NBTTagCompound();
|
||||
+ this.save(savedStack);
|
||||
+ savedStack = (NBTTagCompound) MinecraftServer.getServer().fixerUpper.update(DataConverterTypes.ITEM_STACK, new Dynamic(DynamicOpsNBT.INSTANCE, savedStack), version, CraftMagicNumbers.INSTANCE.getDataVersion()).getValue();
|
||||
+ this.load(savedStack);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ // CraftBukkit - break into own method
|
||||
+ private void load(NBTTagCompound nbttagcompound) {
|
||||
this.item = (Item) BuiltInRegistries.ITEM.get(new MinecraftKey(nbttagcompound.getString("id")));
|
||||
this.count = nbttagcompound.getByte("Count");
|
||||
if (nbttagcompound.contains("tag", 10)) {
|
||||
@@ -189,6 +238,11 @@
|
||||
- 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
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
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 @@
|
||||
|
||||
+ private ItemStack(NBTTagCompound nbttagcompound) {
|
||||
+ this.load(nbttagcompound);
|
||||
+ // CraftBukkit end
|
||||
+ }
|
||||
+
|
||||
public static ItemStack of(NBTTagCompound nbttagcompound) {
|
||||
try {
|
||||
return new ItemStack(nbttagcompound);
|
||||
@@ -266,11 +320,191 @@
|
||||
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 @@
|
||||
return EnumInteractionResult.PASS;
|
||||
} else {
|
||||
Item item = this.getItem();
|
||||
- EnumInteractionResult enuminteractionresult = item.useOn(itemactioncontext);
|
||||
+ // CraftBukkit start - handle all block place event logic here
|
||||
+ NBTTagCompound oldData = this.getTagClone();
|
||||
+ PatchedDataComponentMap oldData = this.getComponentsClone();
|
||||
+ int oldCount = this.getCount();
|
||||
+ WorldServer world = (WorldServer) itemactioncontext.getLevel();
|
||||
+
|
||||
@@ -100,10 +120,10 @@
|
||||
+ } finally {
|
||||
+ world.captureBlockStates = false;
|
||||
+ }
|
||||
+ NBTTagCompound newData = this.getTagClone();
|
||||
+ PatchedDataComponentMap newData = this.getComponentsClone();
|
||||
+ int newCount = this.getCount();
|
||||
+ this.setCount(oldCount);
|
||||
+ this.setTagClone(oldData);
|
||||
+ this.setComponentsClone(oldData);
|
||||
+ if (enuminteractionresult.consumesAction() && world.captureTreeGeneration && world.capturedBlockStates.size() > 0) {
|
||||
+ world.captureTreeGeneration = false;
|
||||
+ Location location = CraftLocation.toBukkit(blockposition, world.getWorld());
|
||||
@@ -124,8 +144,8 @@
|
||||
+
|
||||
+ 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);
|
||||
+ if (this.getCount() == oldCount && Objects.equals(this.components, oldData)) {
|
||||
+ this.applyComponents(newData);
|
||||
+ this.setCount(newCount);
|
||||
+ }
|
||||
+ for (CraftBlockState blockstate : blocks) {
|
||||
@@ -140,7 +160,7 @@
|
||||
+ }
|
||||
+ world.captureTreeGeneration = false;
|
||||
|
||||
if (entityhuman != null && enuminteractionresult.shouldAwardStats()) {
|
||||
if (entityhuman != null && enuminteractionresult.indicateItemUse()) {
|
||||
- entityhuman.awardStat(StatisticList.ITEM_USED.get(item));
|
||||
+ EnumHand enumhand = itemactioncontext.getHand();
|
||||
+ org.bukkit.event.block.BlockPlaceEvent placeEvent = null;
|
||||
@@ -171,8 +191,8 @@
|
||||
+ ItemSign.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);
|
||||
+ if (this.getCount() == oldCount && Objects.equals(this.components, oldData)) {
|
||||
+ this.applyComponents(newData);
|
||||
+ this.setCount(newCount);
|
||||
+ }
|
||||
+
|
||||
@@ -187,7 +207,7 @@
|
||||
+ IBlockData block = world.getBlockState(newblockposition);
|
||||
+
|
||||
+ if (!(block.getBlock() instanceof BlockTileEntity)) { // Containers get placed automatically
|
||||
+ block.getBlock().onPlace(block, world, newblockposition, oldBlock, true);
|
||||
+ block.onPlace(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
|
||||
@@ -271,7 +291,7 @@
|
||||
|
||||
return enuminteractionresult;
|
||||
}
|
||||
@@ -351,6 +585,21 @@
|
||||
@@ -432,6 +652,21 @@
|
||||
}
|
||||
|
||||
i -= k;
|
||||
@@ -284,47 +304,56 @@
|
||||
+ event.getPlayer().updateInventory();
|
||||
+ }
|
||||
+ if (event.isCancelled()) {
|
||||
+ return false;
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ i = event.getDamage();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
if (i <= 0) {
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
@@ -372,6 +621,11 @@
|
||||
if (this.hurt(i, t0.getRandom(), t0 instanceof EntityPlayer ? (EntityPlayer) t0 : null)) {
|
||||
consumer.accept(t0);
|
||||
Item item = this.getItem();
|
||||
+ // CraftBukkit start - Check for item breaking
|
||||
+ if (this.count == 1 && t0 instanceof EntityHuman) {
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerItemBreakEvent((EntityHuman) t0, this);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
@@ -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
|
||||
|
||||
this.shrink(1);
|
||||
if (t0 instanceof EntityHuman) {
|
||||
@@ -524,6 +778,17 @@
|
||||
return this.tag;
|
||||
this.shrink(1);
|
||||
if (entityliving instanceof EntityHuman) {
|
||||
@@ -669,6 +909,17 @@
|
||||
return this.getItem().useOnRelease(this);
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ @Nullable
|
||||
+ private NBTTagCompound getTagClone() {
|
||||
+ return this.tag == null ? null : this.tag.copy();
|
||||
+ private PatchedDataComponentMap getComponentsClone() {
|
||||
+ return this.components.isEmpty() ? null : this.components.copy();
|
||||
+ }
|
||||
+
|
||||
+ private void setTagClone(@Nullable NBTTagCompound nbtttagcompound) {
|
||||
+ this.setTag(nbtttagcompound == null ? null : nbtttagcompound.copy());
|
||||
+ private void setComponentsClone(@Nullable PatchedDataComponentMap patchedDataComponentMap) {
|
||||
+ this.applyComponents(patchedDataComponentMap == null ? null : patchedDataComponentMap.copy());
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public NBTTagCompound getOrCreateTag() {
|
||||
if (this.tag == null) {
|
||||
this.setTag(new NBTTagCompound());
|
||||
@@ -948,6 +1213,13 @@
|
||||
nbttaglist.add(nbttagcompound);
|
||||
@Nullable
|
||||
public <T> T set(DataComponentType<? super T> datacomponenttype, @Nullable T t0) {
|
||||
return this.components.set(datacomponenttype, t0);
|
||||
@@ -728,7 +979,7 @@
|
||||
}
|
||||
|
||||
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);
|
||||
@@ -955,6 +1206,13 @@
|
||||
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
@@ -337,3 +366,12 @@
|
||||
public IChatBaseComponent getDisplayName() {
|
||||
IChatMutableComponent ichatmutablecomponent = IChatBaseComponent.empty().append(this.getHoverName());
|
||||
|
||||
@@ -1017,7 +1275,7 @@
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,19 +1,15 @@
|
||||
--- a/net/minecraft/world/item/ItemTrident.java
|
||||
+++ b/net/minecraft/world/item/ItemTrident.java
|
||||
@@ -68,9 +68,12 @@
|
||||
@@ -72,7 +72,7 @@
|
||||
|
||||
if (k <= 0 || entityhuman.isInWaterOrRain()) {
|
||||
if (!world.isClientSide) {
|
||||
+ // CraftBukkit - moved down
|
||||
+ /*
|
||||
itemstack.hurtAndBreak(1, entityhuman, (entityhuman1) -> {
|
||||
entityhuman1.broadcastBreakEvent(entityliving.getUsedItemHand());
|
||||
});
|
||||
+ */
|
||||
- itemstack.hurtAndBreak(1, entityhuman, EntityLiving.getSlotForHand(entityliving.getUsedItemHand()));
|
||||
+ // itemstack.hurtAndBreak(1, entityhuman, EntityLiving.getSlotForHand(entityliving.getUsedItemHand())); // CraftBukkit - moved down
|
||||
if (k == 0) {
|
||||
EntityThrownTrident entitythrowntrident = new EntityThrownTrident(world, entityhuman, itemstack);
|
||||
|
||||
@@ -79,11 +82,30 @@
|
||||
@@ -81,11 +81,26 @@
|
||||
entitythrowntrident.pickup = EntityArrow.PickupStatus.CREATIVE_ONLY;
|
||||
}
|
||||
|
||||
@@ -26,26 +22,22 @@
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ itemstack.hurtAndBreak(1, entityhuman, (entityhuman1) -> {
|
||||
+ entityhuman1.broadcastBreakEvent(entityliving.getUsedItemHand());
|
||||
+ });
|
||||
+ itemstack.hurtAndBreak(1, entityhuman, EntityLiving.getSlotForHand(entityliving.getUsedItemHand()));
|
||||
+ entitythrowntrident.pickupItemStack = itemstack.copy(); // SPIGOT-4511 update since damage call moved
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
world.playSound((EntityHuman) null, (Entity) entitythrowntrident, SoundEffects.TRIDENT_THROW, SoundCategory.PLAYERS, 1.0F, 1.0F);
|
||||
if (!entityhuman.getAbilities().instabuild) {
|
||||
if (!entityhuman.hasInfiniteMaterials()) {
|
||||
entityhuman.getInventory().removeItem(itemstack);
|
||||
}
|
||||
+ // CraftBukkit start - SPIGOT-5458 also need in this branch :(
|
||||
+ } else {
|
||||
+ itemstack.hurtAndBreak(1, entityhuman, (entityhuman1) -> {
|
||||
+ entityhuman1.broadcastBreakEvent(entityliving.getUsedItemHand());
|
||||
+ });
|
||||
+ itemstack.hurtAndBreak(1, entityhuman, EntityLiving.getSlotForHand(entityliving.getUsedItemHand()));
|
||||
+ // CraftBukkkit end
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,6 +122,7 @@
|
||||
@@ -102,6 +117,7 @@
|
||||
f2 *= f6 / f5;
|
||||
f3 *= f6 / f5;
|
||||
f4 *= f6 / f5;
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
--- a/net/minecraft/world/item/ItemWorldMap.java
|
||||
+++ b/net/minecraft/world/item/ItemWorldMap.java
|
||||
@@ -69,7 +69,7 @@
|
||||
public static Integer getMapId(ItemStack itemstack) {
|
||||
NBTTagCompound nbttagcompound = itemstack.getTag();
|
||||
|
||||
- return nbttagcompound != null && nbttagcompound.contains("map", 99) ? nbttagcompound.getInt("map") : null;
|
||||
+ return nbttagcompound != null && nbttagcompound.contains("map", 99) ? nbttagcompound.getInt("map") : -1; // CraftBukkit - make new maps for no tag
|
||||
}
|
||||
|
||||
public static int createNewSavedData(World world, int i, int j, int k, boolean flag, boolean flag1, ResourceKey<World> resourcekey) {
|
||||
@@ -1,70 +1,38 @@
|
||||
--- a/net/minecraft/world/item/crafting/CraftingManager.java
|
||||
+++ b/net/minecraft/world/item/crafting/CraftingManager.java
|
||||
@@ -34,11 +34,16 @@
|
||||
@@ -34,6 +34,11 @@
|
||||
import net.minecraft.world.level.World;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap;
|
||||
+import net.minecraft.core.registries.BuiltInRegistries;
|
||||
+import com.google.common.collect.LinkedHashMultimap;
|
||||
+import com.google.common.collect.Maps;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class CraftingManager extends ResourceDataJson {
|
||||
|
||||
private static final Gson GSON = (new GsonBuilder()).setPrettyPrinting().disableHtmlEscaping().create();
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
- public Map<Recipes<?>, Map<MinecraftKey, RecipeHolder<?>>> recipes = ImmutableMap.of();
|
||||
+ public Map<Recipes<?>, Object2ObjectLinkedOpenHashMap<MinecraftKey, RecipeHolder<?>>> recipes = ImmutableMap.of(); // CraftBukkit
|
||||
private Map<MinecraftKey, RecipeHolder<?>> byName = ImmutableMap.of();
|
||||
private boolean hasErrors;
|
||||
|
||||
@@ -48,7 +53,12 @@
|
||||
|
||||
protected void apply(Map<MinecraftKey, JsonElement> map, IResourceManager iresourcemanager, GameProfilerFiller gameprofilerfiller) {
|
||||
this.hasErrors = false;
|
||||
- Map<Recipes<?>, Builder<MinecraftKey, RecipeHolder<?>>> map1 = Maps.newHashMap();
|
||||
+ // CraftBukkit start - SPIGOT-5667 make sure all types are populated and mutable
|
||||
+ Map<Recipes<?>, Object2ObjectLinkedOpenHashMap<MinecraftKey, RecipeHolder<?>>> map1 = Maps.newHashMap();
|
||||
+ for (Recipes<?> recipeType : BuiltInRegistries.RECIPE_TYPE) {
|
||||
+ map1.put(recipeType, new Object2ObjectLinkedOpenHashMap<>());
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
Builder<MinecraftKey, RecipeHolder<?>> builder = ImmutableMap.builder();
|
||||
Iterator iterator = map.entrySet().iterator();
|
||||
|
||||
@@ -59,8 +69,10 @@
|
||||
try {
|
||||
RecipeHolder<?> recipeholder = fromJson(minecraftkey, ChatDeserializer.convertToJsonObject((JsonElement) entry.getValue(), "top element"));
|
||||
|
||||
- ((Builder) map1.computeIfAbsent(recipeholder.value().getType(), (recipes) -> {
|
||||
- return ImmutableMap.builder();
|
||||
+ // CraftBukkit start
|
||||
+ (map1.computeIfAbsent(recipeholder.value().getType(), (recipes) -> {
|
||||
+ return new Object2ObjectLinkedOpenHashMap<>();
|
||||
+ // CraftBukkit end
|
||||
})).put(minecraftkey, recipeholder);
|
||||
builder.put(minecraftkey, recipeholder);
|
||||
} catch (IllegalArgumentException | JsonParseException jsonparseexception) {
|
||||
@@ -69,20 +81,37 @@
|
||||
@@ -70,19 +75,39 @@
|
||||
}
|
||||
}
|
||||
|
||||
this.recipes = (Map) map1.entrySet().stream().collect(ImmutableMap.toImmutableMap(Entry::getKey, (entry1) -> {
|
||||
- return ((Builder) entry1.getValue()).build();
|
||||
+ return (entry1.getValue()); // CraftBukkit
|
||||
}));
|
||||
- this.byName = builder.build();
|
||||
+ this.byName = Maps.newHashMap(builder.build()); // CraftBukkit
|
||||
CraftingManager.LOGGER.info("Loaded {} recipes", map1.size());
|
||||
- this.byType = builder.build();
|
||||
- this.byName = com_google_common_collect_immutablemap_builder.build();
|
||||
+ // CraftBukkit start - mutable
|
||||
+ this.byType = LinkedHashMultimap.create(builder.build());
|
||||
+ this.byName = Maps.newHashMap(com_google_common_collect_immutablemap_builder.build());
|
||||
+ // CraftBukkit end
|
||||
CraftingManager.LOGGER.info("Loaded {} recipes", this.byType.size());
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public void addRecipe(RecipeHolder<?> irecipe) {
|
||||
+ Object2ObjectLinkedOpenHashMap<MinecraftKey, RecipeHolder<?>> map = this.recipes.get(irecipe.value().getType()); // CraftBukkit
|
||||
+ Collection<RecipeHolder<?>> map = this.byType.get(irecipe.value().getType()); // CraftBukkit
|
||||
+
|
||||
+ if (byName.containsKey(irecipe.id()) || map.containsKey(irecipe.id())) {
|
||||
+ if (byName.containsKey(irecipe.id())) {
|
||||
+ throw new IllegalStateException("Duplicate recipe ignored with ID " + irecipe.id());
|
||||
+ } else {
|
||||
+ map.putAndMoveToFirst(irecipe.id(), irecipe); // CraftBukkit - SPIGOT-4638: last recipe gets priority
|
||||
+ map.add(irecipe);
|
||||
+ byName.put(irecipe.id(), irecipe);
|
||||
+ }
|
||||
+ }
|
||||
@@ -75,65 +43,81 @@
|
||||
}
|
||||
|
||||
public <C extends IInventory, T extends IRecipe<C>> Optional<RecipeHolder<T>> getRecipeFor(Recipes<T> recipes, C c0, World world) {
|
||||
- return this.byType(recipes).values().stream().filter((recipeholder) -> {
|
||||
- return this.byType(recipes).stream().filter((recipeholder) -> {
|
||||
+ // CraftBukkit start
|
||||
+ Optional<RecipeHolder<T>> recipe = this.byType(recipes).values().stream().filter((recipeholder) -> {
|
||||
+ List<RecipeHolder<T>> list = this.byType(recipes).stream().filter((recipeholder) -> {
|
||||
return recipeholder.value().matches(c0, world);
|
||||
}).findFirst();
|
||||
- }).findFirst();
|
||||
+ }).toList();
|
||||
+ Optional<RecipeHolder<T>> recipe = (list.isEmpty()) ? Optional.empty() : Optional.of(list.getLast()); // CraftBukkit - SPIGOT-4638: last recipe gets priority
|
||||
+ c0.setCurrentRecipe(recipe.orElse(null)); // CraftBukkit - Clear recipe when no recipe is found
|
||||
+ return recipe;
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
public <C extends IInventory, T extends IRecipe<C>> Optional<Pair<MinecraftKey, RecipeHolder<T>>> getRecipeFor(Recipes<T> recipes, C c0, World world, @Nullable MinecraftKey minecraftkey) {
|
||||
@@ -116,7 +145,7 @@
|
||||
public <C extends IInventory, T extends IRecipe<C>> Optional<RecipeHolder<T>> getRecipeFor(Recipes<T> recipes, C c0, World world, @Nullable MinecraftKey minecraftkey) {
|
||||
@@ -94,9 +119,14 @@
|
||||
}
|
||||
}
|
||||
|
||||
- return this.byType(recipes).stream().filter((recipeholder1) -> {
|
||||
+ // CraftBukkit start
|
||||
+ List<RecipeHolder<T>> list = this.byType(recipes).stream().filter((recipeholder1) -> {
|
||||
return recipeholder1.value().matches(c0, world);
|
||||
- }).findFirst();
|
||||
+ }).toList();
|
||||
+ Optional<RecipeHolder<T>> recipe = (list.isEmpty()) ? Optional.empty() : Optional.of(list.getLast()); // CraftBukkit - SPIGOT-4638: last recipe gets priority
|
||||
+ c0.setCurrentRecipe(recipe.orElse(null)); // CraftBukkit - Clear recipe when no recipe is found
|
||||
+ return recipe;
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
private <C extends IInventory, T extends IRecipe<C>> Map<MinecraftKey, RecipeHolder<T>> byType(Recipes<T> recipes) {
|
||||
- return (Map) this.recipes.getOrDefault(recipes, Collections.emptyMap());
|
||||
+ return (Map) this.recipes.getOrDefault(recipes, new Object2ObjectLinkedOpenHashMap<>()); // CraftBukkit
|
||||
public <C extends IInventory, T extends IRecipe<C>> List<RecipeHolder<T>> getAllRecipesFor(Recipes<T> recipes) {
|
||||
@@ -112,7 +142,7 @@
|
||||
}
|
||||
|
||||
private <C extends IInventory, T extends IRecipe<C>> Collection<RecipeHolder<T>> byType(Recipes<T> recipes) {
|
||||
- return this.byType.get(recipes);
|
||||
+ return (Collection) this.byType.get(recipes); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
public <C extends IInventory, T extends IRecipe<C>> NonNullList<ItemStack> getRemainingItemsFor(Recipes<T> recipes, C c0, World world) {
|
||||
@@ -159,12 +188,12 @@
|
||||
@@ -139,7 +169,7 @@
|
||||
private <T extends IRecipe<?>> RecipeHolder<T> byKeyTyped(Recipes<T> recipes, MinecraftKey minecraftkey) {
|
||||
RecipeHolder<?> recipeholder = (RecipeHolder) this.byName.get(minecraftkey);
|
||||
|
||||
public void replaceRecipes(Iterable<RecipeHolder<?>> iterable) {
|
||||
this.hasErrors = false;
|
||||
- Map<Recipes<?>, Map<MinecraftKey, RecipeHolder<?>>> map = Maps.newHashMap();
|
||||
+ Map<Recipes<?>, Object2ObjectLinkedOpenHashMap<MinecraftKey, RecipeHolder<?>>> map = Maps.newHashMap(); // CraftBukkit
|
||||
Builder<MinecraftKey, RecipeHolder<?>> builder = ImmutableMap.builder();
|
||||
- return recipeholder != null && recipeholder.value().getType().equals(recipes) ? recipeholder : null;
|
||||
+ return recipeholder != null && recipeholder.value().getType().equals(recipes) ? (RecipeHolder) recipeholder : null; // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
iterable.forEach((recipeholder) -> {
|
||||
Map<MinecraftKey, RecipeHolder<?>> map1 = (Map) map.computeIfAbsent(recipeholder.value().getType(), (recipes) -> {
|
||||
- return Maps.newHashMap();
|
||||
+ return new Object2ObjectLinkedOpenHashMap<>(); // CraftBukkit
|
||||
});
|
||||
MinecraftKey minecraftkey = recipeholder.id();
|
||||
RecipeHolder<?> recipeholder1 = (RecipeHolder) map1.put(minecraftkey, recipeholder);
|
||||
@@ -175,9 +204,29 @@
|
||||
}
|
||||
});
|
||||
this.recipes = ImmutableMap.copyOf(map);
|
||||
- this.byName = builder.build();
|
||||
+ this.byName = Maps.newHashMap(builder.build()); // CraftBukkit
|
||||
public Collection<RecipeHolder<?>> getOrderedRecipes() {
|
||||
@@ -175,10 +205,31 @@
|
||||
com_google_common_collect_immutablemap_builder.put(recipeholder.id(), recipeholder);
|
||||
}
|
||||
|
||||
- this.byType = builder.build();
|
||||
- this.byName = com_google_common_collect_immutablemap_builder.build();
|
||||
+ // CraftBukkit start - mutable
|
||||
+ this.byType = LinkedHashMultimap.create(builder.build());
|
||||
+ this.byName = Maps.newHashMap(com_google_common_collect_immutablemap_builder.build());
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public boolean removeRecipe(MinecraftKey mcKey) {
|
||||
+ for (Object2ObjectLinkedOpenHashMap<MinecraftKey, RecipeHolder<?>> recipes : recipes.values()) {
|
||||
+ recipes.remove(mcKey);
|
||||
+ Iterator<RecipeHolder<?>> iter = byType.values().iterator();
|
||||
+ while (iter.hasNext()) {
|
||||
+ RecipeHolder<?> recipe = iter.next();
|
||||
+ if (recipe.id().equals(mcKey)) {
|
||||
+ iter.remove();
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return byName.remove(mcKey) != null;
|
||||
+ }
|
||||
+
|
||||
+ public void clearRecipes() {
|
||||
+ this.recipes = Maps.newHashMap();
|
||||
+
|
||||
+ for (Recipes<?> recipeType : BuiltInRegistries.RECIPE_TYPE) {
|
||||
+ this.recipes.put(recipeType, new Object2ObjectLinkedOpenHashMap<>());
|
||||
+ }
|
||||
+
|
||||
+ this.byType = LinkedHashMultimap.create();
|
||||
+ this.byName = Maps.newHashMap();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/item/crafting/IRecipe.java
|
||||
+++ b/net/minecraft/world/item/crafting/IRecipe.java
|
||||
@@ -67,4 +67,6 @@
|
||||
@@ -72,4 +72,6 @@
|
||||
return recipeitemstack.getItems().length == 0;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
--- a/net/minecraft/world/item/crafting/IRecipeComplex.java
|
||||
+++ b/net/minecraft/world/item/crafting/IRecipeComplex.java
|
||||
@@ -3,6 +3,11 @@
|
||||
import net.minecraft.core.IRegistryCustom;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
+// CraftBukkit start
|
||||
|
||||
@@ -1,20 +1,22 @@
|
||||
--- a/net/minecraft/world/item/crafting/RecipeHolder.java
|
||||
+++ b/net/minecraft/world/item/crafting/RecipeHolder.java
|
||||
@@ -2,7 +2,16 @@
|
||||
|
||||
@@ -4,8 +4,19 @@
|
||||
import net.minecraft.network.codec.StreamCodec;
|
||||
import net.minecraft.resources.MinecraftKey;
|
||||
|
||||
-public record RecipeHolder<T extends IRecipe<?>> (MinecraftKey id, T value) {
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.util.CraftNamespacedKey;
|
||||
+import org.bukkit.inventory.Recipe;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
+public record RecipeHolder<T extends IRecipe<?>>(MinecraftKey id, T value) {
|
||||
+
|
||||
public record RecipeHolder<T extends IRecipe<?>>(MinecraftKey id, T value) {
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public final Recipe toBukkitRecipe() {
|
||||
+ return this.value.toBukkitRecipe(CraftNamespacedKey.fromMinecraft(this.id));
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public static final StreamCodec<RegistryFriendlyByteBuf, RecipeHolder<?>> STREAM_CODEC = StreamCodec.composite(MinecraftKey.STREAM_CODEC, RecipeHolder::id, IRecipe.STREAM_CODEC, RecipeHolder::value, RecipeHolder::new);
|
||||
|
||||
public boolean equals(Object object) {
|
||||
if (this == object) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/item/crafting/RecipeItemStack.java
|
||||
+++ b/net/minecraft/world/item/crafting/RecipeItemStack.java
|
||||
@@ -35,6 +35,7 @@
|
||||
@@ -40,6 +40,7 @@
|
||||
public ItemStack[] itemStacks;
|
||||
@Nullable
|
||||
private IntList stackingIds;
|
||||
@@ -8,13 +8,13 @@
|
||||
public static final Codec<RecipeItemStack> CODEC = codec(true);
|
||||
public static final Codec<RecipeItemStack> CODEC_NONEMPTY = codec(false);
|
||||
|
||||
@@ -72,6 +73,15 @@
|
||||
@@ -77,6 +78,15 @@
|
||||
for (int j = 0; j < i; ++j) {
|
||||
ItemStack itemstack1 = aitemstack[j];
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ if (exact) {
|
||||
+ if (itemstack1.getItem() == itemstack.getItem() && ItemStack.isSameItemSameTags(itemstack, itemstack1)) {
|
||||
+ if (itemstack1.getItem() == itemstack.getItem() && ItemStack.isSameItemSameComponents(itemstack, itemstack1)) {
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/item/crafting/ShapedRecipes.java
|
||||
+++ b/net/minecraft/world/item/crafting/ShapedRecipes.java
|
||||
@@ -10,6 +10,14 @@
|
||||
@@ -11,6 +11,14 @@
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.World;
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
public class ShapedRecipes implements RecipeCrafting {
|
||||
|
||||
final ShapedRecipePattern pattern;
|
||||
@@ -30,6 +38,68 @@
|
||||
@@ -31,6 +39,68 @@
|
||||
this(s, craftingbookcategory, shapedrecipepattern, itemstack, true);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/item/crafting/ShapelessRecipes.java
|
||||
+++ b/net/minecraft/world/item/crafting/ShapelessRecipes.java
|
||||
@@ -14,6 +14,13 @@
|
||||
@@ -15,6 +15,13 @@
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.World;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
public class ShapelessRecipes implements RecipeCrafting {
|
||||
|
||||
final String group;
|
||||
@@ -28,6 +35,22 @@
|
||||
@@ -29,6 +36,22 @@
|
||||
this.ingredients = nonnulllist;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
public class SmithingTransformRecipe implements SmithingRecipe {
|
||||
|
||||
final RecipeItemStack template;
|
||||
@@ -71,6 +79,17 @@
|
||||
@@ -67,6 +75,17 @@
|
||||
return Stream.of(this.template, this.base, this.addition).anyMatch(RecipeItemStack::isEmpty);
|
||||
}
|
||||
|
||||
@@ -32,4 +32,4 @@
|
||||
+
|
||||
public static class a implements RecipeSerializer<SmithingTransformRecipe> {
|
||||
|
||||
private static final Codec<SmithingTransformRecipe> CODEC = RecordCodecBuilder.create((instance) -> {
|
||||
private static final MapCodec<SmithingTransformRecipe> CODEC = RecordCodecBuilder.mapCodec((instance) -> {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/item/crafting/SmithingTrimRecipe.java
|
||||
+++ b/net/minecraft/world/item/crafting/SmithingTrimRecipe.java
|
||||
@@ -18,6 +18,13 @@
|
||||
@@ -20,6 +20,13 @@
|
||||
import net.minecraft.world.item.armortrim.TrimPatterns;
|
||||
import net.minecraft.world.level.World;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
public class SmithingTrimRecipe implements SmithingRecipe {
|
||||
|
||||
final RecipeItemStack template;
|
||||
@@ -107,6 +114,13 @@
|
||||
@@ -100,6 +107,13 @@
|
||||
return Stream.of(this.template, this.base, this.addition).anyMatch(RecipeItemStack::isEmpty);
|
||||
}
|
||||
|
||||
@@ -27,4 +27,4 @@
|
||||
+
|
||||
public static class a implements RecipeSerializer<SmithingTrimRecipe> {
|
||||
|
||||
private static final Codec<SmithingTrimRecipe> CODEC = RecordCodecBuilder.create((instance) -> {
|
||||
private static final MapCodec<SmithingTrimRecipe> CODEC = RecordCodecBuilder.mapCodec((instance) -> {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/item/enchantment/EnchantmentFrostWalker.java
|
||||
+++ b/net/minecraft/world/item/enchantment/EnchantmentFrostWalker.java
|
||||
@@ -55,8 +55,11 @@
|
||||
@@ -39,8 +39,11 @@
|
||||
IBlockData iblockdata2 = world.getBlockState(blockposition1);
|
||||
|
||||
if (iblockdata2 == BlockIceFrost.meltsInto() && iblockdata.canSurvive(world, blockposition1) && world.isUnobstructed(iblockdata, blockposition1, VoxelShapeCollision.empty())) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
--- a/net/minecraft/world/item/enchantment/EnchantmentWeaponDamage.java
|
||||
+++ b/net/minecraft/world/item/enchantment/EnchantmentWeaponDamage.java
|
||||
@@ -63,7 +63,7 @@
|
||||
if (this.type == 2 && i > 0 && entityliving1.getMobType() == EnumMonsterType.ARTHROPOD) {
|
||||
@@ -35,7 +35,7 @@
|
||||
if (this.targets.get() == TagsEntity.SENSITIVE_TO_BANE_OF_ARTHROPODS && i > 0 && entityliving1.getType().is((TagKey) this.targets.get())) {
|
||||
int j = 20 + entityliving.getRandom().nextInt(10 * i);
|
||||
|
||||
- entityliving1.addEffect(new MobEffect(MobEffects.MOVEMENT_SLOWDOWN, j, 3));
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/item/trading/MerchantRecipe.java
|
||||
+++ b/net/minecraft/world/item/trading/MerchantRecipe.java
|
||||
@@ -5,6 +5,8 @@
|
||||
@@ -8,6 +8,8 @@
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
+
|
||||
public class MerchantRecipe {
|
||||
|
||||
public ItemStack baseCostA;
|
||||
@@ -17,6 +19,22 @@
|
||||
public static final Codec<MerchantRecipe> CODEC = RecordCodecBuilder.create((instance) -> {
|
||||
@@ -44,6 +46,18 @@
|
||||
public int demand;
|
||||
public float priceMultiplier;
|
||||
public int xp;
|
||||
@@ -20,27 +20,15 @@
|
||||
+ return (bukkitHandle == null) ? bukkitHandle = new CraftMerchantRecipe(this) : bukkitHandle;
|
||||
+ }
|
||||
+
|
||||
+ public MerchantRecipe(ItemStack itemstack, ItemStack itemstack1, ItemStack itemstack2, int uses, int maxUses, int experience, float priceMultiplier, CraftMerchantRecipe bukkit) {
|
||||
+ this(itemstack, itemstack1, itemstack2, uses, maxUses, experience, priceMultiplier, 0, bukkit);
|
||||
+ }
|
||||
+
|
||||
+ public MerchantRecipe(ItemStack itemstack, ItemStack itemstack1, ItemStack itemstack2, int uses, int maxUses, int experience, float priceMultiplier, int demand, CraftMerchantRecipe bukkit) {
|
||||
+ this(itemstack, itemstack1, itemstack2, uses, maxUses, experience, priceMultiplier, demand);
|
||||
+ public MerchantRecipe(ItemCost baseCostA, Optional<ItemCost> costB, ItemStack result, int uses, int maxUses, int experience, float priceMultiplier, int demand, CraftMerchantRecipe bukkit) {
|
||||
+ this(baseCostA, costB, result, uses, maxUses, experience, priceMultiplier, demand);
|
||||
+ this.bukkitHandle = bukkit;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
public MerchantRecipe(NBTTagCompound nbttagcompound) {
|
||||
this.rewardExp = true;
|
||||
@@ -96,6 +114,7 @@
|
||||
return ItemStack.EMPTY;
|
||||
} else {
|
||||
int i = this.baseCostA.getCount();
|
||||
+ if (i <= 0) return ItemStack.EMPTY; // CraftBukkit - SPIGOT-5476
|
||||
int j = Math.max(0, MathHelper.floor((float) (i * this.demand) * this.priceMultiplier));
|
||||
|
||||
return this.baseCostA.copyWithCount(MathHelper.clamp(i + j + this.specialPriceDiff, 1, this.baseCostA.getItem().getMaxStackSize()));
|
||||
@@ -216,7 +235,11 @@
|
||||
private MerchantRecipe(ItemCost itemcost, Optional<ItemCost> optional, ItemStack itemstack, int i, int j, boolean flag, int k, int l, float f, int i1) {
|
||||
this.baseCostA = itemcost;
|
||||
@@ -185,7 +199,11 @@
|
||||
if (!this.satisfiedBy(itemstack, itemstack1)) {
|
||||
return false;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user