summaryrefslogtreecommitdiffstats
path: root/nms-patches
diff options
context:
space:
mode:
authormd_5 <git@md-5.net>2016-11-17 12:41:03 +1100
committermd_5 <git@md-5.net>2016-11-17 12:41:03 +1100
commitc25ddf063a808e3adb749e22017661f403c5fb7e (patch)
treeb2efcff512be12fd3e38cf8c36386148ce6ab4ae /nms-patches
parent51263e97187a84338f89698eef187284055a682a (diff)
downloadcraftbukkit-c25ddf063a808e3adb749e22017661f403c5fb7e.tar
craftbukkit-c25ddf063a808e3adb749e22017661f403c5fb7e.tar.gz
craftbukkit-c25ddf063a808e3adb749e22017661f403c5fb7e.tar.lz
craftbukkit-c25ddf063a808e3adb749e22017661f403c5fb7e.tar.xz
craftbukkit-c25ddf063a808e3adb749e22017661f403c5fb7e.zip
Update to Minecraft 1.11
Diffstat (limited to 'nms-patches')
-rw-r--r--nms-patches/Block.patch16
-rw-r--r--nms-patches/BlockButtonAbstract.patch2
-rw-r--r--nms-patches/BlockCactus.patch2
-rw-r--r--nms-patches/BlockCake.patch6
-rw-r--r--nms-patches/BlockCauldron.patch65
-rw-r--r--nms-patches/BlockChorusFlower.patch4
-rw-r--r--nms-patches/BlockCommand.patch10
-rw-r--r--nms-patches/BlockCrops.patch8
-rw-r--r--nms-patches/BlockDaylightDetector.patch2
-rw-r--r--nms-patches/BlockDiodeAbstract.patch6
-rw-r--r--nms-patches/BlockDispenser.patch10
-rw-r--r--nms-patches/BlockDoor.patch25
-rw-r--r--nms-patches/BlockDragonEgg.patch6
-rw-r--r--nms-patches/BlockDropper.patch24
-rw-r--r--nms-patches/BlockEnderPortal.patch2
-rw-r--r--nms-patches/BlockFire.patch8
-rw-r--r--nms-patches/BlockGrass.patch10
-rw-r--r--nms-patches/BlockIce.patch2
-rw-r--r--nms-patches/BlockJukeBox.patch8
-rw-r--r--nms-patches/BlockLeaves.patch6
-rw-r--r--nms-patches/BlockMobSpawner.patch2
-rw-r--r--nms-patches/BlockMycel.patch8
-rw-r--r--nms-patches/BlockNetherWart.patch2
-rw-r--r--nms-patches/BlockOre.patch4
-rw-r--r--nms-patches/BlockPiston.patch10
-rw-r--r--nms-patches/BlockPortal.patch14
-rw-r--r--nms-patches/BlockPoweredRail.patch2
-rw-r--r--nms-patches/BlockPumpkin.patch2
-rw-r--r--nms-patches/BlockRedstoneLamp.patch10
-rw-r--r--nms-patches/BlockRedstoneOre.patch14
-rw-r--r--nms-patches/BlockRedstoneTorch.patch12
-rw-r--r--nms-patches/BlockSapling.patch6
-rw-r--r--nms-patches/BlockShulkerBox.patch45
-rw-r--r--nms-patches/BlockSkull.patch34
-rw-r--r--nms-patches/BlockSnow.patch4
-rw-r--r--nms-patches/BlockSoil.patch14
-rw-r--r--nms-patches/BlockTrapdoor.patch2
-rw-r--r--nms-patches/BlockTripwire.patch2
-rw-r--r--nms-patches/BlockVine.patch10
-rw-r--r--nms-patches/ChatModifier.patch5
-rw-r--r--nms-patches/Chunk.patch8
-rw-r--r--nms-patches/ChunkProviderGenerate.patch2
-rw-r--r--nms-patches/ChunkProviderServer.patch12
-rw-r--r--nms-patches/ChunkRegionLoader.patch30
-rw-r--r--nms-patches/CommandBlockListenerAbstract.patch19
-rw-r--r--nms-patches/CommandExecute.patch12
-rw-r--r--nms-patches/Container.patch131
-rw-r--r--nms-patches/ContainerAnvil.patch52
-rw-r--r--nms-patches/ContainerBeacon.patch9
-rw-r--r--nms-patches/ContainerBrewingStand.patch14
-rw-r--r--nms-patches/ContainerChest.patch9
-rw-r--r--nms-patches/ContainerDispenser.patch9
-rw-r--r--nms-patches/ContainerEnchantTable.patch47
-rw-r--r--nms-patches/ContainerFurnace.patch10
-rw-r--r--nms-patches/ContainerHopper.patch7
-rw-r--r--nms-patches/ContainerHorse.patch11
-rw-r--r--nms-patches/ContainerMerchant.patch9
-rw-r--r--nms-patches/ContainerPlayer.patch27
-rw-r--r--nms-patches/ContainerShulkerBox.patch34
-rw-r--r--nms-patches/ContainerWorkbench.patch13
-rw-r--r--nms-patches/CraftingManager.patch10
-rw-r--r--nms-patches/DedicatedServer.patch29
-rw-r--r--nms-patches/DispenseBehaviorItem.patch2
-rw-r--r--nms-patches/DispenseBehaviorProjectile.patch10
-rw-r--r--nms-patches/DispenserRegistry.patch99
-rw-r--r--nms-patches/Enchantment.patch6
-rw-r--r--nms-patches/EnchantmentFrostWalker.patch2
-rw-r--r--nms-patches/Entity.patch96
-rw-r--r--nms-patches/EntityAgeable.patch21
-rw-r--r--nms-patches/EntityAnimal.patch18
-rw-r--r--nms-patches/EntityAreaEffectCloud.patch8
-rw-r--r--nms-patches/EntityArmorStand.patch12
-rw-r--r--nms-patches/EntityArrow.patch34
-rw-r--r--nms-patches/EntityBoat.patch21
-rw-r--r--nms-patches/EntityChicken.patch12
-rw-r--r--nms-patches/EntityCow.patch12
-rw-r--r--nms-patches/EntityCreature.patch12
-rw-r--r--nms-patches/EntityCreeper.patch26
-rw-r--r--nms-patches/EntityDamageSourceIndirect.patch2
-rw-r--r--nms-patches/EntityEgg.patch84
-rw-r--r--nms-patches/EntityEnderDragon.patch18
-rw-r--r--nms-patches/EntityEnderman.patch4
-rw-r--r--nms-patches/EntityExperienceOrb.patch10
-rw-r--r--nms-patches/EntityFallingBlock.patch6
-rw-r--r--nms-patches/EntityFireball.patch12
-rw-r--r--nms-patches/EntityFireworks.patch2
-rw-r--r--nms-patches/EntityFishingHook.patch81
-rw-r--r--nms-patches/EntityHanging.patch4
-rw-r--r--nms-patches/EntityHorseAbstract.patch (renamed from nms-patches/EntityHorse.patch)83
-rw-r--r--nms-patches/EntityHuman.patch86
-rw-r--r--nms-patches/EntityInsentient.patch62
-rw-r--r--nms-patches/EntityIronGolem.patch2
-rw-r--r--nms-patches/EntityItem.patch57
-rw-r--r--nms-patches/EntityItemFrame.patch8
-rw-r--r--nms-patches/EntityLeash.patch31
-rw-r--r--nms-patches/EntityLightning.patch14
-rw-r--r--nms-patches/EntityLiving.patch176
-rw-r--r--nms-patches/EntityLlamaSpit.patch11
-rw-r--r--nms-patches/EntityMinecartAbstract.patch30
-rw-r--r--nms-patches/EntityMinecartCommandBlock.patch10
-rw-r--r--nms-patches/EntityMinecartContainer.patch14
-rw-r--r--nms-patches/EntityMonster.patch2
-rw-r--r--nms-patches/EntityMushroomCow.patch4
-rw-r--r--nms-patches/EntityOcelot.patch4
-rw-r--r--nms-patches/EntityPig.patch6
-rw-r--r--nms-patches/EntityPlayer.patch176
-rw-r--r--nms-patches/EntityPotion.patch193
-rw-r--r--nms-patches/EntityRabbit.patch2
-rw-r--r--nms-patches/EntitySheep.patch14
-rw-r--r--nms-patches/EntitySilverfish.patch10
-rw-r--r--nms-patches/EntitySkeleton.patch84
-rw-r--r--nms-patches/EntitySkeletonAbstract.patch71
-rw-r--r--nms-patches/EntitySlime.patch6
-rw-r--r--nms-patches/EntitySnowman.patch6
-rw-r--r--nms-patches/EntityTNTPrimed.patch13
-rw-r--r--nms-patches/EntityThrownExpBottle.patch6
-rw-r--r--nms-patches/EntityTippedArrow.patch6
-rw-r--r--nms-patches/EntityTracker.patch2
-rw-r--r--nms-patches/EntityTrackerEntry.patch8
-rw-r--r--nms-patches/EntityVex.patch19
-rw-r--r--nms-patches/EntityVillager.patch48
-rw-r--r--nms-patches/EntityWither.patch12
-rw-r--r--nms-patches/EntityWolf.patch16
-rw-r--r--nms-patches/EntityZombie.patch70
-rw-r--r--nms-patches/EntityZombieVillager.patch31
-rw-r--r--nms-patches/Explosion.patch24
-rw-r--r--nms-patches/FoodMetaData.patch10
-rw-r--r--nms-patches/HandshakeListener.patch4
-rw-r--r--nms-patches/IDataManager.patch2
-rw-r--r--nms-patches/IInventory.patch14
-rw-r--r--nms-patches/IRecipe.patch4
-rw-r--r--nms-patches/InventoryCraftResult.patch14
-rw-r--r--nms-patches/InventoryCrafting.patch10
-rw-r--r--nms-patches/InventoryEnderChest.patch53
-rw-r--r--nms-patches/InventoryHorseChest.patch63
-rw-r--r--nms-patches/InventoryLargeChest.patch18
-rw-r--r--nms-patches/InventoryMerchant.patch8
-rw-r--r--nms-patches/InventorySubcontainer.patch8
-rw-r--r--nms-patches/ItemArmor.patch21
-rw-r--r--nms-patches/ItemBlock.patch6
-rw-r--r--nms-patches/ItemBoat.patch2
-rw-r--r--nms-patches/ItemBow.patch12
-rw-r--r--nms-patches/ItemBucket.patch37
-rw-r--r--nms-patches/ItemChorusFruit.patch8
-rw-r--r--nms-patches/ItemDye.patch6
-rw-r--r--nms-patches/ItemFireball.patch6
-rw-r--r--nms-patches/ItemFishingRod.patch30
-rw-r--r--nms-patches/ItemFlintAndSteel.patch4
-rw-r--r--nms-patches/ItemHanging.patch2
-rw-r--r--nms-patches/ItemMapEmpty.patch26
-rw-r--r--nms-patches/ItemMinecart.patch8
-rw-r--r--nms-patches/ItemMonsterEgg.patch17
-rw-r--r--nms-patches/ItemRecord.patch4
-rw-r--r--nms-patches/ItemSkull.patch2
-rw-r--r--nms-patches/ItemSnowball.patch18
-rw-r--r--nms-patches/ItemStack.patch134
-rw-r--r--nms-patches/ItemWaterLily.patch4
-rw-r--r--nms-patches/ItemWorldMap.patch64
-rw-r--r--nms-patches/LoginListener.patch20
-rw-r--r--nms-patches/MerchantRecipe.patch10
-rw-r--r--nms-patches/MinecraftServer.patch102
-rw-r--r--nms-patches/MobEffectList.patch6
-rw-r--r--nms-patches/MobSpawnerAbstract.patch2
-rw-r--r--nms-patches/PacketDataSerializer.patch12
-rw-r--r--nms-patches/PathfinderGoalBreed.patch6
-rw-r--r--nms-patches/PathfinderGoalHorseTrap.patch34
-rw-r--r--nms-patches/PathfinderGoalHurtByTarget.patch2
-rw-r--r--nms-patches/PathfinderGoalNearestAttackableTarget.patch14
-rw-r--r--nms-patches/PathfinderGoalPanic.patch2
-rw-r--r--nms-patches/PathfinderGoalTame.patch4
-rw-r--r--nms-patches/PathfinderGoalTarget.patch12
-rw-r--r--nms-patches/PathfinderGoalTempt.patch8
-rw-r--r--nms-patches/PathfinderGoalVillagerFarm.patch11
-rw-r--r--nms-patches/PlayerConnection.patch351
-rw-r--r--nms-patches/PlayerInteractManager.patch156
-rw-r--r--nms-patches/PlayerInventory.patch61
-rw-r--r--nms-patches/PlayerList.patch59
-rw-r--r--nms-patches/RecipeArmorDye.patch6
-rw-r--r--nms-patches/RecipeBookClone.patch5
-rw-r--r--nms-patches/RecipeFireworks.patch12
-rw-r--r--nms-patches/RecipeMapClone.patch5
-rw-r--r--nms-patches/RecipeRepair.patch6
-rw-r--r--nms-patches/RecipeShulkerBox.patch18
-rw-r--r--nms-patches/RecipeTippedArrow.patch16
-rw-r--r--nms-patches/RecipesBanner.patch10
-rw-r--r--nms-patches/RecipesFurnace.patch14
-rw-r--r--nms-patches/RecipiesShield.patch8
-rw-r--r--nms-patches/RegionFile.patch4
-rw-r--r--nms-patches/RegionFileCache.patch14
-rw-r--r--nms-patches/ShapedRecipes.patch10
-rw-r--r--nms-patches/ShapelessRecipes.patch8
-rw-r--r--nms-patches/Slot.patch12
-rw-r--r--nms-patches/SlotFurnaceResult.patch8
-rw-r--r--nms-patches/StructureGenerator.patch38
-rw-r--r--nms-patches/TileEntity.patch8
-rw-r--r--nms-patches/TileEntityBanner.patch28
-rw-r--r--nms-patches/TileEntityBeacon.patch55
-rw-r--r--nms-patches/TileEntityBrewingStand.patch34
-rw-r--r--nms-patches/TileEntityChest.patch58
-rw-r--r--nms-patches/TileEntityDispenser.patch35
-rw-r--r--nms-patches/TileEntityEndGateway.patch6
-rw-r--r--nms-patches/TileEntityFurnace.patch82
-rw-r--r--nms-patches/TileEntityHopper.patch48
-rw-r--r--nms-patches/TileEntityPiston.patch10
-rw-r--r--nms-patches/TileEntityShulkerBox.patch54
-rw-r--r--nms-patches/TileEntitySign.patch6
-rw-r--r--nms-patches/Village.patch2
-rw-r--r--nms-patches/VillageSiege.patch2
-rw-r--r--nms-patches/World.patch110
-rw-r--r--nms-patches/WorldGenRegistration.patch4
-rw-r--r--nms-patches/WorldGenVillagePieces.patch24
-rw-r--r--nms-patches/WorldManager.patch8
-rw-r--r--nms-patches/WorldMap.patch14
-rw-r--r--nms-patches/WorldNBTStorage.patch4
-rw-r--r--nms-patches/WorldServer.patch72
215 files changed, 2608 insertions, 2700 deletions
diff --git a/nms-patches/Block.patch b/nms-patches/Block.patch
index 3a0d2338..18446d80 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 d114d927..59694bc6 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 951d5a9b..282dcd80 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 64b1aec1..a588357c 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 08b09fac..a21ef981 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 95acef09..e5482d55 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 c791a4a0..808f7944 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 22e562bc..385751da 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 134da667..a9525a88 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 36e5c204..e5d9e7d5 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 0ab8ace8..a46b1eef 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<Item, IDispenseBehavior> 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 0de53123..1946c5af 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 454b3191..af397c67 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 cdb5ed4e..07c21cb4 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 5f27102f..9501e5e7 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 2c6895da..9e67ce29 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 741320cc..040f26ae 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 6d0beefb..2971d276 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 ac548cae..477d255e 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 5867b84e..bb3a479d 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 708f413b..67c46a90 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 8fbe0109..626b81bf 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 7992cd52..1af3f818 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 9cf76ccc..236ce96e 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 9c7cf575..56b43ae9 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 90264c38..064c6f62 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 f4dfbd55..973f5576 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 27c335cc..d0fc889a 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 19afa4da..1aec6322 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 417cd311..c4b08ac9 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 f2dd63ce..f74f4350 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<World, List<BlockRedstoneTorch.RedstoneUpdateInfo>> 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 42df791c..bce7652f 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 00000000..ef6b04cd
--- /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 ba234cb7..51d202cf 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 434eaed9..4d864b91 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 35c2fd56..33fdfe06 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 31007095..1eb2c40d 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 c4b40aa3..3f955f11 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 03b7104c..c9c4fd8c 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 f84aedb4..bd72bcff 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 5a5ad49b..7d8f1da3 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<BlockPosition> y;
+ private final ConcurrentLinkedQueue<BlockPosition> 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 cbb0143e..65c2bcd9 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 f83e0c22..bcb4586a 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 a2335fa2..fb39a6e0 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 ffa7081e..f23909ee 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<String[]> buildCommands(ICommandListener sender, String[] args, int pos) {
++ private static ArrayList<String[]> buildCommands(ICommandListener sender, String[] args, int pos) throws CommandException {
+ ArrayList<String[]> commands = new ArrayList<String[]>();
+ java.util.List<EntityPlayer> players = (java.util.List<EntityPlayer>)PlayerSelector.getPlayers(sender, args[pos], EntityPlayer.class);
+
diff --git a/nms-patches/CommandExecute.patch b/nms-patches/CommandExecute.patch
index 582c9a25..e36811c1 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 61526875..7e5e2ff8 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<ItemStack> b = Lists.newArrayList();
-@@ -19,12 +30,24 @@
+ public NonNullList<ItemStack> b = NonNullList.a();
+@@ -18,6 +29,18 @@
protected List<ICrafting> listeners = Lists.newArrayList();
private final Set<EntityHuman> 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<Integer, ItemStack> draggedSlots = new HashMap<Integer, ItemStack>(); // 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<Integer, org.bukkit.inventory.ItemStack> eventmap = new HashMap<Integer, org.bukkit.inventory.ItemStack>();
+ for (Map.Entry<Integer, ItemStack> 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 f18c3171..f42c2945 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 0e544bc0..13196bb7 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 98ae5c5e..dc38c122 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 05e02ff5..9535a080 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 9435edcb..9b8b1ad2 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 e7e871e9..4abd722f 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<WeightedRandomEnchant>();
+ }
+ // 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<org.bukkit.enchantments.Enchantment, Integer> enchants = new java.util.HashMap<org.bukkit.enchantments.Enchantment, Integer>();
+ 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 609b2f6f..e64b7818 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 96f6b28a..54117f62 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 c15f5de3..739df215 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 7cd43434..3610204f 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 a79220cb..3e0d58dc 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 00000000..494f7c49
--- /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 d2b2757c..38991fa5 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 d37e1c5c..1e5049d6 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<ItemStack> b(InventoryCrafting inventorycrafting, World world) {
diff --git a/nms-patches/DedicatedServer.patch b/nms-patches/DedicatedServer.patch
index d14694e7..dc698b69 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 61fe049e..f325425f 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 ecf2de1f..a7f5100e 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 35438f17..c53ea444 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 e339cfd6..0f15da1d 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 2078780d..91fda45b 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 fdbdb8b0..e4236955 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<ItemStack> 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<String> aH;
- private boolean aI;
+ private final Set<String> 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 5a95ae6b..5982edfc 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 03998da2..4661fecc 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 21252917..c5009a55 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 9e7ef90b..2f17e36f 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 ef051dd0..f8c15319 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<Entity> 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 3ae4271f..474b0a42 100644
--- a/nms-patches/EntityBoat.patch
+++ b/nms-patches/EntityBoat.patch
@@ -17,8 +17,8 @@
private static final DataWatcherObject<Integer> 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 2dd746a4..c498decf 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 1593b85b..c231dfd8 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 724b55d2..4d141b8f 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 9f413e37..853db77e 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 3c1c0f81..2bd5300b 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 de818824..314bd2fe 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();
+ 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);
++ // CraftBukkit start
++ if (!hatching) {
++ b0 = 0;
++ }
++ EntityType hatchingType = EntityType.CHICKEN;
+
-+ PlayerEggThrowEvent event = new PlayerEggThrowEvent(player, (org.bukkit.entity.Egg) this.getBukkitEntity(), hatching, (byte) numHatching, hatchingType);
-+ this.world.getServer().getPluginManager().callEvent(event);
++ 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);
+
-+ hatching = event.isHatching();
-+ numHatching = event.getNumHatches();
-+ hatchingType = event.getHatchingType();
-+ }
-
-- 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();
++ 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 59a4484f..cf7365ef 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 fbb2c661..dc6ad778 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 21c585c5..fa196829 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 8dd4e980..c43f5e4f 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 2f7072d8..02e43ed8 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 7d26d656..8a06d7bb 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 043d78d7..a00557b3 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<Integer> 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 0f778848..66deea74 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
index b8d8829f..2fcf61ef 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<Entity> 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 e988303a..d0e1cf94 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<Float> a = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.c);
-@@ -20,7 +33,7 @@
- private InventoryEnderChest enderChest = new InventoryEnderChest();
+@@ -16,10 +28,10 @@
+ protected static final DataWatcherObject<Byte> bq = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.a);
+ protected static final DataWatcherObject<Byte> 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 @@
-
- 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 @@
+@@ -1012,7 +1130,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 5cbb4fe4..44801a84 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<Byte> 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<? extends EntityLiving> 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 @@
-
- if (this.bE) {
+ } else {
+ ItemStack itemstack = entityhuman.b(enumhand);
+
+ 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 6b9b2f87..45aee397 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 7fbea393..3b425b41 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 c98af2f2..4178fdcf 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 bea9f62f..c742be1c 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 b686086c..649e5fd3 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<EntityPlayer>) (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 a6e18d34..f5ea0bf7 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();
+
+@@ -817,7 +958,13 @@
+ }
+ }
-@@ -855,6 +994,12 @@
+- 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<Double, Double> hardHat = new Function<Double, Double>() {
+ @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<Double, Double> blocking = new Function<Double, Double>() {
+ @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 00000000..e45072d4
--- /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 70750191..e7b2a9ad 100644
--- a/nms-patches/EntityMinecartAbstract.patch
+++ b/nms-patches/EntityMinecartAbstract.patch
@@ -17,8 +17,8 @@
private static final DataWatcherObject<Integer> 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 7d98421e..1f44e4af 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<String> a = DataWatcher.a(EntityMinecartCommandBlock.class, DataWatcherRegistry.d);
-+ public static final DataWatcherObject<String> a = DataWatcher.a(EntityMinecartCommandBlock.class, DataWatcherRegistry.d); // PAIL: private -> public
+@@ -5,6 +5,9 @@
+ public static final DataWatcherObject<String> COMMAND = DataWatcher.a(EntityMinecartCommandBlock.class, DataWatcherRegistry.d);
private static final DataWatcherObject<IChatBaseComponent> 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 452fa392..15037a60 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<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
+ private int maxStack = MAX_STACK;
+
-+ public ItemStack[] getContents() {
++ public List<ItemStack> 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 5832a4dc..0a19ca7d 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 8a641252..4fa155b3 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 7d433fa4..6574350a 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 a5618b02..81061ed4 100644
--- a/nms-patches/EntityPig.patch
+++ b/nms-patches/EntityPig.patch
@@ -8,8 +8,8 @@
+
public class EntityPig extends EntityAnimal {
- private static final DataWatcherObject<Boolean> bx = DataWatcher.a(EntityPig.class, DataWatcherRegistry.h);
-@@ -137,6 +139,12 @@
+ private static final DataWatcherObject<Boolean> 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 d5fa2376..0ec9bbfa 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<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>();
++ java.util.List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>(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<ItemStack> list) {
- this.playerConnection.sendPacket(new PacketPlayOutWindowItems(container.windowId, list));
+@@ -648,6 +805,11 @@
+ public void a(Container container, NonNullList<ItemStack> 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 ef720315..ccef405f 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<Optional<ItemStack>> 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 @@
+
+ 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<MobEffect> list) {
+ AxisAlignedBB axisalignedbb = this.getBoundingBox().grow(4.0D, 2.0D, 4.0D);
+ List list1 = this.world.a(EntityLiving.class, axisalignedbb);
++ Map<LivingEntity, Double> affected = new HashMap<LivingEntity, Double>(); // CraftBukkit
-+ 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 (!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<LivingEntity, Double> affected = new HashMap<LivingEntity, Double>();
++ affected.put((LivingEntity) entityliving.getBukkitEntity(), d1);
++ }
++ }
++ }
++ }
+
- if (!list1.isEmpty()) {
- Iterator iterator1 = list1.iterator();
-
-@@ -117,21 +135,45 @@
- d1 = 1.0D;
- }
-
-- Iterator iterator2 = list.iterator();
-+ // CraftBukkit start
-+ affected.put((LivingEntity) entityliving.getBukkitEntity(), d1);
-+ }
-+ }
-+ }
-+ }
++ 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;
++ }
-- 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();
- }
- }
-
-@@ -152,6 +194,7 @@
+@@ -167,6 +199,7 @@
+ private void a(ItemStack itemstack, PotionRegistry potionregistry) {
+ EntityAreaEffectCloud entityareaeffectcloud = new EntityAreaEffectCloud(this.world, this.locX, this.locY, this.locZ);
- 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);
++ 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
+ }
+
+ public boolean isLingering() {
diff --git a/nms-patches/EntityRabbit.patch b/nms-patches/EntityRabbit.patch
index ede26f1e..890a0efd 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 c3ca71f7..c20df343 100644
--- a/nms-patches/EntitySheep.patch
+++ b/nms-patches/EntitySheep.patch
@@ -12,7 +12,7 @@
+
public class EntitySheep extends EntityAnimal {
- private static final DataWatcherObject<Byte> bx = DataWatcher.a(EntitySheep.class, DataWatcherRegistry.a);
+ private static final DataWatcherObject<Byte> 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<EnumColor, float[]> bz = Maps.newEnumMap(EnumColor.class);
- private int bB;
+ private static final Map<EnumColor, float[]> 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 1763e175..8e871c3c 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 2d866566..18243710 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<Integer> a = DataWatcher.a(EntitySkeleton.class, DataWatcherRegistry.b);
- private static final DataWatcherObject<Boolean> 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);
- }
-+ super.die(damagesource); // CraftBukkit - moved from above
+ if (damagesource.getEntity() instanceof EntityCreeper) {
+ EntityCreeper entitycreeper = (EntityCreeper) damagesource.getEntity();
- }
-
-@@ -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));
+@@ -43,6 +43,7 @@
+ this.a(new ItemStack(Items.SKULL, 1, 0), 0.0F);
+ }
}
++ super.die(damagesource); // CraftBukkit - moved from above
-+ // 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 00000000..db96e176
--- /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<Boolean> 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 79e5fc28..6e55a144 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 6a190b67..0fc4443b 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 6b765dd8..37d5ae34 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<Integer> 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 c3a19637..256bf0ad 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 145287c6..fce1c47d 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 e9239724..67c6412c 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 db80f3e0..44d34923 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 00000000..0c50e0e2
--- /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 85102eec..697cdc03 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 3e25bf5b..a1be6ae4 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<Integer> 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 da6feb89..85f3026f 100644
--- a/nms-patches/EntityWolf.patch
+++ b/nms-patches/EntityWolf.patch
@@ -12,7 +12,7 @@
public class EntityWolf extends EntityTameableAnimal {
private static final DataWatcherObject<Float> 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 c4348eb1..2acddcba 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
-
- this.bC -= i;
- if (this.bC <= 0) {
-@@ -221,7 +241,14 @@
+@@ -191,7 +205,14 @@
+ float f = this.world.D(new BlockPosition(this)).b();
- 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());
+@@ -284,7 +305,7 @@
+ entityzombievillager.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);
+- this.world.addEntity(entityzombievillager);
++ this.world.addEntity(entityzombievillager, CreatureSpawnEvent.SpawnReason.INFECTION); // CraftBukkit - add SpawnReason
+ this.world.a((EntityHuman) null, 1026, new BlockPosition(this), 0);
}
-@@ -396,7 +423,7 @@
+@@ -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 00000000..776cdba1
--- /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<Boolean> b = DataWatcher.a(EntityZombieVillager.class, DataWatcherRegistry.h);
+ private static final DataWatcherObject<Integer> 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 4cba2e11..ccc8d40f 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<BlockPosition> blocks = Lists.newArrayList();
private final Map<EntityHuman, Vec3D> 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 0e113968..8037db1f 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 5d301b04..7f0640c2 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 cdb07653..362ecd76 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 16aa68e4..0d2e884c 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<ItemStack> getContents();
+
+ void onOpen(CraftHumanEntity who);
+
diff --git a/nms-patches/IRecipe.patch b/nms-patches/IRecipe.patch
index bc315529..bf22eb6d 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<ItemStack> b(InventoryCrafting inventorycrafting);
+
+ org.bukkit.inventory.Recipe toBukkitRecipe(); // CraftBukkit
}
diff --git a/nms-patches/InventoryCraftResult.patch b/nms-patches/InventoryCraftResult.patch
index a87e7e42..3a400769 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<ItemStack> items;
+ // CraftBukkit start
+ private int maxStack = MAX_STACK;
+
-+ public ItemStack[] getContents() {
++ public java.util.List<ItemStack> 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 45dcce2b..97079fa2 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<ItemStack> 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 26b013ce..2591f07e 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 - add fields and methods
-+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
-+ 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<HumanEntity> getViewers() {
-+ return transaction;
-+ }
-+
-+ public org.bukkit.inventory.InventoryHolder getOwner() {
-+ return this.player;
-+ }
-+
-+ public void setMaxStackSize(int size) {
-+ maxStack = size;
-+ }
++ // CraftBukkit start
++ private final EntityHuman owner;
+
-+ public int getMaxStackSize() {
-+ return maxStack;
++ public InventoryHolder getBukkitOwner() {
++ return owner.getBukkitEntity();
+ }
-+ // 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 da3394f5..875dd670 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<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
-+ 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<HumanEntity> 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 253d591a..3ed9ccd8 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<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
+
-+ public ItemStack[] getContents() {
-+ ItemStack[] result = new ItemStack[this.getSize()];
-+ for (int i = 0; i < result.length; i++) {
-+ result[i] = this.getItem(i);
++ public List<ItemStack> getContents() {
++ List<ItemStack> result = new ArrayList<ItemStack>(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 51bf4d59..58445a12 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<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
+ private int maxStack = MAX_STACK;
+
-+ public ItemStack[] getContents() {
++ public List<ItemStack> 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 a57a94a4..ee8e435a 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<ItemStack> 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 ad7f06ea..61627ea6 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 90aa56cb..34d35aaa 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 410c84fd..abcb54aa 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 b168fc48..d17d8d15 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 4a89f897..e486ce13 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 24c43038..2e175882 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 0f537c0d..e92fa188 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 ca644d64..f60e3955 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 b3efc66c..0c8cee22 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 39a667de..bd5b2aa3 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 bdb70304..89b547f8 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 754beb36..00000000
--- 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<ItemStack> 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 393004a7..2a92f8c0 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 cd535c79..95d75a29 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 ef571447..0dff1125 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 c97743da..da4ce8a1 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 e2a91644..64293dcc 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<ItemStack> a(World world, EntityHuman entityhuman, EnumHand enumhand) {
+ ItemStack itemstack = entityhuman.b(enumhand);
- public InteractionResultWrapper<ItemStack> 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 e6cb7f25..cf740c5a 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 @@
+ }
+
+ 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();
}
-@@ -81,11 +104,137 @@
+@@ -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 ab27cf91..89115f24 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 dde295a5..42baeba5 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 ae5fb655..ceee1d4e 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 7a85d094..176a59b2 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 909dba27..a60fd8bf 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<String> 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 <V> ListenableFuture<V> a(Callable<V> 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 c2e9b5e2..c7556e15 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 408e3a46..21298f01 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 00bc7794..d257ef48 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 e928ca43..4b9f88cf 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 c20e929d..84842053 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 bf9f1666..e0e2e610 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 09c3172e..d1ceb69a 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 41b58874..fa425967 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 395bffec..8026e5b2 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 6aade4c9..acab1523 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 d59fc830..df8f4dcb 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<Item> 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 449a3a77..b24ce69b 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 dcf3649c..9bb29cef 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<Short> 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<Integer> invalidItems = new HashSet<Integer>(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<PacketPlayOutPosition.EnumPlayerTeleportFlags> 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.<PacketPlayOutPosition.EnumPlayerTeleportFlags>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<PacketPlayOutPosition.EnumPlayerTeleportFlags> 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 @@
- }
-
- 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 @@
+@@ -1062,10 +2139,12 @@
+ }
- 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 89fc8b9b..c29cc77a 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 1dfab011..543011b5 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<ItemStack> items;
+@@ -16,11 +25,54 @@
private ItemStack carried;
public boolean f;
@@ -23,15 +24,16 @@
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
+ 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<ItemStack> getContents() {
++ List<ItemStack> combined = new ArrayList<ItemStack>(items.size() + armor.size() + extraSlots.size());
++ for (List<net.minecraft.server.ItemStack> sub : this.g) {
++ combined.addAll(sub);
++ }
++
+ return combined;
+ }
+
-+ public ItemStack[] getArmorContents() {
++ public List<ItemStack> 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 207bdf0c..24d35178 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 b48d0e5b..da5dd043 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 66e76dc1..022d5e7f 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 7532dc06..f4ed6fbf 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 2b067463..23496349 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 ab7e7331..1d0f9144 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 00000000..7f602345
--- /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 dbf39cc1..c828203e 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 @@
- import java.util.Collection;
- import javax.annotation.Nullable;
+@@ -2,9 +2,17 @@
--class RecipeTippedArrow implements IRecipe {
-+class RecipeTippedArrow extends ShapedRecipes implements IRecipe { // CraftBukkit
+ import java.util.Collection;
- private static final ItemStack[] a = new ItemStack[9];
+-public class RecipeTippedArrow implements IRecipe {
++public class RecipeTippedArrow extends ShapedRecipes implements IRecipe { // CraftBukkit
-- 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 09c32114..3de6f89e 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 9c2f9bf8..62124ddc 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 827907a0..236e726a 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 5dd5c60a..de585900 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 e1839bff..e97b881c 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 d76aa390..9f7c4969 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 eee448a9..0ed46af4 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 31176516..00000000
--- 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 dc7854fc..bcc110d7 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 72129e0e..00000000
--- 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 d11d0ddd..3b5db83a 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 caf443b0..c9294ee0 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 74447104..91779ec9 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<MobEffectList> f = Sets.newHashSet();
- private final List<TileEntityBeacon.BeaconColorTracker> 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<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
+ private int maxStack = MAX_STACK;
+
-+ public ItemStack[] getContents() {
-+ return new ItemStack[] { this.inventorySlot };
++ public List<ItemStack> 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 a0b64d7f..ccbc2794 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<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
+ private int maxStack = 64;
+
@@ -38,7 +35,7 @@
+ return transaction;
+ }
+
-+ public ItemStack[] getContents() {
++ public List<ItemStack> 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 1dfb8f18..c302cf64 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<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
+ private int maxStack = MAX_STACK;
+
-+ public ItemStack[] getContents() {
++ public List<ItemStack> 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<ItemStack> 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 5080012f..3414c8aa 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<ItemStack> items;
+ // CraftBukkit start - add fields and methods
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
+ private int maxStack = MAX_STACK;
+
-+ public ItemStack[] getContents() {
++ public List<ItemStack> 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 cb6f07d7..35bfeee3 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 2c0539b7..5c01f0b7 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<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
+
-+ public ItemStack[] getContents() {
++ public List<ItemStack> 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 32d757c8..9393ad7a 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<ItemStack> items;
+ private int f;
+ private long g;
+ // CraftBukkit start - add fields and methods
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
+ private int maxStack = MAX_STACK;
+
-+ public ItemStack[] getContents() {
++ public List<ItemStack> 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 b7f7c901..00000000
--- 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 00000000..6af5516b
--- /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<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
++ private int maxStack = MAX_STACK;
++
++ public List<ItemStack> getContents() {
++ return this.f;
++ }
++
++ public void onOpen(CraftHumanEntity who) {
++ transaction.add(who);
++ }
++
++ public void onClose(CraftHumanEntity who) {
++ transaction.remove(who);
++ }
++
++ public List<HumanEntity> 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 de4c4164..ec5bfd9e 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 ca9591e2..a142c50a 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 811d9f73..626a008a 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 23fffec4..63230475 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<Entity> 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 d4e74798..cd4e2ca9 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 021d1768..6f5ae761 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 98623a14..e1861fd8 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 40d2af95..5c8d8157 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<EntityHuman, WorldMap.WorldMapHumanTracker> j = Maps.newHashMap();
+@@ -20,8 +28,18 @@
+ private final Map<EntityHuman, WorldMap.WorldMapHumanTracker> k = Maps.newHashMap();
public Map<String, MapIcon> 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 5195c15f..4f3b18e3 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 1c5e7557..f73bc578 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<Entity> 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) {