@@ -0,0 +1,47 @@
|
||||
--- a/net/minecraft/server/ItemArmor.java
|
||||
+++ b/net/minecraft/server/ItemArmor.java
|
||||
@@ -6,6 +6,11 @@
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
+import org.bukkit.event.block.BlockDispenseArmorEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class ItemArmor extends Item implements ItemWearable {
|
||||
|
||||
private static final UUID[] j = new UUID[]{UUID.fromString("845DB27C-C624-495F-8C9F-6020A9A58B6B"), UUID.fromString("D8499B04-0E66-4726-AB29-64469D734E0D"), UUID.fromString("9F3D476D-C118-4544-8365-64846904B48E"), UUID.fromString("2AD3F246-FEE1-4E67-B886-69FD380BB150")};
|
||||
@@ -32,6 +37,32 @@
|
||||
EntityLiving entityliving = (EntityLiving) list.get(0);
|
||||
EnumItemSlot enumitemslot = EntityInsentient.j(itemstack);
|
||||
ItemStack itemstack1 = itemstack.cloneAndSubtract(1);
|
||||
+ // CraftBukkit start
|
||||
+ World world = isourceblock.getWorld();
|
||||
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ());
|
||||
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
|
||||
+
|
||||
+ BlockDispenseArmorEvent event = new BlockDispenseArmorEvent(block, craftItem.clone(), (org.bukkit.craftbukkit.entity.CraftLivingEntity) entityliving.getBukkitEntity());
|
||||
+ if (!BlockDispenser.eventFired) {
|
||||
+ world.getServer().getPluginManager().callEvent(event);
|
||||
+ }
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
+ itemstack.add(1);
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ if (!event.getItem().equals(craftItem)) {
|
||||
+ itemstack.add(1);
|
||||
+ // Chain to handler for new item
|
||||
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
|
||||
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem());
|
||||
+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != ItemArmor.a) {
|
||||
+ idispensebehavior.dispense(isourceblock, eventStack);
|
||||
+ return true;
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
entityliving.setSlot(enumitemslot, itemstack1);
|
||||
if (entityliving instanceof EntityInsentient) {
|
||||
@@ -0,0 +1,14 @@
|
||||
--- a/net/minecraft/server/ItemArmorStand.java
|
||||
+++ b/net/minecraft/server/ItemArmorStand.java
|
||||
@@ -38,6 +38,11 @@
|
||||
|
||||
entityarmorstand.setPositionRotation(entityarmorstand.locX(), entityarmorstand.locY(), entityarmorstand.locZ(), f, 0.0F);
|
||||
this.a(entityarmorstand, world.random);
|
||||
+ // CraftBukkit start
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPlaceEvent(itemactioncontext, entityarmorstand).isCancelled()) {
|
||||
+ return EnumInteractionResult.FAIL;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
world.addEntity(entityarmorstand);
|
||||
world.playSound((EntityHuman) null, entityarmorstand.locX(), entityarmorstand.locY(), entityarmorstand.locZ(), SoundEffects.ENTITY_ARMOR_STAND_PLACE, SoundCategory.BLOCKS, 0.75F, 0.8F);
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
--- a/net/minecraft/server/ItemBlock.java
|
||||
+++ b/net/minecraft/server/ItemBlock.java
|
||||
@@ -4,6 +4,12 @@
|
||||
import java.util.Map;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.block.CraftBlock;
|
||||
+import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
||||
+import org.bukkit.event.block.BlockCanBuildEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class ItemBlock extends Item {
|
||||
|
||||
@Deprecated
|
||||
@@ -31,6 +37,12 @@
|
||||
return EnumInteractionResult.FAIL;
|
||||
} else {
|
||||
IBlockData iblockdata = this.c(blockactioncontext1);
|
||||
+ // CraftBukkit start - special case for handling block placement with water lilies
|
||||
+ org.bukkit.block.BlockState blockstate = null;
|
||||
+ if (this instanceof ItemWaterLily) {
|
||||
+ blockstate = org.bukkit.craftbukkit.block.CraftBlockState.getBlockState(blockactioncontext1.getWorld(), blockactioncontext1.getClickPosition());
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
if (iblockdata == null) {
|
||||
return EnumInteractionResult.FAIL;
|
||||
@@ -48,6 +60,15 @@
|
||||
iblockdata1 = this.a(blockposition, world, itemstack, iblockdata1);
|
||||
this.a(blockposition, world, entityhuman, itemstack, iblockdata1);
|
||||
block.postPlace(world, blockposition, iblockdata1, entityhuman, itemstack);
|
||||
+ // CraftBukkit start
|
||||
+ if (blockstate != null) {
|
||||
+ org.bukkit.event.block.BlockPlaceEvent placeEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPlaceEvent((WorldServer) world, entityhuman, blockactioncontext1.getHand(), blockstate, blockposition.getX(), blockposition.getY(), blockposition.getZ());
|
||||
+ if (placeEvent != null && (placeEvent.isCancelled() || !placeEvent.canBuild())) {
|
||||
+ blockstate.update(true, false);
|
||||
+ return EnumInteractionResult.FAIL;
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
if (entityhuman instanceof EntityPlayer) {
|
||||
CriterionTriggers.y.a((EntityPlayer) entityhuman, blockposition, itemstack);
|
||||
}
|
||||
@@ -55,8 +76,8 @@
|
||||
|
||||
SoundEffectType soundeffecttype = iblockdata1.getStepSound();
|
||||
|
||||
- world.playSound(entityhuman, blockposition, this.a(iblockdata1), SoundCategory.BLOCKS, (soundeffecttype.getVolume() + 1.0F) / 2.0F, soundeffecttype.getPitch() * 0.8F);
|
||||
- if (entityhuman == null || !entityhuman.abilities.canInstantlyBuild) {
|
||||
+ // world.playSound(entityhuman, blockposition, this.a(iblockdata1), SoundCategory.BLOCKS, (soundeffecttype.getVolume() + 1.0F) / 2.0F, soundeffecttype.getPitch() * 0.8F);
|
||||
+ if ((entityhuman == null || !entityhuman.abilities.canInstantlyBuild) && itemstack != ItemStack.b) { // CraftBukkit
|
||||
itemstack.subtract(1);
|
||||
}
|
||||
|
||||
@@ -92,6 +113,21 @@
|
||||
|
||||
if (nbttagcompound != null) {
|
||||
NBTTagCompound nbttagcompound1 = nbttagcompound.getCompound("BlockStateTag");
|
||||
+ // CraftBukkit start
|
||||
+ iblockdata1 = getBlockState(iblockdata1, nbttagcompound1);
|
||||
+ }
|
||||
+
|
||||
+ if (iblockdata1 != iblockdata) {
|
||||
+ world.setTypeAndData(blockposition, iblockdata1, 2);
|
||||
+ }
|
||||
+
|
||||
+ return iblockdata1;
|
||||
+ }
|
||||
+
|
||||
+ public static IBlockData getBlockState(IBlockData iblockdata, NBTTagCompound nbttagcompound1) {
|
||||
+ IBlockData iblockdata1 = iblockdata;
|
||||
+ {
|
||||
+ // CraftBukkit end
|
||||
BlockStateList<Block, IBlockData> blockstatelist = iblockdata.getBlock().getStates();
|
||||
Iterator iterator = nbttagcompound1.getKeys().iterator();
|
||||
|
||||
@@ -106,11 +142,6 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
-
|
||||
- if (iblockdata1 != iblockdata) {
|
||||
- world.setTypeAndData(blockposition, iblockdata1, 2);
|
||||
- }
|
||||
-
|
||||
return iblockdata1;
|
||||
}
|
||||
|
||||
@@ -123,8 +154,15 @@
|
||||
protected boolean b(BlockActionContext blockactioncontext, IBlockData iblockdata) {
|
||||
EntityHuman entityhuman = blockactioncontext.getEntity();
|
||||
VoxelShapeCollision voxelshapecollision = entityhuman == null ? VoxelShapeCollision.a() : VoxelShapeCollision.a((Entity) entityhuman);
|
||||
+ // CraftBukkit start - store default return
|
||||
+ boolean defaultReturn = (!this.isCheckCollisions() || iblockdata.canPlace(blockactioncontext.getWorld(), blockactioncontext.getClickPosition())) && blockactioncontext.getWorld().a(iblockdata, blockactioncontext.getClickPosition(), voxelshapecollision);
|
||||
+ org.bukkit.entity.Player player = (blockactioncontext.getEntity() instanceof EntityPlayer) ? (org.bukkit.entity.Player) blockactioncontext.getEntity().getBukkitEntity() : null;
|
||||
+
|
||||
+ BlockCanBuildEvent event = new BlockCanBuildEvent(CraftBlock.at(blockactioncontext.getWorld(), blockactioncontext.getClickPosition()), player, CraftBlockData.fromData(iblockdata), defaultReturn);
|
||||
+ blockactioncontext.getWorld().getServer().getPluginManager().callEvent(event);
|
||||
|
||||
- return (!this.isCheckCollisions() || iblockdata.canPlace(blockactioncontext.getWorld(), blockactioncontext.getClickPosition())) && blockactioncontext.getWorld().a(iblockdata, blockactioncontext.getClickPosition(), voxelshapecollision);
|
||||
+ return event.isBuildable();
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
protected boolean isCheckCollisions() {
|
||||
@@ -0,0 +1,33 @@
|
||||
--- a/net/minecraft/server/ItemBoat.java
|
||||
+++ b/net/minecraft/server/ItemBoat.java
|
||||
@@ -41,6 +41,13 @@
|
||||
}
|
||||
|
||||
if (movingobjectpositionblock.getType() == MovingObjectPosition.EnumMovingObjectType.BLOCK) {
|
||||
+ // CraftBukkit start - Boat placement
|
||||
+ org.bukkit.event.player.PlayerInteractEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent(entityhuman, org.bukkit.event.block.Action.RIGHT_CLICK_BLOCK, movingobjectpositionblock.getBlockPosition(), movingobjectpositionblock.getDirection(), itemstack, enumhand);
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
+ return new InteractionResultWrapper(EnumInteractionResult.PASS, itemstack);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
EntityBoat entityboat = new EntityBoat(world, movingobjectpositionblock.getPos().x, movingobjectpositionblock.getPos().y, movingobjectpositionblock.getPos().z);
|
||||
|
||||
entityboat.setType(this.b);
|
||||
@@ -49,7 +56,15 @@
|
||||
return InteractionResultWrapper.fail(itemstack);
|
||||
} else {
|
||||
if (!world.isClientSide) {
|
||||
- world.addEntity(entityboat);
|
||||
+ // CraftBukkit start
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPlaceEvent(world, movingobjectpositionblock.getBlockPosition(), movingobjectpositionblock.getDirection(), entityhuman, entityboat).isCancelled()) {
|
||||
+ return InteractionResultWrapper.fail(itemstack);
|
||||
+ }
|
||||
+
|
||||
+ if (!world.addEntity(entityboat)) {
|
||||
+ return new InteractionResultWrapper(EnumInteractionResult.PASS, itemstack);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
if (!entityhuman.abilities.canInstantlyBuild) {
|
||||
itemstack.subtract(1);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
--- a/net/minecraft/server/ItemBoneMeal.java
|
||||
+++ b/net/minecraft/server/ItemBoneMeal.java
|
||||
@@ -12,6 +12,12 @@
|
||||
|
||||
@Override
|
||||
public EnumInteractionResult a(ItemActionContext itemactioncontext) {
|
||||
+ // CraftBukkit start - extract bonemeal application logic to separate, static method
|
||||
+ return applyBonemeal(itemactioncontext);
|
||||
+ }
|
||||
+
|
||||
+ public static EnumInteractionResult applyBonemeal(ItemActionContext itemactioncontext) {
|
||||
+ // CraftBukkit end
|
||||
World world = itemactioncontext.getWorld();
|
||||
BlockPosition blockposition = itemactioncontext.getClickPosition();
|
||||
BlockPosition blockposition1 = blockposition.shift(itemactioncontext.getClickedFace());
|
||||
@@ -0,0 +1,35 @@
|
||||
--- a/net/minecraft/server/ItemBow.java
|
||||
+++ b/net/minecraft/server/ItemBow.java
|
||||
@@ -50,6 +50,14 @@
|
||||
if (EnchantmentManager.getEnchantmentLevel(Enchantments.ARROW_FIRE, itemstack) > 0) {
|
||||
entityarrow.setOnFire(100);
|
||||
}
|
||||
+ // CraftBukkit start
|
||||
+ org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(entityhuman, itemstack, itemstack1, entityarrow, entityhuman.getRaisedHand(), f, !flag1);
|
||||
+ if (event.isCancelled()) {
|
||||
+ event.getProjectile().remove();
|
||||
+ return;
|
||||
+ }
|
||||
+ flag1 = !event.shouldConsumeItem();
|
||||
+ // CraftBukkit end
|
||||
|
||||
itemstack.damage(1, entityhuman, (entityhuman1) -> {
|
||||
entityhuman1.broadcastItemBreak(entityhuman.getRaisedHand());
|
||||
@@ -58,7 +66,16 @@
|
||||
entityarrow.fromPlayer = EntityArrow.PickupStatus.CREATIVE_ONLY;
|
||||
}
|
||||
|
||||
- world.addEntity(entityarrow);
|
||||
+ // CraftBukkit start
|
||||
+ if (event.getProjectile() == entityarrow.getBukkitEntity()) {
|
||||
+ if (!world.addEntity(entityarrow)) {
|
||||
+ if (entityhuman instanceof EntityPlayer) {
|
||||
+ ((EntityPlayer) entityhuman).getBukkitEntity().updateInventory();
|
||||
+ }
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_ARROW_SHOOT, SoundCategory.PLAYERS, 1.0F, 1.0F / (ItemBow.RANDOM.nextFloat() * 0.4F + 1.2F) + f * 0.5F);
|
||||
@@ -0,0 +1,82 @@
|
||||
--- a/net/minecraft/server/ItemBucket.java
|
||||
+++ b/net/minecraft/server/ItemBucket.java
|
||||
@@ -2,6 +2,14 @@
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
+import org.bukkit.craftbukkit.util.DummyGeneratorAccess;
|
||||
+import org.bukkit.event.player.PlayerBucketEmptyEvent;
|
||||
+import org.bukkit.event.player.PlayerBucketFillEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class ItemBucket extends Item {
|
||||
|
||||
public final FluidType fluidType;
|
||||
@@ -32,12 +40,22 @@
|
||||
if (this.fluidType == FluidTypes.EMPTY) {
|
||||
iblockdata = world.getType(blockposition);
|
||||
if (iblockdata.getBlock() instanceof IFluidSource) {
|
||||
+ // CraftBukkit start
|
||||
+ FluidType dummyFluid = ((IFluidSource) iblockdata.getBlock()).removeFluid(DummyGeneratorAccess.INSTANCE, blockposition, iblockdata);
|
||||
+ PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent((WorldServer) world, entityhuman, blockposition, blockposition, movingobjectpositionblock.getDirection(), itemstack, dummyFluid.a());
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
+ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutBlockChange(world, blockposition)); // SPIGOT-5163 (see PlayerInteractManager)
|
||||
+ ((EntityPlayer) entityhuman).getBukkitEntity().updateInventory(); // SPIGOT-4541
|
||||
+ return new InteractionResultWrapper(EnumInteractionResult.FAIL, itemstack);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
FluidType fluidtype = ((IFluidSource) iblockdata.getBlock()).removeFluid(world, blockposition, iblockdata);
|
||||
|
||||
if (fluidtype != FluidTypes.EMPTY) {
|
||||
entityhuman.b(StatisticList.ITEM_USED.b(this));
|
||||
entityhuman.playSound(fluidtype.a((Tag) TagsFluid.LAVA) ? SoundEffects.ITEM_BUCKET_FILL_LAVA : SoundEffects.ITEM_BUCKET_FILL, 1.0F, 1.0F);
|
||||
- ItemStack itemstack1 = ItemLiquidUtil.a(itemstack, entityhuman, new ItemStack(fluidtype.a()));
|
||||
+ ItemStack itemstack1 = ItemLiquidUtil.a(itemstack, entityhuman, CraftItemStack.asNMSCopy(event.getItemStack())); // CraftBukkit
|
||||
|
||||
if (!world.isClientSide) {
|
||||
CriterionTriggers.j.a((EntityPlayer) entityhuman, new ItemStack(fluidtype.a()));
|
||||
@@ -52,7 +70,7 @@
|
||||
iblockdata = world.getType(blockposition);
|
||||
BlockPosition blockposition2 = iblockdata.getBlock() instanceof IFluidContainer && this.fluidType == FluidTypes.WATER ? blockposition : blockposition1;
|
||||
|
||||
- if (this.a(entityhuman, world, blockposition2, movingobjectpositionblock1)) {
|
||||
+ if (this.a(entityhuman, world, blockposition2, movingobjectpositionblock1, movingobjectpositionblock1.getDirection(), blockposition, itemstack)) { // CraftBukkit
|
||||
this.a(world, itemstack, blockposition2);
|
||||
if (entityhuman instanceof EntityPlayer) {
|
||||
CriterionTriggers.y.a((EntityPlayer) entityhuman, blockposition2, itemstack);
|
||||
@@ -77,6 +95,11 @@
|
||||
public void a(World world, ItemStack itemstack, BlockPosition blockposition) {}
|
||||
|
||||
public boolean a(@Nullable EntityHuman entityhuman, World world, BlockPosition blockposition, @Nullable MovingObjectPositionBlock movingobjectpositionblock) {
|
||||
+ return a(entityhuman, world, blockposition, movingobjectpositionblock, null, null, null);
|
||||
+ }
|
||||
+
|
||||
+ public boolean a(EntityHuman entityhuman, World world, BlockPosition blockposition, @Nullable MovingObjectPositionBlock movingobjectpositionblock, EnumDirection enumdirection, BlockPosition clicked, ItemStack itemstack) {
|
||||
+ // CraftBukkit end
|
||||
if (!(this.fluidType instanceof FluidTypeFlowing)) {
|
||||
return false;
|
||||
} else {
|
||||
@@ -86,8 +109,18 @@
|
||||
boolean flag = iblockdata.a(this.fluidType);
|
||||
boolean flag1 = iblockdata.isAir() || flag || block instanceof IFluidContainer && ((IFluidContainer) block).canPlace(world, blockposition, iblockdata, this.fluidType);
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ if (flag1 && entityhuman != null) {
|
||||
+ PlayerBucketEmptyEvent event = CraftEventFactory.callPlayerBucketEmptyEvent((WorldServer) world, entityhuman, blockposition, clicked, enumdirection, itemstack);
|
||||
+ if (event.isCancelled()) {
|
||||
+ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutBlockChange(world, blockposition)); // SPIGOT-4238: needed when looking through entity
|
||||
+ ((EntityPlayer) entityhuman).getBukkitEntity().updateInventory(); // SPIGOT-4541
|
||||
+ return false;
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
if (!flag1) {
|
||||
- return movingobjectpositionblock != null && this.a(entityhuman, world, movingobjectpositionblock.getBlockPosition().shift(movingobjectpositionblock.getDirection()), (MovingObjectPositionBlock) null);
|
||||
+ return movingobjectpositionblock != null && this.a(entityhuman, world, movingobjectpositionblock.getBlockPosition().shift(movingobjectpositionblock.getDirection()), (MovingObjectPositionBlock) null, enumdirection, clicked, itemstack); // CraftBukkit
|
||||
} else if (world.getDimensionManager().isNether() && this.fluidType.a((Tag) TagsFluid.WATER)) {
|
||||
int i = blockposition.getX();
|
||||
int j = blockposition.getY();
|
||||
@@ -0,0 +1,35 @@
|
||||
--- a/net/minecraft/server/ItemChorusFruit.java
|
||||
+++ b/net/minecraft/server/ItemChorusFruit.java
|
||||
@@ -1,5 +1,11 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.entity.Player;
|
||||
+import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class ItemChorusFruit extends Item {
|
||||
|
||||
public ItemChorusFruit(Item.Info item_info) {
|
||||
@@ -20,6 +26,20 @@
|
||||
double d4 = MathHelper.a(entityliving.locY() + (double) (entityliving.getRandom().nextInt(16) - 8), 0.0D, (double) (world.getHeight() - 1));
|
||||
double d5 = entityliving.locZ() + (entityliving.getRandom().nextDouble() - 0.5D) * 16.0D;
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ if (entityliving instanceof EntityPlayer) {
|
||||
+ Player player = ((EntityPlayer) entityliving).getBukkitEntity();
|
||||
+ PlayerTeleportEvent teleEvent = new PlayerTeleportEvent(player, player.getLocation(), new Location(player.getWorld(), d3, d4, d5), PlayerTeleportEvent.TeleportCause.CHORUS_FRUIT);
|
||||
+ world.getServer().getPluginManager().callEvent(teleEvent);
|
||||
+ if (teleEvent.isCancelled()) {
|
||||
+ break;
|
||||
+ }
|
||||
+ d3 = teleEvent.getTo().getX();
|
||||
+ d4 = teleEvent.getTo().getY();
|
||||
+ d5 = teleEvent.getTo().getZ();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
if (entityliving.isPassenger()) {
|
||||
entityliving.stopRiding();
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
--- a/net/minecraft/server/ItemCrossbow.java
|
||||
+++ b/net/minecraft/server/ItemCrossbow.java
|
||||
@@ -74,6 +74,10 @@
|
||||
if (itemstack1.isEmpty() && flag) {
|
||||
itemstack1 = new ItemStack(Items.ARROW);
|
||||
itemstack2 = itemstack1.cloneItemStack();
|
||||
+ // CraftBukkit start - SPIGOT-4870, MC-150847
|
||||
+ } else if (itemstack1.isEmpty()) {
|
||||
+ return false;
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
if (!a(entityliving, itemstack, itemstack1, k > 0, flag)) {
|
||||
@@ -198,11 +202,27 @@
|
||||
vector3fa.a(quaternion);
|
||||
((IProjectile) object).shoot((double) vector3fa.a(), (double) vector3fa.b(), (double) vector3fa.c(), f1, f2);
|
||||
}
|
||||
+ // CraftBukkit start
|
||||
+ org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(entityliving, itemstack, itemstack1, (Entity) object, entityliving.getRaisedHand(), f, true);
|
||||
+ if (event.isCancelled()) {
|
||||
+ event.getProjectile().remove();
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
itemstack.damage(flag1 ? 3 : 1, entityliving, (entityliving1) -> {
|
||||
entityliving1.broadcastItemBreak(enumhand);
|
||||
});
|
||||
- world.addEntity((Entity) object);
|
||||
+ // CraftBukkit start
|
||||
+ if (event.getProjectile() == ((Entity) object).getBukkitEntity()) {
|
||||
+ if (!world.addEntity((Entity) object)) {
|
||||
+ if (entityliving instanceof EntityPlayer) {
|
||||
+ ((EntityPlayer) entityliving).getBukkitEntity().updateInventory();
|
||||
+ }
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
world.playSound((EntityHuman) null, entityliving.locX(), entityliving.locY(), entityliving.locZ(), SoundEffects.ITEM_CROSSBOW_SHOOT, SoundCategory.PLAYERS, 1.0F, f);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
--- a/net/minecraft/server/ItemDye.java
|
||||
+++ b/net/minecraft/server/ItemDye.java
|
||||
@@ -3,6 +3,8 @@
|
||||
import com.google.common.collect.Maps;
|
||||
import java.util.Map;
|
||||
|
||||
+import org.bukkit.event.entity.SheepDyeWoolEvent; // CraftBukkit
|
||||
+
|
||||
public class ItemDye extends Item {
|
||||
|
||||
private static final Map<EnumColor, ItemDye> a = Maps.newEnumMap(EnumColor.class);
|
||||
@@ -21,7 +23,17 @@
|
||||
|
||||
if (entitysheep.isAlive() && !entitysheep.isSheared() && entitysheep.getColor() != this.b) {
|
||||
if (!entityhuman.world.isClientSide) {
|
||||
- entitysheep.setColor(this.b);
|
||||
+ // CraftBukkit start
|
||||
+ byte bColor = (byte) this.b.getColorIndex();
|
||||
+ SheepDyeWoolEvent event = new SheepDyeWoolEvent((org.bukkit.entity.Sheep) entitysheep.getBukkitEntity(), org.bukkit.DyeColor.getByWoolData(bColor));
|
||||
+ entitysheep.world.getServer().getPluginManager().callEvent(event);
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
+ return EnumInteractionResult.PASS;
|
||||
+ }
|
||||
+
|
||||
+ entitysheep.setColor(EnumColor.fromColorIndex((byte) event.getColor().getWoolData()));
|
||||
+ // CraftBukkit end
|
||||
itemstack.subtract(1);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
--- a/net/minecraft/server/ItemEgg.java
|
||||
+++ b/net/minecraft/server/ItemEgg.java
|
||||
@@ -10,14 +10,22 @@
|
||||
public InteractionResultWrapper<ItemStack> a(World world, EntityHuman entityhuman, EnumHand enumhand) {
|
||||
ItemStack itemstack = entityhuman.b(enumhand);
|
||||
|
||||
- world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_EGG_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (ItemEgg.RANDOM.nextFloat() * 0.4F + 0.8F));
|
||||
+ // world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_EGG_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (ItemEgg.RANDOM.nextFloat() * 0.4F + 0.8F)); // CraftBukkit - moved down
|
||||
if (!world.isClientSide) {
|
||||
EntityEgg entityegg = new EntityEgg(world, entityhuman);
|
||||
|
||||
entityegg.setItem(itemstack);
|
||||
entityegg.a(entityhuman, entityhuman.pitch, entityhuman.yaw, 0.0F, 1.5F, 1.0F);
|
||||
- world.addEntity(entityegg);
|
||||
+ // CraftBukkit start
|
||||
+ if (!world.addEntity(entityegg)) {
|
||||
+ if (entityhuman instanceof EntityPlayer) {
|
||||
+ ((EntityPlayer) entityhuman).getBukkitEntity().updateInventory();
|
||||
+ }
|
||||
+ return InteractionResultWrapper.fail(itemstack);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
+ world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_EGG_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (ItemEgg.RANDOM.nextFloat() * 0.4F + 0.8F)); // CraftBukkit - from above
|
||||
|
||||
entityhuman.b(StatisticList.ITEM_USED.b(this));
|
||||
if (!entityhuman.abilities.canInstantlyBuild) {
|
||||
@@ -0,0 +1,14 @@
|
||||
--- a/net/minecraft/server/ItemEndCrystal.java
|
||||
+++ b/net/minecraft/server/ItemEndCrystal.java
|
||||
@@ -34,6 +34,11 @@
|
||||
EntityEnderCrystal entityendercrystal = new EntityEnderCrystal(world, d0 + 0.5D, d1, d2 + 0.5D);
|
||||
|
||||
entityendercrystal.setShowingBottom(false);
|
||||
+ // CraftBukkit start
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPlaceEvent(itemactioncontext, entityendercrystal).isCancelled()) {
|
||||
+ return EnumInteractionResult.FAIL;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
world.addEntity(entityendercrystal);
|
||||
EnderDragonBattle enderdragonbattle = ((WorldServer) world).getDragonBattle();
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
--- a/net/minecraft/server/ItemEnderEye.java
|
||||
+++ b/net/minecraft/server/ItemEnderEye.java
|
||||
@@ -61,7 +61,11 @@
|
||||
|
||||
entityendersignal.setItem(itemstack);
|
||||
entityendersignal.a(blockposition);
|
||||
- world.addEntity(entityendersignal);
|
||||
+ // CraftBukkit start
|
||||
+ if (!world.addEntity(entityendersignal)) {
|
||||
+ return new InteractionResultWrapper(EnumInteractionResult.FAIL, itemstack);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
if (entityhuman instanceof EntityPlayer) {
|
||||
CriterionTriggers.m.a((EntityPlayer) entityhuman, blockposition);
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
--- a/net/minecraft/server/ItemEnderPearl.java
|
||||
+++ b/net/minecraft/server/ItemEnderPearl.java
|
||||
@@ -10,16 +10,24 @@
|
||||
public InteractionResultWrapper<ItemStack> a(World world, EntityHuman entityhuman, EnumHand enumhand) {
|
||||
ItemStack itemstack = entityhuman.b(enumhand);
|
||||
|
||||
- world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_ENDER_PEARL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemEnderPearl.RANDOM.nextFloat() * 0.4F + 0.8F));
|
||||
- entityhuman.getCooldownTracker().setCooldown(this, 20);
|
||||
+ // CraftBukkit start - change order
|
||||
if (!world.isClientSide) {
|
||||
EntityEnderPearl entityenderpearl = new EntityEnderPearl(world, entityhuman);
|
||||
|
||||
entityenderpearl.setItem(itemstack);
|
||||
entityenderpearl.a(entityhuman, entityhuman.pitch, entityhuman.yaw, 0.0F, 1.5F, 1.0F);
|
||||
- world.addEntity(entityenderpearl);
|
||||
+ if (!world.addEntity(entityenderpearl)) {
|
||||
+ if (entityhuman instanceof EntityPlayer) {
|
||||
+ ((EntityPlayer) entityhuman).getBukkitEntity().updateInventory();
|
||||
+ }
|
||||
+ return new InteractionResultWrapper(EnumInteractionResult.FAIL, itemstack);
|
||||
+ }
|
||||
}
|
||||
|
||||
+ world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_ENDER_PEARL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemEnderPearl.RANDOM.nextFloat() * 0.4F + 0.8F));
|
||||
+ entityhuman.getCooldownTracker().setCooldown(this, 20);
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
entityhuman.b(StatisticList.ITEM_USED.b(this));
|
||||
if (!entityhuman.abilities.canInstantlyBuild) {
|
||||
itemstack.subtract(1);
|
||||
@@ -0,0 +1,31 @@
|
||||
--- a/net/minecraft/server/ItemFireball.java
|
||||
+++ b/net/minecraft/server/ItemFireball.java
|
||||
@@ -14,12 +14,28 @@
|
||||
boolean flag = false;
|
||||
|
||||
if (BlockCampfire.h(iblockdata)) {
|
||||
+ // CraftBukkit start - fire BlockIgniteEvent
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition, org.bukkit.event.block.BlockIgniteEvent.IgniteCause.FIREBALL, itemactioncontext.getEntity()).isCancelled()) {
|
||||
+ if (!itemactioncontext.getEntity().abilities.canInstantlyBuild) {
|
||||
+ itemactioncontext.getItemStack().subtract(1);
|
||||
+ }
|
||||
+ return EnumInteractionResult.PASS;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.a(world, blockposition);
|
||||
world.setTypeUpdate(blockposition, (IBlockData) iblockdata.set(BlockCampfire.LIT, true));
|
||||
flag = true;
|
||||
} else {
|
||||
blockposition = blockposition.shift(itemactioncontext.getClickedFace());
|
||||
if (BlockFireAbstract.a(world, blockposition, itemactioncontext.f())) {
|
||||
+ // CraftBukkit start - fire BlockIgniteEvent
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition, org.bukkit.event.block.BlockIgniteEvent.IgniteCause.FIREBALL, itemactioncontext.getEntity()).isCancelled()) {
|
||||
+ if (!itemactioncontext.getEntity().abilities.canInstantlyBuild) {
|
||||
+ itemactioncontext.getItemStack().subtract(1);
|
||||
+ }
|
||||
+ return EnumInteractionResult.PASS;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.a(world, blockposition);
|
||||
world.setTypeUpdate(blockposition, BlockFireAbstract.a((IBlockAccess) world, blockposition));
|
||||
flag = true;
|
||||
@@ -0,0 +1,36 @@
|
||||
--- a/net/minecraft/server/ItemFishingRod.java
|
||||
+++ b/net/minecraft/server/ItemFishingRod.java
|
||||
@@ -1,5 +1,7 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
+import org.bukkit.event.player.PlayerFishEvent; // CraftBukkit
|
||||
+
|
||||
public class ItemFishingRod extends Item implements ItemVanishable {
|
||||
|
||||
public ItemFishingRod(Item.Info item_info) {
|
||||
@@ -21,12 +23,23 @@
|
||||
|
||||
world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_FISHING_BOBBER_RETRIEVE, SoundCategory.NEUTRAL, 1.0F, 0.4F / (ItemFishingRod.RANDOM.nextFloat() * 0.4F + 0.8F));
|
||||
} else {
|
||||
- world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_FISHING_BOBBER_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemFishingRod.RANDOM.nextFloat() * 0.4F + 0.8F));
|
||||
+ // world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_FISHING_BOBBER_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemFishingRod.RANDOM.nextFloat() * 0.4F + 0.8F));
|
||||
if (!world.isClientSide) {
|
||||
i = EnchantmentManager.c(itemstack);
|
||||
int j = EnchantmentManager.b(itemstack);
|
||||
|
||||
- world.addEntity(new EntityFishingHook(entityhuman, world, j, i));
|
||||
+ // CraftBukkit start
|
||||
+ EntityFishingHook entityfishinghook = new EntityFishingHook(entityhuman, world, j, i);
|
||||
+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), null, (org.bukkit.entity.FishHook) entityfishinghook.getBukkitEntity(), PlayerFishEvent.State.FISHING);
|
||||
+ world.getServer().getPluginManager().callEvent(playerFishEvent);
|
||||
+
|
||||
+ if (playerFishEvent.isCancelled()) {
|
||||
+ entityhuman.hookedFish = null;
|
||||
+ return new InteractionResultWrapper(EnumInteractionResult.PASS, itemstack);
|
||||
+ }
|
||||
+ world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_FISHING_BOBBER_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemFishingRod.RANDOM.nextFloat() * 0.4F + 0.8F));
|
||||
+ world.addEntity(entityfishinghook);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
entityhuman.b(StatisticList.ITEM_USED.b(this));
|
||||
@@ -0,0 +1,26 @@
|
||||
--- a/net/minecraft/server/ItemFlintAndSteel.java
|
||||
+++ b/net/minecraft/server/ItemFlintAndSteel.java
|
||||
@@ -13,7 +13,7 @@
|
||||
BlockPosition blockposition = itemactioncontext.getClickPosition();
|
||||
IBlockData iblockdata = world.getType(blockposition);
|
||||
|
||||
- if (BlockCampfire.h(iblockdata)) {
|
||||
+ if (BlockCampfire.h(iblockdata) && !org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition, entityhuman).isCancelled()) { // CraftBukkit
|
||||
world.playSound(entityhuman, blockposition, SoundEffects.ITEM_FLINTANDSTEEL_USE, SoundCategory.BLOCKS, 1.0F, ItemFlintAndSteel.RANDOM.nextFloat() * 0.4F + 0.8F);
|
||||
world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockProperties.r, true), 11);
|
||||
if (entityhuman != null) {
|
||||
@@ -27,6 +27,14 @@
|
||||
BlockPosition blockposition1 = blockposition.shift(itemactioncontext.getClickedFace());
|
||||
|
||||
if (BlockFireAbstract.a(world, blockposition1, itemactioncontext.f())) {
|
||||
+ // CraftBukkit start - Store the clicked block
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition1, org.bukkit.event.block.BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL, entityhuman).isCancelled()) {
|
||||
+ itemactioncontext.getItemStack().damage(1, entityhuman, (entityhuman1) -> {
|
||||
+ entityhuman1.broadcastItemBreak(itemactioncontext.getHand());
|
||||
+ });
|
||||
+ return EnumInteractionResult.PASS;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
world.playSound(entityhuman, blockposition1, SoundEffects.ITEM_FLINTANDSTEEL_USE, SoundCategory.BLOCKS, 1.0F, ItemFlintAndSteel.RANDOM.nextFloat() * 0.4F + 0.8F);
|
||||
IBlockData iblockdata1 = BlockFireAbstract.a((IBlockAccess) world, blockposition1);
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
--- a/net/minecraft/server/ItemHanging.java
|
||||
+++ b/net/minecraft/server/ItemHanging.java
|
||||
@@ -1,5 +1,10 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.entity.Player;
|
||||
+import org.bukkit.event.hanging.HangingPlaceEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class ItemHanging extends Item {
|
||||
|
||||
private final EntityTypes<? extends EntityHanging> a;
|
||||
@@ -41,6 +46,18 @@
|
||||
|
||||
if (((EntityHanging) object).survives()) {
|
||||
if (!world.isClientSide) {
|
||||
+ // CraftBukkit start - fire HangingPlaceEvent
|
||||
+ Player who = (itemactioncontext.getEntity() == null) ? null : (Player) itemactioncontext.getEntity().getBukkitEntity();
|
||||
+ org.bukkit.block.Block blockClicked = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
|
||||
+ org.bukkit.block.BlockFace blockFace = org.bukkit.craftbukkit.block.CraftBlock.notchToBlockFace(enumdirection);
|
||||
+
|
||||
+ HangingPlaceEvent event = new HangingPlaceEvent((org.bukkit.entity.Hanging) ((EntityHanging) object).getBukkitEntity(), who, blockClicked, blockFace);
|
||||
+ world.getServer().getPluginManager().callEvent(event);
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
+ return EnumInteractionResult.FAIL;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
((EntityHanging) object).playPlaceSound();
|
||||
world.addEntity((Entity) object);
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
--- a/net/minecraft/server/ItemLeash.java
|
||||
+++ b/net/minecraft/server/ItemLeash.java
|
||||
@@ -3,6 +3,8 @@
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
+import org.bukkit.event.hanging.HangingPlaceEvent; // CraftBukkit
|
||||
+
|
||||
public class ItemLeash extends Item {
|
||||
|
||||
public ItemLeash(Item.Info item_info) {
|
||||
@@ -44,7 +46,23 @@
|
||||
if (entityinsentient.getLeashHolder() == entityhuman) {
|
||||
if (entityleash == null) {
|
||||
entityleash = EntityLeash.a(world, blockposition);
|
||||
+
|
||||
+ // CraftBukkit start - fire HangingPlaceEvent
|
||||
+ HangingPlaceEvent event = new HangingPlaceEvent((org.bukkit.entity.Hanging) entityleash.getBukkitEntity(), entityhuman != null ? (org.bukkit.entity.Player) entityhuman.getBukkitEntity() : null, world.getWorld().getBlockAt(i, j, k), org.bukkit.block.BlockFace.SELF);
|
||||
+ world.getServer().getPluginManager().callEvent(event);
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
+ entityleash.die();
|
||||
+ return EnumInteractionResult.PASS;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+ }
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerLeashEntityEvent(entityinsentient, entityleash, entityhuman).isCancelled()) {
|
||||
+ continue;
|
||||
}
|
||||
+ // CraftBukkit end
|
||||
|
||||
entityinsentient.setLeashHolder(entityleash, true);
|
||||
flag = true;
|
||||
@@ -0,0 +1,11 @@
|
||||
--- a/net/minecraft/server/ItemMilkBucket.java
|
||||
+++ b/net/minecraft/server/ItemMilkBucket.java
|
||||
@@ -20,7 +20,7 @@
|
||||
}
|
||||
|
||||
if (!world.isClientSide) {
|
||||
- entityliving.removeAllEffects();
|
||||
+ entityliving.removeAllEffects(org.bukkit.event.entity.EntityPotionEffectEvent.Cause.MILK); // CraftBukkit
|
||||
}
|
||||
|
||||
return itemstack.isEmpty() ? new ItemStack(Items.BUCKET) : itemstack;
|
||||
@@ -0,0 +1,74 @@
|
||||
--- a/net/minecraft/server/ItemMinecart.java
|
||||
+++ b/net/minecraft/server/ItemMinecart.java
|
||||
@@ -1,5 +1,10 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
+import org.bukkit.event.block.BlockDispenseEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class ItemMinecart extends Item {
|
||||
|
||||
private static final IDispenseBehavior a = new DispenseBehaviorItem() {
|
||||
@@ -38,14 +43,43 @@
|
||||
}
|
||||
}
|
||||
|
||||
- EntityMinecartAbstract entityminecartabstract = EntityMinecartAbstract.a(worldserver, d0, d1 + d3, d2, ((ItemMinecart) itemstack.getItem()).b);
|
||||
+ // CraftBukkit start
|
||||
+ // EntityMinecartAbstract entityminecartabstract = EntityMinecartAbstract.a(world, d0, d1 + d3, d2, ((ItemMinecart) itemstack.getItem()).b);
|
||||
+ ItemStack itemstack1 = itemstack.cloneAndSubtract(1);
|
||||
+ org.bukkit.block.Block block2 = worldserver.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ());
|
||||
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
|
||||
+
|
||||
+ BlockDispenseEvent event = new BlockDispenseEvent(block2, craftItem.clone(), new org.bukkit.util.Vector(d0, d1 + d3, d2));
|
||||
+ if (!BlockDispenser.eventFired) {
|
||||
+ worldserver.getServer().getPluginManager().callEvent(event);
|
||||
+ }
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
+ itemstack.add(1);
|
||||
+ return itemstack;
|
||||
+ }
|
||||
+
|
||||
+ if (!event.getItem().equals(craftItem)) {
|
||||
+ itemstack.add(1);
|
||||
+ // Chain to handler for new item
|
||||
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
|
||||
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem());
|
||||
+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) {
|
||||
+ idispensebehavior.dispense(isourceblock, eventStack);
|
||||
+ return itemstack;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ itemstack1 = CraftItemStack.asNMSCopy(event.getItem());
|
||||
+ EntityMinecartAbstract entityminecartabstract = EntityMinecartAbstract.a(worldserver, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), ((ItemMinecart) itemstack1.getItem()).b);
|
||||
|
||||
if (itemstack.hasName()) {
|
||||
entityminecartabstract.setCustomName(itemstack.getName());
|
||||
}
|
||||
|
||||
- worldserver.addEntity(entityminecartabstract);
|
||||
- itemstack.subtract(1);
|
||||
+ if (!worldserver.addEntity(entityminecartabstract)) itemstack.add(1);
|
||||
+ // itemstack.subtract(1); // CraftBukkit - handled during event processing
|
||||
+ // CraftBukkit end
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
@@ -87,7 +121,12 @@
|
||||
entityminecartabstract.setCustomName(itemstack.getName());
|
||||
}
|
||||
|
||||
- world.addEntity(entityminecartabstract);
|
||||
+ // CraftBukkit start
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPlaceEvent(itemactioncontext, entityminecartabstract).isCancelled()) {
|
||||
+ return EnumInteractionResult.FAIL;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+ if (!world.addEntity(entityminecartabstract)) return EnumInteractionResult.PASS; // CraftBukkit
|
||||
}
|
||||
|
||||
itemstack.subtract(1);
|
||||
@@ -0,0 +1,20 @@
|
||||
--- a/net/minecraft/server/ItemMonsterEgg.java
|
||||
+++ b/net/minecraft/server/ItemMonsterEgg.java
|
||||
@@ -141,7 +141,7 @@
|
||||
return Optional.empty();
|
||||
} else {
|
||||
((EntityInsentient) object).setPositionRotation(vec3d.getX(), vec3d.getY(), vec3d.getZ(), 0.0F, 0.0F);
|
||||
- worldserver.addAllEntities((Entity) object);
|
||||
+ worldserver.addAllEntities((Entity) object, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG); // CraftBukkit
|
||||
if (itemstack.hasName()) {
|
||||
((EntityInsentient) object).setCustomName(itemstack.getName());
|
||||
}
|
||||
@@ -150,7 +150,7 @@
|
||||
itemstack.subtract(1);
|
||||
}
|
||||
|
||||
- return Optional.of(object);
|
||||
+ return Optional.of((EntityInsentient) object); // CraftBukkit - decompile error
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
--- a/net/minecraft/server/ItemPotion.java
|
||||
+++ b/net/minecraft/server/ItemPotion.java
|
||||
@@ -32,7 +32,7 @@
|
||||
if (mobeffect.getMobEffect().isInstant()) {
|
||||
mobeffect.getMobEffect().applyInstantEffect(entityhuman, entityhuman, entityliving, mobeffect.getAmplifier(), 1.0D);
|
||||
} else {
|
||||
- entityliving.addEffect(new MobEffect(mobeffect));
|
||||
+ entityliving.addEffect(new MobEffect(mobeffect), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.POTION_DRINK); // CraftBukkit
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
--- a/net/minecraft/server/ItemRecord.java
|
||||
+++ b/net/minecraft/server/ItemRecord.java
|
||||
@@ -26,6 +26,7 @@
|
||||
ItemStack itemstack = itemactioncontext.getItemStack();
|
||||
|
||||
if (!world.isClientSide) {
|
||||
+ if (true) return EnumInteractionResult.SUCCESS; // CraftBukkit - handled in ItemStack
|
||||
((BlockJukeBox) Blocks.JUKEBOX).a((GeneratorAccess) world, blockposition, iblockdata, itemstack);
|
||||
world.a((EntityHuman) null, 1010, blockposition, Item.getId(this));
|
||||
itemstack.subtract(1);
|
||||
@@ -0,0 +1,23 @@
|
||||
--- a/net/minecraft/server/ItemSign.java
|
||||
+++ b/net/minecraft/server/ItemSign.java
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
public class ItemSign extends ItemBlockWallable {
|
||||
|
||||
+ public static BlockPosition openSign; // CraftBukkit
|
||||
+
|
||||
public ItemSign(Item.Info item_info, Block block, Block block1) {
|
||||
super(block, block1, item_info);
|
||||
}
|
||||
@@ -13,7 +15,10 @@
|
||||
boolean flag = super.a(blockposition, world, entityhuman, itemstack, iblockdata);
|
||||
|
||||
if (!world.isClientSide && !flag && entityhuman != null) {
|
||||
- entityhuman.openSign((TileEntitySign) world.getTileEntity(blockposition));
|
||||
+ // CraftBukkit start - SPIGOT-4678
|
||||
+ // entityhuman.openSign((TileEntitySign) world.getTileEntity(blockposition));
|
||||
+ ItemSign.openSign = blockposition;
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
return flag;
|
||||
@@ -0,0 +1,18 @@
|
||||
--- a/net/minecraft/server/ItemSkullPlayer.java
|
||||
+++ b/net/minecraft/server/ItemSkullPlayer.java
|
||||
@@ -44,6 +44,15 @@
|
||||
nbttagcompound.set("SkullOwner", GameProfileSerializer.serialize(new NBTTagCompound(), gameprofile));
|
||||
return true;
|
||||
} else {
|
||||
+ // CraftBukkit start
|
||||
+ NBTTagList textures = nbttagcompound.getCompound("SkullOwner").getCompound("Properties").getList("textures", 10); // Safe due to method contracts
|
||||
+ for (int i = 0; i < textures.size(); i++) {
|
||||
+ if (textures.get(i) instanceof NBTTagCompound && !((NBTTagCompound) textures.get(i)).hasKeyOfType("Signature", 8) && ((NBTTagCompound) textures.get(i)).getString("Value").trim().isEmpty()) {
|
||||
+ nbttagcompound.remove("SkullOwner");
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
--- a/net/minecraft/server/ItemSnowball.java
|
||||
+++ b/net/minecraft/server/ItemSnowball.java
|
||||
@@ -10,19 +10,32 @@
|
||||
public InteractionResultWrapper<ItemStack> a(World world, EntityHuman entityhuman, EnumHand enumhand) {
|
||||
ItemStack itemstack = entityhuman.b(enumhand);
|
||||
|
||||
- world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemSnowball.RANDOM.nextFloat() * 0.4F + 0.8F));
|
||||
+ // CraftBukkit - moved down
|
||||
+ // world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemSnowball.RANDOM.nextFloat() * 0.4F + 0.8F));
|
||||
if (!world.isClientSide) {
|
||||
EntitySnowball entitysnowball = new EntitySnowball(world, entityhuman);
|
||||
|
||||
entitysnowball.setItem(itemstack);
|
||||
entitysnowball.a(entityhuman, entityhuman.pitch, entityhuman.yaw, 0.0F, 1.5F, 1.0F);
|
||||
- world.addEntity(entitysnowball);
|
||||
+ if (world.addEntity(entitysnowball)) {
|
||||
+ if (!entityhuman.abilities.canInstantlyBuild) {
|
||||
+ itemstack.subtract(1);
|
||||
+ }
|
||||
+
|
||||
+ world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemSnowball.RANDOM.nextFloat() * 0.4F + 0.8F));
|
||||
+ } else if (entityhuman instanceof EntityPlayer) {
|
||||
+ ((EntityPlayer) entityhuman).getBukkitEntity().updateInventory();
|
||||
+ }
|
||||
}
|
||||
+ // CraftBukkit end
|
||||
|
||||
entityhuman.b(StatisticList.ITEM_USED.b(this));
|
||||
+ // CraftBukkit start - moved up
|
||||
+ /*
|
||||
if (!entityhuman.abilities.canInstantlyBuild) {
|
||||
itemstack.subtract(1);
|
||||
}
|
||||
+ */
|
||||
|
||||
return InteractionResultWrapper.a(itemstack, world.s_());
|
||||
}
|
||||
@@ -0,0 +1,325 @@
|
||||
--- a/net/minecraft/server/ItemStack.java
|
||||
+++ b/net/minecraft/server/ItemStack.java
|
||||
@@ -19,6 +19,24 @@
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import com.mojang.serialization.Dynamic;
|
||||
+import java.util.List;
|
||||
+import java.util.Map;
|
||||
+
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.TreeType;
|
||||
+import org.bukkit.block.BlockState;
|
||||
+import org.bukkit.craftbukkit.block.CraftBlock;
|
||||
+import org.bukkit.craftbukkit.block.CraftBlockState;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
+import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||
+import org.bukkit.entity.Player;
|
||||
+import org.bukkit.event.block.BlockFertilizeEvent;
|
||||
+import org.bukkit.event.player.PlayerItemDamageEvent;
|
||||
+import org.bukkit.event.world.StructureGrowEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public final class ItemStack {
|
||||
|
||||
public static final Codec<ItemStack> a = RecordCodecBuilder.create((instance) -> {
|
||||
@@ -32,7 +50,7 @@
|
||||
});
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
public static final ItemStack b = new ItemStack((Item) null);
|
||||
- public static final DecimalFormat c = (DecimalFormat) SystemUtils.a((Object) (new DecimalFormat("#.##")), (decimalformat) -> {
|
||||
+ public static final DecimalFormat c = (DecimalFormat) SystemUtils.a((new DecimalFormat("#.##")), (decimalformat) -> { // CraftBukkit - decompile error
|
||||
decimalformat.setDecimalFormatSymbols(DecimalFormatSymbols.getInstance(Locale.ROOT));
|
||||
});
|
||||
private static final ChatModifier e = ChatModifier.a.setColor(EnumChatFormat.DARK_PURPLE).setItalic(true);
|
||||
@@ -67,23 +85,42 @@
|
||||
this.checkEmpty();
|
||||
}
|
||||
|
||||
+ // Called to run this stack through the data converter to handle older storage methods and serialized items
|
||||
+ public void convertStack(int version) {
|
||||
+ if (0 < version && version < CraftMagicNumbers.INSTANCE.getDataVersion()) {
|
||||
+ NBTTagCompound savedStack = new NBTTagCompound();
|
||||
+ this.save(savedStack);
|
||||
+ savedStack = (NBTTagCompound) MinecraftServer.getServer().dataConverterManager.update(DataConverterTypes.ITEM_STACK, new Dynamic(DynamicOpsNBT.a, savedStack), version, CraftMagicNumbers.INSTANCE.getDataVersion()).getValue();
|
||||
+ this.load(savedStack);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
private void checkEmpty() {
|
||||
+ if (this.j && this == ItemStack.b) throw new AssertionError("TRAP"); // CraftBukkit
|
||||
this.j = false;
|
||||
this.j = this.isEmpty();
|
||||
}
|
||||
|
||||
- private ItemStack(NBTTagCompound nbttagcompound) {
|
||||
+ // CraftBukkit - break into own method
|
||||
+ private void load(NBTTagCompound nbttagcompound) {
|
||||
this.item = (Item) IRegistry.ITEM.get(new MinecraftKey(nbttagcompound.getString("id")));
|
||||
this.count = nbttagcompound.getByte("Count");
|
||||
if (nbttagcompound.hasKeyOfType("tag", 10)) {
|
||||
- this.tag = nbttagcompound.getCompound("tag");
|
||||
- this.getItem().b(nbttagcompound);
|
||||
+ // CraftBukkit start - make defensive copy as this data may be coming from the save thread
|
||||
+ this.tag = (NBTTagCompound) nbttagcompound.getCompound("tag").clone();
|
||||
+ this.getItem().b(this.tag);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
if (this.getItem().usesDurability()) {
|
||||
this.setDamage(this.getDamage());
|
||||
}
|
||||
|
||||
+ }
|
||||
+
|
||||
+ private ItemStack(NBTTagCompound nbttagcompound) {
|
||||
+ this.load(nbttagcompound);
|
||||
+ // CraftBukkit end
|
||||
this.checkEmpty();
|
||||
}
|
||||
|
||||
@@ -113,7 +150,7 @@
|
||||
return this.j ? Items.AIR : this.item;
|
||||
}
|
||||
|
||||
- public EnumInteractionResult placeItem(ItemActionContext itemactioncontext) {
|
||||
+ public EnumInteractionResult placeItem(ItemActionContext itemactioncontext, EnumHand enumhand) { // CraftBukkit - add hand
|
||||
EntityHuman entityhuman = itemactioncontext.getEntity();
|
||||
BlockPosition blockposition = itemactioncontext.getClickPosition();
|
||||
ShapeDetectorBlock shapedetectorblock = new ShapeDetectorBlock(itemactioncontext.getWorld(), blockposition, false);
|
||||
@@ -121,12 +158,153 @@
|
||||
if (entityhuman != null && !entityhuman.abilities.mayBuild && !this.b(itemactioncontext.getWorld().p(), shapedetectorblock)) {
|
||||
return EnumInteractionResult.PASS;
|
||||
} else {
|
||||
+ // CraftBukkit start - handle all block place event logic here
|
||||
+ NBTTagCompound oldData = this.getTagClone();
|
||||
+ int oldCount = this.getCount();
|
||||
+ WorldServer world = (WorldServer) itemactioncontext.getWorld();
|
||||
+
|
||||
+ if (!(this.getItem() instanceof ItemBucket)) { // if not bucket
|
||||
+ world.captureBlockStates = true;
|
||||
+ // special case bonemeal
|
||||
+ if (this.getItem() == Items.BONE_MEAL) {
|
||||
+ world.captureTreeGeneration = true;
|
||||
+ }
|
||||
+ }
|
||||
Item item = this.getItem();
|
||||
EnumInteractionResult enuminteractionresult = item.a(itemactioncontext);
|
||||
+ NBTTagCompound newData = this.getTagClone();
|
||||
+ int newCount = this.getCount();
|
||||
+ this.setCount(oldCount);
|
||||
+ this.setTagClone(oldData);
|
||||
+ world.captureBlockStates = false;
|
||||
+ if (enuminteractionresult.a() && world.captureTreeGeneration && world.capturedBlockStates.size() > 0) {
|
||||
+ world.captureTreeGeneration = false;
|
||||
+ Location location = new Location(world.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ());
|
||||
+ TreeType treeType = BlockSapling.treeType;
|
||||
+ BlockSapling.treeType = null;
|
||||
+ List<BlockState> blocks = new java.util.ArrayList<>(world.capturedBlockStates.values());
|
||||
+ world.capturedBlockStates.clear();
|
||||
+ StructureGrowEvent structureEvent = null;
|
||||
+ if (treeType != null) {
|
||||
+ boolean isBonemeal = getItem() == Items.BONE_MEAL;
|
||||
+ structureEvent = new StructureGrowEvent(location, treeType, isBonemeal, (Player) entityhuman.getBukkitEntity(), blocks);
|
||||
+ org.bukkit.Bukkit.getPluginManager().callEvent(structureEvent);
|
||||
+ }
|
||||
+
|
||||
+ BlockFertilizeEvent fertilizeEvent = new BlockFertilizeEvent(CraftBlock.at(world, blockposition), (Player) entityhuman.getBukkitEntity(), blocks);
|
||||
+ fertilizeEvent.setCancelled(structureEvent != null && structureEvent.isCancelled());
|
||||
+ org.bukkit.Bukkit.getPluginManager().callEvent(fertilizeEvent);
|
||||
+
|
||||
+ if (!fertilizeEvent.isCancelled()) {
|
||||
+ // Change the stack to its new contents if it hasn't been tampered with.
|
||||
+ if (this.getCount() == oldCount && Objects.equals(this.tag, oldData)) {
|
||||
+ this.setTag(newData);
|
||||
+ this.setCount(newCount);
|
||||
+ }
|
||||
+ for (BlockState blockstate : blocks) {
|
||||
+ blockstate.update(true);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return enuminteractionresult;
|
||||
+ }
|
||||
+ world.captureTreeGeneration = false;
|
||||
|
||||
if (entityhuman != null && enuminteractionresult.a()) {
|
||||
- entityhuman.b(StatisticList.ITEM_USED.b(item));
|
||||
+ 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
|
||||
+ for (BlockState blockstate : blocks) {
|
||||
+ blockstate.update(true, false);
|
||||
+ }
|
||||
+
|
||||
+ // Brute force all possible updates
|
||||
+ BlockPosition placedPos = ((CraftBlock) placeEvent.getBlock()).getPosition();
|
||||
+ for (EnumDirection dir : EnumDirection.values()) {
|
||||
+ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutBlockChange(world, placedPos.shift(dir)));
|
||||
+ }
|
||||
+ } else {
|
||||
+ // Change the stack to its new contents if it hasn't been tampered with.
|
||||
+ if (this.getCount() == oldCount && Objects.equals(this.tag, oldData)) {
|
||||
+ this.setTag(newData);
|
||||
+ this.setCount(newCount);
|
||||
+ }
|
||||
+
|
||||
+ for (Map.Entry<BlockPosition, TileEntity> e : world.capturedTileEntities.entrySet()) {
|
||||
+ world.setTileEntity(e.getKey(), e.getValue());
|
||||
+ }
|
||||
+
|
||||
+ for (BlockState blockstate : blocks) {
|
||||
+ int updateFlag = ((CraftBlockState) blockstate).getFlag();
|
||||
+ IBlockData oldBlock = ((CraftBlockState) blockstate).getHandle();
|
||||
+ BlockPosition newblockposition = ((CraftBlockState) blockstate).getPosition();
|
||||
+ IBlockData block = world.getType(newblockposition);
|
||||
+
|
||||
+ if (!(block.getBlock() instanceof BlockTileEntity)) { // Containers get placed automatically
|
||||
+ block.getBlock().onPlace(block, world, newblockposition, oldBlock, true);
|
||||
+ }
|
||||
+
|
||||
+ world.notifyAndUpdatePhysics(newblockposition, null, oldBlock, block, world.getType(newblockposition), updateFlag, 512); // send null chunk as chunk.k() returns false by this point
|
||||
+ }
|
||||
+
|
||||
+ // Special case juke boxes as they update their tile entity. Copied from ItemRecord.
|
||||
+ // PAIL: checkme on updates.
|
||||
+ if (this.item instanceof ItemRecord) {
|
||||
+ ((BlockJukeBox) Blocks.JUKEBOX).a(world, blockposition, world.getType(blockposition), this);
|
||||
+ world.a((EntityHuman) null, 1010, blockposition, Item.getId(this.item));
|
||||
+ this.subtract(1);
|
||||
+ entityhuman.a(StatisticList.PLAY_RECORD);
|
||||
+ }
|
||||
+
|
||||
+ if (this.item == Items.WITHER_SKELETON_SKULL) { // Special case skulls to allow wither spawns to be cancelled
|
||||
+ BlockPosition bp = blockposition;
|
||||
+ if (!world.getType(blockposition).getMaterial().isReplaceable()) {
|
||||
+ if (!world.getType(blockposition).getMaterial().isBuildable()) {
|
||||
+ bp = null;
|
||||
+ } else {
|
||||
+ bp = bp.shift(itemactioncontext.getClickedFace());
|
||||
+ }
|
||||
+ }
|
||||
+ if (bp != null) {
|
||||
+ TileEntity te = world.getTileEntity(bp);
|
||||
+ if (te instanceof TileEntitySkull) {
|
||||
+ BlockWitherSkull.a(world, bp, (TileEntitySkull) te);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ // SPIGOT-4678
|
||||
+ if (this.item instanceof ItemSign && ItemSign.openSign != null) {
|
||||
+ try {
|
||||
+ entityhuman.openSign((TileEntitySign) world.getTileEntity(ItemSign.openSign));
|
||||
+ } finally {
|
||||
+ ItemSign.openSign = null;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ // SPIGOT-1288 - play sound stripped from ItemBlock
|
||||
+ if (this.item instanceof ItemBlock) {
|
||||
+ SoundEffectType soundeffecttype = ((ItemBlock) this.item).getBlock().stepSound;
|
||||
+ world.playSound(entityhuman, blockposition, soundeffecttype.getPlaceSound(), SoundCategory.BLOCKS, (soundeffecttype.getVolume() + 1.0F) / 2.0F, soundeffecttype.getPitch() * 0.8F);
|
||||
+ }
|
||||
+
|
||||
+ entityhuman.b(StatisticList.ITEM_USED.b(item));
|
||||
+ }
|
||||
}
|
||||
+ world.capturedTileEntities.clear();
|
||||
+ world.capturedBlockStates.clear();
|
||||
+ // CraftBukkit end
|
||||
|
||||
return enuminteractionresult;
|
||||
}
|
||||
@@ -207,6 +385,21 @@
|
||||
}
|
||||
|
||||
i -= k;
|
||||
+ // CraftBukkit start
|
||||
+ if (entityplayer != null) {
|
||||
+ PlayerItemDamageEvent event = new PlayerItemDamageEvent(entityplayer.getBukkitEntity(), CraftItemStack.asCraftMirror(this), i);
|
||||
+ event.getPlayer().getServer().getPluginManager().callEvent(event);
|
||||
+
|
||||
+ if (i != event.getDamage() || event.isCancelled()) {
|
||||
+ event.getPlayer().updateInventory();
|
||||
+ }
|
||||
+ if (event.isCancelled()) {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ i = event.getDamage();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
if (i <= 0) {
|
||||
return false;
|
||||
}
|
||||
@@ -228,6 +421,11 @@
|
||||
if (this.isDamaged(i, t0.getRandom(), t0 instanceof EntityPlayer ? (EntityPlayer) t0 : null)) {
|
||||
consumer.accept(t0);
|
||||
Item item = this.getItem();
|
||||
+ // CraftBukkit start - Check for item breaking
|
||||
+ if (this.count == 1 && t0 instanceof EntityHuman) {
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerItemBreakEvent((EntityHuman) t0, this);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
this.subtract(1);
|
||||
if (t0 instanceof EntityHuman) {
|
||||
@@ -359,6 +557,17 @@
|
||||
return this.tag;
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ @Nullable
|
||||
+ private NBTTagCompound getTagClone() {
|
||||
+ return this.tag == null ? null : this.tag.clone();
|
||||
+ }
|
||||
+
|
||||
+ private void setTagClone(@Nullable NBTTagCompound nbtttagcompound) {
|
||||
+ this.setTag(nbtttagcompound == null ? null : nbtttagcompound.clone());
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public NBTTagCompound getOrCreateTag() {
|
||||
if (this.tag == null) {
|
||||
this.setTag(new NBTTagCompound());
|
||||
@@ -522,6 +731,12 @@
|
||||
}
|
||||
|
||||
public void setRepairCost(int i) {
|
||||
+ // CraftBukkit start - remove RepairCost tag when 0 (SPIGOT-3945)
|
||||
+ if (i == 0) {
|
||||
+ this.removeTag("RepairCost");
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.getOrCreateTag().setInt("RepairCost", i);
|
||||
}
|
||||
|
||||
@@ -571,6 +786,13 @@
|
||||
nbttaglist.add(nbttagcompound);
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ @Deprecated
|
||||
+ public void setItem(Item item) {
|
||||
+ this.item = item;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public IChatBaseComponent C() {
|
||||
IChatMutableComponent ichatmutablecomponent = (new ChatComponentText("")).addSibling(this.getName());
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
--- a/net/minecraft/server/ItemTrident.java
|
||||
+++ b/net/minecraft/server/ItemTrident.java
|
||||
@@ -43,9 +43,12 @@
|
||||
|
||||
if (k <= 0 || entityhuman.isInWaterOrRain()) {
|
||||
if (!world.isClientSide) {
|
||||
+ // CraftBukkit - moved down
|
||||
+ /*
|
||||
itemstack.damage(1, entityhuman, (entityhuman1) -> {
|
||||
entityhuman1.broadcastItemBreak(entityliving.getRaisedHand());
|
||||
});
|
||||
+ */
|
||||
if (k == 0) {
|
||||
EntityThrownTrident entitythrowntrident = new EntityThrownTrident(world, entityhuman, itemstack);
|
||||
|
||||
@@ -54,16 +57,39 @@
|
||||
entitythrowntrident.fromPlayer = EntityArrow.PickupStatus.CREATIVE_ONLY;
|
||||
}
|
||||
|
||||
- world.addEntity(entitythrowntrident);
|
||||
+ // CraftBukkit start
|
||||
+ if (!world.addEntity(entitythrowntrident)) {
|
||||
+ if (entityhuman instanceof EntityPlayer) {
|
||||
+ ((EntityPlayer) entityhuman).getBukkitEntity().updateInventory();
|
||||
+ }
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ itemstack.damage(1, entityhuman, (entityhuman1) -> {
|
||||
+ entityhuman1.broadcastItemBreak(entityliving.getRaisedHand());
|
||||
+ });
|
||||
+ entitythrowntrident.trident = itemstack.cloneItemStack(); // SPIGOT-4511 update since damage call moved
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
world.playSound((EntityHuman) null, (Entity) entitythrowntrident, SoundEffects.ITEM_TRIDENT_THROW, SoundCategory.PLAYERS, 1.0F, 1.0F);
|
||||
if (!entityhuman.abilities.canInstantlyBuild) {
|
||||
entityhuman.inventory.f(itemstack);
|
||||
}
|
||||
+ // CraftBukkit start - SPIGOT-5458 also need in this branch :(
|
||||
+ } else {
|
||||
+ itemstack.damage(1, entityhuman, (entityhuman1) -> {
|
||||
+ entityhuman1.broadcastItemBreak(entityliving.getRaisedHand());
|
||||
+ });
|
||||
+ // CraftBukkkit end
|
||||
}
|
||||
}
|
||||
|
||||
entityhuman.b(StatisticList.ITEM_USED.b(this));
|
||||
if (k > 0) {
|
||||
+ // CraftBukkit start
|
||||
+ org.bukkit.event.player.PlayerRiptideEvent event = new org.bukkit.event.player.PlayerRiptideEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack));
|
||||
+ event.getPlayer().getServer().getPluginManager().callEvent(event);
|
||||
+ // CraftBukkit end
|
||||
float f = entityhuman.yaw;
|
||||
float f1 = entityhuman.pitch;
|
||||
float f2 = -MathHelper.sin(f * 0.017453292F) * MathHelper.cos(f1 * 0.017453292F);
|
||||
@@ -0,0 +1,35 @@
|
||||
--- a/net/minecraft/server/ItemWorldMap.java
|
||||
+++ b/net/minecraft/server/ItemWorldMap.java
|
||||
@@ -6,6 +6,11 @@
|
||||
import com.google.common.collect.Multisets;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.Bukkit;
|
||||
+import org.bukkit.event.server.MapInitializeEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class ItemWorldMap extends ItemWorldMapBase {
|
||||
|
||||
public ItemWorldMap(Item.Info item_info) {
|
||||
@@ -38,7 +43,7 @@
|
||||
public static int d(ItemStack itemstack) {
|
||||
NBTTagCompound nbttagcompound = itemstack.getTag();
|
||||
|
||||
- return nbttagcompound != null && nbttagcompound.hasKeyOfType("map", 99) ? nbttagcompound.getInt("map") : 0;
|
||||
+ return nbttagcompound != null && nbttagcompound.hasKeyOfType("map", 99) ? nbttagcompound.getInt("map") : -1; // CraftBukkit - make new maps for no tag
|
||||
}
|
||||
|
||||
private static WorldMap a(ItemStack itemstack, World world, int i, int j, int k, boolean flag, boolean flag1, ResourceKey<World> resourcekey) {
|
||||
@@ -48,6 +53,11 @@
|
||||
worldmap.a(i, j, k, flag, flag1, resourcekey);
|
||||
world.a(worldmap);
|
||||
itemstack.getOrCreateTag().setInt("map", l);
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ MapInitializeEvent event = new MapInitializeEvent(worldmap.mapView);
|
||||
+ Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
+ // CraftBukkit end
|
||||
return worldmap;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
--- a/net/minecraft/server/CraftingManager.java
|
||||
+++ b/net/minecraft/server/CraftingManager.java
|
||||
@@ -23,11 +23,13 @@
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
+import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap; // CraftBukkit
|
||||
+
|
||||
public class CraftingManager extends ResourceDataJson {
|
||||
|
||||
private static final Gson a = (new GsonBuilder()).setPrettyPrinting().disableHtmlEscaping().create();
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
- public Map<Recipes<?>, Map<MinecraftKey, IRecipe<?>>> recipes = ImmutableMap.of();
|
||||
+ public Map<Recipes<?>, Object2ObjectLinkedOpenHashMap<MinecraftKey, IRecipe<?>>> recipes = ImmutableMap.of(); // CraftBukkit
|
||||
private boolean d;
|
||||
|
||||
public CraftingManager() {
|
||||
@@ -36,7 +38,12 @@
|
||||
|
||||
protected void a(Map<MinecraftKey, JsonElement> map, IResourceManager iresourcemanager, GameProfilerFiller gameprofilerfiller) {
|
||||
this.d = false;
|
||||
- Map<Recipes<?>, Builder<MinecraftKey, IRecipe<?>>> map1 = Maps.newHashMap();
|
||||
+ // CraftBukkit start - SPIGOT-5667 make sure all types are populated and mutable
|
||||
+ Map<Recipes<?>, Object2ObjectLinkedOpenHashMap<MinecraftKey, IRecipe<?>>> map1 = Maps.newHashMap();
|
||||
+ for (Recipes<?> recipeType : IRegistry.RECIPE_TYPE) {
|
||||
+ map1.put(recipeType, new Object2ObjectLinkedOpenHashMap<>());
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
Iterator iterator = map.entrySet().iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
@@ -46,24 +53,42 @@
|
||||
try {
|
||||
IRecipe<?> irecipe = a(minecraftkey, ChatDeserializer.m((JsonElement) entry.getValue(), "top element"));
|
||||
|
||||
- ((Builder) map1.computeIfAbsent(irecipe.g(), (recipes) -> {
|
||||
- return ImmutableMap.builder();
|
||||
- })).put(minecraftkey, irecipe);
|
||||
+ // CraftBukkit start - SPIGOT-4638: last recipe gets priority
|
||||
+ (map1.computeIfAbsent(irecipe.g(), (recipes) -> {
|
||||
+ return new Object2ObjectLinkedOpenHashMap<>();
|
||||
+ })).putAndMoveToFirst(minecraftkey, irecipe);
|
||||
+ // CraftBukkit end
|
||||
} catch (IllegalArgumentException | JsonParseException jsonparseexception) {
|
||||
CraftingManager.LOGGER.error("Parsing error loading recipe {}", minecraftkey, jsonparseexception);
|
||||
}
|
||||
}
|
||||
|
||||
this.recipes = (Map) map1.entrySet().stream().collect(ImmutableMap.toImmutableMap(Entry::getKey, (entry1) -> {
|
||||
- return ((Builder) entry1.getValue()).build();
|
||||
+ return (entry1.getValue()); // CraftBukkit
|
||||
}));
|
||||
CraftingManager.LOGGER.info("Loaded {} recipes", map1.size());
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public void addRecipe(IRecipe<?> irecipe) {
|
||||
+ Object2ObjectLinkedOpenHashMap<MinecraftKey, IRecipe<?>> map = this.recipes.get(irecipe.g()); // CraftBukkit
|
||||
+
|
||||
+ if (map.containsKey(irecipe.getKey())) {
|
||||
+ throw new IllegalStateException("Duplicate recipe ignored with ID " + irecipe.getKey());
|
||||
+ } else {
|
||||
+ map.putAndMoveToFirst(irecipe.getKey(), irecipe); // CraftBukkit - SPIGOT-4638: last recipe gets priority
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public <C extends IInventory, T extends IRecipe<C>> Optional<T> craft(Recipes<T> recipes, C c0, World world) {
|
||||
- return this.b(recipes).values().stream().flatMap((irecipe) -> {
|
||||
+ // CraftBukkit start
|
||||
+ Optional<T> recipe = this.b(recipes).values().stream().flatMap((irecipe) -> {
|
||||
return SystemUtils.a(recipes.a(irecipe, world, c0));
|
||||
}).findFirst();
|
||||
+ c0.setCurrentRecipe(recipe.orElse(null)); // CraftBukkit - Clear recipe when no recipe is found
|
||||
+ // CraftBukkit end
|
||||
+ return recipe;
|
||||
}
|
||||
|
||||
public <C extends IInventory, T extends IRecipe<C>> List<T> a(Recipes<T> recipes) {
|
||||
@@ -81,7 +106,7 @@
|
||||
}
|
||||
|
||||
private <C extends IInventory, T extends IRecipe<C>> Map<MinecraftKey, IRecipe<C>> b(Recipes<T> recipes) {
|
||||
- return (Map) this.recipes.getOrDefault(recipes, Collections.emptyMap());
|
||||
+ return (Map) this.recipes.getOrDefault(recipes, new Object2ObjectLinkedOpenHashMap<>()); // CraftBukkit
|
||||
}
|
||||
|
||||
public <C extends IInventory, T extends IRecipe<C>> NonNullList<ItemStack> c(Recipes<T> recipes, C c0, World world) {
|
||||
@@ -102,7 +127,7 @@
|
||||
|
||||
public Optional<? extends IRecipe<?>> getRecipe(MinecraftKey minecraftkey) {
|
||||
return this.recipes.values().stream().map((map) -> {
|
||||
- return (IRecipe) map.get(minecraftkey);
|
||||
+ return map.get(minecraftkey); // CraftBukkit - decompile error
|
||||
}).filter(Objects::nonNull).findFirst();
|
||||
}
|
||||
|
||||
@@ -125,4 +150,14 @@
|
||||
return new JsonSyntaxException("Invalid or unsupported recipe type '" + s + "'");
|
||||
})).a(minecraftkey, jsonobject);
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ public void clearRecipes() {
|
||||
+ this.recipes = Maps.newHashMap();
|
||||
+
|
||||
+ for (Recipes<?> recipeType : IRegistry.RECIPE_TYPE) {
|
||||
+ this.recipes.put(recipeType, new Object2ObjectLinkedOpenHashMap<>());
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
--- a/net/minecraft/server/FurnaceRecipe.java
|
||||
+++ b/net/minecraft/server/FurnaceRecipe.java
|
||||
@@ -1,5 +1,13 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.inventory.CraftFurnaceRecipe;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftRecipe;
|
||||
+import org.bukkit.craftbukkit.util.CraftNamespacedKey;
|
||||
+import org.bukkit.inventory.Recipe;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class FurnaceRecipe extends RecipeCooking {
|
||||
|
||||
public FurnaceRecipe(MinecraftKey minecraftkey, String s, RecipeItemStack recipeitemstack, ItemStack itemstack, float f, int i) {
|
||||
@@ -10,4 +18,14 @@
|
||||
public RecipeSerializer<?> getRecipeSerializer() {
|
||||
return RecipeSerializer.p;
|
||||
}
|
||||
+
|
||||
+ @Override
|
||||
+ public Recipe toBukkitRecipe() {
|
||||
+ CraftItemStack result = CraftItemStack.asCraftMirror(this.result);
|
||||
+
|
||||
+ CraftFurnaceRecipe recipe = new CraftFurnaceRecipe(CraftNamespacedKey.fromMinecraft(this.key), result, CraftRecipe.toBukkit(this.ingredient), this.experience, this.cookingTime);
|
||||
+ recipe.setGroup(this.group);
|
||||
+
|
||||
+ return recipe;
|
||||
+ }
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
--- a/net/minecraft/server/IRecipe.java
|
||||
+++ b/net/minecraft/server/IRecipe.java
|
||||
@@ -35,4 +35,6 @@
|
||||
RecipeSerializer<?> getRecipeSerializer();
|
||||
|
||||
Recipes<?> g();
|
||||
+
|
||||
+ org.bukkit.inventory.Recipe toBukkitRecipe(); // CraftBukkit
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
--- a/net/minecraft/server/IRecipeComplex.java
|
||||
+++ b/net/minecraft/server/IRecipeComplex.java
|
||||
@@ -22,4 +22,11 @@
|
||||
public ItemStack getResult() {
|
||||
return ItemStack.b;
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public org.bukkit.inventory.Recipe toBukkitRecipe() {
|
||||
+ return new org.bukkit.craftbukkit.inventory.CraftComplexRecipe(this);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
--- a/net/minecraft/server/RecipeBlasting.java
|
||||
+++ b/net/minecraft/server/RecipeBlasting.java
|
||||
@@ -1,5 +1,13 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.inventory.CraftBlastingRecipe;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftRecipe;
|
||||
+import org.bukkit.craftbukkit.util.CraftNamespacedKey;
|
||||
+import org.bukkit.inventory.Recipe;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class RecipeBlasting extends RecipeCooking {
|
||||
|
||||
public RecipeBlasting(MinecraftKey minecraftkey, String s, RecipeItemStack recipeitemstack, ItemStack itemstack, float f, int i) {
|
||||
@@ -10,4 +18,16 @@
|
||||
public RecipeSerializer<?> getRecipeSerializer() {
|
||||
return RecipeSerializer.q;
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public Recipe toBukkitRecipe() {
|
||||
+ CraftItemStack result = CraftItemStack.asCraftMirror(this.result);
|
||||
+
|
||||
+ CraftBlastingRecipe recipe = new CraftBlastingRecipe(CraftNamespacedKey.fromMinecraft(this.key), result, CraftRecipe.toBukkit(this.ingredient), this.experience, this.cookingTime);
|
||||
+ recipe.setGroup(this.group);
|
||||
+
|
||||
+ return recipe;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
--- a/net/minecraft/server/RecipeCampfire.java
|
||||
+++ b/net/minecraft/server/RecipeCampfire.java
|
||||
@@ -1,5 +1,13 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.inventory.CraftCampfireRecipe;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftRecipe;
|
||||
+import org.bukkit.craftbukkit.util.CraftNamespacedKey;
|
||||
+import org.bukkit.inventory.Recipe;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class RecipeCampfire extends RecipeCooking {
|
||||
|
||||
public RecipeCampfire(MinecraftKey minecraftkey, String s, RecipeItemStack recipeitemstack, ItemStack itemstack, float f, int i) {
|
||||
@@ -10,4 +18,16 @@
|
||||
public RecipeSerializer<?> getRecipeSerializer() {
|
||||
return RecipeSerializer.s;
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public Recipe toBukkitRecipe() {
|
||||
+ CraftItemStack result = CraftItemStack.asCraftMirror(this.result);
|
||||
+
|
||||
+ CraftCampfireRecipe recipe = new CraftCampfireRecipe(CraftNamespacedKey.fromMinecraft(this.key), result, CraftRecipe.toBukkit(this.ingredient), this.experience, this.cookingTime);
|
||||
+ recipe.setGroup(this.group);
|
||||
+
|
||||
+ return recipe;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
--- a/net/minecraft/server/RecipeItemStack.java
|
||||
+++ b/net/minecraft/server/RecipeItemStack.java
|
||||
@@ -25,6 +25,7 @@
|
||||
private final RecipeItemStack.Provider[] b;
|
||||
public ItemStack[] choices;
|
||||
private IntList d;
|
||||
+ public boolean exact; // CraftBukkit
|
||||
|
||||
public RecipeItemStack(Stream<? extends RecipeItemStack.Provider> stream) {
|
||||
this.b = (RecipeItemStack.Provider[]) stream.toArray((i) -> {
|
||||
@@ -57,6 +58,15 @@
|
||||
for (int j = 0; j < i; ++j) {
|
||||
ItemStack itemstack1 = aitemstack[j];
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ if (exact) {
|
||||
+ if (itemstack1.getItem() == itemstack.getItem() && ItemStack.equals(itemstack, itemstack1)) {
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ continue;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
if (itemstack1.getItem() == itemstack.getItem()) {
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
--- a/net/minecraft/server/RecipeSmithing.java
|
||||
+++ b/net/minecraft/server/RecipeSmithing.java
|
||||
@@ -3,6 +3,14 @@
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftRecipe;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftSmithingRecipe;
|
||||
+import org.bukkit.craftbukkit.util.CraftNamespacedKey;
|
||||
+import org.bukkit.inventory.Recipe;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class RecipeSmithing implements IRecipe<IInventory> {
|
||||
|
||||
private final RecipeItemStack a;
|
||||
@@ -58,6 +66,17 @@
|
||||
return Recipes.SMITHING;
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public Recipe toBukkitRecipe() {
|
||||
+ CraftItemStack result = CraftItemStack.asCraftMirror(this.c);
|
||||
+
|
||||
+ CraftSmithingRecipe recipe = new CraftSmithingRecipe(CraftNamespacedKey.fromMinecraft(this.d), result, CraftRecipe.toBukkit(this.a), CraftRecipe.toBukkit(this.b));
|
||||
+
|
||||
+ return recipe;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public static class a implements RecipeSerializer<RecipeSmithing> {
|
||||
|
||||
public a() {}
|
||||
@@ -0,0 +1,33 @@
|
||||
--- a/net/minecraft/server/RecipeSmoking.java
|
||||
+++ b/net/minecraft/server/RecipeSmoking.java
|
||||
@@ -1,5 +1,13 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftRecipe;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftSmokingRecipe;
|
||||
+import org.bukkit.craftbukkit.util.CraftNamespacedKey;
|
||||
+import org.bukkit.inventory.Recipe;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class RecipeSmoking extends RecipeCooking {
|
||||
|
||||
public RecipeSmoking(MinecraftKey minecraftkey, String s, RecipeItemStack recipeitemstack, ItemStack itemstack, float f, int i) {
|
||||
@@ -10,4 +18,16 @@
|
||||
public RecipeSerializer<?> getRecipeSerializer() {
|
||||
return RecipeSerializer.r;
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public Recipe toBukkitRecipe() {
|
||||
+ CraftItemStack result = CraftItemStack.asCraftMirror(this.result);
|
||||
+
|
||||
+ CraftSmokingRecipe recipe = new CraftSmokingRecipe(CraftNamespacedKey.fromMinecraft(this.key), result, CraftRecipe.toBukkit(this.ingredient), this.experience, this.cookingTime);
|
||||
+ recipe.setGroup(this.group);
|
||||
+
|
||||
+ return recipe;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
--- a/net/minecraft/server/RecipeStonecutting.java
|
||||
+++ b/net/minecraft/server/RecipeStonecutting.java
|
||||
@@ -1,5 +1,13 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftRecipe;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftStonecuttingRecipe;
|
||||
+import org.bukkit.craftbukkit.util.CraftNamespacedKey;
|
||||
+import org.bukkit.inventory.Recipe;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class RecipeStonecutting extends RecipeSingleItem {
|
||||
|
||||
public RecipeStonecutting(MinecraftKey minecraftkey, String s, RecipeItemStack recipeitemstack, ItemStack itemstack) {
|
||||
@@ -10,4 +18,16 @@
|
||||
public boolean a(IInventory iinventory, World world) {
|
||||
return this.ingredient.test(iinventory.getItem(0));
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public Recipe toBukkitRecipe() {
|
||||
+ CraftItemStack result = CraftItemStack.asCraftMirror(this.result);
|
||||
+
|
||||
+ CraftStonecuttingRecipe recipe = new CraftStonecuttingRecipe(CraftNamespacedKey.fromMinecraft(this.key), result, CraftRecipe.toBukkit(this.ingredient));
|
||||
+ recipe.setGroup(this.group);
|
||||
+
|
||||
+ return recipe;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
--- a/net/minecraft/server/ShapedRecipes.java
|
||||
+++ b/net/minecraft/server/ShapedRecipes.java
|
||||
@@ -13,6 +13,13 @@
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftRecipe;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftShapedRecipe;
|
||||
+import org.bukkit.inventory.RecipeChoice;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class ShapedRecipes implements RecipeCrafting {
|
||||
|
||||
private final int width;
|
||||
@@ -31,6 +38,66 @@
|
||||
this.result = itemstack;
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public org.bukkit.inventory.ShapedRecipe toBukkitRecipe() {
|
||||
+ CraftItemStack result = CraftItemStack.asCraftMirror(this.result);
|
||||
+ CraftShapedRecipe recipe = new CraftShapedRecipe(result, this);
|
||||
+ recipe.setGroup(this.group);
|
||||
+
|
||||
+ switch (this.height) {
|
||||
+ case 1:
|
||||
+ switch (this.width) {
|
||||
+ case 1:
|
||||
+ recipe.shape("a");
|
||||
+ break;
|
||||
+ case 2:
|
||||
+ recipe.shape("ab");
|
||||
+ break;
|
||||
+ case 3:
|
||||
+ recipe.shape("abc");
|
||||
+ break;
|
||||
+ }
|
||||
+ break;
|
||||
+ case 2:
|
||||
+ switch (this.width) {
|
||||
+ case 1:
|
||||
+ recipe.shape("a","b");
|
||||
+ break;
|
||||
+ case 2:
|
||||
+ recipe.shape("ab","cd");
|
||||
+ break;
|
||||
+ case 3:
|
||||
+ recipe.shape("abc","def");
|
||||
+ break;
|
||||
+ }
|
||||
+ break;
|
||||
+ case 3:
|
||||
+ switch (this.width) {
|
||||
+ case 1:
|
||||
+ recipe.shape("a","b","c");
|
||||
+ break;
|
||||
+ case 2:
|
||||
+ recipe.shape("ab","cd","ef");
|
||||
+ break;
|
||||
+ case 3:
|
||||
+ recipe.shape("abc","def","ghi");
|
||||
+ break;
|
||||
+ }
|
||||
+ break;
|
||||
+ }
|
||||
+ char c = 'a';
|
||||
+ for (RecipeItemStack list : this.items) {
|
||||
+ RecipeChoice choice = CraftRecipe.toBukkit(list);
|
||||
+ if (choice != null) {
|
||||
+ recipe.setIngredient(c, choice);
|
||||
+ }
|
||||
+
|
||||
+ c++;
|
||||
+ }
|
||||
+ return recipe;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
@Override
|
||||
public MinecraftKey getKey() {
|
||||
return this.key;
|
||||
@@ -0,0 +1,36 @@
|
||||
--- a/net/minecraft/server/ShapelessRecipes.java
|
||||
+++ b/net/minecraft/server/ShapelessRecipes.java
|
||||
@@ -6,6 +6,12 @@
|
||||
import it.unimi.dsi.fastutil.ints.IntList;
|
||||
import java.util.Iterator;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftRecipe;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftShapelessRecipe;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class ShapelessRecipes implements RecipeCrafting {
|
||||
|
||||
private final MinecraftKey key;
|
||||
@@ -20,6 +26,20 @@
|
||||
this.ingredients = nonnulllist;
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ @SuppressWarnings("unchecked")
|
||||
+ public org.bukkit.inventory.ShapelessRecipe toBukkitRecipe() {
|
||||
+ CraftItemStack result = CraftItemStack.asCraftMirror(this.result);
|
||||
+ CraftShapelessRecipe recipe = new CraftShapelessRecipe(result, this);
|
||||
+ recipe.setGroup(this.group);
|
||||
+
|
||||
+ for (RecipeItemStack list : this.ingredients) {
|
||||
+ recipe.addIngredient(CraftRecipe.toBukkit(list));
|
||||
+ }
|
||||
+ return recipe;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
@Override
|
||||
public MinecraftKey getKey() {
|
||||
return this.key;
|
||||
@@ -0,0 +1,16 @@
|
||||
--- a/net/minecraft/server/EnchantmentFrostWalker.java
|
||||
+++ b/net/minecraft/server/EnchantmentFrostWalker.java
|
||||
@@ -46,8 +46,11 @@
|
||||
IBlockData iblockdata2 = world.getType(blockposition1);
|
||||
|
||||
if (iblockdata2.getMaterial() == Material.WATER && (Integer) iblockdata2.get(BlockFluids.LEVEL) == 0 && iblockdata.canPlace(world, blockposition1) && world.a(iblockdata, blockposition1, VoxelShapeCollision.a())) {
|
||||
- world.setTypeUpdate(blockposition1, iblockdata);
|
||||
- world.getBlockTickList().a(blockposition1, Blocks.FROSTED_ICE, MathHelper.nextInt(entityliving.getRandom(), 60, 120));
|
||||
+ // CraftBukkit Start - Call EntityBlockFormEvent for Frost Walker
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition1, iblockdata, entityliving)) {
|
||||
+ world.getBlockTickList().a(blockposition1, Blocks.FROSTED_ICE, MathHelper.nextInt(entityliving.getRandom(), 60, 120));
|
||||
+ }
|
||||
+ // CraftBukkit End
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
--- a/net/minecraft/server/EnchantmentWeaponDamage.java
|
||||
+++ b/net/minecraft/server/EnchantmentWeaponDamage.java
|
||||
@@ -51,7 +51,7 @@
|
||||
if (this.a == 2 && entityliving1.getMonsterType() == EnumMonsterType.ARTHROPOD) {
|
||||
int j = 20 + entityliving.getRandom().nextInt(10 * i);
|
||||
|
||||
- entityliving1.addEffect(new MobEffect(MobEffects.SLOWER_MOVEMENT, j, 3));
|
||||
+ entityliving1.addEffect(new MobEffect(MobEffects.SLOWER_MOVEMENT, j, 3), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
--- a/net/minecraft/server/Enchantments.java
|
||||
+++ b/net/minecraft/server/Enchantments.java
|
||||
@@ -42,7 +42,15 @@
|
||||
public static final Enchantment MENDING = a("mending", new EnchantmentMending(Enchantment.Rarity.RARE, EnumItemSlot.values()));
|
||||
public static final Enchantment VANISHING_CURSE = a("vanishing_curse", new EnchantmentVanishing(Enchantment.Rarity.VERY_RARE, EnumItemSlot.values()));
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ static {
|
||||
+ for (Object enchantment : IRegistry.ENCHANTMENT) {
|
||||
+ org.bukkit.enchantments.Enchantment.registerEnchantment(new org.bukkit.craftbukkit.enchantments.CraftEnchantment((Enchantment) enchantment));
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
private static Enchantment a(String s, Enchantment enchantment) {
|
||||
- return (Enchantment) IRegistry.a(IRegistry.ENCHANTMENT, s, (Object) enchantment);
|
||||
+ return (Enchantment) IRegistry.a(IRegistry.ENCHANTMENT, s, enchantment); // CraftBukkit - decompile error
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
--- a/net/minecraft/server/IMerchant.java
|
||||
+++ b/net/minecraft/server/IMerchant.java
|
||||
@@ -44,4 +44,6 @@
|
||||
}
|
||||
|
||||
}
|
||||
+
|
||||
+ org.bukkit.craftbukkit.inventory.CraftMerchant getCraftMerchant(); // CraftBukkit
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
--- a/net/minecraft/server/MerchantRecipe.java
|
||||
+++ b/net/minecraft/server/MerchantRecipe.java
|
||||
@@ -1,5 +1,7 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
+import org.bukkit.craftbukkit.inventory.CraftMerchantRecipe; // CraftBukkit
|
||||
+
|
||||
public class MerchantRecipe {
|
||||
|
||||
public ItemStack buyingItem1;
|
||||
@@ -12,6 +14,18 @@
|
||||
private int demand;
|
||||
public float priceMultiplier;
|
||||
public int xp;
|
||||
+ // CraftBukkit start
|
||||
+ private CraftMerchantRecipe bukkitHandle;
|
||||
+
|
||||
+ public CraftMerchantRecipe asBukkit() {
|
||||
+ return (bukkitHandle == null) ? bukkitHandle = new CraftMerchantRecipe(this) : bukkitHandle;
|
||||
+ }
|
||||
+
|
||||
+ public MerchantRecipe(ItemStack itemstack, ItemStack itemstack1, ItemStack itemstack2, int uses, int maxUses, int experience, float priceMultiplier, CraftMerchantRecipe bukkit) {
|
||||
+ this(itemstack, itemstack1, itemstack2, uses, maxUses, experience, priceMultiplier);
|
||||
+ this.bukkitHandle = bukkit;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
public MerchantRecipe(NBTTagCompound nbttagcompound) {
|
||||
this.rewardExp = true;
|
||||
@@ -73,6 +87,7 @@
|
||||
|
||||
public ItemStack getBuyItem1() {
|
||||
int i = this.buyingItem1.getCount();
|
||||
+ if (i <= 0) return ItemStack.b; // CraftBukkit - SPIGOT-5476
|
||||
ItemStack itemstack = this.buyingItem1.cloneItemStack();
|
||||
int j = Math.max(0, MathHelper.d((float) (i * this.demand) * this.priceMultiplier));
|
||||
|
||||
Reference in New Issue
Block a user