@@ -1,51 +0,0 @@
|
||||
--- a/net/minecraft/world/item/ItemArmor.java
|
||||
+++ b/net/minecraft/world/item/ItemArmor.java
|
||||
@@ -29,6 +29,12 @@
|
||||
import net.minecraft.world.level.block.BlockDispenser;
|
||||
import net.minecraft.world.phys.AxisAlignedBB;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.block.CraftBlock;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
+import org.bukkit.event.block.BlockDispenseArmorEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class ItemArmor extends Item implements Equipable {
|
||||
|
||||
public static final IDispenseBehavior DISPENSE_ITEM_BEHAVIOR = new DispenseBehaviorItem() {
|
||||
@@ -51,8 +57,34 @@
|
||||
EntityLiving entityliving = (EntityLiving) list.get(0);
|
||||
EnumItemSlot enumitemslot = entityliving.getEquipmentSlotForItem(itemstack);
|
||||
ItemStack itemstack1 = itemstack.split(1);
|
||||
+ // CraftBukkit start
|
||||
+ World world = sourceblock.level();
|
||||
+ org.bukkit.block.Block block = CraftBlock.at(world, sourceblock.pos());
|
||||
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
|
||||
|
||||
- entityliving.setItemSlot(enumitemslot, itemstack1);
|
||||
+ BlockDispenseArmorEvent event = new BlockDispenseArmorEvent(block, craftItem.clone(), (org.bukkit.craftbukkit.entity.CraftLivingEntity) entityliving.getBukkitEntity());
|
||||
+ if (!BlockDispenser.eventFired) {
|
||||
+ world.getCraftServer().getPluginManager().callEvent(event);
|
||||
+ }
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
+ itemstack.grow(1);
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ if (!event.getItem().equals(craftItem)) {
|
||||
+ itemstack.grow(1);
|
||||
+ // Chain to handler for new item
|
||||
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
|
||||
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem());
|
||||
+ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != ItemArmor.DISPENSE_ITEM_BEHAVIOR) {
|
||||
+ idispensebehavior.dispense(sourceblock, eventStack);
|
||||
+ return true;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ entityliving.setItemSlot(enumitemslot, CraftItemStack.asNMSCopy(event.getItem()));
|
||||
+ // CraftBukkit end
|
||||
if (entityliving instanceof EntityInsentient) {
|
||||
((EntityInsentient) entityliving).setDropChance(enumitemslot, 2.0F);
|
||||
((EntityInsentient) entityliving).setPersistenceRequired();
|
||||
@@ -14,7 +14,7 @@
|
||||
public class ItemBlock extends Item {
|
||||
|
||||
/** @deprecated */
|
||||
@@ -68,6 +75,12 @@
|
||||
@@ -62,6 +69,12 @@
|
||||
return EnumInteractionResult.FAIL;
|
||||
} else {
|
||||
IBlockData iblockdata = this.getPlacementState(blockactioncontext1);
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
if (iblockdata == null) {
|
||||
return EnumInteractionResult.FAIL;
|
||||
@@ -85,6 +98,19 @@
|
||||
@@ -79,6 +92,19 @@
|
||||
this.updateCustomBlockEntityTag(blockposition, world, entityhuman, itemstack, iblockdata1);
|
||||
updateBlockEntityComponents(world, blockposition, itemstack);
|
||||
iblockdata1.getBlock().setPlacedBy(world, blockposition, iblockdata1, entityhuman, itemstack);
|
||||
@@ -47,7 +47,7 @@
|
||||
if (entityhuman instanceof EntityPlayer) {
|
||||
CriterionTriggers.PLACED_BLOCK.trigger((EntityPlayer) entityhuman, blockposition, itemstack);
|
||||
}
|
||||
@@ -92,7 +118,7 @@
|
||||
@@ -86,7 +112,7 @@
|
||||
|
||||
SoundEffectType soundeffecttype = iblockdata1.getSoundType();
|
||||
|
||||
@@ -55,8 +55,8 @@
|
||||
+ // world.playSound(entityhuman, blockposition, this.getPlaceSound(iblockdata1), SoundCategory.BLOCKS, (soundeffecttype.getVolume() + 1.0F) / 2.0F, soundeffecttype.getPitch() * 0.8F);
|
||||
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 @@
|
||||
return EnumInteractionResult.SUCCESS;
|
||||
@@ -144,8 +170,15 @@
|
||||
protected boolean canPlace(BlockActionContext blockactioncontext, IBlockData iblockdata) {
|
||||
EntityHuman entityhuman = blockactioncontext.getPlayer();
|
||||
VoxelShapeCollision voxelshapecollision = entityhuman == null ? VoxelShapeCollision.empty() : VoxelShapeCollision.of(entityhuman);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/item/ItemBoat.java
|
||||
+++ b/net/minecraft/world/item/ItemBoat.java
|
||||
@@ -61,6 +61,13 @@
|
||||
@@ -58,6 +58,13 @@
|
||||
}
|
||||
|
||||
if (movingobjectpositionblock.getType() == MovingObjectPosition.EnumMovingObjectType.BLOCK) {
|
||||
@@ -8,35 +8,26 @@
|
||||
+ org.bukkit.event.player.PlayerInteractEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent(entityhuman, org.bukkit.event.block.Action.RIGHT_CLICK_BLOCK, movingobjectpositionblock.getBlockPos(), movingobjectpositionblock.getDirection(), itemstack, false, enumhand, movingobjectpositionblock.getLocation());
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
+ return InteractionResultWrapper.pass(itemstack);
|
||||
+ return EnumInteractionResult.PASS;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
EntityBoat entityboat = this.getBoat(world, movingobjectpositionblock, itemstack, entityhuman);
|
||||
AbstractBoat abstractboat = this.getBoat(world, movingobjectpositionblock, itemstack, entityhuman);
|
||||
|
||||
entityboat.setVariant(this.type);
|
||||
@@ -69,7 +76,15 @@
|
||||
return InteractionResultWrapper.fail(itemstack);
|
||||
} else {
|
||||
if (!world.isClientSide) {
|
||||
- world.addFreshEntity(entityboat);
|
||||
+ // CraftBukkit start
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPlaceEvent(world, movingobjectpositionblock.getBlockPos(), movingobjectpositionblock.getDirection(), entityhuman, entityboat, enumhand).isCancelled()) {
|
||||
+ return InteractionResultWrapper.fail(itemstack);
|
||||
+ }
|
||||
if (abstractboat == null) {
|
||||
@@ -68,7 +75,15 @@
|
||||
return EnumInteractionResult.FAIL;
|
||||
} else {
|
||||
if (!world.isClientSide) {
|
||||
- world.addFreshEntity(abstractboat);
|
||||
+ // CraftBukkit start
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPlaceEvent(world, movingobjectpositionblock.getBlockPos(), movingobjectpositionblock.getDirection(), entityhuman, abstractboat, enumhand).isCancelled()) {
|
||||
+ return EnumInteractionResult.FAIL;
|
||||
+ }
|
||||
+
|
||||
+ if (!world.addFreshEntity(entityboat)) {
|
||||
+ return InteractionResultWrapper.pass(itemstack);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
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) {
|
||||
EntityTypes.createDefaultStackConfig(worldserver, itemstack, entityhuman).accept(object);
|
||||
+ if (!world.addFreshEntity(abstractboat)) {
|
||||
+ return EnumInteractionResult.PASS;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
world.gameEvent((Entity) entityhuman, (Holder) GameEvent.ENTITY_PLACE, movingobjectpositionblock.getLocation());
|
||||
itemstack.consume(1, entityhuman);
|
||||
}
|
||||
|
||||
@@ -23,13 +23,13 @@
|
||||
IFluidSource ifluidsource = (IFluidSource) block;
|
||||
+ // CraftBukkit start
|
||||
+ ItemStack dummyFluid = ifluidsource.pickupBlock(entityhuman, DummyGeneratorAccess.INSTANCE, blockposition, iblockdata);
|
||||
+ if (dummyFluid.isEmpty()) return InteractionResultWrapper.fail(itemstack); // Don't fire event if the bucket won't be filled.
|
||||
+ if (dummyFluid.isEmpty()) return EnumInteractionResult.FAIL; // Don't fire event if the bucket won't be filled.
|
||||
+ PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent((WorldServer) world, entityhuman, blockposition, blockposition, movingobjectpositionblock.getDirection(), itemstack, dummyFluid.getItem(), enumhand);
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
+ ((EntityPlayer) entityhuman).connection.send(new PacketPlayOutBlockChange(world, blockposition)); // SPIGOT-5163 (see PlayerInteractManager)
|
||||
+ ((EntityPlayer) entityhuman).getBukkitEntity().updateInventory(); // SPIGOT-4541
|
||||
+ return InteractionResultWrapper.fail(itemstack);
|
||||
+ return EnumInteractionResult.FAIL;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
--- a/net/minecraft/world/item/ItemChorusFruit.java
|
||||
+++ b/net/minecraft/world/item/ItemChorusFruit.java
|
||||
@@ -36,7 +36,16 @@
|
||||
|
||||
Vec3D vec3d = entityliving.position();
|
||||
|
||||
- if (entityliving.randomTeleport(d0, d1, d2, true)) {
|
||||
+ // CraftBukkit start - handle canceled status of teleport event
|
||||
+ java.util.Optional<Boolean> status = entityliving.randomTeleport(d0, d1, d2, true, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.CHORUS_FRUIT);
|
||||
+
|
||||
+ if (!status.isPresent()) {
|
||||
+ // teleport event was canceled, no more tries
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ if (status.get()) {
|
||||
+ // CraftBukkit end
|
||||
world.gameEvent((Holder) GameEvent.TELEPORT, vec3d, GameEvent.a.of((Entity) entityliving));
|
||||
SoundEffect soundeffect;
|
||||
SoundCategory soundcategory;
|
||||
@@ -1,23 +1,19 @@
|
||||
--- a/net/minecraft/world/item/ItemEgg.java
|
||||
+++ b/net/minecraft/world/item/ItemEgg.java
|
||||
@@ -22,14 +22,22 @@
|
||||
public InteractionResultWrapper<ItemStack> use(World world, EntityHuman entityhuman, EnumHand enumhand) {
|
||||
@@ -23,10 +23,18 @@
|
||||
public EnumInteractionResult use(World world, EntityHuman entityhuman, EnumHand enumhand) {
|
||||
ItemStack itemstack = entityhuman.getItemInHand(enumhand);
|
||||
|
||||
- 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));
|
||||
+ // 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)); // CraftBukkit - moved down
|
||||
if (!world.isClientSide) {
|
||||
EntityEgg entityegg = new EntityEgg(world, entityhuman);
|
||||
|
||||
entityegg.setItem(itemstack);
|
||||
entityegg.shootFromRotation(entityhuman, entityhuman.getXRot(), entityhuman.getYRot(), 0.0F, 1.5F, 1.0F);
|
||||
- world.addFreshEntity(entityegg);
|
||||
if (world instanceof WorldServer worldserver) {
|
||||
- IProjectile.spawnProjectileFromRotation(EntityEgg::new, worldserver, itemstack, entityhuman, 0.0F, 1.5F, 1.0F);
|
||||
+ // CraftBukkit start
|
||||
+ if (!world.addFreshEntity(entityegg)) {
|
||||
+ if (IProjectile.spawnProjectileFromRotation(EntityEgg::new, worldserver, itemstack, entityhuman, 0.0F, 1.5F, 1.0F).isRemoved()) {
|
||||
+ if (entityhuman instanceof net.minecraft.server.level.EntityPlayer) {
|
||||
+ ((net.minecraft.server.level.EntityPlayer) entityhuman).getBukkitEntity().updateInventory();
|
||||
+ }
|
||||
+ return InteractionResultWrapper.fail(itemstack);
|
||||
+ return EnumInteractionResult.FAIL;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
--- a/net/minecraft/world/item/ItemEnderEye.java
|
||||
+++ b/net/minecraft/world/item/ItemEnderEye.java
|
||||
@@ -97,7 +97,11 @@
|
||||
entityendersignal.setItem(itemstack);
|
||||
entityendersignal.signalTo(blockposition);
|
||||
world.gameEvent((Holder) GameEvent.PROJECTILE_SHOOT, entityendersignal.position(), GameEvent.a.of((Entity) entityhuman));
|
||||
- world.addFreshEntity(entityendersignal);
|
||||
+ // CraftBukkit start
|
||||
+ if (!world.addFreshEntity(entityendersignal)) {
|
||||
+ return new InteractionResultWrapper(EnumInteractionResult.FAIL, itemstack);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
if (entityhuman instanceof EntityPlayer) {
|
||||
EntityPlayer entityplayer = (EntityPlayer) entityhuman;
|
||||
@@ -99,7 +99,11 @@
|
||||
entityendersignal.setItem(itemstack);
|
||||
entityendersignal.signalTo(blockposition);
|
||||
world.gameEvent((Holder) GameEvent.PROJECTILE_SHOOT, entityendersignal.position(), GameEvent.a.of((Entity) entityhuman));
|
||||
- world.addFreshEntity(entityendersignal);
|
||||
+ // CraftBukkit start
|
||||
+ if (!world.addFreshEntity(entityendersignal)) {
|
||||
+ return EnumInteractionResult.FAIL;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
if (entityhuman instanceof EntityPlayer) {
|
||||
EntityPlayer entityplayer = (EntityPlayer) entityhuman;
|
||||
|
||||
|
||||
@@ -1,30 +1,22 @@
|
||||
--- a/net/minecraft/world/item/ItemEnderPearl.java
|
||||
+++ b/net/minecraft/world/item/ItemEnderPearl.java
|
||||
@@ -19,16 +19,24 @@
|
||||
public InteractionResultWrapper<ItemStack> use(World world, EntityHuman entityhuman, EnumHand enumhand) {
|
||||
@@ -21,10 +21,17 @@
|
||||
public EnumInteractionResult use(World world, EntityHuman entityhuman, EnumHand enumhand) {
|
||||
ItemStack itemstack = entityhuman.getItemInHand(enumhand);
|
||||
|
||||
- world.playSound((EntityHuman) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.ENDER_PEARL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F));
|
||||
- entityhuman.getCooldowns().addCooldown(this, 20);
|
||||
+ // CraftBukkit start - change order
|
||||
if (!world.isClientSide) {
|
||||
EntityEnderPearl entityenderpearl = new EntityEnderPearl(world, entityhuman);
|
||||
|
||||
entityenderpearl.setItem(itemstack);
|
||||
entityenderpearl.shootFromRotation(entityhuman, entityhuman.getXRot(), entityhuman.getYRot(), 0.0F, 1.5F, 1.0F);
|
||||
- world.addFreshEntity(entityenderpearl);
|
||||
+ if (!world.addFreshEntity(entityenderpearl)) {
|
||||
if (world instanceof WorldServer worldserver) {
|
||||
- IProjectile.spawnProjectileFromRotation(EntityEnderPearl::new, worldserver, itemstack, entityhuman, 0.0F, 1.5F, 1.0F);
|
||||
+ // CraftBukkit start
|
||||
+ if (IProjectile.spawnProjectileFromRotation(EntityEnderPearl::new, worldserver, itemstack, entityhuman, 0.0F, 1.5F, 1.0F).isRemoved()) {
|
||||
+ if (entityhuman instanceof net.minecraft.server.level.EntityPlayer) {
|
||||
+ ((net.minecraft.server.level.EntityPlayer) entityhuman).getBukkitEntity().updateInventory();
|
||||
+ }
|
||||
+ return InteractionResultWrapper.fail(itemstack);
|
||||
+ return EnumInteractionResult.FAIL;
|
||||
+ }
|
||||
}
|
||||
|
||||
+ world.playSound((EntityHuman) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.ENDER_PEARL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F));
|
||||
+ entityhuman.getCooldowns().addCooldown(this, 20);
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
|
||||
entityhuman.awardStat(StatisticList.ITEM_USED.get(this));
|
||||
itemstack.consume(1, entityhuman);
|
||||
return InteractionResultWrapper.sidedSuccess(itemstack, world.isClientSide());
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/item/ItemFishingRod.java
|
||||
+++ b/net/minecraft/world/item/ItemFishingRod.java
|
||||
@@ -13,6 +13,11 @@
|
||||
@@ -14,6 +14,11 @@
|
||||
import net.minecraft.world.level.World;
|
||||
import net.minecraft.world.level.gameevent.GameEvent;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
public class ItemFishingRod extends Item {
|
||||
|
||||
public ItemFishingRod(Item.Info item_info) {
|
||||
@@ -33,13 +38,24 @@
|
||||
@@ -34,13 +39,24 @@
|
||||
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 {
|
||||
@@ -23,18 +23,18 @@
|
||||
int j = (int) (EnchantmentManager.getFishingTimeReduction(worldserver, itemstack, entityhuman) * 20.0F);
|
||||
int k = EnchantmentManager.getFishingLuckBonus(worldserver, itemstack, entityhuman);
|
||||
|
||||
- world.addFreshEntity(new EntityFishingHook(entityhuman, world, k, j));
|
||||
- IProjectile.spawnProjectile(new EntityFishingHook(entityhuman, world, k, j, itemstack), worldserver, itemstack);
|
||||
+ // CraftBukkit start
|
||||
+ EntityFishingHook entityfishinghook = new EntityFishingHook(entityhuman, world, k, j);
|
||||
+ EntityFishingHook entityfishinghook = new EntityFishingHook(entityhuman, world, k, j, itemstack);
|
||||
+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), null, (org.bukkit.entity.FishHook) entityfishinghook.getBukkitEntity(), CraftEquipmentSlot.getHand(enumhand), PlayerFishEvent.State.FISHING);
|
||||
+ world.getCraftServer().getPluginManager().callEvent(playerFishEvent);
|
||||
+
|
||||
+ if (playerFishEvent.isCancelled()) {
|
||||
+ entityhuman.fishing = null;
|
||||
+ return InteractionResultWrapper.pass(itemstack);
|
||||
+ return EnumInteractionResult.PASS;
|
||||
+ }
|
||||
+ world.playSound((EntityHuman) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.FISHING_BOBBER_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F));
|
||||
+ world.addFreshEntity(entityfishinghook);
|
||||
+ IProjectile.spawnProjectile(entityfishinghook, worldserver, itemstack);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/item/ItemHanging.java
|
||||
+++ b/net/minecraft/world/item/ItemHanging.java
|
||||
@@ -24,6 +24,11 @@
|
||||
@@ -25,6 +25,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);
|
||||
@@ -74,6 +79,19 @@
|
||||
@@ -75,6 +80,19 @@
|
||||
|
||||
if (((EntityHanging) object).survives()) {
|
||||
if (!world.isClientSide) {
|
||||
@@ -32,3 +32,12 @@
|
||||
((EntityHanging) object).playPlacementSound();
|
||||
world.gameEvent((Entity) entityhuman, (Holder) GameEvent.ENTITY_PLACE, ((EntityHanging) object).position());
|
||||
world.addFreshEntity((Entity) object);
|
||||
@@ -102,7 +120,7 @@
|
||||
|
||||
if (!customdata.isEmpty()) {
|
||||
customdata.read(holderlookup_a.createSerializationContext(DynamicOpsNBT.INSTANCE), EntityPainting.VARIANT_MAP_CODEC).result().ifPresentOrElse((holder) -> {
|
||||
- Optional optional = ((PaintingVariant) holder.value()).title();
|
||||
+ Optional<IChatBaseComponent> optional = ((PaintingVariant) holder.value()).title(); // CraftBukkit - decompile error
|
||||
|
||||
Objects.requireNonNull(list);
|
||||
optional.ifPresent(list::add);
|
||||
|
||||
@@ -13,17 +13,16 @@
|
||||
public class ItemLeash extends Item {
|
||||
|
||||
public ItemLeash(Item.Info item_info) {
|
||||
@@ -35,7 +41,7 @@
|
||||
@@ -35,14 +41,14 @@
|
||||
EntityHuman entityhuman = itemactioncontext.getPlayer();
|
||||
|
||||
if (!world.isClientSide && entityhuman != null) {
|
||||
- bindPlayerMobs(entityhuman, world, blockposition);
|
||||
+ bindPlayerMobs(entityhuman, world, blockposition, itemactioncontext.getHand()); // CraftBukkit - Pass hand
|
||||
- return bindPlayerMobs(entityhuman, world, blockposition);
|
||||
+ return bindPlayerMobs(entityhuman, world, blockposition, itemactioncontext.getHand()); // CraftBukkit - Pass hand
|
||||
}
|
||||
|
||||
return EnumInteractionResult.sidedSuccess(world.isClientSide);
|
||||
@@ -44,7 +50,7 @@
|
||||
}
|
||||
|
||||
return EnumInteractionResult.PASS;
|
||||
}
|
||||
|
||||
- public static EnumInteractionResult bindPlayerMobs(EntityHuman entityhuman, World world, BlockPosition blockposition) {
|
||||
@@ -31,7 +30,7 @@
|
||||
EntityLeash entityleash = null;
|
||||
List<Leashable> list = leashableInArea(world, blockposition, (leashable) -> {
|
||||
return leashable.getLeashHolder() == entityhuman;
|
||||
@@ -52,22 +58,55 @@
|
||||
@@ -50,22 +56,55 @@
|
||||
|
||||
Leashable leashable;
|
||||
|
||||
@@ -68,7 +67,7 @@
|
||||
|
||||
if (!list.isEmpty()) {
|
||||
world.gameEvent((Holder) GameEvent.BLOCK_ATTACH, blockposition, GameEvent.a.of((Entity) entityhuman));
|
||||
return EnumInteractionResult.SUCCESS;
|
||||
return EnumInteractionResult.SUCCESS_SERVER;
|
||||
} else {
|
||||
+ // CraftBukkit start- remove leash if we do not leash any entity because of the cancelled event
|
||||
+ if (entityleash != null) {
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
--- a/net/minecraft/world/item/ItemMilkBucket.java
|
||||
+++ b/net/minecraft/world/item/ItemMilkBucket.java
|
||||
@@ -25,7 +25,7 @@
|
||||
}
|
||||
|
||||
if (!world.isClientSide) {
|
||||
- entityliving.removeAllEffects();
|
||||
+ entityliving.removeAllEffects(org.bukkit.event.entity.EntityPotionEffectEvent.Cause.MILK); // CraftBukkit
|
||||
}
|
||||
|
||||
if (entityliving instanceof EntityHuman entityhuman) {
|
||||
@@ -1,72 +1,16 @@
|
||||
--- a/net/minecraft/world/item/ItemMinecart.java
|
||||
+++ b/net/minecraft/world/item/ItemMinecart.java
|
||||
@@ -20,6 +20,12 @@
|
||||
import net.minecraft.world.level.gameevent.GameEvent;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
@@ -67,7 +67,12 @@
|
||||
if (world instanceof WorldServer) {
|
||||
WorldServer worldserver = (WorldServer) world;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.block.CraftBlock;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
+import org.bukkit.event.block.BlockDispenseEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class ItemMinecart extends Item {
|
||||
|
||||
private static final IDispenseBehavior DISPENSE_ITEM_BEHAVIOR = new DispenseBehaviorItem() {
|
||||
@@ -59,10 +65,39 @@
|
||||
- worldserver.addFreshEntity(entityminecartabstract);
|
||||
+ // CraftBukkit start
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPlaceEvent(itemactioncontext, entityminecartabstract).isCancelled()) {
|
||||
+ return EnumInteractionResult.FAIL;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+ if (!worldserver.addFreshEntity(entityminecartabstract)) return EnumInteractionResult.PASS; // CraftBukkit
|
||||
worldserver.gameEvent((Holder) GameEvent.ENTITY_PLACE, blockposition, GameEvent.a.of(itemactioncontext.getPlayer(), worldserver.getBlockState(blockposition.below())));
|
||||
}
|
||||
}
|
||||
|
||||
- EntityMinecartAbstract entityminecartabstract = EntityMinecartAbstract.createMinecart(worldserver, d0, d1 + d3, d2, ((ItemMinecart) itemstack.getItem()).type, itemstack, (EntityHuman) null);
|
||||
+ // CraftBukkit start
|
||||
+ // EntityMinecartAbstract entityminecartabstract = EntityMinecartAbstract.createMinecart(worldserver, d0, d1 + d3, d2, ((ItemMinecart) itemstack.getItem()).type);
|
||||
+ ItemStack itemstack1 = itemstack.split(1);
|
||||
+ org.bukkit.block.Block block2 = CraftBlock.at(worldserver, sourceblock.pos());
|
||||
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
|
||||
|
||||
- worldserver.addFreshEntity(entityminecartabstract);
|
||||
- itemstack.shrink(1);
|
||||
+ BlockDispenseEvent event = new BlockDispenseEvent(block2, craftItem.clone(), new org.bukkit.util.Vector(d0, d1 + d3, d2));
|
||||
+ if (!BlockDispenser.eventFired) {
|
||||
+ worldserver.getCraftServer().getPluginManager().callEvent(event);
|
||||
+ }
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
+ itemstack.grow(1);
|
||||
+ return itemstack;
|
||||
+ }
|
||||
+
|
||||
+ if (!event.getItem().equals(craftItem)) {
|
||||
+ itemstack.grow(1);
|
||||
+ // Chain to handler for new item
|
||||
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
|
||||
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem());
|
||||
+ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != this) {
|
||||
+ idispensebehavior.dispense(sourceblock, eventStack);
|
||||
+ return itemstack;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ itemstack1 = CraftItemStack.asNMSCopy(event.getItem());
|
||||
+ EntityMinecartAbstract entityminecartabstract = EntityMinecartAbstract.createMinecart(worldserver, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), ((ItemMinecart) itemstack1.getItem()).type, itemstack1, (EntityHuman) null);
|
||||
+
|
||||
+ if (!worldserver.addFreshEntity(entityminecartabstract)) itemstack.grow(1);
|
||||
+ // itemstack.shrink(1); // CraftBukkit - handled during event processing
|
||||
+ // CraftBukkit end
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
|
||||
- worldserver.addFreshEntity(entityminecartabstract);
|
||||
+ // CraftBukkit start
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPlaceEvent(itemactioncontext, entityminecartabstract).isCancelled()) {
|
||||
+ return EnumInteractionResult.FAIL;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+ if (!worldserver.addFreshEntity(entityminecartabstract)) return EnumInteractionResult.PASS; // CraftBukkit
|
||||
worldserver.gameEvent((Holder) GameEvent.ENTITY_PLACE, blockposition, GameEvent.a.of(itemactioncontext.getPlayer(), worldserver.getBlockState(blockposition.below())));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/item/ItemMonsterEgg.java
|
||||
+++ b/net/minecraft/world/item/ItemMonsterEgg.java
|
||||
@@ -177,10 +177,10 @@
|
||||
@@ -176,10 +176,10 @@
|
||||
return Optional.empty();
|
||||
} else {
|
||||
((EntityInsentient) object).moveTo(vec3d.x(), vec3d.y(), vec3d.z(), 0.0F, 0.0F);
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
--- a/net/minecraft/world/item/ItemPotion.java
|
||||
+++ b/net/minecraft/world/item/ItemPotion.java
|
||||
@@ -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(mobeffect);
|
||||
+ entityliving.addEffect(mobeffect, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.POTION_DRINK); // CraftBukkit
|
||||
}
|
||||
|
||||
});
|
||||
@@ -1,11 +1,16 @@
|
||||
--- a/net/minecraft/world/item/ItemProjectileWeapon.java
|
||||
+++ b/net/minecraft/world/item/ItemProjectileWeapon.java
|
||||
@@ -62,7 +62,22 @@
|
||||
IProjectile iprojectile = this.createProjectile(worldserver, entityliving, itemstack, itemstack1, flag);
|
||||
@@ -54,9 +54,25 @@
|
||||
float f6 = f4 + f5 * (float) ((i + 1) / 2) * f3;
|
||||
|
||||
this.shootProjectile(entityliving, iprojectile, i, f, f1, f6, entityliving1);
|
||||
- worldserver.addFreshEntity(iprojectile);
|
||||
f5 = -f5;
|
||||
- IProjectile.spawnProjectile(this.createProjectile(worldserver, entityliving, itemstack, itemstack1, flag), worldserver, itemstack1, (iprojectile) -> {
|
||||
- this.shootProjectile(entityliving, iprojectile, i, f, f1, f6, entityliving1);
|
||||
- });
|
||||
+ // CraftBukkit start
|
||||
+ IProjectile iprojectile = this.createProjectile(worldserver, entityliving, itemstack, itemstack1, flag);
|
||||
+ this.shootProjectile(entityliving, iprojectile, i, f, f1, f6, entityliving1);
|
||||
+
|
||||
+ 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();
|
||||
@@ -13,7 +18,7 @@
|
||||
+ }
|
||||
+
|
||||
+ if (event.getProjectile() == iprojectile.getBukkitEntity()) {
|
||||
+ if (!worldserver.addFreshEntity(iprojectile)) {
|
||||
+ if (IProjectile.spawnProjectile(iprojectile, worldserver, itemstack1).isRemoved()) {
|
||||
+ if (entityliving instanceof net.minecraft.server.level.EntityPlayer) {
|
||||
+ ((net.minecraft.server.level.EntityPlayer) entityliving).getBukkitEntity().updateInventory();
|
||||
+ }
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
|
||||
+ public static BlockPosition openSign; // CraftBukkit
|
||||
+
|
||||
public ItemSign(Item.Info item_info, Block block, Block block1) {
|
||||
super(block, block1, item_info, EnumDirection.DOWN);
|
||||
public ItemSign(Block block, Block block1, Item.Info item_info) {
|
||||
super(block, block1, EnumDirection.DOWN, item_info);
|
||||
}
|
||||
@@ -35,7 +37,10 @@
|
||||
if (block instanceof BlockSign) {
|
||||
|
||||
@@ -1,31 +1,27 @@
|
||||
--- a/net/minecraft/world/item/ItemSnowball.java
|
||||
+++ b/net/minecraft/world/item/ItemSnowball.java
|
||||
@@ -22,17 +22,25 @@
|
||||
public InteractionResultWrapper<ItemStack> use(World world, EntityHuman entityhuman, EnumHand enumhand) {
|
||||
@@ -23,13 +23,21 @@
|
||||
public EnumInteractionResult use(World world, EntityHuman entityhuman, EnumHand enumhand) {
|
||||
ItemStack itemstack = entityhuman.getItemInHand(enumhand);
|
||||
|
||||
- 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));
|
||||
+ // CraftBukkit - moved down
|
||||
+ // CraftBukkit start - moved down
|
||||
+ // 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));
|
||||
if (!world.isClientSide) {
|
||||
EntitySnowball entitysnowball = new EntitySnowball(world, entityhuman);
|
||||
|
||||
entitysnowball.setItem(itemstack);
|
||||
entitysnowball.shootFromRotation(entityhuman, entityhuman.getXRot(), entityhuman.getYRot(), 0.0F, 1.5F, 1.0F);
|
||||
- world.addFreshEntity(entitysnowball);
|
||||
+ if (world.addFreshEntity(entitysnowball)) {
|
||||
if (world instanceof WorldServer worldserver) {
|
||||
- IProjectile.spawnProjectileFromRotation(EntitySnowball::new, worldserver, itemstack, entityhuman, 0.0F, 1.5F, 1.0F);
|
||||
+ if (IProjectile.spawnProjectileFromRotation(EntitySnowball::new, worldserver, itemstack, entityhuman, 0.0F, 1.5F, 1.0F).isAlive()) {
|
||||
+ 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) {
|
||||
+ ((net.minecraft.server.level.EntityPlayer) entityhuman).getBukkitEntity().updateInventory();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
+ // CraftBukkit end
|
||||
|
||||
entityhuman.awardStat(StatisticList.ITEM_USED.get(this));
|
||||
- itemstack.consume(1, entityhuman);
|
||||
+ // itemstack.consume(1, entityhuman); // CraftBukkit - moved up
|
||||
return InteractionResultWrapper.sidedSuccess(itemstack, world.isClientSide());
|
||||
return EnumInteractionResult.SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/item/ItemStack.java
|
||||
+++ b/net/minecraft/world/item/ItemStack.java
|
||||
@@ -91,6 +91,40 @@
|
||||
@@ -96,17 +96,51 @@
|
||||
import org.apache.commons.lang3.mutable.MutableBoolean;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@@ -40,14 +40,10 @@
|
||||
+
|
||||
public final class ItemStack implements DataComponentHolder {
|
||||
|
||||
public static final Codec<Holder<Item>> ITEM_NON_AIR_CODEC = BuiltInRegistries.ITEM.holderByNameCodec().validate((holder) -> {
|
||||
@@ -99,14 +133,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.intRange(1, 99).fieldOf("count").orElse(1).forGetter(ItemStack::getCount), DataComponentPatch.CODEC.optionalFieldOf("components", DataComponentPatch.EMPTY).forGetter((itemstack) -> {
|
||||
return instance.group(Item.CODEC.fieldOf("id").forGetter(ItemStack::getItemHolder), ExtraCodecs.intRange(1, 99).fieldOf("count").orElse(1).forGetter(ItemStack::getCount), DataComponentPatch.CODEC.optionalFieldOf("components", DataComponentPatch.EMPTY).forGetter((itemstack) -> {
|
||||
return itemstack.components.asPatch();
|
||||
})).apply(instance, ItemStack::new);
|
||||
});
|
||||
@@ -55,7 +51,7 @@
|
||||
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 instance.group(Item.CODEC.fieldOf("id").forGetter(ItemStack::getItemHolder), DataComponentPatch.CODEC.optionalFieldOf("components", DataComponentPatch.EMPTY).forGetter((itemstack) -> {
|
||||
return itemstack.components.asPatch();
|
||||
})).apply(instance, (holder, datacomponentpatch) -> {
|
||||
@@ -131,19 +165,25 @@
|
||||
@@ -88,7 +84,7 @@
|
||||
DataComponentPatch.STREAM_CODEC.encode(registryfriendlybytebuf, itemstack.components.asPatch());
|
||||
}
|
||||
}
|
||||
@@ -187,7 +227,7 @@
|
||||
@@ -186,7 +226,7 @@
|
||||
|
||||
return dataresult.isError() ? dataresult.map((unit) -> {
|
||||
return itemstack;
|
||||
@@ -97,7 +93,7 @@
|
||||
int i = itemstack.getCount();
|
||||
|
||||
return "Item stack with stack size of " + i + " was larger than maximum: " + itemstack.getMaxStackSize();
|
||||
@@ -286,8 +326,9 @@
|
||||
@@ -289,8 +329,9 @@
|
||||
j = itemstack.getMaxStackSize();
|
||||
} while (i <= j);
|
||||
|
||||
@@ -108,7 +104,7 @@
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -369,11 +410,169 @@
|
||||
@@ -372,15 +413,173 @@
|
||||
return EnumInteractionResult.PASS;
|
||||
} else {
|
||||
Item item = this.getItem();
|
||||
@@ -171,108 +167,112 @@
|
||||
+ }
|
||||
+ world.captureTreeGeneration = false;
|
||||
|
||||
if (entityhuman != null && enuminteractionresult.indicateItemUse()) {
|
||||
- entityhuman.awardStat(StatisticList.ITEM_USED.get(item));
|
||||
+ EnumHand enumhand = itemactioncontext.getHand();
|
||||
+ org.bukkit.event.block.BlockPlaceEvent placeEvent = null;
|
||||
+ List<BlockState> blocks = new java.util.ArrayList<>(world.capturedBlockStates.values());
|
||||
+ world.capturedBlockStates.clear();
|
||||
+ if (blocks.size() > 1) {
|
||||
+ placeEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockMultiPlaceEvent(world, entityhuman, enumhand, blocks, blockposition.getX(), blockposition.getY(), blockposition.getZ());
|
||||
+ } else if (blocks.size() == 1) {
|
||||
+ placeEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPlaceEvent(world, entityhuman, enumhand, blocks.get(0), blockposition.getX(), blockposition.getY(), blockposition.getZ());
|
||||
+ }
|
||||
+
|
||||
+ if (placeEvent != null && (placeEvent.isCancelled() || !placeEvent.canBuild())) {
|
||||
+ enuminteractionresult = EnumInteractionResult.FAIL; // cancel placement
|
||||
+ // PAIL: Remove this when MC-99075 fixed
|
||||
+ placeEvent.getPlayer().updateInventory();
|
||||
+ // revert back all captured blocks
|
||||
+ world.preventPoiUpdated = true; // CraftBukkit - SPIGOT-5710
|
||||
+ for (BlockState blockstate : blocks) {
|
||||
+ blockstate.update(true, false);
|
||||
+ }
|
||||
+ world.preventPoiUpdated = false;
|
||||
+
|
||||
+ // Brute force all possible updates
|
||||
+ BlockPosition placedPos = ((CraftBlock) placeEvent.getBlock()).getPosition();
|
||||
+ for (EnumDirection dir : EnumDirection.values()) {
|
||||
+ ((EntityPlayer) entityhuman).connection.send(new PacketPlayOutBlockChange(world, placedPos.relative(dir)));
|
||||
+ }
|
||||
+ 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.components.asPatch(), oldData)) {
|
||||
+ this.restorePatch(newData);
|
||||
+ this.setCount(newCount);
|
||||
if (entityhuman != null && enuminteractionresult instanceof EnumInteractionResult.d) {
|
||||
EnumInteractionResult.d enuminteractionresult_d = (EnumInteractionResult.d) enuminteractionresult;
|
||||
|
||||
if (enuminteractionresult_d.wasItemInteraction()) {
|
||||
- entityhuman.awardStat(StatisticList.ITEM_USED.get(item));
|
||||
+ EnumHand enumhand = itemactioncontext.getHand();
|
||||
+ org.bukkit.event.block.BlockPlaceEvent placeEvent = null;
|
||||
+ List<BlockState> blocks = new java.util.ArrayList<>(world.capturedBlockStates.values());
|
||||
+ world.capturedBlockStates.clear();
|
||||
+ if (blocks.size() > 1) {
|
||||
+ placeEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockMultiPlaceEvent(world, entityhuman, enumhand, blocks, blockposition.getX(), blockposition.getY(), blockposition.getZ());
|
||||
+ } else if (blocks.size() == 1) {
|
||||
+ placeEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPlaceEvent(world, entityhuman, enumhand, blocks.get(0), blockposition.getX(), blockposition.getY(), blockposition.getZ());
|
||||
+ }
|
||||
+
|
||||
+ for (Map.Entry<BlockPosition, TileEntity> e : world.capturedTileEntities.entrySet()) {
|
||||
+ world.setBlockEntity(e.getValue());
|
||||
+ }
|
||||
+ 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
|
||||
+ world.preventPoiUpdated = true; // CraftBukkit - SPIGOT-5710
|
||||
+ for (BlockState blockstate : blocks) {
|
||||
+ blockstate.update(true, false);
|
||||
+ }
|
||||
+ world.preventPoiUpdated = false;
|
||||
+
|
||||
+ for (BlockState blockstate : blocks) {
|
||||
+ int updateFlag = ((CraftBlockState) blockstate).getFlag();
|
||||
+ IBlockData oldBlock = ((CraftBlockState) blockstate).getHandle();
|
||||
+ BlockPosition newblockposition = ((CraftBlockState) blockstate).getPosition();
|
||||
+ IBlockData block = world.getBlockState(newblockposition);
|
||||
+
|
||||
+ if (!(block.getBlock() instanceof BlockTileEntity)) { // Containers get placed automatically
|
||||
+ block.onPlace(world, newblockposition, oldBlock, true, itemactioncontext);
|
||||
+ // Brute force all possible updates
|
||||
+ BlockPosition placedPos = ((CraftBlock) placeEvent.getBlock()).getPosition();
|
||||
+ for (EnumDirection dir : EnumDirection.values()) {
|
||||
+ ((EntityPlayer) entityhuman).connection.send(new PacketPlayOutBlockChange(world, placedPos.relative(dir)));
|
||||
+ }
|
||||
+ 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.components.asPatch(), oldData)) {
|
||||
+ this.restorePatch(newData);
|
||||
+ this.setCount(newCount);
|
||||
+ }
|
||||
+
|
||||
+ world.notifyAndUpdatePhysics(newblockposition, null, oldBlock, block, world.getBlockState(newblockposition), updateFlag, 512); // send null chunk as chunk.k() returns false by this point
|
||||
+ }
|
||||
+ for (Map.Entry<BlockPosition, TileEntity> e : world.capturedTileEntities.entrySet()) {
|
||||
+ world.setBlockEntity(e.getValue());
|
||||
+ }
|
||||
+
|
||||
+ if (this.item == Items.WITHER_SKELETON_SKULL) { // Special case skulls to allow wither spawns to be cancelled
|
||||
+ BlockPosition bp = blockposition;
|
||||
+ if (!world.getBlockState(blockposition).canBeReplaced()) {
|
||||
+ if (!world.getBlockState(blockposition).isSolid()) {
|
||||
+ bp = null;
|
||||
+ } else {
|
||||
+ bp = bp.relative(itemactioncontext.getClickedFace());
|
||||
+ for (BlockState blockstate : blocks) {
|
||||
+ int updateFlag = ((CraftBlockState) blockstate).getFlag();
|
||||
+ IBlockData oldBlock = ((CraftBlockState) blockstate).getHandle();
|
||||
+ BlockPosition newblockposition = ((CraftBlockState) blockstate).getPosition();
|
||||
+ IBlockData block = world.getBlockState(newblockposition);
|
||||
+
|
||||
+ if (!(block.getBlock() instanceof BlockTileEntity)) { // Containers get placed automatically
|
||||
+ block.onPlace(world, newblockposition, oldBlock, true, itemactioncontext);
|
||||
+ }
|
||||
+ }
|
||||
+ if (bp != null) {
|
||||
+ TileEntity te = world.getBlockEntity(bp);
|
||||
+ if (te instanceof TileEntitySkull) {
|
||||
+ BlockWitherSkull.checkSpawn(world, bp, (TileEntitySkull) te);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ // SPIGOT-4678
|
||||
+ if (this.item instanceof ItemSign && ItemSign.openSign != null) {
|
||||
+ try {
|
||||
+ if (world.getBlockEntity(ItemSign.openSign) instanceof TileEntitySign tileentitysign) {
|
||||
+ if (world.getBlockState(ItemSign.openSign).getBlock() instanceof BlockSign blocksign) {
|
||||
+ blocksign.openTextEdit(entityhuman, tileentitysign, true, org.bukkit.event.player.PlayerSignOpenEvent.Cause.PLACE); // Craftbukkit
|
||||
+ world.notifyAndUpdatePhysics(newblockposition, null, oldBlock, block, world.getBlockState(newblockposition), updateFlag, 512); // send null chunk as chunk.k() returns false by this point
|
||||
+ }
|
||||
+
|
||||
+ if (this.item == Items.WITHER_SKELETON_SKULL) { // Special case skulls to allow wither spawns to be cancelled
|
||||
+ BlockPosition bp = blockposition;
|
||||
+ if (!world.getBlockState(blockposition).canBeReplaced()) {
|
||||
+ if (!world.getBlockState(blockposition).isSolid()) {
|
||||
+ bp = null;
|
||||
+ } else {
|
||||
+ bp = bp.relative(itemactioncontext.getClickedFace());
|
||||
+ }
|
||||
+ }
|
||||
+ if (bp != null) {
|
||||
+ TileEntity te = world.getBlockEntity(bp);
|
||||
+ if (te instanceof TileEntitySkull) {
|
||||
+ BlockWitherSkull.checkSpawn(world, bp, (TileEntitySkull) te);
|
||||
+ }
|
||||
+ }
|
||||
+ } finally {
|
||||
+ ItemSign.openSign = null;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ // 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);
|
||||
+ // SPIGOT-4678
|
||||
+ if (this.item instanceof ItemSign && ItemSign.openSign != null) {
|
||||
+ try {
|
||||
+ if (world.getBlockEntity(ItemSign.openSign) instanceof TileEntitySign tileentitysign) {
|
||||
+ if (world.getBlockState(ItemSign.openSign).getBlock() instanceof BlockSign blocksign) {
|
||||
+ blocksign.openTextEdit(entityhuman, tileentitysign, true, org.bukkit.event.player.PlayerSignOpenEvent.Cause.PLACE); // Craftbukkit
|
||||
+ }
|
||||
+ }
|
||||
+ } finally {
|
||||
+ ItemSign.openSign = null;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ // SPIGOT-1288 - play sound stripped from ItemBlock
|
||||
+ if (this.item instanceof ItemBlock) {
|
||||
+ SoundEffectType soundeffecttype = ((ItemBlock) this.item).getBlock().defaultBlockState().getSoundType(); // TODO: not strictly correct, however currently only affects decorated pots
|
||||
+ world.playSound(entityhuman, blockposition, soundeffecttype.getPlaceSound(), SoundCategory.BLOCKS, (soundeffecttype.getVolume() + 1.0F) / 2.0F, soundeffecttype.getPitch() * 0.8F);
|
||||
+ }
|
||||
+ // SPIGOT-7315: Moved from BlockBed#setPlacedBy
|
||||
+ if (placeEvent != null && this.item instanceof ItemBed) {
|
||||
+ BlockPosition position = ((CraftBlock) placeEvent.getBlock()).getPosition();
|
||||
+ IBlockData blockData = world.getBlockState(position);
|
||||
+
|
||||
+ entityhuman.awardStat(StatisticList.ITEM_USED.get(item));
|
||||
+ }
|
||||
+ if (blockData.getBlock() instanceof BlockBed) {
|
||||
+ world.blockUpdated(position, Blocks.AIR);
|
||||
+ blockData.updateNeighbourShapes(world, position, 3);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ // SPIGOT-1288 - play sound stripped from ItemBlock
|
||||
+ if (this.item instanceof ItemBlock) {
|
||||
+ SoundEffectType soundeffecttype = ((ItemBlock) this.item).getBlock().defaultBlockState().getSoundType(); // TODO: not strictly correct, however currently only affects decorated pots
|
||||
+ world.playSound(entityhuman, blockposition, soundeffecttype.getPlaceSound(), SoundCategory.BLOCKS, (soundeffecttype.getVolume() + 1.0F) / 2.0F, soundeffecttype.getPitch() * 0.8F);
|
||||
+ }
|
||||
+
|
||||
+ entityhuman.awardStat(StatisticList.ITEM_USED.get(item));
|
||||
+ }
|
||||
}
|
||||
}
|
||||
+ world.capturedTileEntities.clear();
|
||||
+ world.capturedBlockStates.clear();
|
||||
@@ -280,41 +280,41 @@
|
||||
|
||||
return enuminteractionresult;
|
||||
}
|
||||
@@ -444,6 +643,21 @@
|
||||
if (entityplayer == null || !entityplayer.hasInfiniteMaterials()) {
|
||||
if (i > 0) {
|
||||
i = EnchantmentManager.processDurabilityChange(worldserver, this, i);
|
||||
+ // 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()) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ i = event.getDamage();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
if (i <= 0) {
|
||||
return;
|
||||
}
|
||||
@@ -458,6 +672,11 @@
|
||||
this.setDamageValue(j);
|
||||
if (j >= this.getMaxDamage()) {
|
||||
Item item = this.getItem();
|
||||
+ // CraftBukkit start - Check for item breaking
|
||||
+ if (this.count == 1 && entityplayer != null) {
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerItemBreakEvent(entityplayer, this);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
@@ -487,6 +686,21 @@
|
||||
|
||||
this.shrink(1);
|
||||
consumer.accept(item);
|
||||
@@ -693,6 +912,12 @@
|
||||
public void hurtAndBreak(int i, WorldServer worldserver, @Nullable EntityPlayer entityplayer, Consumer<Item> consumer) {
|
||||
int j = this.processDurabilityChange(i, worldserver, entityplayer);
|
||||
+ // CraftBukkit start
|
||||
+ if (entityplayer != null) {
|
||||
+ PlayerItemDamageEvent event = new PlayerItemDamageEvent(entityplayer.getBukkitEntity(), CraftItemStack.asCraftMirror(this), j);
|
||||
+ event.getPlayer().getServer().getPluginManager().callEvent(event);
|
||||
+
|
||||
+ if (j != event.getDamage() || event.isCancelled()) {
|
||||
+ event.getPlayer().updateInventory();
|
||||
+ }
|
||||
+ if (event.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ j = event.getDamage();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
if (j != 0) {
|
||||
this.applyDamage(this.getDamageValue() + j, entityplayer, consumer);
|
||||
@@ -506,6 +720,11 @@
|
||||
this.setDamageValue(i);
|
||||
if (this.isBroken()) {
|
||||
Item item = this.getItem();
|
||||
+ // CraftBukkit start - Check for item breaking
|
||||
+ if (this.count == 1 && entityplayer != null) {
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerItemBreakEvent(entityplayer, this);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
this.shrink(1);
|
||||
consumer.accept(item);
|
||||
@@ -765,6 +984,12 @@
|
||||
return this.getItem().useOnRelease(this);
|
||||
}
|
||||
|
||||
@@ -327,7 +327,7 @@
|
||||
@Nullable
|
||||
public <T> T set(DataComponentType<? super T> datacomponenttype, @Nullable T t0) {
|
||||
return this.components.set(datacomponenttype, t0);
|
||||
@@ -752,7 +977,7 @@
|
||||
@@ -846,7 +1071,7 @@
|
||||
}
|
||||
|
||||
private <T extends TooltipProvider> void addToTooltip(DataComponentType<T> datacomponenttype, Item.b item_b, Consumer<IChatBaseComponent> consumer, TooltipFlag tooltipflag) {
|
||||
@@ -336,7 +336,7 @@
|
||||
|
||||
if (t0 != null) {
|
||||
t0.addToTooltip(item_b, consumer, tooltipflag);
|
||||
@@ -992,6 +1217,13 @@
|
||||
@@ -1073,6 +1298,13 @@
|
||||
EnchantmentManager.forEachModifier(this, enumitemslot, biconsumer);
|
||||
}
|
||||
|
||||
@@ -350,7 +350,7 @@
|
||||
public IChatBaseComponent getDisplayName() {
|
||||
IChatMutableComponent ichatmutablecomponent = IChatBaseComponent.empty().append(this.getHoverName());
|
||||
|
||||
@@ -1054,7 +1286,7 @@
|
||||
@@ -1135,7 +1367,7 @@
|
||||
}
|
||||
|
||||
public void consume(int i, @Nullable EntityLiving entityliving) {
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
--- a/net/minecraft/world/item/ItemSuspiciousStew.java
|
||||
+++ b/net/minecraft/world/item/ItemSuspiciousStew.java
|
||||
@@ -53,4 +53,15 @@
|
||||
|
||||
return super.finishUsingItem(itemstack, world, entityliving);
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ public void cancelUsingItem(net.minecraft.server.level.EntityPlayer entityplayer, ItemStack itemstack) {
|
||||
+ SuspiciousStewEffects suspicioussteweffects = (SuspiciousStewEffects) itemstack.getOrDefault(DataComponents.SUSPICIOUS_STEW_EFFECTS, SuspiciousStewEffects.EMPTY);
|
||||
+
|
||||
+ for (SuspiciousStewEffects.a suspicioussteweffects_a : suspicioussteweffects.effects()) {
|
||||
+ entityplayer.connection.send(new net.minecraft.network.protocol.game.PacketPlayOutRemoveEntityEffect(entityplayer.getId(), suspicioussteweffects_a.effect()));
|
||||
+ }
|
||||
+ entityplayer.server.getPlayerList().sendActivePlayerEffects(entityplayer);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
@@ -1,47 +1,42 @@
|
||||
--- a/net/minecraft/world/item/ItemTrident.java
|
||||
+++ b/net/minecraft/world/item/ItemTrident.java
|
||||
@@ -77,7 +77,7 @@
|
||||
Holder<SoundEffect> holder = (Holder) EnchantmentManager.pickHighestLevel(itemstack, EnchantmentEffectComponents.TRIDENT_SOUND).orElse(SoundEffects.TRIDENT_THROW);
|
||||
@@ -85,9 +85,19 @@
|
||||
if (world instanceof WorldServer) {
|
||||
WorldServer worldserver = (WorldServer) world;
|
||||
|
||||
if (!world.isClientSide) {
|
||||
- itemstack.hurtAndBreak(1, entityhuman, EntityLiving.getSlotForHand(entityliving.getUsedItemHand()));
|
||||
+ // itemstack.hurtAndBreak(1, entityhuman, EntityLiving.getSlotForHand(entityliving.getUsedItemHand())); // CraftBukkit - moved down
|
||||
if (f == 0.0F) {
|
||||
EntityThrownTrident entitythrowntrident = new EntityThrownTrident(world, entityhuman, itemstack);
|
||||
|
||||
@@ -86,11 +86,26 @@
|
||||
entitythrowntrident.pickup = EntityArrow.PickupStatus.CREATIVE_ONLY;
|
||||
}
|
||||
|
||||
- world.addFreshEntity(entitythrowntrident);
|
||||
+ // CraftBukkit start
|
||||
+ if (!world.addFreshEntity(entitythrowntrident)) {
|
||||
+ if (entityhuman instanceof net.minecraft.server.level.EntityPlayer) {
|
||||
+ ((net.minecraft.server.level.EntityPlayer) entityhuman).getBukkitEntity().updateInventory();
|
||||
+ }
|
||||
+ return;
|
||||
- itemstack.hurtWithoutBreaking(1, entityhuman);
|
||||
+ // itemstack.hurtWithoutBreaking(1, entityhuman); // CraftBukkit - moved down
|
||||
if (f == 0.0F) {
|
||||
EntityThrownTrident entitythrowntrident = (EntityThrownTrident) IProjectile.spawnProjectileFromRotation(EntityThrownTrident::new, worldserver, itemstack, entityhuman, 0.0F, 2.5F, 1.0F);
|
||||
+ // CraftBukkit start
|
||||
+ if (entitythrowntrident.isRemoved()) {
|
||||
+ if (entityhuman instanceof net.minecraft.server.level.EntityPlayer) {
|
||||
+ ((net.minecraft.server.level.EntityPlayer) entityhuman).getBukkitEntity().updateInventory();
|
||||
+ }
|
||||
+
|
||||
+ 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, (SoundEffect) holder.value(), SoundCategory.PLAYERS, 1.0F, 1.0F);
|
||||
if (!entityhuman.hasInfiniteMaterials()) {
|
||||
entityhuman.getInventory().removeItem(itemstack);
|
||||
}
|
||||
+ // CraftBukkit start - SPIGOT-5458 also need in this branch :(
|
||||
+ } else {
|
||||
+ itemstack.hurtAndBreak(1, entityhuman, EntityLiving.getSlotForHand(entityliving.getUsedItemHand()));
|
||||
+ // CraftBukkkit end
|
||||
}
|
||||
}
|
||||
+ return false;
|
||||
+ }
|
||||
+ itemstack.hurtWithoutBreaking(1, entityhuman);
|
||||
+ entitythrowntrident.pickupItemStack = itemstack.copy(); // SPIGOT-4511 update since damage call moved
|
||||
+ // CraftBukkit end
|
||||
|
||||
@@ -106,6 +121,7 @@
|
||||
f3 *= f / f6;
|
||||
f4 *= f / f6;
|
||||
f5 *= f / f6;
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerRiptideEvent(entityhuman, itemstack, f3, f4, f5); // CraftBukkit
|
||||
entityhuman.push((double) f3, (double) f4, (double) f5);
|
||||
entityhuman.startAutoSpinAttack(20, 8.0F, itemstack);
|
||||
if (entityhuman.onGround()) {
|
||||
if (entityhuman.hasInfiniteMaterials()) {
|
||||
entitythrowntrident.pickup = EntityArrow.PickupStatus.CREATIVE_ONLY;
|
||||
@@ -97,6 +107,10 @@
|
||||
|
||||
world.playSound((EntityHuman) null, (Entity) entitythrowntrident, (SoundEffect) holder.value(), SoundCategory.PLAYERS, 1.0F, 1.0F);
|
||||
return true;
|
||||
+ // CraftBukkit start - SPIGOT-5458 also need in this branch :(
|
||||
+ } else {
|
||||
+ itemstack.hurtWithoutBreaking(1, entityhuman);
|
||||
+ // CraftBukkkit end
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,6 +126,7 @@
|
||||
f3 *= f / f6;
|
||||
f4 *= f / f6;
|
||||
f5 *= f / f6;
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerRiptideEvent(entityhuman, itemstack, f3, f4, f5); // CraftBukkit
|
||||
entityhuman.push((double) f3, (double) f4, (double) f5);
|
||||
entityhuman.startAutoSpinAttack(20, 8.0F, itemstack);
|
||||
if (entityhuman.onGround()) {
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
--- a/net/minecraft/world/item/alchemy/PotionContents.java
|
||||
+++ b/net/minecraft/world/item/alchemy/PotionContents.java
|
||||
@@ -93,7 +93,7 @@
|
||||
}
|
||||
|
||||
public PotionContents withEffectAdded(MobEffect mobeffect) {
|
||||
- return new PotionContents(this.potion, this.customColor, SystemUtils.copyAndAdd(this.customEffects, (Object) mobeffect), this.customName);
|
||||
+ return new PotionContents(this.potion, this.customColor, SystemUtils.copyAndAdd(this.customEffects, mobeffect), this.customName); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
public int getColor() {
|
||||
@@ -176,7 +176,7 @@
|
||||
if (((MobEffectList) mobeffect.getEffect().value()).isInstantenous()) {
|
||||
((MobEffectList) mobeffect.getEffect().value()).applyInstantenousEffect(worldserver, entityhuman2, entityhuman2, entityliving, mobeffect.getAmplifier(), 1.0D);
|
||||
} else {
|
||||
- entityliving.addEffect(mobeffect);
|
||||
+ entityliving.addEffect(mobeffect, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.POTION_DRINK); // CraftBukkit
|
||||
}
|
||||
|
||||
});
|
||||
@@ -0,0 +1,51 @@
|
||||
--- a/net/minecraft/world/item/component/Consumable.java
|
||||
+++ b/net/minecraft/world/item/component/Consumable.java
|
||||
@@ -29,6 +29,11 @@
|
||||
import net.minecraft.world.level.World;
|
||||
import net.minecraft.world.level.gameevent.GameEvent;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import net.minecraft.world.item.Items;
|
||||
+import org.bukkit.event.entity.EntityPotionEffectEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public record Consumable(float consumeSeconds, ItemUseAnimation animation, Holder<SoundEffect> sound, boolean hasConsumeParticles, List<ConsumeEffect> onConsumeEffects) {
|
||||
|
||||
public static final float DEFAULT_CONSUME_SECONDS = 1.6F;
|
||||
@@ -69,8 +74,19 @@
|
||||
consumablelistener.onConsume(world, entityliving, itemstack, this);
|
||||
});
|
||||
if (!world.isClientSide) {
|
||||
+ // CraftBukkit start
|
||||
+ EntityPotionEffectEvent.Cause cause;
|
||||
+ if (itemstack.is(Items.MILK_BUCKET)) {
|
||||
+ cause = EntityPotionEffectEvent.Cause.MILK;
|
||||
+ } else if (itemstack.is(Items.POTION)) {
|
||||
+ cause = EntityPotionEffectEvent.Cause.POTION_DRINK;
|
||||
+ } else {
|
||||
+ cause = EntityPotionEffectEvent.Cause.FOOD;
|
||||
+ }
|
||||
+
|
||||
this.onConsumeEffects.forEach((consumeeffect) -> {
|
||||
- consumeeffect.apply(world, itemstack, entityliving);
|
||||
+ consumeeffect.apply(world, itemstack, entityliving, cause);
|
||||
+ // CraftBukkit end
|
||||
});
|
||||
}
|
||||
|
||||
@@ -79,6 +95,15 @@
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public void cancelUsingItem(net.minecraft.server.level.EntityPlayer entityplayer, ItemStack itemstack) {
|
||||
+ itemstack.getAllOfType(ConsumableListener.class).forEach((consumablelistener) -> {
|
||||
+ consumablelistener.cancelUsingItem(entityplayer, itemstack);
|
||||
+ });
|
||||
+ entityplayer.server.getPlayerList().sendActivePlayerEffects(entityplayer);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public boolean canConsume(EntityLiving entityliving, ItemStack itemstack) {
|
||||
FoodInfo foodinfo = (FoodInfo) itemstack.get(DataComponents.FOOD);
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
--- a/net/minecraft/world/item/component/ConsumableListener.java
|
||||
+++ b/net/minecraft/world/item/component/ConsumableListener.java
|
||||
@@ -7,4 +7,6 @@
|
||||
public interface ConsumableListener {
|
||||
|
||||
void onConsume(World world, EntityLiving entityliving, ItemStack itemstack, Consumable consumable);
|
||||
+
|
||||
+ default void cancelUsingItem(net.minecraft.server.level.EntityPlayer entityplayer, ItemStack itemstack) {} // CraftBukkit
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
--- a/net/minecraft/world/item/component/DeathProtection.java
|
||||
+++ b/net/minecraft/world/item/component/DeathProtection.java
|
||||
@@ -15,6 +15,10 @@
|
||||
import net.minecraft.world.item.consume_effects.ClearAllStatusEffectsConsumeEffect;
|
||||
import net.minecraft.world.item.consume_effects.ConsumeEffect;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.event.entity.EntityPotionEffectEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public record DeathProtection(List<ConsumeEffect> deathEffects) {
|
||||
|
||||
public static final Codec<DeathProtection> CODEC = RecordCodecBuilder.create((instance) -> {
|
||||
@@ -29,7 +33,7 @@
|
||||
while (iterator.hasNext()) {
|
||||
ConsumeEffect consumeeffect = (ConsumeEffect) iterator.next();
|
||||
|
||||
- consumeeffect.apply(entityliving.level(), itemstack, entityliving);
|
||||
+ consumeeffect.apply(entityliving.level(), itemstack, entityliving, EntityPotionEffectEvent.Cause.TOTEM); // CraftBukkit
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
--- a/net/minecraft/world/item/component/SuspiciousStewEffects.java
|
||||
+++ b/net/minecraft/world/item/component/SuspiciousStewEffects.java
|
||||
@@ -29,7 +29,7 @@
|
||||
public static final StreamCodec<RegistryFriendlyByteBuf, SuspiciousStewEffects> STREAM_CODEC = SuspiciousStewEffects.a.STREAM_CODEC.apply(ByteBufCodecs.list()).map(SuspiciousStewEffects::new, SuspiciousStewEffects::effects);
|
||||
|
||||
public SuspiciousStewEffects withEffectAdded(SuspiciousStewEffects.a suspicioussteweffects_a) {
|
||||
- return new SuspiciousStewEffects(SystemUtils.copyAndAdd(this.effects, (Object) suspicioussteweffects_a));
|
||||
+ return new SuspiciousStewEffects(SystemUtils.copyAndAdd(this.effects, suspicioussteweffects_a)); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -44,6 +44,15 @@
|
||||
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public void cancelUsingItem(net.minecraft.server.level.EntityPlayer entityplayer, ItemStack itemstack) {
|
||||
+ for (SuspiciousStewEffects.a suspicioussteweffects_a : this.effects) {
|
||||
+ entityplayer.connection.send(new net.minecraft.network.protocol.game.PacketPlayOutRemoveEntityEffect(entityplayer.getId(), suspicioussteweffects_a.effect()));
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
@Override
|
||||
public void addToTooltip(Item.b item_b, Consumer<IChatBaseComponent> consumer, TooltipFlag tooltipflag) {
|
||||
if (tooltipflag.isCreative()) {
|
||||
@@ -0,0 +1,31 @@
|
||||
--- a/net/minecraft/world/item/consume_effects/ApplyStatusEffectsConsumeEffect.java
|
||||
+++ b/net/minecraft/world/item/consume_effects/ApplyStatusEffectsConsumeEffect.java
|
||||
@@ -13,6 +13,10 @@
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.World;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.event.entity.EntityPotionEffectEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public record ApplyStatusEffectsConsumeEffect(List<MobEffect> effects, float probability) implements ConsumeEffect {
|
||||
|
||||
public static final MapCodec<ApplyStatusEffectsConsumeEffect> CODEC = RecordCodecBuilder.mapCodec((instance) -> {
|
||||
@@ -38,7 +42,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
- public boolean apply(World world, ItemStack itemstack, EntityLiving entityliving) {
|
||||
+ public boolean apply(World world, ItemStack itemstack, EntityLiving entityliving, EntityPotionEffectEvent.Cause cause) { // CraftBukkit
|
||||
if (entityliving.getRandom().nextFloat() >= this.probability) {
|
||||
return false;
|
||||
} else {
|
||||
@@ -48,7 +52,7 @@
|
||||
while (iterator.hasNext()) {
|
||||
MobEffect mobeffect = (MobEffect) iterator.next();
|
||||
|
||||
- if (entityliving.addEffect(new MobEffect(mobeffect))) {
|
||||
+ if (entityliving.addEffect(new MobEffect(mobeffect), cause)) { // CraftBukkit
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
--- a/net/minecraft/world/item/consume_effects/ClearAllStatusEffectsConsumeEffect.java
|
||||
+++ b/net/minecraft/world/item/consume_effects/ClearAllStatusEffectsConsumeEffect.java
|
||||
@@ -7,6 +7,10 @@
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.World;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.event.entity.EntityPotionEffectEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public record ClearAllStatusEffectsConsumeEffect() implements ConsumeEffect {
|
||||
|
||||
public static final ClearAllStatusEffectsConsumeEffect INSTANCE = new ClearAllStatusEffectsConsumeEffect();
|
||||
@@ -19,7 +23,9 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
- public boolean apply(World world, ItemStack itemstack, EntityLiving entityliving) {
|
||||
- return entityliving.removeAllEffects();
|
||||
+ // CraftBukkit start
|
||||
+ public boolean apply(World world, ItemStack itemstack, EntityLiving entityliving, EntityPotionEffectEvent.Cause cause) {
|
||||
+ return entityliving.removeAllEffects(cause);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
--- a/net/minecraft/world/item/consume_effects/ConsumeEffect.java
|
||||
+++ b/net/minecraft/world/item/consume_effects/ConsumeEffect.java
|
||||
@@ -12,6 +12,10 @@
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.World;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.event.entity.EntityPotionEffectEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public interface ConsumeEffect {
|
||||
|
||||
Codec<ConsumeEffect> CODEC = BuiltInRegistries.CONSUME_EFFECT_TYPE.byNameCodec().dispatch(ConsumeEffect::getType, ConsumeEffect.a::codec);
|
||||
@@ -19,7 +23,15 @@
|
||||
|
||||
ConsumeEffect.a<? extends ConsumeEffect> getType();
|
||||
|
||||
- boolean apply(World world, ItemStack itemstack, EntityLiving entityliving);
|
||||
+ // CraftBukkit start
|
||||
+ default boolean apply(World world, ItemStack itemstack, EntityLiving entityliving) {
|
||||
+ return this.apply(world, itemstack, entityliving, EntityPotionEffectEvent.Cause.UNKNOWN);
|
||||
+ }
|
||||
+
|
||||
+ default boolean apply(World world, ItemStack itemstack, EntityLiving entityliving, EntityPotionEffectEvent.Cause cause) {
|
||||
+ return this.apply(world, itemstack, entityliving);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
public static record a<T extends ConsumeEffect>(MapCodec<T> codec, StreamCodec<RegistryFriendlyByteBuf, T> streamCodec) {
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
--- a/net/minecraft/world/item/consume_effects/RemoveStatusEffectsConsumeEffect.java
|
||||
+++ b/net/minecraft/world/item/consume_effects/RemoveStatusEffectsConsumeEffect.java
|
||||
@@ -15,6 +15,10 @@
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.World;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.event.entity.EntityPotionEffectEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public record RemoveStatusEffectsConsumeEffect(HolderSet<MobEffectList> effects) implements ConsumeEffect {
|
||||
|
||||
public static final MapCodec<RemoveStatusEffectsConsumeEffect> CODEC = RecordCodecBuilder.mapCodec((instance) -> {
|
||||
@@ -32,14 +36,14 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
- public boolean apply(World world, ItemStack itemstack, EntityLiving entityliving) {
|
||||
+ public boolean apply(World world, ItemStack itemstack, EntityLiving entityliving, EntityPotionEffectEvent.Cause cause) { // CraftBukkit
|
||||
boolean flag = false;
|
||||
Iterator iterator = this.effects.iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
Holder<MobEffectList> holder = (Holder) iterator.next();
|
||||
|
||||
- if (entityliving.removeEffect(holder)) {
|
||||
+ if (entityliving.removeEffect(holder, cause)) { // CraftBukkit
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
--- a/net/minecraft/world/item/consume_effects/TeleportRandomlyConsumeEffect.java
|
||||
+++ b/net/minecraft/world/item/consume_effects/TeleportRandomlyConsumeEffect.java
|
||||
@@ -53,7 +53,16 @@
|
||||
|
||||
Vec3D vec3d = entityliving.position();
|
||||
|
||||
- if (entityliving.randomTeleport(d0, d1, d2, true)) {
|
||||
+ // CraftBukkit start - handle canceled status of teleport event
|
||||
+ java.util.Optional<Boolean> status = entityliving.randomTeleport(d0, d1, d2, true, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.CHORUS_FRUIT);
|
||||
+
|
||||
+ if (!status.isPresent()) {
|
||||
+ // teleport event was canceled, no more tries
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ if (status.get()) {
|
||||
+ // CraftBukkit end
|
||||
world.gameEvent((Holder) GameEvent.TELEPORT, vec3d, GameEvent.a.of((Entity) entityliving));
|
||||
SoundEffect soundeffect;
|
||||
SoundCategory soundcategory;
|
||||
@@ -1,108 +1,87 @@
|
||||
--- a/net/minecraft/world/item/crafting/CraftingManager.java
|
||||
+++ b/net/minecraft/world/item/crafting/CraftingManager.java
|
||||
@@ -34,6 +34,11 @@
|
||||
@@ -38,6 +38,10 @@
|
||||
import net.minecraft.world.level.World;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import com.google.common.collect.LinkedHashMultimap;
|
||||
+import com.google.common.collect.Maps;
|
||||
+import java.util.Collections;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class CraftingManager extends ResourceDataJson {
|
||||
public class CraftingManager extends ResourceDataAbstract<RecipeMap> implements RecipeAccess {
|
||||
|
||||
private static final Gson GSON = (new GsonBuilder()).setPrettyPrinting().disableHtmlEscaping().create();
|
||||
@@ -70,11 +75,26 @@
|
||||
}
|
||||
}
|
||||
|
||||
- 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());
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
@@ -109,7 +113,23 @@
|
||||
CraftingManager.LOGGER.info("Loaded {} recipes", recipemap.values().size());
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public void addRecipe(RecipeHolder<?> irecipe) {
|
||||
+ Collection<RecipeHolder<?>> map = this.byType.get(irecipe.value().getType()); // CraftBukkit
|
||||
+ this.recipes.addRecipe(irecipe);
|
||||
+ finalizeRecipeLoading();
|
||||
+ }
|
||||
+
|
||||
+ if (byName.containsKey(irecipe.id())) {
|
||||
+ throw new IllegalStateException("Duplicate recipe ignored with ID " + irecipe.id());
|
||||
+ } else {
|
||||
+ map.add(irecipe);
|
||||
+ byName.put(irecipe.id(), irecipe);
|
||||
+ private FeatureFlagSet featureflagset;
|
||||
+
|
||||
+ public void finalizeRecipeLoading() {
|
||||
+ if (featureflagset != null) {
|
||||
+ finalizeRecipeLoading(featureflagset);
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public boolean hadErrorsLoading() {
|
||||
return this.hasErrors;
|
||||
}
|
||||
@@ -90,9 +110,13 @@
|
||||
public void finalizeRecipeLoading(FeatureFlagSet featureflagset) {
|
||||
+ this.featureflagset = featureflagset;
|
||||
+ // CraftBukkit end
|
||||
List<SelectableRecipe.a<RecipeStonecutting>> list = new ArrayList();
|
||||
List<CraftingManager.b> list1 = CraftingManager.RECIPE_PROPERTY_SETS.entrySet().stream().map((entry) -> {
|
||||
return new CraftingManager.b((ResourceKey) entry.getKey(), (CraftingManager.c) entry.getValue());
|
||||
@@ -128,7 +148,7 @@
|
||||
RecipeStonecutting recipestonecutting = (RecipeStonecutting) irecipe;
|
||||
|
||||
if (isIngredientEnabled(featureflagset, recipestonecutting.input()) && recipestonecutting.resultDisplay().isEnabled(featureflagset)) {
|
||||
- list.add(new SelectableRecipe.a<>(recipestonecutting.input(), new SelectableRecipe<>(recipestonecutting.resultDisplay(), Optional.of(recipeholder))));
|
||||
+ list.add(new SelectableRecipe.a<RecipeStonecutting>(recipestonecutting.input(), new SelectableRecipe<>(recipestonecutting.resultDisplay(), Optional.of((RecipeHolder<RecipeStonecutting>) recipeholder)))); // CraftBukkit - decompile error
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,7 +190,10 @@
|
||||
}
|
||||
|
||||
public <I extends RecipeInput, T extends IRecipe<I>> Optional<RecipeHolder<T>> getRecipeFor(Recipes<T> recipes, I i0, World world, @Nullable RecipeHolder<T> recipeholder) {
|
||||
- return i0.isEmpty() ? Optional.empty() : (recipeholder != null && recipeholder.value().matches(i0, world) ? Optional.of(recipeholder) : this.byType(recipes).stream().filter((recipeholder1) -> {
|
||||
public <I extends RecipeInput, T extends IRecipe<I>> Optional<RecipeHolder<T>> getRecipeFor(Recipes<T> recipes, I i0, World world) {
|
||||
- return this.recipes.getRecipesFor(recipes, i0, world).findFirst();
|
||||
+ // CraftBukkit start
|
||||
+ List<RecipeHolder<T>> list = this.byType(recipes).stream().filter((recipeholder1) -> {
|
||||
return recipeholder1.value().matches(i0, world);
|
||||
- }).findFirst());
|
||||
+ }).toList();
|
||||
+ Optional<RecipeHolder<T>> recipe = (list.isEmpty() || i0.isEmpty()) ? Optional.empty() : (recipeholder != null && recipeholder.value().matches(i0, world) ? Optional.of(recipeholder) : Optional.of(list.getLast())); // CraftBukkit - SPIGOT-4638: last recipe gets priority
|
||||
+ return recipe;
|
||||
+ List<RecipeHolder<T>> list = this.recipes.getRecipesFor(recipes, i0, world).toList();
|
||||
+ return (list.isEmpty()) ? Optional.empty() : Optional.of(list.getLast()); // CraftBukkit - SPIGOT-4638: last recipe gets priority
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
public <I extends RecipeInput, T extends IRecipe<I>> List<RecipeHolder<T>> getAllRecipesFor(Recipes<T> recipes) {
|
||||
@@ -108,7 +132,7 @@
|
||||
}
|
||||
|
||||
private <I extends RecipeInput, T extends IRecipe<I>> Collection<RecipeHolder<T>> byType(Recipes<T> recipes) {
|
||||
- return this.byType.get(recipes);
|
||||
+ return (Collection) this.byType.get(recipes); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
public <I extends RecipeInput, T extends IRecipe<I>> NonNullList<ItemStack> getRemainingItemsFor(Recipes<T> recipes, I i0, World world) {
|
||||
@@ -135,7 +159,7 @@
|
||||
private <T extends IRecipe<?>> RecipeHolder<T> byKeyTyped(Recipes<T> recipes, MinecraftKey minecraftkey) {
|
||||
RecipeHolder<?> recipeholder = (RecipeHolder) this.byName.get(minecraftkey);
|
||||
public Optional<RecipeHolder<?>> byKey(ResourceKey<IRecipe<?>> resourcekey) {
|
||||
@@ -181,7 +204,7 @@
|
||||
private <T extends IRecipe<?>> RecipeHolder<T> byKeyTyped(Recipes<T> recipes, ResourceKey<IRecipe<?>> resourcekey) {
|
||||
RecipeHolder<?> recipeholder = this.recipes.byKey(resourcekey);
|
||||
|
||||
- return recipeholder != null && recipeholder.value().getType().equals(recipes) ? recipeholder : null;
|
||||
+ return recipeholder != null && recipeholder.value().getType().equals(recipes) ? (RecipeHolder) recipeholder : null; // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
public Collection<RecipeHolder<?>> getOrderedRecipes() {
|
||||
@@ -171,10 +195,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) {
|
||||
+ 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 Map<ResourceKey<RecipePropertySet>, RecipePropertySet> getSynchronizedItemProperties() {
|
||||
@@ -229,6 +252,22 @@
|
||||
return new RecipeHolder<>(resourcekey, irecipe);
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public boolean removeRecipe(ResourceKey<IRecipe<?>> mcKey) {
|
||||
+ boolean removed = this.recipes.removeRecipe(mcKey);
|
||||
+ if (removed) {
|
||||
+ finalizeRecipeLoading();
|
||||
+ }
|
||||
+
|
||||
+ return removed;
|
||||
+ }
|
||||
+
|
||||
+ public void clearRecipes() {
|
||||
+ this.byType = LinkedHashMultimap.create();
|
||||
+ this.byName = Maps.newHashMap();
|
||||
+ this.recipes = RecipeMap.create(Collections.emptyList());
|
||||
+ finalizeRecipeLoading();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
--- a/net/minecraft/world/item/crafting/FurnaceRecipe.java
|
||||
+++ b/net/minecraft/world/item/crafting/FurnaceRecipe.java
|
||||
@@ -3,6 +3,14 @@
|
||||
@@ -4,6 +4,14 @@
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.item.Items;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.NamespacedKey;
|
||||
@@ -15,18 +15,18 @@
|
||||
public class FurnaceRecipe extends RecipeCooking {
|
||||
|
||||
public FurnaceRecipe(String s, CookingBookCategory cookingbookcategory, RecipeItemStack recipeitemstack, ItemStack itemstack, float f, int i) {
|
||||
@@ -18,4 +26,17 @@
|
||||
public RecipeSerializer<?> getSerializer() {
|
||||
return RecipeSerializer.SMELTING_RECIPE;
|
||||
@@ -45,4 +53,17 @@
|
||||
|
||||
return recipebookcategory;
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public Recipe toBukkitRecipe(NamespacedKey id) {
|
||||
+ CraftItemStack result = CraftItemStack.asCraftMirror(this.result);
|
||||
+ CraftItemStack result = CraftItemStack.asCraftMirror(this.result());
|
||||
+
|
||||
+ CraftFurnaceRecipe recipe = new CraftFurnaceRecipe(id, result, CraftRecipe.toBukkit(this.ingredient), this.experience, this.cookingTime);
|
||||
+ recipe.setGroup(this.group);
|
||||
+ CraftFurnaceRecipe recipe = new CraftFurnaceRecipe(id, result, CraftRecipe.toBukkit(this.input()), this.experience(), this.cookingTime());
|
||||
+ recipe.setGroup(this.group());
|
||||
+ recipe.setCategory(CraftRecipe.getCategory(this.category()));
|
||||
+
|
||||
+ return recipe;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
--- a/net/minecraft/world/item/crafting/IRecipe.java
|
||||
+++ b/net/minecraft/world/item/crafting/IRecipe.java
|
||||
@@ -71,4 +71,6 @@
|
||||
return recipeitemstack.getItems().length == 0;
|
||||
});
|
||||
@@ -44,4 +44,6 @@
|
||||
}
|
||||
|
||||
RecipeBookCategory recipeBookCategory();
|
||||
+
|
||||
+ org.bukkit.inventory.Recipe toBukkitRecipe(org.bukkit.NamespacedKey id); // CraftBukkit
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
--- a/net/minecraft/world/item/crafting/IRecipeComplex.java
|
||||
+++ b/net/minecraft/world/item/crafting/IRecipeComplex.java
|
||||
@@ -3,6 +3,15 @@
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
@@ -8,6 +8,15 @@
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||
import net.minecraft.network.codec.StreamCodec;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import net.minecraft.core.IRegistryCustom;
|
||||
+import net.minecraft.world.item.ItemStack;
|
||||
+import org.bukkit.NamespacedKey;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftComplexRecipe;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
@@ -16,21 +16,39 @@
|
||||
public abstract class IRecipeComplex implements RecipeCrafting {
|
||||
|
||||
private final CraftingBookCategory category;
|
||||
@@ -25,4 +34,17 @@
|
||||
public CraftingBookCategory category() {
|
||||
return this.category;
|
||||
}
|
||||
+
|
||||
@@ -34,6 +43,19 @@
|
||||
@Override
|
||||
public abstract RecipeSerializer<? extends IRecipeComplex> getSerializer();
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public Recipe toBukkitRecipe(NamespacedKey id) {
|
||||
+ CraftItemStack result = CraftItemStack.asCraftMirror(getResultItem(IRegistryCustom.EMPTY));
|
||||
+ CraftItemStack result = CraftItemStack.asCraftMirror(ItemStack.EMPTY);
|
||||
+
|
||||
+ CraftComplexRecipe recipe = new CraftComplexRecipe(id, result, this);
|
||||
+ recipe.setGroup(this.getGroup());
|
||||
+ recipe.setGroup(this.group());
|
||||
+ recipe.setCategory(CraftRecipe.getCategory(this.category()));
|
||||
+
|
||||
+ return recipe;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
+
|
||||
public static class Serializer<T extends RecipeCrafting> implements RecipeSerializer<T> {
|
||||
|
||||
private final MapCodec<T> codec;
|
||||
@@ -41,13 +63,13 @@
|
||||
|
||||
public Serializer(IRecipeComplex.Serializer.Factory<T> irecipecomplex_serializer_factory) {
|
||||
this.codec = RecordCodecBuilder.mapCodec((instance) -> {
|
||||
- P1 p1 = instance.group(CraftingBookCategory.CODEC.fieldOf("category").orElse(CraftingBookCategory.MISC).forGetter(RecipeCrafting::category));
|
||||
+ P1<RecordCodecBuilder.Mu<T>, CraftingBookCategory> p1 = instance.group(CraftingBookCategory.CODEC.fieldOf("category").orElse(CraftingBookCategory.MISC).forGetter(RecipeCrafting::category)); // CraftBukkit - decompile error
|
||||
|
||||
Objects.requireNonNull(irecipecomplex_serializer_factory);
|
||||
return p1.apply(instance, irecipecomplex_serializer_factory::create);
|
||||
});
|
||||
StreamCodec streamcodec = CraftingBookCategory.STREAM_CODEC;
|
||||
- Function function = RecipeCrafting::category;
|
||||
+ Function<RecipeCrafting, CraftingBookCategory> function = RecipeCrafting::category; // CraftBukkit - decompile error
|
||||
|
||||
Objects.requireNonNull(irecipecomplex_serializer_factory);
|
||||
this.streamCodec = StreamCodec.composite(streamcodec, function, irecipecomplex_serializer_factory::create);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
--- a/net/minecraft/world/item/crafting/RecipeBlasting.java
|
||||
+++ b/net/minecraft/world/item/crafting/RecipeBlasting.java
|
||||
@@ -3,6 +3,14 @@
|
||||
@@ -4,6 +4,14 @@
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.item.Items;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.NamespacedKey;
|
||||
@@ -15,18 +15,18 @@
|
||||
public class RecipeBlasting extends RecipeCooking {
|
||||
|
||||
public RecipeBlasting(String s, CookingBookCategory cookingbookcategory, RecipeItemStack recipeitemstack, ItemStack itemstack, float f, int i) {
|
||||
@@ -18,4 +26,17 @@
|
||||
public RecipeSerializer<?> getSerializer() {
|
||||
return RecipeSerializer.BLASTING_RECIPE;
|
||||
@@ -43,4 +51,17 @@
|
||||
|
||||
return recipebookcategory;
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public Recipe toBukkitRecipe(NamespacedKey id) {
|
||||
+ CraftItemStack result = CraftItemStack.asCraftMirror(this.result);
|
||||
+ CraftItemStack result = CraftItemStack.asCraftMirror(this.result());
|
||||
+
|
||||
+ CraftBlastingRecipe recipe = new CraftBlastingRecipe(id, result, CraftRecipe.toBukkit(this.ingredient), this.experience, this.cookingTime);
|
||||
+ recipe.setGroup(this.group);
|
||||
+ CraftBlastingRecipe recipe = new CraftBlastingRecipe(id, result, CraftRecipe.toBukkit(this.input()), this.experience(), this.cookingTime());
|
||||
+ recipe.setGroup(this.group());
|
||||
+ recipe.setCategory(CraftRecipe.getCategory(this.category()));
|
||||
+
|
||||
+ return recipe;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
--- a/net/minecraft/world/item/crafting/RecipeCampfire.java
|
||||
+++ b/net/minecraft/world/item/crafting/RecipeCampfire.java
|
||||
@@ -3,6 +3,14 @@
|
||||
@@ -4,6 +4,14 @@
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.item.Items;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.NamespacedKey;
|
||||
@@ -15,18 +15,18 @@
|
||||
public class RecipeCampfire extends RecipeCooking {
|
||||
|
||||
public RecipeCampfire(String s, CookingBookCategory cookingbookcategory, RecipeItemStack recipeitemstack, ItemStack itemstack, float f, int i) {
|
||||
@@ -18,4 +26,17 @@
|
||||
public RecipeSerializer<?> getSerializer() {
|
||||
return RecipeSerializer.CAMPFIRE_COOKING_RECIPE;
|
||||
@@ -29,4 +37,17 @@
|
||||
public RecipeBookCategory recipeBookCategory() {
|
||||
return RecipeBookCategories.CAMPFIRE;
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public Recipe toBukkitRecipe(NamespacedKey id) {
|
||||
+ CraftItemStack result = CraftItemStack.asCraftMirror(this.result);
|
||||
+ CraftItemStack result = CraftItemStack.asCraftMirror(this.result());
|
||||
+
|
||||
+ CraftCampfireRecipe recipe = new CraftCampfireRecipe(id, result, CraftRecipe.toBukkit(this.ingredient), this.experience, this.cookingTime);
|
||||
+ recipe.setGroup(this.group);
|
||||
+ CraftCampfireRecipe recipe = new CraftCampfireRecipe(id, result, CraftRecipe.toBukkit(this.input()), this.experience(), this.cookingTime());
|
||||
+ recipe.setGroup(this.group());
|
||||
+ recipe.setCategory(CraftRecipe.getCategory(this.category()));
|
||||
+
|
||||
+ return recipe;
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
--- a/net/minecraft/world/item/crafting/RecipeHolder.java
|
||||
+++ b/net/minecraft/world/item/crafting/RecipeHolder.java
|
||||
@@ -4,8 +4,19 @@
|
||||
@@ -5,8 +5,19 @@
|
||||
import net.minecraft.network.codec.StreamCodec;
|
||||
import net.minecraft.resources.MinecraftKey;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
|
||||
+// 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<?>>(ResourceKey<IRecipe<?>> id, T value) {
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public final Recipe toBukkitRecipe() {
|
||||
+ return this.value.toBukkitRecipe(CraftNamespacedKey.fromMinecraft(this.id));
|
||||
+ return this.value.toBukkitRecipe(CraftNamespacedKey.fromMinecraft(this.id.location()));
|
||||
+ }
|
||||
+ // 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 static final StreamCodec<RegistryFriendlyByteBuf, RecipeHolder<?>> STREAM_CODEC = StreamCodec.composite(ResourceKey.streamCodec(Registries.RECIPE), RecipeHolder::id, IRecipe.STREAM_CODEC, RecipeHolder::value, RecipeHolder::new);
|
||||
|
||||
public boolean equals(Object object) {
|
||||
|
||||
@@ -1,26 +1,52 @@
|
||||
--- a/net/minecraft/world/item/crafting/RecipeItemStack.java
|
||||
+++ b/net/minecraft/world/item/crafting/RecipeItemStack.java
|
||||
@@ -40,6 +40,7 @@
|
||||
public ItemStack[] itemStacks;
|
||||
@@ -42,6 +42,24 @@
|
||||
private final HolderSet<Item> values;
|
||||
@Nullable
|
||||
private IntList stackingIds;
|
||||
+ public boolean exact; // CraftBukkit
|
||||
public static final Codec<RecipeItemStack> CODEC = codec(true);
|
||||
public static final Codec<RecipeItemStack> CODEC_NONEMPTY = codec(false);
|
||||
|
||||
@@ -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.isSameItemSameComponents(itemstack, itemstack1)) {
|
||||
+ return true;
|
||||
+ }
|
||||
private List<Holder<Item>> items;
|
||||
+ // CraftBukkit start
|
||||
+ @Nullable
|
||||
+ private List<ItemStack> itemStacks;
|
||||
+
|
||||
+ continue;
|
||||
+ public boolean isExact() {
|
||||
+ return this.itemStacks != null;
|
||||
+ }
|
||||
+
|
||||
+ public List<ItemStack> itemStacks() {
|
||||
+ return this.itemStacks;
|
||||
+ }
|
||||
+
|
||||
+ public static RecipeItemStack ofStacks(Stream<ItemStack> stacks) {
|
||||
+ RecipeItemStack recipe = RecipeItemStack.of(stacks.map(ItemStack::getItem));
|
||||
+ recipe.itemStacks = stacks.toList();
|
||||
+ return recipe;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
private RecipeItemStack(HolderSet<Item> holderset) {
|
||||
holderset.unwrap().ifRight((list) -> {
|
||||
@@ -72,6 +90,15 @@
|
||||
}
|
||||
|
||||
public boolean test(ItemStack itemstack) {
|
||||
+ // CraftBukkit start
|
||||
+ if (this.isExact()) {
|
||||
+ for (ItemStack itemstack1 : this.itemStacks()) {
|
||||
+ if (itemstack1.getItem() == itemstack.getItem() && ItemStack.isSameItemSameComponents(itemstack, itemstack1)) {
|
||||
+ return true;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
if (itemstack1.is(itemstack.getItem())) {
|
||||
return true;
|
||||
}
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
List<Holder<Item>> list = this.items();
|
||||
|
||||
for (int i = 0; i < list.size(); ++i) {
|
||||
@@ -85,7 +112,7 @@
|
||||
|
||||
public boolean equals(Object object) {
|
||||
if (object instanceof RecipeItemStack recipeitemstack) {
|
||||
- return Objects.equals(this.values, recipeitemstack.values);
|
||||
+ return Objects.equals(this.values, recipeitemstack.values) && Objects.equals(this.itemStacks, recipeitemstack.itemStacks); // CraftBukkit
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
--- a/net/minecraft/world/item/crafting/RecipeMap.java
|
||||
+++ b/net/minecraft/world/item/crafting/RecipeMap.java
|
||||
@@ -12,6 +12,11 @@
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.level.World;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import com.google.common.collect.LinkedHashMultimap;
|
||||
+import com.google.common.collect.Maps;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class RecipeMap {
|
||||
|
||||
public static final RecipeMap EMPTY = new RecipeMap(ImmutableMultimap.of(), Map.of());
|
||||
@@ -35,11 +40,39 @@
|
||||
com_google_common_collect_immutablemap_builder.put(recipeholder.id(), recipeholder);
|
||||
}
|
||||
|
||||
- return new RecipeMap(builder.build(), com_google_common_collect_immutablemap_builder.build());
|
||||
+ // CraftBukkit start - mutable
|
||||
+ return new RecipeMap(LinkedHashMultimap.create(builder.build()), Maps.newHashMap(com_google_common_collect_immutablemap_builder.build()));
|
||||
+ }
|
||||
+
|
||||
+ public void addRecipe(RecipeHolder<?> irecipe) {
|
||||
+ Collection<RecipeHolder<?>> map = this.byType.get(irecipe.value().getType());
|
||||
+
|
||||
+ if (byKey.containsKey(irecipe.id())) {
|
||||
+ throw new IllegalStateException("Duplicate recipe ignored with ID " + irecipe.id());
|
||||
+ } else {
|
||||
+ map.add(irecipe);
|
||||
+ byKey.put(irecipe.id(), irecipe);
|
||||
+ }
|
||||
}
|
||||
|
||||
+ public boolean removeRecipe(ResourceKey<IRecipe<?>> mcKey) {
|
||||
+ boolean removed = false;
|
||||
+ Iterator<RecipeHolder<?>> iter = byType.values().iterator();
|
||||
+ while (iter.hasNext()) {
|
||||
+ RecipeHolder<?> recipe = iter.next();
|
||||
+ if (recipe.id().equals(mcKey)) {
|
||||
+ iter.remove();
|
||||
+ removed = true;
|
||||
+ }
|
||||
+ }
|
||||
+ removed |= byKey.remove(mcKey) != null;
|
||||
+
|
||||
+ return removed;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public <I extends RecipeInput, T extends IRecipe<I>> Collection<RecipeHolder<T>> byType(Recipes<T> recipes) {
|
||||
- return this.byType.get(recipes);
|
||||
+ return (Collection) this.byType.get(recipes); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
public Collection<RecipeHolder<?>> values() {
|
||||
@@ -1,8 +1,8 @@
|
||||
--- a/net/minecraft/world/item/crafting/RecipeSmoking.java
|
||||
+++ b/net/minecraft/world/item/crafting/RecipeSmoking.java
|
||||
@@ -3,6 +3,14 @@
|
||||
@@ -4,6 +4,14 @@
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.item.Items;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.NamespacedKey;
|
||||
@@ -15,18 +15,18 @@
|
||||
public class RecipeSmoking extends RecipeCooking {
|
||||
|
||||
public RecipeSmoking(String s, CookingBookCategory cookingbookcategory, RecipeItemStack recipeitemstack, ItemStack itemstack, float f, int i) {
|
||||
@@ -18,4 +26,17 @@
|
||||
public RecipeSerializer<?> getSerializer() {
|
||||
return RecipeSerializer.SMOKING_RECIPE;
|
||||
@@ -29,4 +37,17 @@
|
||||
public RecipeBookCategory recipeBookCategory() {
|
||||
return RecipeBookCategories.SMOKER_FOOD;
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public Recipe toBukkitRecipe(NamespacedKey id) {
|
||||
+ CraftItemStack result = CraftItemStack.asCraftMirror(this.result);
|
||||
+ CraftItemStack result = CraftItemStack.asCraftMirror(this.result());
|
||||
+
|
||||
+ CraftSmokingRecipe recipe = new CraftSmokingRecipe(id, result, CraftRecipe.toBukkit(this.ingredient), this.experience, this.cookingTime);
|
||||
+ recipe.setGroup(this.group);
|
||||
+ CraftSmokingRecipe recipe = new CraftSmokingRecipe(id, result, CraftRecipe.toBukkit(this.input()), this.experience(), this.cookingTime());
|
||||
+ recipe.setGroup(this.group());
|
||||
+ recipe.setCategory(CraftRecipe.getCategory(this.category()));
|
||||
+
|
||||
+ return recipe;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
--- a/net/minecraft/world/item/crafting/RecipeStonecutting.java
|
||||
+++ b/net/minecraft/world/item/crafting/RecipeStonecutting.java
|
||||
@@ -4,6 +4,14 @@
|
||||
import net.minecraft.world.level.World;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
@@ -7,6 +7,14 @@
|
||||
import net.minecraft.world.item.crafting.display.SlotDisplay;
|
||||
import net.minecraft.world.item.crafting.display.StonecutterRecipeDisplay;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.NamespacedKey;
|
||||
@@ -15,18 +15,18 @@
|
||||
public class RecipeStonecutting extends RecipeSingleItem {
|
||||
|
||||
public RecipeStonecutting(String s, RecipeItemStack recipeitemstack, ItemStack itemstack) {
|
||||
@@ -18,4 +26,16 @@
|
||||
public ItemStack getToastSymbol() {
|
||||
return new ItemStack(Blocks.STONECUTTER);
|
||||
@@ -36,4 +44,16 @@
|
||||
public RecipeBookCategory recipeBookCategory() {
|
||||
return RecipeBookCategories.STONECUTTER;
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public Recipe toBukkitRecipe(NamespacedKey id) {
|
||||
+ CraftItemStack result = CraftItemStack.asCraftMirror(this.result);
|
||||
+ CraftItemStack result = CraftItemStack.asCraftMirror(this.result());
|
||||
+
|
||||
+ CraftStonecuttingRecipe recipe = new CraftStonecuttingRecipe(id, result, CraftRecipe.toBukkit(this.ingredient));
|
||||
+ recipe.setGroup(this.group);
|
||||
+ CraftStonecuttingRecipe recipe = new CraftStonecuttingRecipe(id, result, CraftRecipe.toBukkit(this.input()));
|
||||
+ recipe.setGroup(this.group());
|
||||
+
|
||||
+ return recipe;
|
||||
+ }
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
--- a/net/minecraft/world/item/crafting/ShapedRecipes.java
|
||||
+++ b/net/minecraft/world/item/crafting/ShapedRecipes.java
|
||||
@@ -10,6 +10,14 @@
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
@@ -17,6 +17,14 @@
|
||||
import net.minecraft.world.item.crafting.display.SlotDisplay;
|
||||
import net.minecraft.world.level.World;
|
||||
|
||||
+// CraftBukkit start
|
||||
@@ -15,7 +15,7 @@
|
||||
public class ShapedRecipes implements RecipeCrafting {
|
||||
|
||||
final ShapedRecipePattern pattern;
|
||||
@@ -30,6 +38,68 @@
|
||||
@@ -39,6 +47,68 @@
|
||||
this(s, craftingbookcategory, shapedrecipepattern, itemstack, true);
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@
|
||||
+ break;
|
||||
+ }
|
||||
+ char c = 'a';
|
||||
+ for (RecipeItemStack list : this.pattern.ingredients()) {
|
||||
+ for (Optional<RecipeItemStack> list : this.pattern.ingredients()) {
|
||||
+ RecipeChoice choice = CraftRecipe.toBukkit(list);
|
||||
+ if (choice != null) {
|
||||
+ recipe.setIngredient(c, choice);
|
||||
@@ -82,5 +82,5 @@
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
@Override
|
||||
public RecipeSerializer<?> getSerializer() {
|
||||
public RecipeSerializer<? extends ShapedRecipes> getSerializer() {
|
||||
return RecipeSerializer.SHAPED_RECIPE;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
--- a/net/minecraft/world/item/crafting/ShapelessRecipes.java
|
||||
+++ b/net/minecraft/world/item/crafting/ShapelessRecipes.java
|
||||
@@ -13,6 +13,13 @@
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
@@ -17,6 +17,13 @@
|
||||
import net.minecraft.world.item.crafting.display.SlotDisplay;
|
||||
import net.minecraft.world.level.World;
|
||||
|
||||
+// CraftBukkit start
|
||||
@@ -14,8 +14,8 @@
|
||||
public class ShapelessRecipes implements RecipeCrafting {
|
||||
|
||||
final String group;
|
||||
@@ -27,6 +34,22 @@
|
||||
this.ingredients = nonnulllist;
|
||||
@@ -33,6 +40,22 @@
|
||||
this.ingredients = list;
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
@@ -35,5 +35,5 @@
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
@Override
|
||||
public RecipeSerializer<?> getSerializer() {
|
||||
public RecipeSerializer<ShapelessRecipes> getSerializer() {
|
||||
return RecipeSerializer.SHAPELESS_RECIPE;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
--- a/net/minecraft/world/item/crafting/SmithingTransformRecipe.java
|
||||
+++ b/net/minecraft/world/item/crafting/SmithingTransformRecipe.java
|
||||
@@ -9,6 +9,14 @@
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.World;
|
||||
@@ -14,6 +14,14 @@
|
||||
import net.minecraft.world.item.crafting.display.SlotDisplay;
|
||||
import net.minecraft.world.item.crafting.display.SmithingRecipeDisplay;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.NamespacedKey;
|
||||
@@ -14,9 +14,9 @@
|
||||
+
|
||||
public class SmithingTransformRecipe implements SmithingRecipe {
|
||||
|
||||
final RecipeItemStack template;
|
||||
@@ -64,6 +72,17 @@
|
||||
return Stream.of(this.template, this.base, this.addition).anyMatch(RecipeItemStack::isEmpty);
|
||||
final Optional<RecipeItemStack> template;
|
||||
@@ -71,6 +79,17 @@
|
||||
return List.of(new SmithingRecipeDisplay(RecipeItemStack.optionalIngredientToDisplay(this.template), RecipeItemStack.optionalIngredientToDisplay(this.base), RecipeItemStack.optionalIngredientToDisplay(this.addition), new SlotDisplay.f(this.result), new SlotDisplay.d(Items.SMITHING_TABLE)));
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
--- a/net/minecraft/world/item/crafting/SmithingTrimRecipe.java
|
||||
+++ b/net/minecraft/world/item/crafting/SmithingTrimRecipe.java
|
||||
@@ -19,6 +19,13 @@
|
||||
import net.minecraft.world.item.armortrim.TrimPatterns;
|
||||
import net.minecraft.world.level.World;
|
||||
@@ -21,6 +21,13 @@
|
||||
import net.minecraft.world.item.equipment.trim.TrimPattern;
|
||||
import net.minecraft.world.item.equipment.trim.TrimPatterns;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.NamespacedKey;
|
||||
@@ -13,9 +13,9 @@
|
||||
+
|
||||
public class SmithingTrimRecipe implements SmithingRecipe {
|
||||
|
||||
final RecipeItemStack template;
|
||||
final Optional<RecipeItemStack> template;
|
||||
@@ -97,6 +104,13 @@
|
||||
return Stream.of(this.template, this.base, this.addition).anyMatch(RecipeItemStack::isEmpty);
|
||||
return List.of(new SmithingRecipeDisplay(slotdisplay2, slotdisplay, slotdisplay1, new SlotDisplay.g(slotdisplay, slotdisplay1, slotdisplay2), new SlotDisplay.d(Items.SMITHING_TABLE)));
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
--- a/net/minecraft/world/item/crafting/TransmuteRecipe.java
|
||||
+++ b/net/minecraft/world/item/crafting/TransmuteRecipe.java
|
||||
@@ -20,6 +20,14 @@
|
||||
import net.minecraft.world.level.IMaterial;
|
||||
import net.minecraft.world.level.World;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.NamespacedKey;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftItemType;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftRecipe;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftTransmuteRecipe;
|
||||
+import org.bukkit.inventory.Recipe;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class TransmuteRecipe implements RecipeCrafting {
|
||||
|
||||
final String group;
|
||||
@@ -84,6 +92,13 @@
|
||||
return List.of(new ShapelessCraftingRecipeDisplay(List.of(this.input.display(), this.material.display()), new SlotDisplay.d(this.result), new SlotDisplay.d(Items.CRAFTING_TABLE)));
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public Recipe toBukkitRecipe(NamespacedKey id) {
|
||||
+ return new CraftTransmuteRecipe(id, CraftItemType.minecraftToBukkit(this.result.value()), CraftRecipe.toBukkit(this.input), CraftRecipe.toBukkit(this.material));
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
@Override
|
||||
public RecipeSerializer<TransmuteRecipe> getSerializer() {
|
||||
return RecipeSerializer.TRANSMUTE;
|
||||
@@ -17,8 +17,8 @@
|
||||
Optional<Holder<EntityTypes<?>>> optional = this.entityTypes().getRandomElement(worldserver.getRandom());
|
||||
|
||||
if (!optional.isEmpty()) {
|
||||
- Entity entity1 = ((EntityTypes) ((Holder) optional.get()).value()).spawn(worldserver, blockposition, EnumMobSpawn.TRIGGERED);
|
||||
+ Entity entity1 = ((EntityTypes) ((Holder) optional.get()).value()).create(worldserver, null, blockposition, EnumMobSpawn.TRIGGERED, false, false); // CraftBukkit
|
||||
- Entity entity1 = ((EntityTypes) ((Holder) optional.get()).value()).spawn(worldserver, blockposition, EntitySpawnReason.TRIGGERED);
|
||||
+ Entity entity1 = ((EntityTypes) ((Holder) optional.get()).value()).create(worldserver, null, blockposition, EntitySpawnReason.TRIGGERED, false, false); // CraftBukkit
|
||||
|
||||
if (entity1 != null) {
|
||||
if (entity1 instanceof EntityLightning) {
|
||||
|
||||
Reference in New Issue
Block a user