diff --git a/nms-patches/Block.patch b/nms-patches/Block.patch index 3a0d23383b..18446d8045 100644 --- a/nms-patches/Block.patch +++ b/nms-patches/Block.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/Block.java +++ b/net/minecraft/server/Block.java -@@ -35,7 +35,7 @@ +@@ -37,7 +37,7 @@ private String name; public static int getId(Block block) { @@ -9,7 +9,7 @@ } public static int getCombinedId(IBlockData iblockdata) { -@@ -332,7 +332,8 @@ +@@ -334,7 +334,8 @@ int j = this.getDropCount(i, world.random); for (int k = 0; k < j; ++k) { @@ -18,8 +18,8 @@ + if (world.random.nextFloat() < f) { Item item = this.getDropType(iblockdata, world.random, i); - if (item != null) { -@@ -873,7 +874,7 @@ + if (item != Items.a) { +@@ -896,7 +897,7 @@ if (hashset.contains(block16)) { for (int i = 0; i < 15; ++i) { @@ -28,16 +28,16 @@ Block.REGISTRY_ID.a(block16.fromLegacyData(i), j); } -@@ -882,7 +883,7 @@ +@@ -905,7 +906,7 @@ - while (iterator2.hasNext()) { - IBlockData iblockdata = (IBlockData) iterator2.next(); + while (unmodifiableiterator.hasNext()) { + IBlockData iblockdata = (IBlockData) unmodifiableiterator.next(); - int k = Block.REGISTRY.a((Object) block16) << 4 | block16.toLegacyData(iblockdata); + int k = Block.REGISTRY.a(block16) << 4 | block16.toLegacyData(iblockdata); // CraftBukkit - decompile error Block.REGISTRY_ID.a(iblockdata, k); } -@@ -891,6 +892,12 @@ +@@ -914,6 +915,12 @@ } diff --git a/nms-patches/BlockButtonAbstract.patch b/nms-patches/BlockButtonAbstract.patch index d114d92769..59694bc661 100644 --- a/nms-patches/BlockButtonAbstract.patch +++ b/nms-patches/BlockButtonAbstract.patch @@ -34,7 +34,7 @@ this.a(entityhuman, world, blockposition); @@ -164,6 +182,16 @@ if (this.I) { - this.e(iblockdata, world, blockposition); + this.d(iblockdata, world, blockposition); } else { + // CraftBukkit start + org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); diff --git a/nms-patches/BlockCactus.patch b/nms-patches/BlockCactus.patch index 951d5a9bbd..282dcd80f8 100644 --- a/nms-patches/BlockCactus.patch +++ b/nms-patches/BlockCactus.patch @@ -19,7 +19,7 @@ + CraftEventFactory.handleBlockGrowEvent(world, blockposition1.getX(), blockposition1.getY(), blockposition1.getZ(), this, 0); // CraftBukkit world.setTypeAndData(blockposition, iblockdata1, 4); - iblockdata1.doPhysics(world, blockposition1, this); + iblockdata1.doPhysics(world, blockposition1, this, blockposition); } else { @@ -87,7 +90,9 @@ } diff --git a/nms-patches/BlockCake.patch b/nms-patches/BlockCake.patch index 64b1aec1f8..a588357c8c 100644 --- a/nms-patches/BlockCake.patch +++ b/nms-patches/BlockCake.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/BlockCake.java +++ b/net/minecraft/server/BlockCake.java -@@ -34,7 +34,18 @@ - private void b(World world, BlockPosition blockposition, IBlockData iblockdata, EntityHuman entityhuman) { - if (entityhuman.m(false)) { +@@ -40,7 +40,18 @@ + return false; + } else { entityhuman.b(StatisticList.J); - entityhuman.getFoodData().eat(2, 0.1F); + // CraftBukkit start diff --git a/nms-patches/BlockCauldron.patch b/nms-patches/BlockCauldron.patch index 08b09fac58..a21ef98197 100644 --- a/nms-patches/BlockCauldron.patch +++ b/nms-patches/BlockCauldron.patch @@ -23,7 +23,7 @@ } } -@@ -58,17 +64,26 @@ +@@ -60,18 +66,27 @@ if (item == Items.WATER_BUCKET) { if (i < 3 && !world.isClientSide) { @@ -39,6 +39,7 @@ - this.a(world, blockposition, iblockdata, 3); + // this.a(world, blockposition, iblockdata, 3); + // CraftBukkit end + world.a((EntityHuman) null, blockposition, SoundEffects.N, SoundCategory.BLOCKS, 1.0F, 1.0F); } return true; @@ -49,19 +50,19 @@ + return true; + } if (!entityhuman.abilities.canInstantlyBuild) { - --itemstack.count; - if (itemstack.count == 0) { -@@ -79,7 +94,8 @@ + itemstack.subtract(1); + if (itemstack.isEmpty()) { +@@ -82,7 +97,8 @@ } entityhuman.b(StatisticList.L); - this.a(world, blockposition, iblockdata, 0); + // this.a(world, blockposition, iblockdata, 0); + // CraftBukkit end + world.a((EntityHuman) null, blockposition, SoundEffects.P, SoundCategory.BLOCKS, 1.0F, 1.0F); } - return true; -@@ -88,6 +104,10 @@ +@@ -92,6 +108,10 @@ if (item == Items.GLASS_BOTTLE) { if (i > 0 && !world.isClientSide) { @@ -72,17 +73,36 @@ if (!entityhuman.abilities.canInstantlyBuild) { itemstack1 = PotionUtil.a(new ItemStack(Items.POTION), Potions.b); entityhuman.b(StatisticList.L); -@@ -100,7 +120,8 @@ - } +@@ -106,12 +126,17 @@ } + world.a((EntityHuman) null, blockposition, SoundEffects.K, SoundCategory.BLOCKS, 1.0F, 1.0F); - this.a(world, blockposition, iblockdata, i - 1); + // this.a(world, blockposition, iblockdata, i - 1); + // CraftBukkit end } return true; -@@ -109,8 +130,13 @@ + } else if (item == Items.POTION && PotionUtil.d(itemstack) == Potions.b) { + if (i < 3 && !world.isClientSide) { ++ // CraftBukkit start ++ if (!this.changeLevel(world, blockposition, iblockdata, i + 1, entityhuman, CauldronLevelChangeEvent.ChangeReason.BOTTLE_EMPTY)) { ++ return true; ++ } + if (!entityhuman.abilities.canInstantlyBuild) { + itemstack1 = new ItemStack(Items.GLASS_BOTTLE); + entityhuman.b(StatisticList.L); +@@ -122,7 +147,8 @@ + } + + world.a((EntityHuman) null, blockposition, SoundEffects.J, SoundCategory.BLOCKS, 1.0F, 1.0F); +- this.a(world, blockposition, iblockdata, i + 1); ++ // this.a(world, blockposition, iblockdata, i + 1); ++ // CraftBukkit end + } + + return true; +@@ -131,8 +157,13 @@ ItemArmor itemarmor = (ItemArmor) item; if (itemarmor.d() == ItemArmor.EnumArmorMaterial.LEATHER && itemarmor.e_(itemstack) && !world.isClientSide) { @@ -90,23 +110,34 @@ + if (!this.changeLevel(world, blockposition, iblockdata, i - 1, entityhuman, CauldronLevelChangeEvent.ChangeReason.ARMOR_WASH)) { + return true; + } - itemarmor.c(itemstack); + itemarmor.d(itemstack); - this.a(world, blockposition, iblockdata, i - 1); + // this.a(world, blockposition, iblockdata, i - 1); + // CraftBukkit end entityhuman.b(StatisticList.M); return true; } -@@ -135,7 +161,7 @@ - } +@@ -140,13 +171,18 @@ + if (i > 0 && item instanceof ItemBanner) { + if (TileEntityBanner.b(itemstack) > 0 && !world.isClientSide) { ++ // CraftBukkit start ++ if (!this.changeLevel(world, blockposition, iblockdata, i - 1, entityhuman, CauldronLevelChangeEvent.ChangeReason.BANNER_WASH)) { ++ return true; ++ } + itemstack1 = itemstack.cloneItemStack(); + itemstack1.setCount(1); + TileEntityBanner.c(itemstack1); + entityhuman.b(StatisticList.N); if (!entityhuman.abilities.canInstantlyBuild) { + itemstack.subtract(1); - this.a(world, blockposition, iblockdata, i - 1); -+ this.changeLevel(world, blockposition, iblockdata, i - 1, entityhuman, CauldronLevelChangeEvent.ChangeReason.BANNER_WASH); // CraftBukkit ++ // this.a(world, blockposition, iblockdata, i - 1); ++ // CraftBukkit end } - } -@@ -148,9 +174,25 @@ + if (itemstack.isEmpty()) { +@@ -167,9 +203,25 @@ } } @@ -133,12 +164,12 @@ } public void h(World world, BlockPosition blockposition) { -@@ -161,7 +203,7 @@ +@@ -180,7 +232,7 @@ IBlockData iblockdata = world.getType(blockposition); if (((Integer) iblockdata.get(BlockCauldron.LEVEL)).intValue() < 3) { - world.setTypeAndData(blockposition, iblockdata.a((IBlockState) BlockCauldron.LEVEL), 2); -+ a(world, blockposition, iblockdata.a((IBlockState) BlockCauldron.LEVEL), 2); // CraftBukkit ++ this.a(world, blockposition, iblockdata.a((IBlockState) BlockCauldron.LEVEL), 2); // CraftBukkit } } diff --git a/nms-patches/BlockChorusFlower.patch b/nms-patches/BlockChorusFlower.patch index 95acef097d..e5482d55b5 100644 --- a/nms-patches/BlockChorusFlower.patch +++ b/nms-patches/BlockChorusFlower.patch @@ -9,7 +9,7 @@ public class BlockChorusFlower extends Block { public static final BlockStateInteger AGE = BlockStateInteger.of("age", 0, 5); -@@ -69,8 +71,20 @@ +@@ -68,8 +70,20 @@ } if (flag && a(world, blockposition1, (EnumDirection) null) && world.isEmpty(blockposition.up(2))) { @@ -32,7 +32,7 @@ } else if (i < 4) { j = random.nextInt(4); boolean flag2 = false; -@@ -84,18 +98,53 @@ +@@ -83,18 +97,53 @@ BlockPosition blockposition2 = blockposition.shift(enumdirection); if (world.isEmpty(blockposition2) && world.isEmpty(blockposition2.down()) && a(world, blockposition2, enumdirection.opposite())) { diff --git a/nms-patches/BlockCommand.patch b/nms-patches/BlockCommand.patch index c791a4a053..808f7944c7 100644 --- a/nms-patches/BlockCommand.patch +++ b/nms-patches/BlockCommand.patch @@ -1,16 +1,16 @@ --- a/net/minecraft/server/BlockCommand.java +++ b/net/minecraft/server/BlockCommand.java -@@ -3,6 +3,8 @@ +@@ -2,6 +2,8 @@ + import java.util.Random; - import javax.annotation.Nullable; +import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit + public class BlockCommand extends BlockTileEntity { public static final BlockStateDirection a = BlockDirectional.FACING; -@@ -30,7 +32,16 @@ - boolean flag1 = tileentitycommand.g(); +@@ -29,7 +31,16 @@ + boolean flag1 = tileentitycommand.f(); boolean flag2 = tileentitycommand.h(); - if (flag && !flag1) { @@ -27,7 +27,7 @@ tileentitycommand.a(true); if (tileentitycommand.k() != TileEntityCommand.Type.SEQUENCE && !flag2) { boolean flag3 = !tileentitycommand.l() || this.e(world, blockposition, iblockdata); -@@ -41,7 +52,7 @@ +@@ -40,7 +51,7 @@ this.c(world, blockposition); } } diff --git a/nms-patches/BlockCrops.patch b/nms-patches/BlockCrops.patch index 22e562bcbe..385751dafb 100644 --- a/nms-patches/BlockCrops.patch +++ b/nms-patches/BlockCrops.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/server/BlockCrops.java +++ b/net/minecraft/server/BlockCrops.java -@@ -3,6 +3,8 @@ +@@ -2,6 +2,8 @@ + import java.util.Random; - import javax.annotation.Nullable; +import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit + public class BlockCrops extends BlockPlant implements IBlockFragilePlantElement { public static final BlockStateInteger AGE = BlockStateInteger.of("age", 0, 7); -@@ -54,7 +56,10 @@ +@@ -53,7 +55,10 @@ float f = a((Block) this, world, blockposition); if (random.nextInt((int) (25.0F / f) + 1) == 0) { @@ -21,7 +21,7 @@ } } } -@@ -69,7 +74,10 @@ +@@ -68,7 +73,10 @@ i = j; } diff --git a/nms-patches/BlockDaylightDetector.patch b/nms-patches/BlockDaylightDetector.patch index 134da667b7..a9525a88cc 100644 --- a/nms-patches/BlockDaylightDetector.patch +++ b/nms-patches/BlockDaylightDetector.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/BlockDaylightDetector.java +++ b/net/minecraft/server/BlockDaylightDetector.java -@@ -46,6 +46,7 @@ +@@ -45,6 +45,7 @@ i = MathHelper.clamp(i, 0, 15); if (((Integer) iblockdata.get(BlockDaylightDetector.POWER)).intValue() != i) { diff --git a/nms-patches/BlockDiodeAbstract.patch b/nms-patches/BlockDiodeAbstract.patch index 36e5c204d2..e5d9e7d5ef 100644 --- a/nms-patches/BlockDiodeAbstract.patch +++ b/nms-patches/BlockDiodeAbstract.patch @@ -18,13 +18,13 @@ + return; + } + // CraftBukkit end - world.setTypeAndData(blockposition, this.y(iblockdata), 2); + world.setTypeAndData(blockposition, this.A(iblockdata), 2); } else if (!this.d) { + // CraftBukkit start + if (CraftEventFactory.callRedstoneChange(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), 0, 15).getNewCurrent() != 15) { + return; + } + // CraftBukkit end - world.setTypeAndData(blockposition, this.x(iblockdata), 2); + world.setTypeAndData(blockposition, this.z(iblockdata), 2); if (!flag) { - world.a(blockposition, this.x(iblockdata).getBlock(), this.D(iblockdata), -1); + world.a(blockposition, this.z(iblockdata).getBlock(), this.F(iblockdata), -1); diff --git a/nms-patches/BlockDispenser.patch b/nms-patches/BlockDispenser.patch index 0ab8ace85a..a46b1eef71 100644 --- a/nms-patches/BlockDispenser.patch +++ b/nms-patches/BlockDispenser.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/BlockDispenser.java +++ b/net/minecraft/server/BlockDispenser.java -@@ -9,6 +9,7 @@ +@@ -8,6 +8,7 @@ public static final BlockStateBoolean TRIGGERED = BlockStateBoolean.of("triggered"); public static final RegistryDefault REGISTRY = new RegistryDefault(new DispenseBehaviorItem()); protected Random d = new Random(); @@ -8,11 +8,11 @@ protected BlockDispenser() { super(Material.STONE); -@@ -84,6 +85,7 @@ +@@ -82,6 +83,7 @@ + IDispenseBehavior idispensebehavior = this.a(itemstack); if (idispensebehavior != IDispenseBehavior.NONE) { - ItemStack itemstack1 = idispensebehavior.a(sourceblock, itemstack); + eventFired = false; // CraftBukkit - reset event status - - tileentitydispenser.setItem(i, itemstack1.count <= 0 ? null : itemstack1); + tileentitydispenser.setItem(i, idispensebehavior.a(sourceblock, itemstack)); } + diff --git a/nms-patches/BlockDoor.patch b/nms-patches/BlockDoor.patch index 0de53123ff..1946c5afff 100644 --- a/nms-patches/BlockDoor.patch +++ b/nms-patches/BlockDoor.patch @@ -1,44 +1,37 @@ --- a/net/minecraft/server/BlockDoor.java +++ b/net/minecraft/server/BlockDoor.java -@@ -3,6 +3,8 @@ +@@ -2,6 +2,8 @@ + import java.util.Random; - import javax.annotation.Nullable; +import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit + public class BlockDoor extends Block { public static final BlockStateDirection FACING = BlockFacingHorizontal.FACING; -@@ -138,9 +140,22 @@ +@@ -137,9 +139,23 @@ this.b(world, blockposition, iblockdata, 0); } } else { -- boolean flag1 = world.isBlockIndirectlyPowered(blockposition) || world.isBlockIndirectlyPowered(blockposition2); +- boolean flag1 = world.isBlockIndirectlyPowered(blockposition) || world.isBlockIndirectlyPowered(blockposition3); -- if (block != this && (flag1 || block.getBlockData().m()) && flag1 != ((Boolean) iblockdata2.get(BlockDoor.POWERED)).booleanValue()) { +- if (block != this && (flag1 || block.getBlockData().n()) && flag1 != ((Boolean) iblockdata2.get(BlockDoor.POWERED)).booleanValue()) { + // CraftBukkit start + org.bukkit.World bworld = world.getWorld(); + org.bukkit.block.Block bukkitBlock = bworld.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); -+ org.bukkit.block.Block blockTop = bworld.getBlockAt(blockposition2.getX(), blockposition2.getY(), blockposition2.getZ()); ++ org.bukkit.block.Block blockTop = bworld.getBlockAt(blockposition3.getX(), blockposition3.getY(), blockposition3.getZ()); + + int power = bukkitBlock.getBlockPower(); + int powerTop = blockTop.getBlockPower(); + if (powerTop > power) power = powerTop; -+ int oldPower = (Boolean)iblockdata2.get(POWERED) ? 15 : 0; ++ int oldPower = (Boolean) iblockdata2.get(BlockDoor.POWERED) ? 15 : 0; + + if (oldPower == 0 ^ power == 0) { + BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bukkitBlock, oldPower, power); + world.getServer().getPluginManager().callEvent(eventRedstone); + + boolean flag1 = eventRedstone.getNewCurrent() > 0; - world.setTypeAndData(blockposition2, iblockdata2.set(BlockDoor.POWERED, Boolean.valueOf(flag1)), 2); ++ // CraftBukkit end + world.setTypeAndData(blockposition3, iblockdata2.set(BlockDoor.POWERED, Boolean.valueOf(flag1)), 2); if (flag1 != ((Boolean) iblockdata.get(BlockDoor.OPEN)).booleanValue()) { world.setTypeAndData(blockposition, iblockdata.set(BlockDoor.OPEN, Boolean.valueOf(flag1)), 2); -@@ -148,6 +163,7 @@ - world.a((EntityHuman) null, flag1 ? this.g() : this.e(), blockposition, 0); - } - } -+ // CraftBukkit end - } - } - diff --git a/nms-patches/BlockDragonEgg.patch b/nms-patches/BlockDragonEgg.patch index 454b319176..af397c6782 100644 --- a/nms-patches/BlockDragonEgg.patch +++ b/nms-patches/BlockDragonEgg.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/server/BlockDragonEgg.java +++ b/net/minecraft/server/BlockDragonEgg.java -@@ -3,6 +3,8 @@ +@@ -2,6 +2,8 @@ + import java.util.Random; - import javax.annotation.Nullable; +import org.bukkit.event.block.BlockFromToEvent; // CraftBukkit + public class BlockDragonEgg extends Block { protected static final AxisAlignedBB a = new AxisAlignedBB(0.0625D, 0.0D, 0.0625D, 0.9375D, 1.0D, 0.9375D); -@@ -67,6 +69,18 @@ +@@ -66,6 +68,18 @@ BlockPosition blockposition1 = blockposition.a(world.random.nextInt(16) - world.random.nextInt(16), world.random.nextInt(8) - world.random.nextInt(8), world.random.nextInt(16) - world.random.nextInt(16)); if (world.getType(blockposition1).getBlock().material == Material.AIR) { diff --git a/nms-patches/BlockDropper.patch b/nms-patches/BlockDropper.patch index cdb5ed4e81..07c21cb4dd 100644 --- a/nms-patches/BlockDropper.patch +++ b/nms-patches/BlockDropper.patch @@ -1,22 +1,22 @@ --- a/net/minecraft/server/BlockDropper.java +++ b/net/minecraft/server/BlockDropper.java -@@ -1,6 +1,10 @@ +@@ -1,5 +1,10 @@ package net.minecraft.server; - import javax.annotation.Nullable; +// CraftBukkit start +import org.bukkit.craftbukkit.inventory.CraftItemStack; +import org.bukkit.event.inventory.InventoryMoveItemEvent; +// CraftBukkit end - ++ public class BlockDropper extends BlockDispenser { -@@ -40,8 +44,25 @@ - itemstack1 = null; - } + private final IDispenseBehavior e = new DispenseBehaviorItem(); +@@ -35,8 +40,25 @@ + if (iinventory == null) { + itemstack1 = this.e.a(sourceblock, itemstack); } else { -- itemstack1 = TileEntityHopper.addItem(iinventory, itemstack.cloneItemStack().cloneAndSubtract(1), enumdirection.opposite()); -- if (itemstack1 == null) { +- itemstack1 = TileEntityHopper.addItem(tileentitydispenser, iinventory, itemstack.cloneItemStack().cloneAndSubtract(1), enumdirection.opposite()); +- if (itemstack1.isEmpty()) { + // CraftBukkit start - Fire event when pushing items into other inventories + CraftItemStack oitemstack = CraftItemStack.asCraftMirror(itemstack.cloneItemStack().cloneAndSubtract(1)); + @@ -33,9 +33,9 @@ + if (event.isCancelled()) { + return; + } -+ itemstack1 = TileEntityHopper.addItem(iinventory, CraftItemStack.asNMSCopy(event.getItem()), enumdirection.opposite()); -+ if (event.getItem().equals(oitemstack) && itemstack1 == null) { ++ itemstack1 = TileEntityHopper.addItem(tileentitydispenser, iinventory, CraftItemStack.asNMSCopy(event.getItem()), enumdirection.opposite()); ++ if (event.getItem().equals(oitemstack) && itemstack1.isEmpty()) { + // CraftBukkit end itemstack1 = itemstack.cloneItemStack(); - if (--itemstack1.count <= 0) { - itemstack1 = null; + itemstack1.subtract(1); + } else { diff --git a/nms-patches/BlockEnderPortal.patch b/nms-patches/BlockEnderPortal.patch index 5f27102f2a..9501e5e798 100644 --- a/nms-patches/BlockEnderPortal.patch +++ b/nms-patches/BlockEnderPortal.patch @@ -12,7 +12,7 @@ @@ -37,6 +39,10 @@ public void a(World world, BlockPosition blockposition, IBlockData iblockdata, Entity entity) { - if (!entity.isPassenger() && !entity.isVehicle() && entity.aX() && !world.isClientSide && entity.getBoundingBox().b(iblockdata.c(world, blockposition).a(blockposition))) { + if (!entity.isPassenger() && !entity.isVehicle() && entity.aX() && !world.isClientSide && entity.getBoundingBox().c(iblockdata.d(world, blockposition).a(blockposition))) { + // CraftBukkit start - Entity in portal + EntityPortalEnterEvent event = new EntityPortalEnterEvent(entity.getBukkitEntity(), new org.bukkit.Location(world.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ())); + world.getServer().getPluginManager().callEvent(event); diff --git a/nms-patches/BlockFire.patch b/nms-patches/BlockFire.patch index 2c6895daab..9e67ce299c 100644 --- a/nms-patches/BlockFire.patch +++ b/nms-patches/BlockFire.patch @@ -34,7 +34,7 @@ @@ -119,14 +125,14 @@ if (!flag) { if (!this.c(world, blockposition)) { - if (!world.getType(blockposition.down()).q() || i > 3) { + if (!world.getType(blockposition.down()).r() || i > 3) { - world.setAir(blockposition); + fireExtinguished(world, blockposition); // CraftBukkit } @@ -96,8 +96,8 @@ @@ -276,7 +312,7 @@ - public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Block block) { - if (!world.getType(blockposition.down()).q() && !this.c(world, blockposition)) { + public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Block block, BlockPosition blockposition1) { + if (!world.getType(blockposition.down()).r() && !this.c(world, blockposition)) { - world.setAir(blockposition); + fireExtinguished(world, blockposition); // CraftBukkit - fuel block gone } @@ -106,7 +106,7 @@ @@ -284,7 +320,7 @@ public void onPlace(World world, BlockPosition blockposition, IBlockData iblockdata) { if (world.worldProvider.getDimensionManager().getDimensionID() > 0 || !Blocks.PORTAL.b(world, blockposition)) { - if (!world.getType(blockposition.down()).q() && !this.c(world, blockposition)) { + if (!world.getType(blockposition.down()).r() && !this.c(world, blockposition)) { - world.setAir(blockposition); + fireExtinguished(world, blockposition); // CraftBukkit - fuel block broke } else { diff --git a/nms-patches/BlockGrass.patch b/nms-patches/BlockGrass.patch index 741320cc33..040f26ae68 100644 --- a/nms-patches/BlockGrass.patch +++ b/nms-patches/BlockGrass.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/BlockGrass.java +++ b/net/minecraft/server/BlockGrass.java -@@ -3,6 +3,14 @@ +@@ -2,6 +2,14 @@ + import java.util.Random; - import javax.annotation.Nullable; +// CraftBukkit start +import org.bukkit.block.BlockState; @@ -15,7 +15,7 @@ public class BlockGrass extends Block implements IBlockFragilePlantElement { public static final BlockStateBoolean SNOWY = BlockStateBoolean.of("snowy"); -@@ -23,7 +31,19 @@ +@@ -22,7 +30,19 @@ public void b(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) { if (!world.isClientSide) { if (world.getLightLevel(blockposition.up()) < 4 && world.getType(blockposition.up()).c() > 2) { @@ -36,7 +36,7 @@ } else { if (world.getLightLevel(blockposition.up()) >= 9) { for (int i = 0; i < 4; ++i) { -@@ -37,7 +57,19 @@ +@@ -36,7 +56,19 @@ IBlockData iblockdata2 = world.getType(blockposition1); if (iblockdata2.getBlock() == Blocks.DIRT && iblockdata2.get(BlockDirt.VARIANT) == BlockDirt.EnumDirtVariant.DIRT && world.getLightLevel(blockposition1.up()) >= 4 && iblockdata1.c() <= 2) { @@ -57,7 +57,7 @@ } } } -@@ -81,13 +113,15 @@ +@@ -79,13 +111,15 @@ IBlockData iblockdata1 = blockflowers.getBlockData().set(blockflowers.g(), blockflowers_enumflowervarient); if (blockflowers.f(world, blockposition2, iblockdata1)) { diff --git a/nms-patches/BlockIce.patch b/nms-patches/BlockIce.patch index 6d0beefb88..2971d2761b 100644 --- a/nms-patches/BlockIce.patch +++ b/nms-patches/BlockIce.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/BlockIce.java +++ b/net/minecraft/server/BlockIce.java -@@ -51,6 +51,11 @@ +@@ -47,6 +47,11 @@ } protected void b(World world, BlockPosition blockposition) { diff --git a/nms-patches/BlockJukeBox.patch b/nms-patches/BlockJukeBox.patch index ac548cae50..477d255e8f 100644 --- a/nms-patches/BlockJukeBox.patch +++ b/nms-patches/BlockJukeBox.patch @@ -1,12 +1,12 @@ --- a/net/minecraft/server/BlockJukeBox.java +++ b/net/minecraft/server/BlockJukeBox.java -@@ -144,6 +144,11 @@ +@@ -143,6 +143,11 @@ } - public void setRecord(@Nullable ItemStack itemstack) { + public void setRecord(ItemStack itemstack) { + // CraftBukkit start - There can only be one -+ if (itemstack != null) { -+ itemstack.count = 1; ++ if (!itemstack.isEmpty()) { ++ itemstack.setCount(1); + } + // CraftBukkit end this.record = itemstack; diff --git a/nms-patches/BlockLeaves.patch b/nms-patches/BlockLeaves.patch index 5867b84ec4..bb3a479d13 100644 --- a/nms-patches/BlockLeaves.patch +++ b/nms-patches/BlockLeaves.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/server/BlockLeaves.java +++ b/net/minecraft/server/BlockLeaves.java -@@ -3,6 +3,8 @@ +@@ -2,6 +2,8 @@ + import java.util.Random; - import javax.annotation.Nullable; +import org.bukkit.event.block.LeavesDecayEvent; // CraftBukkit + public abstract class BlockLeaves extends Block { public static final BlockStateBoolean DECAYABLE = BlockStateBoolean.of("decayable"); -@@ -133,6 +135,14 @@ +@@ -132,6 +134,14 @@ } private void b(World world, BlockPosition blockposition) { diff --git a/nms-patches/BlockMobSpawner.patch b/nms-patches/BlockMobSpawner.patch index 708f413b03..67c46a901d 100644 --- a/nms-patches/BlockMobSpawner.patch +++ b/nms-patches/BlockMobSpawner.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/BlockMobSpawner.java +++ b/net/minecraft/server/BlockMobSpawner.java -@@ -24,9 +24,19 @@ +@@ -22,9 +22,19 @@ public void dropNaturally(World world, BlockPosition blockposition, IBlockData iblockdata, float f, int i) { super.dropNaturally(world, blockposition, iblockdata, f, i); diff --git a/nms-patches/BlockMycel.patch b/nms-patches/BlockMycel.patch index 8fbe01096c..626b81bfc4 100644 --- a/nms-patches/BlockMycel.patch +++ b/nms-patches/BlockMycel.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/BlockMycel.java +++ b/net/minecraft/server/BlockMycel.java -@@ -3,6 +3,13 @@ +@@ -2,6 +2,13 @@ + import java.util.Random; - import javax.annotation.Nullable; +// CraftBukkit start +import org.bukkit.block.BlockState; @@ -14,7 +14,7 @@ public class BlockMycel extends Block { public static final BlockStateBoolean SNOWY = BlockStateBoolean.of("snowy"); -@@ -23,7 +30,19 @@ +@@ -22,7 +29,19 @@ public void b(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) { if (!world.isClientSide) { if (world.getLightLevel(blockposition.up()) < 4 && world.getType(blockposition.up()).c() > 2) { @@ -35,7 +35,7 @@ } else { if (world.getLightLevel(blockposition.up()) >= 9) { for (int i = 0; i < 4; ++i) { -@@ -32,7 +51,19 @@ +@@ -31,7 +50,19 @@ IBlockData iblockdata2 = world.getType(blockposition1.up()); if (iblockdata1.getBlock() == Blocks.DIRT && iblockdata1.get(BlockDirt.VARIANT) == BlockDirt.EnumDirtVariant.DIRT && world.getLightLevel(blockposition1.up()) >= 4 && iblockdata2.c() <= 2) { diff --git a/nms-patches/BlockNetherWart.patch b/nms-patches/BlockNetherWart.patch index 7992cd52b6..1af3f818a2 100644 --- a/nms-patches/BlockNetherWart.patch +++ b/nms-patches/BlockNetherWart.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/BlockNetherWart.java +++ b/net/minecraft/server/BlockNetherWart.java -@@ -32,7 +32,8 @@ +@@ -31,7 +31,8 @@ if (i < 3 && random.nextInt(10) == 0) { iblockdata = iblockdata.set(BlockNetherWart.AGE, Integer.valueOf(i + 1)); diff --git a/nms-patches/BlockOre.patch b/nms-patches/BlockOre.patch index 9cf76ccc1c..236ce96e70 100644 --- a/nms-patches/BlockOre.patch +++ b/nms-patches/BlockOre.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/BlockOre.java +++ b/net/minecraft/server/BlockOre.java -@@ -39,6 +39,7 @@ +@@ -37,6 +37,7 @@ public void dropNaturally(World world, BlockPosition blockposition, IBlockData iblockdata, float f, int i) { super.dropNaturally(world, blockposition, iblockdata, f, i); @@ -8,7 +8,7 @@ if (this.getDropType(iblockdata, world.random, i) != Item.getItemOf(this)) { int j = 0; -@@ -56,9 +57,34 @@ +@@ -54,9 +55,34 @@ this.dropExperience(world, blockposition, j); } diff --git a/nms-patches/BlockPiston.patch b/nms-patches/BlockPiston.patch index 9c7cf575d8..56b43ae9f2 100644 --- a/nms-patches/BlockPiston.patch +++ b/nms-patches/BlockPiston.patch @@ -19,7 +19,7 @@ public class BlockPiston extends BlockDirectional { public static final BlockStateBoolean EXTENDED = BlockStateBoolean.of("extended"); -@@ -99,6 +111,18 @@ +@@ -103,6 +115,18 @@ world.playBlockAction(blockposition, this, 0, enumdirection.a()); } } else if (!flag && ((Boolean) iblockdata.get(BlockPiston.EXTENDED)).booleanValue()) { @@ -38,16 +38,16 @@ world.playBlockAction(blockposition, this, 1, enumdirection.a()); } -@@ -189,7 +213,7 @@ +@@ -193,7 +217,7 @@ } } -- if (!flag1 && iblockdata1.getMaterial() != Material.AIR && a(iblockdata1, world, blockposition1, enumdirection.opposite(), false) && (iblockdata1.o() == EnumPistonReaction.NORMAL || block == Blocks.PISTON || block == Blocks.STICKY_PISTON)) { -+ if (!flag1 && a(iblockdata1, world, blockposition1, enumdirection.opposite(), false) && (iblockdata1.o() == EnumPistonReaction.NORMAL || block == Blocks.PISTON || block == Blocks.STICKY_PISTON)) { // CraftBukkit - remove 'block.getMaterial() != Material.AIR' condition +- if (!flag1 && iblockdata1.getMaterial() != Material.AIR && a(iblockdata1, world, blockposition1, enumdirection.opposite(), false) && (iblockdata1.p() == EnumPistonReaction.NORMAL || block == Blocks.PISTON || block == Blocks.STICKY_PISTON)) { ++ if (!flag1 && a(iblockdata1, world, blockposition1, enumdirection.opposite(), false) && (iblockdata1.p() == EnumPistonReaction.NORMAL || block == Blocks.PISTON || block == Blocks.STICKY_PISTON)) { // CraftBukkit - remove 'block.getMaterial() != Material.AIR' condition this.a(world, blockposition, enumdirection, false); } } else { -@@ -286,6 +310,48 @@ +@@ -274,6 +298,48 @@ int j = list.size() + list1.size(); IBlockData[] aiblockdata = new IBlockData[j]; EnumDirection enumdirection1 = flag ? enumdirection : enumdirection.opposite(); diff --git a/nms-patches/BlockPortal.patch b/nms-patches/BlockPortal.patch index 90264c38f9..064c6f624d 100644 --- a/nms-patches/BlockPortal.patch +++ b/nms-patches/BlockPortal.patch @@ -13,7 +13,7 @@ @@ -43,7 +46,8 @@ } - if (i > 0 && !world.getType(blockposition1.up()).l()) { + if (i > 0 && !world.getType(blockposition1.up()).m()) { - Entity entity = ItemMonsterEgg.a(world, EntityTypes.getName(EntityPigZombie.class), (double) blockposition1.getX() + 0.5D, (double) blockposition1.getY() + 1.1D, (double) blockposition1.getZ() + 0.5D); + // CraftBukkit - set spawn reason to NETHER_PORTAL + Entity entity = ItemMonsterEgg.spawnCreature(world, EntityTypes.getName(EntityPigZombie.class), (double) blockposition1.getX() + 0.5D, (double) blockposition1.getY() + 1.1D, (double) blockposition1.getZ() + 0.5D, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NETHER_PORTAL); @@ -52,7 +52,7 @@ entity.e(blockposition); } -@@ -254,6 +264,7 @@ +@@ -212,6 +222,7 @@ private BlockPosition position; private int height; private int width; @@ -60,7 +60,7 @@ public Shape(World world, BlockPosition blockposition, EnumDirection.EnumAxis enumdirection_enumaxis) { this.a = world; -@@ -312,6 +323,10 @@ +@@ -270,6 +281,10 @@ } protected int c() { @@ -71,7 +71,7 @@ int i; label56: -@@ -332,11 +347,21 @@ +@@ -290,11 +305,21 @@ block = this.a.getType(blockposition.shift(this.d)).getBlock(); if (block != Blocks.OBSIDIAN) { break label56; @@ -93,7 +93,7 @@ } } } -@@ -346,6 +371,11 @@ +@@ -304,6 +329,11 @@ if (this.a.getType(this.position.shift(this.c, i).up(this.height)).getBlock() != Blocks.OBSIDIAN) { this.height = 0; break; @@ -105,7 +105,7 @@ } } -@@ -367,7 +397,27 @@ +@@ -325,7 +355,27 @@ return this.position != null && this.width >= 2 && this.width <= 21 && this.height >= 3 && this.height <= 21; } @@ -134,7 +134,7 @@ for (int i = 0; i < this.width; ++i) { BlockPosition blockposition = this.position.shift(this.c, i); -@@ -376,6 +426,7 @@ +@@ -334,6 +384,7 @@ } } diff --git a/nms-patches/BlockPoweredRail.patch b/nms-patches/BlockPoweredRail.patch index f4dfbd55df..973f55762c 100644 --- a/nms-patches/BlockPoweredRail.patch +++ b/nms-patches/BlockPoweredRail.patch @@ -21,5 +21,5 @@ + } + // CraftBukkit end world.setTypeAndData(blockposition, iblockdata.set(BlockPoweredRail.POWERED, Boolean.valueOf(flag1)), 3); - world.applyPhysics(blockposition.down(), this); + world.applyPhysics(blockposition.down(), this, false); if (((BlockMinecartTrackAbstract.EnumTrackPosition) iblockdata.get(BlockPoweredRail.SHAPE)).c()) { diff --git a/nms-patches/BlockPumpkin.patch b/nms-patches/BlockPumpkin.patch index 27c335cca9..d0fc889ade 100644 --- a/nms-patches/BlockPumpkin.patch +++ b/nms-patches/BlockPumpkin.patch @@ -43,7 +43,7 @@ world.addParticle(EnumParticle.SNOW_SHOVEL, (double) blockposition1.getX() + world.random.nextDouble(), (double) blockposition1.getY() + world.random.nextDouble() * 2.5D, (double) blockposition1.getZ() + world.random.nextDouble(), 0.0D, 0.0D, 0.0D, new int[0]); @@ -62,12 +75,17 @@ - world.update(shapedetectorblock1.getPosition(), Blocks.AIR); + world.update(shapedetectorblock1.getPosition(), Blocks.AIR, false); } + } // CraftBukkit end } else { diff --git a/nms-patches/BlockRedstoneLamp.patch b/nms-patches/BlockRedstoneLamp.patch index 19afa4dad2..1aec63228a 100644 --- a/nms-patches/BlockRedstoneLamp.patch +++ b/nms-patches/BlockRedstoneLamp.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/server/BlockRedstoneLamp.java +++ b/net/minecraft/server/BlockRedstoneLamp.java -@@ -3,6 +3,8 @@ +@@ -2,6 +2,8 @@ + import java.util.Random; - import javax.annotation.Nullable; +import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit + public class BlockRedstoneLamp extends Block { private final boolean a; -@@ -21,6 +23,11 @@ +@@ -20,6 +22,11 @@ if (this.a && !world.isBlockIndirectlyPowered(blockposition)) { world.setTypeAndData(blockposition, Blocks.REDSTONE_LAMP.getBlockData(), 2); } else if (!this.a && world.isBlockIndirectlyPowered(blockposition)) { @@ -21,7 +21,7 @@ world.setTypeAndData(blockposition, Blocks.LIT_REDSTONE_LAMP.getBlockData(), 2); } -@@ -32,6 +39,11 @@ +@@ -31,6 +38,11 @@ if (this.a && !world.isBlockIndirectlyPowered(blockposition)) { world.a(blockposition, (Block) this, 4); } else if (!this.a && world.isBlockIndirectlyPowered(blockposition)) { @@ -33,7 +33,7 @@ world.setTypeAndData(blockposition, Blocks.LIT_REDSTONE_LAMP.getBlockData(), 2); } -@@ -41,6 +53,11 @@ +@@ -40,6 +52,11 @@ public void b(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) { if (!world.isClientSide) { if (this.a && !world.isBlockIndirectlyPowered(blockposition)) { diff --git a/nms-patches/BlockRedstoneOre.patch b/nms-patches/BlockRedstoneOre.patch index 417cd3111d..c4b08ac9a8 100644 --- a/nms-patches/BlockRedstoneOre.patch +++ b/nms-patches/BlockRedstoneOre.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/BlockRedstoneOre.java +++ b/net/minecraft/server/BlockRedstoneOre.java -@@ -3,6 +3,11 @@ +@@ -2,6 +2,11 @@ + import java.util.Random; - import javax.annotation.Nullable; +// CraftBukkit start +import org.bukkit.craftbukkit.event.CraftEventFactory; @@ -12,7 +12,7 @@ public class BlockRedstoneOre extends Block { private final boolean a; -@@ -21,23 +26,45 @@ +@@ -20,23 +25,45 @@ } public void attack(World world, BlockPosition blockposition, EntityHuman entityhuman) { @@ -45,10 +45,10 @@ } + - public boolean interact(World world, BlockPosition blockposition, IBlockData iblockdata, EntityHuman entityhuman, EnumHand enumhand, @Nullable ItemStack itemstack, EnumDirection enumdirection, float f, float f1, float f2) { + public boolean interact(World world, BlockPosition blockposition, IBlockData iblockdata, EntityHuman entityhuman, EnumHand enumhand, EnumDirection enumdirection, float f, float f1, float f2) { - this.interact(world, blockposition); + this.interact(world, blockposition, entityhuman); // CraftBukkit - add entityhuman - return super.interact(world, blockposition, iblockdata, entityhuman, enumhand, itemstack, enumdirection, f, f1, f2); + return super.interact(world, blockposition, iblockdata, entityhuman, enumhand, enumdirection, f, f1, f2); } - private void interact(World world, BlockPosition blockposition) { @@ -63,7 +63,7 @@ world.setTypeUpdate(blockposition, Blocks.LIT_REDSTONE_ORE.getBlockData()); } -@@ -45,6 +72,11 @@ +@@ -44,6 +71,11 @@ public void b(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) { if (this == Blocks.LIT_REDSTONE_ORE) { @@ -75,7 +75,7 @@ world.setTypeUpdate(blockposition, Blocks.REDSTONE_ORE.getBlockData()); } -@@ -65,12 +97,25 @@ +@@ -63,12 +95,25 @@ public void dropNaturally(World world, BlockPosition blockposition, IBlockData iblockdata, float f, int i) { super.dropNaturally(world, blockposition, iblockdata, f, i); diff --git a/nms-patches/BlockRedstoneTorch.patch b/nms-patches/BlockRedstoneTorch.patch index f2dd63cedb..f74f435057 100644 --- a/nms-patches/BlockRedstoneTorch.patch +++ b/nms-patches/BlockRedstoneTorch.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/server/BlockRedstoneTorch.java +++ b/net/minecraft/server/BlockRedstoneTorch.java -@@ -7,6 +7,8 @@ +@@ -6,6 +6,8 @@ + import java.util.Map; import java.util.Random; - import javax.annotation.Nullable; +import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit + public class BlockRedstoneTorch extends BlockTorch { private static final Map> g = Maps.newHashMap(); -@@ -14,7 +16,7 @@ +@@ -13,7 +15,7 @@ private boolean a(World world, BlockPosition blockposition, boolean flag) { if (!BlockRedstoneTorch.g.containsKey(world)) { @@ -18,7 +18,7 @@ } List list = (List) BlockRedstoneTorch.g.get(world); -@@ -97,8 +99,25 @@ +@@ -96,8 +98,25 @@ list.remove(0); } @@ -43,8 +43,8 @@ + // CraftBukkit end world.setTypeAndData(blockposition, Blocks.UNLIT_REDSTONE_TORCH.getBlockData().set(BlockRedstoneTorch.FACING, iblockdata.get(BlockRedstoneTorch.FACING)), 3); if (this.a(world, blockposition, true)) { - world.a((EntityHuman) null, blockposition, SoundEffects.eR, SoundCategory.BLOCKS, 0.5F, 2.6F + (world.random.nextFloat() - world.random.nextFloat()) * 0.8F); -@@ -115,6 +134,15 @@ + world.a((EntityHuman) null, blockposition, SoundEffects.fl, SoundCategory.BLOCKS, 0.5F, 2.6F + (world.random.nextFloat() - world.random.nextFloat()) * 0.8F); +@@ -114,6 +133,15 @@ } } } else if (!flag && !this.a(world, blockposition, false)) { diff --git a/nms-patches/BlockSapling.patch b/nms-patches/BlockSapling.patch index 42df791c87..bce7652f2c 100644 --- a/nms-patches/BlockSapling.patch +++ b/nms-patches/BlockSapling.patch @@ -21,7 +21,7 @@ + public static TreeType treeType; // CraftBukkit protected BlockSapling() { - this.w(this.blockStateList.getBlockData().set(BlockSapling.TYPE, BlockWood.EnumLogVariant.OAK).set(BlockSapling.STAGE, Integer.valueOf(0))); + this.y(this.blockStateList.getBlockData().set(BlockSapling.TYPE, BlockWood.EnumLogVariant.OAK).set(BlockSapling.STAGE, Integer.valueOf(0))); @@ -25,7 +35,30 @@ if (!world.isClientSide) { super.b(world, blockposition, iblockdata, random); @@ -89,7 +89,7 @@ } break; - case 2: + case BIRCH: + treeType = TreeType.BIRCH; // CraftBukkit object = new WorldGenForest(true, false); break; @@ -111,7 +111,7 @@ } break; - case 4: + case ACACIA: + treeType = TreeType.ACACIA; // CraftBukkit object = new WorldGenAcaciaTree(true); break; diff --git a/nms-patches/BlockShulkerBox.patch b/nms-patches/BlockShulkerBox.patch new file mode 100644 index 0000000000..ef6b04cde6 --- /dev/null +++ b/nms-patches/BlockShulkerBox.patch @@ -0,0 +1,45 @@ +--- a/net/minecraft/server/BlockShulkerBox.java ++++ b/net/minecraft/server/BlockShulkerBox.java +@@ -89,7 +89,32 @@ + tileentityshulkerbox.d(entityhuman); + } + +- public void dropNaturally(World world, BlockPosition blockposition, IBlockData iblockdata, float f, int i) {} ++ // CraftBukkit start - override to prevent duplication when dropping ++ public void dropNaturally(World world, BlockPosition blockposition, IBlockData iblockdata, float f, int i) { ++ TileEntity tileentity = world.getTileEntity(blockposition); ++ ++ if (tileentity instanceof TileEntityShulkerBox) { ++ TileEntityShulkerBox tileentityshulkerbox = (TileEntityShulkerBox) tileentity; ++ ++ if (!tileentityshulkerbox.r() && tileentityshulkerbox.F()) { ++ ItemStack itemstack = new ItemStack(Item.getItemOf(this)); ++ NBTTagCompound nbttagcompound = new NBTTagCompound(); ++ NBTTagCompound nbttagcompound1 = new NBTTagCompound(); ++ ++ nbttagcompound.set("BlockEntityTag", ((TileEntityShulkerBox) tileentity).f(nbttagcompound1)); ++ itemstack.setTag(nbttagcompound); ++ if (tileentityshulkerbox.hasCustomName()) { ++ itemstack.g(tileentityshulkerbox.getName()); ++ tileentityshulkerbox.a(""); ++ } ++ ++ a(world, blockposition, itemstack); ++ } ++ ++ world.updateAdjacentComparators(blockposition, iblockdata.getBlock()); ++ } ++ } ++ // CraftBukkit end + + public void postPlace(World world, BlockPosition blockposition, IBlockData iblockdata, EntityLiving entityliving, ItemStack itemstack) { + if (itemstack.hasName()) { +@@ -105,7 +130,7 @@ + public void remove(World world, BlockPosition blockposition, IBlockData iblockdata) { + TileEntity tileentity = world.getTileEntity(blockposition); + +- if (tileentity instanceof TileEntityShulkerBox) { ++ if (false && tileentity instanceof TileEntityShulkerBox) { // CraftBukkit - moved up + TileEntityShulkerBox tileentityshulkerbox = (TileEntityShulkerBox) tileentity; + + if (!tileentityshulkerbox.r() && tileentityshulkerbox.F()) { diff --git a/nms-patches/BlockSkull.patch b/nms-patches/BlockSkull.patch index ba234cb7d4..51d202cf22 100644 --- a/nms-patches/BlockSkull.patch +++ b/nms-patches/BlockSkull.patch @@ -12,7 +12,7 @@ public class BlockSkull extends BlockTileEntity { public static final BlockStateDirection FACING = BlockDirectional.FACING; -@@ -82,7 +87,25 @@ +@@ -82,7 +87,29 @@ return new ItemStack(Items.SKULL, 1, i); } @@ -21,25 +21,29 @@ + @Override + public void dropNaturally(World world, BlockPosition blockposition, IBlockData iblockdata, float f, int i) { + if (world.random.nextFloat() < f) { -+ TileEntitySkull tileentityskull = (TileEntitySkull) world.getTileEntity(blockposition); -+ ItemStack itemstack = this.a(world, blockposition, iblockdata); ++ TileEntity tileentity = world.getTileEntity(blockposition); + -+ if (tileentityskull.getSkullType() == 3 && tileentityskull.getGameProfile() != null) { -+ itemstack.setTag(new NBTTagCompound()); -+ NBTTagCompound nbttagcompound = new NBTTagCompound(); ++ if (tileentity instanceof TileEntitySkull) { ++ TileEntitySkull tileentityskull = (TileEntitySkull) tileentity; ++ ItemStack itemstack = this.a(world, blockposition, iblockdata); + -+ GameProfileSerializer.serialize(nbttagcompound, tileentityskull.getGameProfile()); -+ itemstack.getTag().set("SkullOwner", nbttagcompound); ++ if (tileentityskull.getSkullType() == 3 && tileentityskull.getGameProfile() != null) { ++ itemstack.setTag(new NBTTagCompound()); ++ NBTTagCompound nbttagcompound = new NBTTagCompound(); ++ ++ GameProfileSerializer.serialize(nbttagcompound, tileentityskull.getGameProfile()); ++ itemstack.getTag().set("SkullOwner", nbttagcompound); ++ } ++ ++ a(world, blockposition, itemstack); + } -+ -+ a(world, blockposition, itemstack); + } + } + // CraftBukkit end public void a(World world, BlockPosition blockposition, IBlockData iblockdata, EntityHuman entityhuman) { if (entityhuman.abilities.canInstantlyBuild) { -@@ -95,7 +118,10 @@ +@@ -95,7 +122,10 @@ public void remove(World world, BlockPosition blockposition, IBlockData iblockdata) { if (!world.isClientSide) { @@ -51,7 +55,7 @@ TileEntity tileentity = world.getTileEntity(blockposition); if (tileentity instanceof TileEntitySkull) { -@@ -128,24 +154,36 @@ +@@ -127,24 +157,36 @@ } public void a(World world, BlockPosition blockposition, TileEntitySkull tileentityskull) { @@ -90,7 +94,7 @@ } } -@@ -158,14 +196,16 @@ +@@ -157,14 +199,16 @@ entitywither.o(); Iterator iterator = world.a(EntityHuman.class, entitywither.getBoundingBox().g(50.0D)).iterator(); @@ -109,8 +113,8 @@ int k; for (k = 0; k < 120; ++k) { -@@ -179,6 +219,7 @@ - world.update(shapedetectorblock2.getPosition(), Blocks.AIR); +@@ -178,6 +222,7 @@ + world.update(shapedetectorblock2.getPosition(), Blocks.AIR, false); } } + } // CraftBukkit end diff --git a/nms-patches/BlockSnow.patch b/nms-patches/BlockSnow.patch index 434eaed912..4d864b9166 100644 --- a/nms-patches/BlockSnow.patch +++ b/nms-patches/BlockSnow.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/server/BlockSnow.java +++ b/net/minecraft/server/BlockSnow.java -@@ -82,6 +82,11 @@ +@@ -81,6 +81,11 @@ public void b(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) { - if (world.b(EnumSkyBlock.BLOCK, blockposition) > 11) { + if (world.getBrightness(EnumSkyBlock.BLOCK, blockposition) > 11) { + // CraftBukkit start + if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), Blocks.AIR).isCancelled()) { + return; diff --git a/nms-patches/BlockSoil.patch b/nms-patches/BlockSoil.patch index 35c2fd56b1..33fdfe06c8 100644 --- a/nms-patches/BlockSoil.patch +++ b/nms-patches/BlockSoil.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/BlockSoil.java +++ b/net/minecraft/server/BlockSoil.java @@ -4,6 +4,11 @@ + import java.util.List; import java.util.Random; - import javax.annotation.Nullable; +// CraftBukkit start +import org.bukkit.event.entity.EntityInteractEvent; @@ -15,23 +15,22 @@ @@ -35,6 +40,12 @@ if (i > 0) { world.setTypeAndData(blockposition, iblockdata.set(BlockSoil.MOISTURE, Integer.valueOf(i - 1)), 2); - } else if (!this.b(world, blockposition)) { + } else if (!this.c(world, blockposition)) { + // CraftBukkit start + org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); + if (CraftEventFactory.callBlockFadeEvent(block, Blocks.DIRT).isCancelled()) { + return; + } + // CraftBukkit end - world.setTypeUpdate(blockposition, Blocks.DIRT.getBlockData()); + this.b(world, blockposition); } } else if (i < 7) { -@@ -44,11 +55,31 @@ +@@ -44,11 +55,29 @@ } public void fallOn(World world, BlockPosition blockposition, Entity entity, float f) { + super.fallOn(world, blockposition, entity, f); // CraftBukkit - moved here as game rules / events shouldn't affect fall damage. if (!world.isClientSide && world.random.nextFloat() < f - 0.5F && entity instanceof EntityLiving && (entity instanceof EntityHuman || world.getGameRules().getBoolean("mobGriefing")) && entity.width * entity.width * entity.length > 0.512F) { -+ + // CraftBukkit start - Interact soil + org.bukkit.event.Cancellable cancellable; + if (entity instanceof EntityHuman) { @@ -49,12 +48,11 @@ + return; + } + // CraftBukkit end -+ - world.setTypeUpdate(blockposition, Blocks.DIRT.getBlockData()); + this.b(world, blockposition); } - super.fallOn(world, blockposition, entity, f); + // super.fallOn(world, blockposition, entity, f); // CraftBukkit - moved up } - private boolean b(World world, BlockPosition blockposition) { + private void b(World world, BlockPosition blockposition) { diff --git a/nms-patches/BlockTrapdoor.patch b/nms-patches/BlockTrapdoor.patch index 310070951d..1eb2c40d99 100644 --- a/nms-patches/BlockTrapdoor.patch +++ b/nms-patches/BlockTrapdoor.patch @@ -11,7 +11,7 @@ @@ -91,6 +92,19 @@ boolean flag = world.isBlockIndirectlyPowered(blockposition); - if (flag || block.getBlockData().m()) { + if (flag || block.getBlockData().n()) { + // CraftBukkit start + org.bukkit.World bworld = world.getWorld(); + org.bukkit.block.Block bblock = bworld.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); diff --git a/nms-patches/BlockTripwire.patch b/nms-patches/BlockTripwire.patch index c4b40aa363..3f955f11bf 100644 --- a/nms-patches/BlockTripwire.patch +++ b/nms-patches/BlockTripwire.patch @@ -9,7 +9,7 @@ public class BlockTripwire extends Block { public static final BlockStateBoolean POWERED = BlockStateBoolean.of("powered"); -@@ -139,6 +141,40 @@ +@@ -138,6 +140,40 @@ } } diff --git a/nms-patches/BlockVine.patch b/nms-patches/BlockVine.patch index 03b7104c18..c9c4fd8cdb 100644 --- a/nms-patches/BlockVine.patch +++ b/nms-patches/BlockVine.patch @@ -32,25 +32,25 @@ + org.bukkit.block.Block source = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); + org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(blockposition2.getX(), blockposition2.getY(), blockposition2.getZ()); + - if (flag2 && this.x(world.getType(blockposition3))) { + if (flag2 && this.z(world.getType(blockposition3))) { - world.setTypeAndData(blockposition2, this.getBlockData().set(getDirection(enumdirection2), Boolean.valueOf(true)), 2); + // world.setTypeAndData(blockposition2, this.getBlockData().set(getDirection(enumdirection2), Boolean.valueOf(true)), 2); + CraftEventFactory.handleBlockSpreadEvent(bukkitBlock, source, this, toLegacyData(this.getBlockData().set(getDirection(enumdirection2), Boolean.valueOf(true)))); - } else if (flag3 && this.x(world.getType(blockposition4))) { + } else if (flag3 && this.z(world.getType(blockposition4))) { - world.setTypeAndData(blockposition2, this.getBlockData().set(getDirection(enumdirection3), Boolean.valueOf(true)), 2); + // world.setTypeAndData(blockposition2, this.getBlockData().set(getDirection(enumdirection3), Boolean.valueOf(true)), 2); + CraftEventFactory.handleBlockSpreadEvent(bukkitBlock, source, this, toLegacyData(this.getBlockData().set(getDirection(enumdirection3), Boolean.valueOf(true)))); - } else if (flag2 && world.isEmpty(blockposition3) && this.x(world.getType(blockposition.shift(enumdirection2)))) { + } else if (flag2 && world.isEmpty(blockposition3) && this.z(world.getType(blockposition.shift(enumdirection2)))) { - world.setTypeAndData(blockposition3, this.getBlockData().set(getDirection(enumdirection.opposite()), Boolean.valueOf(true)), 2); + // world.setTypeAndData(blockposition3, this.getBlockData().set(getDirection(enumdirection.opposite()), Boolean.valueOf(true)), 2); + bukkitBlock = world.getWorld().getBlockAt(blockposition3.getX(), blockposition3.getY(), blockposition3.getZ()); + CraftEventFactory.handleBlockSpreadEvent(bukkitBlock, source, this, toLegacyData(this.getBlockData().set(getDirection(enumdirection.opposite()), Boolean.valueOf(true)))); - } else if (flag3 && world.isEmpty(blockposition4) && this.x(world.getType(blockposition.shift(enumdirection3)))) { + } else if (flag3 && world.isEmpty(blockposition4) && this.z(world.getType(blockposition.shift(enumdirection3)))) { - world.setTypeAndData(blockposition4, this.getBlockData().set(getDirection(enumdirection.opposite()), Boolean.valueOf(true)), 2); + // world.setTypeAndData(blockposition4, this.getBlockData().set(getDirection(enumdirection.opposite()), Boolean.valueOf(true)), 2); + bukkitBlock = world.getWorld().getBlockAt(blockposition4.getX(), blockposition4.getY(), blockposition4.getZ()); + CraftEventFactory.handleBlockSpreadEvent(bukkitBlock, source, this, toLegacyData(this.getBlockData().set(getDirection(enumdirection.opposite()), Boolean.valueOf(true)))); - } else if (this.x(world.getType(blockposition2.up()))) { + } else if (this.z(world.getType(blockposition2.up()))) { - world.setTypeAndData(blockposition2, this.getBlockData(), 2); + // world.setTypeAndData(blockposition2, this.getBlockData(), 2); + CraftEventFactory.handleBlockSpreadEvent(bukkitBlock, source, this, toLegacyData(this.getBlockData())); diff --git a/nms-patches/ChatModifier.patch b/nms-patches/ChatModifier.patch index f84aedb42f..bd72bcff2d 100644 --- a/nms-patches/ChatModifier.patch +++ b/nms-patches/ChatModifier.patch @@ -28,15 +28,16 @@ return i; } -@@ -440,11 +442,11 @@ - } +@@ -441,12 +443,12 @@ } + @Nullable - public JsonElement serialize(Object object, Type type, JsonSerializationContext jsonserializationcontext) { + public JsonElement serialize(ChatModifier object, Type type, JsonSerializationContext jsonserializationcontext) { // CraftBukkit - fix decompile error return this.a((ChatModifier) object, type, jsonserializationcontext); } + @Nullable - public Object deserialize(JsonElement jsonelement, Type type, JsonDeserializationContext jsondeserializationcontext) throws JsonParseException { + public ChatModifier deserialize(JsonElement jsonelement, Type type, JsonDeserializationContext jsondeserializationcontext) throws JsonParseException { // CraftBukkit - fix decompile error return this.a(jsonelement, type, jsondeserializationcontext); diff --git a/nms-patches/Chunk.patch b/nms-patches/Chunk.patch index 5a5ad49b22..7d8f1da376 100644 --- a/nms-patches/Chunk.patch +++ b/nms-patches/Chunk.patch @@ -11,7 +11,7 @@ private static final Logger e = LogManager.getLogger(); @@ -42,6 +45,35 @@ - private ConcurrentLinkedQueue y; + private final ConcurrentLinkedQueue y; public boolean d; + // CraftBukkit start - Neighbor loaded cache for chunk lighting and entity ticking @@ -91,7 +91,7 @@ if (chunk_enumtileentitystate == Chunk.EnumTileEntityState.IMMEDIATE) { @@ -639,6 +687,13 @@ - tileentity.z(); + tileentity.A(); this.tileEntities.put(blockposition, tileentity); + // CraftBukkit start + } else { @@ -131,9 +131,9 @@ while (iterator.hasNext()) { Entity entity = (Entity) iterator.next(); -- if (entity.getBoundingBox().b(axisalignedbb) && (predicate == null || predicate.apply(entity))) { +- if (entity.getBoundingBox().c(axisalignedbb) && (predicate == null || predicate.apply(entity))) { - list.add(entity); -+ if (entity.getBoundingBox().b(axisalignedbb) && (predicate == null || predicate.apply((T) entity))) { // CraftBukkit - fix decompile error ++ if (entity.getBoundingBox().c(axisalignedbb) && (predicate == null || predicate.apply((T) entity))) { // CraftBukkit - fix decompile error + list.add((T) entity); // Fix decompile error } } diff --git a/nms-patches/ChunkProviderGenerate.patch b/nms-patches/ChunkProviderGenerate.patch index cbb0143e23..65c2bcd92b 100644 --- a/nms-patches/ChunkProviderGenerate.patch +++ b/nms-patches/ChunkProviderGenerate.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/ChunkProviderGenerate.java +++ b/net/minecraft/server/ChunkProviderGenerate.java -@@ -228,6 +228,11 @@ +@@ -234,6 +234,11 @@ f5 = 1.0F + f5 * 2.0F; f6 = 1.0F + f6 * 4.0F; } diff --git a/nms-patches/ChunkProviderServer.patch b/nms-patches/ChunkProviderServer.patch index f83e0c22a3..bcb4586a4f 100644 --- a/nms-patches/ChunkProviderServer.patch +++ b/nms-patches/ChunkProviderServer.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/ChunkProviderServer.java +++ b/net/minecraft/server/ChunkProviderServer.java -@@ -14,6 +14,11 @@ +@@ -15,6 +15,11 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -12,7 +12,7 @@ public class ChunkProviderServer implements IChunkProvider { private static final Logger a = LogManager.getLogger(); -@@ -69,19 +74,82 @@ +@@ -70,19 +75,82 @@ Chunk chunk = this.getLoadedChunkAt(i, j); if (chunk == null) { @@ -97,7 +97,7 @@ if (chunk == null) { long k = ChunkCoordIntPair.a(i, j); -@@ -100,7 +168,7 @@ +@@ -101,7 +169,7 @@ this.chunks.put(k, chunk); chunk.addEntities(); @@ -106,7 +106,7 @@ } return chunk; -@@ -146,10 +214,12 @@ +@@ -147,10 +215,12 @@ public boolean a(boolean flag) { int i = 0; @@ -122,7 +122,7 @@ if (flag) { this.saveChunkNOP(chunk); -@@ -182,10 +252,12 @@ +@@ -183,10 +253,12 @@ Chunk chunk = (Chunk) this.chunks.get(olong); if (chunk != null && chunk.d) { @@ -139,7 +139,7 @@ ++i; } } -@@ -197,6 +269,40 @@ +@@ -198,6 +270,40 @@ return false; } diff --git a/nms-patches/ChunkRegionLoader.patch b/nms-patches/ChunkRegionLoader.patch index a2335fa26f..fb39a6e007 100644 --- a/nms-patches/ChunkRegionLoader.patch +++ b/nms-patches/ChunkRegionLoader.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/ChunkRegionLoader.java +++ b/net/minecraft/server/ChunkRegionLoader.java -@@ -29,25 +29,55 @@ +@@ -29,19 +29,49 @@ this.e = dataconvertermanager; } @@ -38,9 +38,9 @@ NBTTagCompound nbttagcompound = (NBTTagCompound) this.b.get(chunkcoordintpair); if (nbttagcompound == null) { -- DataInputStream datainputstream = RegionFileCache.c(this.d, i, j); +- DataInputStream datainputstream = RegionFileCache.d(this.d, i, j); + // CraftBukkit start -+ nbttagcompound = RegionFileCache.c(this.d, i, j); ++ nbttagcompound = RegionFileCache.d(this.d, i, j); - if (datainputstream == null) { + if (nbttagcompound == null) { @@ -53,14 +53,16 @@ } return this.a(world, i, j, nbttagcompound); +@@ -55,7 +85,7 @@ } + @Nullable - protected Chunk a(World world, int i, int j, NBTTagCompound nbttagcompound) { + protected Object[] a(World world, int i, int j, NBTTagCompound nbttagcompound) { // CraftBukkit - return Chunk -> Object[] if (!nbttagcompound.hasKeyOfType("Level", 10)) { ChunkRegionLoader.a.error("Chunk file at {},{} is missing level data, skipping", new Object[] { Integer.valueOf(i), Integer.valueOf(j)}); return null; -@@ -64,10 +94,28 @@ +@@ -72,10 +102,28 @@ ChunkRegionLoader.a.error("Chunk file at {},{} is in the wrong location; relocating. (Expected {}, {}, got {}, {})", new Object[] { Integer.valueOf(i), Integer.valueOf(j), Integer.valueOf(i), Integer.valueOf(j), Integer.valueOf(chunk.locX), Integer.valueOf(chunk.locZ)}); nbttagcompound1.setInt("xPos", i); nbttagcompound1.setInt("zPos", j); @@ -90,7 +92,7 @@ } } } -@@ -98,20 +146,27 @@ +@@ -106,20 +154,27 @@ } public boolean c() { @@ -121,13 +123,13 @@ if (nbttagcompound != null) { try { -@@ -131,10 +186,14 @@ +@@ -139,10 +194,14 @@ } private void b(ChunkCoordIntPair chunkcoordintpair, NBTTagCompound nbttagcompound) throws IOException { -- DataOutputStream dataoutputstream = RegionFileCache.d(this.d, chunkcoordintpair.x, chunkcoordintpair.z); +- DataOutputStream dataoutputstream = RegionFileCache.e(this.d, chunkcoordintpair.x, chunkcoordintpair.z); + // CraftBukkit start -+ RegionFileCache.d(this.d, chunkcoordintpair.x, chunkcoordintpair.z, nbttagcompound); ++ RegionFileCache.e(this.d, chunkcoordintpair.x, chunkcoordintpair.z, nbttagcompound); + /* NBTCompressedStreamTools.a(nbttagcompound, (DataOutput) dataoutputstream); @@ -137,7 +139,7 @@ } public void b(World world, Chunk chunk) throws IOException {} -@@ -149,6 +208,7 @@ +@@ -157,6 +216,7 @@ if (this.c()) { continue; } @@ -145,7 +147,7 @@ } } finally { this.f = false; -@@ -326,6 +386,13 @@ +@@ -334,6 +394,13 @@ chunk.a(nbttagcompound.getByteArray("Biomes")); } @@ -158,8 +160,8 @@ + NBTTagList nbttaglist1 = nbttagcompound.getList("Entities", 10); - if (nbttaglist1 != null) { -@@ -369,7 +436,7 @@ + for (int l = 0; l < nbttaglist1.size(); ++l) { +@@ -371,7 +438,7 @@ } } @@ -168,7 +170,7 @@ } @Nullable -@@ -397,14 +464,20 @@ +@@ -399,14 +466,20 @@ } @Nullable @@ -190,7 +192,7 @@ return null; } else { if (nbttagcompound.hasKeyOfType("Passengers", 9)) { -@@ -433,8 +506,14 @@ +@@ -435,8 +508,14 @@ } } diff --git a/nms-patches/CommandBlockListenerAbstract.patch b/nms-patches/CommandBlockListenerAbstract.patch index ffa7081e68..f23909ee56 100644 --- a/nms-patches/CommandBlockListenerAbstract.patch +++ b/nms-patches/CommandBlockListenerAbstract.patch @@ -33,12 +33,25 @@ } catch (Throwable throwable) { CrashReport crashreport = CrashReport.a(throwable, "Executing command block"); CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Command to be executed"); -@@ -124,6 +134,125 @@ +@@ -124,6 +134,138 @@ } } ++ public static int executeSafely(ICommandListener sender, org.bukkit.command.CommandSender bSender, String command) { ++ try { ++ return executeCommand(sender, bSender, command); ++ } catch (CommandException commandexception) { ++ // Taken from CommandHandler ++ ChatMessage chatmessage = new ChatMessage(commandexception.getMessage(), commandexception.getArgs()); ++ chatmessage.getChatModifier().setColor(EnumChatFormat.RED); ++ sender.sendMessage(chatmessage); ++ } ++ ++ return 0; ++ } ++ + // CraftBukkit start -+ public static int executeCommand(ICommandListener sender, org.bukkit.command.CommandSender bSender, String command) { ++ public static int executeCommand(ICommandListener sender, org.bukkit.command.CommandSender bSender, String command) throws CommandException { + org.bukkit.command.SimpleCommandMap commandMap = sender.getWorld().getServer().getCommandMap(); + Joiner joiner = Joiner.on(" "); + if (command.startsWith("/")) { @@ -137,7 +150,7 @@ + return completed; + } + -+ private static ArrayList buildCommands(ICommandListener sender, String[] args, int pos) { ++ private static ArrayList buildCommands(ICommandListener sender, String[] args, int pos) throws CommandException { + ArrayList commands = new ArrayList(); + java.util.List players = (java.util.List)PlayerSelector.getPlayers(sender, args[pos], EntityPlayer.class); + diff --git a/nms-patches/CommandExecute.patch b/nms-patches/CommandExecute.patch index 582c9a25b0..e36811c105 100644 --- a/nms-patches/CommandExecute.patch +++ b/nms-patches/CommandExecute.patch @@ -11,7 +11,7 @@ public class CommandExecute extends CommandAbstract { -@@ -55,7 +59,10 @@ +@@ -58,7 +62,10 @@ } String s = a(astring, b0); @@ -23,15 +23,15 @@ public String getName() { return entity.getName(); } -@@ -100,25 +107,59 @@ - return entity.h(); +@@ -103,25 +110,59 @@ + return entity.B_(); } }; + ICommandListener icommandlistener1 = new ProxyListener(); // CraftBukkit ICommandHandler icommandhandler = minecraftserver.getCommandHandler(); try { -- int j = icommandhandler.a(icommandlistener1, s); +- int i = icommandhandler.a(icommandlistener1, s); + // CraftBukkit start + org.bukkit.command.CommandSender sender = null; + ICommandListener listener = icommandlistener; @@ -52,10 +52,10 @@ + throw new CommandException("Unhandled executor " + icommandlistener.getClass().getSimpleName(), new Object[0]); + } + } -+ int j = CommandBlockListenerAbstract.executeCommand(icommandlistener1, new ProxiedNativeCommandSender(icommandlistener1, sender, entity.getBukkitEntity()), s); ++ int i = CommandBlockListenerAbstract.executeCommand(icommandlistener1, new ProxiedNativeCommandSender(icommandlistener1, sender, entity.getBukkitEntity()), s); + // CraftBukkit end - if (j < 1) { + if (i < 1) { throw new CommandException("commands.execute.allInvocationsFailed", new Object[] { s}); } } catch (Throwable throwable) { diff --git a/nms-patches/Container.patch b/nms-patches/Container.patch index 615268753a..7e5e2ff846 100644 --- a/nms-patches/Container.patch +++ b/nms-patches/Container.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/Container.java +++ b/net/minecraft/server/Container.java -@@ -8,6 +8,17 @@ +@@ -7,6 +7,17 @@ import java.util.Set; import javax.annotation.Nullable; @@ -17,8 +17,8 @@ + public abstract class Container { - public List b = Lists.newArrayList(); -@@ -19,12 +30,24 @@ + public NonNullList b = NonNullList.a(); +@@ -18,6 +29,18 @@ protected List listeners = Lists.newArrayList(); private final Set i = Sets.newHashSet(); @@ -37,38 +37,28 @@ public Container() {} protected Slot a(Slot slot) { - slot.rawSlotIndex = this.c.size(); - this.c.add(slot); -- this.b.add((Object) null); -+ this.b.add(null); // CraftBukkit - fix decompile error - return slot; - } - @@ -128,6 +151,7 @@ - k = playerinventory.getCarried().count; + l = playerinventory.getCarried().getCount(); Iterator iterator = this.h.iterator(); + Map draggedSlots = new HashMap(); // CraftBukkit - Store slots from drag in map (raw slot id -> new stack) while (iterator.hasNext()) { Slot slot1 = (Slot) iterator.next(); - -@@ -145,16 +169,48 @@ + ItemStack itemstack3 = playerinventory.getCarried(); +@@ -143,12 +167,48 @@ } - k -= itemstack2.count - i1; -- slot1.set(itemstack2); -+ // slot1.set(itemstack2); -+ draggedSlots.put(slot1.rawSlotIndex, itemstack2); // CraftBukkit - Put in map instead of setting - } - } - -- itemstack1.count = k; -- if (itemstack1.count <= 0) { -- itemstack1 = null; + l -= itemstack4.getCount() - j1; +- slot1.set(itemstack4); ++ // slot1.set(itemstack4); ++ draggedSlots.put(slot1.rawSlotIndex, itemstack4); // CraftBukkit - Put in map instead of setting ++ } ++ } ++ + // CraftBukkit start - InventoryDragEvent + InventoryView view = getBukkitView(); -+ org.bukkit.inventory.ItemStack newcursor = CraftItemStack.asCraftMirror(itemstack1); -+ newcursor.setAmount(k); ++ org.bukkit.inventory.ItemStack newcursor = CraftItemStack.asCraftMirror(itemstack2); ++ newcursor.setAmount(l); + Map eventmap = new HashMap(); + for (Map.Entry ditem : draggedSlots.entrySet()) { + eventmap.put(ditem.getKey(), CraftItemStack.asBukkitCopy(ditem.getValue())); @@ -93,12 +83,13 @@ + if (playerinventory.getCarried() != null) { + playerinventory.setCarried(CraftItemStack.asNMSCopy(event.getCursor())); + needsUpdate = true; -+ } + } + } else { + playerinventory.setCarried(oldCursor); } -- playerinventory.setCarried(itemstack1); +- itemstack2.setCount(l); +- playerinventory.setCarried(itemstack2); + if (needsUpdate && entityhuman instanceof EntityPlayer) { + ((EntityPlayer) entityhuman).updateInventory(this); + } @@ -106,69 +97,7 @@ } this.d(); -@@ -177,8 +233,14 @@ - } - - if (j == 1) { -- entityhuman.drop(playerinventory.getCarried().cloneAndSubtract(1), true); -- if (playerinventory.getCarried().count == 0) { -+ // CraftBukkit start - Store a reference, don't drop unless > 0 -+ ItemStack carried = playerinventory.getCarried(); -+ if (carried.count > 0) { -+ entityhuman.drop(carried.cloneAndSubtract(1), true); -+ } -+ -+ if (carried.count == 0) { -+ // CraftBukkit end - playerinventory.setCarried((ItemStack) null); - } - } -@@ -229,7 +291,11 @@ - slot2.set(itemstack3.cloneAndSubtract(j1)); - if (itemstack3.count == 0) { - playerinventory.setCarried((ItemStack) null); -+ // CraftBukkit start - Update client cursor if we didn't empty it -+ } else if (entityhuman instanceof EntityPlayer) { -+ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutSetSlot(-1, -1, entityhuman.inventory.getCarried())); - } -+ // CraftBukkit end - } - } else if (slot2.isAllowed(entityhuman)) { - if (itemstack3 == null) { -@@ -259,7 +325,11 @@ - itemstack3.cloneAndSubtract(j1); - if (itemstack3.count == 0) { - playerinventory.setCarried((ItemStack) null); -+ // CraftBukkit start - Update client cursor if we didn't empty it -+ } else if (entityhuman instanceof EntityPlayer) { -+ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutSetSlot(-1, -1, entityhuman.inventory.getCarried())); - } -+ // CraftBukkit end - - itemstack1.count += j1; - } else if (itemstack3.count <= slot2.getMaxStackSize(itemstack3)) { -@@ -268,7 +338,10 @@ - } - } else if (itemstack1.getItem() == itemstack3.getItem() && itemstack3.getMaxStackSize() > 1 && (!itemstack1.usesData() || itemstack1.getData() == itemstack3.getData()) && ItemStack.equals(itemstack1, itemstack3)) { - j1 = itemstack1.count; -- if (j1 > 0 && j1 + itemstack3.count <= itemstack3.getMaxStackSize()) { -+ // CraftBukkit start - itemstack3.getMaxStackSize() -> maxStack -+ int maxStack = Math.min(itemstack3.getMaxStackSize(), slot2.getMaxStackSize()); -+ if (j1 > 0 && j1 + itemstack3.count <= maxStack) { -+ // CraftBukkit end - itemstack3.count += j1; - itemstack1 = slot2.a(j1); - if (itemstack1.count == 0) { -@@ -276,11 +349,24 @@ - } - - slot2.a(entityhuman, playerinventory.getCarried()); -+ // CraftBukkit start - Update client cursor if we didn't empty it -+ } else if (entityhuman instanceof EntityPlayer) { -+ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutSetSlot(-1, -1, entityhuman.inventory.getCarried())); - } -+ // CraftBukkit end - } +@@ -258,6 +318,15 @@ } slot2.f(); @@ -184,25 +113,3 @@ } } } else if (inventoryclicktype == InventoryClickType.SWAP && j >= 0 && j < 9) { -@@ -434,14 +520,17 @@ - if (itemstack1 != null && a(itemstack, itemstack1)) { - int l = itemstack1.count + itemstack.count; - -- if (l <= itemstack.getMaxStackSize()) { -+ // CraftBukkit start - itemstack.getMaxStackSize() -> maxStack -+ int maxStack = Math.min(itemstack.getMaxStackSize(), slot.getMaxStackSize()); -+ if (l <= maxStack) { - itemstack.count = 0; - itemstack1.count = l; - slot.f(); - flag1 = true; -- } else if (itemstack1.count < itemstack.getMaxStackSize()) { -- itemstack.count -= itemstack.getMaxStackSize() - itemstack1.count; -- itemstack1.count = itemstack.getMaxStackSize(); -+ } else if (itemstack1.count < maxStack) { -+ itemstack.count -= maxStack - itemstack1.count; -+ itemstack1.count = maxStack; -+ // CraftBukkit end - slot.f(); - flag1 = true; - } diff --git a/nms-patches/ContainerAnvil.patch b/nms-patches/ContainerAnvil.patch index f18c3171a8..f42c2945b3 100644 --- a/nms-patches/ContainerAnvil.patch +++ b/nms-patches/ContainerAnvil.patch @@ -1,24 +1,22 @@ --- a/net/minecraft/server/ContainerAnvil.java +++ b/net/minecraft/server/ContainerAnvil.java -@@ -7,6 +7,12 @@ +@@ -6,6 +6,10 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -+ // CraftBukkit start ++// CraftBukkit start +import org.bukkit.craftbukkit.inventory.CraftInventoryView; -+import org.bukkit.craftbukkit.inventory.CraftItemStack; -+import org.bukkit.event.inventory.PrepareAnvilEvent; +// CraftBukkit end + public class ContainerAnvil extends Container { private static final Logger f = LogManager.getLogger(); -@@ -23,8 +29,13 @@ +@@ -22,8 +26,13 @@ private int k; private String l; private final EntityHuman m; + // CraftBukkit start -+ private CraftInventoryView bukkitEntity = null; ++ private CraftInventoryView bukkitEntity; + private PlayerInventory player; + // CraftBukkit end @@ -27,34 +25,34 @@ this.j = blockposition; this.i = world; this.m = entityhuman; -@@ -110,7 +121,7 @@ +@@ -110,7 +119,7 @@ byte b1 = 0; - if (itemstack == null) { -- this.g.setItem(0, (ItemStack) null); -+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), null); // CraftBukkit + if (itemstack.isEmpty()) { +- this.g.setItem(0, ItemStack.a); ++ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.a); // CraftBukkit this.a = 0; } else { ItemStack itemstack1 = itemstack.cloneItemStack(); -@@ -128,7 +139,7 @@ - if (itemstack1.e() && itemstack1.getItem().a(itemstack, itemstack2)) { - k = Math.min(itemstack1.h(), itemstack1.j() / 4); +@@ -128,7 +137,7 @@ + if (itemstack1.f() && itemstack1.getItem().a(itemstack, itemstack2)) { + k = Math.min(itemstack1.i(), itemstack1.k() / 4); if (k <= 0) { -- this.g.setItem(0, (ItemStack) null); -+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), null); // CraftBukkit +- this.g.setItem(0, ItemStack.a); ++ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.a); // CraftBukkit this.a = 0; return; } -@@ -143,7 +154,7 @@ +@@ -143,7 +152,7 @@ this.k = l; } else { - if (!flag && (itemstack1.getItem() != itemstack2.getItem() || !itemstack1.e())) { -- this.g.setItem(0, (ItemStack) null); -+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), null); // CraftBukkit + if (!flag && (itemstack1.getItem() != itemstack2.getItem() || !itemstack1.f())) { +- this.g.setItem(0, ItemStack.a); ++ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.a); // CraftBukkit this.a = 0; return; } -@@ -270,7 +281,7 @@ +@@ -270,7 +279,7 @@ EnchantmentManager.a(map, itemstack1); } @@ -63,18 +61,19 @@ this.b(); } } -@@ -295,6 +306,7 @@ +@@ -295,6 +304,7 @@ } public boolean a(EntityHuman entityhuman) { + if (!this.checkReachable) return true; // CraftBukkit - return this.i.getType(this.j).getBlock() != Blocks.ANVIL ? false : entityhuman.e((double) this.j.getX() + 0.5D, (double) this.j.getY() + 0.5D, (double) this.j.getZ() + 0.5D) <= 64.0D; + return this.i.getType(this.j).getBlock() != Blocks.ANVIL ? false : entityhuman.d((double) this.j.getX() + 0.5D, (double) this.j.getY() + 0.5D, (double) this.j.getZ() + 0.5D) <= 64.0D; } -@@ -352,6 +364,20 @@ +@@ -350,4 +360,18 @@ + this.e(); } - ++ + // CraftBukkit start + @Override + public CraftInventoryView getBukkitView() { @@ -88,7 +87,4 @@ + return bukkitEntity; + } + // CraftBukkit end -+ - static class SyntheticClass_1 { - - static final int[] a = new int[Enchantment.Rarity.values().length]; + } diff --git a/nms-patches/ContainerBeacon.patch b/nms-patches/ContainerBeacon.patch index 0e544bc0e5..13196bb70c 100644 --- a/nms-patches/ContainerBeacon.patch +++ b/nms-patches/ContainerBeacon.patch @@ -1,11 +1,10 @@ --- a/net/minecraft/server/ContainerBeacon.java +++ b/net/minecraft/server/ContainerBeacon.java -@@ -1,13 +1,19 @@ +@@ -1,11 +1,18 @@ package net.minecraft.server; - import javax.annotation.Nullable; +import org.bukkit.craftbukkit.inventory.CraftInventoryView; // CraftBukkit - ++ public class ContainerBeacon extends Container { private final IInventory beacon; @@ -20,7 +19,7 @@ this.beacon = iinventory1; this.f = new ContainerBeacon.SlotBeacon(iinventory1, 0, 136, 110); this.a((Slot) this.f); -@@ -50,6 +56,7 @@ +@@ -48,6 +55,7 @@ } public boolean a(EntityHuman entityhuman) { @@ -28,7 +27,7 @@ return this.beacon.a(entityhuman); } -@@ -114,4 +121,17 @@ +@@ -113,4 +121,17 @@ return 1; } } diff --git a/nms-patches/ContainerBrewingStand.patch b/nms-patches/ContainerBrewingStand.patch index 98ae5c5eab..dc38c122a7 100644 --- a/nms-patches/ContainerBrewingStand.patch +++ b/nms-patches/ContainerBrewingStand.patch @@ -1,17 +1,17 @@ --- a/net/minecraft/server/ContainerBrewingStand.java +++ b/net/minecraft/server/ContainerBrewingStand.java -@@ -1,6 +1,10 @@ +@@ -1,5 +1,10 @@ package net.minecraft.server; - import javax.annotation.Nullable; +// CraftBukkit start +import org.bukkit.craftbukkit.inventory.CraftInventoryBrewer; +import org.bukkit.craftbukkit.inventory.CraftInventoryView; +// CraftBukkit end - ++ public class ContainerBrewingStand extends Container { -@@ -9,7 +13,13 @@ + private final IInventory brewingStand; +@@ -7,7 +12,13 @@ private int g; private int h; @@ -25,7 +25,7 @@ this.brewingStand = iinventory; this.a((Slot) (new ContainerBrewingStand.SlotPotionBottle(playerinventory.player, iinventory, 0, 56, 51))); this.a((Slot) (new ContainerBrewingStand.SlotPotionBottle(playerinventory.player, iinventory, 1, 79, 58))); -@@ -56,6 +66,7 @@ +@@ -54,6 +65,7 @@ } public boolean a(EntityHuman entityhuman) { @@ -33,8 +33,8 @@ return this.brewingStand.a(entityhuman); } -@@ -185,4 +196,17 @@ - } +@@ -181,4 +193,17 @@ + return item == Items.POTION || item == Items.SPLASH_POTION || item == Items.LINGERING_POTION || item == Items.GLASS_BOTTLE; } } + diff --git a/nms-patches/ContainerChest.patch b/nms-patches/ContainerChest.patch index 05e02ff571..9535a08097 100644 --- a/nms-patches/ContainerChest.patch +++ b/nms-patches/ContainerChest.patch @@ -1,14 +1,13 @@ --- a/net/minecraft/server/ContainerChest.java +++ b/net/minecraft/server/ContainerChest.java -@@ -1,11 +1,38 @@ +@@ -1,9 +1,37 @@ package net.minecraft.server; - import javax.annotation.Nullable; +// CraftBukkit start +import org.bukkit.craftbukkit.inventory.CraftInventory; +import org.bukkit.craftbukkit.inventory.CraftInventoryView; +// CraftBukkit end - ++ public class ContainerChest extends Container { private final IInventory container; @@ -39,7 +38,7 @@ public ContainerChest(IInventory iinventory, IInventory iinventory1, EntityHuman entityhuman) { this.container = iinventory1; -@@ -13,6 +40,11 @@ +@@ -11,6 +39,11 @@ iinventory1.startOpen(entityhuman); int i = (this.f - 4) * 18; @@ -51,7 +50,7 @@ int j; int k; -@@ -35,6 +67,7 @@ +@@ -33,6 +66,7 @@ } public boolean a(EntityHuman entityhuman) { diff --git a/nms-patches/ContainerDispenser.patch b/nms-patches/ContainerDispenser.patch index 9435edcb5c..9b8b1ad258 100644 --- a/nms-patches/ContainerDispenser.patch +++ b/nms-patches/ContainerDispenser.patch @@ -1,14 +1,13 @@ --- a/net/minecraft/server/ContainerDispenser.java +++ b/net/minecraft/server/ContainerDispenser.java -@@ -1,13 +1,25 @@ +@@ -1,11 +1,24 @@ package net.minecraft.server; - import javax.annotation.Nullable; +// CraftBukkit start +import org.bukkit.craftbukkit.inventory.CraftInventory; +import org.bukkit.craftbukkit.inventory.CraftInventoryView; +// CraftBukkit end - ++ public class ContainerDispenser extends Container { public final IInventory items; @@ -26,7 +25,7 @@ int i; int j; -@@ -31,6 +43,7 @@ +@@ -29,6 +42,7 @@ } public boolean a(EntityHuman entityhuman) { @@ -34,7 +33,7 @@ return this.items.a(entityhuman); } -@@ -66,4 +79,17 @@ +@@ -63,4 +77,17 @@ return itemstack; } diff --git a/nms-patches/ContainerEnchantTable.patch b/nms-patches/ContainerEnchantTable.patch index e7e871e98d..4abd722f81 100644 --- a/nms-patches/ContainerEnchantTable.patch +++ b/nms-patches/ContainerEnchantTable.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/ContainerEnchantTable.java +++ b/net/minecraft/server/ContainerEnchantTable.java -@@ -4,9 +4,22 @@ +@@ -3,9 +3,22 @@ + import java.util.List; import java.util.Random; - import javax.annotation.Nullable; +// CraftBukkit start +import java.util.Map; @@ -24,7 +24,7 @@ public int getMaxStackSize() { return 64; } -@@ -15,6 +28,11 @@ +@@ -14,6 +27,11 @@ super.update(); ContainerEnchantTable.this.a((IInventory) this); } @@ -36,7 +36,7 @@ }; public World world; private final BlockPosition position; -@@ -23,6 +41,10 @@ +@@ -22,6 +40,10 @@ public int[] costs = new int[3]; public int[] h = new int[] { -1, -1, -1}; public int[] i = new int[] { -1, -1, -1}; @@ -47,7 +47,7 @@ public ContainerEnchantTable(PlayerInventory playerinventory, World world, BlockPosition blockposition) { this.world = world; -@@ -55,6 +77,9 @@ +@@ -54,6 +76,9 @@ this.a(new Slot(playerinventory, i, 8 + i * 18, 142)); } @@ -57,23 +57,23 @@ } protected void c(ICrafting icrafting) { -@@ -91,7 +116,7 @@ +@@ -90,7 +115,7 @@ ItemStack itemstack = iinventory.getItem(0); int i; -- if (itemstack != null && itemstack.v()) { -+ if (itemstack != null) { // CraftBukkit - relax condition +- if (!itemstack.isEmpty() && itemstack.canEnchant()) { ++ if (!itemstack.isEmpty()) { // CraftBukkit - relax condition if (!this.world.isClientSide) { i = 0; -@@ -140,6 +165,20 @@ +@@ -139,6 +164,20 @@ } } + // CraftBukkit start + CraftItemStack item = CraftItemStack.asCraftMirror(itemstack); + PrepareItemEnchantEvent event = new PrepareItemEnchantEvent(player, this.getBukkitView(), this.world.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ()), item, this.costs, i); -+ event.setCancelled(!itemstack.v()); ++ event.setCancelled(!itemstack.canEnchant()); + this.world.getServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { @@ -87,8 +87,8 @@ for (j = 0; j < 3; ++j) { if (this.costs[j] > 0) { List list = this.a(itemstack, j, this.costs[j]); -@@ -176,24 +215,55 @@ - } else if (this.costs[i] > 0 && itemstack != null && (entityhuman.expLevel >= j && entityhuman.expLevel >= this.costs[i] || entityhuman.abilities.canInstantlyBuild)) { +@@ -175,26 +214,56 @@ + } else if (this.costs[i] > 0 && !itemstack.isEmpty() && (entityhuman.expLevel >= j && entityhuman.expLevel >= this.costs[i] || entityhuman.abilities.canInstantlyBuild)) { if (!this.world.isClientSide) { List list = this.a(itemstack, i, this.costs[i]); + // CraftBukkit start - Provide an empty enchantment list @@ -96,10 +96,12 @@ + list = new java.util.ArrayList(); + } + // CraftBukkit end - boolean flag = itemstack.getItem() == Items.BOOK; ++ boolean flag = itemstack.getItem() == Items.BOOK; - if (list != null) { +- if (!list.isEmpty()) { - entityhuman.enchantDone(j); +- boolean flag = itemstack.getItem() == Items.BOOK; ++ if (list != null) { + // CraftBukkit start + Map enchants = new java.util.HashMap(); + for (Object obj : list) { @@ -110,13 +112,14 @@ + + EnchantItemEvent event = new EnchantItemEvent((Player) entityhuman.getBukkitEntity(), this.getBukkitView(), this.world.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ()), item, this.costs[i], enchants, i); + this.world.getServer().getPluginManager().callEvent(event); -+ + + int level = event.getExpLevelCost(); + if (event.isCancelled() || (level > entityhuman.expLevel && !entityhuman.abilities.canInstantlyBuild) || event.getEnchantsToAdd().isEmpty()) { + return false; + } if (flag) { - itemstack.setItem(Items.ENCHANTED_BOOK); + itemstack = new ItemStack(Items.ENCHANTED_BOOK); + this.enchantSlots.setItem(0, itemstack); } - for (int k = 0; k < list.size(); ++k) { @@ -148,9 +151,9 @@ + + // CraftBukkit - TODO: let plugins change this if (!entityhuman.abilities.canInstantlyBuild) { - itemstack1.count -= j; - if (itemstack1.count <= 0) { -@@ -228,6 +298,11 @@ + itemstack1.subtract(j); + if (itemstack1.isEmpty()) { +@@ -229,6 +298,11 @@ public void b(EntityHuman entityhuman) { super.b(entityhuman); @@ -162,15 +165,15 @@ if (!this.world.isClientSide) { for (int i = 0; i < this.enchantSlots.getSize(); ++i) { ItemStack itemstack = this.enchantSlots.splitWithoutUpdate(i); -@@ -241,6 +316,7 @@ +@@ -242,6 +316,7 @@ } public boolean a(EntityHuman entityhuman) { + if (!this.checkReachable) return true; // CraftBukkit - return this.world.getType(this.position).getBlock() != Blocks.ENCHANTING_TABLE ? false : entityhuman.e((double) this.position.getX() + 0.5D, (double) this.position.getY() + 0.5D, (double) this.position.getZ() + 0.5D) <= 64.0D; + return this.world.getType(this.position).getBlock() != Blocks.ENCHANTING_TABLE ? false : entityhuman.d((double) this.position.getX() + 0.5D, (double) this.position.getY() + 0.5D, (double) this.position.getZ() + 0.5D) <= 64.0D; } -@@ -294,4 +370,17 @@ +@@ -294,4 +369,17 @@ return itemstack; } diff --git a/nms-patches/ContainerFurnace.patch b/nms-patches/ContainerFurnace.patch index 609b2f6fb6..e64b781864 100644 --- a/nms-patches/ContainerFurnace.patch +++ b/nms-patches/ContainerFurnace.patch @@ -1,17 +1,17 @@ --- a/net/minecraft/server/ContainerFurnace.java +++ b/net/minecraft/server/ContainerFurnace.java -@@ -1,6 +1,10 @@ +@@ -1,5 +1,10 @@ package net.minecraft.server; - import javax.annotation.Nullable; +// CraftBukkit start +import org.bukkit.craftbukkit.inventory.CraftInventoryFurnace; +import org.bukkit.craftbukkit.inventory.CraftInventoryView; +// CraftBukkit end - ++ public class ContainerFurnace extends Container { -@@ -10,11 +14,28 @@ + private final IInventory furnace; +@@ -8,11 +13,28 @@ private int h; private int i; @@ -40,7 +40,7 @@ int i; -@@ -65,6 +86,7 @@ +@@ -63,6 +85,7 @@ } public boolean a(EntityHuman entityhuman) { diff --git a/nms-patches/ContainerHopper.patch b/nms-patches/ContainerHopper.patch index 96f6b28aa4..54117f6294 100644 --- a/nms-patches/ContainerHopper.patch +++ b/nms-patches/ContainerHopper.patch @@ -1,14 +1,13 @@ --- a/net/minecraft/server/ContainerHopper.java +++ b/net/minecraft/server/ContainerHopper.java -@@ -1,13 +1,34 @@ +@@ -1,11 +1,33 @@ package net.minecraft.server; - import javax.annotation.Nullable; +// CraftBukkit start +import org.bukkit.craftbukkit.inventory.CraftInventory; +import org.bukkit.craftbukkit.inventory.CraftInventoryView; +// CraftBukkit end - ++ public class ContainerHopper extends Container { private final IInventory hopper; @@ -35,7 +34,7 @@ iinventory.startOpen(entityhuman); boolean flag = true; -@@ -30,6 +51,7 @@ +@@ -28,6 +50,7 @@ } public boolean a(EntityHuman entityhuman) { diff --git a/nms-patches/ContainerHorse.patch b/nms-patches/ContainerHorse.patch index c15f5de3c3..739df2152c 100644 --- a/nms-patches/ContainerHorse.patch +++ b/nms-patches/ContainerHorse.patch @@ -1,19 +1,18 @@ --- a/net/minecraft/server/ContainerHorse.java +++ b/net/minecraft/server/ContainerHorse.java -@@ -1,13 +1,34 @@ +@@ -1,11 +1,33 @@ package net.minecraft.server; - import javax.annotation.Nullable; +// CraftBukkit start +import org.bukkit.craftbukkit.inventory.CraftInventory; +import org.bukkit.craftbukkit.inventory.CraftInventoryView; +import org.bukkit.inventory.InventoryView; +// CraftBukkit end - ++ public class ContainerHorse extends Container { private final IInventory a; - private final EntityHorse f; + private final EntityHorseAbstract f; + // CraftBukkit start + org.bukkit.craftbukkit.inventory.CraftInventoryView bukkitEntity; @@ -29,9 +28,9 @@ + return bukkitEntity = new CraftInventoryView(player.player.getBukkitEntity(), inventory, this); + } + - public ContainerHorse(IInventory iinventory, final IInventory iinventory1, final EntityHorse entityhorse, EntityHuman entityhuman) { + public ContainerHorse(IInventory iinventory, final IInventory iinventory1, final EntityHorseAbstract entityhorseabstract, EntityHuman entityhuman) { + player = (PlayerInventory) iinventory; + // CraftBukkit end this.a = iinventory1; - this.f = entityhorse; + this.f = entityhorseabstract; boolean flag = true; diff --git a/nms-patches/ContainerMerchant.patch b/nms-patches/ContainerMerchant.patch index 7cd43434dc..3610204f0f 100644 --- a/nms-patches/ContainerMerchant.patch +++ b/nms-patches/ContainerMerchant.patch @@ -1,14 +1,13 @@ --- a/net/minecraft/server/ContainerMerchant.java +++ b/net/minecraft/server/ContainerMerchant.java -@@ -1,6 +1,7 @@ +@@ -1,11 +1,26 @@ package net.minecraft.server; - import javax.annotation.Nullable; +import org.bukkit.craftbukkit.inventory.CraftInventoryView; // CraftBukkit - ++ public class ContainerMerchant extends Container { -@@ -8,6 +9,19 @@ + private final IMerchant merchant; private final InventoryMerchant f; private final World g; @@ -28,7 +27,7 @@ public ContainerMerchant(PlayerInventory playerinventory, IMerchant imerchant, World world) { this.merchant = imerchant; this.g = world; -@@ -15,6 +29,7 @@ +@@ -13,6 +28,7 @@ this.a(new Slot(this.f, 0, 36, 53)); this.a(new Slot(this.f, 1, 62, 53)); this.a((Slot) (new SlotMerchantResult(playerinventory.player, imerchant, this.f, 2, 120, 53))); diff --git a/nms-patches/ContainerPlayer.patch b/nms-patches/ContainerPlayer.patch index a79220cb9f..3e0d58dcea 100644 --- a/nms-patches/ContainerPlayer.patch +++ b/nms-patches/ContainerPlayer.patch @@ -1,17 +1,17 @@ --- a/net/minecraft/server/ContainerPlayer.java +++ b/net/minecraft/server/ContainerPlayer.java -@@ -1,6 +1,10 @@ +@@ -1,5 +1,10 @@ package net.minecraft.server; - import javax.annotation.Nullable; +// CraftBukkit start +import org.bukkit.craftbukkit.inventory.CraftInventoryCrafting; +import org.bukkit.craftbukkit.inventory.CraftInventoryView; +// CraftBukkit end - ++ public class ContainerPlayer extends Container { -@@ -9,10 +13,20 @@ + private static final EnumItemSlot[] h = new EnumItemSlot[] { EnumItemSlot.HEAD, EnumItemSlot.CHEST, EnumItemSlot.LEGS, EnumItemSlot.FEET}; +@@ -7,10 +12,20 @@ public IInventory resultInventory = new InventoryCraftResult(); public boolean g; private final EntityHuman owner; @@ -32,7 +32,7 @@ this.a((Slot) (new SlotResult(playerinventory.player, this.craftInventory, this.resultInventory, 0, 154, 28))); int i; -@@ -25,7 +39,7 @@ +@@ -23,7 +38,7 @@ } for (i = 0; i < 4; ++i) { @@ -41,9 +41,18 @@ this.a(new Slot(playerinventory, 36 + (3 - i), 8, 8 + i * 18) { public int getMaxStackSize() { -@@ -59,11 +73,22 @@ - return super.isAllowed(itemstack); - } +@@ -31,7 +46,7 @@ + } + + public boolean isAllowed(ItemStack itemstack) { +- return enumitemslot == EntityInsentient.d(itemstack); ++ return enumitemslot1 == EntityInsentient.d(itemstack); // CraftBukkit - decompile error + } + + public boolean isAllowed(EntityHuman entityhuman) { +@@ -54,11 +69,22 @@ + + this.a(new Slot(playerinventory, 40, 77, 62) { }); - this.a((IInventory) this.craftInventory); + // this.a((IInventory) this.craftInventory); // CraftBukkit - unneeded since it just sets result slot to empty @@ -66,7 +75,7 @@ } public void b(EntityHuman entityhuman) { -@@ -150,4 +175,17 @@ +@@ -148,4 +174,17 @@ public boolean a(ItemStack itemstack, Slot slot) { return slot.inventory != this.resultInventory && super.a(itemstack, slot); } diff --git a/nms-patches/ContainerShulkerBox.patch b/nms-patches/ContainerShulkerBox.patch new file mode 100644 index 0000000000..494f7c4946 --- /dev/null +++ b/nms-patches/ContainerShulkerBox.patch @@ -0,0 +1,34 @@ +--- a/net/minecraft/server/ContainerShulkerBox.java ++++ b/net/minecraft/server/ContainerShulkerBox.java +@@ -1,11 +1,31 @@ + package net.minecraft.server; + ++// CraftBukkit start ++import org.bukkit.craftbukkit.inventory.CraftInventory; ++import org.bukkit.craftbukkit.inventory.CraftInventoryView; ++// CraftBukkit end ++ + public class ContainerShulkerBox extends Container { + + private final IInventory a; ++ // CraftBukkit start ++ private CraftInventoryView bukkitEntity; ++ private PlayerInventory player; ++ ++ @Override ++ public CraftInventoryView getBukkitView() { ++ if (bukkitEntity != null) { ++ return bukkitEntity; ++ } ++ ++ bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), new CraftInventory(this.a), this); ++ return bukkitEntity; ++ } ++ // CraftBukkit end + + public ContainerShulkerBox(PlayerInventory playerinventory, IInventory iinventory, EntityHuman entityhuman) { + this.a = iinventory; ++ this.player = playerinventory; // CraftBukkit - save player + iinventory.startOpen(entityhuman); + boolean flag = true; + boolean flag1 = true; diff --git a/nms-patches/ContainerWorkbench.patch b/nms-patches/ContainerWorkbench.patch index d2b2757cc4..38991fa57b 100644 --- a/nms-patches/ContainerWorkbench.patch +++ b/nms-patches/ContainerWorkbench.patch @@ -1,14 +1,13 @@ --- a/net/minecraft/server/ContainerWorkbench.java +++ b/net/minecraft/server/ContainerWorkbench.java -@@ -1,15 +1,29 @@ +@@ -1,13 +1,28 @@ package net.minecraft.server; - import javax.annotation.Nullable; +// CraftBukkit start +import org.bukkit.craftbukkit.inventory.CraftInventoryCrafting; +import org.bukkit.craftbukkit.inventory.CraftInventoryView; +// CraftBukkit end - ++ public class ContainerWorkbench extends Container { - public InventoryCrafting craftInventory = new InventoryCrafting(this, 3, 3); @@ -32,7 +31,7 @@ this.g = world; this.h = blockposition; this.a((Slot) (new SlotResult(playerinventory.player, this.craftInventory, this.resultInventory, 0, 124, 35))); -@@ -37,7 +51,21 @@ +@@ -35,7 +50,21 @@ } public void a(IInventory iinventory) { @@ -55,15 +54,15 @@ } public void b(EntityHuman entityhuman) { -@@ -55,6 +83,7 @@ +@@ -53,6 +82,7 @@ } public boolean a(EntityHuman entityhuman) { + if (!this.checkReachable) return true; // CraftBukkit - return this.g.getType(this.h).getBlock() != Blocks.CRAFTING_TABLE ? false : entityhuman.e((double) this.h.getX() + 0.5D, (double) this.h.getY() + 0.5D, (double) this.h.getZ() + 0.5D) <= 64.0D; + return this.g.getType(this.h).getBlock() != Blocks.CRAFTING_TABLE ? false : entityhuman.d((double) this.h.getX() + 0.5D, (double) this.h.getY() + 0.5D, (double) this.h.getZ() + 0.5D) <= 64.0D; } -@@ -104,4 +133,17 @@ +@@ -106,4 +136,17 @@ public boolean a(ItemStack itemstack, Slot slot) { return slot.inventory != this.resultInventory && super.a(itemstack, slot); } diff --git a/nms-patches/CraftingManager.patch b/nms-patches/CraftingManager.patch index d37e1c5cf8..1e5049d69b 100644 --- a/nms-patches/CraftingManager.patch +++ b/nms-patches/CraftingManager.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/CraftingManager.java +++ b/net/minecraft/server/CraftingManager.java -@@ -10,10 +10,16 @@ +@@ -9,10 +9,16 @@ + import java.util.Iterator; import java.util.List; - import javax.annotation.Nullable; +import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit + @@ -17,7 +17,7 @@ public static CraftingManager getInstance() { return CraftingManager.a; -@@ -178,7 +184,12 @@ +@@ -179,7 +185,12 @@ this.registerShapedRecipe(new ItemStack(Items.ARMOR_STAND, 1), new Object[] { "///", " / ", "/_/", Character.valueOf('/'), Items.STICK, Character.valueOf('_'), new ItemStack(Blocks.STONE_SLAB, 1, BlockDoubleStepAbstract.EnumStoneSlabVariant.STONE.a())}); this.registerShapedRecipe(new ItemStack(Blocks.END_ROD, 4), new Object[] { "/", "#", Character.valueOf('/'), Items.BLAZE_ROD, Character.valueOf('#'), Items.CHORUS_FRUIT_POPPED}); this.registerShapedRecipe(new ItemStack(Blocks.di, 1), new Object[] { "XXX", "XXX", "XXX", Character.valueOf('X'), new ItemStack(Items.DYE, 1, EnumColor.WHITE.getInvColorIndex())}); @@ -36,7 +36,7 @@ do { if (!iterator.hasNext()) { + inventorycrafting.currentRecipe = null; // CraftBukkit - Clear recipe when no recipe is found - return null; + return ItemStack.a; } irecipe = (IRecipe) iterator.next(); @@ -50,4 +50,4 @@ + // CraftBukkit end } - public ItemStack[] b(InventoryCrafting inventorycrafting, World world) { + public NonNullList b(InventoryCrafting inventorycrafting, World world) { diff --git a/nms-patches/DedicatedServer.patch b/nms-patches/DedicatedServer.patch index d14694e7b5..dc698b697f 100644 --- a/nms-patches/DedicatedServer.patch +++ b/nms-patches/DedicatedServer.patch @@ -98,7 +98,7 @@ + thread.setDaemon(true); thread.start(); - DedicatedServer.LOGGER.info("Starting minecraft server version 1.10.2"); + DedicatedServer.LOGGER.info("Starting minecraft server version 1.11"); @@ -78,7 +125,7 @@ } @@ -108,7 +108,7 @@ this.r = new EULA(new File("eula.txt")); if (!this.r.a()) { DedicatedServer.LOGGER.info("You need to agree to the EULA in order to run the server. Go to eula.txt for more info."); -@@ -134,6 +181,8 @@ +@@ -135,6 +182,8 @@ return false; } @@ -117,7 +117,7 @@ if (!this.getOnlineMode()) { DedicatedServer.LOGGER.warn("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!"); DedicatedServer.LOGGER.warn("The server will make no attempt to authenticate usernames. Beware."); -@@ -148,7 +197,7 @@ +@@ -149,7 +198,7 @@ if (!NameReferencingFileConverter.a(this.propertyManager)) { return false; } else { @@ -126,7 +126,7 @@ long j = System.nanoTime(); if (this.S() == null) { -@@ -206,7 +255,18 @@ +@@ -207,7 +256,18 @@ DedicatedServer.LOGGER.info("Starting remote control listener"); this.p = new RemoteControlListener(this); this.p.a(); @@ -143,18 +143,9 @@ } + // CraftBukkit end - if (this.aP() > 0L) { + if (this.aQ() > 0L) { Thread thread1 = new Thread(new ThreadWatchdog(this)); -@@ -266,7 +326,7 @@ - return this.propertyManager.getBoolean("hardcore", false); - } - -- protected void a(CrashReport crashreport) {} -+ public void a(CrashReport crashreport) {} - - public CrashReport b(CrashReport crashreport) { - crashreport = super.b(crashreport); -@@ -293,11 +353,11 @@ +@@ -292,11 +352,11 @@ return crashreport; } @@ -166,9 +157,9 @@ - protected void D() { + public void D() { // CraftBukkit - fix decompile error super.D(); - this.aL(); + this.aM(); } -@@ -328,7 +388,15 @@ +@@ -327,7 +387,15 @@ while (!this.serverCommandQueue.isEmpty()) { ServerCommand servercommand = (ServerCommand) this.serverCommandQueue.remove(0); @@ -185,7 +176,7 @@ } } -@@ -535,16 +603,70 @@ +@@ -534,16 +602,70 @@ } public String getPlugins() { @@ -252,7 +243,7 @@ } public PlayerList getPlayerList() { - return this.aM(); + return this.aN(); } + + // CraftBukkit start diff --git a/nms-patches/DispenseBehaviorItem.patch b/nms-patches/DispenseBehaviorItem.patch index 61fe049e84..f325425fd2 100644 --- a/nms-patches/DispenseBehaviorItem.patch +++ b/nms-patches/DispenseBehaviorItem.patch @@ -18,7 +18,7 @@ - a(isourceblock.getWorld(), itemstack1, 6, enumdirection, iposition); + // CraftBukkit start + if (!a(isourceblock.getWorld(), itemstack1, 6, enumdirection, isourceblock)) { -+ itemstack.count++; ++ itemstack.add(1); + } + // CraftBukkit end return itemstack; diff --git a/nms-patches/DispenseBehaviorProjectile.patch b/nms-patches/DispenseBehaviorProjectile.patch index ecf2de1f5f..a7f5100e76 100644 --- a/nms-patches/DispenseBehaviorProjectile.patch +++ b/nms-patches/DispenseBehaviorProjectile.patch @@ -16,7 +16,7 @@ IProjectile iprojectile = this.a(world, iposition, itemstack); - iprojectile.shoot((double) enumdirection.getAdjacentX(), (double) ((float) enumdirection.getAdjacentY() + 0.1F), (double) enumdirection.getAdjacentZ(), this.getPower(), this.a()); -+ // iprojectile.shoot((double) enumdirection.getAdjacentX(), (double) ((float) enumdirection.getAdjacentY() + 0.1F), (double) enumdirection.getAdjacentZ(), this.b(), this.a()); ++ // iprojectile.shoot((double) enumdirection.getAdjacentX(), (double) ((float) enumdirection.getAdjacentY() + 0.1F), (double) enumdirection.getAdjacentZ(), this.getPower(), this.a()); + // CraftBukkit start + ItemStack itemstack1 = itemstack.cloneAndSubtract(1); + org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); @@ -28,12 +28,12 @@ + } + + if (event.isCancelled()) { -+ itemstack.count++; ++ itemstack.add(1); + return itemstack; + } + + if (!event.getItem().equals(craftItem)) { -+ itemstack.count++; ++ itemstack.add(1); + // Chain to handler for new item + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); @@ -47,8 +47,8 @@ + ((Entity) iprojectile).projectileSource = new org.bukkit.craftbukkit.projectiles.CraftBlockProjectileSource((TileEntityDispenser) isourceblock.getTileEntity()); + // CraftBukkit end world.addEntity((Entity) iprojectile); -- itemstack.cloneAndSubtract(1); -+ // itemstack.cloneAndSubtract(1); // CraftBukkit - Handled during event processing +- itemstack.subtract(1); ++ // itemstack.subtract(1); // CraftBukkit - Handled during event processing return itemstack; } diff --git a/nms-patches/DispenserRegistry.patch b/nms-patches/DispenserRegistry.patch index 35438f175e..c53ea44444 100644 --- a/nms-patches/DispenserRegistry.patch +++ b/nms-patches/DispenserRegistry.patch @@ -32,7 +32,7 @@ @@ -106,14 +111,46 @@ double d0 = isourceblock.getX() + (double) enumdirection.getAdjacentX(); - double d1 = (double) ((float) isourceblock.getBlockPosition().getY() + 0.2F); + double d1 = (double) ((float) (isourceblock.getBlockPosition().getY() + enumdirection.getAdjacentY()) + 0.2F); double d2 = isourceblock.getZ() + (double) enumdirection.getAdjacentZ(); - Entity entity = ItemMonsterEgg.a(isourceblock.getWorld(), ItemMonsterEgg.h(itemstack), d0, d1, d2); + // Entity entity = ItemMonsterEgg.a(isourceblock.getWorld(), ItemMonsterEgg.h(itemstack), d0, d1, d2); @@ -49,12 +49,12 @@ + } + + if (event.isCancelled()) { -+ itemstack.count++; ++ itemstack.add(1); + return itemstack; + } + + if (!event.getItem().equals(craftItem)) { -+ itemstack.count++; ++ itemstack.add(1); + // Chain to handler for new item + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); @@ -73,8 +73,8 @@ } ItemMonsterEgg.a(isourceblock.getWorld(), (EntityHuman) null, itemstack, entity); -- itemstack.cloneAndSubtract(1); -+ // itemstack.cloneAndSubtract(1);// Handled during event processing +- itemstack.subtract(1); ++ // itemstack.subtract(1);// Handled during event processing + // CraftBukkit end return itemstack; } @@ -96,12 +96,12 @@ + } + + if (event.isCancelled()) { -+ itemstack.count++; ++ itemstack.add(1); + return itemstack; + } + + if (!event.getItem().equals(craftItem)) { -+ itemstack.count++; ++ itemstack.add(1); + // Chain to handler for new item + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); @@ -115,8 +115,8 @@ + EntityFireworks entityfireworks = new EntityFireworks(isourceblock.getWorld(), event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), itemstack1); isourceblock.getWorld().addEntity(entityfireworks); -- itemstack.cloneAndSubtract(1); -+ // itemstack.cloneAndSubtract(1); // Handled during event processing +- itemstack.subtract(1); ++ // itemstack.subtract(1); // Handled during event processing + // CraftBukkit end return itemstack; } @@ -126,7 +126,7 @@ double d5 = random.nextGaussian() * 0.05D + (double) enumdirection.getAdjacentZ(); - world.addEntity(new EntitySmallFireball(world, d0, d1, d2, d3, d4, d5)); -- itemstack.cloneAndSubtract(1); +- itemstack.subtract(1); + // CraftBukkit start + ItemStack itemstack1 = itemstack.cloneAndSubtract(1); + org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); @@ -138,12 +138,12 @@ + } + + if (event.isCancelled()) { -+ itemstack.count++; ++ itemstack.add(1); + return itemstack; + } + + if (!event.getItem().equals(craftItem)) { -+ itemstack.count++; ++ itemstack.add(1); + // Chain to handler for new item + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); @@ -157,15 +157,16 @@ + fireball.projectileSource = new org.bukkit.craftbukkit.projectiles.CraftBlockProjectileSource((TileEntityDispenser) isourceblock.getTileEntity()); + + world.addEntity(fireball); -+ // itemstack.a(1); // Handled during event processing ++ // itemstack.subtract(1); // Handled during event processing + // CraftBukkit end return itemstack; } -@@ -169,9 +265,48 @@ +@@ -169,7 +265,53 @@ ItemBucket itembucket = (ItemBucket) itemstack.getItem(); BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.e().get(BlockDispenser.FACING)); +- return itembucket.a((EntityHuman) null, isourceblock.getWorld(), blockposition) ? new ItemStack(Items.BUCKET) : this.b.a(isourceblock, itemstack); + // CraftBukkit start + World world = isourceblock.getWorld(); + int x = blockposition.getX(); @@ -198,22 +199,25 @@ + } + // CraftBukkit end + - if (itembucket.a((EntityHuman) null, isourceblock.getWorld(), blockposition)) { -- itemstack.setItem(Items.BUCKET); -- itemstack.count = 1; ++ if (itembucket.a((EntityHuman) null, isourceblock.getWorld(), blockposition)) { + // CraftBukkit start - Handle stacked buckets + Item item = Items.BUCKET; -+ if (--itemstack.count == 0) { ++ itemstack.subtract(1); ++ if (itemstack.isEmpty()) { + itemstack.setItem(Items.BUCKET); -+ itemstack.count = 1; ++ itemstack.setCount(1); + } else if (((TileEntityDispenser) isourceblock.getTileEntity()).addItem(new ItemStack(item)) < 0) { + this.b.a(isourceblock, new ItemStack(item)); + } + // CraftBukkit end - return itemstack; - } else { - return this.b.a(isourceblock, itemstack); -@@ -202,6 +337,30 @@ ++ return itemstack; ++ } else { ++ return this.b.a(isourceblock, itemstack); ++ } + } + }; + +@@ -196,6 +338,30 @@ item = Items.LAVA_BUCKET; } @@ -242,11 +246,11 @@ + // CraftBukkit end + world.setAir(blockposition); - if (--itemstack.count == 0) { - itemstack.setItem(item); -@@ -220,11 +379,39 @@ + itemstack.subtract(1); + if (itemstack.isEmpty()) { +@@ -213,14 +379,42 @@ + protected ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) { World world = isourceblock.getWorld(); - BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.e().get(BlockDispenser.FACING)); + // CraftBukkit start + org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); @@ -272,22 +276,25 @@ + } + // CraftBukkit end + + this.b = true; + BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.e().get(BlockDispenser.FACING)); + if (world.isEmpty(blockposition)) { - world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData()); - if (itemstack.isDamaged(1, world.random)) { -- itemstack.count = 0; +- itemstack.setCount(0); + // CraftBukkit start - Ignition by dispensing flint and steel + if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()).isCancelled()) { + world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData()); + if (itemstack.isDamaged(1, world.random)) { -+ itemstack.count = 0; ++ itemstack.setCount(0); + } } + // CraftBukkit end } else if (world.getType(blockposition).getBlock() == Blocks.TNT) { Blocks.TNT.postBreak(world, blockposition, Blocks.TNT.getBlockData().set(BlockTNT.EXPLODE, Boolean.valueOf(true))); world.setAir(blockposition); -@@ -252,6 +439,30 @@ +@@ -238,6 +432,30 @@ World world = isourceblock.getWorld(); BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.e().get(BlockDispenser.FACING)); @@ -318,7 +325,7 @@ if (ItemDye.a(itemstack, world, blockposition)) { if (!world.isClientSide) { world.triggerEffect(2005, blockposition, 0); -@@ -279,11 +490,40 @@ +@@ -256,11 +474,40 @@ protected ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) { World world = isourceblock.getWorld(); BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.e().get(BlockDispenser.FACING)); @@ -336,12 +343,12 @@ + } + + if (event.isCancelled()) { -+ itemstack.count++; ++ itemstack.add(1); + return itemstack; + } + + if (!event.getItem().equals(craftItem)) { -+ itemstack.count++; ++ itemstack.add(1); + // Chain to handler for new item + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); @@ -355,13 +362,13 @@ + // CraftBukkit end world.addEntity(entitytntprimed); - world.a((EntityHuman) null, entitytntprimed.locX, entitytntprimed.locY, entitytntprimed.locZ, SoundEffects.gz, SoundCategory.BLOCKS, 1.0F, 1.0F); -- --itemstack.count; -+ // --itemstack.count; // CraftBukkit - handled above + world.a((EntityHuman) null, entitytntprimed.locX, entitytntprimed.locY, entitytntprimed.locZ, SoundEffects.gV, SoundCategory.BLOCKS, 1.0F, 1.0F); +- itemstack.subtract(1); ++ // itemstack.subtract(1); // CraftBukkit - handled above return itemstack; } }); -@@ -296,6 +536,30 @@ +@@ -271,6 +518,30 @@ BlockPosition blockposition = isourceblock.getBlockPosition().shift(enumdirection); BlockSkull blockskull = Blocks.SKULL; @@ -389,10 +396,10 @@ + } + // CraftBukkit end + + this.b = true; if (world.isEmpty(blockposition) && blockskull.b(world, blockposition, itemstack)) { if (!world.isClientSide) { - world.setTypeAndData(blockposition, blockskull.getBlockData().set(BlockSkull.FACING, EnumDirection.UP), 3); -@@ -354,6 +618,30 @@ +@@ -319,6 +590,30 @@ BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.e().get(BlockDispenser.FACING)); BlockPumpkin blockpumpkin = (BlockPumpkin) Blocks.PUMPKIN; @@ -420,10 +427,10 @@ + } + // CraftBukkit end + + this.b = true; if (world.isEmpty(blockposition) && blockpumpkin.b(world, blockposition)) { if (!world.isClientSide) { - world.setTypeAndData(blockposition, blockpumpkin.getBlockData(), 3); -@@ -437,12 +725,40 @@ +@@ -456,12 +751,40 @@ d3 = 0.0D; } @@ -440,12 +447,12 @@ + } + + if (event.isCancelled()) { -+ itemstack.count++; ++ itemstack.add(1); + return itemstack; + } + + if (!event.getItem().equals(craftItem)) { -+ itemstack.count++; ++ itemstack.add(1); + // Chain to handler for new item + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); @@ -459,10 +466,10 @@ + // CraftBukkit end entityboat.setType(this.c); - entityboat.yaw = enumdirection.opposite().l(); + entityboat.yaw = enumdirection.l(); world.addEntity(entityboat); -- itemstack.cloneAndSubtract(1); -+ // itemstack.cloneAndSubtract(1); // CraftBukkit - handled during event processing +- itemstack.subtract(1); ++ // itemstack.subtract(1); // CraftBukkit - handled during event processing return itemstack; } diff --git a/nms-patches/Enchantment.patch b/nms-patches/Enchantment.patch index e339cfd62e..0f15da1de1 100644 --- a/nms-patches/Enchantment.patch +++ b/nms-patches/Enchantment.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/Enchantment.java +++ b/net/minecraft/server/Enchantment.java -@@ -18,7 +18,7 @@ +@@ -19,7 +19,7 @@ } public static int getId(Enchantment enchantment) { @@ -9,10 +9,10 @@ } @Nullable -@@ -139,6 +139,11 @@ - Enchantment.enchantments.a(61, new MinecraftKey("luck_of_the_sea"), new EnchantmentLootBonus(Enchantment.Rarity.RARE, EnchantmentSlotType.FISHING_ROD, new EnumItemSlot[] { EnumItemSlot.MAINHAND})); +@@ -149,6 +149,11 @@ Enchantment.enchantments.a(62, new MinecraftKey("lure"), new EnchantmentLure(Enchantment.Rarity.RARE, EnchantmentSlotType.FISHING_ROD, new EnumItemSlot[] { EnumItemSlot.MAINHAND})); Enchantment.enchantments.a(70, new MinecraftKey("mending"), new EnchantmentMending(Enchantment.Rarity.RARE, EnumItemSlot.values())); + Enchantment.enchantments.a(71, new MinecraftKey("vanishing_curse"), new EnchantmentVanishing(Enchantment.Rarity.VERY_RARE, EnumItemSlot.values())); + // CraftBukkit start + for (Object enchantment : Enchantment.enchantments) { + org.bukkit.enchantments.Enchantment.registerEnchantment(new org.bukkit.craftbukkit.enchantments.CraftEnchantment((Enchantment) enchantment)); diff --git a/nms-patches/EnchantmentFrostWalker.patch b/nms-patches/EnchantmentFrostWalker.patch index 2078780da0..91fda45bf2 100644 --- a/nms-patches/EnchantmentFrostWalker.patch +++ b/nms-patches/EnchantmentFrostWalker.patch @@ -12,7 +12,7 @@ @@ -42,8 +45,18 @@ IBlockData iblockdata1 = world.getType(blockposition_mutableblockposition1); - if (iblockdata1.getMaterial() == Material.WATER && ((Integer) iblockdata1.get(BlockFluids.LEVEL)).intValue() == 0 && world.a(Blocks.FROSTED_ICE, blockposition_mutableblockposition1, false, EnumDirection.DOWN, (Entity) null, (ItemStack) null)) { + if (iblockdata1.getMaterial() == Material.WATER && ((Integer) iblockdata1.get(BlockFluids.LEVEL)).intValue() == 0 && world.a(Blocks.FROSTED_ICE, blockposition_mutableblockposition1, false, EnumDirection.DOWN, (Entity) null)) { - world.setTypeUpdate(blockposition_mutableblockposition1, Blocks.FROSTED_ICE.getBlockData()); - world.a(blockposition_mutableblockposition1.h(), Blocks.FROSTED_ICE, MathHelper.nextInt(entityliving.getRandom(), 60, 120)); + // CraftBukkit Start - Call EntityBlockFormEvent for Frost Walker diff --git a/nms-patches/Entity.patch b/nms-patches/Entity.patch index fdbdb8b0b9..e42369558c 100644 --- a/nms-patches/Entity.patch +++ b/nms-patches/Entity.patch @@ -47,19 +47,19 @@ + // CraftBukikt end + private static final Logger a = LogManager.getLogger(); - private static final AxisAlignedBB b = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D); - private static double c = 1.0D; -@@ -99,6 +139,9 @@ + private static final List b = Collections.emptyList(); + private static final AxisAlignedBB c = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D); +@@ -98,6 +138,9 @@ public boolean glowing; - private final Set aH; - private boolean aI; + private final Set aG; + private boolean aH; + public boolean valid; // CraftBukkit + public org.bukkit.projectiles.ProjectileSource projectileSource; // CraftBukkit - For projectiles only + public boolean forceExplosionKnockback; // CraftBukkit - SPIGOT-949 public Entity(World world) { this.id = Entity.entityCount++; -@@ -197,6 +240,33 @@ +@@ -202,6 +245,33 @@ } protected void setYawPitch(float f, float f1) { @@ -93,8 +93,8 @@ this.yaw = f % 360.0F; this.pitch = f1 % 360.0F; } -@@ -240,7 +310,7 @@ - if (this.al) { +@@ -245,7 +315,7 @@ + if (this.ak) { MinecraftServer minecraftserver = this.world.getMinecraftServer(); - if (minecraftserver.getAllowNether()) { @@ -102,7 +102,7 @@ if (!this.isPassenger()) { int i = this.V(); -@@ -325,6 +395,27 @@ +@@ -330,6 +400,27 @@ protected void burnFromLava() { if (!this.fireProof) { this.damageEntity(DamageSource.LAVA, 4.0F); @@ -130,8 +130,8 @@ this.setOnFire(15); } } -@@ -365,6 +456,22 @@ - this.a(this.getBoundingBox().c(d0, d1, d2)); +@@ -370,6 +461,22 @@ + this.a(this.getBoundingBox().d(d0, d1, d2)); this.recalcPosition(); } else { + // CraftBukkit start - Don't do anything if we aren't moving @@ -153,7 +153,25 @@ this.world.methodProfiler.a("move"); double d3 = this.locX; double d4 = this.locY; -@@ -587,6 +694,28 @@ +@@ -470,7 +577,7 @@ + } + } + +- boolean flag1 = this.onGround || d1 != d1 && d1 < 0.0D; ++ boolean flag1 = this.onGround || d1 != d7 && d1 < 0.0D; // CraftBukkit - decompile error + double d10; + + if (this.P > 0.0F && flag1 && (d6 != d0 || d8 != d2)) { +@@ -568,7 +675,7 @@ + this.world.methodProfiler.a("rest"); + this.recalcPosition(); + this.positionChanged = d6 != d0 || d8 != d2; +- this.B = d1 != d1; ++ this.B = d1 != d7; // CraftBukkit - decompile error + this.onGround = this.B && d7 < 0.0D; + this.C = this.positionChanged || this.B; + j = MathHelper.floor(this.locX); +@@ -603,6 +710,28 @@ block1.a(this.world, this); } @@ -182,7 +200,7 @@ if (this.playStepSound() && !flag && !this.isPassenger()) { double d21 = this.locX - d3; double d22 = this.locY - d4; -@@ -618,6 +747,8 @@ +@@ -634,6 +763,8 @@ } } @@ -191,7 +209,7 @@ try { this.checkBlockCollisions(); } catch (Throwable throwable) { -@@ -627,6 +758,8 @@ +@@ -643,6 +774,8 @@ this.appendEntityCrashDetails(crashreportsystemdetails); throw new ReportedException(crashreport); } @@ -200,7 +218,7 @@ boolean flag2 = this.ai(); -@@ -635,7 +768,14 @@ +@@ -651,7 +784,14 @@ if (!flag2) { ++this.fireTicks; if (this.fireTicks == 0) { @@ -216,7 +234,7 @@ } } } else if (this.fireTicks <= 0) { -@@ -756,7 +896,7 @@ +@@ -772,7 +912,7 @@ return null; } @@ -225,7 +243,7 @@ if (!this.fireProof) { this.damageEntity(DamageSource.FIRE, (float) i); } -@@ -922,6 +1062,13 @@ +@@ -938,6 +1078,13 @@ } public void spawnIn(World world) { @@ -239,7 +257,7 @@ this.world = world; } -@@ -1126,6 +1273,18 @@ +@@ -1170,6 +1317,18 @@ try { nbttagcompound.set("Pos", this.a(new double[] { this.locX, this.locY, this.locZ})); nbttagcompound.set("Motion", this.a(new double[] { this.motX, this.motY, this.motZ})); @@ -258,7 +276,7 @@ nbttagcompound.set("Rotation", this.a(new float[] { this.yaw, this.pitch})); nbttagcompound.setFloat("FallDistance", this.fallDistance); nbttagcompound.setShort("Fire", (short) this.fireTicks); -@@ -1135,6 +1294,12 @@ +@@ -1179,6 +1338,12 @@ nbttagcompound.setBoolean("Invulnerable", this.invulnerable); nbttagcompound.setInt("PortalCooldown", this.portalCooldown); nbttagcompound.a("UUID", this.getUniqueID()); @@ -268,10 +286,10 @@ + nbttagcompound.setLong("WorldUUIDMost", this.world.getDataManager().getUUID().getMostSignificantBits()); + nbttagcompound.setInt("Bukkit.updateLevel", CURRENT_LEVEL); + // CraftBukkit end - if (this.getCustomName() != null && !this.getCustomName().isEmpty()) { + if (this.hasCustomName()) { nbttagcompound.setString("CustomName", this.getCustomName()); } -@@ -1210,6 +1375,8 @@ +@@ -1254,6 +1419,8 @@ this.motX = nbttaglist1.e(0); this.motY = nbttaglist1.e(1); this.motZ = nbttaglist1.e(2); @@ -280,7 +298,7 @@ if (Math.abs(this.motX) > 10.0D) { this.motX = 0.0D; } -@@ -1221,6 +1388,7 @@ +@@ -1265,6 +1432,7 @@ if (Math.abs(this.motZ) > 10.0D) { this.motZ = 0.0D; } @@ -288,7 +306,7 @@ this.locX = nbttaglist.e(0); this.locY = nbttaglist.e(1); -@@ -1278,6 +1446,58 @@ +@@ -1322,6 +1490,58 @@ this.setPosition(this.locX, this.locY, this.locZ); } @@ -347,10 +365,10 @@ } catch (Throwable throwable) { CrashReport crashreport = CrashReport.a(throwable, "Loading entity NBT"); CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Entity being loaded"); -@@ -1337,6 +1557,12 @@ - - public EntityItem a(ItemStack itemstack, float f) { - if (itemstack.count != 0 && itemstack.getItem() != null) { +@@ -1389,6 +1609,12 @@ + if (itemstack.isEmpty()) { + return null; + } else { + // CraftBukkit start - Capture drops for death event + if (this instanceof EntityLiving && !((EntityLiving) this).forceDrops) { + ((EntityLiving) this).drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemstack)); @@ -360,7 +378,7 @@ EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY + (double) f, this.locZ, itemstack); entityitem.q(); -@@ -1458,6 +1684,24 @@ +@@ -1514,6 +1740,24 @@ if (entity.bB() != this) { throw new IllegalStateException("Use x.startRiding(y), not y.addPassenger(x)"); } else { @@ -385,7 +403,7 @@ if (!this.world.isClientSide && entity instanceof EntityHuman && !(this.bw() instanceof EntityHuman)) { this.passengers.add(0, entity); } else { -@@ -1471,6 +1715,22 @@ +@@ -1527,6 +1771,22 @@ if (entity.bB() == this) { throw new IllegalStateException("Use x.stopRiding(y), not y.removePassenger(x)"); } else { @@ -408,7 +426,7 @@ this.passengers.remove(entity); entity.j = 60; } -@@ -1610,14 +1870,48 @@ +@@ -1666,14 +1926,48 @@ } public void setAirTicks(int i) { @@ -460,10 +478,10 @@ } } -@@ -1752,19 +2046,67 @@ +@@ -1818,19 +2112,67 @@ if (!this.world.isClientSide && !this.dead) { this.world.methodProfiler.a("changeDimension"); - MinecraftServer minecraftserver = this.h(); + MinecraftServer minecraftserver = this.B_(); - int j = this.dimension; - WorldServer worldserver = minecraftserver.getWorldServer(j); - WorldServer worldserver1 = minecraftserver.getWorldServer(i); @@ -531,7 +549,7 @@ BlockPosition blockposition; if (i == 1) { -@@ -1793,12 +2135,18 @@ +@@ -1859,12 +2201,18 @@ blockposition = new BlockPosition(this); } @@ -543,7 +561,7 @@ + // worldserver.entityJoinedWorld(this, false); // Handled in repositionEntity + // CraftBukkit end this.world.methodProfiler.c("reloading"); - Entity entity = EntityTypes.createEntityByName(EntityTypes.b(this), worldserver1); + Entity entity = EntityTypes.a(this.getClass(), (World) worldserver1); if (entity != null) { entity.a(this); @@ -551,7 +569,7 @@ if (j == 1 && i == 1) { BlockPosition blockposition1 = worldserver1.q(worldserver1.getSpawn()); -@@ -1806,6 +2154,7 @@ +@@ -1872,6 +2220,7 @@ } else { entity.setPositionRotation(blockposition, entity.yaw, entity.pitch); } @@ -559,7 +577,7 @@ boolean flag = entity.attachedToPlayer; -@@ -1813,6 +2162,14 @@ +@@ -1879,6 +2228,14 @@ worldserver1.addEntity(entity); entity.attachedToPlayer = flag; worldserver1.entityJoinedWorld(entity, false); @@ -574,7 +592,7 @@ } this.dead = true; -@@ -1923,6 +2280,11 @@ +@@ -1989,6 +2346,11 @@ } public void setCustomName(String s) { @@ -586,7 +604,7 @@ this.datawatcher.set(Entity.aA, s); } -@@ -1980,7 +2342,26 @@ +@@ -2046,7 +2408,26 @@ } public void a(AxisAlignedBB axisalignedbb) { @@ -614,7 +632,7 @@ } public float getHeadHeight() { -@@ -2154,7 +2535,7 @@ +@@ -2220,7 +2601,7 @@ for (Iterator iterator = this.bx().iterator(); iterator.hasNext(); entity.a(oclass, set)) { entity = (Entity) iterator.next(); if (oclass.isAssignableFrom(entity.getClass())) { diff --git a/nms-patches/EntityAgeable.patch b/nms-patches/EntityAgeable.patch index 5a95ae6bcc..5982edfc1e 100644 --- a/nms-patches/EntityAgeable.patch +++ b/nms-patches/EntityAgeable.patch @@ -2,13 +2,13 @@ +++ b/net/minecraft/server/EntityAgeable.java @@ -10,6 +10,7 @@ protected int c; - private float by = -1.0F; - private float bz; + private float bx = -1.0F; + private float by; + public boolean ageLocked; // CraftBukkit public EntityAgeable(World world) { super(world); -@@ -28,13 +29,18 @@ +@@ -31,7 +32,7 @@ if (entityageable != null) { entityageable.setAgeRaw(-24000); entityageable.setPositionRotation(this.locX, this.locY, this.locZ, 0.0F, 0.0F); @@ -17,18 +17,7 @@ if (itemstack.hasName()) { entityageable.setCustomName(itemstack.getName()); } - - if (!entityhuman.abilities.canInstantlyBuild) { - --itemstack.count; -+ // CraftBukkit start - allow less than 0 stacks as "infinite" -+ if (itemstack.count == 0) { -+ entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, (ItemStack) null); -+ } -+ // CraftBukkit end - } - } - } -@@ -97,12 +103,14 @@ +@@ -110,12 +111,14 @@ super.b(nbttagcompound); nbttagcompound.setInt("Age", this.getAge()); nbttagcompound.setInt("ForcedAge", this.b); @@ -43,7 +32,7 @@ } public void a(DataWatcherObject datawatcherobject) { -@@ -115,7 +123,7 @@ +@@ -128,7 +131,7 @@ public void n() { super.n(); diff --git a/nms-patches/EntityAnimal.patch b/nms-patches/EntityAnimal.patch index 03998da232..4661feccf6 100644 --- a/nms-patches/EntityAnimal.patch +++ b/nms-patches/EntityAnimal.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/server/EntityAnimal.java +++ b/net/minecraft/server/EntityAnimal.java -@@ -7,6 +7,7 @@ - protected Block bA; - private int bx; - private EntityHuman by; +@@ -5,6 +5,7 @@ + protected Block bz; + private int bw; + private EntityHuman bx; + public ItemStack breedItem; // CraftBukkit - Add breedItem variable public EntityAnimal(World world) { super(world); -@@ -40,6 +41,9 @@ +@@ -38,6 +39,9 @@ } @@ -18,18 +18,18 @@ public boolean damageEntity(DamageSource damagesource, float f) { if (this.isInvulnerable(damagesource)) { return false; -@@ -48,6 +52,7 @@ +@@ -46,6 +50,7 @@ return super.damageEntity(damagesource, f); } } + // CraftBukkit end */ public float a(BlockPosition blockposition) { - return this.world.getType(blockposition.down()).getBlock() == Blocks.GRASS ? 10.0F : this.world.n(blockposition) - 0.5F; + return this.world.getType(blockposition.down()).getBlock() == this.bz ? 10.0F : this.world.n(blockposition) - 0.5F; @@ -120,6 +125,7 @@ public void c(EntityHuman entityhuman) { - this.bx = 600; - this.by = entityhuman; + this.bw = 600; + this.bx = entityhuman; + this.breedItem = entityhuman.inventory.getItemInHand(); // CraftBukkit this.world.broadcastEntityEffect(this, (byte) 18); } diff --git a/nms-patches/EntityAreaEffectCloud.patch b/nms-patches/EntityAreaEffectCloud.patch index 2125291710..c5009a553f 100644 --- a/nms-patches/EntityAreaEffectCloud.patch +++ b/nms-patches/EntityAreaEffectCloud.patch @@ -11,7 +11,7 @@ import java.util.Map.Entry; import javax.annotation.Nullable; -@@ -96,6 +100,22 @@ +@@ -101,6 +105,22 @@ } @@ -34,7 +34,7 @@ public int getColor() { return ((Integer) this.getDataWatcher().get(EntityAreaEffectCloud.b)).intValue(); } -@@ -265,6 +285,7 @@ +@@ -270,6 +290,7 @@ if (!list.isEmpty()) { Iterator iterator2 = list.iterator(); @@ -42,7 +42,7 @@ while (iterator2.hasNext()) { EntityLiving entityliving = (EntityLiving) iterator2.next(); -@@ -274,6 +295,17 @@ +@@ -279,6 +300,17 @@ double d2 = d0 * d0 + d1 * d1; if (d2 <= (double) (f * f)) { @@ -57,6 +57,6 @@ + if (entity instanceof CraftLivingEntity) { + EntityLiving entityliving = ((CraftLivingEntity) entity).getHandle(); + // CraftBukkit end - this.au.put(entityliving, Integer.valueOf(this.ticksLived + this.reapplicationDelay)); + this.at.put(entityliving, Integer.valueOf(this.ticksLived + this.reapplicationDelay)); Iterator iterator3 = arraylist.iterator(); diff --git a/nms-patches/EntityArmorStand.patch b/nms-patches/EntityArmorStand.patch index 9e7ef90b8a..2f17e36f2d 100644 --- a/nms-patches/EntityArmorStand.patch +++ b/nms-patches/EntityArmorStand.patch @@ -15,10 +15,10 @@ + public class EntityArmorStand extends EntityLiving { - private static final Vector3f br = new Vector3f(0.0F, 0.0F, 0.0F); -@@ -373,6 +382,21 @@ - if (itemstack1 == null || (this.bB & 1 << enumitemslot.c() + 8) == 0) { - if (itemstack1 != null || (this.bB & 1 << enumitemslot.c() + 16) == 0) { + private static final Vector3f bq = new Vector3f(0.0F, 0.0F, 0.0F); +@@ -364,6 +373,21 @@ + if (itemstack1.isEmpty() || (this.bA & 1 << enumitemslot.c() + 8) == 0) { + if (!itemstack1.isEmpty() || (this.bA & 1 << enumitemslot.c() + 16) == 0) { ItemStack itemstack2; + // CraftBukkit start + org.bukkit.inventory.ItemStack armorStandItem = CraftItemStack.asCraftMirror(itemstack1); @@ -36,9 +36,9 @@ + } + // CraftBukkit end - if (entityhuman.abilities.canInstantlyBuild && (itemstack1 == null || itemstack1.getItem() == Item.getItemOf(Blocks.AIR)) && itemstack != null) { + if (entityhuman.abilities.canInstantlyBuild && itemstack1.isEmpty() && !itemstack.isEmpty()) { itemstack2 = itemstack.cloneItemStack(); -@@ -394,6 +418,11 @@ +@@ -385,6 +409,11 @@ } public boolean damageEntity(DamageSource damagesource, float f) { diff --git a/nms-patches/EntityArrow.patch b/nms-patches/EntityArrow.patch index ef051dd026..f8c15319f1 100644 --- a/nms-patches/EntityArrow.patch +++ b/nms-patches/EntityArrow.patch @@ -1,19 +1,20 @@ --- a/net/minecraft/server/EntityArrow.java +++ b/net/minecraft/server/EntityArrow.java -@@ -5,6 +5,12 @@ +@@ -5,6 +5,13 @@ import java.util.List; import javax.annotation.Nullable; +// CraftBukkit start +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityCombustByEntityEvent; ++import org.bukkit.event.entity.EntityCombustEvent; +import org.bukkit.event.player.PlayerPickupArrowEvent; +// CraftBukkit end + public abstract class EntityArrow extends Entity implements IProjectile { private static final Predicate f = Predicates.and(new Predicate[] { IEntitySelector.e, IEntitySelector.a, new Predicate() { -@@ -50,6 +56,7 @@ +@@ -50,6 +57,7 @@ public EntityArrow(World world, EntityLiving entityliving) { this(world, entityliving.locX, entityliving.locY + (double) entityliving.getHeadHeight() - 0.10000000149011612D, entityliving.locZ); this.shooter = entityliving; @@ -21,7 +22,7 @@ if (entityliving instanceof EntityHuman) { this.fromPlayer = EntityArrow.PickupStatus.ALLOWED; } -@@ -236,7 +243,7 @@ +@@ -236,7 +244,7 @@ protected void a(MovingObjectPosition movingobjectposition) { Entity entity = movingobjectposition.entity; @@ -30,7 +31,7 @@ if (entity != null) { float f = MathHelper.sqrt(this.motX * this.motX + this.motY * this.motY + this.motZ * this.motZ); int i = MathHelper.f((double) f * this.damage); -@@ -254,7 +261,13 @@ +@@ -254,7 +262,13 @@ } if (this.isBurning() && !(entity instanceof EntityEnderman)) { @@ -45,7 +46,7 @@ } if (entity.damageEntity(damagesource, (float) i)) { -@@ -410,6 +423,20 @@ +@@ -422,6 +436,20 @@ public void d(EntityHuman entityhuman) { if (!this.world.isClientSide && this.inGround && this.shake <= 0) { @@ -66,16 +67,19 @@ boolean flag = this.fromPlayer == EntityArrow.PickupStatus.ALLOWED || this.fromPlayer == EntityArrow.PickupStatus.CREATIVE_ONLY && entityhuman.abilities.canInstantlyBuild; if (this.fromPlayer == EntityArrow.PickupStatus.ALLOWED && !entityhuman.inventory.pickup(this.j())) { -@@ -468,6 +495,12 @@ - return (b0 & 1) != 0; - } +@@ -493,7 +521,14 @@ + } -+ // CraftBukkit start -+ public boolean isInGround() { -+ return inGround; -+ } -+ // CraftBukkit end + if (EnchantmentManager.a(Enchantments.ARROW_FIRE, entityliving) > 0) { +- this.setOnFire(100); ++ // CraftBukkit start - call EntityCombustEvent ++ EntityCombustEvent event = new EntityCombustEvent(this.getBukkitEntity(), 100); ++ this.world.getServer().getPluginManager().callEvent(event); + - public static enum PickupStatus { ++ if (!event.isCancelled()) { ++ this.setOnFire(event.getDuration()); ++ } ++ // CraftBukkit end + } - DISALLOWED, ALLOWED, CREATIVE_ONLY; + } diff --git a/nms-patches/EntityBoat.patch b/nms-patches/EntityBoat.patch index 3ae4271f82..474b0a4260 100644 --- a/nms-patches/EntityBoat.patch +++ b/nms-patches/EntityBoat.patch @@ -17,8 +17,8 @@ private static final DataWatcherObject a = DataWatcher.a(EntityBoat.class, DataWatcherRegistry.b); @@ -32,6 +41,14 @@ - private EntityBoat.EnumStatus aI; - private double aJ; + private EntityBoat.EnumStatus aH; + private double aI; + // CraftBukkit start + // PAIL: Some of these haven't worked since a few updates, and since 1.9 they are less and less applicable. @@ -101,16 +101,15 @@ super.collide(entity); } -@@ -158,6 +214,8 @@ +@@ -158,6 +214,7 @@ return this.getDirection().e(); } + private Location lastLocation; // CraftBukkit -+ - public void m() { - this.aI = this.aH; - this.aH = this.t(); -@@ -178,7 +236,6 @@ + public void A_() { + this.aH = this.aG; + this.aG = this.t(); +@@ -178,7 +235,6 @@ if (this.n() > 0.0F) { this.setDamage(this.n() - 1.0F); } @@ -118,7 +117,7 @@ this.lastX = this.locX; this.lastY = this.locY; this.lastZ = this.locZ; -@@ -202,6 +259,22 @@ +@@ -202,6 +258,22 @@ this.motZ = 0.0D; } @@ -141,7 +140,7 @@ for (int i = 0; i <= 1; ++i) { if (this.a(i)) { this.f[i] = (float) ((double) this.f[i] + 0.01D); -@@ -599,6 +672,11 @@ +@@ -593,6 +665,11 @@ this.e(this.fallDistance, 1.0F); if (!this.world.isClientSide && !this.dead) { @@ -153,7 +152,7 @@ this.die(); if (this.world.getGameRules().getBoolean("doEntityDrops")) { int i; -@@ -612,6 +690,7 @@ +@@ -606,6 +683,7 @@ } } } diff --git a/nms-patches/EntityChicken.patch b/nms-patches/EntityChicken.patch index 2dd746a413..c498decfb0 100644 --- a/nms-patches/EntityChicken.patch +++ b/nms-patches/EntityChicken.patch @@ -10,15 +10,15 @@ + } + // CraftBukkit end super.n(); - this.bB = this.bx; - this.bz = this.by; + this.bA = this.bw; + this.by = this.bx; @@ -61,7 +66,9 @@ - this.bx += this.bC * 2.0F; - if (!this.world.isClientSide && !this.isBaby() && !this.isChickenJockey() && --this.bD <= 0) { - this.a(SoundEffects.aa, 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); + this.bw += this.bB * 2.0F; + if (!this.world.isClientSide && !this.isBaby() && !this.isChickenJockey() && --this.bC <= 0) { + this.a(SoundEffects.ac, 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); + this.forceDrops = true; // CraftBukkit this.a(Items.EGG, 1); + this.forceDrops = false; // CraftBukkit - this.bD = this.random.nextInt(6000) + 6000; + this.bC = this.random.nextInt(6000) + 6000; } diff --git a/nms-patches/EntityCow.patch b/nms-patches/EntityCow.patch index 1593b85b4c..c231dfd81e 100644 --- a/nms-patches/EntityCow.patch +++ b/nms-patches/EntityCow.patch @@ -11,10 +11,10 @@ public class EntityCow extends EntityAnimal { -@@ -57,12 +61,22 @@ +@@ -59,13 +63,23 @@ + ItemStack itemstack = entityhuman.b(enumhand); - public boolean a(EntityHuman entityhuman, EnumHand enumhand, @Nullable ItemStack itemstack) { - if (itemstack != null && itemstack.getItem() == Items.BUCKET && !entityhuman.abilities.canInstantlyBuild && !this.isBaby()) { + if (itemstack.getItem() == Items.BUCKET && !entityhuman.abilities.canInstantlyBuild && !this.isBaby()) { + // CraftBukkit start - Got milk? + org.bukkit.Location loc = this.getBukkitEntity().getLocation(); + org.bukkit.event.player.PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent(entityhuman, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), null, itemstack, Items.MILK_BUCKET); @@ -24,12 +24,12 @@ + } + + ItemStack result = CraftItemStack.asNMSCopy(event.getItemStack()); - entityhuman.a(SoundEffects.ap, 1.0F, 1.0F); -- if (--itemstack.count == 0) { + entityhuman.a(SoundEffects.ar, 1.0F, 1.0F); + itemstack.subtract(1); + if (itemstack.isEmpty()) { - entityhuman.a(enumhand, new ItemStack(Items.MILK_BUCKET)); - } else if (!entityhuman.inventory.pickup(new ItemStack(Items.MILK_BUCKET))) { - entityhuman.drop(new ItemStack(Items.MILK_BUCKET), false); -+ if (--itemstack.count <= 0) { + entityhuman.a(enumhand, result); + } else if (!entityhuman.inventory.pickup(result)) { + entityhuman.drop(result, false); diff --git a/nms-patches/EntityCreature.patch b/nms-patches/EntityCreature.patch index 724b55d234..4d141b8f72 100644 --- a/nms-patches/EntityCreature.patch +++ b/nms-patches/EntityCreature.patch @@ -10,8 +10,8 @@ + public abstract class EntityCreature extends EntityInsentient { - public static final UUID bv = UUID.fromString("E199AD21-BA8A-4C53-8D13-6182D5C69D3A"); -@@ -71,6 +75,7 @@ + public static final UUID bu = UUID.fromString("E199AD21-BA8A-4C53-8D13-6182D5C69D3A"); +@@ -68,6 +72,7 @@ if (this instanceof EntityTameableAnimal && ((EntityTameableAnimal) this).isSitting()) { if (f > 10.0F) { @@ -19,11 +19,11 @@ this.unleash(true, true); } -@@ -103,6 +108,7 @@ - } +@@ -76,6 +81,7 @@ + this.q(f); if (f > 10.0F) { + this.world.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE)); // CraftBukkit this.unleash(true, true); - } - } else if (!this.isLeashed() && this.bx) { + this.goalSelector.c(1); + } else if (f > 6.0F) { diff --git a/nms-patches/EntityCreeper.patch b/nms-patches/EntityCreeper.patch index 9f413e379e..853db77e31 100644 --- a/nms-patches/EntityCreeper.patch +++ b/nms-patches/EntityCreeper.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/EntityCreeper.java +++ b/net/minecraft/server/EntityCreeper.java -@@ -1,6 +1,10 @@ - package net.minecraft.server; - +@@ -3,6 +3,10 @@ + import java.util.Collection; + import java.util.Iterator; import javax.annotation.Nullable; +// CraftBukkit start +import org.bukkit.craftbukkit.event.CraftEventFactory; @@ -11,7 +11,7 @@ public class EntityCreeper extends EntityMonster { -@@ -123,7 +127,7 @@ +@@ -125,7 +129,7 @@ } public void die(DamageSource damagesource) { @@ -20,7 +20,7 @@ if (this.world.getGameRules().getBoolean("doMobLoot")) { if (damagesource.getEntity() instanceof EntitySkeleton) { int i = Item.getId(Items.RECORD_13); -@@ -136,6 +140,7 @@ +@@ -138,6 +142,7 @@ this.a(new ItemStack(Items.SKULL, 1, 4), 0.0F); } } @@ -28,7 +28,7 @@ } -@@ -162,9 +167,19 @@ +@@ -164,9 +169,19 @@ public void onLightningStrike(EntityLightning entitylightning) { super.onLightningStrike(entitylightning); @@ -46,23 +46,25 @@ + } + // CraftBukkit end + - protected boolean a(EntityHuman entityhuman, EnumHand enumhand, @Nullable ItemStack itemstack) { - if (itemstack != null && itemstack.getItem() == Items.FLINT_AND_STEEL) { - this.world.a(entityhuman, this.locX, this.locY, this.locZ, SoundEffects.by, this.bC(), 1.0F, this.random.nextFloat() * 0.4F + 0.8F); -@@ -184,9 +199,17 @@ + protected boolean a(EntityHuman entityhuman, EnumHand enumhand) { + ItemStack itemstack = entityhuman.b(enumhand); + +@@ -188,10 +203,18 @@ boolean flag = this.world.getGameRules().getBoolean("mobGriefing"); float f = this.isPowered() ? 2.0F : 1.0F; -- this.aV = true; +- this.aU = true; - this.world.explode(this, this.locX, this.locY, this.locZ, (float) this.explosionRadius * f, flag); - this.die(); +- this.do_(); + // CraftBukkit start + ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), this.explosionRadius * f, false); + this.world.getServer().getPluginManager().callEvent(event); + if (!event.isCancelled()) { -+ this.aV = true; ++ this.aU = true; + this.world.createExplosion(this, this.locX, this.locY, this.locZ, event.getRadius(), event.getFire(), flag); + this.die(); ++ this.do_(); + } else { + fuseTicks = 0; + } diff --git a/nms-patches/EntityDamageSourceIndirect.patch b/nms-patches/EntityDamageSourceIndirect.patch index 3c1c0f81ad..2bd5300b6a 100644 --- a/nms-patches/EntityDamageSourceIndirect.patch +++ b/nms-patches/EntityDamageSourceIndirect.patch @@ -2,7 +2,7 @@ +++ b/net/minecraft/server/EntityDamageSourceIndirect.java @@ -29,4 +29,10 @@ - return itemstack != null && itemstack.hasName() && LocaleI18n.c(s1) ? new ChatMessage(s1, new Object[] { entityliving.getScoreboardDisplayName(), ichatbasecomponent, itemstack.B()}) : new ChatMessage(s, new Object[] { entityliving.getScoreboardDisplayName(), ichatbasecomponent}); + return !itemstack.isEmpty() && itemstack.hasName() && LocaleI18n.c(s1) ? new ChatMessage(s1, new Object[] { entityliving.getScoreboardDisplayName(), ichatbasecomponent, itemstack.C()}) : new ChatMessage(s, new Object[] { entityliving.getScoreboardDisplayName(), ichatbasecomponent}); } + + // CraftBukkit start diff --git a/nms-patches/EntityEgg.patch b/nms-patches/EntityEgg.patch index de81882486..314bd2fe85 100644 --- a/nms-patches/EntityEgg.patch +++ b/nms-patches/EntityEgg.patch @@ -13,54 +13,50 @@ public class EntityEgg extends EntityProjectile { public EntityEgg(World world) { -@@ -23,21 +30,37 @@ - movingobjectposition.entity.damageEntity(DamageSource.projectile(this, this.getShooter()), 0.0F); +@@ -24,20 +31,40 @@ } -- if (!this.world.isClientSide && this.random.nextInt(8) == 0) { -- byte b0 = 1; -+ // CraftBukkit start - Fire PlayerEggThrowEvent -+ boolean hatching = !this.world.isClientSide && this.random.nextInt(8) == 0; -+ int numHatching = (this.random.nextInt(32) == 0) ? 4 : 1; -+ if (!hatching) { -+ numHatching = 0; -+ } -+ -+ EntityType hatchingType = EntityType.CHICKEN; -+ -+ Entity shooter = this.getShooter(); -+ if (shooter instanceof EntityPlayer) { -+ Player player = (shooter == null) ? null : (Player) shooter.getBukkitEntity(); -+ -+ PlayerEggThrowEvent event = new PlayerEggThrowEvent(player, (org.bukkit.entity.Egg) this.getBukkitEntity(), hatching, (byte) numHatching, hatchingType); -+ this.world.getServer().getPluginManager().callEvent(event); -+ -+ hatching = event.isHatching(); -+ numHatching = event.getNumHatches(); -+ hatchingType = event.getHatchingType(); -+ } + if (!this.world.isClientSide) { +- if (this.random.nextInt(8) == 0) { ++ boolean hatching = this.random.nextInt(8) == 0; // CraftBukkit ++ if (true) { + byte b0 = 1; -- if (this.random.nextInt(32) == 0) { -- b0 = 4; -- } -- -- for (int i = 0; i < b0; ++i) { -- EntityChicken entitychicken = new EntityChicken(this.world); -- -- entitychicken.setAgeRaw(-24000); -- entitychicken.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, 0.0F); -- this.world.addEntity(entitychicken); -- } -+ if (hatching) { -+ for (int k = 0; k < numHatching; k++) { -+ Entity entity = world.getWorld().createEntity(new org.bukkit.Location(world.getWorld(), this.locX, this.locY, this.locZ, this.yaw, 0.0F), hatchingType.getEntityClass()); -+ if (entity.getBukkitEntity() instanceof Ageable) { -+ ((Ageable) entity.getBukkitEntity()).setBaby(); + if (this.random.nextInt(32) == 0) { + b0 = 4; + } + +- for (int i = 0; i < b0; ++i) { +- EntityChicken entitychicken = new EntityChicken(this.world); ++ // CraftBukkit start ++ if (!hatching) { ++ b0 = 0; ++ } ++ EntityType hatchingType = EntityType.CHICKEN; ++ ++ Entity shooter = this.getShooter(); ++ if (shooter instanceof EntityPlayer) { ++ PlayerEggThrowEvent event = new PlayerEggThrowEvent((Player) shooter.getBukkitEntity(), (org.bukkit.entity.Egg) this.getBukkitEntity(), hatching, b0, hatchingType); ++ this.world.getServer().getPluginManager().callEvent(event); ++ ++ b0 = event.getNumHatches(); ++ hatching = event.isHatching(); ++ hatchingType = event.getHatchingType(); + } -+ world.getWorld().addEntity(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.EGG); -+ } - } -+ // CraftBukkit end - double d0 = 0.08D; +- entitychicken.setAgeRaw(-24000); +- entitychicken.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, 0.0F); +- this.world.addEntity(entitychicken); ++ if (hatching) { ++ for (int i = 0; i < b0; ++i) { ++ Entity entity = world.getWorld().createEntity(new org.bukkit.Location(world.getWorld(), this.locX, this.locY, this.locZ, this.yaw, 0.0F), hatchingType.getEntityClass()); ++ if (entity.getBukkitEntity() instanceof Ageable) { ++ ((Ageable) entity.getBukkitEntity()).setBaby(); ++ } ++ world.getWorld().addEntity(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.EGG); ++ } + } ++ // CraftBukkit end + } + this.world.broadcastEntityEffect(this, (byte) 3); diff --git a/nms-patches/EntityEnderDragon.patch b/nms-patches/EntityEnderDragon.patch index 59a4484fc8..cf7365ef0c 100644 --- a/nms-patches/EntityEnderDragon.patch +++ b/nms-patches/EntityEnderDragon.patch @@ -12,16 +12,16 @@ +// PAIL: Fixme public class EntityEnderDragon extends EntityInsentient implements IComplex, IMonster { - private static final Logger bJ = LogManager.getLogger(); + private static final Logger bI = LogManager.getLogger(); @@ -33,6 +38,7 @@ - private final PathPoint[] bO = new PathPoint[24]; - private final int[] bP = new int[24]; - private final Path bQ = new Path(); + private final PathPoint[] bN = new PathPoint[24]; + private final int[] bO = new int[24]; + private final Path bP = new Path(); + private Explosion explosionSource = new Explosion(null, this, Double.NaN, Double.NaN, Double.NaN, Float.NaN, true, true); // CraftBukkit - reusable source for CraftTNTPrimed.getSource() public EntityEnderDragon(World world) { super(world); -@@ -170,7 +176,7 @@ +@@ -171,7 +177,7 @@ Vec3D vec3d = idragoncontroller.g(); @@ -30,7 +30,7 @@ d0 = vec3d.x - this.locX; d1 = vec3d.y - this.locY; d2 = vec3d.z - this.locZ; -@@ -314,7 +320,14 @@ +@@ -327,7 +333,14 @@ if (this.currentEnderCrystal.dead) { this.currentEnderCrystal = null; } else if (this.ticksLived % 10 == 0 && this.getHealth() < this.getMaxHealth()) { @@ -46,7 +46,7 @@ } } -@@ -387,6 +400,10 @@ +@@ -400,6 +413,10 @@ int j1 = MathHelper.floor(axisalignedbb.f); boolean flag = false; boolean flag1 = false; @@ -57,7 +57,7 @@ for (int k1 = i; k1 <= l; ++k1) { for (int l1 = j; l1 <= i1; ++l1) { -@@ -400,7 +417,11 @@ +@@ -413,7 +430,11 @@ flag = true; } else if (block != Blocks.BARRIER && block != Blocks.OBSIDIAN && block != Blocks.END_STONE && block != Blocks.BEDROCK && block != Blocks.END_PORTAL && block != Blocks.END_PORTAL_FRAME) { if (block != Blocks.COMMAND_BLOCK && block != Blocks.dc && block != Blocks.dd && block != Blocks.IRON_BARS && block != Blocks.END_GATEWAY) { @@ -70,7 +70,7 @@ } else { flag = true; } -@@ -412,6 +433,41 @@ +@@ -425,6 +446,41 @@ } } diff --git a/nms-patches/EntityEnderman.patch b/nms-patches/EntityEnderman.patch index fbb2c66102..dc6ad77876 100644 --- a/nms-patches/EntityEnderman.patch +++ b/nms-patches/EntityEnderman.patch @@ -36,7 +36,7 @@ } -@@ -320,8 +333,12 @@ +@@ -317,8 +330,12 @@ boolean flag = movingobjectposition != null && movingobjectposition.a().equals(blockposition); if (EntityEnderman.c.contains(block) && flag) { @@ -51,7 +51,7 @@ } } -@@ -351,8 +368,12 @@ +@@ -348,8 +365,12 @@ IBlockData iblockdata2 = this.a.getCarried(); if (iblockdata2 != null && this.a(world, blockposition, iblockdata2.getBlock(), iblockdata, iblockdata1)) { diff --git a/nms-patches/EntityExperienceOrb.patch b/nms-patches/EntityExperienceOrb.patch index 21c585c528..fa1968292e 100644 --- a/nms-patches/EntityExperienceOrb.patch +++ b/nms-patches/EntityExperienceOrb.patch @@ -14,8 +14,8 @@ public int a; @@ -34,6 +40,7 @@ - public void m() { - super.m(); + public void A_() { + super.A_(); + EntityHuman prevTarget = this.targetPlayer;// CraftBukkit - store old target if (this.c > 0) { --this.c; @@ -45,8 +45,8 @@ + // CraftBukkit end } - this.move(this.motX, this.motY, this.motZ); -@@ -154,7 +173,7 @@ + this.move(EnumMoveType.SELF, this.motX, this.motY, this.motZ); +@@ -153,7 +172,7 @@ } if (this.value > 0) { @@ -55,7 +55,7 @@ } this.die(); -@@ -176,6 +195,24 @@ +@@ -175,6 +194,24 @@ } public static int getOrbValue(int i) { diff --git a/nms-patches/EntityFallingBlock.patch b/nms-patches/EntityFallingBlock.patch index 8dd4e980f0..c43f5e4fd7 100644 --- a/nms-patches/EntityFallingBlock.patch +++ b/nms-patches/EntityFallingBlock.patch @@ -31,9 +31,9 @@ if (iblockdata.getBlock() != Blocks.PISTON_EXTENSION) { this.die(); if (!this.f) { -- if (this.world.a(block, blockposition, true, EnumDirection.UP, (Entity) null, (ItemStack) null) && !BlockFalling.i(this.world.getType(blockposition.down())) && this.world.setTypeAndData(blockposition, this.block, 3)) { +- if (this.world.a(block, blockposition, true, EnumDirection.UP, (Entity) null) && !BlockFalling.i(this.world.getType(blockposition.down())) && this.world.setTypeAndData(blockposition, this.block, 3)) { + // CraftBukkit start -+ if (this.world.a(block, blockposition, true, EnumDirection.UP, (Entity) null, (ItemStack) null) && !BlockFalling.i(this.world.getType(blockposition.down()))) { ++ if (this.world.a(block, blockposition, true, EnumDirection.UP, (Entity) null) && !BlockFalling.i(this.world.getType(blockposition.down()))) { + if (CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, this.block.getBlock(), this.block.getBlock().toLegacyData(this.block)).isCancelled()) { + return; + } @@ -42,7 +42,7 @@ if (block instanceof BlockFalling) { ((BlockFalling) block).a_(this.world, blockposition); } -@@ -154,7 +162,9 @@ +@@ -156,7 +164,9 @@ while (iterator.hasNext()) { Entity entity = (Entity) iterator.next(); diff --git a/nms-patches/EntityFireball.patch b/nms-patches/EntityFireball.patch index 2f7072d8e4..02e43ed882 100644 --- a/nms-patches/EntityFireball.patch +++ b/nms-patches/EntityFireball.patch @@ -7,8 +7,8 @@ + public abstract class EntityFireball extends Entity { - private int e = -1; -@@ -13,6 +15,8 @@ + public EntityLiving shooter; +@@ -8,6 +10,8 @@ public double dirX; public double dirY; public double dirZ; @@ -17,7 +17,7 @@ public EntityFireball(World world) { super(world); -@@ -36,12 +40,19 @@ +@@ -31,12 +35,19 @@ public EntityFireball(World world, EntityLiving entityliving, double d0, double d1, double d2) { super(world); this.shooter = entityliving; @@ -37,7 +37,7 @@ d0 += this.random.nextGaussian() * 0.4D; d1 += this.random.nextGaussian() * 0.4D; d2 += this.random.nextGaussian() * 0.4D; -@@ -85,6 +96,12 @@ +@@ -61,6 +72,12 @@ if (movingobjectposition != null) { this.a(movingobjectposition); @@ -50,7 +50,7 @@ } this.locX += this.motX; -@@ -191,6 +208,11 @@ +@@ -150,6 +167,11 @@ } else { this.ap(); if (damagesource.getEntity() != null) { @@ -62,7 +62,7 @@ Vec3D vec3d = damagesource.getEntity().aB(); if (vec3d != null) { -@@ -204,6 +226,7 @@ +@@ -163,6 +185,7 @@ if (damagesource.getEntity() instanceof EntityLiving) { this.shooter = (EntityLiving) damagesource.getEntity(); diff --git a/nms-patches/EntityFireworks.patch b/nms-patches/EntityFireworks.patch index 7d26d6561d..8a06d7bb38 100644 --- a/nms-patches/EntityFireworks.patch +++ b/nms-patches/EntityFireworks.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/EntityFireworks.java +++ b/net/minecraft/server/EntityFireworks.java -@@ -80,7 +80,7 @@ +@@ -77,7 +77,7 @@ } if (!this.world.isClientSide && this.ticksFlown > this.expectedLifespan) { diff --git a/nms-patches/EntityFishingHook.patch b/nms-patches/EntityFishingHook.patch index 043d78d78b..a00557b387 100644 --- a/nms-patches/EntityFishingHook.patch +++ b/nms-patches/EntityFishingHook.patch @@ -1,52 +1,51 @@ --- a/net/minecraft/server/EntityFishingHook.java +++ b/net/minecraft/server/EntityFishingHook.java -@@ -3,6 +3,12 @@ +@@ -2,6 +2,11 @@ + import java.util.Iterator; import java.util.List; - +// CraftBukkit start +import org.bukkit.entity.Player; +import org.bukkit.entity.Fish; +import org.bukkit.event.player.PlayerFishEvent; +// CraftBukkit end -+ + public class EntityFishingHook extends Entity { - private static final DataWatcherObject c = DataWatcher.a(EntityFishingHook.class, DataWatcherRegistry.b); -@@ -193,6 +199,7 @@ - } +@@ -220,6 +225,7 @@ + vec3d = new Vec3D(this.locX, this.locY, this.locZ); + vec3d1 = new Vec3D(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ); + if (movingobjectposition != null) { ++ org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this); // Craftbukkit - Call event + vec3d1 = new Vec3D(movingobjectposition.pos.x, movingobjectposition.pos.y, movingobjectposition.pos.z); + } - if (movingobjectposition != null) { -+ org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this); // Craftbukkit - Call event - if (movingobjectposition.entity != null) { - this.hooked = movingobjectposition.entity; - this.getDataWatcher().set(EntityFishingHook.c, Integer.valueOf(this.hooked.getId() + 1)); -@@ -266,6 +273,10 @@ - if (this.au <= 0) { - this.av = 0; - this.aw = 0; -+ // CraftBukkit start -+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), null, (Fish) this.getBukkitEntity(), PlayerFishEvent.State.FAILED_ATTEMPT); -+ this.world.getServer().getPluginManager().callEvent(playerFishEvent); -+ // CraftBukkit end - } - } else { - double d10; -@@ -278,6 +289,13 @@ - if (this.aw > 0) { - this.aw -= l; - if (this.aw <= 0) { -+ // CraftBukkit start -+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), null, (Fish) this.getBukkitEntity(), PlayerFishEvent.State.BITE); -+ this.world.getServer().getPluginManager().callEvent(playerFishEvent); -+ if (playerFishEvent.isCancelled()) { -+ return; -+ } -+ // CraftBukkit end - this.motY -= 0.20000000298023224D; - this.a(SoundEffects.G, 0.25F, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F); - f2 = (float) MathHelper.floor(this.getBoundingBox().b); -@@ -390,6 +408,14 @@ +@@ -283,6 +289,10 @@ + if (this.g <= 0) { + this.h = 0; + this.at = 0; ++ // CraftBukkit start ++ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), null, (Fish) this.getBukkitEntity(), PlayerFishEvent.State.FAILED_ATTEMPT); ++ this.world.getServer().getPluginManager().callEvent(playerFishEvent); ++ // CraftBukkit end + } else { + this.motY -= 0.2D * (double) this.random.nextFloat() * (double) this.random.nextFloat(); + } +@@ -318,6 +328,13 @@ + worldserver.a(EnumParticle.WATER_WAKE, d0, d1, d2, 0, (double) (-f4), 0.01D, (double) f3, 1.0D, new int[0]); + } + } else { ++ // CraftBukkit start ++ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), null, (Fish) this.getBukkitEntity(), PlayerFishEvent.State.BITE); ++ this.world.getServer().getPluginManager().callEvent(playerFishEvent); ++ if (playerFishEvent.isCancelled()) { ++ return; ++ } ++ // CraftBukkit end + this.motY = (double) (-0.4F * MathHelper.a(this.random, 0.6F, 1.0F)); + this.a(SoundEffects.H, 0.25F, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F); + double d3 = this.getBoundingBox().b + 0.5D; +@@ -374,6 +391,14 @@ int i = 0; if (this.hooked != null) { @@ -61,7 +60,7 @@ this.k(); this.world.broadcastEntityEffect(this, (byte) 31); i = this.hooked instanceof EntityItem ? 3 : 5; -@@ -402,6 +428,15 @@ +@@ -386,6 +411,15 @@ while (iterator.hasNext()) { ItemStack itemstack = (ItemStack) iterator.next(); EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY, this.locZ, itemstack); @@ -77,7 +76,7 @@ double d0 = this.owner.locX - this.locX; double d1 = this.owner.locY - this.locY; double d2 = this.owner.locZ - this.locZ; -@@ -412,15 +447,36 @@ +@@ -396,15 +430,36 @@ entityitem.motY = d1 * 0.1D + (double) MathHelper.sqrt(d3) * 0.08D; entityitem.motZ = d2 * 0.1D; this.world.addEntity(entityitem); @@ -86,7 +85,7 @@ + if (playerFishEvent.getExpToDrop() > 0) { + this.owner.world.addEntity(new EntityExperienceOrb(this.owner.world, this.owner.locX, this.owner.locY + 0.5D, this.owner.locZ + 0.5D, playerFishEvent.getExpToDrop())); + } -+ // CraftBukkit end ++ // CraftBukkit end } i = 1; @@ -114,4 +113,4 @@ + // CraftBukkit end this.die(); - this.owner.hookedFish = null; + return i; diff --git a/nms-patches/EntityHanging.patch b/nms-patches/EntityHanging.patch index 0f778848ea..66deea741d 100644 --- a/nms-patches/EntityHanging.patch +++ b/nms-patches/EntityHanging.patch @@ -146,7 +146,7 @@ this.a(damagesource.getEntity()); @@ -151,6 +198,18 @@ - public void move(double d0, double d1, double d2) { + public void move(EnumMoveType enummovetype, double d0, double d1, double d2) { if (!this.world.isClientSide && !this.dead && d0 * d0 + d1 * d1 + d2 * d2 > 0.0D) { + if (this.dead) return; // CraftBukkit + @@ -166,7 +166,7 @@ @@ -158,7 +217,7 @@ } - public void g(double d0, double d1, double d2) { + public void f(double d0, double d1, double d2) { - if (!this.world.isClientSide && !this.dead && d0 * d0 + d1 * d1 + d2 * d2 > 0.0D) { + if (false && !this.world.isClientSide && !this.dead && d0 * d0 + d1 * d1 + d2 * d2 > 0.0D) { // CraftBukkit - not needed this.die(); diff --git a/nms-patches/EntityHorse.patch b/nms-patches/EntityHorseAbstract.patch similarity index 62% rename from nms-patches/EntityHorse.patch rename to nms-patches/EntityHorseAbstract.patch index b8d8829ff3..2fcf61efd9 100644 --- a/nms-patches/EntityHorse.patch +++ b/nms-patches/EntityHorseAbstract.patch @@ -1,32 +1,31 @@ ---- a/net/minecraft/server/EntityHorse.java -+++ b/net/minecraft/server/EntityHorse.java -@@ -7,6 +7,8 @@ +--- a/net/minecraft/server/EntityHorseAbstract.java ++++ b/net/minecraft/server/EntityHorseAbstract.java +@@ -6,6 +6,7 @@ + import java.util.List; import java.util.UUID; import javax.annotation.Nullable; - +import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; // CraftBukkit -+ - public class EntityHorse extends EntityAnimal implements IInventoryListener, IJumpable { - private static final Predicate bD = new Predicate() { -@@ -52,6 +54,7 @@ - private int ce; - private String cf; - private final String[] cg = new String[3]; + public abstract class EntityHorseAbstract extends EntityAnimal implements IInventoryListener, IJumpable { + +@@ -39,6 +40,7 @@ + private float bS; + protected boolean bE = true; + protected int bF; + public int maxDomestication = 100; // CraftBukkit - store max domestication value - public EntityHorse(World world) { + public EntityHorseAbstract(World world) { super(world); -@@ -320,7 +323,7 @@ - public void loadChest() { +@@ -214,7 +216,7 @@ + protected void dx() { InventoryHorseChest inventoryhorsechest = this.inventoryChest; -- this.inventoryChest = new InventoryHorseChest("HorseChest", this.dN()); -+ this.inventoryChest = new InventoryHorseChest("HorseChest", this.dN(), this); // CraftBukkit +- this.inventoryChest = new InventoryHorseChest("HorseChest", this.di()); ++ this.inventoryChest = new InventoryHorseChest("HorseChest", this.di(), this); // CraftBukkit this.inventoryChest.a(this.getName()); if (inventoryhorsechest != null) { inventoryhorsechest.b(this); -@@ -473,7 +476,7 @@ +@@ -354,7 +356,7 @@ } public int getMaxDomestication() { @@ -34,31 +33,34 @@ + return this.maxDomestication; // CraftBukkit - return stored max domestication instead of 100 } - protected float ch() { -@@ -563,7 +566,7 @@ - } + protected float ci() { +@@ -414,7 +416,7 @@ + } - if (this.getHealth() < this.getMaxHealth() && f > 0.0F) { -- this.heal(f); -+ this.heal(f, RegainReason.EATING); // CraftBukkit - flag = true; - } + if (this.getHealth() < this.getMaxHealth() && f > 0.0F) { +- this.heal(f); ++ this.heal(f, RegainReason.EATING); // CraftBukkit + flag = true; + } -@@ -654,11 +657,11 @@ +@@ -465,7 +467,7 @@ } public void die(DamageSource damagesource) { - super.die(damagesource); + // super.die(damagesource); // Moved down - if (!this.world.isClientSide) { - this.dropChest(); + if (!this.world.isClientSide && this.inventoryChest != null) { + for (int i = 0; i < this.inventoryChest.getSize(); ++i) { + ItemStack itemstack = this.inventoryChest.getItem(i); +@@ -476,6 +478,7 @@ + } + } -- + super.die(damagesource); // CraftBukkit } public void n() { -@@ -669,7 +672,7 @@ +@@ -486,7 +489,7 @@ super.n(); if (!this.world.isClientSide) { if (this.random.nextInt(900) == 0 && this.deathTicks == 0) { @@ -66,29 +68,28 @@ + this.heal(1.0F, RegainReason.REGEN); // CraftBukkit } - if (!this.dr() && !this.isVehicle() && this.random.nextInt(300) == 0 && this.world.getType(new BlockPosition(MathHelper.floor(this.locX), MathHelper.floor(this.locY) - 1, MathHelper.floor(this.locZ))).getBlock() == Blocks.GRASS) { -@@ -929,6 +932,7 @@ + if (this.dE()) { +@@ -719,6 +722,7 @@ if (this.getOwnerUUID() != null) { nbttagcompound.setString("OwnerUUID", this.getOwnerUUID().toString()); } + nbttagcompound.setInt("Bukkit.MaxDomestication", this.maxDomestication); // CraftBukkit - if (this.hasChest()) { - NBTTagList nbttaglist = new NBTTagList(); -@@ -984,6 +988,12 @@ + if (!this.inventoryChest.getItem(0).isEmpty()) { + nbttagcompound.set("SaddleItem", this.inventoryChest.getItem(0).save(new NBTTagCompound())); +@@ -745,6 +749,11 @@ + if (!s.isEmpty()) { this.setOwnerUUID(UUID.fromString(s)); } - + // CraftBukkit start + if (nbttagcompound.hasKey("Bukkit.MaxDomestication")) { + this.maxDomestication = nbttagcompound.getInt("Bukkit.MaxDomestication"); + } + // CraftBukkit end -+ + AttributeInstance attributeinstance = this.getAttributeMap().a("Speed"); - if (attributeinstance != null) { -@@ -1156,6 +1166,18 @@ +@@ -797,6 +806,18 @@ } public void b(int i) { @@ -105,5 +106,5 @@ + } + // CraftBukkit end this.canSlide = true; - this.setStanding(); + this.dL(); } diff --git a/nms-patches/EntityHuman.patch b/nms-patches/EntityHuman.patch index e988303a0c..d0e1cf9490 100644 --- a/nms-patches/EntityHuman.patch +++ b/nms-patches/EntityHuman.patch @@ -1,13 +1,12 @@ --- a/net/minecraft/server/EntityHuman.java +++ b/net/minecraft/server/EntityHuman.java -@@ -10,6 +10,19 @@ +@@ -9,6 +9,18 @@ import java.util.UUID; import javax.annotation.Nullable; +// CraftBukkit start +import org.bukkit.craftbukkit.entity.CraftHumanEntity; +import org.bukkit.craftbukkit.entity.CraftItem; -+import org.bukkit.craftbukkit.event.CraftEventFactory; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityCombustByEntityEvent; +import org.bukkit.event.player.PlayerBedEnterEvent; @@ -20,17 +19,21 @@ public abstract class EntityHuman extends EntityLiving { private static final DataWatcherObject a = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.c); -@@ -20,7 +33,7 @@ - private InventoryEnderChest enderChest = new InventoryEnderChest(); +@@ -16,10 +28,10 @@ + protected static final DataWatcherObject bq = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.a); + protected static final DataWatcherObject br = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.a); + public PlayerInventory inventory = new PlayerInventory(this); +- private InventoryEnderChest enderChest = new InventoryEnderChest(); ++ private InventoryEnderChest enderChest = new InventoryEnderChest(this); // CraftBukkit - add "this" to constructor public Container defaultContainer; public Container activeContainer; - protected FoodMetaData foodData = new FoodMetaData(); + protected FoodMetaData foodData = new FoodMetaData(this); // CraftBukkit - add "this" to constructor - protected int bx; + protected int bw; + public float bx; public float by; - public float bz; -@@ -52,6 +65,17 @@ - private final ItemCooldown bW = this.l(); +@@ -52,6 +64,17 @@ + @Nullable public EntityFishingHook hookedFish; + // CraftBukkit start @@ -47,7 +50,7 @@ protected ItemCooldown l() { return new ItemCooldown(); } -@@ -307,7 +331,8 @@ +@@ -312,7 +335,8 @@ if (this.world.getDifficulty() == EnumDifficulty.PEACEFUL && this.world.getGameRules().getBoolean("naturalRegeneration")) { if (this.getHealth() < this.getMaxHealth() && this.ticksLived % 20 == 0) { @@ -57,7 +60,7 @@ } if (this.foodData.c() && this.ticksLived % 10 == 0) { -@@ -331,7 +356,7 @@ +@@ -336,7 +360,7 @@ this.l((float) attributeinstance.getValue()); float f = MathHelper.sqrt(this.motX * this.motX + this.motZ * this.motZ); @@ -66,7 +69,7 @@ if (f > 0.1F) { f = 0.1F; -@@ -423,28 +448,34 @@ +@@ -442,28 +466,34 @@ public void b(Entity entity, int i) { if (entity != this) { this.addScore(i); @@ -107,7 +110,7 @@ String s = entity instanceof EntityHuman ? entity.getName() : entity.bf(); ScoreboardTeam scoreboardteam = this.getScoreboard().getPlayerTeam(this.getName()); -@@ -469,7 +500,10 @@ +@@ -488,7 +518,10 @@ int j = scoreboardteam1.m().b(); if (j >= 0 && j < IScoreboardCriteria.m.length) { @@ -119,15 +122,15 @@ } } -@@ -478,6 +512,7 @@ +@@ -497,6 +530,7 @@ @Nullable public EntityItem a(boolean flag) { + // Called only when dropped by Q or CTRL-Q - return this.a(this.inventory.splitStack(this.inventory.itemInHandIndex, flag && this.inventory.getItemInHand() != null ? this.inventory.getItemInHand().count : 1), false, true); + return this.a(this.inventory.splitStack(this.inventory.itemInHandIndex, flag && !this.inventory.getItemInHand().isEmpty() ? this.inventory.getItemInHand().getCount() : 1), false, true); } -@@ -522,6 +557,30 @@ +@@ -539,6 +573,30 @@ entityitem.motZ += Math.sin((double) f1) * (double) f; } @@ -158,7 +161,7 @@ ItemStack itemstack1 = this.a(entityitem); if (flag1) { -@@ -630,6 +689,13 @@ +@@ -646,6 +704,13 @@ this.a(true, true, false); } @@ -172,20 +175,15 @@ if (nbttagcompound.hasKeyOfType("SpawnX", 99) && nbttagcompound.hasKeyOfType("SpawnY", 99) && nbttagcompound.hasKeyOfType("SpawnZ", 99)) { this.e = new BlockPosition(nbttagcompound.getInt("SpawnX"), nbttagcompound.getInt("SpawnY"), nbttagcompound.getInt("SpawnZ")); this.f = nbttagcompound.getBoolean("SpawnForced"); -@@ -667,6 +733,12 @@ +@@ -683,6 +748,7 @@ this.foodData.b(nbttagcompound); this.abilities.a(nbttagcompound); - nbttagcompound.set("EnderItems", this.enderChest.h()); -+ ItemStack itemstack = this.inventory.getItemInHand(); -+ -+ if (itemstack != null && itemstack.getItem() != null) { -+ nbttagcompound.set("SelectedItem", itemstack.save(new NBTTagCompound())); -+ } + nbttagcompound.set("EnderItems", this.enderChest.i()); + nbttagcompound.setString("SpawnWorld", spawnWorld); // CraftBukkit - fixes bed spawns for multiworld worlds } public boolean damageEntity(DamageSource damagesource, float f) { -@@ -685,7 +757,7 @@ +@@ -701,7 +767,7 @@ if (damagesource.r()) { if (this.world.getDifficulty() == EnumDifficulty.PEACEFUL) { @@ -194,7 +192,7 @@ } if (this.world.getDifficulty() == EnumDifficulty.EASY) { -@@ -697,16 +769,35 @@ +@@ -713,7 +779,7 @@ } } @@ -203,6 +201,8 @@ } } } +@@ -727,10 +793,29 @@ + } public boolean a(EntityHuman entityhuman) { - ScoreboardTeamBase scoreboardteambase = this.aQ(); @@ -234,8 +234,8 @@ } protected void damageArmor(float f) { -@@ -750,7 +841,12 @@ - return (float) i / (float) this.inventory.armor.length; +@@ -773,7 +858,12 @@ + return (float) i / (float) this.inventory.armor.size(); } - protected void damageEntity0(DamageSource damagesource, float f) { @@ -248,7 +248,7 @@ if (!this.isInvulnerable(damagesource)) { f = this.applyArmorModifier(damagesource, f); f = this.applyMagicModifier(damagesource, f); -@@ -770,6 +866,7 @@ +@@ -793,6 +883,7 @@ } } @@ -256,7 +256,7 @@ } public void openSign(TileEntitySign tileentitysign) {} -@@ -894,8 +991,15 @@ +@@ -914,8 +1005,15 @@ if (entity instanceof EntityLiving) { f3 = ((EntityLiving) entity).getHealth(); if (j > 0 && !entity.isBurning()) { @@ -274,7 +274,7 @@ } } -@@ -925,8 +1029,11 @@ +@@ -945,8 +1043,11 @@ EntityLiving entityliving = (EntityLiving) iterator.next(); if (entityliving != this && entityliving != entity && !this.r(entityliving) && this.h(entityliving) < 9.0D) { @@ -287,7 +287,7 @@ } } -@@ -935,11 +1042,28 @@ +@@ -955,11 +1056,28 @@ } if (entity instanceof EntityPlayer && entity.velocityChanged) { @@ -316,19 +316,9 @@ } if (flag2) { -@@ -1001,7 +1125,8 @@ +@@ -1012,7 +1130,14 @@ - if (itemstack3 != null && object instanceof EntityLiving) { - itemstack3.a((EntityLiving) object, this); -- if (itemstack3.count <= 0) { -+ // CraftBukkit - bypass infinite items; <= 0 -> == 0 -+ if (itemstack3.count == 0) { - this.a(EnumHand.MAIN_HAND, (ItemStack) null); - } - } -@@ -1011,7 +1136,14 @@ - - this.a(StatisticList.y, Math.round(f5 * 10.0F)); + this.a(StatisticList.y, Math.round(f4 * 10.0F)); if (j > 0) { - entity.setOnFire(j * 4); + // CraftBukkit start - Call a combust event when somebody hits with a fire enchanted item @@ -341,8 +331,8 @@ + // CraftBukkit end } - if (this.world instanceof WorldServer && f5 > 2.0F) { -@@ -1100,6 +1232,20 @@ + if (this.world instanceof WorldServer && f4 > 2.0F) { +@@ -1118,6 +1243,20 @@ this.stopRiding(); } @@ -362,8 +352,8 @@ + this.setSize(0.2F, 0.2F); if (this.world.isLoaded(blockposition)) { - EnumDirection enumdirection = (EnumDirection) this.world.getType(blockposition).get(BlockFacingHorizontal.FACING); -@@ -1184,6 +1330,23 @@ + float f = 0.5F + (float) enumdirection.getAdjacentX() * 0.4F; +@@ -1177,6 +1316,23 @@ this.world.everyoneSleeping(); } @@ -387,7 +377,7 @@ this.sleepTicks = flag ? 0 : 100; if (flag2) { this.setRespawnPosition(this.bedPosition, false); -@@ -1235,9 +1398,11 @@ +@@ -1228,9 +1384,11 @@ if (blockposition != null) { this.e = blockposition; this.f = flag; diff --git a/nms-patches/EntityInsentient.patch b/nms-patches/EntityInsentient.patch index 5cbb4fe442..44801a840a 100644 --- a/nms-patches/EntityInsentient.patch +++ b/nms-patches/EntityInsentient.patch @@ -16,7 +16,7 @@ public abstract class EntityInsentient extends EntityLiving { private static final DataWatcherObject a = DataWatcher.a(EntityInsentient.class, DataWatcherRegistry.a); -@@ -52,6 +61,9 @@ +@@ -57,6 +66,9 @@ this.r(); } @@ -26,20 +26,7 @@ } protected void r() {} -@@ -66,9 +78,10 @@ - } - - public float a(PathType pathtype) { -- Float float = (Float) this.bB.get(pathtype); -+ // CraftBukkit - decompile error -+ Float ofloat = (Float) this.bB.get(pathtype); - -- return float == null ? pathtype.a() : float.floatValue(); -+ return ofloat == null ? pathtype.a() : ofloat.floatValue(); - } - - public void a(PathType pathtype, float f) { -@@ -105,7 +118,38 @@ +@@ -110,7 +122,38 @@ } public void setGoalTarget(@Nullable EntityLiving entityliving) { @@ -78,7 +65,7 @@ } public boolean d(Class oclass) { -@@ -350,11 +394,20 @@ +@@ -340,11 +383,20 @@ public void a(NBTTagCompound nbttagcompound) { super.a(nbttagcompound); @@ -101,7 +88,7 @@ NBTTagList nbttaglist; int i; -@@ -579,11 +632,11 @@ +@@ -569,11 +621,11 @@ double d2 = entityhuman.locZ - this.locZ; double d3 = d0 * d0 + d1 * d1 + d2 * d2; @@ -115,9 +102,9 @@ this.die(); } else if (d3 < 1024.0D) { this.ticksFarFromPlayer = 0; -@@ -965,9 +1018,21 @@ +@@ -942,12 +994,24 @@ - public final boolean a(EntityHuman entityhuman, @Nullable ItemStack itemstack, EnumHand enumhand) { + public final boolean b(EntityHuman entityhuman, EnumHand enumhand) { if (this.isLeashed() && this.getLeashHolder() == entityhuman) { + // CraftBukkit start - fire PlayerUnleashEntityEvent + if (CraftEventFactory.callPlayerUnleashEntityEvent(this, entityhuman).isCancelled()) { @@ -127,19 +114,22 @@ + // CraftBukkit end this.unleash(true, !entityhuman.abilities.canInstantlyBuild); return true; - } else if (itemstack != null && itemstack.getItem() == Items.LEAD && this.a(entityhuman)) { -+ // CraftBukkit start - fire PlayerLeashEntityEvent -+ if (CraftEventFactory.callPlayerLeashEntityEvent(this, entityhuman, entityhuman).isCancelled()) { -+ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutAttachEntity(this, this.getLeashHolder())); -+ return false; -+ } -+ // CraftBukkit end - this.setLeashHolder(entityhuman, true); - --itemstack.count; - return true; -@@ -987,10 +1052,12 @@ + } else { + ItemStack itemstack = entityhuman.b(enumhand); - if (this.bE) { + if (itemstack.getItem() == Items.LEAD && this.a(entityhuman)) { ++ // CraftBukkit start - fire PlayerLeashEntityEvent ++ if (CraftEventFactory.callPlayerLeashEntityEvent(this, entityhuman, entityhuman).isCancelled()) { ++ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutAttachEntity(this, this.getLeashHolder())); ++ return false; ++ } ++ // CraftBukkit end + this.setLeashHolder(entityhuman, true); + itemstack.subtract(1); + return true; +@@ -968,10 +1032,12 @@ + + if (this.bD) { if (!this.isAlive()) { + this.world.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.PLAYER_UNLEASH)); // CraftBukkit this.unleash(true, true); @@ -150,8 +140,8 @@ this.unleash(true, true); } } -@@ -1001,7 +1068,9 @@ - this.bE = false; +@@ -982,7 +1048,9 @@ + this.bD = false; this.leashHolder = null; if (!this.world.isClientSide && flag1) { + this.forceDrops = true; // CraftBukkit @@ -160,9 +150,9 @@ } if (!this.world.isClientSide && flag && this.world instanceof WorldServer) { -@@ -1071,6 +1140,7 @@ +@@ -1052,6 +1120,7 @@ - this.leashHolder = entityleash; + this.setLeashHolder(entityleash, true); } else { + this.world.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.UNKNOWN)); // CraftBukkit this.unleash(false, true); diff --git a/nms-patches/EntityIronGolem.patch b/nms-patches/EntityIronGolem.patch index 6b9b2f87d3..45aee397dc 100644 --- a/nms-patches/EntityIronGolem.patch +++ b/nms-patches/EntityIronGolem.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/EntityIronGolem.java +++ b/net/minecraft/server/EntityIronGolem.java -@@ -72,7 +72,7 @@ +@@ -73,7 +73,7 @@ protected void C(Entity entity) { if (entity instanceof IMonster && !(entity instanceof EntityCreeper) && this.getRandom().nextInt(20) == 0) { diff --git a/nms-patches/EntityItem.patch b/nms-patches/EntityItem.patch index 7fbea393b3..3b425b41ba 100644 --- a/nms-patches/EntityItem.patch +++ b/nms-patches/EntityItem.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/EntityItem.java +++ b/net/minecraft/server/EntityItem.java -@@ -5,6 +5,7 @@ +@@ -4,6 +4,7 @@ import javax.annotation.Nullable; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -8,7 +8,7 @@ public class EntityItem extends Entity { -@@ -16,6 +17,7 @@ +@@ -15,6 +16,7 @@ private String g; private String h; public float a; @@ -16,7 +16,7 @@ public EntityItem(World world, double d0, double d1, double d2) { super(world); -@@ -31,6 +33,11 @@ +@@ -30,6 +32,11 @@ public EntityItem(World world, double d0, double d1, double d2, ItemStack itemstack) { this(world, d0, d1, d2); @@ -28,10 +28,10 @@ this.setItemStack(itemstack); } -@@ -55,9 +62,12 @@ +@@ -54,9 +61,12 @@ this.die(); } else { - super.m(); + super.A_(); - if (this.pickupDelay > 0 && this.pickupDelay != 32767) { - --this.pickupDelay; - } @@ -44,7 +44,7 @@ this.lastX = this.locX; this.lastY = this.locY; -@@ -96,12 +106,20 @@ +@@ -104,9 +114,11 @@ this.motY *= -0.5D; } @@ -55,6 +55,10 @@ + // Craftbukkit end */ this.ak(); + if (!this.world.isClientSide) { +@@ -121,6 +133,12 @@ + } + if (!this.world.isClientSide && this.age >= 6000) { + // CraftBukkit start - fire ItemDespawnEvent + if (org.bukkit.craftbukkit.event.CraftEventFactory.callItemDespawnEvent(this).isCancelled()) { @@ -65,16 +69,16 @@ this.die(); } -@@ -143,6 +161,7 @@ - } else if (itemstack1.count + itemstack.count > itemstack1.getMaxStackSize()) { +@@ -162,6 +180,7 @@ + } else if (itemstack1.getCount() + itemstack.getCount() > itemstack1.getMaxStackSize()) { return false; } else { + if (org.bukkit.craftbukkit.event.CraftEventFactory.callItemMergeEvent(this, entityitem).isCancelled()) return false; // CraftBukkit - itemstack1.count += itemstack.count; + itemstack1.add(itemstack.getCount()); entityitem.pickupDelay = Math.max(entityitem.pickupDelay, this.pickupDelay); entityitem.age = Math.min(entityitem.age, this.age); -@@ -189,6 +208,11 @@ - } else if (this.getItemStack() != null && this.getItemStack().getItem() == Items.NETHER_STAR && damagesource.isExplosion()) { +@@ -208,6 +227,11 @@ + } else if (!this.getItemStack().isEmpty() && this.getItemStack().getItem() == Items.NETHER_STAR && damagesource.isExplosion()) { return false; } else { + // CraftBukkit start @@ -85,40 +89,33 @@ this.ap(); this.f = (int) ((float) this.f - f); if (this.f <= 0) { -@@ -238,7 +262,18 @@ +@@ -257,6 +281,12 @@ NBTTagCompound nbttagcompound1 = nbttagcompound.getCompound("Item"); -- this.setItemStack(ItemStack.createStack(nbttagcompound1)); + // CraftBukkit start - Handle missing "Item" compounds -+ if (nbttagcompound1 != null) { -+ ItemStack itemstack = ItemStack.createStack(nbttagcompound1); -+ if (itemstack != null) { -+ this.setItemStack(itemstack); -+ } else { -+ this.die(); -+ } -+ } else { ++ if (nbttagcompound1 == null) { + this.die(); ++ return; + } + // CraftBukkit end - if (this.getItemStack() == null) { + this.setItemStack(new ItemStack(nbttagcompound1)); + if (this.getItemStack().isEmpty()) { this.die(); - } -@@ -250,6 +285,26 @@ - ItemStack itemstack = this.getItemStack(); - int i = itemstack.count; +@@ -270,6 +300,26 @@ + Item item = itemstack.getItem(); + int i = itemstack.getCount(); + // CraftBukkit start - fire PlayerPickupItemEvent + int canHold = entityhuman.inventory.canHold(itemstack); -+ int remaining = itemstack.count - canHold; ++ int remaining = i - canHold; + + if (this.pickupDelay <= 0 && canHold > 0) { -+ itemstack.count = canHold; ++ itemstack.setCount(canHold); + PlayerPickupItemEvent event = new PlayerPickupItemEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), (org.bukkit.entity.Item) this.getBukkitEntity(), remaining); + // event.setCancelled(!entityhuman.canPickUpLoot); TODO + this.world.getServer().getPluginManager().callEvent(event); -+ itemstack.count = canHold + remaining; ++ itemstack.setCount(canHold + remaining); + + if (event.isCancelled()) { + return; @@ -130,5 +127,5 @@ + // CraftBukkit end + if (this.pickupDelay == 0 && (this.h == null || 6000 - this.age <= 200 || this.h.equals(entityhuman.getName())) && entityhuman.inventory.pickup(itemstack)) { - if (itemstack.getItem() == Item.getItemOf(Blocks.LOG)) { + if (item == Item.getItemOf(Blocks.LOG)) { entityhuman.b((Statistic) AchievementList.g); diff --git a/nms-patches/EntityItemFrame.patch b/nms-patches/EntityItemFrame.patch index c98af2f284..4178fdcf91 100644 --- a/nms-patches/EntityItemFrame.patch +++ b/nms-patches/EntityItemFrame.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/EntityItemFrame.java +++ b/net/minecraft/server/EntityItemFrame.java -@@ -32,6 +32,11 @@ +@@ -31,6 +31,11 @@ return false; - } else if (!damagesource.isExplosion() && this.getItem() != null) { + } else if (!damagesource.isExplosion() && !this.getItem().isEmpty()) { if (!this.world.isClientSide) { + // CraftBukkit start - fire EntityDamageEvent + if (org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f, false) || this.dead) { @@ -10,5 +10,5 @@ + } + // CraftBukkit end this.b(damagesource.getEntity(), false); - this.a(SoundEffects.cX, 1.0F, 1.0F); - this.setItem((ItemStack) null); + this.a(SoundEffects.dh, 1.0F, 1.0F); + this.setItem(ItemStack.a); diff --git a/nms-patches/EntityLeash.patch b/nms-patches/EntityLeash.patch index bea9f62f72..c742be1c79 100644 --- a/nms-patches/EntityLeash.patch +++ b/nms-patches/EntityLeash.patch @@ -8,20 +8,19 @@ import java.util.Iterator; import java.util.List; import javax.annotation.Nullable; -@@ -74,6 +76,12 @@ - while (iterator.hasNext()) { - entityinsentient = (EntityInsentient) iterator.next(); - if (entityinsentient.isLeashed() && entityinsentient.getLeashHolder() == entityhuman) { -+ // CraftBukkit start -+ if (CraftEventFactory.callPlayerLeashEntityEvent(entityinsentient, this, entityhuman).isCancelled()) { -+ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutAttachEntity(entityinsentient, entityinsentient.getLeashHolder())); -+ continue; -+ } -+ // CraftBukkit end - entityinsentient.setLeashHolder(this, true); - flag = true; - } -@@ -81,8 +89,11 @@ +@@ -71,22 +73,42 @@ + while (iterator.hasNext()) { + entityinsentient = (EntityInsentient) iterator.next(); + if (entityinsentient.isLeashed() && entityinsentient.getLeashHolder() == entityhuman) { ++ // CraftBukkit start ++ if (CraftEventFactory.callPlayerLeashEntityEvent(entityinsentient, this, entityhuman).isCancelled()) { ++ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutAttachEntity(entityinsentient, entityinsentient.getLeashHolder())); ++ continue; ++ } ++ // CraftBukkit end + entityinsentient.setLeashHolder(this, true); + flag = true; + } } if (!flag) { @@ -32,10 +31,8 @@ + boolean die = true; + // CraftBukkit end + if (true || entityhuman.abilities.canInstantlyBuild) { // CraftBukkit - Process for non-creative as well - d0 = 7.0D; - list = this.world.a(EntityInsentient.class, new AxisAlignedBB(this.locX - 7.0D, this.locY - 7.0D, this.locZ - 7.0D, this.locX + 7.0D, this.locY + 7.0D, this.locZ + 7.0D)); iterator = list.iterator(); -@@ -90,9 +101,20 @@ + while (iterator.hasNext()) { entityinsentient = (EntityInsentient) iterator.next(); if (entityinsentient.isLeashed() && entityinsentient.getLeashHolder() == this) { diff --git a/nms-patches/EntityLightning.patch b/nms-patches/EntityLightning.patch index b686086c39..649e5fd39b 100644 --- a/nms-patches/EntityLightning.patch +++ b/nms-patches/EntityLightning.patch @@ -46,12 +46,12 @@ } } @@ -41,7 +53,24 @@ - public void m() { - super.m(); + public void A_() { + super.A_(); if (this.lifeTicks == 2) { -- this.world.a((EntityHuman) null, this.locX, this.locY, this.locZ, SoundEffects.dn, SoundCategory.WEATHER, 10000.0F, 0.8F + this.random.nextFloat() * 0.2F); +- this.world.a((EntityHuman) null, this.locX, this.locY, this.locZ, SoundEffects.dx, SoundCategory.WEATHER, 10000.0F, 0.8F + this.random.nextFloat() * 0.2F); + // CraftBukkit start - Use relative location for far away sounds -+ // this.world.a((EntityHuman) null, this.locX, this.locY, this.locZ, SoundEffects.dn, SoundCategory.WEATHER, 10000.0F, 0.8F + this.random.nextFloat() * 0.2F); ++ // this.world.a((EntityHuman) null, this.locX, this.locY, this.locZ, SoundEffects.dv, SoundCategory.WEATHER, 10000.0F, 0.8F + this.random.nextFloat() * 0.2F); + float pitch = 0.8F + this.random.nextFloat() * 0.2F; + int viewDistance = ((WorldServer) this.world).getServer().getViewDistance() * 16; + for (EntityPlayer player : (List) (List) this.world.players) { @@ -62,13 +62,13 @@ + double deltaLength = Math.sqrt(distanceSquared); + double relativeX = player.locX + (deltaX / deltaLength) * viewDistance; + double relativeZ = player.locZ + (deltaZ / deltaLength) * viewDistance; -+ player.playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect(SoundEffects.dn, SoundCategory.WEATHER, relativeX, this.locY, relativeZ, 10000.0F, pitch)); ++ player.playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect(SoundEffects.dx, SoundCategory.WEATHER, relativeX, this.locY, relativeZ, 10000.0F, pitch)); + } else { -+ player.playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect(SoundEffects.dn, SoundCategory.WEATHER, this.locX, this.locY, this.locZ, 10000.0F, pitch)); ++ player.playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect(SoundEffects.dx, SoundCategory.WEATHER, this.locX, this.locY, this.locZ, 10000.0F, pitch)); + } + } + // CraftBukkit end - this.world.a((EntityHuman) null, this.locX, this.locY, this.locZ, SoundEffects.dm, SoundCategory.WEATHER, 2.0F, 0.5F + this.random.nextFloat() * 0.2F); + this.world.a((EntityHuman) null, this.locX, this.locY, this.locZ, SoundEffects.dw, SoundCategory.WEATHER, 2.0F, 0.5F + this.random.nextFloat() * 0.2F); } @@ -57,13 +86,17 @@ diff --git a/nms-patches/EntityLiving.patch b/nms-patches/EntityLiving.patch index a6e18d34e7..f5ea0bf7e4 100644 --- a/nms-patches/EntityLiving.patch +++ b/nms-patches/EntityLiving.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/EntityLiving.java +++ b/net/minecraft/server/EntityLiving.java -@@ -10,6 +10,22 @@ - import java.util.UUID; - import javax.annotation.Nullable; +@@ -13,6 +13,24 @@ + import org.apache.logging.log4j.LogManager; + import org.apache.logging.log4j.Logger; +// CraftBukkit start +import java.util.ArrayList; @@ -12,18 +12,20 @@ +import org.bukkit.craftbukkit.attribute.CraftAttributeMap; +import org.bukkit.craftbukkit.event.CraftEventFactory; +import org.bukkit.craftbukkit.inventory.CraftItemStack; ++import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.entity.EntityDamageEvent.DamageModifier; +import org.bukkit.event.entity.EntityRegainHealthEvent; ++import org.bukkit.event.entity.EntityResurrectEvent; +import org.bukkit.event.entity.EntityTeleportEvent; +import org.bukkit.event.player.PlayerItemConsumeEvent; +// CraftBukkit end + public abstract class EntityLiving extends Entity { - private static final UUID a = UUID.fromString("662A6B8D-DA3E-4C1C-8813-96EA6097278D"); -@@ -83,6 +99,14 @@ + private static final Logger a = LogManager.getLogger(); +@@ -87,6 +105,14 @@ private BlockPosition bE; private DamageSource bF; private long bG; @@ -38,17 +40,17 @@ public void Q() { this.damageEntity(DamageSource.OUT_OF_WORLD, Float.MAX_VALUE); -@@ -91,7 +115,8 @@ - public EntityLiving(World world) { - super(world); +@@ -101,7 +127,8 @@ + this.updateEffects = true; + this.activeItem = ItemStack.a; this.initAttributes(); - this.setHealth(this.getMaxHealth()); + // CraftBukkit - setHealth(getMaxHealth()) inlined and simplified to skip the instanceof check for EntityPlayer, as getBukkitEntity() is not initialized in constructor + this.datawatcher.set(EntityLiving.HEALTH, (float) this.getAttributeInstance(GenericAttributes.maxHealth).getValue()); this.i = true; - this.aN = (float) ((Math.random() + 1.0D) * 0.009999999776482582D); + this.aM = (float) ((Math.random() + 1.0D) * 0.009999999776482582D); this.setPosition(this.locX, this.locY, this.locZ); -@@ -129,7 +154,13 @@ +@@ -139,7 +166,13 @@ double d1 = Math.min((double) (0.2F + f / 15.0F), 2.5D); int i = (int) (150.0D * d1); @@ -63,7 +65,7 @@ } } -@@ -191,7 +222,11 @@ +@@ -201,7 +234,11 @@ this.stopRiding(); } } else { @@ -76,7 +78,7 @@ } if (!this.world.isClientSide) { -@@ -248,6 +283,18 @@ +@@ -258,6 +295,18 @@ this.world.methodProfiler.b(); } @@ -95,9 +97,9 @@ protected void b(BlockPosition blockposition) { int i = EnchantmentManager.a(Enchantments.j, this); -@@ -263,19 +310,19 @@ +@@ -273,19 +322,19 @@ - protected void bF() { + protected void bG() { ++this.deathTicks; - if (this.deathTicks == 20) { + if (this.deathTicks >= 20 && !this.dead) { // CraftBukkit - (this.deathTicks == 20) -> (this.deathTicks >= 20 && !this.dead) @@ -105,14 +107,14 @@ - if (!this.world.isClientSide && (this.alwaysGivesExp() || this.lastDamageByPlayerTime > 0 && this.isDropExperience() && this.world.getGameRules().getBoolean("doMobLoot"))) { - i = this.getExpValue(this.killer); +- +- while (i > 0) { +- int j = EntityExperienceOrb.getOrbValue(i); + // CraftBukkit start - Update getExpReward() above if the removed if() changes! + i = this.expToDrop; + while (i > 0) { + int j = EntityExperienceOrb.getOrbValue(i); -- while (i > 0) { -- int j = EntityExperienceOrb.getOrbValue(i); -- - i -= j; - this.world.addEntity(new EntityExperienceOrb(this.world, this.locX, this.locY, this.locZ, j)); - } @@ -124,7 +126,7 @@ this.die(); -@@ -430,6 +477,17 @@ +@@ -441,6 +490,17 @@ } } @@ -132,9 +134,9 @@ + if (nbttagcompound.hasKey("Bukkit.MaxHealth")) { + NBTBase nbtbase = nbttagcompound.get("Bukkit.MaxHealth"); + if (nbtbase.getTypeId() == 5) { -+ this.getAttributeInstance(GenericAttributes.maxHealth).setValue(((NBTTagFloat) nbtbase).h()); // PAIL: rename ++ this.getAttributeInstance(GenericAttributes.maxHealth).setValue(((NBTTagFloat) nbtbase).asDouble()); + } else if (nbtbase.getTypeId() == 3) { -+ this.getAttributeInstance(GenericAttributes.maxHealth).setValue(((NBTTagInt) nbtbase).h()); // PAIL: rename ++ this.getAttributeInstance(GenericAttributes.maxHealth).setValue(((NBTTagInt) nbtbase).asDouble()); + } + } + // CraftBukkit end @@ -142,7 +144,7 @@ if (nbttagcompound.hasKeyOfType("Health", 99)) { this.setHealth(nbttagcompound.getFloat("Health")); } -@@ -449,9 +507,15 @@ +@@ -463,9 +523,15 @@ } @@ -155,12 +157,12 @@ Iterator iterator = this.effects.keySet().iterator(); + isTickingEffects = true; // CraftBukkit - while (iterator.hasNext()) { - MobEffectList mobeffectlist = (MobEffectList) iterator.next(); - MobEffect mobeffect = (MobEffect) this.effects.get(mobeffectlist); -@@ -465,6 +529,16 @@ - this.a(mobeffect, false); - } + try { + while (iterator.hasNext()) { + MobEffectList mobeffectlist = (MobEffectList) iterator.next(); +@@ -483,6 +549,16 @@ + } catch (ConcurrentModificationException concurrentmodificationexception) { + ; } + // CraftBukkit start + isTickingEffects = false; @@ -175,7 +177,7 @@ if (this.updateEffects) { if (!this.world.isClientSide) { -@@ -562,6 +636,12 @@ +@@ -580,6 +656,12 @@ } public void addEffect(MobEffect mobeffect) { @@ -188,7 +190,7 @@ if (this.d(mobeffect)) { MobEffect mobeffect1 = (MobEffect) this.effects.get(mobeffect.getMobEffect()); -@@ -594,6 +674,12 @@ +@@ -612,6 +694,12 @@ @Nullable public MobEffect c(@Nullable MobEffectList mobeffectlist) { @@ -201,7 +203,7 @@ return (MobEffect) this.effects.remove(mobeffectlist); } -@@ -633,20 +719,52 @@ +@@ -651,20 +739,52 @@ } @@ -255,27 +257,27 @@ this.datawatcher.set(EntityLiving.HEALTH, Float.valueOf(MathHelper.a(f, 0.0F, this.getMaxHealth()))); } -@@ -662,14 +780,16 @@ +@@ -680,14 +800,16 @@ } else if (damagesource.o() && this.hasEffect(MobEffects.FIRE_RESISTANCE)) { return false; } else { -- if ((damagesource == DamageSource.ANVIL || damagesource == DamageSource.FALLING_BLOCK) && this.getEquipment(EnumItemSlot.HEAD) != null) { +- if ((damagesource == DamageSource.ANVIL || damagesource == DamageSource.FALLING_BLOCK) && !this.getEquipment(EnumItemSlot.HEAD).isEmpty()) { + // CraftBukkit - Moved into damageEntity0(DamageSource, float) -+ if (false && (damagesource == DamageSource.ANVIL || damagesource == DamageSource.FALLING_BLOCK) && this.getEquipment(EnumItemSlot.HEAD) != null) { ++ if (false && (damagesource == DamageSource.ANVIL || damagesource == DamageSource.FALLING_BLOCK) && !this.getEquipment(EnumItemSlot.HEAD).isEmpty()) { this.getEquipment(EnumItemSlot.HEAD).damage((int) (f * 4.0F + this.random.nextFloat() * f * 2.0F), this); f *= 0.75F; } - boolean flag = false; -+ boolean flag = f > 0.0F && this.d(damagesource); // Copied from below ++ boolean flag = f > 0.0F && this.applyBlockingModifier(damagesource); // Copied from below -- if (f > 0.0F && this.d(damagesource)) { +- if (f > 0.0F && this.applyBlockingModifier(damagesource)) { + // CraftBukkit - Moved into damageEntity0(DamageSource, float) -+ if (false && f > 0.0F && this.d(damagesource)) { - this.k(f); - if (damagesource.a()) { - f = 0.0F; -@@ -688,20 +808,39 @@ ++ if (false && f > 0.0F && this.applyBlockingModifier(damagesource)) { + this.damageShield(f); + f = 0.0F; + if (!damagesource.a()) { +@@ -706,20 +828,39 @@ if ((float) this.noDamageTicks > (float) this.maxNoDamageTicks / 2.0F) { if (f <= this.lastDamage) { @@ -301,8 +303,8 @@ - this.damageEntity0(damagesource, f); + // this.damageEntity0(damagesource, f); + // CraftBukkit end - this.aA = 10; - this.hurtTicks = this.aA; + this.az = 10; + this.hurtTicks = this.az; } + // CraftBukkit start @@ -314,10 +316,25 @@ + } + // CraftBukkit end + - this.aB = 0.0F; - Entity entity = damagesource.getEntity(); + this.aA = 0.0F; + Entity entity1 = damagesource.getEntity(); -@@ -855,6 +994,12 @@ +@@ -817,7 +958,13 @@ + } + } + +- if (flag) { ++ // CraftBukkit start ++ EntityResurrectEvent event = new EntityResurrectEvent((LivingEntity) this.getBukkitEntity()); ++ event.setCancelled(!flag); ++ this.world.getServer().getPluginManager().callEvent(event); ++ ++ if (!event.isCancelled()) { ++ // CraftBukkit end + if (this instanceof EntityHuman) { + ((EntityHuman) this).b(StatisticList.b(Items.cY)); + } +@@ -914,6 +1061,12 @@ boolean flag = this.lastDamageByPlayerTime > 0; this.a(flag, i, damagesource); @@ -330,7 +347,7 @@ } } -@@ -944,8 +1089,13 @@ +@@ -1003,8 +1156,13 @@ int i = MathHelper.f((f - 3.0F - f2) * f1); if (i > 0) { @@ -345,7 +362,7 @@ int j = MathHelper.floor(this.locX); int k = MathHelper.floor(this.locY - 0.20000000298023224D); int l = MathHelper.floor(this.locZ); -@@ -972,7 +1122,7 @@ +@@ -1031,7 +1189,7 @@ protected float applyArmorModifier(DamageSource damagesource, float f) { if (!damagesource.ignoresArmor()) { @@ -354,7 +371,7 @@ f = CombatMath.a(f, (float) this.getArmorStrength(), (float) this.getAttributeInstance(GenericAttributes.h).getValue()); } -@@ -985,7 +1135,8 @@ +@@ -1044,7 +1202,8 @@ } else { int i; @@ -364,7 +381,7 @@ i = (this.getEffect(MobEffects.RESISTANCE).getAmplifier() + 1) * 5; int j = 25 - i; float f1 = f * (float) j; -@@ -1006,22 +1157,127 @@ +@@ -1065,22 +1224,129 @@ } } @@ -385,7 +402,7 @@ + Function hardHat = new Function() { + @Override + public Double apply(Double f) { -+ if ((damagesource == DamageSource.ANVIL || damagesource == DamageSource.FALLING_BLOCK) && EntityLiving.this.getEquipment(EnumItemSlot.HEAD) != null) { ++ if ((damagesource == DamageSource.ANVIL || damagesource == DamageSource.FALLING_BLOCK) && !EntityLiving.this.getEquipment(EnumItemSlot.HEAD).isEmpty()) { + return -(f - (f * 0.75F)); + + } @@ -398,7 +415,7 @@ + Function blocking = new Function() { + @Override + public Double apply(Double f) { -+ return -((EntityLiving.this.d(damagesource)) ? ((damagesource.a()) ? f : (f - (f * 0.33F))) : 0.0); // PAIL: rename ++ return -((EntityLiving.this.applyBlockingModifier(damagesource)) ? f : 0.0); + } + }; + float blockingModifier = blocking.apply((double) f).floatValue(); @@ -463,14 +480,13 @@ + this.damageArmor(armorDamage); + } + -+ // Apply blocking code ++ // Apply blocking code // PAIL: steal from above + if (event.getDamage(DamageModifier.BLOCKING) < 0) { -+ this.k((float) event.getDamage()); // PAIL: rename -+ if (damagesource.i() instanceof EntityLiving) {// PAIL: rename -+ ((EntityLiving) damagesource.i()).a(EntityLiving.this, 0.5F, EntityLiving.this.locX - damagesource.i().locX, EntityLiving.this.locZ - damagesource.i().locZ); -+ } -+ if (f <= 0) { -+ return false; ++ this.damageShield((float) -event.getDamage(DamageModifier.BLOCKING)); ++ Entity entity = damagesource.i(); ++ ++ if (entity instanceof EntityLiving) { ++ this.c((EntityLiving) entity); + } + } + @@ -494,23 +510,26 @@ + if (!human) { + this.setAbsorptionHearts(this.getAbsorptionHearts() - f); + } ++ ++ return true; ++ } else { ++ return event.getDamage(DamageModifier.BLOCKING) < 0; + // CraftBukkit end } -+ return true; } + return false; // CraftBukkit } public CombatTracker getCombatTracker() { -@@ -1088,6 +1344,7 @@ +@@ -1147,6 +1413,7 @@ public AttributeMapBase getAttributeMap() { - if (this.br == null) { - this.br = new AttributeMapServer(); -+ this.craftAttributes = new CraftAttributeMap(br); // CraftBukkit // PAIL: rename + if (this.attributeMap == null) { + this.attributeMap = new AttributeMapServer(); ++ this.craftAttributes = new CraftAttributeMap(attributeMap); // CraftBukkit } - return this.br; -@@ -1376,6 +1633,7 @@ + return this.attributeMap; +@@ -1438,6 +1705,7 @@ } if (this.onGround && !this.world.isClientSide) { @@ -518,7 +537,7 @@ this.setFlag(7, false); } } else { -@@ -1736,6 +1994,7 @@ +@@ -1798,6 +2066,7 @@ } if (!this.world.isClientSide) { @@ -526,7 +545,7 @@ this.setFlag(7, flag); } -@@ -1824,11 +2083,11 @@ +@@ -1895,11 +2164,11 @@ } public boolean isInteractable() { @@ -535,18 +554,18 @@ } public boolean isCollidable() { -- return !this.dead; -+ return !this.dead && this.collides; // CraftBukkit +- return this.isAlive() && !this.m_(); ++ return this.isAlive() && !this.m_() && this.collides; // CraftBukkit } protected void ap() { -@@ -1965,7 +2224,22 @@ +@@ -2036,7 +2305,23 @@ protected void v() { - if (this.bo != null && this.cx()) { - this.a(this.bo, 16); -- ItemStack itemstack = this.bo.a(this.world, this); + if (!this.activeItem.isEmpty() && this.isHandRaised()) { + this.a(this.activeItem, 16); +- this.a(this.cz(), this.activeItem.a(this.world, this)); + // CraftBukkit start - fire PlayerItemConsumeEvent -+ org.bukkit.inventory.ItemStack craftItem = CraftItemStack.asBukkitCopy(this.bo); // PAIL: rename ++ org.bukkit.inventory.ItemStack craftItem = CraftItemStack.asBukkitCopy(this.activeItem); + PlayerItemConsumeEvent event = new PlayerItemConsumeEvent((Player) this.getBukkitEntity(), craftItem); + world.getServer().getPluginManager().callEvent(event); + @@ -559,12 +578,13 @@ + return; + } + -+ ItemStack itemstack = (craftItem.equals(event.getItem())) ? this.bo.a(this.world, this) : CraftItemStack.asNMSCopy(event.getItem()).a(world, this); ++ ItemStack itemstack = (craftItem.equals(event.getItem())) ? this.activeItem.a(this.world, this) : CraftItemStack.asNMSCopy(event.getItem()).a(world, this); ++ this.a(this.cz(), itemstack); + // CraftBukkit end + this.cF(); + } - if (itemstack != null && itemstack.count == 0) { - itemstack = null; -@@ -2051,10 +2325,18 @@ +@@ -2115,10 +2400,18 @@ } if (flag1) { diff --git a/nms-patches/EntityLlamaSpit.patch b/nms-patches/EntityLlamaSpit.patch new file mode 100644 index 0000000000..e45072d4ab --- /dev/null +++ b/nms-patches/EntityLlamaSpit.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/server/EntityLlamaSpit.java ++++ b/net/minecraft/server/EntityLlamaSpit.java +@@ -7,7 +7,7 @@ + + public class EntityLlamaSpit extends Entity implements IProjectile { + +- public EntityLlama shooter; ++ public EntityLiving shooter; // CraftBukkit - type + private NBTTagCompound b; + + public EntityLlamaSpit(World world) { diff --git a/nms-patches/EntityMinecartAbstract.patch b/nms-patches/EntityMinecartAbstract.patch index 7075019165..e7b2a9ad40 100644 --- a/nms-patches/EntityMinecartAbstract.patch +++ b/nms-patches/EntityMinecartAbstract.patch @@ -17,8 +17,8 @@ private static final DataWatcherObject a = DataWatcher.a(EntityMinecartAbstract.class, DataWatcherRegistry.b); @@ -23,6 +32,17 @@ + private double ax; private double ay; - private double az; + // CraftBukkit start + public boolean slowWhenEmpty = true; @@ -79,10 +79,10 @@ this.az(); if (flag && !this.hasCustomName()) { this.die(); -@@ -150,6 +194,14 @@ +@@ -146,6 +190,14 @@ } - public void m() { + public void A_() { + // CraftBukkit start + double prevX = this.locX; + double prevY = this.locY; @@ -94,16 +94,16 @@ if (this.getType() > 0) { this.d(this.getType() - 1); } -@@ -170,7 +222,7 @@ +@@ -166,7 +218,7 @@ i = this.V(); - if (this.al) { + if (this.ak) { - if (minecraftserver.getAllowNether()) { + if (true || minecraftserver.getAllowNether()) { // CraftBukkit - multi-world should still allow teleport even if default vanilla nether disabled - if (!this.isPassenger() && this.am++ >= i) { - this.am = i; + if (!this.isPassenger() && this.al++ >= i) { + this.al = i; this.portalCooldown = this.aE(); -@@ -270,6 +322,18 @@ +@@ -266,6 +318,18 @@ } this.setYawPitch(this.yaw, this.pitch); @@ -122,7 +122,7 @@ if (this.v() == EntityMinecartAbstract.EnumMinecartType.RIDEABLE && this.motX * this.motX + this.motZ * this.motZ > 0.01D) { List list = this.world.getEntities(this, this.getBoundingBox().grow(0.20000000298023224D, 0.0D, 0.20000000298023224D), IEntitySelector.a(this)); -@@ -278,8 +342,24 @@ +@@ -274,8 +338,24 @@ Entity entity = (Entity) list.get(l); if (!(entity instanceof EntityHuman) && !(entity instanceof EntityIronGolem) && !(entity instanceof EntityMinecartAbstract) && !this.isVehicle() && !entity.isPassenger()) { @@ -147,7 +147,7 @@ entity.collide(this); } } -@@ -291,6 +371,14 @@ +@@ -287,6 +367,14 @@ Entity entity1 = (Entity) iterator.next(); if (!this.w(entity1) && entity1.isCollidable() && entity1 instanceof EntityMinecartAbstract) { @@ -162,7 +162,7 @@ entity1.collide(this); } } -@@ -301,7 +389,7 @@ +@@ -297,7 +385,7 @@ } protected double o() { @@ -171,7 +171,7 @@ } public void a(int i, int j, int k, boolean flag) {} -@@ -312,16 +400,20 @@ +@@ -308,16 +396,20 @@ this.motX = MathHelper.a(this.motX, -d0, d0); this.motZ = MathHelper.a(this.motZ, -d0, d0); if (this.onGround) { @@ -185,7 +185,7 @@ + // CraftBukkit end } - this.move(this.motX, this.motY, this.motZ); + this.move(EnumMoveType.SELF, this.motX, this.motY, this.motZ); if (!this.onGround) { - this.motX *= 0.949999988079071D; - this.motY *= 0.949999988079071D; @@ -198,7 +198,7 @@ } } -@@ -509,7 +601,7 @@ +@@ -505,7 +597,7 @@ } protected void r() { @@ -207,7 +207,7 @@ this.motX *= 0.996999979019165D; this.motY *= 0.0D; this.motZ *= 0.996999979019165D; -@@ -854,4 +946,26 @@ +@@ -780,4 +872,26 @@ } } diff --git a/nms-patches/EntityMinecartCommandBlock.patch b/nms-patches/EntityMinecartCommandBlock.patch index 7d98421eaa..1f44e4afca 100644 --- a/nms-patches/EntityMinecartCommandBlock.patch +++ b/nms-patches/EntityMinecartCommandBlock.patch @@ -1,16 +1,12 @@ --- a/net/minecraft/server/EntityMinecartCommandBlock.java +++ b/net/minecraft/server/EntityMinecartCommandBlock.java -@@ -4,9 +4,12 @@ - - public class EntityMinecartCommandBlock extends EntityMinecartAbstract { - -- private static final DataWatcherObject a = DataWatcher.a(EntityMinecartCommandBlock.class, DataWatcherRegistry.d); -+ public static final DataWatcherObject a = DataWatcher.a(EntityMinecartCommandBlock.class, DataWatcherRegistry.d); // PAIL: private -> public +@@ -5,6 +5,9 @@ + public static final DataWatcherObject COMMAND = DataWatcher.a(EntityMinecartCommandBlock.class, DataWatcherRegistry.d); private static final DataWatcherObject b = DataWatcher.a(EntityMinecartCommandBlock.class, DataWatcherRegistry.e); private final CommandBlockListenerAbstract c = new CommandBlockListenerAbstract() { + { + this.sender = (org.bukkit.craftbukkit.entity.CraftMinecartCommand) EntityMinecartCommandBlock.this.getBukkitEntity(); // CraftBukkit - Set the sender + } public void i() { - EntityMinecartCommandBlock.this.getDataWatcher().set(EntityMinecartCommandBlock.a, this.getCommand()); + EntityMinecartCommandBlock.this.getDataWatcher().set(EntityMinecartCommandBlock.COMMAND, this.getCommand()); EntityMinecartCommandBlock.this.getDataWatcher().set(EntityMinecartCommandBlock.b, this.l()); diff --git a/nms-patches/EntityMinecartContainer.patch b/nms-patches/EntityMinecartContainer.patch index 452fa392e8..15037a6063 100644 --- a/nms-patches/EntityMinecartContainer.patch +++ b/nms-patches/EntityMinecartContainer.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/server/EntityMinecartContainer.java +++ b/net/minecraft/server/EntityMinecartContainer.java -@@ -2,14 +2,57 @@ - +@@ -3,6 +3,13 @@ + import java.util.Iterator; import java.util.Random; import javax.annotation.Nullable; +// CraftBukkit start @@ -14,9 +14,7 @@ public abstract class EntityMinecartContainer extends EntityMinecartAbstract implements ITileInventory, ILootable { -- private ItemStack[] items = new ItemStack[36]; -+ private ItemStack[] items = new ItemStack[27]; // CraftBukkit - 36 -> 27 - private boolean b = true; +@@ -11,6 +18,42 @@ private MinecraftKey c; private long d; @@ -24,7 +22,7 @@ + public List transaction = new java.util.ArrayList(); + private int maxStack = MAX_STACK; + -+ public ItemStack[] getContents() { ++ public List getContents() { + return this.items; + } + @@ -58,8 +56,8 @@ + public EntityMinecartContainer(World world) { super(world); - } -@@ -75,7 +118,7 @@ + this.items = NonNullList.a(36, ItemStack.a); +@@ -93,7 +136,7 @@ } public int getMaxStackSize() { diff --git a/nms-patches/EntityMonster.patch b/nms-patches/EntityMonster.patch index 5832a4dc02..0a19ca7d49 100644 --- a/nms-patches/EntityMonster.patch +++ b/nms-patches/EntityMonster.patch @@ -8,7 +8,7 @@ public abstract class EntityMonster extends EntityCreature implements IMonster { public EntityMonster(World world) { -@@ -79,7 +81,14 @@ +@@ -75,7 +77,14 @@ int j = EnchantmentManager.getFireAspectEnchantmentLevel(this); if (j > 0) { diff --git a/nms-patches/EntityMushroomCow.patch b/nms-patches/EntityMushroomCow.patch index 8a64125238..4fa155b34e 100644 --- a/nms-patches/EntityMushroomCow.patch +++ b/nms-patches/EntityMushroomCow.patch @@ -8,10 +8,10 @@ public class EntityMushroomCow extends EntityCow { -@@ -24,6 +25,14 @@ +@@ -27,6 +28,14 @@ return true; - } else if (itemstack != null && itemstack.getItem() == Items.SHEARS && this.getAge() >= 0) { + } else if (itemstack.getItem() == Items.SHEARS && this.getAge() >= 0) { + // CraftBukkit start + PlayerShearEntityEvent event = new PlayerShearEntityEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), this.getBukkitEntity()); + this.world.getServer().getPluginManager().callEvent(event); diff --git a/nms-patches/EntityOcelot.patch b/nms-patches/EntityOcelot.patch index 7d433fa41a..6574350a93 100644 --- a/nms-patches/EntityOcelot.patch +++ b/nms-patches/EntityOcelot.patch @@ -27,7 +27,7 @@ @Nullable protected MinecraftKey J() { -@@ -131,7 +135,8 @@ +@@ -133,7 +137,8 @@ } if (!this.world.isClientSide) { @@ -37,7 +37,7 @@ this.setTamed(true); this.setCatType(1 + this.world.random.nextInt(3)); this.setOwnerUUID(entityhuman.getUniqueID()); -@@ -240,7 +245,7 @@ +@@ -238,7 +243,7 @@ entityocelot.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, 0.0F); entityocelot.setAgeRaw(-24000); diff --git a/nms-patches/EntityPig.patch b/nms-patches/EntityPig.patch index a5618b021e..81061ed483 100644 --- a/nms-patches/EntityPig.patch +++ b/nms-patches/EntityPig.patch @@ -8,8 +8,8 @@ + public class EntityPig extends EntityAnimal { - private static final DataWatcherObject bx = DataWatcher.a(EntityPig.class, DataWatcherRegistry.h); -@@ -137,6 +139,12 @@ + private static final DataWatcherObject bw = DataWatcher.a(EntityPig.class, DataWatcherRegistry.h); +@@ -144,6 +146,12 @@ if (!this.world.isClientSide && !this.dead) { EntityPigZombie entitypigzombie = new EntityPigZombie(this.world); @@ -22,7 +22,7 @@ entitypigzombie.setSlot(EnumItemSlot.MAINHAND, new ItemStack(Items.GOLDEN_SWORD)); entitypigzombie.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, this.pitch); entitypigzombie.setAI(this.hasAI()); -@@ -145,7 +153,8 @@ +@@ -152,7 +160,8 @@ entitypigzombie.setCustomNameVisible(this.getCustomNameVisible()); } diff --git a/nms-patches/EntityPlayer.patch b/nms-patches/EntityPlayer.patch index d5fa237677..0ec9bbfa67 100644 --- a/nms-patches/EntityPlayer.patch +++ b/nms-patches/EntityPlayer.patch @@ -19,7 +19,7 @@ + public class EntityPlayer extends EntityHuman implements ICrafting { - private static final Logger bS = LogManager.getLogger(); + private static final Logger bR = LogManager.getLogger(); @@ -44,6 +57,18 @@ public int ping; public boolean viewingCredits; @@ -39,7 +39,15 @@ public EntityPlayer(MinecraftServer minecraftserver, WorldServer worldserver, GameProfile gameprofile, PlayerInteractManager playerinteractmanager) { super(worldserver, gameprofile); playerinteractmanager.player = this; -@@ -74,6 +99,11 @@ +@@ -67,13 +92,18 @@ + + this.server = minecraftserver; + this.bU = minecraftserver.getPlayerList().a((EntityHuman) this); +- this.P = 0.0F; ++ this.P = 1.0F; // CraftBukkit - hit when sneaking + this.setPositionRotation(blockposition, 0.0F, 0.0F); + + while (!worldserver.getCubes(this, this.getBoundingBox()).isEmpty() && this.locY < 255.0D) { this.setPosition(this.locX, this.locY + 1.0D, this.locZ); } @@ -96,7 +104,7 @@ @@ -134,6 +190,11 @@ } - public void m() { + public void A_() { + // CraftBukkit start + if (this.joining) { + this.joining = false; @@ -108,14 +116,14 @@ @@ -193,7 +254,7 @@ } - if (this.getHealth() != this.lastHealthSent || this.cd != this.foodData.getFoodLevel() || this.foodData.getSaturationLevel() == 0.0F != this.ce) { + if (this.getHealth() != this.lastHealthSent || this.cc != this.foodData.getFoodLevel() || this.foodData.getSaturationLevel() == 0.0F != this.cd) { - this.playerConnection.sendPacket(new PacketPlayOutUpdateHealth(this.getHealth(), this.foodData.getFoodLevel(), this.foodData.getSaturationLevel())); + this.playerConnection.sendPacket(new PacketPlayOutUpdateHealth(this.getBukkitEntity().getScaledHealth(), this.foodData.getFoodLevel(), this.foodData.getSaturationLevel())); // CraftBukkit this.lastHealthSent = this.getHealth(); - this.cd = this.foodData.getFoodLevel(); - this.ce = this.foodData.getSaturationLevel() == 0.0F; + this.cc = this.foodData.getFoodLevel(); + this.cd = this.foodData.getSaturationLevel() == 0.0F; @@ -214,6 +275,12 @@ - this.a(IScoreboardCriteria.i, MathHelper.f((float) this.bY)); + this.a(IScoreboardCriteria.i, MathHelper.f((float) this.bX)); } + // CraftBukkit start - Force max health updates @@ -124,9 +132,9 @@ + } + // CraftBukkit end + - if (this.getArmorStrength() != this.bZ) { - this.bZ = this.getArmorStrength(); - this.a(IScoreboardCriteria.j, MathHelper.f((float) this.bZ)); + if (this.getArmorStrength() != this.bY) { + this.bY = this.getArmorStrength(); + this.a(IScoreboardCriteria.j, MathHelper.f((float) this.bY)); @@ -238,6 +305,16 @@ this.o(); } @@ -159,7 +167,7 @@ scoreboardscore.setScore(i); } -@@ -302,30 +378,79 @@ +@@ -302,31 +378,61 @@ boolean flag = this.world.getGameRules().getBoolean("showDeathMessages"); this.playerConnection.sendPacket(new PacketPlayOutCombatEvent(this.getCombatTracker(), PacketPlayOutCombatEvent.EnumCombatEventType.ENTITY_DIED, flag)); @@ -169,34 +177,24 @@ + if (this.dead) { + return; + } -+ java.util.List loot = new java.util.ArrayList(); ++ java.util.List loot = new java.util.ArrayList(this.inventory.getSize()); + boolean keepInventory = this.world.getGameRules().getBoolean("keepInventory"); + + if (!keepInventory) { -+ for (int i = 0; i < this.inventory.items.length; ++i) { -+ if (this.inventory.items[i] != null) { -+ loot.add(CraftItemStack.asCraftMirror(this.inventory.items[i])); -+ } -+ } -+ for (int i = 0; i < this.inventory.armor.length; ++i) { -+ if (this.inventory.armor[i] != null) { -+ loot.add(CraftItemStack.asCraftMirror(this.inventory.armor[i])); -+ } -+ } -+ for (int i = 0; i < this.inventory.extraSlots.length; ++i) { -+ if (this.inventory.extraSlots[i] != null) { -+ loot.add(CraftItemStack.asCraftMirror(this.inventory.extraSlots[i])); ++ for (ItemStack item : this.inventory.getContents()) { ++ if (!EnchantmentManager.c(item)) { // PAIL: shouldNotDrop (Vanishing enchant) ++ loot.add(CraftItemStack.asCraftMirror(item)); + } + } + } ++ ++ IChatBaseComponent chatmessage = this.getCombatTracker().getDeathMessage(); - if (scoreboardteambase != null && scoreboardteambase.getDeathMessageVisibility() != ScoreboardTeamBase.EnumNameTagVisibility.ALWAYS) { - if (scoreboardteambase.getDeathMessageVisibility() == ScoreboardTeamBase.EnumNameTagVisibility.HIDE_FOR_OTHER_TEAMS) { - this.server.getPlayerList().a((EntityHuman) this, this.getCombatTracker().getDeathMessage()); - } else if (scoreboardteambase.getDeathMessageVisibility() == ScoreboardTeamBase.EnumNameTagVisibility.HIDE_FOR_OWN_TEAM) { - this.server.getPlayerList().b((EntityHuman) this, this.getCombatTracker().getDeathMessage()); -+ IChatBaseComponent chatmessage = this.getCombatTracker().getDeathMessage(); -+ + String deathmessage = chatmessage.toPlainText(); + org.bukkit.event.entity.PlayerDeathEvent event = CraftEventFactory.callPlayerDeathEvent(this, loot, deathmessage, keepInventory); + @@ -222,18 +220,11 @@ } - if (!this.world.getGameRules().getBoolean("keepInventory") && !this.isSpectator()) { -- this.inventory.n(); +- this.cN(); +- this.inventory.o(); + // we clean the player's inventory after the EntityDeathEvent is called so plugins can get the exact state of the inventory. + if (!event.getKeepInventory()) { -+ for (int i = 0; i < this.inventory.items.length; ++i) { -+ this.inventory.items[i] = null; -+ } -+ for (int i = 0; i < this.inventory.armor.length; ++i) { -+ this.inventory.armor[i] = null; -+ } -+ for (int i = 0; i < this.inventory.extraSlots.length; ++i) { -+ this.inventory.extraSlots[i] = null; -+ } ++ this.inventory.clear(); } - Collection collection = this.world.getScoreboard().getObjectivesForCriteria(IScoreboardCriteria.d); @@ -252,7 +243,7 @@ scoreboardscore.incrementScore(); } -@@ -382,13 +507,15 @@ +@@ -385,13 +491,15 @@ } private boolean canPvP() { @@ -270,7 +261,7 @@ this.world.kill(this); if (!this.viewingCredits) { this.viewingCredits = true; -@@ -409,7 +536,10 @@ +@@ -412,7 +520,10 @@ this.b((Statistic) AchievementList.y); } @@ -282,7 +273,7 @@ this.playerConnection.sendPacket(new PacketPlayOutWorldEvent(1032, BlockPosition.ZERO, 0, false)); this.lastSentExp = -1; this.lastHealthSent = -1.0F; -@@ -454,6 +584,7 @@ +@@ -457,6 +568,7 @@ } public void a(boolean flag, boolean flag1, boolean flag2) { @@ -290,7 +281,7 @@ if (this.isSleeping()) { this.x().getTracker().sendPacketToEntity(this, new PacketPlayOutAnimation(this, 2)); } -@@ -532,23 +663,48 @@ +@@ -535,23 +647,52 @@ this.playerConnection.sendPacket(new PacketPlayOutOpenSignEditor(tileentitysign.getPosition())); } @@ -302,25 +293,23 @@ public void openTileEntity(ITileEntityContainer itileentitycontainer) { - if (itileentitycontainer instanceof ILootable && ((ILootable) itileentitycontainer).b() != null && this.isSpectator()) { -- this.sendMessage((new ChatMessage("container.spectatorCantOpen", new Object[0])).setChatModifier((new ChatModifier()).setColor(EnumChatFormat.RED))); -- } else { -- this.nextContainerCounter(); -- this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.containerCounter, itileentitycontainer.getContainerName(), itileentitycontainer.getScoreboardDisplayName())); -- this.activeContainer = itileentitycontainer.createContainer(this.inventory, this); -- this.activeContainer.windowId = this.containerCounter; -- this.activeContainer.addSlotListener(this); + // CraftBukkit start - Inventory open hook -+ Container container = CraftEventFactory.callInventoryOpenEvent(this, itileentitycontainer.createContainer(this.inventory, this)); -+ if (container == null) { -+ return; ++ if (false && itileentitycontainer instanceof ILootable && ((ILootable) itileentitycontainer).b() != null && this.isSpectator()) { + this.a((new ChatMessage("container.spectatorCantOpen", new Object[0])).setChatModifier((new ChatModifier()).setColor(EnumChatFormat.RED)), true); + } else { ++ boolean cancelled = itileentitycontainer instanceof ILootable && ((ILootable) itileentitycontainer).b() != null && this.isSpectator(); ++ Container container = CraftEventFactory.callInventoryOpenEvent(this, itileentitycontainer.createContainer(this.inventory, this), cancelled); ++ if (container == null) { ++ return; ++ } + this.nextContainerCounter(); + this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.containerCounter, itileentitycontainer.getContainerName(), itileentitycontainer.getScoreboardDisplayName())); +- this.activeContainer = itileentitycontainer.createContainer(this.inventory, this); ++ this.activeContainer = container; ++ // CraftBukkit end + this.activeContainer.windowId = this.containerCounter; + this.activeContainer.addSlotListener(this); } -+ -+ this.nextContainerCounter(); -+ this.activeContainer = container; -+ this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.containerCounter, itileentitycontainer.getContainerName(), itileentitycontainer.getScoreboardDisplayName())); -+ // CraftBukkit end -+ this.activeContainer.windowId = this.containerCounter; -+ this.activeContainer.addSlotListener(this); } public void openContainer(IInventory iinventory) { @@ -329,7 +318,7 @@ + boolean cancelled = false; + if (iinventory instanceof ITileInventory) { + ITileInventory itileinventory = (ITileInventory) iinventory; -+ cancelled = itileinventory.x_() && !this.a(itileinventory.y_()) && !this.isSpectator(); // PAIL: rename ++ cancelled = itileinventory.isLocked() && !this.a(itileinventory.getLock()) && !this.isSpectator(); + } + + Container container; @@ -346,12 +335,12 @@ + // CraftBukkit end + if (iinventory instanceof ILootable && ((ILootable) iinventory).b() != null && this.isSpectator()) { - this.sendMessage((new ChatMessage("container.spectatorCantOpen", new Object[0])).setChatModifier((new ChatModifier()).setColor(EnumChatFormat.RED))); + this.a((new ChatMessage("container.spectatorCantOpen", new Object[0])).setChatModifier((new ChatModifier()).setColor(EnumChatFormat.RED)), true); } else { -@@ -562,18 +718,21 @@ - if (itileinventory.x_() && !this.a(itileinventory.y_()) && !this.isSpectator()) { +@@ -565,18 +706,21 @@ + if (itileinventory.isLocked() && !this.a(itileinventory.getLock()) && !this.isSpectator()) { this.playerConnection.sendPacket(new PacketPlayOutChat(new ChatMessage("container.isLocked", new Object[] { iinventory.getScoreboardDisplayName()}), (byte) 2)); - this.playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect(SoundEffects.W, SoundCategory.BLOCKS, this.locX, this.locY, this.locZ, 1.0F, 1.0F)); + this.playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect(SoundEffects.Y, SoundCategory.BLOCKS, this.locX, this.locY, this.locZ, 1.0F, 1.0F)); + iinventory.closeContainer(this); // CraftBukkit return; } @@ -372,7 +361,7 @@ this.activeContainer.windowId = this.containerCounter; this.activeContainer.addSlotListener(this); -@@ -581,8 +740,14 @@ +@@ -584,8 +728,14 @@ } public void openTrade(IMerchant imerchant) { @@ -388,14 +377,12 @@ this.activeContainer.windowId = this.containerCounter; this.activeContainer.addSlotListener(this); InventoryMerchant inventorymerchant = ((ContainerMerchant) this.activeContainer).e(); -@@ -601,14 +766,21 @@ - +@@ -605,13 +755,20 @@ } -- public void openHorseInventory(EntityHorse entityhorse, IInventory iinventory) { -+ public void a(EntityHorse entityhorse, IInventory iinventory) { + public void openHorseInventory(EntityHorseAbstract entityhorseabstract, IInventory iinventory) { + // CraftBukkit start - Inventory open hook -+ Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerHorse(this.inventory, iinventory, entityhorse, this)); ++ Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerHorse(this.inventory, iinventory, entityhorseabstract, this)); + if (container == null) { + iinventory.closeContainer(this); + return; @@ -406,15 +393,15 @@ } this.nextContainerCounter(); - this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.containerCounter, "EntityHorse", iinventory.getScoreboardDisplayName(), iinventory.getSize(), entityhorse.getId())); -- this.activeContainer = new ContainerHorse(this.inventory, iinventory, entityhorse, this); -+ this.activeContainer = container; + this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.containerCounter, "EntityHorse", iinventory.getScoreboardDisplayName(), iinventory.getSize(), entityhorseabstract.getId())); +- this.activeContainer = new ContainerHorse(this.inventory, iinventory, entityhorseabstract, this); ++ this.activeContainer = container; // CraftBukkit this.activeContainer.windowId = this.containerCounter; this.activeContainer.addSlotListener(this); } -@@ -645,6 +817,11 @@ - public void a(Container container, List list) { - this.playerConnection.sendPacket(new PacketPlayOutWindowItems(container.windowId, list)); +@@ -648,6 +805,11 @@ + public void a(Container container, NonNullList nonnulllist) { + this.playerConnection.sendPacket(new PacketPlayOutWindowItems(container.windowId, nonnulllist)); this.playerConnection.sendPacket(new PacketPlayOutSetSlot(-1, -1, this.inventory.getCarried())); + // CraftBukkit start - Send a Set Slot to update the crafting result slot + if (java.util.EnumSet.of(InventoryType.CRAFTING,InventoryType.WORKBENCH).contains(container.getBukkitView().getType())) { @@ -424,7 +411,7 @@ } public void setContainerData(Container container, int i, int j) { -@@ -659,6 +836,7 @@ +@@ -662,6 +824,7 @@ } public void closeInventory() { @@ -432,24 +419,25 @@ this.playerConnection.sendPacket(new PacketPlayOutCloseWindow(this.activeContainer.windowId)); this.s(); } -@@ -740,7 +918,16 @@ +@@ -743,8 +906,17 @@ public void triggerHealthUpdate() { this.lastHealthSent = -1.0E8F; + this.lastSentExp = -1; // CraftBukkit - Added to reset -+ } -+ + } + + // CraftBukkit start - Support multi-line messages + public void sendMessage(IChatBaseComponent[] ichatbasecomponent) { + for (IChatBaseComponent component : ichatbasecomponent) { + this.sendMessage(component); + } - } ++ } + // CraftBukkit end - - public void b(IChatBaseComponent ichatbasecomponent) { - this.playerConnection.sendPacket(new PacketPlayOutChat(ichatbasecomponent)); -@@ -801,6 +988,8 @@ ++ + public void a(IChatBaseComponent ichatbasecomponent, boolean flag) { + this.playerConnection.sendPacket(new PacketPlayOutChat(ichatbasecomponent, (byte) (flag ? 2 : 0))); + } +@@ -804,6 +976,8 @@ } public void a(EnumGamemode enumgamemode) { @@ -458,15 +446,15 @@ this.playerInteractManager.setGameMode(enumgamemode); this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(3, (float) enumgamemode.getId())); if (enumgamemode == EnumGamemode.SPECTATOR) { -@@ -811,6 +1000,7 @@ +@@ -814,6 +988,7 @@ this.updateAbilities(); - this.cv(); + this.cw(); + // CraftBukkit end */ } public boolean isSpectator() { -@@ -826,6 +1016,7 @@ +@@ -829,6 +1004,7 @@ } public boolean a(int i, String s) { @@ -474,7 +462,7 @@ if ("seed".equals(s) && !this.server.aa()) { return true; } else if (!"tell".equals(s) && !"help".equals(s) && !"me".equals(s) && !"trigger".equals(s)) { -@@ -839,6 +1030,15 @@ +@@ -842,6 +1018,15 @@ } else { return true; } @@ -490,7 +478,7 @@ } public String A() { -@@ -850,6 +1050,12 @@ +@@ -853,6 +1038,12 @@ } public void a(PacketPlayInSettings packetplayinsettings) { @@ -501,9 +489,9 @@ + } + // CraftBukkit end this.locale = packetplayinsettings.a(); - this.ch = packetplayinsettings.c(); - this.ci = packetplayinsettings.d(); -@@ -938,7 +1144,7 @@ + this.cg = packetplayinsettings.c(); + this.ch = packetplayinsettings.d(); +@@ -941,7 +1132,7 @@ @Nullable public IChatBaseComponent getPlayerListName() { @@ -512,7 +500,7 @@ } public void a(EnumHand enumhand) { -@@ -955,11 +1161,145 @@ +@@ -958,11 +1149,145 @@ } public void M() { @@ -618,7 +606,7 @@ + // SPIGOT-1903, MC-98153 + public void forceSetPositionRotation(double x, double y, double z, float yaw, float pitch) { + this.setPositionRotation(x, y, z, yaw, pitch); -+ this.playerConnection.d(); ++ this.playerConnection.syncPosition(); + } + + public void reset() { diff --git a/nms-patches/EntityPotion.patch b/nms-patches/EntityPotion.patch index ef72031596..ccef405fb2 100644 --- a/nms-patches/EntityPotion.patch +++ b/nms-patches/EntityPotion.patch @@ -1,134 +1,117 @@ --- a/net/minecraft/server/EntityPotion.java +++ b/net/minecraft/server/EntityPotion.java -@@ -7,6 +7,13 @@ +@@ -6,6 +6,12 @@ + import javax.annotation.Nullable; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; - +// CraftBukkit start +import java.util.HashMap; -+ ++import java.util.Map; +import org.bukkit.craftbukkit.entity.CraftLivingEntity; +import org.bukkit.entity.LivingEntity; +// CraftBukkit end -+ + public class EntityPotion extends EntityProjectile { - private static final DataWatcherObject> d = DataWatcher.a(EntityPotion.class, DataWatcherRegistry.f); -@@ -78,10 +85,11 @@ - this.world.triggerEffect(2002, new BlockPosition(this), PotionRegistry.a(potionregistry)); - this.die(); - } else { -- if (!list.isEmpty()) { -+ if (true || !list.isEmpty()) { // CraftBukkit - Call event even if no effects to apply - if (this.isLingering()) { - EntityAreaEffectCloud entityareaeffectcloud = new EntityAreaEffectCloud(this.world, this.locX, this.locY, this.locZ); +@@ -87,7 +93,7 @@ -+ entityareaeffectcloud.projectileSource = this.projectileSource; // CraftBukkit - entityareaeffectcloud.setSource(this.getShooter()); - entityareaeffectcloud.setRadius(3.0F); - entityareaeffectcloud.setRadiusOnUse(-0.5F); -@@ -96,11 +104,21 @@ - entityareaeffectcloud.a(new MobEffect(mobeffect.getMobEffect(), mobeffect.getDuration(), mobeffect.getAmplifier())); + if (flag) { + this.n(); +- } else if (!list.isEmpty()) { ++ } else if (true || !list.isEmpty()) { // CraftBukkit - Call event even if no effects to apply + if (this.isLingering()) { + this.a(itemstack, potionregistry); + } else { +@@ -124,6 +130,7 @@ + private void a(MovingObjectPosition movingobjectposition, List list) { + AxisAlignedBB axisalignedbb = this.getBoundingBox().grow(4.0D, 2.0D, 4.0D); + List list1 = this.world.a(EntityLiving.class, axisalignedbb); ++ Map affected = new HashMap(); // CraftBukkit + + if (!list1.isEmpty()) { + Iterator iterator = list1.iterator(); +@@ -141,21 +148,46 @@ + d1 = 1.0D; } -- this.world.addEntity(entityareaeffectcloud); +- Iterator iterator1 = list.iterator(); + // CraftBukkit start -+ org.bukkit.event.entity.LingeringPotionSplashEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callLingeringPotionSplashEvent(this, entityareaeffectcloud); -+ if (!(event.isCancelled() || entityareaeffectcloud.dead)) { -+ this.world.addEntity(entityareaeffectcloud); -+ } else { -+ entityareaeffectcloud.dead = true; -+ } -+ // CraftBukkit end - } else { - AxisAlignedBB axisalignedbb = this.getBoundingBox().grow(4.0D, 2.0D, 4.0D); - List list1 = this.world.a(EntityLiving.class, axisalignedbb); - -+ // CraftBukkit -+ HashMap affected = new HashMap(); ++ affected.put((LivingEntity) entityliving.getBukkitEntity(), d1); ++ } ++ } ++ } ++ } + - if (!list1.isEmpty()) { - Iterator iterator1 = list1.iterator(); ++ org.bukkit.event.entity.PotionSplashEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPotionSplashEvent(this, affected); ++ if (!event.isCancelled() && list != null && !list.isEmpty()) { // do not process effects if there are no effects to process ++ for (LivingEntity victim : event.getAffectedEntities()) { ++ if (!(victim instanceof CraftLivingEntity)) { ++ continue; ++ } -@@ -117,21 +135,45 @@ - d1 = 1.0D; - } - -- Iterator iterator2 = list.iterator(); -+ // CraftBukkit start -+ affected.put((LivingEntity) entityliving.getBukkitEntity(), d1); -+ } -+ } -+ } -+ } - -- while (iterator2.hasNext()) { -- MobEffect mobeffect1 = (MobEffect) iterator2.next(); -- MobEffectList mobeffectlist = mobeffect1.getMobEffect(); +- while (iterator1.hasNext()) { +- MobEffect mobeffect = (MobEffect) iterator1.next(); +- MobEffectList mobeffectlist = mobeffect.getMobEffect(); - -- if (mobeffectlist.isInstant()) { -- mobeffectlist.applyInstantEffect(this, this.getShooter(), entityliving, mobeffect1.getAmplifier(), d1); -- } else { -- int i = (int) (d1 * (double) mobeffect1.getDuration() + 0.5D); +- if (mobeffectlist.isInstant()) { +- mobeffectlist.applyInstantEffect(this, this.getShooter(), entityliving, mobeffect.getAmplifier(), d1); +- } else { +- int i = (int) (d1 * (double) mobeffect.getDuration() + 0.5D); - -- if (i > 20) { -- entityliving.addEffect(new MobEffect(mobeffectlist, i, mobeffect1.getAmplifier())); -- } -- } -+ org.bukkit.event.entity.PotionSplashEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPotionSplashEvent(this, affected); -+ if (!event.isCancelled() && list != null && !list.isEmpty()) { // do not process effects if there are no effects to process -+ for (LivingEntity victim : event.getAffectedEntities()) { -+ if (!(victim instanceof CraftLivingEntity)) { -+ continue; -+ } +- if (i > 20) { +- entityliving.addEffect(new MobEffect(mobeffectlist, i, mobeffect.getAmplifier(), mobeffect.isAmbient(), mobeffect.isShowParticles())); +- } +- } ++ EntityLiving entityliving = ((CraftLivingEntity) victim).getHandle(); ++ double d1 = event.getIntensity(victim); ++ // CraftBukkit end + -+ EntityLiving entityliving = ((CraftLivingEntity) victim).getHandle(); -+ double d1 = event.getIntensity(victim); -+ // CraftBukkit end ++ Iterator iterator1 = list.iterator(); + -+ Iterator iterator2 = list.iterator(); ++ while (iterator1.hasNext()) { ++ MobEffect mobeffect = (MobEffect) iterator1.next(); ++ MobEffectList mobeffectlist = mobeffect.getMobEffect(); ++ // CraftBukkit start - Abide by PVP settings - for players only! ++ if (!this.world.pvpMode && this.getShooter() instanceof EntityPlayer && entityliving instanceof EntityPlayer && entityliving != this.getShooter()) { ++ int i = MobEffectList.getId(mobeffectlist); ++ // Block SLOWER_MOVEMENT, SLOWER_DIG, HARM, BLINDNESS, HUNGER, WEAKNESS and POISON potions ++ if (i == 2 || i == 4 || i == 7 || i == 15 || i == 17 || i == 18 || i == 19) { ++ continue; ++ } ++ } ++ // CraftBukkit end + -+ while (iterator2.hasNext()) { -+ MobEffect mobeffect1 = (MobEffect) iterator2.next(); -+ MobEffectList mobeffectlist = mobeffect1.getMobEffect(); -+ // CraftBukkit start - Abide by PVP settings - for players only! -+ if (!this.world.pvpMode && this.getShooter() instanceof EntityPlayer && entityliving instanceof EntityPlayer && entityliving != this.getShooter()) { -+ int i = MobEffectList.getId(mobeffectlist); -+ // Block SLOWER_MOVEMENT, SLOWER_DIG, HARM, BLINDNESS, HUNGER, WEAKNESS and POISON potions -+ if (i == 2 || i == 4 || i == 7 || i == 15 || i == 17 || i == 18 || i == 19) { -+ continue; -+ } -+ } -+ // CraftBukkit end -+ if (mobeffectlist.isInstant()) { -+ mobeffectlist.applyInstantEffect(this, this.getShooter(), entityliving, mobeffect1.getAmplifier(), d1); -+ } else { -+ int i = (int) (d1 * (double) mobeffect1.getDuration() + 0.5D); ++ if (mobeffectlist.isInstant()) { ++ mobeffectlist.applyInstantEffect(this, this.getShooter(), entityliving, mobeffect.getAmplifier(), d1); ++ } else { ++ int i = (int) (d1 * (double) mobeffect.getDuration() + 0.5D); + -+ if (i > 20) { -+ entityliving.addEffect(new MobEffect(mobeffectlist, i, mobeffect1.getAmplifier())); - } - } - } -@@ -139,10 +181,10 @@ ++ if (i > 20) { ++ entityliving.addEffect(new MobEffect(mobeffectlist, i, mobeffect.getAmplifier(), mobeffect.isAmbient(), mobeffect.isShowParticles())); } } } -- -- this.world.triggerEffect(2002, new BlockPosition(this), PotionRegistry.a(potionregistry)); -- this.die(); - } -+ -+ this.world.triggerEffect(2002, new BlockPosition(this), PotionRegistry.a(potionregistry)); -+ this.die(); +@@ -167,6 +199,7 @@ + private void a(ItemStack itemstack, PotionRegistry potionregistry) { + EntityAreaEffectCloud entityareaeffectcloud = new EntityAreaEffectCloud(this.world, this.locX, this.locY, this.locZ); + ++ entityareaeffectcloud.projectileSource = this.projectileSource; // CraftBukkit + entityareaeffectcloud.setSource(this.getShooter()); + entityareaeffectcloud.setRadius(3.0F); + entityareaeffectcloud.setRadiusOnUse(-0.5F); +@@ -181,7 +214,14 @@ + entityareaeffectcloud.a(new MobEffect(mobeffect)); } + +- this.world.addEntity(entityareaeffectcloud); ++ // CraftBukkit start ++ org.bukkit.event.entity.LingeringPotionSplashEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callLingeringPotionSplashEvent(this, entityareaeffectcloud); ++ if (!(event.isCancelled() || entityareaeffectcloud.dead)) { ++ this.world.addEntity(entityareaeffectcloud); ++ } else { ++ entityareaeffectcloud.dead = true; ++ } ++ // CraftBukkit end } -@@ -152,6 +194,7 @@ - - private void a(BlockPosition blockposition) { - if (this.world.getType(blockposition).getBlock() == Blocks.FIRE) { -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, Blocks.AIR, 0).isCancelled()) return; // CraftBukkit - this.world.setTypeAndData(blockposition, Blocks.AIR.getBlockData(), 2); - } - + public boolean isLingering() { diff --git a/nms-patches/EntityRabbit.patch b/nms-patches/EntityRabbit.patch index ede26f1e51..890a0efdd1 100644 --- a/nms-patches/EntityRabbit.patch +++ b/nms-patches/EntityRabbit.patch @@ -15,7 +15,7 @@ protected void r() { this.goalSelector.a(1, new PathfinderGoalFloat(this)); -@@ -412,9 +418,23 @@ +@@ -400,9 +406,23 @@ Integer integer = (Integer) iblockdata.get(BlockCarrots.AGE); if (integer.intValue() == 0) { diff --git a/nms-patches/EntitySheep.patch b/nms-patches/EntitySheep.patch index c3ca71f737..c20df3432c 100644 --- a/nms-patches/EntitySheep.patch +++ b/nms-patches/EntitySheep.patch @@ -12,7 +12,7 @@ + public class EntitySheep extends EntityAnimal { - private static final DataWatcherObject bx = DataWatcher.a(EntitySheep.class, DataWatcherRegistry.a); + private static final DataWatcherObject bw = DataWatcher.a(EntitySheep.class, DataWatcherRegistry.a); @@ -12,6 +18,13 @@ public boolean a(EntityHuman entityhuman) { return false; @@ -25,8 +25,8 @@ + } + // CraftBukkit end }, 2, 1); - private static final Map bz = Maps.newEnumMap(EnumColor.class); - private int bB; + private static final Map by = Maps.newEnumMap(EnumColor.class); + private int bA; @@ -26,6 +39,7 @@ this.setSize(0.9F, 1.3F); this.container.setItem(0, new ItemStack(Items.DYE)); @@ -35,9 +35,9 @@ } protected void r() { -@@ -126,11 +140,22 @@ - public boolean a(EntityHuman entityhuman, EnumHand enumhand, @Nullable ItemStack itemstack) { - if (itemstack != null && itemstack.getItem() == Items.SHEARS && !this.isSheared() && !this.isBaby()) { +@@ -128,11 +142,22 @@ + + if (itemstack.getItem() == Items.SHEARS && !this.isSheared() && !this.isBaby()) { if (!this.world.isClientSide) { + // CraftBukkit start + PlayerShearEntityEvent event = new PlayerShearEntityEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), this.getBukkitEntity()); @@ -58,7 +58,7 @@ entityitem.motY += (double) (this.random.nextFloat() * 0.05F); entityitem.motX += (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F); -@@ -217,6 +242,12 @@ +@@ -219,6 +244,12 @@ } public void A() { diff --git a/nms-patches/EntitySilverfish.patch b/nms-patches/EntitySilverfish.patch index 1763e175a5..8e871c3c78 100644 --- a/nms-patches/EntitySilverfish.patch +++ b/nms-patches/EntitySilverfish.patch @@ -1,18 +1,18 @@ --- a/net/minecraft/server/EntitySilverfish.java +++ b/net/minecraft/server/EntitySilverfish.java -@@ -156,6 +156,11 @@ +@@ -157,6 +157,11 @@ IBlockData iblockdata = world.getType(blockposition); if (BlockMonsterEggs.i(iblockdata)) { + // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.silverfish, blockposition, Blocks.MONSTER_EGG, Block.getId(BlockMonsterEggs.getById(iblockdata.getBlock().toLegacyData(iblockdata)))).isCancelled()) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.a, blockposition, Blocks.MONSTER_EGG, Block.getId(BlockMonsterEggs.getById(iblockdata.getBlock().toLegacyData(iblockdata)))).isCancelled()) { + return; + } + // CraftBukkit end world.setTypeAndData(blockposition, Blocks.MONSTER_EGG.getBlockData().set(BlockMonsterEggs.VARIANT, BlockMonsterEggs.EnumMonsterEggVarient.a(iblockdata)), 3); - this.silverfish.doSpawnEffect(); - this.silverfish.die(); -@@ -199,6 +204,11 @@ + this.a.doSpawnEffect(); + this.a.die(); +@@ -200,6 +205,11 @@ IBlockData iblockdata = world.getType(blockposition1); if (iblockdata.getBlock() == Blocks.MONSTER_EGG) { diff --git a/nms-patches/EntitySkeleton.patch b/nms-patches/EntitySkeleton.patch index 2d8665663a..1824371042 100644 --- a/nms-patches/EntitySkeleton.patch +++ b/nms-patches/EntitySkeleton.patch @@ -1,89 +1,19 @@ --- a/net/minecraft/server/EntitySkeleton.java +++ b/net/minecraft/server/EntitySkeleton.java -@@ -2,13 +2,14 @@ - - import java.util.Calendar; - import javax.annotation.Nullable; -+import org.bukkit.event.entity.EntityCombustEvent; // CraftBukkit - - public class EntitySkeleton extends EntityMonster implements IRangedEntity { - - private static final DataWatcherObject a = DataWatcher.a(EntitySkeleton.class, DataWatcherRegistry.b); - private static final DataWatcherObject b = DataWatcher.a(EntitySkeleton.class, DataWatcherRegistry.h); - private final PathfinderGoalBowShoot c = new PathfinderGoalBowShoot(this, 1.0D, 20, 15.0F); -- private final PathfinderGoalMeleeAttack bx = new PathfinderGoalMeleeAttack(this, 1.2D, flag) { -+ private final PathfinderGoalMeleeAttack bx = new PathfinderGoalMeleeAttack(this, 1.2D, false) { // CraftBukkit decompile error flag -> false - public void d() { - super.d(); - EntitySkeleton.this.a(false); -@@ -105,7 +106,14 @@ - } - - if (flag) { -- this.setOnFire(8); -+ // CraftBukkit start -+ EntityCombustEvent event = new EntityCombustEvent(this.getBukkitEntity(), 8); -+ this.world.getServer().getPluginManager().callEvent(event); -+ -+ if (!event.isCancelled()) { -+ this.setOnFire(event.getDuration()); -+ } -+ // CraftBukkit end - } - } - } -@@ -128,7 +136,7 @@ +@@ -34,7 +34,7 @@ } public void die(DamageSource damagesource) { - super.die(damagesource); + // super.die(damagesource); // CraftBukkit - if (damagesource.i() instanceof EntityArrow && damagesource.getEntity() instanceof EntityHuman) { - EntityHuman entityhuman = (EntityHuman) damagesource.getEntity(); - double d0 = entityhuman.locX - this.locX; -@@ -141,6 +149,7 @@ - ((EntityCreeper) damagesource.getEntity()).setCausedHeadDrop(); - this.a(new ItemStack(Items.SKULL, 1, this.getSkeletonType() == EnumSkeletonType.WITHER ? 1 : 0), 0.0F); + if (damagesource.getEntity() instanceof EntityCreeper) { + EntityCreeper entitycreeper = (EntityCreeper) damagesource.getEntity(); + +@@ -43,6 +43,7 @@ + this.a(new ItemStack(Items.SKULL, 1, 0), 0.0F); + } } + super.die(damagesource); // CraftBukkit - moved from above } -@@ -234,7 +243,14 @@ - - flag = flag || EnchantmentManager.a(Enchantments.ARROW_FIRE, (EntityLiving) this) > 0; - if (flag) { -- entitytippedarrow.setOnFire(100); -+ // CraftBukkit start - call EntityCombustEvent -+ EntityCombustEvent event = new EntityCombustEvent(entitytippedarrow.getBukkitEntity(), 100); -+ this.world.getServer().getPluginManager().callEvent(event); -+ -+ if (!event.isCancelled()) { -+ entitytippedarrow.setOnFire(event.getDuration()); -+ } -+ // CraftBukkit end - } - - ItemStack itemstack = this.b(EnumHand.OFF_HAND); -@@ -245,8 +261,20 @@ - entitytippedarrow.a(new MobEffect(MobEffects.SLOWER_MOVEMENT, 600)); - } - -+ // CraftBukkit start -+ org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(this, this.getItemInMainHand(), entitytippedarrow, 0.8F); -+ if (event.isCancelled()) { -+ event.getProjectile().remove(); -+ return; -+ } -+ -+ if (event.getProjectile() == entitytippedarrow.getBukkitEntity()) { -+ world.addEntity(entitytippedarrow); -+ } -+ // CraftBukkit end -+ - this.a(SoundEffects.fz, 1.0F, 1.0F / (this.getRandom().nextFloat() * 0.4F + 0.8F)); -- this.world.addEntity(entitytippedarrow); -+ // this.world.addEntity(entitytippedarrow); // CraftBukkit - moved up - } - - public EnumSkeletonType getSkeletonType() { diff --git a/nms-patches/EntitySkeletonAbstract.patch b/nms-patches/EntitySkeletonAbstract.patch new file mode 100644 index 0000000000..db96e176e2 --- /dev/null +++ b/nms-patches/EntitySkeletonAbstract.patch @@ -0,0 +1,71 @@ +--- a/net/minecraft/server/EntitySkeletonAbstract.java ++++ b/net/minecraft/server/EntitySkeletonAbstract.java +@@ -2,12 +2,13 @@ + + import java.util.Calendar; + import javax.annotation.Nullable; ++import org.bukkit.event.entity.EntityCombustEvent; // CraftBukkit + + public abstract class EntitySkeletonAbstract extends EntityMonster implements IRangedEntity { + + private static final DataWatcherObject a = DataWatcher.a(EntitySkeletonAbstract.class, DataWatcherRegistry.h); + private final PathfinderGoalBowShoot b = new PathfinderGoalBowShoot(this, 1.0D, 20, 15.0F); +- private final PathfinderGoalMeleeAttack c = new PathfinderGoalMeleeAttack(this, 1.2D, flag) { ++ private final PathfinderGoalMeleeAttack c = new PathfinderGoalMeleeAttack(this, 1.2D, false) { // CraftBukkit - decompile error + public void d() { + super.d(); + EntitySkeletonAbstract.this.a(false); +@@ -80,7 +81,14 @@ + } + + if (flag) { +- this.setOnFire(8); ++ // CraftBukkit start ++ EntityCombustEvent event = new EntityCombustEvent(this.getBukkitEntity(), 8); ++ this.world.getServer().getPluginManager().callEvent(event); ++ ++ if (!event.isCancelled()) { ++ this.setOnFire(event.getDuration()); ++ } ++ // CraftBukkit end + } + } + } +@@ -99,7 +107,7 @@ + } + + public void die(DamageSource damagesource) { +- super.die(damagesource); ++ // super.die(damagesource); // CraftBukkit + if (damagesource.i() instanceof EntityArrow && damagesource.getEntity() instanceof EntityHuman) { + EntityHuman entityhuman = (EntityHuman) damagesource.getEntity(); + double d0 = entityhuman.locX - this.locX; +@@ -109,6 +117,7 @@ + entityhuman.b((Statistic) AchievementList.v); + } + } ++ super.die(damagesource); // CraftBukkit - moved from above + + } + +@@ -166,8 +175,19 @@ + double d3 = (double) MathHelper.sqrt(d0 * d0 + d2 * d2); + + entityarrow.shoot(d0, d1 + d3 * 0.20000000298023224D, d2, 1.6F, (float) (14 - this.world.getDifficulty().a() * 4)); ++ // CraftBukkit start ++ org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(this, this.getItemInMainHand(), entityarrow, 0.8F); ++ if (event.isCancelled()) { ++ event.getProjectile().remove(); ++ return; ++ } ++ ++ if (event.getProjectile() == entityarrow.getBukkitEntity()) { ++ world.addEntity(entityarrow); ++ } ++ // CraftBukkit end + this.a(SoundEffects.fV, 1.0F, 1.0F / (this.getRandom().nextFloat() * 0.4F + 0.8F)); +- this.world.addEntity(entityarrow); ++ // this.world.addEntity(entityarrow); // CraftBukkit - moved up + } + + protected EntityArrow a(float f) { diff --git a/nms-patches/EntitySlime.patch b/nms-patches/EntitySlime.patch index 79e5fc2865..6e55a144bb 100644 --- a/nms-patches/EntitySlime.patch +++ b/nms-patches/EntitySlime.patch @@ -10,7 +10,7 @@ public class EntitySlime extends EntityInsentient implements IMonster { -@@ -140,6 +143,18 @@ +@@ -143,6 +146,18 @@ if (!this.world.isClientSide && i > 1 && this.getHealth() <= 0.0F) { int j = 2 + this.random.nextInt(3); @@ -29,9 +29,9 @@ for (int k = 0; k < j; ++k) { float f = ((float) (k % 2) - 0.5F) * (float) i / 4.0F; float f1 = ((float) (k / 2) - 0.5F) * (float) i / 4.0F; -@@ -155,7 +170,7 @@ +@@ -158,7 +173,7 @@ - entityslime.setSize(i / 2); + entityslime.setSize(i / 2, true); entityslime.setPositionRotation(this.locX + (double) f, this.locY + 0.5D, this.locZ + (double) f1, this.random.nextFloat() * 360.0F, 0.0F); - this.world.addEntity(entityslime); + this.world.addEntity(entityslime, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SLIME_SPLIT); // CraftBukkit - SpawnReason diff --git a/nms-patches/EntitySnowman.patch b/nms-patches/EntitySnowman.patch index 6a190b6737..0fc4443b30 100644 --- a/nms-patches/EntitySnowman.patch +++ b/nms-patches/EntitySnowman.patch @@ -12,7 +12,7 @@ public class EntitySnowman extends EntityGolem implements IRangedEntity { -@@ -46,7 +51,7 @@ +@@ -59,7 +64,7 @@ } if (this.world.getBiome(new BlockPosition(i, 0, k)).a(new BlockPosition(i, j, k)) > 1.0F) { @@ -21,10 +21,10 @@ } if (!this.world.getGameRules().getBoolean("mobGriefing")) { -@@ -60,7 +65,17 @@ +@@ -73,7 +78,17 @@ BlockPosition blockposition = new BlockPosition(i, j, k); - if (this.world.getType(blockposition).getMaterial() == Material.AIR && this.world.getBiome(new BlockPosition(i, 0, k)).a(blockposition) < 0.8F && Blocks.SNOW_LAYER.canPlace(this.world, blockposition)) { + if (this.world.getType(blockposition).getMaterial() == Material.AIR && this.world.getBiome(blockposition).a(blockposition) < 0.8F && Blocks.SNOW_LAYER.canPlace(this.world, blockposition)) { - this.world.setTypeUpdate(blockposition, Blocks.SNOW_LAYER.getBlockData()); + // CraftBukkit start + org.bukkit.block.BlockState blockState = this.world.getWorld().getBlockAt(i, j, k).getState(); diff --git a/nms-patches/EntityTNTPrimed.patch b/nms-patches/EntityTNTPrimed.patch index 6b765dd848..37d5ae34b9 100644 --- a/nms-patches/EntityTNTPrimed.patch +++ b/nms-patches/EntityTNTPrimed.patch @@ -1,13 +1,15 @@ --- a/net/minecraft/server/EntityTNTPrimed.java +++ b/net/minecraft/server/EntityTNTPrimed.java -@@ -1,10 +1,14 @@ +@@ -1,6 +1,7 @@ package net.minecraft.server; + import javax.annotation.Nullable; +import org.bukkit.event.entity.ExplosionPrimeEvent; // CraftBukkit -+ + public class EntityTNTPrimed extends Entity { - private static final DataWatcherObject FUSE_TICKS = DataWatcher.a(EntityTNTPrimed.class, DataWatcherRegistry.b); +@@ -8,6 +9,8 @@ + @Nullable private EntityLiving source; private int c; + public float yield = 4; // CraftBukkit - add field @@ -15,7 +17,7 @@ public EntityTNTPrimed(World world) { super(world); -@@ -60,10 +64,13 @@ +@@ -63,10 +66,13 @@ --this.c; if (this.c <= 0) { @@ -30,7 +32,7 @@ } else { this.ak(); this.world.addParticle(EnumParticle.SMOKE_NORMAL, this.locX, this.locY + 0.5D, this.locZ, 0.0D, 0.0D, 0.0D, new int[0]); -@@ -72,9 +79,18 @@ +@@ -75,9 +81,17 @@ } private void explode() { @@ -40,7 +42,6 @@ - this.world.explode(this, this.locX, this.locY + (double) (this.length / 16.0F), this.locZ, 4.0F, true); + org.bukkit.craftbukkit.CraftServer server = this.world.getServer(); -+ + ExplosionPrimeEvent event = new ExplosionPrimeEvent((org.bukkit.entity.Explosive) org.bukkit.craftbukkit.entity.CraftEntity.getEntity(server, this)); + server.getPluginManager().callEvent(event); + diff --git a/nms-patches/EntityThrownExpBottle.patch b/nms-patches/EntityThrownExpBottle.patch index c3a19637cb..256bf0ad75 100644 --- a/nms-patches/EntityThrownExpBottle.patch +++ b/nms-patches/EntityThrownExpBottle.patch @@ -4,16 +4,16 @@ protected void a(MovingObjectPosition movingobjectposition) { if (!this.world.isClientSide) { -- this.world.triggerEffect(2002, new BlockPosition(this), 0); +- this.world.triggerEffect(2002, new BlockPosition(this), PotionUtil.a(Potions.b)); + // CraftBukkit - moved to after event -+ // this.world.triggerEffect(2002, new BlockPosition(this), 0); ++ // this.world.triggerEffect(2002, new BlockPosition(this), PotionUtil.a(Potions.b)); int i = 3 + this.world.random.nextInt(5) + this.world.random.nextInt(5); + // CraftBukkit start + org.bukkit.event.entity.ExpBottleEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callExpBottleEvent(this, i); + i = event.getExperience(); + if (event.getShowEffect()) { -+ this.world.triggerEffect(2002, new BlockPosition(this), 0); ++ this.world.triggerEffect(2002, new BlockPosition(this), PotionUtil.a(Potions.b)); + } + // CraftBukkit end + diff --git a/nms-patches/EntityTippedArrow.patch b/nms-patches/EntityTippedArrow.patch index 145287c67a..fce1c47dc6 100644 --- a/nms-patches/EntityTippedArrow.patch +++ b/nms-patches/EntityTippedArrow.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/EntityTippedArrow.java +++ b/net/minecraft/server/EntityTippedArrow.java -@@ -98,6 +98,25 @@ +@@ -102,6 +102,25 @@ } } @@ -19,10 +19,10 @@ + } + + public boolean isTipped() { -+ return !(this.effects.isEmpty() && this.potionRegistry == Potions.a); // PAIL: rename ++ return !(this.effects.isEmpty() && this.potionRegistry == Potions.EMPTY); + } + // CraftBukkit end + - public int n() { + public int q() { return ((Integer) this.datawatcher.get(EntityTippedArrow.f)).intValue(); } diff --git a/nms-patches/EntityTracker.patch b/nms-patches/EntityTracker.patch index e923972430..67c6412c45 100644 --- a/nms-patches/EntityTracker.patch +++ b/nms-patches/EntityTracker.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/EntityTracker.java +++ b/net/minecraft/server/EntityTracker.java -@@ -116,11 +116,12 @@ +@@ -120,11 +120,12 @@ CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Entity To Track"); crashreportsystemdetails.a("Tracking range", (Object) (i + " blocks")); diff --git a/nms-patches/EntityTrackerEntry.patch b/nms-patches/EntityTrackerEntry.patch index db80f3e042..44d34923b9 100644 --- a/nms-patches/EntityTrackerEntry.patch +++ b/nms-patches/EntityTrackerEntry.patch @@ -22,8 +22,8 @@ EntityItemFrame entityitemframe = (EntityItemFrame) this.tracker; ItemStack itemstack = entityitemframe.getItem(); -- if (itemstack != null && itemstack.getItem() instanceof ItemWorldMap) { -+ if (this.a % 10 == 0 && itemstack != null && itemstack.getItem() instanceof ItemWorldMap) { // CraftBukkit - Moved this.m % 10 logic here so item frames do not enter the other blocks +- if (itemstack.getItem() instanceof ItemWorldMap) { ++ if (this.a % 10 == 0 && itemstack.getItem() instanceof ItemWorldMap) { // CraftBukkit - Moved this.a % 10 logic here so item frames do not enter the other blocks WorldMap worldmap = Items.FILLED_MAP.getSavedMap(itemstack, this.tracker.world); - Iterator iterator = list.iterator(); + Iterator iterator = this.trackedPlayers.iterator(); // CraftBukkit @@ -161,7 +161,7 @@ if (this.tracker instanceof EntityLiving) { EntityLiving entityliving = (EntityLiving) this.tracker; Iterator iterator = entityliving.getEffects().iterator(); -@@ -372,7 +444,10 @@ +@@ -380,7 +452,10 @@ private Packet e() { if (this.tracker.dead) { @@ -172,4 +172,4 @@ + // CraftBukkit end } - if (this.tracker instanceof EntityItem) { + if (this.tracker instanceof EntityPlayer) { diff --git a/nms-patches/EntityVex.patch b/nms-patches/EntityVex.patch new file mode 100644 index 0000000000..0c50e0e260 --- /dev/null +++ b/nms-patches/EntityVex.patch @@ -0,0 +1,19 @@ +--- a/net/minecraft/server/EntityVex.java ++++ b/net/minecraft/server/EntityVex.java +@@ -1,6 +1,7 @@ + package net.minecraft.server; + + import javax.annotation.Nullable; ++import org.bukkit.event.entity.EntityTargetEvent; + + public class EntityVex extends EntityMonster { + +@@ -182,7 +183,7 @@ + } + + public void c() { +- EntityVex.this.setGoalTarget(EntityVex.this.b.getGoalTarget()); ++ EntityVex.this.setGoalTarget(EntityVex.this.b.getGoalTarget(), EntityTargetEvent.TargetReason.OWNER_ATTACKED_TARGET, true); // CraftBukkit + super.c(); + } + } diff --git a/nms-patches/EntityVillager.patch b/nms-patches/EntityVillager.patch index 85102eecb3..697cdc0322 100644 --- a/nms-patches/EntityVillager.patch +++ b/nms-patches/EntityVillager.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/server/EntityVillager.java +++ b/net/minecraft/server/EntityVillager.java -@@ -3,6 +3,14 @@ - import java.util.Iterator; - import java.util.Random; +@@ -6,6 +6,14 @@ import javax.annotation.Nullable; + import org.apache.logging.log4j.LogManager; + import org.apache.logging.log4j.Logger; +// CraftBukkit start +import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.entity.CraftVillager; @@ -13,9 +13,9 @@ +import org.bukkit.event.entity.VillagerReplenishTradeEvent; +// CraftBukkit end - public class EntityVillager extends EntityAgeable implements IMerchant, NPC { + public class EntityVillager extends EntityAgeable implements NPC, IMerchant { -@@ -31,7 +39,7 @@ +@@ -36,7 +44,7 @@ public EntityVillager(World world, int i) { super(world); @@ -24,7 +24,7 @@ this.setProfession(i); this.setSize(0.6F, 1.95F); ((Navigation) this.getNavigation()).a(true); -@@ -110,7 +118,14 @@ +@@ -118,7 +126,14 @@ MerchantRecipe merchantrecipe = (MerchantRecipe) iterator.next(); if (merchantrecipe.h()) { @@ -40,25 +40,25 @@ } } -@@ -429,7 +444,20 @@ - for (int l = 0; l < k; ++l) { - EntityVillager.IMerchantRecipeOption entityvillager_imerchantrecipeoption = aentityvillager_imerchantrecipeoption3[l]; +@@ -454,7 +469,20 @@ + for (int l = 0; l < k; ++l) { + EntityVillager.IMerchantRecipeOption entityvillager_imerchantrecipeoption = aentityvillager_imerchantrecipeoption3[l]; -- entityvillager_imerchantrecipeoption.a(this.trades, this.random); -+ // CraftBukkit start -+ // this is a hack. this must be done because otherwise, if -+ // mojang adds a new type of villager merchant option, it will need to -+ // have event handling added manually. this is better than having to do that. -+ MerchantRecipeList list = new MerchantRecipeList(); -+ entityvillager_imerchantrecipeoption.a(list, this.random); -+ for (MerchantRecipe recipe : list) { -+ VillagerAcquireTradeEvent event = new VillagerAcquireTradeEvent((Villager) getBukkitEntity(), recipe.asBukkit()); -+ Bukkit.getPluginManager().callEvent(event); -+ if (!event.isCancelled()) { -+ this.trades.add(CraftMerchantRecipe.fromBukkit(event.getRecipe()).toMinecraft()); +- entityvillager_imerchantrecipeoption.a(this, this.trades, this.random); ++ // CraftBukkit start ++ // this is a hack. this must be done because otherwise, if ++ // mojang adds a new type of villager merchant option, it will need to ++ // have event handling added manually. this is better than having to do that. ++ MerchantRecipeList list = new MerchantRecipeList(); ++ entityvillager_imerchantrecipeoption.a(this, list, this.random); ++ for (MerchantRecipe recipe : list) { ++ VillagerAcquireTradeEvent event = new VillagerAcquireTradeEvent((Villager) getBukkitEntity(), recipe.asBukkit()); ++ Bukkit.getPluginManager().callEvent(event); ++ if (!event.isCancelled()) { ++ this.trades.add(CraftMerchantRecipe.fromBukkit(event.getRecipe()).toMinecraft()); ++ } + } -+ } -+ // CraftBukkit end ++ // CraftBukkit end + } } - } diff --git a/nms-patches/EntityWither.patch b/nms-patches/EntityWither.patch index 3e25bf5bb7..a1be6ae4e0 100644 --- a/nms-patches/EntityWither.patch +++ b/nms-patches/EntityWither.patch @@ -13,9 +13,9 @@ public class EntityWither extends EntityMonster implements IRangedEntity { private static final DataWatcherObject a = DataWatcher.a(EntityWither.class, DataWatcherRegistry.b); -@@ -184,13 +190,38 @@ - if (this.de() > 0) { - i = this.de() - 1; +@@ -188,13 +194,38 @@ + if (this.dh() > 0) { + i = this.dh() - 1; if (i <= 0) { - this.world.createExplosion(this, this.locX, this.locY + (double) this.getHeadHeight(), this.locZ, 7.0F, false, this.world.getGameRules().getBoolean("mobGriefing")); - this.world.a(1023, new BlockPosition(this), 0); @@ -55,7 +55,7 @@ } } else { -@@ -281,6 +312,11 @@ +@@ -285,6 +316,11 @@ Block block = iblockdata.getBlock(); if (iblockdata.getMaterial() != Material.AIR && a(block)) { @@ -67,7 +67,7 @@ flag = this.world.setAir(blockposition, true) || flag; } } -@@ -294,7 +330,7 @@ +@@ -298,7 +334,7 @@ } if (this.ticksLived % 20 == 0) { @@ -75,4 +75,4 @@ + this.heal(1.0F, EntityRegainHealthEvent.RegainReason.REGEN); // CraftBukkit } - this.bG.setProgress(this.getHealth() / this.getMaxHealth()); + this.bF.setProgress(this.getHealth() / this.getMaxHealth()); diff --git a/nms-patches/EntityWolf.patch b/nms-patches/EntityWolf.patch index da6feb89a2..85f3026fc6 100644 --- a/nms-patches/EntityWolf.patch +++ b/nms-patches/EntityWolf.patch @@ -12,7 +12,7 @@ public class EntityWolf extends EntityTameableAnimal { private static final DataWatcherObject DATA_HEALTH = DataWatcher.a(EntityWolf.class, DataWatcherRegistry.c); -@@ -61,6 +66,22 @@ +@@ -62,6 +67,22 @@ this.getAttributeMap().b(GenericAttributes.ATTACK_DAMAGE).setValue(2.0D); } @@ -35,7 +35,7 @@ public void setGoalTarget(@Nullable EntityLiving entityliving) { super.setGoalTarget(entityliving); if (entityliving == null) { -@@ -199,9 +220,10 @@ +@@ -200,9 +221,10 @@ Entity entity = damagesource.getEntity(); if (this.goalSit != null) { @@ -48,8 +48,8 @@ if (entity != null && !(entity instanceof EntityHuman) && !(entity instanceof EntityArrow)) { f = (f + 1.0F) / 2.0F; } -@@ -242,7 +264,7 @@ - --itemstack.count; +@@ -245,7 +267,7 @@ + itemstack.subtract(1); } - this.heal((float) itemfood.getNutrition(itemstack)); @@ -57,16 +57,16 @@ return true; } } else if (itemstack.getItem() == Items.DYE) { -@@ -263,7 +285,7 @@ +@@ -266,7 +288,7 @@ this.goalSit.setSitting(!this.isSitting()); - this.be = false; + this.bd = false; this.navigation.o(); - this.setGoalTarget((EntityLiving) null); + this.setGoalTarget((EntityLiving) null, TargetReason.FORGOT_TARGET, true); // CraftBukkit - reason } - } else if (itemstack != null && itemstack.getItem() == Items.BONE && !this.isAngry()) { + } else if (itemstack.getItem() == Items.BONE && !this.isAngry()) { if (!entityhuman.abilities.canInstantlyBuild) { -@@ -271,12 +293,14 @@ +@@ -274,12 +296,14 @@ } if (!this.world.isClientSide) { diff --git a/nms-patches/EntityZombie.patch b/nms-patches/EntityZombie.patch index c4348eb1ab..2acddcba3f 100644 --- a/nms-patches/EntityZombie.patch +++ b/nms-patches/EntityZombie.patch @@ -14,15 +14,7 @@ public class EntityZombie extends EntityMonster { protected static final IAttribute a = (new AttributeRanged((IAttribute) null, "zombie.spawnReinforcements", 0.0D, 0.0D, 1.0D)).a("Spawn Reinforcements Chance"); -@@ -19,6 +26,7 @@ - private boolean bD; - private float bE = -1.0F; - private float bF; -+ private int lastTick = MinecraftServer.currentTick; // CraftBukkit - add field - - public EntityZombie(World world) { - super(world); -@@ -153,7 +161,14 @@ +@@ -133,7 +140,14 @@ } if (flag) { @@ -38,8 +30,8 @@ } } } -@@ -183,8 +198,8 @@ - if (this.world.getType(new BlockPosition(i1, j1 - 1, k1)).q() && this.world.getLightLevel(new BlockPosition(i1, j1, k1)) < 10) { +@@ -167,8 +181,8 @@ + if (this.world.getType(new BlockPosition(i1, j1 - 1, k1)).r() && this.world.getLightLevel(new BlockPosition(i1, j1, k1)) < 10) { entityzombie.setPosition((double) i1, (double) j1, (double) k1); if (!this.world.isPlayerNearby((double) i1, (double) j1, (double) k1, 7.0D) && this.world.a(entityzombie.getBoundingBox(), (Entity) entityzombie) && this.world.getCubes(entityzombie, entityzombie.getBoundingBox()).isEmpty() && !this.world.containsLiquid(entityzombie.getBoundingBox())) { - this.world.addEntity(entityzombie); @@ -49,23 +41,11 @@ entityzombie.prepare(this.world.D(new BlockPosition(entityzombie)), (GroupDataEntity) null); this.getAttributeInstance(EntityZombie.a).b(new AttributeModifier("Zombie reinforcement caller charge", -0.05000000074505806D, 0)); entityzombie.getAttributeInstance(EntityZombie.a).b(new AttributeModifier("Zombie reinforcement callee charge", -0.05000000074505806D, 0)); -@@ -203,6 +218,11 @@ - public void m() { - if (!this.world.isClientSide && this.isConverting()) { - int i = this.getConversionTime(); -+ // CraftBukkit start - Use wall time instead of ticks for villager conversion -+ int elapsedTicks = MinecraftServer.currentTick - this.lastTick; -+ this.lastTick = MinecraftServer.currentTick; -+ i *= elapsedTicks; -+ // CraftBukkit end +@@ -191,7 +205,14 @@ + float f = this.world.D(new BlockPosition(this)).b(); - this.bC -= i; - if (this.bC <= 0) { -@@ -221,7 +241,14 @@ - - if (this.getItemInMainHand() == null) { - if (this.isBurning() && this.random.nextFloat() < f * 0.3F) { -- entity.setOnFire(2 * (int) f); + if (this.getItemInMainHand().isEmpty() && this.isBurning() && this.random.nextFloat() < f * 0.3F) { +- entity.setOnFire(2 * (int) f); + // CraftBukkit start + EntityCombustByEntityEvent event = new EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), 2 * (int) f); // PAIL: fixme + this.world.getServer().getPluginManager().callEvent(event); @@ -74,19 +54,19 @@ + entity.setOnFire(event.getDuration()); + } + // CraftBukkit end - } - - if (this.getVillagerType() == EnumZombieType.HUSK && entity instanceof EntityLiving) { -@@ -335,7 +362,7 @@ - entityzombie.setCustomNameVisible(entityvillager.getCustomNameVisible()); } - -- this.world.addEntity(entityzombie); -+ this.world.addEntity(entityzombie, CreatureSpawnEvent.SpawnReason.INFECTION); // CraftBukkit - add SpawnReason - this.world.a((EntityHuman) null, 1026, new BlockPosition((int) this.locX, (int) this.locY, (int) this.locZ), 0); } -@@ -396,7 +423,7 @@ +@@ -284,7 +305,7 @@ + entityzombievillager.setCustomNameVisible(entityvillager.getCustomNameVisible()); + } + +- this.world.addEntity(entityzombievillager); ++ this.world.addEntity(entityzombievillager, CreatureSpawnEvent.SpawnReason.INFECTION); // CraftBukkit - add SpawnReason + this.world.a((EntityHuman) null, 1026, new BlockPosition(this), 0); + } + +@@ -334,7 +355,7 @@ entitychicken1.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, 0.0F); entitychicken1.prepare(difficultydamagescaler, (GroupDataEntity) null); entitychicken1.p(true); @@ -95,24 +75,18 @@ this.startRiding(entitychicken1); } } -@@ -480,7 +507,7 @@ - entityvillager.setCustomNameVisible(this.getCustomNameVisible()); - } - -- this.world.addEntity(entityvillager); -+ this.world.addEntity(entityvillager, CreatureSpawnEvent.SpawnReason.CURED); // CraftBukkit - add SpawnReason - entityvillager.addEffect(new MobEffect(MobEffects.CONFUSION, 200, 0)); - this.world.a((EntityHuman) null, 1027, new BlockPosition((int) this.locX, (int) this.locY, (int) this.locZ), 0); - } -@@ -536,11 +563,12 @@ +@@ -392,7 +413,7 @@ } public void die(DamageSource damagesource) { - super.die(damagesource); + // super.die(damagesource); // CraftBukkit - if (damagesource.getEntity() instanceof EntityCreeper && !(this instanceof EntityPigZombie) && ((EntityCreeper) damagesource.getEntity()).isPowered() && ((EntityCreeper) damagesource.getEntity()).canCauseHeadDrop()) { - ((EntityCreeper) damagesource.getEntity()).setCausedHeadDrop(); - this.a(new ItemStack(Items.SKULL, 1, 2), 0.0F); + if (damagesource.getEntity() instanceof EntityCreeper) { + EntityCreeper entitycreeper = (EntityCreeper) damagesource.getEntity(); + +@@ -405,6 +426,7 @@ + } + } } + super.die(damagesource); // CraftBukkit - moved from above diff --git a/nms-patches/EntityZombieVillager.patch b/nms-patches/EntityZombieVillager.patch new file mode 100644 index 0000000000..776cdba140 --- /dev/null +++ b/nms-patches/EntityZombieVillager.patch @@ -0,0 +1,31 @@ +--- a/net/minecraft/server/EntityZombieVillager.java ++++ b/net/minecraft/server/EntityZombieVillager.java +@@ -7,6 +7,7 @@ + private static final DataWatcherObject b = DataWatcher.a(EntityZombieVillager.class, DataWatcherRegistry.h); + private static final DataWatcherObject c = DataWatcher.a(EntityZombieVillager.class, DataWatcherRegistry.b); + private int conversionTime; ++ private int lastTick = MinecraftServer.currentTick; // CraftBukkit - add field + + public EntityZombieVillager(World world) { + super(world); +@@ -54,6 +55,11 @@ + public void A_() { + if (!this.world.isClientSide && this.isConverting()) { + int i = this.dq(); ++ // CraftBukkit start - Use wall time instead of ticks for villager conversion ++ int elapsedTicks = MinecraftServer.currentTick - this.lastTick; ++ this.lastTick = MinecraftServer.currentTick; ++ i *= elapsedTicks; ++ // CraftBukkit end + + this.conversionTime -= i; + if (this.conversionTime <= 0) { +@@ -116,7 +122,7 @@ + entityvillager.setCustomNameVisible(this.getCustomNameVisible()); + } + +- this.world.addEntity(entityvillager); ++ this.world.addEntity(entityvillager, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CURED); // CraftBukkit - add SpawnReason + entityvillager.addEffect(new MobEffect(MobEffects.CONFUSION, 200, 0)); + this.world.a((EntityHuman) null, 1027, new BlockPosition((int) this.locX, (int) this.locY, (int) this.locZ), 0); + } diff --git a/nms-patches/Explosion.patch b/nms-patches/Explosion.patch index 4cba2e11d2..ccc8d40fc6 100644 --- a/nms-patches/Explosion.patch +++ b/nms-patches/Explosion.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/Explosion.java +++ b/net/minecraft/server/Explosion.java -@@ -9,6 +9,13 @@ - import java.util.Map; +@@ -10,6 +10,13 @@ import java.util.Random; + import javax.annotation.Nullable; +// CraftBukkit start +import org.bukkit.craftbukkit.event.CraftEventFactory; @@ -14,7 +14,7 @@ public class Explosion { private final boolean a; -@@ -22,11 +29,12 @@ +@@ -23,11 +30,12 @@ private final float size; private final List blocks = Lists.newArrayList(); private final Map k = Maps.newHashMap(); @@ -28,7 +28,7 @@ this.posX = d0; this.posY = d1; this.posZ = d2; -@@ -35,6 +43,11 @@ +@@ -36,6 +44,11 @@ } public void a() { @@ -40,7 +40,7 @@ HashSet hashset = Sets.newHashSet(); boolean flag = true; -@@ -68,7 +81,7 @@ +@@ -69,7 +82,7 @@ f -= (f2 + 0.3F) * 0.3F; } @@ -49,7 +49,7 @@ hashset.add(blockposition); } -@@ -112,7 +125,16 @@ +@@ -113,7 +126,16 @@ double d12 = (double) this.world.a(vec3d, entity.getBoundingBox()); double d13 = (1.0D - d7) * d12; @@ -64,10 +64,10 @@ + continue; + } + // CraftBukkit end - double d14 = 1.0D; + double d14 = d13; if (entity instanceof EntityLiving) { -@@ -148,6 +170,50 @@ +@@ -149,6 +171,50 @@ BlockPosition blockposition; if (this.b) { @@ -118,7 +118,7 @@ iterator = this.blocks.iterator(); while (iterator.hasNext()) { -@@ -179,7 +245,8 @@ +@@ -180,7 +246,8 @@ if (iblockdata.getMaterial() != Material.AIR) { if (block.a(this)) { @@ -128,7 +128,7 @@ } this.world.setTypeAndData(blockposition, Blocks.AIR.getBlockData(), 3); -@@ -194,7 +261,11 @@ +@@ -195,7 +262,11 @@ while (iterator.hasNext()) { blockposition = (BlockPosition) iterator.next(); if (this.world.getType(blockposition).getMaterial() == Material.AIR && this.world.getType(blockposition.down()).b() && this.c.nextInt(3) == 0) { @@ -141,9 +141,9 @@ } } } -@@ -206,7 +277,9 @@ - } +@@ -208,7 +279,9 @@ + @Nullable public EntityLiving getSource() { - return this.source == null ? null : (this.source instanceof EntityTNTPrimed ? ((EntityTNTPrimed) this.source).getSource() : (this.source instanceof EntityLiving ? (EntityLiving) this.source : null)); + // CraftBukkit start - obtain Fireball shooter for explosion tracking diff --git a/nms-patches/FoodMetaData.patch b/nms-patches/FoodMetaData.patch index 0e11396841..8037db1f39 100644 --- a/nms-patches/FoodMetaData.patch +++ b/nms-patches/FoodMetaData.patch @@ -57,18 +57,18 @@ @@ -39,14 +65,14 @@ if (this.foodTickTimer >= 10) { - float f = Math.min(this.saturationLevel, 4.0F); + float f = Math.min(this.saturationLevel, 6.0F); -- entityhuman.heal(f / 4.0F); -+ entityhuman.heal(f / 4.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.SATIATED); // CraftBukkit - added RegainReason +- entityhuman.heal(f / 6.0F); ++ entityhuman.heal(f / 6.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.SATIATED); // CraftBukkit - added RegainReason this.a(f); this.foodTickTimer = 0; } - } else if (flag && this.foodLevel >= 18 && entityhuman.cY()) { + } else if (flag && this.foodLevel >= 18 && entityhuman.db()) { ++this.foodTickTimer; if (this.foodTickTimer >= 80) { - entityhuman.heal(1.0F); + entityhuman.heal(1.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.SATIATED); // CraftBukkit - added RegainReason - this.a(4.0F); + this.a(6.0F); this.foodTickTimer = 0; } diff --git a/nms-patches/HandshakeListener.patch b/nms-patches/HandshakeListener.patch index 5d301b0464..7f0640c23b 100644 --- a/nms-patches/HandshakeListener.patch +++ b/nms-patches/HandshakeListener.patch @@ -57,8 +57,8 @@ + } + // CraftBukkit end + - if (packethandshakinginsetprotocol.b() > 210) { - chatcomponenttext = new ChatComponentText("Outdated server! I\'m still on 1.10.2"); + if (packethandshakinginsetprotocol.b() > 315) { + chatcomponenttext = new ChatComponentText("Outdated server! I\'m still on 1.11"); this.b.sendPacket(new PacketLoginOutDisconnect(chatcomponenttext)); @@ -26,6 +71,7 @@ this.b.close(chatcomponenttext); diff --git a/nms-patches/IDataManager.patch b/nms-patches/IDataManager.patch index cdb07653be..362ecd7607 100644 --- a/nms-patches/IDataManager.patch +++ b/nms-patches/IDataManager.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/IDataManager.java +++ b/net/minecraft/server/IDataManager.java -@@ -23,4 +23,6 @@ +@@ -25,4 +25,6 @@ File getDataFile(String s); DefinedStructureManager h(); diff --git a/nms-patches/IInventory.patch b/nms-patches/IInventory.patch index 16aa68e4aa..0d2e884cea 100644 --- a/nms-patches/IInventory.patch +++ b/nms-patches/IInventory.patch @@ -1,20 +1,20 @@ --- a/net/minecraft/server/IInventory.java +++ b/net/minecraft/server/IInventory.java -@@ -1,6 +1,7 @@ +@@ -1,5 +1,7 @@ package net.minecraft.server; - import javax.annotation.Nullable; +import org.bukkit.craftbukkit.entity.CraftHumanEntity; // CraftBukkit - ++ public interface IInventory extends INamableTileEntity { -@@ -36,4 +37,22 @@ - int g(); + int getSize(); +@@ -33,4 +35,22 @@ + int h(); - void l(); + void clear(); + + // CraftBukkit start -+ ItemStack[] getContents(); ++ java.util.List getContents(); + + void onOpen(CraftHumanEntity who); + diff --git a/nms-patches/IRecipe.patch b/nms-patches/IRecipe.patch index bc31552956..bf22eb6d0c 100644 --- a/nms-patches/IRecipe.patch +++ b/nms-patches/IRecipe.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/server/IRecipe.java +++ b/net/minecraft/server/IRecipe.java -@@ -15,4 +15,6 @@ +@@ -11,4 +11,6 @@ ItemStack b(); - ItemStack[] b(InventoryCrafting inventorycrafting); + NonNullList b(InventoryCrafting inventorycrafting); + + org.bukkit.inventory.Recipe toBukkitRecipe(); // CraftBukkit } diff --git a/nms-patches/InventoryCraftResult.patch b/nms-patches/InventoryCraftResult.patch index a87e7e4214..3a400769fe 100644 --- a/nms-patches/InventoryCraftResult.patch +++ b/nms-patches/InventoryCraftResult.patch @@ -3,7 +3,7 @@ @@ -1,11 +1,44 @@ package net.minecraft.server; - import javax.annotation.Nullable; + import java.util.Iterator; +// CraftBukkit start +import org.bukkit.Location; +import org.bukkit.craftbukkit.entity.CraftHumanEntity; @@ -12,12 +12,12 @@ public class InventoryCraftResult implements IInventory { - private final ItemStack[] items = new ItemStack[1]; + private final NonNullList items; + // CraftBukkit start + private int maxStack = MAX_STACK; + -+ public ItemStack[] getContents() { ++ public java.util.List getContents() { + return this.items; + } + @@ -42,10 +42,10 @@ + } + // CraftBukkit end + - public InventoryCraftResult() {} - - public int getSize() { -@@ -44,7 +77,7 @@ + public InventoryCraftResult() { + this.items = NonNullList.a(1, ItemStack.a); + } +@@ -59,7 +92,7 @@ } public int getMaxStackSize() { diff --git a/nms-patches/InventoryCrafting.patch b/nms-patches/InventoryCrafting.patch index 45dcce2bd6..97079fa26a 100644 --- a/nms-patches/InventoryCrafting.patch +++ b/nms-patches/InventoryCrafting.patch @@ -3,7 +3,7 @@ @@ -1,6 +1,14 @@ package net.minecraft.server; - import javax.annotation.Nullable; + import java.util.Iterator; +// CraftBukkit start +import java.util.List; +import org.bukkit.Location; @@ -26,7 +26,7 @@ + private EntityHuman owner; + private int maxStack = MAX_STACK; + -+ public ItemStack[] getContents() { ++ public List getContents() { + return this.items; + } + @@ -35,7 +35,7 @@ + } + + public InventoryType getInvType() { -+ return items.length == 4 ? InventoryType.CRAFTING : InventoryType.WORKBENCH; ++ return items.size() == 4 ? InventoryType.CRAFTING : InventoryType.WORKBENCH; + } + + public void onClose(CraftHumanEntity who) { @@ -67,5 +67,5 @@ + // CraftBukkit end + public InventoryCrafting(Container container, int i, int j) { - int k = i * j; - + this.items = NonNullList.a(i * j, ItemStack.a); + this.d = container; diff --git a/nms-patches/InventoryEnderChest.patch b/nms-patches/InventoryEnderChest.patch index 26b013cece..2591f07ed6 100644 --- a/nms-patches/InventoryEnderChest.patch +++ b/nms-patches/InventoryEnderChest.patch @@ -1,52 +1,25 @@ --- a/net/minecraft/server/InventoryEnderChest.java +++ b/net/minecraft/server/InventoryEnderChest.java -@@ -1,9 +1,49 @@ +@@ -1,11 +1,21 @@ package net.minecraft.server; -+// CraftBukkit start -+import java.util.List; -+import org.bukkit.craftbukkit.entity.CraftHumanEntity; -+import org.bukkit.entity.HumanEntity; -+// CraftBukkit end ++import org.bukkit.inventory.InventoryHolder; + public class InventoryEnderChest extends InventorySubcontainer { private TileEntityEnderChest a; ++ // CraftBukkit start ++ private final EntityHuman owner; ++ ++ public InventoryHolder getBukkitOwner() { ++ return owner.getBukkitEntity(); ++ } -+ // CraftBukkit start - add fields and methods -+ public List transaction = new java.util.ArrayList(); -+ public org.bukkit.entity.Player player; -+ private int maxStack = MAX_STACK; -+ -+ public ItemStack[] getContents() { -+ return this.items; -+ } -+ -+ public void onOpen(CraftHumanEntity who) { -+ transaction.add(who); -+ } -+ -+ public void onClose(CraftHumanEntity who) { -+ transaction.remove(who); -+ } -+ -+ public List getViewers() { -+ return transaction; -+ } -+ -+ public org.bukkit.inventory.InventoryHolder getOwner() { -+ return this.player; -+ } -+ -+ public void setMaxStackSize(int size) { -+ maxStack = size; -+ } -+ -+ public int getMaxStackSize() { -+ return maxStack; -+ } -+ // CraftBukkit end -+ - public InventoryEnderChest() { +- public InventoryEnderChest() { ++ public InventoryEnderChest(EntityHuman owner) { super("container.enderchest", false, 27); ++ this.owner = owner; ++ // CraftBukkit end } + + public void a(TileEntityEnderChest tileentityenderchest) { diff --git a/nms-patches/InventoryHorseChest.patch b/nms-patches/InventoryHorseChest.patch index da3394f566..875dd670de 100644 --- a/nms-patches/InventoryHorseChest.patch +++ b/nms-patches/InventoryHorseChest.patch @@ -1,63 +1,14 @@ --- a/net/minecraft/server/InventoryHorseChest.java +++ b/net/minecraft/server/InventoryHorseChest.java -@@ -1,8 +1,60 @@ - package net.minecraft.server; +@@ -2,7 +2,9 @@ -+// CraftBukkit start -+import java.util.List; -+import org.bukkit.craftbukkit.entity.CraftHumanEntity; -+import org.bukkit.entity.HumanEntity; -+// CraftBukkit end -+ public class InventoryHorseChest extends InventorySubcontainer { - public InventoryHorseChest(String s, int i) { - super(s, false, i); +- public InventoryHorseChest(String s, int i) { +- super(s, false, i); ++ // CraftBukkit start ++ public InventoryHorseChest(String s, int i, EntityHorseAbstract owner) { ++ super(s, false, i, (org.bukkit.entity.AbstractHorse) owner.getBukkitEntity()); ++ // CraftBukkit end } -+ -+ // CraftBukkit start - add fields and methods -+ public List transaction = new java.util.ArrayList(); -+ private EntityHorse horse; -+ private int maxStack = MAX_STACK; -+ -+ public InventoryHorseChest(String s, int i, EntityHorse horse) { -+ super(s, false, i, (org.bukkit.craftbukkit.entity.CraftHorse) horse.getBukkitEntity()); -+ this.horse = horse; -+ } -+ -+ @Override -+ public ItemStack[] getContents() { -+ return this.items; -+ } -+ -+ @Override -+ public void onOpen(CraftHumanEntity who) { -+ transaction.add(who); -+ } -+ -+ @Override -+ public void onClose(CraftHumanEntity who) { -+ transaction.remove(who); -+ } -+ -+ @Override -+ public List getViewers() { -+ return transaction; -+ } -+ -+ @Override -+ public org.bukkit.inventory.InventoryHolder getOwner() { -+ return (org.bukkit.entity.Horse) this.horse.getBukkitEntity(); -+ } -+ -+ @Override -+ public void setMaxStackSize(int size) { -+ maxStack = size; -+ } -+ -+ @Override -+ public int getMaxStackSize() { -+ return maxStack; -+ } -+ // CraftBukkit end } diff --git a/nms-patches/InventoryLargeChest.patch b/nms-patches/InventoryLargeChest.patch index 253d591a84..3ed9ccd87e 100644 --- a/nms-patches/InventoryLargeChest.patch +++ b/nms-patches/InventoryLargeChest.patch @@ -1,30 +1,30 @@ --- a/net/minecraft/server/InventoryLargeChest.java +++ b/net/minecraft/server/InventoryLargeChest.java -@@ -1,6 +1,13 @@ +@@ -1,11 +1,62 @@ package net.minecraft.server; - import javax.annotation.Nullable; +// CraftBukkit start ++import java.util.ArrayList; +import java.util.List; +import org.bukkit.Location; + +import org.bukkit.craftbukkit.entity.CraftHumanEntity; +import org.bukkit.entity.HumanEntity; +// CraftBukkit end - ++ public class InventoryLargeChest implements ITileInventory { -@@ -8,6 +15,48 @@ + private final String a; public final ITileInventory left; public final ITileInventory right; + // CraftBukkit start - add fields and methods + public List transaction = new java.util.ArrayList(); + -+ public ItemStack[] getContents() { -+ ItemStack[] result = new ItemStack[this.getSize()]; -+ for (int i = 0; i < result.length; i++) { -+ result[i] = this.getItem(i); ++ public List getContents() { ++ List result = new ArrayList(this.getSize()); ++ for (int i = 0; i < this.getSize(); i++) { ++ result.add(this.getItem(i)); + } + return result; + } @@ -63,7 +63,7 @@ public InventoryLargeChest(String s, ITileInventory itileinventory, ITileInventory itileinventory1) { this.a = s; if (itileinventory == null) { -@@ -73,7 +122,7 @@ +@@ -72,7 +123,7 @@ } public int getMaxStackSize() { diff --git a/nms-patches/InventoryMerchant.patch b/nms-patches/InventoryMerchant.patch index 51bf4d5949..58445a1259 100644 --- a/nms-patches/InventoryMerchant.patch +++ b/nms-patches/InventoryMerchant.patch @@ -3,7 +3,7 @@ @@ -1,6 +1,13 @@ package net.minecraft.server; - import javax.annotation.Nullable; + import java.util.Iterator; +// CraftBukkit start +import java.util.List; +import org.bukkit.Location; @@ -22,7 +22,7 @@ + public List transaction = new java.util.ArrayList(); + private int maxStack = MAX_STACK; + -+ public ItemStack[] getContents() { ++ public List getContents() { + return this.itemsInSlots; + } + @@ -53,9 +53,9 @@ + // CraftBukkit end + public InventoryMerchant(EntityHuman entityhuman, IMerchant imerchant) { + this.itemsInSlots = NonNullList.a(3, ItemStack.a); this.player = entityhuman; - this.merchant = imerchant; -@@ -73,7 +114,7 @@ +@@ -89,7 +130,7 @@ } public int getMaxStackSize() { diff --git a/nms-patches/InventorySubcontainer.patch b/nms-patches/InventorySubcontainer.patch index a57a94a409..ee8e435a44 100644 --- a/nms-patches/InventorySubcontainer.patch +++ b/nms-patches/InventorySubcontainer.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/InventorySubcontainer.java +++ b/net/minecraft/server/InventorySubcontainer.java @@ -4,6 +4,13 @@ + import java.util.Iterator; import java.util.List; - import javax.annotation.Nullable; +// CraftBukkit start +import java.util.List; @@ -23,7 +23,7 @@ + private int maxStack = MAX_STACK; + protected org.bukkit.inventory.InventoryHolder bukkitOwner; + -+ public ItemStack[] getContents() { ++ public List getContents() { + return this.items; + } + @@ -56,9 +56,9 @@ + this(s, flag, i, null); + } + -+ public InventorySubcontainer(String s, boolean flag, int i, org.bukkit.inventory.InventoryHolder owner) { // Added argument ++ public InventorySubcontainer(String s, boolean flag, int i, org.bukkit.inventory.InventoryHolder owner) { + this.bukkitOwner = owner; -+ // CraftBukkit end ++ // CraftBukkit end this.a = s; this.e = flag; this.b = i; diff --git a/nms-patches/ItemArmor.patch b/nms-patches/ItemArmor.patch index ad7f06eaac..61627ea6b0 100644 --- a/nms-patches/ItemArmor.patch +++ b/nms-patches/ItemArmor.patch @@ -12,13 +12,11 @@ public class ItemArmor extends Item { private static final int[] n = new int[] { 13, 15, 16, 11}; -@@ -32,7 +37,33 @@ - } else { +@@ -33,6 +38,32 @@ EntityLiving entityliving = (EntityLiving) list.get(0); EnumItemSlot enumitemslot = EntityInsentient.d(itemstack); -- ItemStack itemstack1 = itemstack.cloneItemStack(); + ItemStack itemstack1 = itemstack.cloneAndSubtract(1); + // CraftBukkit start -+ ItemStack itemstack1 = itemstack.cloneAndSubtract(1); + 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); @@ -29,12 +27,12 @@ + } + + if (event.isCancelled()) { -+ itemstack.count++; ++ itemstack.add(1); + return itemstack; + } + + if (!event.getItem().equals(craftItem)) { -+ itemstack.count++; ++ itemstack.add(1); + // Chain to handler for new item + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); @@ -45,14 +43,5 @@ + } + // CraftBukkit end - itemstack1.count = 1; entityliving.setSlot(enumitemslot, itemstack1); -@@ -40,7 +71,7 @@ - ((EntityInsentient) entityliving).a(enumitemslot, 2.0F); - } - -- --itemstack.count; -+ // --itemstack.count; // CraftBukkit - handled above - return itemstack; - } - } + if (entityliving instanceof EntityInsentient) { diff --git a/nms-patches/ItemBlock.patch b/nms-patches/ItemBlock.patch index 90aa56cb99..34d35aaa83 100644 --- a/nms-patches/ItemBlock.patch +++ b/nms-patches/ItemBlock.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/server/ItemBlock.java +++ b/net/minecraft/server/ItemBlock.java -@@ -36,7 +36,7 @@ +@@ -33,7 +33,7 @@ - SoundEffectType soundeffecttype = this.a.w(); + SoundEffectType soundeffecttype = this.a.getStepSound(); - world.a(entityhuman, blockposition, soundeffecttype.e(), SoundCategory.BLOCKS, (soundeffecttype.a() + 1.0F) / 2.0F, soundeffecttype.b() * 0.8F); + // world.a(entityhuman, blockposition, soundeffecttype.e(), SoundCategory.BLOCKS, (soundeffecttype.a() + 1.0F) / 2.0F, soundeffecttype.b() * 0.8F); // CraftBukkit - SPIGOT-1288 - --itemstack.count; + itemstack.subtract(1); } diff --git a/nms-patches/ItemBoat.patch b/nms-patches/ItemBoat.patch index 410c84fd26..abcb54aa2b 100644 --- a/nms-patches/ItemBoat.patch +++ b/nms-patches/ItemBoat.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/ItemBoat.java +++ b/net/minecraft/server/ItemBoat.java -@@ -55,6 +55,13 @@ +@@ -56,6 +56,13 @@ } else if (movingobjectposition.type != MovingObjectPosition.EnumMovingObjectType.BLOCK) { return new InteractionResultWrapper(EnumInteractionResult.PASS, itemstack); } else { diff --git a/nms-patches/ItemBow.patch b/nms-patches/ItemBow.patch index b168fc48ae..d17d8d150d 100644 --- a/nms-patches/ItemBow.patch +++ b/nms-patches/ItemBow.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/server/ItemBow.java +++ b/net/minecraft/server/ItemBow.java -@@ -1,6 +1,7 @@ +@@ -1,5 +1,7 @@ package net.minecraft.server; - import javax.annotation.Nullable; +import org.bukkit.event.entity.EntityCombustEvent; // CraftBukkit - ++ public class ItemBow extends Item { -@@ -75,7 +76,20 @@ + public ItemBow() { +@@ -73,7 +75,20 @@ } if (EnchantmentManager.getEnchantmentLevel(Enchantments.ARROW_FIRE, itemstack) > 0) { @@ -30,7 +30,7 @@ } itemstack.damage(1, entityhuman); -@@ -83,7 +97,15 @@ +@@ -81,7 +96,15 @@ entityarrow.fromPlayer = EntityArrow.PickupStatus.CREATIVE_ONLY; } @@ -46,4 +46,4 @@ + // CraftBukkit end } - world.a((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.v, SoundCategory.NEUTRAL, 1.0F, 1.0F / (ItemBow.j.nextFloat() * 0.4F + 1.2F) + f * 0.5F); + world.a((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.w, SoundCategory.PLAYERS, 1.0F, 1.0F / (ItemBow.j.nextFloat() * 0.4F + 1.2F) + f * 0.5F); diff --git a/nms-patches/ItemBucket.patch b/nms-patches/ItemBucket.patch index 4a89f897d8..e486ce1339 100644 --- a/nms-patches/ItemBucket.patch +++ b/nms-patches/ItemBucket.patch @@ -13,7 +13,7 @@ public class ItemBucket extends Item { -@@ -33,15 +39,29 @@ +@@ -34,15 +40,29 @@ Material material = iblockdata.getMaterial(); if (material == Material.WATER && ((Integer) iblockdata.get(BlockFluids.LEVEL)).intValue() == 0) { @@ -26,9 +26,9 @@ + // CraftBukkit end world.setTypeAndData(blockposition, Blocks.AIR.getBlockData(), 11); entityhuman.b(StatisticList.b((Item) this)); - entityhuman.a(SoundEffects.N, 1.0F, 1.0F); + entityhuman.a(SoundEffects.P, 1.0F, 1.0F); - return new InteractionResultWrapper(EnumInteractionResult.SUCCESS, this.a(itemstack, entityhuman, Items.WATER_BUCKET)); -+ return new InteractionResultWrapper(EnumInteractionResult.SUCCESS, this.a(itemstack, entityhuman, Items.WATER_BUCKET, event.getItemStack())); // CraftBUkkit ++ return new InteractionResultWrapper(EnumInteractionResult.SUCCESS, this.a(itemstack, entityhuman, Items.WATER_BUCKET, event.getItemStack())); // CraftBukkit } else if (material == Material.LAVA && ((Integer) iblockdata.get(BlockFluids.LEVEL)).intValue() == 0) { + // CraftBukkit start + PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent(entityhuman, blockposition.getX(), blockposition.getY(), blockposition.getZ(), null, itemstack, Items.LAVA_BUCKET); @@ -37,7 +37,7 @@ + return new InteractionResultWrapper(EnumInteractionResult.FAIL, itemstack); + } + // CraftBukkit end - entityhuman.a(SoundEffects.O, 1.0F, 1.0F); + entityhuman.a(SoundEffects.Q, 1.0F, 1.0F); world.setTypeAndData(blockposition, Blocks.AIR.getBlockData(), 11); entityhuman.b(StatisticList.b((Item) this)); - return new InteractionResultWrapper(EnumInteractionResult.SUCCESS, this.a(itemstack, entityhuman, Items.LAVA_BUCKET)); @@ -45,7 +45,7 @@ } else { return new InteractionResultWrapper(EnumInteractionResult.FAIL, itemstack); } -@@ -52,7 +72,7 @@ +@@ -53,7 +73,7 @@ if (!entityhuman.a(blockposition1, movingobjectposition.direction, itemstack)) { return new InteractionResultWrapper(EnumInteractionResult.FAIL, itemstack); @@ -54,7 +54,7 @@ entityhuman.b(StatisticList.b((Item) this)); return !entityhuman.abilities.canInstantlyBuild ? new InteractionResultWrapper(EnumInteractionResult.SUCCESS, new ItemStack(Items.BUCKET)) : new InteractionResultWrapper(EnumInteractionResult.SUCCESS, itemstack); } else { -@@ -62,21 +82,28 @@ +@@ -63,16 +83,19 @@ } } @@ -63,17 +63,22 @@ + private ItemStack a(ItemStack itemstack, EntityHuman entityhuman, Item item, org.bukkit.inventory.ItemStack result) { if (entityhuman.abilities.canInstantlyBuild) { return itemstack; - } else if (--itemstack.count <= 0) { -- return new ItemStack(item); -+ return CraftItemStack.asNMSCopy(result); // CraftBukkit } else { -- if (!entityhuman.inventory.pickup(new ItemStack(item))) { -- entityhuman.drop(new ItemStack(item), false); -+ if (!entityhuman.inventory.pickup(CraftItemStack.asNMSCopy(result))) { -+ entityhuman.drop(CraftItemStack.asNMSCopy(result), false); - } + itemstack.subtract(1); + if (itemstack.isEmpty()) { +- return new ItemStack(item); ++ // CraftBukkit start ++ return CraftItemStack.asNMSCopy(result); + } else { +- if (!entityhuman.inventory.pickup(new ItemStack(item))) { +- entityhuman.drop(new ItemStack(item), false); ++ if (!entityhuman.inventory.pickup(CraftItemStack.asNMSCopy(result))) { ++ entityhuman.drop(CraftItemStack.asNMSCopy(result), false); ++ // CraftBukkit end + } - return itemstack; + return itemstack; +@@ -80,7 +103,13 @@ } } @@ -87,7 +92,7 @@ if (this.a == Blocks.AIR) { return false; } else { -@@ -88,6 +115,15 @@ +@@ -92,6 +121,15 @@ if (!world.isEmpty(blockposition) && !flag && !flag1) { return false; } else { diff --git a/nms-patches/ItemChorusFruit.patch b/nms-patches/ItemChorusFruit.patch index 24c4303823..2e175882af 100644 --- a/nms-patches/ItemChorusFruit.patch +++ b/nms-patches/ItemChorusFruit.patch @@ -1,18 +1,18 @@ --- a/net/minecraft/server/ItemChorusFruit.java +++ b/net/minecraft/server/ItemChorusFruit.java -@@ -1,6 +1,11 @@ +@@ -1,5 +1,11 @@ package net.minecraft.server; - import javax.annotation.Nullable; +// CraftBukkit start +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.event.player.PlayerTeleportEvent; +// CraftBukkit end - ++ public class ItemChorusFruit extends ItemFood { -@@ -22,6 +27,20 @@ + public ItemChorusFruit(int i, float f) { +@@ -19,6 +25,20 @@ double d4 = MathHelper.a(entityliving.locY + (double) (entityliving.getRandom().nextInt(16) - 8), 0.0D, (double) (world.Z() - 1)); double d5 = entityliving.locZ + (entityliving.getRandom().nextDouble() - 0.5D) * 16.0D; diff --git a/nms-patches/ItemDye.patch b/nms-patches/ItemDye.patch index 0f537c0d56..e92fa1886a 100644 --- a/nms-patches/ItemDye.patch +++ b/nms-patches/ItemDye.patch @@ -8,13 +8,13 @@ public class ItemDye extends Item { public static final int[] a = new int[] { 1973019, 11743532, 3887386, 5320730, 2437522, 8073150, 2651799, 11250603, 4408131, 14188952, 4312372, 14602026, 6719955, 12801229, 15435844, 15790320}; -@@ -87,6 +89,17 @@ +@@ -89,6 +91,17 @@ EnumColor enumcolor = EnumColor.fromInvColorIndex(itemstack.getData()); if (!entitysheep.isSheared() && entitysheep.getColor() != enumcolor) { + // CraftBukkit start + byte bColor = (byte) enumcolor.getColorIndex(); -+ SheepDyeWoolEvent event = new SheepDyeWoolEvent((org.bukkit.entity.Sheep) entitysheep.getBukkitEntity(), org.bukkit.DyeColor.getByData(bColor)); ++ SheepDyeWoolEvent event = new SheepDyeWoolEvent((org.bukkit.entity.Sheep) entitysheep.getBukkitEntity(), org.bukkit.DyeColor.getByWoolData(bColor)); + entitysheep.world.getServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { @@ -24,5 +24,5 @@ + enumcolor = EnumColor.fromColorIndex((byte) event.getColor().getWoolData()); + // CraftBukkit end entitysheep.setColor(enumcolor); - --itemstack.count; + itemstack.subtract(1); } diff --git a/nms-patches/ItemFireball.patch b/nms-patches/ItemFireball.patch index ca644d64d4..f60e3955a9 100644 --- a/nms-patches/ItemFireball.patch +++ b/nms-patches/ItemFireball.patch @@ -1,17 +1,17 @@ --- a/net/minecraft/server/ItemFireball.java +++ b/net/minecraft/server/ItemFireball.java -@@ -15,6 +15,14 @@ +@@ -17,6 +17,14 @@ return EnumInteractionResult.FAIL; } else { if (world.getType(blockposition).getMaterial() == Material.AIR) { + // CraftBukkit start - fire BlockIgniteEvent + if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), org.bukkit.event.block.BlockIgniteEvent.IgniteCause.FIREBALL, entityhuman).isCancelled()) { + if (!entityhuman.abilities.canInstantlyBuild) { -+ --itemstack.count; ++ itemstack.subtract(1); + } + return EnumInteractionResult.PASS; + } + // CraftBukkit end - world.a((EntityHuman) null, blockposition, SoundEffects.bn, SoundCategory.BLOCKS, 1.0F, (ItemFireball.j.nextFloat() - ItemFireball.j.nextFloat()) * 0.2F + 1.0F); + world.a((EntityHuman) null, blockposition, SoundEffects.bx, SoundCategory.BLOCKS, 1.0F, (ItemFireball.j.nextFloat() - ItemFireball.j.nextFloat()) * 0.2F + 1.0F); world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData()); } diff --git a/nms-patches/ItemFishingRod.patch b/nms-patches/ItemFishingRod.patch index b3efc66c62..0c8cee22c8 100644 --- a/nms-patches/ItemFishingRod.patch +++ b/nms-patches/ItemFishingRod.patch @@ -8,23 +8,23 @@ public class ItemFishingRod extends Item { public ItemFishingRod() { -@@ -17,9 +19,18 @@ +@@ -19,9 +21,18 @@ itemstack.damage(i, entityhuman); entityhuman.a(enumhand); } else { -+ // CraftBukkit start -+ EntityFishingHook hook = new EntityFishingHook(world, entityhuman); -+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), null, (org.bukkit.entity.Fish) hook.getBukkitEntity(), PlayerFishEvent.State.FISHING); -+ world.getServer().getPluginManager().callEvent(playerFishEvent); -+ -+ if (playerFishEvent.isCancelled()) { -+ return new InteractionResultWrapper(EnumInteractionResult.PASS, itemstack); -+ } -+ // CraftBukkit end - world.a((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.H, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemFishingRod.j.nextFloat() * 0.4F + 0.8F)); +- world.a((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.I, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemFishingRod.j.nextFloat() * 0.4F + 0.8F)); if (!world.isClientSide) { -- world.addEntity(new EntityFishingHook(world, entityhuman)); -+ world.addEntity(hook); // CraftBukkit - moved creation up - } ++ // CraftBukkit start + EntityFishingHook entityfishinghook = new EntityFishingHook(world, entityhuman); ++ PlayerFishEvent playerFishEvent = new PlayerFishEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), null, (org.bukkit.entity.Fish) entityfishinghook.getBukkitEntity(), PlayerFishEvent.State.FISHING); ++ world.getServer().getPluginManager().callEvent(playerFishEvent); ++ ++ if (playerFishEvent.isCancelled()) { ++ entityhuman.hookedFish = null; ++ return new InteractionResultWrapper(EnumInteractionResult.PASS, itemstack); ++ } ++ world.a((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.I, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemFishingRod.j.nextFloat() * 0.4F + 0.8F)); ++ // CraftBukkit end - entityhuman.a(enumhand); + world.addEntity(entityfishinghook); + } diff --git a/nms-patches/ItemFlintAndSteel.patch b/nms-patches/ItemFlintAndSteel.patch index 39a667dea0..bd5b2aa3cc 100644 --- a/nms-patches/ItemFlintAndSteel.patch +++ b/nms-patches/ItemFlintAndSteel.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/ItemFlintAndSteel.java +++ b/net/minecraft/server/ItemFlintAndSteel.java -@@ -14,6 +14,12 @@ +@@ -16,6 +16,12 @@ return EnumInteractionResult.FAIL; } else { if (world.getType(blockposition).getMaterial() == Material.AIR) { @@ -10,6 +10,6 @@ + return EnumInteractionResult.PASS; + } + // CraftBukkit end - world.a(entityhuman, blockposition, SoundEffects.by, SoundCategory.BLOCKS, 1.0F, ItemFlintAndSteel.j.nextFloat() * 0.4F + 0.8F); + world.a(entityhuman, blockposition, SoundEffects.bI, SoundCategory.BLOCKS, 1.0F, ItemFlintAndSteel.j.nextFloat() * 0.4F + 0.8F); world.setTypeAndData(blockposition, Blocks.FIRE.getBlockData(), 11); } diff --git a/nms-patches/ItemHanging.patch b/nms-patches/ItemHanging.patch index bdb703042a..89b547f8ff 100644 --- a/nms-patches/ItemHanging.patch +++ b/nms-patches/ItemHanging.patch @@ -11,7 +11,7 @@ public class ItemHanging extends Item { -@@ -19,6 +23,18 @@ +@@ -20,6 +24,18 @@ if (entityhanging != null && entityhanging.survives()) { if (!world.isClientSide) { diff --git a/nms-patches/ItemMapEmpty.patch b/nms-patches/ItemMapEmpty.patch deleted file mode 100644 index 754beb3693..0000000000 --- a/nms-patches/ItemMapEmpty.patch +++ /dev/null @@ -1,26 +0,0 @@ ---- a/net/minecraft/server/ItemMapEmpty.java -+++ b/net/minecraft/server/ItemMapEmpty.java -@@ -7,16 +7,20 @@ - } - - public InteractionResultWrapper a(ItemStack itemstack, World world, EntityHuman entityhuman, EnumHand enumhand) { -- ItemStack itemstack1 = new ItemStack(Items.FILLED_MAP, 1, world.b("map")); -+ World worldMain = world.getServer().getServer().worlds.get(0); // CraftBukkit - store reference to primary world -+ ItemStack itemstack1 = new ItemStack(Items.FILLED_MAP, 1, worldMain.b("map")); // CraftBukkit - use primary world for maps - String s = "map_" + itemstack1.getData(); - WorldMap worldmap = new WorldMap(s); - -- world.a(s, (PersistentBase) worldmap); -+ worldMain.a(s, (PersistentBase) worldmap); // CraftBukkit - worldmap.scale = 0; - worldmap.a(entityhuman.locX, entityhuman.locZ, worldmap.scale); -- worldmap.map = (byte) world.worldProvider.getDimensionManager().getDimensionID(); -+ worldmap.map = (byte) ((WorldServer) world).dimension; // CraftBukkit - use bukkit dimension - worldmap.track = true; - worldmap.c(); -+ -+ org.bukkit.craftbukkit.event.CraftEventFactory.callEvent(new org.bukkit.event.server.MapInitializeEvent(worldmap.mapView)); // CraftBukkit -+ - --itemstack.count; - if (itemstack.count <= 0) { - return new InteractionResultWrapper(EnumInteractionResult.SUCCESS, itemstack1); diff --git a/nms-patches/ItemMinecart.patch b/nms-patches/ItemMinecart.patch index 393004a7c1..2a92f8c0aa 100644 --- a/nms-patches/ItemMinecart.patch +++ b/nms-patches/ItemMinecart.patch @@ -28,12 +28,12 @@ + } + + if (event.isCancelled()) { -+ itemstack.count++; ++ itemstack.add(1); + return itemstack; + } + + if (!event.getItem().equals(craftItem)) { -+ itemstack.count++; ++ itemstack.add(1); + // Chain to handler for new item + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); @@ -51,8 +51,8 @@ } world.addEntity(entityminecartabstract); -- itemstack.cloneAndSubtract(1); -+ // itemstack.cloneAndSubtract(1); // CraftBukkit - handled during event processing +- itemstack.subtract(1); ++ // itemstack.subtract(1); // CraftBukkit - handled during event processing + // CraftBukkit end return itemstack; } diff --git a/nms-patches/ItemMonsterEgg.patch b/nms-patches/ItemMonsterEgg.patch index cd535c79a4..95d75a2970 100644 --- a/nms-patches/ItemMonsterEgg.patch +++ b/nms-patches/ItemMonsterEgg.patch @@ -1,19 +1,20 @@ --- a/net/minecraft/server/ItemMonsterEgg.java +++ b/net/minecraft/server/ItemMonsterEgg.java -@@ -131,6 +131,10 @@ +@@ -153,6 +153,11 @@ @Nullable - public static Entity a(World world, @Nullable String s, double d0, double d1, double d2) { -+ return spawnCreature(world, s, d0, d1, d2, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG); + public static Entity a(World world, @Nullable MinecraftKey minecraftkey, double d0, double d1, double d2) { ++ return spawnCreature(world, minecraftkey, d0, d1, d2, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG); + } + -+ public static Entity spawnCreature(World world, String s, double d0, double d1, double d2, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) { - if (s != null && EntityTypes.eggInfo.containsKey(s)) { ++ @Nullable ++ public static Entity spawnCreature(World world, @Nullable MinecraftKey minecraftkey, double d0, double d1, double d2, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) { + if (minecraftkey != null && EntityTypes.eggInfo.containsKey(minecraftkey)) { Entity entity = null; -@@ -143,8 +147,13 @@ - entityinsentient.aQ = entityinsentient.yaw; - entityinsentient.aO = entityinsentient.yaw; +@@ -165,8 +170,13 @@ + entityinsentient.aP = entityinsentient.yaw; + entityinsentient.aN = entityinsentient.yaw; entityinsentient.prepare(world.D(new BlockPosition(entityinsentient)), (GroupDataEntity) null); - world.addEntity(entity); - entityinsentient.D(); diff --git a/nms-patches/ItemRecord.patch b/nms-patches/ItemRecord.patch index ef57144703..0dff1125b8 100644 --- a/nms-patches/ItemRecord.patch +++ b/nms-patches/ItemRecord.patch @@ -5,6 +5,6 @@ if (iblockdata.getBlock() == Blocks.JUKEBOX && !((Boolean) iblockdata.get(BlockJukeBox.HAS_RECORD)).booleanValue()) { if (!world.isClientSide) { + if (true) return EnumInteractionResult.SUCCESS; // CraftBukkit - handled in ItemStack + ItemStack itemstack = entityhuman.b(enumhand); + ((BlockJukeBox) Blocks.JUKEBOX).a(world, blockposition, iblockdata, itemstack); - world.a((EntityHuman) null, 1010, blockposition, Item.getId(this)); - --itemstack.count; diff --git a/nms-patches/ItemSkull.patch b/nms-patches/ItemSkull.patch index c97743dabe..da4ce8a1ba 100644 --- a/nms-patches/ItemSkull.patch +++ b/nms-patches/ItemSkull.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/ItemSkull.java +++ b/net/minecraft/server/ItemSkull.java -@@ -117,6 +117,15 @@ +@@ -120,6 +120,15 @@ nbttagcompound.set("SkullOwner", GameProfileSerializer.serialize(new NBTTagCompound(), gameprofile)); return true; } else { diff --git a/nms-patches/ItemSnowball.patch b/nms-patches/ItemSnowball.patch index e2a91644a6..64293dcc6e 100644 --- a/nms-patches/ItemSnowball.patch +++ b/nms-patches/ItemSnowball.patch @@ -1,16 +1,16 @@ --- a/net/minecraft/server/ItemSnowball.java +++ b/net/minecraft/server/ItemSnowball.java -@@ -8,17 +8,28 @@ - } +@@ -10,17 +10,29 @@ + public InteractionResultWrapper a(World world, EntityHuman entityhuman, EnumHand enumhand) { + ItemStack itemstack = entityhuman.b(enumhand); - public InteractionResultWrapper a(ItemStack itemstack, World world, EntityHuman entityhuman, EnumHand enumhand) { -- if (!entityhuman.abilities.canInstantlyBuild) { + // CraftBukkit start - moved down -+ /*if (!entityhuman.abilities.canInstantlyBuild) { - --itemstack.count; ++ /* + if (!entityhuman.abilities.canInstantlyBuild) { + itemstack.subtract(1); } - world.a((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.fS, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemSnowball.j.nextFloat() * 0.4F + 0.8F)); + world.a((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.go, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemSnowball.j.nextFloat() * 0.4F + 0.8F)); + */ if (!world.isClientSide) { EntitySnowball entitysnowball = new EntitySnowball(world, entityhuman); @@ -19,10 +19,10 @@ - world.addEntity(entitysnowball); + if (world.addEntity(entitysnowball)) { + if (!entityhuman.abilities.canInstantlyBuild) { -+ --itemstack.count; ++ itemstack.subtract(1); + } + -+ world.a((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.fS, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemSnowball.j.nextFloat() * 0.4F + 0.8F)); ++ world.a((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.go, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemSnowball.j.nextFloat() * 0.4F + 0.8F)); + } else if (entityhuman instanceof EntityPlayer) { + ((EntityPlayer) entityhuman).getBukkitEntity().updateInventory(); + } diff --git a/nms-patches/ItemStack.patch b/nms-patches/ItemStack.patch index e6cb7f258e..cf740c5a0d 100644 --- a/nms-patches/ItemStack.patch +++ b/nms-patches/ItemStack.patch @@ -19,38 +19,67 @@ + public final class ItemStack { - public static final DecimalFormat a = new DecimalFormat("#.##"); -@@ -43,10 +56,20 @@ - public ItemStack(Item item, int i, int j) { + public static final ItemStack a = new ItemStack((Item) null); +@@ -46,6 +59,15 @@ this.item = item; + this.damage = j; this.count = i; -- this.damage = j; -- if (this.damage < 0) { -- this.damage = 0; -+ + // CraftBukkit start - Pass to setData to do filtering -+ this.setData(j); -+ //this.damage = j; -+ //if (this.damage < 0) { -+ // this.damage = 0; -+ //} + if (MinecraftServer.getServer() != null) { ++ this.setData(j); + NBTTagCompound savedStack = new NBTTagCompound(); + this.save(savedStack); + MinecraftServer.getServer().getDataConverterManager().a(DataConverterTypes.ITEM_INSTANCE, savedStack); // PAIL: convert -+ this.c(savedStack); // PAIL: load - } ++ this.load(savedStack); ++ } + // CraftBukkit end - + if (this.damage < 0) { + this.damage = 0; + } +@@ -54,20 +76,32 @@ } -@@ -81,11 +104,137 @@ + private void F() { ++ if (this.g && this == ItemStack.a) throw new AssertionError("TRAP"); // CraftBukkit + this.g = this.isEmpty(); + } + +- public ItemStack(NBTTagCompound nbttagcompound) { ++ // CraftBukkit - break into own method ++ public void load(NBTTagCompound nbttagcompound) { + this.item = Item.b(nbttagcompound.getString("id")); + this.count = nbttagcompound.getByte("Count"); +- this.damage = Math.max(0, nbttagcompound.getShort("Damage")); ++ // CraftBukkit start - Route through setData for filtering ++ // this.damage = Math.max(0, nbttagcompound.getShort("Damage")); ++ this.setData(Math.max(0, nbttagcompound.getShort("Damage"))); ++ // CraftBukkit end ++ + if (nbttagcompound.hasKeyOfType("tag", 10)) { +- this.tag = nbttagcompound.getCompound("tag"); ++ // CraftBukkit start - make defensive copy as this data may be coming from the save thread ++ this.tag = (NBTTagCompound) nbttagcompound.getCompound("tag").clone(); + if (this.item != null) { +- this.item.a(nbttagcompound); ++ this.item.a(this.tag); ++ // CraftBukkit end + } + } ++ } + ++ public ItemStack(NBTTagCompound nbttagcompound) { ++ this.load(nbttagcompound); ++ // CraftBukkit end + this.F(); + } + +@@ -94,11 +128,137 @@ } public EnumInteractionResult placeItem(EntityHuman entityhuman, World world, BlockPosition blockposition, EnumHand enumhand, EnumDirection enumdirection, float f, float f1, float f2) { + // CraftBukkit start - handle all block place event logic here -+ int data = this.getData(); -+ int count = this.count; ++ int oldData = this.getData(); ++ int oldCount = this.getCount(); + + if (!(this.getItem() instanceof ItemBucket)) { // if not bucket + world.captureBlockStates = true; @@ -62,11 +91,11 @@ + } + } + } - EnumInteractionResult enuminteractionresult = this.getItem().a(this, entityhuman, world, blockposition, enumhand, enumdirection, f, f1, f2); + EnumInteractionResult enuminteractionresult = this.getItem().a(entityhuman, world, blockposition, enumhand, enumdirection, f, f1, f2); + int newData = this.getData(); -+ int newCount = this.count; -+ this.count = count; -+ this.setData(data); ++ int newCount = this.getCount(); ++ this.setCount(oldCount); ++ this.setData(oldData); + world.captureBlockStates = false; + if (enuminteractionresult == EnumInteractionResult.SUCCESS && world.captureTreeGeneration && world.capturedBlockStates.size() > 0) { + world.captureTreeGeneration = false; @@ -77,15 +106,15 @@ + world.capturedBlockStates.clear(); + StructureGrowEvent event = null; + if (treeType != null) { -+ boolean isBonemeal = getItem() == Items.DYE && data == 15; ++ boolean isBonemeal = getItem() == Items.DYE && oldData == 15; + event = new StructureGrowEvent(location, treeType, isBonemeal, (Player) entityhuman.getBukkitEntity(), blocks); + org.bukkit.Bukkit.getPluginManager().callEvent(event); + } + if (event == null || !event.isCancelled()) { + // Change the stack to its new contents if it hasn't been tampered with. -+ if (this.count == count && this.getData() == data) { ++ if (this.getCount() == oldCount && this.getData() == oldData) { + this.setData(newData); -+ this.count = newCount; ++ this.setCount(newCount); + } + for (BlockState blockstate : blocks) { + blockstate.update(true); @@ -117,9 +146,9 @@ + } + } else { + // Change the stack to its new contents if it hasn't been tampered with. -+ if (this.count == count && this.getData() == data) { ++ if (this.getCount() == oldCount && this.getData() == oldData) { + this.setData(newData); -+ this.count = newCount; ++ this.setCount(newCount); + } + for (BlockState blockstate : blocks) { + int x = blockstate.getX(); @@ -147,7 +176,7 @@ + if (this.getItem() instanceof ItemRecord) { + ((BlockJukeBox) Blocks.JUKEBOX).a(world, blockposition, world.getType(blockposition), this); + world.a((EntityHuman) null, 1010, blockposition, Item.getId(this.item)); -+ --this.count; ++ this.subtract(1); + entityhuman.b(StatisticList.Z); + } + @@ -170,7 +199,7 @@ + + // SPIGOT-1288 - play sound stripped from ItemBlock + if (this.getItem() instanceof ItemBlock) { -+ SoundEffectType soundeffecttype = ((ItemBlock) this.getItem()).d().w(); // PAIL: rename ++ SoundEffectType soundeffecttype = ((ItemBlock) this.getItem()).getBlock().getStepSound(); + world.a(entityhuman, blockposition, soundeffecttype.e(), SoundCategory.BLOCKS, (soundeffecttype.a() + 1.0F) / 2.0F, soundeffecttype.b() * 0.8F); + } + @@ -183,7 +212,7 @@ return enuminteractionresult; } -@@ -110,7 +259,7 @@ +@@ -122,7 +282,7 @@ nbttagcompound.setByte("Count", (byte) this.count); nbttagcompound.setShort("Damage", (short) this.damage); if (this.tag != null) { @@ -192,27 +221,7 @@ } return nbttagcompound; -@@ -119,13 +268,18 @@ - public void c(NBTTagCompound nbttagcompound) { - this.item = Item.d(nbttagcompound.getString("id")); - this.count = nbttagcompound.getByte("Count"); -+ /* CraftBukkit start - Route through setData for filtering - this.damage = nbttagcompound.getShort("Damage"); - if (this.damage < 0) { - this.damage = 0; - } -+ */ -+ this.setData(nbttagcompound.getShort("Damage")); -+ // CraftBukkit end - - if (nbttagcompound.hasKeyOfType("tag", 10)) { -- this.tag = nbttagcompound.getCompound("tag"); -+ // CraftBukkit - make defensive copy as this data may be coming from the save thread -+ this.tag = (NBTTagCompound) nbttagcompound.getCompound("tag").clone(); - if (this.item != null) { - this.item.a(this.tag); - } -@@ -162,11 +316,30 @@ +@@ -157,11 +317,30 @@ } public void setData(int i) { @@ -238,15 +247,14 @@ + // CraftBukkit end this.damage = i; if (this.damage < 0) { -- this.damage = 0; -+ // this.damage = 0; // CraftBukkit - remove this. + this.damage = 0; } - } - public int j() { -@@ -214,6 +387,12 @@ - this.count = 0; + public int k() { +@@ -205,6 +384,11 @@ + entityhuman.b(StatisticList.c(this.item)); } + // CraftBukkit start - Check for item breaking @@ -254,15 +262,19 @@ + org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerItemBreakEvent((EntityHuman) entityliving, this); + } + // CraftBukkit end -+ this.damage = 0; } -@@ -514,6 +693,7 @@ - @Deprecated - public void setItem(Item item) { - this.item = item; -+ this.setData(this.getData()); // CraftBukkit - Set data again to ensure it is filtered properly +@@ -509,6 +693,12 @@ + nbttaglist.add(nbttagcompound); } - public IChatBaseComponent B() { ++ @Deprecated ++ public void setItem(Item item) { ++ this.item = item; ++ this.setData(this.getData()); // CraftBukkit - Set data again to ensure it is filtered properly ++ } ++ + public IChatBaseComponent C() { + ChatComponentText chatcomponenttext = new ChatComponentText(this.getName()); + diff --git a/nms-patches/ItemWaterLily.patch b/nms-patches/ItemWaterLily.patch index ab27cf91ae..89115f2428 100644 --- a/nms-patches/ItemWaterLily.patch +++ b/nms-patches/ItemWaterLily.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/ItemWaterLily.java +++ b/net/minecraft/server/ItemWaterLily.java -@@ -23,7 +23,15 @@ +@@ -24,7 +24,15 @@ IBlockData iblockdata = world.getType(blockposition); if (iblockdata.getMaterial() == Material.WATER && ((Integer) iblockdata.get(BlockFluids.LEVEL)).intValue() == 0 && world.isEmpty(blockposition1)) { @@ -14,5 +14,5 @@ + } + // CraftBukkit end if (!entityhuman.abilities.canInstantlyBuild) { - --itemstack.count; + itemstack.subtract(1); } diff --git a/nms-patches/ItemWorldMap.patch b/nms-patches/ItemWorldMap.patch index dde295a598..42baeba595 100644 --- a/nms-patches/ItemWorldMap.patch +++ b/nms-patches/ItemWorldMap.patch @@ -12,9 +12,30 @@ public class ItemWorldMap extends ItemWorldMapBase { protected ItemWorldMap() { -@@ -12,25 +17,32 @@ +@@ -12,41 +17,50 @@ } + public static ItemStack a(World world, double d0, double d1, byte b0, boolean flag, boolean flag1) { +- ItemStack itemstack = new ItemStack(Items.FILLED_MAP, 1, world.b("map")); ++ World worldMain = world.getServer().getServer().worlds.get(0); // CraftBukkit - store reference to primary world ++ ItemStack itemstack = new ItemStack(Items.FILLED_MAP, 1, worldMain.b("map")); // CraftBukkit - use primary world for maps + String s = "map_" + itemstack.getData(); + WorldMap worldmap = new WorldMap(s); + +- world.a(s, (PersistentBase) worldmap); ++ worldMain.a(s, (PersistentBase) worldmap); // CraftBukkit + worldmap.scale = b0; + worldmap.a(d0, d1, worldmap.scale); +- worldmap.map = (byte) world.worldProvider.getDimensionManager().getDimensionID(); ++ worldmap.map = (byte) ((WorldServer) world).dimension; // CraftBukkit - use bukkit dimension + worldmap.track = flag; + worldmap.unlimitedTracking = flag1; + worldmap.c(); ++ org.bukkit.craftbukkit.event.CraftEventFactory.callEvent(new org.bukkit.event.server.MapInitializeEvent(worldmap.mapView)); // CraftBukkit + return itemstack; + } + + @Nullable public WorldMap getSavedMap(ItemStack itemstack, World world) { + World worldMain = world.getServer().getServer().worlds.get(0); // CraftBukkit - store reference to primary world String s = "map_" + itemstack.getData(); @@ -50,7 +71,7 @@ int i = 1 << worldmap.scale; int j = worldmap.centerX; int k = worldmap.centerZ; -@@ -197,6 +209,7 @@ +@@ -308,6 +322,7 @@ protected static void a(ItemStack itemstack, World world, int i) { WorldMap worldmap = Items.FILLED_MAP.getSavedMap(itemstack, world); @@ -58,16 +79,18 @@ itemstack.setData(world.b("map")); WorldMap worldmap1 = new WorldMap("map_" + itemstack.getData()); -@@ -206,11 +219,16 @@ - worldmap1.map = worldmap.map; - worldmap1.c(); - world.a("map_" + itemstack.getData(), (PersistentBase) worldmap1); -+ // CraftBukkit start -+ MapInitializeEvent event = new MapInitializeEvent(worldmap1.mapView); -+ Bukkit.getServer().getPluginManager().callEvent(event); -+ // CraftBukkit end - } +@@ -318,6 +333,10 @@ + worldmap1.map = worldmap.map; + worldmap1.c(); + world.a("map_" + itemstack.getData(), (PersistentBase) worldmap1); ++ // CraftBukkit start ++ MapInitializeEvent event = new MapInitializeEvent(worldmap1.mapView); ++ Bukkit.getServer().getPluginManager().callEvent(event); ++ // CraftBukkit end + } + } +@@ -325,6 +344,7 @@ protected static void b(ItemStack itemstack, World world) { WorldMap worldmap = Items.FILLED_MAP.getSavedMap(itemstack, world); @@ -75,13 +98,14 @@ itemstack.setData(world.b("map")); WorldMap worldmap1 = new WorldMap("map_" + itemstack.getData()); -@@ -221,5 +239,9 @@ - worldmap1.map = worldmap.map; - worldmap1.c(); - world.a("map_" + itemstack.getData(), (PersistentBase) worldmap1); -+ // CraftBukkit start -+ MapInitializeEvent event = new MapInitializeEvent(worldmap1.mapView); -+ Bukkit.getServer().getPluginManager().callEvent(event); -+ // CraftBukkit end +@@ -336,6 +356,10 @@ + worldmap1.map = worldmap.map; + worldmap1.c(); + world.a("map_" + itemstack.getData(), (PersistentBase) worldmap1); ++ // CraftBukkit start ++ MapInitializeEvent event = new MapInitializeEvent(worldmap1.mapView); ++ Bukkit.getServer().getPluginManager().callEvent(event); ++ // CraftBukkit end + } + } - } diff --git a/nms-patches/LoginListener.patch b/nms-patches/LoginListener.patch index ae5fb65559..ceee1d4e8d 100644 --- a/nms-patches/LoginListener.patch +++ b/nms-patches/LoginListener.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/LoginListener.java +++ b/net/minecraft/server/LoginListener.java -@@ -18,6 +18,12 @@ +@@ -22,6 +22,12 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -13,7 +13,7 @@ public class LoginListener implements PacketLoginInListener, ITickable { private static final AtomicInteger b = new AtomicInteger(0); -@@ -32,6 +38,7 @@ +@@ -36,6 +42,7 @@ private final String j; private SecretKey loginKey; private EntityPlayer l; @@ -21,7 +21,7 @@ public LoginListener(MinecraftServer minecraftserver, NetworkManager networkmanager) { this.g = LoginListener.EnumProtocolState.HELLO; -@@ -78,10 +85,12 @@ +@@ -82,10 +89,12 @@ this.i = this.a(this.i); } @@ -36,9 +36,9 @@ + // CraftBukkit end } else { this.g = LoginListener.EnumProtocolState.ACCEPTED; - if (this.server.aF() >= 0 && !this.networkManager.isLocal()) { -@@ -90,7 +99,7 @@ - LoginListener.this.networkManager.setCompressionLevel(LoginListener.this.server.aF()); + if (this.server.aG() >= 0 && !this.networkManager.isLocal()) { +@@ -94,7 +103,7 @@ + LoginListener.this.networkManager.setCompressionLevel(LoginListener.this.server.aG()); } - public void operationComplete(Future future) throws Exception { @@ -46,7 +46,7 @@ this.a((ChannelFuture) future); } }, new GenericFutureListener[0]); -@@ -101,9 +110,9 @@ +@@ -105,9 +114,9 @@ if (entityplayer != null) { this.g = LoginListener.EnumProtocolState.DELAY_ACCEPT; @@ -58,9 +58,9 @@ } } -@@ -148,6 +157,43 @@ +@@ -152,6 +161,43 @@ - LoginListener.this.i = LoginListener.this.server.ay().hasJoinedServer(new GameProfile((UUID) null, gameprofile.getName()), s); + LoginListener.this.i = LoginListener.this.server.az().hasJoinedServer(new GameProfile((UUID) null, gameprofile.getName()), s, this.a()); if (LoginListener.this.i != null) { + // CraftBukkit start - fire PlayerPreLoginEvent + if (!networkManager.isConnected()) { @@ -102,7 +102,7 @@ LoginListener.c.info("UUID of player {} is {}", new Object[] { LoginListener.this.i.getName(), LoginListener.this.i.getId()}); LoginListener.this.g = LoginListener.EnumProtocolState.READY_TO_ACCEPT; } else if (LoginListener.this.server.R()) { -@@ -167,6 +213,11 @@ +@@ -171,6 +217,11 @@ LoginListener.this.disconnect("Authentication servers are down. Please try again later, sorry!"); LoginListener.c.error("Couldn\'t verify username because servers are unavailable"); } diff --git a/nms-patches/MerchantRecipe.patch b/nms-patches/MerchantRecipe.patch index 7a85d09462..176a59b24e 100644 --- a/nms-patches/MerchantRecipe.patch +++ b/nms-patches/MerchantRecipe.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/server/MerchantRecipe.java +++ b/net/minecraft/server/MerchantRecipe.java -@@ -1,6 +1,7 @@ +@@ -1,5 +1,7 @@ package net.minecraft.server; - import javax.annotation.Nullable; +import org.bukkit.craftbukkit.inventory.CraftMerchantRecipe; // CraftBukkit - ++ public class MerchantRecipe { -@@ -10,6 +11,18 @@ + public ItemStack buyingItem1; +@@ -8,6 +10,18 @@ public int uses; public int maxUses; public boolean rewardExp; @@ -26,4 +26,4 @@ + // CraftBukkit end public MerchantRecipe(NBTTagCompound nbttagcompound) { - this.a(nbttagcompound); + this.buyingItem1 = ItemStack.a; diff --git a/nms-patches/MinecraftServer.patch b/nms-patches/MinecraftServer.patch index 909dba27d5..a60fd8bfe3 100644 --- a/nms-patches/MinecraftServer.patch +++ b/nms-patches/MinecraftServer.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -38,6 +38,13 @@ +@@ -40,6 +40,13 @@ import org.apache.commons.lang3.Validate; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -14,9 +14,9 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAsyncTaskHandler, IMojangStatistics { -@@ -94,19 +101,61 @@ +@@ -97,19 +104,61 @@ private Thread serverThread; - private long aa = av(); + private long ab = aw(); - public MinecraftServer(File file, Proxy proxy, DataConverterManager dataconvertermanager, YggdrasilAuthenticationService yggdrasilauthenticationservice, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache) { + // CraftBukkit start @@ -34,10 +34,10 @@ + + public MinecraftServer(OptionSet options, Proxy proxy, DataConverterManager dataconvertermanager, YggdrasilAuthenticationService yggdrasilauthenticationservice, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache) { this.e = proxy; - this.U = yggdrasilauthenticationservice; - this.V = minecraftsessionservice; - this.W = gameprofilerepository; - this.X = usercache; + this.V = yggdrasilauthenticationservice; + this.W = minecraftsessionservice; + this.X = gameprofilerepository; + this.Y = usercache; - this.universe = file; + // this.universe = file; // CraftBukkit this.p = new ServerConnection(this); @@ -79,7 +79,7 @@ protected CommandDispatcher i() { return new CommandDispatcher(this); } -@@ -144,6 +193,7 @@ +@@ -147,6 +196,7 @@ this.a(s); this.b("menu.loadingLevel"); this.worldServer = new WorldServer[3]; @@ -87,7 +87,7 @@ this.i = new long[this.worldServer.length][100]; IDataManager idatamanager = this.convertable.a(s, true); -@@ -167,36 +217,108 @@ +@@ -170,36 +220,108 @@ worlddata.a(s1); worldsettings = new WorldSettings(worlddata); } @@ -207,18 +207,18 @@ this.v.setPlayerFileData(this.worldServer); this.a(this.getDifficulty()); this.l(); -@@ -212,25 +334,38 @@ +@@ -215,25 +337,38 @@ this.b("menu.generatingTerrain"); boolean flag4 = false; - MinecraftServer.LOGGER.info("Preparing start region for level 0"); - WorldServer worldserver = this.worldServer[0]; - BlockPosition blockposition = worldserver.getSpawn(); -- long j = av(); +- long j = aw(); - - for (int k = -192; k <= 192 && this.isRunning(); k += 16) { - for (int l = -192; l <= 192 && this.isRunning(); l += 16) { -- long i1 = av(); +- long i1 = aw(); - - if (i1 - j > 1000L) { - this.a_("Preparing spawn area", i * 100 / 625); @@ -234,12 +234,12 @@ + } + + BlockPosition blockposition = worldserver.getSpawn(); -+ long j = av(); ++ long j = aw(); + i = 0; + + for (int k = -192; k <= 192 && this.isRunning(); k += 16) { + for (int l = -192; l <= 192 && this.isRunning(); l += 16) { -+ long i1 = av(); ++ long i1 = aw(); + + if (i1 - j > 1000L) { + this.a_("Preparing spawn area", i * 100 / 625); @@ -261,7 +261,7 @@ this.t(); } -@@ -266,14 +401,17 @@ +@@ -273,14 +408,17 @@ protected void t() { this.f = null; this.g = 0; @@ -281,7 +281,7 @@ if (worldserver != null) { if (!flag) { -@@ -282,6 +420,7 @@ +@@ -289,6 +427,7 @@ try { worldserver.save(true, (IProgressUpdate) null); @@ -289,7 +289,7 @@ } catch (ExceptionWorldConflict exceptionworldconflict) { MinecraftServer.LOGGER.warn(exceptionworldconflict.getMessage()); } -@@ -290,8 +429,24 @@ +@@ -297,8 +436,24 @@ } @@ -312,10 +312,10 @@ + this.server.disablePlugins(); + } + // CraftBukkit end - if (this.am() != null) { - this.am().b(); + if (this.an() != null) { + this.an().b(); } -@@ -300,6 +455,7 @@ +@@ -307,6 +462,7 @@ MinecraftServer.LOGGER.info("Saving players"); this.v.savePlayers(); this.v.u(); @@ -323,7 +323,7 @@ } if (this.worldServer != null) { -@@ -321,12 +477,14 @@ +@@ -328,12 +484,14 @@ aworldserver = this.worldServer; i = aworldserver.length; @@ -338,18 +338,18 @@ } if (this.m.d()) { -@@ -366,6 +524,7 @@ - long k = j - this.aa; +@@ -373,6 +531,7 @@ + long k = j - this.ab; - if (k > 2000L && this.aa - this.Q >= 15000L) { + if (k > 2000L && this.ab - this.R >= 15000L) { + if (server.getWarnOnOverload()) // CraftBukkit MinecraftServer.LOGGER.warn("Can\'t keep up! Did the system time change, or is the server overloaded? Running {}ms behind, skipping {} tick(s)", new Object[] { Long.valueOf(k), Long.valueOf(k / 50L)}); k = 2000L; - this.Q = this.aa; -@@ -378,11 +537,12 @@ + this.R = this.ab; +@@ -385,11 +544,12 @@ i += k; - this.aa = j; + this.ab = j; - if (this.worldServer[0].everyoneDeeplySleeping()) { + if (this.worlds.get(0).everyoneDeeplySleeping()) { // CraftBukkit this.C(); @@ -360,7 +360,7 @@ i -= 50L; this.C(); } -@@ -420,6 +580,12 @@ +@@ -427,6 +587,12 @@ } catch (Throwable throwable1) { MinecraftServer.LOGGER.error("Exception stopping the server", throwable1); } finally { @@ -373,7 +373,7 @@ this.B(); } -@@ -463,7 +629,7 @@ +@@ -470,7 +636,7 @@ public void B() {} @@ -382,7 +382,7 @@ long i = System.nanoTime(); ++this.ticks; -@@ -489,7 +655,7 @@ +@@ -496,7 +662,7 @@ this.q.b().a(agameprofile); } @@ -391,7 +391,7 @@ this.methodProfiler.a("save"); this.v.savePlayers(); this.saveChunks(true); -@@ -513,6 +679,7 @@ +@@ -520,6 +686,7 @@ } public void D() { @@ -399,7 +399,7 @@ this.methodProfiler.a("jobs"); Queue queue = this.j; -@@ -524,20 +691,38 @@ +@@ -531,20 +698,38 @@ this.methodProfiler.c("levels"); @@ -441,7 +441,7 @@ this.methodProfiler.a("tick"); -@@ -564,9 +749,9 @@ +@@ -571,9 +756,9 @@ worldserver.getTracker().updatePlayers(); this.methodProfiler.b(); this.methodProfiler.b(); @@ -453,7 +453,7 @@ } this.methodProfiler.c("connection"); -@@ -590,10 +775,11 @@ +@@ -597,10 +782,11 @@ this.o.add(itickable); } @@ -466,7 +466,7 @@ boolean flag = true; String s = null; String s1 = "."; -@@ -638,13 +824,16 @@ +@@ -645,13 +831,16 @@ ++j; } } @@ -484,7 +484,7 @@ if (s != null) { dedicatedserver.i(s); } -@@ -675,6 +864,25 @@ +@@ -682,6 +871,25 @@ dedicatedserver.stop(); } }); @@ -510,7 +510,7 @@ } catch (Exception exception) { MinecraftServer.LOGGER.fatal("Failed to start the minecraft server", exception); } -@@ -682,8 +890,10 @@ +@@ -689,8 +897,10 @@ } public void F() { @@ -521,7 +521,7 @@ } public File d(String s) { -@@ -699,7 +909,14 @@ +@@ -706,7 +916,14 @@ } public WorldServer getWorldServer(int i) { @@ -537,7 +537,7 @@ } public String getVersion() { -@@ -723,7 +940,7 @@ +@@ -730,7 +947,7 @@ } public boolean isDebugging() { @@ -546,7 +546,7 @@ } public void g(String s) { -@@ -738,7 +955,7 @@ +@@ -745,7 +962,7 @@ } public String getServerModName() { @@ -555,7 +555,7 @@ } public CrashReport b(CrashReport crashreport) { -@@ -767,6 +984,7 @@ +@@ -774,6 +991,7 @@ } public List tabCompleteCommand(ICommandListener icommandlistener, String s, @Nullable BlockPosition blockposition, boolean flag) { @@ -563,7 +563,7 @@ ArrayList arraylist = Lists.newArrayList(); boolean flag1 = s.startsWith("/"); -@@ -809,10 +1027,13 @@ +@@ -816,10 +1034,13 @@ return arraylist; } @@ -578,7 +578,7 @@ } public String getName() { -@@ -868,11 +1089,13 @@ +@@ -875,11 +1096,13 @@ } public void a(EnumDifficulty enumdifficulty) { @@ -595,7 +595,7 @@ if (worldserver != null) { if (worldserver.getWorldData().isHardcore()) { -@@ -939,13 +1162,11 @@ +@@ -946,13 +1169,11 @@ int i = 0; if (this.worldServer != null) { @@ -613,7 +613,7 @@ WorldData worlddata = worldserver.getWorldData(); mojangstatisticsgenerator.a("world[" + i + "][dimension]", Integer.valueOf(worldserver.worldProvider.getDimensionManager().getDimensionID())); -@@ -978,7 +1199,7 @@ +@@ -985,7 +1206,7 @@ public abstract boolean aa(); public boolean getOnlineMode() { @@ -622,7 +622,7 @@ } public void setOnlineMode(boolean flag) { -@@ -1050,13 +1271,9 @@ +@@ -1065,13 +1286,9 @@ } public void setGamemode(EnumGamemode enumgamemode) { @@ -639,7 +639,7 @@ } } -@@ -1088,7 +1305,7 @@ +@@ -1103,7 +1320,7 @@ } public World getWorld() { @@ -648,7 +648,7 @@ } public Entity f() { -@@ -1160,8 +1377,10 @@ +@@ -1175,8 +1392,10 @@ WorldServer[] aworldserver = this.worldServer; int i = aworldserver.length; @@ -661,7 +661,7 @@ if (worldserver != null) { Entity entity = worldserver.getEntity(uuid); -@@ -1176,7 +1395,7 @@ +@@ -1191,7 +1410,7 @@ } public boolean getSendCommandFeedback() { @@ -670,7 +670,7 @@ } public void a(CommandObjectiveExecutor.EnumCommandResult commandobjectiveexecutor_enumcommandresult, int i) {} -@@ -1191,7 +1410,7 @@ +@@ -1206,7 +1425,7 @@ public ListenableFuture a(Callable callable) { Validate.notNull(callable); @@ -679,7 +679,7 @@ ListenableFutureTask listenablefuturetask = ListenableFutureTask.create(callable); Queue queue = this.j; -@@ -1236,4 +1455,11 @@ +@@ -1251,4 +1470,11 @@ public int a(@Nullable WorldServer worldserver) { return worldserver != null ? worldserver.getGameRules().c("spawnRadius") : 10; } diff --git a/nms-patches/MobEffectList.patch b/nms-patches/MobEffectList.patch index c2e9b5e2d2..c7556e1568 100644 --- a/nms-patches/MobEffectList.patch +++ b/nms-patches/MobEffectList.patch @@ -36,7 +36,7 @@ } else if (this == MobEffects.WITHER) { entityliving.damageEntity(DamageSource.WITHER, 1.0F); @@ -63,14 +68,25 @@ - ((EntityHuman) entityliving).applyExhaustion(0.025F * (float) (i + 1)); + ((EntityHuman) entityliving).applyExhaustion(0.005F * (float) (i + 1)); } else if (this == MobEffects.SATURATION && entityliving instanceof EntityHuman) { if (!entityliving.world.isClientSide) { - ((EntityHuman) entityliving).getFoodData().eat(i + 1, 1.0F); @@ -53,8 +53,8 @@ + ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutUpdateHealth(((EntityPlayer) entityhuman).getBukkitEntity().getScaledHealth(), entityhuman.getFoodData().foodLevel, entityhuman.getFoodData().saturationLevel)); + // CraftBukkit end } - } else if ((this != MobEffects.HEAL || entityliving.bS()) && (this != MobEffects.HARM || !entityliving.bS())) { - if (this == MobEffects.HARM && !entityliving.bS() || this == MobEffects.HEAL && entityliving.bS()) { + } else if ((this != MobEffects.HEAL || entityliving.bT()) && (this != MobEffects.HARM || !entityliving.bT())) { + if (this == MobEffects.HARM && !entityliving.bT() || this == MobEffects.HEAL && entityliving.bT()) { entityliving.damageEntity(DamageSource.MAGIC, (float) (6 << i)); } } else { diff --git a/nms-patches/MobSpawnerAbstract.patch b/nms-patches/MobSpawnerAbstract.patch index 408e3a4647..21298f01d0 100644 --- a/nms-patches/MobSpawnerAbstract.patch +++ b/nms-patches/MobSpawnerAbstract.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/MobSpawnerAbstract.java +++ b/net/minecraft/server/MobSpawnerAbstract.java -@@ -95,7 +95,7 @@ +@@ -104,7 +104,7 @@ ((EntityInsentient) entity).prepare(world.D(new BlockPosition(entity)), (GroupDataEntity) null); } diff --git a/nms-patches/PacketDataSerializer.patch b/nms-patches/PacketDataSerializer.patch index 00bc7794f8..d257ef48f1 100644 --- a/nms-patches/PacketDataSerializer.patch +++ b/nms-patches/PacketDataSerializer.patch @@ -30,21 +30,21 @@ @@ -232,7 +234,7 @@ } - public PacketDataSerializer a(@Nullable ItemStack itemstack) { -- if (itemstack == null) { -+ if (itemstack == null || itemstack.getItem() == null) { // CraftBukkit - NPE fix itemstack.getItem() + public PacketDataSerializer a(ItemStack itemstack) { +- if (itemstack.isEmpty()) { ++ if (itemstack.isEmpty() || itemstack.getItem() == null) { // CraftBukkit - NPE fix itemstack.getItem() this.writeShort(-1); } else { this.writeShort(Item.getId(itemstack.getItem())); @@ -261,6 +263,11 @@ + ItemStack itemstack = new ItemStack(Item.getById(short0), b0, short1); - itemstack = new ItemStack(Item.getById(short0), b0, short1); itemstack.setTag(this.j()); + // CraftBukkit start + if (itemstack.getTag() != null) { + CraftItemStack.setItemMeta(itemstack, CraftItemStack.getItemMeta(itemstack)); + } + // CraftBukkit end + return itemstack; } - - return itemstack; + } diff --git a/nms-patches/PathfinderGoalBreed.patch b/nms-patches/PathfinderGoalBreed.patch index e928ca43e3..4b9f88cf18 100644 --- a/nms-patches/PathfinderGoalBreed.patch +++ b/nms-patches/PathfinderGoalBreed.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/PathfinderGoalBreed.java +++ b/net/minecraft/server/PathfinderGoalBreed.java -@@ -69,11 +69,23 @@ +@@ -75,11 +75,23 @@ EntityAgeable entityageable = this.animal.createChild(this.partner); if (entityageable != null) { @@ -24,7 +24,7 @@ if (entityhuman != null) { entityhuman.b(StatisticList.C); -@@ -88,7 +100,7 @@ +@@ -94,7 +106,7 @@ this.partner.resetLove(); entityageable.setAgeRaw(-24000); entityageable.setPositionRotation(this.animal.locX, this.animal.locY, this.animal.locZ, 0.0F, 0.0F); @@ -33,7 +33,7 @@ Random random = this.animal.getRandom(); for (int i = 0; i < 7; ++i) { -@@ -103,7 +115,7 @@ +@@ -109,7 +121,7 @@ } if (this.a.getGameRules().getBoolean("doMobLoot")) { diff --git a/nms-patches/PathfinderGoalHorseTrap.patch b/nms-patches/PathfinderGoalHorseTrap.patch index c20e929d7a..848420532f 100644 --- a/nms-patches/PathfinderGoalHorseTrap.patch +++ b/nms-patches/PathfinderGoalHorseTrap.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/PathfinderGoalHorseTrap.java +++ b/net/minecraft/server/PathfinderGoalHorseTrap.java -@@ -22,13 +22,14 @@ +@@ -21,13 +21,14 @@ this.a.world.strikeLightning(new EntityLightning(this.a.world, this.a.locX, this.a.locY, this.a.locZ, true)); EntitySkeleton entityskeleton = this.a(difficultydamagescaler, this.a); @@ -8,28 +8,28 @@ + if (entityskeleton != null) entityskeleton.startRiding(this.a); // CraftBukkit for (int i = 0; i < 3; ++i) { - EntityHorse entityhorse = this.a(difficultydamagescaler); -+ if (entityhorse == null) continue; // CraftBukkit - EntitySkeleton entityskeleton1 = this.a(difficultydamagescaler, entityhorse); + EntityHorseAbstract entityhorseabstract = this.a(difficultydamagescaler); ++ if (entityhorseabstract == null) continue; // CraftBukkit + EntitySkeleton entityskeleton1 = this.a(difficultydamagescaler, entityhorseabstract); -- entityskeleton1.startRiding(entityhorse); -+ if (entityskeleton1 != null) entityskeleton1.startRiding(entityhorse); // CraftBukkit - entityhorse.g(this.a.getRandom().nextGaussian() * 0.5D, 0.0D, this.a.getRandom().nextGaussian() * 0.5D); +- entityskeleton1.startRiding(entityhorseabstract); ++ if (entityskeleton1 != null) entityskeleton1.startRiding(entityhorseabstract); // CraftBukkit + entityhorseabstract.f(this.a.getRandom().nextGaussian() * 0.5D, 0.0D, this.a.getRandom().nextGaussian() * 0.5D); } -@@ -44,7 +45,7 @@ - entityhorse.setType(EnumHorseType.SKELETON); - entityhorse.setTame(true); - entityhorse.setAgeRaw(0); -- entityhorse.world.addEntity(entityhorse); -+ if (!entityhorse.world.addEntity(entityhorse, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.TRAP)) return null; // CraftBukkit - return entityhorse; +@@ -42,7 +43,7 @@ + entityhorseskeleton.cS(); + entityhorseskeleton.setTamed(true); + entityhorseskeleton.setAgeRaw(0); +- entityhorseskeleton.world.addEntity(entityhorseskeleton); ++ if (!entityhorseskeleton.world.addEntity(entityhorseskeleton, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.TRAP)) return null; // CraftBukkit + return entityhorseskeleton; } -@@ -61,7 +62,7 @@ +@@ -59,7 +60,7 @@ - EnchantmentManager.a(entityskeleton.getRandom(), entityskeleton.getItemInMainHand(), (int) (5.0F + difficultydamagescaler.d() * (float) entityskeleton.getRandom().nextInt(18)), false); - EnchantmentManager.a(entityskeleton.getRandom(), entityskeleton.getEquipment(EnumItemSlot.HEAD), (int) (5.0F + difficultydamagescaler.d() * (float) entityskeleton.getRandom().nextInt(18)), false); + entityskeleton.setSlot(EnumItemSlot.MAINHAND, EnchantmentManager.a(entityskeleton.getRandom(), entityskeleton.getItemInMainHand(), (int) (5.0F + difficultydamagescaler.d() * (float) entityskeleton.getRandom().nextInt(18)), false)); + entityskeleton.setSlot(EnumItemSlot.HEAD, EnchantmentManager.a(entityskeleton.getRandom(), entityskeleton.getEquipment(EnumItemSlot.HEAD), (int) (5.0F + difficultydamagescaler.d() * (float) entityskeleton.getRandom().nextInt(18)), false)); - entityskeleton.world.addEntity(entityskeleton); + if (!entityskeleton.world.addEntity(entityskeleton, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.JOCKEY)) return null; // CraftBukkit return entityskeleton; diff --git a/nms-patches/PathfinderGoalHurtByTarget.patch b/nms-patches/PathfinderGoalHurtByTarget.patch index bf9f166640..e0e2e61033 100644 --- a/nms-patches/PathfinderGoalHurtByTarget.patch +++ b/nms-patches/PathfinderGoalHurtByTarget.patch @@ -7,7 +7,7 @@ - this.e.setGoalTarget(this.e.getLastDamager()); + this.e.setGoalTarget(this.e.getLastDamager(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY, true); // CraftBukkit - reason this.g = this.e.getGoalTarget(); - this.b = this.e.bK(); + this.b = this.e.bL(); this.h = 300; @@ -66,6 +66,6 @@ } diff --git a/nms-patches/PathfinderGoalNearestAttackableTarget.patch b/nms-patches/PathfinderGoalNearestAttackableTarget.patch index 09c3172eea..d1ceb69a18 100644 --- a/nms-patches/PathfinderGoalNearestAttackableTarget.patch +++ b/nms-patches/PathfinderGoalNearestAttackableTarget.patch @@ -3,7 +3,7 @@ @@ -35,7 +35,7 @@ } - public boolean apply(Object object) { + public boolean apply(@Nullable Object object) { - return this.a((EntityLiving) object); + return this.a((T) object); // CraftBukkit - fix decompile error } @@ -23,12 +23,12 @@ @Nullable public Double a(@Nullable EntityHuman entityhuman) { ItemStack itemstack = entityhuman.getEquipment(EnumItemSlot.HEAD); -@@ -73,10 +73,10 @@ - return Double.valueOf(1.0D); +@@ -74,10 +74,10 @@ } -- public Object apply(Object object) { -+ public Double apply(EntityHuman object) { // CraftBukkit - fix decompile error + @Nullable +- public Object apply(@Nullable Object object) { ++ public Double apply(@Nullable EntityHuman object) { // CraftBukkit - fix decompile error return this.a((EntityHuman) object); } - }, this.c); @@ -36,7 +36,7 @@ return this.d != null; } } -@@ -86,7 +86,7 @@ +@@ -87,7 +87,7 @@ } public void c() { @@ -45,7 +45,7 @@ super.c(); } -@@ -105,7 +105,7 @@ +@@ -106,7 +106,7 @@ return d0 < d1 ? -1 : (d0 > d1 ? 1 : 0); } diff --git a/nms-patches/PathfinderGoalPanic.patch b/nms-patches/PathfinderGoalPanic.patch index 41b58874ef..fa42596765 100644 --- a/nms-patches/PathfinderGoalPanic.patch +++ b/nms-patches/PathfinderGoalPanic.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/PathfinderGoalPanic.java +++ b/net/minecraft/server/PathfinderGoalPanic.java -@@ -47,6 +47,12 @@ +@@ -53,6 +53,12 @@ } public boolean b() { diff --git a/nms-patches/PathfinderGoalTame.patch b/nms-patches/PathfinderGoalTame.patch index 395bffec29..8026e5b2b8 100644 --- a/nms-patches/PathfinderGoalTame.patch +++ b/nms-patches/PathfinderGoalTame.patch @@ -7,6 +7,6 @@ - if (j > 0 && this.entity.getRandom().nextInt(j) < i) { + // CraftBukkit - fire EntityTameEvent + if (j > 0 && this.entity.getRandom().nextInt(j) < i && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this.entity, ((org.bukkit.craftbukkit.entity.CraftHumanEntity) this.entity.getBukkitEntity().getPassenger()).getHandle()).isCancelled()) { - this.entity.g((EntityHuman) entity); - this.entity.world.broadcastEntityEffect(this.entity, (byte) 7); + this.entity.h((EntityHuman) entity); return; + } diff --git a/nms-patches/PathfinderGoalTarget.patch b/nms-patches/PathfinderGoalTarget.patch index 6aade4c9da..acab1523a3 100644 --- a/nms-patches/PathfinderGoalTarget.patch +++ b/nms-patches/PathfinderGoalTarget.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/server/PathfinderGoalTarget.java +++ b/net/minecraft/server/PathfinderGoalTarget.java -@@ -1,5 +1,7 @@ +@@ -1,6 +1,7 @@ package net.minecraft.server; -+import org.bukkit.event.entity.EntityTargetEvent; -+ + import javax.annotation.Nullable; ++import org.bukkit.event.entity.EntityTargetEvent; // CraftBukkit + public abstract class PathfinderGoalTarget extends PathfinderGoal { - protected final EntityCreature e; -@@ -56,7 +58,7 @@ +@@ -58,7 +59,7 @@ if (entityliving instanceof EntityHuman && ((EntityHuman) entityliving).abilities.isInvulnerable) { return false; } else { @@ -17,7 +17,7 @@ return true; } } -@@ -77,7 +79,7 @@ +@@ -79,7 +80,7 @@ } public void d() { diff --git a/nms-patches/PathfinderGoalTempt.patch b/nms-patches/PathfinderGoalTempt.patch index d59fc83048..df8f4dcbaf 100644 --- a/nms-patches/PathfinderGoalTempt.patch +++ b/nms-patches/PathfinderGoalTempt.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/server/PathfinderGoalTempt.java +++ b/net/minecraft/server/PathfinderGoalTempt.java -@@ -3,6 +3,12 @@ +@@ -2,6 +2,12 @@ + import com.google.common.collect.Sets; import java.util.Set; - import javax.annotation.Nullable; +// CraftBukkit start +import org.bukkit.craftbukkit.entity.CraftLivingEntity; +import org.bukkit.craftbukkit.event.CraftEventFactory; @@ -13,7 +13,7 @@ public class PathfinderGoalTempt extends PathfinderGoal { -@@ -13,7 +19,7 @@ +@@ -12,7 +18,7 @@ private double e; private double f; private double g; @@ -22,7 +22,7 @@ private int i; private boolean j; private final Set k; -@@ -40,7 +46,18 @@ +@@ -39,7 +45,18 @@ return false; } else { this.h = this.a.world.findNearbyPlayer(this.a, 10.0D); diff --git a/nms-patches/PathfinderGoalVillagerFarm.patch b/nms-patches/PathfinderGoalVillagerFarm.patch index 449a3a7780..b24ce69b74 100644 --- a/nms-patches/PathfinderGoalVillagerFarm.patch +++ b/nms-patches/PathfinderGoalVillagerFarm.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/server/PathfinderGoalVillagerFarm.java +++ b/net/minecraft/server/PathfinderGoalVillagerFarm.java -@@ -48,7 +48,11 @@ +@@ -40,7 +40,11 @@ Block block = iblockdata.getBlock(); - if (this.f == 0 && block instanceof BlockCrops && ((BlockCrops) block).y(iblockdata)) { + if (this.f == 0 && block instanceof BlockCrops && ((BlockCrops) block).A(iblockdata)) { - world.setAir(blockposition, true); + // CraftBukkit start + if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.c, blockposition, Blocks.AIR, 0).isCancelled()) { @@ -11,15 +11,14 @@ + } + // CraftBukkit end } else if (this.f == 1 && iblockdata.getMaterial() == Material.AIR) { - InventorySubcontainer inventorysubcontainer = this.c.dj(); + InventorySubcontainer inventorysubcontainer = this.c.dm(); -@@ -57,19 +61,29 @@ +@@ -49,19 +53,28 @@ boolean flag = false; - if (itemstack != null) { + if (!itemstack.isEmpty()) { + // CraftBukkit start + Block planted = null; -+ if (itemstack.getItem() == Items.WHEAT_SEEDS) { - world.setTypeAndData(blockposition, Blocks.WHEAT.getBlockData(), 3); + planted = Blocks.WHEAT; diff --git a/nms-patches/PlayerConnection.patch b/nms-patches/PlayerConnection.patch index dcf3649c4d..9bb29cef10 100644 --- a/nms-patches/PlayerConnection.patch +++ b/nms-patches/PlayerConnection.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/PlayerConnection.java +++ b/net/minecraft/server/PlayerConnection.java -@@ -16,6 +16,49 @@ +@@ -15,6 +15,49 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -50,7 +50,7 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable { private static final Logger LOGGER = LogManager.getLogger(); -@@ -26,7 +69,10 @@ +@@ -25,7 +68,10 @@ private int f; private long g; private long h; @@ -62,15 +62,15 @@ private int j; private final IntHashMap k = new IntHashMap(); private double l; -@@ -51,6 +97,7 @@ +@@ -50,6 +96,7 @@ private int E; - private int F; - private int G; + private int receivedMovePackets; + private int processedMovePackets; + private boolean processedDisconnect; // CraftBukkit - Added public PlayerConnection(MinecraftServer minecraftserver, NetworkManager networkmanager, EntityPlayer entityplayer) { this.minecraftServer = minecraftserver; -@@ -58,7 +105,32 @@ +@@ -57,7 +104,32 @@ networkmanager.setPacketListener(this); this.player = entityplayer; entityplayer.playerConnection = this; @@ -101,9 +101,9 @@ + private final static HashSet invalidItems = new HashSet(java.util.Arrays.asList(8, 9, 10, 11, 26, 34, 36, 43, 51, 52, 55, 59, 60, 62, 63, 64, 68, 71, 74, 75, 83, 90, 92, 93, 94, 104, 105, 115, 117, 118, 119, 125, 127, 132, 140, 141, 142, 144)); // TODO: Check after every update. + // CraftBukkit end - public void E_() { - this.d(); -@@ -110,21 +182,27 @@ + public void F_() { + this.syncPosition(); +@@ -109,15 +181,21 @@ } this.minecraftServer.methodProfiler.b(); @@ -120,19 +120,12 @@ --this.j; } - if (this.player.I() > 0L && this.minecraftServer.getIdleTimeout() > 0 && MinecraftServer.av() - this.player.I() > (long) (this.minecraftServer.getIdleTimeout() * 1000 * 60)) { + if (this.player.I() > 0L && this.minecraftServer.getIdleTimeout() > 0 && MinecraftServer.aw() - this.player.I() > (long) (this.minecraftServer.getIdleTimeout() * 1000 * 60)) { + this.player.resetIdleTimer(); // CraftBukkit - SPIGOT-854 this.disconnect("You have been idle for too long!"); } - } - -- private void d() { -+ public void d() { // PAIL: syncPosition, private->public - this.l = this.player.locX; - this.m = this.player.locY; - this.n = this.player.locZ; -@@ -138,19 +216,40 @@ +@@ -137,19 +215,40 @@ } public void disconnect(String s) { @@ -176,7 +169,7 @@ } public void a(PacketPlayInSteerVehicle packetplayinsteervehicle) { -@@ -189,7 +288,34 @@ +@@ -188,7 +287,34 @@ double d9 = entity.motX * entity.motX + entity.motY * entity.motY + entity.motZ * entity.motZ; double d10 = d6 * d6 + d7 * d7 + d8 * d8; @@ -187,8 +180,8 @@ + this.allowedPlayerTicks = Math.max(this.allowedPlayerTicks, 1); + this.lastTick = (int) (System.currentTimeMillis() / 50); + -+ ++this.F; -+ int i = this.F - this.G; // PAIL: Rename ++ ++this.receivedMovePackets; ++ int i = this.receivedMovePackets - this.processedMovePackets; + if (i > Math.max(this.allowedPlayerTicks, 5)) { + PlayerConnection.LOGGER.debug(this.player.getName() + " is sending move packets too frequently (" + i + " packets since last tick)"); + i = 1; @@ -207,12 +200,12 @@ + } + speed *= 2f; // TODO: Get the speed of the vehicle instead of the player + -+ if (d10 - d9 > Math.max(100, Math.pow((double) (10.0F * (float) i * speed), 2)) && (!this.minecraftServer.R() || !this.minecraftServer.Q().equals(entity.getName()))) { ++ if (d10 - d9 > Math.max(100.0D, Math.pow((double) (10.0F * (float) i * speed), 2)) && (!this.minecraftServer.R() || !this.minecraftServer.Q().equals(entity.getName()))) { + // CraftBukkit end PlayerConnection.LOGGER.warn("{} (vehicle of {}) moved too quickly! {},{},{}", new Object[] { entity.getName(), this.player.getName(), Double.valueOf(d6), Double.valueOf(d7), Double.valueOf(d8)}); this.networkManager.sendPacket(new PacketPlayOutVehicleMove(entity)); return; -@@ -227,6 +353,62 @@ +@@ -226,6 +352,62 @@ return; } @@ -235,7 +228,7 @@ + double delta = Math.pow(this.lastPosX - to.getX(), 2) + Math.pow(this.lastPosY - to.getY(), 2) + Math.pow(this.lastPosZ - to.getZ(), 2); + float deltaAngle = Math.abs(this.lastYaw - to.getYaw()) + Math.abs(this.lastPitch - to.getPitch()); + -+ if ((delta > 1f / 256 || deltaAngle > 10f) && !this.player.cj()) { ++ if ((delta > 1f / 256 || deltaAngle > 10f) && !this.player.isFrozen()) { + this.lastPosX = to.getX(); + this.lastPosY = to.getY(); + this.lastPosZ = to.getZ(); @@ -274,17 +267,17 @@ + this.minecraftServer.getPlayerList().d(this.player); this.player.checkMovement(this.player.locX - d0, this.player.locY - d1, this.player.locZ - d2); - this.D = d11 >= -0.03125D && !this.minecraftServer.getAllowFlight() && !worldserver.d(entity.getBoundingBox().g(0.0625D).a(0.0D, -0.55D, 0.0D)); -@@ -261,7 +443,7 @@ + this.D = d11 >= -0.03125D && !this.minecraftServer.getAllowFlight() && !worldserver.d(entity.getBoundingBox().g(0.0625D).b(0.0D, -0.55D, 0.0D)); +@@ -260,7 +442,7 @@ } else { WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); - if (!this.player.viewingCredits) { -+ if (!this.player.viewingCredits && !this.player.cj()) { // CraftBukkit // PAIL: rename ++ if (!this.player.viewingCredits && !this.player.isFrozen()) { // CraftBukkit if (this.e == 0) { - this.d(); + this.syncPosition(); } -@@ -271,13 +453,21 @@ +@@ -270,13 +452,21 @@ this.A = this.e; this.a(this.teleportPos.x, this.teleportPos.y, this.teleportPos.z, this.player.yaw, this.player.pitch); } @@ -307,19 +300,18 @@ double d0 = this.player.locX; double d1 = this.player.locY; double d2 = this.player.locZ; -@@ -296,15 +486,33 @@ - ++this.F; - int i = this.F - this.G; +@@ -295,15 +485,33 @@ + ++this.receivedMovePackets; + int i = this.receivedMovePackets - this.processedMovePackets; - if (i > 5) { -- PlayerConnection.LOGGER.debug("{} is sending move packets too frequently ({} packets since last tick)", new Object[] { this.player.getName(), Integer.valueOf(i)}); + // CraftBukkit start - handle custom speeds and skipped ticks + this.allowedPlayerTicks += (System.currentTimeMillis() / 50) - this.lastTick; + this.allowedPlayerTicks = Math.max(this.allowedPlayerTicks, 1); + this.lastTick = (int) (System.currentTimeMillis() / 50); + + if (i > Math.max(this.allowedPlayerTicks, 5)) { -+ PlayerConnection.LOGGER.debug(this.player.getName() + " is sending move packets too frequently (" + i + " packets since last tick)"); + PlayerConnection.LOGGER.debug("{} is sending move packets too frequently ({} packets since last tick)", new Object[] { this.player.getName(), Integer.valueOf(i)}); i = 1; } @@ -335,16 +327,16 @@ + speed = player.abilities.walkSpeed * 10f; + } + - if (!this.player.K() && (!this.player.x().getGameRules().getBoolean("disableElytraMovementCheck") || !this.player.cG())) { - float f2 = this.player.cG() ? 300.0F : 100.0F; + if (!this.player.K() && (!this.player.x().getGameRules().getBoolean("disableElytraMovementCheck") || !this.player.cH())) { + float f2 = this.player.cH() ? 300.0F : 100.0F; - if (d11 - d10 > (double) (f2 * (float) i) && (!this.minecraftServer.R() || !this.minecraftServer.Q().equals(this.player.getName()))) { -+ if (d11 - d10 > Math.max(100, Math.pow((double) (10.0F * (float) i * speed), 2)) && (!this.minecraftServer.R() || !this.minecraftServer.Q().equals(this.player.getName()))) { ++ if (d11 - d10 > Math.max(f2, Math.pow((double) (10.0F * (float) i * speed), 2)) && (!this.minecraftServer.R() || !this.minecraftServer.Q().equals(this.player.getName()))) { + // CraftBukkit end PlayerConnection.LOGGER.warn("{} moved too quickly! {},{},{}", new Object[] { this.player.getName(), Double.valueOf(d7), Double.valueOf(d8), Double.valueOf(d9)}); this.a(this.player.locX, this.player.locY, this.player.locZ, this.player.yaw, this.player.pitch); return; -@@ -350,6 +558,69 @@ +@@ -349,6 +557,69 @@ } } @@ -373,7 +365,7 @@ + double delta = Math.pow(this.lastPosX - to.getX(), 2) + Math.pow(this.lastPosY - to.getY(), 2) + Math.pow(this.lastPosZ - to.getZ(), 2); + float deltaAngle = Math.abs(this.lastYaw - to.getYaw()) + Math.abs(this.lastPitch - to.getPitch()); + -+ if ((delta > 1f / 256 || deltaAngle > 10f) && !this.player.cj()) { ++ if ((delta > 1f / 256 || deltaAngle > 10f) && !this.player.isFrozen()) { + this.lastPosX = to.getX(); + this.lastPosY = to.getY(); + this.lastPosZ = to.getZ(); @@ -413,8 +405,8 @@ + this.B = d12 >= -0.03125D; this.B &= !this.minecraftServer.getAllowFlight() && !this.player.abilities.canFly; - this.B &= !this.player.hasEffect(MobEffects.LEVITATION) && !this.player.cG() && !worldserver.d(this.player.getBoundingBox().g(0.0625D).a(0.0D, -0.55D, 0.0D)); -@@ -366,15 +637,79 @@ + this.B &= !this.player.hasEffect(MobEffects.LEVITATION) && !this.player.cH() && !worldserver.d(this.player.getBoundingBox().g(0.0625D).b(0.0D, -0.55D, 0.0D)); +@@ -365,10 +636,68 @@ } public void a(double d0, double d1, double d2, float f, float f1) { @@ -423,9 +415,6 @@ } public void a(double d0, double d1, double d2, float f, float f1, Set set) { -- double d3 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.X) ? this.player.locX : 0.0D; -- double d4 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.Y) ? this.player.locY : 0.0D; -- double d5 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.Z) ? this.player.locZ : 0.0D; + // CraftBukkit start - Delegate to teleport(Location) + Player player = this.getPlayer(); + Location from = player.getLocation(); @@ -470,36 +459,24 @@ + } + + public void teleport(Location dest) { -+ internalTeleport(dest.getX(), dest.getY(), dest.getZ(), dest.getYaw(), dest.getPitch(), Collections.emptySet()); ++ internalTeleport(dest.getX(), dest.getY(), dest.getZ(), dest.getYaw(), dest.getPitch(), Collections.emptySet()); + } + -+ private void internalTeleport(double d0, double d1, double d2, float f, float f1, Set set) { ++ private void internalTeleport(double d0, double d1, double d2, float f, float f1, Set set) { ++ // CraftBukkit start + if (Float.isNaN(f)) { + f = 0; + } -+ + if (Float.isNaN(f1)) { + f1 = 0; + } -+ this.justTeleported = true; -+ this.teleportPos = new Vec3D(d0, d1, d2); -+ if (set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.X)) { -+ this.teleportPos = this.teleportPos.add(this.player.locX, 0.0D, 0.0D); -+ } - -- this.teleportPos = new Vec3D(d0 + d3, d1 + d4, d2 + d5); -+ if (set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.Y)) { -+ this.teleportPos = this.teleportPos.add(0.0D, this.player.locY, 0.0D); -+ } + -+ if (set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.Z)) { -+ this.teleportPos = this.teleportPos.add(0.0D, 0.0D, this.player.locZ); -+ } ++ this.justTeleported = true; + // CraftBukkit end - float f2 = f; - float f3 = f1; - -@@ -386,6 +721,14 @@ + double d3 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.X) ? this.player.locX : 0.0D; + double d4 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.Y) ? this.player.locY : 0.0D; + double d5 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.Z) ? this.player.locZ : 0.0D; +@@ -385,6 +714,14 @@ f3 = f1 + this.player.pitch; } @@ -514,40 +491,34 @@ if (++this.teleportAwait == Integer.MAX_VALUE) { this.teleportAwait = 0; } -@@ -397,37 +740,61 @@ +@@ -396,6 +733,7 @@ public void a(PacketPlayInBlockDig packetplayinblockdig) { PlayerConnectionUtils.ensureMainThread(packetplayinblockdig, this, this.player.x()); -+ if (this.player.cj()) return; // CraftBukkit ++ if (this.player.isFrozen()) return; // CraftBukkit WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); BlockPosition blockposition = packetplayinblockdig.a(); - this.player.resetIdleTimer(); - ItemStack itemstack; - -+ // CraftBukkit start - switch (PlayerConnection.SyntheticClass_1.a[packetplayinblockdig.c().ordinal()]) { -- case 1: -+ case 1: // SWAP_HELD_ITEMS +@@ -405,7 +743,15 @@ if (!this.player.isSpectator()) { -- itemstack = this.player.b(EnumHand.OFF_HAND); + ItemStack itemstack = this.player.b(EnumHand.OFF_HAND); + - this.player.a(EnumHand.OFF_HAND, this.player.b(EnumHand.MAIN_HAND)); + // CraftBukkit start -+ PlayerSwapHandItemsEvent swapItemsEvent = new PlayerSwapHandItemsEvent(getPlayer(), CraftItemStack.asBukkitCopy(this.player.b(EnumHand.OFF_HAND)), CraftItemStack.asBukkitCopy(this.player.b(EnumHand.MAIN_HAND))); ++ PlayerSwapHandItemsEvent swapItemsEvent = new PlayerSwapHandItemsEvent(getPlayer(), CraftItemStack.asBukkitCopy(itemstack), CraftItemStack.asBukkitCopy(this.player.b(EnumHand.MAIN_HAND))); + this.server.getPluginManager().callEvent(swapItemsEvent); + if (swapItemsEvent.isCancelled()) { + return; + } + itemstack = CraftItemStack.asNMSCopy(swapItemsEvent.getMainHandItem()); + this.player.a(EnumHand.OFF_HAND, CraftItemStack.asNMSCopy(swapItemsEvent.getOffHandItem())); - this.player.a(EnumHand.MAIN_HAND, itemstack); + // CraftBukkit end + this.player.a(EnumHand.MAIN_HAND, itemstack); } - return; +@@ -413,6 +759,21 @@ -- case 2: -+ case 2: // DROP_ITEM + case DROP_ITEM: if (!this.player.isSpectator()) { + // limit how quickly items can be dropped + // If the ticks aren't the same then the count starts from 0 and we update the lastDropTick. @@ -567,35 +538,7 @@ this.player.a(false); } - return; - -- case 3: -+ case 3: // DROP_ALL_ITEMS - if (!this.player.isSpectator()) { - this.player.a(true); - } - - return; - -- case 4: -+ case 4: // RELEASE_USE_ITEM - this.player.clearActiveItem(); - itemstack = this.player.getItemInMainHand(); - if (itemstack != null && itemstack.count == 0) { -@@ -436,9 +803,9 @@ - - return; - -- case 5: -- case 6: -- case 7: -+ case 5: // START_DESTROY_BLOCK -+ case 6: // ABORT_DESTROY_BLOCK -+ case 7: // STOP_DESTROY_BLOCK - double d0 = this.player.locX - ((double) blockposition.getX() + 0.5D); - double d1 = this.player.locY - ((double) blockposition.getY() + 0.5D) + 1.5D; - double d2 = this.player.locZ - ((double) blockposition.getZ() + 0.5D); -@@ -453,7 +820,15 @@ +@@ -446,7 +807,15 @@ if (!this.minecraftServer.a(worldserver, blockposition, this.player) && worldserver.getWorldBorder().a(blockposition)) { this.player.playerInteractManager.a(blockposition, packetplayinblockdig.b()); } else { @@ -611,7 +554,7 @@ } } else { if (packetplayinblockdig.c() == PacketPlayInBlockDig.EnumPlayerDigType.STOP_DESTROY_BLOCK) { -@@ -473,10 +848,12 @@ +@@ -466,10 +835,12 @@ default: throw new IllegalArgumentException("Invalid player action"); } @@ -620,14 +563,14 @@ public void a(PacketPlayInUseItem packetplayinuseitem) { PlayerConnectionUtils.ensureMainThread(packetplayinuseitem, this, this.player.x()); -+ if (this.player.cj()) return; // CraftBukkit ++ if (this.player.isFrozen()) return; // CraftBukkit WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); EnumHand enumhand = packetplayinuseitem.c(); ItemStack itemstack = this.player.b(enumhand); -@@ -490,6 +867,13 @@ +@@ -483,6 +854,13 @@ chatmessage.getChatModifier().setColor(EnumChatFormat.RED); - this.player.playerConnection.sendPacket(new PacketPlayOutChat(chatmessage)); - } else if (this.teleportPos == null && this.player.e((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) < 64.0D && !this.minecraftServer.a(worldserver, blockposition, this.player) && worldserver.getWorldBorder().a(blockposition)) { + this.player.playerConnection.sendPacket(new PacketPlayOutChat(chatmessage, (byte) 2)); + } else if (this.teleportPos == null && this.player.d((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) < 64.0D && !this.minecraftServer.a(worldserver, blockposition, this.player) && worldserver.getWorldBorder().a(blockposition)) { + // CraftBukkit start - Check if we can actually do something over this large a distance + Location eyeLoc = this.getPlayer().getEyeLocation(); + double reachDistance = NumberConversions.square(eyeLoc.getX() - blockposition.getX()) + NumberConversions.square(eyeLoc.getY() - blockposition.getY()) + NumberConversions.square(eyeLoc.getZ() - blockposition.getZ()); @@ -638,22 +581,18 @@ this.player.playerInteractManager.a(this.player, worldserver, itemstack, enumhand, blockposition, enumdirection, packetplayinuseitem.d(), packetplayinuseitem.e(), packetplayinuseitem.f()); } -@@ -504,19 +888,55 @@ +@@ -492,13 +870,50 @@ public void a(PacketPlayInBlockPlace packetplayinblockplace) { PlayerConnectionUtils.ensureMainThread(packetplayinblockplace, this, this.player.x()); -+ if (this.player.cj()) return; // CraftBukkit ++ if (this.player.isFrozen()) return; // CraftBukkit WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); EnumHand enumhand = packetplayinblockplace.a(); ItemStack itemstack = this.player.b(enumhand); this.player.resetIdleTimer(); - if (itemstack != null) { + if (!itemstack.isEmpty()) { - this.player.playerInteractManager.a(this.player, worldserver, itemstack, enumhand); -- itemstack = this.player.b(enumhand); -- if (itemstack != null && itemstack.count == 0) { -- this.player.a(enumhand, (ItemStack) null); -- itemstack = null; + // CraftBukkit start + // Raytrace to look for 'rogue armswings' + float f1 = this.player.pitch; @@ -673,7 +612,7 @@ + Vec3D vec3d1 = vec3d.add((double) f7 * d3, (double) f6 * d3, (double) f8 * d3); + MovingObjectPosition movingobjectposition = this.player.world.rayTrace(vec3d, vec3d1, false); + -+ boolean cancelled = false; ++ boolean cancelled; + if (movingobjectposition == null || movingobjectposition.type != MovingObjectPosition.EnumMovingObjectType.BLOCK) { + org.bukkit.event.player.PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.RIGHT_CLICK_AIR, itemstack, enumhand); + cancelled = event.useItemInHand() == Event.Result.DENY; @@ -685,21 +624,16 @@ + org.bukkit.event.player.PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(player, Action.RIGHT_CLICK_BLOCK, movingobjectposition.a(), movingobjectposition.direction, itemstack, true, enumhand); + cancelled = event.useItemInHand() == Event.Result.DENY; + } - } - ++ } ++ + if (!cancelled) { + this.player.playerInteractManager.a(this.player, worldserver, itemstack, enumhand); -+ itemstack = this.player.b(enumhand); -+ if (itemstack != null && itemstack.count == 0) { -+ this.player.a(enumhand, (ItemStack) null); -+ itemstack = null; -+ } + } + // CraftBukkit end } } -@@ -527,8 +947,8 @@ +@@ -509,8 +924,8 @@ WorldServer[] aworldserver = this.minecraftServer.worldServer; int i = aworldserver.length; @@ -710,7 +644,7 @@ if (worldserver != null) { entity = packetplayinspectate.a(worldserver); -@@ -541,6 +961,8 @@ +@@ -523,6 +938,8 @@ if (entity != null) { this.player.setSpectatorTarget(this.player); this.player.stopRiding(); @@ -719,7 +653,7 @@ if (entity.world == this.player.world) { this.player.enderTeleportTo(entity.locX, entity.locY, entity.locZ); } else { -@@ -566,12 +988,19 @@ +@@ -548,12 +965,19 @@ this.minecraftServer.getPlayerList().b(this.player, worldserver2); this.minecraftServer.getPlayerList().updateClient(this.player); } @@ -740,7 +674,7 @@ public void a(PacketPlayInBoatMove packetplayinboatmove) { PlayerConnectionUtils.ensureMainThread(packetplayinboatmove, this, this.player.x()); -@@ -584,14 +1013,29 @@ +@@ -566,14 +990,29 @@ } public void a(IChatBaseComponent ichatbasecomponent) { @@ -755,7 +689,7 @@ + PlayerConnection.LOGGER.info("{} lost connection: {}", new Object[] { this.player.getName(), ichatbasecomponent.toPlainText()});// CraftBukkit - Don't toString(). + // CraftBukkit start - Replace vanilla quit message handling with our own. + /* - this.minecraftServer.aC(); + this.minecraftServer.aD(); ChatMessage chatmessage = new ChatMessage("multiplayer.player.left", new Object[] { this.player.getScoreboardDisplayName()}); chatmessage.getChatModifier().setColor(EnumChatFormat.YELLOW); @@ -772,7 +706,7 @@ if (this.minecraftServer.R() && this.player.getName().equals(this.minecraftServer.Q())) { PlayerConnection.LOGGER.info("Stopping singleplayer server as player logged out"); this.minecraftServer.safeShutdown(); -@@ -613,6 +1057,15 @@ +@@ -595,6 +1034,15 @@ } } @@ -788,11 +722,11 @@ try { this.networkManager.sendPacket(packet); } catch (Throwable throwable) { -@@ -634,17 +1087,32 @@ +@@ -616,17 +1064,32 @@ public void a(PacketPlayInHeldItemSlot packetplayinhelditemslot) { PlayerConnectionUtils.ensureMainThread(packetplayinhelditemslot, this, this.player.x()); -+ if (this.player.cj()) return; // CraftBukkit ++ if (this.player.isFrozen()) return; // CraftBukkit if (packetplayinhelditemslot.a() >= 0 && packetplayinhelditemslot.a() < PlayerInventory.getHotbarSize()) { + PlayerItemHeldEvent event = new PlayerItemHeldEvent(this.getPlayer(), this.player.inventory.itemInHandIndex, packetplayinhelditemslot.a()); + this.server.getPluginManager().callEvent(event); @@ -823,7 +757,7 @@ ChatMessage chatmessage = new ChatMessage("chat.cannotSend", new Object[0]); chatmessage.getChatModifier().setColor(EnumChatFormat.RED); -@@ -657,39 +1125,249 @@ +@@ -639,39 +1102,249 @@ for (int i = 0; i < s.length(); ++i) { if (!SharedConstants.isAllowedChatCharacter(s.charAt(i))) { @@ -1020,7 +954,7 @@ public void a(PacketPlayInArmAnimation packetplayinarmanimation) { PlayerConnectionUtils.ensureMainThread(packetplayinarmanimation, this, this.player.x()); -+ if (this.player.cj()) return; // CraftBukkit ++ if (this.player.isFrozen()) return; // CraftBukkit this.player.resetIdleTimer(); + // CraftBukkit start - Raytrace to look for 'rogue armswings' + float f1 = this.player.pitch; @@ -1081,17 +1015,17 @@ this.player.resetIdleTimer(); IJumpable ijumpable; -@@ -759,6 +1437,7 @@ +@@ -743,6 +1416,7 @@ public void a(PacketPlayInUseEntity packetplayinuseentity) { PlayerConnectionUtils.ensureMainThread(packetplayinuseentity, this, this.player.x()); -+ if (this.player.cj()) return; // CraftBukkit ++ if (this.player.isFrozen()) return; // CraftBukkit WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); Entity entity = packetplayinuseentity.a((World) worldserver); -@@ -775,22 +1454,72 @@ +@@ -758,20 +1432,68 @@ + if (this.player.h(entity) < d0) { EnumHand enumhand; - ItemStack itemstack; + ItemStack itemInHand = this.player.b(packetplayinuseentity.b() == null ? EnumHand.MAIN_HAND : packetplayinuseentity.b()); // CraftBukkit + @@ -1127,21 +1061,17 @@ + if (packetplayinuseentity.a() == PacketPlayInUseEntity.EnumEntityUseAction.INTERACT) { enumhand = packetplayinuseentity.b(); - itemstack = this.player.b(enumhand); - this.player.a(entity, itemstack, enumhand); -+ + this.player.a(entity, enumhand); + // CraftBukkit start -+ if (itemInHand != null && itemInHand.count <= -1) { ++ if (!itemInHand.isEmpty() && itemInHand.getCount() <= -1) { + this.player.updateInventory(this.player.activeContainer); + } + // CraftBukkit end } else if (packetplayinuseentity.a() == PacketPlayInUseEntity.EnumEntityUseAction.INTERACT_AT) { enumhand = packetplayinuseentity.b(); - itemstack = this.player.b(enumhand); - entity.a((EntityHuman) this.player, packetplayinuseentity.c(), itemstack, enumhand); -+ + entity.a(this.player, packetplayinuseentity.c(), enumhand); + // CraftBukkit start -+ if (itemInHand != null && itemInHand.count <= -1) { ++ if (!itemInHand.isEmpty() && itemInHand.getCount() <= -1) { + this.player.updateInventory(this.player.activeContainer); + } + // CraftBukkit end @@ -1156,15 +1086,15 @@ this.player.attack(entity); + + // CraftBukkit start -+ if (itemInHand != null && itemInHand.count <= -1) { ++ if (!itemInHand.isEmpty() && itemInHand.getCount() <= -1) { + this.player.updateInventory(this.player.activeContainer); + } + // CraftBukkit end } } } -@@ -806,7 +1535,8 @@ - case 1: +@@ -787,7 +1509,8 @@ + case PERFORM_RESPAWN: if (this.player.viewingCredits) { this.player.viewingCredits = false; - this.player = this.minecraftServer.getPlayerList().moveToWorld(this.player, 0, true); @@ -1173,12 +1103,12 @@ } else { if (this.player.getHealth() > 0.0F) { return; -@@ -832,14 +1562,20 @@ +@@ -813,14 +1536,20 @@ public void a(PacketPlayInCloseWindow packetplayinclosewindow) { PlayerConnectionUtils.ensureMainThread(packetplayinclosewindow, this, this.player.x()); + -+ if (this.player.cj()) return; // CraftBukkit ++ if (this.player.isFrozen()) return; // CraftBukkit + CraftEventFactory.handleInventoryCloseEvent(this.player); // CraftBukkit + this.player.s(); @@ -1186,18 +1116,18 @@ public void a(PacketPlayInWindowClick packetplayinwindowclick) { PlayerConnectionUtils.ensureMainThread(packetplayinwindowclick, this, this.player.x()); -+ if (this.player.cj()) return; // CraftBukkit ++ if (this.player.isFrozen()) return; // CraftBukkit this.player.resetIdleTimer(); if (this.player.activeContainer.windowId == packetplayinwindowclick.a() && this.player.activeContainer.c(this.player)) { - if (this.player.isSpectator()) { + boolean cancelled = this.player.isSpectator(); // CraftBukkit - see below if + if (false/*this.player.isSpectator()*/) { // CraftBukkit - ArrayList arraylist = Lists.newArrayList(); + NonNullList nonnulllist = NonNullList.a(); for (int i = 0; i < this.player.activeContainer.c.size(); ++i) { -@@ -848,8 +1584,279 @@ +@@ -829,8 +1558,279 @@ - this.player.a(this.player.activeContainer, (List) arraylist); + this.player.a(this.player.activeContainer, nonnulllist); } else { - ItemStack itemstack = this.player.activeContainer.a(packetplayinwindowclick.b(), packetplayinwindowclick.c(), packetplayinwindowclick.f(), this.player); + // CraftBukkit start - Call InventoryClickEvent @@ -1207,12 +1137,12 @@ + + InventoryView inventory = this.player.activeContainer.getBukkitView(); + SlotType type = CraftInventoryView.getSlotType(inventory, packetplayinwindowclick.b()); - ++ + InventoryClickEvent event; + ClickType click = ClickType.UNKNOWN; + InventoryAction action = InventoryAction.UNKNOWN; + -+ ItemStack itemstack = null; ++ ItemStack itemstack = ItemStack.a; + + switch (packetplayinwindowclick.f()) { + case PICKUP: @@ -1243,24 +1173,24 @@ + action = packetplayinwindowclick.c() == 0 ? InventoryAction.PICKUP_ALL : InventoryAction.PICKUP_HALF; + } else if (slot.isAllowed(cursor)) { + if (clickedItem.doMaterialsMatch(cursor) && ItemStack.equals(clickedItem, cursor)) { -+ int toPlace = packetplayinwindowclick.c() == 0 ? cursor.count : 1; -+ toPlace = Math.min(toPlace, clickedItem.getMaxStackSize() - clickedItem.count); -+ toPlace = Math.min(toPlace, slot.inventory.getMaxStackSize() - clickedItem.count); ++ int toPlace = packetplayinwindowclick.c() == 0 ? cursor.getCount() : 1; ++ toPlace = Math.min(toPlace, clickedItem.getMaxStackSize() - clickedItem.getCount()); ++ toPlace = Math.min(toPlace, slot.inventory.getMaxStackSize() - clickedItem.getCount()); + if (toPlace == 1) { + action = InventoryAction.PLACE_ONE; -+ } else if (toPlace == cursor.count) { ++ } else if (toPlace == cursor.getCount()) { + action = InventoryAction.PLACE_ALL; + } else if (toPlace < 0) { + action = toPlace != -1 ? InventoryAction.PICKUP_SOME : InventoryAction.PICKUP_ONE; // this happens with oversized stacks + } else if (toPlace != 0) { + action = InventoryAction.PLACE_SOME; + } -+ } else if (cursor.count <= slot.getMaxStackSize()) { ++ } else if (cursor.getCount() <= slot.getMaxStackSize()) { + action = InventoryAction.SWAP_WITH_CURSOR; + } + } else if (cursor.getItem() == clickedItem.getItem() && (!cursor.usesData() || cursor.getData() == clickedItem.getData()) && ItemStack.equals(cursor, clickedItem)) { -+ if (clickedItem.count >= 0) { -+ if (clickedItem.count + cursor.count <= cursor.getMaxStackSize()) { ++ if (clickedItem.getCount() >= 0) { ++ if (clickedItem.getCount() + cursor.getCount() <= cursor.getMaxStackSize()) { + // As of 1.5, this is result slots only + action = InventoryAction.PICKUP_ALL; + } @@ -1409,7 +1339,7 @@ + if (this.player.activeContainer != oldContainer) { + return; + } -+ + + switch (event.getResult()) { + case ALLOW: + case DEFAULT: @@ -1476,25 +1406,23 @@ if (ItemStack.matches(packetplayinwindowclick.e(), itemstack)) { this.player.playerConnection.sendPacket(new PacketPlayOutTransaction(packetplayinwindowclick.a(), packetplayinwindowclick.d(), true)); this.player.f = true; -@@ -878,6 +1885,7 @@ +@@ -859,6 +1859,7 @@ public void a(PacketPlayInEnchantItem packetplayinenchantitem) { PlayerConnectionUtils.ensureMainThread(packetplayinenchantitem, this, this.player.x()); -+ if (this.player.cj()) return; // CraftBukkit ++ if (this.player.isFrozen()) return; // CraftBukkit this.player.resetIdleTimer(); if (this.player.activeContainer.windowId == packetplayinenchantitem.a() && this.player.activeContainer.c(this.player) && !this.player.isSpectator()) { this.player.activeContainer.a(this.player, packetplayinenchantitem.b()); -@@ -911,8 +1919,48 @@ +@@ -892,7 +1893,46 @@ } boolean flag1 = packetplayinsetcreativeslot.a() >= 1 && packetplayinsetcreativeslot.a() <= 45; -- boolean flag2 = itemstack == null || itemstack.getItem() != null; +- boolean flag2 = itemstack.isEmpty() || itemstack.getData() >= 0 && itemstack.getCount() <= 64 && !itemstack.isEmpty(); + // CraftBukkit - Add invalidItems check -+ boolean flag2 = itemstack == null || itemstack.getItem() != null && !invalidItems.contains(Item.getId(itemstack.getItem())); - boolean flag3 = itemstack == null || itemstack.getData() >= 0 && itemstack.count <= 64 && itemstack.count > 0; -+ // CraftBukkit start - Call click event ++ boolean flag2 = itemstack.isEmpty() || itemstack.getData() >= 0 && itemstack.getCount() <= 64 && !itemstack.isEmpty() && !invalidItems.contains(Item.getId(itemstack.getItem())); + if (flag || (flag1 && !ItemStack.matches(this.player.defaultContainer.getSlot(packetplayinsetcreativeslot.a()).getItem(), packetplayinsetcreativeslot.getItemStack()))) { // Insist on valid slot -+ ++ // CraftBukkit start - Call click event + org.bukkit.entity.HumanEntity player = this.player.getBukkitEntity(); + InventoryView inventory = new CraftInventoryView(player, player.getInventory(), this.player.defaultContainer); + org.bukkit.inventory.ItemStack item = CraftItemStack.asBukkitCopy(packetplayinsetcreativeslot.getItemStack()); @@ -1517,7 +1445,7 @@ + switch (event.getResult()) { + case ALLOW: + // Plugin cleared the id / stacksize checks -+ flag2 = flag3 = true; ++ flag2 = true; + break; + case DEFAULT: + break; @@ -1532,27 +1460,27 @@ + } + // CraftBukkit end - if (flag1 && flag2 && flag3) { - if (itemstack == null) { -@@ -936,6 +1984,7 @@ + if (flag1 && flag2) { + if (itemstack.isEmpty()) { +@@ -916,6 +1956,7 @@ public void a(PacketPlayInTransaction packetplayintransaction) { PlayerConnectionUtils.ensureMainThread(packetplayintransaction, this, this.player.x()); -+ if (this.player.cj()) return; // CraftBukkit ++ if (this.player.isFrozen()) return; // CraftBukkit Short oshort = (Short) this.k.get(this.player.activeContainer.windowId); if (oshort != null && packetplayintransaction.b() == oshort.shortValue() && this.player.activeContainer.windowId == packetplayintransaction.a() && !this.player.activeContainer.c(this.player) && !this.player.isSpectator()) { -@@ -946,6 +1995,7 @@ +@@ -926,6 +1967,7 @@ public void a(PacketPlayInUpdateSign packetplayinupdatesign) { PlayerConnectionUtils.ensureMainThread(packetplayinupdatesign, this, this.player.x()); -+ if (this.player.cj()) return; // CraftBukkit ++ if (this.player.isFrozen()) return; // CraftBukkit this.player.resetIdleTimer(); WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); BlockPosition blockposition = packetplayinupdatesign.a(); -@@ -962,14 +2012,30 @@ +@@ -942,14 +1984,30 @@ - if (!tileentitysign.d() || tileentitysign.e() != this.player) { + if (!tileentitysign.a() || tileentitysign.e() != this.player) { this.minecraftServer.warning("Player " + this.player.getName() + " just tried to change non-editable sign"); + this.sendPacket(tileentity.getUpdatePacket()); // CraftBukkit return; @@ -1582,7 +1510,7 @@ tileentitysign.update(); worldserver.notify(blockposition, iblockdata, iblockdata, 3); -@@ -992,11 +2058,27 @@ +@@ -972,11 +2030,27 @@ public void a(PacketPlayInAbilities packetplayinabilities) { PlayerConnectionUtils.ensureMainThread(packetplayinabilities, this, this.player.x()); @@ -1611,7 +1539,7 @@ ArrayList arraylist = Lists.newArrayList(); Iterator iterator = this.minecraftServer.tabCompleteCommand(this.player, packetplayintabcomplete.a(), packetplayintabcomplete.b(), packetplayintabcomplete.c()).iterator(); -@@ -1040,10 +2122,13 @@ +@@ -1020,10 +2094,13 @@ } if (itemstack.getItem() == Items.WRITABLE_BOOK && itemstack.getItem() == itemstack1.getItem()) { @@ -1625,19 +1553,12 @@ } } else { String s1; -@@ -1067,6 +2152,7 @@ - } +@@ -1062,10 +2139,12 @@ + } - if (itemstack.getItem() == Items.WRITABLE_BOOK && itemstack1.getItem() == Items.WRITABLE_BOOK) { -+ itemstack1 = new ItemStack(Items.WRITABLE_BOOK); // CraftBukkit - itemstack1.a("author", (NBTBase) (new NBTTagString(this.player.getName()))); - itemstack1.a("title", (NBTBase) (new NBTTagString(itemstack.getTag().getString("title")))); - NBTTagList nbttaglist = itemstack.getTag().getList("pages", 8); -@@ -1081,9 +2167,11 @@ - - itemstack1.a("pages", (NBTBase) nbttaglist); - itemstack1.setItem(Items.WRITTEN_BOOK); -+ CraftEventFactory.handleEditBookEvent(player, itemstack1); // CraftBukkit + itemstack2.a("pages", (NBTBase) nbttaglist); ++ CraftEventFactory.handleEditBookEvent(player, itemstack2); // CraftBukkit + this.player.setSlot(EnumItemSlot.MAINHAND, itemstack2); } } catch (Exception exception1) { PlayerConnection.LOGGER.error("Couldn\'t sign book", exception1); @@ -1645,7 +1566,7 @@ } } else if ("MC|TrSel".equals(s)) { try { -@@ -1095,6 +2183,7 @@ +@@ -1077,6 +2156,7 @@ } } catch (Exception exception2) { PlayerConnection.LOGGER.error("Couldn\'t select trade", exception2); @@ -1653,7 +1574,7 @@ } } else { TileEntity tileentity; -@@ -1144,6 +2233,7 @@ +@@ -1126,6 +2206,7 @@ } } catch (Exception exception3) { PlayerConnection.LOGGER.error("Couldn\'t set command block", exception3); @@ -1661,7 +1582,7 @@ } } else if ("MC|AutoCmd".equals(s)) { if (!this.minecraftServer.getEnableCommandBlock()) { -@@ -1211,6 +2301,7 @@ +@@ -1193,6 +2274,7 @@ } } catch (Exception exception4) { PlayerConnection.LOGGER.error("Couldn\'t set command block", exception4); @@ -1669,7 +1590,7 @@ } } else { int k; -@@ -1234,6 +2325,7 @@ +@@ -1216,6 +2298,7 @@ } } catch (Exception exception5) { PlayerConnection.LOGGER.error("Couldn\'t set beacon", exception5); @@ -1677,7 +1598,7 @@ } } } else if ("MC|ItemName".equals(s)) { -@@ -1320,6 +2412,7 @@ +@@ -1302,6 +2385,7 @@ } } catch (Exception exception6) { PlayerConnection.LOGGER.error("Couldn\'t set structure block", exception6); @@ -1685,19 +1606,16 @@ } } else if ("MC|PickItem".equals(s)) { packetdataserializer = packetplayincustompayload.b(); -@@ -1332,14 +2425,37 @@ - this.player.playerConnection.sendPacket(new PacketPlayOutHeldItemSlot(this.player.inventory.itemInHandIndex)); - } catch (Exception exception7) { +@@ -1316,9 +2400,31 @@ PlayerConnection.LOGGER.error("Couldn\'t pick item", exception7); -+ this.disconnect("Invalid item data!"); // CraftBukkit -+ } -+ } + } + } + // CraftBukkit start + else if (packetplayincustompayload.a().equals("REGISTER")) { + String channels = packetplayincustompayload.b().toString(com.google.common.base.Charsets.UTF_8); + for (String channel : channels.split("\0")) { + getPlayer().addChannel(channel); - } ++ } + } else if (packetplayincustompayload.a().equals("UNREGISTER")) { + String channels = packetplayincustompayload.b().toString(com.google.common.base.Charsets.UTF_8); + for (String channel : channels.split("\0")) { @@ -1707,19 +1625,16 @@ + byte[] data = new byte[packetplayincustompayload.b().readableBytes()]; + packetplayincustompayload.b().readBytes(data); + server.getMessenger().dispatchIncomingMessage(player.getBukkitEntity(), packetplayincustompayload.a(), data); - } ++ } + // CraftBukkit end } } } } - ++ + // CraftBukkit start - Add "isDisconnected" method + public final boolean isDisconnected() { + return !this.player.joining && !this.networkManager.isConnected(); + } -+ - static class SyntheticClass_1 { - - static final int[] a; + } diff --git a/nms-patches/PlayerInteractManager.patch b/nms-patches/PlayerInteractManager.patch index 89fc8b9b5f..c29cc77ad9 100644 --- a/nms-patches/PlayerInteractManager.patch +++ b/nms-patches/PlayerInteractManager.patch @@ -1,9 +1,8 @@ --- a/net/minecraft/server/PlayerInteractManager.java +++ b/net/minecraft/server/PlayerInteractManager.java -@@ -1,6 +1,13 @@ +@@ -1,5 +1,13 @@ package net.minecraft.server; - import javax.annotation.Nullable; +// CraftBukkit start +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.craftbukkit.event.CraftEventFactory; @@ -11,10 +10,11 @@ +import org.bukkit.event.block.Action; +import org.bukkit.event.player.PlayerInteractEvent; +// CraftBukkit end - ++ public class PlayerInteractManager { -@@ -28,7 +35,7 @@ + public World world; +@@ -26,7 +34,7 @@ this.gamemode = enumgamemode; enumgamemode.a(this.player.abilities); this.player.updateAbilities(); @@ -23,7 +23,7 @@ this.world.everyoneSleeping(); } -@@ -53,7 +60,7 @@ +@@ -51,7 +59,7 @@ } public void a() { @@ -32,7 +32,7 @@ float f; int i; -@@ -100,6 +107,19 @@ +@@ -98,6 +106,19 @@ } public void a(BlockPosition blockposition, EnumDirection enumdirection) { @@ -52,7 +52,7 @@ if (this.isCreative()) { if (!this.world.douseFire((EntityHuman) null, blockposition, enumdirection)) { this.breakBlock(blockposition); -@@ -127,15 +147,49 @@ +@@ -125,15 +146,49 @@ } } @@ -79,8 +79,8 @@ f = iblockdata.a((EntityHuman) this.player, this.player.world, blockposition); + // Allow fire punching to be blocked + this.world.douseFire((EntityHuman) null, blockposition, enumdirection); -+ } -+ + } + + if (event.useItemInHand() == Event.Result.DENY) { + // If we 'insta destroyed' then the client needs to be informed. + if (f > 1.0f) { @@ -94,8 +94,8 @@ + // Let the client know the block still exists + ((EntityPlayer) this.player).playerConnection.sendPacket(new PacketPlayOutBlockChange(this.world, blockposition)); + return; - } - ++ } ++ + if (blockEvent.getInstaBreak()) { + f = 2.0f; + } @@ -104,7 +104,7 @@ if (iblockdata.getMaterial() != Material.AIR && f >= 1.0F) { this.breakBlock(blockposition); } else { -@@ -152,6 +206,7 @@ +@@ -150,6 +205,7 @@ public void a(BlockPosition blockposition) { if (blockposition.equals(this.f)) { @@ -112,7 +112,7 @@ int i = this.currentTick - this.lastDigTick; IBlockData iblockdata = this.world.getType(blockposition); -@@ -169,6 +224,10 @@ +@@ -167,6 +223,10 @@ this.j = this.lastDigTick; } } @@ -123,11 +123,11 @@ } } -@@ -192,13 +251,80 @@ +@@ -190,13 +250,86 @@ } public boolean breakBlock(BlockPosition blockposition) { -- if (this.gamemode.isCreative() && this.player.getItemInMainHand() != null && this.player.getItemInMainHand().getItem() instanceof ItemSword) { +- if (this.gamemode.isCreative() && !this.player.getItemInMainHand().isEmpty() && this.player.getItemInMainHand().getItem() instanceof ItemSword) { + // CraftBukkit start - fire BlockBreakEvent + BlockBreakEvent event = null; + @@ -135,7 +135,7 @@ + org.bukkit.block.Block block = this.world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); + + // Sword + Creative mode pre-cancel -+ boolean isSwordNoBreak = this.gamemode.isCreative() && this.player.getItemInMainHand() != null && this.player.getItemInMainHand().getItem() instanceof ItemSword; ++ boolean isSwordNoBreak = this.gamemode.isCreative() && !this.player.getItemInMainHand().isEmpty() && this.player.getItemInMainHand().getItem() instanceof ItemSword; + + // Tell client the block is gone immediately then process events + // Don't tell the client if its a creative sword break because its not broken! @@ -157,7 +157,7 @@ + ItemStack itemstack = this.player.getEquipment(EnumItemSlot.MAINHAND); + + if (nmsBlock != null && !event.isCancelled() && !this.isCreative() && this.player.hasBlock(nmsBlock.getBlockData())) { -+ // Copied from block.a(World world, EntityHuman entityhuman, BlockPosition blockposition, IBlockData iblockdata, TileEntity tileentity) ++ // Copied from block.a(World world, EntityHuman entityhuman, BlockPosition blockposition, IBlockData iblockdata, @Nullable TileEntity tileentity, ItemStack itemstack) + // PAIL: checkme each update + if (!(nmsBlock.o() && EnchantmentManager.getEnchantmentLevel(Enchantments.SILK_TOUCH, itemstack) > 0)) { + int bonusLevel = EnchantmentManager.getEnchantmentLevel(Enchantments.LOOT_BONUS_BLOCKS, itemstack); @@ -187,7 +187,7 @@ + return false; + } + } -+ if (false && this.gamemode.isCreative() && this.player.getItemInMainHand() != null && this.player.getItemInMainHand().getItem() instanceof ItemSword) { // CraftBukkit - false ++ if (false && this.gamemode.isCreative() && !this.player.getItemInMainHand().isEmpty() && this.player.getItemInMainHand().getItem() instanceof ItemSword) { // CraftBukkit - false return false; } else { IBlockData iblockdata = this.world.getType(blockposition); @@ -200,12 +200,18 @@ + iblockdata.getBlock().dropNaturally(world, blockposition, iblockdata, 1.0F, 0); + return this.c(blockposition); + } ++ ++ // And shulker boxes too for duplication on cancel reasons ++ if (iblockdata.getBlock() instanceof BlockShulkerBox) { ++ iblockdata.getBlock().dropNaturally(world, blockposition, iblockdata, 1.0F, 0); ++ return this.c(blockposition); ++ } + // CraftBukkit end + - if ((block instanceof BlockCommand || block instanceof BlockStructure) && !this.player.dh()) { + if ((block instanceof BlockCommand || block instanceof BlockStructure) && !this.player.dk()) { this.world.notify(blockposition, iblockdata, iblockdata, 3); return false; -@@ -243,6 +369,12 @@ +@@ -238,6 +371,12 @@ } } @@ -218,27 +224,18 @@ return flag; } } -@@ -283,7 +415,13 @@ +@@ -280,63 +419,81 @@ } } -+ // CraftBukkit start ++ // CraftBukkit start - whole method + public boolean interactResult = false; + public boolean firedInteract = false; -+ // CraftBukkit end -+ - public EnumInteractionResult a(EntityHuman entityhuman, World world, @Nullable ItemStack itemstack, EnumHand enumhand, BlockPosition blockposition, EnumDirection enumdirection, float f, float f1, float f2) { -+ /* CraftBukkit start - whole method - if (this.gamemode == EnumGamemode.SPECTATOR) { - TileEntity tileentity = world.getTileEntity(blockposition); - -@@ -340,6 +478,74 @@ - } - } - } -+ // Interact event */ + public EnumInteractionResult a(EntityHuman entityhuman, World world, ItemStack itemstack, EnumHand enumhand, BlockPosition blockposition, EnumDirection enumdirection, float f, float f1, float f2) { +- if (this.gamemode == EnumGamemode.SPECTATOR) { +- TileEntity tileentity = world.getTileEntity(blockposition); + IBlockData blockdata = world.getType(blockposition); -+ EnumInteractionResult result = EnumInteractionResult.FAIL; ++ EnumInteractionResult enuminteractionresult = EnumInteractionResult.FAIL; + if (blockdata.getBlock() != Blocks.AIR) { + boolean cancelledBlock = false; + @@ -247,7 +244,7 @@ + cancelledBlock = !(tileentity instanceof ITileInventory || tileentity instanceof IInventory); + } + -+ if (!entityhuman.getBukkitEntity().isOp() && itemstack != null && Block.asBlock(itemstack.getItem()) instanceof BlockCommand) { ++ if (!entityhuman.getBukkitEntity().isOp() && Block.asBlock(itemstack.getItem()) instanceof BlockCommand) { + cancelledBlock = true; + } + @@ -263,46 +260,87 @@ + } else if (blockdata.getBlock() instanceof BlockCake) { + ((EntityPlayer) entityhuman).getBukkitEntity().sendHealthUpdate(); // SPIGOT-1341 - reset health for cake + } -+ result = (event.useItemInHand() != Event.Result.ALLOW) ? EnumInteractionResult.SUCCESS : EnumInteractionResult.PASS; ++ enuminteractionresult = (event.useItemInHand() != Event.Result.ALLOW) ? EnumInteractionResult.SUCCESS : EnumInteractionResult.PASS; + } else if (this.gamemode == EnumGamemode.SPECTATOR) { + TileEntity tileentity = world.getTileEntity(blockposition); + + if (tileentity instanceof ITileInventory) { + Block block = world.getType(blockposition).getBlock(); + ITileInventory itileinventory = (ITileInventory) tileentity; -+ + +- if (tileentity instanceof ITileInventory) { +- Block block = world.getType(blockposition).getBlock(); +- ITileInventory itileinventory = (ITileInventory) tileentity; +- +- if (itileinventory instanceof TileEntityChest && block instanceof BlockChest) { +- itileinventory = ((BlockChest) block).c(world, blockposition); +- } + if (itileinventory instanceof TileEntityChest && block instanceof BlockChest) { + itileinventory = ((BlockChest) block).c(world, blockposition); // PAIL: rename + } -+ + +- if (itileinventory != null) { +- entityhuman.openContainer(itileinventory); + if (itileinventory != null) { + entityhuman.openContainer(itileinventory); + return EnumInteractionResult.SUCCESS; + } + } else if (tileentity instanceof IInventory) { + entityhuman.openContainer((IInventory) tileentity); -+ return EnumInteractionResult.SUCCESS; -+ } -+ + return EnumInteractionResult.SUCCESS; + } +- } else if (tileentity instanceof IInventory) { +- entityhuman.openContainer((IInventory) tileentity); +- return EnumInteractionResult.SUCCESS; +- } + +- return EnumInteractionResult.PASS; +- } else { +- if (!entityhuman.isSneaking() || entityhuman.getItemInMainHand().isEmpty() && entityhuman.getItemInOffHand().isEmpty()) { +- IBlockData iblockdata = world.getType(blockposition); + return EnumInteractionResult.PASS; -+ } else if (!entityhuman.isSneaking() || entityhuman.getItemInMainHand() == null && entityhuman.getItemInOffHand() == null) { -+ result = blockdata.getBlock().interact(world, blockposition, blockdata, entityhuman, enumhand, itemstack, enumdirection, f, f1, f2) ? EnumInteractionResult.SUCCESS : EnumInteractionResult.PASS; -+ } -+ -+ if (itemstack != null && result != EnumInteractionResult.SUCCESS && !interactResult) { // add !interactResult SPIGOT-764 -+ int j1 = itemstack.getData(); -+ int k1 = itemstack.count; -+ -+ result = itemstack.placeItem(entityhuman, world, blockposition, enumhand, enumdirection, f, f1, f2); -+ ++ } else { ++ if (!entityhuman.isSneaking() || entityhuman.getItemInMainHand().isEmpty() && entityhuman.getItemInOffHand().isEmpty()) { ++ IBlockData iblockdata = world.getType(blockposition); + +- if (iblockdata.getBlock().interact(world, blockposition, iblockdata, entityhuman, enumhand, enumdirection, f, f1, f2)) { +- return EnumInteractionResult.SUCCESS; ++ enuminteractionresult = iblockdata.getBlock().interact(world, blockposition, iblockdata, entityhuman, enumhand, enumdirection, f, f1, f2) ? EnumInteractionResult.SUCCESS : EnumInteractionResult.PASS; + } + } + +- if (itemstack.isEmpty()) { +- return EnumInteractionResult.PASS; +- } else if (entityhuman.di().a(itemstack.getItem())) { +- return EnumInteractionResult.PASS; +- } else { +- if (itemstack.getItem() instanceof ItemBlock && !entityhuman.dk()) { +- Block block1 = ((ItemBlock) itemstack.getItem()).getBlock(); ++ if (!itemstack.isEmpty() && enuminteractionresult != EnumInteractionResult.SUCCESS && !interactResult) { // add !interactResult SPIGOT-764 ++ int i = itemstack.getData(); ++ int j = itemstack.getCount(); + +- if (block1 instanceof BlockCommand || block1 instanceof BlockStructure) { +- return EnumInteractionResult.FAIL; +- } +- } ++ enuminteractionresult = itemstack.placeItem(entityhuman, world, blockposition, enumhand, enumdirection, f, f1, f2); + + // The item count should not decrement in Creative mode. -+ if (this.isCreative()) { -+ itemstack.setData(j1); -+ itemstack.count = k1; -+ } -+ } -+ } -+ return result; + if (this.isCreative()) { +- int i = itemstack.getData(); +- int j = itemstack.getCount(); +- EnumInteractionResult enuminteractionresult = itemstack.placeItem(entityhuman, world, blockposition, enumhand, enumdirection, f, f1, f2); +- + itemstack.setData(i); + itemstack.setCount(j); +- return enuminteractionresult; +- } else { +- return itemstack.placeItem(entityhuman, world, blockposition, enumhand, enumdirection, f, f1, f2); + } + } + } ++ return enuminteractionresult; + // CraftBukkit end } diff --git a/nms-patches/PlayerInventory.patch b/nms-patches/PlayerInventory.patch index 1dfab01125..543011b56e 100644 --- a/nms-patches/PlayerInventory.patch +++ b/nms-patches/PlayerInventory.patch @@ -1,10 +1,11 @@ --- a/net/minecraft/server/PlayerInventory.java +++ b/net/minecraft/server/PlayerInventory.java -@@ -3,6 +3,14 @@ - import java.util.Arrays; +@@ -5,6 +5,15 @@ + import java.util.List; import javax.annotation.Nullable; +// CraftBukkit start ++import java.util.ArrayList; +import java.util.List; +import org.bukkit.Location; + @@ -14,8 +15,8 @@ + public class PlayerInventory implements IInventory { - public final ItemStack[] items = new ItemStack[36]; -@@ -14,6 +22,48 @@ + public final NonNullList items; +@@ -16,11 +25,54 @@ private ItemStack carried; public boolean f; @@ -23,15 +24,16 @@ + public List transaction = new java.util.ArrayList(); + private int maxStack = MAX_STACK; + -+ public ItemStack[] getContents() { -+ ItemStack[] combined = new ItemStack[items.length + armor.length + extraSlots.length]; -+ System.arraycopy(items, 0, combined, 0, items.length); -+ System.arraycopy(armor, 0, combined, items.length, armor.length); -+ System.arraycopy(extraSlots, 0, combined, items.length + armor.length, extraSlots.length); ++ public List getContents() { ++ List combined = new ArrayList(items.size() + armor.size() + extraSlots.size()); ++ for (List sub : this.g) { ++ combined.addAll(sub); ++ } ++ + return combined; + } + -+ public ItemStack[] getArmorContents() { ++ public List getArmorContents() { + return this.armor; + } + @@ -62,32 +64,39 @@ + // CraftBukkit end + public PlayerInventory(EntityHuman entityhuman) { - this.g = new ItemStack[][] { this.items, this.armor, this.extraSlots}; + this.items = NonNullList.a(36, ItemStack.a); + this.armor = NonNullList.a(4, ItemStack.a); + this.extraSlots = NonNullList.a(1, ItemStack.a); +- this.g = Arrays.asList(new NonNullList[] { this.items, this.armor, this.extraSlots}); ++ this.g = (List) Arrays.asList(new NonNullList[] { this.items, this.armor, this.extraSlots}); // CraftBukkit - decompile error + this.carried = ItemStack.a; this.player = entityhuman; -@@ -36,6 +86,22 @@ + } +@@ -41,6 +93,23 @@ return itemstack.getItem() == itemstack1.getItem() && (!itemstack.usesData() || itemstack.getData() == itemstack1.getData()) && ItemStack.equals(itemstack, itemstack1); } + // CraftBukkit start - Watch method above! :D + public int canHold(ItemStack itemstack) { -+ int remains = itemstack.count; -+ for (int i = 0; i < this.items.length; ++i) { -+ if (this.items[i] == null) return itemstack.count; ++ int remains = itemstack.getCount(); ++ for (int i = 0; i < this.items.size(); ++i) { ++ ItemStack itemstack1 = this.getItem(i); ++ if (itemstack1.isEmpty()) return itemstack.getCount(); + + // Taken from firstPartial(ItemStack) -+ if (this.items[i] != null && this.items[i].getItem() == itemstack.getItem() && this.items[i].isStackable() && this.items[i].count < this.items[i].getMaxStackSize() && this.items[i].count < this.getMaxStackSize() && (!this.items[i].usesData() || this.items[i].getData() == itemstack.getData()) && ItemStack.equals(this.items[i], itemstack)) { -+ remains -= (this.items[i].getMaxStackSize() < this.getMaxStackSize() ? this.items[i].getMaxStackSize() : this.getMaxStackSize()) - this.items[i].count; ++ if (!itemstack1.isEmpty() && itemstack1.getItem() == itemstack.getItem() && itemstack1.isStackable() && itemstack1.getCount() < itemstack1.getMaxStackSize() && itemstack1.getCount() < this.getMaxStackSize() && (!itemstack1.usesData() || itemstack1.getData() == itemstack.getData()) && ItemStack.equals(itemstack1, itemstack)) { ++ remains -= (itemstack1.getMaxStackSize() < this.getMaxStackSize() ? itemstack1.getMaxStackSize() : this.getMaxStackSize()) - itemstack1.getCount(); + } -+ if (remains <= 0) return itemstack.count; ++ if (remains <= 0) return itemstack.getCount(); + } -+ return itemstack.count - remains; ++ return itemstack.getCount() - remains; + } + // CraftBukkit end + public int getFirstEmptySlotIndex() { - for (int i = 0; i < this.items.length; ++i) { - if (this.items[i] == null) { -@@ -462,7 +528,7 @@ + for (int i = 0; i < this.items.size(); ++i) { + if (((ItemStack) this.items.get(i)).isEmpty()) { +@@ -477,7 +546,7 @@ } public int getMaxStackSize() { @@ -96,13 +105,13 @@ } public boolean b(IBlockData iblockdata) { -@@ -519,6 +585,11 @@ +@@ -533,6 +602,11 @@ + } - @Nullable public ItemStack getCarried() { + // CraftBukkit start -+ if (this.carried != null && this.carried.count == 0) { -+ this.setCarried(null); ++ if (this.carried.isEmpty()) { ++ this.setCarried(ItemStack.a); + } + // CraftBukkit end return this.carried; diff --git a/nms-patches/PlayerList.patch b/nms-patches/PlayerList.patch index 207bdf0c18..24d35178b5 100644 --- a/nms-patches/PlayerList.patch +++ b/nms-patches/PlayerList.patch @@ -74,19 +74,19 @@ + // PlayerList.f.info("{}[{}] logged in with entity id {} at ({}, {}, {})", new Object[] { entityplayer.getName(), s1, Integer.valueOf(entityplayer.getId()), Double.valueOf(entityplayer.locX), Double.valueOf(entityplayer.locY), Double.valueOf(entityplayer.locZ)}); WorldServer worldserver = this.server.getWorldServer(entityplayer.dimension); WorldData worlddata = worldserver.getWorldData(); - BlockPosition blockposition = worldserver.getSpawn(); -@@ -81,6 +116,7 @@ + +@@ -80,6 +115,7 @@ PlayerConnection playerconnection = new PlayerConnection(this.server, networkmanager, entityplayer); playerconnection.sendPacket(new PacketPlayOutLogin(entityplayer.getId(), entityplayer.playerInteractManager.getGameMode(), worlddata.isHardcore(), worldserver.worldProvider.getDimensionManager().getDimensionID(), worldserver.getDifficulty(), this.getMaxPlayers(), worlddata.getType(), worldserver.getGameRules().getBoolean("reducedDebugInfo"))); + entityplayer.getBukkitEntity().sendSupportedChannels(); // CraftBukkit playerconnection.sendPacket(new PacketPlayOutCustomPayload("MC|Brand", (new PacketDataSerializer(Unpooled.buffer())).a(this.getServer().getServerModName()))); playerconnection.sendPacket(new PacketPlayOutServerDifficulty(worlddata.getDifficulty(), worlddata.isDifficultyLocked())); - playerconnection.sendPacket(new PacketPlayOutSpawnPosition(blockposition)); -@@ -91,17 +127,23 @@ + playerconnection.sendPacket(new PacketPlayOutAbilities(entityplayer.abilities)); +@@ -89,17 +125,23 @@ entityplayer.getStatisticManager().updateStatistics(entityplayer); this.sendScoreboard((ScoreboardServer) worldserver.getScoreboard(), entityplayer); - this.server.aC(); + this.server.aD(); - ChatMessage chatmessage; + // CraftBukkit start - login message is handled in the event + // ChatMessage chatmessage; @@ -113,7 +113,7 @@ playerconnection.a(entityplayer.locX, entityplayer.locY, entityplayer.locZ, entityplayer.yaw, entityplayer.pitch); this.b(entityplayer, worldserver); if (!this.server.getResourcePack().isEmpty()) { -@@ -161,6 +203,8 @@ +@@ -159,6 +201,8 @@ } entityplayer.syncInventory(); @@ -122,7 +122,7 @@ } public void sendScoreboard(ScoreboardServer scoreboardserver, EntityPlayer entityplayer) { -@@ -193,26 +237,27 @@ +@@ -191,26 +235,27 @@ } public void setPlayerFileData(WorldServer[] aworldserver) { @@ -155,7 +155,7 @@ } public void b(WorldBorder worldborder, double d0) {} -@@ -237,7 +282,7 @@ +@@ -235,7 +280,7 @@ } public NBTTagCompound a(EntityPlayer entityplayer) { @@ -164,7 +164,7 @@ NBTTagCompound nbttagcompound1; if (entityplayer.getName().equals(this.server.Q()) && nbttagcompound != null) { -@@ -261,28 +306,72 @@ +@@ -259,28 +304,72 @@ } @@ -237,13 +237,13 @@ + cserver.getPluginManager().callEvent(playerQuitEvent); + entityplayer.getBukkitEntity().disconnect(playerQuitEvent.getQuitMessage()); + -+ entityplayer.k_();// SPIGOT-924 // PAIL: rename - playerTick ++ entityplayer.playerTick();// SPIGOT-924 + // CraftBukkit end + this.savePlayerFile(entityplayer); if (entityplayer.isPassenger()) { Entity entity = entityplayer.getVehicle(); -@@ -314,13 +403,61 @@ +@@ -312,13 +401,61 @@ this.o.remove(uuid); } @@ -308,7 +308,7 @@ GameProfileBanEntry gameprofilebanentry = (GameProfileBanEntry) this.k.get(gameprofile); s = "You are banned from this server!\nReason: " + gameprofilebanentry.getReason(); -@@ -328,10 +465,12 @@ +@@ -326,10 +463,12 @@ s = s + "\nYour ban will be removed on " + PlayerList.g.format(gameprofilebanentry.getExpires()); } @@ -324,7 +324,7 @@ IpBanEntry ipbanentry = this.l.get(socketaddress); s = "Your IP address is banned from this server!\nReason: " + ipbanentry.getReason(); -@@ -339,13 +478,25 @@ +@@ -337,13 +476,25 @@ s = s + "\nYour ban will be removed on " + PlayerList.g.format(ipbanentry.getExpires()); } @@ -353,7 +353,7 @@ UUID uuid = EntityHuman.a(gameprofile); ArrayList arraylist = Lists.newArrayList(); -@@ -380,17 +531,26 @@ +@@ -378,17 +529,26 @@ } return new EntityPlayer(this.server, this.server.getWorldServer(0), gameprofile, (PlayerInteractManager) object); @@ -381,7 +381,7 @@ entityplayer.dimension = i; Object object; -@@ -401,6 +561,11 @@ +@@ -399,6 +559,11 @@ } EntityPlayer entityplayer1 = new EntityPlayer(this.server, this.server.getWorldServer(entityplayer.dimension), entityplayer.getProfile(), (PlayerInteractManager) object); @@ -393,7 +393,7 @@ entityplayer1.playerConnection = entityplayer.playerConnection; entityplayer1.copyTo(entityplayer, flag); -@@ -415,43 +580,157 @@ +@@ -413,43 +578,157 @@ entityplayer1.a(s); } @@ -568,7 +568,7 @@ public void f(EntityPlayer entityplayer) { GameProfile gameprofile = entityplayer.getProfile(); int i = this.isOp(gameprofile) ? this.operators.a(gameprofile) : 0; -@@ -490,12 +769,111 @@ +@@ -488,12 +767,111 @@ } public void changeWorld(Entity entity, int i, WorldServer worldserver, WorldServer worldserver1) { @@ -680,7 +680,7 @@ if (entity.dimension == -1) { d0 = MathHelper.a(d0 / 8.0D, worldserver1.getWorldBorder().b() + 16.0D, worldserver1.getWorldBorder().d() - 16.0D); d1 = MathHelper.a(d1 / 8.0D, worldserver1.getWorldBorder().c() + 16.0D, worldserver1.getWorldBorder().e() - 16.0D); -@@ -514,6 +892,8 @@ +@@ -512,6 +890,8 @@ BlockPosition blockposition; if (i == 1) { @@ -689,7 +689,7 @@ blockposition = worldserver1.getSpawn(); } else { blockposition = worldserver1.getDimensionSpawn(); -@@ -527,16 +907,27 @@ +@@ -525,16 +905,27 @@ worldserver.entityJoinedWorld(entity, false); } } @@ -720,7 +720,7 @@ worldserver1.entityJoinedWorld(entity, false); } -@@ -544,6 +935,7 @@ +@@ -542,6 +933,7 @@ } entity.spawnIn(worldserver1); @@ -728,7 +728,7 @@ } public void tick() { -@@ -561,6 +953,25 @@ +@@ -559,6 +951,25 @@ } @@ -754,7 +754,7 @@ public void a(Packet packet, int i) { for (int j = 0; j < this.players.size(); ++j) { EntityPlayer entityplayer = (EntityPlayer) this.players.get(j); -@@ -659,11 +1070,23 @@ +@@ -657,11 +1068,23 @@ this.operators.add(new OpListEntry(gameprofile, this.server.q(), this.operators.b(gameprofile))); this.b(this.a(gameprofile.getId()), i); @@ -778,7 +778,7 @@ } private void b(EntityPlayer entityplayer, int i) { -@@ -688,7 +1111,7 @@ +@@ -686,7 +1109,7 @@ } public boolean isOp(GameProfile gameprofile) { @@ -787,7 +787,7 @@ } @Nullable -@@ -712,6 +1135,12 @@ +@@ -710,6 +1133,12 @@ for (int j = 0; j < this.players.size(); ++j) { EntityPlayer entityplayer = (EntityPlayer) this.players.get(j); @@ -800,7 +800,7 @@ if (entityplayer != entityhuman && entityplayer.dimension == i) { double d4 = d0 - entityplayer.locX; double d5 = d1 - entityplayer.locY; -@@ -759,21 +1188,26 @@ +@@ -757,7 +1186,7 @@ public void reloadWhitelist() {} public void b(EntityPlayer entityplayer, WorldServer worldserver) { @@ -809,6 +809,9 @@ entityplayer.playerConnection.sendPacket(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.INITIALIZE)); entityplayer.playerConnection.sendPacket(new PacketPlayOutUpdateTime(worldserver.getTime(), worldserver.getDayTime(), worldserver.getGameRules().getBoolean("doDaylightCycle"))); +@@ -765,16 +1194,21 @@ + + entityplayer.playerConnection.sendPacket(new PacketPlayOutSpawnPosition(blockposition)); if (worldserver.W()) { - entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(1, 0.0F)); - entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(7, worldserver.j(1.0F))); @@ -832,7 +835,7 @@ entityplayer.playerConnection.sendPacket(new PacketPlayOutHeldItemSlot(entityplayer.inventory.itemInHandIndex)); } -@@ -786,7 +1220,7 @@ +@@ -787,7 +1221,7 @@ } public String[] getSeenPlayers() { @@ -841,7 +844,7 @@ } public boolean getHasWhitelist() { -@@ -835,17 +1269,29 @@ +@@ -836,17 +1270,29 @@ } public void u() { @@ -874,7 +877,7 @@ } public void sendMessage(IChatBaseComponent ichatbasecomponent) { -@@ -882,8 +1328,10 @@ +@@ -883,8 +1329,10 @@ WorldServer[] aworldserver = this.server.worldServer; int j = aworldserver.length; diff --git a/nms-patches/RecipeArmorDye.patch b/nms-patches/RecipeArmorDye.patch index b48d0e5b5c..da5dd0433d 100644 --- a/nms-patches/RecipeArmorDye.patch +++ b/nms-patches/RecipeArmorDye.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/RecipeArmorDye.java +++ b/net/minecraft/server/RecipeArmorDye.java -@@ -4,9 +4,13 @@ +@@ -3,9 +3,13 @@ + import com.google.common.collect.Lists; import java.util.ArrayList; - import javax.annotation.Nullable; -public class RecipeArmorDye implements IRecipe { +public class RecipeArmorDye extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends @@ -15,4 +15,4 @@ + // CraftBukkit end public boolean a(InventoryCrafting inventorycrafting, World world) { - ItemStack itemstack = null; + ItemStack itemstack = ItemStack.a; diff --git a/nms-patches/RecipeBookClone.patch b/nms-patches/RecipeBookClone.patch index 66e76dc109..022d5e7f95 100644 --- a/nms-patches/RecipeBookClone.patch +++ b/nms-patches/RecipeBookClone.patch @@ -1,8 +1,7 @@ --- a/net/minecraft/server/RecipeBookClone.java +++ b/net/minecraft/server/RecipeBookClone.java -@@ -2,9 +2,12 @@ - - import javax.annotation.Nullable; +@@ -1,8 +1,11 @@ + package net.minecraft.server; -public class RecipeBookClone implements IRecipe { +public class RecipeBookClone extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends diff --git a/nms-patches/RecipeFireworks.patch b/nms-patches/RecipeFireworks.patch index 7532dc061b..f4ed6fbfa7 100644 --- a/nms-patches/RecipeFireworks.patch +++ b/nms-patches/RecipeFireworks.patch @@ -1,20 +1,20 @@ --- a/net/minecraft/server/RecipeFireworks.java +++ b/net/minecraft/server/RecipeFireworks.java -@@ -4,11 +4,15 @@ +@@ -3,13 +3,16 @@ + import com.google.common.collect.Lists; import java.util.ArrayList; - import javax.annotation.Nullable; -public class RecipeFireworks implements IRecipe { +public class RecipeFireworks extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends private ItemStack a; -- public RecipeFireworks() {} + // CraftBukkit start - Delegate to new parent class with bogus info -+ public RecipeFireworks() { + public RecipeFireworks() { + super(new ItemStack(Items.FIREWORKS, 0, 0), java.util.Arrays.asList(new ItemStack(Items.GUNPOWDER, 0, 5))); -+ } + this.a = ItemStack.a; + } + // CraftBukkit end public boolean a(InventoryCrafting inventorycrafting, World world) { - this.a = null; + this.a = ItemStack.a; diff --git a/nms-patches/RecipeMapClone.patch b/nms-patches/RecipeMapClone.patch index 2b0674631f..234963490e 100644 --- a/nms-patches/RecipeMapClone.patch +++ b/nms-patches/RecipeMapClone.patch @@ -1,8 +1,7 @@ --- a/net/minecraft/server/RecipeMapClone.java +++ b/net/minecraft/server/RecipeMapClone.java -@@ -2,9 +2,13 @@ - - import javax.annotation.Nullable; +@@ -1,8 +1,12 @@ + package net.minecraft.server; -public class RecipeMapClone implements IRecipe { +public class RecipeMapClone extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends diff --git a/nms-patches/RecipeRepair.patch b/nms-patches/RecipeRepair.patch index ab7e733106..1d0f914425 100644 --- a/nms-patches/RecipeRepair.patch +++ b/nms-patches/RecipeRepair.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/RecipeRepair.java +++ b/net/minecraft/server/RecipeRepair.java -@@ -4,9 +4,13 @@ +@@ -3,9 +3,13 @@ + import com.google.common.collect.Lists; import java.util.ArrayList; - import javax.annotation.Nullable; -public class RecipeRepair implements IRecipe { +public class RecipeRepair extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends @@ -16,7 +16,7 @@ public boolean a(InventoryCrafting inventorycrafting, World world) { ArrayList arraylist = Lists.newArrayList(); -@@ -64,7 +68,17 @@ +@@ -62,7 +66,17 @@ i1 = 0; } diff --git a/nms-patches/RecipeShulkerBox.patch b/nms-patches/RecipeShulkerBox.patch new file mode 100644 index 0000000000..7f602345cb --- /dev/null +++ b/nms-patches/RecipeShulkerBox.patch @@ -0,0 +1,18 @@ +--- a/net/minecraft/server/RecipeShulkerBox.java ++++ b/net/minecraft/server/RecipeShulkerBox.java +@@ -9,9 +9,13 @@ + craftingmanager.a(new RecipeShulkerBox.Dye(null)); + } + +- static class Dye implements IRecipe { ++ static class Dye extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends + +- private Dye() {} ++ // CraftBukkit start - Delegate to new parent class with bogus info ++ public Dye() { ++ super(new ItemStack(Blocks.WHITE_SHULKER_BOX, 0, 0), java.util.Arrays.asList(new ItemStack(Items.DYE, 0, 5))); ++ } ++ // CraftBukkit end + + public boolean a(InventoryCrafting inventorycrafting, World world) { + int i = 0; diff --git a/nms-patches/RecipeTippedArrow.patch b/nms-patches/RecipeTippedArrow.patch index dbf39cc1cf..c828203e71 100644 --- a/nms-patches/RecipeTippedArrow.patch +++ b/nms-patches/RecipeTippedArrow.patch @@ -1,17 +1,15 @@ --- a/net/minecraft/server/RecipeTippedArrow.java +++ b/net/minecraft/server/RecipeTippedArrow.java -@@ -3,11 +3,19 @@ +@@ -2,9 +2,17 @@ + import java.util.Collection; - import javax.annotation.Nullable; --class RecipeTippedArrow implements IRecipe { -+class RecipeTippedArrow extends ShapedRecipes implements IRecipe { // CraftBukkit +-public class RecipeTippedArrow implements IRecipe { ++public class RecipeTippedArrow extends ShapedRecipes implements IRecipe { // CraftBukkit - private static final ItemStack[] a = new ItemStack[9]; - -- RecipeTippedArrow() {} +- public RecipeTippedArrow() {} + // CraftBukkit start -+ RecipeTippedArrow() { ++ public RecipeTippedArrow() { + super(3, 3, new ItemStack[]{ + new ItemStack(Items.ARROW, 0), new ItemStack(Items.ARROW, 0), new ItemStack(Items.ARROW, 0), + new ItemStack(Items.ARROW, 0), new ItemStack(Items.LINGERING_POTION, 0), new ItemStack(Items.ARROW, 0), @@ -21,4 +19,4 @@ + // CraftBukkit end public boolean a(InventoryCrafting inventorycrafting, World world) { - if (inventorycrafting.i() == 3 && inventorycrafting.h() == 3) { + if (inventorycrafting.j() == 3 && inventorycrafting.i() == 3) { diff --git a/nms-patches/RecipesBanner.patch b/nms-patches/RecipesBanner.patch index 09c32114e9..3de6f89eae 100644 --- a/nms-patches/RecipesBanner.patch +++ b/nms-patches/RecipesBanner.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/RecipesBanner.java +++ b/net/minecraft/server/RecipesBanner.java -@@ -22,9 +22,13 @@ - - static class SyntheticClass_1 { } +@@ -20,9 +20,13 @@ + craftingmanager.a(new RecipesBanner.AddRecipe(null)); + } - static class AddRecipe implements IRecipe { + static class AddRecipe extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends @@ -16,7 +16,7 @@ public boolean a(InventoryCrafting inventorycrafting, World world) { boolean flag = false; -@@ -212,9 +216,13 @@ +@@ -208,9 +212,13 @@ } } @@ -31,4 +31,4 @@ + // CraftBukkit end public boolean a(InventoryCrafting inventorycrafting, World world) { - ItemStack itemstack = null; + ItemStack itemstack = ItemStack.a; diff --git a/nms-patches/RecipesFurnace.patch b/nms-patches/RecipesFurnace.patch index 9c2f9bf80a..62124ddc04 100644 --- a/nms-patches/RecipesFurnace.patch +++ b/nms-patches/RecipesFurnace.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/RecipesFurnace.java +++ b/net/minecraft/server/RecipesFurnace.java -@@ -9,8 +9,10 @@ +@@ -8,8 +8,10 @@ public class RecipesFurnace { private static final RecipesFurnace a = new RecipesFurnace(); @@ -12,7 +12,7 @@ public static RecipesFurnace getInstance() { return RecipesFurnace.a; -@@ -55,6 +57,12 @@ +@@ -54,6 +56,12 @@ this.registerRecipe(Blocks.QUARTZ_ORE, new ItemStack(Items.QUARTZ), 0.2F); } @@ -25,9 +25,9 @@ public void registerRecipe(Block block, ItemStack itemstack, float f) { this.a(Item.getItemOf(block), itemstack, f); } -@@ -70,13 +78,23 @@ +@@ -68,13 +76,23 @@ + } - @Nullable public ItemStack getResult(ItemStack itemstack) { - Iterator iterator = this.recipes.entrySet().iterator(); + // CraftBukkit start - initialize to customRecipes @@ -39,19 +39,19 @@ do { if (!iterator.hasNext()) { -- return null; +- return ItemStack.a; + // CraftBukkit start - fall back to vanilla recipes + if (!vanilla && !this.recipes.isEmpty()) { + iterator = this.recipes.entrySet().iterator(); + vanilla = true; + } else { -+ return null; ++ return ItemStack.a; + } + // CraftBukkit end } entry = (Entry) iterator.next(); -@@ -94,13 +112,23 @@ +@@ -92,13 +110,23 @@ } public float b(ItemStack itemstack) { diff --git a/nms-patches/RecipiesShield.patch b/nms-patches/RecipiesShield.patch index 827907a096..236e726ad6 100644 --- a/nms-patches/RecipiesShield.patch +++ b/nms-patches/RecipiesShield.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/RecipiesShield.java +++ b/net/minecraft/server/RecipiesShield.java -@@ -13,9 +13,13 @@ - - static class SyntheticClass_1 { } +@@ -9,9 +9,13 @@ + craftingmanager.a(new RecipiesShield.Decoration(null)); + } - static class Decoration implements IRecipe { + static class Decoration extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends @@ -15,4 +15,4 @@ + // CraftBukkit end public boolean a(InventoryCrafting inventorycrafting, World world) { - ItemStack itemstack = null; + ItemStack itemstack = ItemStack.a; diff --git a/nms-patches/RegionFile.patch b/nms-patches/RegionFile.patch index 5dd5c60ae4..de58590070 100644 --- a/nms-patches/RegionFile.patch +++ b/nms-patches/RegionFile.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/RegionFile.java +++ b/net/minecraft/server/RegionFile.java -@@ -85,6 +85,45 @@ +@@ -86,6 +86,45 @@ } @@ -43,6 +43,6 @@ + } + // CraftBukkit end + + @Nullable public synchronized DataInputStream a(int i, int j) { if (this.d(i, j)) { - return null; diff --git a/nms-patches/RegionFileCache.patch b/nms-patches/RegionFileCache.patch index e1839bffb6..e97b881c74 100644 --- a/nms-patches/RegionFileCache.patch +++ b/nms-patches/RegionFileCache.patch @@ -1,12 +1,12 @@ --- a/net/minecraft/server/RegionFileCache.java +++ b/net/minecraft/server/RegionFileCache.java -@@ -53,15 +53,25 @@ +@@ -74,17 +74,27 @@ RegionFileCache.a.clear(); } -- public static DataInputStream c(File file, int i, int j) { +- public static DataInputStream d(File file, int i, int j) { + // CraftBukkit start - call sites hoisted for synchronization -+ public static synchronized NBTTagCompound c(File file, int i, int j) throws IOException { ++ public static synchronized NBTTagCompound d(File file, int i, int j) throws IOException { RegionFile regionfile = a(file, i, j); - return regionfile.a(i & 31, j & 31); @@ -19,8 +19,8 @@ + return NBTCompressedStreamTools.a(datainputstream); } -- public static DataOutputStream d(File file, int i, int j) { -+ public static synchronized void d(File file, int i, int j, NBTTagCompound nbttagcompound) throws IOException { +- public static DataOutputStream e(File file, int i, int j) { ++ public static synchronized void e(File file, int i, int j, NBTTagCompound nbttagcompound) throws IOException { RegionFile regionfile = a(file, i, j); - return regionfile.b(i & 31, j & 31); @@ -29,4 +29,6 @@ + dataoutputstream.close(); } + // CraftBukkit end - } + + public static boolean f(File file, int i, int j) { + RegionFile regionfile = b(file, i, j); diff --git a/nms-patches/ShapedRecipes.patch b/nms-patches/ShapedRecipes.patch index d76aa390b7..9f7c496925 100644 --- a/nms-patches/ShapedRecipes.patch +++ b/nms-patches/ShapedRecipes.patch @@ -1,17 +1,17 @@ --- a/net/minecraft/server/ShapedRecipes.java +++ b/net/minecraft/server/ShapedRecipes.java -@@ -1,6 +1,10 @@ +@@ -1,5 +1,10 @@ package net.minecraft.server; - import javax.annotation.Nullable; +// CraftBukkit start +import org.bukkit.craftbukkit.inventory.CraftItemStack; +import org.bukkit.craftbukkit.inventory.CraftShapedRecipe; +// CraftBukkit end - ++ public class ShapedRecipes implements IRecipe { -@@ -17,6 +21,62 @@ + private final int width; +@@ -22,6 +27,62 @@ this.result = itemstack; } @@ -71,6 +71,6 @@ + } + // CraftBukkit end + - @Nullable public ItemStack b() { return this.result; + } diff --git a/nms-patches/ShapelessRecipes.patch b/nms-patches/ShapelessRecipes.patch index eee448a906..0ed46af4c5 100644 --- a/nms-patches/ShapelessRecipes.patch +++ b/nms-patches/ShapelessRecipes.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/ShapelessRecipes.java +++ b/net/minecraft/server/ShapelessRecipes.java -@@ -6,6 +6,11 @@ +@@ -5,6 +5,11 @@ + import java.util.Iterator; import java.util.List; - import javax.annotation.Nullable; +// CraftBukkit start +import org.bukkit.craftbukkit.inventory.CraftItemStack; @@ -12,7 +12,7 @@ public class ShapelessRecipes implements IRecipe { private final ItemStack result; -@@ -16,6 +21,20 @@ +@@ -15,6 +20,20 @@ this.ingredients = list; } @@ -30,6 +30,6 @@ + } + // CraftBukkit end + - @Nullable public ItemStack b() { return this.result; + } diff --git a/nms-patches/Slot.patch b/nms-patches/Slot.patch deleted file mode 100644 index 3117651641..0000000000 --- a/nms-patches/Slot.patch +++ /dev/null @@ -1,12 +0,0 @@ ---- a/net/minecraft/server/Slot.java -+++ b/net/minecraft/server/Slot.java -@@ -48,6 +48,9 @@ - } - - public boolean hasItem() { -+ if (getItem() != null && getItem().count == 0) { -+ set(null); -+ } - return this.getItem() != null; - } - diff --git a/nms-patches/SlotFurnaceResult.patch b/nms-patches/SlotFurnaceResult.patch index dc7854fc67..bcc110d72f 100644 --- a/nms-patches/SlotFurnaceResult.patch +++ b/nms-patches/SlotFurnaceResult.patch @@ -1,17 +1,17 @@ --- a/net/minecraft/server/SlotFurnaceResult.java +++ b/net/minecraft/server/SlotFurnaceResult.java -@@ -1,6 +1,10 @@ +@@ -1,5 +1,10 @@ package net.minecraft.server; - import javax.annotation.Nullable; +// CraftBukkit start +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.FurnaceExtractEvent; +// CraftBukkit end - ++ public class SlotFurnaceResult extends Slot { -@@ -52,6 +56,18 @@ + private final EntityHuman a; +@@ -51,6 +56,18 @@ i = j; } diff --git a/nms-patches/StructureGenerator.patch b/nms-patches/StructureGenerator.patch deleted file mode 100644 index 72129e0ee7..0000000000 --- a/nms-patches/StructureGenerator.patch +++ /dev/null @@ -1,38 +0,0 @@ ---- a/net/minecraft/server/StructureGenerator.java -+++ b/net/minecraft/server/StructureGenerator.java -@@ -93,7 +93,7 @@ - return this.c(blockposition) != null; - } - -- protected StructureStart c(BlockPosition blockposition) { -+ protected synchronized StructureStart c(BlockPosition blockposition) { // CraftBukkit - synchronized - Iterator iterator = this.c.values().iterator(); - - while (iterator.hasNext()) { -@@ -115,7 +115,7 @@ - return null; - } - -- public boolean b(World world, BlockPosition blockposition) { -+ public synchronized boolean b(World world, BlockPosition blockposition) { // CraftBukkit - synchronized - this.a(world); - Iterator iterator = this.c.values().iterator(); - -@@ -132,7 +132,7 @@ - return true; - } - -- public BlockPosition getNearestGeneratedFeature(World world, BlockPosition blockposition) { -+ public synchronized BlockPosition getNearestGeneratedFeature(World world, BlockPosition blockposition) { // CraftBukkit - synchronized - this.g = world; - this.a(world); - this.f.setSeed(world.getSeed()); -@@ -194,7 +194,7 @@ - return null; - } - -- protected void a(World world) { -+ protected synchronized void a(World world) { // CraftBukkit - synchronized - if (this.a == null) { - this.a = (PersistentStructure) world.a(PersistentStructure.class, this.a()); - if (this.a == null) { diff --git a/nms-patches/TileEntity.patch b/nms-patches/TileEntity.patch index d11d0ddde3..3b5db83aa6 100644 --- a/nms-patches/TileEntity.patch +++ b/nms-patches/TileEntity.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/TileEntity.java +++ b/net/minecraft/server/TileEntity.java -@@ -6,6 +6,8 @@ +@@ -4,6 +4,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -9,9 +9,9 @@ public abstract class TileEntity { private static final Logger a = LogManager.getLogger(); -@@ -256,4 +258,13 @@ - a(TileEntityEndGateway.class, "EndGateway"); - a(TileEntityCommand.class, "Control"); +@@ -255,4 +257,13 @@ + a("command_block", TileEntityCommand.class); + a("shulker_box", TileEntityShulkerBox.class); } + + // CraftBukkit start - add method diff --git a/nms-patches/TileEntityBanner.patch b/nms-patches/TileEntityBanner.patch index caf443b037..c9294ee0b2 100644 --- a/nms-patches/TileEntityBanner.patch +++ b/nms-patches/TileEntityBanner.patch @@ -1,26 +1,26 @@ --- a/net/minecraft/server/TileEntityBanner.java +++ b/net/minecraft/server/TileEntityBanner.java -@@ -21,6 +21,11 @@ +@@ -23,6 +23,11 @@ - if (nbttagcompound.hasKey("Patterns")) { - this.patterns = nbttagcompound.getList("Patterns", 10).d(); -+ // CraftBukkit start -+ while (this.patterns.size() > 20) { -+ this.patterns.remove(20); -+ } -+ // CraftBukkit end - } + if (nbttagcompound != null && nbttagcompound.hasKeyOfType("Patterns", 9)) { + this.patterns = nbttagcompound.getList("Patterns", 10).d(); ++ // CraftBukkit start ++ while (this.patterns.size() > 20) { ++ this.patterns.remove(20); ++ } ++ // CraftBukkit end + } - if (nbttagcompound.hasKeyOfType("Base", 99)) { -@@ -56,6 +61,11 @@ - super.a(nbttagcompound); - this.color = nbttagcompound.getInt("Base"); + this.color = flag ? d(itemstack) : ItemBanner.c(itemstack); +@@ -67,6 +72,11 @@ + + this.color = EnumColor.fromInvColorIndex(nbttagcompound.getInt("Base")); this.patterns = nbttagcompound.getList("Patterns", 10); + // CraftBukkit start + while (this.patterns.size() > 20) { + this.patterns.remove(20); + } + // CraftBukkit end - this.h = null; this.i = null; this.j = null; + this.k = null; diff --git a/nms-patches/TileEntityBeacon.patch b/nms-patches/TileEntityBeacon.patch index 7444710428..91779ec980 100644 --- a/nms-patches/TileEntityBeacon.patch +++ b/nms-patches/TileEntityBeacon.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/TileEntityBeacon.java +++ b/net/minecraft/server/TileEntityBeacon.java -@@ -9,19 +9,58 @@ +@@ -9,6 +9,13 @@ import java.util.Set; import javax.annotation.Nullable; @@ -14,25 +14,16 @@ public class TileEntityBeacon extends TileEntityContainer implements ITickable, IWorldInventory { public static final MobEffectList[][] a = new MobEffectList[][] { { MobEffects.FASTER_MOVEMENT, MobEffects.FASTER_DIG}, { MobEffects.RESISTANCE, MobEffects.JUMP}, { MobEffects.INCREASE_DAMAGE}, { MobEffects.REGENERATION}}; - private static final Set f = Sets.newHashSet(); - private final List g = Lists.newArrayList(); - private boolean j; -- private int k = -1; -+ public int k = -1; // PAIL: private -> public - @Nullable -- private MobEffectList l; -+ public MobEffectList l; // PAIL: private -> public - @Nullable -- private MobEffectList m; -+ public MobEffectList m; // PAIL: private -> public +@@ -22,6 +29,38 @@ + public MobEffectList secondaryEffect; private ItemStack inventorySlot; private String o; + // CraftBukkit start - add fields and methods + public List transaction = new java.util.ArrayList(); + private int maxStack = MAX_STACK; + -+ public ItemStack[] getContents() { -+ return new ItemStack[] { this.inventorySlot }; ++ public List getContents() { ++ return Arrays.asList(this.inventorySlot); + } + + public void onOpen(CraftHumanEntity who) { @@ -52,29 +43,29 @@ + } + + public PotionEffect getPrimaryEffect() { -+ return (this.l != null) ? CraftPotionUtil.toBukkit(new MobEffect(this.l, getLevel(), getAmplification(), true, true)) : null; ++ return (this.primaryEffect != null) ? CraftPotionUtil.toBukkit(new MobEffect(this.primaryEffect, getLevel(), getAmplification(), true, true)) : null; + } + + public PotionEffect getSecondaryEffect() { -+ return (hasSecondaryEffect()) ? CraftPotionUtil.toBukkit(new MobEffect(this.m, getLevel(), getAmplification(), true, true)) : null; ++ return (hasSecondaryEffect()) ? CraftPotionUtil.toBukkit(new MobEffect(this.secondaryEffect, getLevel(), getAmplification(), true, true)) : null; + } + // CraftBukkit end - public TileEntityBeacon() {} - -@@ -40,41 +79,79 @@ + public TileEntityBeacon() { + this.inventorySlot = ItemStack.a; +@@ -42,41 +81,79 @@ } - private void E() { -- if (this.j && this.k > 0 && !this.world.isClientSide && this.l != null) { -- double d0 = (double) (this.k * 10 + 10); +- if (this.j && this.levels > 0 && !this.world.isClientSide && this.primaryEffect != null) { +- double d0 = (double) (this.levels * 10 + 10); + // CraftBukkit start - split into components + private byte getAmplification() { + { byte b0 = 0; - if (this.k >= 4 && this.l == this.m) { + if (this.levels >= 4 && this.primaryEffect == this.secondaryEffect) { b0 = 1; } @@ -84,19 +75,19 @@ + + private int getLevel() { + { - int i = (9 + this.k * 2) * 20; + int i = (9 + this.levels * 2) * 20; + return i; + } + } + + public List getHumansInRange() { + { -+ double d0 = (double) (this.k * 10 + 10); ++ double d0 = (double) (this.levels * 10 + 10); + int j = this.position.getX(); int k = this.position.getY(); int l = this.position.getZ(); - AxisAlignedBB axisalignedbb = (new AxisAlignedBB((double) j, (double) k, (double) l, (double) (j + 1), (double) (k + 1), (double) (l + 1))).g(d0).a(0.0D, (double) this.world.getHeight(), 0.0D); + AxisAlignedBB axisalignedbb = (new AxisAlignedBB((double) j, (double) k, (double) l, (double) (j + 1), (double) (k + 1), (double) (l + 1))).g(d0).b(0.0D, (double) this.world.getHeight(), 0.0D); List list = this.world.a(EntityHuman.class, axisalignedbb); + + return list; @@ -111,7 +102,7 @@ while (iterator.hasNext()) { entityhuman = (EntityHuman) iterator.next(); -- entityhuman.addEffect(new MobEffect(this.l, i, b0, true, true)); +- entityhuman.addEffect(new MobEffect(this.primaryEffect, i, b0, true, true)); + entityhuman.addEffect(new MobEffect(effects, i, b0, true, true)); } + } @@ -119,7 +110,7 @@ + private boolean hasSecondaryEffect() { + { - if (this.k >= 4 && this.l != this.m && this.m != null) { + if (this.levels >= 4 && this.primaryEffect != this.secondaryEffect && this.secondaryEffect != null) { - iterator = list.iterator(); + return true; + } @@ -129,20 +120,20 @@ + } + + private void E() { -+ if (this.j && this.k > 0 && !this.world.isClientSide && this.l != null) { ++ if (this.j && this.levels > 0 && !this.world.isClientSide && this.primaryEffect != null) { + byte b0 = getAmplification(); + + int i = getLevel(); + List list = getHumansInRange(); + -+ applyEffect(list, this.l, i, b0); ++ applyEffect(list, this.primaryEffect, i, b0); - while (iterator.hasNext()) { - entityhuman = (EntityHuman) iterator.next(); -- entityhuman.addEffect(new MobEffect(this.m, i, 0, true, true)); +- entityhuman.addEffect(new MobEffect(this.secondaryEffect, i, 0, true, true)); - } + if (hasSecondaryEffect()) { -+ applyEffect(list, this.m, i, 0); ++ applyEffect(list, this.secondaryEffect, i, 0); } } @@ -150,4 +141,4 @@ + // CraftBukkit end private void F() { - int i = this.k; + int i = this.levels; diff --git a/nms-patches/TileEntityBrewingStand.patch b/nms-patches/TileEntityBrewingStand.patch index a0b64d7f7c..ccbc279430 100644 --- a/nms-patches/TileEntityBrewingStand.patch +++ b/nms-patches/TileEntityBrewingStand.patch @@ -2,7 +2,7 @@ +++ b/net/minecraft/server/TileEntityBrewingStand.java @@ -3,6 +3,13 @@ import java.util.Arrays; - import javax.annotation.Nullable; + import java.util.Iterator; +// CraftBukkit start +import java.util.List; @@ -14,15 +14,12 @@ public class TileEntityBrewingStand extends TileEntityContainer implements ITickable, IWorldInventory { private static final int[] a = new int[] { 3}; -@@ -14,9 +21,35 @@ +@@ -14,6 +21,31 @@ private Item k; private String l; private int m; -+ private int lastTick = MinecraftServer.currentTick; // CraftBukkit - add field - - public TileEntityBrewingStand() {} - + // CraftBukkit start - add fields and methods ++ private int lastTick = MinecraftServer.currentTick; + public List transaction = new java.util.ArrayList(); + private int maxStack = 64; + @@ -38,7 +35,7 @@ + return transaction; + } + -+ public ItemStack[] getContents() { ++ public List getContents() { + return this.items; + } + @@ -46,13 +43,12 @@ + maxStack = size; + } + // CraftBukkit end -+ - public String getName() { - return this.hasCustomName() ? this.l : "container.brewing"; - } -@@ -47,9 +80,14 @@ - boolean flag = this.n(); + + public TileEntityBrewingStand() { + this.items = NonNullList.a(5, ItemStack.a); +@@ -64,9 +96,14 @@ boolean flag1 = this.brewTime > 0; + ItemStack itemstack1 = (ItemStack) this.items.get(3); + // CraftBukkit start - Use wall time instead of ticks for brewing + int elapsedTicks = MinecraftServer.currentTick - this.lastTick; @@ -66,11 +62,11 @@ + // CraftBukkit end if (flag2 && flag) { - this.o(); -@@ -125,6 +163,15 @@ + this.p(); +@@ -140,6 +177,15 @@ - private void o() { - ItemStack itemstack = this.items[3]; + private void p() { + ItemStack itemstack = (ItemStack) this.items.get(3); + // CraftBukkit start + if (getOwner() != null) { + BrewEvent event = new BrewEvent(world.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ()), (org.bukkit.inventory.BrewerInventory) this.getOwner().getInventory()); @@ -82,8 +78,8 @@ + // CraftBukkit end for (int i = 0; i < 3; ++i) { - this.items[i] = PotionBrewer.d(itemstack, this.items[i]); -@@ -225,7 +272,7 @@ + this.items.set(i, PotionBrewer.d(itemstack, (ItemStack) this.items.get(i))); +@@ -210,7 +256,7 @@ } public int getMaxStackSize() { diff --git a/nms-patches/TileEntityChest.patch b/nms-patches/TileEntityChest.patch index 1dfb8f1858..c302cf6447 100644 --- a/nms-patches/TileEntityChest.patch +++ b/nms-patches/TileEntityChest.patch @@ -1,26 +1,25 @@ --- a/net/minecraft/server/TileEntityChest.java +++ b/net/minecraft/server/TileEntityChest.java -@@ -4,6 +4,11 @@ +@@ -3,6 +3,10 @@ + import java.util.Iterator; import java.util.List; import javax.annotation.Nullable; - +// CraftBukkit start +import org.bukkit.craftbukkit.entity.CraftHumanEntity; +import org.bukkit.entity.HumanEntity; +// CraftBukkit end -+ - public class TileEntityChest extends TileEntityLootable implements ITickable, IInventory { - private ItemStack[] items = new ItemStack[27]; -@@ -21,6 +26,31 @@ + public class TileEntityChest extends TileEntityLootable implements ITickable { - public TileEntityChest() {} +@@ -18,6 +22,31 @@ + private int q; + private BlockChest.Type r; + // CraftBukkit start - add fields and methods + public List transaction = new java.util.ArrayList(); + private int maxStack = MAX_STACK; + -+ public ItemStack[] getContents() { ++ public List getContents() { + return this.items; + } + @@ -41,10 +40,10 @@ + } + // CraftBukkit end + - public TileEntityChest(BlockChest.Type blockchest_type) { - this.q = blockchest_type; + public TileEntityChest() { + this.items = NonNullList.a(27, ItemStack.a); } -@@ -127,10 +157,11 @@ +@@ -82,7 +111,7 @@ } public int getMaxStackSize() { @@ -52,12 +51,8 @@ + return maxStack; // CraftBukkit } - public boolean a(EntityHuman entityhuman) { -+ if (this.world == null) return true; // CraftBukkit - return this.world.getTileEntity(this.position) != this ? false : entityhuman.e((double) this.position.getX() + 0.5D, (double) this.position.getY() + 0.5D, (double) this.position.getZ() + 0.5D) <= 64.0D; - } - -@@ -307,9 +338,21 @@ + public void invalidateBlockCache() { +@@ -258,9 +287,21 @@ if (this.l < 0) { this.l = 0; } @@ -76,41 +71,40 @@ + } + } + // CraftBukkit end - this.world.applyPhysics(this.position, this.getBlock()); - this.world.applyPhysics(this.position.down(), this.getBlock()); - } -@@ -318,8 +361,20 @@ + this.world.applyPhysics(this.position, this.getBlock(), false); + if (this.p() == BlockChest.Type.TRAP) { + this.world.applyPhysics(this.position.down(), this.getBlock(), false); +@@ -271,12 +312,21 @@ public void closeContainer(EntityHuman entityhuman) { if (!entityhuman.isSpectator() && this.getBlock() instanceof BlockChest) { + int oldPower = Math.max(0, Math.min(15, this.l)); // CraftBukkit - Get power before new viewer is added --this.l; -+ if (this.world == null) return; // CraftBukkit this.world.playBlockAction(this.position, this.getBlock(), 1, this.l); + this.world.applyPhysics(this.position, this.getBlock(), false); + + // CraftBukkit start - Call redstone event -+ if (this.getBlock() == Blocks.TRAPPED_CHEST) { + if (this.p() == BlockChest.Type.TRAP) { + int newPower = Math.max(0, Math.min(15, this.l)); + + if (oldPower != newPower) { + org.bukkit.craftbukkit.event.CraftEventFactory.callRedstoneChange(world, position.getX(), position.getY(), position.getZ(), oldPower, newPower); + } -+ } + this.world.applyPhysics(this.position.down(), this.getBlock(), false); + } + // CraftBukkit end - this.world.applyPhysics(this.position, this.getBlock()); - this.world.applyPhysics(this.position.down(), this.getBlock()); } -@@ -376,6 +431,13 @@ } - +@@ -311,4 +361,11 @@ + protected NonNullList q() { + return this.items; + } ++ + // CraftBukkit start + @Override + public boolean isFilteredNBT() { + return true; + } + // CraftBukkit end -+ - static class SyntheticClass_1 { - - static final int[] a = new int[EnumDirection.values().length]; + } diff --git a/nms-patches/TileEntityDispenser.patch b/nms-patches/TileEntityDispenser.patch index 5080012fcf..3414c8aa5f 100644 --- a/nms-patches/TileEntityDispenser.patch +++ b/nms-patches/TileEntityDispenser.patch @@ -1,27 +1,26 @@ --- a/net/minecraft/server/TileEntityDispenser.java +++ b/net/minecraft/server/TileEntityDispenser.java -@@ -3,12 +3,44 @@ - import java.util.Random; - import javax.annotation.Nullable; +@@ -2,12 +2,43 @@ + import java.util.Iterator; + import java.util.Random; +// CraftBukkit start +import java.util.List; + +import org.bukkit.craftbukkit.entity.CraftHumanEntity; +import org.bukkit.entity.HumanEntity; +// CraftBukkit end -+ - public class TileEntityDispenser extends TileEntityLootable implements IInventory { - private static final Random f = new Random(); - private ItemStack[] items = new ItemStack[9]; - protected String a; + public class TileEntityDispenser extends TileEntityLootable { + + private static final Random a = new Random(); + private NonNullList items; + // CraftBukkit start - add fields and methods + public List transaction = new java.util.ArrayList(); + private int maxStack = MAX_STACK; + -+ public ItemStack[] getContents() { ++ public List getContents() { + return this.items; + } + @@ -42,18 +41,10 @@ + } + // CraftBukkit end + - public TileEntityDispenser() {} - - public int getSize() { -@@ -46,6 +78,7 @@ - - for (int k = 0; k < this.items.length; ++k) { - if (this.items[k] != null && TileEntityDispenser.f.nextInt(j++) == 0) { -+ if (this.items[k].count == 0) continue; // CraftBukkit - i = k; - } - } -@@ -139,7 +172,7 @@ + public TileEntityDispenser() { + this.items = NonNullList.a(9, ItemStack.a); + } +@@ -92,7 +123,7 @@ } public int getMaxStackSize() { @@ -61,4 +52,4 @@ + return maxStack; // CraftBukkit } - public boolean a(EntityHuman entityhuman) { + public String getContainerName() { diff --git a/nms-patches/TileEntityEndGateway.patch b/nms-patches/TileEntityEndGateway.patch index cb6f07d729..35bfeee38e 100644 --- a/nms-patches/TileEntityEndGateway.patch +++ b/nms-patches/TileEntityEndGateway.patch @@ -11,11 +11,11 @@ +import org.bukkit.event.player.PlayerTeleportEvent; +// CraftBukkit end - public class TileEntityEndGateway extends TileEntity implements ITickable { + public class TileEntityEndGateway extends TileEntityEnderPortal implements ITickable { -@@ -107,6 +113,26 @@ +@@ -111,6 +117,26 @@ if (this.exitPortal != null) { - BlockPosition blockposition = this.exactTeleport ? this.exitPortal : this.k(); + BlockPosition blockposition = this.exactTeleport ? this.exitPortal : this.i(); + // CraftBukkit start - Fire PlayerTeleportEvent + if (entity instanceof EntityPlayer) { diff --git a/nms-patches/TileEntityFurnace.patch b/nms-patches/TileEntityFurnace.patch index 2c0539b77d..5c01f0b7c7 100644 --- a/nms-patches/TileEntityFurnace.patch +++ b/nms-patches/TileEntityFurnace.patch @@ -3,7 +3,7 @@ @@ -1,6 +1,15 @@ package net.minecraft.server; - import javax.annotation.Nullable; + import java.util.Iterator; +// CraftBukkit start +import java.util.List; + @@ -25,7 +25,7 @@ + private int maxStack = MAX_STACK; + public List transaction = new java.util.ArrayList(); + -+ public ItemStack[] getContents() { ++ public List getContents() { + return this.items; + } + @@ -46,13 +46,13 @@ + } + // CraftBukkit end + - public TileEntityFurnace() {} - - public int getSize() { -@@ -126,11 +161,29 @@ + public TileEntityFurnace() { + this.items = NonNullList.a(3, ItemStack.a); + } +@@ -119,11 +154,29 @@ } - public void E_() { + public void F_() { - boolean flag = this.isBurning(); + boolean flag = (this.getBlock() == Blocks.LIT_FURNACE); // CraftBukkit - SPIGOT-844 - Check if furnace block is lit using the block instead of burn time boolean flag1 = false; @@ -61,12 +61,12 @@ + int elapsedTicks = MinecraftServer.currentTick - this.lastTick; + this.lastTick = MinecraftServer.currentTick; + -+ // CraftBukkit - moved from below ++ // CraftBukkit - moved from below - edited for wall time + if (this.isBurning() && this.canBurn()) { + this.cookTime += elapsedTicks; + if (this.cookTime >= this.cookTimeTotal) { + this.cookTime = 0; -+ this.cookTimeTotal = this.a(this.items[0]); ++ this.cookTimeTotal = this.a((ItemStack) this.items.get(0)); + this.burn(); + flag1 = true; + } @@ -81,19 +81,19 @@ } if (!this.world.isClientSide) { -@@ -139,10 +192,21 @@ +@@ -134,10 +187,21 @@ this.cookTime = MathHelper.clamp(this.cookTime - 2, 0, this.cookTimeTotal); } } else { - if (!this.isBurning() && this.canBurn()) { -- this.burnTime = fuelTime(this.items[1]); +- this.burnTime = fuelTime(itemstack); - this.ticksForCurrentFuel = this.burnTime; - if (this.isBurning()) { + // CraftBukkit start - Handle multiple elapsed ticks + if (this.burnTime <= 0 && this.canBurn()) { // CraftBukkit - == to <= -+ CraftItemStack fuel = CraftItemStack.asCraftMirror(this.items[1]); ++ CraftItemStack fuel = CraftItemStack.asCraftMirror(itemstack); + -+ FurnaceBurnEvent furnaceBurnEvent = new FurnaceBurnEvent(this.world.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ()), fuel, fuelTime(this.items[1])); ++ FurnaceBurnEvent furnaceBurnEvent = new FurnaceBurnEvent(this.world.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ()), fuel, fuelTime(itemstack)); + this.world.getServer().getPluginManager().callEvent(furnaceBurnEvent); + + if (furnaceBurnEvent.isCancelled()) { @@ -105,9 +105,9 @@ + if (this.burnTime > 0 && furnaceBurnEvent.isBurning()) { + // CraftBukkit end flag1 = true; - if (this.items[1] != null) { - --this.items[1].count; -@@ -155,6 +219,7 @@ + if (!itemstack.isEmpty()) { + Item item = itemstack.getItem(); +@@ -152,6 +216,7 @@ } } @@ -115,7 +115,7 @@ if (this.isBurning() && this.canBurn()) { ++this.cookTime; if (this.cookTime == this.cookTimeTotal) { -@@ -166,11 +231,13 @@ +@@ -163,11 +228,13 @@ } else { this.cookTime = 0; } @@ -129,23 +129,23 @@ } } -@@ -190,7 +257,8 @@ - } else { - ItemStack itemstack = RecipesFurnace.getInstance().getResult(this.items[0]); +@@ -192,7 +259,8 @@ + } else { + ItemStack itemstack1 = (ItemStack) this.items.get(2); -- return itemstack == null ? false : (this.items[2] == null ? true : (!this.items[2].doMaterialsMatch(itemstack) ? false : (this.items[2].count < this.getMaxStackSize() && this.items[2].count < this.items[2].getMaxStackSize() ? true : this.items[2].count < itemstack.getMaxStackSize()))); -+ // CraftBukkit - consider resultant count instead of current count -+ return itemstack == null ? false : (this.items[2] == null ? true : (!this.items[2].doMaterialsMatch(itemstack) ? false : (this.items[2].count + itemstack.count <= this.getMaxStackSize() && this.items[2].count < this.items[2].getMaxStackSize() ? true : this.items[2].count + itemstack.count <= itemstack.getMaxStackSize()))); +- return itemstack1.isEmpty() ? true : (!itemstack1.doMaterialsMatch(itemstack) ? false : (itemstack1.getCount() < this.getMaxStackSize() && itemstack1.getCount() < itemstack1.getMaxStackSize() ? true : itemstack1.getCount() < itemstack.getMaxStackSize())); ++ // CraftBukkit - consider resultant count instead of current count ++ return itemstack1.isEmpty() ? true : (!itemstack1.doMaterialsMatch(itemstack) ? false : (itemstack1.getCount() + itemstack.getCount() < this.getMaxStackSize() && itemstack1.getCount() + itemstack.getCount() < itemstack1.getMaxStackSize() ? true : itemstack1.getCount() + itemstack.getCount() < itemstack.getMaxStackSize())); + } } } - -@@ -198,11 +266,38 @@ - if (this.canBurn()) { - ItemStack itemstack = RecipesFurnace.getInstance().getResult(this.items[0]); +@@ -203,11 +271,38 @@ + ItemStack itemstack1 = RecipesFurnace.getInstance().getResult(itemstack); + ItemStack itemstack2 = (ItemStack) this.items.get(2); + // CraftBukkit start - fire FurnaceSmeltEvent -+ CraftItemStack source = CraftItemStack.asCraftMirror(this.items[0]); -+ org.bukkit.inventory.ItemStack result = CraftItemStack.asBukkitCopy(itemstack); ++ CraftItemStack source = CraftItemStack.asCraftMirror(itemstack); ++ org.bukkit.inventory.ItemStack result = CraftItemStack.asBukkitCopy(itemstack1); + + FurnaceSmeltEvent furnaceSmeltEvent = new FurnaceSmeltEvent(this.world.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ()), source, result); + this.world.getServer().getPluginManager().callEvent(furnaceSmeltEvent); @@ -155,26 +155,26 @@ + } + + result = furnaceSmeltEvent.getResult(); -+ itemstack = CraftItemStack.asNMSCopy(result); ++ itemstack1 = CraftItemStack.asNMSCopy(result); + -+ if (itemstack != null) { -+ if (this.items[2] == null) { -+ this.items[2] = itemstack; -+ } else if (CraftItemStack.asCraftMirror(this.items[2]).isSimilar(result)) { -+ this.items[2].count += itemstack.count; ++ if (!itemstack1.isEmpty()) { ++ if (itemstack2.isEmpty()) { ++ this.items.set(2, itemstack1.cloneItemStack()); ++ } else if (CraftItemStack.asCraftMirror(itemstack2).isSimilar(result)) { ++ itemstack2.add(itemstack1.getCount()); + } else { + return; + } + } + + /* - if (this.items[2] == null) { - this.items[2] = itemstack.cloneItemStack(); - } else if (this.items[2].getItem() == itemstack.getItem()) { - ++this.items[2].count; + if (itemstack2.isEmpty()) { + this.items.set(2, itemstack1.cloneItemStack()); + } else if (itemstack2.getItem() == itemstack1.getItem()) { + itemstack2.add(1); } + */ + // CraftBukkit end - if (this.items[0].getItem() == Item.getItemOf(Blocks.SPONGE) && this.items[0].getData() == 1 && this.items[1] != null && this.items[1].getItem() == Items.BUCKET) { - this.items[1] = new ItemStack(Items.WATER_BUCKET); + if (itemstack.getItem() == Item.getItemOf(Blocks.SPONGE) && itemstack.getData() == 1 && !((ItemStack) this.items.get(1)).isEmpty() && ((ItemStack) this.items.get(1)).getItem() == Items.BUCKET) { + this.items.set(1, new ItemStack(Items.WATER_BUCKET)); diff --git a/nms-patches/TileEntityHopper.patch b/nms-patches/TileEntityHopper.patch index 32d757c8bc..9393ad7afa 100644 --- a/nms-patches/TileEntityHopper.patch +++ b/nms-patches/TileEntityHopper.patch @@ -15,15 +15,15 @@ + public class TileEntityHopper extends TileEntityLootable implements IHopper, ITickable { - private ItemStack[] items = new ItemStack[5]; - private String f; - private int g = -1; + private NonNullList items; + private int f; + private long g; + // CraftBukkit start - add fields and methods + public List transaction = new java.util.ArrayList(); + private int maxStack = MAX_STACK; + -+ public ItemStack[] getContents() { ++ public List getContents() { + return this.items; + } + @@ -44,10 +44,10 @@ + } + // CraftBukkit end + - public TileEntityHopper() {} - - public static void a(DataConverterManager dataconvertermanager) { -@@ -109,7 +143,7 @@ + public TileEntityHopper() { + this.items = NonNullList.a(5, ItemStack.a); + this.f = -1; +@@ -72,7 +106,7 @@ } public int getMaxStackSize() { @@ -55,13 +55,13 @@ + return maxStack; // CraftBukkit } - public boolean a(EntityHuman entityhuman) { -@@ -205,10 +239,35 @@ + public void F_() { +@@ -163,10 +197,35 @@ for (int i = 0; i < this.getSize(); ++i) { - if (this.getItem(i) != null) { + if (!this.getItem(i).isEmpty()) { ItemStack itemstack = this.getItem(i).cloneItemStack(); -- ItemStack itemstack1 = addItem(iinventory, this.splitStack(i, 1), enumdirection); -+ // ItemStack itemstack1 = addItem(iinventory, this.splitStack(i, 1), enumdirection); +- ItemStack itemstack1 = addItem(this, iinventory, this.splitStack(i, 1), enumdirection); ++ // ItemStack itemstack1 = addItem(this, iinventory, this.splitStack(i, 1), enumdirection); + + // CraftBukkit start - Call event when pushing items into other inventories + CraftItemStack oitemstack = CraftItemStack.asCraftMirror(this.splitStack(i, 1)); @@ -81,9 +81,9 @@ + this.setCooldown(8); // Delay hopper checks + return false; + } -+ ItemStack itemstack1 = addItem(iinventory, CraftItemStack.asNMSCopy(event.getItem()), enumdirection); ++ ItemStack itemstack1 = addItem(this, iinventory, CraftItemStack.asNMSCopy(event.getItem()), enumdirection); - if (itemstack1 == null || itemstack1.count == 0) { + if (itemstack1.isEmpty()) { - iinventory.update(); + if (event.getItem().equals(oitemstack)) { + iinventory.update(); @@ -94,12 +94,12 @@ return true; } -@@ -330,10 +389,41 @@ +@@ -288,10 +347,41 @@ - if (itemstack != null && b(iinventory, itemstack, i, enumdirection)) { + if (!itemstack.isEmpty() && b(iinventory, itemstack, i, enumdirection)) { ItemStack itemstack1 = itemstack.cloneItemStack(); -- ItemStack itemstack2 = addItem(ihopper, iinventory.splitStack(i, 1), (EnumDirection) null); -+ // ItemStack itemstack2 = addItem(ihopper, iinventory.splitStack(i, 1), (EnumDirection) null); +- ItemStack itemstack2 = addItem(iinventory, ihopper, iinventory.splitStack(i, 1), (EnumDirection) null); ++ // ItemStack itemstack2 = addItem(iinventory, ihopper, iinventory.splitStack(i, 1), (EnumDirection) null); + // CraftBukkit start - Call event on collection of items from inventories into the hopper + CraftItemStack oitemstack = CraftItemStack.asCraftMirror(iinventory.splitStack(i, 1)); + @@ -125,9 +125,9 @@ + + return false; + } -+ ItemStack itemstack2 = addItem(ihopper, CraftItemStack.asNMSCopy(event.getItem()), null); ++ ItemStack itemstack2 = addItem(iinventory, ihopper, CraftItemStack.asNMSCopy(event.getItem()), null); - if (itemstack2 == null || itemstack2.count == 0) { + if (itemstack2.isEmpty()) { - iinventory.update(); + if (event.getItem().equals(oitemstack)) { + iinventory.update(); @@ -138,17 +138,17 @@ return true; } -@@ -349,6 +439,13 @@ +@@ -307,6 +397,13 @@ if (entityitem == null) { return false; } else { + // CraftBukkit start -+ InventoryPickupItemEvent event = new InventoryPickupItemEvent(iinventory.getOwner().getInventory(), (org.bukkit.entity.Item) entityitem.getBukkitEntity()); ++ InventoryPickupItemEvent event = new InventoryPickupItemEvent(iinventory1.getOwner().getInventory(), (org.bukkit.entity.Item) entityitem.getBukkitEntity()); + entityitem.world.getServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { + return false; + } + // CraftBukkit end ItemStack itemstack = entityitem.getItemStack().cloneItemStack(); - ItemStack itemstack1 = addItem(iinventory, itemstack, (EnumDirection) null); + ItemStack itemstack1 = addItem(iinventory, iinventory1, itemstack, (EnumDirection) null); diff --git a/nms-patches/TileEntityPiston.patch b/nms-patches/TileEntityPiston.patch deleted file mode 100644 index b7f7c9014c..0000000000 --- a/nms-patches/TileEntityPiston.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/net/minecraft/server/TileEntityPiston.java -+++ b/net/minecraft/server/TileEntityPiston.java -@@ -133,6 +133,7 @@ - } - - public void E_() { -+ if (this.world == null) return; // CraftBukkit - this.j = this.i; - if (this.j >= 1.0F) { - this.j(); diff --git a/nms-patches/TileEntityShulkerBox.patch b/nms-patches/TileEntityShulkerBox.patch new file mode 100644 index 0000000000..6af5516b9d --- /dev/null +++ b/nms-patches/TileEntityShulkerBox.patch @@ -0,0 +1,54 @@ +--- a/net/minecraft/server/TileEntityShulkerBox.java ++++ b/net/minecraft/server/TileEntityShulkerBox.java +@@ -3,6 +3,10 @@ + import java.util.Iterator; + import java.util.List; + import javax.annotation.Nullable; ++// CraftBukkit start ++import org.bukkit.craftbukkit.entity.CraftHumanEntity; ++import org.bukkit.entity.HumanEntity; ++// CraftBukkit end + + public class TileEntityShulkerBox extends TileEntityLootable implements ITickable, IWorldInventory { + +@@ -16,6 +20,31 @@ + private EnumColor l; + private boolean p; + ++ // CraftBukkit start - add fields and methods ++ public List transaction = new java.util.ArrayList(); ++ private int maxStack = MAX_STACK; ++ ++ public List getContents() { ++ return this.f; ++ } ++ ++ public void onOpen(CraftHumanEntity who) { ++ transaction.add(who); ++ } ++ ++ public void onClose(CraftHumanEntity who) { ++ transaction.remove(who); ++ } ++ ++ public List getViewers() { ++ return transaction; ++ } ++ ++ public void setMaxStackSize(int size) { ++ maxStack = size; ++ } ++ // CraftBukkit end ++ + public TileEntityShulkerBox() { + this((EnumColor) null); + } +@@ -144,7 +173,7 @@ + } + + public int getMaxStackSize() { +- return 64; ++ return maxStack; // CraftBukkit + } + + public boolean c(int i, int j) { diff --git a/nms-patches/TileEntitySign.patch b/nms-patches/TileEntitySign.patch index de4c416452..ec5bfd9ea4 100644 --- a/nms-patches/TileEntitySign.patch +++ b/nms-patches/TileEntitySign.patch @@ -56,10 +56,10 @@ ChatClickable chatclickable = chatmodifier.h(); if (chatclickable.a() == ChatClickable.EnumClickAction.RUN_COMMAND) { -- entityhuman.h().getCommandHandler().a(icommandlistener, chatclickable.b()); +- entityhuman.B_().getCommandHandler().a(icommandlistener, chatclickable.b()); + // CraftBukkit start -+ // entityhuman.h().getCommandHandler().a(icommandlistener, chatclickable.b()); -+ CommandBlockListenerAbstract.executeCommand(icommandlistener, new org.bukkit.craftbukkit.command.ProxiedNativeCommandSender( ++ // entityhuman.B_().getCommandHandler().a(icommandlistener, chatclickable.b()); ++ CommandBlockListenerAbstract.executeSafely(icommandlistener, new org.bukkit.craftbukkit.command.ProxiedNativeCommandSender( + icommandlistener, + new org.bukkit.craftbukkit.command.CraftBlockCommandSender(icommandlistener), + entityhuman.getBukkitEntity() diff --git a/nms-patches/Village.patch b/nms-patches/Village.patch index ca9591e2b0..a142c50abd 100644 --- a/nms-patches/Village.patch +++ b/nms-patches/Village.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/Village.java +++ b/net/minecraft/server/Village.java -@@ -62,7 +62,7 @@ +@@ -64,7 +64,7 @@ EntityIronGolem entityirongolem = new EntityIronGolem(this.a); entityirongolem.setPosition(vec3d.x, vec3d.y, vec3d.z); diff --git a/nms-patches/VillageSiege.patch b/nms-patches/VillageSiege.patch index 811d9f73b2..626a008aa0 100644 --- a/nms-patches/VillageSiege.patch +++ b/nms-patches/VillageSiege.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/VillageSiege.java +++ b/net/minecraft/server/VillageSiege.java -@@ -141,7 +141,7 @@ +@@ -140,7 +140,7 @@ } entityzombie.setPositionRotation(vec3d.x, vec3d.y, vec3d.z, this.a.random.nextFloat() * 360.0F, 0.0F); diff --git a/nms-patches/World.patch b/nms-patches/World.patch index 23fffec4c4..6323047567 100644 --- a/nms-patches/World.patch +++ b/nms-patches/World.patch @@ -112,7 +112,7 @@ } public World b() { -@@ -202,6 +291,27 @@ +@@ -206,6 +295,27 @@ } public boolean setTypeAndData(BlockPosition blockposition, IBlockData iblockdata, int i) { @@ -140,7 +140,7 @@ if (this.E(blockposition)) { return false; } else if (!this.isClientSide && this.worldData.getType() == WorldType.DEBUG_ALL_BLOCK_STATES) { -@@ -209,9 +319,23 @@ +@@ -213,9 +323,23 @@ } else { Chunk chunk = this.getChunkAtWorldCoords(blockposition); Block block = iblockdata.getBlock(); @@ -164,7 +164,7 @@ return false; } else { if (iblockdata.c() != iblockdata1.c() || iblockdata.d() != iblockdata1.d()) { -@@ -220,6 +344,7 @@ +@@ -224,6 +348,7 @@ this.methodProfiler.b(); } @@ -172,9 +172,9 @@ if ((i & 2) != 0 && (!this.isClientSide || (i & 4) == 0) && chunk.isReady()) { this.notify(blockposition, iblockdata1, iblockdata, i); } -@@ -230,12 +355,35 @@ - this.updateAdjacentComparators(blockposition, block); - } +@@ -236,12 +361,37 @@ + } else if (!this.isClientSide && (i & 16) == 0) { + this.c(blockposition, block); } + */ + @@ -190,17 +190,19 @@ } } -+ // CraftBukkit start - Split off from original setTypeAndData(int i, int j, int k, Block block, int l, int i1) method in order to directly send client and physic updates -+ public void notifyAndUpdatePhysics(BlockPosition blockposition, Chunk chunk, IBlockData oldBlock, IBlockData newBlock, int flag) { -+ if ((flag & 2) != 0 && (chunk == null || chunk.isReady())) { // allow chunk to be null here as chunk.isReady() is false when we send our notification during block placement -+ this.notify(blockposition, oldBlock, newBlock, flag); ++ // CraftBukkit start - Split off from above in order to directly send client and physic updates ++ public void notifyAndUpdatePhysics(BlockPosition blockposition, Chunk chunk, IBlockData oldBlock, IBlockData newBlock, int i) { ++ if ((i & 2) != 0 && (!this.isClientSide || (i & 4) == 0) && (chunk == null || chunk.isReady())) { // allow chunk to be null here as chunk.isReady() is false when we send our notification during block placement ++ this.notify(blockposition, oldBlock, newBlock, i); + } + -+ if (!this.isClientSide && (flag & 1) != 0) { -+ this.update(blockposition, oldBlock.getBlock()); -+ if (newBlock.n()) { ++ if (!this.isClientSide && (i & 1) != 0) { ++ this.update(blockposition, oldBlock.getBlock(), true); ++ if (newBlock.o()) { + this.updateAdjacentComparators(blockposition, newBlock.getBlock()); + } ++ } else if (!this.isClientSide && (i & 16) == 0) { ++ this.c(blockposition, newBlock.getBlock()); + } + } + // CraftBukkit end @@ -208,19 +210,19 @@ public boolean setAir(BlockPosition blockposition) { return this.setTypeAndData(blockposition, Blocks.AIR.getBlockData(), 3); } -@@ -269,6 +417,11 @@ +@@ -275,6 +425,11 @@ - public void update(BlockPosition blockposition, Block block) { + public void update(BlockPosition blockposition, Block block, boolean flag) { if (this.worldData.getType() != WorldType.DEBUG_ALL_BLOCK_STATES) { + // CraftBukkit start + if (populating) { + return; + } + // CraftBukkit end - this.applyPhysics(blockposition, block); + this.applyPhysics(blockposition, block, flag); } -@@ -344,6 +497,17 @@ +@@ -363,6 +518,17 @@ IBlockData iblockdata = this.getType(blockposition); try { @@ -235,10 +237,10 @@ + } + } + // CraftBukkit end - iblockdata.doPhysics(this, blockposition, block); + iblockdata.doPhysics(this, blockposition, block, blockposition1); } catch (Throwable throwable) { CrashReport crashreport = CrashReport.a(throwable, "Exception while updating neighbours"); -@@ -530,6 +694,17 @@ +@@ -580,6 +746,17 @@ } public IBlockData getType(BlockPosition blockposition) { @@ -256,7 +258,7 @@ if (this.E(blockposition)) { return Blocks.AIR.getBlockData(); } else { -@@ -728,6 +903,13 @@ +@@ -785,6 +962,13 @@ } public boolean addEntity(Entity entity) { @@ -270,7 +272,7 @@ int i = MathHelper.floor(entity.locX / 16.0D); int j = MathHelper.floor(entity.locZ / 16.0D); boolean flag = entity.attachedToPlayer; -@@ -736,6 +918,34 @@ +@@ -793,6 +977,34 @@ flag = true; } @@ -305,7 +307,7 @@ if (!flag && !this.isChunkLoaded(i, j, false)) { return false; } else { -@@ -758,6 +968,7 @@ +@@ -815,6 +1027,7 @@ ((IWorldAccess) this.u.get(i)).a(entity); } @@ -313,7 +315,7 @@ } protected void c(Entity entity) { -@@ -765,6 +976,7 @@ +@@ -822,6 +1035,7 @@ ((IWorldAccess) this.u.get(i)).b(entity); } @@ -321,7 +323,7 @@ } public void kill(Entity entity) { -@@ -800,7 +1012,15 @@ +@@ -857,7 +1071,15 @@ this.getChunkAt(i, j).b(entity); } @@ -338,7 +340,7 @@ this.c(entity); } -@@ -1048,6 +1268,11 @@ +@@ -1068,6 +1290,11 @@ for (i = 0; i < this.j.size(); ++i) { entity = (Entity) this.j.get(i); @@ -350,7 +352,7 @@ try { ++entity.ticksLived; -@@ -1096,8 +1321,10 @@ +@@ -1116,8 +1343,10 @@ CrashReportSystemDetails crashreportsystemdetails1; CrashReport crashreport1; @@ -363,7 +365,7 @@ Entity entity1 = entity.bB(); if (entity1 != null) { -@@ -1130,7 +1357,7 @@ +@@ -1150,7 +1379,7 @@ this.getChunkAt(j, l).b(entity); } @@ -372,7 +374,7 @@ this.c(entity); } -@@ -1139,6 +1366,13 @@ +@@ -1159,6 +1388,13 @@ this.methodProfiler.c("blockEntities"); this.M = true; @@ -386,16 +388,16 @@ Iterator iterator = this.tileEntityListTick.iterator(); while (iterator.hasNext()) { -@@ -1149,7 +1383,7 @@ +@@ -1169,7 +1405,7 @@ if (this.isLoaded(blockposition) && this.N.a(blockposition)) { try { - this.methodProfiler.a(tileentity.getClass().getSimpleName()); + this.methodProfiler.a(""/*tileentity.getClass().getSimpleName()*/); // CraftBukkit: SPIGOT-1900 - ((ITickable) tileentity).E_(); + ((ITickable) tileentity).F_(); this.methodProfiler.b(); } catch (Throwable throwable2) { -@@ -1171,11 +1405,13 @@ +@@ -1191,11 +1427,13 @@ } this.M = false; @@ -409,10 +411,10 @@ this.methodProfiler.c("pendingBlockEntities"); if (!this.b.isEmpty()) { -@@ -1183,9 +1419,11 @@ +@@ -1203,9 +1441,11 @@ TileEntity tileentity1 = (TileEntity) this.b.get(i1); - if (!tileentity1.x()) { + if (!tileentity1.y()) { + /* CraftBukkit start - Order matters, moved down if (!this.tileEntityList.contains(tileentity1)) { this.a(tileentity1); @@ -421,7 +423,7 @@ if (this.isLoaded(tileentity1.getPosition())) { Chunk chunk = this.getChunkAtWorldCoords(tileentity1.getPosition()); -@@ -1193,6 +1431,12 @@ +@@ -1213,6 +1453,12 @@ chunk.a(tileentity1.getPosition(), tileentity1); this.notify(tileentity1.getPosition(), iblockdata, iblockdata, 3); @@ -434,7 +436,7 @@ } } } -@@ -1247,7 +1491,10 @@ +@@ -1267,7 +1513,10 @@ int j = MathHelper.floor(entity.locZ); boolean flag1 = true; @@ -446,7 +448,7 @@ entity.M = entity.locX; entity.N = entity.locY; entity.O = entity.locZ; -@@ -1586,11 +1833,18 @@ +@@ -1571,11 +1820,18 @@ } } @@ -465,10 +467,10 @@ TileEntity tileentity = null; if (this.M) { -@@ -1625,6 +1879,14 @@ +@@ -1610,6 +1866,14 @@ public void setTileEntity(BlockPosition blockposition, @Nullable TileEntity tileentity) { if (!this.E(blockposition)) { - if (tileentity != null && !tileentity.x()) { + if (tileentity != null && !tileentity.y()) { + // CraftBukkit start + if (captureBlockStates) { + tileentity.a(this); @@ -480,7 +482,7 @@ if (this.M) { tileentity.setPosition(blockposition); Iterator iterator = this.b.iterator(); -@@ -1780,6 +2042,14 @@ +@@ -1769,6 +2033,14 @@ } this.o = MathHelper.a(this.o, 0.0F, 1.0F); @@ -495,7 +497,7 @@ } } } -@@ -1911,7 +2181,10 @@ +@@ -1900,7 +2172,10 @@ } public boolean c(EnumSkyBlock enumskyblock, BlockPosition blockposition) { @@ -507,7 +509,7 @@ return false; } else { int i = 0; -@@ -2078,7 +2351,7 @@ +@@ -2067,7 +2342,7 @@ while (iterator.hasNext()) { Entity entity = (Entity) iterator.next(); @@ -516,7 +518,7 @@ arraylist.add(entity); } } -@@ -2093,7 +2366,7 @@ +@@ -2082,7 +2357,7 @@ while (iterator.hasNext()) { Entity entity = (Entity) iterator.next(); @@ -525,7 +527,7 @@ arraylist.add(entity); } } -@@ -2142,7 +2415,7 @@ +@@ -2131,7 +2406,7 @@ } } @@ -534,7 +536,7 @@ } @Nullable -@@ -2163,8 +2436,17 @@ +@@ -2152,8 +2427,17 @@ while (iterator.hasNext()) { Entity entity = (Entity) iterator.next(); @@ -554,7 +556,7 @@ ++i; } } -@@ -2173,12 +2455,18 @@ +@@ -2162,12 +2446,18 @@ } public void a(Collection collection) { @@ -574,13 +576,13 @@ this.b(entity); } -@@ -2192,7 +2480,13 @@ +@@ -2181,7 +2471,13 @@ IBlockData iblockdata = this.getType(blockposition); - AxisAlignedBB axisalignedbb = flag ? null : block.getBlockData().d(this, blockposition); + AxisAlignedBB axisalignedbb = flag ? null : block.getBlockData().c(this, blockposition); -- return axisalignedbb != Block.k && !this.a(axisalignedbb.a(blockposition), entity) ? false : (iblockdata.getMaterial() == Material.ORIENTABLE && block == Blocks.ANVIL ? true : iblockdata.getMaterial().isReplaceable() && block.canPlace(this, blockposition, enumdirection, itemstack)); +- return axisalignedbb != Block.k && !this.a(axisalignedbb.a(blockposition), entity) ? false : (iblockdata.getMaterial() == Material.ORIENTABLE && block == Blocks.ANVIL ? true : iblockdata.getMaterial().isReplaceable() && block.canPlace(this, blockposition, enumdirection)); + // CraftBukkit start - store default return -+ boolean defaultReturn = axisalignedbb != Block.k && !this.a(axisalignedbb.a(blockposition), entity) ? false : (iblockdata.getMaterial() == Material.ORIENTABLE && block == Blocks.ANVIL ? true : iblockdata.getMaterial().isReplaceable() && block.canPlace(this, blockposition, enumdirection, itemstack)); ++ boolean defaultReturn = axisalignedbb != Block.k && !this.a(axisalignedbb.a(blockposition), entity) ? false : (iblockdata.getMaterial() == Material.ORIENTABLE && block == Blocks.ANVIL ? true : iblockdata.getMaterial().isReplaceable() && block.canPlace(this, blockposition, enumdirection)); + BlockCanBuildEvent event = new BlockCanBuildEvent(this.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), CraftMagicNumbers.getId(block), defaultReturn); + this.getServer().getPluginManager().callEvent(event); + @@ -589,7 +591,7 @@ } public int K() { -@@ -2295,6 +2589,11 @@ +@@ -2291,6 +2587,11 @@ for (int i = 0; i < this.players.size(); ++i) { EntityHuman entityhuman1 = (EntityHuman) this.players.get(i); @@ -599,9 +601,9 @@ + } + // CraftBukkit end - if ((IEntitySelector.d.apply(entityhuman1) || !flag) && (IEntitySelector.e.apply(entityhuman1) || flag)) { - double d5 = entityhuman1.e(d0, d1, d2); -@@ -2463,6 +2762,16 @@ + if (predicate.apply(entityhuman1)) { + double d5 = entityhuman1.d(d0, d1, d2); +@@ -2459,6 +2760,16 @@ public void everyoneSleeping() {} @@ -618,7 +620,7 @@ public float h(float f) { return (this.p + (this.q - this.p) * f) * this.j(f); } -@@ -2680,7 +2989,7 @@ +@@ -2676,7 +2987,7 @@ int l = j * 16 + 8 - blockposition.getZ(); boolean flag = true; diff --git a/nms-patches/WorldGenRegistration.patch b/nms-patches/WorldGenRegistration.patch index d4e747989f..cd4e2ca908 100644 --- a/nms-patches/WorldGenRegistration.patch +++ b/nms-patches/WorldGenRegistration.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/server/WorldGenRegistration.java +++ b/net/minecraft/server/WorldGenRegistration.java -@@ -158,7 +158,7 @@ - +@@ -157,7 +157,7 @@ + entitywitch.cS(); entitywitch.setPositionRotation((double) i + 0.5D, (double) j, (double) k + 0.5D, 0.0F, 0.0F); entitywitch.prepare(world.D(new BlockPosition(i, j, k)), (GroupDataEntity) null); - world.addEntity(entitywitch); diff --git a/nms-patches/WorldGenVillagePieces.patch b/nms-patches/WorldGenVillagePieces.patch index 021d1768a3..6f5ae761f8 100644 --- a/nms-patches/WorldGenVillagePieces.patch +++ b/nms-patches/WorldGenVillagePieces.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/WorldGenVillagePieces.java +++ b/net/minecraft/server/WorldGenVillagePieces.java -@@ -269,10 +269,10 @@ +@@ -238,10 +238,10 @@ protected void a(NBTTagCompound nbttagcompound) { super.a(nbttagcompound); @@ -14,8 +14,8 @@ + nbttagcompound.setInt("CD", Block.REGISTRY.a(this.d)); } - protected void b(NBTTagCompound nbttagcompound) { -@@ -402,8 +402,8 @@ + protected void a(NBTTagCompound nbttagcompound, DefinedStructureManager definedstructuremanager) { +@@ -371,8 +371,8 @@ protected void a(NBTTagCompound nbttagcompound) { super.a(nbttagcompound); @@ -25,19 +25,19 @@ + nbttagcompound.setInt("CB", Block.REGISTRY.a(this.b)); } - protected void b(NBTTagCompound nbttagcompound) { -@@ -1701,14 +1701,14 @@ - entityzombie.prepare(world.D(new BlockPosition(entityzombie)), (GroupDataEntity) null); - entityzombie.setVillagerType(EnumZombieType.b(this.c(i1, 0))); - entityzombie.cQ(); -- world.addEntity(entityzombie); -+ world.addEntity(entityzombie, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CHUNK_GEN); // CraftBukkit - add SpawnReason + protected void a(NBTTagCompound nbttagcompound, DefinedStructureManager definedstructuremanager) { +@@ -1672,14 +1672,14 @@ + entityzombievillager.prepare(world.D(new BlockPosition(entityzombievillager)), (GroupDataEntity) null); + entityzombievillager.setProfession(this.c(i1, 0)); + entityzombievillager.cS(); +- world.addEntity(entityzombievillager); ++ world.addEntity(entityzombievillager, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CHUNK_GEN); // CraftBukkit - add SpawnReason } else { EntityVillager entityvillager = new EntityVillager(world); entityvillager.setPositionRotation((double) j1 + 0.5D, (double) k1, (double) l1 + 0.5D, 0.0F, 0.0F); - entityvillager.prepare(world.D(new BlockPosition(entityvillager)), (GroupDataEntity) null); - entityvillager.setProfession(this.c(i1, entityvillager.getProfession())); + entityvillager.setProfession(this.c(i1, world.random.nextInt(6))); + entityvillager.a(world.D(new BlockPosition(entityvillager)), (GroupDataEntity) null, false); - world.addEntity(entityvillager); + world.addEntity(entityvillager, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CHUNK_GEN); // CraftBukkit - add SpawnReason } diff --git a/nms-patches/WorldManager.patch b/nms-patches/WorldManager.patch index 98623a14cb..e1861fd85a 100644 --- a/nms-patches/WorldManager.patch +++ b/nms-patches/WorldManager.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/WorldManager.java +++ b/net/minecraft/server/WorldManager.java -@@ -33,7 +33,8 @@ +@@ -35,7 +35,8 @@ } public void a(@Nullable EntityHuman entityhuman, SoundEffect soundeffect, SoundCategory soundcategory, double d0, double d1, double d2, float f, float f1) { @@ -10,7 +10,7 @@ } public void a(int i, int j, int k, int l, int i1, int j1) {} -@@ -47,7 +48,8 @@ +@@ -49,7 +50,8 @@ public void a(SoundEffect soundeffect, BlockPosition blockposition) {} public void a(EntityHuman entityhuman, int i, BlockPosition blockposition, int j) { @@ -20,7 +20,7 @@ } public void a(int i, BlockPosition blockposition, int j) { -@@ -57,6 +59,12 @@ +@@ -59,6 +61,12 @@ public void b(int i, BlockPosition blockposition, int j) { Iterator iterator = this.a.getPlayerList().v().iterator(); @@ -33,7 +33,7 @@ while (iterator.hasNext()) { EntityPlayer entityplayer = (EntityPlayer) iterator.next(); -@@ -65,6 +73,12 @@ +@@ -67,6 +75,12 @@ double d1 = (double) blockposition.getY() - entityplayer.locY; double d2 = (double) blockposition.getZ() - entityplayer.locZ; diff --git a/nms-patches/WorldMap.patch b/nms-patches/WorldMap.patch index 40d2af9552..5c8d8157c3 100644 --- a/nms-patches/WorldMap.patch +++ b/nms-patches/WorldMap.patch @@ -15,8 +15,8 @@ public class WorldMap extends PersistentBase { public int centerX; -@@ -19,8 +27,18 @@ - private final Map j = Maps.newHashMap(); +@@ -20,8 +28,18 @@ + private final Map k = Maps.newHashMap(); public Map decorations = Maps.newLinkedHashMap(); + // CraftBukkit start @@ -34,7 +34,7 @@ } public void a(double d0, double d1, int i) { -@@ -33,7 +51,30 @@ +@@ -34,7 +52,30 @@ } public void a(NBTTagCompound nbttagcompound) { @@ -66,7 +66,7 @@ this.centerX = nbttagcompound.getInt("xCenter"); this.centerZ = nbttagcompound.getInt("zCenter"); this.scale = nbttagcompound.getByte("scale"); -@@ -74,6 +115,25 @@ +@@ -76,6 +117,25 @@ } public NBTTagCompound b(NBTTagCompound nbttagcompound) { @@ -92,9 +92,9 @@ nbttagcompound.setByte("dimension", this.map); nbttagcompound.setInt("xCenter", this.centerX); nbttagcompound.setInt("zCenter", this.centerZ); -@@ -223,12 +283,26 @@ - } +@@ -265,12 +325,26 @@ + @Nullable public Packet a(ItemStack itemstack) { + // CraftBukkit start + org.bukkit.craftbukkit.map.RenderData render = WorldMap.this.mapView.render((org.bukkit.craftbukkit.entity.CraftPlayer) this.trackee.getBukkitEntity()); // CraftBukkit @@ -104,7 +104,7 @@ + for ( org.bukkit.map.MapCursor cursor : render.cursors) { + + if (cursor.isVisible()) { -+ icons.add(new MapIcon(cursor.getRawType(), cursor.getX(), cursor.getY(), cursor.getDirection())); ++ icons.add(new MapIcon(MapIcon.Type.a(cursor.getRawType()), cursor.getX(), cursor.getY(), cursor.getDirection())); + } + } + diff --git a/nms-patches/WorldNBTStorage.patch b/nms-patches/WorldNBTStorage.patch index 5195c15f1a..4f3b18e3b6 100644 --- a/nms-patches/WorldNBTStorage.patch +++ b/nms-patches/WorldNBTStorage.patch @@ -20,7 +20,7 @@ public WorldNBTStorage(File file, String s, boolean flag, DataConverterManager dataconvertermanager) { this.a = dataconvertermanager; -@@ -166,12 +172,38 @@ +@@ -167,12 +173,38 @@ } if (nbttagcompound != null) { @@ -59,7 +59,7 @@ public IPlayerFileData getPlayerFileData() { return this; } -@@ -201,4 +233,50 @@ +@@ -202,4 +234,50 @@ public DefinedStructureManager h() { return this.h; } diff --git a/nms-patches/WorldServer.patch b/nms-patches/WorldServer.patch index 1c5e7557db..f73bc578c6 100644 --- a/nms-patches/WorldServer.patch +++ b/nms-patches/WorldServer.patch @@ -54,7 +54,7 @@ + this.portalTravelAgent = new org.bukkit.craftbukkit.CraftTravelAgent(this); // CraftBukkit this.H(); this.I(); - this.getWorldBorder().a(minecraftserver.aD()); + this.getWorldBorder().a(minecraftserver.aE()); @@ -64,6 +84,7 @@ this.villages.a((World) this); } @@ -207,7 +207,7 @@ ++j; } } -@@ -190,25 +309,46 @@ +@@ -193,25 +312,46 @@ } private void c() { @@ -258,16 +258,16 @@ return false; } else { -@@ -279,7 +419,7 @@ - entityhorse.y(true); - entityhorse.setAgeRaw(0); - entityhorse.setPosition((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ()); -- this.addEntity(entityhorse); -+ this.addEntity(entityhorse, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING); // CraftBukkit +@@ -281,7 +421,7 @@ + entityhorseskeleton.p(true); + entityhorseskeleton.setAgeRaw(0); + entityhorseskeleton.setPosition((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ()); +- this.addEntity(entityhorseskeleton); ++ this.addEntity(entityhorseskeleton, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING); // CraftBukkit this.strikeLightning(new EntityLightning(this, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), true)); } else { this.strikeLightning(new EntityLightning(this, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), false)); -@@ -295,11 +435,29 @@ +@@ -297,11 +437,29 @@ BlockPosition blockposition1 = blockposition.down(); if (this.v(blockposition1)) { @@ -299,7 +299,7 @@ } if (flag && this.getBiome(blockposition1).d()) { -@@ -374,7 +532,7 @@ +@@ -376,7 +534,7 @@ public boolean b(BlockPosition blockposition, Block block) { NextTickListEntry nextticklistentry = new NextTickListEntry(blockposition, block); @@ -308,7 +308,7 @@ } public void a(BlockPosition blockposition, Block block, int i) { -@@ -413,8 +571,8 @@ +@@ -415,8 +573,8 @@ nextticklistentry.a(j); } @@ -319,7 +319,7 @@ this.nextTickList.add(nextticklistentry); } } -@@ -436,15 +594,15 @@ +@@ -438,15 +596,15 @@ nextticklistentry.a((long) i + this.worldData.getTime()); } @@ -338,7 +338,7 @@ if (this.emptyTime++ >= 300) { return; } -@@ -514,11 +672,17 @@ +@@ -516,11 +674,17 @@ } else { int i = this.nextTickList.size(); @@ -358,7 +358,7 @@ } this.methodProfiler.a("cleaning"); -@@ -531,8 +695,9 @@ +@@ -533,8 +697,9 @@ break; } @@ -369,7 +369,7 @@ this.U.add(nextticklistentry); } -@@ -602,7 +767,7 @@ +@@ -604,7 +769,7 @@ if (blockposition.getX() >= structureboundingbox.a && blockposition.getX() < structureboundingbox.d && blockposition.getZ() >= structureboundingbox.c && blockposition.getZ() < structureboundingbox.f) { if (flag) { if (i == 0) { @@ -378,7 +378,7 @@ } iterator.remove(); -@@ -620,6 +785,7 @@ +@@ -622,6 +787,7 @@ return arraylist; } @@ -386,7 +386,7 @@ public void entityJoinedWorld(Entity entity, boolean flag) { if (!this.getSpawnAnimals() && (entity instanceof EntityAnimal || entity instanceof EntityWaterAnimal)) { entity.die(); -@@ -631,6 +797,7 @@ +@@ -633,6 +799,7 @@ super.entityJoinedWorld(entity, flag); } @@ -394,7 +394,7 @@ private boolean getSpawnNPCs() { return this.server.getSpawnNPCs(); -@@ -643,7 +810,54 @@ +@@ -645,7 +812,54 @@ protected IChunkProvider n() { IChunkLoader ichunkloader = this.dataManager.createChunkLoader(this.worldProvider); @@ -450,7 +450,7 @@ } public boolean a(EntityHuman entityhuman, BlockPosition blockposition) { -@@ -705,6 +919,23 @@ +@@ -707,6 +921,23 @@ int j = this.worldProvider.getSeaLevel(); int k = 8; @@ -474,7 +474,7 @@ if (blockposition != null) { i = blockposition.getX(); k = blockposition.getZ(); -@@ -714,7 +945,7 @@ +@@ -716,7 +947,7 @@ int l = 0; @@ -483,7 +483,7 @@ i += random.nextInt(64) - random.nextInt(64); k += random.nextInt(64) - random.nextInt(64); ++l; -@@ -755,6 +986,7 @@ +@@ -758,6 +989,7 @@ ChunkProviderServer chunkproviderserver = this.getChunkProviderServer(); if (chunkproviderserver.e()) { @@ -491,7 +491,7 @@ if (iprogressupdate != null) { iprogressupdate.a("Saving level"); } -@@ -765,7 +997,8 @@ +@@ -768,7 +1000,8 @@ } chunkproviderserver.a(flag); @@ -501,7 +501,7 @@ Iterator iterator = arraylist.iterator(); while (iterator.hasNext()) { -@@ -800,6 +1033,12 @@ +@@ -803,6 +1036,12 @@ } } @@ -514,7 +514,7 @@ this.worldData.a(this.getWorldBorder().getSize()); this.worldData.d(this.getWorldBorder().getCenterX()); this.worldData.c(this.getWorldBorder().getCenterZ()); -@@ -813,9 +1052,13 @@ +@@ -816,9 +1055,13 @@ this.worldMaps.a(); } @@ -530,25 +530,25 @@ public void a(Collection collection) { ArrayList arraylist = Lists.newArrayList(collection); -@@ -834,7 +1077,7 @@ +@@ -837,7 +1080,7 @@ private boolean i(Entity entity) { if (entity.dead) { -- WorldServer.a.warn("Tried to add entity {} but it was marked as removed already", new Object[] { EntityTypes.b(entity)}); -+ // WorldServer.a.warn("Tried to add entity {} but it was marked as removed already", new Object[] { EntityTypes.b(entity)}); // CraftBukkit +- WorldServer.a.warn("Tried to add entity {} but it was marked as removed already", new Object[] { EntityTypes.a(entity)}); ++ // WorldServer.a.warn("Tried to add entity {} but it was marked as removed already", new Object[] { EntityTypes.a(entity)}); // CraftBukkit return false; } else { UUID uuid = entity.getUniqueID(); -@@ -846,7 +1089,7 @@ +@@ -849,7 +1092,7 @@ this.f.remove(entity1); } else { if (!(entity instanceof EntityHuman)) { -- WorldServer.a.warn("Keeping entity {} that already exists with UUID {}", new Object[] { EntityTypes.b(entity1), uuid.toString()}); -+ // WorldServer.a.warn("Keeping entity {} that already exists with UUID {}", new Object[] { EntityTypes.b(entity1), uuid.toString()}); // CraftBukkit +- WorldServer.a.warn("Keeping entity {} that already exists with UUID {}", new Object[] { EntityTypes.a(entity1), uuid.toString()}); ++ // WorldServer.a.warn("Keeping entity {} that already exists with UUID {}", new Object[] { EntityTypes.a(entity1), uuid.toString()}); // CraftBukkit return false; } -@@ -899,8 +1142,16 @@ +@@ -902,8 +1145,16 @@ } public boolean strikeLightning(Entity entity) { @@ -566,7 +566,7 @@ return true; } else { return false; -@@ -916,10 +1167,20 @@ +@@ -919,10 +1170,20 @@ } public Explosion createExplosion(@Nullable Entity entity, double d0, double d1, double d2, float f, boolean flag, boolean flag1) { @@ -587,7 +587,7 @@ if (!flag1) { explosion.clearBlocks(); } -@@ -965,7 +1226,8 @@ +@@ -968,7 +1229,8 @@ BlockActionData blockactiondata = (BlockActionData) iterator.next(); if (this.a(blockactiondata)) { @@ -597,7 +597,7 @@ } } -@@ -988,6 +1250,7 @@ +@@ -991,6 +1253,7 @@ boolean flag = this.W(); super.t(); @@ -605,7 +605,7 @@ if (this.n != this.o) { this.server.getPlayerList().a((Packet) (new PacketPlayOutGameStateChange(7, this.o)), this.worldProvider.getDimensionManager().getDimensionID()); } -@@ -1006,6 +1269,21 @@ +@@ -1009,6 +1272,21 @@ this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(7, this.o)); this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(8, this.q)); } @@ -627,7 +627,7 @@ } -@@ -1035,10 +1313,20 @@ +@@ -1038,10 +1316,20 @@ } public void a(EnumParticle enumparticle, boolean flag, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6, int... aint) { diff --git a/pom.xml b/pom.xml index c868c79eb8..06ebffa2db 100644 --- a/pom.xml +++ b/pom.xml @@ -4,17 +4,18 @@ org.bukkit craftbukkit jar - 1.10.2-R0.1-SNAPSHOT + 1.11-R0.1-SNAPSHOT CraftBukkit http://www.bukkit.org UTF-8 unknown - 1.10.2 - 1_10_R1 + 1.11 + 1_11_R1 git-Bukkit- + yyyyMMdd-HHmm 1.6 1.6 @@ -41,19 +42,19 @@ jline jline - 2.12 + 2.12.1 compile org.xerial sqlite-jdbc - 3.7.2 + 3.14.2.1 compile mysql mysql-connector-java - 5.1.37 + 5.1.39 compile @@ -101,14 +102,14 @@ org.apache.maven.plugins maven-jar-plugin - 2.6 + 3.0.2 org.bukkit.craftbukkit.Main CraftBukkit ${describe} - Bukkit Team + ${maven.build.timestamp} Bukkit ${api.version} Bukkit Team @@ -139,7 +140,7 @@ org.codehaus.mojo animal-sniffer-maven-plugin - 1.14 + 1.15 process-classes @@ -159,7 +160,7 @@ org.apache.maven.plugins maven-shade-plugin - 2.4.1 + 2.4.3 package @@ -196,6 +197,11 @@ net.minecraft.server.v${minecraft_version} + + + META-INF/services/java.sql.Driver + + @@ -223,7 +229,7 @@ org.apache.maven.plugins maven-surefire-plugin - 2.19 + 2.19.1 ${basedir}/target/test-server diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java index 53db00bf30..fe677569f4 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -1163,11 +1163,6 @@ public final class CraftServer implements Server { return console.isHardcore(); } - @Override - public boolean useExactLoginLocation() { - return configuration.getBoolean("settings.use-exact-login-location"); - } - public ChunkGenerator getGenerator(String world) { ConfigurationSection section = configuration.getConfigurationSection("worlds"); ChunkGenerator result = null; diff --git a/src/main/java/org/bukkit/craftbukkit/CraftSound.java b/src/main/java/org/bukkit/craftbukkit/CraftSound.java index 8eb3945d5d..82ab649113 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftSound.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftSound.java @@ -94,6 +94,8 @@ public enum CraftSound { BLOCK_SAND_HIT("block.sand.hit"), BLOCK_SAND_PLACE("block.sand.place"), BLOCK_SAND_STEP("block.sand.step"), + BLOCK_SHULKER_BOX_CLOSE("block.shulker_box.close"), + BLOCK_SHULKER_BOX_OPEN("block.shulker_box.open"), BLOCK_SLIME_BREAK("block.slime.break"), BLOCK_SLIME_FALL("block.slime.fall"), BLOCK_SLIME_HIT("block.slime.hit"), @@ -182,6 +184,7 @@ public enum CraftSound { ENTITY_ELDER_GUARDIAN_CURSE("entity.elder_guardian.curse"), ENTITY_ELDER_GUARDIAN_DEATH("entity.elder_guardian.death"), ENTITY_ELDER_GUARDIAN_DEATH_LAND("entity.elder_guardian.death_land"), + ENTITY_ELDER_GUARDIAN_FLOP("entity.elder_guardian.flop"), ENTITY_ELDER_GUARDIAN_HURT("entity.elder_guardian.hurt"), ENTITY_ELDER_GUARDIAN_HURT_LAND("entity.elder_guardian.hurt_land"), ENTITY_ENDERDRAGON_AMBIENT("entity.enderdragon.ambient"), @@ -203,9 +206,16 @@ public enum CraftSound { ENTITY_ENDERMITE_HURT("entity.endermite.hurt"), ENTITY_ENDERMITE_STEP("entity.endermite.step"), ENTITY_ENDERPEARL_THROW("entity.enderpearl.throw"), + ENTITY_EVOCATION_FANGS_ATTACK("entity.evocation_fangs.attack"), + ENTITY_EVOCATION_ILLAGER_AMBIENT("entity.evocation_illager.ambient"), + ENTITY_EVOCATION_ILLAGER_CAST_SPELL("entity.evocation_illager.cast_spell"), + ENTITY_EVOCATION_ILLAGER_DEATH("entity.evocation_illager.death"), + ENTITY_EVOCATION_ILLAGER_HURT("entity.evocation_illager.hurt"), + ENTITY_EVOCATION_ILLAGER_PREPARE_ATTACK("entity.evocation_illager.prepare_attack"), + ENTITY_EVOCATION_ILLAGER_PREPARE_SUMMON("entity.evocation_illager.prepare_summon"), + ENTITY_EVOCATION_ILLAGER_PREPARE_WOLOLO("entity.evocation_illager.prepare_wololo"), ENTITY_EXPERIENCE_BOTTLE_THROW("entity.experience_bottle.throw"), ENTITY_EXPERIENCE_ORB_PICKUP("entity.experience_orb.pickup"), - ENTITY_EXPERIENCE_ORB_TOUCH("entity.experience_orb.touch"), ENTITY_FIREWORK_BLAST("entity.firework.blast"), ENTITY_FIREWORK_BLAST_FAR("entity.firework.blast_far"), ENTITY_FIREWORK_LARGE_BLAST("entity.firework.large_blast"), @@ -278,6 +288,15 @@ public enum CraftSound { ENTITY_LIGHTNING_IMPACT("entity.lightning.impact"), ENTITY_LIGHTNING_THUNDER("entity.lightning.thunder"), ENTITY_LINGERINGPOTION_THROW("entity.lingeringpotion.throw"), + ENTITY_LLAMA_AMBIENT("entity.llama.ambient"), + ENTITY_LLAMA_ANGRY("entity.llama.angry"), + ENTITY_LLAMA_CHEST("entity.llama.chest"), + ENTITY_LLAMA_DEATH("entity.llama.death"), + ENTITY_LLAMA_EAT("entity.llama.eat"), + ENTITY_LLAMA_HURT("entity.llama.hurt"), + ENTITY_LLAMA_SPIT("entity.llama.spit"), + ENTITY_LLAMA_STEP("entity.llama.step"), + ENTITY_LLAMA_SWAG("entity.llama.swag"), ENTITY_MAGMACUBE_DEATH("entity.magmacube.death"), ENTITY_MAGMACUBE_HURT("entity.magmacube.hurt"), ENTITY_MAGMACUBE_JUMP("entity.magmacube.jump"), @@ -286,6 +305,7 @@ public enum CraftSound { ENTITY_MINECART_RIDING("entity.minecart.riding"), ENTITY_MOOSHROOM_SHEAR("entity.mooshroom.shear"), ENTITY_MULE_AMBIENT("entity.mule.ambient"), + ENTITY_MULE_CHEST("entity.mule.chest"), ENTITY_MULE_DEATH("entity.mule.death"), ENTITY_MULE_HURT("entity.mule.hurt"), ENTITY_PAINTING_BREAK("entity.painting.break"), @@ -379,12 +399,19 @@ public enum CraftSound { ENTITY_STRAY_HURT("entity.stray.hurt"), ENTITY_STRAY_STEP("entity.stray.step"), ENTITY_TNT_PRIMED("entity.tnt.primed"), + ENTITY_VEX_AMBIENT("entity.vex.ambient"), + ENTITY_VEX_CHARGE("entity.vex.charge"), + ENTITY_VEX_DEATH("entity.vex.death"), + ENTITY_VEX_HURT("entity.vex.hurt"), ENTITY_VILLAGER_AMBIENT("entity.villager.ambient"), ENTITY_VILLAGER_DEATH("entity.villager.death"), ENTITY_VILLAGER_HURT("entity.villager.hurt"), ENTITY_VILLAGER_NO("entity.villager.no"), ENTITY_VILLAGER_TRADING("entity.villager.trading"), ENTITY_VILLAGER_YES("entity.villager.yes"), + ENTITY_VINDICATION_ILLAGER_AMBIENT("entity.vindication_illager.ambient"), + ENTITY_VINDICATION_ILLAGER_DEATH("entity.vindication_illager.death"), + ENTITY_VINDICATION_ILLAGER_HURT("entity.vindication_illager.hurt"), ENTITY_WITCH_AMBIENT("entity.witch.ambient"), ENTITY_WITCH_DEATH("entity.witch.death"), ENTITY_WITCH_DRINK("entity.witch.drink"), @@ -432,10 +459,12 @@ public enum CraftSound { ENTITY_ZOMBIE_VILLAGER_STEP("entity.zombie_villager.step"), ITEM_ARMOR_EQUIP_CHAIN("item.armor.equip_chain"), ITEM_ARMOR_EQUIP_DIAMOND("item.armor.equip_diamond"), + ITEM_ARMOR_EQUIP_ELYTRA("item.armor.equip_elytra"), ITEM_ARMOR_EQUIP_GENERIC("item.armor.equip_generic"), ITEM_ARMOR_EQUIP_GOLD("item.armor.equip_gold"), ITEM_ARMOR_EQUIP_IRON("item.armor.equip_iron"), ITEM_ARMOR_EQUIP_LEATHER("item.armor.equip_leather"), + ITEM_BOTTLE_EMPTY("item.bottle.empty"), ITEM_BOTTLE_FILL("item.bottle.fill"), ITEM_BOTTLE_FILL_DRAGONBREATH("item.bottle.fill_dragonbreath"), ITEM_BUCKET_EMPTY("item.bucket.empty"), @@ -450,6 +479,7 @@ public enum CraftSound { ITEM_SHIELD_BLOCK("item.shield.block"), ITEM_SHIELD_BREAK("item.shield.break"), ITEM_SHOVEL_FLATTEN("item.shovel.flatten"), + ITEM_TOTEM_USE("item.totem.use"), MUSIC_CREATIVE("music.creative"), MUSIC_CREDITS("music.credits"), MUSIC_DRAGON("music.dragon"), diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index 3f62540d49..ae0cc72b29 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -930,6 +930,9 @@ public class CraftWorld implements World { } else if (ShulkerBullet.class.isAssignableFrom(clazz)) { entity = new EntityShulkerBullet(world); entity.setPositionRotation(x, y, z, yaw, pitch); + } else if (LlamaSpit.class.isAssignableFrom(clazz)) { + entity = new EntityLlama(world); + entity.setPositionRotation(x, y, z, yaw, pitch); } } else if (Minecart.class.isAssignableFrom(clazz)) { if (PoweredMinecart.class.isAssignableFrom(clazz)) { @@ -979,10 +982,30 @@ public class CraftWorld implements World { // need a net server handler for this one } else if (Sheep.class.isAssignableFrom(clazz)) { entity = new EntitySheep(world); - } else if (Horse.class.isAssignableFrom(clazz)) { - entity = new EntityHorse(world); + } else if (AbstractHorse.class.isAssignableFrom(clazz)) { + if (ChestedHorse.class.isAssignableFrom(clazz)) { + if (Donkey.class.isAssignableFrom(clazz)) { + entity = new EntityHorseDonkey(world); + } else if (Mule.class.isAssignableFrom(clazz)) { + entity = new EntityHorseMule(world); + } else if (Llama.class.isAssignableFrom(clazz)) { + entity = new EntityLlama(world); + } + } else if (SkeletonHorse.class.isAssignableFrom(clazz)) { + entity = new EntityHorseSkeleton(world); + } else if (ZombieHorse.class.isAssignableFrom(clazz)) { + entity = new EntityHorseZombie(world); + } else { + entity = new EntityHorse(world); + } } else if (Skeleton.class.isAssignableFrom(clazz)) { - entity = new EntitySkeleton(world); + if (Stray.class.isAssignableFrom(clazz)){ + entity = new EntitySkeletonStray(world); + } else if (WitherSkeleton.class.isAssignableFrom(clazz)) { + entity = new EntitySkeletonWither(world); + } else { + entity = new EntitySkeleton(world); + } } else if (Slime.class.isAssignableFrom(clazz)) { if (MagmaCube.class.isAssignableFrom(clazz)) { entity = new EntityMagmaCube(world); @@ -1006,7 +1029,13 @@ public class CraftWorld implements World { } else if (PigZombie.class.isAssignableFrom(clazz)) { entity = new EntityPigZombie(world); } else if (Zombie.class.isAssignableFrom(clazz)) { - entity = new EntityZombie(world); + if (Husk.class.isAssignableFrom(clazz)) { + entity = new EntityZombieHusk(world); + } else if (ZombieVillager.class.isAssignableFrom(clazz)) { + entity = new EntityZombieVillager(world); + } else { + entity = new EntityZombie(world); + } } else if (Giant.class.isAssignableFrom(clazz)) { entity = new EntityGiantZombie(world); } else if (Silverfish.class.isAssignableFrom(clazz)) { @@ -1034,11 +1063,21 @@ public class CraftWorld implements World { } else if (Endermite.class.isAssignableFrom(clazz)) { entity = new EntityEndermite(world); } else if (Guardian.class.isAssignableFrom(clazz)) { - entity = new EntityGuardian(world); + if (ElderGuardian.class.isAssignableFrom(clazz)){ + entity = new EntityGuardianElder(world); + } else { + entity = new EntityGuardian(world); + } } else if (ArmorStand.class.isAssignableFrom(clazz)) { entity = new EntityArmorStand(world, x, y, z); } else if (PolarBear.class.isAssignableFrom(clazz)) { entity = new EntityPolarBear(world); + } else if (Evoker.class.isAssignableFrom(clazz)) { + entity = new EntityEvoker(world); + } else if (Vex.class.isAssignableFrom(clazz)) { + entity = new EntityVex(world); + } else if (Vindicator.class.isAssignableFrom(clazz)) { + entity = new EntityVindicator(world); } if (entity != null) { @@ -1113,6 +1152,8 @@ public class CraftWorld implements World { entity = new EntityFireworks(world, x, y, z, null); } else if (AreaEffectCloud.class.isAssignableFrom(clazz)) { entity = new EntityAreaEffectCloud(world, x, y, z); + } else if (EvokerFangs.class.isAssignableFrom(clazz)) { + entity = new EntityEvokerFangs(world); } if (entity != null) { diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java index 4e642b7785..86218a5a03 100644 --- a/src/main/java/org/bukkit/craftbukkit/Main.java +++ b/src/main/java/org/bukkit/craftbukkit/Main.java @@ -4,7 +4,11 @@ import java.io.File; import java.io.IOException; import java.text.SimpleDateFormat; import java.util.Arrays; +import java.util.Calendar; +import java.util.Date; import java.util.List; +import java.util.TimeZone; +import java.util.concurrent.TimeUnit; import java.util.logging.Level; import java.util.logging.Logger; import joptsimple.OptionParser; @@ -165,6 +169,19 @@ public class Main { useConsole = false; } + if (Main.class.getPackage().getImplementationVendor() != null && System.getProperty("IReallyKnowWhatIAmDoingISwear") == null) { + Date buildDate = new SimpleDateFormat("yyyyMMdd-HHmm").parse(Main.class.getPackage().getImplementationVendor()); + + Calendar deadline = Calendar.getInstance(); + deadline.add(Calendar.DAY_OF_YEAR, -3); + if (buildDate.before(deadline.getTime())) { + System.err.println("*** Error, this build is outdated ***"); + System.err.println("*** Please download a new build as per instructions from https://www.spigotmc.org/ ***"); + System.err.println("*** Server will start in 30 seconds ***"); + Thread.sleep(TimeUnit.SECONDS.toMillis(30)); + } + } + System.out.println("Loading libraries, please wait..."); MinecraftServer.main(options); } catch (Throwable t) { diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBanner.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBanner.java index fb706206bc..b769af0891 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBanner.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBanner.java @@ -2,6 +2,7 @@ package org.bukkit.craftbukkit.block; import java.util.ArrayList; import java.util.List; +import net.minecraft.server.EnumColor; import net.minecraft.server.NBTTagCompound; import net.minecraft.server.NBTTagList; import net.minecraft.server.TileEntityBanner; @@ -25,7 +26,7 @@ public class CraftBanner extends CraftBlockState implements Banner { CraftWorld world = (CraftWorld) block.getWorld(); banner = (TileEntityBanner) world.getTileEntityAt(getX(), getY(), getZ()); - base = DyeColor.getByDyeData((byte) banner.color); + base = DyeColor.getByDyeData((byte) banner.color.getColorIndex()); if (banner.patterns != null) { for (int i = 0; i < banner.patterns.size(); i++) { @@ -39,7 +40,7 @@ public class CraftBanner extends CraftBlockState implements Banner { super(material); banner = te; - base = DyeColor.getByDyeData((byte) banner.color); + base = DyeColor.getByDyeData((byte) banner.color.getColorIndex()); if (banner.patterns != null) { for (int i = 0; i < banner.patterns.size(); i++) { @@ -99,7 +100,7 @@ public class CraftBanner extends CraftBlockState implements Banner { boolean result = (isPlaced()) ? super.update(force, applyPhysics) : true; if (result) { - banner.color = base.getDyeData(); + banner.color = EnumColor.fromColorIndex(base.getDyeData()); NBTTagList newPatterns = new NBTTagList(); diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java index d70f26163f..7dc2978e19 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java @@ -66,7 +66,7 @@ public class CraftBeacon extends CraftContainer implements Beacon { @Override public int getTier() { - return beacon.k; + return beacon.levels; } @Override @@ -76,7 +76,7 @@ public class CraftBeacon extends CraftContainer implements Beacon { @Override public void setPrimaryEffect(PotionEffectType effect) { - beacon.l = (effect != null) ? MobEffectList.fromId(effect.getId()) : null; + beacon.primaryEffect = (effect != null) ? MobEffectList.fromId(effect.getId()) : null; } @Override @@ -86,6 +86,6 @@ public class CraftBeacon extends CraftContainer implements Beacon { @Override public void setSecondaryEffect(PotionEffectType effect) { - beacon.m = (effect != null) ? MobEffectList.fromId(effect.getId()) : null; + beacon.secondaryEffect = (effect != null) ? MobEffectList.fromId(effect.getId()) : null; } } diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java index 89b23e298e..0374578f1c 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java @@ -145,7 +145,7 @@ public class CraftBlock implements Block { return chunk.getHandle().getWorld().setTypeAndData(position, blockData, 3); } else { IBlockData old = chunk.getHandle().getBlockData(position); - boolean success = chunk.getHandle().getWorld().setTypeAndData(position, blockData, 2); + boolean success = chunk.getHandle().getWorld().setTypeAndData(position, blockData, 18); // NOTIFY | NO_OBSERVER if (success) { chunk.getHandle().getWorld().notify( position, @@ -173,11 +173,11 @@ public class CraftBlock implements Block { } public byte getLightFromSky() { - return (byte) chunk.getHandle().getWorld().b(EnumSkyBlock.SKY, new BlockPosition(this.x, this.y, this.z)); // PAIL: rename + return (byte) chunk.getHandle().getWorld().getBrightness(EnumSkyBlock.SKY, new BlockPosition(this.x, this.y, this.z)); } public byte getLightFromBlocks() { - return (byte) chunk.getHandle().getWorld().b(EnumSkyBlock.BLOCK, new BlockPosition(this.x, this.y, this.z)); // PAIL: rename + return (byte) chunk.getHandle().getWorld().getBrightness(EnumSkyBlock.BLOCK, new BlockPosition(this.x, this.y, this.z)); } @@ -306,6 +306,23 @@ public class CraftBlock implements Block { return new CraftFlowerPot(this); case STRUCTURE_BLOCK: return new CraftStructureBlock(this); + case WHITE_SHULKER_BOX: + case ORANGE_SHULKER_BOX: + case MAGENTA_SHULKER_BOX: + case LIGHT_BLUE_SHULKER_BOX: + case YELLOW_SHULKER_BOX: + case LIME_SHULKER_BOX: + case PINK_SHULKER_BOX: + case GRAY_SHULKER_BOX: + case SILVER_SHULKER_BOX: + case CYAN_SHULKER_BOX: + case PURPLE_SHULKER_BOX: + case BLUE_SHULKER_BOX: + case BROWN_SHULKER_BOX: + case GREEN_SHULKER_BOX: + case RED_SHULKER_BOX: + case BLACK_SHULKER_BOX: + return new CraftShulkerBox(this); default: return new CraftBlockState(this); } diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java index 80ada02d37..09fddf4ac4 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java @@ -172,7 +172,7 @@ public class CraftBlockState implements BlockState { // Update levers etc if (applyPhysics && getData() instanceof Attachable) { - world.getHandle().applyPhysics(pos.shift(CraftBlock.blockFaceToNotch(((Attachable) getData()).getAttachedFace())), newBlock.getBlock()); + world.getHandle().applyPhysics(pos.shift(CraftBlock.blockFaceToNotch(((Attachable) getData()).getAttachedFace())), newBlock.getBlock(), false); } return true; diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftContainer.java b/src/main/java/org/bukkit/craftbukkit/block/CraftContainer.java index adf15651cd..421bc972dd 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftContainer.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftContainer.java @@ -26,12 +26,12 @@ public class CraftContainer extends CraftBlockState implements Lockable { @Override public boolean isLocked() { - return container.x_(); // PAIL: isLocked + return container.isLocked(); } @Override public String getLock() { - return container.y_().b(); // PAIL: getLock, getKey + return container.getLock().b(); // PAIL: getKey } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java b/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java index 2472dc6674..a5fec06b83 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java @@ -1,5 +1,6 @@ package org.bukkit.craftbukkit.block; +import net.minecraft.server.MinecraftKey; import net.minecraft.server.TileEntityMobSpawner; import org.bukkit.Material; @@ -23,7 +24,7 @@ public class CraftCreatureSpawner extends CraftBlockState implements CreatureSpa } public EntityType getSpawnedType() { - return EntityType.fromName(spawner.getSpawner().getMobName()); + return EntityType.fromName(spawner.getSpawner().getMobName().a()); } public void setSpawnedType(EntityType entityType) { @@ -31,21 +32,11 @@ public class CraftCreatureSpawner extends CraftBlockState implements CreatureSpa throw new IllegalArgumentException("Can't spawn EntityType " + entityType + " from mobspawners!"); } - spawner.getSpawner().setMobName(entityType.getName()); - } - - @Deprecated - public String getCreatureTypeId() { - return spawner.getSpawner().getMobName(); - } - - @Deprecated - public void setCreatureTypeId(String creatureName) { - setCreatureTypeByName(creatureName); + spawner.getSpawner().setMobName(new MinecraftKey(entityType.getName())); } public String getCreatureTypeName() { - return spawner.getSpawner().getMobName(); + return spawner.getSpawner().getMobName().a(); } public void setCreatureTypeByName(String creatureType) { diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftFlowerPot.java b/src/main/java/org/bukkit/craftbukkit/block/CraftFlowerPot.java index cc388d2195..f48dcb17f4 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftFlowerPot.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftFlowerPot.java @@ -1,10 +1,12 @@ package org.bukkit.craftbukkit.block; +import net.minecraft.server.ItemStack; import net.minecraft.server.TileEntityFlowerPot; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.FlowerPot; import org.bukkit.craftbukkit.CraftWorld; +import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.craftbukkit.util.CraftMagicNumbers; import org.bukkit.material.MaterialData; @@ -32,9 +34,9 @@ public class CraftFlowerPot extends CraftBlockState implements FlowerPot { @Override public void setContents(MaterialData item) { if (item == null) { - pot.a(null, 0); + pot.setContents(ItemStack.a); } else { - pot.a(CraftMagicNumbers.getItem(item.getItemType()), item.getData()); // PAIL: rename + pot.setContents(CraftItemStack.asNMSCopy(item.toItemStack())); } } } diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftShulkerBox.java b/src/main/java/org/bukkit/craftbukkit/block/CraftShulkerBox.java new file mode 100644 index 0000000000..acd9a717aa --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftShulkerBox.java @@ -0,0 +1,34 @@ +package org.bukkit.craftbukkit.block; + +import net.minecraft.server.TileEntityShulkerBox; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.ShulkerBox; +import org.bukkit.craftbukkit.CraftWorld; +import org.bukkit.craftbukkit.inventory.CraftInventory; +import org.bukkit.inventory.Inventory; + +public class CraftShulkerBox extends CraftContainer implements ShulkerBox { + + private final CraftWorld world; + private final TileEntityShulkerBox box; + + public CraftShulkerBox(final Block block) { + super(block); + + world = (CraftWorld) block.getWorld(); + box = (TileEntityShulkerBox) world.getTileEntityAt(getX(), getY(), getZ()); + } + + public CraftShulkerBox(final Material material, final TileEntityShulkerBox te) { + super(material, te); + + box = te; + world = null; + } + + @Override + public Inventory getInventory() { + return new CraftInventory(box); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java b/src/main/java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java index d091e6d512..5f683b9452 100644 --- a/src/main/java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java +++ b/src/main/java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java @@ -24,7 +24,7 @@ public final class VanillaCommandWrapper extends VanillaCommand { protected final CommandAbstract vanillaCommand; public VanillaCommandWrapper(CommandAbstract vanillaCommand, String usage) { - super(vanillaCommand.getCommand(), "A Mojang provided command.", usage, vanillaCommand.b()); // PAIL: rename + super(vanillaCommand.getCommand(), "A Mojang provided command.", usage, vanillaCommand.getAliases()); this.vanillaCommand = vanillaCommand; this.setPermission("minecraft.command." + vanillaCommand.getCommand()); } @@ -34,7 +34,14 @@ public final class VanillaCommandWrapper extends VanillaCommand { if (!testPermission(sender)) return true; ICommandListener icommandlistener = getListener(sender); - dispatchVanillaCommand(sender, icommandlistener, args); + try { + dispatchVanillaCommand(sender, icommandlistener, args); + } catch (CommandException commandexception) { + // Taken from CommandHandler + ChatMessage chatmessage = new ChatMessage(commandexception.getMessage(), commandexception.getArgs()); + chatmessage.getChatModifier().setColor(EnumChatFormat.RED); + icommandlistener.sendMessage(chatmessage); + } return true; } @@ -48,7 +55,7 @@ public final class VanillaCommandWrapper extends VanillaCommand { public static CommandSender lastSender = null; // Nasty :( - public final int dispatchVanillaCommand(CommandSender bSender, ICommandListener icommandlistener, String[] as) { + public final int dispatchVanillaCommand(CommandSender bSender, ICommandListener icommandlistener, String[] as) throws CommandException { // Copied from net.minecraft.server.CommandHandler int i = getPlayerListSize(as); int j = 0; @@ -154,7 +161,7 @@ public final class VanillaCommandWrapper extends VanillaCommand { throw new IllegalArgumentException("Cannot make " + sender + " a vanilla command listener"); } - private int getPlayerListSize(String as[]) { + private int getPlayerListSize(String as[]) throws CommandException { for (int i = 0; i < as.length; i++) { if (vanillaCommand.isListStart(as, i) && PlayerSelector.isList(as[i])) { return i; diff --git a/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java b/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java index 78a535a9a8..58af14d7c3 100644 --- a/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java +++ b/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java @@ -56,7 +56,7 @@ public class CraftEnchantment extends Enchantment { @Override public boolean isTreasure() { - return target.e(); // PAIL: isTreasure + return target.isTreasure(); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java new file mode 100644 index 0000000000..62c7d44c75 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java @@ -0,0 +1,97 @@ +package org.bukkit.craftbukkit.entity; + +import java.util.UUID; +import net.minecraft.server.EntityHorse; +import net.minecraft.server.EntityHorseAbstract; +import org.apache.commons.lang.Validate; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.craftbukkit.inventory.CraftInventory; +import org.bukkit.entity.AbstractHorse; +import org.bukkit.entity.AnimalTamer; +import org.bukkit.entity.Horse; +import org.bukkit.inventory.Inventory; + +public abstract class CraftAbstractHorse extends CraftAnimals implements AbstractHorse { + + public CraftAbstractHorse(CraftServer server, EntityHorseAbstract entity) { + super(server, entity); + } + + @Override + public EntityHorseAbstract getHandle() { + return (EntityHorseAbstract) entity; + } + + public void setVariant(Horse.Variant variant) { + throw new UnsupportedOperationException("Not supported."); + } + + public int getDomestication() { + return getHandle().getTemper(); + } + + public void setDomestication(int value) { + Validate.isTrue(value >= 0, "Domestication cannot be less than zero"); + Validate.isTrue(value <= getMaxDomestication(), "Domestication cannot be greater than the max domestication"); + getHandle().setTemper(value); + } + + public int getMaxDomestication() { + return getHandle().getMaxDomestication(); + } + + public void setMaxDomestication(int value) { + Validate.isTrue(value > 0, "Max domestication cannot be zero or less"); + getHandle().maxDomestication = value; + } + + public double getJumpStrength() { + return getHandle().getJumpStrength(); + } + + public void setJumpStrength(double strength) { + Validate.isTrue(strength >= 0, "Jump strength cannot be less than zero"); + getHandle().getAttributeInstance(EntityHorse.attributeJumpStrength).setValue(strength); + } + + @Override + public boolean isTamed() { + return getHandle().isTamed(); + } + + @Override + public void setTamed(boolean tamed) { + getHandle().setTamed(tamed); + } + + @Override + public AnimalTamer getOwner() { + if (getOwnerUUID() == null) return null; + return getServer().getOfflinePlayer(getOwnerUUID()); + } + + @Override + public void setOwner(AnimalTamer owner) { + if (owner != null) { + setTamed(true); + getHandle().setGoalTarget(null, null, false); + setOwnerUUID(owner.getUniqueId()); + } else { + setTamed(false); + setOwnerUUID(null); + } + } + + public UUID getOwnerUUID() { + return getHandle().getOwnerUUID(); + } + + public void setOwnerUUID(UUID uuid) { + getHandle().setOwnerUUID(uuid); + } + + @Override + public Inventory getInventory() { + return new CraftInventory(getHandle().inventoryChest); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftChestedHorse.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftChestedHorse.java new file mode 100644 index 0000000000..3e5331e470 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftChestedHorse.java @@ -0,0 +1,27 @@ +package org.bukkit.craftbukkit.entity; + +import net.minecraft.server.EntityHorseChestedAbstract; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.entity.ChestedHorse; + +public abstract class CraftChestedHorse extends CraftAbstractHorse implements ChestedHorse { + + public CraftChestedHorse(CraftServer server, EntityHorseChestedAbstract entity) { + super(server, entity); + } + + @Override + public EntityHorseChestedAbstract getHandle() { + return (EntityHorseChestedAbstract) super.getHandle(); + } + + @Override + public boolean isCarryingChest() { + return getHandle().isCarryingChest(); + } + + @Override + public void setCarryingChest(boolean chest) { + getHandle().setCarryingChest(chest); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftDonkey.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftDonkey.java new file mode 100644 index 0000000000..b4d74414ad --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftDonkey.java @@ -0,0 +1,29 @@ +package org.bukkit.craftbukkit.entity; + +import net.minecraft.server.EntityHorseDonkey; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.entity.Donkey; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Horse.Variant; + +public class CraftDonkey extends CraftChestedHorse implements Donkey { + + public CraftDonkey(CraftServer server, EntityHorseDonkey entity) { + super(server, entity); + } + + @Override + public String toString() { + return "CraftDonkey"; + } + + @Override + public EntityType getType() { + return EntityType.DONKEY; + } + + @Override + public Variant getVariant() { + return Variant.DONKEY; + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftElderGuardian.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftElderGuardian.java new file mode 100644 index 0000000000..34df49bbd8 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftElderGuardian.java @@ -0,0 +1,28 @@ +package org.bukkit.craftbukkit.entity; + +import net.minecraft.server.EntityGuardianElder; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.entity.ElderGuardian; +import org.bukkit.entity.EntityType; + +public class CraftElderGuardian extends CraftGuardian implements ElderGuardian { + + public CraftElderGuardian(CraftServer server, EntityGuardianElder entity) { + super(server, entity); + } + + @Override + public String toString() { + return "CraftElderGuardian"; + } + + @Override + public EntityType getType() { + return EntityType.ELDER_GUARDIAN; + } + + @Override + public boolean isElder() { + return true; + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java index e1b16b458c..9f5133b60f 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java @@ -65,7 +65,15 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { else if (entity instanceof EntityOcelot) { return new CraftOcelot(server, (EntityOcelot) entity); } } else if (entity instanceof EntitySheep) { return new CraftSheep(server, (EntitySheep) entity); } - else if (entity instanceof EntityHorse) { return new CraftHorse(server, (EntityHorse) entity); } + else if (entity instanceof EntityHorseAbstract) { + if (entity instanceof EntityHorseChestedAbstract){ + if (entity instanceof EntityHorseDonkey) { return new CraftDonkey(server, (EntityHorseDonkey) entity); } + else if (entity instanceof EntityHorseMule) { return new CraftMule(server, (EntityHorseMule) entity); } + else if (entity instanceof EntityLlama) { return new CraftLlama(server, (EntityLlama) entity); } + } else if (entity instanceof EntityHorse) { return new CraftHorse(server, (EntityHorse) entity); } + else if (entity instanceof EntityHorseSkeleton) { return new CraftSkeletonHorse(server, (EntityHorseSkeleton) entity); } + else if (entity instanceof EntityHorseZombie) { return new CraftZombieHorse(server, (EntityHorseZombie) entity); } + } else if (entity instanceof EntityRabbit) { return new CraftRabbit(server, (EntityRabbit) entity); } else if (entity instanceof EntityPolarBear) { return new CraftPolarBear(server, (EntityPolarBear) entity); } else { return new CraftAnimals(server, (EntityAnimal) entity); } @@ -74,13 +82,19 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { else if (entity instanceof EntityMonster) { if (entity instanceof EntityZombie) { if (entity instanceof EntityPigZombie) { return new CraftPigZombie(server, (EntityPigZombie) entity); } + else if (entity instanceof EntityZombieHusk) { return new CraftHusk(server, (EntityZombieHusk) entity); } + else if (entity instanceof EntityZombieVillager) { return new CraftVillagerZombie(server, (EntityZombieVillager) entity); } else { return new CraftZombie(server, (EntityZombie) entity); } } else if (entity instanceof EntityCreeper) { return new CraftCreeper(server, (EntityCreeper) entity); } else if (entity instanceof EntityEnderman) { return new CraftEnderman(server, (EntityEnderman) entity); } else if (entity instanceof EntitySilverfish) { return new CraftSilverfish(server, (EntitySilverfish) entity); } else if (entity instanceof EntityGiantZombie) { return new CraftGiant(server, (EntityGiantZombie) entity); } - else if (entity instanceof EntitySkeleton) { return new CraftSkeleton(server, (EntitySkeleton) entity); } + else if (entity instanceof EntitySkeletonAbstract) { + if (entity instanceof EntitySkeletonStray) { return new CraftStray(server, (EntitySkeletonStray) entity); } + else if (entity instanceof EntitySkeletonWither) { return new CraftWitherSkeleton(server, (EntitySkeletonWither) entity); } + else { return new CraftSkeleton(server, (EntitySkeletonAbstract) entity); } + } else if (entity instanceof EntityBlaze) { return new CraftBlaze(server, (EntityBlaze) entity); } else if (entity instanceof EntityWitch) { return new CraftWitch(server, (EntityWitch) entity); } else if (entity instanceof EntityWither) { return new CraftWither(server, (EntityWither) entity); } @@ -89,7 +103,13 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { else { return new CraftSpider(server, (EntitySpider) entity); } } else if (entity instanceof EntityEndermite) { return new CraftEndermite(server, (EntityEndermite) entity); } - else if (entity instanceof EntityGuardian) { return new CraftGuardian(server, (EntityGuardian) entity); } + else if (entity instanceof EntityGuardian) { + if (entity instanceof EntityGuardianElder) { return new CraftElderGuardian(server, (EntityGuardianElder) entity); } + else { return new CraftGuardian(server, (EntityGuardian) entity); } + } + else if (entity instanceof EntityEvoker) { return new CraftEvoker(server, (EntityEvoker) entity); } + else if (entity instanceof EntityVex) { return new CraftVex(server, (EntityVex) entity); } + else if (entity instanceof EntityVindicator) { return new CraftVindicator(server, (EntityVindicator) entity); } else { return new CraftMonster(server, (EntityMonster) entity); } } @@ -145,7 +165,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { else if (entity instanceof EntityEnderPearl) { return new CraftEnderPearl(server, (EntityEnderPearl) entity); } else if (entity instanceof EntityThrownExpBottle) { return new CraftThrownExpBottle(server, (EntityThrownExpBottle) entity); } } - else if (entity instanceof EntityFallingBlock) { return new CraftFallingSand(server, (EntityFallingBlock) entity); } + else if (entity instanceof EntityFallingBlock) { return new CraftFallingBlock(server, (EntityFallingBlock) entity); } else if (entity instanceof EntityFireball) { if (entity instanceof EntitySmallFireball) { return new CraftSmallFireball(server, (EntitySmallFireball) entity); } else if (entity instanceof EntityLargeFireball) { return new CraftLargeFireball(server, (EntityLargeFireball) entity); } @@ -179,6 +199,8 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { else if (entity instanceof EntityFireworks) { return new CraftFirework(server, (EntityFireworks) entity); } else if (entity instanceof EntityShulkerBullet) { return new CraftShulkerBullet(server, (EntityShulkerBullet) entity); } else if (entity instanceof EntityAreaEffectCloud) { return new CraftAreaEffectCloud(server, (EntityAreaEffectCloud) entity); } + else if (entity instanceof EntityEvokerFangs) { return new CraftEvokerFangs(server, (EntityEvokerFangs) entity); } + else if (entity instanceof EntityLlamaSpit) { return new CraftLlamaSpit(server, (EntityLlamaSpit) entity); } throw new AssertionError("Unknown entity " + (entity == null ? null : entity.getClass())); } @@ -213,7 +235,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { public boolean isOnGround() { if (entity instanceof EntityArrow) { - return ((EntityArrow) entity).isInGround(); + return ((EntityArrow) entity).inGround; } return entity.onGround; } @@ -267,7 +289,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { } public int getMaxFireTicks() { - return entity.maxFireTicks; + return entity.getMaxFireTicks(); } public void setFireTicks(int ticks) { diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEvoker.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEvoker.java new file mode 100644 index 0000000000..a5eeee5e0c --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEvoker.java @@ -0,0 +1,28 @@ +package org.bukkit.craftbukkit.entity; + +import net.minecraft.server.EntityEvoker; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Evoker; + +public class CraftEvoker extends CraftMonster implements Evoker { + + public CraftEvoker(CraftServer server, EntityEvoker entity) { + super(server, entity); + } + + @Override + public EntityEvoker getHandle() { + return (EntityEvoker) super.getHandle(); + } + + @Override + public String toString() { + return "CraftEvoker"; + } + + @Override + public EntityType getType() { + return EntityType.EVOKER; + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEvokerFangs.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEvokerFangs.java new file mode 100644 index 0000000000..a9f086bf3c --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEvokerFangs.java @@ -0,0 +1,29 @@ +package org.bukkit.craftbukkit.entity; + +import net.minecraft.server.Entity; +import net.minecraft.server.EntityEvokerFangs; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.EvokerFangs; + +public class CraftEvokerFangs extends CraftEntity implements EvokerFangs { + + public CraftEvokerFangs(CraftServer server, EntityEvokerFangs entity) { + super(server, entity); + } + + @Override + public EntityEvokerFangs getHandle() { + return (EntityEvokerFangs) super.getHandle(); + } + + @Override + public String toString() { + return "CraftEvokerFangs"; + } + + @Override + public EntityType getType() { + return EntityType.EVOKER_FANGS; + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingSand.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingBlock.java similarity index 86% rename from src/main/java/org/bukkit/craftbukkit/entity/CraftFallingSand.java rename to src/main/java/org/bukkit/craftbukkit/entity/CraftFallingBlock.java index ad4eb39623..b0a7f63926 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingSand.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingBlock.java @@ -6,11 +6,11 @@ import org.bukkit.Material; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.util.CraftMagicNumbers; import org.bukkit.entity.EntityType; -import org.bukkit.entity.FallingSand; +import org.bukkit.entity.FallingBlock; -public class CraftFallingSand extends CraftEntity implements FallingSand { +public class CraftFallingBlock extends CraftEntity implements FallingBlock { - public CraftFallingSand(CraftServer server, EntityFallingBlock entity) { + public CraftFallingBlock(CraftServer server, EntityFallingBlock entity) { super(server, entity); } @@ -21,7 +21,7 @@ public class CraftFallingSand extends CraftEntity implements FallingSand { @Override public String toString() { - return "CraftFallingSand"; + return "CraftFallingBlock"; } public EntityType getType() { diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java index b1f4d6e19a..e97037f60f 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java @@ -1,9 +1,6 @@ package org.bukkit.craftbukkit.entity; -import com.google.common.base.Optional; import net.minecraft.server.EntityFireworks; -import net.minecraft.server.ItemStack; -import net.minecraft.server.Items; import org.bukkit.Material; import org.bukkit.craftbukkit.CraftServer; @@ -21,15 +18,7 @@ public class CraftFirework extends CraftEntity implements Firework { public CraftFirework(CraftServer server, EntityFireworks entity) { super(server, entity); - - ItemStack item = getHandle().getDataWatcher().get(EntityFireworks.FIREWORK_ITEM).orNull(); - - if (item == null) { - item = new ItemStack(Items.FIREWORKS); - getHandle().getDataWatcher().set(EntityFireworks.FIREWORK_ITEM, Optional.of(item)); - } - - this.item = CraftItemStack.asCraftMirror(item); + this.item = CraftItemStack.asCraftMirror(getHandle().getDataWatcher().get(EntityFireworks.FIREWORK_ITEM)); // Ensure the item is a firework... if (this.item.getType() != Material.FIREWORK) { diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftGuardian.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftGuardian.java index 3a0ce677be..fd4f774f08 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftGuardian.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftGuardian.java @@ -1,7 +1,6 @@ package org.bukkit.craftbukkit.entity; import net.minecraft.server.EntityGuardian; -import net.minecraft.server.GenericAttributes; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.EntityType; import org.bukkit.entity.Guardian; @@ -24,33 +23,11 @@ public class CraftGuardian extends CraftMonster implements Guardian { @Override public boolean isElder() { - return ((EntityGuardian)entity).isElder(); + return false; } @Override - public void setElder( boolean shouldBeElder ) { - EntityGuardian entityGuardian = (EntityGuardian) entity; - - if (!isElder() && shouldBeElder) { - entityGuardian.setElder(true); - } else if (isElder() && !shouldBeElder) { - entityGuardian.setElder(false); - - // Since minecraft does not reset the elder Guardian to a guardian we have to do that - entity.setSize(0.85F, 0.85F); - - // Since aW() calls its supers it will try to re register attributes which is invalid - // check these on update - entityGuardian.getAttributeInstance(GenericAttributes.ATTACK_DAMAGE).setValue(6.0D); - entityGuardian.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).setValue(0.5D); - entityGuardian.getAttributeInstance(GenericAttributes.FOLLOW_RANGE).setValue(16.0D); - entityGuardian.getAttributeInstance(GenericAttributes.maxHealth).setValue(30.0D); - - // Update pathfinding (random stroll back to 80) - entityGuardian.goalRandomStroll.setTimeBetweenMovement(80); - - // Tell minecraft that we need persistence since the guardian changed - entityGuardian.initAttributes(); - } + public void setElder(boolean shouldBeElder) { + throw new UnsupportedOperationException("Not supported."); } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHorse.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHorse.java index 26b1814ae0..98ef44c302 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHorse.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHorse.java @@ -1,18 +1,14 @@ package org.bukkit.craftbukkit.entity; import net.minecraft.server.EntityHorse; -import net.minecraft.server.EnumHorseType; import org.apache.commons.lang.Validate; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.inventory.CraftInventoryHorse; -import org.bukkit.entity.AnimalTamer; import org.bukkit.entity.EntityType; import org.bukkit.entity.Horse; import org.bukkit.inventory.HorseInventory; -import java.util.UUID; - -public class CraftHorse extends CraftAnimals implements Horse { +public class CraftHorse extends CraftAbstractHorse implements Horse { public CraftHorse(CraftServer server, EntityHorse entity) { super(server, entity); @@ -20,110 +16,47 @@ public class CraftHorse extends CraftAnimals implements Horse { @Override public EntityHorse getHandle() { - return (EntityHorse) entity; + return (EntityHorse) super.getHandle(); } + @Override public Variant getVariant() { - return Variant.values()[getHandle().getType().ordinal()]; - } - - public void setVariant(Variant variant) { - Validate.notNull(variant, "Variant cannot be null"); - getHandle().setType(EnumHorseType.values()[variant.ordinal()]); + return Variant.HORSE; } + @Override public Color getColor() { return Color.values()[getHandle().getVariant() & 0xFF]; } + @Override public void setColor(Color color) { Validate.notNull(color, "Color cannot be null"); getHandle().setVariant(color.ordinal() & 0xFF | getStyle().ordinal() << 8); } + @Override public Style getStyle() { return Style.values()[getHandle().getVariant() >>> 8]; } + @Override public void setStyle(Style style) { Validate.notNull(style, "Style cannot be null"); getHandle().setVariant(getColor().ordinal() & 0xFF | style.ordinal() << 8); } + @Override public boolean isCarryingChest() { - return getHandle().hasChest(); + return false; } + @Override public void setCarryingChest(boolean chest) { - if (chest == isCarryingChest()) return; - getHandle().setHasChest(chest); - getHandle().loadChest(); - } - - public int getDomestication() { - return getHandle().getTemper(); - } - - public void setDomestication(int value) { - Validate.isTrue(value >= 0, "Domestication cannot be less than zero"); - Validate.isTrue(value <= getMaxDomestication(), "Domestication cannot be greater than the max domestication"); - getHandle().setTemper(value); - } - - public int getMaxDomestication() { - return getHandle().getMaxDomestication(); - } - - public void setMaxDomestication(int value) { - Validate.isTrue(value > 0, "Max domestication cannot be zero or less"); - getHandle().maxDomestication = value; - } - - public double getJumpStrength() { - return getHandle().getJumpStrength(); - } - - public void setJumpStrength(double strength) { - Validate.isTrue(strength >= 0, "Jump strength cannot be less than zero"); - getHandle().getAttributeInstance(EntityHorse.attributeJumpStrength).setValue(strength); + throw new UnsupportedOperationException("Not supported."); } @Override - public boolean isTamed() { - return getHandle().isTamed(); - } - - @Override - public void setTamed(boolean tamed) { - getHandle().setTame(tamed); - } - - @Override - public AnimalTamer getOwner() { - if (getOwnerUUID() == null) return null; - return getServer().getOfflinePlayer(getOwnerUUID()); - } - - @Override - public void setOwner(AnimalTamer owner) { - if (owner != null) { - setTamed(true); - getHandle().setGoalTarget(null, null, false); - setOwnerUUID(owner.getUniqueId()); - } else { - setTamed(false); - setOwnerUUID(null); - } - } - - public UUID getOwnerUUID() { - return getHandle().getOwnerUUID(); - } - - public void setOwnerUUID(UUID uuid) { - getHandle().setOwnerUUID(uuid); - } - public HorseInventory getInventory() { return new CraftInventoryHorse(getHandle().inventoryChest); } @@ -133,6 +66,7 @@ public class CraftHorse extends CraftAnimals implements Horse { return "CraftHorse{variant=" + getVariant() + ", owner=" + getOwner() + '}'; } + @Override public EntityType getType() { return EntityType.HORSE; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java index 6b6621b267..4249512899 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java @@ -381,7 +381,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { @Override public boolean isHandRaised() { - return getHandle().cx(); // PAIL: rename + return getHandle().isHandRaised(); } public boolean setWindowProperty(InventoryView.Property prop, int value) { diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHusk.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHusk.java new file mode 100644 index 0000000000..46425820b2 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHusk.java @@ -0,0 +1,23 @@ +package org.bukkit.craftbukkit.entity; + +import net.minecraft.server.EntityZombieHusk; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Husk; + +public class CraftHusk extends CraftZombie implements Husk { + + public CraftHusk(CraftServer server, EntityZombieHusk entity) { + super(server, entity); + } + + @Override + public String toString() { + return "CraftHusk"; + } + + @Override + public EntityType getType() { + return EntityType.HUSK; + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java index 80aae1048e..4641e3d529 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java @@ -117,7 +117,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { } public void resetMaxHealth() { - setMaxHealth(getHandle().getAttributeInstance(GenericAttributes.maxHealth).getAttribute().b()); // PAIL: getDefault + setMaxHealth(getHandle().getAttributeInstance(GenericAttributes.maxHealth).getAttribute().getDefault()); } public double getEyeHeight() { diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java new file mode 100644 index 0000000000..9dde90faea --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java @@ -0,0 +1,54 @@ +package org.bukkit.craftbukkit.entity; + +import com.google.common.base.Preconditions; +import net.minecraft.server.EntityLlama; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.craftbukkit.inventory.CraftInventoryLlama; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Horse; +import org.bukkit.entity.Llama; +import org.bukkit.inventory.LlamaInventory; + +public class CraftLlama extends CraftChestedHorse implements Llama { + + public CraftLlama(CraftServer server, EntityLlama entity) { + super(server, entity); + } + + @Override + public EntityLlama getHandle() { + return (EntityLlama) super.getHandle(); + } + + @Override + public Color getColor() { + return Color.values()[getHandle().getVariant()]; + } + + @Override + public void setColor(Color color) { + Preconditions.checkArgument(color != null, "color"); + + getHandle().setVariant(color.ordinal()); + } + + @Override + public LlamaInventory getInventory() { + return new CraftInventoryLlama(getHandle().inventoryChest); + } + + @Override + public Horse.Variant getVariant() { + return Horse.Variant.LLAMA; + } + + @Override + public String toString() { + return "CraftLlama"; + } + + @Override + public EntityType getType() { + return EntityType.LLAMA; + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLlamaSpit.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLlamaSpit.java new file mode 100644 index 0000000000..c3a20cb8f3 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLlamaSpit.java @@ -0,0 +1,50 @@ +package org.bukkit.craftbukkit.entity; + +import net.minecraft.server.EntityLlamaSpit; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.LlamaSpit; +import org.bukkit.projectiles.ProjectileSource; + +public class CraftLlamaSpit extends AbstractProjectile implements LlamaSpit { + + public CraftLlamaSpit(CraftServer server, EntityLlamaSpit entity) { + super(server, entity); + } + + @Override + public EntityLlamaSpit getHandle() { + return (EntityLlamaSpit) super.getHandle(); + } + + @Override + public String toString() { + return "CraftLlamaSpit"; + } + + @Override + public EntityType getType() { + return EntityType.LLAMA_SPIT; + } + + @Override + public LivingEntity _INVALID_getShooter() { + return (getHandle().shooter != null) ? (LivingEntity) getHandle().shooter.getBukkitEntity() : null; + } + + @Override + public ProjectileSource getShooter() { + return (getHandle().shooter != null) ? (ProjectileSource) getHandle().shooter.getBukkitEntity() : null; + } + + @Override + public void _INVALID_setShooter(LivingEntity shooter) { + getHandle().shooter = (shooter != null) ? ((CraftLivingEntity) shooter).getHandle() : null; + } + + @Override + public void setShooter(ProjectileSource source) { + getHandle().shooter = (source != null) ? ((CraftLivingEntity) source).getHandle() : null; + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartChest.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartChest.java index f5a18757fd..69435c4576 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartChest.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartChest.java @@ -5,7 +5,7 @@ import net.minecraft.server.EntityMinecartChest; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.inventory.CraftInventory; import org.bukkit.entity.EntityType; -import org.bukkit.entity.StorageMinecart; +import org.bukkit.entity.minecart.StorageMinecart; import org.bukkit.inventory.Inventory; @SuppressWarnings("deprecation") diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartCommand.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartCommand.java index 3e4f03a7bd..3817675047 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartCommand.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartCommand.java @@ -35,7 +35,7 @@ public class CraftMinecartCommand extends CraftMinecart implements CommandMineca @Override public void setCommand(String command) { getHandle().getCommandBlock().setCommand(command != null ? command : ""); - getHandle().getDataWatcher().set(EntityMinecartCommandBlock.a, getHandle().getCommandBlock().getCommand()); // PAIL: rename + getHandle().getDataWatcher().set(EntityMinecartCommandBlock.COMMAND, getHandle().getCommandBlock().getCommand()); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartFurnace.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartFurnace.java index 463b4ceeb2..2d2d945235 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartFurnace.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartFurnace.java @@ -4,7 +4,7 @@ import net.minecraft.server.EntityMinecartFurnace; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.EntityType; -import org.bukkit.entity.PoweredMinecart; +import org.bukkit.entity.minecart.PoweredMinecart; @SuppressWarnings("deprecation") public class CraftMinecartFurnace extends CraftMinecart implements PoweredMinecart { diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMule.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMule.java new file mode 100644 index 0000000000..cf9b3ac18b --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMule.java @@ -0,0 +1,29 @@ +package org.bukkit.craftbukkit.entity; + +import net.minecraft.server.EntityHorseMule; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Horse.Variant; +import org.bukkit.entity.Mule; + +public class CraftMule extends CraftChestedHorse implements Mule { + + public CraftMule(CraftServer server, EntityHorseMule entity) { + super(server, entity); + } + + @Override + public String toString() { + return "CraftMule"; + } + + @Override + public EntityType getType() { + return EntityType.MULE; + } + + @Override + public Variant getVariant() { + return Variant.MULE; + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index fd1b079e6d..bdd1aa0eb4 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -426,7 +426,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { Collection icons = new ArrayList(); for (MapCursor cursor : data.cursors) { if (cursor.isVisible()) { - icons.add(new MapIcon(cursor.getRawType(), cursor.getX(), cursor.getY(), cursor.getDirection())); + icons.add(new MapIcon(MapIcon.Type.a(cursor.getRawType()), cursor.getX(), cursor.getY(), cursor.getDirection())); } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeleton.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeleton.java index db25681913..4ed89615fd 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeleton.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeleton.java @@ -1,22 +1,20 @@ package org.bukkit.craftbukkit.entity; -import net.minecraft.server.EntitySkeleton; -import net.minecraft.server.EnumSkeletonType; +import net.minecraft.server.EntitySkeletonAbstract; -import org.apache.commons.lang.Validate; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.EntityType; import org.bukkit.entity.Skeleton; public class CraftSkeleton extends CraftMonster implements Skeleton { - public CraftSkeleton(CraftServer server, EntitySkeleton entity) { + public CraftSkeleton(CraftServer server, EntitySkeletonAbstract entity) { super(server, entity); } @Override - public EntitySkeleton getHandle() { - return (EntitySkeleton) entity; + public EntitySkeletonAbstract getHandle() { + return (EntitySkeletonAbstract) entity; } @Override @@ -28,12 +26,13 @@ public class CraftSkeleton extends CraftMonster implements Skeleton { return EntityType.SKELETON; } + @Override public SkeletonType getSkeletonType() { - return SkeletonType.values()[getHandle().getSkeletonType().ordinal()]; + return SkeletonType.NORMAL; } + @Override public void setSkeletonType(SkeletonType type) { - Validate.notNull(type); - getHandle().setSkeletonType(EnumSkeletonType.a(type.ordinal())); // PAIL: rename + throw new UnsupportedOperationException("Not supported."); } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeletonHorse.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeletonHorse.java new file mode 100644 index 0000000000..e822c2200d --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeletonHorse.java @@ -0,0 +1,29 @@ +package org.bukkit.craftbukkit.entity; + +import net.minecraft.server.EntityHorseSkeleton; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Horse.Variant; +import org.bukkit.entity.SkeletonHorse; + +public class CraftSkeletonHorse extends CraftAbstractHorse implements SkeletonHorse { + + public CraftSkeletonHorse(CraftServer server, EntityHorseSkeleton entity) { + super(server, entity); + } + + @Override + public String toString() { + return "CraftSkeletonHorse"; + } + + @Override + public EntityType getType() { + return EntityType.SKELETON_HORSE; + } + + @Override + public Variant getVariant() { + return Variant.SKELETON_HORSE; + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSlime.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSlime.java index da3df00f84..b29749fa86 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSlime.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSlime.java @@ -17,7 +17,7 @@ public class CraftSlime extends CraftLivingEntity implements Slime { } public void setSize(int size) { - getHandle().setSize(size); + getHandle().setSize(size, true); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowman.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowman.java index f1725b8d9d..eddd605e5f 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowman.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowman.java @@ -12,12 +12,12 @@ public class CraftSnowman extends CraftGolem implements Snowman { @Override public boolean isDerp() { - return getHandle().isDerp(); + return getHandle().hasPumpkin(); } @Override public void setDerp(boolean derpMode) { - getHandle().setDerp(derpMode); + getHandle().setHasPumpkin(derpMode); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftStray.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftStray.java new file mode 100644 index 0000000000..0fcb05bad5 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftStray.java @@ -0,0 +1,28 @@ +package org.bukkit.craftbukkit.entity; + +import net.minecraft.server.EntitySkeletonStray; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Stray; + +public class CraftStray extends CraftSkeleton implements Stray { + + public CraftStray(CraftServer server, EntitySkeletonStray entity) { + super(server, entity); + } + + @Override + public String toString() { + return "CraftStray"; + } + + @Override + public EntityType getType() { + return EntityType.STRAY; + } + + @Override + public SkeletonType getSkeletonType() { + return SkeletonType.STRAY; + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftVex.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftVex.java new file mode 100644 index 0000000000..787a41e015 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftVex.java @@ -0,0 +1,28 @@ +package org.bukkit.craftbukkit.entity; + +import net.minecraft.server.EntityVex; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Vex; + +public class CraftVex extends CraftMonster implements Vex { + + public CraftVex(CraftServer server, EntityVex entity) { + super(server, entity); + } + + @Override + public EntityVex getHandle() { + return (EntityVex) super.getHandle(); + } + + @Override + public String toString() { + return "CraftVex"; + } + + @Override + public EntityType getType() { + return EntityType.VEX; + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftVillagerZombie.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftVillagerZombie.java new file mode 100644 index 0000000000..b649374e42 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftVillagerZombie.java @@ -0,0 +1,39 @@ +package org.bukkit.craftbukkit.entity; + +import net.minecraft.server.EntityZombieVillager; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Villager; +import org.bukkit.entity.ZombieVillager; + +public class CraftVillagerZombie extends CraftZombie implements ZombieVillager { + + public CraftVillagerZombie(CraftServer server, EntityZombieVillager entity) { + super(server, entity); + } + + @Override + public EntityZombieVillager getHandle() { + return (EntityZombieVillager) super.getHandle(); + } + + @Override + public String toString() { + return "CraftVillagerZombie"; + } + + @Override + public EntityType getType() { + return EntityType.ZOMBIE_VILLAGER; + } + + @Override + public Villager.Profession getVillagerProfession() { + return Villager.Profession.values()[getHandle().getProfession()]; + } + + @Override + public void setVillagerProfession(Villager.Profession profession) { + getHandle().setProfession(profession == null ? 0 : profession.ordinal()); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftVindicator.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftVindicator.java new file mode 100644 index 0000000000..3835897c40 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftVindicator.java @@ -0,0 +1,28 @@ +package org.bukkit.craftbukkit.entity; + +import net.minecraft.server.EntityVindicator; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Vindicator; + +public class CraftVindicator extends CraftMonster implements Vindicator { + + public CraftVindicator(CraftServer server, EntityVindicator entity) { + super(server, entity); + } + + @Override + public EntityVindicator getHandle() { + return (EntityVindicator) super.getHandle(); + } + + @Override + public String toString() { + return "CraftVindicator"; + } + + @Override + public EntityType getType() { + return EntityType.VINDICATOR; + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftWitherSkeleton.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftWitherSkeleton.java new file mode 100644 index 0000000000..6fb1da7da1 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftWitherSkeleton.java @@ -0,0 +1,28 @@ +package org.bukkit.craftbukkit.entity; + +import net.minecraft.server.EntitySkeletonWither; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.WitherSkeleton; + +public class CraftWitherSkeleton extends CraftSkeleton implements WitherSkeleton { + + public CraftWitherSkeleton(CraftServer server, EntitySkeletonWither entity) { + super(server, entity); + } + + @Override + public String toString() { + return "CraftWitherSkeleton"; + } + + @Override + public EntityType getType() { + return EntityType.WITHER_SKELETON; + } + + @Override + public SkeletonType getSkeletonType() { + return SkeletonType.WITHER; + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java index 6ec924b152..d2c3dbe483 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java @@ -1,7 +1,7 @@ package org.bukkit.craftbukkit.entity; import net.minecraft.server.EntityZombie; -import net.minecraft.server.EnumZombieType; +import net.minecraft.server.EntityZombieVillager; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.EntityType; @@ -37,20 +37,21 @@ public class CraftZombie extends CraftMonster implements Zombie { } public boolean isVillager() { - return getHandle().isVillager(); + return getHandle() instanceof EntityZombieVillager; } + @Override public void setVillager(boolean flag) { - getHandle().setVillagerType(flag ? EnumZombieType.VILLAGER_FARMER : EnumZombieType.NORMAL); + throw new UnsupportedOperationException("Not supported."); } @Override public void setVillagerProfession(Villager.Profession profession) { - getHandle().setVillagerType(profession == null ? EnumZombieType.NORMAL : EnumZombieType.a(profession.ordinal())); + throw new UnsupportedOperationException("Not supported."); } @Override public Villager.Profession getVillagerProfession() { - return Villager.Profession.values()[getHandle().getVillagerType().ordinal()]; + return null; } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftZombieHorse.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftZombieHorse.java new file mode 100644 index 0000000000..5b31b68168 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftZombieHorse.java @@ -0,0 +1,29 @@ +package org.bukkit.craftbukkit.entity; + +import net.minecraft.server.EntityHorseZombie; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Horse.Variant; +import org.bukkit.entity.ZombieHorse; + +public class CraftZombieHorse extends CraftAbstractHorse implements ZombieHorse { + + public CraftZombieHorse(CraftServer server, EntityHorseZombie entity) { + super(server, entity); + } + + @Override + public String toString() { + return "CraftZombieHorse"; + } + + @Override + public EntityType getType() { + return EntityType.ZOMBIE_HORSE; + } + + @Override + public Variant getVariant() { + return Variant.UNDEAD_HORSE; + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index a42ecf3ec4..cbaf930536 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -36,7 +36,6 @@ import org.bukkit.entity.Arrow; import org.bukkit.entity.Creeper; import org.bukkit.entity.EntityType; import org.bukkit.entity.Firework; -import org.bukkit.entity.Horse; import org.bukkit.entity.LightningStrike; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Pig; @@ -62,6 +61,7 @@ import org.bukkit.event.server.ServerListPingEvent; import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.InventoryView; import org.bukkit.inventory.meta.BookMeta; +import org.bukkit.entity.AbstractHorse; public class CraftEventFactory { public static final DamageSource MELTING = CraftDamageSource.copyOf(DamageSource.BURN); @@ -550,6 +550,8 @@ public class CraftEventFactory { cause = DamageCause.FALL; } else if (source == DamageSource.FLY_INTO_WALL) { cause = DamageCause.FLY_INTO_WALL; + } else if (source == DamageSource.CRAMMING) { + cause = DamageCause.CRAMMING; } else if (source == DamageSource.GENERIC) { cause = DamageCause.CUSTOM; } @@ -669,7 +671,7 @@ public class CraftEventFactory { } public static HorseJumpEvent callHorseJumpEvent(Entity horse, float power) { - HorseJumpEvent event = new HorseJumpEvent((Horse) horse.getBukkitEntity(), power); + HorseJumpEvent event = new HorseJumpEvent((AbstractHorse) horse.getBukkitEntity(), power); horse.getBukkitEntity().getServer().getPluginManager().callEvent(event); return event; } diff --git a/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java b/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java index aa292e318c..0acad719a7 100644 --- a/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java +++ b/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java @@ -221,8 +221,8 @@ public class CustomChunkGenerator extends InternalChunkGenerator { } @Override - public BlockPosition findNearestMapFeature(World world, String type, BlockPosition position) { - return "Stronghold".equals(type) && this.strongholdGen != null ? this.strongholdGen.getNearestGeneratedFeature(world, position) : null; + public BlockPosition findNearestMapFeature(World world, String type, BlockPosition position, boolean flag) { + return "Stronghold".equals(type) && this.strongholdGen != null ? this.strongholdGen.getNearestGeneratedFeature(world, position, flag) : null; } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/generator/NormalChunkGenerator.java b/src/main/java/org/bukkit/craftbukkit/generator/NormalChunkGenerator.java index cbcca41c43..1ea560242a 100644 --- a/src/main/java/org/bukkit/craftbukkit/generator/NormalChunkGenerator.java +++ b/src/main/java/org/bukkit/craftbukkit/generator/NormalChunkGenerator.java @@ -52,8 +52,8 @@ public class NormalChunkGenerator extends InternalChunkGenerator { } @Override - public BlockPosition findNearestMapFeature(World world, String s, BlockPosition blockPosition) { - return generator.findNearestMapFeature(world, s, blockPosition); + public BlockPosition findNearestMapFeature(World world, String s, BlockPosition blockPosition, boolean flag) { + return generator.findNearestMapFeature(world, s, blockPosition, flag); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java index 3297216d58..2b5494c4b1 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java @@ -61,11 +61,11 @@ public class CraftInventory implements Inventory { public ItemStack[] getContents() { ItemStack[] items = new ItemStack[getSize()]; - net.minecraft.server.ItemStack[] mcItems = getInventory().getContents(); + List mcItems = getInventory().getContents(); - int size = Math.min(items.length, mcItems.length); + int size = Math.min(items.length, mcItems.size()); for (int i = 0; i < size; i++) { - items[i] = mcItems[i] == null ? null : CraftItemStack.asCraftMirror(mcItems[i]); + items[i] = (mcItems.get(i) == net.minecraft.server.ItemStack.a) ? null : CraftItemStack.asCraftMirror(mcItems.get(i)); } return items; } @@ -85,7 +85,7 @@ public class CraftInventory implements Inventory { } public void setItem(int index, ItemStack item) { - getInventory().setItem(index, ((item == null || item.getTypeId() == 0) ? null : CraftItemStack.asNMSCopy(item))); + getInventory().setItem(index, ((item == null || item.getTypeId() == 0) ? net.minecraft.server.ItemStack.a : CraftItemStack.asNMSCopy(item))); } public boolean contains(int materialId) { diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCrafting.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCrafting.java index dded0f022e..fafc9f6be4 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCrafting.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCrafting.java @@ -1,6 +1,7 @@ package org.bukkit.craftbukkit.inventory; import java.util.Arrays; +import java.util.List; import net.minecraft.server.IRecipe; import net.minecraft.server.IInventory; @@ -33,8 +34,8 @@ public class CraftInventoryCrafting extends CraftInventory implements CraftingIn @Override public void setContents(ItemStack[] items) { - int resultLen = getResultInventory().getContents().length; - int len = getMatrixInventory().getContents().length + resultLen; + int resultLen = getResultInventory().getContents().size(); + int len = getMatrixInventory().getContents().size() + resultLen; if (len > items.length) { throw new IllegalArgumentException("Invalid inventory size; expected " + len + " or less"); } @@ -44,17 +45,17 @@ public class CraftInventoryCrafting extends CraftInventory implements CraftingIn @Override public ItemStack[] getContents() { ItemStack[] items = new ItemStack[getSize()]; - net.minecraft.server.ItemStack[] mcResultItems = getResultInventory().getContents(); + List mcResultItems = getResultInventory().getContents(); int i = 0; - for (i = 0; i < mcResultItems.length; i++ ) { - items[i] = CraftItemStack.asCraftMirror(mcResultItems[i]); + for (i = 0; i < mcResultItems.size(); i++ ) { + items[i] = CraftItemStack.asCraftMirror(mcResultItems.get(i)); } - net.minecraft.server.ItemStack[] mcItems = getMatrixInventory().getContents(); + List mcItems = getMatrixInventory().getContents(); - for (int j = 0; j < mcItems.length; j++) { - items[i + j] = CraftItemStack.asCraftMirror(mcItems[j]); + for (int j = 0; j < mcItems.size(); j++) { + items[i + j] = CraftItemStack.asCraftMirror(mcItems.get(j)); } return items; @@ -86,11 +87,11 @@ public class CraftInventoryCrafting extends CraftInventory implements CraftingIn } public ItemStack[] getMatrix() { - net.minecraft.server.ItemStack[] matrix = getMatrixInventory().getContents(); - ItemStack[] items = new ItemStack[matrix.length]; + List matrix = getMatrixInventory().getContents(); + ItemStack[] items = new ItemStack[matrix.size()]; - for (int i = 0; i < matrix.length; i++) { - items[i] = CraftItemStack.asCraftMirror(matrix[i]); + for (int i = 0; i < matrix.size(); i++) { + items[i] = CraftItemStack.asCraftMirror(matrix.get(i)); } return items; @@ -103,13 +104,13 @@ public class CraftInventoryCrafting extends CraftInventory implements CraftingIn } public void setMatrix(ItemStack[] contents) { - if (getMatrixInventory().getContents().length > contents.length) { - throw new IllegalArgumentException("Invalid inventory size; expected " + getMatrixInventory().getContents().length + " or less"); + if (getMatrixInventory().getContents().size() > contents.length) { + throw new IllegalArgumentException("Invalid inventory size; expected " + getMatrixInventory().getContents().size() + " or less"); } - net.minecraft.server.ItemStack[] mcItems = getMatrixInventory().getContents(); + List mcItems = getMatrixInventory().getContents(); - for (int i = 0; i < mcItems.length; i++) { + for (int i = 0; i < mcItems.size(); i++) { if (i < contents.length) { ItemStack item = contents[i]; if (item == null || item.getTypeId() <= 0) { @@ -124,11 +125,11 @@ public class CraftInventoryCrafting extends CraftInventory implements CraftingIn } public void setResult(ItemStack item) { - net.minecraft.server.ItemStack[] contents = getResultInventory().getContents(); + List contents = getResultInventory().getContents(); if (item == null || item.getTypeId() <= 0) { - contents[0] = null; + contents.set(0, net.minecraft.server.ItemStack.a); } else { - contents[0] = CraftItemStack.asNMSCopy(item); + contents.set(0, CraftItemStack.asNMSCopy(item)); } } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java index 2b39678252..da8df638b4 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java @@ -1,11 +1,13 @@ package org.bukkit.craftbukkit.inventory; import java.util.ArrayList; +import java.util.Iterator; import java.util.List; import net.minecraft.server.ChatComponentText; import net.minecraft.server.IChatBaseComponent; import org.apache.commons.lang.Validate; +import org.bukkit.Location; import org.bukkit.craftbukkit.entity.CraftHumanEntity; import org.bukkit.entity.HumanEntity; import org.bukkit.event.inventory.InventoryType; @@ -14,7 +16,7 @@ import org.bukkit.inventory.InventoryHolder; import net.minecraft.server.EntityHuman; import net.minecraft.server.IInventory; import net.minecraft.server.ItemStack; -import org.bukkit.Location; +import net.minecraft.server.NonNullList; public class CraftInventoryCustom extends CraftInventory { public CraftInventoryCustom(InventoryHolder owner, InventoryType type) { @@ -34,7 +36,7 @@ public class CraftInventoryCustom extends CraftInventory { } static class MinecraftInventory implements IInventory { - private final ItemStack[] items; + private final NonNullList items; private int maxStack = MAX_STACK; private final List viewers; private final String title; @@ -57,7 +59,7 @@ public class CraftInventoryCustom extends CraftInventory { public MinecraftInventory(InventoryHolder owner, int size, String title) { Validate.notNull(title, "Title cannot be null"); - this.items = new ItemStack[size]; + this.items = NonNullList.a(size, ItemStack.a); this.title = title; this.viewers = new ArrayList(); this.owner = owner; @@ -65,23 +67,23 @@ public class CraftInventoryCustom extends CraftInventory { } public int getSize() { - return items.length; + return items.size(); } public ItemStack getItem(int i) { - return items[i]; + return items.get(i); } public ItemStack splitStack(int i, int j) { ItemStack stack = this.getItem(i); ItemStack result; - if (stack == null) return null; - if (stack.count <= j) { - this.setItem(i, null); + if (stack == ItemStack.a) return stack; + if (stack.getCount() <= j) { + this.setItem(i, ItemStack.a); result = stack; } else { result = CraftItemStack.copyNMSStack(stack, j); - stack.count -= j; + stack.subtract(j); } this.update(); return result; @@ -90,21 +92,21 @@ public class CraftInventoryCustom extends CraftInventory { public ItemStack splitWithoutUpdate(int i) { ItemStack stack = this.getItem(i); ItemStack result; - if (stack == null) return null; - if (stack.count <= 1) { + if (stack == ItemStack.a) return stack; + if (stack.getCount() <= 1) { this.setItem(i, null); result = stack; } else { result = CraftItemStack.copyNMSStack(stack, 1); - stack.count -= 1; + stack.subtract(1); } return result; } public void setItem(int i, ItemStack itemstack) { - items[i] = itemstack; - if (itemstack != null && this.getMaxStackSize() > 0 && itemstack.count > this.getMaxStackSize()) { - itemstack.count = this.getMaxStackSize(); + items.set(i, itemstack); + if (itemstack != ItemStack.a && this.getMaxStackSize() > 0 && itemstack.getCount() > this.getMaxStackSize()) { + itemstack.setCount(this.getMaxStackSize()); } } @@ -122,7 +124,7 @@ public class CraftInventoryCustom extends CraftInventory { return true; } - public ItemStack[] getContents() { + public List getContents() { return items; } @@ -141,7 +143,7 @@ public class CraftInventoryCustom extends CraftInventory { public InventoryType getType() { return type; } - + public InventoryHolder getOwner() { return owner; } @@ -170,13 +172,13 @@ public class CraftInventoryCustom extends CraftInventory { } @Override - public int g() { + public int h() { return 0; } @Override - public void l() { - + public void clear() { + items.clear(); } @Override @@ -198,5 +200,22 @@ public class CraftInventoryCustom extends CraftInventory { public Location getLocation() { return null; } + + @Override + public boolean w_() { + Iterator iterator = this.items.iterator(); + + ItemStack itemstack; + + do { + if (!iterator.hasNext()) { + return true; + } + + itemstack = (ItemStack) iterator.next(); + } while (itemstack.isEmpty()); + + return false; + } } } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryDoubleChest.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryDoubleChest.java index 24e25882c4..39c7d6b7a7 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryDoubleChest.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryDoubleChest.java @@ -44,8 +44,8 @@ public class CraftInventoryDoubleChest extends CraftInventory implements DoubleC @Override public void setContents(ItemStack[] items) { - if (getInventory().getContents().length < items.length) { - throw new IllegalArgumentException("Invalid inventory size; expected " + getInventory().getContents().length + " or less"); + if (getInventory().getContents().size() < items.length) { + throw new IllegalArgumentException("Invalid inventory size; expected " + getInventory().getContents().size() + " or less"); } ItemStack[] leftItems = new ItemStack[left.getSize()], rightItems = new ItemStack[right.getSize()]; System.arraycopy(items, 0, leftItems, 0, Math.min(left.getSize(),items.length)); diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryLlama.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryLlama.java new file mode 100644 index 0000000000..342b74ae61 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryLlama.java @@ -0,0 +1,22 @@ +package org.bukkit.craftbukkit.inventory; + +import net.minecraft.server.IInventory; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.LlamaInventory; + +public class CraftInventoryLlama extends CraftInventory implements LlamaInventory { + + public CraftInventoryLlama(IInventory inventory) { + super(inventory); + } + + @Override + public ItemStack getDecor() { + return getItem(1); + } + + @Override + public void setDecor(ItemStack stack) { + setItem(1, stack); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryPlayer.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryPlayer.java index 51a8b4e2e5..d8c5364df9 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryPlayer.java @@ -25,7 +25,7 @@ public class CraftInventoryPlayer extends CraftInventory implements org.bukkit.i @Override public ItemStack[] getStorageContents() { - return Arrays.copyOfRange(getContents(), 0, getInventory().items.length); + return Arrays.copyOfRange(getContents(), 0, getInventory().items.size()); } @@ -41,7 +41,7 @@ public class CraftInventoryPlayer extends CraftInventory implements org.bukkit.i @Override public ItemStack getItemInOffHand() { - return CraftItemStack.asCraftMirror(getInventory().extraSlots[0]); + return CraftItemStack.asCraftMirror(getInventory().extraSlots.get(0)); } @Override @@ -148,8 +148,8 @@ public class CraftInventoryPlayer extends CraftInventory implements org.bukkit.i } public ItemStack[] getArmorContents() { - int start = getInventory().items.length; - return Arrays.copyOfRange(getContents(), start, start + getInventory().armor.length); + int start = getInventory().items.size(); + return Arrays.copyOfRange(getContents(), start, start + getInventory().armor.size()); } private void setSlots(ItemStack[] items, int baseSlot, int length) { @@ -169,23 +169,23 @@ public class CraftInventoryPlayer extends CraftInventory implements org.bukkit.i @Override public void setStorageContents(ItemStack[] items) throws IllegalArgumentException { - setSlots(items, 0, getInventory().items.length); + setSlots(items, 0, getInventory().items.size()); } @Override public void setArmorContents(ItemStack[] items) { - setSlots(items, getInventory().items.length, getInventory().armor.length); + setSlots(items, getInventory().items.size(), getInventory().armor.size()); } @Override public ItemStack[] getExtraContents() { - int start = getInventory().items.length + getInventory().armor.length; - return Arrays.copyOfRange(getContents(), start, start + getInventory().extraSlots.length); + int start = getInventory().items.size() + getInventory().armor.size(); + return Arrays.copyOfRange(getContents(), start, start + getInventory().extraSlots.size()); } @Override public void setExtraContents(ItemStack[] items) { - setSlots(items, getInventory().items.length + getInventory().armor.length, getInventory().extraSlots.length); + setSlots(items, getInventory().items.size() + getInventory().armor.size(), getInventory().extraSlots.size()); } public int clear(int id, int data) { diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java index 4e4a46f14b..79fe4181d5 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java @@ -114,6 +114,22 @@ public final class CraftItemFactory implements ItemFactory { case FLOWER_POT_ITEM: case SHIELD: case STRUCTURE_BLOCK: + case WHITE_SHULKER_BOX: + case ORANGE_SHULKER_BOX: + case MAGENTA_SHULKER_BOX: + case LIGHT_BLUE_SHULKER_BOX: + case YELLOW_SHULKER_BOX: + case LIME_SHULKER_BOX: + case PINK_SHULKER_BOX: + case GRAY_SHULKER_BOX: + case SILVER_SHULKER_BOX: + case CYAN_SHULKER_BOX: + case PURPLE_SHULKER_BOX: + case BLUE_SHULKER_BOX: + case BROWN_SHULKER_BOX: + case GREEN_SHULKER_BOX: + case RED_SHULKER_BOX: + case BLACK_SHULKER_BOX: return new CraftMetaBlockState(meta, material); default: return new CraftMetaItem(meta); diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java index 6f5dcbd652..866e54dd9e 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java @@ -20,11 +20,7 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import com.google.common.collect.ImmutableMap; -import net.minecraft.server.IChatBaseComponent.ChatSerializer; -import net.minecraft.server.Items; -import net.minecraft.server.NBTTagString; import org.bukkit.craftbukkit.enchantments.CraftEnchantment; -import org.bukkit.craftbukkit.util.CraftChatMessage; @DelegateDeserialization(ItemStack.class) public final class CraftItemStack extends ItemStack { @@ -32,16 +28,16 @@ public final class CraftItemStack extends ItemStack { public static net.minecraft.server.ItemStack asNMSCopy(ItemStack original) { if (original instanceof CraftItemStack) { CraftItemStack stack = (CraftItemStack) original; - return stack.handle == null ? null : stack.handle.cloneItemStack(); + return stack.handle == null ? net.minecraft.server.ItemStack.a : stack.handle.cloneItemStack(); } if (original == null || original.getTypeId() <= 0) { - return null; + return net.minecraft.server.ItemStack.a; } Item item = CraftMagicNumbers.getItem(original.getType()); if (item == null) { - return null; + return net.minecraft.server.ItemStack.a; } net.minecraft.server.ItemStack stack = new net.minecraft.server.ItemStack(item, original.getAmount(), original.getDurability()); @@ -53,7 +49,7 @@ public final class CraftItemStack extends ItemStack { public static net.minecraft.server.ItemStack copyNMSStack(net.minecraft.server.ItemStack original, int amount) { net.minecraft.server.ItemStack stack = original.cloneItemStack(); - stack.count = amount; + stack.setCount(amount); return stack; } @@ -61,10 +57,10 @@ public final class CraftItemStack extends ItemStack { * Copies the NMS stack to return as a strictly-Bukkit stack */ public static ItemStack asBukkitCopy(net.minecraft.server.ItemStack original) { - if (original == null) { + if (original == net.minecraft.server.ItemStack.a) { return new ItemStack(Material.AIR); } - ItemStack stack = new ItemStack(CraftMagicNumbers.getMaterial(original.getItem()), original.count, (short) original.getData()); + ItemStack stack = new ItemStack(CraftMagicNumbers.getMaterial(original.getItem()), original.getCount(), (short) original.getData()); if (hasItemMeta(original)) { stack.setItemMeta(getItemMeta(original)); } @@ -143,7 +139,7 @@ public final class CraftItemStack extends ItemStack { @Override public int getAmount() { - return handle != null ? handle.count : 0; + return handle != null ? handle.getCount() : 0; } @Override @@ -154,7 +150,7 @@ public final class CraftItemStack extends ItemStack { if (amount == 0) { handle = null; } else { - handle.count = amount; + handle.setCount(amount); } } @@ -375,6 +371,22 @@ public final class CraftItemStack extends ItemStack { case FLOWER_POT_ITEM: case SHIELD: case STRUCTURE_BLOCK: + case WHITE_SHULKER_BOX: + case ORANGE_SHULKER_BOX: + case MAGENTA_SHULKER_BOX: + case LIGHT_BLUE_SHULKER_BOX: + case YELLOW_SHULKER_BOX: + case LIME_SHULKER_BOX: + case PINK_SHULKER_BOX: + case GRAY_SHULKER_BOX: + case SILVER_SHULKER_BOX: + case CYAN_SHULKER_BOX: + case PURPLE_SHULKER_BOX: + case BLUE_SHULKER_BOX: + case BROWN_SHULKER_BOX: + case GREEN_SHULKER_BOX: + case RED_SHULKER_BOX: + case BLACK_SHULKER_BOX: return new CraftMetaBlockState(item.getTag(), CraftMagicNumbers.getMaterial(item.getItem())); default: return new CraftMetaItem(item.getTag()); diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java index b9d4717f56..91ff76d81d 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java @@ -181,6 +181,22 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta case FLOWER_POT_ITEM: case SHIELD: case STRUCTURE_BLOCK: + case WHITE_SHULKER_BOX: + case ORANGE_SHULKER_BOX: + case MAGENTA_SHULKER_BOX: + case LIGHT_BLUE_SHULKER_BOX: + case YELLOW_SHULKER_BOX: + case LIME_SHULKER_BOX: + case PINK_SHULKER_BOX: + case GRAY_SHULKER_BOX: + case SILVER_SHULKER_BOX: + case CYAN_SHULKER_BOX: + case PURPLE_SHULKER_BOX: + case BLUE_SHULKER_BOX: + case BROWN_SHULKER_BOX: + case GREEN_SHULKER_BOX: + case RED_SHULKER_BOX: + case BLACK_SHULKER_BOX: return true; } return false; diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMap.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMap.java index d8af390544..83dfda52a0 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMap.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMap.java @@ -3,6 +3,7 @@ package org.bukkit.craftbukkit.inventory; import java.util.Map; import net.minecraft.server.NBTTagCompound; +import net.minecraft.server.NBTTagString; import org.bukkit.Material; import org.bukkit.configuration.serialization.DelegateDeserialization; @@ -14,11 +15,15 @@ import com.google.common.collect.ImmutableMap; @DelegateDeserialization(SerializableMeta.class) class CraftMetaMap extends CraftMetaItem implements MapMeta { static final ItemMetaKey MAP_SCALING = new ItemMetaKey("map_is_scaling", "scaling"); + static final ItemMetaKey MAP_LOC_NAME = new ItemMetaKey("LocName", "display-loc-name"); + static final ItemMetaKey MAP_COLOR = new ItemMetaKey("Mapcolor", "display-map-color"); static final byte SCALING_EMPTY = (byte) 0; static final byte SCALING_TRUE = (byte) 1; static final byte SCALING_FALSE = (byte) 2; private byte scaling = SCALING_EMPTY; + private String locName; + private String mapColor; CraftMetaMap(CraftMetaItem meta) { super(meta); @@ -37,6 +42,18 @@ class CraftMetaMap extends CraftMetaItem implements MapMeta { if (tag.hasKey(MAP_SCALING.NBT)) { this.scaling = tag.getBoolean(MAP_SCALING.NBT) ? SCALING_TRUE : SCALING_FALSE; } + + if (tag.hasKey(DISPLAY.NBT)) { + NBTTagCompound display = tag.getCompound(DISPLAY.NBT); + + if (display.hasKey(MAP_LOC_NAME.NBT)) { + locName = display.getString(MAP_LOC_NAME.NBT); + } + + if (display.hasKey(MAP_COLOR.NBT)) { + mapColor = display.getString(MAP_COLOR.NBT); + } + } } CraftMetaMap(Map map) { @@ -55,6 +72,14 @@ class CraftMetaMap extends CraftMetaItem implements MapMeta { if (hasScaling()) { tag.setBoolean(MAP_SCALING.NBT, isScaling()); } + + if (hasLocationName()) { + setDisplayTag(tag, MAP_LOC_NAME.NBT, new NBTTagString(getLocationName())); + } + + if (hasMapColor()) { + setDisplayTag(tag, MAP_COLOR.NBT, new NBTTagString(mapColor)); + } } @Override @@ -88,6 +113,25 @@ class CraftMetaMap extends CraftMetaItem implements MapMeta { this.scaling = scaling ? SCALING_TRUE : SCALING_FALSE; } + @Override + public boolean hasLocationName() { + return this.locName != null; + } + + @Override + public String getLocationName() { + return this.locName; + } + + @Override + public void setLocationName(String name) { + this.locName = name; + } + + public boolean hasMapColor() { + return this.mapColor != null; + } + @Override boolean equalsCommon(CraftMetaItem meta) { if (!super.equalsCommon(meta)) { @@ -96,7 +140,9 @@ class CraftMetaMap extends CraftMetaItem implements MapMeta { if (meta instanceof CraftMetaMap) { CraftMetaMap that = (CraftMetaMap) meta; - return (this.scaling == that.scaling); + return (this.scaling == that.scaling) + && (hasLocationName() ? that.hasLocationName() && this.getLocationName().equals(that.getLocationName()) : !that.hasLocationName()) + && (hasMapColor() ? that.hasMapColor() && this.mapColor.equals(that.mapColor) : !that.hasMapColor()); } return true; } @@ -130,6 +176,14 @@ class CraftMetaMap extends CraftMetaItem implements MapMeta { builder.put(MAP_SCALING.BUKKIT, isScaling()); } + if (hasLocationName()) { + builder.put(MAP_LOC_NAME.BUKKIT, getLocationName()); + } + + if (hasMapColor()) { + builder.put(MAP_COLOR.BUKKIT, mapColor); + } + return builder; } } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/InventoryWrapper.java b/src/main/java/org/bukkit/craftbukkit/inventory/InventoryWrapper.java index 125f7e1abb..5634a22b5d 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/InventoryWrapper.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/InventoryWrapper.java @@ -1,5 +1,7 @@ package org.bukkit.craftbukkit.inventory; +import com.google.common.base.Predicates; +import com.google.common.collect.Iterables; import java.util.ArrayList; import java.util.List; import net.minecraft.server.EntityHuman; @@ -40,12 +42,12 @@ public class InventoryWrapper implements IInventory { if (stack == null) { return null; } - if (stack.count <= j) { + if (stack.getCount() <= j) { this.setItem(i, null); result = stack; } else { result = CraftItemStack.copyNMSStack(stack, j); - stack.count -= j; + stack.subtract(j); } this.update(); return result; @@ -59,12 +61,12 @@ public class InventoryWrapper implements IInventory { if (stack == null) { return null; } - if (stack.count <= 1) { + if (stack.getCount() <= 1) { this.setItem(i, null); result = stack; } else { result = CraftItemStack.copyNMSStack(stack, 1); - stack.count -= 1; + stack.subtract(1); } return result; } @@ -111,22 +113,22 @@ public class InventoryWrapper implements IInventory { } @Override - public int g() { + public int h() { return 0; } @Override - public void l() { + public void clear() { inventory.clear(); } @Override - public ItemStack[] getContents() { + public List getContents() { int size = getSize(); - ItemStack[] items = new ItemStack[size]; + List items = new ArrayList(size); for (int i = 0; i < size; i++) { - items[i] = getItem(i); + items.set(i, getItem(i)); } return items; @@ -176,4 +178,9 @@ public class InventoryWrapper implements IInventory { public Location getLocation() { return inventory.getLocation(); } + + @Override + public boolean w_() { + return Iterables.any(inventory, Predicates.notNull()); + } } diff --git a/src/main/java/org/bukkit/craftbukkit/map/CraftMapRenderer.java b/src/main/java/org/bukkit/craftbukkit/map/CraftMapRenderer.java index d56a291cdb..a55915a4f3 100644 --- a/src/main/java/org/bukkit/craftbukkit/map/CraftMapRenderer.java +++ b/src/main/java/org/bukkit/craftbukkit/map/CraftMapRenderer.java @@ -41,7 +41,6 @@ public class CraftMapRenderer extends MapRenderer { continue; } - MapIcon decoration = (MapIcon) worldMap.decorations.get(key); cursors.addCursor(decoration.getX(), decoration.getY(), (byte) (decoration.getRotation() & 15), decoration.getType()); } diff --git a/src/main/java/org/bukkit/craftbukkit/map/CraftMapView.java b/src/main/java/org/bukkit/craftbukkit/map/CraftMapView.java index 1a150d98b5..6c42708cc6 100644 --- a/src/main/java/org/bukkit/craftbukkit/map/CraftMapView.java +++ b/src/main/java/org/bukkit/craftbukkit/map/CraftMapView.java @@ -160,4 +160,13 @@ public final class CraftMapView implements MapView { return render; } + @Override + public boolean isUnlimitedTracking() { + return worldMap.unlimitedTracking; + } + + @Override + public void setUnlimitedTracking(boolean unlimited) { + worldMap.unlimitedTracking = unlimited; + } } diff --git a/src/test/java/org/bukkit/MaterialTest.java b/src/test/java/org/bukkit/MaterialTest.java index a63c0f4d28..a9b4e525e1 100644 --- a/src/test/java/org/bukkit/MaterialTest.java +++ b/src/test/java/org/bukkit/MaterialTest.java @@ -27,7 +27,6 @@ public class MaterialTest extends AbstractTestingBase { materials.put(material.getId(), material); } - materials.remove(0); // Purge air. Iterator items = Item.REGISTRY.iterator();