summaryrefslogtreecommitdiffstats
path: root/nms-patches
diff options
context:
space:
mode:
authormd_5 <git@md-5.net>2018-07-15 10:00:00 +1000
committermd_5 <git@md-5.net>2018-07-15 10:00:00 +1000
commit421c1728c81e2f729dff88da2ac96535d2b8e5e8 (patch)
tree6c51d93e811d1eb86b68461a42fc5cf03b168b0c /nms-patches
parent57ab4cfc6f4ff526d44319d9b8c79f6848db2de7 (diff)
downloadcraftbukkit-421c1728c81e2f729dff88da2ac96535d2b8e5e8.tar
craftbukkit-421c1728c81e2f729dff88da2ac96535d2b8e5e8.tar.gz
craftbukkit-421c1728c81e2f729dff88da2ac96535d2b8e5e8.tar.lz
craftbukkit-421c1728c81e2f729dff88da2ac96535d2b8e5e8.tar.xz
craftbukkit-421c1728c81e2f729dff88da2ac96535d2b8e5e8.zip
Update to Minecraft 1.13-pre7
Diffstat (limited to 'nms-patches')
-rw-r--r--nms-patches/Advancement.patch11
-rw-r--r--nms-patches/AdvancementDataPlayer.patch59
-rw-r--r--nms-patches/AdvancementRewards.patch52
-rw-r--r--nms-patches/Advancements.patch6
-rw-r--r--nms-patches/Block.patch61
-rw-r--r--nms-patches/BlockButtonAbstract.patch76
-rw-r--r--nms-patches/BlockCactus.patch25
-rw-r--r--nms-patches/BlockCake.patch4
-rw-r--r--nms-patches/BlockCauldron.patch70
-rw-r--r--nms-patches/BlockChorusFlower.patch75
-rw-r--r--nms-patches/BlockCocoa.patch26
-rw-r--r--nms-patches/BlockCommand.patch4
-rw-r--r--nms-patches/BlockConcretePowder.patch48
-rw-r--r--nms-patches/BlockCrops.patch20
-rw-r--r--nms-patches/BlockDaylightDetector.patch6
-rw-r--r--nms-patches/BlockDiodeAbstract.patch22
-rw-r--r--nms-patches/BlockDirtSnowSpreadable.patch23
-rw-r--r--nms-patches/BlockDispenser.patch22
-rw-r--r--nms-patches/BlockDoor.patch47
-rw-r--r--nms-patches/BlockDragonEgg.patch41
-rw-r--r--nms-patches/BlockDropper.patch54
-rw-r--r--nms-patches/BlockEnderPortal.patch14
-rw-r--r--nms-patches/BlockFire.patch158
-rw-r--r--nms-patches/BlockFlowing.patch66
-rw-r--r--nms-patches/BlockFluids.patch30
-rw-r--r--nms-patches/BlockGrass.patch72
-rw-r--r--nms-patches/BlockIce.patch8
-rw-r--r--nms-patches/BlockJukeBox.patch14
-rw-r--r--nms-patches/BlockLeaves.patch34
-rw-r--r--nms-patches/BlockLever.patch17
-rw-r--r--nms-patches/BlockMagma.patch2
-rw-r--r--nms-patches/BlockMinecartDetector.patch8
-rw-r--r--nms-patches/BlockMobSpawner.patch10
-rw-r--r--nms-patches/BlockMonsterEggs.patch8
-rw-r--r--nms-patches/BlockMushroom.patch38
-rw-r--r--nms-patches/BlockMycel.patch58
-rw-r--r--nms-patches/BlockNetherWart.patch9
-rw-r--r--nms-patches/BlockNote.patch46
-rw-r--r--nms-patches/BlockOre.patch18
-rw-r--r--nms-patches/BlockPiston.patch51
-rw-r--r--nms-patches/BlockPlant.patch24
-rw-r--r--nms-patches/BlockPortal.patch80
-rw-r--r--nms-patches/BlockPoweredRail.patch19
-rw-r--r--nms-patches/BlockPressurePlateAbstract.patch8
-rw-r--r--nms-patches/BlockPressurePlateBinary.patch2
-rw-r--r--nms-patches/BlockPressurePlateWeighted.patch6
-rw-r--r--nms-patches/BlockPumpkin.patch81
-rw-r--r--nms-patches/BlockPumpkinCarved.patch65
-rw-r--r--nms-patches/BlockRedstoneLamp.patch57
-rw-r--r--nms-patches/BlockRedstoneOre.patch69
-rw-r--r--nms-patches/BlockRedstoneTorch.patch39
-rw-r--r--nms-patches/BlockRedstoneWire.patch8
-rw-r--r--nms-patches/BlockReed.patch21
-rw-r--r--nms-patches/BlockSapling.patch135
-rw-r--r--nms-patches/BlockShulkerBox.patch65
-rw-r--r--nms-patches/BlockSkull.patch123
-rw-r--r--nms-patches/BlockSkullAbstract.patch45
-rw-r--r--nms-patches/BlockSnow.patch8
-rw-r--r--nms-patches/BlockSnowBlock.patch8
-rw-r--r--nms-patches/BlockSoil.patch23
-rw-r--r--nms-patches/BlockStateInteger.patch18
-rw-r--r--nms-patches/BlockStationary.patch40
-rw-r--r--nms-patches/BlockStem.patch44
-rw-r--r--nms-patches/BlockTNT.patch6
-rw-r--r--nms-patches/BlockTallPlant.patch20
-rw-r--r--nms-patches/BlockTrapdoor.patch14
-rw-r--r--nms-patches/BlockTripwire.patch8
-rw-r--r--nms-patches/BlockTripwireHook.patch6
-rw-r--r--nms-patches/BlockVine.patch102
-rw-r--r--nms-patches/BlockWaterLily.patch8
-rw-r--r--nms-patches/BlockWitherSkull.patch66
-rw-r--r--nms-patches/ChatBaseComponent.patch11
-rw-r--r--nms-patches/ChatModifier.patch45
-rw-r--r--nms-patches/Chunk.patch167
-rw-r--r--nms-patches/ChunkMap.patch88
-rw-r--r--nms-patches/ChunkProviderGenerate.patch13
-rw-r--r--nms-patches/ChunkProviderServer.patch136
-rw-r--r--nms-patches/ChunkRegionLoader.patch284
-rw-r--r--nms-patches/ChunkSection.patch36
-rw-r--r--nms-patches/CommandBlockListenerAbstract.patch214
-rw-r--r--nms-patches/CommandDebug.patch46
-rw-r--r--nms-patches/CommandDispatcher.patch189
-rw-r--r--nms-patches/CommandExecute.patch58
-rw-r--r--nms-patches/CommandGamemode.patch45
-rw-r--r--nms-patches/CommandGamerule.patch23
-rw-r--r--nms-patches/CommandListenerWrapper.patch46
-rw-r--r--nms-patches/CommandSpreadPlayers.patch42
-rw-r--r--nms-patches/CommandTeleport.patch27
-rw-r--r--nms-patches/CommandTp.patch45
-rw-r--r--nms-patches/Container.patch10
-rw-r--r--nms-patches/ContainerAnvil.patch24
-rw-r--r--nms-patches/ContainerEnchantTable.patch42
-rw-r--r--nms-patches/ContainerFurnace.patch15
-rw-r--r--nms-patches/ContainerPlayer.patch30
-rw-r--r--nms-patches/ContainerWorkbench.patch10
-rw-r--r--nms-patches/CraftingManager.patch43
-rw-r--r--nms-patches/CrashReport.patch6
-rw-r--r--nms-patches/CustomFunction.patch22
-rw-r--r--nms-patches/CustomFunctionData.patch65
-rw-r--r--nms-patches/DamageSource.patch6
-rw-r--r--nms-patches/DataConverterFlatten.patch11
-rw-r--r--nms-patches/DataConverterMap.patch20
-rw-r--r--nms-patches/DataInspectorBlockEntity.patch12
-rw-r--r--nms-patches/DataPaletteBlock.patch25
-rw-r--r--nms-patches/DataWatcher.patch14
-rw-r--r--nms-patches/DedicatedServer.patch111
-rw-r--r--nms-patches/DispenseBehaviorItem.patch7
-rw-r--r--nms-patches/DispenseBehaviorProjectile.patch2
-rw-r--r--nms-patches/DispenserRegistry.patch386
-rw-r--r--nms-patches/Enchantment.patch35
-rw-r--r--nms-patches/EnchantmentFrostWalker.patch12
-rw-r--r--nms-patches/EnchantmentThorns.patch2
-rw-r--r--nms-patches/Entity.patch217
-rw-r--r--nms-patches/EntityAgeable.patch36
-rw-r--r--nms-patches/EntityAnimal.patch18
-rw-r--r--nms-patches/EntityAreaEffectCloud.patch16
-rw-r--r--nms-patches/EntityArmorStand.patch76
-rw-r--r--nms-patches/EntityArrow.patch72
-rw-r--r--nms-patches/EntityBoat.patch56
-rw-r--r--nms-patches/EntityChicken.patch22
-rw-r--r--nms-patches/EntityCow.patch2
-rw-r--r--nms-patches/EntityCreature.patch13
-rw-r--r--nms-patches/EntityCreeper.patch33
-rw-r--r--nms-patches/EntityDamageSourceIndirect.patch2
-rw-r--r--nms-patches/EntityEgg.patch2
-rw-r--r--nms-patches/EntityEnderCrystal.patch8
-rw-r--r--nms-patches/EntityEnderDragon.patch25
-rw-r--r--nms-patches/EntityEnderPearl.patch2
-rw-r--r--nms-patches/EntityEnderSignal.patch19
-rw-r--r--nms-patches/EntityEnderman.patch43
-rw-r--r--nms-patches/EntityEvokerFangs.patch2
-rw-r--r--nms-patches/EntityExperienceOrb.patch27
-rw-r--r--nms-patches/EntityFallingBlock.patch22
-rw-r--r--nms-patches/EntityFireball.patch21
-rw-r--r--nms-patches/EntityFireworks.patch14
-rw-r--r--nms-patches/EntityFishingHook.patch54
-rw-r--r--nms-patches/EntityGhast.patch2
-rw-r--r--nms-patches/EntityHanging.patch14
-rw-r--r--nms-patches/EntityHorseAbstract.patch50
-rw-r--r--nms-patches/EntityHorseChestedAbstract.patch2
-rw-r--r--nms-patches/EntityHuman.patch100
-rw-r--r--nms-patches/EntityInsentient.patch77
-rw-r--r--nms-patches/EntityIronGolem.patch17
-rw-r--r--nms-patches/EntityItem.patch48
-rw-r--r--nms-patches/EntityItemFrame.patch6
-rw-r--r--nms-patches/EntityLargeFireball.patch6
-rw-r--r--nms-patches/EntityLeash.patch2
-rw-r--r--nms-patches/EntityLightning.patch90
-rw-r--r--nms-patches/EntityLiving.patch143
-rw-r--r--nms-patches/EntityLlamaSpit.patch2
-rw-r--r--nms-patches/EntityMinecartAbstract.patch58
-rw-r--r--nms-patches/EntityMinecartCommandBlock.patch21
-rw-r--r--nms-patches/EntityMinecartContainer.patch8
-rw-r--r--nms-patches/EntityMonster.patch26
-rw-r--r--nms-patches/EntityMushroomCow.patch4
-rw-r--r--nms-patches/EntityOcelot.patch10
-rw-r--r--nms-patches/EntityPainting.patch9
-rw-r--r--nms-patches/EntityParrot.patch97
-rw-r--r--nms-patches/EntityPhantom.patch20
-rw-r--r--nms-patches/EntityPig.patch14
-rw-r--r--nms-patches/EntityPlayer.patch425
-rw-r--r--nms-patches/EntityPotion.patch14
-rw-r--r--nms-patches/EntityProjectile.patch12
-rw-r--r--nms-patches/EntityRabbit.patch16
-rw-r--r--nms-patches/EntitySheep.patch43
-rw-r--r--nms-patches/EntityShulker.patch15
-rw-r--r--nms-patches/EntityShulkerBullet.patch12
-rw-r--r--nms-patches/EntitySilverfish.patch16
-rw-r--r--nms-patches/EntitySkeleton.patch6
-rw-r--r--nms-patches/EntitySkeletonAbstract.patch38
-rw-r--r--nms-patches/EntitySkeletonWither.patch6
-rw-r--r--nms-patches/EntitySlime.patch9
-rw-r--r--nms-patches/EntitySmallFireball.patch12
-rw-r--r--nms-patches/EntitySnowman.patch14
-rw-r--r--nms-patches/EntitySpider.patch2
-rw-r--r--nms-patches/EntityTNTPrimed.patch6
-rw-r--r--nms-patches/EntityThrownExpBottle.patch2
-rw-r--r--nms-patches/EntityTracker.patch15
-rw-r--r--nms-patches/EntityTrackerEntry.patch2
-rw-r--r--nms-patches/EntityTypes.patch39
-rw-r--r--nms-patches/EntityVex.patch2
-rw-r--r--nms-patches/EntityVillager.patch39
-rw-r--r--nms-patches/EntityWither.patch20
-rw-r--r--nms-patches/EntityWitherSkull.patch6
-rw-r--r--nms-patches/EntityWolf.patch28
-rw-r--r--nms-patches/EntityZombie.patch56
-rw-r--r--nms-patches/EntityZombieVillager.patch16
-rw-r--r--nms-patches/ExpirableListEntry.patch4
-rw-r--r--nms-patches/Explosion.patch36
-rw-r--r--nms-patches/FluidTypeFlowing.patch46
-rw-r--r--nms-patches/FluidTypeLava.patch44
-rw-r--r--nms-patches/FoodMetaData.patch2
-rw-r--r--nms-patches/FurnaceRecipe.patch44
-rw-r--r--nms-patches/HandshakeListener.patch4
-rw-r--r--nms-patches/ICommandListener.patch9
-rw-r--r--nms-patches/IDataManager.patch6
-rw-r--r--nms-patches/IInventory.patch15
-rw-r--r--nms-patches/IRecipe.patch10
-rw-r--r--nms-patches/IWorldWriter.patch11
-rw-r--r--nms-patches/InventoryCraftResult.patch4
-rw-r--r--nms-patches/InventoryCrafting.patch20
-rw-r--r--nms-patches/InventoryEnderChest.patch2
-rw-r--r--nms-patches/InventoryHorseChest.patch8
-rw-r--r--nms-patches/InventoryLargeChest.patch13
-rw-r--r--nms-patches/InventoryMerchant.patch8
-rw-r--r--nms-patches/InventorySubcontainer.patch22
-rw-r--r--nms-patches/ItemArmor.patch12
-rw-r--r--nms-patches/ItemBlock.patch32
-rw-r--r--nms-patches/ItemBoat.patch14
-rw-r--r--nms-patches/ItemBow.patch24
-rw-r--r--nms-patches/ItemBucket.patch87
-rw-r--r--nms-patches/ItemChorusFruit.patch4
-rw-r--r--nms-patches/ItemDye.patch20
-rw-r--r--nms-patches/ItemEnderPearl.patch6
-rw-r--r--nms-patches/ItemFireball.patch28
-rw-r--r--nms-patches/ItemFishingRod.patch35
-rw-r--r--nms-patches/ItemFlintAndSteel.patch26
-rw-r--r--nms-patches/ItemHanging.patch6
-rw-r--r--nms-patches/ItemLeash.patch4
-rw-r--r--nms-patches/ItemMinecart.patch4
-rw-r--r--nms-patches/ItemMonsterEgg.patch30
-rw-r--r--nms-patches/ItemRecord.patch10
-rw-r--r--nms-patches/ItemRedstone.patch11
-rw-r--r--nms-patches/ItemReed.patch11
-rw-r--r--nms-patches/ItemSkullPlayer.patch (renamed from nms-patches/ItemSkull.patch)6
-rw-r--r--nms-patches/ItemSnowball.patch8
-rw-r--r--nms-patches/ItemStack.patch388
-rw-r--r--nms-patches/ItemWaterLily.patch12
-rw-r--r--nms-patches/ItemWorldMap.patch137
-rw-r--r--nms-patches/ItemWrittenBook.patch54
-rw-r--r--nms-patches/JsonList.patch29
-rw-r--r--nms-patches/LoginListener.patch39
-rw-r--r--nms-patches/MethodProfiler.patch66
-rw-r--r--nms-patches/MinecraftServer.patch520
-rw-r--r--nms-patches/MobEffectList.patch29
-rw-r--r--nms-patches/MobSpawnerAbstract.patch40
-rw-r--r--nms-patches/NameReferencingFileConverter.patch14
-rw-r--r--nms-patches/NetworkManager.patch31
-rw-r--r--nms-patches/PacketDataSerializer.patch4
-rw-r--r--nms-patches/PacketStatusListener.patch2
-rw-r--r--nms-patches/PathfinderGoalBreakDoor.patch6
-rw-r--r--nms-patches/PathfinderGoalBreed.patch12
-rw-r--r--nms-patches/PathfinderGoalEatTile.patch33
-rw-r--r--nms-patches/PathfinderGoalFollowOwner.patch14
-rw-r--r--nms-patches/PathfinderGoalHorseTrap.patch2
-rw-r--r--nms-patches/PathfinderGoalHurtByTarget.patch2
-rw-r--r--nms-patches/PathfinderGoalMakeLove.patch16
-rw-r--r--nms-patches/PathfinderGoalNearestAttackableTarget.patch17
-rw-r--r--nms-patches/PathfinderGoalNearestAttackableTargetInsentient.patch2
-rw-r--r--nms-patches/PathfinderGoalPanic.patch2
-rw-r--r--nms-patches/PathfinderGoalSit.patch2
-rw-r--r--nms-patches/PathfinderGoalTargetNearestPlayer.patch2
-rw-r--r--nms-patches/PathfinderGoalTempt.patch14
-rw-r--r--nms-patches/PathfinderGoalVillagerFarm.patch14
-rw-r--r--nms-patches/PlayerChunk.patch72
-rw-r--r--nms-patches/PlayerChunkMap.patch41
-rw-r--r--nms-patches/PlayerConnection.patch722
-rw-r--r--nms-patches/PlayerInteractManager.patch228
-rw-r--r--nms-patches/PlayerInventory.patch16
-rw-r--r--nms-patches/PlayerList.patch258
-rw-r--r--nms-patches/PortalTravelAgent.patch37
-rw-r--r--nms-patches/RecipeArmorDye.patch16
-rw-r--r--nms-patches/RecipeBannerAdd.patch18
-rw-r--r--nms-patches/RecipeBannerDuplicate.patch17
-rw-r--r--nms-patches/RecipeBookClone.patch17
-rw-r--r--nms-patches/RecipeFireworks.patch21
-rw-r--r--nms-patches/RecipeFireworksFade.patch20
-rw-r--r--nms-patches/RecipeFireworksStar.patch30
-rw-r--r--nms-patches/RecipeMapClone.patch16
-rw-r--r--nms-patches/RecipeRepair.patch46
-rw-r--r--nms-patches/RecipeShulkerBox.patch25
-rw-r--r--nms-patches/RecipeTippedArrow.patch16
-rw-r--r--nms-patches/RecipesBanner.patch37
-rw-r--r--nms-patches/RecipesFurnace.patch80
-rw-r--r--nms-patches/RecipiesShield.patch25
-rw-r--r--nms-patches/RegionFileCache.patch5
-rw-r--r--nms-patches/RegionLimitedWorldAccess.patch30
-rw-r--r--nms-patches/RemoteControlCommandListener.patch11
-rw-r--r--nms-patches/ScoreboardServer.patch51
-rw-r--r--nms-patches/ScoreboardTeam.patch47
-rw-r--r--nms-patches/SecondaryWorldServer.patch12
-rw-r--r--nms-patches/ShapedRecipes.patch44
-rw-r--r--nms-patches/ShapelessRecipes.patch45
-rw-r--r--nms-patches/SlotFurnaceResult.patch40
-rw-r--r--nms-patches/SpawnerCreature.patch82
-rw-r--r--nms-patches/StatisticManager.patch6
-rw-r--r--nms-patches/TickListServer.patch111
-rw-r--r--nms-patches/TileEntity.patch30
-rw-r--r--nms-patches/TileEntityBanner.patch12
-rw-r--r--nms-patches/TileEntityBeacon.patch30
-rw-r--r--nms-patches/TileEntityBrewingStand.patch26
-rw-r--r--nms-patches/TileEntityChest.patch66
-rw-r--r--nms-patches/TileEntityCommand.patch20
-rw-r--r--nms-patches/TileEntityContainer.patch6
-rw-r--r--nms-patches/TileEntityDispenser.patch6
-rw-r--r--nms-patches/TileEntityEndGateway.patch6
-rw-r--r--nms-patches/TileEntityFurnace.patch70
-rw-r--r--nms-patches/TileEntityHopper.patch40
-rw-r--r--nms-patches/TileEntityJukeBox.patch14
-rw-r--r--nms-patches/TileEntityNote.patch16
-rw-r--r--nms-patches/TileEntityShulkerBox.patch20
-rw-r--r--nms-patches/TileEntitySign.patch63
-rw-r--r--nms-patches/TileEntitySkull.patch23
-rw-r--r--nms-patches/TileEntityStructure.patch36
-rw-r--r--nms-patches/UserCache.patch2
-rw-r--r--nms-patches/Village.patch16
-rw-r--r--nms-patches/World.patch291
-rw-r--r--nms-patches/WorldData.patch38
-rw-r--r--nms-patches/WorldGenGroundBush.patch2
-rw-r--r--nms-patches/WorldGenMegaTreeAbstract.patch11
-rw-r--r--nms-patches/WorldGenRegistration.patch11
-rw-r--r--nms-patches/WorldGenTreeProvider.patch40
-rw-r--r--nms-patches/WorldGenVillagePieces.patch46
-rw-r--r--nms-patches/WorldGenWitchHut.patch11
-rw-r--r--nms-patches/WorldMap.patch28
-rw-r--r--nms-patches/WorldNBTStorage.patch23
-rw-r--r--nms-patches/WorldProviderHell.patch2
-rw-r--r--nms-patches/WorldServer.patch408
318 files changed, 6366 insertions, 7033 deletions
diff --git a/nms-patches/Advancement.patch b/nms-patches/Advancement.patch
index ba026b62..348a5175 100644
--- a/nms-patches/Advancement.patch
+++ b/nms-patches/Advancement.patch
@@ -1,6 +1,6 @@
--- a/net/minecraft/server/Advancement.java
+++ b/net/minecraft/server/Advancement.java
-@@ -24,6 +24,7 @@
+@@ -27,6 +27,7 @@
private final String[][] f;
private final Set<Advancement> g = Sets.newLinkedHashSet();
private final IChatBaseComponent h;
@@ -8,3 +8,12 @@
public Advancement(MinecraftKey minecraftkey, @Nullable Advancement advancement, @Nullable AdvancementDisplay advancementdisplay, AdvancementRewards advancementrewards, Map<String, Criterion> map, String[][] astring) {
this.d = minecraftkey;
+@@ -206,7 +207,7 @@
+ }
+
+ public Advancement b(MinecraftKey minecraftkey) {
+- if (!this.a((minecraftkey) -> {
++ if (!this.a((Function<MinecraftKey, Advancement>) (minecraftkey1) -> { // CraftBukkit - decompile error
+ return null;
+ })) {
+ throw new IllegalStateException("Tried to build incomplete advancement!");
diff --git a/nms-patches/AdvancementDataPlayer.patch b/nms-patches/AdvancementDataPlayer.patch
index 947510a9..0cadb6c8 100644
--- a/nms-patches/AdvancementDataPlayer.patch
+++ b/nms-patches/AdvancementDataPlayer.patch
@@ -1,6 +1,6 @@
--- a/net/minecraft/server/AdvancementDataPlayer.java
+++ b/net/minecraft/server/AdvancementDataPlayer.java
-@@ -31,7 +31,7 @@
+@@ -38,7 +38,7 @@
private static final Logger a = LogManager.getLogger();
private static final Gson b = (new GsonBuilder()).registerTypeAdapter(AdvancementProgress.class, new AdvancementProgress.a()).registerTypeAdapter(MinecraftKey.class, new MinecraftKey.a()).setPrettyPrinting().create();
@@ -9,7 +9,7 @@
};
private final MinecraftServer d;
private final File e;
-@@ -93,7 +93,7 @@
+@@ -100,7 +100,7 @@
Iterator iterator = this.data.entrySet().iterator();
while (iterator.hasNext()) {
@@ -18,29 +18,38 @@
if (((AdvancementProgress) entry.getValue()).isDone()) {
arraylist.add(entry.getKey());
-@@ -129,7 +129,7 @@
- if (this.e.isFile()) {
- try {
- String s = Files.toString(this.e, StandardCharsets.UTF_8);
-- Map map = (Map) ChatDeserializer.a(AdvancementDataPlayer.b, s, AdvancementDataPlayer.c.getType());
-+ Map<MinecraftKey, AdvancementProgress> map = (Map) ChatDeserializer.a(AdvancementDataPlayer.b, s, AdvancementDataPlayer.c.getType()); // CraftBukkit
-
- if (map == null) {
- throw new JsonParseException("Found null for advancements");
-@@ -143,7 +143,11 @@
- Advancement advancement = this.d.getAdvancementData().a((MinecraftKey) entry.getKey());
-
- if (advancement == null) {
-- AdvancementDataPlayer.a.warn("Ignored advancement \'" + entry.getKey() + "\' in progress file " + this.e + " - it doesn\'t exist anymore?");
-+ // CraftBukkit start
-+ if (((MinecraftKey) entry.getKey()).b().equals("minecraft")) {
-+ AdvancementDataPlayer.a.warn("Ignored advancement \'" + entry.getKey() + "\' in progress file " + this.e + " - it doesn\'t exist anymore?");
-+ }
-+ // CraftBukkit end
- } else {
- this.a(advancement, (AdvancementProgress) entry.getValue());
- }
-@@ -195,6 +199,7 @@
+@@ -140,7 +140,7 @@
+
+ try {
+ jsonreader.setLenient(false);
+- Dynamic dynamic = new Dynamic(JsonOps.INSTANCE, Streams.parse(jsonreader));
++ Dynamic<?> dynamic = new Dynamic(JsonOps.INSTANCE, Streams.parse(jsonreader)); // CraftBukkit - decompile error
+
+ if (!dynamic.get("DataVersion").flatMap(Dynamic::getNumberValue).isPresent()) {
+ dynamic = dynamic.set("DataVersion", dynamic.createInt(1343));
+@@ -148,7 +148,7 @@
+
+ dynamic = this.d.aB().update(DataFixTypes.ADVANCEMENTS, dynamic, dynamic.getInt("DataVersion"), 1513);
+ dynamic = dynamic.remove("DataVersion");
+- Map map = (Map) AdvancementDataPlayer.b.getAdapter(AdvancementDataPlayer.c).fromJsonTree((JsonElement) dynamic.getValue());
++ Map<MinecraftKey, AdvancementProgress> map = (Map) AdvancementDataPlayer.b.getAdapter(AdvancementDataPlayer.c).fromJsonTree((JsonElement) dynamic.getValue()); // CraftBukkit - decompile error
+
+ if (map == null) {
+ throw new JsonParseException("Found null for advancements");
+@@ -162,7 +162,11 @@
+ Advancement advancement = this.d.getAdvancementData().a((MinecraftKey) entry.getKey());
+
+ if (advancement == null) {
+- AdvancementDataPlayer.a.warn("Ignored advancement \'{}\' in progress file {} - it doesn\'t exist anymore?", entry.getKey(), this.e);
++ // CraftBukkit start
++ if (((MinecraftKey) entry.getKey()).b().equals("minecraft")) {
++ AdvancementDataPlayer.a.warn("Ignored advancement \'{}\' in progress file {} - it doesn\'t exist anymore?", entry.getKey(), this.e);
++ }
++ // CraftBukkit end
+ } else {
+ this.a(advancement, (AdvancementProgress) entry.getValue());
+ }
+@@ -231,6 +235,7 @@
this.i.add(advancement);
flag = true;
if (!flag1 && advancementprogress.isDone()) {
diff --git a/nms-patches/AdvancementRewards.patch b/nms-patches/AdvancementRewards.patch
deleted file mode 100644
index 8f0ea2c3..00000000
--- a/nms-patches/AdvancementRewards.patch
+++ /dev/null
@@ -1,52 +0,0 @@
---- a/net/minecraft/server/AdvancementRewards.java
-+++ b/net/minecraft/server/AdvancementRewards.java
-@@ -66,7 +66,24 @@
- CustomFunction customfunction = this.e.a(minecraftserver.aL());
-
- if (customfunction != null) {
-- ICommandListener icommandlistener = new ICommandListener() {
-+ // CraftBukkit start
-+ ICommandListener icommandlistener = new AdvancementCommandListener(entityplayer, minecraftserver);
-+
-+ minecraftserver.aL().a(customfunction, icommandlistener);
-+ }
-+
-+ }
-+
-+ public static class AdvancementCommandListener implements ICommandListener {
-+
-+ private final EntityPlayer entityplayer;
-+ private final MinecraftServer minecraftserver;
-+
-+ public AdvancementCommandListener(EntityPlayer entityplayer, MinecraftServer minecraftserver) {
-+ this.entityplayer = entityplayer;
-+ this.minecraftserver = minecraftserver;
-+ }
-+
- public String getName() {
- return entityplayer.getName();
- }
-@@ -108,12 +125,8 @@
- public MinecraftServer C_() {
- return entityplayer.C_();
- }
-- };
--
-- minecraftserver.aL().a(customfunction, icommandlistener);
-- }
--
-- }
-+ }
-+ // CraftBukkit end
-
- public String toString() {
- return "AdvancementRewards{experience=" + this.b + ", loot=" + Arrays.toString(this.c) + ", recipes=" + Arrays.toString(this.d) + ", function=" + this.e + '}';
-@@ -156,7 +169,7 @@
- return new AdvancementRewards(i, aminecraftkey, aminecraftkey1, customfunction_a);
- }
-
-- public Object deserialize(JsonElement jsonelement, Type type, JsonDeserializationContext jsondeserializationcontext) throws JsonParseException {
-+ public AdvancementRewards deserialize(JsonElement jsonelement, Type type, JsonDeserializationContext jsondeserializationcontext) throws JsonParseException { // CraftBukkit - decompile error
- return this.a(jsonelement, type, jsondeserializationcontext);
- }
- }
diff --git a/nms-patches/Advancements.patch b/nms-patches/Advancements.patch
index c6fb5b4c..9871ffc7 100644
--- a/nms-patches/Advancements.patch
+++ b/nms-patches/Advancements.patch
@@ -1,11 +1,11 @@
--- a/net/minecraft/server/Advancements.java
+++ b/net/minecraft/server/Advancements.java
-@@ -71,7 +71,7 @@
+@@ -72,7 +72,7 @@
}
}
-- Advancements.a.info("Loaded " + this.advancements.size() + " advancements");
-+ // Advancements.a.info("Loaded " + this.b.size() + " advancements"); // CraftBukkit - moved to AdvancementDataWorld#reload
+- Advancements.a.info("Loaded {} advancements", Integer.valueOf(this.advancements.size()));
++ // Advancements.a.info("Loaded {} advancements", Integer.valueOf(this.advancements.size())); // CraftBukkit - moved to AdvancementDataWorld#reload
}
public void a() {
diff --git a/nms-patches/Block.patch b/nms-patches/Block.patch
index 8060e69d..abff3dcd 100644
--- a/nms-patches/Block.patch
+++ b/nms-patches/Block.patch
@@ -1,28 +1,28 @@
--- a/net/minecraft/server/Block.java
+++ b/net/minecraft/server/Block.java
-@@ -37,7 +37,7 @@
- private String name;
-
- public static int getId(Block block) {
-- return Block.REGISTRY.a((Object) block);
-+ return Block.REGISTRY.a(block); // CraftBukkit - decompile error
+@@ -213,7 +213,7 @@
}
- public static int getCombinedId(IBlockData iblockdata) {
-@@ -343,7 +343,8 @@
- int j = this.getDropCount(i, world.random);
+ public Block(Block.Info block_info) {
+- BlockStateList.a blockstatelist_a = new BlockStateList.a(this);
++ BlockStateList.a<Block, IBlockData> blockstatelist_a = new BlockStateList.a(this); // CraftBukkit - decompile error
+
+ this.a(blockstatelist_a);
+ this.blockStateList = blockstatelist_a.a(BlockData::new);
+@@ -428,7 +428,8 @@
+ int j = this.getDropCount(iblockdata, i, world, blockposition, world.random);
for (int k = 0; k < j; ++k) {
-- if (world.random.nextFloat() <= f) {
+- if (f >= 1.0F || world.random.nextFloat() <= f) {
+ // CraftBukkit - <= to < to allow for plugins to completely disable block drops from explosions
-+ if (world.random.nextFloat() < f) {
- Item item = this.getDropType(iblockdata, world.random, i);
++ if (f >= 1.0F || world.random.nextFloat() < f) {
+ Item item = this.getDropType(iblockdata, world, blockposition, i).getItem();
- if (item != Items.a) {
-@@ -364,7 +365,13 @@
+ if (item != Items.AIR) {
+@@ -449,7 +450,13 @@
EntityItem entityitem = new EntityItem(world, (double) blockposition.getX() + d0, (double) blockposition.getY() + d1, (double) blockposition.getZ() + d2, itemstack);
- entityitem.q();
+ entityitem.n();
- world.addEntity(entityitem);
+ // CraftBukkit start
+ if (world.captureDrops != null) {
@@ -34,34 +34,25 @@
}
}
-@@ -931,7 +938,7 @@
-
- if (hashset.contains(block16)) {
- for (int i = 0; i < 15; ++i) {
-- int j = Block.REGISTRY.a((Object) block16) << 4 | i;
-+ int j = Block.REGISTRY.a(block16) << 4 | i; // CraftBukkit - decompile error
-
- Block.REGISTRY_ID.a(block16.fromLegacyData(i), j);
- }
-@@ -940,7 +947,7 @@
+@@ -668,7 +675,7 @@
+ }
- 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
+ public String toString() {
+- return "Block{" + Block.REGISTRY.b(this) + "}";
++ return Block.REGISTRY.b(this).toString(); // CraftBukkit - cheap hack
+ }
- Block.REGISTRY_ID.a(iblockdata, k);
- }
-@@ -949,6 +956,12 @@
+ public static boolean c(Block block) {
+@@ -1380,6 +1387,12 @@
}
+ // CraftBukkit start
-+ public int getExpDrop(World world, IBlockData data, int enchantmentLevel) {
++ public int getExpDrop(IBlockData iblockdata, World world, BlockPosition blockposition, int enchantmentLevel) {
+ return 0;
+ }
+ // CraftBukkit end
+
- private static void a(int i, MinecraftKey minecraftkey, Block block) {
- Block.REGISTRY.a(i, minecraftkey, block);
+ private static void a(MinecraftKey minecraftkey, Block block) {
+ Block.REGISTRY.a(minecraftkey, block);
}
diff --git a/nms-patches/BlockButtonAbstract.patch b/nms-patches/BlockButtonAbstract.patch
index bf32c8f2..028d1dd1 100644
--- a/nms-patches/BlockButtonAbstract.patch
+++ b/nms-patches/BlockButtonAbstract.patch
@@ -9,10 +9,10 @@
+import org.bukkit.event.entity.EntityInteractEvent;
+// CraftBukkit end
+
- public abstract class BlockButtonAbstract extends BlockDirectional {
+ public abstract class BlockButtonAbstract extends BlockAttachable {
- public static final BlockStateBoolean POWERED = BlockStateBoolean.of("powered");
-@@ -126,6 +131,19 @@
+ public static final BlockStateBoolean POWERED = BlockProperties.t;
+@@ -77,6 +82,19 @@
if (((Boolean) iblockdata.get(BlockButtonAbstract.POWERED)).booleanValue()) {
return true;
} else {
@@ -29,27 +29,27 @@
+ return true;
+ }
+ // CraftBukkit end
- world.setTypeAndData(blockposition, iblockdata.set(BlockButtonAbstract.POWERED, Boolean.valueOf(true)), 3);
- world.b(blockposition, blockposition);
- this.a(entityhuman, world, blockposition);
-@@ -167,6 +185,16 @@
- if (this.I) {
- this.d(iblockdata, world, blockposition);
- } else {
-+ // CraftBukkit start
-+ org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
+ world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockButtonAbstract.POWERED, Boolean.valueOf(true)), 3);
+ this.a(entityhuman, world, blockposition, true);
+ this.c(iblockdata, world, blockposition);
+@@ -118,6 +136,16 @@
+ if (this.F) {
+ this.b(iblockdata, world, blockposition);
+ } else {
++ // CraftBukkit start
++ org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
+
-+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, 15, 0);
-+ world.getServer().getPluginManager().callEvent(eventRedstone);
++ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, 15, 0);
++ world.getServer().getPluginManager().callEvent(eventRedstone);
+
-+ if (eventRedstone.getNewCurrent() > 0) {
-+ return;
-+ }
-+ // CraftBukkit end
- world.setTypeUpdate(blockposition, iblockdata.set(BlockButtonAbstract.POWERED, Boolean.valueOf(false)));
- this.c(world, blockposition, (EnumDirection) iblockdata.get(BlockButtonAbstract.FACING));
- this.b(world, blockposition);
-@@ -192,7 +220,41 @@
++ if (eventRedstone.getNewCurrent() > 0) {
++ return;
++ }
++ // CraftBukkit end
+ world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockButtonAbstract.POWERED, Boolean.valueOf(false)), 3);
+ this.c(iblockdata, world, blockposition);
+ this.a((EntityHuman) null, world, blockposition, false);
+@@ -137,7 +165,44 @@
boolean flag = !list.isEmpty();
boolean flag1 = ((Boolean) iblockdata.get(BlockButtonAbstract.POWERED)).booleanValue();
@@ -77,34 +77,20 @@
+ }
+ // CraftBukkit end
+
- if (flag && !flag1) {
-+ // CraftBukkit start
-+ org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
-+
-+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, 0, 15);
-+ world.getServer().getPluginManager().callEvent(eventRedstone);
-+
-+ if (eventRedstone.getNewCurrent() <= 0) {
-+ return;
-+ }
-+ // CraftBukkit end
- world.setTypeUpdate(blockposition, iblockdata.set(BlockButtonAbstract.POWERED, Boolean.valueOf(true)));
- this.c(world, blockposition, (EnumDirection) iblockdata.get(BlockButtonAbstract.FACING));
- world.b(blockposition, blockposition);
-@@ -200,6 +262,16 @@
- }
-
- if (!flag && flag1) {
+ if (flag != flag1) {
+ // CraftBukkit start
++ boolean powered = flag1;
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
++ int old = (powered) ? 15 : 0;
++ int current = (!powered) ? 15 : 0;
+
-+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, 15, 0);
++ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, old, current);
+ world.getServer().getPluginManager().callEvent(eventRedstone);
+
-+ if (eventRedstone.getNewCurrent() > 0) {
++ if ((flag && eventRedstone.getNewCurrent() <= 0) || (!flag && eventRedstone.getNewCurrent() > 0)) {
+ return;
+ }
+ // CraftBukkit end
- world.setTypeUpdate(blockposition, iblockdata.set(BlockButtonAbstract.POWERED, Boolean.valueOf(false)));
- this.c(world, blockposition, (EnumDirection) iblockdata.get(BlockButtonAbstract.FACING));
- world.b(blockposition, blockposition);
+ world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockButtonAbstract.POWERED, Boolean.valueOf(flag)), 3);
+ this.c(iblockdata, world, blockposition);
+ this.a((EntityHuman) null, world, blockposition, flag);
diff --git a/nms-patches/BlockCactus.patch b/nms-patches/BlockCactus.patch
index 282dcd80..9be8a495 100644
--- a/nms-patches/BlockCactus.patch
+++ b/nms-patches/BlockCactus.patch
@@ -8,26 +8,23 @@
+
public class BlockCactus extends Block {
- public static final BlockStateInteger AGE = BlockStateInteger.of("age", 0, 15);
-@@ -30,9 +32,10 @@
- int j = ((Integer) iblockdata.get(BlockCactus.AGE)).intValue();
+ public static final BlockStateInteger AGE = BlockProperties.W;
+@@ -31,7 +33,7 @@
+ int j = ((Integer) iblockdata.get(BlockCactus.AGE)).intValue();
- if (j == 15) {
-- world.setTypeUpdate(blockposition1, this.getBlockData());
-+ // world.setTypeUpdate(blockposition1, this.getBlockData()); // CraftBukkit
- IBlockData iblockdata1 = iblockdata.set(BlockCactus.AGE, Integer.valueOf(0));
+ if (j == 15) {
+- world.setTypeUpdate(blockposition1, this.getBlockData());
++ CraftEventFactory.handleBlockGrowEvent(world, blockposition1, this.getBlockData()); // CraftBukkit
+ IBlockData iblockdata1 = (IBlockData) iblockdata.set(BlockCactus.AGE, Integer.valueOf(0));
-+ CraftEventFactory.handleBlockGrowEvent(world, blockposition1.getX(), blockposition1.getY(), blockposition1.getZ(), this, 0); // CraftBukkit
- world.setTypeAndData(blockposition, iblockdata1, 4);
- iblockdata1.doPhysics(world, blockposition1, this, blockposition);
- } else {
-@@ -87,7 +90,9 @@
+ world.setTypeAndData(blockposition, iblockdata1, 4);
+@@ -92,7 +94,9 @@
}
- public void a(World world, BlockPosition blockposition, IBlockData iblockdata, Entity entity) {
+ public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) {
+ CraftEventFactory.blockDamage = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); // CraftBukkit
entity.damageEntity(DamageSource.CACTUS, 1.0F);
+ CraftEventFactory.blockDamage = null; // CraftBukkit
}
- public IBlockData fromLegacyData(int i) {
+ public TextureType c() {
diff --git a/nms-patches/BlockCake.patch b/nms-patches/BlockCake.patch
index 80b0801d..4830491d 100644
--- a/nms-patches/BlockCake.patch
+++ b/nms-patches/BlockCake.patch
@@ -1,9 +1,9 @@
--- a/net/minecraft/server/BlockCake.java
+++ b/net/minecraft/server/BlockCake.java
-@@ -40,7 +40,18 @@
+@@ -33,7 +33,18 @@
return false;
} else {
- entityhuman.b(StatisticList.H);
+ entityhuman.a(StatisticList.EAT_CAKE_SLICE);
- entityhuman.getFoodData().eat(2, 0.1F);
+ // CraftBukkit start
+ // entityhuman.getFoodData().eat(2, 0.1F);
diff --git a/nms-patches/BlockCauldron.patch b/nms-patches/BlockCauldron.patch
index 4ba652e4..9b862840 100644
--- a/nms-patches/BlockCauldron.patch
+++ b/nms-patches/BlockCauldron.patch
@@ -1,14 +1,14 @@
--- a/net/minecraft/server/BlockCauldron.java
+++ b/net/minecraft/server/BlockCauldron.java
-@@ -3,6 +3,7 @@
- import java.util.List;
- import java.util.Random;
- import javax.annotation.Nullable;
-+import org.bukkit.event.block.CauldronLevelChangeEvent; // CraftBukkit
+@@ -1,5 +1,7 @@
+ package net.minecraft.server;
++import org.bukkit.event.block.CauldronLevelChangeEvent; // CraftBukkit
++
public class BlockCauldron extends Block {
-@@ -43,8 +44,13 @@
+ public static final BlockStateInteger LEVEL = BlockProperties.ae;
+@@ -32,8 +34,13 @@
float f = (float) blockposition.getY() + (6.0F + (float) (3 * i)) / 16.0F;
if (!world.isClientSide && entity.isBurning() && i > 0 && entity.getBoundingBox().b <= (double) f) {
@@ -23,7 +23,7 @@
}
}
-@@ -60,18 +66,27 @@
+@@ -49,18 +56,27 @@
if (item == Items.WATER_BUCKET) {
if (i < 3 && !world.isClientSide) {
@@ -35,11 +35,11 @@
entityhuman.a(enumhand, new ItemStack(Items.BUCKET));
}
- entityhuman.b(StatisticList.I);
+ entityhuman.a(StatisticList.FILL_CAULDRON);
- this.a(world, blockposition, iblockdata, 3);
+ // this.a(world, blockposition, iblockdata, 3);
+ // CraftBukkit end
- world.a((EntityHuman) null, blockposition, SoundEffects.Q, SoundCategory.BLOCKS, 1.0F, 1.0F);
+ world.a((EntityHuman) null, blockposition, SoundEffects.ITEM_BUCKET_EMPTY, SoundCategory.BLOCKS, 1.0F, 1.0F);
}
return true;
@@ -52,17 +52,17 @@
if (!entityhuman.abilities.canInstantlyBuild) {
itemstack.subtract(1);
if (itemstack.isEmpty()) {
-@@ -82,7 +97,8 @@
+@@ -71,7 +87,8 @@
}
- entityhuman.b(StatisticList.J);
+ entityhuman.a(StatisticList.USE_CAULDRON);
- this.a(world, blockposition, iblockdata, 0);
+ // this.a(world, blockposition, iblockdata, 0);
+ // CraftBukkit end
- world.a((EntityHuman) null, blockposition, SoundEffects.S, SoundCategory.BLOCKS, 1.0F, 1.0F);
+ world.a((EntityHuman) null, blockposition, SoundEffects.ITEM_BUCKET_FILL, SoundCategory.BLOCKS, 1.0F, 1.0F);
}
-@@ -92,6 +108,10 @@
+@@ -81,6 +98,10 @@
if (item == Items.GLASS_BOTTLE) {
if (i > 0 && !world.isClientSide) {
@@ -72,11 +72,11 @@
+ }
if (!entityhuman.abilities.canInstantlyBuild) {
itemstack1 = PotionUtil.a(new ItemStack(Items.POTION), Potions.b);
- entityhuman.b(StatisticList.J);
-@@ -106,12 +126,17 @@
+ entityhuman.a(StatisticList.USE_CAULDRON);
+@@ -95,12 +116,17 @@
}
- world.a((EntityHuman) null, blockposition, SoundEffects.N, SoundCategory.BLOCKS, 1.0F, 1.0F);
+ world.a((EntityHuman) null, blockposition, SoundEffects.ITEM_BOTTLE_FILL, SoundCategory.BLOCKS, 1.0F, 1.0F);
- this.a(world, blockposition, iblockdata, i - 1);
+ // this.a(world, blockposition, iblockdata, i - 1);
+ // CraftBukkit end
@@ -91,44 +91,44 @@
+ }
if (!entityhuman.abilities.canInstantlyBuild) {
itemstack1 = new ItemStack(Items.GLASS_BOTTLE);
- entityhuman.b(StatisticList.J);
-@@ -122,7 +147,8 @@
+ entityhuman.a(StatisticList.USE_CAULDRON);
+@@ -111,7 +137,8 @@
}
- world.a((EntityHuman) null, blockposition, SoundEffects.M, SoundCategory.BLOCKS, 1.0F, 1.0F);
+ world.a((EntityHuman) null, blockposition, SoundEffects.ITEM_BOTTLE_EMPTY, 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;
+@@ -120,8 +147,13 @@
+ ItemArmorColorable itemarmorcolorable = (ItemArmorColorable) item;
- if (itemarmor.d() == ItemArmor.EnumArmorMaterial.LEATHER && itemarmor.e_(itemstack) && !world.isClientSide) {
+ if (itemarmorcolorable.e(itemstack) && !world.isClientSide) {
+ // CraftBukkit start
+ if (!this.changeLevel(world, blockposition, iblockdata, i - 1, entityhuman, CauldronLevelChangeEvent.ChangeReason.ARMOR_WASH)) {
+ return true;
+ }
- itemarmor.d(itemstack);
+ itemarmorcolorable.g(itemstack);
- this.a(world, blockposition, iblockdata, i - 1);
+ // this.a(world, blockposition, iblockdata, i - 1);
+ // CraftBukkit end
- entityhuman.b(StatisticList.K);
+ entityhuman.a(StatisticList.CLEAN_ARMOR);
return true;
}
-@@ -140,13 +171,18 @@
+@@ -129,13 +161,18 @@
if (i > 0 && item instanceof ItemBanner) {
- if (TileEntityBanner.b(itemstack) > 0 && !world.isClientSide) {
+ if (TileEntityBanner.a(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.L);
+ TileEntityBanner.b(itemstack1);
+ entityhuman.a(StatisticList.CLEAN_BANNER);
if (!entityhuman.abilities.canInstantlyBuild) {
itemstack.subtract(1);
- this.a(world, blockposition, iblockdata, i - 1);
@@ -137,13 +137,13 @@
}
if (itemstack.isEmpty()) {
-@@ -167,9 +203,25 @@
+@@ -171,9 +208,25 @@
}
}
+ // CraftBukkit start
public void a(World world, BlockPosition blockposition, IBlockData iblockdata, int i) {
-- world.setTypeAndData(blockposition, iblockdata.set(BlockCauldron.LEVEL, Integer.valueOf(MathHelper.clamp(i, 0, 3))), 2);
+- world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockCauldron.LEVEL, Integer.valueOf(MathHelper.clamp(i, 0, 3))), 2);
+ this.changeLevel(world, blockposition, iblockdata, i, null, CauldronLevelChangeEvent.ChangeReason.UNKNOWN);
+ }
+
@@ -157,19 +157,19 @@
+ if (event.isCancelled()) {
+ return false;
+ }
-+ world.setTypeAndData(blockposition, iblockdata.set(BlockCauldron.LEVEL, event.getNewLevel()), 2);
++ world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockCauldron.LEVEL, event.getNewLevel()), 2);
world.updateAdjacentComparators(blockposition, this);
+ return true;
+ // CraftBukkit end
}
- public void h(World world, BlockPosition blockposition) {
-@@ -180,7 +232,7 @@
+ public void c(World world, BlockPosition blockposition) {
+@@ -184,7 +237,7 @@
IBlockData iblockdata = world.getType(blockposition);
if (((Integer) iblockdata.get(BlockCauldron.LEVEL)).intValue() < 3) {
-- world.setTypeAndData(blockposition, iblockdata.a((IBlockState) BlockCauldron.LEVEL), 2);
-+ this.a(world, blockposition, iblockdata.a((IBlockState) BlockCauldron.LEVEL), 2); // CraftBukkit
+- world.setTypeAndData(blockposition, (IBlockData) iblockdata.a((IBlockState) BlockCauldron.LEVEL), 2);
++ this.a(world, blockposition, (IBlockData) iblockdata.a((IBlockState) BlockCauldron.LEVEL), 2); // CraftBukkit
}
}
diff --git a/nms-patches/BlockChorusFlower.patch b/nms-patches/BlockChorusFlower.patch
index e5482d55..2e24180c 100644
--- a/nms-patches/BlockChorusFlower.patch
+++ b/nms-patches/BlockChorusFlower.patch
@@ -8,46 +8,31 @@
+
public class BlockChorusFlower extends Block {
- public static final BlockStateInteger AGE = BlockStateInteger.of("age", 0, 5);
-@@ -68,8 +70,20 @@
+ public static final BlockStateInteger AGE = BlockProperties.U;
+@@ -61,8 +63,12 @@
}
- if (flag && a(world, blockposition1, (EnumDirection) null) && world.isEmpty(blockposition.up(2))) {
-- world.setTypeAndData(blockposition, Blocks.CHORUS_PLANT.getBlockData(), 2);
-- this.a(world, blockposition1, i);
-+ // world.setTypeAndData(blockposition, Blocks.CHORUS_PLANT.getBlockData(), 2);
-+ // this.a(world, blockposition1, i);
+ if (flag && a((IWorldReader) world, blockposition1, (EnumDirection) null) && world.isEmpty(blockposition.up(2))) {
+- world.setTypeAndData(blockposition, this.b.a((IBlockAccess) world, blockposition), 2);
+- this.b(world, blockposition1, i);
+ // CraftBukkit start - add event
-+ BlockPosition target = blockposition1;
-+ if (CraftEventFactory.handleBlockSpreadEvent(
-+ world.getWorld().getBlockAt(target.getX(), target.getY(), target.getZ()),
-+ world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()),
-+ this,
-+ toLegacyData(this.getBlockData().set(BlockChorusFlower.AGE, Integer.valueOf(i)))
-+ )) {
-+ world.setTypeAndData(blockposition, Blocks.CHORUS_PLANT.getBlockData(), 2);
-+ world.triggerEffect(1033, blockposition, 0);
++ if (CraftEventFactory.handleBlockSpreadEvent(world, blockposition, blockposition1, this.getBlockData().set(BlockChorusFlower.AGE, Integer.valueOf(i)), 2)) {
++ world.setTypeAndData(blockposition, this.b.a((IBlockAccess) world, blockposition), 2);
++ this.b(world, blockposition1, i);
+ }
+ // CraftBukkit end
} else if (i < 4) {
j = random.nextInt(4);
- boolean flag2 = false;
-@@ -83,18 +97,53 @@
+ if (flag1) {
+@@ -76,18 +82,30 @@
BlockPosition blockposition2 = blockposition.shift(enumdirection);
- if (world.isEmpty(blockposition2) && world.isEmpty(blockposition2.down()) && a(world, blockposition2, enumdirection.opposite())) {
-- this.a(world, blockposition2, i + 1);
+ if (world.isEmpty(blockposition2) && world.isEmpty(blockposition2.down()) && a((IWorldReader) world, blockposition2, enumdirection.opposite())) {
+- this.b(world, blockposition2, i + 1);
- flag2 = true;
+ // CraftBukkit start - add event
-+ // this.a(world, blockposition2, i + 1);
-+ BlockPosition target = blockposition2;
-+ if (CraftEventFactory.handleBlockSpreadEvent(
-+ world.getWorld().getBlockAt(target.getX(), target.getY(), target.getZ()),
-+ world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()),
-+ this,
-+ toLegacyData(this.getBlockData().set(BlockChorusFlower.AGE, Integer.valueOf(i + 1)))
-+ )) {
-+ world.triggerEffect(1033, blockposition, 0);
++ if (CraftEventFactory.handleBlockSpreadEvent(world, blockposition, blockposition2, this.getBlockData().set(BlockChorusFlower.AGE, Integer.valueOf(i + 1)), 2)) {
++ this.b(world, blockposition2, i + 1);
+ flag2 = true;
+ }
+ // CraftBukkit end
@@ -55,37 +40,21 @@
}
if (flag2) {
- world.setTypeAndData(blockposition, Blocks.CHORUS_PLANT.getBlockData(), 2);
+ world.setTypeAndData(blockposition, this.b.a((IBlockAccess) world, blockposition), 2);
} else {
-- this.c(world, blockposition);
+- this.a(world, blockposition);
+ // CraftBukkit - add event
-+ if (CraftEventFactory.handleBlockGrowEvent(
-+ world,
-+ blockposition.getX(),
-+ blockposition.getY(),
-+ blockposition.getZ(),
-+ this,
-+ toLegacyData(iblockdata.set(BlockChorusFlower.AGE, Integer.valueOf(5)))
-+ )) {
-+ world.triggerEffect(1034, blockposition, 0);
++ if (CraftEventFactory.handleBlockGrowEvent(world, blockposition, this.getBlockData().set(BlockChorusFlower.AGE, Integer.valueOf(5)), 2)) {
++ this.a(world, blockposition);
+ }
-+ // this.c(world, blockposition);
+ // CraftBukkit end
}
- } else if (i == 4) {
-- this.c(world, blockposition);
+ } else {
+- this.a(world, blockposition);
+ // CraftBukkit - add event
-+ if (CraftEventFactory.handleBlockGrowEvent(
-+ world,
-+ blockposition.getX(),
-+ blockposition.getY(),
-+ blockposition.getZ(),
-+ this,
-+ toLegacyData(iblockdata.set(BlockChorusFlower.AGE, Integer.valueOf(5)))
-+ )) {
-+ world.triggerEffect(1034, blockposition, 0);
++ if (CraftEventFactory.handleBlockGrowEvent(world, blockposition, this.getBlockData().set(BlockChorusFlower.AGE, Integer.valueOf(5)), 2)) {
++ this.a(world, blockposition);
+ }
-+ // this.c(world, blockposition);
+ // CraftBukkit end
}
diff --git a/nms-patches/BlockCocoa.patch b/nms-patches/BlockCocoa.patch
index 470a26f6..3affcb74 100644
--- a/nms-patches/BlockCocoa.patch
+++ b/nms-patches/BlockCocoa.patch
@@ -1,35 +1,29 @@
--- a/net/minecraft/server/BlockCocoa.java
+++ b/net/minecraft/server/BlockCocoa.java
-@@ -2,6 +2,8 @@
-
+@@ -3,6 +3,8 @@
import java.util.Random;
+ import javax.annotation.Nullable;
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
+
public class BlockCocoa extends BlockFacingHorizontal implements IBlockFragilePlantElement {
- public static final BlockStateInteger AGE = BlockStateInteger.of("age", 0, 2);
-@@ -23,7 +25,10 @@
+ public static final BlockStateInteger AGE = BlockProperties.S;
+@@ -21,7 +23,7 @@
int i = ((Integer) iblockdata.get(BlockCocoa.AGE)).intValue();
if (i < 2) {
-- world.setTypeAndData(blockposition, iblockdata.set(BlockCocoa.AGE, Integer.valueOf(i + 1)), 2);
-+ // CraftBukkit start
-+ IBlockData data = iblockdata.set(AGE, Integer.valueOf(i + 1));
-+ CraftEventFactory.handleBlockGrowEvent(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this, toLegacyData(data));
-+ // CraftBukkit end
+- world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockCocoa.AGE, Integer.valueOf(i + 1)), 2);
++ CraftEventFactory.handleBlockGrowEvent(world, blockposition, (IBlockData) iblockdata.set(BlockCocoa.AGE, Integer.valueOf(i + 1)), 2); // CraftBukkkit
}
}
-@@ -124,7 +129,10 @@
+@@ -109,7 +111,7 @@
}
public void b(World world, Random random, BlockPosition blockposition, IBlockData iblockdata) {
-- world.setTypeAndData(blockposition, iblockdata.set(BlockCocoa.AGE, Integer.valueOf(((Integer) iblockdata.get(BlockCocoa.AGE)).intValue() + 1)), 2);
-+ // CraftBukkit start
-+ IBlockData data = iblockdata.set(AGE, Integer.valueOf(((Integer) iblockdata.get(AGE)).intValue() + 1));
-+ CraftEventFactory.handleBlockGrowEvent(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this, toLegacyData(data));
-+ // CraftBukkit end
+- world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockCocoa.AGE, Integer.valueOf(((Integer) iblockdata.get(BlockCocoa.AGE)).intValue() + 1)), 2);
++ CraftEventFactory.handleBlockGrowEvent(world, blockposition, (IBlockData) iblockdata.set(BlockCocoa.AGE, Integer.valueOf(((Integer) iblockdata.get(BlockCocoa.AGE)).intValue() + 1)), 2); // CraftBukkit
}
- public IBlockData fromLegacyData(int i) {
+ public TextureType c() {
diff --git a/nms-patches/BlockCommand.patch b/nms-patches/BlockCommand.patch
index 12a88a41..4f0974f2 100644
--- a/nms-patches/BlockCommand.patch
+++ b/nms-patches/BlockCommand.patch
@@ -12,7 +12,7 @@
@@ -30,6 +32,15 @@
TileEntityCommand tileentitycommand = (TileEntityCommand) tileentity;
boolean flag = world.isBlockIndirectlyPowered(blockposition);
- boolean flag1 = tileentitycommand.f();
+ boolean flag1 = tileentitycommand.d();
+ // CraftBukkit start
+ org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
+ int old = flag1 ? 15 : 0;
@@ -24,4 +24,4 @@
+ // CraftBukkit end
tileentitycommand.a(flag);
- if (!flag1 && !tileentitycommand.h() && tileentitycommand.l() != TileEntityCommand.Type.SEQUENCE) {
+ if (!flag1 && !tileentitycommand.e() && tileentitycommand.j() != TileEntityCommand.Type.SEQUENCE) {
diff --git a/nms-patches/BlockConcretePowder.patch b/nms-patches/BlockConcretePowder.patch
index dd2708f7..83e11280 100644
--- a/nms-patches/BlockConcretePowder.patch
+++ b/nms-patches/BlockConcretePowder.patch
@@ -1,22 +1,46 @@
--- a/net/minecraft/server/BlockConcretePowder.java
+++ b/net/minecraft/server/BlockConcretePowder.java
-@@ -11,8 +11,8 @@
+@@ -1,5 +1,10 @@
+ package net.minecraft.server;
+
++// CraftBukkit start
++import org.bukkit.craftbukkit.block.CraftBlockState;
++import org.bukkit.event.block.BlockFormEvent;
++// CraftBukkit end
++
+ public class BlockConcretePowder extends BlockFalling {
+
+ private final IBlockData a;
+@@ -10,8 +15,8 @@
}
public void a(World world, BlockPosition blockposition, IBlockData iblockdata, IBlockData iblockdata1) {
- if (iblockdata1.getMaterial().isLiquid()) {
-- world.setTypeAndData(blockposition, Blocks.dR.getBlockData().set(BlockCloth.COLOR, iblockdata.get(BlockConcretePowder.a)), 3);
-+ if (iblockdata1.getMaterial().isLiquid() && world.getType(blockposition).getBlock() != Blocks.dR) { // CraftBukkit - don't double concrete
-+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition, Blocks.dR.getBlockData().set(BlockCloth.COLOR, iblockdata.get(BlockConcretePowder.a)), null); // CraftBukkit
+- world.setTypeAndData(blockposition, this.a, 3);
++ if (iblockdata1.getMaterial().isLiquid() && !(world.getType(blockposition).getBlock() instanceof BlockConcretePowder)) { // CraftBukkit - don't double concrete
++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition, this.a, 3);
}
}
-@@ -36,7 +36,7 @@
- }
-
- if (flag) {
-- world.setTypeAndData(blockposition, Blocks.dR.getBlockData().set(BlockCloth.COLOR, iblockdata.get(BlockConcretePowder.a)), 3);
-+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition, Blocks.dR.getBlockData().set(BlockCloth.COLOR, iblockdata.get(BlockConcretePowder.a)), null); // CraftBukkit
- }
+@@ -45,6 +50,20 @@
+ }
- return flag;
+ public IBlockData updateState(IBlockData iblockdata, EnumDirection enumdirection, IBlockData iblockdata1, GeneratorAccess generatoraccess, BlockPosition blockposition, BlockPosition blockposition1) {
+- return a((IBlockAccess) generatoraccess, blockposition) ? this.a : super.updateState(iblockdata, enumdirection, iblockdata1, generatoraccess, blockposition, blockposition1);
++ // CraftBukkit start
++ if (a((IBlockAccess) generatoraccess, blockposition)) {
++ CraftBlockState blockState = CraftBlockState.getBlockState(generatoraccess, blockposition);
++ blockState.setData(this.a);
++
++ BlockFormEvent event = new BlockFormEvent(blockState.getBlock(), blockState);
++ generatoraccess.getMinecraftWorld().getMinecraftServer().server.getPluginManager().callEvent(event);
++
++ if (!event.isCancelled()) {
++ return blockState.getHandle();
++ }
++ }
++
++ return super.updateState(iblockdata, enumdirection, iblockdata1, generatoraccess, blockposition, blockposition1);
++ // CraftBukkit end
+ }
+ }
diff --git a/nms-patches/BlockCrops.patch b/nms-patches/BlockCrops.patch
index 385751da..f5169e79 100644
--- a/nms-patches/BlockCrops.patch
+++ b/nms-patches/BlockCrops.patch
@@ -8,28 +8,22 @@
+
public class BlockCrops extends BlockPlant implements IBlockFragilePlantElement {
- public static final BlockStateInteger AGE = BlockStateInteger.of("age", 0, 7);
-@@ -53,7 +55,10 @@
- float f = a((Block) this, world, blockposition);
+ public static final BlockStateInteger AGE = BlockProperties.V;
+@@ -49,7 +51,7 @@
+ float f = a((Block) this, (IBlockAccess) world, blockposition);
if (random.nextInt((int) (25.0F / f) + 1) == 0) {
- world.setTypeAndData(blockposition, this.setAge(i + 1), 2);
-+ // CraftBukkit start
-+ IBlockData data = this.setAge(i + 1);
-+ CraftEventFactory.handleBlockGrowEvent(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this, toLegacyData(data));
-+ // CraftBukkit end
++ CraftEventFactory.handleBlockGrowEvent(world, blockposition, this.setAge(i + 1), 2); // CraftBukkit
}
}
}
-@@ -68,7 +73,10 @@
+@@ -64,7 +66,7 @@
i = j;
}
- world.setTypeAndData(blockposition, this.setAge(i), 2);
-+ // CraftBukkit start
-+ IBlockData data = this.setAge(i);
-+ CraftEventFactory.handleBlockGrowEvent(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this, toLegacyData(data));
-+ // CraftBukkit end
++ CraftEventFactory.handleBlockGrowEvent(world, blockposition, this.setAge(i), 2); // CraftBukkit
}
- protected int b(World world) {
+ protected int a(World world) {
diff --git a/nms-patches/BlockDaylightDetector.patch b/nms-patches/BlockDaylightDetector.patch
index a9525a88..b62dbbf6 100644
--- a/nms-patches/BlockDaylightDetector.patch
+++ b/nms-patches/BlockDaylightDetector.patch
@@ -1,10 +1,10 @@
--- a/net/minecraft/server/BlockDaylightDetector.java
+++ b/net/minecraft/server/BlockDaylightDetector.java
-@@ -45,6 +45,7 @@
+@@ -36,6 +36,7 @@
i = MathHelper.clamp(i, 0, 15);
if (((Integer) iblockdata.get(BlockDaylightDetector.POWER)).intValue() != i) {
-+ i = org.bukkit.craftbukkit.event.CraftEventFactory.callRedstoneChange(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), ((Integer) iblockdata.get(POWER)), i).getNewCurrent(); // CraftBukkit - Call BlockRedstoneEvent
- world.setTypeAndData(blockposition, iblockdata.set(BlockDaylightDetector.POWER, Integer.valueOf(i)), 3);
++ i = org.bukkit.craftbukkit.event.CraftEventFactory.callRedstoneChange(world, blockposition, ((Integer) iblockdata.get(POWER)), i).getNewCurrent(); // CraftBukkit - Call BlockRedstoneEvent
+ world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockDaylightDetector.POWER, Integer.valueOf(i)), 3);
}
diff --git a/nms-patches/BlockDiodeAbstract.patch b/nms-patches/BlockDiodeAbstract.patch
index f7f4522e..b870476b 100644
--- a/nms-patches/BlockDiodeAbstract.patch
+++ b/nms-patches/BlockDiodeAbstract.patch
@@ -8,23 +8,23 @@
+
public abstract class BlockDiodeAbstract extends BlockFacingHorizontal {
- protected static final AxisAlignedBB c = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 0.125D, 1.0D);
-@@ -35,8 +37,18 @@
- boolean flag = this.e(world, blockposition, iblockdata);
+ protected static final VoxelShape b = Block.a(0.0D, 0.0D, 0.0D, 16.0D, 2.0D, 16.0D);
+@@ -29,8 +31,18 @@
+ boolean flag1 = this.a(world, blockposition, iblockdata);
- if (this.d && !flag) {
+ if (flag && !flag1) {
+ // CraftBukkit start
-+ if (CraftEventFactory.callRedstoneChange(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), 15, 0).getNewCurrent() != 0) {
++ if (CraftEventFactory.callRedstoneChange(world, blockposition, 15, 0).getNewCurrent() != 0) {
+ return;
+ }
+ // CraftBukkit end
- world.setTypeAndData(blockposition, this.z(iblockdata), 2);
- } else if (!this.d) {
+ world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockDiodeAbstract.c, Boolean.valueOf(false)), 2);
+ } else if (!flag) {
+ // CraftBukkit start
-+ if (CraftEventFactory.callRedstoneChange(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), 0, 15).getNewCurrent() != 15) {
++ if (CraftEventFactory.callRedstoneChange(world, blockposition, 0, 15).getNewCurrent() != 15) {
+ return;
+ }
+ // CraftBukkit end
- world.setTypeAndData(blockposition, this.y(iblockdata), 2);
- if (!flag) {
- world.a(blockposition, this.y(iblockdata).getBlock(), this.E(iblockdata), -1);
+ world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockDiodeAbstract.c, Boolean.valueOf(true)), 2);
+ if (!flag1) {
+ world.I().a(blockposition, this, this.j(iblockdata), TickListPriority.HIGH);
diff --git a/nms-patches/BlockDirtSnowSpreadable.patch b/nms-patches/BlockDirtSnowSpreadable.patch
new file mode 100644
index 00000000..af18d01d
--- /dev/null
+++ b/nms-patches/BlockDirtSnowSpreadable.patch
@@ -0,0 +1,23 @@
+--- a/net/minecraft/server/BlockDirtSnowSpreadable.java
++++ b/net/minecraft/server/BlockDirtSnowSpreadable.java
+@@ -23,6 +23,11 @@
+ public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) {
+ if (!world.isClientSide) {
+ if (!a((IWorldReader) world, blockposition)) {
++ // CraftBukkit start
++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(world, blockposition, Blocks.DIRT.getBlockData()).isCancelled()) {
++ return;
++ }
++ // CraftBukkit end
+ world.setTypeUpdate(blockposition, Blocks.DIRT.getBlockData());
+ } else {
+ if (world.getLightLevel(blockposition.up()) >= 9) {
+@@ -34,7 +39,7 @@
+ }
+
+ if (world.getType(blockposition1).getBlock() == Blocks.DIRT && b(world, blockposition1)) {
+- world.setTypeUpdate(blockposition1, this.getBlockData());
++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(world, blockposition, blockposition1, this.getBlockData()); // CraftBukkit
+ }
+ }
+ }
diff --git a/nms-patches/BlockDispenser.patch b/nms-patches/BlockDispenser.patch
index a46b1eef..45431d4b 100644
--- a/nms-patches/BlockDispenser.patch
+++ b/nms-patches/BlockDispenser.patch
@@ -1,18 +1,18 @@
--- a/net/minecraft/server/BlockDispenser.java
+++ b/net/minecraft/server/BlockDispenser.java
-@@ -8,6 +8,7 @@
- public static final BlockStateBoolean TRIGGERED = BlockStateBoolean.of("triggered");
+@@ -7,6 +7,7 @@
+ public static final BlockStateDirection FACING = BlockDirectional.FACING;
+ public static final BlockStateBoolean TRIGGERED = BlockProperties.w;
public static final RegistryDefault<Item, IDispenseBehavior> REGISTRY = new RegistryDefault(new DispenseBehaviorItem());
- protected Random d = new Random();
+ public static boolean eventFired = false; // CraftBukkit
- protected BlockDispenser() {
- super(Material.STONE);
-@@ -82,6 +83,7 @@
- IDispenseBehavior idispensebehavior = this.a(itemstack);
+ public static void a(IMaterial imaterial, IDispenseBehavior idispensebehavior) {
+ BlockDispenser.REGISTRY.a(imaterial.getItem(), idispensebehavior);
+@@ -52,6 +53,7 @@
+ IDispenseBehavior idispensebehavior = this.a(itemstack);
- if (idispensebehavior != IDispenseBehavior.NONE) {
-+ eventFired = false; // CraftBukkit - reset event status
- tileentitydispenser.setItem(i, idispensebehavior.a(sourceblock, itemstack));
- }
+ if (idispensebehavior != IDispenseBehavior.NONE) {
++ eventFired = false; // CraftBukkit - reset event status
+ tileentitydispenser.setItem(i, idispensebehavior.dispense(sourceblock, itemstack));
+ }
diff --git a/nms-patches/BlockDoor.patch b/nms-patches/BlockDoor.patch
index 063d2ea1..e47addb1 100644
--- a/nms-patches/BlockDoor.patch
+++ b/nms-patches/BlockDoor.patch
@@ -2,36 +2,37 @@
+++ b/net/minecraft/server/BlockDoor.java
@@ -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;
-@@ -137,9 +139,23 @@
- this.b(world, blockposition, iblockdata, 0);
- }
- } else {
-- boolean flag1 = world.isBlockIndirectlyPowered(blockposition) || world.isBlockIndirectlyPowered(blockposition3);
+@@ -169,9 +171,24 @@
+ }
-- if (block != this && (flag1 || block.getBlockData().m()) && 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(blockposition3.getX(), blockposition3.getY(), blockposition3.getZ());
+ public void doPhysics(IBlockData iblockdata, World world, BlockPosition blockposition, Block block, BlockPosition blockposition1) {
+- boolean flag = world.isBlockIndirectlyPowered(blockposition) || world.isBlockIndirectlyPowered(blockposition.shift(iblockdata.get(BlockDoor.HALF) == BlockPropertyDoubleBlockHalf.LOWER ? EnumDirection.UP : EnumDirection.DOWN));
++ // CraftBukkit start
++ BlockPosition otherHalf = blockposition.shift(iblockdata.get(BlockDoor.HALF) == BlockPropertyDoubleBlockHalf.LOWER ? EnumDirection.UP : EnumDirection.DOWN);
+
-+ int power = bukkitBlock.getBlockPower();
-+ int powerTop = blockTop.getBlockPower();
-+ if (powerTop > power) power = powerTop;
-+ int oldPower = (Boolean) iblockdata2.get(BlockDoor.POWERED) ? 15 : 0;
++ 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(otherHalf.getX(), otherHalf.getY(), otherHalf.getZ());
+
-+ if (oldPower == 0 ^ power == 0) {
-+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bukkitBlock, oldPower, power);
-+ world.getServer().getPluginManager().callEvent(eventRedstone);
++ int power = bukkitBlock.getBlockPower();
++ int powerTop = blockTop.getBlockPower();
++ if (powerTop > power) power = powerTop;
++ int oldPower = ((Boolean) iblockdata.get(BlockDoor.POWERED)).booleanValue() ? 15 : 0;
+
-+ boolean flag1 = eventRedstone.getNewCurrent() > 0;
-+ // 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);
++ if (oldPower == 0 ^ power == 0) {
++ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bukkitBlock, oldPower, power);
++ world.getServer().getPluginManager().callEvent(eventRedstone);
+
+- if (block != this && flag != ((Boolean) iblockdata.get(BlockDoor.POWERED)).booleanValue()) {
++ boolean flag = eventRedstone.getNewCurrent() > 0;
++ // CraftBukkit end
+ if (flag != ((Boolean) iblockdata.get(BlockDoor.OPEN)).booleanValue()) {
+ this.b(world, blockposition, flag);
+ }
diff --git a/nms-patches/BlockDragonEgg.patch b/nms-patches/BlockDragonEgg.patch
index af397c67..1533b9bd 100644
--- a/nms-patches/BlockDragonEgg.patch
+++ b/nms-patches/BlockDragonEgg.patch
@@ -1,30 +1,29 @@
--- a/net/minecraft/server/BlockDragonEgg.java
+++ b/net/minecraft/server/BlockDragonEgg.java
-@@ -2,6 +2,8 @@
-
- import java.util.Random;
+@@ -1,5 +1,7 @@
+ package net.minecraft.server;
+import org.bukkit.event.block.BlockFromToEvent; // CraftBukkit
+
- public class BlockDragonEgg extends Block {
+ public class BlockDragonEgg extends BlockFalling {
- protected static final AxisAlignedBB a = new AxisAlignedBB(0.0625D, 0.0D, 0.0625D, 0.9375D, 1.0D, 0.9375D);
-@@ -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));
+ protected static final VoxelShape a = Block.a(1.0D, 0.0D, 1.0D, 15.0D, 16.0D, 15.0D);
+@@ -26,6 +28,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) {
-+ // CraftBukkit start
-+ org.bukkit.block.Block from = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
-+ org.bukkit.block.Block to = world.getWorld().getBlockAt(blockposition1.getX(), blockposition1.getY(), blockposition1.getZ());
-+ BlockFromToEvent event = new BlockFromToEvent(from, to);
-+ org.bukkit.Bukkit.getPluginManager().callEvent(event);
+ if (world.getType(blockposition1).isAir()) {
++ // CraftBukkit start
++ org.bukkit.block.Block from = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
++ org.bukkit.block.Block to = world.getWorld().getBlockAt(blockposition1.getX(), blockposition1.getY(), blockposition1.getZ());
++ BlockFromToEvent event = new BlockFromToEvent(from, to);
++ org.bukkit.Bukkit.getPluginManager().callEvent(event);
+
-+ if (event.isCancelled()) {
-+ return;
-+ }
++ if (event.isCancelled()) {
++ return;
++ }
+
-+ blockposition1 = new BlockPosition(event.getToBlock().getX(), event.getToBlock().getY(), event.getToBlock().getZ());
-+ // CraftBukkit end
- if (world.isClientSide) {
- for (int j = 0; j < 128; ++j) {
- double d0 = world.random.nextDouble();
++ blockposition1 = new BlockPosition(event.getToBlock().getX(), event.getToBlock().getY(), event.getToBlock().getZ());
++ // CraftBukkit end
+ if (world.isClientSide) {
+ for (int j = 0; j < 128; ++j) {
+ double d0 = world.random.nextDouble();
diff --git a/nms-patches/BlockDropper.patch b/nms-patches/BlockDropper.patch
index 07c21cb4..ba4ddc9b 100644
--- a/nms-patches/BlockDropper.patch
+++ b/nms-patches/BlockDropper.patch
@@ -10,32 +10,32 @@
+
public class BlockDropper extends BlockDispenser {
- private final IDispenseBehavior e = new DispenseBehaviorItem();
-@@ -35,8 +40,25 @@
- if (iinventory == null) {
- itemstack1 = this.e.a(sourceblock, itemstack);
- } else {
-- 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));
+ private static final IDispenseBehavior c = new DispenseBehaviorItem();
+@@ -34,8 +39,25 @@
+ if (iinventory == null) {
+ itemstack1 = BlockDropper.c.dispense(sourceblock, itemstack);
+ } else {
+- 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));
+
-+ org.bukkit.inventory.Inventory destinationInventory;
-+ // Have to special case large chests as they work oddly
-+ if (iinventory instanceof InventoryLargeChest) {
-+ destinationInventory = new org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest((InventoryLargeChest) iinventory);
-+ } else {
-+ destinationInventory = iinventory.getOwner().getInventory();
-+ }
++ org.bukkit.inventory.Inventory destinationInventory;
++ // Have to special case large chests as they work oddly
++ if (iinventory instanceof InventoryLargeChest) {
++ destinationInventory = new org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest((InventoryLargeChest) iinventory);
++ } else {
++ destinationInventory = iinventory.getOwner().getInventory();
++ }
+
-+ InventoryMoveItemEvent event = new InventoryMoveItemEvent(tileentitydispenser.getOwner().getInventory(), oitemstack.clone(), destinationInventory, true);
-+ world.getServer().getPluginManager().callEvent(event);
-+ if (event.isCancelled()) {
-+ return;
-+ }
-+ itemstack1 = TileEntityHopper.addItem(tileentitydispenser, iinventory, CraftItemStack.asNMSCopy(event.getItem()), enumdirection.opposite());
-+ if (event.getItem().equals(oitemstack) && itemstack1.isEmpty()) {
-+ // CraftBukkit end
- itemstack1 = itemstack.cloneItemStack();
- itemstack1.subtract(1);
- } else {
++ InventoryMoveItemEvent event = new InventoryMoveItemEvent(tileentitydispenser.getOwner().getInventory(), oitemstack.clone(), destinationInventory, true);
++ world.getServer().getPluginManager().callEvent(event);
++ if (event.isCancelled()) {
++ return;
++ }
++ itemstack1 = TileEntityHopper.addItem(tileentitydispenser, iinventory, CraftItemStack.asNMSCopy(event.getItem()), enumdirection.opposite());
++ if (event.getItem().equals(oitemstack) && itemstack1.isEmpty()) {
++ // CraftBukkit end
+ itemstack1 = itemstack.cloneItemStack();
+ itemstack1.subtract(1);
+ } else {
diff --git a/nms-patches/BlockEnderPortal.patch b/nms-patches/BlockEnderPortal.patch
index 52f8b812..9f871fba 100644
--- a/nms-patches/BlockEnderPortal.patch
+++ b/nms-patches/BlockEnderPortal.patch
@@ -1,22 +1,22 @@
--- a/net/minecraft/server/BlockEnderPortal.java
+++ b/net/minecraft/server/BlockEnderPortal.java
-@@ -4,6 +4,8 @@
+@@ -2,6 +2,8 @@
+
import java.util.Random;
- import javax.annotation.Nullable;
+import org.bukkit.event.entity.EntityPortalEnterEvent; // CraftBukkit
+
public class BlockEnderPortal extends BlockTileEntity {
- protected static final AxisAlignedBB a = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 0.75D, 1.0D);
-@@ -37,6 +39,10 @@
+ protected static final VoxelShape a = Block.a(0.0D, 0.0D, 0.0D, 16.0D, 12.0D, 16.0D);
+@@ -28,6 +30,10 @@
- public void a(World world, BlockPosition blockposition, IBlockData iblockdata, Entity entity) {
- if (!world.isClientSide && !entity.isPassenger() && !entity.isVehicle() && entity.bf() && entity.getBoundingBox().c(iblockdata.e(world, blockposition).a(blockposition))) {
+ public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) {
+ if (!world.isClientSide && !entity.isPassenger() && !entity.isVehicle() && entity.bm() && VoxelShapes.c(VoxelShapes.a(entity.getBoundingBox().d((double) (-blockposition.getX()), (double) (-blockposition.getY()), (double) (-blockposition.getZ()))), iblockdata.g(world, blockposition), OperatorBoolean.AND)) {
+ // 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);
+ // CraftBukkit end
- entity.b(1);
+ entity.d(1);
}
diff --git a/nms-patches/BlockFire.patch b/nms-patches/BlockFire.patch
index f5ce1cd8..9f26ccf3 100644
--- a/nms-patches/BlockFire.patch
+++ b/nms-patches/BlockFire.patch
@@ -1,39 +1,65 @@
--- a/net/minecraft/server/BlockFire.java
+++ b/net/minecraft/server/BlockFire.java
-@@ -5,6 +5,12 @@
- import java.util.Random;
+@@ -8,6 +8,16 @@
+ import java.util.function.Predicate;
import javax.annotation.Nullable;
+// CraftBukkit start
++
++import org.bukkit.Bukkit;
++import org.bukkit.craftbukkit.block.CraftBlockState;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.event.block.BlockBurnEvent;
++import org.bukkit.event.block.BlockFadeEvent;
+import org.bukkit.event.block.BlockSpreadEvent;
+// CraftBukkit end
+
public class BlockFire extends Block {
- public static final BlockStateInteger AGE = BlockStateInteger.of("age", 0, 15);
-@@ -95,7 +101,7 @@
- public void b(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) {
+ public static final BlockStateInteger AGE = BlockProperties.W;
+@@ -32,7 +42,20 @@
+ }
+
+ public IBlockData updateState(IBlockData iblockdata, EnumDirection enumdirection, IBlockData iblockdata1, GeneratorAccess generatoraccess, BlockPosition blockposition, BlockPosition blockposition1) {
+- return this.canPlace(iblockdata, generatoraccess, blockposition) ? (IBlockData) this.a((IBlockAccess) generatoraccess, blockposition).set(BlockFire.AGE, iblockdata.get(BlockFire.AGE)) : Blocks.AIR.getBlockData();
++ // CraftBukkit start
++ if (!iblockdata.canPlace(generatoraccess, blockposition)) {
++ CraftBlockState blockState = CraftBlockState.getBlockState(generatoraccess, blockposition);
++ blockState.setData(Blocks.AIR.getBlockData());
++
++ BlockFadeEvent event = new BlockFadeEvent(blockState.getBlock(), blockState);
++ generatoraccess.getMinecraftWorld().getMinecraftServer().server.getPluginManager().callEvent(event);
++
++ if (!event.isCancelled()) {
++ return blockState.getHandle();
++ }
++ }
++ return this.a((IBlockAccess) generatoraccess, blockposition).set(BlockFire.AGE, iblockdata.get(BlockFire.AGE));
++ // CraftBukkit end
+ }
+
+ @Nullable
+@@ -82,7 +105,7 @@
+ public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) {
if (world.getGameRules().getBoolean("doFireTick")) {
- if (!this.canPlace(world, blockposition)) {
+ if (!iblockdata.canPlace(world, blockposition)) {
- world.setAir(blockposition);
+ fireExtinguished(world, blockposition); // CraftBukkit - invalid place location
}
Block block = world.getType(blockposition.down()).getBlock();
-@@ -108,7 +114,7 @@
+@@ -90,7 +113,7 @@
int i = ((Integer) iblockdata.get(BlockFire.AGE)).intValue();
- if (!flag && world.isRaining() && this.b(world, blockposition) && random.nextFloat() < 0.2F + (float) i * 0.03F) {
+ if (!flag && world.isRaining() && this.a(world, blockposition) && random.nextFloat() < 0.2F + (float) i * 0.03F) {
- world.setAir(blockposition);
+ fireExtinguished(world, blockposition); // CraftBukkit - extinguished by rain
} else {
- if (i < 15) {
- iblockdata = iblockdata.set(BlockFire.AGE, Integer.valueOf(i + random.nextInt(3) / 2));
-@@ -119,14 +125,14 @@
- if (!flag) {
- if (!this.c(world, blockposition)) {
+ int j = Math.min(15, i + random.nextInt(3) / 2);
+
+@@ -103,14 +126,14 @@
+ world.I().a(blockposition, this, this.a((IWorldReader) world) + random.nextInt(10));
+ if (!this.d(world, blockposition)) {
if (!world.getType(blockposition.down()).q() || i > 3) {
- world.setAir(blockposition);
+ fireExtinguished(world, blockposition); // CraftBukkit
@@ -42,68 +68,57 @@
return;
}
- if (!this.c((IBlockAccess) world, blockposition.down()) && i == 15 && random.nextInt(4) == 0) {
+ if (i == 15 && random.nextInt(4) == 0 && !this.j(world.getType(blockposition.down()))) {
- world.setAir(blockposition);
+ fireExtinguished(world, blockposition); // CraftBukkit
return;
}
}
-@@ -138,12 +144,14 @@
- b0 = -50;
- }
+@@ -118,12 +141,14 @@
+ boolean flag1 = world.x(blockposition);
+ int k = flag1 ? -50 : 0;
-- this.a(world, blockposition.east(), 300 + b0, random, i);
-- this.a(world, blockposition.west(), 300 + b0, random, i);
-- this.a(world, blockposition.down(), 250 + b0, random, i);
-- this.a(world, blockposition.up(), 250 + b0, random, i);
-- this.a(world, blockposition.north(), 300 + b0, random, i);
-- this.a(world, blockposition.south(), 300 + b0, random, i);
+- this.a(world, blockposition.east(), 300 + k, random, i);
+- this.a(world, blockposition.west(), 300 + k, random, i);
+- this.a(world, blockposition.down(), 250 + k, random, i);
+- this.a(world, blockposition.up(), 250 + k, random, i);
+- this.a(world, blockposition.north(), 300 + k, random, i);
+- this.a(world, blockposition.south(), 300 + k, random, i);
+ // CraftBukkit start - add source blockposition to burn calls
-+ this.a(world, blockposition.east(), 300 + b0, random, i, blockposition);
-+ this.a(world, blockposition.west(), 300 + b0, random, i, blockposition);
-+ this.a(world, blockposition.down(), 250 + b0, random, i, blockposition);
-+ this.a(world, blockposition.up(), 250 + b0, random, i, blockposition);
-+ this.a(world, blockposition.north(), 300 + b0, random, i, blockposition);
-+ this.a(world, blockposition.south(), 300 + b0, random, i, blockposition);
++ this.a(world, blockposition.east(), 300 + k, random, i, blockposition);
++ this.a(world, blockposition.west(), 300 + k, random, i, blockposition);
++ this.a(world, blockposition.down(), 250 + k, random, i, blockposition);
++ this.a(world, blockposition.up(), 250 + k, random, i, blockposition);
++ this.a(world, blockposition.north(), 300 + k, random, i, blockposition);
++ this.a(world, blockposition.south(), 300 + k, random, i, blockposition);
+ // CraftBukkit end
+ BlockPosition.MutableBlockPosition blockposition_mutableblockposition = new BlockPosition.MutableBlockPosition();
- for (int j = -1; j <= 1; ++j) {
- for (int k = -1; k <= 1; ++k) {
-@@ -172,7 +180,26 @@
- l1 = 15;
- }
+ for (int l = -1; l <= 1; ++l) {
+@@ -149,7 +174,15 @@
+ if (i2 > 0 && random.nextInt(k1) <= i2 && (!world.isRaining() || !this.a(world, (BlockPosition) blockposition_mutableblockposition))) {
+ int j2 = Math.min(15, i + random.nextInt(5) / 4);
-- world.setTypeAndData(blockposition1, iblockdata.set(BlockFire.AGE, Integer.valueOf(l1)), 3);
+- world.setTypeAndData(blockposition_mutableblockposition, (IBlockData) this.a((IBlockAccess) world, (BlockPosition) blockposition_mutableblockposition).set(BlockFire.AGE, Integer.valueOf(j2)), 3);
+ // CraftBukkit start - Call to stop spread of fire
-+ if (world.getType(blockposition1) != Blocks.FIRE) {
-+ if (CraftEventFactory.callBlockIgniteEvent(world, blockposition1.getX(), blockposition1.getY(), blockposition1.getZ(), blockposition.getX(), blockposition.getY(), blockposition.getZ()).isCancelled()) {
++ if (world.getType(blockposition_mutableblockposition) != Blocks.FIRE) {
++ if (CraftEventFactory.callBlockIgniteEvent(world, blockposition_mutableblockposition, blockposition).isCancelled()) {
+ continue;
+ }
+
-+ org.bukkit.Server server = world.getServer();
-+ org.bukkit.World bworld = world.getWorld();
-+ org.bukkit.block.BlockState blockState = bworld.getBlockAt(blockposition1.getX(), blockposition1.getY(), blockposition1.getZ()).getState();
-+ blockState.setTypeId(Block.getId(this));
-+ blockState.setData(new org.bukkit.material.MaterialData(Block.getId(this), (byte) l1));
-+
-+ BlockSpreadEvent spreadEvent = new BlockSpreadEvent(blockState.getBlock(), bworld.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), blockState);
-+ server.getPluginManager().callEvent(spreadEvent);
-+
-+ if (!spreadEvent.isCancelled()) {
-+ blockState.update(true);
-+ }
++ CraftEventFactory.handleBlockSpreadEvent(world, blockposition, blockposition_mutableblockposition, (IBlockData) this.a((IBlockAccess) world, (BlockPosition) blockposition_mutableblockposition).set(BlockFire.AGE, Integer.valueOf(j2)), 3); // CraftBukkit
+ }
+ // CraftBukkit end
}
}
}
-@@ -204,12 +231,24 @@
- return integer == null ? 0 : integer.intValue();
+@@ -173,12 +206,24 @@
+ return this.flameChances.getInt(block);
}
- private void a(World world, BlockPosition blockposition, int i, Random random, int j) {
+ private void a(World world, BlockPosition blockposition, int i, Random random, int j, BlockPosition sourceposition) { // CraftBukkit add sourceposition
- int k = this.e(world.getType(blockposition).getBlock());
+ int k = this.f(world.getType(blockposition).getBlock());
if (random.nextInt(i) < k) {
IBlockData iblockdata = world.getType(blockposition);
@@ -121,34 +136,25 @@
+ // CraftBukkit end
+
if (random.nextInt(j + 10) < 5 && !world.isRainingAt(blockposition)) {
- int l = j + random.nextInt(5) / 4;
-
-@@ -276,7 +315,7 @@
-
- public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Block block, BlockPosition blockposition1) {
- if (!world.getType(blockposition.down()).q() && !this.c(world, blockposition)) {
-- world.setAir(blockposition);
-+ fireExtinguished(world, blockposition); // CraftBukkit - fuel block gone
- }
+ int l = Math.min(j + random.nextInt(5) / 4, 15);
- }
-@@ -284,7 +323,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)) {
-- world.setAir(blockposition);
-+ fireExtinguished(world, blockposition); // CraftBukkit - fuel block broke
- } else {
- world.a(blockposition, (Block) this, this.a(world) + world.random.nextInt(10));
- }
-@@ -310,4 +349,12 @@
- public EnumBlockFaceShape a(IBlockAccess iblockaccess, IBlockData iblockdata, BlockPosition blockposition, EnumDirection enumdirection) {
- return EnumBlockFaceShape.UNDEFINED;
+@@ -241,7 +286,7 @@
+ if (iblockdata1.getBlock() != iblockdata.getBlock()) {
+ if (world.worldProvider.getDimensionManager().getDimensionID() > 0 || !((BlockPortal) Blocks.NETHER_PORTAL).a((GeneratorAccess) world, blockposition)) {
+ if (!iblockdata.canPlace(world, blockposition)) {
+- world.setAir(blockposition);
++ fireExtinguished(world, blockposition); // CraftBukkit - fuel block broke
+ } else {
+ world.I().a(blockposition, this, this.a((IWorldReader) world) + world.random.nextInt(10));
+ }
+@@ -387,4 +432,12 @@
+ blockfire.a(Blocks.BLACK_CARPET, 60, 20);
+ blockfire.a(Blocks.DRIED_KELP_BLOCK, 30, 60);
}
+
+ // CraftBukkit start
-+ private void fireExtinguished(World world, BlockPosition position) {
-+ if (!CraftEventFactory.callBlockFadeEvent(world.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ()), Blocks.AIR).isCancelled()) {
++ private void fireExtinguished(GeneratorAccess world, BlockPosition position) {
++ if (!CraftEventFactory.callBlockFadeEvent(world, position, Blocks.AIR.getBlockData()).isCancelled()) {
+ world.setAir(position);
+ }
+ }
diff --git a/nms-patches/BlockFlowing.patch b/nms-patches/BlockFlowing.patch
deleted file mode 100644
index 55906695..00000000
--- a/nms-patches/BlockFlowing.patch
+++ /dev/null
@@ -1,66 +0,0 @@
---- a/net/minecraft/server/BlockFlowing.java
-+++ b/net/minecraft/server/BlockFlowing.java
-@@ -5,6 +5,11 @@
- import java.util.Random;
- import java.util.Set;
-
-+// CraftBukkit start
-+import org.bukkit.block.BlockFace;
-+import org.bukkit.event.block.BlockFromToEvent;
-+// CraftBukkit end
-+
- public class BlockFlowing extends BlockFluids {
-
- int a;
-@@ -85,12 +90,25 @@
- this.f(world, blockposition, iblockdata);
- }
-
-+ org.bukkit.block.Block source = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); // CraftBukkit
- IBlockData iblockdata2 = world.getType(blockposition.down());
-
- if (this.h(world, blockposition.down(), iblockdata2)) {
-+ // CraftBukkit start
-+ BlockFromToEvent event = new BlockFromToEvent(source, BlockFace.DOWN);
-+ world.getServer().getPluginManager().callEvent(event);
-+
-+ if (event.isCancelled()) {
-+ return;
-+ }
-+ // CraftBukkit end
-+
- if (this.material == Material.LAVA && world.getType(blockposition.down()).getMaterial() == Material.WATER) {
-- world.setTypeUpdate(blockposition.down(), Blocks.STONE.getBlockData());
-- this.fizz(world, blockposition.down());
-+ // CraftBukkit start
-+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition.down(), Blocks.STONE.getBlockData(), null)) {
-+ this.fizz(world, blockposition.down());
-+ }
-+ // CraftBukkit end
- return;
- }
-
-@@ -116,14 +134,21 @@
- while (iterator1.hasNext()) {
- EnumDirection enumdirection1 = (EnumDirection) iterator1.next();
-
-- this.flow(world, blockposition.shift(enumdirection1), world.getType(blockposition.shift(enumdirection1)), k);
-+ // CraftBukkit start
-+ BlockFromToEvent event = new BlockFromToEvent(source, org.bukkit.craftbukkit.block.CraftBlock.notchToBlockFace(enumdirection1));
-+ world.getServer().getPluginManager().callEvent(event);
-+
-+ if (!event.isCancelled()) {
-+ this.flow(world, blockposition.shift(enumdirection1), world.getType(blockposition.shift(enumdirection1)), k);
-+ }
-+ // CraftBukkit end
- }
- }
-
- }
-
- private void flow(World world, BlockPosition blockposition, IBlockData iblockdata, int i) {
-- if (this.h(world, blockposition, iblockdata)) {
-+ if (world.isLoaded(blockposition) && this.h(world, blockposition, iblockdata)) { // CraftBukkit - add isLoaded check
- if (iblockdata.getMaterial() != Material.AIR) {
- if (this.material == Material.LAVA) {
- this.fizz(world, blockposition);
diff --git a/nms-patches/BlockFluids.patch b/nms-patches/BlockFluids.patch
index cccec394..cad979d2 100644
--- a/nms-patches/BlockFluids.patch
+++ b/nms-patches/BlockFluids.patch
@@ -1,27 +1,41 @@
--- a/net/minecraft/server/BlockFluids.java
+++ b/net/minecraft/server/BlockFluids.java
-@@ -175,14 +175,20 @@
- Integer integer = (Integer) iblockdata.get(BlockFluids.LEVEL);
+@@ -46,10 +46,10 @@
+ public VoxelShape a(IBlockData iblockdata, IBlockAccess iblockaccess, BlockPosition blockposition) {
+ Fluid fluid = iblockaccess.b(blockposition.up());
- if (integer.intValue() == 0) {
+- return fluid.c().a((FluidType) this.b) ? VoxelShapes.b() : (VoxelShape) this.c.computeIfAbsent(iblockdata, (iblockdata) -> {
+- Fluid fluid = iblockdata.s();
++ return fluid.c().a((FluidType) this.b) ? VoxelShapes.b() : (VoxelShape) this.c.computeIfAbsent(iblockdata, (iblockdata1) -> { // CraftBukkit - decompile errors
++ Fluid fluid1 = iblockdata1.s();
+
+- return VoxelShapes.a(0.0D, 0.0D, 0.0D, 1.0D, (double) fluid.f(), 1.0D);
++ return VoxelShapes.a(0.0D, 0.0D, 0.0D, 1.0D, (double) fluid1.f(), 1.0D);
+ });
+ }
+
+@@ -106,14 +106,20 @@
+ Fluid fluid = world.b(blockposition);
+
+ if (fluid.d()) {
- world.setTypeUpdate(blockposition, Blocks.OBSIDIAN.getBlockData());
- this.fizz(world, blockposition);
+ // CraftBukkit start
-+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition, Blocks.OBSIDIAN.getBlockData(), null)) {
++ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition, Blocks.OBSIDIAN.getBlockData())) {
+ this.fizz(world, blockposition);
+ }
+ // CraftBukkit end
- return true;
+ return false;
}
- if (integer.intValue() <= 4) {
+ if (fluid.f() >= 0.44444445F) {
- world.setTypeUpdate(blockposition, Blocks.COBBLESTONE.getBlockData());
- this.fizz(world, blockposition);
+ // CraftBukkit start
-+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition, Blocks.COBBLESTONE.getBlockData(), null)) {
++ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition, Blocks.COBBLESTONE.getBlockData())) {
+ this.fizz(world, blockposition);
+ }
+ // CraftBukkit end
- return true;
+ return false;
}
}
diff --git a/nms-patches/BlockGrass.patch b/nms-patches/BlockGrass.patch
index 040f26ae..68f953a2 100644
--- a/nms-patches/BlockGrass.patch
+++ b/nms-patches/BlockGrass.patch
@@ -1,77 +1,11 @@
--- a/net/minecraft/server/BlockGrass.java
+++ b/net/minecraft/server/BlockGrass.java
-@@ -2,6 +2,14 @@
-
- import java.util.Random;
-
-+// CraftBukkit start
-+import org.bukkit.block.BlockState;
-+import org.bukkit.craftbukkit.event.CraftEventFactory;
-+import org.bukkit.craftbukkit.util.CraftMagicNumbers;
-+import org.bukkit.event.block.BlockSpreadEvent;
-+import org.bukkit.event.block.BlockFadeEvent;
-+// CraftBukkit end
-+
- public class BlockGrass extends Block implements IBlockFragilePlantElement {
-
- public static final BlockStateBoolean SNOWY = BlockStateBoolean.of("snowy");
-@@ -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) {
-- world.setTypeUpdate(blockposition, Blocks.DIRT.getBlockData());
-+ // CraftBukkit start
-+ // world.setTypeUpdate(blockposition, Blocks.DIRT.getBlockData());
-+ org.bukkit.World bworld = world.getWorld();
-+ BlockState blockState = bworld.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()).getState();
-+ blockState.setType(CraftMagicNumbers.getMaterial(Blocks.DIRT));
-+
-+ BlockFadeEvent event = new BlockFadeEvent(blockState.getBlock(), blockState);
-+ world.getServer().getPluginManager().callEvent(event);
-+
-+ if (!event.isCancelled()) {
-+ blockState.update(true);
-+ }
-+ // CraftBukkit end
- } else {
- if (world.getLightLevel(blockposition.up()) >= 9) {
- for (int i = 0; i < 4; ++i) {
-@@ -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) {
-- world.setTypeUpdate(blockposition1, Blocks.GRASS.getBlockData());
-+ // CraftBukkit start
-+ // world.setTypeUpdate(blockposition1, Blocks.GRASS.getBlockData());
-+ org.bukkit.World bworld = world.getWorld();
-+ BlockState blockState = bworld.getBlockAt(blockposition1.getX(), blockposition1.getY(), blockposition1.getZ()).getState();
-+ blockState.setType(CraftMagicNumbers.getMaterial(Blocks.GRASS));
-+
-+ BlockSpreadEvent event = new BlockSpreadEvent(blockState.getBlock(), bworld.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), blockState);
-+ world.getServer().getPluginManager().callEvent(event);
-+
-+ if (!event.isCancelled()) {
-+ blockState.update(true);
-+ }
-+ // CraftBukkit end
- }
- }
- }
-@@ -79,13 +111,15 @@
- IBlockData iblockdata1 = blockflowers.getBlockData().set(blockflowers.g(), blockflowers_enumflowervarient);
-
- if (blockflowers.f(world, blockposition2, iblockdata1)) {
-- world.setTypeAndData(blockposition2, iblockdata1, 3);
-+ // world.setTypeAndData(blockposition2, iblockdata1, 3); // CraftBukkit
-+ CraftEventFactory.handleBlockGrowEvent(world, blockposition2.getX(), blockposition2.getY(), blockposition2.getZ(), iblockdata1.getBlock(), iblockdata1.getBlock().toLegacyData(iblockdata1)); // CraftBukkit
+@@ -51,7 +51,7 @@
}
- } else {
- IBlockData iblockdata2 = Blocks.TALLGRASS.getBlockData().set(BlockLongGrass.TYPE, BlockLongGrass.EnumTallGrassType.GRASS);
- if (Blocks.TALLGRASS.f(world, blockposition2, iblockdata2)) {
+ if (iblockdata2.canPlace(world, blockposition2)) {
- world.setTypeAndData(blockposition2, iblockdata2, 3);
-+ // world.setTypeAndData(blockposition2, iblockdata2, 3); // CraftBukkit
-+ CraftEventFactory.handleBlockGrowEvent(world, blockposition2.getX(), blockposition2.getY(), blockposition2.getZ(), iblockdata2.getBlock(), iblockdata2.getBlock().toLegacyData(iblockdata2)); // CraftBukkit
++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(world, blockposition2, iblockdata2, 3); // CraftBukkit
}
}
}
diff --git a/nms-patches/BlockIce.patch b/nms-patches/BlockIce.patch
index 2971d276..e7a33760 100644
--- a/nms-patches/BlockIce.patch
+++ b/nms-patches/BlockIce.patch
@@ -1,14 +1,14 @@
--- a/net/minecraft/server/BlockIce.java
+++ b/net/minecraft/server/BlockIce.java
-@@ -47,6 +47,11 @@
+@@ -52,6 +52,11 @@
}
- protected void b(World world, BlockPosition blockposition) {
+ protected void b(IBlockData iblockdata, World world, BlockPosition blockposition) {
+ // CraftBukkit start
-+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), world.worldProvider.l() ? Blocks.AIR : Blocks.WATER).isCancelled()) {
++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(world, blockposition, world.worldProvider.isNether() ? Blocks.AIR.getBlockData() : Blocks.WATER.getBlockData()).isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
- if (world.worldProvider.l()) {
+ if (world.worldProvider.isNether()) {
world.setAir(blockposition);
} else {
diff --git a/nms-patches/BlockJukeBox.patch b/nms-patches/BlockJukeBox.patch
deleted file mode 100644
index 2b1a5cd6..00000000
--- a/nms-patches/BlockJukeBox.patch
+++ /dev/null
@@ -1,14 +0,0 @@
---- a/net/minecraft/server/BlockJukeBox.java
-+++ b/net/minecraft/server/BlockJukeBox.java
-@@ -141,6 +141,11 @@
- }
-
- public void setRecord(ItemStack itemstack) {
-+ // CraftBukkit start - There can only be one
-+ if (!itemstack.isEmpty()) {
-+ itemstack.setCount(1);
-+ }
-+ // CraftBukkit end
- this.record = itemstack;
- this.update();
- }
diff --git a/nms-patches/BlockLeaves.patch b/nms-patches/BlockLeaves.patch
index bb3a479d..3aad2770 100644
--- a/nms-patches/BlockLeaves.patch
+++ b/nms-patches/BlockLeaves.patch
@@ -1,26 +1,26 @@
--- a/net/minecraft/server/BlockLeaves.java
+++ b/net/minecraft/server/BlockLeaves.java
-@@ -2,6 +2,8 @@
-
+@@ -3,6 +3,8 @@
import java.util.Random;
+ import javax.annotation.Nullable;
+import org.bukkit.event.block.LeavesDecayEvent; // CraftBukkit
+
- public abstract class BlockLeaves extends Block {
+ public class BlockLeaves extends Block {
- public static final BlockStateBoolean DECAYABLE = BlockStateBoolean.of("decayable");
-@@ -132,6 +134,14 @@
- }
+ public static final BlockStateInteger DISTANCE = BlockProperties.aa;
+@@ -20,6 +22,14 @@
- private void b(World world, BlockPosition blockposition) {
-+ // CraftBukkit start
-+ LeavesDecayEvent event = new LeavesDecayEvent(world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()));
-+ world.getServer().getPluginManager().callEvent(event);
+ public void b(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) {
+ if (!((Boolean) iblockdata.get(BlockLeaves.PERSISTENT)).booleanValue() && ((Integer) iblockdata.get(BlockLeaves.DISTANCE)).intValue() == 7) {
++ // CraftBukkit start
++ LeavesDecayEvent event = new LeavesDecayEvent(world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()));
++ world.getServer().getPluginManager().callEvent(event);
+
-+ if (event.isCancelled() || world.getType(blockposition).getBlock() != this) {
-+ return;
-+ }
-+ // CraftBukkit end
- this.b(world, blockposition, world.getType(blockposition), 0);
- world.setAir(blockposition);
- }
++ if (event.isCancelled() || world.getType(blockposition).getBlock() != this) {
++ return;
++ }
++ // CraftBukkit end
+ iblockdata.a(world, blockposition, 0);
+ world.setAir(blockposition);
+ }
diff --git a/nms-patches/BlockLever.patch b/nms-patches/BlockLever.patch
index db03cc1f..945ac935 100644
--- a/nms-patches/BlockLever.patch
+++ b/nms-patches/BlockLever.patch
@@ -1,16 +1,15 @@
--- a/net/minecraft/server/BlockLever.java
+++ b/net/minecraft/server/BlockLever.java
-@@ -3,6 +3,8 @@
- import java.util.Iterator;
- import javax.annotation.Nullable;
+@@ -1,5 +1,7 @@
+ package net.minecraft.server;
+import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
+
- public class BlockLever extends Block {
+ public class BlockLever extends BlockAttachable {
+
+ public static final BlockStateBoolean POWERED = BlockProperties.t;
+@@ -73,6 +75,20 @@
- public static final BlockStateEnum<BlockLever.EnumLeverPosition> FACING = BlockStateEnum.of("facing", BlockLever.EnumLeverPosition.class);
-@@ -129,6 +131,20 @@
- if (world.isClientSide) {
return true;
} else {
+ // CraftBukkit start - Interact Lever
@@ -27,6 +26,6 @@
+ }
+ // CraftBukkit end
+
- iblockdata = iblockdata.a((IBlockState) BlockLever.POWERED);
world.setTypeAndData(blockposition, iblockdata, 3);
- float f3 = ((Boolean) iblockdata.get(BlockLever.POWERED)).booleanValue() ? 0.6F : 0.5F;
+ float f3 = flag ? 0.6F : 0.5F;
+
diff --git a/nms-patches/BlockMagma.patch b/nms-patches/BlockMagma.patch
index 75f5fbad..6e1cc11c 100644
--- a/nms-patches/BlockMagma.patch
+++ b/nms-patches/BlockMagma.patch
@@ -1,6 +1,6 @@
--- a/net/minecraft/server/BlockMagma.java
+++ b/net/minecraft/server/BlockMagma.java
-@@ -17,7 +17,9 @@
+@@ -10,7 +10,9 @@
public void stepOn(World world, BlockPosition blockposition, Entity entity) {
if (!entity.isFireProof() && entity instanceof EntityLiving && !EnchantmentManager.i((EntityLiving) entity)) {
diff --git a/nms-patches/BlockMinecartDetector.patch b/nms-patches/BlockMinecartDetector.patch
index 014c5102..071412c9 100644
--- a/nms-patches/BlockMinecartDetector.patch
+++ b/nms-patches/BlockMinecartDetector.patch
@@ -1,15 +1,15 @@
--- a/net/minecraft/server/BlockMinecartDetector.java
+++ b/net/minecraft/server/BlockMinecartDetector.java
@@ -6,6 +6,8 @@
- import java.util.Random;
+ import java.util.function.Predicate;
import javax.annotation.Nullable;
+import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
+
public class BlockMinecartDetector extends BlockMinecartTrackAbstract {
- public static final BlockStateEnum<BlockMinecartTrackAbstract.EnumTrackPosition> SHAPE = BlockStateEnum.a("shape", BlockMinecartTrackAbstract.EnumTrackPosition.class, new Predicate() {
-@@ -66,6 +68,17 @@
+ public static final BlockStateEnum<BlockPropertyTrackPosition> SHAPE = BlockProperties.R;
+@@ -55,6 +57,17 @@
flag1 = true;
}
@@ -25,5 +25,5 @@
+ // CraftBukkit end
+
if (flag1 && !flag) {
- world.setTypeAndData(blockposition, iblockdata.set(BlockMinecartDetector.POWERED, Boolean.valueOf(true)), 3);
+ world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockMinecartDetector.POWERED, Boolean.valueOf(true)), 3);
this.b(world, blockposition, iblockdata, true);
diff --git a/nms-patches/BlockMobSpawner.patch b/nms-patches/BlockMobSpawner.patch
index 67c46a90..2b95d6b1 100644
--- a/nms-patches/BlockMobSpawner.patch
+++ b/nms-patches/BlockMobSpawner.patch
@@ -1,9 +1,9 @@
--- a/net/minecraft/server/BlockMobSpawner.java
+++ b/net/minecraft/server/BlockMobSpawner.java
-@@ -22,9 +22,19 @@
+@@ -16,9 +16,19 @@
- public void dropNaturally(World world, BlockPosition blockposition, IBlockData iblockdata, float f, int i) {
- super.dropNaturally(world, blockposition, iblockdata, f, i);
+ public void dropNaturally(IBlockData iblockdata, World world, BlockPosition blockposition, float f, int i) {
+ super.dropNaturally(iblockdata, world, blockposition, f, i);
+ /* CraftBukkit start - Delegate to getExpDrop
int j = 15 + world.random.nextInt(15) + world.random.nextInt(15);
@@ -12,11 +12,11 @@
+ }
+
+ @Override
-+ public int getExpDrop(World world, IBlockData iblockdata, int enchantmentLevel) {
++ public int getExpDrop(IBlockData iblockdata, World world, BlockPosition blockposition, int enchantmentLevel) {
+ int j = 15 + world.random.nextInt(15) + world.random.nextInt(15);
+
+ return j;
+ // CraftBukkit end
}
- public boolean b(IBlockData iblockdata) {
+ public EnumRenderType c(IBlockData iblockdata) {
diff --git a/nms-patches/BlockMonsterEggs.patch b/nms-patches/BlockMonsterEggs.patch
index ae60b27d..7b493438 100644
--- a/nms-patches/BlockMonsterEggs.patch
+++ b/nms-patches/BlockMonsterEggs.patch
@@ -1,15 +1,15 @@
--- a/net/minecraft/server/BlockMonsterEggs.java
+++ b/net/minecraft/server/BlockMonsterEggs.java
-@@ -2,6 +2,8 @@
-
+@@ -4,6 +4,8 @@
+ import java.util.Map;
import java.util.Random;
+import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; // CraftBukkit
+
public class BlockMonsterEggs extends Block {
- public static final BlockStateEnum<BlockMonsterEggs.EnumMonsterEggVarient> VARIANT = BlockStateEnum.of("variant", BlockMonsterEggs.EnumMonsterEggVarient.class);
-@@ -50,7 +52,7 @@
+ private final Block a;
+@@ -36,7 +38,7 @@
EntitySilverfish entitysilverfish = new EntitySilverfish(world);
entitysilverfish.setPositionRotation((double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, 0.0F, 0.0F);
diff --git a/nms-patches/BlockMushroom.patch b/nms-patches/BlockMushroom.patch
index 911f296f..0787a57c 100644
--- a/nms-patches/BlockMushroom.patch
+++ b/nms-patches/BlockMushroom.patch
@@ -1,55 +1,41 @@
--- a/net/minecraft/server/BlockMushroom.java
+++ b/net/minecraft/server/BlockMushroom.java
-@@ -3,6 +3,12 @@
+@@ -3,6 +3,10 @@
import java.util.Iterator;
import java.util.Random;
+// CraftBukkit start
+import org.bukkit.TreeType;
-+import org.bukkit.block.BlockState;
-+import org.bukkit.event.block.BlockSpreadEvent;
+// CraftBukkit end
+
public class BlockMushroom extends BlockPlant implements IBlockFragilePlantElement {
- protected static final AxisAlignedBB a = new AxisAlignedBB(0.30000001192092896D, 0.0D, 0.30000001192092896D, 0.699999988079071D, 0.4000000059604645D, 0.699999988079071D);
-@@ -16,6 +22,7 @@
+ protected static final VoxelShape a = Block.a(5.0D, 0.0D, 5.0D, 11.0D, 6.0D, 11.0D);
+@@ -16,6 +20,7 @@
}
- public void b(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) {
+ public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) {
+ final int sourceX = blockposition.getX(), sourceY = blockposition.getY(), sourceZ = blockposition.getZ(); // CraftBukkit
if (random.nextInt(25) == 0) {
int i = 5;
boolean flag = true;
-@@ -43,7 +50,19 @@
+@@ -43,7 +48,7 @@
}
- if (world.isEmpty(blockposition2) && this.f(world, blockposition2, this.getBlockData())) {
-- world.setTypeAndData(blockposition2, this.getBlockData(), 2);
-+ // CraftBukkit start
-+ // world.setTypeAndData(blockposition2, this.getBlockData(), 2);
-+ org.bukkit.World bworld = world.getWorld();
-+ BlockState blockState = bworld.getBlockAt(blockposition2.getX(), blockposition2.getY(), blockposition2.getZ()).getState();
-+ blockState.setType(org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(this)); // nms: this.id, 0, 2
-+
-+ BlockSpreadEvent event = new BlockSpreadEvent(blockState.getBlock(), bworld.getBlockAt(sourceX, sourceY, sourceZ), blockState);
-+ world.getServer().getPluginManager().callEvent(event);
-+
-+ if (!event.isCancelled()) {
-+ blockState.update(true);
-+ }
-+ // CraftBukkit end
+ if (world.isEmpty(blockposition2) && iblockdata.canPlace(world, blockposition2)) {
+- world.setTypeAndData(blockposition2, iblockdata, 2);
++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(world, blockposition, blockposition2, iblockdata, 2); // CraftBukkit
}
}
-@@ -72,8 +91,10 @@
- WorldGenHugeMushroom worldgenhugemushroom = null;
+@@ -66,8 +71,10 @@
+ WorldGenerator worldgenerator = null;
if (this == Blocks.BROWN_MUSHROOM) {
+ BlockSapling.treeType = TreeType.BROWN_MUSHROOM; // CraftBukkit
- worldgenhugemushroom = new WorldGenHugeMushroom(Blocks.BROWN_MUSHROOM_BLOCK);
+ worldgenerator = WorldGenerator.U;
} else if (this == Blocks.RED_MUSHROOM) {
+ BlockSapling.treeType = TreeType.RED_MUSHROOM; // CraftBukkit
- worldgenhugemushroom = new WorldGenHugeMushroom(Blocks.RED_MUSHROOM_BLOCK);
+ worldgenerator = WorldGenerator.T;
}
diff --git a/nms-patches/BlockMycel.patch b/nms-patches/BlockMycel.patch
deleted file mode 100644
index 626b81bf..00000000
--- a/nms-patches/BlockMycel.patch
+++ /dev/null
@@ -1,58 +0,0 @@
---- a/net/minecraft/server/BlockMycel.java
-+++ b/net/minecraft/server/BlockMycel.java
-@@ -2,6 +2,13 @@
-
- import java.util.Random;
-
-+// CraftBukkit start
-+import org.bukkit.block.BlockState;
-+import org.bukkit.craftbukkit.util.CraftMagicNumbers;
-+import org.bukkit.event.block.BlockFadeEvent;
-+import org.bukkit.event.block.BlockSpreadEvent;
-+// CraftBukkit end
-+
- public class BlockMycel extends Block {
-
- public static final BlockStateBoolean SNOWY = BlockStateBoolean.of("snowy");
-@@ -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) {
-- world.setTypeUpdate(blockposition, Blocks.DIRT.getBlockData().set(BlockDirt.VARIANT, BlockDirt.EnumDirtVariant.DIRT));
-+ // CraftBukkit start
-+ // world.setTypeUpdate(blockposition, Blocks.DIRT.getBlockData().set(BlockDirt.VARIANT, BlockDirt.EnumDirtVariant.DIRT));
-+ org.bukkit.World bworld = world.getWorld();
-+ BlockState blockState = bworld.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()).getState();
-+ blockState.setType(CraftMagicNumbers.getMaterial(Blocks.DIRT));
-+
-+ BlockFadeEvent event = new BlockFadeEvent(blockState.getBlock(), blockState);
-+ world.getServer().getPluginManager().callEvent(event);
-+
-+ if (!event.isCancelled()) {
-+ blockState.update(true);
-+ }
-+ // CraftBukkit end
- } else {
- if (world.getLightLevel(blockposition.up()) >= 9) {
- for (int i = 0; i < 4; ++i) {
-@@ -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) {
-- world.setTypeUpdate(blockposition1, this.getBlockData());
-+ // CraftBukkit start
-+ // world.setTypeUpdate(blockposition1, this.getBlockData());
-+ org.bukkit.World bworld = world.getWorld();
-+ BlockState blockState = bworld.getBlockAt(blockposition1.getX(), blockposition1.getY(), blockposition1.getZ()).getState();
-+ blockState.setType(CraftMagicNumbers.getMaterial(this));
-+
-+ BlockSpreadEvent event = new BlockSpreadEvent(blockState.getBlock(), bworld.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), blockState);
-+ world.getServer().getPluginManager().callEvent(event);
-+
-+ if (!event.isCancelled()) {
-+ blockState.update(true);
-+ }
-+ // CraftBukkit end
- }
- }
- }
diff --git a/nms-patches/BlockNetherWart.patch b/nms-patches/BlockNetherWart.patch
index 1af3f818..f0aca39f 100644
--- a/nms-patches/BlockNetherWart.patch
+++ b/nms-patches/BlockNetherWart.patch
@@ -1,12 +1,11 @@
--- a/net/minecraft/server/BlockNetherWart.java
+++ b/net/minecraft/server/BlockNetherWart.java
-@@ -31,7 +31,8 @@
+@@ -25,7 +25,7 @@
if (i < 3 && random.nextInt(10) == 0) {
- iblockdata = iblockdata.set(BlockNetherWart.AGE, Integer.valueOf(i + 1));
+ iblockdata = (IBlockData) iblockdata.set(BlockNetherWart.AGE, Integer.valueOf(i + 1));
- world.setTypeAndData(blockposition, iblockdata, 2);
-+ // world.setTypeAndData(blockposition, iblockdata, 2); // CraftBukkit
-+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this, toLegacyData(iblockdata)); // CraftBukkit
++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(world, blockposition, iblockdata, 2); // CraftBukkit
}
- super.b(world, blockposition, iblockdata, random);
+ super.a(iblockdata, world, blockposition, random);
diff --git a/nms-patches/BlockNote.patch b/nms-patches/BlockNote.patch
new file mode 100644
index 00000000..246b882b
--- /dev/null
+++ b/nms-patches/BlockNote.patch
@@ -0,0 +1,46 @@
+--- a/net/minecraft/server/BlockNote.java
++++ b/net/minecraft/server/BlockNote.java
+@@ -24,7 +24,7 @@
+
+ if (flag != ((Boolean) iblockdata.get(BlockNote.POWERED)).booleanValue()) {
+ if (flag) {
+- this.play(world, blockposition);
++ this.play(world, blockposition, iblockdata); // CraftBukkit
+ }
+
+ world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockNote.POWERED, Boolean.valueOf(flag)), 3);
+@@ -32,9 +32,14 @@
+
+ }
+
+- private void play(World world, BlockPosition blockposition) {
++ private void play(World world, BlockPosition blockposition, IBlockData data) { // CraftBukkit
+ if (world.getType(blockposition.up()).isAir()) {
+- world.playBlockAction(blockposition, this, 0, 0);
++ // CraftBukkit start
++ org.bukkit.event.block.NotePlayEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callNotePlayEvent(world, blockposition, data.get(BlockNote.INSTRUMENT), data.get(BlockNote.NOTE));
++ if (!event.isCancelled()) {
++ world.playBlockAction(blockposition, this, 0, 0);
++ }
++ // CraftBukkit end
+ }
+
+ }
+@@ -45,7 +50,7 @@
+ } else {
+ iblockdata = (IBlockData) iblockdata.a((IBlockState) BlockNote.NOTE);
+ world.setTypeAndData(blockposition, iblockdata, 3);
+- this.play(world, blockposition);
++ this.play(world, blockposition, iblockdata); // CraftBukkit
+ entityhuman.a(StatisticList.TUNE_NOTEBLOCK);
+ return true;
+ }
+@@ -53,7 +58,7 @@
+
+ public void attack(IBlockData iblockdata, World world, BlockPosition blockposition, EntityHuman entityhuman) {
+ if (!world.isClientSide) {
+- this.play(world, blockposition);
++ this.play(world, blockposition, iblockdata); // CraftBukkit
+ entityhuman.a(StatisticList.PLAY_NOTEBLOCK);
+ }
+ }
diff --git a/nms-patches/BlockOre.patch b/nms-patches/BlockOre.patch
index 236ce96e..38a98939 100644
--- a/nms-patches/BlockOre.patch
+++ b/nms-patches/BlockOre.patch
@@ -1,14 +1,14 @@
--- a/net/minecraft/server/BlockOre.java
+++ b/net/minecraft/server/BlockOre.java
-@@ -37,6 +37,7 @@
+@@ -32,6 +32,7 @@
- public void dropNaturally(World world, BlockPosition blockposition, IBlockData iblockdata, float f, int i) {
- super.dropNaturally(world, blockposition, iblockdata, f, i);
+ public void dropNaturally(IBlockData iblockdata, World world, BlockPosition blockposition, float f, int i) {
+ super.dropNaturally(iblockdata, world, blockposition, f, i);
+ /* CraftBukkit start - Delegated to getExpDrop
- if (this.getDropType(iblockdata, world.random, i) != Item.getItemOf(this)) {
+ if (this.getDropType(iblockdata, world, blockposition, i) != this) {
int j = 0;
-@@ -54,9 +55,34 @@
+@@ -49,9 +50,34 @@
this.dropExperience(world, blockposition, j);
}
@@ -17,8 +17,8 @@
}
+ @Override
-+ public int getExpDrop(World world, IBlockData iblockdata, int i) {
-+ if (this.getDropType(iblockdata, world.random, i) != Item.getItemOf(this)) {
++ public int getExpDrop(IBlockData iblockdata, World world, BlockPosition blockposition, int enchantmentLevel) {
++ if (this.getDropType(iblockdata, world, blockposition, enchantmentLevel) != this) {
+ int j = 0;
+
+ if (this == Blocks.COAL_ORE) {
@@ -29,7 +29,7 @@
+ j = MathHelper.nextInt(world.random, 3, 7);
+ } else if (this == Blocks.LAPIS_ORE) {
+ j = MathHelper.nextInt(world.random, 2, 5);
-+ } else if (this == Blocks.QUARTZ_ORE) {
++ } else if (this == Blocks.NETHER_QUARTZ_ORE) {
+ j = MathHelper.nextInt(world.random, 2, 5);
+ }
+
@@ -40,6 +40,6 @@
+ // CraftBukkit end
+ }
+
- public ItemStack a(World world, BlockPosition blockposition, IBlockData iblockdata) {
+ public ItemStack a(IBlockAccess iblockaccess, BlockPosition blockposition, IBlockData iblockdata) {
return new ItemStack(this);
}
diff --git a/nms-patches/BlockPiston.patch b/nms-patches/BlockPiston.patch
index c7e24f36..ae8fcc83 100644
--- a/nms-patches/BlockPiston.patch
+++ b/nms-patches/BlockPiston.patch
@@ -1,8 +1,8 @@
--- a/net/minecraft/server/BlockPiston.java
+++ b/net/minecraft/server/BlockPiston.java
-@@ -5,6 +5,18 @@
+@@ -7,6 +7,18 @@
+ import java.util.Iterator;
import java.util.List;
- import javax.annotation.Nullable;
+// CraftBukkit start
+import java.util.AbstractList;
@@ -18,39 +18,30 @@
+
public class BlockPiston extends BlockDirectional {
- public static final BlockStateBoolean EXTENDED = BlockStateBoolean.of("extended");
-@@ -103,6 +115,18 @@
- world.playBlockAction(blockposition, this, 0, enumdirection.a());
- }
- } else if (!flag && ((Boolean) iblockdata.get(BlockPiston.EXTENDED)).booleanValue()) {
-+ // CraftBukkit start
-+ if (!this.sticky) {
-+ org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
-+ BlockPistonRetractEvent event = new BlockPistonRetractEvent(block, ImmutableList.<org.bukkit.block.Block>of(), CraftBlock.notchToBlockFace(enumdirection));
-+ world.getServer().getPluginManager().callEvent(event);
-+
-+ if (event.isCancelled()) {
-+ return;
-+ }
-+ }
-+ // PAIL: checkME - what happened to setTypeAndData?
-+ // CraftBukkit end
- world.playBlockAction(blockposition, this, 1, enumdirection.a());
- }
-
-@@ -193,7 +217,7 @@
+ public static final BlockStateBoolean EXTENDED = BlockProperties.f;
+@@ -109,6 +121,18 @@
+ b0 = 2;
}
}
++ // CraftBukkit start
++ if (!this.sticky) {
++ org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
++ BlockPistonRetractEvent event = new BlockPistonRetractEvent(block, ImmutableList.<org.bukkit.block.Block>of(), CraftBlock.notchToBlockFace(enumdirection));
++ world.getServer().getPluginManager().callEvent(event);
++
++ if (event.isCancelled()) {
++ return;
++ }
++ }
++ // PAIL: checkME - what happened to setTypeAndData?
++ // CraftBukkit end
+ }
-- if (!flag1 && iblockdata1.getMaterial() != Material.AIR && a(iblockdata1, world, blockposition1, enumdirection.opposite(), false, enumdirection) && (iblockdata1.o() == EnumPistonReaction.NORMAL || block == Blocks.PISTON || block == Blocks.STICKY_PISTON)) {
-+ if (!flag1 && a(iblockdata1, world, blockposition1, enumdirection.opposite(), false, enumdirection) && (iblockdata1.o() == EnumPistonReaction.NORMAL || block == Blocks.PISTON || block == Blocks.STICKY_PISTON)) { // CraftBukkit - remove 'block.getMaterial() != Material.AIR' condition
- this.a(world, blockposition, enumdirection, false);
- }
- } else {
-@@ -277,6 +301,48 @@
- int j = list.size() + list1.size();
+ world.playBlockAction(blockposition, this, b0, enumdirection.a());
+@@ -271,6 +295,48 @@
IBlockData[] aiblockdata = new IBlockData[j];
EnumDirection enumdirection1 = flag ? enumdirection : enumdirection.opposite();
+ HashSet hashset = Sets.newHashSet(list);
+ // CraftBukkit start
+ final org.bukkit.block.Block bblock = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
+
diff --git a/nms-patches/BlockPlant.patch b/nms-patches/BlockPlant.patch
index c9ac5dc7..d3ff331e 100644
--- a/nms-patches/BlockPlant.patch
+++ b/nms-patches/BlockPlant.patch
@@ -1,14 +1,18 @@
--- a/net/minecraft/server/BlockPlant.java
+++ b/net/minecraft/server/BlockPlant.java
-@@ -40,6 +40,11 @@
+@@ -13,7 +13,14 @@
+ }
- protected void e(World world, BlockPosition blockposition, IBlockData iblockdata) {
- if (!this.f(world, blockposition, iblockdata)) {
-+ // CraftBukkit start
-+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPhysicsEvent(world, blockposition).isCancelled()) {
-+ return;
+ public IBlockData updateState(IBlockData iblockdata, EnumDirection enumdirection, IBlockData iblockdata1, GeneratorAccess generatoraccess, BlockPosition blockposition, BlockPosition blockposition1) {
+- return !iblockdata.canPlace(generatoraccess, blockposition) ? Blocks.AIR.getBlockData() : super.updateState(iblockdata, enumdirection, iblockdata1, generatoraccess, blockposition, blockposition1);
++ // CraftBukkit start
++ if (!iblockdata.canPlace(generatoraccess, blockposition)) {
++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPhysicsEvent(generatoraccess, blockposition).isCancelled()) {
++ return Blocks.AIR.getBlockData();
+ }
-+ // CraftBukkit end
- this.b(world, blockposition, iblockdata, 0);
- world.setTypeAndData(blockposition, Blocks.AIR.getBlockData(), 3);
- }
++ }
++ return super.updateState(iblockdata, enumdirection, iblockdata1, generatoraccess, blockposition, blockposition1);
++ // CraftBukkit end
+ }
+
+ public boolean canPlace(IBlockData iblockdata, IWorldReader iworldreader, BlockPosition blockposition) {
diff --git a/nms-patches/BlockPortal.patch b/nms-patches/BlockPortal.patch
index f9ccf2aa..07c4cf20 100644
--- a/nms-patches/BlockPortal.patch
+++ b/nms-patches/BlockPortal.patch
@@ -1,50 +1,45 @@
--- a/net/minecraft/server/BlockPortal.java
+++ b/net/minecraft/server/BlockPortal.java
-@@ -4,6 +4,9 @@
+@@ -4,6 +4,12 @@
import java.util.Random;
import javax.annotation.Nullable;
-+import org.bukkit.event.entity.EntityPortalEnterEvent; // CraftBukkit
-+import org.bukkit.event.world.PortalCreateEvent; // CraftBukkit
++// CraftBukkit start
++import org.bukkit.craftbukkit.block.CraftBlock;
++import org.bukkit.event.entity.EntityPortalEnterEvent;
++import org.bukkit.event.world.PortalCreateEvent;
++// CraftBukkit end
+
- public class BlockPortal extends BlockHalfTransparent {
+ public class BlockPortal extends Block {
- public static final BlockStateEnum<EnumDirection.EnumAxis> AXIS = BlockStateEnum.of("axis", EnumDirection.EnumAxis.class, new EnumDirection.EnumAxis[] { EnumDirection.EnumAxis.X, EnumDirection.EnumAxis.Z});
-@@ -43,7 +46,8 @@
+ public static final BlockStateEnum<EnumDirection.EnumAxis> AXIS = BlockProperties.y;
+@@ -37,7 +43,8 @@
}
- if (i > 0 && !world.getType(blockposition1.up()).l()) {
-- Entity entity = ItemMonsterEgg.a(world, EntityTypes.getName(EntityPigZombie.class), (double) blockposition1.getX() + 0.5D, (double) blockposition1.getY() + 1.1D, (double) blockposition1.getZ() + 0.5D);
+ if (i > 0 && !world.getType(blockposition1.up()).isOccluding()) {
+- Entity entity = EntityTypes.ZOMBIE_PIGMAN.a(world, (NBTTagCompound) null, (IChatBaseComponent) null, (EntityHuman) null, blockposition1.up(), false, false);
+ // 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);
++ Entity entity = EntityTypes.ZOMBIE_PIGMAN.spawnCreature(world, (NBTTagCompound) null, (IChatBaseComponent) null, (EntityHuman) null, blockposition1.up(), false, false, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NETHER_PORTAL);
if (entity != null) {
- entity.portalCooldown = entity.aM();
-@@ -70,14 +74,16 @@
- BlockPortal.Shape blockportal_shape = new BlockPortal.Shape(world, blockposition, EnumDirection.EnumAxis.X);
+ entity.portalCooldown = entity.aQ();
+@@ -55,8 +62,10 @@
+ BlockPortal.Shape blockportal_shape = this.b(generatoraccess, blockposition);
- if (blockportal_shape.d() && blockportal_shape.e == 0) {
+ if (blockportal_shape != null) {
- blockportal_shape.createPortal();
- return true;
+ // CraftBukkit start - return portalcreator
+ return blockportal_shape.createPortal();
+ // return true;
++ // CraftBukkit end
} else {
- BlockPortal.Shape blockportal_shape1 = new BlockPortal.Shape(world, blockposition, EnumDirection.EnumAxis.Z);
-
- if (blockportal_shape1.d() && blockportal_shape1.e == 0) {
-- blockportal_shape1.createPortal();
-- return true;
-+ return blockportal_shape1.createPortal();
-+ // return true;
-+ // CraftBukkit end
- } else {
- return false;
- }
-@@ -108,6 +114,10 @@
+ return false;
+ }
+@@ -93,6 +102,10 @@
- public void a(World world, BlockPosition blockposition, IBlockData iblockdata, Entity entity) {
- if (!entity.isPassenger() && !entity.isVehicle() && entity.bf()) {
+ public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) {
+ if (!entity.isPassenger() && !entity.isVehicle() && entity.bm()) {
+ // 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);
@@ -52,33 +47,32 @@
entity.e(blockposition);
}
-@@ -216,6 +226,7 @@
+@@ -193,6 +206,7 @@
private BlockPosition position;
private int height;
private int width;
+ java.util.Collection<org.bukkit.block.Block> blocks = new java.util.HashSet<org.bukkit.block.Block>(); // CraftBukkit - add field
- public Shape(World world, BlockPosition blockposition, EnumDirection.EnumAxis enumdirection_enumaxis) {
- this.a = world;
-@@ -274,6 +285,10 @@
+ public Shape(GeneratorAccess generatoraccess, BlockPosition blockposition, EnumDirection.EnumAxis enumdirection_enumaxis) {
+ this.a = generatoraccess;
+@@ -251,6 +265,9 @@
}
protected int c() {
+ // CraftBukkit start
+ this.blocks.clear();
-+ org.bukkit.World bworld = this.a.getWorld();
+ // CraftBukkit end
int i;
label56:
-@@ -294,11 +309,21 @@
+@@ -273,11 +290,21 @@
block = this.a.getType(blockposition.shift(this.d)).getBlock();
if (block != Blocks.OBSIDIAN) {
break label56;
+ // CraftBukkit start - add the block to our list
+ } else {
+ BlockPosition pos = blockposition.shift(this.d);
-+ blocks.add(bworld.getBlockAt(pos.getX(), pos.getY(), pos.getZ()));
++ blocks.add(CraftBlock.at(this.a, pos));
+ // CraftBukkit end
}
} else if (i == this.width - 1) {
@@ -88,31 +82,31 @@
+ // CraftBukkit start - add the block to our list
+ } else {
+ BlockPosition pos = blockposition.shift(this.c);
-+ blocks.add(bworld.getBlockAt(pos.getX(), pos.getY(), pos.getZ()));
++ blocks.add(CraftBlock.at(this.a, pos));
+ // CraftBukkit end
}
}
}
-@@ -308,6 +333,11 @@
+@@ -287,6 +314,11 @@
if (this.a.getType(this.position.shift(this.c, i).up(this.height)).getBlock() != Blocks.OBSIDIAN) {
this.height = 0;
break;
+ // CraftBukkit start - add the block to our list
+ } else {
+ BlockPosition pos = this.position.shift(this.c, i).up(this.height);
-+ blocks.add(bworld.getBlockAt(pos.getX(), pos.getY(), pos.getZ()));
++ blocks.add(CraftBlock.at(this.a, pos));
+ // CraftBukkit end
}
}
-@@ -329,7 +359,27 @@
+@@ -310,7 +342,27 @@
return this.position != null && this.width >= 2 && this.width <= 21 && this.height >= 3 && this.height <= 21;
}
- public void createPortal() {
+ // CraftBukkit start - return boolean
+ public boolean createPortal() {
-+ org.bukkit.World bworld = this.a.getWorld();
++ org.bukkit.World bworld = this.a.getMinecraftWorld().getWorld();
+
+ // Copy below for loop
+ for (int i = 0; i < this.width; ++i) {
@@ -125,7 +119,7 @@
+ }
+
+ PortalCreateEvent event = new PortalCreateEvent(blocks, bworld, PortalCreateEvent.CreateReason.FIRE);
-+ this.a.getServer().getPluginManager().callEvent(event);
++ this.a.getMinecraftWorld().getMinecraftServer().server.getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ return false;
@@ -134,11 +128,11 @@
for (int i = 0; i < this.width; ++i) {
BlockPosition blockposition = this.position.shift(this.c, i);
-@@ -338,6 +388,7 @@
+@@ -319,6 +371,7 @@
}
}
+ return true; // CraftBukkit
}
- }
- }
+
+ private boolean g() {
diff --git a/nms-patches/BlockPoweredRail.patch b/nms-patches/BlockPoweredRail.patch
index 973f5576..5a9e7598 100644
--- a/nms-patches/BlockPoweredRail.patch
+++ b/nms-patches/BlockPoweredRail.patch
@@ -1,25 +1,24 @@
--- a/net/minecraft/server/BlockPoweredRail.java
+++ b/net/minecraft/server/BlockPoweredRail.java
-@@ -3,6 +3,8 @@
- import com.google.common.base.Predicate;
- import javax.annotation.Nullable;
+@@ -1,5 +1,7 @@
+ package net.minecraft.server;
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
+
public class BlockPoweredRail extends BlockMinecartTrackAbstract {
- public static final BlockStateEnum<BlockMinecartTrackAbstract.EnumTrackPosition> SHAPE = BlockStateEnum.a("shape", BlockMinecartTrackAbstract.EnumTrackPosition.class, new Predicate() {
-@@ -117,6 +119,13 @@
+ public static final BlockStateEnum<BlockPropertyTrackPosition> SHAPE = BlockProperties.R;
+@@ -106,6 +108,13 @@
boolean flag1 = world.isBlockIndirectlyPowered(blockposition) || this.a(world, blockposition, iblockdata, true, 0) || this.a(world, blockposition, iblockdata, false, 0);
if (flag1 != flag) {
+ // CraftBukkit start
-+ int power = (Boolean)iblockdata.get(POWERED) ? 15 : 0;
-+ int newPower = CraftEventFactory.callRedstoneChange(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), power, 15 - power).getNewCurrent();
++ int power = flag ? 15 : 0;
++ int newPower = CraftEventFactory.callRedstoneChange(world, blockposition, power, 15 - power).getNewCurrent();
+ if (newPower == power) {
+ return;
+ }
+ // CraftBukkit end
- world.setTypeAndData(blockposition, iblockdata.set(BlockPoweredRail.POWERED, Boolean.valueOf(flag1)), 3);
- world.applyPhysics(blockposition.down(), this, false);
- if (((BlockMinecartTrackAbstract.EnumTrackPosition) iblockdata.get(BlockPoweredRail.SHAPE)).c()) {
+ world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockPoweredRail.POWERED, Boolean.valueOf(flag1)), 3);
+ world.applyPhysics(blockposition.down(), this);
+ if (((BlockPropertyTrackPosition) iblockdata.get(BlockPoweredRail.SHAPE)).c()) {
diff --git a/nms-patches/BlockPressurePlateAbstract.patch b/nms-patches/BlockPressurePlateAbstract.patch
index 775f0989..08fea30f 100644
--- a/nms-patches/BlockPressurePlateAbstract.patch
+++ b/nms-patches/BlockPressurePlateAbstract.patch
@@ -1,15 +1,15 @@
--- a/net/minecraft/server/BlockPressurePlateAbstract.java
+++ b/net/minecraft/server/BlockPressurePlateAbstract.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 abstract class BlockPressurePlateAbstract extends Block {
- protected static final AxisAlignedBB a = new AxisAlignedBB(0.0625D, 0.0D, 0.0625D, 0.9375D, 0.03125D, 0.9375D);
-@@ -95,6 +97,19 @@
+ protected static final VoxelShape a = Block.a(1.0D, 0.0D, 1.0D, 15.0D, 0.5D, 15.0D);
+@@ -65,6 +67,19 @@
boolean flag = i > 0;
boolean flag1 = j > 0;
diff --git a/nms-patches/BlockPressurePlateBinary.patch b/nms-patches/BlockPressurePlateBinary.patch
index fea5dce1..6607944b 100644
--- a/nms-patches/BlockPressurePlateBinary.patch
+++ b/nms-patches/BlockPressurePlateBinary.patch
@@ -8,7 +8,7 @@
+
public class BlockPressurePlateBinary extends BlockPressurePlateAbstract {
- public static final BlockStateBoolean POWERED = BlockStateBoolean.of("powered");
+ public static final BlockStateBoolean POWERED = BlockProperties.t;
@@ -63,6 +65,26 @@
while (iterator.hasNext()) {
Entity entity = (Entity) iterator.next();
diff --git a/nms-patches/BlockPressurePlateWeighted.patch b/nms-patches/BlockPressurePlateWeighted.patch
index d24fd748..6550159b 100644
--- a/nms-patches/BlockPressurePlateWeighted.patch
+++ b/nms-patches/BlockPressurePlateWeighted.patch
@@ -7,11 +7,11 @@
+
public class BlockPressurePlateWeighted extends BlockPressurePlateAbstract {
- public static final BlockStateInteger POWER = BlockStateInteger.of("power", 0, 15);
-@@ -16,7 +18,31 @@
+ public static final BlockStateInteger POWER = BlockProperties.ak;
+@@ -12,7 +14,31 @@
}
- protected int e(World world, BlockPosition blockposition) {
+ protected int b(World world, BlockPosition blockposition) {
- int i = Math.min(world.a(Entity.class, BlockPressurePlateWeighted.c.a(blockposition)).size(), this.weight);
+ // CraftBukkit start
+ // int i = Math.min(world.a(Entity.class, BlockPressurePlateWeighted.c.a(blockposition)).size(), this.weight);
diff --git a/nms-patches/BlockPumpkin.patch b/nms-patches/BlockPumpkin.patch
deleted file mode 100644
index 04cdad4b..00000000
--- a/nms-patches/BlockPumpkin.patch
+++ /dev/null
@@ -1,81 +0,0 @@
---- a/net/minecraft/server/BlockPumpkin.java
-+++ b/net/minecraft/server/BlockPumpkin.java
-@@ -4,6 +4,12 @@
- import java.util.Iterator;
- import javax.annotation.Nullable;
-
-+// CraftBukkit start
-+import org.bukkit.craftbukkit.util.BlockStateListPopulator;
-+import org.bukkit.event.block.BlockRedstoneEvent;
-+import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
-+// CraftBukkit end
-+
- public class BlockPumpkin extends BlockFacingHorizontal {
-
- private ShapeDetector snowGolemPart;
-@@ -43,18 +49,25 @@
- EntityPlayer entityplayer;
- int j;
-
-+ BlockStateListPopulator blockList = new BlockStateListPopulator(world.getWorld()); // CraftBukkit - Use BlockStateListPopulator
- if (shapedetector_shapedetectorcollection != null) {
- for (i = 0; i < this.getDetectorSnowGolem().b(); ++i) {
- ShapeDetectorBlock shapedetectorblock = shapedetector_shapedetectorcollection.a(0, i, 0);
-
-- world.setTypeAndData(shapedetectorblock.getPosition(), Blocks.AIR.getBlockData(), 2);
-+ // CraftBukkit start
-+ // world.setTypeAndData(shapedetectorblock.d(), Blocks.AIR.getBlockData(), 2);
-+ BlockPosition pos = shapedetectorblock.getPosition();
-+ blockList.setTypeId(pos.getX(), pos.getY(), pos.getZ(), 0);
-+ // CraftBukkit end
- }
-
- EntitySnowman entitysnowman = new EntitySnowman(world);
- BlockPosition blockposition1 = shapedetector_shapedetectorcollection.a(0, 2, 0).getPosition();
-
- entitysnowman.setPositionRotation((double) blockposition1.getX() + 0.5D, (double) blockposition1.getY() + 0.05D, (double) blockposition1.getZ() + 0.5D, 0.0F, 0.0F);
-- world.addEntity(entitysnowman);
-+ // CraftBukkit start
-+ if (world.addEntity(entitysnowman, SpawnReason.BUILD_SNOWMAN)) {
-+ blockList.updateList();
- iterator = world.a(EntityPlayer.class, entitysnowman.getBoundingBox().g(5.0D)).iterator();
-
- while (iterator.hasNext()) {
-@@ -71,12 +84,17 @@
-
- world.update(shapedetectorblock1.getPosition(), Blocks.AIR, false);
- }
-+ } // CraftBukkit end
- } else {
- shapedetector_shapedetectorcollection = this.getDetectorIronGolem().a(world, blockposition);
- if (shapedetector_shapedetectorcollection != null) {
- for (i = 0; i < this.getDetectorIronGolem().c(); ++i) {
- for (int k = 0; k < this.getDetectorIronGolem().b(); ++k) {
-- world.setTypeAndData(shapedetector_shapedetectorcollection.a(i, k, 0).getPosition(), Blocks.AIR.getBlockData(), 2);
-+ // CraftBukkit start
-+ // world.setTypeAndData(shapedetector_shapedetectorcollection.a(i, k, 0).getPosition(), Blocks.AIR.getBlockData(), 2);
-+ BlockPosition pos = shapedetector_shapedetectorcollection.a(i, k, 0).getPosition();
-+ blockList.setTypeId(pos.getX(), pos.getY(), pos.getZ(), 0);
-+ // CraftBukkit end
- }
- }
-
-@@ -85,7 +103,9 @@
-
- entityirongolem.setPlayerCreated(true);
- entityirongolem.setPositionRotation((double) blockposition2.getX() + 0.5D, (double) blockposition2.getY() + 0.05D, (double) blockposition2.getZ() + 0.5D, 0.0F, 0.0F);
-- world.addEntity(entityirongolem);
-+ // CraftBukkit start
-+ if (world.addEntity(entityirongolem, SpawnReason.BUILD_IRONGOLEM)) {
-+ blockList.updateList();
- iterator = world.a(EntityPlayer.class, entityirongolem.getBoundingBox().g(5.0D)).iterator();
-
- while (iterator.hasNext()) {
-@@ -105,6 +125,7 @@
- }
- }
- }
-+ } // CraftBukkit end
- }
-
- }
diff --git a/nms-patches/BlockPumpkinCarved.patch b/nms-patches/BlockPumpkinCarved.patch
new file mode 100644
index 00000000..8e2dfb39
--- /dev/null
+++ b/nms-patches/BlockPumpkinCarved.patch
@@ -0,0 +1,65 @@
+--- a/net/minecraft/server/BlockPumpkinCarved.java
++++ b/net/minecraft/server/BlockPumpkinCarved.java
+@@ -3,6 +3,12 @@
+ import java.util.Iterator;
+ import java.util.function.Predicate;
+
++// CraftBukkit start
++import org.bukkit.craftbukkit.util.BlockStateListPopulator;
++import org.bukkit.event.block.BlockRedstoneEvent;
++import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
++// CraftBukkit end
++
+ public class BlockPumpkinCarved extends BlockFacingHorizontal {
+
+ public static final BlockStateDirection a = BlockFacingHorizontal.FACING;
+@@ -38,18 +44,24 @@
+ int j;
+ int k;
+
++ BlockStateListPopulator blockList = new BlockStateListPopulator(world); // CraftBukkit - Use BlockStateListPopulator
+ if (shapedetector_shapedetectorcollection != null) {
+ for (i = 0; i < this.d().b(); ++i) {
+ ShapeDetectorBlock shapedetectorblock1 = shapedetector_shapedetectorcollection.a(0, i, 0);
+
+- world.setTypeAndData(shapedetectorblock1.getPosition(), Blocks.AIR.getBlockData(), 2);
++ blockList.setTypeAndData(shapedetectorblock1.getPosition(), Blocks.AIR.getBlockData(), 2); // CraftBukkit
+ }
+
+ EntitySnowman entitysnowman = new EntitySnowman(world);
+ BlockPosition blockposition1 = shapedetector_shapedetectorcollection.a(0, 2, 0).getPosition();
+
+ entitysnowman.setPositionRotation((double) blockposition1.getX() + 0.5D, (double) blockposition1.getY() + 0.05D, (double) blockposition1.getZ() + 0.5D, 0.0F, 0.0F);
+- world.addEntity(entitysnowman);
++ // CraftBukkit start
++ if (!world.addEntity(entitysnowman, SpawnReason.BUILD_SNOWMAN)) {
++ return;
++ }
++ blockList.updateList();
++ // CraftBukkit end
+ iterator = world.a(EntityPlayer.class, entitysnowman.getBoundingBox().g(5.0D)).iterator();
+
+ while (iterator.hasNext()) {
+@@ -70,7 +82,7 @@
+ if (shapedetector_shapedetectorcollection != null) {
+ for (i = 0; i < this.f().c(); ++i) {
+ for (int l = 0; l < this.f().b(); ++l) {
+- world.setTypeAndData(shapedetector_shapedetectorcollection.a(i, l, 0).getPosition(), Blocks.AIR.getBlockData(), 2);
++ blockList.setTypeAndData(shapedetector_shapedetectorcollection.a(i, l, 0).getPosition(), Blocks.AIR.getBlockData(), 2); // CraftBukkit
+ }
+ }
+
+@@ -79,7 +91,12 @@
+
+ entityirongolem.setPlayerCreated(true);
+ entityirongolem.setPositionRotation((double) blockposition2.getX() + 0.5D, (double) blockposition2.getY() + 0.05D, (double) blockposition2.getZ() + 0.5D, 0.0F, 0.0F);
+- world.addEntity(entityirongolem);
++ // CraftBukkit start
++ if (!world.addEntity(entityirongolem, SpawnReason.BUILD_IRONGOLEM)) {
++ return;
++ }
++ blockList.updateList();
++ // CraftBukkit end
+ iterator = world.a(EntityPlayer.class, entityirongolem.getBoundingBox().g(5.0D)).iterator();
+
+ while (iterator.hasNext()) {
diff --git a/nms-patches/BlockRedstoneLamp.patch b/nms-patches/BlockRedstoneLamp.patch
index e349acdc..71ed926c 100644
--- a/nms-patches/BlockRedstoneLamp.patch
+++ b/nms-patches/BlockRedstoneLamp.patch
@@ -1,54 +1,35 @@
--- a/net/minecraft/server/BlockRedstoneLamp.java
+++ b/net/minecraft/server/BlockRedstoneLamp.java
-@@ -2,6 +2,8 @@
-
+@@ -3,6 +3,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;
-@@ -18,8 +20,18 @@
- public void onPlace(World world, BlockPosition blockposition, IBlockData iblockdata) {
- if (!world.isClientSide) {
- if (this.a && !world.isBlockIndirectlyPowered(blockposition)) {
-+ // CraftBukkit start
-+ if (CraftEventFactory.callRedstoneChange(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), 15, 0).getNewCurrent() != 0) {
-+ return;
-+ }
-+ // CraftBukkit end
- world.setTypeAndData(blockposition, Blocks.REDSTONE_LAMP.getBlockData(), 2);
- } else if (!this.a && world.isBlockIndirectlyPowered(blockposition)) {
-+ // CraftBukkit start
-+ if (CraftEventFactory.callRedstoneChange(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), 0, 15).getNewCurrent() != 15) {
-+ return;
-+ }
-+ // CraftBukkit end
- world.setTypeAndData(blockposition, Blocks.LIT_REDSTONE_LAMP.getBlockData(), 2);
- }
-
-@@ -31,6 +43,11 @@
- if (this.a && !world.isBlockIndirectlyPowered(blockposition)) {
- world.a(blockposition, (Block) this, 4);
- } else if (!this.a && world.isBlockIndirectlyPowered(blockposition)) {
-+ // CraftBukkit start
-+ if (CraftEventFactory.callRedstoneChange(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), 0, 15).getNewCurrent() != 15) {
-+ return;
-+ }
-+ // CraftBukkit end
- world.setTypeAndData(blockposition, Blocks.LIT_REDSTONE_LAMP.getBlockData(), 2);
+ public static final BlockStateBoolean a = BlockRedstoneTorch.LIT;
+@@ -33,6 +35,11 @@
+ if (flag) {
+ world.I().a(blockposition, this, 4);
+ } else {
++ // CraftBukkit start
++ if (CraftEventFactory.callRedstoneChange(world, blockposition, 0, 15).getNewCurrent() != 15) {
++ return;
++ }
++ // CraftBukkit end
+ world.setTypeAndData(blockposition, (IBlockData) iblockdata.a((IBlockState) BlockRedstoneLamp.a), 2);
+ }
}
-
-@@ -40,6 +57,11 @@
- public void b(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) {
+@@ -43,6 +50,11 @@
+ public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) {
if (!world.isClientSide) {
- if (this.a && !world.isBlockIndirectlyPowered(blockposition)) {
+ if (((Boolean) iblockdata.get(BlockRedstoneLamp.a)).booleanValue() && !world.isBlockIndirectlyPowered(blockposition)) {
+ // CraftBukkit start
-+ if (CraftEventFactory.callRedstoneChange(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), 15, 0).getNewCurrent() != 0) {
++ if (CraftEventFactory.callRedstoneChange(world, blockposition, 15, 0).getNewCurrent() != 0) {
+ return;
+ }
+ // CraftBukkit end
- world.setTypeAndData(blockposition, Blocks.REDSTONE_LAMP.getBlockData(), 2);
+ world.setTypeAndData(blockposition, (IBlockData) iblockdata.a((IBlockState) BlockRedstoneLamp.a), 2);
}
diff --git a/nms-patches/BlockRedstoneOre.patch b/nms-patches/BlockRedstoneOre.patch
index c4b08ac9..e9312c2c 100644
--- a/nms-patches/BlockRedstoneOre.patch
+++ b/nms-patches/BlockRedstoneOre.patch
@@ -11,76 +11,75 @@
+
public class BlockRedstoneOre extends Block {
- private final boolean a;
-@@ -20,23 +25,45 @@
+ public static final BlockStateBoolean a = BlockRedstoneTorch.LIT;
+@@ -16,23 +21,44 @@
}
- public void attack(World world, BlockPosition blockposition, EntityHuman entityhuman) {
-- this.interact(world, blockposition);
-+ this.interact(world, blockposition, entityhuman); // CraftBukkit - add entityhuman
- super.attack(world, blockposition, entityhuman);
+ public void attack(IBlockData iblockdata, World world, BlockPosition blockposition, EntityHuman entityhuman) {
+- interact(iblockdata, world, blockposition);
++ interact(iblockdata, world, blockposition, entityhuman); // CraftBukkit - add entityhuman
+ super.attack(iblockdata, world, blockposition, entityhuman);
}
public void stepOn(World world, BlockPosition blockposition, Entity entity) {
-- this.interact(world, blockposition);
+- interact(world.getType(blockposition), world, blockposition);
- super.stepOn(world, blockposition, entity);
+ // CraftBukkit start
-+ // this.interact(world, blockposition);
++ // interact(world.getType(blockposition), world, blockposition);
+ // super.stepOn(world, blockposition, entity);
+ if (entity instanceof EntityHuman) {
+ org.bukkit.event.player.PlayerInteractEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent((EntityHuman) entity, org.bukkit.event.block.Action.PHYSICAL, blockposition, null, null, null);
+ if (!event.isCancelled()) {
-+ this.interact(world, blockposition, entity); // add entity
++ interact(world.getType(blockposition), world, blockposition, entity); // add entity
+ super.stepOn(world, blockposition, entity);
+ }
+ } else {
+ EntityInteractEvent event = new EntityInteractEvent(entity.getBukkitEntity(), world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()));
+ world.getServer().getPluginManager().callEvent(event);
+ if (!event.isCancelled()) {
-+ this.interact(world, blockposition, entity); // add entity
++ interact(world.getType(blockposition), world, blockposition, entity); // add entity
+ super.stepOn(world, blockposition, entity);
+ }
+ }
+ // CraftBukkit end
}
-+
- 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, enumdirection, f, f1, f2);
+ public boolean interact(IBlockData iblockdata, World world, BlockPosition blockposition, EntityHuman entityhuman, EnumHand enumhand, EnumDirection enumdirection, float f, float f1, float f2) {
+- interact(iblockdata, world, blockposition);
++ interact(iblockdata, world, blockposition, entityhuman); // CraftBukkit - add entityhuman
+ return super.interact(iblockdata, world, blockposition, entityhuman, enumhand, enumdirection, f, f1, f2);
}
-- private void interact(World world, BlockPosition blockposition) {
-+ private void interact(World world, BlockPosition blockposition, Entity entity) { // CraftBukkit - add Entity
- this.playEffect(world, blockposition);
- if (this == Blocks.REDSTONE_ORE) {
+- private static void interact(IBlockData iblockdata, World world, BlockPosition blockposition) {
++ private static void interact(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { // CraftBukkit - add Entity
+ playEffect(world, blockposition);
+ if (!((Boolean) iblockdata.get(BlockRedstoneOre.a)).booleanValue()) {
+ // CraftBukkit start
-+ if (CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, Blocks.LIT_REDSTONE_ORE, 0).isCancelled()) {
++ if (CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, iblockdata.set(BlockRedstoneOre.a, Boolean.valueOf(true))).isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
- world.setTypeUpdate(blockposition, Blocks.LIT_REDSTONE_ORE.getBlockData());
+ world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockRedstoneOre.a, Boolean.valueOf(true)), 3);
}
-@@ -44,6 +71,11 @@
+@@ -40,6 +66,11 @@
- public void b(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) {
- if (this == Blocks.LIT_REDSTONE_ORE) {
+ public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) {
+ if (((Boolean) iblockdata.get(BlockRedstoneOre.a)).booleanValue()) {
+ // CraftBukkit start
-+ if (CraftEventFactory.callBlockFadeEvent(world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), Blocks.REDSTONE_ORE).isCancelled()) {
++ if (CraftEventFactory.callBlockFadeEvent(world, blockposition, iblockdata.set(BlockRedstoneOre.a, Boolean.valueOf(false))).isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
- world.setTypeUpdate(blockposition, Blocks.REDSTONE_ORE.getBlockData());
+ world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockRedstoneOre.a, Boolean.valueOf(false)), 3);
}
-@@ -63,12 +95,25 @@
+@@ -59,12 +90,25 @@
- public void dropNaturally(World world, BlockPosition blockposition, IBlockData iblockdata, float f, int i) {
- super.dropNaturally(world, blockposition, iblockdata, f, i);
+ public void dropNaturally(IBlockData iblockdata, World world, BlockPosition blockposition, float f, int i) {
+ super.dropNaturally(iblockdata, world, blockposition, f, i);
+ /* CraftBukkit start - Delegated to getExpDrop
- if (this.getDropType(iblockdata, world.random, i) != Item.getItemOf(this)) {
+ if (this.getDropType(iblockdata, world, blockposition, i) != this) {
int j = 1 + world.random.nextInt(5);
this.dropExperience(world, blockposition, j);
@@ -88,16 +87,16 @@
+ // */
+
+ }
-+
+
+ @Override
-+ public int getExpDrop(World world, IBlockData data, int i) {
-+ if (this.getDropType(data, world.random, i) != Item.getItemOf(this)) {
++ public int getExpDrop(IBlockData iblockdata, World world, BlockPosition blockposition, int enchantmentLevel) {
++ if (this.getDropType(iblockdata, world, blockposition, enchantmentLevel) != this) {
+ int j = 1 + world.random.nextInt(5);
-
++
+ return j;
+ }
+ return 0;
+ // CraftBukkit end
}
- private void playEffect(World world, BlockPosition blockposition) {
+ private static void playEffect(World world, BlockPosition blockposition) {
diff --git a/nms-patches/BlockRedstoneTorch.patch b/nms-patches/BlockRedstoneTorch.patch
index e35ce527..4506c4b4 100644
--- a/nms-patches/BlockRedstoneTorch.patch
+++ b/nms-patches/BlockRedstoneTorch.patch
@@ -8,29 +8,19 @@
+
public class BlockRedstoneTorch extends BlockTorch {
- private static final Map<World, List<BlockRedstoneTorch.RedstoneUpdateInfo>> g = Maps.newHashMap();
-@@ -13,7 +15,7 @@
-
- private boolean a(World world, BlockPosition blockposition, boolean flag) {
- if (!BlockRedstoneTorch.g.containsKey(world)) {
-- BlockRedstoneTorch.g.put(world, Lists.newArrayList());
-+ BlockRedstoneTorch.g.put(world, Lists.<BlockRedstoneTorch.RedstoneUpdateInfo>newArrayList()); // CraftBukkit - fix decompile error
- }
-
- List list = (List) BlockRedstoneTorch.g.get(world);
-@@ -96,8 +98,25 @@
+ public static final BlockStateBoolean LIT = BlockProperties.o;
+@@ -65,8 +67,24 @@
list.remove(0);
}
+ // CraftBukkit start
+ org.bukkit.plugin.PluginManager manager = world.getServer().getPluginManager();
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
-+ int oldCurrent = this.isOn ? 15 : 0;
++ int oldCurrent = ((Boolean) iblockdata.get(BlockRedstoneTorch.LIT)).booleanValue() ? 15 : 0;
+
+ BlockRedstoneEvent event = new BlockRedstoneEvent(block, oldCurrent, oldCurrent);
+ // CraftBukkit end
-+
- if (this.isOn) {
+ if (((Boolean) iblockdata.get(BlockRedstoneTorch.LIT)).booleanValue()) {
if (flag) {
+ // CraftBukkit start
+ if (oldCurrent != 0) {
@@ -41,13 +31,13 @@
+ }
+ }
+ // 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.gm, SoundCategory.BLOCKS, 0.5F, 2.6F + (world.random.nextFloat() - world.random.nextFloat()) * 0.8F);
-@@ -114,6 +133,15 @@
+ world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockRedstoneTorch.LIT, Boolean.valueOf(false)), 3);
+ if (a(world, blockposition, true)) {
+ world.a((EntityHuman) null, blockposition, SoundEffects.BLOCK_REDSTONE_TORCH_BURNOUT, SoundCategory.BLOCKS, 0.5F, 2.6F + (world.random.nextFloat() - world.random.nextFloat()) * 0.8F);
+@@ -83,6 +101,15 @@
}
}
- } else if (!flag && !this.a(world, blockposition, false)) {
+ } else if (!flag && !a(world, blockposition, false)) {
+ // CraftBukkit start
+ if (oldCurrent != 15) {
+ event.setNewCurrent(15);
@@ -57,6 +47,15 @@
+ }
+ }
+ // CraftBukkit end
- world.setTypeAndData(blockposition, Blocks.REDSTONE_TORCH.getBlockData().set(BlockRedstoneTorch.FACING, iblockdata.get(BlockRedstoneTorch.FACING)), 3);
+ world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockRedstoneTorch.LIT, Boolean.valueOf(true)), 3);
}
+@@ -112,7 +139,7 @@
+ }
+
+ private static boolean a(World world, BlockPosition blockposition, boolean flag) {
+- Object object = (List) BlockRedstoneTorch.b.get(world);
++ List<RedstoneUpdateInfo> object = (List) BlockRedstoneTorch.b.get(world); // CraftBukkit - decompile error
+
+ if (object == null) {
+ object = Lists.newArrayList();
diff --git a/nms-patches/BlockRedstoneWire.patch b/nms-patches/BlockRedstoneWire.patch
index 0f200a35..206d6222 100644
--- a/nms-patches/BlockRedstoneWire.patch
+++ b/nms-patches/BlockRedstoneWire.patch
@@ -1,6 +1,6 @@
--- a/net/minecraft/server/BlockRedstoneWire.java
+++ b/net/minecraft/server/BlockRedstoneWire.java
-@@ -9,6 +9,8 @@
+@@ -11,6 +11,8 @@
import java.util.Set;
import javax.annotation.Nullable;
@@ -8,8 +8,8 @@
+
public class BlockRedstoneWire extends Block {
- public static final BlockStateEnum<BlockRedstoneWire.EnumRedstoneWireConnection> NORTH = BlockStateEnum.of("north", BlockRedstoneWire.EnumRedstoneWireConnection.class);
-@@ -168,6 +170,15 @@
+ public static final BlockStateEnum<BlockPropertyRedstoneSide> NORTH = BlockProperties.L;
+@@ -216,6 +218,15 @@
j = k;
}
@@ -23,5 +23,5 @@
+ // CraftBukkit end
+
if (i != j) {
- iblockdata = iblockdata.set(BlockRedstoneWire.POWER, Integer.valueOf(j));
+ iblockdata = (IBlockData) iblockdata.set(BlockRedstoneWire.POWER, Integer.valueOf(j));
if (world.getType(blockposition) == iblockdata1) {
diff --git a/nms-patches/BlockReed.patch b/nms-patches/BlockReed.patch
index 8acc843a..4bdaf9e7 100644
--- a/nms-patches/BlockReed.patch
+++ b/nms-patches/BlockReed.patch
@@ -1,16 +1,11 @@
--- a/net/minecraft/server/BlockReed.java
+++ b/net/minecraft/server/BlockReed.java
-@@ -32,8 +32,12 @@
- int j = ((Integer) iblockdata.get(BlockReed.AGE)).intValue();
+@@ -29,7 +29,7 @@
+ int j = ((Integer) iblockdata.get(BlockReed.AGE)).intValue();
- if (j == 15) {
-- world.setTypeUpdate(blockposition.up(), this.getBlockData());
-+ // CraftBukkit start
-+ // world.setTypeUpdate(blockposition.up(), this.getBlockData()); // CraftBukkit
-+ BlockPosition upPos = blockposition.up();
-+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(world, upPos.getX(), upPos.getY(), upPos.getZ(), this, 0);
- world.setTypeAndData(blockposition, iblockdata.set(BlockReed.AGE, Integer.valueOf(0)), 4);
-+ // CraftBukkit end
- } else {
- world.setTypeAndData(blockposition, iblockdata.set(BlockReed.AGE, Integer.valueOf(j + 1)), 4);
- }
+ if (j == 15) {
+- world.setTypeUpdate(blockposition.up(), this.getBlockData());
++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(world, blockposition.up(), this.getBlockData()); // CraftBukkit
+ world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockReed.AGE, Integer.valueOf(0)), 4);
+ } else {
+ world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockReed.AGE, Integer.valueOf(j + 1)), 4);
diff --git a/nms-patches/BlockSapling.patch b/nms-patches/BlockSapling.patch
index c5f6c374..3dab6232 100644
--- a/nms-patches/BlockSapling.patch
+++ b/nms-patches/BlockSapling.patch
@@ -15,112 +15,41 @@
+
public class BlockSapling extends BlockPlant implements IBlockFragilePlantElement {
- public static final BlockStateEnum<BlockWood.EnumLogVariant> TYPE = BlockStateEnum.of("type", BlockWood.EnumLogVariant.class);
- public static final BlockStateInteger STAGE = BlockStateInteger.of("stage", 0, 1);
- protected static final AxisAlignedBB d = new AxisAlignedBB(0.09999999403953552D, 0.0D, 0.09999999403953552D, 0.8999999761581421D, 0.800000011920929D, 0.8999999761581421D);
+ public static final BlockStateInteger STAGE = BlockProperties.al;
+ protected static final VoxelShape b = Block.a(2.0D, 0.0D, 2.0D, 14.0D, 12.0D, 14.0D);
+ private final WorldGenTreeProvider c;
+ public static TreeType treeType; // CraftBukkit
- protected BlockSapling() {
- this.w(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);
- if (world.getLightLevel(blockposition.up()) >= 9 && random.nextInt(7) == 0) {
-+ // CraftBukkit start
-+ world.captureTreeGeneration = true;
-+ // CraftBukkit end
- this.grow(world, blockposition, iblockdata, random);
-+ // CraftBukkit start
-+ world.captureTreeGeneration = false;
-+ if (world.capturedBlockStates.size() > 0) {
-+ TreeType treeType = BlockSapling.treeType;
-+ BlockSapling.treeType = null;
-+ Location location = new Location(world.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ());
-+ List<BlockState> blocks = (List<BlockState>) world.capturedBlockStates.clone();
-+ world.capturedBlockStates.clear();
-+ StructureGrowEvent event = null;
-+ if (treeType != null) {
-+ event = new StructureGrowEvent(location, treeType, false, null, blocks);
-+ org.bukkit.Bukkit.getPluginManager().callEvent(event);
-+ }
-+ if (event == null || !event.isCancelled()) {
-+ for (BlockState blockstate : blocks) {
-+ blockstate.update(true);
-+ }
+ protected BlockSapling(WorldGenTreeProvider worldgentreeprovider, Block.Info block_info) {
+ super(block_info);
+@@ -21,7 +31,30 @@
+ public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) {
+ super.a(iblockdata, world, blockposition, random);
+ if (world.getLightLevel(blockposition.up()) >= 9 && random.nextInt(7) == 0) {
++ // CraftBukkit start
++ world.captureTreeGeneration = true;
++ // CraftBukkit end
+ this.grow(world, blockposition, iblockdata, random);
++ // CraftBukkit start
++ world.captureTreeGeneration = false;
++ if (world.capturedBlockStates.size() > 0) {
++ TreeType treeType = BlockSapling.treeType;
++ BlockSapling.treeType = null;
++ Location location = new Location(world.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ());
++ List<BlockState> blocks = (List<BlockState>) world.capturedBlockStates.clone();
++ world.capturedBlockStates.clear();
++ StructureGrowEvent event = null;
++ if (treeType != null) {
++ event = new StructureGrowEvent(location, treeType, false, null, blocks);
++ org.bukkit.Bukkit.getPluginManager().callEvent(event);
++ }
++ if (event == null || !event.isCancelled()) {
++ for (BlockState blockstate : blocks) {
++ blockstate.update(true);
+ }
+ }
-+ // CraftBukkit end
- }
-
++ }
++ // CraftBukkit end
}
-@@ -41,7 +74,17 @@
- }
-
- public void d(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) {
-- Object object = random.nextInt(10) == 0 ? new WorldGenBigTree(true) : new WorldGenTrees(true);
-+ // CraftBukkit start - Turn ternary operator into if statement to set treeType
-+ // Object object = random.nextInt(10) == 0 ? new WorldGenBigTree(true) : new WorldGenTrees(true);
-+ Object object;
-+ if (random.nextInt(10) == 0) {
-+ treeType = TreeType.BIG_TREE;
-+ object = new WorldGenBigTree(true);
-+ } else {
-+ treeType = TreeType.TREE;
-+ object = new WorldGenTrees(true);
-+ }
-+ // CraftBukkit end
- int i = 0;
- int j = 0;
- boolean flag = false;
-@@ -53,6 +96,7 @@
- for (i = 0; i >= -1; --i) {
- for (j = 0; j >= -1; --j) {
- if (this.a(world, blockposition, i, j, BlockWood.EnumLogVariant.SPRUCE)) {
-+ treeType = TreeType.MEGA_REDWOOD; // CraftBukkit
- object = new WorldGenMegaTree(false, random.nextBoolean());
- flag = true;
- break label66;
-@@ -63,11 +107,13 @@
- if (!flag) {
- i = 0;
- j = 0;
-+ treeType = TreeType.REDWOOD; // CraftBukkit
- object = new WorldGenTaiga2(true);
- }
- break;
- case BIRCH:
-+ treeType = TreeType.BIRCH; // CraftBukkit
- object = new WorldGenForest(true, false);
- break;
-
-@@ -79,6 +125,7 @@
- for (i = 0; i >= -1; --i) {
- for (j = 0; j >= -1; --j) {
- if (this.a(world, blockposition, i, j, BlockWood.EnumLogVariant.JUNGLE)) {
-+ treeType = TreeType.JUNGLE; // CraftBukkit
- object = new WorldGenJungleTree(true, 10, 20, iblockdata1, iblockdata2);
- flag = true;
- break label78;
-@@ -89,11 +136,13 @@
- if (!flag) {
- i = 0;
- j = 0;
-+ treeType = TreeType.SMALL_JUNGLE; // CraftBukkit
- object = new WorldGenTrees(true, 4 + random.nextInt(7), iblockdata1, iblockdata2, false);
- }
- break;
-
- case ACACIA:
-+ treeType = TreeType.ACACIA; // CraftBukkit
- object = new WorldGenAcaciaTree(true);
- break;
-
-@@ -102,6 +151,7 @@
- for (i = 0; i >= -1; --i) {
- for (j = 0; j >= -1; --j) {
- if (this.a(world, blockposition, i, j, BlockWood.EnumLogVariant.DARK_OAK)) {
-+ treeType = TreeType.DARK_OAK; // CraftBukkit
- object = new WorldGenForestTree(true);
- flag = true;
- break label90;
+ }
diff --git a/nms-patches/BlockShulkerBox.patch b/nms-patches/BlockShulkerBox.patch
index e0a5aaa3..e4c24bc9 100644
--- a/nms-patches/BlockShulkerBox.patch
+++ b/nms-patches/BlockShulkerBox.patch
@@ -1,32 +1,31 @@
--- a/net/minecraft/server/BlockShulkerBox.java
+++ b/net/minecraft/server/BlockShulkerBox.java
-@@ -92,7 +92,32 @@
-
+@@ -81,7 +81,31 @@
+ super.a(world, blockposition, iblockdata, entityhuman);
}
-- public void dropNaturally(World world, BlockPosition blockposition, IBlockData iblockdata, float f, int i) {}
+- public void dropNaturally(IBlockData iblockdata, World world, BlockPosition blockposition, 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);
++ @Override
++ public void dropNaturally(IBlockData iblockdata, World world, BlockPosition blockposition, float f, int i) {
++ if (true) {
++ TileEntity tileentity = world.getTileEntity(blockposition);
+
-+ if (tileentity instanceof TileEntityShulkerBox) {
-+ TileEntityShulkerBox tileentityshulkerbox = (TileEntityShulkerBox) tileentity;
++ 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();
++ if (!tileentityshulkerbox.s() && tileentityshulkerbox.G()) {
++ ItemStack itemstack = new ItemStack(this);
+
-+ nbttagcompound.set("BlockEntityTag", ((TileEntityShulkerBox) tileentity).f(nbttagcompound1));
-+ itemstack.setTag(nbttagcompound);
-+ if (tileentityshulkerbox.hasCustomName()) {
-+ itemstack.g(tileentityshulkerbox.getName());
-+ tileentityshulkerbox.setCustomName("");
-+ }
++ itemstack.getOrCreateTag().set("BlockEntityTag", ((TileEntityShulkerBox) tileentity).g(new NBTTagCompound()));
++ if (tileentityshulkerbox.hasCustomName()) {
++ itemstack.a(tileentityshulkerbox.getCustomName());
++ tileentityshulkerbox.setCustomName((IChatBaseComponent) null);
++ }
+
-+ a(world, blockposition, itemstack);
++ a(world, blockposition, itemstack);
++ }
+ }
-+
+ world.updateAdjacentComparators(blockposition, iblockdata.getBlock());
+ }
+ }
@@ -34,22 +33,22 @@
public void postPlace(World world, BlockPosition blockposition, IBlockData iblockdata, EntityLiving entityliving, ItemStack itemstack) {
if (itemstack.hasName()) {
-@@ -108,7 +133,7 @@
- public void remove(World world, BlockPosition blockposition, IBlockData iblockdata) {
- TileEntity tileentity = world.getTileEntity(blockposition);
+@@ -98,7 +122,7 @@
+ if (iblockdata.getBlock() != iblockdata1.getBlock()) {
+ TileEntity tileentity = world.getTileEntity(blockposition);
-- if (tileentity instanceof TileEntityShulkerBox) {
-+ if (false && tileentity instanceof TileEntityShulkerBox) { // CraftBukkit - moved up
- TileEntityShulkerBox tileentityshulkerbox = (TileEntityShulkerBox) tileentity;
+- if (tileentity instanceof TileEntityShulkerBox) {
++ if (false && tileentity instanceof TileEntityShulkerBox) { // CraftBukkit - moved up
+ TileEntityShulkerBox tileentityshulkerbox = (TileEntityShulkerBox) tileentity;
- if (!tileentityshulkerbox.r() && tileentityshulkerbox.F()) {
-@@ -126,8 +151,8 @@
- a(world, blockposition, itemstack);
+ if (!tileentityshulkerbox.s() && tileentityshulkerbox.G()) {
+@@ -113,8 +137,8 @@
+ a(world, blockposition, itemstack);
+ }
+
+- world.updateAdjacentComparators(blockposition, iblockdata.getBlock());
}
++ world.updateAdjacentComparators(blockposition, iblockdata.getBlock()); // CraftBukkit - moved down
-- world.updateAdjacentComparators(blockposition, iblockdata.getBlock());
+ super.remove(iblockdata, world, blockposition, iblockdata1, flag);
}
-+ world.updateAdjacentComparators(blockposition, iblockdata.getBlock()); // CraftBukkit - moved down
-
- super.remove(world, blockposition, iblockdata);
- }
diff --git a/nms-patches/BlockSkull.patch b/nms-patches/BlockSkull.patch
deleted file mode 100644
index b2c8601e..00000000
--- a/nms-patches/BlockSkull.patch
+++ /dev/null
@@ -1,123 +0,0 @@
---- a/net/minecraft/server/BlockSkull.java
-+++ b/net/minecraft/server/BlockSkull.java
-@@ -5,6 +5,11 @@
- import java.util.Random;
- import javax.annotation.Nullable;
-
-+// CraftBukkit start
-+import org.bukkit.craftbukkit.util.BlockStateListPopulator;
-+import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
-+// CraftBukkit end
-+
- public class BlockSkull extends BlockTileEntity {
-
- public static final BlockStateDirection FACING = BlockDirectional.FACING;
-@@ -82,7 +87,29 @@
- return new ItemStack(Items.SKULL, 1, i);
- }
-
-- public void dropNaturally(World world, BlockPosition blockposition, IBlockData iblockdata, float f, int i) {}
-+ // CraftBukkit start - Special case dropping so we can get info from the tile entity
-+ @Override
-+ public void dropNaturally(World world, BlockPosition blockposition, IBlockData iblockdata, float f, int i) {
-+ if (world.random.nextFloat() < f) {
-+ TileEntity tileentity = world.getTileEntity(blockposition);
-+
-+ if (tileentity instanceof TileEntitySkull) {
-+ TileEntitySkull tileentityskull = (TileEntitySkull) tileentity;
-+ ItemStack itemstack = this.a(world, blockposition, iblockdata);
-+
-+ 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);
-+ }
-+ }
-+ }
-+ // CraftBukkit end
-
- public void a(World world, BlockPosition blockposition, IBlockData iblockdata, EntityHuman entityhuman) {
- if (entityhuman.abilities.canInstantlyBuild) {
-@@ -95,7 +122,10 @@
-
- public void remove(World world, BlockPosition blockposition, IBlockData iblockdata) {
- if (!world.isClientSide) {
-- if (!((Boolean) iblockdata.get(BlockSkull.NODROP)).booleanValue()) {
-+ // CraftBukkit start - Drop item in code above, not here
-+ // if (!((Boolean) iblockdata.get(BlockSkull.NODROP)).booleanValue()) {
-+ if (false) {
-+ // CraftBukkit end
- TileEntity tileentity = world.getTileEntity(blockposition);
-
- if (tileentity instanceof TileEntitySkull) {
-@@ -127,24 +157,36 @@
- }
-
- public void a(World world, BlockPosition blockposition, TileEntitySkull tileentityskull) {
-+ if (world.captureBlockStates) return; // CraftBukkit
- if (tileentityskull.getSkullType() == 1 && blockposition.getY() >= 2 && world.getDifficulty() != EnumDifficulty.PEACEFUL && !world.isClientSide) {
- ShapeDetector shapedetector = this.g();
- ShapeDetector.ShapeDetectorCollection shapedetector_shapedetectorcollection = shapedetector.a(world, blockposition);
-
- if (shapedetector_shapedetectorcollection != null) {
-+ // CraftBukkit start - Use BlockStateListPopulator
-+ BlockStateListPopulator blockList = new BlockStateListPopulator(world.getWorld());
- int i;
-
- for (i = 0; i < 3; ++i) {
- ShapeDetectorBlock shapedetectorblock = shapedetector_shapedetectorcollection.a(i, 0, 0);
-
-- world.setTypeAndData(shapedetectorblock.getPosition(), shapedetectorblock.a().set(BlockSkull.NODROP, Boolean.valueOf(true)), 2);
-+ // CraftBukkit start
-+ // world.setTypeAndData(shapedetectorblock.getPosition(), shapedetectorblock.a().set(BlockSkull.NODROP, Boolean.valueOf(true)), 2);
-+ BlockPosition pos = shapedetectorblock.getPosition();
-+ IBlockData data = shapedetectorblock.a().set(BlockSkull.NODROP, Boolean.valueOf(true));
-+ blockList.setTypeAndData(pos.getX(), pos.getY(), pos.getZ(), data.getBlock(), data.getBlock().toLegacyData(data), 2);
-+ // CraftBukkit end
- }
-
- for (i = 0; i < shapedetector.c(); ++i) {
- for (int j = 0; j < shapedetector.b(); ++j) {
- ShapeDetectorBlock shapedetectorblock1 = shapedetector_shapedetectorcollection.a(i, j, 0);
-
-- world.setTypeAndData(shapedetectorblock1.getPosition(), Blocks.AIR.getBlockData(), 2);
-+ // CraftBukkit start
-+ // world.setTypeAndData(shapedetectorblock1.getPosition(), Blocks.AIR.getBlockData(), 2);
-+ BlockPosition pos = shapedetectorblock1.getPosition();
-+ blockList.setTypeAndData(pos.getX(), pos.getY(), pos.getZ(), Blocks.AIR, 0, 2);
-+ // CraftBukkit end
- }
- }
-
-@@ -157,14 +199,16 @@
- entitywither.p();
- Iterator iterator = world.a(EntityPlayer.class, entitywither.getBoundingBox().g(50.0D)).iterator();
-
-+ // CraftBukkit start
-+ if (world.addEntity(entitywither, SpawnReason.BUILD_WITHER)) {
-+ blockList.updateList();
-+
- while (iterator.hasNext()) {
- EntityPlayer entityplayer = (EntityPlayer) iterator.next();
-
- CriterionTriggers.m.a(entityplayer, (Entity) entitywither);
- }
-
-- world.addEntity(entitywither);
--
- int k;
-
- for (k = 0; k < 120; ++k) {
-@@ -178,6 +222,7 @@
- world.update(shapedetectorblock2.getPosition(), Blocks.AIR, false);
- }
- }
-+ } // CraftBukkit end
-
- }
- }
diff --git a/nms-patches/BlockSkullAbstract.patch b/nms-patches/BlockSkullAbstract.patch
new file mode 100644
index 00000000..84a88f4b
--- /dev/null
+++ b/nms-patches/BlockSkullAbstract.patch
@@ -0,0 +1,45 @@
+--- a/net/minecraft/server/BlockSkullAbstract.java
++++ b/net/minecraft/server/BlockSkullAbstract.java
+@@ -17,7 +17,32 @@
+ return new TileEntitySkull();
+ }
+
+- public void dropNaturally(IBlockData iblockdata, World world, BlockPosition blockposition, float f, int i) {}
++ // CraftBukkit start - Special case dropping so we can get info from the tile entity
++ @Override
++ public void dropNaturally(IBlockData iblockdata, World world, BlockPosition blockposition, float f, int i) {
++ if (world.random.nextFloat() < f) {
++ TileEntity tileentity = world.getTileEntity(blockposition);
++
++ if (tileentity instanceof TileEntitySkull) {
++ TileEntitySkull tileentityskull = (TileEntitySkull) tileentity;
++
++ if (tileentityskull.shouldDrop()) {
++ ItemStack itemstack = this.a((IBlockAccess) world, blockposition, iblockdata);
++ Block block = tileentityskull.getBlock().getBlock();
++
++ if ((block == Blocks.PLAYER_HEAD || block == Blocks.PLAYER_WALL_HEAD) && tileentityskull.getGameProfile() != null) {
++ NBTTagCompound nbttagcompound = new NBTTagCompound();
++
++ GameProfileSerializer.serialize(nbttagcompound, tileentityskull.getGameProfile());
++ itemstack.getOrCreateTag().set("SkullOwner", nbttagcompound);
++ }
++
++ a(world, blockposition, itemstack);
++ }
++ }
++ }
++ }
++ // CraftBukkit end
+
+ public void a(World world, BlockPosition blockposition, IBlockData iblockdata, EntityHuman entityhuman) {
+ if (!world.isClientSide && entityhuman.abilities.canInstantlyBuild) {
+@@ -35,7 +60,7 @@
+ if (iblockdata.getBlock() != iblockdata1.getBlock() && !world.isClientSide) {
+ TileEntity tileentity = world.getTileEntity(blockposition);
+
+- if (tileentity instanceof TileEntitySkull) {
++ if (false && tileentity instanceof TileEntitySkull) { // CraftBukkit - Drop item in code above, not here
+ TileEntitySkull tileentityskull = (TileEntitySkull) tileentity;
+
+ if (tileentityskull.shouldDrop()) {
diff --git a/nms-patches/BlockSnow.patch b/nms-patches/BlockSnow.patch
index b69c90e1..00bda675 100644
--- a/nms-patches/BlockSnow.patch
+++ b/nms-patches/BlockSnow.patch
@@ -1,14 +1,14 @@
--- a/net/minecraft/server/BlockSnow.java
+++ b/net/minecraft/server/BlockSnow.java
-@@ -91,6 +91,11 @@
+@@ -88,6 +88,11 @@
- public void b(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) {
+ public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) {
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()) {
++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(world, blockposition, Blocks.AIR.getBlockData()).isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
- this.b(world, blockposition, world.getType(blockposition), 0);
+ iblockdata.a(world, blockposition, 0);
world.setAir(blockposition);
}
diff --git a/nms-patches/BlockSnowBlock.patch b/nms-patches/BlockSnowBlock.patch
index 53291493..0bd8cb69 100644
--- a/nms-patches/BlockSnowBlock.patch
+++ b/nms-patches/BlockSnowBlock.patch
@@ -1,14 +1,14 @@
--- a/net/minecraft/server/BlockSnowBlock.java
+++ b/net/minecraft/server/BlockSnowBlock.java
-@@ -20,6 +20,11 @@
+@@ -18,6 +18,11 @@
- public void b(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) {
+ public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) {
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()) {
++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(world, blockposition, Blocks.AIR.getBlockData()).isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
- this.b(world, blockposition, world.getType(blockposition), 0);
+ iblockdata.a(world, blockposition, 0);
world.setAir(blockposition);
}
diff --git a/nms-patches/BlockSoil.patch b/nms-patches/BlockSoil.patch
index a7d37719..7c6475a0 100644
--- a/nms-patches/BlockSoil.patch
+++ b/nms-patches/BlockSoil.patch
@@ -1,7 +1,7 @@
--- a/net/minecraft/server/BlockSoil.java
+++ b/net/minecraft/server/BlockSoil.java
-@@ -4,6 +4,11 @@
- import java.util.List;
+@@ -3,6 +3,11 @@
+ import java.util.Iterator;
import java.util.Random;
+// CraftBukkit start
@@ -11,8 +11,8 @@
+
public class BlockSoil extends Block {
- public static final BlockStateInteger MOISTURE = BlockStateInteger.of("moisture", 0, 7);
-@@ -45,14 +50,38 @@
+ public static final BlockStateInteger MOISTURE = BlockProperties.ah;
+@@ -63,14 +68,37 @@
}
public void fallOn(World world, BlockPosition blockposition, Entity entity, float f) {
@@ -31,24 +31,23 @@
+ return;
+ }
+
-+ if (CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, Blocks.DIRT, 0).isCancelled()) {
++ if (CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, Blocks.DIRT.getBlockData()).isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
- b(world, blockposition);
+ b(world.getType(blockposition), world, blockposition);
}
- super.fallOn(world, blockposition, entity, f);
+ // super.fallOn(world, blockposition, entity, f); // CraftBukkit - moved up
}
- protected static void b(World world, BlockPosition blockposition) {
+ protected static void b(IBlockData iblockdata, World world, BlockPosition blockposition) {
+ // CraftBukkit start
-+ org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
-+ if (CraftEventFactory.callBlockFadeEvent(block, Blocks.DIRT).isCancelled()) {
++ if (CraftEventFactory.callBlockFadeEvent(world, blockposition, Blocks.DIRT.getBlockData()).isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
- world.setTypeUpdate(blockposition, Blocks.DIRT.getBlockData());
- AxisAlignedBB axisalignedbb = BlockSoil.c.a(blockposition);
- List list = world.getEntities((Entity) null, axisalignedbb);
+ world.setTypeUpdate(blockposition, a(iblockdata, Blocks.DIRT.getBlockData(), (GeneratorAccess) world, blockposition));
+ }
+
diff --git a/nms-patches/BlockStateInteger.patch b/nms-patches/BlockStateInteger.patch
new file mode 100644
index 00000000..878d458d
--- /dev/null
+++ b/nms-patches/BlockStateInteger.patch
@@ -0,0 +1,18 @@
+--- a/net/minecraft/server/BlockStateInteger.java
++++ b/net/minecraft/server/BlockStateInteger.java
+@@ -9,9 +9,15 @@
+ public class BlockStateInteger extends BlockState<Integer> {
+
+ private final ImmutableSet<Integer> a;
++ // CraftBukkit start
++ public final int min;
++ public final int max;
+
+ protected BlockStateInteger(String s, int i, int j) {
+ super(s, Integer.class);
++ this.min = i;
++ this.max = j;
++ // CraftBukkit end
+ if (i < 0) {
+ throw new IllegalArgumentException("Min value of " + s + " must be 0 or greater");
+ } else if (j <= i) {
diff --git a/nms-patches/BlockStationary.patch b/nms-patches/BlockStationary.patch
deleted file mode 100644
index 02a516fd..00000000
--- a/nms-patches/BlockStationary.patch
+++ /dev/null
@@ -1,40 +0,0 @@
---- a/net/minecraft/server/BlockStationary.java
-+++ b/net/minecraft/server/BlockStationary.java
-@@ -2,6 +2,8 @@
-
- import java.util.Random;
-
-+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
-+
- public class BlockStationary extends BlockFluids {
-
- protected BlockStationary(Material material) {
-@@ -45,6 +47,13 @@
-
- if (block.material == Material.AIR) {
- if (this.c(world, blockposition1)) {
-+ // CraftBukkit start - Prevent lava putting something on fire
-+ if (world.getType(blockposition1) != Blocks.FIRE) {
-+ if (CraftEventFactory.callBlockIgniteEvent(world, blockposition1.getX(), blockposition1.getY(), blockposition1.getZ(), blockposition.getX(), blockposition.getY(), blockposition.getZ()).isCancelled()) {
-+ continue;
-+ }
-+ }
-+ // CraftBukkit end
- world.setTypeUpdate(blockposition1, Blocks.FIRE.getBlockData());
- return;
- }
-@@ -61,6 +70,14 @@
- }
-
- if (world.isEmpty(blockposition2.up()) && this.d(world, blockposition2)) {
-+ // CraftBukkit start - Prevent lava putting something on fire
-+ BlockPosition up = blockposition2.up();
-+ if (world.getType(up) != Blocks.FIRE) {
-+ if (CraftEventFactory.callBlockIgniteEvent(world, up.getX(), up.getY(), up.getZ(), blockposition.getX(), blockposition.getY(), blockposition.getZ()).isCancelled()) {
-+ continue;
-+ }
-+ }
-+ // CraftBukkit end
- world.setTypeUpdate(blockposition2.up(), Blocks.FIRE.getBlockData());
- }
- }
diff --git a/nms-patches/BlockStem.patch b/nms-patches/BlockStem.patch
index df952dca..1159ca0a 100644
--- a/nms-patches/BlockStem.patch
+++ b/nms-patches/BlockStem.patch
@@ -1,6 +1,6 @@
--- a/net/minecraft/server/BlockStem.java
+++ b/net/minecraft/server/BlockStem.java
-@@ -4,6 +4,8 @@
+@@ -3,6 +3,8 @@
import java.util.Random;
import javax.annotation.Nullable;
@@ -8,34 +8,30 @@
+
public class BlockStem extends BlockPlant implements IBlockFragilePlantElement {
- public static final BlockStateInteger AGE = BlockStateInteger.of("age", 0, 7);
-@@ -54,7 +56,8 @@
+ public static final BlockStateInteger AGE = BlockProperties.V;
+@@ -33,14 +35,14 @@
if (i < 7) {
- iblockdata = iblockdata.set(BlockStem.AGE, Integer.valueOf(i + 1));
+ iblockdata = (IBlockData) iblockdata.set(BlockStem.AGE, Integer.valueOf(i + 1));
- world.setTypeAndData(blockposition, iblockdata, 2);
-+ // world.setTypeAndData(blockposition, iblockdata, 2); // CraftBukkit
-+ CraftEventFactory.handleBlockGrowEvent(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this, toLegacyData(iblockdata)); // CraftBukkit
++ CraftEventFactory.handleBlockGrowEvent(world, blockposition, iblockdata, 2); // CraftBukkit
} else {
- Iterator iterator = EnumDirection.EnumDirectionLimit.HORIZONTAL.iterator();
+ EnumDirection enumdirection = EnumDirection.EnumDirectionLimit.HORIZONTAL.a(random);
+ BlockPosition blockposition1 = blockposition.shift(enumdirection);
+ Block block = world.getType(blockposition1.down()).getBlock();
-@@ -70,7 +73,8 @@
- Block block = world.getType(blockposition.down()).getBlock();
-
- if (world.getType(blockposition).getBlock().material == Material.AIR && (block == Blocks.FARMLAND || block == Blocks.DIRT || block == Blocks.GRASS)) {
-- world.setTypeUpdate(blockposition, this.blockFruit.getBlockData());
-+ // world.setTypeUpdate(blockposition, this.blockFruit.getBlockData()); // CraftBukkit
-+ CraftEventFactory.handleBlockGrowEvent(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this.blockFruit, 0); // CraftBukkit
+ if (world.getType(blockposition1).isAir() && (block == Blocks.FARMLAND || block == Blocks.DIRT || block == Blocks.COARSE_DIRT || block == Blocks.PODZOL || block == Blocks.GRASS_BLOCK)) {
+- world.setTypeUpdate(blockposition1, this.blockFruit.getBlockData());
++ CraftEventFactory.handleBlockGrowEvent(world, blockposition1, this.blockFruit.getBlockData()); // CraftBukkit
+ world.setTypeUpdate(blockposition, (IBlockData) this.blockFruit.d().getBlockData().set(BlockFacingHorizontal.FACING, enumdirection));
}
}
- }
-@@ -81,7 +85,8 @@
- public void g(World world, BlockPosition blockposition, IBlockData iblockdata) {
- int i = ((Integer) iblockdata.get(BlockStem.AGE)).intValue() + MathHelper.nextInt(world.random, 2, 5);
-
-- world.setTypeAndData(blockposition, iblockdata.set(BlockStem.AGE, Integer.valueOf(Math.min(7, i))), 2);
-+ // world.setTypeAndData(blockposition, iblockdata.set(BlockStem.AGE, Integer.valueOf(Math.min(7, i))), 2);
-+ CraftEventFactory.handleBlockGrowEvent(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this, Math.min(7, i)); // CraftBukkit
- }
+@@ -94,7 +96,7 @@
+ int i = Math.min(7, ((Integer) iblockdata.get(BlockStem.AGE)).intValue() + MathHelper.nextInt(world.random, 2, 5));
+ IBlockData iblockdata1 = (IBlockData) iblockdata.set(BlockStem.AGE, Integer.valueOf(i));
- public void dropNaturally(World world, BlockPosition blockposition, IBlockData iblockdata, float f, int i) {
+- world.setTypeAndData(blockposition, iblockdata1, 2);
++ CraftEventFactory.handleBlockGrowEvent(world, blockposition, iblockdata1, 2); // CraftBukkit
+ if (i == 7) {
+ iblockdata1.a(world, blockposition, world.random);
+ }
diff --git a/nms-patches/BlockTNT.patch b/nms-patches/BlockTNT.patch
index ef5838b9..1af71a5f 100644
--- a/nms-patches/BlockTNT.patch
+++ b/nms-patches/BlockTNT.patch
@@ -1,14 +1,14 @@
--- a/net/minecraft/server/BlockTNT.java
+++ b/net/minecraft/server/BlockTNT.java
-@@ -75,6 +75,11 @@
+@@ -72,6 +72,11 @@
EntityArrow entityarrow = (EntityArrow) entity;
if (entityarrow.isBurning()) {
+ // CraftBukkit start
-+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entityarrow, blockposition, Blocks.AIR, 0).isCancelled()) {
++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entityarrow, blockposition, Blocks.AIR.getBlockData()).isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
- this.a(world, blockposition, world.getType(blockposition).set(BlockTNT.EXPLODE, Boolean.valueOf(true)), entityarrow.shooter instanceof EntityLiving ? (EntityLiving) entityarrow.shooter : null);
+ this.a(world, blockposition, entityarrow.shooter instanceof EntityLiving ? (EntityLiving) entityarrow.shooter : null);
world.setAir(blockposition);
}
diff --git a/nms-patches/BlockTallPlant.patch b/nms-patches/BlockTallPlant.patch
index a1127a3a..70676d56 100644
--- a/nms-patches/BlockTallPlant.patch
+++ b/nms-patches/BlockTallPlant.patch
@@ -1,14 +1,14 @@
--- a/net/minecraft/server/BlockTallPlant.java
+++ b/net/minecraft/server/BlockTallPlant.java
@@ -48,6 +48,11 @@
+ }
- protected void e(World world, BlockPosition blockposition, IBlockData iblockdata) {
- if (!this.f(world, blockposition, iblockdata)) {
-+ // CraftBukkit start
-+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPhysicsEvent(world, blockposition).isCancelled()) {
-+ return;
-+ }
-+ // CraftBukkit end
- boolean flag = iblockdata.get(BlockTallPlant.HALF) == BlockTallPlant.EnumTallPlantHalf.UPPER;
- BlockPosition blockposition1 = flag ? blockposition : blockposition.up();
- BlockPosition blockposition2 = flag ? blockposition.down() : blockposition;
+ public void a(World world, BlockPosition blockposition, IBlockData iblockdata, EntityHuman entityhuman) {
++ // CraftBukkit start
++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPhysicsEvent(world, blockposition).isCancelled()) {
++ return;
++ }
++ // CraftBukkit end
+ BlockPropertyDoubleBlockHalf blockpropertydoubleblockhalf = (BlockPropertyDoubleBlockHalf) iblockdata.get(BlockTallPlant.HALF);
+ boolean flag = blockpropertydoubleblockhalf == BlockPropertyDoubleBlockHalf.LOWER;
+ BlockPosition blockposition1 = flag ? blockposition.up() : blockposition.down();
diff --git a/nms-patches/BlockTrapdoor.patch b/nms-patches/BlockTrapdoor.patch
index 31007095..c809229b 100644
--- a/nms-patches/BlockTrapdoor.patch
+++ b/nms-patches/BlockTrapdoor.patch
@@ -6,12 +6,12 @@
import javax.annotation.Nullable;
+import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
- public class BlockTrapdoor extends Block {
+ public class BlockTrapdoor extends BlockFacingHorizontal implements IFluidSource, IFluidContainer {
-@@ -91,6 +92,19 @@
+@@ -94,6 +95,19 @@
boolean flag = world.isBlockIndirectlyPowered(blockposition);
- if (flag || block.getBlockData().m()) {
+ if (flag != ((Boolean) iblockdata.get(BlockTrapdoor.c)).booleanValue()) {
+ // CraftBukkit start
+ org.bukkit.World bworld = world.getWorld();
+ org.bukkit.block.Block bblock = bworld.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
@@ -19,12 +19,12 @@
+ int power = bblock.getBlockPower();
+ int oldPower = (Boolean) iblockdata.get(OPEN) ? 15 : 0;
+
-+ if (oldPower == 0 ^ power == 0 || block.getBlockData().n()) {
++ if (oldPower == 0 ^ power == 0 || block.getBlockData().isPowerSource()) {
+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bblock, oldPower, power);
+ world.getServer().getPluginManager().callEvent(eventRedstone);
+ flag = eventRedstone.getNewCurrent() > 0;
+ }
+ // CraftBukkit end
- boolean flag1 = ((Boolean) iblockdata.get(BlockTrapdoor.OPEN)).booleanValue();
-
- if (flag1 != flag) {
+ if (((Boolean) iblockdata.get(BlockTrapdoor.OPEN)).booleanValue() != flag) {
+ iblockdata = (IBlockData) iblockdata.set(BlockTrapdoor.OPEN, Boolean.valueOf(flag));
+ this.a((EntityHuman) null, world, blockposition, flag);
diff --git a/nms-patches/BlockTripwire.patch b/nms-patches/BlockTripwire.patch
index 3f955f11..598b9c1b 100644
--- a/nms-patches/BlockTripwire.patch
+++ b/nms-patches/BlockTripwire.patch
@@ -1,15 +1,15 @@
--- a/net/minecraft/server/BlockTripwire.java
+++ b/net/minecraft/server/BlockTripwire.java
@@ -5,6 +5,8 @@
+ import java.util.Map;
import java.util.Random;
- import javax.annotation.Nullable;
+import org.bukkit.event.entity.EntityInteractEvent; // CraftBukkit
+
public class BlockTripwire extends Block {
- public static final BlockStateBoolean POWERED = BlockStateBoolean.of("powered");
-@@ -138,6 +140,40 @@
+ public static final BlockStateBoolean POWERED = BlockProperties.t;
+@@ -134,6 +136,40 @@
}
}
@@ -48,5 +48,5 @@
+ // CraftBukkit end
+
if (flag1 != flag) {
- iblockdata = iblockdata.set(BlockTripwire.POWERED, Boolean.valueOf(flag1));
+ iblockdata = (IBlockData) iblockdata.set(BlockTripwire.POWERED, Boolean.valueOf(flag1));
world.setTypeAndData(blockposition, iblockdata, 3);
diff --git a/nms-patches/BlockTripwireHook.patch b/nms-patches/BlockTripwireHook.patch
index d3cf0947..dcc5409e 100644
--- a/nms-patches/BlockTripwireHook.patch
+++ b/nms-patches/BlockTripwireHook.patch
@@ -1,6 +1,6 @@
--- a/net/minecraft/server/BlockTripwireHook.java
+++ b/net/minecraft/server/BlockTripwireHook.java
-@@ -5,6 +5,8 @@
+@@ -4,6 +4,8 @@
import java.util.Random;
import javax.annotation.Nullable;
@@ -9,7 +9,7 @@
public class BlockTripwireHook extends Block {
public static final BlockStateDirection FACING = BlockFacingHorizontal.FACING;
-@@ -160,6 +162,17 @@
+@@ -137,6 +139,17 @@
this.a(world, blockposition1, flag4, flag5, flag2, flag3);
}
@@ -26,4 +26,4 @@
+
this.a(world, blockposition, flag4, flag5, flag2, flag3);
if (!flag) {
- world.setTypeAndData(blockposition, iblockdata3.set(BlockTripwireHook.FACING, enumdirection), 3);
+ world.setTypeAndData(blockposition, (IBlockData) iblockdata3.set(BlockTripwireHook.FACING, enumdirection), 3);
diff --git a/nms-patches/BlockVine.patch b/nms-patches/BlockVine.patch
index aa2e152b..d7093f6f 100644
--- a/nms-patches/BlockVine.patch
+++ b/nms-patches/BlockVine.patch
@@ -1,71 +1,59 @@
--- a/net/minecraft/server/BlockVine.java
+++ b/net/minecraft/server/BlockVine.java
-@@ -4,6 +4,8 @@
- import java.util.Random;
+@@ -7,6 +7,8 @@
+ import java.util.function.Predicate;
import javax.annotation.Nullable;
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
+
public class BlockVine extends Block {
- public static final BlockStateBoolean UP = BlockStateBoolean.of("up");
-@@ -177,7 +179,13 @@
- }
-
- if (((Boolean) iblockdata1.get(BlockVine.NORTH)).booleanValue() || ((Boolean) iblockdata1.get(BlockVine.EAST)).booleanValue() || ((Boolean) iblockdata1.get(BlockVine.SOUTH)).booleanValue() || ((Boolean) iblockdata1.get(BlockVine.WEST)).booleanValue()) {
-- world.setTypeAndData(blockposition1, iblockdata1, 2);
-+ // CraftBukkit start - Call BlockSpreadEvent
-+ // world.setTypeAndData(blockposition1, iblockdata1, 2);
-+ BlockPosition target = blockposition1;
-+ org.bukkit.block.Block source = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
-+ org.bukkit.block.Block block = world.getWorld().getBlockAt(target.getX(), target.getY(), target.getZ());
-+ CraftEventFactory.handleBlockSpreadEvent(block, source, this, toLegacyData(iblockdata1));
-+ // CraftBukkit end
- }
-
- } else {
-@@ -198,15 +206,26 @@
- BlockPosition blockposition3 = blockposition2.shift(enumdirection2);
- BlockPosition blockposition4 = blockposition2.shift(enumdirection3);
+ public static final BlockStateBoolean UP = BlockSprawling.q;
+@@ -183,20 +185,24 @@
+ BlockPosition blockposition3 = blockposition2.shift(enumdirection1);
+ BlockPosition blockposition4 = blockposition2.shift(enumdirection2);
-+ // CraftBukkit start - Call BlockSpreadEvent
-+ 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());
++ // CraftBukkit start - Call BlockSpreadEvent
++ BlockPosition source = blockposition;
+
- if (flag2 && this.a(world, blockposition3.shift(enumdirection2), enumdirection2)) {
-- 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.a(world, blockposition4.shift(enumdirection3), enumdirection3)) {
-- 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.a(world, blockposition3, enumdirection)) {
-- 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.a(world, blockposition4, enumdirection)) {
-- 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))));
+ if (flag && this.b(world, blockposition3, enumdirection1)) {
+- world.setTypeAndData(blockposition2, (IBlockData) this.getBlockData().set(getDirection(enumdirection1), Boolean.valueOf(true)), 2);
++ CraftEventFactory.handleBlockSpreadEvent(world, source, blockposition2, (IBlockData) this.getBlockData().set(getDirection(enumdirection1), Boolean.valueOf(true)), 2);
+ } else if (flag1 && this.b(world, blockposition4, enumdirection2)) {
+- world.setTypeAndData(blockposition2, (IBlockData) this.getBlockData().set(getDirection(enumdirection2), Boolean.valueOf(true)), 2);
++ CraftEventFactory.handleBlockSpreadEvent(world, source, blockposition2, (IBlockData) this.getBlockData().set(getDirection(enumdirection2), Boolean.valueOf(true)), 2);
+ } else {
+ EnumDirection enumdirection3 = enumdirection.opposite();
+
+ if (flag && world.isEmpty(blockposition3) && this.b(world, blockposition.shift(enumdirection1), enumdirection3)) {
+- world.setTypeAndData(blockposition3, (IBlockData) this.getBlockData().set(getDirection(enumdirection3), Boolean.valueOf(true)), 2);
++ CraftEventFactory.handleBlockSpreadEvent(world, source, blockposition3, (IBlockData) this.getBlockData().set(getDirection(enumdirection3), Boolean.valueOf(true)), 2);
+ } else if (flag1 && world.isEmpty(blockposition4) && this.b(world, blockposition.shift(enumdirection2), enumdirection3)) {
+- world.setTypeAndData(blockposition4, (IBlockData) this.getBlockData().set(getDirection(enumdirection3), Boolean.valueOf(true)), 2);
++ CraftEventFactory.handleBlockSpreadEvent(world, source, blockposition4, (IBlockData) this.getBlockData().set(getDirection(enumdirection3), Boolean.valueOf(true)), 2);
+ } else if ((double) world.random.nextFloat() < 0.05D && this.b(world, blockposition2.up(), EnumDirection.UP)) {
+- world.setTypeAndData(blockposition2, (IBlockData) this.getBlockData().set(BlockVine.UP, Boolean.valueOf(true)), 2);
++ CraftEventFactory.handleBlockSpreadEvent(world, source, blockposition2, (IBlockData) this.getBlockData().set(BlockVine.UP, Boolean.valueOf(true)), 2);
}
+ // CraftBukkit end
- } else if (iblockdata2.d(world, blockposition2, enumdirection) == EnumBlockFaceShape.SOLID) {
- world.setTypeAndData(blockposition, iblockdata.set(getDirection(enumdirection), Boolean.valueOf(true)), 2);
}
-@@ -233,7 +252,12 @@
- }
+ } else if (this.b(world, blockposition2, enumdirection)) {
+ world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(getDirection(enumdirection), Boolean.valueOf(true)), 2);
+@@ -226,7 +232,7 @@
+ }
- if (((Boolean) iblockdata3.get(BlockVine.NORTH)).booleanValue() || ((Boolean) iblockdata3.get(BlockVine.EAST)).booleanValue() || ((Boolean) iblockdata3.get(BlockVine.SOUTH)).booleanValue() || ((Boolean) iblockdata3.get(BlockVine.WEST)).booleanValue()) {
-- world.setTypeAndData(blockposition2, iblockdata3, 2);
-+ // CraftBukkit start - Call BlockSpreadEvent
-+ // world.setTypeAndData(blockposition2, iblockdata3, 2);
-+ 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());
-+ CraftEventFactory.handleBlockSpreadEvent(bukkitBlock, source, this, toLegacyData(iblockdata3));
-+ // CraftBukkit end
- }
- } else if (block == this) {
- iblockdata3 = iblockdata2;
+ if (this.x(iblockdata3)) {
+- world.setTypeAndData(blockposition1, iblockdata3, 2);
++ CraftEventFactory.handleBlockSpreadEvent(world, blockposition, blockposition1, iblockdata3, 2); // CraftBukkit
+ }
+
+ return;
+@@ -241,7 +247,7 @@
+ IBlockData iblockdata5 = this.a(iblockdata, iblockdata4, random);
+
+ if (iblockdata4 != iblockdata5 && this.x(iblockdata5)) {
+- world.setTypeAndData(blockposition2, iblockdata5, 2);
++ CraftEventFactory.handleBlockSpreadEvent(world, blockposition, blockposition2, iblockdata5, 2); // CraftBukkit
+ }
+ }
+ }
diff --git a/nms-patches/BlockWaterLily.patch b/nms-patches/BlockWaterLily.patch
index 83a6ae1d..e055a696 100644
--- a/nms-patches/BlockWaterLily.patch
+++ b/nms-patches/BlockWaterLily.patch
@@ -1,11 +1,11 @@
--- a/net/minecraft/server/BlockWaterLily.java
+++ b/net/minecraft/server/BlockWaterLily.java
-@@ -20,7 +20,7 @@
+@@ -10,7 +10,7 @@
- public void a(World world, BlockPosition blockposition, IBlockData iblockdata, Entity entity) {
- super.a(world, blockposition, iblockdata, entity);
+ public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) {
+ super.a(iblockdata, world, blockposition, entity);
- if (entity instanceof EntityBoat) {
-+ if (entity instanceof EntityBoat && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, Blocks.AIR, 0).isCancelled()) { // CraftBukkit
++ if (entity instanceof EntityBoat && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, Blocks.AIR.getBlockData()).isCancelled()) { // CraftBukkit
world.setAir(new BlockPosition(blockposition), true);
}
diff --git a/nms-patches/BlockWitherSkull.patch b/nms-patches/BlockWitherSkull.patch
new file mode 100644
index 00000000..bc921119
--- /dev/null
+++ b/nms-patches/BlockWitherSkull.patch
@@ -0,0 +1,66 @@
+--- a/net/minecraft/server/BlockWitherSkull.java
++++ b/net/minecraft/server/BlockWitherSkull.java
+@@ -3,6 +3,11 @@
+ import java.util.Iterator;
+ import javax.annotation.Nullable;
+
++// CraftBukkit start
++import org.bukkit.craftbukkit.util.BlockStateListPopulator;
++import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
++// CraftBukkit end
++
+ public class BlockWitherSkull extends BlockSkull {
+
+ private static ShapeDetector c;
+@@ -23,6 +28,7 @@
+ }
+
+ public static void a(World world, BlockPosition blockposition, TileEntitySkull tileentityskull) {
++ if (world.captureBlockStates) return; // CraftBukkit
+ Block block = tileentityskull.getBlock().getBlock();
+ boolean flag = block == Blocks.WITHER_SKELETON_SKULL || block == Blocks.WITHER_SKELETON_WALL_SKULL;
+
+@@ -31,6 +37,8 @@
+ ShapeDetector.ShapeDetectorCollection shapedetector_shapedetectorcollection = shapedetector.a(world, blockposition);
+
+ if (shapedetector_shapedetectorcollection != null) {
++ // CraftBukkit start - Use BlockStateListPopulator
++ BlockStateListPopulator blockList = new BlockStateListPopulator(world);
+ int i;
+
+ for (i = 0; i < 3; ++i) {
+@@ -39,7 +47,7 @@
+
+ for (i = 0; i < shapedetector.c(); ++i) {
+ for (int j = 0; j < shapedetector.b(); ++j) {
+- world.setTypeAndData(shapedetector_shapedetectorcollection.a(i, j, 0).getPosition(), Blocks.AIR.getBlockData(), 2);
++ blockList.setTypeAndData(shapedetector_shapedetectorcollection.a(i, j, 0).getPosition(), Blocks.AIR.getBlockData(), 2); // CraftBukkit
+ }
+ }
+
+@@ -50,6 +58,16 @@
+ entitywither.setPositionRotation((double) blockposition2.getX() + 0.5D, (double) blockposition2.getY() + 0.55D, (double) blockposition2.getZ() + 0.5D, shapedetector_shapedetectorcollection.getFacing().k() == EnumDirection.EnumAxis.X ? 0.0F : 90.0F, 0.0F);
+ entitywither.aQ = shapedetector_shapedetectorcollection.getFacing().k() == EnumDirection.EnumAxis.X ? 0.0F : 90.0F;
+ entitywither.l();
++ // CraftBukkit start
++ if (!world.addEntity(entitywither, SpawnReason.BUILD_WITHER)) {
++ // Restore drop status from above
++ for (i = 0; i < 3; ++i) {
++ TileEntitySkull.setShouldDrop(world, shapedetector_shapedetectorcollection.a(i, 0, 0).getPosition(), true);
++ }
++ return;
++ }
++ blockList.updateList();
++ // CraftBukkit end
+ Iterator iterator = world.a(EntityPlayer.class, entitywither.getBoundingBox().g(50.0D)).iterator();
+
+ while (iterator.hasNext()) {
+@@ -58,7 +76,7 @@
+ CriterionTriggers.n.a(entityplayer, (Entity) entitywither);
+ }
+
+- world.addEntity(entitywither);
++ // world.addEntity(entitywither); // CraftBukkit - moved up
+
+ int k;
+
diff --git a/nms-patches/ChatBaseComponent.patch b/nms-patches/ChatBaseComponent.patch
deleted file mode 100644
index bd82c4a1..00000000
--- a/nms-patches/ChatBaseComponent.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- a/net/minecraft/server/ChatBaseComponent.java
-+++ b/net/minecraft/server/ChatBaseComponent.java
-@@ -112,7 +112,7 @@
- }
-
- public int hashCode() {
-- return 31 * this.b.hashCode() + this.a.hashCode();
-+ return 31 * this.getChatModifier().hashCode() + this.a.hashCode(); // CraftBukkit - fix null pointer
- }
-
- public String toString() {
diff --git a/nms-patches/ChatModifier.patch b/nms-patches/ChatModifier.patch
deleted file mode 100644
index bd72bcff..00000000
--- a/nms-patches/ChatModifier.patch
+++ /dev/null
@@ -1,45 +0,0 @@
---- a/net/minecraft/server/ChatModifier.java
-+++ b/net/minecraft/server/ChatModifier.java
-@@ -263,16 +263,18 @@
- }
-
- public int hashCode() {
-- int i = this.b.hashCode();
-+ // CraftBukkit start - fix npe
-+ int i = b == null ? 0 : this.b.hashCode();
-
-- i = 31 * i + this.c.hashCode();
-- i = 31 * i + this.d.hashCode();
-- i = 31 * i + this.e.hashCode();
-- i = 31 * i + this.f.hashCode();
-- i = 31 * i + this.g.hashCode();
-- i = 31 * i + this.h.hashCode();
-- i = 31 * i + this.i.hashCode();
-- i = 31 * i + this.j.hashCode();
-+ i = 31 * i + (c == null ? 0 : this.c.hashCode());
-+ i = 31 * i + (d == null ? 0 : this.d.hashCode());
-+ i = 31 * i + (e == null ? 0 : this.e.hashCode());
-+ i = 31 * i + (f == null ? 0 : this.f.hashCode());
-+ i = 31 * i + (g == null ? 0 : this.g.hashCode());
-+ i = 31 * i + (h == null ? 0 : this.h.hashCode());
-+ i = 31 * i + (this.i == null ? 0 : this.i.hashCode());
-+ i = 31 * i + (j == null ? 0 : this.j.hashCode());
-+ // CraftBukkit end
- return i;
- }
-
-@@ -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 92d24e2d..7159a34c 100644
--- a/nms-patches/Chunk.patch
+++ b/nms-patches/Chunk.patch
@@ -1,18 +1,17 @@
--- a/net/minecraft/server/Chunk.java
+++ b/net/minecraft/server/Chunk.java
-@@ -14,6 +14,9 @@
+@@ -23,6 +23,8 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+import com.google.common.collect.Lists; // CraftBukkit
-+import org.bukkit.Server; // CraftBukkit
+
- public class Chunk {
+ public class Chunk implements IChunkAccess {
private static final Logger e = LogManager.getLogger();
-@@ -42,6 +45,35 @@
- private final ConcurrentLinkedQueue<BlockPosition> y;
- public boolean d;
+@@ -58,6 +60,35 @@
+ private int E;
+ private final AtomicInteger F;
+ // CraftBukkit start - Neighbor loaded cache for chunk lighting and entity ticking
+ private int neighbors = 0x1 << 12;
@@ -43,13 +42,13 @@
+ }
+ // CraftBukkit end
+
- public Chunk(World world, int i, int j) {
+ public Chunk(World world, int i, int j, BiomeBase[] abiomebase, ChunkConverter chunkconverter, TickList<Block> ticklist, TickList<FluidType> ticklist1, long k) {
this.sections = new ChunkSection[16];
- this.g = new byte[256];
-@@ -62,8 +94,15 @@
-
- Arrays.fill(this.h, -999);
- Arrays.fill(this.g, (byte) -1);
+ this.h = new boolean[256];
+@@ -95,8 +126,16 @@
+ this.t = ticklist;
+ this.u = ticklist1;
+ this.A = k;
+ // CraftBukkit start
+ this.bukkitChunk = new org.bukkit.craftbukkit.CraftChunk(this);
+ this.chunkKey = ChunkCoordIntPair.a(this.locX, this.locZ);
@@ -57,22 +56,41 @@
+ public org.bukkit.Chunk bukkitChunk;
+ public boolean mustSave;
++ public boolean newChunk;
+ // CraftBukkit end
+
- public Chunk(World world, ChunkSnapshot chunksnapshot, int i, int j) {
- this(world, i, j);
- boolean flag = true;
-@@ -467,7 +506,8 @@
+ public Chunk(World world, ProtoChunk protochunk, int i, int j) {
+ this(world, i, j, protochunk.getBiomeIndex(), protochunk.v(), protochunk.n(), protochunk.o(), protochunk.m());
+
+@@ -136,14 +175,15 @@
+ HeightMap.Type heightmap_type = (HeightMap.Type) iterator.next();
+
+ if (heightmap_type.c() == HeightMap.Use.LIVE_WORLD) {
+- ((HeightMap) this.heightMap.computeIfAbsent(heightmap_type, (heightmap_type) -> {
+- return new HeightMap(this, heightmap_type);
++ ((HeightMap) this.heightMap.computeIfAbsent(heightmap_type, (heightmap_type1) -> { // CraftBukkit - decompile error
++ return new HeightMap(this, heightmap_type1); // CraftBukkit - decompile error
+ })).a(protochunk.b(heightmap_type).b());
+ }
+ }
+
+ this.y = true;
+ this.a(ChunkStatus.FULLCHUNK);
++ this.newChunk = true; // CraftBukkit
+ }
+
+ public Set<BlockPosition> t() {
+@@ -474,7 +514,8 @@
}
}
-- if (!this.world.isClientSide && block1 != block) {
+- if (!this.world.isClientSide) {
+ // CraftBukkit - Don't place while processing the BlockPlaceEvent, unless it's a BlockContainer. Prevents blocks such as TNT from activating when cancelled.
-+ if (!this.world.isClientSide && block1 != block && (!this.world.captureBlockStates || block instanceof BlockTileEntity)) {
- block.onPlace(this.world, blockposition, iblockdata);
++ if (!this.world.isClientSide && (!this.world.captureBlockStates || block instanceof BlockTileEntity)) {
+ iblockdata.onPlace(this.world, blockposition, iblockdata1);
}
-@@ -604,7 +644,15 @@
+@@ -654,7 +695,15 @@
@Nullable
public TileEntity a(BlockPosition blockposition, Chunk.EnumTileEntityState chunk_enumtileentitystate) {
@@ -89,21 +107,21 @@
if (tileentity == null) {
if (chunk_enumtileentitystate == Chunk.EnumTileEntityState.IMMEDIATE) {
-@@ -639,6 +687,13 @@
+@@ -689,6 +738,13 @@
- tileentity.A();
+ tileentity.z();
this.tileEntities.put(blockposition, tileentity);
+ // CraftBukkit start
+ } else {
+ System.out.println("Attempted to place a tile entity (" + tileentity + ") at " + tileentity.position.getX() + "," + tileentity.position.getY() + "," + tileentity.position.getZ()
-+ + " (" + org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(getBlockData(blockposition).getBlock()) + ") where there was no entity tile!");
++ + " (" + getType(blockposition) + ") where there was no entity tile!");
+ System.out.println("Chunk coordinates: " + (this.locX * 16) + "," + (this.locZ * 16));
+ new Exception().printStackTrace();
+ // CraftBukkit end
}
}
-@@ -681,9 +736,21 @@
+@@ -735,9 +791,21 @@
int i = aentityslice.length;
for (int j = 0; j < i; ++j) {
@@ -127,80 +145,49 @@
}
}
-@@ -745,8 +812,8 @@
+@@ -799,8 +867,8 @@
while (iterator.hasNext()) {
Entity entity = (Entity) iterator.next();
-- if (entity.getBoundingBox().c(axisalignedbb) && (predicate == null || predicate.apply(entity))) {
+- if (entity.getBoundingBox().c(axisalignedbb) && (predicate == null || predicate.test(entity))) {
- list.add(entity);
-+ if (entity.getBoundingBox().c(axisalignedbb) && (predicate == null || predicate.apply((T) entity))) { // CraftBukkit - fix decompile error
++ if (entity.getBoundingBox().c(axisalignedbb) && (predicate == null || predicate.test((T) entity))) { // CraftBukkit - fix decompile error
+ list.add((T) entity); // Fix decompile error
}
}
}
-@@ -773,7 +840,34 @@
- return false;
+@@ -1006,13 +1074,13 @@
+
+ @Nullable
+ public LongSet b(String s) {
+- return (LongSet) this.r.computeIfAbsent(s, (s) -> {
++ return (LongSet) this.r.computeIfAbsent(s, (s1) -> { // CraftBukkit - decompile error
+ return new LongOpenHashSet();
+ });
}
-- public void loadNearby(IChunkProvider ichunkprovider, ChunkGenerator chunkgenerator) {
-+ // CraftBukkit start
-+ public void loadNearby(IChunkProvider ichunkprovider, ChunkGenerator chunkgenerator, boolean newChunk) {
-+ Server server = world.getServer();
-+ if (server != null) {
-+ /*
-+ * If it's a new world, the first few chunks are generated inside
-+ * the World constructor. We can't reliably alter that, so we have
-+ * no way of creating a CraftWorld/CraftServer at that point.
-+ */
-+ server.getPluginManager().callEvent(new org.bukkit.event.world.ChunkLoadEvent(bukkitChunk, newChunk));
-+ }
-+
-+ // Update neighbor counts
-+ for (int x = -2; x < 3; x++) {
-+ for (int z = -2; z < 3; z++) {
-+ if (x == 0 && z == 0) {
-+ continue;
-+ }
-+
-+ Chunk neighbor = getWorld().getChunkIfLoaded(locX + x, locZ + z);
-+ if (neighbor != null) {
-+ neighbor.setNeighborLoaded(-x, -z);
-+ setNeighborLoaded(x, z);
-+ }
-+ }
-+ }
-+ // CraftBukkit end
-+
- Chunk chunk = ichunkprovider.getLoadedChunkAt(this.locX, this.locZ - 1);
- Chunk chunk1 = ichunkprovider.getLoadedChunkAt(this.locX + 1, this.locZ);
- Chunk chunk2 = ichunkprovider.getLoadedChunkAt(this.locX, this.locZ + 1);
-@@ -809,6 +903,29 @@
- } else {
- this.o();
- chunkgenerator.recreateStructures(this.locX, this.locZ);
-+
-+ // CraftBukkit start
-+ BlockSand.instaFall = true;
-+ Random random = new Random();
-+ random.setSeed(world.getSeed());
-+ long xRand = random.nextLong() / 2L * 2L + 1L;
-+ long zRand = random.nextLong() / 2L * 2L + 1L;
-+ random.setSeed((long) locX * xRand + (long) locZ * zRand ^ world.getSeed());
-+
-+ org.bukkit.World world = this.world.getWorld();
-+ if (world != null) {
-+ this.world.populating = true;
-+ try {
-+ for (org.bukkit.generator.BlockPopulator populator : world.getPopulators()) {
-+ populator.populate(world, random, bukkitChunk);
-+ }
-+ } finally {
-+ this.world.populating = false;
-+ }
-+ }
-+ BlockSand.instaFall = false;
-+ this.world.getServer().getPluginManager().callEvent(new org.bukkit.event.world.ChunkPopulateEvent(bukkitChunk));
-+ // CraftBukkit end
- this.markDirty();
- }
+ public void a(String s, long i) {
+- ((LongSet) this.r.computeIfAbsent(s, (s) -> {
++ ((LongSet) this.r.computeIfAbsent(s, (s1) -> { // CraftBukkit - decompile error
+ return new LongOpenHashSet();
+ })).add(i);
+ }
+@@ -1061,14 +1129,14 @@
+ }
+
+ if (this.t instanceof ProtoChunkTickList) {
+- ((ProtoChunkTickList) this.t).a(this.world.I(), (blockposition) -> {
+- return this.world.getType(blockposition).getBlock();
++ ((ProtoChunkTickList<Block>) this.t).a(this.world.I(), (blockposition1) -> { // CraftBukkit - decompile error
++ return this.world.getType(blockposition1).getBlock();
+ });
+ }
+
+ if (this.u instanceof ProtoChunkTickList) {
+- ((ProtoChunkTickList) this.u).a(this.world.H(), (blockposition) -> {
+- return this.world.b(blockposition).c();
++ ((ProtoChunkTickList<FluidType>) this.u).a(this.world.H(), (blockposition1) -> { // CraftBukkit - decompile error
++ return this.world.b(blockposition1).c();
+ });
+ }
diff --git a/nms-patches/ChunkMap.patch b/nms-patches/ChunkMap.patch
new file mode 100644
index 00000000..8007134e
--- /dev/null
+++ b/nms-patches/ChunkMap.patch
@@ -0,0 +1,88 @@
+--- a/net/minecraft/server/ChunkMap.java
++++ b/net/minecraft/server/ChunkMap.java
+@@ -31,6 +31,54 @@
+ }
+ }
+
++ org.bukkit.Server server = chunk.world.getServer();
++ if (server != null) {
++ /*
++ * If it's a new world, the first few chunks are generated inside
++ * the World constructor. We can't reliably alter that, so we have
++ * no way of creating a CraftWorld/CraftServer at that point.
++ */
++ server.getPluginManager().callEvent(new org.bukkit.event.world.ChunkLoadEvent(chunk.bukkitChunk, chunk.newChunk));
++ }
++
++ // Update neighbor counts
++ for (int x = -2; x < 3; x++) {
++ for (int z = -2; z < 3; z++) {
++ if (x == 0 && z == 0) {
++ continue;
++ }
++
++ Chunk neighbor = this.get(ChunkCoordIntPair.a(chunkcoordintpair.x + x, chunkcoordintpair.z + z));
++ if (neighbor != null) {
++ neighbor.setNeighborLoaded(-x, -z);
++ chunk.setNeighborLoaded(x, z);
++ }
++ }
++ }
++
++ if (chunk.newChunk) {
++ BlockSand.instaFall = true;
++ java.util.Random random = new java.util.Random();
++ random.setSeed(chunk.world.getSeed());
++ long xRand = random.nextLong() / 2L * 2L + 1L;
++ long zRand = random.nextLong() / 2L * 2L + 1L;
++ random.setSeed((long) chunk.locX * xRand + (long) chunk.locZ * zRand ^ chunk.world.getSeed());
++
++ org.bukkit.World world = chunk.world.getWorld();
++ if (world != null) {
++ chunk.world.populating = true;
++ try {
++ for (org.bukkit.generator.BlockPopulator populator : world.getPopulators()) {
++ populator.populate(world, random, chunk.bukkitChunk);
++ }
++ } finally {
++ chunk.world.populating = false;
++ }
++ }
++ BlockSand.instaFall = false;
++ chunk.world.getServer().getPluginManager().callEvent(new org.bukkit.event.world.ChunkPopulateEvent(chunk.bukkitChunk));
++ }
++
+ return chunk1;
+ }
+
+@@ -69,23 +117,25 @@
+ throw new RuntimeException("Not yet implemented");
+ }
+
+- public Object remove(Object object) {
++ // CraftBukkit start - decompile errors
++ public Chunk remove(Object object) {
+ return this.a(object);
+ }
+
+- public Object remove(long i) {
++ public Chunk remove(long i) {
+ return this.a(i);
+ }
+
+- public Object put(Long olong, Object object) {
++ public Chunk put(Long olong, Chunk object) {
+ return this.a(olong, (Chunk) object);
+ }
+
+- public Object put(long i, Object object) {
++ public Chunk put(long i, Chunk object) {
+ return this.a(i, (Chunk) object);
+ }
+
+- public Object put(Object object, Object object1) {
++ public Object put(Object object, Chunk object1) {
+ return this.a((Long) object, (Chunk) object1);
+ }
++ // CraftBukkit end
+ }
diff --git a/nms-patches/ChunkProviderGenerate.patch b/nms-patches/ChunkProviderGenerate.patch
index 65c2bcd9..f884de90 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
-@@ -234,6 +234,11 @@
+@@ -166,6 +166,11 @@
f5 = 1.0F + f5 * 2.0F;
f6 = 1.0F + f6 * 4.0F;
}
@@ -10,5 +10,14 @@
+ }
+ // CraftBukkit end
- float f7 = this.r[l1 + 2 + (i2 + 2) * 5] / (f5 + 2.0F);
+ float f7 = this.o[l1 + 2 + (i2 + 2) * 5] / (f5 + 2.0F);
+@@ -267,7 +272,7 @@
+ return this.a.getSeaLevel() + 1;
+ }
+
+- public GeneratorSettings getSettings() {
++ public GeneratorSettingsOverworld getSettings() { // CraftBukkit - decompile error
+ return this.f();
+ }
+ }
diff --git a/nms-patches/ChunkProviderServer.patch b/nms-patches/ChunkProviderServer.patch
index 9f92a1c3..008a069b 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
-@@ -15,6 +15,11 @@
+@@ -20,6 +20,11 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -12,40 +12,31 @@
public class ChunkProviderServer implements IChunkProvider {
private static final Logger a = LogManager.getLogger();
-@@ -70,19 +75,82 @@
- Chunk chunk = this.getLoadedChunkAt(i, j);
+@@ -35,7 +40,7 @@
+ this.world = worldserver;
+ this.chunkLoader = ichunkloader;
+ this.chunkGenerator = chunkgenerator;
+- this.f = new ChunkTaskScheduler(2, worldserver, chunkgenerator, ichunkloader, iasynctaskhandler);
++ this.f = new ChunkTaskScheduler(0, worldserver, chunkgenerator, ichunkloader, iasynctaskhandler); // CraftBukkit - very buggy, broken in lots of __subtle__ ways. Same goes for async chunk loading. Also Bukkit API / plugins can't handle async events at all anyway.
+ this.g = new SchedulerBatch(this.f);
+ }
+
+@@ -77,9 +82,10 @@
+ @Nullable
+ private Chunk loadChunkAt(int i, int j) {
+ try {
+- Chunk chunk = this.chunkLoader.a(this.world, i, j, (chunk) -> {
+- chunk.setLastSaved(this.world.getTime());
+- this.chunks.put(ChunkCoordIntPair.a(i, j), chunk);
++ // CraftBukkit - decompile error
++ Chunk chunk = this.chunkLoader.a(this.world, i, j, (chunk1) -> {
++ chunk1.setLastSaved(this.world.getTime());
++ this.chunks.put(ChunkCoordIntPair.a(i, j), chunk1);
+ });
- if (chunk == null) {
-+ // CraftBukkit start
-+ ChunkRegionLoader loader = null;
-+
-+ if (this.chunkLoader instanceof ChunkRegionLoader) {
-+ loader = (ChunkRegionLoader) this.chunkLoader;
-+ }
-+ if (loader != null && loader.chunkExists(i, j)) {
-+ chunk = ChunkIOExecutor.syncChunkLoad(world, loader, this, i, j);
-+ }
-+ }
-+
-+ return chunk;
-+ }
-+
-+ @Nullable
-+ public Chunk originalGetOrLoadChunkAt(int i, int j) {
-+ // CraftBukkit end
-+ Chunk chunk = this.getLoadedChunkAt(i, j);
-+
-+ if (chunk == null) {
- chunk = this.loadChunk(i, j);
if (chunk != null) {
- this.chunks.put(ChunkCoordIntPair.a(i, j), chunk);
- chunk.addEntities();
-- chunk.loadNearby(this, this.chunkGenerator);
-+ chunk.loadNearby(this, this.chunkGenerator, false); // CraftBukkit
- }
+@@ -104,6 +110,12 @@
}
-
- return chunk;
}
+ // CraftBukkit start
@@ -55,74 +46,27 @@
+ // CraftBukkit end
+
public Chunk getChunkAt(int i, int j) {
-- Chunk chunk = this.getOrLoadChunkAt(i, j);
-+ return getChunkAt(i, j, null);
-+ }
-+
-+ public Chunk getChunkAt(int i, int j, Runnable runnable) {
-+ return getChunkAt(i, j, runnable, true);
-+ }
-+
-+ public Chunk getChunkAt(int i, int j, Runnable runnable, boolean generate) {
-+ Chunk chunk = getLoadedChunkAt(i, j);
-+ ChunkRegionLoader loader = null;
-+
-+ if (this.chunkLoader instanceof ChunkRegionLoader) {
-+ loader = (ChunkRegionLoader) this.chunkLoader;
-+
-+ }
-+ // We can only use the queue for already generated chunks
-+ if (chunk == null && loader != null && loader.chunkExists(i, j)) {
-+ if (runnable != null) {
-+ ChunkIOExecutor.queueChunkLoad(world, loader, this, i, j, runnable);
-+ return null;
-+ } else {
-+ chunk = ChunkIOExecutor.syncChunkLoad(world, loader, this, i, j);
-+ }
-+ } else if (chunk == null && generate) {
-+ chunk = originalGetChunkAt(i, j);
-+ }
-+
-+ // If we didn't load the chunk async and have a callback run it now
-+ if (runnable != null) {
-+ runnable.run();
-+ }
-+
-+ return chunk;
-+ }
-+
-+ public Chunk originalGetChunkAt(int i, int j) {
-+ Chunk chunk = this.originalGetOrLoadChunkAt(i, j);
-+ // CraftBukkit end
+ Chunk chunk = this.getOrLoadChunkAt(i, j);
- if (chunk == null) {
- long k = ChunkCoordIntPair.a(i, j);
-@@ -101,7 +169,7 @@
+@@ -125,7 +137,7 @@
+ synchronized (this.chunks) {
+ IChunkAccess ichunkaccess = (IChunkAccess) this.chunks.get(ChunkCoordIntPair.a(i, j));
- this.chunks.put(k, chunk);
- chunk.addEntities();
-- chunk.loadNearby(this, this.chunkGenerator);
-+ chunk.loadNearby(this, this.chunkGenerator, true); // CraftBukkit
+- return ichunkaccess != null ? ichunkaccess : (IChunkAccess) this.f.c((Object) (new ChunkCoordIntPair(i, j)));
++ return ichunkaccess != null ? ichunkaccess : (IChunkAccess) this.f.c((new ChunkCoordIntPair(i, j))); // CraftBukkit - decompile error
}
+ }
- return chunk;
-@@ -147,10 +215,12 @@
-
- public boolean a(boolean flag) {
- int i = 0;
-- ArrayList arraylist = Lists.newArrayList(this.chunks.values());
-
-- for (int j = 0; j < arraylist.size(); ++j) {
-- Chunk chunk = (Chunk) arraylist.get(j);
-+ // CraftBukkit start
-+ Iterator iterator = this.chunks.values().iterator();
-+ while (iterator.hasNext()) {
-+ Chunk chunk = (Chunk) iterator.next();
-+ // CraftBukkit end
+@@ -150,7 +162,7 @@
+ public CompletableFuture<Chunk> generateChunk(int i, int j) {
+ this.g.b();
+ this.g.a(new ChunkCoordIntPair(i, j));
+- CompletableFuture completablefuture = this.g.c();
++ CompletableFuture<ProtoChunk> completablefuture = this.g.c(); // CraftBukkit - decompile error
- if (flag) {
- this.saveChunkNOP(chunk);
-@@ -183,10 +253,12 @@
+ return completablefuture.thenApply(this::a);
+ }
+@@ -268,10 +280,12 @@
Chunk chunk = (Chunk) this.chunks.get(olong);
if (chunk != null && chunk.d) {
@@ -139,7 +83,7 @@
++i;
}
}
-@@ -198,6 +270,40 @@
+@@ -284,6 +298,40 @@
return false;
}
diff --git a/nms-patches/ChunkRegionLoader.patch b/nms-patches/ChunkRegionLoader.patch
index bf874a1b..d657e19a 100644
--- a/nms-patches/ChunkRegionLoader.patch
+++ b/nms-patches/ChunkRegionLoader.patch
@@ -1,112 +1,123 @@
--- a/net/minecraft/server/ChunkRegionLoader.java
+++ b/net/minecraft/server/ChunkRegionLoader.java
-@@ -19,29 +19,47 @@
-
- private static final Logger a = LogManager.getLogger();
- private final Map<ChunkCoordIntPair, NBTTagCompound> b = Maps.newConcurrentMap();
-- private final Set<ChunkCoordIntPair> c = Collections.newSetFromMap(Maps.newConcurrentMap());
-+ // CraftBukkit
-+ // private final Set<ChunkCoordIntPair> c = Collections.newSetFromMap(Maps.newConcurrentMap());
- private final File d;
- private final DataConverterManager e;
+@@ -34,7 +34,7 @@
+ private final File c;
+ private final DataFixer d;
+ private PersistentStructureLegacy e;
- private boolean f;
-+ // private boolean f;
-+ // CraftBukkit
++ // private boolean f; // CraftBukkit
- public ChunkRegionLoader(File file, DataConverterManager dataconvertermanager) {
- this.d = file;
- this.e = dataconvertermanager;
+ public ChunkRegionLoader(File file, DataFixer datafixer) {
+ this.c = file;
+@@ -50,12 +50,13 @@
+
+ @Nullable
+ private NBTTagCompound b(GeneratorAccess generatoraccess, int i, int j) throws IOException {
+- DataInputStream datainputstream = RegionFileCache.d(this.c, i, j);
++ // CraftBukkit start
++ NBTTagCompound nbttagcompound = RegionFileCache.d(this.c, i, j);
+
+- if (datainputstream == null) {
++ if (nbttagcompound == null) {
+ return null;
+ } else {
+- NBTTagCompound nbttagcompound = NBTCompressedStreamTools.a(datainputstream);
++ // CraftBukkit end
+ int k = nbttagcompound.hasKeyOfType("DataVersion", 99) ? nbttagcompound.getInt("DataVersion") : -1;
+
+ if (k < 1493) {
+@@ -78,13 +79,29 @@
+ }
}
+ // CraftBukkit start - Add async variant, provide compatibility
@Nullable
- public Chunk a(World world, int i, int j) throws IOException {
-+ Object[] data = loadChunk(world, i, j);
+ public synchronized Chunk a(GeneratorAccess generatoraccess, int i, int j, Consumer<Chunk> consumer) throws IOException {
++ Object[] data = loadChunk(generatoraccess, i, j, consumer);
+ if (data != null) {
+ Chunk chunk = (Chunk) data[0];
+ NBTTagCompound nbttagcompound = (NBTTagCompound) data[1];
-+ loadEntities(chunk, nbttagcompound.getCompound("Level"), world);
++ consumer.accept(chunk);
++ this.loadEntities(nbttagcompound.getCompound("Level"), chunk);
+ return chunk;
+ }
+
+ return null;
+ }
+
-+ public Object[] loadChunk(World world, int i, int j) throws IOException {
++ public synchronized Object[] loadChunk(GeneratorAccess generatoraccess, int i, int j, Consumer<Chunk> consumer) throws IOException {
+ // CraftBukkit end
- ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(i, j);
- NBTTagCompound nbttagcompound = (NBTTagCompound) this.b.get(chunkcoordintpair);
+ NBTTagCompound nbttagcompound = this.a(generatoraccess, i, j);
if (nbttagcompound == null) {
-- DataInputStream datainputstream = RegionFileCache.d(this.d, i, j);
-+ // CraftBukkit start
-+ nbttagcompound = RegionFileCache.d(this.d, i, j);
+ return null;
+ } else {
++ /*
+ Chunk chunk = this.a(generatoraccess, i, j, nbttagcompound);
-- if (datainputstream == null) {
-+ if (nbttagcompound == null) {
- return null;
+ if (chunk != null) {
+@@ -93,6 +110,9 @@
}
-- nbttagcompound = this.e.a((DataConverterType) DataConverterTypes.CHUNK, NBTCompressedStreamTools.a(datainputstream));
-+ nbttagcompound = this.e.a((DataConverterType) DataConverterTypes.CHUNK, nbttagcompound);
-+ // CraftBukkit end
+ return chunk;
++ */
++
++ return this.a(generatoraccess, i, j, nbttagcompound);
}
+ }
- return this.a(world, i, j, nbttagcompound);
-@@ -55,7 +73,7 @@
+@@ -121,7 +141,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", Integer.valueOf(i), Integer.valueOf(j));
- return null;
-@@ -72,10 +90,28 @@
- ChunkRegionLoader.a.error("Chunk file at {},{} is in the wrong location; relocating. (Expected {}, {}, got {}, {})", 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);
+- protected Chunk a(GeneratorAccess generatoraccess, int i, int j, NBTTagCompound nbttagcompound) {
++ protected Object[] a(GeneratorAccess generatoraccess, int i, int j, NBTTagCompound nbttagcompound) { // CraftBukkit - return Chunk -> Object[]
+ if (nbttagcompound.hasKeyOfType("Level", 10) && nbttagcompound.getCompound("Level").hasKeyOfType("Status", 8)) {
+ ChunkStatus.Type chunkstatus_type = this.a(nbttagcompound);
+
+@@ -140,10 +160,28 @@
+ ChunkRegionLoader.a.error("Chunk file at {},{} is in the wrong location; relocating. (Expected {}, {}, got {}, {})", 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);
+
-+ // CraftBukkit start - Have to move tile entities since we don't load them at this stage
-+ NBTTagList tileEntities = nbttagcompound.getCompound("Level").getList("TileEntities", 10);
-+ if (tileEntities != null) {
-+ for (int te = 0; te < tileEntities.size(); te++) {
-+ NBTTagCompound tileEntity = (NBTTagCompound) tileEntities.get(te);
-+ int x = tileEntity.getInt("x") - chunk.locX * 16;
-+ int z = tileEntity.getInt("z") - chunk.locZ * 16;
-+ tileEntity.setInt("x", i * 16 + x);
-+ tileEntity.setInt("z", j * 16 + z);
++ // CraftBukkit start - Have to move tile entities since we don't load them at this stage
++ NBTTagList tileEntities = nbttagcompound.getCompound("Level").getList("TileEntities", 10);
++ if (tileEntities != null) {
++ for (int te = 0; te < tileEntities.size(); te++) {
++ NBTTagCompound tileEntity = (NBTTagCompound) tileEntities.get(te);
++ int x = tileEntity.getInt("x") - chunk.locX * 16;
++ int z = tileEntity.getInt("z") - chunk.locZ * 16;
++ tileEntity.setInt("x", i * 16 + x);
++ tileEntity.setInt("z", j * 16 + z);
++ }
+ }
-+ }
++ // CraftBukkit end
+ chunk = this.a(generatoraccess, nbttagcompound1);
+ }
+
+- return chunk;
++ // CraftBukkit start
++ Object[] data = new Object[2];
++ data[0] = chunk;
++ data[1] = nbttagcompound;
++ return data;
+ // CraftBukkit end
- chunk = this.a(world, nbttagcompound1);
}
-
-- return chunk;
-+ // CraftBukkit start
-+ Object[] data = new Object[2];
-+ data[0] = chunk;
-+ data[1] = nbttagcompound;
-+ return data;
-+ // CraftBukkit end
}
- }
- }
-@@ -98,7 +134,9 @@
- }
+ } else {
+@@ -158,7 +196,7 @@
+ ChunkStatus.Type chunkstatus_type = this.a(nbttagcompound);
- protected void a(ChunkCoordIntPair chunkcoordintpair, NBTTagCompound nbttagcompound) {
-- if (!this.c.contains(chunkcoordintpair)) {
-+ // CraftBukkit
-+ // if (!this.c.contains(chunkcoordintpair))
-+ {
- this.b.put(chunkcoordintpair, nbttagcompound);
- }
+ if (chunkstatus_type == ChunkStatus.Type.LEVELCHUNK) {
+- return new ProtoChunkExtension(this.a(generatoraccess, i, j, nbttagcompound));
++ return new ProtoChunkExtension((IChunkAccess) this.a(generatoraccess, i, j, nbttagcompound)[0]); // CraftBukkit - fix up access
+ } else {
+ NBTTagCompound nbttagcompound1 = nbttagcompound.getCompound("Level");
-@@ -106,20 +144,32 @@
+@@ -204,19 +242,30 @@
}
- public boolean a() {
+ public synchronized boolean a() {
- if (this.b.isEmpty()) {
- if (this.f) {
+ // CraftBukkit start
@@ -118,7 +129,7 @@
+ if (!iter.hasNext()) {
+ if (logCompletion) {
+ // CraftBukkit end
- ChunkRegionLoader.a.info("ThreadedAnvilChunkStorage ({}): All chunks are saved", this.d.getName());
+ ChunkRegionLoader.a.info("ThreadedAnvilChunkStorage ({}): All chunks are saved", this.c.getName());
}
return false;
@@ -133,40 +144,37 @@
boolean flag;
try {
-- this.c.add(chunkcoordintpair);
-- NBTTagCompound nbttagcompound = (NBTTagCompound) this.b.remove(chunkcoordintpair);
-+ // this.c.add(chunkcoordintpair);
-+ // NBTTagCompound nbttagcompound = (NBTTagCompound) this.b.remove(chunkcoordintpair);
-+ // CraftBukkit
+- NBTTagCompound nbttagcompound = (NBTTagCompound) this.b.get(chunkcoordintpair);
++ // NBTTagCompound nbttagcompound = (NBTTagCompound) this.b.get(chunkcoordintpair); // CraftBukkit
if (nbttagcompound != null) {
try {
-@@ -131,7 +181,7 @@
+@@ -228,7 +277,7 @@
flag = true;
} finally {
-- this.c.remove(chunkcoordintpair);
+- this.b.remove(chunkcoordintpair);
+ this.b.remove(chunkcoordintpair, nbttagcompound); // CraftBukkit
}
return flag;
-@@ -139,10 +189,14 @@
+@@ -248,10 +297,14 @@
}
private void b(ChunkCoordIntPair chunkcoordintpair, NBTTagCompound nbttagcompound) throws IOException {
-- DataOutputStream dataoutputstream = RegionFileCache.e(this.d, chunkcoordintpair.x, chunkcoordintpair.z);
+- DataOutputStream dataoutputstream = RegionFileCache.e(this.c, chunkcoordintpair.x, chunkcoordintpair.z);
+ // CraftBukkit start
-+ RegionFileCache.e(this.d, chunkcoordintpair.x, chunkcoordintpair.z, nbttagcompound);
++ RegionFileCache.e(this.c, chunkcoordintpair.x, chunkcoordintpair.z, nbttagcompound);
+ /*
NBTCompressedStreamTools.a(nbttagcompound, (DataOutput) dataoutputstream);
dataoutputstream.close();
+ */
+ // CraftBukkit end
- }
-
- public void b(World world, Chunk chunk) throws IOException {}
-@@ -151,15 +205,16 @@
+ if (this.e != null) {
+ this.e.a(chunkcoordintpair.a());
+ }
+@@ -264,15 +317,16 @@
public void c() {
try {
@@ -186,30 +194,52 @@
}
}
-@@ -334,6 +389,13 @@
- chunk.a(nbttagcompound.getByteArray("Biomes"));
+@@ -301,7 +355,7 @@
+
+ if (abiomebase != null) {
+ for (int k = 0; k < abiomebase.length; ++k) {
+- aint[k] = BiomeBase.REGISTRY_ID.a((Object) abiomebase[k]);
++ aint[k] = BiomeBase.REGISTRY_ID.a(abiomebase[k]); // CraftBukkit - decompile error
+ }
}
-+ // CraftBukkit start - End this method here and split off entity loading to another method
-+ return chunk;
-+ }
-+
-+ public void loadEntities(Chunk chunk, NBTTagCompound nbttagcompound, World world) {
-+ // CraftBukkit end
-+
- NBTTagList nbttaglist1 = nbttagcompound.getList("Entities", 10);
+@@ -383,7 +437,7 @@
+ int[] aint = new int[abiomebase.length];
- for (int l = 0; l < nbttaglist1.size(); ++l) {
-@@ -371,7 +433,7 @@
- }
+ for (int i = 0; i < abiomebase.length; ++i) {
+- aint[i] = BiomeBase.REGISTRY_ID.a((Object) abiomebase[i]);
++ aint[i] = BiomeBase.REGISTRY_ID.a(abiomebase[i]); // CraftBukkit - decompile error
}
-- return chunk;
-+ // return chunk; // CraftBukkit
- }
+ nbttagcompound.setIntArray("Biomes", aint);
+@@ -485,7 +539,7 @@
+ }
- @Nullable
-@@ -399,14 +461,20 @@
+ ChunkConverter chunkconverter = nbttagcompound.hasKeyOfType("UpgradeData", 10) ? new ChunkConverter(nbttagcompound.getCompound("UpgradeData")) : ChunkConverter.a;
+- Predicate predicate = (block) -> {
++ Predicate<Block> predicate = (block) -> { // CraftBukkit - decompile error
+ return block.getBlockData().isAir();
+ };
+ RegistryBlocks registryblocks = Block.REGISTRY;
+@@ -497,7 +551,7 @@
+ Block.REGISTRY.getClass();
+ ProtoChunkTickList protochunkticklist = new ProtoChunkTickList(predicate, function, registryblocks1::get, new ChunkCoordIntPair(i, j));
+
+- predicate = (fluidtype) -> {
++ Predicate<FluidType> predicate1 = (fluidtype) -> { // CraftBukkit - decompile error
+ return fluidtype == FluidTypes.a;
+ };
+ registryblocks = FluidType.c;
+@@ -505,7 +559,7 @@
+ function = registryblocks::b;
+ registryblocks1 = FluidType.c;
+ FluidType.c.getClass();
+- ProtoChunkTickList protochunkticklist1 = new ProtoChunkTickList(predicate, function, registryblocks1::get, new ChunkCoordIntPair(i, j));
++ ProtoChunkTickList protochunkticklist1 = new ProtoChunkTickList(predicate1, function, registryblocks1::get, new ChunkCoordIntPair(i, j)); // CraftBukkit - decompile error
+ long i1 = nbttagcompound.getLong("InhabitedTime");
+ Chunk chunk = new Chunk(generatoraccess.getMinecraftWorld(), i, j, abiomebase, chunkconverter, protochunkticklist, protochunkticklist1, i1);
+
+@@ -852,17 +906,29 @@
}
@Nullable
@@ -220,30 +250,40 @@
+
+ public static Entity spawnEntity(NBTTagCompound nbttagcompound, World world, double d0, double d1, double d2, boolean flag, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) {
+ // CraftBukkit end
- Entity entity = a(nbttagcompound, world);
-
- if (entity == null) {
- return null;
- } else {
+ return a(nbttagcompound, world, (entity) -> {
entity.setPositionRotation(d0, d1, d2, entity.yaw, entity.pitch);
-- if (flag && !world.addEntity(entity)) {
-+ if (flag && !world.addEntity(entity, spawnReason)) { // CraftBukkit
- return null;
- } else {
- if (nbttagcompound.hasKeyOfType("Passengers", 9)) {
-@@ -435,8 +503,14 @@
+- return flag && !world.addEntity(entity) ? null : entity;
++ return flag && !world.addEntity(entity, spawnReason) ? null : entity;
+ });
+ }
+
+ @Nullable
++ // CraftBukkit start
+ public static Entity a(NBTTagCompound nbttagcompound, World world, boolean flag) {
++ return spawnEntity(nbttagcompound, world, flag, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT);
++ }
++
++ public static Entity spawnEntity(NBTTagCompound nbttagcompound, World world, boolean flag, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) {
++ // CraftBukkit end
+ return a(nbttagcompound, world, (entity) -> {
+- return flag && !world.addEntity(entity) ? null : entity;
++ return flag && !world.addEntity(entity, spawnReason) ? null : entity; // CraftBukkit
+ });
+ }
+
+@@ -876,8 +942,14 @@
}
}
+ // CraftBukkit start
- public static void a(Entity entity, World world) {
-- if (world.addEntity(entity) && entity.isVehicle()) {
-+ a(entity, world, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT);
+ public static void a(Entity entity, GeneratorAccess generatoraccess) {
+- if (generatoraccess.addEntity(entity) && entity.isVehicle()) {
++ a(entity, generatoraccess, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT);
+ }
+
-+ public static void a(Entity entity, World world, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) {
-+ if (world.addEntity(entity, reason) && entity.isVehicle()) {
++ public static void a(Entity entity, GeneratorAccess generatoraccess, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) {
++ if (generatoraccess.addEntity(entity, reason) && entity.isVehicle()) {
+ // CraftBukkit end
- Iterator iterator = entity.bF().iterator();
+ Iterator iterator = entity.bP().iterator();
while (iterator.hasNext()) {
diff --git a/nms-patches/ChunkSection.patch b/nms-patches/ChunkSection.patch
index 7a9ab688..88b6e356 100644
--- a/nms-patches/ChunkSection.patch
+++ b/nms-patches/ChunkSection.patch
@@ -1,31 +1,15 @@
--- a/net/minecraft/server/ChunkSection.java
+++ b/net/minecraft/server/ChunkSection.java
-@@ -19,6 +19,24 @@
+@@ -15,7 +15,7 @@
- }
-
-+ // CraftBukkit start
-+ public ChunkSection(int y, boolean flag, char[] blockIds) {
-+ this.yPos = y;
-+ this.blockIds = new DataPaletteBlock();
-+ for (int i = 0; i < blockIds.length; i++) {
-+ int xx = i & 15;
-+ int yy = (i >> 8) & 15;
-+ int zz = (i >> 4) & 15;
-+ this.blockIds.setBlock(xx, yy, zz, Block.REGISTRY_ID.fromId(blockIds[i]));
-+ }
-+ this.emittedLight = new NibbleArray();
-+ if (flag) {
-+ this.skyLight = new NibbleArray();
-+ }
-+ recalcBlockCounts();
-+ }
-+ // CraftBukkit end
-+
- public IBlockData getType(int i, int j, int k) {
- return this.blockIds.a(i, j, k);
- }
-@@ -46,7 +64,7 @@
+ public ChunkSection(int i, boolean flag) {
+ this.yPos = i;
+- this.blockIds = new DataPaletteBlock(ChunkSection.GLOBAL_PALETTE, Block.REGISTRY_ID, GameProfileSerializer::d, GameProfileSerializer::a, Blocks.AIR.getBlockData());
++ this.blockIds = new DataPaletteBlock<>(ChunkSection.GLOBAL_PALETTE, Block.REGISTRY_ID, GameProfileSerializer::d, GameProfileSerializer::a, Blocks.AIR.getBlockData()); // CraftBukkit - decompile error
+ this.emittedLight = new NibbleArray();
+ if (flag) {
+ this.skyLight = new NibbleArray();
+@@ -62,7 +62,7 @@
}
public boolean a() {
@@ -33,4 +17,4 @@
+ return false; // CraftBukkit - MC-80966
}
- public boolean shouldTick() {
+ public boolean b() {
diff --git a/nms-patches/CommandBlockListenerAbstract.patch b/nms-patches/CommandBlockListenerAbstract.patch
index 359289f0..84668fcc 100644
--- a/nms-patches/CommandBlockListenerAbstract.patch
+++ b/nms-patches/CommandBlockListenerAbstract.patch
@@ -1,209 +1,37 @@
--- a/net/minecraft/server/CommandBlockListenerAbstract.java
+++ b/net/minecraft/server/CommandBlockListenerAbstract.java
-@@ -4,6 +4,15 @@
+@@ -5,6 +5,7 @@
+ import java.text.SimpleDateFormat;
import java.util.Date;
import javax.annotation.Nullable;
-
-+// CraftBukkit start
-+import java.util.ArrayList;
-+import org.bukkit.craftbukkit.command.VanillaCommandWrapper;
-+import com.google.common.base.Joiner;
-+import java.util.logging.Level;
+import org.bukkit.command.CommandSender;
-+import org.bukkit.event.server.ServerCommandEvent;
-+// CraftBukkit end
-+
+
public abstract class CommandBlockListenerAbstract implements ICommandListener {
- private static final SimpleDateFormat a = new SimpleDateFormat("HH:mm:ss");
-@@ -15,6 +24,7 @@
+@@ -16,6 +17,10 @@
+ private IChatBaseComponent f;
private String g = "";
- private String h = "@";
- private final CommandObjectiveExecutor i = new CommandObjectiveExecutor();
-+ protected org.bukkit.command.CommandSender sender; // CraftBukkit - add sender
+ private IChatBaseComponent h = new ChatComponentText("@");
++ // CraftBukkit start
++ @Override
++ public abstract CommandSender getBukkitSender(CommandListenerWrapper wrapper);
++ // CraftBukkit end
public CommandBlockListenerAbstract() {}
-@@ -107,7 +117,9 @@
- if (minecraftserver != null && minecraftserver.M() && minecraftserver.getEnableCommandBlock()) {
+@@ -103,14 +108,7 @@
+ if (minecraftserver != null && minecraftserver.F() && minecraftserver.getEnableCommandBlock() && !UtilColor.b(this.g)) {
try {
this.f = null;
-- this.d = minecraftserver.getCommandHandler().a(this, this.g);
-+ // CraftBukkit start - Handle command block commands using Bukkit dispatcher
-+ this.d = executeSafely(this, sender, this.g);
-+ // CraftBukkit end
+- CommandListenerWrapper commandlistenerwrapper = this.getWrapper().a((commandcontext, flag, i) -> {
+- if (flag) {
+- ++this.d;
+- }
+-
+- });
+-
+- minecraftserver.getCommandDispatcher().a(commandlistenerwrapper, this.g);
++ this.d = minecraftserver.getCommandDispatcher().dispatchServerCommand(this.getWrapper(), this.g); // CraftBukkit
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.a(throwable, "Executing command block");
CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Command to be executed");
-@@ -149,6 +161,171 @@
- }
- }
-
-+ 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) throws CommandException {
-+ org.bukkit.command.SimpleCommandMap commandMap = sender.getWorld().getServer().getCommandMap();
-+ Joiner joiner = Joiner.on(" ");
-+ if (command.startsWith("/")) {
-+ command = command.substring(1);
-+ }
-+
-+ ServerCommandEvent event = new ServerCommandEvent(bSender, command);
-+ org.bukkit.Bukkit.getPluginManager().callEvent(event);
-+ if (event.isCancelled()) {
-+ return 0;
-+ }
-+ command = event.getCommand();
-+
-+ String[] args = command.split(" ");
-+ ArrayList<String[]> commands = new ArrayList<String[]>();
-+
-+ String cmd = args[0];
-+ if (cmd.startsWith("minecraft:")) cmd = cmd.substring("minecraft:".length());
-+ if (cmd.startsWith("bukkit:")) cmd = cmd.substring("bukkit:".length());
-+
-+ // Block disallowed commands
-+ if (cmd.equalsIgnoreCase("stop") || cmd.equalsIgnoreCase("kick") || cmd.equalsIgnoreCase("op")
-+ || cmd.equalsIgnoreCase("deop") || cmd.equalsIgnoreCase("ban") || cmd.equalsIgnoreCase("ban-ip")
-+ || cmd.equalsIgnoreCase("pardon") || cmd.equalsIgnoreCase("pardon-ip") || cmd.equalsIgnoreCase("reload")) {
-+ return 0;
-+ }
-+
-+ // Handle vanilla commands;
-+ org.bukkit.command.Command commandBlockCommand = commandMap.getCommand(args[0]);
-+ if (sender.getWorld().getServer().getCommandBlockOverride(args[0])) {
-+ commandBlockCommand = commandMap.getCommand("minecraft:" + args[0]);
-+ }
-+ if (commandBlockCommand instanceof VanillaCommandWrapper) {
-+ command = command.trim();
-+ if (command.startsWith("/")) {
-+ command = command.substring(1);
-+ }
-+ String as[] = command.split(" ");
-+ as = VanillaCommandWrapper.dropFirstArgument(as);
-+ if (!sender.getWorld().getServer().getPermissionOverride(sender) && !((VanillaCommandWrapper) commandBlockCommand).testPermission(bSender)) {
-+ return 0;
-+ }
-+ return ((VanillaCommandWrapper) commandBlockCommand).dispatchVanillaCommand(bSender, sender, as);
-+ }
-+
-+ // Make sure this is a valid command
-+ if (commandMap.getCommand(args[0]) == null) {
-+ return 0;
-+ }
-+
-+ commands.add(args);
-+
-+ // Find positions of command block syntax, if any
-+ WorldServer[] prev = MinecraftServer.getServer().worldServer;
-+ MinecraftServer server = MinecraftServer.getServer();
-+ server.worldServer = new WorldServer[server.worlds.size()];
-+ server.worldServer[0] = (WorldServer) sender.getWorld();
-+ int bpos = 0;
-+ for (int pos = 1; pos < server.worldServer.length; pos++) {
-+ WorldServer world = server.worlds.get(bpos++);
-+ if (server.worldServer[0] == world) {
-+ pos--;
-+ continue;
-+ }
-+ server.worldServer[pos] = world;
-+ }
-+ try {
-+ ArrayList<String[]> newCommands = new ArrayList<String[]>();
-+ for (int i = 0; i < args.length; i++) {
-+ if (PlayerSelector.isPattern(args[i])) {
-+ for (int j = 0; j < commands.size(); j++) {
-+ newCommands.addAll(buildCommands(sender, commands.get(j), i));
-+ }
-+ ArrayList<String[]> temp = commands;
-+ commands = newCommands;
-+ newCommands = temp;
-+ newCommands.clear();
-+ }
-+ }
-+ } finally {
-+ MinecraftServer.getServer().worldServer = prev;
-+ }
-+
-+ int completed = 0;
-+
-+ // Now dispatch all of the commands we ended up with
-+ for (int i = 0; i < commands.size(); i++) {
-+ try {
-+ if (commandMap.dispatch(bSender, joiner.join(java.util.Arrays.asList(commands.get(i))))) {
-+ completed++;
-+ }
-+ } catch (Throwable exception) {
-+ if (sender.f() instanceof EntityMinecartCommandBlock) {
-+ MinecraftServer.getServer().server.getLogger().log(Level.WARNING, String.format("MinecartCommandBlock at (%d,%d,%d) failed to handle command", sender.getChunkCoordinates().getX(), sender.getChunkCoordinates().getY(), sender.getChunkCoordinates().getZ()), exception);
-+ } else if (sender instanceof CommandBlockListenerAbstract) {
-+ CommandBlockListenerAbstract listener = (CommandBlockListenerAbstract) sender;
-+ MinecraftServer.getServer().server.getLogger().log(Level.WARNING, String.format("CommandBlock at (%d,%d,%d) failed to handle command", listener.getChunkCoordinates().getX(), listener.getChunkCoordinates().getY(), listener.getChunkCoordinates().getZ()), exception);
-+ } else {
-+ MinecraftServer.getServer().server.getLogger().log(Level.WARNING, String.format("Unknown CommandBlock failed to handle command"), exception);
-+ }
-+ }
-+ }
-+
-+ return completed;
-+ }
-+
-+ 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);
-+
-+ if (players != null) {
-+ for (EntityPlayer player : players) {
-+ if (player.world != sender.getWorld()) {
-+ continue;
-+ }
-+ String[] command = args.clone();
-+ command[pos] = player.getName();
-+ commands.add(command);
-+ }
-+ }
-+
-+ return commands;
-+ }
-+
-+ public static CommandSender unwrapSender(ICommandListener listener) {
-+ org.bukkit.command.CommandSender sender = null;
-+ while (sender == null) {
-+ if (listener instanceof DedicatedServer) {
-+ sender = ((DedicatedServer) listener).console;
-+ } else if (listener instanceof RemoteControlCommandListener) {
-+ sender = ((RemoteControlCommandListener) listener).C_().remoteConsole;
-+ } else if (listener instanceof CommandBlockListenerAbstract) {
-+ sender = ((CommandBlockListenerAbstract) listener).sender;
-+ } else if (listener instanceof CustomFunctionData.CustomFunctionListener) {
-+ sender = ((CustomFunctionData.CustomFunctionListener) listener).sender;
-+ } else if (listener instanceof CommandListenerWrapper) {
-+ listener = ((CommandListenerWrapper) listener).base; // Search deeper
-+ } else if (VanillaCommandWrapper.lastSender != null) {
-+ sender = VanillaCommandWrapper.lastSender;
-+ } else if (listener.f() != null) {
-+ sender = listener.f().getBukkitEntity();
-+ } else {
-+ throw new RuntimeException("Unhandled executor " + listener.getClass().getSimpleName());
-+ }
-+ }
-+
-+ return sender;
-+ }
-+ // CraftBukkit end
-+
- public String getName() {
- return this.h;
- }
diff --git a/nms-patches/CommandDebug.patch b/nms-patches/CommandDebug.patch
index 68da6b1f..d982a483 100644
--- a/nms-patches/CommandDebug.patch
+++ b/nms-patches/CommandDebug.patch
@@ -1,32 +1,32 @@
--- a/net/minecraft/server/CommandDebug.java
+++ b/net/minecraft/server/CommandDebug.java
-@@ -34,6 +34,14 @@
+@@ -35,6 +35,14 @@
}
- public void execute(MinecraftServer minecraftserver, ICommandListener icommandlistener, String[] astring) throws CommandException {
+ private static int a(CommandListenerWrapper commandlistenerwrapper) throws CommandSyntaxException {
+ // CraftBukkit start - only allow use when enabled (so that no blank profile results occur)
-+ if (!minecraftserver.methodProfiler.ENABLED) {
-+ icommandlistener.sendMessage(new ChatComponentText("Vanilla debug profiling is disabled."));
-+ icommandlistener.sendMessage(new ChatComponentText("To enable, restart the server with `-DenableDebugMethodProfiler=true' before `-jar'."));
-+ icommandlistener.sendMessage(new ChatComponentText("Use `/timings' for plugin timings."));
-+ return;
++ if (!commandlistenerwrapper.getServer().methodProfiler.ENABLED) {
++ commandlistenerwrapper.sendFailureMessage(new ChatComponentText("Vanilla debug profiling is disabled."));
++ commandlistenerwrapper.sendFailureMessage(new ChatComponentText("To enable, restart the server with `-DenableDebugMethodProfiler=true' before `-jar'."));
++ commandlistenerwrapper.sendFailureMessage(new ChatComponentText("Use `/timings' for plugin timings."));
++ return 0;
+ }
+ // CraftBukkit end
- if (astring.length < 1) {
- throw new ExceptionUsage("commands.debug.usage", new Object[0]);
- } else {
-@@ -142,6 +150,13 @@
- }
+ MinecraftServer minecraftserver = commandlistenerwrapper.getServer();
+ MethodProfiler methodprofiler = minecraftserver.methodProfiler;
- public List<String> tabComplete(MinecraftServer minecraftserver, ICommandListener icommandlistener, String[] astring, @Nullable BlockPosition blockposition) {
-- return astring.length == 1 ? a(astring, new String[] { "start", "stop"}) : Collections.emptyList();
-+ return astring.length == 1 ? a(astring, new String[] { "start", "stop"}) : Collections.<String>emptyList(); // CraftBukkit - decompile error
-+ }
-+
-+ // CraftBukkit start - fix decompile error
-+ @Override
-+ public int compareTo(ICommand o) {
-+ return a((ICommand) o);
+@@ -48,6 +56,14 @@
}
-+ // CraftBukkit end
- }
+
+ private static int b(CommandListenerWrapper commandlistenerwrapper) throws CommandSyntaxException {
++ // CraftBukkit start - only allow use when enabled (so that no blank profile results occur)
++ if (!commandlistenerwrapper.getServer().methodProfiler.ENABLED) {
++ commandlistenerwrapper.sendFailureMessage(new ChatComponentText("Vanilla debug profiling is disabled."));
++ commandlistenerwrapper.sendFailureMessage(new ChatComponentText("To enable, restart the server with `-DenableDebugMethodProfiler=true' before `-jar'."));
++ commandlistenerwrapper.sendFailureMessage(new ChatComponentText("Use `/timings' for plugin timings."));
++ return 0;
++ }
++ // CraftBukkit end
+ MinecraftServer minecraftserver = commandlistenerwrapper.getServer();
+ MethodProfiler methodprofiler = minecraftserver.methodProfiler;
+
diff --git a/nms-patches/CommandDispatcher.patch b/nms-patches/CommandDispatcher.patch
new file mode 100644
index 00000000..f9842a44
--- /dev/null
+++ b/nms-patches/CommandDispatcher.patch
@@ -0,0 +1,189 @@
+--- a/net/minecraft/server/CommandDispatcher.java
++++ b/net/minecraft/server/CommandDispatcher.java
+@@ -26,12 +26,19 @@
+ import org.apache.logging.log4j.LogManager;
+ import org.apache.logging.log4j.Logger;
+
++// CraftBukkit start
++import com.google.common.base.Joiner;
++import org.apache.logging.log4j.Level;
++import org.bukkit.event.server.ServerCommandEvent;
++// CraftBukkit end
++
+ public class CommandDispatcher {
+
+ private static final Logger a = LogManager.getLogger();
+ private final com.mojang.brigadier.CommandDispatcher<CommandListenerWrapper> b = new com.mojang.brigadier.CommandDispatcher();
+
+- public CommandDispatcher(boolean flag) {
++ // CraftBukkit start
++ public final CommandDispatcher init(boolean flag) {
+ CommandAdvancement.a(this.b);
+ CommandExecute.a(this.b);
+ CommmandBossBar.a(this.b);
+@@ -100,6 +107,11 @@
+ this.b.findAmbiguities((commandnode, commandnode1, commandnode2, collection) -> {
+ CommandDispatcher.a.warn("Ambiguity between arguments {} and {} with inputs: {}", this.b.getPath(commandnode1), this.b.getPath(commandnode2), collection);
+ });
++ return this;
++ }
++
++ public CommandDispatcher() {
++ // CraftBukkit end
+ this.b.setConsumer((commandcontext, flag, i) -> {
+ ((CommandListenerWrapper) commandcontext.getSource()).a(commandcontext, flag, i);
+ });
+@@ -114,7 +126,58 @@
+
+ }
+
++ // CraftBukkit start
++ public int dispatchServerCommand(CommandListenerWrapper sender, String command) {
++ Joiner joiner = Joiner.on(" ");
++ if (command.startsWith("/")) {
++ command = command.substring(1);
++ }
++
++ ServerCommandEvent event = new ServerCommandEvent(sender.getBukkitSender(), command);
++ org.bukkit.Bukkit.getPluginManager().callEvent(event);
++ if (event.isCancelled()) {
++ return 0;
++ }
++ command = event.getCommand();
++
++ String[] args = command.split(" ");
++
++ String cmd = args[0];
++ if (cmd.startsWith("minecraft:")) cmd = cmd.substring("minecraft:".length());
++ if (cmd.startsWith("bukkit:")) cmd = cmd.substring("bukkit:".length());
++
++ // Block disallowed commands
++ if (cmd.equalsIgnoreCase("stop") || cmd.equalsIgnoreCase("kick") || cmd.equalsIgnoreCase("op")
++ || cmd.equalsIgnoreCase("deop") || cmd.equalsIgnoreCase("ban") || cmd.equalsIgnoreCase("ban-ip")
++ || cmd.equalsIgnoreCase("pardon") || cmd.equalsIgnoreCase("pardon-ip") || cmd.equalsIgnoreCase("reload")) {
++ return 0;
++ }
++
++ // Handle vanilla commands;
++ if (sender.getWorld().getServer().getCommandBlockOverride(args[0])) {
++ args[0] = "minecraft:" + args[0];
++ }
++
++ return this.a(sender, joiner.join(args));
++ }
++
+ public int a(CommandListenerWrapper commandlistenerwrapper, String s) {
++ // Some commands use the worldserver variable but we leave it full of null values,
++ // so we must temporarily populate it with the world of the commandsender
++ WorldServer[] prev = MinecraftServer.getServer().worldServer;
++ MinecraftServer server = MinecraftServer.getServer();
++ server.worldServer = new WorldServer[server.worlds.size()];
++ server.worldServer[0] = (WorldServer) commandlistenerwrapper.getWorld();
++ int bpos = 0;
++ for (int pos = 1; pos < server.worldServer.length; pos++) {
++ WorldServer world = server.worlds.get(bpos++);
++ if (server.worldServer[0] == world) {
++ pos--;
++ continue;
++ }
++ server.worldServer[pos] = world;
++ }
++ // CraftBukkit end
+ String s1 = s;
+
+ if (s.startsWith("/")) {
+@@ -126,7 +189,6 @@
+ byte b0;
+
+ try {
+- byte b1;
+ ChatComponentText chatcomponenttext;
+
+ try {
+@@ -135,54 +197,59 @@
+ return i;
+ } catch (CommandException commandexception) {
+ commandlistenerwrapper.sendFailureMessage(commandexception.a());
+- b1 = 0;
+- return b1;
++ b0 = 0;
++ return b0;
+ } catch (CommandSyntaxException commandsyntaxexception) {
+ commandlistenerwrapper.sendFailureMessage(ChatComponentUtils.a(commandsyntaxexception.getRawMessage()));
+ if (commandsyntaxexception.getInput() != null && commandsyntaxexception.getCursor() >= 0) {
+ int j = Math.min(commandsyntaxexception.getInput().length(), commandsyntaxexception.getCursor());
+- IChatBaseComponent ichatbasecomponent = (new ChatComponentText("")).a(EnumChatFormat.GRAY).a((chatmodifier) -> {
+- chatmodifier.setChatClickable(new ChatClickable(ChatClickable.EnumClickAction.SUGGEST_COMMAND, s));
+- });
+
++ chatcomponenttext = new ChatComponentText("");
+ if (j > 10) {
+- ichatbasecomponent.a("...");
++ chatcomponenttext.a("...");
+ }
+
+- ichatbasecomponent.a(commandsyntaxexception.getInput().substring(Math.max(0, j - 10), j));
++ chatcomponenttext.a(commandsyntaxexception.getInput().substring(Math.max(0, j - 10), j));
+ if (j < commandsyntaxexception.getInput().length()) {
+- IChatBaseComponent ichatbasecomponent1 = (new ChatComponentText(commandsyntaxexception.getInput().substring(j))).a(new EnumChatFormat[] { EnumChatFormat.RED, EnumChatFormat.UNDERLINE});
++ ChatComponentText chatcomponenttext1 = new ChatComponentText(commandsyntaxexception.getInput().substring(j));
+
+- ichatbasecomponent.addSibling(ichatbasecomponent1);
++ chatcomponenttext1.getChatModifier().setColor(EnumChatFormat.RED);
++ chatcomponenttext1.getChatModifier().setUnderline(Boolean.valueOf(true));
++ chatcomponenttext.addSibling(chatcomponenttext1);
+ }
+
+- ichatbasecomponent.addSibling((new ChatMessage("command.context.here", new Object[0])).a(new EnumChatFormat[] { EnumChatFormat.RED, EnumChatFormat.ITALIC}));
+- commandlistenerwrapper.sendFailureMessage(ichatbasecomponent);
++ ChatMessage chatmessage = new ChatMessage("command.context.here", new Object[0]);
++
++ chatmessage.getChatModifier().setItalic(Boolean.valueOf(true));
++ chatmessage.getChatModifier().setColor(EnumChatFormat.RED);
++ chatcomponenttext.addSibling(chatmessage);
++ chatcomponenttext.getChatModifier().setColor(EnumChatFormat.GRAY);
++ chatcomponenttext.getChatModifier().setChatClickable(new ChatClickable(ChatClickable.EnumClickAction.SUGGEST_COMMAND, s1));
++ commandlistenerwrapper.sendFailureMessage(chatcomponenttext);
+ }
+
+- b1 = 0;
+- return b1;
++ b0 = 0;
+ } catch (Exception exception) {
+- chatcomponenttext = new ChatComponentText;
+- }
++ ChatMessage chatmessage1 = new ChatMessage("command.failed", new Object[0]);
+
+- chatcomponenttext.<init>(exception.getMessage() == null ? exception.getClass().getName() : exception.getMessage());
+- ChatComponentText chatcomponenttext1 = chatcomponenttext;
++ chatcomponenttext = new ChatComponentText(exception.getMessage() == null ? exception.getClass().getName() : exception.getMessage());
++ if (CommandDispatcher.a.isDebugEnabled()) {
++ StackTraceElement[] astacktraceelement = exception.getStackTrace();
+
+- if (CommandDispatcher.a.isDebugEnabled()) {
+- StackTraceElement[] astacktraceelement = exception.getStackTrace();
+-
+- for (int k = 0; k < Math.min(astacktraceelement.length, 3); ++k) {
+- chatcomponenttext1.a("\n\n").a(astacktraceelement[k].getMethodName()).a("\n ").a(astacktraceelement[k].getFileName()).a(":").a(String.valueOf(astacktraceelement[k].getLineNumber()));
++ for (int k = 0; k < Math.min(astacktraceelement.length, 3); ++k) {
++ chatcomponenttext.a("\n\n" + astacktraceelement[k].getMethodName() + "\n " + astacktraceelement[k].getFileName() + ":" + astacktraceelement[k].getLineNumber());
++ }
+ }
+- }
+
+- commandlistenerwrapper.sendFailureMessage((new ChatMessage("command.failed", new Object[0])).a((chatmodifier) -> {
+- chatmodifier.setChatHoverable(new ChatHoverable(ChatHoverable.EnumHoverAction.SHOW_TEXT, ichatbasecomponent));
+- }));
+- b0 = 0;
++ chatmessage1.getChatModifier().setChatHoverable(new ChatHoverable(ChatHoverable.EnumHoverAction.SHOW_TEXT, chatcomponenttext));
++ commandlistenerwrapper.sendFailureMessage(chatmessage1);
++ byte b1 = 0;
++
++ return b1;
++ }
+ } finally {
+ commandlistenerwrapper.getServer().methodProfiler.e();
++ MinecraftServer.getServer().worldServer = prev; // CraftBukkit
+ }
+
+ return b0;
diff --git a/nms-patches/CommandExecute.patch b/nms-patches/CommandExecute.patch
deleted file mode 100644
index eef65e5b..00000000
--- a/nms-patches/CommandExecute.patch
+++ /dev/null
@@ -1,58 +0,0 @@
---- a/net/minecraft/server/CommandExecute.java
-+++ b/net/minecraft/server/CommandExecute.java
-@@ -4,6 +4,10 @@
- import java.util.Collections;
- import java.util.List;
- import javax.annotation.Nullable;
-+// CraftBukkit start
-+import org.bukkit.craftbukkit.command.ProxiedNativeCommandSender;
-+import org.bukkit.craftbukkit.command.VanillaCommandWrapper;
-+// CraftBukkit end
-
- public class CommandExecute extends CommandAbstract {
-
-@@ -59,26 +63,41 @@
- }
-
- String s = a(astring, b0);
-- CommandListenerWrapper commandlistenerwrapper = CommandListenerWrapper.a(icommandlistener).a(entity, new Vec3D(d0, d1, d2)).a(minecraftserver.worldServer[0].getGameRules().getBoolean("commandBlockOutput"));
-+ CommandListenerWrapper commandlistenerwrapper = CommandListenerWrapper.a(icommandlistener).a(entity, new Vec3D(d0, d1, d2)).a(minecraftserver.worlds.get(0).getGameRules().getBoolean("commandBlockOutput")); // CraftBukkit
- ICommandHandler icommandhandler = minecraftserver.getCommandHandler();
-
- try {
-- int i = icommandhandler.a(commandlistenerwrapper, s);
-+ // CraftBukkit start
-+ org.bukkit.command.CommandSender sender = CommandBlockListenerAbstract.unwrapSender(icommandlistener);
-+ int i = CommandBlockListenerAbstract.executeCommand(commandlistenerwrapper, new ProxiedNativeCommandSender(commandlistenerwrapper, sender, entity.getBukkitEntity()), s);
-+ // CraftBukkit end
-
- if (i < 1) {
- throw new CommandException("commands.execute.allInvocationsFailed", new Object[] { s});
- }
- } catch (Throwable throwable) {
-+ // CraftBukkit start
-+ if (throwable instanceof CommandException) {
-+ throw (CommandException) throwable;
-+ }
-+ // CraftBukkit end
- throw new CommandException("commands.execute.failed", new Object[] { s, entity.getName()});
- }
- }
- }
-
- public List<String> tabComplete(MinecraftServer minecraftserver, ICommandListener icommandlistener, String[] astring, @Nullable BlockPosition blockposition) {
-- return astring.length == 1 ? a(astring, minecraftserver.getPlayers()) : (astring.length > 1 && astring.length <= 4 ? a(astring, 1, blockposition) : (astring.length > 5 && astring.length <= 8 && "detect".equals(astring[4]) ? a(astring, 5, blockposition) : (astring.length == 9 && "detect".equals(astring[4]) ? a(astring, (Collection) Block.REGISTRY.keySet()) : Collections.emptyList())));
-+ return astring.length == 1 ? a(astring, minecraftserver.getPlayers()) : (astring.length > 1 && astring.length <= 4 ? a(astring, 1, blockposition) : (astring.length > 5 && astring.length <= 8 && "detect".equals(astring[4]) ? a(astring, 5, blockposition) : (astring.length == 9 && "detect".equals(astring[4]) ? a(astring, (Collection) Block.REGISTRY.keySet()) : Collections.<String>emptyList()))); // CraftBukkit - decompile error
- }
-
- public boolean isListStart(String[] astring, int i) {
- return i == 0;
- }
-+
-+ // CraftBukkit start - fix decompiler error
-+ @Override
-+ public int compareTo(ICommand o) {
-+ return a((ICommand) o);
-+ }
-+ // CraftBukkit end
- }
diff --git a/nms-patches/CommandGamemode.patch b/nms-patches/CommandGamemode.patch
index 1c227638..939a80d3 100644
--- a/nms-patches/CommandGamemode.patch
+++ b/nms-patches/CommandGamemode.patch
@@ -1,34 +1,15 @@
--- a/net/minecraft/server/CommandGamemode.java
+++ b/net/minecraft/server/CommandGamemode.java
-@@ -28,6 +28,12 @@
- EntityPlayer entityplayer = astring.length >= 2 ? b(minecraftserver, icommandlistener, astring[1]) : a(icommandlistener);
-
- entityplayer.a(enumgamemode);
-+ // CraftBukkit start - handle event cancelling the change
-+ if (entityplayer.playerInteractManager.getGameMode() != enumgamemode) {
-+ icommandlistener.sendMessage(new ChatComponentText("Failed to set the gamemode of '" + entityplayer.getName() + "'"));
-+ return;
-+ }
-+ // CraftBukkit end
- ChatMessage chatmessage = new ChatMessage("gameMode." + enumgamemode.b(), new Object[0]);
-
- if (icommandlistener.getWorld().getGameRules().getBoolean("sendCommandFeedback")) {
-@@ -50,10 +56,17 @@
- }
-
- public List<String> tabComplete(MinecraftServer minecraftserver, ICommandListener icommandlistener, String[] astring, @Nullable BlockPosition blockposition) {
-- return astring.length == 1 ? a(astring, new String[] { "survival", "creative", "adventure", "spectator"}) : (astring.length == 2 ? a(astring, minecraftserver.getPlayers()) : Collections.emptyList());
-+ return astring.length == 1 ? a(astring, new String[] { "survival", "creative", "adventure", "spectator"}) : (astring.length == 2 ? a(astring, minecraftserver.getPlayers()) : Collections.<String>emptyList()); // CraftBukkit - decompile error
- }
-
- public boolean isListStart(String[] astring, int i) {
- return i == 1;
- }
-+
-+ // CraftBukkit start - fix decompiler error
-+ @Override
-+ public int compareTo(ICommand o) {
-+ return a((ICommand) o);
-+ }
-+ // CraftBukkit end
- }
+@@ -57,6 +57,12 @@
+
+ if (entityplayer.playerInteractManager.getGameMode() != enumgamemode) {
+ entityplayer.a(enumgamemode);
++ // CraftBukkit start - handle event cancelling the change
++ if (entityplayer.playerInteractManager.getGameMode() != enumgamemode) {
++ commandcontext.getSource().sendFailureMessage(new ChatComponentText("Failed to set the gamemode of '" + entityplayer.getName() + "'"));
++ continue;
++ }
++ // CraftBukkit end
+ a((CommandListenerWrapper) commandcontext.getSource(), entityplayer, enumgamemode);
+ ++i;
+ }
diff --git a/nms-patches/CommandGamerule.patch b/nms-patches/CommandGamerule.patch
deleted file mode 100644
index 6de41819..00000000
--- a/nms-patches/CommandGamerule.patch
+++ /dev/null
@@ -1,23 +0,0 @@
---- a/net/minecraft/server/CommandGamerule.java
-+++ b/net/minecraft/server/CommandGamerule.java
-@@ -23,7 +23,7 @@
- }
-
- public void execute(MinecraftServer minecraftserver, ICommandListener icommandlistener, String[] astring) throws CommandException {
-- GameRules gamerules = this.a(minecraftserver);
-+ GameRules gamerules = icommandlistener.getWorld().getGameRules(); // CraftBukkit - Use current world
- String s = astring.length > 0 ? astring[0] : "";
- String s1 = astring.length > 1 ? a(astring, 1) : "";
-
-@@ -92,4 +92,11 @@
- private GameRules a(MinecraftServer minecraftserver) {
- return minecraftserver.getWorldServer(0).getGameRules();
- }
-+
-+ // CraftBukkit start - fix decompile error
-+ @Override
-+ public int compareTo(ICommand o) {
-+ return a((ICommand) o);
-+ }
-+ // CraftBukkit end
- }
diff --git a/nms-patches/CommandListenerWrapper.patch b/nms-patches/CommandListenerWrapper.patch
new file mode 100644
index 00000000..0f8d1c9d
--- /dev/null
+++ b/nms-patches/CommandListenerWrapper.patch
@@ -0,0 +1,46 @@
+--- a/net/minecraft/server/CommandListenerWrapper.java
++++ b/net/minecraft/server/CommandListenerWrapper.java
+@@ -7,6 +7,7 @@
+ import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
+ import com.mojang.brigadier.suggestion.Suggestions;
+ import com.mojang.brigadier.suggestion.SuggestionsBuilder;
++import com.mojang.brigadier.tree.CommandNode;
+ import java.util.Collection;
+ import java.util.Collections;
+ import java.util.Iterator;
+@@ -31,9 +32,10 @@
+ private final ResultConsumer<CommandListenerWrapper> l;
+ private final ArgumentAnchor.Anchor m;
+ private final Vec2F n;
++ public CommandNode currentCommand; // CraftBukkit
+
+ public CommandListenerWrapper(ICommandListener icommandlistener, Vec3D vec3d, Vec2F vec2f, WorldServer worldserver, int i, String s, IChatBaseComponent ichatbasecomponent, MinecraftServer minecraftserver, @Nullable Entity entity) {
+- this(icommandlistener, vec3d, vec2f, worldserver, i, s, ichatbasecomponent, minecraftserver, entity, false, (commandcontext, flag, i) -> {
++ this(icommandlistener, vec3d, vec2f, worldserver, i, s, ichatbasecomponent, minecraftserver, entity, false, (commandcontext, flag, ix) -> { // CraftBukkit - decompile error
+ }, ArgumentAnchor.Anchor.FEET);
+ }
+
+@@ -119,6 +121,12 @@
+ }
+
+ public boolean hasPermission(int i) {
++ // CraftBukkit start
++ if (currentCommand != null) {
++ return this.f >= i || getBukkitSender().hasPermission(org.bukkit.craftbukkit.command.VanillaCommandWrapper.getPermission(currentCommand));
++ }
++ // CraftBukkit end
++
+ return this.f >= i;
+ }
+
+@@ -232,4 +240,10 @@
+ public Collection<ICompletionProvider.a> a(boolean flag) {
+ return Collections.singleton(ICompletionProvider.a.b);
+ }
++
++ // CraftBukkit start
++ public org.bukkit.command.CommandSender getBukkitSender() {
++ return base.getBukkitSender(this);
++ }
++ // CraftBukkit end
+ }
diff --git a/nms-patches/CommandSpreadPlayers.patch b/nms-patches/CommandSpreadPlayers.patch
index 33279985..652eaa86 100644
--- a/nms-patches/CommandSpreadPlayers.patch
+++ b/nms-patches/CommandSpreadPlayers.patch
@@ -1,50 +1,32 @@
--- a/net/minecraft/server/CommandSpreadPlayers.java
+++ b/net/minecraft/server/CommandSpreadPlayers.java
-@@ -240,9 +240,16 @@
- }
-
- public List<String> tabComplete(MinecraftServer minecraftserver, ICommandListener icommandlistener, String[] astring, @Nullable BlockPosition blockposition) {
-- return astring.length >= 1 && astring.length <= 2 ? b(astring, 0, blockposition) : Collections.emptyList();
-+ return astring.length >= 1 && astring.length <= 2 ? b(astring, 0, blockposition) : Collections.<String>emptyList(); // CraftBukkit - decompile error
- }
-
-+ // CraftBukkit start - fix decompile error
-+ @Override
-+ public int compareTo(ICommand o) {
-+ return a(o);
-+ }
-+ // CraftBukkit end
-+
- static class Location2D {
-
- double a;
-@@ -309,7 +316,7 @@
+@@ -269,7 +269,7 @@
}
blockposition = blockposition.down();
-- } while (world.getType(blockposition).getMaterial() == Material.AIR);
-+ } while (getType(world, blockposition).getMaterial() == Material.AIR); // CraftBukkit
+- } while (iblockaccess.getType(blockposition).isAir());
++ } while (getType(iblockaccess, blockposition).isAir()); // CraftBukkit
return blockposition.getY() + 1;
}
-@@ -325,7 +332,7 @@
+@@ -285,7 +285,7 @@
}
blockposition = blockposition.down();
-- material = world.getType(blockposition).getMaterial();
-+ material = getType(world, blockposition).getMaterial(); // CraftBukkit
- } while (material == Material.AIR);
+- iblockdata = iblockaccess.getType(blockposition);
++ iblockdata = getType(iblockaccess, blockposition); // CraftBukkit
+ } while (iblockdata.isAir());
- return !material.isLiquid() && material != Material.FIRE;
-@@ -335,5 +342,12 @@
+ Material material = iblockdata.getMaterial();
+@@ -297,5 +297,12 @@
this.a = MathHelper.a(random, d0, d2);
this.b = MathHelper.a(random, d1, d3);
}
+
+ // CraftBukkit start - add a version of getType which force loads chunks
-+ private static IBlockData getType(World world, BlockPosition position) {
-+ ((ChunkProviderServer) world.chunkProvider).getChunkAt(position.getX() >> 4, position.getZ() >> 4);
-+ return world.getType(position);
++ private static IBlockData getType(IBlockAccess iblockaccess, BlockPosition position) {
++ ((ChunkProviderServer) ((World) iblockaccess).chunkProvider).getChunkAt(position.getX() >> 4, position.getZ() >> 4);
++ return iblockaccess.getType(position);
+ }
+ // CraftBukkit end
}
diff --git a/nms-patches/CommandTeleport.patch b/nms-patches/CommandTeleport.patch
index 003cc6c1..3b5763e9 100644
--- a/nms-patches/CommandTeleport.patch
+++ b/nms-patches/CommandTeleport.patch
@@ -1,23 +1,14 @@
--- a/net/minecraft/server/CommandTeleport.java
+++ b/net/minecraft/server/CommandTeleport.java
-@@ -69,7 +69,7 @@
+@@ -116,9 +116,9 @@
+ if (entity instanceof EntityPlayer) {
+ entity.stopRiding();
+ if (worldserver == entity.world) {
+- ((EntityPlayer) entity).playerConnection.a(d0, d1, d2, f, f1, set);
++ ((EntityPlayer) entity).playerConnection.a(d0, d1, d2, f, f1, set, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.COMMAND); // CraftBukkit
+ } else {
+- ((EntityPlayer) entity).a(worldserver, d0, d1, d2, f, f1);
++ ((EntityPlayer) entity).a(worldserver, d0, d1, d2, f, f1, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.COMMAND); // CraftBukkit
}
- entity.stopRiding();
-- ((EntityPlayer) entity).playerConnection.a(commandabstract_commandnumber.a(), commandabstract_commandnumber1.a(), commandabstract_commandnumber2.a(), f, f1, enumset);
-+ ((EntityPlayer) entity).playerConnection.a(commandabstract_commandnumber.a(), commandabstract_commandnumber1.a(), commandabstract_commandnumber2.a(), f, f1, enumset, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.COMMAND); // CraftBukkit
entity.setHeadRotation(f);
- } else {
- float f2 = (float) MathHelper.g(commandabstract_commandnumber3.a());
-@@ -94,4 +94,11 @@
- public boolean isListStart(String[] astring, int i) {
- return i == 0;
- }
-+
-+ // CraftBukkit start - fix decompile error
-+ @Override
-+ public int compareTo(ICommand o) {
-+ return a((ICommand) o);
-+ }
-+ // CraftBukkit end
- }
diff --git a/nms-patches/CommandTp.patch b/nms-patches/CommandTp.patch
deleted file mode 100644
index 603af708..00000000
--- a/nms-patches/CommandTp.patch
+++ /dev/null
@@ -1,45 +0,0 @@
---- a/net/minecraft/server/CommandTp.java
-+++ b/net/minecraft/server/CommandTp.java
-@@ -53,17 +53,11 @@
- } else {
- Entity entity = c(minecraftserver, icommandlistener, astring[astring.length - 1]);
-
-- if (entity.world != ((Entity) object).world) {
-- throw new CommandException("commands.tp.notSameDimension", new Object[0]);
-- } else {
-- ((Entity) object).stopRiding();
-- if (object instanceof EntityPlayer) {
-- ((EntityPlayer) object).playerConnection.a(entity.locX, entity.locY, entity.locZ, entity.yaw, entity.pitch);
-- } else {
-- ((Entity) object).setPositionRotation(entity.locX, entity.locY, entity.locZ, entity.yaw, entity.pitch);
-- }
--
-+ // CraftBukkit Start
-+ // Use Bukkit teleport method in all cases. It has cross dimensional handling, events
-+ if (((Entity) object).getBukkitEntity().teleport(entity.getBukkitEntity(), org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.COMMAND)) {
- a(icommandlistener, (ICommand) this, "commands.tp.success", new Object[] { ((Entity) object).getName(), entity.getName()});
-+ // CraftBukkit End
- }
- }
- }
-@@ -107,7 +101,7 @@
- }
-
- entity.stopRiding();
-- ((EntityPlayer) entity).playerConnection.a(commandabstract_commandnumber.b(), commandabstract_commandnumber1.b(), commandabstract_commandnumber2.b(), f, f1, enumset);
-+ ((EntityPlayer) entity).playerConnection.a(commandabstract_commandnumber.b(), commandabstract_commandnumber1.b(), commandabstract_commandnumber2.b(), f, f1, enumset, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.COMMAND); // CraftBukkit
- entity.setHeadRotation(f);
- } else {
- float f2 = (float) MathHelper.g(commandabstract_commandnumber3.a());
-@@ -132,4 +126,11 @@
- public boolean isListStart(String[] astring, int i) {
- return i == 0;
- }
-+
-+ // CraftBukkit start - fix decompile error
-+ @Override
-+ public int compareTo(ICommand o) {
-+ return a((ICommand) o);
-+ }
-+ // CraftBukkit end
- }
diff --git a/nms-patches/Container.patch b/nms-patches/Container.patch
index 26daef63..ef86d902 100644
--- a/nms-patches/Container.patch
+++ b/nms-patches/Container.patch
@@ -96,7 +96,7 @@
+ // CraftBukkit end
}
- this.d();
+ this.c();
@@ -165,8 +225,11 @@
if (i == -999) {
if (!playerinventory.getCarried().isEmpty()) {
@@ -126,11 +126,11 @@
}
}
} else if (inventoryclicktype == InventoryClickType.SWAP && j >= 0 && j < 9) {
-@@ -564,6 +636,7 @@
- inventorycraftresult.a(irecipe);
- itemstack = irecipe.craftItem(inventorycrafting);
+@@ -567,6 +639,7 @@
+ if (inventorycraftresult.a(world, entityplayer, irecipe) && irecipe != null) {
+ itemstack = irecipe.craftItem(iinventory);
}
-+ itemstack = org.bukkit.craftbukkit.event.CraftEventFactory.callPreCraftEvent(inventorycrafting, itemstack, getBukkitView(), false); // CraftBukkit
++ itemstack = org.bukkit.craftbukkit.event.CraftEventFactory.callPreCraftEvent(iinventory, inventorycraftresult, itemstack, getBukkitView(), false); // CraftBukkit
inventorycraftresult.setItem(0, itemstack);
entityplayer.playerConnection.sendPacket(new PacketPlayOutSetSlot(this.windowId, 0, itemstack));
diff --git a/nms-patches/ContainerAnvil.patch b/nms-patches/ContainerAnvil.patch
index e32f857e..0f9f7d3a 100644
--- a/nms-patches/ContainerAnvil.patch
+++ b/nms-patches/ContainerAnvil.patch
@@ -26,7 +26,7 @@
this.j = blockposition;
this.i = world;
this.m = entityhuman;
-@@ -110,7 +120,7 @@
+@@ -111,7 +121,7 @@
byte b1 = 0;
if (itemstack.isEmpty()) {
@@ -35,25 +35,25 @@
this.levelCost = 0;
} else {
ItemStack itemstack1 = itemstack.cloneItemStack();
-@@ -128,7 +138,7 @@
- if (itemstack1.f() && itemstack1.getItem().a(itemstack, itemstack2)) {
- k = Math.min(itemstack1.i(), itemstack1.k() / 4);
+@@ -129,7 +139,7 @@
+ if (itemstack1.e() && itemstack1.getItem().a(itemstack, itemstack2)) {
+ k = Math.min(itemstack1.getDamage(), itemstack1.h() / 4);
if (k <= 0) {
- this.g.setItem(0, ItemStack.a);
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.a); // CraftBukkit
this.levelCost = 0;
return;
}
-@@ -143,7 +153,7 @@
+@@ -144,7 +154,7 @@
this.k = l;
} else {
- if (!flag && (itemstack1.getItem() != itemstack2.getItem() || !itemstack1.f())) {
+ if (!flag && (itemstack1.getItem() != itemstack2.getItem() || !itemstack1.e())) {
- this.g.setItem(0, ItemStack.a);
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.a); // CraftBukkit
this.levelCost = 0;
return;
}
-@@ -236,7 +246,7 @@
+@@ -237,7 +247,7 @@
}
if (flag2 && !flag1) {
@@ -62,7 +62,7 @@
this.levelCost = 0;
return;
}
-@@ -283,7 +293,7 @@
+@@ -284,7 +294,7 @@
EnchantmentManager.a(map, itemstack1);
}
@@ -71,17 +71,17 @@
this.b();
}
}
-@@ -301,6 +311,7 @@
+@@ -302,6 +312,7 @@
}
public boolean canUse(EntityHuman entityhuman) {
+ if (!this.checkReachable) return true; // CraftBukkit
- 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;
+ return !this.i.getType(this.j).a(TagsBlock.x) ? false : entityhuman.d((double) this.j.getX() + 0.5D, (double) this.j.getY() + 0.5D, (double) this.j.getZ() + 0.5D) <= 64.0D;
}
-@@ -356,4 +367,33 @@
+@@ -357,4 +368,33 @@
- this.e();
+ this.d();
}
+
+ // CraftBukkit start
diff --git a/nms-patches/ContainerEnchantTable.patch b/nms-patches/ContainerEnchantTable.patch
index 6b4c4a70..a6d9ffd1 100644
--- a/nms-patches/ContainerEnchantTable.patch
+++ b/nms-patches/ContainerEnchantTable.patch
@@ -1,6 +1,6 @@
--- a/net/minecraft/server/ContainerEnchantTable.java
+++ b/net/minecraft/server/ContainerEnchantTable.java
-@@ -3,6 +3,19 @@
+@@ -3,6 +3,21 @@
import java.util.List;
import java.util.Random;
@@ -8,9 +8,11 @@
+import java.util.Collections;
+import java.util.Map;
+import org.bukkit.Location;
++import org.bukkit.NamespacedKey;
+import org.bukkit.craftbukkit.inventory.CraftInventoryEnchanting;
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
++import org.bukkit.craftbukkit.util.CraftNamespacedKey;
+import org.bukkit.enchantments.EnchantmentOffer;
+import org.bukkit.event.enchantment.EnchantItemEvent;
+import org.bukkit.event.enchantment.PrepareItemEnchantEvent;
@@ -19,8 +21,8 @@
+
public class ContainerEnchantTable extends Container {
- public IInventory enchantSlots = new InventorySubcontainer("Enchant", true, 2) {
-@@ -14,6 +27,13 @@
+ public IInventory enchantSlots = new InventorySubcontainer(new ChatComponentText("Enchant"), 2) {
+@@ -14,6 +29,13 @@
super.update();
ContainerEnchantTable.this.a((IInventory) this);
}
@@ -34,7 +36,7 @@
};
public World world;
private final BlockPosition position;
-@@ -22,6 +42,10 @@
+@@ -22,6 +44,10 @@
public int[] costs = new int[3];
public int[] h = new int[] { -1, -1, -1};
public int[] i = new int[] { -1, -1, -1};
@@ -45,7 +47,7 @@
public ContainerEnchantTable(PlayerInventory playerinventory, World world, BlockPosition blockposition) {
this.world = world;
-@@ -54,6 +78,9 @@
+@@ -54,6 +80,9 @@
this.a(new Slot(playerinventory, i, 8 + i * 18, 142));
}
@@ -55,7 +57,7 @@
}
protected void c(ICrafting icrafting) {
-@@ -90,7 +117,7 @@
+@@ -90,7 +119,7 @@
ItemStack itemstack = iinventory.getItem(0);
int i;
@@ -64,7 +66,14 @@
if (!this.world.isClientSide) {
i = 0;
-@@ -152,6 +179,41 @@
+@@ -146,12 +175,47 @@
+ if (list != null && !list.isEmpty()) {
+ WeightedRandomEnchant weightedrandomenchant = (WeightedRandomEnchant) list.get(this.l.nextInt(list.size()));
+
+- this.h[j] = Enchantment.enchantments.a((Object) weightedrandomenchant.enchantment);
++ this.h[j] = Enchantment.enchantments.a(weightedrandomenchant.enchantment); // CraftBukkit - decompile error
+ this.i[j] = weightedrandomenchant.level;
+ }
}
}
@@ -72,7 +81,7 @@
+ CraftItemStack item = CraftItemStack.asCraftMirror(itemstack);
+ org.bukkit.enchantments.EnchantmentOffer[] offers = new EnchantmentOffer[3];
+ for (j = 0; j < 3; ++j) {
-+ org.bukkit.enchantments.Enchantment enchantment = (this.h[j] >= 0) ? org.bukkit.enchantments.Enchantment.getById(this.h[j]) : null;
++ org.bukkit.enchantments.Enchantment enchantment = (this.h[j] >= 0) ? org.bukkit.enchantments.Enchantment.getByKey(CraftNamespacedKey.fromMinecraft(Enchantment.getId(Enchantment.enchantments.getId(this.h[j])))) : null;
+ offers[j] = (enchantment != null) ? new EnchantmentOffer(enchantment, this.i[j], this.costs[j]) : null;
+ }
+
@@ -93,7 +102,7 @@
+ EnchantmentOffer offer = event.getOffers()[j];
+ if (offer != null) {
+ this.costs[j] = offer.getCost();
-+ this.h[j] = offer.getEnchantment().getId();
++ this.h[j] = Enchantment.enchantments.a(Enchantment.fromId(CraftNamespacedKey.toMinecraft(offer.getEnchantment().getKey())));
+ this.i[j] = offer.getEnchantmentLevel();
+ } else {
+ this.costs[j] = 0;
@@ -106,7 +115,7 @@
this.b();
}
} else {
-@@ -176,25 +238,52 @@
+@@ -176,25 +240,53 @@
if (!this.world.isClientSide) {
List list = this.a(itemstack, i, this.costs[i]);
@@ -119,7 +128,7 @@
+ Map<org.bukkit.enchantments.Enchantment, Integer> enchants = new java.util.HashMap<org.bukkit.enchantments.Enchantment, Integer>();
+ for (Object obj : list) {
+ WeightedRandomEnchant instance = (WeightedRandomEnchant) obj;
-+ enchants.put(org.bukkit.enchantments.Enchantment.getById(Enchantment.getId(instance.enchantment)), instance.level);
++ enchants.put(org.bukkit.enchantments.Enchantment.getByKey(CraftNamespacedKey.fromMinecraft(Enchantment.getId(instance.enchantment))), instance.level);
+ }
+ CraftItemStack item = CraftItemStack.asCraftMirror(itemstack);
+
@@ -141,8 +150,9 @@
+ for (Map.Entry<org.bukkit.enchantments.Enchantment, Integer> entry : event.getEnchantsToAdd().entrySet()) {
+ try {
+ if (flag) {
-+ int enchantId = entry.getKey().getId();
-+ if (Enchantment.c(enchantId) == null) {
++ NamespacedKey enchantId = entry.getKey().getKey();
++ Enchantment nms = Enchantment.fromId(CraftNamespacedKey.toMinecraft(enchantId));
++ if (nms == null) {
+ continue;
+ }
@@ -150,7 +160,7 @@
- ItemEnchantedBook.a(itemstack, weightedrandomenchant);
- } else {
- itemstack.addEnchantment(weightedrandomenchant.enchantment, weightedrandomenchant.level);
-+ WeightedRandomEnchant weightedrandomenchant = new WeightedRandomEnchant(Enchantment.c(enchantId), entry.getValue());
++ WeightedRandomEnchant weightedrandomenchant = new WeightedRandomEnchant(nms, entry.getValue());
+ ItemEnchantedBook.a(itemstack, weightedrandomenchant);
+ } else {
+ item.addUnsafeEnchantment(entry.getKey(), entry.getValue());
@@ -167,7 +177,7 @@
if (!entityhuman.abilities.canInstantlyBuild) {
itemstack1.subtract(j);
if (itemstack1.isEmpty()) {
-@@ -233,12 +322,18 @@
+@@ -233,12 +325,18 @@
public void b(EntityHuman entityhuman) {
super.b(entityhuman);
@@ -186,7 +196,7 @@
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;
}
-@@ -291,4 +386,17 @@
+@@ -291,4 +389,17 @@
return itemstack;
}
diff --git a/nms-patches/ContainerFurnace.patch b/nms-patches/ContainerFurnace.patch
index 51ddf578..320e3f3d 100644
--- a/nms-patches/ContainerFurnace.patch
+++ b/nms-patches/ContainerFurnace.patch
@@ -1,19 +1,19 @@
--- a/net/minecraft/server/ContainerFurnace.java
+++ b/net/minecraft/server/ContainerFurnace.java
-@@ -1,5 +1,10 @@
+@@ -1,6 +1,10 @@
package net.minecraft.server;
+ import java.util.Iterator;
+// CraftBukkit start
+import org.bukkit.craftbukkit.inventory.CraftInventoryFurnace;
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
+// CraftBukkit end
-+
- public class ContainerFurnace extends Container {
- private final IInventory furnace;
-@@ -8,11 +13,28 @@
- private int h;
+ public class ContainerFurnace extends ContainerRecipeBook {
+
+@@ -11,12 +15,29 @@
private int i;
+ private int j;
+ // CraftBukkit start
+ private CraftInventoryView bukkitEntity = null;
@@ -33,6 +33,7 @@
+
public ContainerFurnace(PlayerInventory playerinventory, IInventory iinventory) {
this.furnace = iinventory;
+ this.f = playerinventory.player.world;
this.a(new Slot(iinventory, 0, 56, 17));
this.a((Slot) (new SlotFurnaceFuel(iinventory, 1, 56, 53)));
this.a((Slot) (new SlotFurnaceResult(playerinventory.player, iinventory, 2, 116, 35)));
@@ -40,7 +41,7 @@
int i;
-@@ -63,6 +85,7 @@
+@@ -95,6 +116,7 @@
}
public boolean canUse(EntityHuman entityhuman) {
diff --git a/nms-patches/ContainerPlayer.patch b/nms-patches/ContainerPlayer.patch
index feaa5bcd..40595e49 100644
--- a/nms-patches/ContainerPlayer.patch
+++ b/nms-patches/ContainerPlayer.patch
@@ -8,10 +8,10 @@
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
+// CraftBukkit end
+
- public class ContainerPlayer extends Container {
+ public class ContainerPlayer extends ContainerRecipeBook {
- private static final EnumItemSlot[] h = new EnumItemSlot[] { EnumItemSlot.HEAD, EnumItemSlot.CHEST, EnumItemSlot.LEGS, EnumItemSlot.FEET};
-@@ -7,10 +12,20 @@
+ private static final String[] h = new String[] { "item/empty_armor_slot_boots", "item/empty_armor_slot_leggings", "item/empty_armor_slot_chestplate", "item/empty_armor_slot_helmet"};
+@@ -8,10 +13,20 @@
public InventoryCraftResult resultInventory = new InventoryCraftResult();
public boolean g;
private final EntityHuman owner;
@@ -32,27 +32,9 @@
this.a((Slot) (new SlotResult(playerinventory.player, this.craftInventory, this.resultInventory, 0, 154, 28)));
int i;
-@@ -23,7 +38,7 @@
- }
-
- for (i = 0; i < 4; ++i) {
-- final EnumItemSlot enumitemslot = ContainerPlayer.h[i];
-+ final EnumItemSlot enumitemslot1 = ContainerPlayer.h[i];
-
- this.a(new Slot(playerinventory, 36 + (3 - i), 8, 8 + i * 18) {
- public int getMaxStackSize() {
-@@ -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) {
-@@ -141,4 +156,17 @@
- public boolean a(ItemStack itemstack, Slot slot) {
- return slot.inventory != this.resultInventory && super.a(itemstack, slot);
+@@ -167,4 +182,17 @@
+ public int g() {
+ return this.craftInventory.n();
}
+
+ // CraftBukkit start
diff --git a/nms-patches/ContainerWorkbench.patch b/nms-patches/ContainerWorkbench.patch
index 153d2c64..f5dd0d2d 100644
--- a/nms-patches/ContainerWorkbench.patch
+++ b/nms-patches/ContainerWorkbench.patch
@@ -8,7 +8,7 @@
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
+// CraftBukkit end
+
- public class ContainerWorkbench extends Container {
+ public class ContainerWorkbench extends ContainerRecipeBook {
- public InventoryCrafting craftInventory = new InventoryCrafting(this, 3, 3);
- public InventoryCraftResult resultInventory = new InventoryCraftResult();
@@ -32,7 +32,7 @@
this.g = world;
this.h = blockposition;
this.i = playerinventory.player;
-@@ -47,6 +62,7 @@
+@@ -60,6 +75,7 @@
}
public boolean canUse(EntityHuman entityhuman) {
@@ -40,9 +40,9 @@
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;
}
-@@ -100,4 +116,17 @@
- public boolean a(ItemStack itemstack, Slot slot) {
- return slot.inventory != this.resultInventory && super.a(itemstack, slot);
+@@ -125,4 +141,17 @@
+ public int g() {
+ return this.craftInventory.n();
}
+
+ // CraftBukkit start
diff --git a/nms-patches/CraftingManager.patch b/nms-patches/CraftingManager.patch
index a619d68f..c788f891 100644
--- a/nms-patches/CraftingManager.patch
+++ b/nms-patches/CraftingManager.patch
@@ -1,57 +1,32 @@
--- a/net/minecraft/server/CraftingManager.java
+++ b/net/minecraft/server/CraftingManager.java
-@@ -34,6 +34,7 @@
-
- public static boolean init() {
- try {
-+ CraftingManager.c = 0; // Reset recipe ID count
- a("armordye", new RecipeArmorDye());
- a("bookcloning", new RecipeBookClone());
- a("mapcloning", new RecipeMapClone());
-@@ -147,6 +148,7 @@
- if (CraftingManager.recipes.d(minecraftkey)) {
- throw new IllegalStateException("Duplicate recipe ignored with ID " + minecraftkey);
- } else {
-+ irecipe.setKey(minecraftkey); // CraftBukkit
- CraftingManager.recipes.a(CraftingManager.c++, minecraftkey, irecipe);
- }
- }
-@@ -158,12 +160,14 @@
+@@ -96,12 +96,14 @@
do {
if (!iterator.hasNext()) {
-+ inventorycrafting.currentRecipe = null; // CraftBukkit - Clear recipe when no recipe is found
++ iinventory.setCurrentRecipe(null); // CraftBukkit - Clear recipe when no recipe is found
return ItemStack.a;
}
irecipe = (IRecipe) iterator.next();
- } while (!irecipe.a(inventorycrafting, world));
+ } while (!irecipe.a(iinventory, world));
-+ inventorycrafting.currentRecipe = irecipe; // CraftBukkit
- return irecipe.craftItem(inventorycrafting);
++ iinventory.setCurrentRecipe(irecipe); // CraftBukkit
+ return irecipe.craftItem(iinventory);
}
-@@ -175,12 +179,14 @@
+@@ -113,12 +115,14 @@
do {
if (!iterator.hasNext()) {
-+ inventorycrafting.currentRecipe = null; // CraftBukkit - Clear recipe when no recipe is found
++ iinventory.setCurrentRecipe(null); // CraftBukkit - Clear recipe when no recipe is found
return null;
}
irecipe = (IRecipe) iterator.next();
- } while (!irecipe.a(inventorycrafting, world));
+ } while (!irecipe.a(iinventory, world));
-+ inventorycrafting.currentRecipe = irecipe; // CraftBukkit
++ iinventory.setCurrentRecipe(irecipe); // CraftBukkit
return irecipe;
}
-@@ -210,7 +216,7 @@
- }
-
- public static int a(IRecipe irecipe) {
-- return CraftingManager.recipes.a((Object) irecipe);
-+ return CraftingManager.recipes.a(irecipe); // CraftBukkit - decompile error
- }
-
- @Nullable
diff --git a/nms-patches/CrashReport.patch b/nms-patches/CrashReport.patch
index de74312b..7e9cb276 100644
--- a/nms-patches/CrashReport.patch
+++ b/nms-patches/CrashReport.patch
@@ -1,8 +1,8 @@
--- a/net/minecraft/server/CrashReport.java
+++ b/net/minecraft/server/CrashReport.java
-@@ -125,6 +125,7 @@
- return this.a();
- }
+@@ -63,6 +63,7 @@
+
+ return String.format("%d total; %s", new Object[] { Integer.valueOf(list.size()), list.stream().collect(Collectors.joining(" "))});
});
+ this.d.a("CraftBukkit Information", (CrashReportCallable) new org.bukkit.craftbukkit.CraftCrashReport()); // CraftBukkit
}
diff --git a/nms-patches/CustomFunction.patch b/nms-patches/CustomFunction.patch
index a01167d4..034c3546 100644
--- a/nms-patches/CustomFunction.patch
+++ b/nms-patches/CustomFunction.patch
@@ -1,19 +1,11 @@
--- a/net/minecraft/server/CustomFunction.java
+++ b/net/minecraft/server/CustomFunction.java
-@@ -122,7 +122,15 @@
- }
+@@ -45,7 +45,7 @@
+ }
- public void a(CustomFunctionData customfunctiondata, ICommandListener icommandlistener, ArrayDeque<CustomFunctionData.a> arraydeque, int i) {
-- customfunctiondata.a().a(icommandlistener, this.a);
-+ // CraftBukkit start
-+ org.bukkit.command.CommandSender sender;
-+ if (icommandlistener instanceof CustomFunctionData.CustomFunctionListener) {
-+ sender = ((CustomFunctionData.CustomFunctionListener) icommandlistener).sender;
-+ } else {
-+ sender = CommandBlockListenerAbstract.unwrapSender(icommandlistener);
-+ }
-+ CommandBlockListenerAbstract.executeSafely(icommandlistener, sender, this.a);
-+ // CraftBukkit end
- }
+ try {
+- ParseResults parseresults = customfunctiondata.a().getCommandDispatcher().a().parse(s, customfunctiondata.f());
++ ParseResults parseresults = customfunctiondata.d().parse(s, customfunctiondata.f()); // CraftBukkit
- public String toString() {
+ if (parseresults.getReader().canRead()) {
+ if (parseresults.getExceptions().size() == 1) {
diff --git a/nms-patches/CustomFunctionData.patch b/nms-patches/CustomFunctionData.patch
index 821ff006..d478a823 100644
--- a/nms-patches/CustomFunctionData.patch
+++ b/nms-patches/CustomFunctionData.patch
@@ -1,45 +1,38 @@
--- a/net/minecraft/server/CustomFunctionData.java
+++ b/net/minecraft/server/CustomFunctionData.java
-@@ -23,7 +23,14 @@
- private CustomFunction f;
- private final ArrayDeque<CustomFunctionData.a> g = new ArrayDeque();
- private boolean h = false;
-- private final ICommandListener i = new ICommandListener() {
-+ // CraftBukkit start
-+ private final ICommandListener i = new CustomFunctionListener();
-+
-+ public class CustomFunctionListener implements ICommandListener {
-+
-+ protected org.bukkit.command.CommandSender sender = new org.bukkit.craftbukkit.command.CraftFunctionCommandSender(this);
-+ // CraftBukkit end
-+
- public String getName() {
- return CustomFunctionData.this.e;
- }
-@@ -33,7 +40,7 @@
- }
+@@ -32,14 +32,16 @@
+ private final Map<MinecraftKey, CustomFunction> g = Maps.newHashMap();
+ private final ArrayDeque<CustomFunctionData.a> h = new ArrayDeque();
+ private boolean i;
+- private final Tags<CustomFunction> j = new Tags((minecraftkey) -> {
++ private final Tags<CustomFunction> j = new Tags<>((minecraftkey) -> { // CraftBukkit - decompile error
+ return this.a(minecraftkey) != null;
+ }, this::a, "tags/functions", true, "function");
+ private final List<CustomFunction> k = Lists.newArrayList();
+ private boolean l;
++ private final com.mojang.brigadier.CommandDispatcher<CommandListenerWrapper> dispatcher; // CraftBukkit
- public World getWorld() {
-- return CustomFunctionData.this.c.worldServer[0];
-+ return CustomFunctionData.this.c.worlds.get(0); // CraftBukkit
- }
-
- public MinecraftServer C_() {
-@@ -57,7 +64,7 @@
+ public CustomFunctionData(MinecraftServer minecraftserver) {
+ this.f = minecraftserver;
++ this.dispatcher = this.f.getCommandDispatcher().a(); // CraftBukkit
}
- public int c() {
-- return this.c.worldServer[0].getGameRules().c("maxCommandChainLength");
-+ return this.c.worlds.get(0).getGameRules().c("maxCommandChainLength"); // CraftBukkit
+ @Nullable
+@@ -60,7 +62,7 @@
}
- public Map<MinecraftKey, CustomFunction> d() {
-@@ -65,7 +72,7 @@
+ public com.mojang.brigadier.CommandDispatcher<CommandListenerWrapper> d() {
+- return this.f.getCommandDispatcher().a();
++ return dispatcher; // CraftBukkit
}
- public void e() {
-- String s = this.c.worldServer[0].getGameRules().get("gameLoopFunction");
-+ String s = this.c.worlds.get(0).getGameRules().get("gameLoopFunction"); // CraftBukkit
-
- if (!s.equals(this.e)) {
- this.e = s;
+ public void X_() {
+@@ -164,7 +166,7 @@
+ arraylist.add(CompletableFuture.supplyAsync(() -> {
+ return a(iresourcemanager, minecraftkey);
+ }, Resource.a).thenApplyAsync((list) -> {
+- return CustomFunction.a(minecraftkey, this, list);
++ return CustomFunction.a(minecraftkey1, this, list); // CraftBukkit - decompile error
+ }).handle((customfunction, throwable) -> {
+ return this.a(customfunction, throwable, minecraftkey);
+ }));
diff --git a/nms-patches/DamageSource.patch b/nms-patches/DamageSource.patch
index ac9ca78e..9a4a324c 100644
--- a/nms-patches/DamageSource.patch
+++ b/nms-patches/DamageSource.patch
@@ -1,9 +1,9 @@
--- a/net/minecraft/server/DamageSource.java
+++ b/net/minecraft/server/DamageSource.java
-@@ -34,6 +34,18 @@
- private boolean C;
+@@ -35,6 +35,18 @@
private boolean D;
- public String translationIndex;
+ private boolean E;
+ public final String translationIndex;
+ // CraftBukkit start
+ private boolean sweep;
+
diff --git a/nms-patches/DataConverterFlatten.patch b/nms-patches/DataConverterFlatten.patch
new file mode 100644
index 00000000..4c4a198f
--- /dev/null
+++ b/nms-patches/DataConverterFlatten.patch
@@ -0,0 +1,11 @@
+--- a/net/minecraft/server/DataConverterFlatten.java
++++ b/net/minecraft/server/DataConverterFlatten.java
+@@ -378,7 +378,7 @@
+ Typed typed2 = typed.getOrCreateTyped(opticfinder1);
+ Dynamic dynamic1 = (Dynamic) typed2.get(DSL.remainderFinder());
+
+- dynamic1 = dynamic1.set("Damage", dynamic1.createInt(i));
++ if (i != 0) dynamic1 = dynamic1.set("Damage", dynamic1.createInt(i)); // CraftBukkit
+ typed1 = typed1.set(opticfinder1, typed2.set(DSL.remainderFinder(), dynamic1));
+ }
+
diff --git a/nms-patches/DataConverterMap.patch b/nms-patches/DataConverterMap.patch
new file mode 100644
index 00000000..190d6490
--- /dev/null
+++ b/nms-patches/DataConverterMap.patch
@@ -0,0 +1,20 @@
+--- a/net/minecraft/server/DataConverterMap.java
++++ b/net/minecraft/server/DataConverterMap.java
+@@ -22,7 +22,7 @@
+ public TypeRewriteRule makeRule() {
+ Type type = this.getInputSchema().getType(DataConverterTypes.ITEM_STACK);
+ OpticFinder opticfinder = DSL.fieldFinder("id", DSL.named(DataConverterTypes.q.typeName(), DSL.namespacedString()));
+- OpticFinder opticfinder1 = type.findField("tag");
++ OpticFinder<?> opticfinder1 = type.findField("tag"); // CraftBukkit - decompile error
+
+ return this.fixTypeEverywhereTyped("ItemInstanceMapIdFix", type, (typed) -> {
+ Optional optional = typed.getOptional(opticfinder);
+@@ -32,7 +32,7 @@
+ Typed typed1 = typed.getOrCreateTyped(opticfinder1);
+ Dynamic dynamic1 = (Dynamic) typed1.get(DSL.remainderFinder());
+
+- dynamic1 = dynamic1.set("map", dynamic1.createInt(dynamic.getInt("Damage")));
++ if (!dynamic1.get("map").isPresent()) dynamic1 = dynamic1.set("map", dynamic1.createInt(dynamic.getInt("Damage"))); // CraftBukkit
+ return typed.set(opticfinder1, typed1.set(DSL.remainderFinder(), dynamic1));
+ } else {
+ return typed;
diff --git a/nms-patches/DataInspectorBlockEntity.patch b/nms-patches/DataInspectorBlockEntity.patch
deleted file mode 100644
index 0ec5d799..00000000
--- a/nms-patches/DataInspectorBlockEntity.patch
+++ /dev/null
@@ -1,12 +0,0 @@
---- a/net/minecraft/server/DataInspectorBlockEntity.java
-+++ b/net/minecraft/server/DataInspectorBlockEntity.java
-@@ -32,7 +32,8 @@
- boolean flag;
-
- if (s1 == null) {
-- DataInspectorBlockEntity.a.warn("Unable to resolve BlockEntity for ItemInstance: {}", s);
-+ // CraftBukkit - Remove unnecessary warning (occurs when deserializing a Shulker Box item)
-+ // DataInspectorBlockEntity.a.warn("Unable to resolve BlockEntity for ItemInstance: {}", s);
- flag = false;
- } else {
- flag = !nbttagcompound2.hasKey("id");
diff --git a/nms-patches/DataPaletteBlock.patch b/nms-patches/DataPaletteBlock.patch
deleted file mode 100644
index 676b070e..00000000
--- a/nms-patches/DataPaletteBlock.patch
+++ /dev/null
@@ -1,25 +0,0 @@
---- a/net/minecraft/server/DataPaletteBlock.java
-+++ b/net/minecraft/server/DataPaletteBlock.java
-@@ -112,7 +112,21 @@
- int i1 = nibblearray1 == null ? 0 : nibblearray1.a(j, k, l);
- int j1 = i1 << 12 | (abyte[i] & 255) << 4 | nibblearray.a(j, k, l);
-
-- this.setBlockIndex(i, (IBlockData) Block.REGISTRY_ID.fromId(j1));
-+ // CraftBukkit start - fix blocks with random data values (caused by plugins)
-+ IBlockData data = Block.REGISTRY_ID.fromId(j1);
-+ if (data == null) {
-+ Block block = Block.getById(j1 >> 4);
-+ if (block != null) {
-+ try {
-+ data = block.fromLegacyData(j1 & 0xF);
-+ } catch (Exception ignored) {
-+ data = block.getBlockData();
-+ }
-+ }
-+ }
-+ this.setBlockIndex(i, data);
-+ // this.setBlockIndex(i, (IBlockData) Block.REGISTRY_ID.fromId(j1));
-+ // CraftBukkit end
- }
-
- }
diff --git a/nms-patches/DataWatcher.patch b/nms-patches/DataWatcher.patch
index 131d78a7..676bc64c 100644
--- a/nms-patches/DataWatcher.patch
+++ b/nms-patches/DataWatcher.patch
@@ -18,3 +18,17 @@
DataWatcher.Item datawatcher_item = new DataWatcher.Item(datawatcherobject, t0);
this.e.writeLock().lock();
+@@ -128,6 +128,13 @@
+
+ }
+
++ // CraftBukkit start - add method from above
++ public <T> void markDirty(DataWatcherObject<T> datawatcherobject) {
++ this.b(datawatcherobject).a(true);
++ this.g = true;
++ }
++ // CraftBukkit end
++
+ public boolean a() {
+ return this.g;
+ }
diff --git a/nms-patches/DedicatedServer.patch b/nms-patches/DedicatedServer.patch
index 9cd3444c..e2d9e6ee 100644
--- a/nms-patches/DedicatedServer.patch
+++ b/nms-patches/DedicatedServer.patch
@@ -1,6 +1,6 @@
--- a/net/minecraft/server/DedicatedServer.java
+++ b/net/minecraft/server/DedicatedServer.java
-@@ -19,11 +19,21 @@
+@@ -23,11 +23,22 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -8,6 +8,7 @@
+import java.io.PrintStream;
+import org.apache.logging.log4j.Level;
+
++import org.bukkit.command.CommandSender;
+import org.bukkit.craftbukkit.LoggerOutputStream;
+import org.bukkit.event.server.ServerCommandEvent;
+import org.bukkit.craftbukkit.util.Waitable;
@@ -17,26 +18,26 @@
public class DedicatedServer extends MinecraftServer implements IMinecraftServer {
private static final Logger LOGGER = LogManager.getLogger();
- private static final Pattern l = Pattern.compile("^[a-fA-F0-9]{40}$");
+ private static final Pattern i = Pattern.compile("^[a-fA-F0-9]{40}$");
- private final List<ServerCommand> serverCommandQueue = Collections.synchronizedList(Lists.newArrayList());
+ private final List<ServerCommand> serverCommandQueue = Collections.synchronizedList(Lists.<ServerCommand>newArrayList()); // CraftBukkit - fix decompile error
- private RemoteStatusListener n;
+ private RemoteStatusListener k;
public final RemoteControlCommandListener remoteControlCommandListener = new RemoteControlCommandListener(this);
- private RemoteControlListener p;
-@@ -33,8 +43,10 @@
- private EnumGamemode t;
- private boolean u;
+ private RemoteControlListener m;
+@@ -37,8 +48,10 @@
+ private EnumGamemode q;
+ private boolean r;
-- public DedicatedServer(File file, DataConverterManager dataconvertermanager, YggdrasilAuthenticationService yggdrasilauthenticationservice, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache) {
-- super(file, Proxy.NO_PROXY, dataconvertermanager, yggdrasilauthenticationservice, minecraftsessionservice, gameprofilerepository, usercache);
+- public DedicatedServer(File file, DataFixer datafixer, YggdrasilAuthenticationService yggdrasilauthenticationservice, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache) {
+- super(file, Proxy.NO_PROXY, datafixer, new CommandDispatcher(true), yggdrasilauthenticationservice, minecraftsessionservice, gameprofilerepository, usercache);
+ // CraftBukkit start - Signature changed
-+ public DedicatedServer(joptsimple.OptionSet options, DataConverterManager dataconvertermanager, YggdrasilAuthenticationService yggdrasilauthenticationservice, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache) {
-+ super(options, Proxy.NO_PROXY, dataconvertermanager, yggdrasilauthenticationservice, minecraftsessionservice, gameprofilerepository, usercache);
++ public DedicatedServer(joptsimple.OptionSet options, DataFixer datafixer, YggdrasilAuthenticationService yggdrasilauthenticationservice, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache) {
++ super(options, Proxy.NO_PROXY, datafixer, new CommandDispatcher().init(true), yggdrasilauthenticationservice, minecraftsessionservice, gameprofilerepository, usercache);
+ // CraftBukkit end
Thread thread = new Thread("Server Infinisleeper") {
{
this.setDaemon(true);
-@@ -53,16 +65,30 @@
+@@ -58,16 +71,30 @@
};
}
@@ -56,22 +57,22 @@
try {
- while (!DedicatedServer.this.isStopped() && DedicatedServer.this.isRunning() && (s = bufferedreader.readLine()) != null) {
-- DedicatedServer.this.issueCommand(s, DedicatedServer.this);
+- DedicatedServer.this.issueCommand(s, DedicatedServer.this.getServerCommandListener());
+ // CraftBukkit start - JLine disabling compatibility
-+ while (!isStopped() && isRunning()) {
++ while (!DedicatedServer.this.isStopped() && DedicatedServer.this.isRunning()) {
+ if (org.bukkit.craftbukkit.Main.useJline) {
+ s = bufferedreader.readLine(">", null);
+ } else {
+ s = bufferedreader.readLine();
+ }
+ if (s != null && s.trim().length() > 0) { // Trim to filter lines which are just spaces
-+ issueCommand(s, DedicatedServer.this);
++ DedicatedServer.this.issueCommand(s, DedicatedServer.this.getServerCommandListener());
+ }
+ // CraftBukkit end
}
} catch (IOException ioexception) {
DedicatedServer.LOGGER.error("Exception handling console input", ioexception);
-@@ -71,6 +97,27 @@
+@@ -76,6 +103,27 @@
}
};
@@ -97,18 +98,18 @@
+ // CraftBukkit end
+
thread.setDaemon(true);
+ thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(DedicatedServer.LOGGER));
thread.start();
- DedicatedServer.LOGGER.info("Starting minecraft server version 1.12.2");
-@@ -79,7 +126,7 @@
+@@ -85,7 +133,7 @@
}
DedicatedServer.LOGGER.info("Loading properties");
- this.propertyManager = new PropertyManager(new File("server.properties"));
+ this.propertyManager = new PropertyManager(this.options); // CraftBukkit - CLI argument support
- this.r = new EULA(new File("eula.txt"));
- if (!this.r.a()) {
+ this.o = new EULA(new File("eula.txt"));
+ if (!this.o.a()) {
DedicatedServer.LOGGER.info("You need to agree to the EULA in order to run the server. Go to eula.txt for more info.");
-@@ -136,6 +183,12 @@
+@@ -143,6 +191,12 @@
return false;
}
@@ -121,28 +122,19 @@
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.");
-@@ -150,7 +203,7 @@
+@@ -157,7 +211,7 @@
if (!NameReferencingFileConverter.a(this.propertyManager)) {
return false;
} else {
- this.a((PlayerList) (new DedicatedPlayerList(this)));
-+ this.convertable = new WorldLoaderServer(server.getWorldContainer(), this.dataConverterManager); // CraftBukkit - moved from MinecraftServer constructor
- long j = System.nanoTime();
++ this.convertable = new WorldLoaderServer(server.getWorldContainer().toPath(), server.getWorldContainer().toPath().resolve("../backups"), this.dataConverterManager); // CraftBukkit - moved from MinecraftServer constructor
+ long j = SystemUtils.c();
- if (this.S() == null) {
-@@ -198,7 +251,7 @@
-
- DedicatedServer.LOGGER.info("Done ({})! For help, type \"help\" or \"?\"", s3);
- if (this.propertyManager.a("announce-player-achievements")) {
-- this.worldServer[0].getGameRules().set("announceAdvancements", this.propertyManager.getBoolean("announce-player-achievements", true) ? "true" : "false");
-+ this.worlds.get(0).getGameRules().set("announceAdvancements", this.propertyManager.getBoolean("announce-player-achievements", true) ? "true" : "false"); // CraftBukkit
- this.propertyManager.b("announce-player-achievements");
- this.propertyManager.savePropertiesFile();
- }
-@@ -213,7 +266,18 @@
+ if (this.K() == null) {
+@@ -228,7 +282,18 @@
DedicatedServer.LOGGER.info("Starting remote control listener");
- this.p = new RemoteControlListener(this);
- this.p.a();
+ this.m = new RemoteControlListener(this);
+ this.m.a();
+ this.remoteConsole = new org.bukkit.craftbukkit.command.CraftRemoteConsoleCommandSender(this.remoteControlCommandListener); // CraftBukkit
+ }
+
@@ -156,40 +148,40 @@
}
+ // CraftBukkit end
- if (this.aT() > 0L) {
+ if (this.ba() > 0L) {
Thread thread1 = new Thread(new ThreadWatchdog(this));
-@@ -299,11 +363,11 @@
+@@ -303,11 +368,11 @@
return crashreport;
}
-- protected void B() {
-+ public void B() {
+- protected void u() {
++ public void u() { // CraftBukkit - decompile error
System.exit(0);
}
-- protected void D() {
-+ public void D() { // CraftBukkit - fix decompile error
- super.D();
- this.aP();
+- protected void w() {
++ public void w() { // CraftBukkit - fix decompile error
+ super.w();
+ this.aW();
}
-@@ -334,7 +398,15 @@
+@@ -342,7 +407,15 @@
while (!this.serverCommandQueue.isEmpty()) {
ServerCommand servercommand = (ServerCommand) this.serverCommandQueue.remove(0);
-- this.getCommandHandler().a(servercommand.source, servercommand.command);
+- this.getCommandDispatcher().a(servercommand.source, servercommand.command);
+ // CraftBukkit start - ServerCommand for preprocessing
+ ServerCommandEvent event = new ServerCommandEvent(console, servercommand.command);
+ server.getPluginManager().callEvent(event);
+ if (event.isCancelled()) continue;
+ servercommand = new ServerCommand(event.getCommand(), servercommand.source);
+
-+ // this.getCommandHandler().a(servercommand.source, servercommand.command); // Called in dispatchServerCommand
++ // this.getCommandDispatcher().a(servercommand.source, servercommand.command); // Called in dispatchServerCommand
+ server.dispatchServerCommand(console, servercommand);
+ // CraftBukkit end
}
}
-@@ -537,16 +609,70 @@
+@@ -549,16 +622,75 @@
}
public String getPlugins() {
@@ -210,17 +202,17 @@
+ if (i > 0) {
+ result.append("; ");
+ }
-+
+
+- public String executeRemoteCommand(String s) {
+- this.remoteControlCommandListener.clearMessages();
+- this.getCommandDispatcher().a(this.remoteControlCommandListener.f(), s);
+- return this.remoteControlCommandListener.getMessages();
+ result.append(plugins[i].getDescription().getName());
+ result.append(" ");
+ result.append(plugins[i].getDescription().getVersion().replaceAll(";", ","));
+ }
+ }
-
-- public String executeRemoteCommand(String s) {
-- this.remoteControlCommandListener.clearMessages();
-- this.b.a(this.remoteControlCommandListener, s);
-- return this.remoteControlCommandListener.getMessages();
++
+ return result.toString();
+ // CraftBukkit end
+ }
@@ -238,7 +230,7 @@
+ return "";
+ }
+ // Event change end
-+ ServerCommand serverCommand = new ServerCommand(event.getCommand(), remoteControlCommandListener);
++ ServerCommand serverCommand = new ServerCommand(event.getCommand(), remoteControlCommandListener.f());
+ server.dispatchServerCommand(remoteConsole, serverCommand);
+ return remoteControlCommandListener.getMessages();
+ }
@@ -256,7 +248,7 @@
}
public PlayerList getPlayerList() {
- return this.aQ();
+ return this.aX();
}
+
+ // CraftBukkit start
@@ -264,5 +256,10 @@
+ public PropertyManager getPropertyManager() {
+ return this.propertyManager;
+ }
++
++ @Override
++ public CommandSender getBukkitSender(CommandListenerWrapper wrapper) {
++ return console;
++ }
+ // CraftBukkit end
}
diff --git a/nms-patches/DispenseBehaviorItem.patch b/nms-patches/DispenseBehaviorItem.patch
index f325425f..50eb6ee9 100644
--- a/nms-patches/DispenseBehaviorItem.patch
+++ b/nms-patches/DispenseBehaviorItem.patch
@@ -11,7 +11,7 @@
public class DispenseBehaviorItem implements IDispenseBehavior {
public DispenseBehaviorItem() {}
-@@ -17,11 +22,18 @@
+@@ -17,11 +22,19 @@
IPosition iposition = BlockDispenser.a(isourceblock);
ItemStack itemstack1 = itemstack.cloneAndSubtract(1);
@@ -27,12 +27,13 @@
- public static void a(World world, ItemStack itemstack, int i, EnumDirection enumdirection, IPosition iposition) {
+ // CraftBukkit start - void -> boolean return, IPosition -> ISourceBlock last argument
+ public static boolean a(World world, ItemStack itemstack, int i, EnumDirection enumdirection, ISourceBlock isourceblock) {
++ if (itemstack.isEmpty()) return true;
+ IPosition iposition = BlockDispenser.a(isourceblock);
+ // CraftBukkit end
double d0 = iposition.getX();
double d1 = iposition.getY();
double d2 = iposition.getZ();
-@@ -41,7 +53,41 @@
+@@ -41,7 +54,41 @@
entityitem.motX += world.random.nextGaussian() * 0.007499999832361937D * (double) i;
entityitem.motY += world.random.nextGaussian() * 0.007499999832361937D * (double) i;
entityitem.motZ += world.random.nextGaussian() * 0.007499999832361937D * (double) i;
@@ -60,7 +61,7 @@
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem());
+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior.getClass() != DispenseBehaviorItem.class) {
-+ idispensebehavior.a(isourceblock, eventStack);
++ idispensebehavior.dispense(isourceblock, eventStack);
+ } else {
+ world.addEntity(entityitem);
+ }
diff --git a/nms-patches/DispenseBehaviorProjectile.patch b/nms-patches/DispenseBehaviorProjectile.patch
index a7f5100e..e3b3fd05 100644
--- a/nms-patches/DispenseBehaviorProjectile.patch
+++ b/nms-patches/DispenseBehaviorProjectile.patch
@@ -38,7 +38,7 @@
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem());
+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) {
-+ idispensebehavior.a(isourceblock, eventStack);
++ idispensebehavior.dispense(isourceblock, eventStack);
+ return itemstack;
+ }
+ }
diff --git a/nms-patches/DispenserRegistry.patch b/nms-patches/DispenserRegistry.patch
index 5d7bba4e..47b0478d 100644
--- a/nms-patches/DispenserRegistry.patch
+++ b/nms-patches/DispenserRegistry.patch
@@ -16,38 +16,35 @@
public class DispenserRegistry {
public static final PrintStream a = System.out;
-@@ -71,7 +80,7 @@
- BlockDispenser.REGISTRY.a(Items.SPLASH_POTION, new IDispenseBehavior() {
- public ItemStack a(ISourceBlock isourceblock, final ItemStack itemstack) {
+@@ -70,7 +79,7 @@
+ BlockDispenser.a((IMaterial) Items.SPLASH_POTION, new IDispenseBehavior() {
+ public ItemStack dispense(ISourceBlock isourceblock, final ItemStack itemstack) {
return (new DispenseBehaviorProjectile() {
- protected IProjectile a(World world, IPosition iposition, ItemStack itemstack) {
+ protected IProjectile a(World world, IPosition iposition, ItemStack itemstack1) { // CraftBukkit - decompile issue
return new EntityPotion(world, iposition.getX(), iposition.getY(), iposition.getZ(), itemstack1.cloneItemStack());
}
-@@ -88,7 +97,7 @@
- BlockDispenser.REGISTRY.a(Items.LINGERING_POTION, new IDispenseBehavior() {
- public ItemStack a(ISourceBlock isourceblock, final ItemStack itemstack) {
+@@ -87,7 +96,7 @@
+ BlockDispenser.a((IMaterial) Items.LINGERING_POTION, new IDispenseBehavior() {
+ public ItemStack dispense(ISourceBlock isourceblock, final ItemStack itemstack) {
return (new DispenseBehaviorProjectile() {
- protected IProjectile a(World world, IPosition iposition, ItemStack itemstack) {
+ protected IProjectile a(World world, IPosition iposition, ItemStack itemstack1) { // CraftBukkit - decompile issue
return new EntityPotion(world, iposition.getX(), iposition.getY(), iposition.getZ(), itemstack1.cloneItemStack());
}
-@@ -108,14 +117,46 @@
- double d0 = isourceblock.getX() + (double) enumdirection.getAdjacentX();
- 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);
-+
+@@ -106,11 +115,39 @@
+ EnumDirection enumdirection = (EnumDirection) isourceblock.e().get(BlockDispenser.FACING);
+ EntityTypes entitytypes = ((ItemMonsterEgg) itemstack.getItem()).b(itemstack.getTag());
+
+ // CraftBukkit start
+ World world = isourceblock.getWorld();
+ ItemStack itemstack1 = itemstack.cloneAndSubtract(1);
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ());
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
+
-+ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(d0, d1, d2));
++ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0));
+ if (!BlockDispenser.eventFired) {
+ world.getServer().getPluginManager().callEvent(event);
+ }
@@ -63,27 +60,22 @@
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem());
+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) {
-+ idispensebehavior.a(isourceblock, eventStack);
++ idispensebehavior.dispense(isourceblock, eventStack);
+ return itemstack;
+ }
+ }
+
-+ itemstack1 = CraftItemStack.asNMSCopy(event.getItem());
-+
-+ Entity entity = ItemMonsterEgg.spawnCreature(isourceblock.getWorld(), ItemMonsterEgg.h(itemstack), event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DISPENSE_EGG);
-
- if (entity instanceof EntityLiving && itemstack.hasName()) {
- entity.setCustomName(itemstack.getName());
+ if (entitytypes != null) {
+ entitytypes.a(isourceblock.getWorld(), itemstack, (EntityHuman) null, isourceblock.getBlockPosition().shift(enumdirection), enumdirection != EnumDirection.UP, false);
}
- ItemMonsterEgg.a(isourceblock.getWorld(), (EntityHuman) null, itemstack, entity);
- itemstack.subtract(1);
-+ // itemstack.subtract(1);// Handled during event processing
++ // itemstack.subtract(1); // Handled during event processing
+ // CraftBukkit end
return itemstack;
}
- });
-@@ -125,10 +166,39 @@
+ };
+@@ -128,10 +165,39 @@
double d0 = isourceblock.getX() + (double) enumdirection.getAdjacentX();
double d1 = (double) ((float) isourceblock.getBlockPosition().getY() + 0.2F);
double d2 = isourceblock.getZ() + (double) enumdirection.getAdjacentZ();
@@ -110,7 +102,7 @@
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem());
+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) {
-+ idispensebehavior.a(isourceblock, eventStack);
++ idispensebehavior.dispense(isourceblock, eventStack);
+ return itemstack;
+ }
+ }
@@ -125,7 +117,7 @@
return itemstack;
}
-@@ -149,8 +219,38 @@
+@@ -152,8 +218,38 @@
double d4 = random.nextGaussian() * 0.05D + (double) enumdirection.getAdjacentY();
double d5 = random.nextGaussian() * 0.05D + (double) enumdirection.getAdjacentZ();
@@ -152,7 +144,7 @@
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem());
+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) {
-+ idispensebehavior.a(isourceblock, eventStack);
++ idispensebehavior.dispense(isourceblock, eventStack);
+ return itemstack;
+ }
+ }
@@ -166,13 +158,11 @@
return itemstack;
}
-@@ -171,7 +271,53 @@
- ItemBucket itembucket = (ItemBucket) itemstack.getItem();
+@@ -175,9 +271,49 @@
BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.e().get(BlockDispenser.FACING));
+ World world = isourceblock.getWorld();
-- 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();
+ int y = blockposition.getY();
+ int z = blockposition.getZ();
@@ -194,7 +184,7 @@
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem());
+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) {
-+ idispensebehavior.a(isourceblock, eventStack);
++ idispensebehavior.dispense(isourceblock, eventStack);
+ return itemstack;
+ }
+ }
@@ -203,7 +193,9 @@
+ }
+ // CraftBukkit end
+
-+ if (itembucket.a((EntityHuman) null, isourceblock.getWorld(), blockposition)) {
+ if (itembucket.a((EntityHuman) null, world, blockposition, (MovingObjectPosition) null)) {
+- itembucket.a(world, itemstack, blockposition);
+- return new ItemStack(Items.BUCKET);
+ // CraftBukkit start - Handle stacked buckets
+ Item item = Items.BUCKET;
+ itemstack.subtract(1);
@@ -211,25 +203,53 @@
+ itemstack.setItem(Items.BUCKET);
+ itemstack.setCount(1);
+ } else if (((TileEntityDispenser) isourceblock.getTileEntity()).addItem(new ItemStack(item)) < 0) {
-+ this.b.a(isourceblock, new ItemStack(item));
++ this.a.dispense(isourceblock, new ItemStack(item));
+ }
+ // CraftBukkit end
+ return itemstack;
-+ } else {
-+ return this.b.a(isourceblock, itemstack);
-+ }
- }
- };
-
-@@ -198,6 +344,30 @@
- item = Items.LAVA_BUCKET;
+ } else {
+ return this.a.dispense(isourceblock, itemstack);
}
+@@ -207,6 +343,30 @@
+ } else {
+ Item item = fluidtype.b();
+
++ // CraftBukkit start
++ org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ());
++ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack);
++
++ BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockposition.getX(), blockposition.getY(), blockposition.getZ()));
++ if (!BlockDispenser.eventFired) {
++ world.getServer().getPluginManager().callEvent(event);
++ }
++
++ if (event.isCancelled()) {
++ return itemstack;
++ }
++
++ if (!event.getItem().equals(craftItem)) {
++ // Chain to handler for new item
++ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
++ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem());
++ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) {
++ idispensebehavior.dispense(isourceblock, eventStack);
++ return itemstack;
++ }
++ }
++ // CraftBukkit end
++
+ itemstack.subtract(1);
+ if (itemstack.isEmpty()) {
+ return new ItemStack(item);
+@@ -227,14 +387,42 @@
+ protected ItemStack a(ISourceBlock isourceblock, ItemStack itemstack) {
+ World world = isourceblock.getWorld();
+ // CraftBukkit start
+ org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ());
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack);
+
-+ BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockposition.getX(), blockposition.getY(), blockposition.getZ()));
++ BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0));
+ if (!BlockDispenser.eventFired) {
+ world.getServer().getPluginManager().callEvent(event);
+ }
@@ -243,19 +263,34 @@
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem());
+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) {
-+ idispensebehavior.a(isourceblock, eventStack);
++ idispensebehavior.dispense(isourceblock, eventStack);
+ return itemstack;
+ }
+ }
+ // CraftBukkit end
+
- world.setAir(blockposition);
- itemstack.subtract(1);
- if (itemstack.isEmpty()) {
-@@ -215,14 +385,42 @@
- protected ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) {
- World world = isourceblock.getWorld();
+ this.a = true;
+ BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.e().get(BlockDispenser.FACING));
+ if (ItemFlintAndSteel.a((GeneratorAccess) world, blockposition)) {
+- world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData());
+- if (itemstack.isDamaged(1, world.random, (EntityPlayer) null)) {
+- itemstack.setCount(0);
++ // CraftBukkit start - Ignition by dispensing flint and steel
++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition, isourceblock.getBlockPosition()).isCancelled()) {
++ world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData());
++ if (itemstack.isDamaged(1, world.random, (EntityPlayer) null)) {
++ itemstack.setCount(0);
++ }
+ }
++ // CraftBukkit end
+ } else {
+ Block block = world.getType(blockposition).getBlock();
+
+@@ -254,12 +442,55 @@
+ this.a = true;
+ 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());
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack);
@@ -274,92 +309,42 @@
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem());
+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) {
-+ idispensebehavior.a(isourceblock, eventStack);
++ idispensebehavior.dispense(isourceblock, eventStack);
+ return itemstack;
+ }
+ }
+ // 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, (EntityPlayer) null)) {
-- 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, (EntityPlayer) null)) {
-+ 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);
-@@ -240,6 +438,32 @@
- 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());
-+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack);
-+
-+ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0));
-+ if (!BlockDispenser.eventFired) {
-+ world.getServer().getPluginManager().callEvent(event);
-+ }
-+
-+ if (event.isCancelled()) {
-+ return itemstack;
+ if (!ItemBoneMeal.a(itemstack, world, blockposition) && !ItemBoneMeal.b(itemstack, world, blockposition)) {
+ this.a = false;
+ } else if (!world.isClientSide) {
+ world.triggerEffect(2005, blockposition, 0);
+ }
++ // CraftBukkit start
++ world.captureTreeGeneration = false;
++ if (world.capturedBlockStates.size() > 0) {
++ TreeType treeType = BlockSapling.treeType;
++ BlockSapling.treeType = null;
++ Location location = new Location(world.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ());
++ List<org.bukkit.block.BlockState> blocks = (List<org.bukkit.block.BlockState>) world.capturedBlockStates.clone();
++ world.capturedBlockStates.clear();
++ StructureGrowEvent structureEvent = null;
++ if (treeType != null) {
++ structureEvent = new StructureGrowEvent(location, treeType, false, null, blocks);
++ org.bukkit.Bukkit.getPluginManager().callEvent(structureEvent);
+ }
-+
-+ if (!event.getItem().equals(craftItem)) {
-+ // Chain to handler for new item
-+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
-+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem());
-+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) {
-+ idispensebehavior.a(isourceblock, eventStack);
-+ return itemstack;
++ if (structureEvent == null || !structureEvent.isCancelled()) {
++ for (org.bukkit.block.BlockState blockstate : blocks) {
++ blockstate.update(true);
+ }
+ }
-+
-+ world.captureTreeGeneration = true;
-+ // CraftBukkit end
-+
- if (ItemDye.a(itemstack, world, blockposition)) {
- if (!world.isClientSide) {
- world.triggerEffect(2005, blockposition, 0);
-@@ -247,6 +471,26 @@
- } else {
- this.b = false;
- }
-+ // CraftBukkit start
-+ world.captureTreeGeneration = false;
-+ if (world.capturedBlockStates.size() > 0) {
-+ TreeType treeType = BlockSapling.treeType;
-+ BlockSapling.treeType = null;
-+ Location location = new Location(world.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ());
-+ List<org.bukkit.block.BlockState> blocks = (List<org.bukkit.block.BlockState>) world.capturedBlockStates.clone();
-+ world.capturedBlockStates.clear();
-+ StructureGrowEvent structureEvent = null;
-+ if (treeType != null) {
-+ structureEvent = new StructureGrowEvent(location, treeType, false, null, blocks);
-+ org.bukkit.Bukkit.getPluginManager().callEvent(structureEvent);
-+ }
-+ if (structureEvent == null || !structureEvent.isCancelled()) {
-+ for (org.bukkit.block.BlockState blockstate : blocks) {
-+ blockstate.update(true);
-+ }
-+ }
-+ }
-+ // CraftBukkit end
++ }
++ // CraftBukkit end
- return itemstack;
- } else {
-@@ -258,11 +502,40 @@
- protected ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) {
+ return itemstack;
+ }
+@@ -268,11 +499,40 @@
+ protected ItemStack a(ISourceBlock isourceblock, ItemStack itemstack) {
World world = isourceblock.getWorld();
BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.e().get(BlockDispenser.FACING));
- EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(world, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, (EntityLiving) null);
@@ -386,7 +371,7 @@
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem());
+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) {
-+ idispensebehavior.a(isourceblock, eventStack);
++ idispensebehavior.dispense(isourceblock, eventStack);
+ return itemstack;
+ }
+ }
@@ -395,15 +380,15 @@
+ // CraftBukkit end
world.addEntity(entitytntprimed);
- world.a((EntityHuman) null, entitytntprimed.locX, entitytntprimed.locY, entitytntprimed.locZ, SoundEffects.hW, SoundCategory.BLOCKS, 1.0F, 1.0F);
+ world.a((EntityHuman) null, entitytntprimed.locX, entitytntprimed.locY, entitytntprimed.locZ, SoundEffects.ENTITY_TNT_PRIMED, SoundCategory.BLOCKS, 1.0F, 1.0F);
- itemstack.subtract(1);
+ // itemstack.subtract(1); // CraftBukkit - handled above
return itemstack;
}
- });
-@@ -273,6 +546,30 @@
+ }));
+@@ -294,6 +554,30 @@
+ EnumDirection enumdirection = (EnumDirection) isourceblock.e().get(BlockDispenser.FACING);
BlockPosition blockposition = isourceblock.getBlockPosition().shift(enumdirection);
- BlockSkull blockskull = Blocks.SKULL;
+ // CraftBukkit start
+ org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ());
@@ -423,18 +408,18 @@
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem());
+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) {
-+ idispensebehavior.a(isourceblock, eventStack);
++ idispensebehavior.dispense(isourceblock, eventStack);
+ return itemstack;
+ }
+ }
+ // CraftBukkit end
+
- this.b = true;
- if (world.isEmpty(blockposition) && blockskull.b(world, blockposition, itemstack)) {
- if (!world.isClientSide) {
-@@ -321,6 +618,30 @@
+ this.a = true;
+ if (world.isEmpty(blockposition) && BlockWitherSkull.b(world, blockposition, itemstack)) {
+ world.setTypeAndData(blockposition, (IBlockData) Blocks.WITHER_SKELETON_SKULL.getBlockData().set(BlockSkull.a, Integer.valueOf(enumdirection.opposite().get2DRotationValue() * 4)), 3);
+@@ -317,6 +601,30 @@
BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.e().get(BlockDispenser.FACING));
- BlockPumpkin blockpumpkin = (BlockPumpkin) Blocks.PUMPKIN;
+ BlockPumpkinCarved blockpumpkincarved = (BlockPumpkinCarved) Blocks.CARVED_PUMPKIN;
+ // CraftBukkit start
+ org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ());
@@ -454,47 +439,108 @@
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem());
+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) {
-+ idispensebehavior.a(isourceblock, eventStack);
++ idispensebehavior.dispense(isourceblock, eventStack);
+ return itemstack;
+ }
+ }
+ // CraftBukkit end
+
- this.b = true;
- if (world.isEmpty(blockposition) && blockpumpkin.b(world, blockposition)) {
+ this.a = true;
+ if (world.isEmpty(blockposition) && blockpumpkincarved.a((IWorldReader) world, blockposition)) {
if (!world.isClientSide) {
-@@ -407,6 +728,30 @@
- EnumDirection enumdirection = (EnumDirection) isourceblock.e().get(BlockDispenser.FACING);
- BlockPosition blockposition = isourceblock.getBlockPosition().shift(enumdirection);
+@@ -378,6 +686,51 @@
+ }
-+ // CraftBukkit start
-+ org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ());
-+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack);
-+
-+ BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockposition.getX(), blockposition.getY(), blockposition.getZ()));
-+ if (!BlockDispenser.eventFired) {
-+ world.getServer().getPluginManager().callEvent(event);
-+ }
+ d();
++ // CraftBukkit start - easier than fixing the decompile
++ DataConverterFlattenData.a(1440, "{Name:\'minecraft:portal\',Properties:{axis:\'x\'}}", new String[]{"{Name:\'minecraft:portal\',Properties:{axis:\'x\'}}"});
++
++ DataConverterMaterialId.ID_MAPPING.put(409, "minecraft:prismarine_shard");
++ DataConverterMaterialId.ID_MAPPING.put(410, "minecraft:prismarine_crystals");
++ DataConverterMaterialId.ID_MAPPING.put(411, "minecraft:rabbit");
++ DataConverterMaterialId.ID_MAPPING.put(412, "minecraft:cooked_rabbit");
++ DataConverterMaterialId.ID_MAPPING.put(413, "minecraft:rabbit_stew");
++ DataConverterMaterialId.ID_MAPPING.put(414, "minecraft:rabbit_foot");
++ DataConverterMaterialId.ID_MAPPING.put(415, "minecraft:rabbit_hide");
++ DataConverterMaterialId.ID_MAPPING.put(416, "minecraft:armor_stand");
++
++ DataConverterMaterialId.ID_MAPPING.put(423, "minecraft:mutton");
++ DataConverterMaterialId.ID_MAPPING.put(424, "minecraft:cooked_mutton");
++ DataConverterMaterialId.ID_MAPPING.put(425, "minecraft:banner");
++ DataConverterMaterialId.ID_MAPPING.put(426, "minecraft:end_crystal");
++ DataConverterMaterialId.ID_MAPPING.put(427, "minecraft:spruce_door");
++ DataConverterMaterialId.ID_MAPPING.put(428, "minecraft:birch_door");
++ DataConverterMaterialId.ID_MAPPING.put(429, "minecraft:jungle_door");
++ DataConverterMaterialId.ID_MAPPING.put(430, "minecraft:acacia_door");
++ DataConverterMaterialId.ID_MAPPING.put(431, "minecraft:dark_oak_door");
++ DataConverterMaterialId.ID_MAPPING.put(432, "minecraft:chorus_fruit");
++ DataConverterMaterialId.ID_MAPPING.put(433, "minecraft:chorus_fruit_popped");
++ DataConverterMaterialId.ID_MAPPING.put(434, "minecraft:beetroot");
++ DataConverterMaterialId.ID_MAPPING.put(435, "minecraft:beetroot_seeds");
++ DataConverterMaterialId.ID_MAPPING.put(436, "minecraft:beetroot_soup");
++ DataConverterMaterialId.ID_MAPPING.put(437, "minecraft:dragon_breath");
++ DataConverterMaterialId.ID_MAPPING.put(438, "minecraft:splash_potion");
++ DataConverterMaterialId.ID_MAPPING.put(439, "minecraft:spectral_arrow");
++ DataConverterMaterialId.ID_MAPPING.put(440, "minecraft:tipped_arrow");
++ DataConverterMaterialId.ID_MAPPING.put(441, "minecraft:lingering_potion");
++ DataConverterMaterialId.ID_MAPPING.put(442, "minecraft:shield");
++ DataConverterMaterialId.ID_MAPPING.put(443, "minecraft:elytra");
++ DataConverterMaterialId.ID_MAPPING.put(444, "minecraft:spruce_boat");
++ DataConverterMaterialId.ID_MAPPING.put(445, "minecraft:birch_boat");
++ DataConverterMaterialId.ID_MAPPING.put(446, "minecraft:jungle_boat");
++ DataConverterMaterialId.ID_MAPPING.put(447, "minecraft:acacia_boat");
++ DataConverterMaterialId.ID_MAPPING.put(448, "minecraft:dark_oak_boat");
++ DataConverterMaterialId.ID_MAPPING.put(449, "minecraft:totem_of_undying");
++ DataConverterMaterialId.ID_MAPPING.put(450, "minecraft:shulker_shell");
++ DataConverterMaterialId.ID_MAPPING.put(452, "minecraft:iron_nugget");
++ DataConverterMaterialId.ID_MAPPING.put(453, "minecraft:knowledge_book");
++
++ DataConverterSpawnEgg.ID_MAPPING[23] = "Arrow";
++ // CraftBukkit end
+ }
+ }
+ }
+@@ -386,7 +739,7 @@
+ LocaleLanguage localelanguage = LocaleLanguage.a();
+
+ registrymaterials.iterator().forEachRemaining((object) -> {
+- String s = (String) function.apply(object);
++ String s1 = (String) function.apply(object); // CraftBukkit - decompile error
+
+ if (!localelanguage.b(s)) {
+ DispenserRegistry.c.warn("Missing translation for {}: {} (key: \'{}\')", s1, registrymaterials.b(object), s);
+@@ -480,6 +833,30 @@
+ BlockPosition blockposition = isourceblock.getBlockPosition().shift(enumdirection);
+ EnumDirection enumdirection1 = isourceblock.getWorld().isEmpty(blockposition.down()) ? enumdirection : EnumDirection.UP;
+
++ // CraftBukkit start
++ org.bukkit.block.Block bukkitBlock = isourceblock.getWorld().getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ());
++ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack);
+
-+ if (event.isCancelled()) {
-+ return itemstack;
-+ }
++ BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockposition.getX(), blockposition.getY(), blockposition.getZ()));
++ if (!BlockDispenser.eventFired) {
++ isourceblock.getWorld().getServer().getPluginManager().callEvent(event);
++ }
+
-+ if (!event.getItem().equals(craftItem)) {
-+ // Chain to handler for new item
-+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
-+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem());
-+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) {
-+ idispensebehavior.a(isourceblock, eventStack);
++ if (event.isCancelled()) {
+ return itemstack;
+ }
-+ }
-+ // CraftBukkit end
+
- this.b = world.a(block, blockposition, false, EnumDirection.DOWN, (Entity) null);
- if (this.b) {
- EnumDirection enumdirection1 = world.isEmpty(blockposition.down()) ? enumdirection : EnumDirection.UP;
-@@ -475,12 +820,40 @@
++ if (!event.getItem().equals(craftItem)) {
++ // Chain to handler for new item
++ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
++ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem());
++ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) {
++ idispensebehavior.dispense(isourceblock, eventStack);
++ return itemstack;
++ }
++ }
++ // CraftBukkit end
++
+ this.a = ((ItemBlock) item).a((BlockActionContext) (new DispenserRegistry.b(isourceblock.getWorld(), blockposition, enumdirection, itemstack, enumdirection1))) == EnumInteractionResult.SUCCESS;
+ if (this.a) {
+ itemstack.subtract(1);
+@@ -533,12 +910,40 @@
d3 = 0.0D;
}
@@ -521,7 +567,7 @@
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem());
+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) {
-+ idispensebehavior.a(isourceblock, eventStack);
++ idispensebehavior.dispense(isourceblock, eventStack);
+ return itemstack;
+ }
+ }
@@ -529,7 +575,7 @@
+ EntityBoat entityboat = new EntityBoat(world, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ());
+ // CraftBukkit end
- entityboat.setType(this.c);
+ entityboat.setType(this.b);
entityboat.yaw = enumdirection.l();
- world.addEntity(entityboat);
- itemstack.subtract(1);
diff --git a/nms-patches/Enchantment.patch b/nms-patches/Enchantment.patch
index 498dc965..25991604 100644
--- a/nms-patches/Enchantment.patch
+++ b/nms-patches/Enchantment.patch
@@ -1,18 +1,27 @@
--- a/net/minecraft/server/Enchantment.java
+++ b/net/minecraft/server/Enchantment.java
-@@ -20,7 +20,7 @@
- }
-
- public static int getId(Enchantment enchantment) {
-- return Enchantment.enchantments.a((Object) enchantment);
-+ return Enchantment.enchantments.a(enchantment); // CraftBukkit - fix decompile error
- }
-
+@@ -15,6 +15,17 @@
@Nullable
-@@ -155,6 +155,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()));
+ protected String d;
+
++ // CraftBukkit start - add back
++ @Nullable
++ public static Enchantment fromId(MinecraftKey key) {
++ return Enchantment.enchantments.get(key);
++ }
++
++ public static MinecraftKey getId(Enchantment enchantment) {
++ return Enchantment.enchantments.b(enchantment);
++ }
++ // CraftBukkit end
++
+ protected Enchantment(Enchantment.Rarity enchantment_rarity, EnchantmentSlotType enchantmentslottype, EnumItemSlot[] aenumitemslot) {
+ this.e = enchantment_rarity;
+ this.itemTarget = enchantmentslottype;
+@@ -153,6 +164,11 @@
+ a("channeling", new EnchantmentTridentChanneling(Enchantment.Rarity.VERY_RARE, new EnumItemSlot[] { EnumItemSlot.MAINHAND}));
+ a("mending", new EnchantmentMending(Enchantment.Rarity.RARE, EnumItemSlot.values()));
+ a("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));
@@ -20,4 +29,4 @@
+ // CraftBukkit end
}
- public static enum Rarity {
+ private static void a(String s, Enchantment enchantment) {
diff --git a/nms-patches/EnchantmentFrostWalker.patch b/nms-patches/EnchantmentFrostWalker.patch
index c4f9f2b8..5ebd39a3 100644
--- a/nms-patches/EnchantmentFrostWalker.patch
+++ b/nms-patches/EnchantmentFrostWalker.patch
@@ -10,14 +10,14 @@
public class EnchantmentFrostWalker extends Enchantment {
@@ -42,8 +45,11 @@
- IBlockData iblockdata1 = world.getType(blockposition_mutableblockposition1);
+ IBlockData iblockdata2 = 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)) {
-- world.setTypeUpdate(blockposition_mutableblockposition1, Blocks.FROSTED_ICE.getBlockData());
-- world.a(blockposition_mutableblockposition1.h(), Blocks.FROSTED_ICE, MathHelper.nextInt(entityliving.getRandom(), 60, 120));
+ if (iblockdata2.getMaterial() == Material.WATER && ((Integer) iblockdata2.get(BlockFluids.LEVEL)).intValue() == 0 && iblockdata.canPlace(world, blockposition_mutableblockposition1) && world.a(iblockdata, (BlockPosition) blockposition_mutableblockposition1)) {
+- world.setTypeUpdate(blockposition_mutableblockposition1, iblockdata);
+- world.I().a(blockposition_mutableblockposition1.h(), Blocks.FROSTED_ICE, MathHelper.nextInt(entityliving.getRandom(), 60, 120));
+ // CraftBukkit Start - Call EntityBlockFormEvent for Frost Walker
-+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition_mutableblockposition1, Blocks.FROSTED_ICE.getBlockData(), entityliving)) {
-+ world.a(blockposition_mutableblockposition1.h(), Blocks.FROSTED_ICE, MathHelper.nextInt(entityliving.getRandom(), 60, 120));
++ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition_mutableblockposition1, iblockdata, entityliving)) {
++ world.I().a(blockposition_mutableblockposition1.h(), Blocks.FROSTED_ICE, MathHelper.nextInt(entityliving.getRandom(), 60, 120));
+ }
+ // CraftBukkit End
}
diff --git a/nms-patches/EnchantmentThorns.patch b/nms-patches/EnchantmentThorns.patch
index 82ffbcd9..8f997f9e 100644
--- a/nms-patches/EnchantmentThorns.patch
+++ b/nms-patches/EnchantmentThorns.patch
@@ -1,6 +1,6 @@
--- a/net/minecraft/server/EnchantmentThorns.java
+++ b/net/minecraft/server/EnchantmentThorns.java
-@@ -29,7 +29,7 @@
+@@ -28,7 +28,7 @@
Random random = entityliving.getRandom();
ItemStack itemstack = EnchantmentManager.b(Enchantments.THORNS, entityliving);
diff --git a/nms-patches/Entity.patch b/nms-patches/Entity.patch
index 39777cd1..b7bc2f61 100644
--- a/nms-patches/Entity.patch
+++ b/nms-patches/Entity.patch
@@ -1,6 +1,6 @@
--- a/net/minecraft/server/Entity.java
+++ b/net/minecraft/server/Entity.java
-@@ -16,8 +16,48 @@
+@@ -19,8 +19,54 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -10,6 +10,7 @@
+import org.bukkit.Server;
+import org.bukkit.TravelAgent;
+import org.bukkit.block.BlockFace;
++import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Hanging;
+import org.bukkit.entity.LivingEntity;
+import org.bukkit.entity.Vehicle;
@@ -28,7 +29,7 @@
+import org.bukkit.plugin.PluginManager;
+// CraftBukkit end
+
- public abstract class Entity implements ICommandListener {
+ public abstract class Entity implements INamableTileEntity, ICommandListener {
+ // CraftBukkit start
+ private static final int CURRENT_LEVEL = 2;
@@ -44,15 +45,20 @@
+ }
+ return bukkitEntity;
+ }
-+ // CraftBukikt end
-+
- private static final Logger a = LogManager.getLogger();
- 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);
-@@ -102,6 +142,15 @@
- private boolean aI;
- private final double[] aJ;
- private long aK;
++
++ @Override
++ public CommandSender getBukkitSender(CommandListenerWrapper wrapper) {
++ return getBukkitEntity();
++ }
++ // CraftBukkit end
++
+ protected static final Logger i = LogManager.getLogger();
+ private static final List<ItemStack> a = Collections.emptyList();
+ private static final AxisAlignedBB b = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D);
+@@ -107,6 +153,15 @@
+ private boolean aK;
+ private final double[] aL;
+ private long aM;
+ // CraftBukkit start
+ public boolean valid;
+ public org.bukkit.projectiles.ProjectileSource projectileSource; // For projectiles only
@@ -63,9 +69,9 @@
+ }
+ // CraftBukkit end
- public Entity(World world) {
+ public Entity(EntityTypes<?> entitytypes, World world) {
this.id = Entity.entityCount++;
-@@ -208,6 +257,33 @@
+@@ -212,6 +267,33 @@
}
protected void setYawPitch(float f, float f1) {
@@ -99,8 +105,8 @@
this.yaw = f % 360.0F;
this.pitch = f1 % 360.0F;
}
-@@ -230,6 +306,51 @@
- this.Y();
+@@ -234,6 +316,51 @@
+ this.W();
}
+ // CraftBukkit start
@@ -108,16 +114,16 @@
+ // No clean way to break out of ticking once the entity has been copied to a new world, so instead we move the portalling later in the tick cycle
+ if (!this.world.isClientSide && this.world instanceof WorldServer) {
+ this.world.methodProfiler.a("portal");
-+ if (this.ak) {
++ if (this.an) {
+ MinecraftServer minecraftserver = this.world.getMinecraftServer();
+
+ if (true || minecraftserver.getAllowNether()) { // CraftBukkit
+ if (!this.isPassenger()) {
-+ int i = this.Z();
++ int i = this.X();
+
-+ if (this.al++ >= i) {
-+ this.al = i;
-+ this.portalCooldown = this.aM();
++ if (this.ao++ >= i) {
++ this.ao = i;
++ this.portalCooldown = this.aQ();
+ byte b0;
+
+ if (this.world.worldProvider.getDimensionManager().getDimensionID() == -1) {
@@ -126,32 +132,32 @@
+ b0 = -1;
+ }
+
-+ this.b(b0);
++ this.d(b0);
+ }
+ }
+
-+ this.ak = false;
++ this.an = false;
+ }
+ } else {
-+ if (this.al > 0) {
-+ this.al -= 4;
++ if (this.ao > 0) {
++ this.ao -= 4;
+ }
+
-+ if (this.al < 0) {
-+ this.al = 0;
++ if (this.ao < 0) {
++ this.ao = 0;
+ }
+ }
+
-+ this.I();
-+ this.world.methodProfiler.b();
++ this.E();
++ this.world.methodProfiler.e();
+ }
+ }
+ // CraftBukkit end
+
- public void Y() {
+ public void W() {
this.world.methodProfiler.a("entityBaseTick");
- if (this.isPassenger() && this.bJ().dead) {
-@@ -246,6 +367,8 @@
+ if (this.isPassenger() && this.getVehicle().dead) {
+@@ -250,6 +377,8 @@
this.lastZ = this.locZ;
this.lastPitch = this.pitch;
this.lastYaw = this.yaw;
@@ -159,16 +165,16 @@
+ /*
if (!this.world.isClientSide && this.world instanceof WorldServer) {
this.world.methodProfiler.a("portal");
- if (this.ak) {
-@@ -285,6 +408,7 @@
- this.I();
- this.world.methodProfiler.b();
+ if (this.an) {
+@@ -289,6 +418,7 @@
+ this.E();
+ this.world.methodProfiler.e();
}
+ */
- this.as();
- this.aq();
-@@ -336,6 +460,27 @@
+ this.av();
+ this.r();
+@@ -340,6 +470,27 @@
protected void burnFromLava() {
if (!this.fireProof) {
this.damageEntity(DamageSource.LAVA, 4.0F);
@@ -196,7 +202,7 @@
this.setOnFire(15);
}
}
-@@ -376,6 +521,22 @@
+@@ -378,6 +529,22 @@
this.a(this.getBoundingBox().d(d0, d1, d2));
this.recalcPosition();
} else {
@@ -219,7 +225,7 @@
if (enummovetype == EnumMoveType.PISTON) {
long i = this.world.getTime();
-@@ -517,7 +678,7 @@
+@@ -505,7 +672,7 @@
}
}
@@ -227,18 +233,18 @@
+ boolean flag = this.onGround || d1 != d8 && d1 < 0.0D; // CraftBukkit - decompile error
double d11;
- if (this.P > 0.0F && flag && (d7 != d0 || d9 != d2)) {
-@@ -615,7 +776,7 @@
+ if (this.Q > 0.0F && flag && (d7 != d0 || d9 != d2)) {
+@@ -592,7 +759,7 @@
this.world.methodProfiler.a("rest");
this.recalcPosition();
this.positionChanged = d7 != d0 || d9 != d2;
-- this.B = d1 != d1;
-+ this.B = d1 != d8; // CraftBukkit - decompile error
- this.onGround = this.B && d8 < 0.0D;
- this.C = this.positionChanged || this.B;
- l = MathHelper.floor(this.locX);
-@@ -650,6 +811,28 @@
- block1.a(this.world, this);
+- this.C = d1 != d1;
++ this.C = d1 != d8; // CraftBukkit - decompile error
+ this.onGround = this.C && d8 < 0.0D;
+ this.D = this.positionChanged || this.C;
+ int k = MathHelper.floor(this.locX);
+@@ -627,6 +794,28 @@
+ block1.a((IBlockAccess) this.world, this);
}
+ // CraftBukkit start
@@ -266,7 +272,7 @@
if (this.playStepSound() && (!this.onGround || !this.isSneaking() || !(this instanceof EntityHuman)) && !this.isPassenger()) {
double d22 = this.locX - d4;
double d23 = this.locY - d5;
-@@ -685,6 +868,8 @@
+@@ -662,6 +851,8 @@
}
}
@@ -275,16 +281,16 @@
try {
this.checkBlockCollisions();
} catch (Throwable throwable) {
-@@ -694,6 +879,8 @@
+@@ -671,6 +862,8 @@
this.appendEntityCrashDetails(crashreportsystemdetails);
throw new ReportedException(crashreport);
}
+ */
+ // CraftBukkit end
- boolean flag1 = this.an();
+ boolean flag1 = this.ap();
-@@ -702,7 +889,14 @@
+@@ -679,7 +872,14 @@
if (!flag1) {
++this.fireTicks;
if (this.fireTicks == 0) {
@@ -300,7 +306,7 @@
}
}
} else if (this.fireTicks <= 0) {
-@@ -834,7 +1028,7 @@
+@@ -875,7 +1075,7 @@
return null;
}
@@ -309,7 +315,7 @@
if (!this.fireProof) {
this.damageEntity(DamageSource.FIRE, (float) i);
}
-@@ -1008,6 +1202,13 @@
+@@ -1094,6 +1294,13 @@
}
public void spawnIn(World world) {
@@ -323,7 +329,7 @@
this.world = world;
}
-@@ -1245,6 +1446,18 @@
+@@ -1318,6 +1525,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}));
@@ -342,7 +348,7 @@
nbttagcompound.set("Rotation", this.a(new float[] { this.yaw, this.pitch}));
nbttagcompound.setFloat("FallDistance", this.fallDistance);
nbttagcompound.setShort("Fire", (short) this.fireTicks);
-@@ -1254,6 +1467,12 @@
+@@ -1327,6 +1546,12 @@
nbttagcompound.setBoolean("Invulnerable", this.invulnerable);
nbttagcompound.setInt("PortalCooldown", this.portalCooldown);
nbttagcompound.a("UUID", this.getUniqueID());
@@ -352,27 +358,27 @@
+ nbttagcompound.setLong("WorldUUIDMost", this.world.getDataManager().getUUID().getMostSignificantBits());
+ nbttagcompound.setInt("Bukkit.updateLevel", CURRENT_LEVEL);
+ // CraftBukkit end
- if (this.hasCustomName()) {
- nbttagcompound.setString("CustomName", this.getCustomName());
- }
-@@ -1329,6 +1548,8 @@
- this.motX = nbttaglist1.f(0);
- this.motY = nbttaglist1.f(1);
- this.motZ = nbttaglist1.f(2);
+ IChatBaseComponent ichatbasecomponent = this.getCustomName();
+
+ if (ichatbasecomponent != null) {
+@@ -1403,6 +1628,8 @@
+ this.motX = nbttaglist1.k(0);
+ this.motY = nbttaglist1.k(1);
+ this.motZ = nbttaglist1.k(2);
+
+ /* CraftBukkit start - Moved section down
if (Math.abs(this.motX) > 10.0D) {
this.motX = 0.0D;
}
-@@ -1340,6 +1561,7 @@
+@@ -1414,6 +1641,7 @@
if (Math.abs(this.motZ) > 10.0D) {
this.motZ = 0.0D;
}
+ // CraftBukkit end */
- this.locX = nbttaglist.f(0);
- this.locY = nbttaglist.f(1);
-@@ -1397,6 +1619,57 @@
+ this.locX = nbttaglist.k(0);
+ this.locY = nbttaglist.k(1);
+@@ -1470,6 +1698,57 @@
this.setPosition(this.locX, this.locY, this.locZ);
}
@@ -430,7 +436,7 @@
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.a(throwable, "Loading entity NBT");
CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Entity being loaded");
-@@ -1464,6 +1737,12 @@
+@@ -1543,6 +1822,12 @@
if (itemstack.isEmpty()) {
return null;
} else {
@@ -442,9 +448,9 @@
+ // CraftBukkit end
EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY + (double) f, this.locZ, itemstack);
- entityitem.q();
-@@ -1589,6 +1868,24 @@
- if (entity.bJ() != this) {
+ entityitem.n();
+@@ -1687,6 +1972,24 @@
+ if (entity.getVehicle() != this) {
throw new IllegalStateException("Use x.startRiding(y), not y.addPassenger(x)");
} else {
+ // CraftBukkit start
@@ -465,11 +471,11 @@
+ }
+ }
+ // CraftBukkit end
- if (!this.world.isClientSide && entity instanceof EntityHuman && !(this.bE() instanceof EntityHuman)) {
+ if (!this.world.isClientSide && entity instanceof EntityHuman && !(this.bO() instanceof EntityHuman)) {
this.passengers.add(0, entity);
} else {
-@@ -1602,6 +1899,22 @@
- if (entity.bJ() == this) {
+@@ -1700,6 +2003,22 @@
+ if (entity.getVehicle() == this) {
throw new IllegalStateException("Use x.stopRiding(y), not y.removePassenger(x)");
} else {
+ // CraftBukkit start
@@ -489,20 +495,20 @@
+ }
+ // CraftBukkit end
this.passengers.remove(entity);
- entity.j = 60;
+ entity.k = 60;
}
-@@ -1741,14 +2054,49 @@
+@@ -1859,14 +2178,49 @@
}
public void setAirTicks(int i) {
-- this.datawatcher.set(Entity.aA, Integer.valueOf(i));
+- this.datawatcher.set(Entity.aD, Integer.valueOf(i));
+ // CraftBukkit start
+ EntityAirChangeEvent event = new EntityAirChangeEvent(this.getBukkitEntity(), i);
+ event.getEntity().getServer().getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ return;
+ }
-+ this.datawatcher.set(Entity.aA, Integer.valueOf(event.getAmount()));
++ this.datawatcher.set(Entity.aD, Integer.valueOf(event.getAmount()));
+ // CraftBukkit end
}
@@ -544,10 +550,10 @@
}
}
-@@ -1893,19 +2241,76 @@
+@@ -2035,19 +2389,76 @@
if (!this.world.isClientSide && !this.dead) {
this.world.methodProfiler.a("changeDimension");
- MinecraftServer minecraftserver = this.C_();
+ MinecraftServer minecraftserver = this.bK();
- int j = this.dimension;
- WorldServer worldserver = minecraftserver.getWorldServer(j);
- WorldServer worldserver1 = minecraftserver.getWorldServer(i);
@@ -596,7 +602,7 @@
+
+ // Need to make sure the profiler state is reset afterwards (but we still want to time the call)
+ Entity entity = this.teleportTo(exit, true);
-+ this.world.methodProfiler.b();
++ this.world.methodProfiler.e();
+ return entity;
+ }
+ return null;
@@ -612,7 +618,7 @@
this.dimension = i;
+ /* CraftBukkit start - TODO: Check if we need this
if (j == 1 && i == 1) {
- worldserver1 = minecraftserver.getWorldServer(0);
+ worldserver1 = minecraftserver.a(DimensionManager.OVERWORLD);
this.dimension = 0;
}
+ // CraftBukkit end */
@@ -624,7 +630,7 @@
BlockPosition blockposition;
if (i == 1) {
-@@ -1934,12 +2339,18 @@
+@@ -2076,12 +2487,18 @@
blockposition = new BlockPosition(this);
}
@@ -636,15 +642,15 @@
+ // worldserver.entityJoinedWorld(this, false); // Handled in repositionEntity
+ // CraftBukkit end
this.world.methodProfiler.c("reloading");
- Entity entity = EntityTypes.a(this.getClass(), (World) worldserver1);
+ Entity entity = this.P().a((World) worldserver1);
if (entity != null) {
- entity.a(this);
+ entity.v(this);
+ /* CraftBukkit start - We need to do this...
if (j == 1 && i == 1) {
- BlockPosition blockposition1 = worldserver1.q(worldserver1.getSpawn());
+ BlockPosition blockposition1 = worldserver1.getHighestBlockYAt(HeightMap.Type.MOTION_BLOCKING_NO_LEAVES, worldserver1.getSpawn());
-@@ -1947,6 +2358,7 @@
+@@ -2089,6 +2506,7 @@
} else {
entity.setPositionRotation(blockposition, entity.yaw, entity.pitch);
}
@@ -652,7 +658,7 @@
boolean flag = entity.attachedToPlayer;
-@@ -1954,13 +2366,21 @@
+@@ -2096,13 +2514,21 @@
worldserver1.addEntity(entity);
entity.attachedToPlayer = flag;
worldserver1.entityJoinedWorld(entity, false);
@@ -667,27 +673,15 @@
}
this.dead = true;
- this.world.methodProfiler.b();
- worldserver.m();
- worldserver1.m();
-- this.world.methodProfiler.b();
-+ // this.world.methodProfiler.b(); // CraftBukkit: Moved up to keep balanced
+ this.world.methodProfiler.e();
+ worldserver.q_();
+ worldserver1.q_();
+- this.world.methodProfiler.e();
++ // this.world.methodProfiler.e(); // CraftBukkit: Moved up to keep balanced
return entity;
} else {
return null;
-@@ -2064,6 +2484,11 @@
- }
-
- public void setCustomName(String s) {
-+ // CraftBukkit start - Add a sane limit for name length
-+ if (s.length() > 256) {
-+ s = s.substring(0, 256);
-+ }
-+ // CraftBukkit end
- this.datawatcher.set(Entity.aB, s);
- }
-
-@@ -2121,7 +2546,26 @@
+@@ -2242,7 +2668,26 @@
}
public void a(AxisAlignedBB axisalignedbb) {
@@ -715,12 +709,3 @@
}
public float getHeadHeight() {
-@@ -2295,7 +2739,7 @@
- for (Iterator iterator = this.bF().iterator(); iterator.hasNext(); entity.a(oclass, set)) {
- entity = (Entity) iterator.next();
- if (oclass.isAssignableFrom(entity.getClass())) {
-- set.add(entity);
-+ set.add((T) entity); // CraftBukkit - decompile error
- }
- }
-
diff --git a/nms-patches/EntityAgeable.patch b/nms-patches/EntityAgeable.patch
index 5800328e..02e44b54 100644
--- a/nms-patches/EntityAgeable.patch
+++ b/nms-patches/EntityAgeable.patch
@@ -2,22 +2,22 @@
+++ b/net/minecraft/server/EntityAgeable.java
@@ -10,6 +10,7 @@
protected int c;
- private float by = -1.0F;
- private float bz;
+ private float bD = -1.0F;
+ private float bE;
+ public boolean ageLocked; // CraftBukkit
- public EntityAgeable(World world) {
- super(world);
-@@ -31,7 +32,7 @@
- if (entityageable != null) {
- entityageable.setAgeRaw(-24000);
- entityageable.setPositionRotation(this.locX, this.locY, this.locZ, 0.0F, 0.0F);
-- this.world.addEntity(entityageable);
-+ this.world.addEntity(entityageable, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG); // CraftBukkit
- if (itemstack.hasName()) {
- entityageable.setCustomName(itemstack.getName());
- }
-@@ -110,12 +111,14 @@
+ protected EntityAgeable(EntityTypes<?> entitytypes, World world) {
+ super(entitytypes, world);
+@@ -29,7 +30,7 @@
+ if (entityageable != null) {
+ entityageable.setAgeRaw(-24000);
+ entityageable.setPositionRotation(this.locX, this.locY, this.locZ, 0.0F, 0.0F);
+- this.world.addEntity(entityageable);
++ this.world.addEntity(entityageable, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG); // CraftBukkit
+ if (itemstack.hasName()) {
+ entityageable.setCustomName(itemstack.getName());
+ }
+@@ -97,12 +98,14 @@
super.b(nbttagcompound);
nbttagcompound.setInt("Age", this.getAge());
nbttagcompound.setInt("ForcedAge", this.b);
@@ -32,12 +32,12 @@
}
public void a(DataWatcherObject<?> datawatcherobject) {
-@@ -128,7 +131,7 @@
+@@ -115,7 +118,7 @@
- public void n() {
- super.n();
+ public void k() {
+ super.k();
- if (this.world.isClientSide) {
+ if (this.world.isClientSide || ageLocked) { // CraftBukkit
if (this.c > 0) {
if (this.c % 4 == 0) {
- this.world.addParticle(EnumParticle.VILLAGER_HAPPY, this.locX + (double) (this.random.nextFloat() * this.width * 2.0F) - (double) this.width, this.locY + 0.5D + (double) (this.random.nextFloat() * this.length), this.locZ + (double) (this.random.nextFloat() * this.width * 2.0F) - (double) this.width, 0.0D, 0.0D, 0.0D, new int[0]);
+ this.world.addParticle(Particles.z, this.locX + (double) (this.random.nextFloat() * this.width * 2.0F) - (double) this.width, this.locY + 0.5D + (double) (this.random.nextFloat() * this.length), this.locZ + (double) (this.random.nextFloat() * this.width * 2.0F) - (double) this.width, 0.0D, 0.0D, 0.0D);
diff --git a/nms-patches/EntityAnimal.patch b/nms-patches/EntityAnimal.patch
index 80469e67..a095cddf 100644
--- a/nms-patches/EntityAnimal.patch
+++ b/nms-patches/EntityAnimal.patch
@@ -1,13 +1,13 @@
--- a/net/minecraft/server/EntityAnimal.java
+++ b/net/minecraft/server/EntityAnimal.java
@@ -8,6 +8,7 @@
- protected Block bA;
- private int bx;
- private UUID by;
+ protected Block bF;
+ private int bC;
+ private UUID bD;
+ public ItemStack breedItem; // CraftBukkit - Add breedItem variable
- public EntityAnimal(World world) {
- super(world);
+ protected EntityAnimal(EntityTypes<?> entitytypes, World world) {
+ super(entitytypes, world);
@@ -41,6 +42,9 @@
}
@@ -24,11 +24,11 @@
}
+ // CraftBukkit end */
- public float a(BlockPosition blockposition) {
- return this.world.getType(blockposition.down()).getBlock() == this.bA ? 10.0F : this.world.n(blockposition) - 0.5F;
-@@ -130,6 +135,7 @@
+ public float a(BlockPosition blockposition, IWorldReader iworldreader) {
+ return iworldreader.getType(blockposition.down()).getBlock() == this.bF ? 10.0F : iworldreader.A(blockposition) - 0.5F;
+@@ -134,6 +139,7 @@
if (entityhuman != null) {
- this.by = entityhuman.getUniqueID();
+ this.bD = entityhuman.getUniqueID();
}
+ this.breedItem = entityhuman.inventory.getItemInHand(); // CraftBukkit
diff --git a/nms-patches/EntityAreaEffectCloud.patch b/nms-patches/EntityAreaEffectCloud.patch
index c5009a55..ab14a3ca 100644
--- a/nms-patches/EntityAreaEffectCloud.patch
+++ b/nms-patches/EntityAreaEffectCloud.patch
@@ -1,6 +1,6 @@
--- a/net/minecraft/server/EntityAreaEffectCloud.java
+++ b/net/minecraft/server/EntityAreaEffectCloud.java
-@@ -8,6 +8,10 @@
+@@ -10,6 +10,10 @@
import java.util.List;
import java.util.Map;
import java.util.UUID;
@@ -10,15 +10,15 @@
+
import java.util.Map.Entry;
import javax.annotation.Nullable;
-
-@@ -101,6 +105,22 @@
+ import org.apache.logging.log4j.LogManager;
+@@ -102,6 +106,22 @@
}
+ // CraftBukkit start accessor methods
+ public void refreshEffects() {
+ if (!this.hasColor) {
-+ this.getDataWatcher().set(EntityAreaEffectCloud.b, Integer.valueOf(PotionUtil.a((Collection) PotionUtil.a(this.potionRegistry, (Collection) this.effects)))); // PAIL: rename
++ this.getDataWatcher().set(EntityAreaEffectCloud.c, Integer.valueOf(PotionUtil.a((Collection) PotionUtil.a(this.potionRegistry, (Collection) this.effects)))); // PAIL: rename
+ }
+ }
+
@@ -32,9 +32,9 @@
+ // CraftBukkit end
+
public int getColor() {
- return ((Integer) this.getDataWatcher().get(EntityAreaEffectCloud.b)).intValue();
+ return ((Integer) this.getDataWatcher().get(EntityAreaEffectCloud.c)).intValue();
}
-@@ -270,6 +290,7 @@
+@@ -245,6 +265,7 @@
if (!list.isEmpty()) {
Iterator iterator2 = list.iterator();
@@ -42,7 +42,7 @@
while (iterator2.hasNext()) {
EntityLiving entityliving = (EntityLiving) iterator2.next();
-@@ -279,6 +300,17 @@
+@@ -254,6 +275,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.at.put(entityliving, Integer.valueOf(this.ticksLived + this.reapplicationDelay));
+ this.h.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 496a0925..a0f06e68 100644
--- a/nms-patches/EntityArmorStand.patch
+++ b/nms-patches/EntityArmorStand.patch
@@ -1,7 +1,7 @@
--- a/net/minecraft/server/EntityArmorStand.java
+++ b/net/minecraft/server/EntityArmorStand.java
@@ -5,6 +5,15 @@
- import java.util.List;
+ import java.util.function.Predicate;
import javax.annotation.Nullable;
+// CraftBukkit start
@@ -15,8 +15,8 @@
+
public class EntityArmorStand extends EntityLiving {
- private static final Vector3f br = new Vector3f(0.0F, 0.0F, 0.0F);
-@@ -61,6 +70,13 @@
+ private static final Vector3f bx = new Vector3f(0.0F, 0.0F, 0.0F);
+@@ -56,6 +65,13 @@
this.setPosition(d0, d1, d2);
}
@@ -30,9 +30,9 @@
public final void setSize(float f, float f1) {
double d0 = this.locX;
double d1 = this.locY;
-@@ -364,6 +380,21 @@
- if (itemstack1.isEmpty() || (this.bB & 1 << enumitemslot.c() + 8) == 0) {
- if (!itemstack1.isEmpty() || (this.bB & 1 << enumitemslot.c() + 16) == 0) {
+@@ -355,6 +371,21 @@
+ if (itemstack1.isEmpty() || (this.bH & 1 << enumitemslot.c() + 8) == 0) {
+ if (!itemstack1.isEmpty() || (this.bH & 1 << enumitemslot.c() + 16) == 0) {
ItemStack itemstack2;
+ // CraftBukkit start
+ org.bukkit.inventory.ItemStack armorStandItem = CraftItemStack.asCraftMirror(itemstack1);
@@ -52,7 +52,7 @@
if (entityhuman.abilities.canInstantlyBuild && itemstack1.isEmpty() && !itemstack.isEmpty()) {
itemstack2 = itemstack.cloneItemStack();
-@@ -385,14 +416,19 @@
+@@ -376,14 +407,19 @@
}
public boolean damageEntity(DamageSource damagesource, float f) {
@@ -66,69 +66,69 @@
- this.die();
+ this.killEntity(); // CraftBukkit - this.die() -> this.killEntity()
return false;
- } else if (!this.isInvulnerable(damagesource) && !this.bA && !this.isMarker()) {
+ } else if (!this.isInvulnerable(damagesource) && !this.bG && !this.isMarker()) {
if (damagesource.isExplosion()) {
- this.F();
+ this.D();
- this.die();
+ this.killEntity(); // CraftBukkit - this.die() -> this.killEntity()
return false;
} else if (DamageSource.FIRE.equals(damagesource)) {
if (this.isBurning()) {
-@@ -421,7 +457,7 @@
- } else if (damagesource.u()) {
- this.H();
- this.D();
+@@ -407,7 +443,7 @@
+ } else if (damagesource.v()) {
+ this.F();
+ this.A();
+- this.die();
++ this.killEntity(); // CraftBukkit - this.die() -> this.killEntity()
+ return false;
+ } else {
+ long i = this.world.getTime();
+@@ -418,7 +454,7 @@
+ } else {
+ this.B();
+ this.A();
- this.die();
+ this.killEntity(); // CraftBukkit - this.die() -> this.killEntity()
- return false;
- } else {
- long i = this.world.getTime();
-@@ -432,7 +468,7 @@
- } else {
- this.E();
- this.D();
-- this.die();
-+ this.killEntity(); // CraftBukkit - this.die() -> this.killEntity()
- }
+ }
- return false;
-@@ -460,7 +496,7 @@
+ return true;
+@@ -445,7 +481,7 @@
f1 -= f;
if (f1 <= 0.5F) {
- this.F();
+ this.D();
- this.die();
+ this.killEntity(); // CraftBukkit - this.die() -> this.killEntity()
} else {
this.setHealth(f1);
}
-@@ -468,7 +504,7 @@
+@@ -453,7 +489,7 @@
}
- private void E() {
+ private void B() {
- Block.a(this.world, new BlockPosition(this), new ItemStack(Items.ARMOR_STAND));
+ drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(new ItemStack(Items.ARMOR_STAND))); // CraftBukkit - add to drops
- this.F();
+ this.D();
}
-@@ -481,7 +517,7 @@
- for (i = 0; i < this.by.size(); ++i) {
- itemstack = (ItemStack) this.by.get(i);
+@@ -466,7 +502,7 @@
+ for (i = 0; i < this.bE.size(); ++i) {
+ itemstack = (ItemStack) this.bE.get(i);
if (!itemstack.isEmpty()) {
- Block.a(this.world, (new BlockPosition(this)).up(), itemstack);
+ drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemstack)); // CraftBukkit - add to drops
- this.by.set(i, ItemStack.a);
+ this.bE.set(i, ItemStack.a);
}
}
-@@ -489,7 +525,7 @@
- for (i = 0; i < this.bz.size(); ++i) {
- itemstack = (ItemStack) this.bz.get(i);
+@@ -474,7 +510,7 @@
+ for (i = 0; i < this.bF.size(); ++i) {
+ itemstack = (ItemStack) this.bF.get(i);
if (!itemstack.isEmpty()) {
- Block.a(this.world, (new BlockPosition(this)).up(), itemstack);
+ drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemstack)); // CraftBukkit - add to drops
- this.bz.set(i, ItemStack.a);
+ this.bF.set(i, ItemStack.a);
}
}
-@@ -601,6 +637,7 @@
+@@ -586,6 +622,7 @@
}
public void killEntity() {
diff --git a/nms-patches/EntityArrow.patch b/nms-patches/EntityArrow.patch
index 3d27615c..91b2b41f 100644
--- a/nms-patches/EntityArrow.patch
+++ b/nms-patches/EntityArrow.patch
@@ -1,7 +1,7 @@
--- a/net/minecraft/server/EntityArrow.java
+++ b/net/minecraft/server/EntityArrow.java
@@ -5,6 +5,13 @@
- import java.util.List;
+ import java.util.function.Predicate;
import javax.annotation.Nullable;
+// CraftBukkit start
@@ -13,58 +13,44 @@
+
public abstract class EntityArrow extends Entity implements IProjectile {
- private static final Predicate<Entity> f = Predicates.and(new Predicate[] { IEntitySelector.e, IEntitySelector.a, new Predicate() {
-@@ -17,9 +24,9 @@
- }
- }});
- private static final DataWatcherObject<Byte> g = DataWatcher.a(EntityArrow.class, DataWatcherRegistry.a);
-- private int h;
-- private int at;
-- private int au;
-+ public int h; // PAIL: private->public
-+ public int at; // PAIL: private->public
-+ public int au; // PAIL: private->public
- private Block av;
- private int aw;
- public boolean inGround;
-@@ -50,6 +57,7 @@
- public EntityArrow(World world, EntityLiving entityliving) {
- this(world, entityliving.locX, entityliving.locY + (double) entityliving.getHeadHeight() - 0.10000000149011612D, entityliving.locZ);
+ private static final Predicate<Entity> f = IEntitySelector.e.and(IEntitySelector.a.and(Entity::isInteractable));
+@@ -42,6 +49,7 @@
+ protected EntityArrow(EntityTypes<?> entitytypes, EntityLiving entityliving, World world) {
+ this(entitytypes, entityliving.locX, entityliving.locY + (double) entityliving.getHeadHeight() - 0.10000000149011612D, entityliving.locZ, world);
this.shooter = entityliving;
+ this.projectileSource = (LivingEntity) entityliving.getBukkitEntity(); // CraftBukkit
if (entityliving instanceof EntityHuman) {
this.fromPlayer = EntityArrow.PickupStatus.ALLOWED;
}
-@@ -236,7 +244,7 @@
+@@ -245,6 +253,7 @@
+ }
protected void a(MovingObjectPosition movingobjectposition) {
- Entity entity = movingobjectposition.entity;
--
+ org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this, movingobjectposition); // CraftBukkit - Call event
- 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 +262,13 @@
- }
+ if (movingobjectposition.entity != null) {
+ this.b(movingobjectposition);
+ } else {
+@@ -293,7 +302,13 @@
+ }
- if (this.isBurning() && !(entity instanceof EntityEnderman)) {
-- entity.setOnFire(5);
-+ // CraftBukkit start
-+ EntityCombustByEntityEvent combustEvent = new EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), 5);
-+ org.bukkit.Bukkit.getPluginManager().callEvent(combustEvent);
-+ if (!combustEvent.isCancelled()) {
-+ entity.setOnFire(combustEvent.getDuration());
-+ }
-+ // CraftBukkit end
- }
+ if (this.isBurning() && !(entity instanceof EntityEnderman)) {
+- entity.setOnFire(5);
++ // CraftBukkit start
++ EntityCombustByEntityEvent combustEvent = new EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), 5);
++ org.bukkit.Bukkit.getPluginManager().callEvent(combustEvent);
++ if (!combustEvent.isCancelled()) {
++ entity.setOnFire(combustEvent.getDuration());
++ }
++ // CraftBukkit end
+ }
- if (entity.damageEntity(damagesource, (float) i)) {
-@@ -422,9 +436,22 @@
+ if (entity.damageEntity(damagesource, (float) i)) {
+@@ -430,9 +445,22 @@
public void d(EntityHuman entityhuman) {
- if (!this.world.isClientSide && this.inGround && this.shake <= 0) {
+ if (!this.world.isClientSide && (this.inGround || this.p()) && this.shake <= 0) {
+ // CraftBukkit start
-+ ItemStack itemstack = this.j(); // PAIL: rename
++ ItemStack itemstack = this.getItemStack();
+ EntityItem item = new EntityItem(this.world, this.locX, this.locY, this.locZ, itemstack);
+ if (this.fromPlayer == PickupStatus.ALLOWED && entityhuman.inventory.canHold(itemstack) > 0) {
+ PlayerPickupArrowEvent event = new PlayerPickupArrowEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), new org.bukkit.craftbukkit.entity.CraftItem(this.world.getServer(), this, item), (org.bukkit.entity.Arrow) this.getBukkitEntity());
@@ -75,15 +61,15 @@
+ return;
+ }
+ }
- boolean flag = this.fromPlayer == EntityArrow.PickupStatus.ALLOWED || this.fromPlayer == EntityArrow.PickupStatus.CREATIVE_ONLY && entityhuman.abilities.canInstantlyBuild;
+ boolean flag = this.fromPlayer == EntityArrow.PickupStatus.ALLOWED || this.fromPlayer == EntityArrow.PickupStatus.CREATIVE_ONLY && entityhuman.abilities.canInstantlyBuild || this.p() && this.shooter == entityhuman;
-- if (this.fromPlayer == EntityArrow.PickupStatus.ALLOWED && !entityhuman.inventory.pickup(this.j())) {
+- if (this.fromPlayer == EntityArrow.PickupStatus.ALLOWED && !entityhuman.inventory.pickup(this.getItemStack())) {
+ if (this.fromPlayer == EntityArrow.PickupStatus.ALLOWED && !entityhuman.inventory.pickup(item.getItemStack())) {
+ // CraftBukkit end
flag = false;
}
-@@ -493,7 +520,14 @@
+@@ -505,7 +533,14 @@
}
if (EnchantmentManager.a(Enchantments.ARROW_FIRE, entityliving) > 0) {
diff --git a/nms-patches/EntityBoat.patch b/nms-patches/EntityBoat.patch
index e322502a..949598f6 100644
--- a/nms-patches/EntityBoat.patch
+++ b/nms-patches/EntityBoat.patch
@@ -1,6 +1,6 @@
--- a/net/minecraft/server/EntityBoat.java
+++ b/net/minecraft/server/EntityBoat.java
-@@ -5,6 +5,15 @@
+@@ -3,6 +3,15 @@
import java.util.List;
import javax.annotation.Nullable;
@@ -16,9 +16,9 @@
public class EntityBoat extends Entity {
private static final DataWatcherObject<Integer> a = DataWatcher.a(EntityBoat.class, DataWatcherRegistry.b);
-@@ -32,6 +41,14 @@
- private EntityBoat.EnumStatus aH;
- private double aI;
+@@ -37,6 +46,14 @@
+ private float aR;
+ private float aS;
+ // CraftBukkit start
+ // PAIL: Some of these haven't worked since a few updates, and since 1.9 they are less and less applicable.
@@ -29,9 +29,9 @@
+ // CraftBukkit end
+
public EntityBoat(World world) {
- super(world);
- this.f = new float[2];
-@@ -95,6 +112,19 @@
+ super(EntityTypes.BOAT, world);
+ this.h = new float[2];
+@@ -94,6 +111,19 @@
if (damagesource instanceof EntityDamageSourceIndirect && damagesource.getEntity() != null && this.w(damagesource.getEntity())) {
return false;
} else {
@@ -48,13 +48,13 @@
+ // f = event.getDamage(); // TODO Why don't we do this?
+ // CraftBukkit end
+
- this.d(-this.r());
- this.c(10);
- this.setDamage(this.p() + f * 10.0F);
-@@ -102,6 +132,15 @@
+ this.c(-this.o());
+ this.b(10);
+ this.setDamage(this.m() + f * 10.0F);
+@@ -101,6 +131,15 @@
boolean flag = damagesource.getEntity() instanceof EntityHuman && ((EntityHuman) damagesource.getEntity()).abilities.canInstantlyBuild;
- if (flag || this.p() > 40.0F) {
+ if (flag || this.m() > 40.0F) {
+ // CraftBukkit start
+ VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, attacker);
+ this.world.getServer().getPluginManager().callEvent(destroyEvent);
@@ -65,9 +65,9 @@
+ }
+ // CraftBukkit end
if (!flag && this.world.getGameRules().getBoolean("doEntityDrops")) {
- this.a(this.j(), 1, 0.0F);
+ this.a((IMaterial) this.f());
}
-@@ -119,9 +158,25 @@
+@@ -134,9 +173,25 @@
public void collide(Entity entity) {
if (entity instanceof EntityBoat) {
if (entity.getBoundingBox().b < this.getBoundingBox().e) {
@@ -93,23 +93,15 @@
super.collide(entity);
}
-@@ -158,6 +213,7 @@
+@@ -173,6 +228,7 @@
return this.getDirection().e();
}
+ private Location lastLocation; // CraftBukkit
- public void B_() {
- this.aH = this.aG;
- this.aG = this.u();
-@@ -178,7 +234,6 @@
- if (this.p() > 0.0F) {
- this.setDamage(this.p() - 1.0F);
- }
--
- this.lastX = this.locX;
- this.lastY = this.locY;
- this.lastZ = this.locZ;
-@@ -202,6 +257,22 @@
+ public void tick() {
+ this.aM = this.aL;
+ this.aL = this.s();
+@@ -217,6 +273,22 @@
this.motZ = 0.0D;
}
@@ -129,12 +121,12 @@
+ lastLocation = vehicle.getLocation();
+ // CraftBukkit end
+
+ this.q();
+
for (int i = 0; i <= 1; ++i) {
- if (this.a(i)) {
- if (!this.isSilent() && (double) (this.f[i] % 6.2831855F) <= 0.7853981852531433D && ((double) this.f[i] + 0.39269909262657166D) % 6.2831854820251465D >= 0.7853981852531433D) {
-@@ -622,6 +693,11 @@
+@@ -737,6 +809,11 @@
- this.e(this.fallDistance, 1.0F);
+ this.c(this.fallDistance, 1.0F);
if (!this.world.isClientSide && !this.dead) {
+ // CraftBukkit start
+ Vehicle vehicle = (Vehicle) this.getBukkitEntity();
@@ -144,7 +136,7 @@
this.die();
if (this.world.getGameRules().getBoolean("doEntityDrops")) {
int i;
-@@ -635,6 +711,7 @@
+@@ -750,6 +827,7 @@
}
}
}
diff --git a/nms-patches/EntityChicken.patch b/nms-patches/EntityChicken.patch
index d98f010b..11ec20a8 100644
--- a/nms-patches/EntityChicken.patch
+++ b/nms-patches/EntityChicken.patch
@@ -1,24 +1,24 @@
--- a/net/minecraft/server/EntityChicken.java
+++ b/net/minecraft/server/EntityChicken.java
-@@ -44,6 +44,11 @@
+@@ -42,6 +42,11 @@
}
- public void n() {
+ public void k() {
+ // CraftBukkit start
+ if (this.isChickenJockey()) {
+ this.persistent = !this.isTypeNotPersistent();
+ }
+ // CraftBukkit end
- super.n();
- this.bB = this.bx;
- this.bz = this.by;
-@@ -61,7 +66,9 @@
- this.bx += this.bC * 2.0F;
- if (!this.world.isClientSide && !this.isBaby() && !this.isChickenJockey() && --this.bD <= 0) {
- this.a(SoundEffects.af, 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F);
+ super.k();
+ this.bG = this.bC;
+ this.bE = this.bD;
+@@ -59,7 +64,9 @@
+ this.bC += this.bH * 2.0F;
+ if (!this.world.isClientSide && !this.isBaby() && !this.isChickenJockey() && --this.bI <= 0) {
+ this.a(SoundEffects.ENTITY_CHICKEN_EGG, 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F);
+ this.forceDrops = true; // CraftBukkit
- this.a(Items.EGG, 1);
+ this.a((IMaterial) Items.EGG);
+ this.forceDrops = false; // CraftBukkit
- this.bD = this.random.nextInt(6000) + 6000;
+ this.bI = this.random.nextInt(6000) + 6000;
}
diff --git a/nms-patches/EntityCow.patch b/nms-patches/EntityCow.patch
index a69a0750..fda4509e 100644
--- a/nms-patches/EntityCow.patch
+++ b/nms-patches/EntityCow.patch
@@ -24,7 +24,7 @@
+ }
+
+ ItemStack result = CraftItemStack.asNMSCopy(event.getItemStack());
- entityhuman.a(SoundEffects.au, 1.0F, 1.0F);
+ entityhuman.a(SoundEffects.ENTITY_COW_MILK, 1.0F, 1.0F);
itemstack.subtract(1);
if (itemstack.isEmpty()) {
- entityhuman.a(enumhand, new ItemStack(Items.MILK_BUCKET));
diff --git a/nms-patches/EntityCreature.patch b/nms-patches/EntityCreature.patch
index 7813c998..6580470d 100644
--- a/nms-patches/EntityCreature.patch
+++ b/nms-patches/EntityCreature.patch
@@ -1,8 +1,7 @@
--- a/net/minecraft/server/EntityCreature.java
+++ b/net/minecraft/server/EntityCreature.java
-@@ -2,6 +2,10 @@
-
- import java.util.UUID;
+@@ -1,5 +1,9 @@
+ package net.minecraft.server;
+// CraftBukkit start
+import org.bukkit.event.entity.EntityUnleashEvent;
@@ -10,8 +9,8 @@
+
public abstract class EntityCreature extends EntityInsentient {
- public static final UUID bv = UUID.fromString("E199AD21-BA8A-4C53-8D13-6182D5C69D3A");
-@@ -68,6 +72,7 @@
+ private BlockPosition a;
+@@ -66,6 +70,7 @@
if (this instanceof EntityTameableAnimal && ((EntityTameableAnimal) this).isSitting()) {
if (f > 10.0F) {
@@ -19,9 +18,9 @@
this.unleash(true, true);
}
-@@ -76,6 +81,7 @@
+@@ -74,6 +79,7 @@
- this.q(f);
+ this.u(f);
if (f > 10.0F) {
+ this.world.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE)); // CraftBukkit
this.unleash(true, true);
diff --git a/nms-patches/EntityCreeper.patch b/nms-patches/EntityCreeper.patch
index 580aeb91..4a0912c6 100644
--- a/nms-patches/EntityCreeper.patch
+++ b/nms-patches/EntityCreeper.patch
@@ -11,18 +11,7 @@
public class EntityCreeper extends EntityMonster {
-@@ -11,8 +15,8 @@
- private static final DataWatcherObject<Boolean> c = DataWatcher.a(EntityCreeper.class, DataWatcherRegistry.h);
- private int bx;
- private int fuseTicks;
-- private int maxFuseTicks = 30;
-- private int explosionRadius = 3;
-+ public int maxFuseTicks = 30; // PAIL private -> public
-+ public int explosionRadius = 3; // PAIL private -> public
- private int bB;
-
- public EntityCreeper(World world) {
-@@ -125,7 +129,7 @@
+@@ -121,7 +125,7 @@
}
public void die(DamageSource damagesource) {
@@ -30,16 +19,16 @@
+ // super.die(damagesource); // CraftBukkit - Moved to end
if (this.world.getGameRules().getBoolean("doMobLoot")) {
if (damagesource.getEntity() instanceof EntitySkeleton) {
- int i = Item.getId(Items.RECORD_13);
-@@ -138,6 +142,7 @@
- this.a(new ItemStack(Items.SKULL, 1, 4), 0.0F);
+ this.a((IMaterial) ItemRecord.a(this.random));
+@@ -130,6 +134,7 @@
+ this.a((IMaterial) Items.CREEPER_HEAD);
}
}
+ super.die(damagesource); // CraftBukkit - Moved from above
}
-@@ -164,9 +169,19 @@
+@@ -156,9 +161,19 @@
public void onLightningStrike(EntityLightning entitylightning) {
super.onLightningStrike(entitylightning);
@@ -60,22 +49,22 @@
protected boolean a(EntityHuman entityhuman, EnumHand enumhand) {
ItemStack itemstack = entityhuman.b(enumhand);
-@@ -188,10 +203,18 @@
+@@ -180,10 +195,18 @@
boolean flag = this.world.getGameRules().getBoolean("mobGriefing");
float f = this.isPowered() ? 2.0F : 1.0F;
-- this.aU = true;
+- this.aX = true;
- this.world.explode(this, this.locX, this.locY, this.locZ, (float) this.explosionRadius * f, flag);
- this.die();
-- this.ds();
+- this.dF();
+ // CraftBukkit start
+ ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), this.explosionRadius * f, false);
+ this.world.getServer().getPluginManager().callEvent(event);
+ if (!event.isCancelled()) {
-+ this.aU = true;
++ this.aX = true;
+ this.world.createExplosion(this, this.locX, this.locY, this.locZ, event.getRadius(), event.getFire(), flag);
+ this.die();
-+ this.ds();
++ this.dF();
+ } else {
+ fuseTicks = 0;
+ }
@@ -83,7 +72,7 @@
}
}
-@@ -202,6 +225,7 @@
+@@ -194,6 +217,7 @@
if (!collection.isEmpty()) {
EntityAreaEffectCloud entityareaeffectcloud = new EntityAreaEffectCloud(this.world, this.locX, this.locY, this.locZ);
diff --git a/nms-patches/EntityDamageSourceIndirect.patch b/nms-patches/EntityDamageSourceIndirect.patch
index 2bd5300b..9e9dd43d 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.isEmpty() && itemstack.hasName() && LocaleI18n.c(s1) ? new ChatMessage(s1, new Object[] { entityliving.getScoreboardDisplayName(), ichatbasecomponent, itemstack.C()}) : new ChatMessage(s, new Object[] { entityliving.getScoreboardDisplayName(), ichatbasecomponent});
+ return !itemstack.isEmpty() && itemstack.hasName() ? new ChatMessage(s1, new Object[] { entityliving.getScoreboardDisplayName(), ichatbasecomponent, itemstack.A()}) : new ChatMessage(s, new Object[] { entityliving.getScoreboardDisplayName(), ichatbasecomponent});
}
+
+ // CraftBukkit start
diff --git a/nms-patches/EntityEgg.patch b/nms-patches/EntityEgg.patch
index 314bd2fe..3d0192eb 100644
--- a/nms-patches/EntityEgg.patch
+++ b/nms-patches/EntityEgg.patch
@@ -13,7 +13,7 @@
public class EntityEgg extends EntityProjectile {
public EntityEgg(World world) {
-@@ -24,20 +31,40 @@
+@@ -20,20 +27,40 @@
}
if (!this.world.isClientSide) {
diff --git a/nms-patches/EntityEnderCrystal.patch b/nms-patches/EntityEnderCrystal.patch
index e8fe828c..81245d86 100644
--- a/nms-patches/EntityEnderCrystal.patch
+++ b/nms-patches/EntityEnderCrystal.patch
@@ -1,7 +1,7 @@
--- a/net/minecraft/server/EntityEnderCrystal.java
+++ b/net/minecraft/server/EntityEnderCrystal.java
@@ -3,6 +3,11 @@
- import com.google.common.base.Optional;
+ import java.util.Optional;
import javax.annotation.Nullable;
+// CraftBukkit start
@@ -11,14 +11,14 @@
+
public class EntityEnderCrystal extends Entity {
- private static final DataWatcherObject<Optional<BlockPosition>> b = DataWatcher.a(EntityEnderCrystal.class, DataWatcherRegistry.k);
+ private static final DataWatcherObject<Optional<BlockPosition>> b = DataWatcher.a(EntityEnderCrystal.class, DataWatcherRegistry.m);
@@ -39,7 +44,11 @@
BlockPosition blockposition = new BlockPosition(this);
- if (this.world.worldProvider instanceof WorldProviderTheEnd && this.world.getType(blockposition).getBlock() != Blocks.FIRE) {
+ if (this.world.worldProvider instanceof WorldProviderTheEnd && this.world.getType(blockposition).isAir()) {
- this.world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData());
+ // CraftBukkit start
-+ if (!CraftEventFactory.callBlockIgniteEvent(this.world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this).isCancelled()) {
++ if (!CraftEventFactory.callBlockIgniteEvent(this.world, blockposition, this).isCancelled()) {
+ this.world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData());
+ }
+ // CraftBukkit end
diff --git a/nms-patches/EntityEnderDragon.patch b/nms-patches/EntityEnderDragon.patch
index 6bfae174..8c1b4cde 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 bQ = 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[] bV = new PathPoint[24];
+ private final int[] bW = new int[24];
+ private final Path bX = 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);
-@@ -171,7 +177,7 @@
+ super(EntityTypes.ENDER_DRAGON, world);
+@@ -170,7 +176,7 @@
Vec3D vec3d = idragoncontroller.g();
@@ -30,7 +30,7 @@
d0 = vec3d.x - this.locX;
d1 = vec3d.y - this.locY;
d2 = vec3d.z - this.locZ;
-@@ -327,7 +333,14 @@
+@@ -326,7 +332,14 @@
if (this.currentEnderCrystal.dead) {
this.currentEnderCrystal = null;
} else if (this.ticksLived % 10 == 0 && this.getHealth() < this.getMaxHealth()) {
@@ -46,7 +46,7 @@
}
}
-@@ -400,6 +413,10 @@
+@@ -399,6 +412,10 @@
int j1 = MathHelper.floor(axisalignedbb.f);
boolean flag = false;
boolean flag1 = false;
@@ -57,10 +57,10 @@
for (int k1 = i; k1 <= l; ++k1) {
for (int l1 = j; l1 <= i1; ++l1) {
-@@ -413,7 +430,11 @@
+@@ -412,7 +429,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) {
+ if (block != Blocks.COMMAND_BLOCK && block != Blocks.REPEATING_COMMAND_BLOCK && block != Blocks.CHAIN_COMMAND_BLOCK && block != Blocks.IRON_BARS && block != Blocks.END_GATEWAY) {
- flag1 = this.world.setAir(blockposition) || flag1;
+ // CraftBukkit start - Add blocks to list rather than destroying them
+ // flag1 = this.world.setAir(blockposition) || flag1;
@@ -70,7 +70,7 @@
} else {
flag = true;
}
-@@ -425,6 +446,41 @@
+@@ -424,6 +445,42 @@
}
}
@@ -100,7 +100,8 @@
+
+ Block nmsBlock = org.bukkit.craftbukkit.util.CraftMagicNumbers.getBlock(blockId);
+ if (nmsBlock.a(explosionSource)) {
-+ nmsBlock.dropNaturally(this.world, new BlockPosition(blockX, blockY, blockZ), nmsBlock.fromLegacyData(block.getData()), event.getYield(), 0);
++ BlockPosition pos = new BlockPosition(blockX, blockY, blockZ);
++ nmsBlock.dropNaturally(world.getType(pos), world, pos, event.getYield(), 0);
+ }
+ nmsBlock.wasExploded(world, new BlockPosition(blockX, blockY, blockZ), explosionSource);
+
diff --git a/nms-patches/EntityEnderPearl.patch b/nms-patches/EntityEnderPearl.patch
index d61d7c67..9f8b18a9 100644
--- a/nms-patches/EntityEnderPearl.patch
+++ b/nms-patches/EntityEnderPearl.patch
@@ -13,7 +13,7 @@
public class EntityEnderPearl extends EntityProjectile {
-@@ -61,21 +67,35 @@
+@@ -57,21 +63,35 @@
EntityPlayer entityplayer = (EntityPlayer) entityliving;
if (entityplayer.playerConnection.a().isConnected() && entityplayer.world == this.world && !entityplayer.isSleeping()) {
diff --git a/nms-patches/EntityEnderSignal.patch b/nms-patches/EntityEnderSignal.patch
deleted file mode 100644
index b611b974..00000000
--- a/nms-patches/EntityEnderSignal.patch
+++ /dev/null
@@ -1,19 +0,0 @@
---- a/net/minecraft/server/EntityEnderSignal.java
-+++ b/net/minecraft/server/EntityEnderSignal.java
-@@ -2,11 +2,11 @@
-
- public class EntityEnderSignal extends Entity {
-
-- private double a;
-- private double b;
-- private double c;
-- private int d;
-- private boolean e;
-+ public double a; // CraftBukkit private -> public // PAIL rename targetX
-+ public double b; // CraftBukkit private -> public // PAIL rename targetY
-+ public double c; // CraftBukkit private -> public // PAIL rename targetZ
-+ public int d; // CraftBukkit private -> public // PAIL rename despawnTimer
-+ public boolean e; // CraftBukkit private -> public // PAIL rename shouldDropItem
-
- public EntityEnderSignal(World world) {
- super(world);
diff --git a/nms-patches/EntityEnderman.patch b/nms-patches/EntityEnderman.patch
index dc6ad778..fdfcc0f5 100644
--- a/nms-patches/EntityEnderman.patch
+++ b/nms-patches/EntityEnderman.patch
@@ -1,21 +1,28 @@
--- a/net/minecraft/server/EntityEnderman.java
+++ b/net/minecraft/server/EntityEnderman.java
-@@ -4,6 +4,8 @@
- import com.google.common.base.Optional;
- import com.google.common.base.Predicate;
- import com.google.common.collect.Sets;
-+import org.bukkit.event.entity.EntityTargetEvent;
-+
- import java.util.Random;
- import java.util.Set;
- import java.util.UUID;
-@@ -56,7 +58,17 @@
+@@ -33,7 +33,14 @@
+ this.goalSelector.a(11, new EntityEnderman.PathfinderGoalEndermanPickupBlock(this));
+ this.targetSelector.a(1, new EntityEnderman.PathfinderGoalPlayerWhoLookedAtTarget(this));
+ this.targetSelector.a(2, new PathfinderGoalHurtByTarget(this, false, new Class[0]));
+- this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget(this, EntityEndermite.class, 10, true, false, EntityEndermite::l));
++ // CraftBukkit - decompile error
++ this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget(this, EntityEndermite.class, 10, true, false, new Predicate<EntityEndermite>() {
++ @Override
++ public boolean test(EntityEndermite entityendermite) {
++ return entityendermite.l();
++ }
++ }));
++ // CraftBukkit end
+ }
+
+ protected void initAttributes() {
+@@ -45,7 +52,17 @@
}
public void setGoalTarget(@Nullable EntityLiving entityliving) {
- super.setGoalTarget(entityliving);
+ // CraftBukkit start - fire event
-+ setGoalTarget(entityliving, EntityTargetEvent.TargetReason.UNKNOWN, true);
++ setGoalTarget(entityliving, org.bukkit.event.entity.EntityTargetEvent.TargetReason.UNKNOWN, true);
+ }
+
+ @Override
@@ -28,7 +35,7 @@
AttributeInstance attributeinstance = this.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED);
if (entityliving == null) {
-@@ -70,6 +82,7 @@
+@@ -59,6 +76,7 @@
attributeinstance.b(EntityEnderman.b);
}
}
@@ -36,14 +43,14 @@
}
-@@ -317,8 +330,12 @@
+@@ -277,8 +295,12 @@
boolean flag = movingobjectposition != null && movingobjectposition.a().equals(blockposition);
- if (EntityEnderman.c.contains(block) && flag) {
+ if (block.a(TagsBlock.G) && flag) {
- this.enderman.setCarried(iblockdata);
- world.setAir(blockposition);
+ // CraftBukkit start - Pickup event
-+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.enderman, this.enderman.world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), org.bukkit.Material.AIR).isCancelled()) {
++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.enderman, blockposition, Blocks.AIR.getBlockData()).isCancelled()) {
+ this.enderman.setCarried(iblockdata);
+ world.setAir(blockposition);
+ }
@@ -51,12 +58,12 @@
}
}
-@@ -348,8 +365,12 @@
+@@ -308,8 +330,12 @@
IBlockData iblockdata2 = this.a.getCarried();
- if (iblockdata2 != null && this.a(world, blockposition, iblockdata2.getBlock(), iblockdata, iblockdata1)) {
+ if (iblockdata2 != null && this.a(world, blockposition, iblockdata2, iblockdata, iblockdata1)) {
+ // CraftBukkit start - Place event
-+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.a, blockposition, this.a.getCarried().getBlock(), this.a.getCarried().getBlock().toLegacyData(this.a.getCarried())).isCancelled()) {
++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.a, blockposition, iblockdata2).isCancelled()) {
world.setTypeAndData(blockposition, iblockdata2, 3);
this.a.setCarried((IBlockData) null);
+ }
diff --git a/nms-patches/EntityEvokerFangs.patch b/nms-patches/EntityEvokerFangs.patch
index 0e392ed5..b90581a8 100644
--- a/nms-patches/EntityEvokerFangs.patch
+++ b/nms-patches/EntityEvokerFangs.patch
@@ -2,7 +2,7 @@
+++ b/net/minecraft/server/EntityEvokerFangs.java
@@ -108,7 +108,9 @@
- if (entityliving.isAlive() && !entityliving.be() && entityliving != entityliving1) {
+ if (entityliving.isAlive() && !entityliving.bl() && entityliving != entityliving1) {
if (entityliving1 == null) {
+ org.bukkit.craftbukkit.event.CraftEventFactory.entityDamage = this; // CraftBukkit
entityliving.damageEntity(DamageSource.MAGIC, 6.0F);
diff --git a/nms-patches/EntityExperienceOrb.patch b/nms-patches/EntityExperienceOrb.patch
index bd249662..050cf6e0 100644
--- a/nms-patches/EntityExperienceOrb.patch
+++ b/nms-patches/EntityExperienceOrb.patch
@@ -14,13 +14,13 @@
public int a;
@@ -34,6 +40,7 @@
- public void B_() {
- super.B_();
+ public void tick() {
+ super.tick();
+ EntityHuman prevTarget = this.targetPlayer;// CraftBukkit - store old target
if (this.c > 0) {
--this.c;
}
-@@ -68,6 +75,16 @@
+@@ -70,6 +77,16 @@
}
if (this.targetPlayer != null) {
@@ -37,7 +37,7 @@
double d1 = (this.targetPlayer.locX - this.locX) / 8.0D;
double d2 = (this.targetPlayer.locY + (double) this.targetPlayer.getHeadHeight() / 2.0D - this.locY) / 8.0D;
double d3 = (this.targetPlayer.locZ - this.locZ) / 8.0D;
-@@ -80,6 +97,8 @@
+@@ -82,6 +99,8 @@
this.motY += d2 / d4 * d5 * 0.1D;
this.motZ += d3 / d4 * d5 * 0.1D;
}
@@ -46,22 +46,21 @@
}
this.move(EnumMoveType.SELF, this.motX, this.motY, this.motZ);
-@@ -148,12 +167,18 @@
- if (!itemstack.isEmpty() && itemstack.h()) {
- int i = Math.min(this.d(this.value), itemstack.i());
+@@ -155,12 +174,18 @@
+ if (!itemstack.isEmpty() && itemstack.f()) {
+ int i = Math.min(this.c(this.value), itemstack.getDamage());
-- this.value -= this.c(i);
-- itemstack.setData(itemstack.i() - i);
-- }
+- this.value -= this.b(i);
+- itemstack.setDamage(itemstack.getDamage() - i);
+ // CraftBukkit start
+ org.bukkit.event.player.PlayerItemMendEvent event = CraftEventFactory.callPlayerItemMendEvent(entityhuman, this, itemstack, i);
+ i = event.getRepairAmount();
+ if (!event.isCancelled()) {
-+ this.value -= this.c(i);
-+ itemstack.setData(itemstack.i() - i);
++ this.value -= this.b(i);
++ itemstack.setDamage(itemstack.getDamage() - i);
+ }
+ // CraftBukkit end
-+ }
+ }
if (this.value > 0) {
- entityhuman.giveExp(this.value);
@@ -69,7 +68,7 @@
}
this.die();
-@@ -175,6 +200,24 @@
+@@ -182,6 +207,24 @@
}
public static int getOrbValue(int i) {
diff --git a/nms-patches/EntityFallingBlock.patch b/nms-patches/EntityFallingBlock.patch
index afdb8dbb..c09b0e5f 100644
--- a/nms-patches/EntityFallingBlock.patch
+++ b/nms-patches/EntityFallingBlock.patch
@@ -1,40 +1,40 @@
--- a/net/minecraft/server/EntityFallingBlock.java
+++ b/net/minecraft/server/EntityFallingBlock.java
-@@ -5,6 +5,8 @@
+@@ -4,6 +4,8 @@
+ import java.util.ArrayList;
import java.util.Iterator;
- import javax.annotation.Nullable;
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
+
public class EntityFallingBlock extends Entity {
private IBlockData block;
-@@ -69,7 +71,7 @@
+@@ -71,7 +73,7 @@
if (this.ticksLived++ == 0) {
blockposition = new BlockPosition(this);
- if (this.world.getType(blockposition).getBlock() == block) {
-+ if (this.world.getType(blockposition).getBlock() == block && !CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, Blocks.AIR, 0).isCancelled()) {
++ if (this.world.getType(blockposition).getBlock() == block && !CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, Blocks.AIR.getBlockData()).isCancelled()) {
this.world.setAir(blockposition);
} else if (!this.world.isClientSide) {
this.die();
-@@ -110,7 +112,7 @@
+@@ -112,7 +114,7 @@
- if (!flag1 && BlockFalling.x(this.world.getType(new BlockPosition(this.locX, this.locY - 0.009999999776482582D, this.locZ)))) {
+ if (!flag1 && BlockFalling.j(this.world.getType(new BlockPosition(this.locX, this.locY - 0.009999999776482582D, this.locZ)))) {
this.onGround = false;
- return;
+ // return; // CraftBukkit
}
this.motX *= 0.699999988079071D;
-@@ -119,7 +121,13 @@
- if (iblockdata.getBlock() != Blocks.PISTON_EXTENSION) {
+@@ -121,7 +123,13 @@
+ if (iblockdata.getBlock() != Blocks.MOVING_PISTON) {
this.die();
if (!this.f) {
-- if (this.world.a(block, blockposition, true, EnumDirection.UP, (Entity) null) && (flag1 || !BlockFalling.x(this.world.getType(blockposition.down()))) && this.world.setTypeAndData(blockposition, this.block, 3)) {
+- if (iblockdata.getMaterial().isReplaceable() && (flag1 || !BlockFalling.j(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) && (flag1 || !BlockFalling.x(this.world.getType(blockposition.down())))) {
-+ if (CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, this.block.getBlock(), this.block.getBlock().toLegacyData(this.block)).isCancelled()) {
++ if (iblockdata.getMaterial().isReplaceable() && (flag1 || !BlockFalling.j(this.world.getType(blockposition.down())))) {
++ if (CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, this.block).isCancelled()) {
+ return;
+ }
+ this.world.setTypeAndData(blockposition, this.block, 3);
diff --git a/nms-patches/EntityFireball.patch b/nms-patches/EntityFireball.patch
index e9e26fd1..b236dc4b 100644
--- a/nms-patches/EntityFireball.patch
+++ b/nms-patches/EntityFireball.patch
@@ -15,14 +15,13 @@
+ public float bukkitYield = 1; // CraftBukkit
+ public boolean isIncendiary = true; // CraftBukkit
- public EntityFireball(World world) {
- super(world);
-@@ -31,12 +35,19 @@
- public EntityFireball(World world, EntityLiving entityliving, double d0, double d1, double d2) {
- super(world);
+ protected EntityFireball(EntityTypes<?> entitytypes, World world, float f, float f1) {
+ super(entitytypes, world);
+@@ -28,11 +32,18 @@
+ public EntityFireball(EntityTypes<?> entitytypes, EntityLiving entityliving, double d0, double d1, double d2, World world, float f, float f1) {
+ this(entitytypes, world, f, f1);
this.shooter = entityliving;
+ this.projectileSource = (org.bukkit.entity.LivingEntity) entityliving.getBukkitEntity(); // CraftBukkit
- this.setSize(1.0F, 1.0F);
this.setPositionRotation(entityliving.locX, entityliving.locY, entityliving.locZ, entityliving.yaw, entityliving.pitch);
this.setPosition(this.locX, this.locY, this.locZ);
this.motX = 0.0D;
@@ -37,7 +36,7 @@
d0 += this.random.nextGaussian() * 0.4D;
d1 += this.random.nextGaussian() * 0.4D;
d2 += this.random.nextGaussian() * 0.4D;
-@@ -61,6 +72,12 @@
+@@ -59,6 +70,12 @@
if (movingobjectposition != null) {
this.a(movingobjectposition);
@@ -50,19 +49,19 @@
}
this.locX += this.motX;
-@@ -150,6 +167,11 @@
+@@ -146,6 +163,11 @@
} else {
- this.ax();
+ this.aA();
if (damagesource.getEntity() != null) {
+ // CraftBukkit start
+ if (CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f)) {
+ return false;
+ }
+ // CraftBukkit end
- Vec3D vec3d = damagesource.getEntity().aJ();
+ Vec3D vec3d = damagesource.getEntity().aN();
if (vec3d != null) {
-@@ -163,6 +185,7 @@
+@@ -159,6 +181,7 @@
if (damagesource.getEntity() instanceof EntityLiving) {
this.shooter = (EntityLiving) damagesource.getEntity();
diff --git a/nms-patches/EntityFireworks.patch b/nms-patches/EntityFireworks.patch
index 99fc74ae..a0176143 100644
--- a/nms-patches/EntityFireworks.patch
+++ b/nms-patches/EntityFireworks.patch
@@ -8,37 +8,37 @@
public class EntityFireworks extends Entity {
-@@ -117,8 +118,12 @@
+@@ -114,8 +115,12 @@
}
if (!this.world.isClientSide && this.ticksFlown > this.expectedLifespan) {
- this.world.broadcastEntityEffect(this, (byte) 17);
-- this.k();
+- this.i();
+ // CraftBukkit start
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callFireworkExplodeEvent(this).isCancelled()) {
+ this.world.broadcastEntityEffect(this, (byte) 17);
-+ this.k();
++ this.i();
+ }
+ // CraftBukkit end
this.die();
}
-@@ -136,7 +141,9 @@
+@@ -133,7 +138,9 @@
if (f > 0.0F) {
if (this.e != null) {
+ CraftEventFactory.entityDamage = this; // CraftBukkit
- this.e.damageEntity(DamageSource.t, (float) (5 + nbttaglist.size() * 2));
+ this.e.damageEntity(DamageSource.FIREWORKS, (float) (5 + nbttaglist.size() * 2));
+ CraftEventFactory.entityDamage = null; // CraftBukkit
}
double d0 = 5.0D;
-@@ -162,7 +169,9 @@
+@@ -159,7 +166,9 @@
if (flag) {
float f1 = f * (float) Math.sqrt((5.0D - (double) this.g(entityliving)) / 5.0D);
+ CraftEventFactory.entityDamage = this; // CraftBukkit
- entityliving.damageEntity(DamageSource.t, f1);
+ entityliving.damageEntity(DamageSource.FIREWORKS, f1);
+ CraftEventFactory.entityDamage = null; // CraftBukkit
}
}
diff --git a/nms-patches/EntityFishingHook.patch b/nms-patches/EntityFishingHook.patch
index bcad37d4..10a8f121 100644
--- a/nms-patches/EntityFishingHook.patch
+++ b/nms-patches/EntityFishingHook.patch
@@ -1,71 +1,71 @@
--- a/net/minecraft/server/EntityFishingHook.java
+++ b/net/minecraft/server/EntityFishingHook.java
-@@ -2,6 +2,11 @@
-
+@@ -3,6 +3,11 @@
+ import java.util.Collections;
import java.util.Iterator;
import java.util.List;
+// CraftBukkit start
+import org.bukkit.entity.Player;
-+import org.bukkit.entity.Fish;
++import org.bukkit.entity.FishHook;
+import org.bukkit.event.player.PlayerFishEvent;
+// CraftBukkit end
public class EntityFishingHook extends Entity {
-@@ -261,6 +266,7 @@
+@@ -266,6 +271,7 @@
}
if (movingobjectposition != null && movingobjectposition.type != MovingObjectPosition.EnumMovingObjectType.MISS) {
+ org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this, movingobjectposition); // Craftbukkit - Call event
if (movingobjectposition.type == MovingObjectPosition.EnumMovingObjectType.ENTITY) {
this.hooked = movingobjectposition.entity;
- this.s();
-@@ -293,6 +299,10 @@
+ this.o();
+@@ -298,6 +304,10 @@
if (this.g <= 0) {
this.h = 0;
- this.at = 0;
+ this.aw = 0;
+ // CraftBukkit start
-+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), null, (Fish) this.getBukkitEntity(), PlayerFishEvent.State.FAILED_ATTEMPT);
++ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), null, (FishHook) 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();
}
-@@ -328,6 +338,13 @@
- worldserver.a(EnumParticle.WATER_WAKE, d0, d1, d2, 0, (double) (-f4), 0.01D, (double) f3, 1.0D, new int[0]);
+@@ -333,6 +343,13 @@
+ worldserver.a(Particles.x, d0, d1, d2, 0, (double) (-f4), 0.01D, (double) f3, 1.0D);
}
} else {
+ // CraftBukkit start
-+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), null, (Fish) this.getBukkitEntity(), PlayerFishEvent.State.BITE);
++ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), null, (FishHook) 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.K, 0.25F, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F);
+ this.a(SoundEffects.ENTITY_FISHING_BOBBER_SPLASH, 0.25F, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F);
double d3 = this.getBoundingBox().b + 0.5D;
-@@ -384,6 +401,14 @@
+@@ -389,6 +406,14 @@
int i = 0;
if (this.hooked != null) {
+ // CraftBukkit start
-+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), this.hooked.getBukkitEntity(), (Fish) this.getBukkitEntity(), PlayerFishEvent.State.CAUGHT_ENTITY);
++ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), this.hooked.getBukkitEntity(), (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.CAUGHT_ENTITY);
+ this.world.getServer().getPluginManager().callEvent(playerFishEvent);
+
+ if (playerFishEvent.isCancelled()) {
+ return 0;
+ }
+ // CraftBukkit end
- this.k();
+ this.f();
+ CriterionTriggers.D.a((EntityPlayer) this.owner, itemstack, this, Collections.emptyList());
this.world.broadcastEntityEffect(this, (byte) 31);
- i = this.hooked instanceof EntityItem ? 3 : 5;
-@@ -396,6 +421,15 @@
+@@ -405,6 +430,15 @@
while (iterator.hasNext()) {
- ItemStack itemstack = (ItemStack) iterator.next();
- EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY, this.locZ, itemstack);
+ ItemStack itemstack1 = (ItemStack) iterator.next();
+ EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY, this.locZ, itemstack1);
+ // CraftBukkit start
-+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), entityitem.getBukkitEntity(), (Fish) this.getBukkitEntity(), PlayerFishEvent.State.CAUGHT_FISH);
++ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), entityitem.getBukkitEntity(), (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.CAUGHT_FISH);
+ playerFishEvent.setExpToDrop(this.random.nextInt(6) + 1);
+ this.world.getServer().getPluginManager().callEvent(playerFishEvent);
+
@@ -76,7 +76,7 @@
double d0 = this.owner.locX - this.locX;
double d1 = this.owner.locY - this.locY;
double d2 = this.owner.locZ - this.locZ;
-@@ -406,7 +440,11 @@
+@@ -415,7 +449,11 @@
entityitem.motY = d1 * 0.1D + (double) MathHelper.sqrt(d3) * 0.08D;
entityitem.motZ = d2 * 0.1D;
this.world.addEntity(entityitem);
@@ -86,15 +86,15 @@
+ 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
- Item item = itemstack.getItem();
-
- if (item == Items.FISH || item == Items.COOKED_FISH) {
-@@ -418,8 +456,25 @@
+ if (itemstack1.getItem().a(TagsItem.G)) {
+ this.owner.a(StatisticList.FISH_CAUGHT, 1);
+ }
+@@ -425,8 +463,25 @@
}
if (this.isInGround) {
+ // CraftBukkit start
-+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), null, (Fish) this.getBukkitEntity(), PlayerFishEvent.State.IN_GROUND);
++ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), null, (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.IN_GROUND);
+ this.world.getServer().getPluginManager().callEvent(playerFishEvent);
+
+ if (playerFishEvent.isCancelled()) {
@@ -105,7 +105,7 @@
}
+ // CraftBukkit start
+ if (i == 0) {
-+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), null, (Fish) this.getBukkitEntity(), PlayerFishEvent.State.FAILED_ATTEMPT);
++ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), null, (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.FAILED_ATTEMPT);
+ this.world.getServer().getPluginManager().callEvent(playerFishEvent);
+ if (playerFishEvent.isCancelled()) {
+ return 0;
diff --git a/nms-patches/EntityGhast.patch b/nms-patches/EntityGhast.patch
index e4a07c97..8e11962a 100644
--- a/nms-patches/EntityGhast.patch
+++ b/nms-patches/EntityGhast.patch
@@ -1,6 +1,6 @@
--- a/net/minecraft/server/EntityGhast.java
+++ b/net/minecraft/server/EntityGhast.java
-@@ -158,7 +158,8 @@
+@@ -154,7 +154,8 @@
world.a((EntityHuman) null, 1016, new BlockPosition(this.ghast), 0);
EntityLargeFireball entitylargefireball = new EntityLargeFireball(world, this.ghast, d2, d3, d4);
diff --git a/nms-patches/EntityHanging.patch b/nms-patches/EntityHanging.patch
index 1c6ff302..83063756 100644
--- a/nms-patches/EntityHanging.patch
+++ b/nms-patches/EntityHanging.patch
@@ -12,8 +12,8 @@
+
public abstract class EntityHanging extends Entity {
- private static final Predicate<Entity> c = new Predicate() {
-@@ -41,43 +47,52 @@
+ protected static final Predicate<Entity> a = (entity) -> {
+@@ -35,43 +41,52 @@
this.updateBoundingBox();
}
@@ -98,7 +98,7 @@
return i % 32 == 0 ? 0.5D : 0.0D;
}
-@@ -88,6 +103,24 @@
+@@ -82,6 +97,24 @@
if (this.d++ == 100 && !this.world.isClientSide) {
this.d = 0;
if (!this.dead && !this.survives()) {
@@ -123,7 +123,7 @@
this.die();
this.a((Entity) null);
}
-@@ -140,6 +173,21 @@
+@@ -134,6 +167,21 @@
return false;
} else {
if (!this.dead && !this.world.isClientSide) {
@@ -143,9 +143,9 @@
+ // CraftBukkit end
+
this.die();
- this.ax();
+ this.aA();
this.a(damagesource.getEntity());
-@@ -151,6 +199,18 @@
+@@ -145,6 +193,18 @@
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) {
@@ -164,7 +164,7 @@
this.die();
this.a((Entity) null);
}
-@@ -158,7 +218,7 @@
+@@ -152,7 +212,7 @@
}
public void f(double d0, double d1, double d2) {
diff --git a/nms-patches/EntityHorseAbstract.patch b/nms-patches/EntityHorseAbstract.patch
index 58896b49..f4b2eeda 100644
--- a/nms-patches/EntityHorseAbstract.patch
+++ b/nms-patches/EntityHorseAbstract.patch
@@ -1,31 +1,31 @@
--- 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 java.util.function.Predicate;
import javax.annotation.Nullable;
+import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; // CraftBukkit
public abstract class EntityHorseAbstract extends EntityAnimal implements IInventoryListener, IJumpable {
-@@ -39,6 +40,7 @@
- private float bT;
- protected boolean bF = true;
- protected int bG;
+@@ -33,6 +34,7 @@
+ private float bY;
+ protected boolean bK = true;
+ protected int bL;
+ public int maxDomestication = 100; // CraftBukkit - store max domestication value
- public EntityHorseAbstract(World world) {
- super(world);
-@@ -214,7 +216,7 @@
+ protected EntityHorseAbstract(EntityTypes<?> entitytypes, World world) {
+ super(entitytypes, world);
+@@ -212,7 +214,7 @@
public void loadChest() {
InventoryHorseChest inventoryhorsechest = this.inventoryChest;
-- this.inventoryChest = new InventoryHorseChest("HorseChest", this.dn());
-+ this.inventoryChest = new InventoryHorseChest("HorseChest", this.dn(), this); // CraftBukkit
- this.inventoryChest.a(this.getName());
+- this.inventoryChest = new InventoryHorseChest(this.getDisplayName(), this.dA());
++ this.inventoryChest = new InventoryHorseChest(this.getDisplayName(), this.dA(), this); // CraftBukkit
+ this.inventoryChest.a(this.getCustomName());
if (inventoryhorsechest != null) {
inventoryhorsechest.b(this);
-@@ -354,7 +356,7 @@
+@@ -348,7 +350,7 @@
}
public int getMaxDomestication() {
@@ -33,8 +33,8 @@
+ return this.maxDomestication; // CraftBukkit - return stored max domestication instead of 100
}
- protected float cq() {
-@@ -414,7 +416,7 @@
+ protected float cC() {
+@@ -408,7 +410,7 @@
}
if (this.getHealth() < this.getMaxHealth() && f > 0.0F) {
@@ -43,7 +43,7 @@
flag = true;
}
-@@ -465,7 +467,7 @@
+@@ -459,7 +461,7 @@
}
public void die(DamageSource damagesource) {
@@ -52,24 +52,24 @@
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 @@
+@@ -470,6 +472,7 @@
}
}
+ super.die(damagesource); // CraftBukkit
}
- public void n() {
-@@ -486,7 +489,7 @@
- super.n();
+ public void k() {
+@@ -480,7 +483,7 @@
+ super.k();
if (!this.world.isClientSide) {
if (this.random.nextInt(900) == 0 && this.deathTicks == 0) {
- this.heal(1.0F);
+ this.heal(1.0F, RegainReason.REGEN); // CraftBukkit
}
- if (this.dJ()) {
-@@ -723,6 +726,7 @@
+ if (this.dY()) {
+@@ -716,6 +719,7 @@
if (this.getOwnerUUID() != null) {
nbttagcompound.setString("OwnerUUID", this.getOwnerUUID().toString());
}
@@ -77,7 +77,7 @@
if (!this.inventoryChest.getItem(0).isEmpty()) {
nbttagcompound.set("SaddleItem", this.inventoryChest.getItem(0).save(new NBTTagCompound()));
-@@ -749,6 +753,11 @@
+@@ -742,6 +746,11 @@
if (!s.isEmpty()) {
this.setOwnerUUID(UUID.fromString(s));
}
@@ -89,10 +89,10 @@
AttributeInstance attributeinstance = this.getAttributeMap().a("Speed");
-@@ -801,6 +810,18 @@
+@@ -794,6 +803,18 @@
}
- public void b_(int i) {
+ public void b(int i) {
+ // CraftBukkit start
+ float power;
+ if (i >= 90) {
@@ -106,5 +106,5 @@
+ }
+ // CraftBukkit end
this.canSlide = true;
- this.dt();
+ this.dH();
}
diff --git a/nms-patches/EntityHorseChestedAbstract.patch b/nms-patches/EntityHorseChestedAbstract.patch
index 2e49b194..0fff1fc3 100644
--- a/nms-patches/EntityHorseChestedAbstract.patch
+++ b/nms-patches/EntityHorseChestedAbstract.patch
@@ -8,7 +8,7 @@
+ // super.die(damagesource); // CraftBukkit - moved down
if (this.isCarryingChest()) {
if (!this.world.isClientSide) {
- this.a(Item.getItemOf(Blocks.CHEST), 1);
+ this.a((IMaterial) Blocks.CHEST);
}
- this.setCarryingChest(false);
diff --git a/nms-patches/EntityHuman.patch b/nms-patches/EntityHuman.patch
index 42eff8f3..d8a3d00c 100644
--- a/nms-patches/EntityHuman.patch
+++ b/nms-patches/EntityHuman.patch
@@ -1,7 +1,7 @@
--- a/net/minecraft/server/EntityHuman.java
+++ b/net/minecraft/server/EntityHuman.java
-@@ -9,6 +9,19 @@
- import java.util.UUID;
+@@ -15,6 +15,19 @@
+ import java.util.function.ToIntFunction;
import javax.annotation.Nullable;
+// CraftBukkit start
@@ -20,9 +20,9 @@
public abstract class EntityHuman extends EntityLiving {
private static final DataWatcherObject<Float> a = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.c);
-@@ -18,10 +31,10 @@
- protected static final DataWatcherObject<NBTTagCompound> bt = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.n);
- protected static final DataWatcherObject<NBTTagCompound> bu = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.n);
+@@ -24,10 +37,10 @@
+ protected static final DataWatcherObject<NBTTagCompound> bz = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.p);
+ protected static final DataWatcherObject<NBTTagCompound> bA = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.p);
public PlayerInventory inventory = new PlayerInventory(this);
- protected InventoryEnderChest enderChest = new InventoryEnderChest();
+ protected InventoryEnderChest enderChest = new InventoryEnderChest(this); // CraftBukkit - add "this" to constructor
@@ -30,10 +30,10 @@
public Container activeContainer;
- protected FoodMetaData foodData = new FoodMetaData();
+ protected FoodMetaData foodData = new FoodMetaData(this); // CraftBukkit - add "this" to constructor
- protected int bA;
- public float bB;
- public float bC;
-@@ -52,6 +65,17 @@
+ protected int bG;
+ public float bH;
+ public float bI;
+@@ -60,6 +73,17 @@
@Nullable
public EntityFishingHook hookedFish;
@@ -48,10 +48,10 @@
+ }
+ // CraftBukkit end
+
- protected ItemCooldown l() {
- return new ItemCooldown();
- }
-@@ -310,7 +334,8 @@
+ public EntityHuman(World world, GameProfile gameprofile) {
+ super(EntityTypes.PLAYER, world);
+ this.cd = ItemStack.a;
+@@ -369,7 +393,8 @@
if (this.world.getDifficulty() == EnumDifficulty.PEACEFUL && this.world.getGameRules().getBoolean("naturalRegeneration")) {
if (this.getHealth() < this.getMaxHealth() && this.ticksLived % 20 == 0) {
@@ -61,16 +61,16 @@
}
if (this.foodData.c() && this.ticksLived % 10 == 0) {
-@@ -334,7 +359,7 @@
+@@ -393,7 +418,7 @@
- this.k((float) attributeinstance.getValue());
+ this.o((float) attributeinstance.getValue());
float f = MathHelper.sqrt(this.motX * this.motX + this.motZ * this.motZ);
- float f1 = (float) (Math.atan(-this.motY * 0.20000000298023224D) * 15.0D);
+ float f1 = (float) ( org.bukkit.craftbukkit.TrigMath.atan(-this.motY * 0.20000000298023224D) * 15.0D); // CraftBukkit
if (f > 0.1F) {
f = 0.1F;
-@@ -456,6 +481,7 @@
+@@ -516,6 +541,7 @@
@Nullable
public EntityItem a(boolean flag) {
@@ -78,7 +78,7 @@
return this.a(this.inventory.splitStack(this.inventory.itemInHandIndex, flag && !this.inventory.getItemInHand().isEmpty() ? this.inventory.getItemInHand().getCount() : 1), false, true);
}
-@@ -498,6 +524,30 @@
+@@ -558,6 +584,30 @@
entityitem.motZ += Math.sin((double) f1) * (double) f;
}
@@ -109,7 +109,7 @@
ItemStack itemstack1 = this.a(entityitem);
if (flag1) {
-@@ -613,6 +663,13 @@
+@@ -655,6 +705,13 @@
this.a(true, true, false);
}
@@ -121,9 +121,9 @@
+ // CraftBukkit end
+
if (nbttagcompound.hasKeyOfType("SpawnX", 99) && nbttagcompound.hasKeyOfType("SpawnY", 99) && nbttagcompound.hasKeyOfType("SpawnZ", 99)) {
- this.d = new BlockPosition(nbttagcompound.getInt("SpawnX"), nbttagcompound.getInt("SpawnY"), nbttagcompound.getInt("SpawnZ"));
- this.e = nbttagcompound.getBoolean("SpawnForced");
-@@ -665,6 +722,7 @@
+ this.e = new BlockPosition(nbttagcompound.getInt("SpawnX"), nbttagcompound.getInt("SpawnY"), nbttagcompound.getInt("SpawnZ"));
+ this.f = nbttagcompound.getBoolean("SpawnForced");
+@@ -705,6 +762,7 @@
if (!this.getShoulderEntityRight().isEmpty()) {
nbttagcompound.set("ShoulderEntityRight", this.getShoulderEntityRight());
}
@@ -131,20 +131,20 @@
}
-@@ -682,10 +740,10 @@
+@@ -722,10 +780,10 @@
this.a(true, true, false);
}
- this.releaseShoulderEntities();
+ // this.releaseShoulderEntities(); // CraftBukkit - moved down
- if (damagesource.r()) {
+ if (damagesource.s()) {
if (this.world.getDifficulty() == EnumDifficulty.PEACEFUL) {
- f = 0.0F;
+ return false; // CraftBukkit - f = 0.0f -> return false
}
if (this.world.getDifficulty() == EnumDifficulty.EASY) {
-@@ -697,7 +755,13 @@
+@@ -737,7 +795,13 @@
}
}
@@ -159,12 +159,12 @@
}
}
}
-@@ -711,10 +775,29 @@
+@@ -751,10 +815,29 @@
}
public boolean a(EntityHuman entityhuman) {
-- ScoreboardTeamBase scoreboardteambase = this.aY();
-- ScoreboardTeamBase scoreboardteambase1 = entityhuman.aY();
+- ScoreboardTeamBase scoreboardteambase = this.be();
+- ScoreboardTeamBase scoreboardteambase1 = entityhuman.be();
+ // CraftBukkit start - Change to check OTHER player's scoreboard team according to API
+ // To summarize this method's logic, it's "Can parameter hurt this"
+ org.bukkit.scoreboard.Team team;
@@ -192,7 +192,7 @@
}
protected void damageArmor(float f) {
-@@ -757,7 +840,12 @@
+@@ -797,7 +880,12 @@
return (float) i / (float) this.inventory.armor.size();
}
@@ -206,7 +206,7 @@
if (!this.isInvulnerable(damagesource)) {
f = this.applyArmorModifier(damagesource, f);
f = this.applyMagicModifier(damagesource, f);
-@@ -777,6 +865,7 @@
+@@ -817,6 +905,7 @@
}
}
@@ -214,7 +214,7 @@
}
public void openSign(TileEntitySign tileentitysign) {}
-@@ -898,8 +987,15 @@
+@@ -938,8 +1027,15 @@
if (entity instanceof EntityLiving) {
f3 = ((EntityLiving) entity).getHealth();
if (j > 0 && !entity.isBurning()) {
@@ -232,7 +232,7 @@
}
}
-@@ -930,8 +1026,11 @@
+@@ -970,8 +1066,11 @@
EntityLiving entityliving = (EntityLiving) iterator.next();
if (entityliving != this && entityliving != entity && !this.r(entityliving) && this.h(entityliving) < 9.0D) {
@@ -245,7 +245,7 @@
}
}
-@@ -940,11 +1039,28 @@
+@@ -980,11 +1079,28 @@
}
if (entity instanceof EntityPlayer && entity.velocityChanged) {
@@ -274,9 +274,9 @@
}
if (flag2) {
-@@ -993,7 +1109,14 @@
+@@ -1033,7 +1149,14 @@
- this.a(StatisticList.y, Math.round(f5 * 10.0F));
+ this.a(StatisticList.DAMAGE_DEALT, Math.round(f5 * 10.0F));
if (j > 0) {
- entity.setOnFire(j * 4);
+ // CraftBukkit start - Call a combust event when somebody hits with a fire enchanted item
@@ -290,7 +290,7 @@
}
if (this.world instanceof WorldServer && f5 > 2.0F) {
-@@ -1009,6 +1132,11 @@
+@@ -1049,6 +1172,11 @@
if (flag4) {
entity.extinguish();
}
@@ -302,7 +302,7 @@
}
}
-@@ -1099,6 +1227,20 @@
+@@ -1145,6 +1273,20 @@
this.stopRiding();
}
@@ -321,9 +321,9 @@
+ // CraftBukkit end
+
this.releaseShoulderEntities();
+ this.a(StatisticList.CUSTOM.b(StatisticList.n));
this.setSize(0.2F, 0.2F);
- if (this.world.isLoaded(blockposition)) {
-@@ -1159,6 +1301,23 @@
+@@ -1206,6 +1348,23 @@
this.world.everyoneSleeping();
}
@@ -347,21 +347,21 @@
this.sleepTicks = flag ? 0 : 100;
if (flag2) {
this.setRespawnPosition(this.bedPosition, false);
-@@ -1210,9 +1369,11 @@
+@@ -1257,9 +1416,11 @@
if (blockposition != null) {
- this.d = blockposition;
- this.e = flag;
+ this.e = blockposition;
+ this.f = flag;
+ this.spawnWorld = this.world.worldData.getName(); // CraftBukkit
} else {
- this.d = null;
- this.e = false;
+ this.e = null;
+ this.f = false;
+ this.spawnWorld = ""; // CraftBukkit
}
}
-@@ -1256,7 +1417,11 @@
+@@ -1325,7 +1486,11 @@
this.motY = d3 * 0.6D;
- this.aR = f3;
+ this.aU = f3;
this.fallDistance = 0.0F;
- this.setFlag(7, false);
+ // CraftBukkit start
@@ -372,7 +372,7 @@
} else {
super.a(f, f1, f2);
}
-@@ -1540,13 +1705,17 @@
+@@ -1636,13 +1801,17 @@
}
protected void releaseShoulderEntities() {
@@ -395,7 +395,7 @@
if (!this.world.isClientSide && !nbttagcompound.isEmpty()) {
Entity entity = EntityTypes.a(nbttagcompound, this.world);
-@@ -1555,9 +1724,10 @@
+@@ -1651,9 +1820,10 @@
}
entity.setPosition(this.locX, this.locY + 0.699999988079071D, this.locZ);
@@ -407,12 +407,12 @@
}
public abstract boolean isSpectator();
-@@ -1759,7 +1929,7 @@
+@@ -1864,7 +2034,7 @@
return entitymonster.c(this.a);
}
-- public boolean apply(@Nullable Object object) {
-+ public boolean apply(@Nullable EntityMonster object) { // CraftBukkit - decompile error
+- public boolean test(@Nullable Object object) {
++ public boolean test(@Nullable EntityMonster object) { // CraftBukkit - decompile error
return this.a((EntityMonster) object);
}
diff --git a/nms-patches/EntityInsentient.patch b/nms-patches/EntityInsentient.patch
index ef6aadb7..a93da205 100644
--- a/nms-patches/EntityInsentient.patch
+++ b/nms-patches/EntityInsentient.patch
@@ -1,6 +1,6 @@
--- a/net/minecraft/server/EntityInsentient.java
+++ b/net/minecraft/server/EntityInsentient.java
-@@ -9,6 +9,17 @@
+@@ -9,6 +9,18 @@
import java.util.UUID;
import javax.annotation.Nullable;
@@ -8,6 +8,7 @@
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.craftbukkit.entity.CraftLivingEntity;
+import org.bukkit.entity.LivingEntity;
++import org.bukkit.event.entity.EntityCombustByEntityEvent;
+import org.bukkit.event.entity.EntityPickupItemEvent;
+import org.bukkit.event.entity.EntityTargetLivingEntityEvent;
+import org.bukkit.event.entity.EntityTargetEvent;
@@ -18,17 +19,17 @@
public abstract class EntityInsentient extends EntityLiving {
private static final DataWatcherObject<Byte> a = DataWatcher.a(EntityInsentient.class, DataWatcherRegistry.a);
-@@ -27,7 +38,7 @@
+@@ -27,7 +39,7 @@
public float[] dropChanceHand;
- private final NonNullList<ItemStack> by;
+ private final NonNullList<ItemStack> bE;
public float[] dropChanceArmor;
- public boolean canPickUpLoot;
+ // public boolean canPickUpLoot; // CraftBukkit - moved up to EntityLiving
public boolean persistent;
- private final Map<PathType, Float> bB;
- private MinecraftKey bC;
-@@ -57,6 +68,9 @@
- this.r();
+ private final Map<PathType, Float> bH;
+ private MinecraftKey bI;
+@@ -57,6 +69,9 @@
+ this.n();
}
+ // CraftBukkit start - default persistance to type's persistance value
@@ -36,8 +37,8 @@
+ // CraftBukkit end
}
- protected void r() {}
-@@ -110,7 +124,38 @@
+ protected void n() {}
+@@ -110,7 +125,38 @@
}
public void setGoalTarget(@Nullable EntityLiving entityliving) {
@@ -75,18 +76,18 @@
+ // CraftBukkit end
}
- public boolean d(Class<? extends EntityLiving> oclass) {
-@@ -340,11 +385,20 @@
+ public boolean b(Class<? extends EntityLiving> oclass) {
+@@ -336,11 +382,20 @@
public void a(NBTTagCompound nbttagcompound) {
super.a(nbttagcompound);
+
+ // CraftBukkit start - If looting or persistence is false only use it if it was set after we started using it
if (nbttagcompound.hasKeyOfType("CanPickUpLoot", 1)) {
-- this.m(nbttagcompound.getBoolean("CanPickUpLoot"));
+- this.p(nbttagcompound.getBoolean("CanPickUpLoot"));
+ boolean data = nbttagcompound.getBoolean("CanPickUpLoot");
+ if (isLevelAtLeast(nbttagcompound, 1) || data) {
-+ this.m(data);
++ this.p(data);
+ }
}
@@ -99,13 +100,13 @@
NBTTagList nbttaglist;
int i;
-@@ -508,7 +562,15 @@
- }
- }
+@@ -470,11 +525,21 @@
+ ItemStack itemstack1 = this.getEquipment(enumitemslot);
+ boolean flag = this.a(itemstack, itemstack1, enumitemslot);
-- if (flag && this.c(itemstack)) {
+- if (flag && this.d(itemstack)) {
+ // CraftBukkit start
-+ boolean canPickup = flag && this.c(itemstack);
++ boolean canPickup = flag && this.d(itemstack);
+
+ EntityPickupItemEvent entityEvent = new EntityPickupItemEvent((LivingEntity) getBukkitEntity(), (org.bukkit.entity.Item) entityitem.getBukkitEntity(), 0);
+ entityEvent.setCancelled(!canPickup);
@@ -113,20 +114,16 @@
+ canPickup = !entityEvent.isCancelled();
+ if (canPickup) {
+ // CraftBukkit end
- double d0;
-
- switch (enumitemslot.a()) {
-@@ -525,7 +587,9 @@
- }
+ double d0 = this.c(enumitemslot);
if (!itemstack1.isEmpty() && (double) (this.random.nextFloat() - 0.1F) < d0) {
+ this.forceDrops = true; // CraftBukkit
- this.a(itemstack1, 0.0F);
+ this.a_(itemstack1);
+ this.forceDrops = false; // CraftBukkit
}
this.setSlot(enumitemslot, itemstack);
-@@ -565,11 +629,11 @@
+@@ -554,11 +619,11 @@
double d2 = entityhuman.locZ - this.locZ;
double d3 = d0 * d0 + d1 * d1 + d2 * d2;
@@ -140,7 +137,7 @@
this.die();
} else if (d3 < 1024.0D) {
this.ticksFarFromPlayer = 0;
-@@ -938,12 +1002,24 @@
+@@ -946,12 +1011,24 @@
public final boolean b(EntityHuman entityhuman, EnumHand enumhand) {
if (this.isLeashed() && this.getLeashHolder() == entityhuman) {
@@ -165,9 +162,9 @@
this.setLeashHolder(entityhuman, true);
itemstack.subtract(1);
return true;
-@@ -964,10 +1040,12 @@
+@@ -972,10 +1049,12 @@
- if (this.bE) {
+ if (this.bK) {
if (!this.isAlive()) {
+ this.world.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.PLAYER_UNLEASH)); // CraftBukkit
this.unleash(true, true);
@@ -178,17 +175,17 @@
this.unleash(true, true);
}
}
-@@ -978,7 +1056,9 @@
- this.bE = false;
+@@ -986,7 +1065,9 @@
+ this.bK = false;
this.leashHolder = null;
if (!this.world.isClientSide && flag1) {
+ this.forceDrops = true; // CraftBukkit
- this.a(Items.LEAD, 1);
+ this.a((IMaterial) Items.LEAD);
+ this.forceDrops = false; // CraftBukkit
}
if (!this.world.isClientSide && flag && this.world instanceof WorldServer) {
-@@ -1048,6 +1128,7 @@
+@@ -1056,6 +1137,7 @@
this.setLeashHolder(entityleash, true);
} else {
@@ -196,3 +193,19 @@
this.unleash(false, true);
}
}
+@@ -1151,7 +1233,14 @@
+ int j = EnchantmentManager.getFireAspectEnchantmentLevel(this);
+
+ if (j > 0) {
+- entity.setOnFire(j * 4);
++ // CraftBukkit start - Call a combust event when somebody hits with a fire enchanted item
++ EntityCombustByEntityEvent combustEvent = new EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), j * 4);
++ org.bukkit.Bukkit.getPluginManager().callEvent(combustEvent);
++
++ if (!combustEvent.isCancelled()) {
++ entity.setOnFire(combustEvent.getDuration());
++ }
++ // CraftBukkit end
+ }
+
+ if (entity instanceof EntityHuman) {
diff --git a/nms-patches/EntityIronGolem.patch b/nms-patches/EntityIronGolem.patch
index 45aee397..5b53545a 100644
--- a/nms-patches/EntityIronGolem.patch
+++ b/nms-patches/EntityIronGolem.patch
@@ -1,6 +1,21 @@
--- a/net/minecraft/server/EntityIronGolem.java
+++ b/net/minecraft/server/EntityIronGolem.java
-@@ -73,7 +73,7 @@
+@@ -28,8 +28,12 @@
+ this.goalSelector.a(8, new PathfinderGoalRandomLookaround(this));
+ this.targetSelector.a(1, new PathfinderGoalDefendVillage(this));
+ this.targetSelector.a(2, new PathfinderGoalHurtByTarget(this, false, new Class[0]));
+- this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget(this, EntityInsentient.class, 10, false, true, (entityinsentient) -> {
+- return entityinsentient != null && IMonster.e.test(entityinsentient) && !(entityinsentient instanceof EntityCreeper);
++ // CraftBukkit start - decompile error
++ this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget(this, EntityInsentient.class, 10, false, true, new Predicate<EntityInsentient>() {
++ public boolean test(@Nullable EntityInsentient entityinsentient) {
++ return entityinsentient != null && IMonster.e.test(entityinsentient) && !(entityinsentient instanceof EntityCreeper);
++ }
++ // CraftBukkit end
+ }));
+ }
+
+@@ -67,7 +71,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 0cb43b4b..f12c053c 100644
--- a/nms-patches/EntityItem.patch
+++ b/nms-patches/EntityItem.patch
@@ -1,9 +1,9 @@
--- a/net/minecraft/server/EntityItem.java
+++ b/net/minecraft/server/EntityItem.java
-@@ -4,6 +4,10 @@
+@@ -3,6 +3,10 @@
+ import java.util.Iterator;
+ import java.util.UUID;
import javax.annotation.Nullable;
- import org.apache.logging.log4j.LogManager;
- import org.apache.logging.log4j.Logger;
+// CraftBukkit start
+import org.bukkit.event.entity.EntityPickupItemEvent;
+import org.bukkit.event.player.PlayerPickupItemEvent;
@@ -11,18 +11,18 @@
public class EntityItem extends Entity {
-@@ -15,6 +19,7 @@
- private String g;
- private String h;
+@@ -13,6 +17,7 @@
+ private UUID f;
+ private UUID g;
public float a;
+ private int lastTick = MinecraftServer.currentTick - 1; // CraftBukkit
- public EntityItem(World world, double d0, double d1, double d2) {
- super(world);
-@@ -54,9 +59,12 @@
+ public EntityItem(World world) {
+ super(EntityTypes.ITEM, world);
+@@ -48,9 +53,12 @@
this.die();
} else {
- super.B_();
+ super.tick();
- if (this.pickupDelay > 0 && this.pickupDelay != 32767) {
- --this.pickupDelay;
- }
@@ -35,7 +35,7 @@
this.lastX = this.locX;
this.lastY = this.locY;
-@@ -104,9 +112,11 @@
+@@ -100,9 +108,11 @@
this.motY *= -0.5D;
}
@@ -45,9 +45,9 @@
}
+ // Craftbukkit end */
- this.aq();
+ this.impulse |= this.at();
if (!this.world.isClientSide) {
-@@ -121,6 +131,12 @@
+@@ -117,6 +127,12 @@
}
if (!this.world.isClientSide && this.age >= 6000) {
@@ -60,7 +60,7 @@
this.die();
}
-@@ -162,6 +178,7 @@
+@@ -165,6 +181,7 @@
} else if (itemstack1.getCount() + itemstack.getCount() > itemstack1.getMaxStackSize()) {
return false;
} else {
@@ -68,7 +68,7 @@
itemstack1.add(itemstack.getCount());
entityitem.pickupDelay = Math.max(entityitem.pickupDelay, this.pickupDelay);
entityitem.age = Math.min(entityitem.age, this.age);
-@@ -208,6 +225,11 @@
+@@ -197,6 +214,11 @@
} else if (!this.getItemStack().isEmpty() && this.getItemStack().getItem() == Items.NETHER_STAR && damagesource.isExplosion()) {
return false;
} else {
@@ -77,10 +77,10 @@
+ return false;
+ }
+ // CraftBukkit end
- this.ax();
- this.f = (int) ((float) this.f - f);
- if (this.f <= 0) {
-@@ -270,6 +292,35 @@
+ this.aA();
+ this.e = (int) ((float) this.e - f);
+ if (this.e <= 0) {
+@@ -255,6 +277,35 @@
Item item = itemstack.getItem();
int i = itemstack.getCount();
@@ -113,6 +113,14 @@
+ }
+ // CraftBukkit end
+
- if (this.pickupDelay == 0 && (this.h == null || 6000 - this.age <= 200 || this.h.equals(entityhuman.getName())) && entityhuman.inventory.pickup(itemstack)) {
+ if (this.pickupDelay == 0 && (this.g == null || 6000 - this.age <= 200 || this.g.equals(entityhuman.getUniqueID())) && entityhuman.inventory.pickup(itemstack)) {
entityhuman.receive(this, i);
if (itemstack.isEmpty()) {
+@@ -294,6 +345,7 @@
+ }
+
+ public void setItemStack(ItemStack itemstack) {
++ com.google.common.base.Preconditions.checkArgument(!itemstack.isEmpty(), "Cannot drop air"); // CraftBukkit
+ this.getDataWatcher().set(EntityItem.b, itemstack);
+ }
+
diff --git a/nms-patches/EntityItemFrame.patch b/nms-patches/EntityItemFrame.patch
index f2cd4fa0..e15c81e4 100644
--- a/nms-patches/EntityItemFrame.patch
+++ b/nms-patches/EntityItemFrame.patch
@@ -1,6 +1,6 @@
--- a/net/minecraft/server/EntityItemFrame.java
+++ b/net/minecraft/server/EntityItemFrame.java
-@@ -31,6 +31,11 @@
+@@ -97,6 +97,11 @@
return false;
} else if (!damagesource.isExplosion() && !this.getItem().isEmpty()) {
if (!this.world.isClientSide) {
@@ -10,5 +10,5 @@
+ }
+ // CraftBukkit end
this.b(damagesource.getEntity(), false);
- this.a(SoundEffects.du, 1.0F, 1.0F);
- this.setItem(ItemStack.a);
+ this.a(SoundEffects.ENTITY_ITEM_FRAME_REMOVE_ITEM, 1.0F, 1.0F);
+ }
diff --git a/nms-patches/EntityLargeFireball.patch b/nms-patches/EntityLargeFireball.patch
index 3e4e73c7..d3072c01 100644
--- a/nms-patches/EntityLargeFireball.patch
+++ b/nms-patches/EntityLargeFireball.patch
@@ -10,12 +10,12 @@
public int yield = 1;
public EntityLargeFireball(World world) {
- super(world);
+ super(EntityTypes.FIREBALL, world, 1.0F, 1.0F);
+ isIncendiary = this.world.getGameRules().getBoolean("mobGriefing"); // CraftBukkit
}
public EntityLargeFireball(World world, EntityLiving entityliving, double d0, double d1, double d2) {
- super(world, entityliving, d0, d1, d2);
+ super(EntityTypes.FIREBALL, entityliving, d0, d1, d2, world, 1.0F, 1.0F);
+ isIncendiary = this.world.getGameRules().getBoolean("mobGriefing"); // CraftBukkit
}
@@ -37,7 +37,7 @@
this.die();
}
-@@ -39,7 +51,8 @@
+@@ -35,7 +47,8 @@
public void a(NBTTagCompound nbttagcompound) {
super.a(nbttagcompound);
if (nbttagcompound.hasKeyOfType("ExplosionPower", 99)) {
diff --git a/nms-patches/EntityLeash.patch b/nms-patches/EntityLeash.patch
index c742be1c..78552678 100644
--- a/nms-patches/EntityLeash.patch
+++ b/nms-patches/EntityLeash.patch
@@ -8,7 +8,7 @@
import java.util.Iterator;
import java.util.List;
import javax.annotation.Nullable;
-@@ -71,22 +73,42 @@
+@@ -67,22 +69,42 @@
while (iterator.hasNext()) {
entityinsentient = (EntityInsentient) iterator.next();
if (entityinsentient.isLeashed() && entityinsentient.getLeashHolder() == entityhuman) {
diff --git a/nms-patches/EntityLightning.patch b/nms-patches/EntityLightning.patch
index ec1e14a8..d57c0b1a 100644
--- a/nms-patches/EntityLightning.patch
+++ b/nms-patches/EntityLightning.patch
@@ -1,57 +1,33 @@
--- a/net/minecraft/server/EntityLightning.java
+++ b/net/minecraft/server/EntityLightning.java
-@@ -2,15 +2,19 @@
-
+@@ -4,6 +4,8 @@
import java.util.List;
+ import javax.annotation.Nullable;
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
+
public class EntityLightning extends EntityWeather {
private int lifeTicks;
- public long a;
- private int c;
+@@ -12,9 +14,11 @@
private final boolean d;
+ @Nullable
+ private EntityPlayer e;
+ public boolean isEffect; // CraftBukkit
public EntityLightning(World world, double d0, double d1, double d2, boolean flag) {
- super(world);
+ super(EntityTypes.LIGHTNING_BOLT, world);
+ this.isEffect = flag; // CraftBukkit
this.setPositionRotation(d0, d1, d2, 0.0F, 0.0F);
this.lifeTicks = 2;
this.a = this.random.nextLong();
-@@ -20,14 +24,22 @@
-
- if (!flag && !world.isClientSide && world.getGameRules().getBoolean("doFireTick") && (world.getDifficulty() == EnumDifficulty.NORMAL || world.getDifficulty() == EnumDifficulty.HARD) && world.areChunksLoaded(blockposition, 10)) {
- if (world.getType(blockposition).getMaterial() == Material.AIR && Blocks.FIRE.canPlace(world, blockposition)) {
-- world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData());
-+ // CraftBukkit start
-+ if (!CraftEventFactory.callBlockIgniteEvent(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this).isCancelled()) {
-+ world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData());
-+ }
-+ // CraftBukkit end
- }
-
- for (int i = 0; i < 4; ++i) {
- BlockPosition blockposition1 = blockposition.a(this.random.nextInt(3) - 1, this.random.nextInt(3) - 1, this.random.nextInt(3) - 1);
-
- if (world.getType(blockposition1).getMaterial() == Material.AIR && Blocks.FIRE.canPlace(world, blockposition1)) {
-- world.setTypeUpdate(blockposition1, Blocks.FIRE.getBlockData());
-+ // CraftBukkit start
-+ if (!CraftEventFactory.callBlockIgniteEvent(world, blockposition1.getX(), blockposition1.getY(), blockposition1.getZ(), this).isCancelled()) {
-+ world.setTypeUpdate(blockposition1, Blocks.FIRE.getBlockData());
-+ }
-+ // CraftBukkit end
- }
- }
- }
-@@ -41,7 +53,24 @@
- public void B_() {
- super.B_();
+@@ -39,7 +43,24 @@
+ public void tick() {
+ super.tick();
if (this.lifeTicks == 2) {
-- this.world.a((EntityHuman) null, this.locX, this.locY, this.locZ, SoundEffects.dK, SoundCategory.WEATHER, 10000.0F, 0.8F + this.random.nextFloat() * 0.2F);
+- this.world.a((EntityHuman) null, this.locX, this.locY, this.locZ, SoundEffects.ENTITY_LIGHTNING_BOLT_THUNDER, 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.dG, SoundCategory.WEATHER, 10000.0F, 0.8F + this.random.nextFloat() * 0.2F);
++ // this.world.a((EntityHuman) null, this.locX, this.locY, this.locZ, SoundEffects.ENTITY_LIGHTNING_BOLT_THUNDER, 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,27 +38,16 @@
+ 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.dK, SoundCategory.WEATHER, relativeX, this.locY, relativeZ, 10000.0F, pitch));
++ player.playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect(SoundEffects.ENTITY_LIGHTNING_BOLT_THUNDER, SoundCategory.WEATHER, relativeX, this.locY, relativeZ, 10000.0F, pitch));
+ } else {
-+ player.playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect(SoundEffects.dK, SoundCategory.WEATHER, this.locX, this.locY, this.locZ, 10000.0F, pitch));
++ player.playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect(SoundEffects.ENTITY_LIGHTNING_BOLT_THUNDER, 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.dJ, SoundCategory.WEATHER, 2.0F, 0.5F + this.random.nextFloat() * 0.2F);
+ this.world.a((EntityHuman) null, this.locX, this.locY, this.locZ, SoundEffects.ENTITY_LIGHTNING_BOLT_IMPACT, SoundCategory.WEATHER, 2.0F, 0.5F + this.random.nextFloat() * 0.2F);
}
-@@ -57,13 +86,17 @@
- BlockPosition blockposition = new BlockPosition(this);
-
- if (this.world.getGameRules().getBoolean("doFireTick") && this.world.areChunksLoaded(blockposition, 10) && this.world.getType(blockposition).getMaterial() == Material.AIR && Blocks.FIRE.canPlace(this.world, blockposition)) {
-- this.world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData());
-+ // CraftBukkit start - add "!isEffect"
-+ if (!isEffect && !CraftEventFactory.callBlockIgniteEvent(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this).isCancelled()) {
-+ this.world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData());
-+ }
-+ // CraftBukkit end
- }
- }
+@@ -55,7 +76,7 @@
}
}
@@ -91,3 +56,28 @@
if (this.world.isClientSide) {
this.world.d(2);
} else if (!this.d) {
+@@ -82,14 +103,22 @@
+ BlockPosition blockposition = new BlockPosition(this);
+
+ if (this.world.areChunksLoaded(blockposition, 10) && this.world.getType(blockposition).isAir() && iblockdata.canPlace(this.world, blockposition)) {
+- this.world.setTypeUpdate(blockposition, iblockdata);
++ // CraftBukkit start - add "!isEffect"
++ if (!isEffect && !CraftEventFactory.callBlockIgniteEvent(world, blockposition, this).isCancelled()) {
++ this.world.setTypeUpdate(blockposition, iblockdata);
++ }
++ // CraftBukkit end
+ }
+
+ for (int j = 0; j < i; ++j) {
+ BlockPosition blockposition1 = blockposition.a(this.random.nextInt(3) - 1, this.random.nextInt(3) - 1, this.random.nextInt(3) - 1);
+
+ if (this.world.getType(blockposition1).isAir() && iblockdata.canPlace(this.world, blockposition1)) {
+- this.world.setTypeUpdate(blockposition1, iblockdata);
++ // CraftBukkit start - add "!isEffect"
++ if (!isEffect && !CraftEventFactory.callBlockIgniteEvent(world, blockposition1, this).isCancelled()) {
++ this.world.setTypeUpdate(blockposition1, iblockdata);
++ }
++ // CraftBukkit end
+ }
+ }
+
diff --git a/nms-patches/EntityLiving.patch b/nms-patches/EntityLiving.patch
index 72d5cdcc..df052af4 100644
--- a/nms-patches/EntityLiving.patch
+++ b/nms-patches/EntityLiving.patch
@@ -25,10 +25,10 @@
public abstract class EntityLiving extends Entity {
private static final Logger a = LogManager.getLogger();
-@@ -88,6 +106,20 @@
- private BlockPosition bF;
- private DamageSource bG;
- private long bH;
+@@ -93,6 +111,20 @@
+ protected int bw;
+ private float bO;
+ private float bP;
+ // CraftBukkit start
+ public int expToDrop;
+ public int maxAirTicks = 300;
@@ -44,48 +44,35 @@
+ }
+ // CraftBukkit end
- public void killEntity() {
- this.damageEntity(DamageSource.OUT_OF_WORLD, Float.MAX_VALUE);
-@@ -102,7 +134,8 @@
+ protected EntityLiving(EntityTypes<?> entitytypes, World world) {
+ super(entitytypes, world);
+@@ -103,7 +135,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.aM = (float) ((Math.random() + 1.0D) * 0.009999999776482582D);
+ this.j = true;
+ this.aP = (float) ((Math.random() + 1.0D) * 0.009999999776482582D);
this.setPosition(this.locX, this.locY, this.locZ);
-@@ -140,7 +173,13 @@
+@@ -145,7 +178,13 @@
double d1 = Math.min((double) (0.2F + f / 15.0F), 2.5D);
int i = (int) (150.0D * d1);
-- ((WorldServer) this.world).a(EnumParticle.BLOCK_DUST, this.locX, this.locY, this.locZ, i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D, new int[] { Block.getCombinedId(iblockdata)});
+- ((WorldServer) this.world).a(new ParticleParamBlock(Particles.d, iblockdata), this.locX, this.locY, this.locZ, i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D);
+ // CraftBukkit start - visiblity api
+ if (this instanceof EntityPlayer) {
-+ ((WorldServer) this.world).sendParticles((EntityPlayer) this, EnumParticle.BLOCK_DUST, false, this.locX, this.locY, this.locZ, i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D, new int[] { Block.getCombinedId(iblockdata)});
++ ((WorldServer) this.world).sendParticles((EntityPlayer) this, new ParticleParamBlock(Particles.d, iblockdata), this.locX, this.locY, this.locZ, i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D);
+ } else {
-+ ((WorldServer) this.world).a(EnumParticle.BLOCK_DUST, this.locX, this.locY, this.locZ, i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D, new int[] { Block.getCombinedId(iblockdata)});
++ ((WorldServer) this.world).a(new ParticleParamBlock(Particles.d, iblockdata), this.locX, this.locY, this.locZ, i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D);
+ }
+ // CraftBukkit end
}
}
-@@ -202,7 +241,11 @@
- this.stopRiding();
- }
- } else {
-- this.setAirTicks(300);
-+ // CraftBukkit start - Only set if needed to work around a DataWatcher inefficiency
-+ if (this.getAirTicks() != 300) {
-+ this.setAirTicks(maxAirTicks);
-+ }
-+ // CraftBukkit end
- }
-
- if (!this.world.isClientSide) {
-@@ -259,6 +302,18 @@
- this.world.methodProfiler.b();
+@@ -264,6 +303,18 @@
+ this.world.methodProfiler.e();
}
+ // CraftBukkit start
@@ -103,9 +90,9 @@
protected void b(BlockPosition blockposition) {
int i = EnchantmentManager.a(Enchantments.j, this);
-@@ -274,19 +329,19 @@
+@@ -283,19 +334,19 @@
- protected void bO() {
+ protected void ca() {
++this.deathTicks;
- if (this.deathTicks == 20) {
+ if (this.deathTicks >= 20 && !this.dead) { // CraftBukkit - (this.deathTicks == 20) -> (this.deathTicks >= 20 && !this.dead)
@@ -113,14 +100,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));
- }
@@ -132,7 +119,7 @@
this.die();
-@@ -442,6 +497,17 @@
+@@ -455,6 +506,17 @@
}
}
@@ -150,7 +137,7 @@
if (nbttagcompound.hasKeyOfType("Health", 99)) {
this.setHealth(nbttagcompound.getFloat("Health"));
}
-@@ -464,9 +530,15 @@
+@@ -478,9 +540,15 @@
}
@@ -166,7 +153,7 @@
try {
while (iterator.hasNext()) {
MobEffectList mobeffectlist = (MobEffectList) iterator.next();
-@@ -484,6 +556,17 @@
+@@ -498,6 +566,17 @@
} catch (ConcurrentModificationException concurrentmodificationexception) {
;
}
@@ -184,20 +171,20 @@
if (this.updateEffects) {
if (!this.world.isClientSide) {
-@@ -585,6 +668,12 @@
+@@ -604,6 +683,12 @@
}
- public void addEffect(MobEffect mobeffect) {
+ public boolean addEffect(MobEffect mobeffect) {
+ // CraftBukkit start
+ if (isTickingEffects) {
+ effectsToProcess.add(mobeffect);
-+ return;
++ return true;
+ }
+ // CraftBukkit end
- if (this.d(mobeffect)) {
- MobEffect mobeffect1 = (MobEffect) this.effects.get(mobeffect.getMobEffect());
-
-@@ -617,6 +706,12 @@
+ if (!this.d(mobeffect)) {
+ return false;
+ } else {
+@@ -640,6 +725,12 @@
@Nullable
public MobEffect c(@Nullable MobEffectList mobeffectlist) {
@@ -210,7 +197,7 @@
return (MobEffect) this.effects.remove(mobeffectlist);
}
-@@ -656,20 +751,52 @@
+@@ -681,20 +772,52 @@
}
@@ -235,7 +222,7 @@
}
- public final float getHealth() {
+ public float getHealth() {
+ // CraftBukkit start - Use unscaled health
+ if (this instanceof EntityPlayer) {
+ return (float) ((EntityPlayer) this).getBukkitEntity().getHealth();
@@ -264,7 +251,7 @@
this.datawatcher.set(EntityLiving.HEALTH, Float.valueOf(MathHelper.a(f, 0.0F, this.getMaxHealth())));
}
-@@ -687,14 +814,16 @@
+@@ -712,14 +835,16 @@
} else {
float f1 = f;
@@ -283,8 +270,8 @@
+ if (false && f > 0.0F && this.applyBlockingModifier(damagesource)) {
this.damageShield(f);
f = 0.0F;
- if (!damagesource.a()) {
-@@ -713,20 +842,39 @@
+ if (!damagesource.b()) {
+@@ -738,20 +863,39 @@
if ((float) this.noDamageTicks > (float) this.maxNoDamageTicks / 2.0F) {
if (f <= this.lastDamage) {
@@ -310,8 +297,8 @@
- this.damageEntity0(damagesource, f);
+ // this.damageEntity0(damagesource, f);
+ // CraftBukkit end
- this.az = 10;
- this.hurtTicks = this.az;
+ this.aC = 10;
+ this.hurtTicks = this.aC;
}
+ // CraftBukkit start
@@ -323,10 +310,10 @@
+ }
+ // CraftBukkit end
+
- this.aA = 0.0F;
+ this.aD = 0.0F;
Entity entity1 = damagesource.getEntity();
-@@ -833,19 +981,29 @@
+@@ -858,19 +1002,29 @@
EnumHand[] aenumhand = EnumHand.values();
int i = aenumhand.length;
@@ -337,7 +324,7 @@
- ItemStack itemstack1 = this.b(enumhand);
+ itemstack1 = this.b(enumhand);
- if (itemstack1.getItem() == Items.cY) {
+ if (itemstack1.getItem() == Items.TOTEM_OF_UNDYING) {
itemstack = itemstack1.cloneItemStack();
- itemstack1.subtract(1);
+ // itemstack1.subtract(1); // CraftBukkit
@@ -359,8 +346,8 @@
+ // CraftBukkit end
EntityPlayer entityplayer = (EntityPlayer) this;
- entityplayer.b(StatisticList.b(Items.cY));
-@@ -859,7 +1017,7 @@
+ entityplayer.b(StatisticList.ITEM_USED.b(Items.TOTEM_OF_UNDYING));
+@@ -884,7 +1038,7 @@
this.world.broadcastEntityEffect(this, (byte) 35);
}
@@ -369,7 +356,7 @@
}
}
-@@ -944,6 +1102,12 @@
+@@ -955,6 +1109,12 @@
boolean flag = this.lastDamageByPlayerTime > 0;
this.a(flag, i, damagesource);
@@ -382,7 +369,7 @@
}
}
-@@ -1033,8 +1197,13 @@
+@@ -1044,8 +1204,13 @@
int i = MathHelper.f((f - 3.0F - f2) * f1);
if (i > 0) {
@@ -391,13 +378,13 @@
+ return;
+ }
+ // CraftBukkit end
- this.a(this.e(i), 1.0F, 1.0F);
+ this.a(this.n(i), 1.0F, 1.0F);
- this.damageEntity(DamageSource.FALL, (float) i);
+ // this.damageEntity(DamageSource.FALL, (float) i); // CraftBukkit - moved up
int j = MathHelper.floor(this.locX);
int k = MathHelper.floor(this.locY - 0.20000000298023224D);
int l = MathHelper.floor(this.locZ);
-@@ -1061,7 +1230,7 @@
+@@ -1072,7 +1237,7 @@
protected float applyArmorModifier(DamageSource damagesource, float f) {
if (!damagesource.ignoresArmor()) {
@@ -406,7 +393,7 @@
f = CombatMath.a(f, (float) this.getArmorStrength(), (float) this.getAttributeInstance(GenericAttributes.i).getValue());
}
-@@ -1074,7 +1243,8 @@
+@@ -1085,7 +1250,8 @@
} else {
int i;
@@ -416,7 +403,7 @@
i = (this.getEffect(MobEffects.RESISTANCE).getAmplifier() + 1) * 5;
int j = 25 - i;
float f1 = f * (float) j;
-@@ -1095,22 +1265,142 @@
+@@ -1106,22 +1272,142 @@
}
}
@@ -518,7 +505,7 @@
+ // Apply blocking code // PAIL: steal from above
+ if (event.getDamage(DamageModifier.BLOCKING) < 0) {
+ this.damageShield((float) -event.getDamage(DamageModifier.BLOCKING));
-+ Entity entity = damagesource.i();
++ Entity entity = damagesource.j();
+
+ if (entity instanceof EntityLiving) {
+ this.c((EntityLiving) entity);
@@ -532,7 +519,7 @@
+ // PAIL: Be sure to drag all this code from the EntityHuman subclass each update.
+ ((EntityHuman) this).applyExhaustion(damagesource.getExhaustionCost());
+ if (f < 3.4028235E37F) {
-+ ((EntityHuman) this).a(StatisticList.z, Math.round(f * 10.0F));
++ ((EntityHuman) this).a(StatisticList.DAMAGE_TAKEN, Math.round(f * 10.0F));
+ }
+ }
+ // CraftBukkit end
@@ -569,7 +556,7 @@
}
public CombatTracker getCombatTracker() {
-@@ -1177,6 +1467,7 @@
+@@ -1188,6 +1474,7 @@
public AttributeMapBase getAttributeMap() {
if (this.attributeMap == null) {
this.attributeMap = new AttributeMapServer();
@@ -577,7 +564,7 @@
}
return this.attributeMap;
-@@ -1469,6 +1760,7 @@
+@@ -1490,6 +1777,7 @@
}
if (this.onGround && !this.world.isClientSide) {
@@ -585,7 +572,7 @@
this.setFlag(7, false);
}
} else {
-@@ -1838,6 +2130,7 @@
+@@ -1891,6 +2179,7 @@
}
if (!this.world.isClientSide) {
@@ -593,7 +580,7 @@
this.setFlag(7, flag);
}
-@@ -1931,11 +2224,11 @@
+@@ -2018,11 +2307,11 @@
}
public boolean isInteractable() {
@@ -602,16 +589,16 @@
}
public boolean isCollidable() {
-- return this.isAlive() && !this.m_();
-+ return this.isAlive() && !this.m_() && this.collides; // CraftBukkit
+- return this.isAlive() && !this.z_();
++ return this.isAlive() && !this.z_() && this.collides; // CraftBukkit
}
- protected void ax() {
-@@ -2072,7 +2365,27 @@
- protected void v() {
+ protected void aA() {
+@@ -2182,7 +2471,27 @@
+ protected void q() {
if (!this.activeItem.isEmpty() && this.isHandRaised()) {
this.b(this.activeItem, 16);
-- this.a(this.cH(), this.activeItem.a(this.world, this));
+- this.a(this.cT(), this.activeItem.a(this.world, this));
+ // CraftBukkit start - fire PlayerItemConsumeEvent
+ ItemStack itemstack;
+ if (this instanceof EntityPlayer) {
@@ -631,17 +618,17 @@
+ itemstack = this.activeItem.a(this.world, this);
+ }
+
-+ this.a(this.cH(), itemstack);
++ this.a(this.cT(), itemstack);
+ // CraftBukkit end
- this.cN();
+ this.cZ();
}
-@@ -2151,10 +2464,18 @@
+@@ -2261,10 +2570,18 @@
}
if (flag1) {
- this.enderTeleportTo(this.locX, this.locY, this.locZ);
-- if (world.getCubes(this, this.getBoundingBox()).isEmpty() && !world.containsLiquid(this.getBoundingBox())) {
+- if (world.getCubes(this, this.getBoundingBox()) && !world.containsLiquid(this.getBoundingBox())) {
- flag = true;
+ // CraftBukkit start - Teleport event
+ // this.enderTeleportTo(this.locX, this.locY, this.locZ);
@@ -650,7 +637,7 @@
+ if (!teleport.isCancelled()) {
+ Location to = teleport.getTo();
+ this.enderTeleportTo(to.getX(), to.getY(), to.getZ());
-+ if (world.getCubes(this, this.getBoundingBox()).isEmpty() && !world.containsLiquid(this.getBoundingBox())) {
++ if (world.getCubes((Entity) this, this.getBoundingBox()) && !world.containsLiquid(this.getBoundingBox())) {
+ flag = true;
+ }
}
diff --git a/nms-patches/EntityLlamaSpit.patch b/nms-patches/EntityLlamaSpit.patch
index 4b284248..02f5ea83 100644
--- a/nms-patches/EntityLlamaSpit.patch
+++ b/nms-patches/EntityLlamaSpit.patch
@@ -15,5 +15,5 @@
public void a(MovingObjectPosition movingobjectposition) {
+ org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this, movingobjectposition); // Craftbukkit - Call event
if (movingobjectposition.entity != null && this.shooter != null) {
- movingobjectposition.entity.damageEntity(DamageSource.a(this, this.shooter).b(), 1.0F);
+ movingobjectposition.entity.damageEntity(DamageSource.a(this, (EntityLiving) this.shooter).c(), 1.0F);
}
diff --git a/nms-patches/EntityMinecartAbstract.patch b/nms-patches/EntityMinecartAbstract.patch
index 7e9aac01..d3ac7cc3 100644
--- a/nms-patches/EntityMinecartAbstract.patch
+++ b/nms-patches/EntityMinecartAbstract.patch
@@ -1,7 +1,7 @@
--- a/net/minecraft/server/EntityMinecartAbstract.java
+++ b/net/minecraft/server/EntityMinecartAbstract.java
-@@ -6,6 +6,15 @@
- import java.util.Map;
+@@ -8,6 +8,15 @@
+ import java.util.function.ToIntFunction;
import javax.annotation.Nullable;
+// CraftBukkit start
@@ -16,9 +16,9 @@
public abstract class EntityMinecartAbstract extends Entity implements INamableTileEntity {
private static final DataWatcherObject<Integer> a = DataWatcher.a(EntityMinecartAbstract.class, DataWatcherRegistry.b);
-@@ -23,6 +32,17 @@
- private double ax;
- private double ay;
+@@ -25,6 +34,17 @@
+ private double aA;
+ private double aB;
+ // CraftBukkit start
+ public boolean slowWhenEmpty = true;
@@ -31,10 +31,10 @@
+ public double maxSpeed = 0.4D;
+ // CraftBukkit end
+
- public EntityMinecartAbstract(World world) {
- super(world);
- this.i = true;
-@@ -101,6 +121,19 @@
+ protected EntityMinecartAbstract(EntityTypes<?> entitytypes, World world) {
+ super(entitytypes, world);
+ this.j = true;
+@@ -98,6 +118,19 @@
if (this.isInvulnerable(damagesource)) {
return false;
} else {
@@ -51,10 +51,10 @@
+
+ f = (float) event.getDamage();
+ // CraftBukkit end
- this.e(-this.u());
- this.d(10);
- this.ax();
-@@ -108,6 +141,15 @@
+ this.l(-this.u());
+ this.e(10);
+ this.aA();
+@@ -105,6 +138,15 @@
boolean flag = damagesource.getEntity() instanceof EntityHuman && ((EntityHuman) damagesource.getEntity()).abilities.canInstantlyBuild;
if (flag || this.getDamage() > 40.0F) {
@@ -70,10 +70,10 @@
this.ejectPassengers();
if (flag && !this.hasCustomName()) {
this.die();
-@@ -146,6 +188,14 @@
+@@ -143,6 +185,14 @@
}
- public void B_() {
+ public void tick() {
+ // CraftBukkit start
+ double prevX = this.locX;
+ double prevY = this.locY;
@@ -83,9 +83,9 @@
+ // CraftBukkit end
+
if (this.getType() > 0) {
- this.d(this.getType() - 1);
+ this.e(this.getType() - 1);
}
-@@ -160,6 +210,8 @@
+@@ -157,6 +207,8 @@
int i;
@@ -94,15 +94,15 @@
if (!this.world.isClientSide && this.world instanceof WorldServer) {
this.world.methodProfiler.a("portal");
MinecraftServer minecraftserver = this.world.getMinecraftServer();
-@@ -199,6 +251,7 @@
+@@ -196,6 +248,7 @@
- this.world.methodProfiler.b();
+ this.world.methodProfiler.e();
}
+ */
if (this.world.isClientSide) {
- if (this.at > 0) {
-@@ -266,6 +319,18 @@
+ if (this.aw > 0) {
+@@ -263,6 +316,18 @@
}
this.setYawPitch(this.yaw, this.pitch);
@@ -121,7 +121,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));
-@@ -274,8 +339,24 @@
+@@ -271,8 +336,24 @@
Entity entity = (Entity) list.get(l);
if (!(entity instanceof EntityHuman) && !(entity instanceof EntityIronGolem) && !(entity instanceof EntityMinecartAbstract) && !this.isVehicle() && !entity.isPassenger()) {
@@ -146,7 +146,7 @@
entity.collide(this);
}
}
-@@ -287,6 +368,14 @@
+@@ -284,6 +365,14 @@
Entity entity1 = (Entity) iterator.next();
if (!this.w(entity1) && entity1.isCollidable() && entity1 instanceof EntityMinecartAbstract) {
@@ -161,7 +161,7 @@
entity1.collide(this);
}
}
-@@ -297,7 +386,7 @@
+@@ -294,7 +383,7 @@
}
protected double p() {
@@ -170,7 +170,7 @@
}
public void a(int i, int j, int k, boolean flag) {}
-@@ -308,16 +397,20 @@
+@@ -305,16 +394,20 @@
this.motX = MathHelper.a(this.motX, -d0, d0);
this.motZ = MathHelper.a(this.motZ, -d0, d0);
if (this.onGround) {
@@ -197,7 +197,7 @@
}
}
-@@ -505,7 +598,7 @@
+@@ -502,7 +595,7 @@
}
protected void r() {
@@ -206,7 +206,7 @@
this.motX *= 0.996999979019165D;
this.motY *= 0.0D;
this.motZ *= 0.996999979019165D;
-@@ -618,6 +711,14 @@
+@@ -599,6 +692,14 @@
if (!this.world.isClientSide) {
if (!entity.noclip && !this.noclip) {
if (!this.w(entity)) {
@@ -221,8 +221,8 @@
double d0 = entity.locX - this.locX;
double d1 = entity.locZ - this.locZ;
double d2 = d0 * d0 + d1 * d1;
-@@ -780,4 +881,26 @@
-
+@@ -745,4 +846,26 @@
+ return this.i;
}
}
+
diff --git a/nms-patches/EntityMinecartCommandBlock.patch b/nms-patches/EntityMinecartCommandBlock.patch
index 1f44e4af..e6ac3a1c 100644
--- a/nms-patches/EntityMinecartCommandBlock.patch
+++ b/nms-patches/EntityMinecartCommandBlock.patch
@@ -1,12 +1,15 @@
--- a/net/minecraft/server/EntityMinecartCommandBlock.java
+++ b/net/minecraft/server/EntityMinecartCommandBlock.java
-@@ -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
+@@ -92,5 +92,12 @@
+ public CommandListenerWrapper getWrapper() {
+ return new CommandListenerWrapper(this, new Vec3D(EntityMinecartCommandBlock.this.locX, EntityMinecartCommandBlock.this.locY, EntityMinecartCommandBlock.this.locZ), EntityMinecartCommandBlock.this.aO(), this.d(), 2, this.getName().getString(), EntityMinecartCommandBlock.this.getScoreboardDisplayName(), this.d().getMinecraftServer(), EntityMinecartCommandBlock.this);
+ }
++
++ // CraftBukkit start
++ @Override
++ public org.bukkit.command.CommandSender getBukkitSender(CommandListenerWrapper wrapper) {
++ return (org.bukkit.craftbukkit.entity.CraftMinecartCommand) EntityMinecartCommandBlock.this.getBukkitEntity();
+ }
- public void i() {
- EntityMinecartCommandBlock.this.getDataWatcher().set(EntityMinecartCommandBlock.COMMAND, this.getCommand());
- EntityMinecartCommandBlock.this.getDataWatcher().set(EntityMinecartCommandBlock.b, this.l());
++ // CraftBukkit end
+ }
+ }
diff --git a/nms-patches/EntityMinecartContainer.patch b/nms-patches/EntityMinecartContainer.patch
index 19c2f366..f2044686 100644
--- a/nms-patches/EntityMinecartContainer.patch
+++ b/nms-patches/EntityMinecartContainer.patch
@@ -54,15 +54,15 @@
+ }
+ // CraftBukkit end
+
- public EntityMinecartContainer(World world) {
- super(world);
+ protected EntityMinecartContainer(EntityTypes<?> entitytypes, World world) {
+ super(entitytypes, world);
- this.items = NonNullList.a(36, ItemStack.a);
+ this.items = NonNullList.a(this.getSize(), ItemStack.a); // CraftBukkit - SPIGOT-3513
this.b = true;
}
- public EntityMinecartContainer(World world, double d0, double d1, double d2) {
- super(world, d0, d1, d2);
+ protected EntityMinecartContainer(EntityTypes<?> entitytypes, double d0, double d1, double d2, World world) {
+ super(entitytypes, world, d0, d1, d2);
- this.items = NonNullList.a(36, ItemStack.a);
+ this.items = NonNullList.a(this.getSize(), ItemStack.a); // CraftBukkit - SPIGOT-3513
this.b = true;
diff --git a/nms-patches/EntityMonster.patch b/nms-patches/EntityMonster.patch
deleted file mode 100644
index 0a19ca7d..00000000
--- a/nms-patches/EntityMonster.patch
+++ /dev/null
@@ -1,26 +0,0 @@
---- a/net/minecraft/server/EntityMonster.java
-+++ b/net/minecraft/server/EntityMonster.java
-@@ -1,5 +1,7 @@
- package net.minecraft.server;
-
-+import org.bukkit.event.entity.EntityCombustByEntityEvent; // CraftBukkit
-+
- public abstract class EntityMonster extends EntityCreature implements IMonster {
-
- public EntityMonster(World world) {
-@@ -75,7 +77,14 @@
- int j = EnchantmentManager.getFireAspectEnchantmentLevel(this);
-
- if (j > 0) {
-- entity.setOnFire(j * 4);
-+ // CraftBukkit start - Call a combust event when somebody hits with a fire enchanted item
-+ EntityCombustByEntityEvent combustEvent = new EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), j * 4);
-+ org.bukkit.Bukkit.getPluginManager().callEvent(combustEvent);
-+
-+ if (!combustEvent.isCancelled()) {
-+ entity.setOnFire(combustEvent.getDuration());
-+ }
-+ // CraftBukkit end
- }
-
- if (entity instanceof EntityHuman) {
diff --git a/nms-patches/EntityMushroomCow.patch b/nms-patches/EntityMushroomCow.patch
index 4fa155b3..8888c99b 100644
--- a/nms-patches/EntityMushroomCow.patch
+++ b/nms-patches/EntityMushroomCow.patch
@@ -8,7 +8,7 @@
public class EntityMushroomCow extends EntityCow {
-@@ -27,6 +28,14 @@
+@@ -23,6 +24,14 @@
return true;
} else if (itemstack.getItem() == Items.SHEARS && this.getAge() >= 0) {
@@ -21,5 +21,5 @@
+ }
+ // CraftBukkit end
this.die();
- this.world.addParticle(EnumParticle.EXPLOSION_LARGE, this.locX, this.locY + (double) (this.length / 2.0F), this.locZ, 0.0D, 0.0D, 0.0D, new int[0]);
+ this.world.addParticle(Particles.u, this.locX, this.locY + (double) (this.length / 2.0F), this.locZ, 0.0D, 0.0D, 0.0D);
if (!this.world.isClientSide) {
diff --git a/nms-patches/EntityOcelot.patch b/nms-patches/EntityOcelot.patch
index 1caea988..9f18245b 100644
--- a/nms-patches/EntityOcelot.patch
+++ b/nms-patches/EntityOcelot.patch
@@ -1,6 +1,6 @@
--- a/net/minecraft/server/EntityOcelot.java
+++ b/net/minecraft/server/EntityOcelot.java
-@@ -57,7 +57,7 @@
+@@ -60,7 +60,7 @@
}
protected boolean isTypeNotPersistent() {
@@ -9,7 +9,7 @@
}
protected void initAttributes() {
-@@ -108,7 +108,8 @@
+@@ -107,7 +107,8 @@
return false;
} else {
if (this.goalSit != null) {
@@ -19,7 +19,7 @@
}
return super.damageEntity(damagesource, f);
-@@ -133,7 +134,8 @@
+@@ -132,7 +133,8 @@
}
if (!this.world.isClientSide) {
@@ -28,8 +28,8 @@
+ if (this.random.nextInt(3) == 0 && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this, entityhuman).isCancelled()) {
this.c(entityhuman);
this.setCatType(1 + this.world.random.nextInt(3));
- this.p(true);
-@@ -237,7 +239,7 @@
+ this.s(true);
+@@ -238,7 +240,7 @@
entityocelot.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, 0.0F);
entityocelot.setAgeRaw(-24000);
diff --git a/nms-patches/EntityPainting.patch b/nms-patches/EntityPainting.patch
index 06269bbb..cc62b670 100644
--- a/nms-patches/EntityPainting.patch
+++ b/nms-patches/EntityPainting.patch
@@ -1,10 +1,13 @@
--- a/net/minecraft/server/EntityPainting.java
+++ b/net/minecraft/server/EntityPainting.java
-@@ -11,6 +11,7 @@
+@@ -11,6 +11,10 @@
public EntityPainting(World world) {
- super(world);
-+ this.art = EnumArt.values()[this.random.nextInt(EnumArt.values().length)]; // CraftBukkit - generate a non-null painting
+ super(EntityTypes.PAINTING, world);
++ // CraftBukkit start - generate a non-null painting
++ ArrayList arraylist = Lists.newArrayList(Paintings.a);
++ this.art = (Paintings) arraylist.get(this.random.nextInt(arraylist.size()));
++ // CraftBukkit end
}
public EntityPainting(World world, BlockPosition blockposition, EnumDirection enumdirection) {
diff --git a/nms-patches/EntityParrot.patch b/nms-patches/EntityParrot.patch
index 432c1d97..07a227bb 100644
--- a/nms-patches/EntityParrot.patch
+++ b/nms-patches/EntityParrot.patch
@@ -1,33 +1,24 @@
--- a/net/minecraft/server/EntityParrot.java
+++ b/net/minecraft/server/EntityParrot.java
-@@ -15,7 +15,7 @@
- private static final DataWatcherObject<Integer> bG = DataWatcher.a(EntityParrot.class, DataWatcherRegistry.b);
- private static final Predicate<EntityInsentient> bH = new Predicate() {
- public boolean a(@Nullable EntityInsentient entityinsentient) {
-- return entityinsentient != null && EntityParrot.bK.containsKey(EntityTypes.b.a((Object) entityinsentient.getClass()));
-+ return entityinsentient != null && EntityParrot.bK.containsKey(EntityTypes.b.a(entityinsentient.getClass())); // CraftBukkit - decompile error
- }
-
- public boolean apply(@Nullable Object object) {
-@@ -114,7 +114,7 @@
- EntityInsentient entityinsentient = (EntityInsentient) list.get(world.random.nextInt(list.size()));
-
- if (!entityinsentient.isSilent()) {
-- SoundEffect soundeffect = g(EntityTypes.b.a((Object) entityinsentient.getClass()));
-+ SoundEffect soundeffect = g(EntityTypes.b.a(entityinsentient.getClass())); // CraftBukkit - decompile error
-
- world.a((EntityHuman) null, entity.locX, entity.locY, entity.locZ, soundeffect, entity.bK(), 0.7F, b(world.random));
- return true;
-@@ -140,7 +140,7 @@
+@@ -27,7 +27,7 @@
+ };
+ private static final Item bN = Items.COOKIE;
+ private static final Set<Item> bO = Sets.newHashSet(new Item[] { Items.WHEAT_SEEDS, Items.MELON_SEEDS, Items.PUMPKIN_SEEDS, Items.BEETROOT_SEEDS});
+- private static final Map<EntityTypes<?>, SoundEffect> bP = (Map) SystemUtils.a((Object) Maps.newHashMap(), (hashmap) -> {
++ private static final Map<EntityTypes<?>, SoundEffect> bP = (Map) SystemUtils.a(Maps.newHashMap(), (hashmap) -> { // CraftBukkit - decompile error
+ hashmap.put(EntityTypes.BLAZE, SoundEffects.ENTITY_PARROT_IMITATE_BLAZE);
+ hashmap.put(EntityTypes.CAVE_SPIDER, SoundEffects.ENTITY_PARROT_IMITATE_SPIDER);
+ hashmap.put(EntityTypes.CREEPER, SoundEffects.ENTITY_PARROT_IMITATE_CREEPER);
+@@ -174,7 +174,7 @@
}
if (!this.world.isClientSide) {
- if (this.random.nextInt(10) == 0) {
+ if (this.random.nextInt(10) == 0 && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this, entityhuman).isCancelled()) { // CraftBukkit
this.c(entityhuman);
- this.p(true);
+ this.s(true);
this.world.broadcastEntityEffect(this, (byte) 7);
-@@ -276,7 +276,8 @@
+@@ -310,7 +310,8 @@
return false;
} else {
if (this.goalSit != null) {
@@ -37,67 +28,3 @@
}
return super.damageEntity(damagesource, f);
-@@ -316,33 +317,35 @@
- }
-
- static {
-- EntityParrot.bK.put(EntityTypes.b.a((Object) EntityBlaze.class), SoundEffects.eM);
-- EntityParrot.bK.put(EntityTypes.b.a((Object) EntityCaveSpider.class), SoundEffects.fc);
-- EntityParrot.bK.put(EntityTypes.b.a((Object) EntityCreeper.class), SoundEffects.eN);
-- EntityParrot.bK.put(EntityTypes.b.a((Object) EntityGuardianElder.class), SoundEffects.eO);
-- EntityParrot.bK.put(EntityTypes.b.a((Object) EntityEnderDragon.class), SoundEffects.eP);
-- EntityParrot.bK.put(EntityTypes.b.a((Object) EntityEnderman.class), SoundEffects.eQ);
-- EntityParrot.bK.put(EntityTypes.b.a((Object) EntityEndermite.class), SoundEffects.eR);
-- EntityParrot.bK.put(EntityTypes.b.a((Object) EntityEvoker.class), SoundEffects.eS);
-- EntityParrot.bK.put(EntityTypes.b.a((Object) EntityGhast.class), SoundEffects.eT);
-- EntityParrot.bK.put(EntityTypes.b.a((Object) EntityZombieHusk.class), SoundEffects.eU);
-- EntityParrot.bK.put(EntityTypes.b.a((Object) EntityIllagerIllusioner.class), SoundEffects.eV);
-- EntityParrot.bK.put(EntityTypes.b.a((Object) EntityMagmaCube.class), SoundEffects.eW);
-- EntityParrot.bK.put(EntityTypes.b.a((Object) EntityPigZombie.class), SoundEffects.fl);
-- EntityParrot.bK.put(EntityTypes.b.a((Object) EntityPolarBear.class), SoundEffects.eX);
-- EntityParrot.bK.put(EntityTypes.b.a((Object) EntityShulker.class), SoundEffects.eY);
-- EntityParrot.bK.put(EntityTypes.b.a((Object) EntitySilverfish.class), SoundEffects.eZ);
-- EntityParrot.bK.put(EntityTypes.b.a((Object) EntitySkeleton.class), SoundEffects.fa);
-- EntityParrot.bK.put(EntityTypes.b.a((Object) EntitySlime.class), SoundEffects.fb);
-- EntityParrot.bK.put(EntityTypes.b.a((Object) EntitySpider.class), SoundEffects.fc);
-- EntityParrot.bK.put(EntityTypes.b.a((Object) EntitySkeletonStray.class), SoundEffects.fd);
-- EntityParrot.bK.put(EntityTypes.b.a((Object) EntityVex.class), SoundEffects.fe);
-- EntityParrot.bK.put(EntityTypes.b.a((Object) EntityVindicator.class), SoundEffects.ff);
-- EntityParrot.bK.put(EntityTypes.b.a((Object) EntityWitch.class), SoundEffects.fg);
-- EntityParrot.bK.put(EntityTypes.b.a((Object) EntityWither.class), SoundEffects.fh);
-- EntityParrot.bK.put(EntityTypes.b.a((Object) EntitySkeletonWither.class), SoundEffects.fi);
-- EntityParrot.bK.put(EntityTypes.b.a((Object) EntityWolf.class), SoundEffects.fj);
-- EntityParrot.bK.put(EntityTypes.b.a((Object) EntityZombie.class), SoundEffects.fk);
-- EntityParrot.bK.put(EntityTypes.b.a((Object) EntityZombieVillager.class), SoundEffects.fm);
-+ // CraftBukkit start
-+ EntityParrot.bK.put(EntityTypes.b.a(EntityBlaze.class), SoundEffects.eM);
-+ EntityParrot.bK.put(EntityTypes.b.a(EntityCaveSpider.class), SoundEffects.fc);
-+ EntityParrot.bK.put(EntityTypes.b.a(EntityCreeper.class), SoundEffects.eN);
-+ EntityParrot.bK.put(EntityTypes.b.a(EntityGuardianElder.class), SoundEffects.eO);
-+ EntityParrot.bK.put(EntityTypes.b.a(EntityEnderDragon.class), SoundEffects.eP);
-+ EntityParrot.bK.put(EntityTypes.b.a(EntityEnderman.class), SoundEffects.eQ);
-+ EntityParrot.bK.put(EntityTypes.b.a(EntityEndermite.class), SoundEffects.eR);
-+ EntityParrot.bK.put(EntityTypes.b.a(EntityEvoker.class), SoundEffects.eS);
-+ EntityParrot.bK.put(EntityTypes.b.a(EntityGhast.class), SoundEffects.eT);
-+ EntityParrot.bK.put(EntityTypes.b.a(EntityZombieHusk.class), SoundEffects.eU);
-+ EntityParrot.bK.put(EntityTypes.b.a(EntityIllagerIllusioner.class), SoundEffects.eV);
-+ EntityParrot.bK.put(EntityTypes.b.a(EntityMagmaCube.class), SoundEffects.eW);
-+ EntityParrot.bK.put(EntityTypes.b.a(EntityPigZombie.class), SoundEffects.fl);
-+ EntityParrot.bK.put(EntityTypes.b.a(EntityPolarBear.class), SoundEffects.eX);
-+ EntityParrot.bK.put(EntityTypes.b.a(EntityShulker.class), SoundEffects.eY);
-+ EntityParrot.bK.put(EntityTypes.b.a(EntitySilverfish.class), SoundEffects.eZ);
-+ EntityParrot.bK.put(EntityTypes.b.a(EntitySkeleton.class), SoundEffects.fa);
-+ EntityParrot.bK.put(EntityTypes.b.a(EntitySlime.class), SoundEffects.fb);
-+ EntityParrot.bK.put(EntityTypes.b.a(EntitySpider.class), SoundEffects.fc);
-+ EntityParrot.bK.put(EntityTypes.b.a(EntitySkeletonStray.class), SoundEffects.fd);
-+ EntityParrot.bK.put(EntityTypes.b.a(EntityVex.class), SoundEffects.fe);
-+ EntityParrot.bK.put(EntityTypes.b.a(EntityVindicator.class), SoundEffects.ff);
-+ EntityParrot.bK.put(EntityTypes.b.a(EntityWitch.class), SoundEffects.fg);
-+ EntityParrot.bK.put(EntityTypes.b.a(EntityWither.class), SoundEffects.fh);
-+ EntityParrot.bK.put(EntityTypes.b.a(EntitySkeletonWither.class), SoundEffects.fi);
-+ EntityParrot.bK.put(EntityTypes.b.a(EntityWolf.class), SoundEffects.fj);
-+ EntityParrot.bK.put(EntityTypes.b.a(EntityZombie.class), SoundEffects.fk);
-+ EntityParrot.bK.put(EntityTypes.b.a(EntityZombieVillager.class), SoundEffects.fm);
-+ // CraftBukkit end
- }
- }
diff --git a/nms-patches/EntityPhantom.patch b/nms-patches/EntityPhantom.patch
new file mode 100644
index 00000000..a6589d39
--- /dev/null
+++ b/nms-patches/EntityPhantom.patch
@@ -0,0 +1,20 @@
+--- a/net/minecraft/server/EntityPhantom.java
++++ b/net/minecraft/server/EntityPhantom.java
+@@ -186,7 +186,7 @@
+ } else {
+ this.b = 60;
+ AxisAlignedBB axisalignedbb = EntityPhantom.this.getBoundingBox().grow(16.0D, 64.0D, 16.0D);
+- List list = EntityPhantom.this.world.a(EntityHuman.class, axisalignedbb);
++ List<EntityHuman> list = EntityPhantom.this.world.a(EntityHuman.class, axisalignedbb); // CraftBukkit - decompile error
+
+ if (!list.isEmpty()) {
+ list.sort((entityhuman, entityhuman1) -> {
+@@ -198,7 +198,7 @@
+ EntityHuman entityhuman = (EntityHuman) iterator.next();
+
+ if (PathfinderGoalTarget.a(EntityPhantom.this, entityhuman, false, false)) {
+- EntityPhantom.this.setGoalTarget(entityhuman);
++ EntityPhantom.this.setGoalTarget(entityhuman, org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_PLAYER, true); // CraftBukkit - reason
+ return true;
+ }
+ }
diff --git a/nms-patches/EntityPig.patch b/nms-patches/EntityPig.patch
index 0af22aaf..02669176 100644
--- a/nms-patches/EntityPig.patch
+++ b/nms-patches/EntityPig.patch
@@ -1,15 +1,15 @@
--- a/net/minecraft/server/EntityPig.java
+++ b/net/minecraft/server/EntityPig.java
-@@ -4,6 +4,8 @@
- import java.util.Set;
+@@ -2,6 +2,8 @@
+
import javax.annotation.Nullable;
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
+
public class EntityPig extends EntityAnimal {
- private static final DataWatcherObject<Boolean> bx = DataWatcher.a(EntityPig.class, DataWatcherRegistry.h);
-@@ -124,13 +126,14 @@
+ private static final DataWatcherObject<Boolean> bC = DataWatcher.a(EntityPig.class, DataWatcherRegistry.i);
+@@ -118,13 +120,14 @@
}
public void die(DamageSource damagesource) {
@@ -17,7 +17,7 @@
+ // super.die(damagesource); // CraftBukkit - Moved to end
if (!this.world.isClientSide) {
if (this.hasSaddle()) {
- this.a(Items.SADDLE, 1);
+ this.a((IMaterial) Items.SADDLE);
}
}
@@ -25,7 +25,7 @@
}
@Nullable
-@@ -155,6 +158,12 @@
+@@ -149,6 +152,12 @@
if (!this.world.isClientSide && !this.dead) {
EntityPigZombie entitypigzombie = new EntityPigZombie(this.world);
@@ -38,7 +38,7 @@
entitypigzombie.setSlot(EnumItemSlot.MAINHAND, new ItemStack(Items.GOLDEN_SWORD));
entitypigzombie.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, this.pitch);
entitypigzombie.setNoAI(this.isNoAI());
-@@ -163,7 +172,8 @@
+@@ -157,7 +166,8 @@
entitypigzombie.setCustomNameVisible(this.getCustomNameVisible());
}
diff --git a/nms-patches/EntityPlayer.patch b/nms-patches/EntityPlayer.patch
index 364fe7e4..71ab9dcd 100644
--- a/nms-patches/EntityPlayer.patch
+++ b/nms-patches/EntityPlayer.patch
@@ -1,6 +1,6 @@
--- a/net/minecraft/server/EntityPlayer.java
+++ b/net/minecraft/server/EntityPlayer.java
-@@ -11,10 +11,27 @@
+@@ -15,11 +15,29 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -8,6 +8,7 @@
+import com.google.common.base.Preconditions;
+import org.bukkit.Bukkit;
+import org.bukkit.GameMode;
++import org.bukkit.Location;
+import org.bukkit.WeatherType;
+import org.bukkit.craftbukkit.CraftWorld;
+import org.bukkit.craftbukkit.entity.CraftPlayer;
@@ -23,13 +24,14 @@
+
public class EntityPlayer extends EntityHuman implements ICrafting {
- private static final Logger bV = LogManager.getLogger();
+ private static final Logger cc = LogManager.getLogger();
+ private static final IChatBaseComponent cd = (new ChatMessage("multiplayer.message_not_delivered", new Object[0])).a(EnumChatFormat.RED);
- public String locale = "en_US";
+ public String locale = "en_us"; // CraftBukkit - lowercase
public PlayerConnection playerConnection;
public final MinecraftServer server;
public final PlayerInteractManager playerInteractManager;
-@@ -50,10 +67,45 @@
+@@ -55,6 +73,19 @@
public int ping;
public boolean viewingCredits;
@@ -47,69 +49,73 @@
+ // CraftBukkit end
+
public EntityPlayer(MinecraftServer minecraftserver, WorldServer worldserver, GameProfile gameprofile, PlayerInteractManager playerinteractmanager) {
- super(worldserver, gameprofile);
+ super((World) worldserver, gameprofile);
playerinteractmanager.player = this;
- this.playerInteractManager = playerinteractmanager;
-+ // CraftBukkit start
-+ BlockPosition blockposition = getSpawnPoint(minecraftserver, worldserver);
-+
-+ this.server = minecraftserver;
-+ this.bZ = minecraftserver.getPlayerList().getStatisticManager(this);
-+ this.bY = minecraftserver.getPlayerList().h(this);
-+ this.P = 1.0F;
-+ this.setPositionRotation(blockposition, 0.0F, 0.0F);
-+ // CraftBukkit end
-+
-+ while (!worldserver.getCubes(this, this.getBoundingBox()).isEmpty() && this.locY < 255.0D) {
-+ this.setPosition(this.locX, this.locY + 1.0D, this.locZ);
-+ }
+@@ -65,7 +96,49 @@
+ this.cg = minecraftserver.getPlayerList().h(this);
+ this.Q = 1.0F;
+ this.a(worldserver);
+
+ // CraftBukkit start
+ this.displayName = this.getName();
+ this.canPickUpLoot = true;
+ this.maxHealthCache = this.getMaxHealth();
-+ // CraftBukkit end
+ }
+
-+ public final BlockPosition getSpawnPoint(MinecraftServer minecraftserver, WorldServer worldserver) {
- BlockPosition blockposition = worldserver.getSpawn();
-
- if (worldserver.worldProvider.m() && worldserver.getWorldData().getGameType() != EnumGamemode.ADVENTURE) {
-@@ -71,17 +123,9 @@
- blockposition = worldserver.q(blockposition.a(this.random.nextInt(i * 2 + 1) - i, 0, this.random.nextInt(i * 2 + 1) - i));
- }
-
-- this.server = minecraftserver;
-- this.bZ = minecraftserver.getPlayerList().getStatisticManager(this);
-- this.bY = minecraftserver.getPlayerList().h(this);
-- this.P = 1.0F;
-- 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);
-- }
--
++ // Yes, this doesn't match Vanilla, but it's the best we can do for now.
++ // If this is an issue, PRs are welcome
++ public final BlockPosition getSpawnPoint(WorldServer worldserver) {
++ BlockPosition blockposition = worldserver.getSpawn();
++
++ if (worldserver.worldProvider.g() && worldserver.getWorldData().getGameType() != EnumGamemode.ADVENTURE) {
++ int i = Math.max(0, this.server.a(worldserver));
++ int j = MathHelper.floor(worldserver.getWorldBorder().b((double) blockposition.getX(), (double) blockposition.getZ()));
++
++ if (j < i) {
++ i = j;
++ }
++
++ if (j <= 1) {
++ i = 1;
++ }
++
++ int k = (i * 2 + 1) * (i * 2 + 1);
++ int l = this.s(k);
++ int i1 = (new Random()).nextInt(k);
++
++ for (int j1 = 0; j1 < k; ++j1) {
++ int k1 = (i1 + l * j1) % k;
++ int l1 = k1 % (i * 2 + 1);
++ int i2 = k1 / (i * 2 + 1);
++ BlockPosition blockposition1 = worldserver.o().a(blockposition.getX() + l1 - i, blockposition.getZ() + i2 - i, false);
++
++ if (blockposition1 != null) {
++ return blockposition1;
++ }
++ }
++ }
++
+ return blockposition;
}
+ // CraftBukkit end
- public void a(NBTTagCompound nbttagcompound) {
- super.a(nbttagcompound);
-@@ -103,6 +147,7 @@
+ private void a(WorldServer worldserver) {
+ BlockPosition blockposition = worldserver.getSpawn();
+@@ -133,6 +206,7 @@
if (nbttagcompound.hasKeyOfType("recipeBook", 10)) {
- this.cr.a(nbttagcompound.getCompound("recipeBook"));
+ this.cz.a(nbttagcompound.getCompound("recipeBook"));
}
+ this.getBukkitEntity().readExtraData(nbttagcompound); // CraftBukkit
}
-@@ -149,7 +194,33 @@
+@@ -163,8 +237,34 @@
}
- nbttagcompound.set("recipeBook", this.cr.c());
+ nbttagcompound.set("recipeBook", this.cz.e());
+ this.getBukkitEntity().setExtraData(nbttagcompound); // CraftBukkit
-+ }
-+
+ }
+
+ // CraftBukkit start - World fallback code, either respawn location or global spawn
+ public void spawnIn(World world) {
+ super.spawnIn(world);
@@ -132,15 +138,16 @@
+ }
+ this.dimension = ((WorldServer) this.world).dimension;
+ this.playerInteractManager.a((WorldServer) world);
- }
++ }
+ // CraftBukkit end
-
- public void levelDown(int i) {
- super.levelDown(i);
-@@ -184,6 +255,11 @@
++
+ public void a(int i) {
+ float f = (float) this.getExpToLevel();
+ float f1 = (f - 1.0F) / f;
+@@ -211,6 +311,11 @@
}
- public void B_() {
+ public void tick() {
+ // CraftBukkit start
+ if (this.joining) {
+ this.joining = false;
@@ -149,17 +156,17 @@
this.playerInteractManager.a();
--this.invulnerableTicks;
if (this.noDamageTicks > 0) {
-@@ -249,7 +325,7 @@
+@@ -276,7 +381,7 @@
}
- if (this.getHealth() != this.lastHealthSent || this.ch != this.foodData.getFoodLevel() || this.foodData.getSaturationLevel() == 0.0F != this.ci) {
+ if (this.getHealth() != this.lastHealthSent || this.cp != this.foodData.getFoodLevel() || this.foodData.getSaturationLevel() == 0.0F != this.cq) {
- 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.ch = this.foodData.getFoodLevel();
- this.ci = this.foodData.getSaturationLevel() == 0.0F;
-@@ -270,6 +346,12 @@
- this.a(IScoreboardCriteria.i, MathHelper.f((float) this.cc));
+ this.cp = this.foodData.getFoodLevel();
+ this.cq = this.foodData.getSaturationLevel() == 0.0F;
+@@ -307,6 +412,12 @@
+ this.a(IScoreboardCriteria.k, MathHelper.f((float) this.cn));
}
+ // CraftBukkit start - Force max health updates
@@ -168,11 +175,11 @@
+ }
+ // CraftBukkit end
+
- if (this.getArmorStrength() != this.cd) {
- this.cd = this.getArmorStrength();
- this.a(IScoreboardCriteria.j, MathHelper.f((float) this.cd));
-@@ -294,6 +376,16 @@
- CriterionTriggers.o.a(this);
+ if (this.expLevel != this.cm) {
+ this.cm = this.expLevel;
+ this.a(IScoreboardCriteria.l, MathHelper.f((float) this.cm));
+@@ -321,6 +432,16 @@
+ CriterionTriggers.p.a(this);
}
+ // CraftBukkit start - initialize oldLevel and fire PlayerLevelChangeEvent
@@ -188,27 +195,22 @@
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.a(throwable, "Ticking player");
CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Player being ticked");
-@@ -304,12 +396,11 @@
+@@ -331,7 +452,8 @@
}
private void a(IScoreboardCriteria iscoreboardcriteria, int i) {
-- Collection collection = this.getScoreboard().getObjectivesForCriteria(iscoreboardcriteria);
-+ Collection collection = this.world.getServer().getScoreboardManager().getScoreboardScores(iscoreboardcriteria, this.getName(), new java.util.ArrayList<ScoreboardScore>()); // CraftBukkit - Use our scores instead
- Iterator iterator = collection.iterator();
-
- while (iterator.hasNext()) {
-- ScoreboardObjective scoreboardobjective = (ScoreboardObjective) iterator.next();
-- ScoreboardScore scoreboardscore = this.getScoreboard().getPlayerScoreForObjective(this.getName(), scoreboardobjective);
-+ ScoreboardScore scoreboardscore = (ScoreboardScore) iterator.next(); // CraftBukkit - Use our scores instead
-
+- this.getScoreboard().getObjectivesForCriteria(iscoreboardcriteria, this.getName(), (scoreboardscore) -> {
++ // CraftBukkit - Use our scores instead
++ this.world.getServer().getScoreboardManager().getScoreboardScores(iscoreboardcriteria, this.getName(), (scoreboardscore) -> {
scoreboardscore.setScore(i);
- }
-@@ -320,32 +411,62 @@
+ });
+ }
+@@ -340,27 +462,59 @@
boolean flag = this.world.getGameRules().getBoolean("showDeathMessages");
this.playerConnection.sendPacket(new PacketPlayOutCombatEvent(this.getCombatTracker(), PacketPlayOutCombatEvent.EnumCombatEventType.ENTITY_DIED, flag));
- if (flag) {
-- ScoreboardTeamBase scoreboardteambase = this.aY();
+- ScoreboardTeamBase scoreboardteambase = this.be();
+ // CraftBukkit start - fire PlayerDeathEvent
+ if (this.dead) {
+ return;
@@ -223,22 +225,22 @@
+ }
+ }
+ }
-+
-+ IChatBaseComponent chatmessage = this.getCombatTracker().getDeathMessage();
-+
-+ String deathmessage = chatmessage.toPlainText();
-+ org.bukkit.event.entity.PlayerDeathEvent event = CraftEventFactory.callPlayerDeathEvent(this, loot, deathmessage, keepInventory);
- 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.getString();
++ org.bukkit.event.entity.PlayerDeathEvent event = CraftEventFactory.callPlayerDeathEvent(this, loot, deathmessage, keepInventory);
++
+ String deathMessage = event.getDeathMessage();
+
+ if (deathMessage != null && deathMessage.length() > 0 && flag) { // TODO: allow plugins to override?
+ if (deathMessage.equals(deathmessage)) {
-+ ScoreboardTeamBase scoreboardteambase = this.aY();
++ ScoreboardTeamBase scoreboardteambase = this.be();
+
+ if (scoreboardteambase != null && scoreboardteambase.getDeathMessageVisibility() != ScoreboardTeamBase.EnumNameTagVisibility.ALWAYS) {
+ if (scoreboardteambase.getDeathMessageVisibility() == ScoreboardTeamBase.EnumNameTagVisibility.HIDE_FOR_OTHER_TEAMS) {
@@ -257,85 +259,50 @@
this.releaseShoulderEntities();
- if (!this.world.getGameRules().getBoolean("keepInventory") && !this.isSpectator()) {
-- this.cV();
-- this.inventory.o();
+- this.di();
+- this.inventory.q();
+ // we clean the player's inventory after the EntityDeathEvent is called so plugins can get the exact state of the inventory.
+ if (!event.getKeepInventory()) {
+ this.inventory.clear();
}
-- Collection collection = this.world.getScoreboard().getObjectivesForCriteria(IScoreboardCriteria.d);
+- this.getScoreboard().getObjectivesForCriteria(IScoreboardCriteria.d, this.getName(), ScoreboardScore::incrementScore);
+ this.closeInventory();
+ this.setSpectatorTarget(this); // Remove spectated target
+ // CraftBukkit end
+
+ // CraftBukkit - Get our scores instead
-+ Collection collection = this.world.getServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.d, this.getName(), new java.util.ArrayList<ScoreboardScore>());
- Iterator iterator = collection.iterator();
++ this.world.getServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.d, this.getName(), ScoreboardScore::incrementScore);
++
+ EntityLiving entityliving = this.cu();
- while (iterator.hasNext()) {
-- ScoreboardObjective scoreboardobjective = (ScoreboardObjective) iterator.next();
-- ScoreboardScore scoreboardscore = this.getScoreboard().getPlayerScoreForObjective(this.getName(), scoreboardobjective);
-+ ScoreboardScore scoreboardscore = (ScoreboardScore) iterator.next(); // CraftBukkit - Use our scores instead
+ if (entityliving != null) {
+@@ -383,10 +537,12 @@
+ String s = this.getName();
+ String s1 = entity.getName();
- scoreboardscore.incrementScore();
- }
-@@ -373,29 +494,36 @@
- if (entity != this) {
- super.a(entity, i, damagesource);
- this.addScore(i);
-- Collection collection = this.getScoreboard().getObjectivesForCriteria(IScoreboardCriteria.f);
+- this.getScoreboard().getObjectivesForCriteria(IScoreboardCriteria.f, s, ScoreboardScore::incrementScore);
+ // CraftBukkit - Get our scores instead
-+ Collection<ScoreboardScore> collection = this.world.getServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.f, this.getName(), new java.util.ArrayList<ScoreboardScore>());
-
++ this.world.getServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.f, s, ScoreboardScore::incrementScore);
if (entity instanceof EntityHuman) {
- this.b(StatisticList.D);
-- collection.addAll(this.getScoreboard().getObjectivesForCriteria(IScoreboardCriteria.e));
+ this.a(StatisticList.PLAYER_KILLS);
+- this.getScoreboard().getObjectivesForCriteria(IScoreboardCriteria.e, s, ScoreboardScore::incrementScore);
+ // CraftBukkit - Get our scores instead
-+ this.world.getServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.e, this.getName(), collection);
-+ // collection.addAll(this.getScoreboard().getObjectivesForCriteria(IScoreboardCriteria.e));
-+ // CraftBukkit end
++ this.world.getServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.e, s, ScoreboardScore::incrementScore);
} else {
- this.b(StatisticList.B);
- }
-
- collection.addAll(this.E(entity));
-- Iterator iterator = collection.iterator();
-+ Iterator<ScoreboardScore> iterator = collection.iterator(); // CraftBukkit
-
- while (iterator.hasNext()) {
-- ScoreboardObjective scoreboardobjective = (ScoreboardObjective) iterator.next();
-+ // CraftBukkit start
-+ // ScoreboardObjective scoreboardobjective = (ScoreboardObjective) iterator.next();
-
-- this.getScoreboard().getPlayerScoreForObjective(this.getName(), scoreboardobjective).incrementScore();
-+ // this.getScoreboard().getPlayerScoreForObjective(this.getName(), scoreboardobjective).incrementScore();
-+ iterator.next().incrementScore();
-+ // CraftBukkit end
+ this.a(StatisticList.MOB_KILLS);
}
+@@ -404,7 +560,8 @@
+ int i = scoreboardteam.getColor().b();
- CriterionTriggers.b.a(this, entity, damagesource);
- }
- }
-
-- private Collection<ScoreboardObjective> E(Entity entity) {
-+ private Collection<ScoreboardScore> E(Entity entity) { // CraftBukkit
- String s = entity instanceof EntityHuman ? entity.getName() : entity.bn();
- ScoreboardTeam scoreboardteam = this.getScoreboard().getPlayerTeam(this.getName());
-
-@@ -420,7 +548,10 @@
- int j = scoreboardteam1.getColor().b();
-
- if (j >= 0 && j < IScoreboardCriteria.m.length) {
-- return this.getScoreboard().getObjectivesForCriteria(IScoreboardCriteria.m[j]);
+ if (i >= 0 && i < aiscoreboardcriteria.length) {
+- this.getScoreboard().getObjectivesForCriteria(aiscoreboardcriteria[i], s, ScoreboardScore::incrementScore);
+ // CraftBukkit - Get our scores instead
-+ return this.world.getServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.m[j], this.getName(), new java.util.ArrayList<ScoreboardScore>());
-+ // return this.getScoreboard().getObjectivesForCriteria(IScoreboardCriteria.m[j]);
-+ // CraftBukkit end
++ this.world.getServer().getScoreboardManager().getScoreboardScores(aiscoreboardcriteria[i], s, ScoreboardScore::incrementScore);
}
}
-@@ -462,12 +593,14 @@
+@@ -445,12 +602,14 @@
}
private boolean canPvP() {
@@ -345,14 +312,14 @@
}
@Nullable
- public Entity b(int i) {
+ public Entity d(int i) {
- this.worldChangeInvuln = true;
+ if (this.isSleeping()) return this; // CraftBukkit - SPIGOT-3154
+ // this.worldChangeInvuln = true; // CraftBukkit - Moved down and into PlayerList#changeDimension
if (this.dimension == 0 && i == -1) {
- this.cv = new Vec3D(this.locX, this.locY, this.locZ);
+ this.cD = new Vec3D(this.locX, this.locY, this.locZ);
} else if (this.dimension != -1 && i != 0) {
-@@ -475,6 +608,7 @@
+@@ -458,6 +617,7 @@
}
if (this.dimension == 1 && i == 1) {
@@ -360,7 +327,7 @@
this.world.kill(this);
if (!this.viewingCredits) {
this.viewingCredits = true;
-@@ -488,7 +622,10 @@
+@@ -471,7 +631,10 @@
i = 1;
}
@@ -372,15 +339,15 @@
this.playerConnection.sendPacket(new PacketPlayOutWorldEvent(1032, BlockPosition.ZERO, 0, false));
this.lastSentExp = -1;
this.lastHealthSent = -1.0F;
-@@ -534,6 +671,7 @@
+@@ -517,6 +680,7 @@
}
public void a(boolean flag, boolean flag1, boolean flag2) {
+ if (!this.sleeping) return; // CraftBukkit - Can't leave bed if not in one!
if (this.isSleeping()) {
- this.x().getTracker().sendPacketToEntity(this, new PacketPlayOutAnimation(this, 2));
+ this.getWorldServer().getTracker().sendPacketToEntity(this, new PacketPlayOutAnimation(this, 2));
}
-@@ -612,23 +750,55 @@
+@@ -595,23 +759,55 @@
this.playerConnection.sendPacket(new PacketPlayOutOpenSignEditor(tileentitysign.getPosition()));
}
@@ -391,12 +358,12 @@
}
public void openTileEntity(ITileEntityContainer itileentitycontainer) {
-- if (itileentitycontainer instanceof ILootable && ((ILootable) itileentitycontainer).b() != null && this.isSpectator()) {
+- if (itileentitycontainer instanceof ILootable && ((ILootable) itileentitycontainer).Q_() != null && this.isSpectator()) {
+ // CraftBukkit start - Inventory open hook
-+ 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);
++ if (false && itileentitycontainer instanceof ILootable && ((ILootable) itileentitycontainer).Q_() != null && this.isSpectator()) {
+ this.a((new ChatMessage("container.spectatorCantOpen", new Object[0])).a(EnumChatFormat.RED), true);
} else {
-+ boolean cancelled = itileentitycontainer instanceof ILootable && ((ILootable) itileentitycontainer).b() != null && this.isSpectator();
++ boolean cancelled = itileentitycontainer instanceof ILootable && ((ILootable) itileentitycontainer).Q_() != null && this.isSpectator();
+ Container container = CraftEventFactory.callInventoryOpenEvent(this, itileentitycontainer.createContainer(this.inventory, this), cancelled);
+ if (container == null) {
+ return;
@@ -436,13 +403,13 @@
+ }
+ // CraftBukkit end
+
- if (iinventory instanceof ILootable && ((ILootable) iinventory).b() != null && this.isSpectator()) {
- this.a((new ChatMessage("container.spectatorCantOpen", new Object[0])).setChatModifier((new ChatModifier()).setColor(EnumChatFormat.RED)), true);
+ if (iinventory instanceof ILootable && ((ILootable) iinventory).Q_() != null && this.isSpectator()) {
+ this.a((new ChatMessage("container.spectatorCantOpen", new Object[0])).a(EnumChatFormat.RED), true);
} else {
-@@ -642,18 +812,21 @@
+@@ -625,18 +821,21 @@
if (itileinventory.isLocked() && !this.a(itileinventory.getLock()) && !this.isSpectator()) {
this.playerConnection.sendPacket(new PacketPlayOutChat(new ChatMessage("container.isLocked", new Object[] { iinventory.getScoreboardDisplayName()}), ChatMessageType.GAME_INFO));
- this.playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect(SoundEffects.ab, SoundCategory.BLOCKS, this.locX, this.locY, this.locZ, 1.0F, 1.0F));
+ this.playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect(SoundEffects.BLOCK_CHEST_LOCKED, SoundCategory.BLOCKS, this.locX, this.locY, this.locZ, 1.0F, 1.0F));
+ iinventory.closeContainer(this); // CraftBukkit
return;
}
@@ -463,7 +430,7 @@
this.activeContainer.windowId = this.containerCounter;
this.activeContainer.addSlotListener(this);
-@@ -661,8 +834,14 @@
+@@ -644,8 +843,14 @@
}
public void openTrade(IMerchant imerchant) {
@@ -478,8 +445,8 @@
+ this.activeContainer = container; // CraftBukkit
this.activeContainer.windowId = this.containerCounter;
this.activeContainer.addSlotListener(this);
- InventoryMerchant inventorymerchant = ((ContainerMerchant) this.activeContainer).e();
-@@ -682,13 +861,20 @@
+ InventoryMerchant inventorymerchant = ((ContainerMerchant) this.activeContainer).d();
+@@ -665,13 +870,20 @@
}
public void openHorseInventory(EntityHorseAbstract entityhorseabstract, IInventory iinventory) {
@@ -501,7 +468,7 @@
this.activeContainer.windowId = this.containerCounter;
this.activeContainer.addSlotListener(this);
}
-@@ -729,6 +915,11 @@
+@@ -712,6 +924,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()));
@@ -513,59 +480,59 @@
}
public void setContainerData(Container container, int i, int j) {
-@@ -743,6 +934,7 @@
+@@ -726,6 +943,7 @@
}
public void closeInventory() {
+ CraftEventFactory.handleInventoryCloseEvent(this); // CraftBukkit
this.playerConnection.sendPacket(new PacketPlayOutCloseWindow(this.activeContainer.windowId));
- this.r();
+ this.m();
+ }
+@@ -759,14 +977,14 @@
+
+ public void a(Statistic<?> statistic, int i) {
+ this.ch.b(this, statistic, i);
+- this.getScoreboard().getObjectivesForCriteria(statistic, this.getName(), (scoreboardscore) -> {
++ this.world.getServer().getScoreboardManager().getScoreboardScores(statistic, this.getName(), (scoreboardscore) -> { // CraftBukkit - Get our scores instead
+ scoreboardscore.addScore(i);
+ });
}
-@@ -814,10 +1006,16 @@
- for (int j = 0; j < i; ++j) {
- MinecraftKey minecraftkey = aminecraftkey1[j];
-
-+ // CraftBukkit start
-+ if (CraftingManager.a(minecraftkey) == null) {
-+ Bukkit.getLogger().warning("Ignoring grant of non existent recipe " + minecraftkey);
-+ continue;
-+ }
-+ // CraftBukit end
- arraylist.add(CraftingManager.a(minecraftkey));
- }
-- this.a((List) arraylist);
-+ this.a((List<IRecipe>) arraylist); // CraftBukkit - decompile error
+ public void a(Statistic<?> statistic) {
+ this.ch.setStatistic(this, statistic, 0);
+- this.getScoreboard().getObjectivesForCriteria(statistic, this.getName(), ScoreboardScore::c);
++ this.world.getServer().getScoreboardManager().getScoreboardScores(statistic, this.getName(), ScoreboardScore::c); // CraftBukkit - Get our scores instead
}
- public void b(List<IRecipe> list) {
-@@ -839,7 +1037,16 @@
+ public int a(Collection<IRecipe> collection) {
+@@ -814,8 +1032,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 a(IChatBaseComponent ichatbasecomponent, boolean flag) {
this.playerConnection.sendPacket(new PacketPlayOutChat(ichatbasecomponent, flag ? ChatMessageType.GAME_INFO : ChatMessageType.CHAT));
-@@ -879,7 +1086,7 @@
+ }
+@@ -866,7 +1093,7 @@
this.lastSentExp = -1;
this.lastHealthSent = -1.0F;
- this.ch = -1;
-- this.cr.a((RecipeBook) entityplayer.cr);
-+ // this.cr.a((RecipeBook) entityplayer.cr); // CraftBukkit
+ this.cp = -1;
+- this.cz.a((RecipeBook) entityplayer.cz);
++ // this.cz.a((RecipeBook) entityplayer.cz); // CraftBukkit
this.removeQueue.addAll(entityplayer.removeQueue);
- this.cq = entityplayer.cq;
- this.cv = entityplayer.cv;
-@@ -938,6 +1145,18 @@
+ this.cy = entityplayer.cy;
+ this.cD = entityplayer.cD;
+@@ -925,6 +1152,18 @@
}
public void a(EnumGamemode enumgamemode) {
@@ -584,31 +551,7 @@
this.playerInteractManager.setGameMode(enumgamemode);
this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(3, (float) enumgamemode.getId()));
if (enumgamemode == EnumGamemode.SPECTATOR) {
-@@ -964,6 +1183,7 @@
- }
-
- public boolean a(int i, String s) {
-+ /* CraftBukkit start
- if ("seed".equals(s) && !this.server.aa()) {
- return true;
- } else if (!"tell".equals(s) && !"help".equals(s) && !"me".equals(s) && !"trigger".equals(s)) {
-@@ -977,6 +1197,15 @@
- } else {
- return true;
- }
-+ */
-+ if ("@".equals(s)) {
-+ return getBukkitEntity().hasPermission("minecraft.command.selector");
-+ }
-+ if ("".equals(s)) {
-+ return getBukkitEntity().isOp();
-+ }
-+ return getBukkitEntity().hasPermission("minecraft.command." + s);
-+ // CraftBukkit end
- }
-
- public String A() {
-@@ -988,6 +1217,16 @@
+@@ -968,6 +1207,16 @@
}
public void a(PacketPlayInSettings packetplayinsettings) {
@@ -618,23 +561,23 @@
+ this.server.server.getPluginManager().callEvent(event);
+ }
+ if (!this.locale.equals(packetplayinsettings.a())) {
-+ PlayerLocaleChangeEvent event = new PlayerLocaleChangeEvent(getBukkitEntity(), packetplayinsettings.a());
++ PlayerLocaleChangeEvent event = new PlayerLocaleChangeEvent(getBukkitEntity(), packetplayinsettings.b());
+ this.server.server.getPluginManager().callEvent(event);
+ }
+ // CraftBukkit end
- this.locale = packetplayinsettings.a();
- this.cl = packetplayinsettings.c();
- this.cm = packetplayinsettings.d();
-@@ -1053,7 +1292,7 @@
- this.co = (Entity) (entity == null ? this : entity);
- if (entity1 != this.co) {
- this.playerConnection.sendPacket(new PacketPlayOutCamera(this.co));
-- this.enderTeleportTo(this.co.locX, this.co.locY, this.co.locZ);
-+ this.playerConnection.a(this.co.locX, this.co.locY, this.co.locZ, this.yaw, this.pitch, TeleportCause.SPECTATE); // CraftBukkit
+ this.locale = packetplayinsettings.b();
+ this.ct = packetplayinsettings.d();
+ this.cu = packetplayinsettings.e();
+@@ -1039,7 +1288,7 @@
+ this.cw = (Entity) (entity == null ? this : entity);
+ if (entity1 != this.cw) {
+ this.playerConnection.sendPacket(new PacketPlayOutCamera(this.cw));
+- this.enderTeleportTo(this.cw.locX, this.cw.locY, this.cw.locZ);
++ this.playerConnection.a(this.cw.locX, this.cw.locY, this.cw.locZ, this.yaw, this.pitch, TeleportCause.SPECTATE); // CraftBukkit
}
}
-@@ -1080,7 +1319,7 @@
+@@ -1066,7 +1315,7 @@
@Nullable
public IChatBaseComponent getPlayerListName() {
@@ -643,15 +586,15 @@
}
public void a(EnumHand enumhand) {
-@@ -1097,12 +1336,17 @@
+@@ -1083,12 +1332,17 @@
}
- public void N() {
+ public void J() {
+ if (!CraftEventFactory.callToggleGlideEvent(this, true).isCancelled()) // CraftBukkit
this.setFlag(7, true);
}
- public void O() {
+ public void K() {
+ // CraftBukkit start
+ if (!CraftEventFactory.callToggleGlideEvent(this, false).isCancelled()) {
this.setFlag(7, true);
@@ -661,10 +604,32 @@
}
public AdvancementDataPlayer getAdvancementData() {
-@@ -1113,4 +1357,144 @@
- public Vec3D Q() {
- return this.cv;
+@@ -1100,9 +1354,16 @@
+ return this.cD;
}
+
++ // CraftBukkit start
+ public void a(WorldServer worldserver, double d0, double d1, double d2, float f, float f1) {
++ this.a(worldserver, d0, d1, d2, f, f1, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.UNKNOWN);
++ }
++
++ public void a(WorldServer worldserver, double d0, double d1, double d2, float f, float f1, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause cause) {
++ // CraftBukkit end
+ this.setSpectatorTarget(this);
+ this.stopRiding();
++ /* CraftBukkit start - replace with bukkit handling for multi-world
+ if (worldserver == this.world) {
+ this.playerConnection.a(d0, d1, d2, f, f1);
+ } else {
+@@ -1127,6 +1388,149 @@
+ this.server.getPlayerList().b(this, worldserver);
+ this.server.getPlayerList().updateClient(this);
+ }
++ */
++ this.getBukkitEntity().teleport(new Location(worldserver.getWorld(), d0, d1, d2, f, f1), cause);
++ // CraftBukkit end
++
++ }
+
+ // CraftBukkit start - Add per-player time and weather.
+ public long timeOffset = 0;
@@ -799,10 +764,10 @@
+ }
+ this.keepLevel = false;
+ }
-+
+
+ @Override
+ public CraftPlayer getBukkitEntity() {
+ return (CraftPlayer) super.getBukkitEntity();
-+ }
+ }
+ // CraftBukkit end
}
diff --git a/nms-patches/EntityPotion.patch b/nms-patches/EntityPotion.patch
index 117e59dc..f39d8365 100644
--- a/nms-patches/EntityPotion.patch
+++ b/nms-patches/EntityPotion.patch
@@ -1,7 +1,7 @@
--- a/net/minecraft/server/EntityPotion.java
+++ b/net/minecraft/server/EntityPotion.java
-@@ -6,6 +6,12 @@
- import javax.annotation.Nullable;
+@@ -5,6 +5,12 @@
+ import java.util.function.Predicate;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+// CraftBukkit start
@@ -13,16 +13,16 @@
public class EntityPotion extends EntityProjectile {
-@@ -87,7 +93,7 @@
+@@ -77,7 +83,7 @@
if (flag) {
- this.n();
+ this.l();
- } 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 @@
+@@ -114,6 +120,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);
@@ -30,7 +30,7 @@
if (!list1.isEmpty()) {
Iterator iterator = list1.iterator();
-@@ -141,21 +148,46 @@
+@@ -131,21 +138,46 @@
d1 = 1.0D;
}
@@ -91,7 +91,7 @@
}
}
}
-@@ -187,7 +219,14 @@
+@@ -177,7 +209,14 @@
entityareaeffectcloud.setColor(nbttagcompound.getInt("CustomPotionColor"));
}
diff --git a/nms-patches/EntityProjectile.patch b/nms-patches/EntityProjectile.patch
index af70eb1b..3e8aa8a0 100644
--- a/nms-patches/EntityProjectile.patch
+++ b/nms-patches/EntityProjectile.patch
@@ -1,14 +1,14 @@
--- a/net/minecraft/server/EntityProjectile.java
+++ b/net/minecraft/server/EntityProjectile.java
-@@ -35,6 +35,7 @@
- public EntityProjectile(World world, EntityLiving entityliving) {
- this(world, entityliving.locX, entityliving.locY + (double) entityliving.getHeadHeight() - 0.10000000149011612D, entityliving.locZ);
+@@ -33,6 +33,7 @@
+ this(entitytypes, entityliving.locX, entityliving.locY + (double) entityliving.getHeadHeight() - 0.10000000149011612D, entityliving.locZ, world);
this.shooter = entityliving;
+ this.shooterId = entityliving.getUniqueID();
+ this.projectileSource = (org.bukkit.entity.LivingEntity) entityliving.getBukkitEntity(); // CraftBukkit
}
- protected void i() {}
-@@ -127,7 +128,7 @@
+ protected void x_() {}
+@@ -111,7 +112,7 @@
if (entity1.isInteractable()) {
if (entity1 == this.d) {
flag = true;
@@ -17,7 +17,7 @@
this.d = entity1;
flag = true;
} else {
-@@ -164,6 +165,11 @@
+@@ -148,6 +149,11 @@
this.e(movingobjectposition.a());
} else {
this.a(movingobjectposition);
diff --git a/nms-patches/EntityRabbit.patch b/nms-patches/EntityRabbit.patch
index 890a0efd..91309d3b 100644
--- a/nms-patches/EntityRabbit.patch
+++ b/nms-patches/EntityRabbit.patch
@@ -1,8 +1,8 @@
--- a/net/minecraft/server/EntityRabbit.java
+++ b/net/minecraft/server/EntityRabbit.java
-@@ -16,8 +16,14 @@
+@@ -17,8 +17,14 @@
this.setSize(0.4F, 0.5F);
- this.g = new EntityRabbit.ControllerJumpRabbit(this);
+ this.h = new EntityRabbit.ControllerJumpRabbit(this);
this.moveController = new EntityRabbit.ControllerMoveRabbit(this);
+ this.initializePathFinderGoals(); // CraftBukkit - moved code
+ }
@@ -13,14 +13,14 @@
}
+ // CraftBukkit end
- protected void r() {
+ protected void n() {
this.goalSelector.a(1, new PathfinderGoalFloat(this));
-@@ -400,9 +406,23 @@
+@@ -397,9 +403,23 @@
Integer integer = (Integer) iblockdata.get(BlockCarrots.AGE);
if (integer.intValue() == 0) {
+ // CraftBukkit start
-+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.c, blockposition, Blocks.AIR, 0).isCancelled()) {
++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.f, blockposition, Blocks.AIR.getBlockData()).isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
@@ -29,13 +29,13 @@
} else {
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(
-+ this.c,
++ this.f,
+ blockposition,
-+ block, block.toLegacyData(iblockdata.set(BlockCarrots.AGE, Integer.valueOf(integer.intValue() - 1)))
++ iblockdata.set(BlockCarrots.AGE, Integer.valueOf(integer.intValue() - 1))
+ ).isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
- world.setTypeAndData(blockposition, iblockdata.set(BlockCarrots.AGE, Integer.valueOf(integer.intValue() - 1)), 2);
+ world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockCarrots.AGE, Integer.valueOf(integer.intValue() - 1)), 2);
world.triggerEffect(2001, blockposition, Block.getCombinedId(iblockdata));
}
diff --git a/nms-patches/EntitySheep.patch b/nms-patches/EntitySheep.patch
index 2f4845db..d9a10993 100644
--- a/nms-patches/EntitySheep.patch
+++ b/nms-patches/EntitySheep.patch
@@ -1,7 +1,7 @@
--- a/net/minecraft/server/EntitySheep.java
+++ b/net/minecraft/server/EntitySheep.java
-@@ -5,6 +5,12 @@
- import java.util.Random;
+@@ -10,6 +10,12 @@
+ import java.util.stream.Collectors;
import javax.annotation.Nullable;
+// CraftBukkit start
@@ -12,8 +12,8 @@
+
public class EntitySheep extends EntityAnimal {
- private static final DataWatcherObject<Byte> bx = DataWatcher.a(EntitySheep.class, DataWatcherRegistry.a);
-@@ -12,6 +18,13 @@
+ private static final DataWatcherObject<Byte> bC = DataWatcher.a(EntitySheep.class, DataWatcherRegistry.a);
+@@ -17,8 +23,15 @@
public boolean canUse(EntityHuman entityhuman) {
return false;
}
@@ -25,17 +25,12 @@
+ }
+ // CraftBukkit end
}, 2, 1);
- private static final Map<EnumColor, float[]> bz = Maps.newEnumMap(EnumColor.class);
- private int bB;
-@@ -29,6 +42,7 @@
- this.setSize(0.9F, 1.3F);
- this.container.setItem(0, new ItemStack(Items.DYE));
- this.container.setItem(1, new ItemStack(Items.DYE));
-+ this.container.resultInventory = new InventoryCraftResult(); // CraftBukkit - add result slot for event
- }
-
- protected void r() {
-@@ -131,11 +145,22 @@
+- private static final Map<EnumColor, IMaterial> bE = (Map) SystemUtils.a((Object) Maps.newEnumMap(EnumColor.class), (enummap) -> {
++ private static final Map<EnumColor, IMaterial> bE = (Map) SystemUtils.a(Maps.newEnumMap(EnumColor.class), (enummap) -> { // CraftBukkit - decompile error
+ enummap.put(EnumColor.WHITE, Blocks.WHITE_WOOL);
+ enummap.put(EnumColor.ORANGE, Blocks.ORANGE_WOOL);
+ enummap.put(EnumColor.MAGENTA, Blocks.MAGENTA_WOOL);
+@@ -158,11 +171,22 @@
if (itemstack.getItem() == Items.SHEARS && !this.isSheared() && !this.isBaby()) {
if (!this.world.isClientSide) {
@@ -53,15 +48,15 @@
for (int j = 0; j < i; ++j) {
+ this.forceDrops = true; // CraftBukkit
- EntityItem entityitem = this.a(new ItemStack(Item.getItemOf(Blocks.WOOL), 1, this.getColor().getColorIndex()), 1.0F);
+ EntityItem entityitem = this.a((IMaterial) EntitySheep.bE.get(this.getColor()), 1);
+ this.forceDrops = false; // CraftBukkit
- entityitem.motY += (double) (this.random.nextFloat() * 0.05F);
- entityitem.motX += (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F);
-@@ -222,6 +247,12 @@
+ if (entityitem != null) {
+ entityitem.motY += (double) (this.random.nextFloat() * 0.05F);
+@@ -247,6 +271,12 @@
}
- public void A() {
+ public void x() {
+ // CraftBukkit start
+ SheepRegrowWoolEvent event = new SheepRegrowWoolEvent((org.bukkit.entity.Sheep) this.getBukkitEntity());
+ this.world.getServer().getPluginManager().callEvent(event);
@@ -71,3 +66,11 @@
this.setSheared(false);
if (this.isBaby()) {
this.setAge(60);
+@@ -267,6 +297,7 @@
+
+ this.container.setItem(0, new ItemStack(ItemDye.a(enumcolor)));
+ this.container.setItem(1, new ItemStack(ItemDye.a(enumcolor1)));
++ this.container.resultInventory = new InventoryCraftResult(); // CraftBukkit - add result slot for event
+ ItemStack itemstack = entityanimal.world.D().craft(this.container, ((EntitySheep) entityanimal).world);
+ Item item = itemstack.getItem();
+ EnumColor enumcolor2;
diff --git a/nms-patches/EntityShulker.patch b/nms-patches/EntityShulker.patch
index 9b21b293..80e651f4 100644
--- a/nms-patches/EntityShulker.patch
+++ b/nms-patches/EntityShulker.patch
@@ -1,8 +1,8 @@
--- a/net/minecraft/server/EntityShulker.java
+++ b/net/minecraft/server/EntityShulker.java
@@ -6,6 +6,10 @@
- import java.util.List;
import java.util.UUID;
+ import java.util.function.Predicate;
import javax.annotation.Nullable;
+// CraftBukkit start
+import org.bukkit.Location;
@@ -11,19 +11,10 @@
public class EntityShulker extends EntityGolem implements IMonster {
-@@ -112,7 +116,7 @@
-
- this.datawatcher.set(EntityShulker.b, Optional.of(new BlockPosition(i, j, k)));
- } else {
-- this.datawatcher.set(EntityShulker.b, Optional.absent());
-+ this.datawatcher.set(EntityShulker.b, Optional.<BlockPosition>absent());
- }
-
- }
-@@ -331,8 +335,17 @@
+@@ -326,8 +330,17 @@
EnumDirection enumdirection = aenumdirection[k];
- if (this.world.d(blockposition1.shift(enumdirection), false)) {
+ if (this.world.q(blockposition1.shift(enumdirection))) {
- this.datawatcher.set(EntityShulker.a, enumdirection);
- flag = true;
+ // CraftBukkit start
diff --git a/nms-patches/EntityShulkerBullet.patch b/nms-patches/EntityShulkerBullet.patch
index 915d3747..a3b15400 100644
--- a/nms-patches/EntityShulkerBullet.patch
+++ b/nms-patches/EntityShulkerBullet.patch
@@ -1,6 +1,6 @@
--- a/net/minecraft/server/EntityShulkerBullet.java
+++ b/net/minecraft/server/EntityShulkerBullet.java
-@@ -46,8 +46,29 @@
+@@ -42,8 +42,29 @@
this.target = entity;
this.c = EnumDirection.UP;
this.a(enumdirection_enumaxis);
@@ -27,14 +27,14 @@
+ }
+ // CraftBukkit end
+
- protected void b(NBTTagCompound nbttagcompound) {
- BlockPosition blockposition;
- NBTTagCompound nbttagcompound1;
+ public SoundCategory bV() {
+ return SoundCategory.HOSTILE;
+ }
@@ -287,6 +308,7 @@
}
protected void a(MovingObjectPosition movingobjectposition) {
+ org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this, movingobjectposition); // Craftbukkit - Call event
if (movingobjectposition.entity == null) {
- ((WorldServer) this.world).a(EnumParticle.EXPLOSION_LARGE, this.locX, this.locY, this.locZ, 2, 0.2D, 0.2D, 0.2D, 0.0D, new int[0]);
- this.a(SoundEffects.gD, 1.0F, 1.0F);
+ ((WorldServer) this.world).a(Particles.u, this.locX, this.locY, this.locZ, 2, 0.2D, 0.2D, 0.2D, 0.0D);
+ this.a(SoundEffects.ENTITY_SHULKER_BULLET_HIT, 1.0F, 1.0F);
diff --git a/nms-patches/EntitySilverfish.patch b/nms-patches/EntitySilverfish.patch
index c631fa4c..6eeae7d5 100644
--- a/nms-patches/EntitySilverfish.patch
+++ b/nms-patches/EntitySilverfish.patch
@@ -1,23 +1,23 @@
--- a/net/minecraft/server/EntitySilverfish.java
+++ b/net/minecraft/server/EntitySilverfish.java
-@@ -157,6 +157,11 @@
+@@ -153,6 +153,11 @@
IBlockData iblockdata = world.getType(blockposition);
- if (BlockMonsterEggs.x(iblockdata)) {
+ if (BlockMonsterEggs.j(iblockdata)) {
+ // CraftBukkit start
-+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.a, blockposition, Blocks.MONSTER_EGG, Block.getId(BlockMonsterEggs.getById(iblockdata.getBlock().toLegacyData(iblockdata)))).isCancelled()) {
++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.a, blockposition, BlockMonsterEggs.f(iblockdata.getBlock())).isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
- world.setTypeAndData(blockposition, Blocks.MONSTER_EGG.getBlockData().set(BlockMonsterEggs.VARIANT, BlockMonsterEggs.EnumMonsterEggVarient.a(iblockdata)), 3);
+ world.setTypeAndData(blockposition, BlockMonsterEggs.f(iblockdata.getBlock()), 3);
this.a.doSpawnEffect();
this.a.die();
-@@ -200,6 +205,11 @@
- IBlockData iblockdata = world.getType(blockposition1);
+@@ -197,6 +202,11 @@
+ Block block = iblockdata.getBlock();
- if (iblockdata.getBlock() == Blocks.MONSTER_EGG) {
+ if (block instanceof BlockMonsterEggs) {
+ // CraftBukkit start
-+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.silverfish, blockposition1, Blocks.AIR, 0).isCancelled()) {
++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.silverfish, blockposition1, Blocks.AIR.getBlockData()).isCancelled()) {
+ continue;
+ }
+ // CraftBukkit end
diff --git a/nms-patches/EntitySkeleton.patch b/nms-patches/EntitySkeleton.patch
index 18243710..c763f721 100644
--- a/nms-patches/EntitySkeleton.patch
+++ b/nms-patches/EntitySkeleton.patch
@@ -1,6 +1,6 @@
--- a/net/minecraft/server/EntitySkeleton.java
+++ b/net/minecraft/server/EntitySkeleton.java
-@@ -34,7 +34,7 @@
+@@ -30,7 +30,7 @@
}
public void die(DamageSource damagesource) {
@@ -9,8 +9,8 @@
if (damagesource.getEntity() instanceof EntityCreeper) {
EntityCreeper entitycreeper = (EntityCreeper) damagesource.getEntity();
-@@ -43,6 +43,7 @@
- this.a(new ItemStack(Items.SKULL, 1, 0), 0.0F);
+@@ -39,6 +39,7 @@
+ this.a((IMaterial) Items.SKELETON_SKULL);
}
}
+ super.die(damagesource); // CraftBukkit - moved from above
diff --git a/nms-patches/EntitySkeletonAbstract.patch b/nms-patches/EntitySkeletonAbstract.patch
index 424cca7c..9b16ed82 100644
--- a/nms-patches/EntitySkeletonAbstract.patch
+++ b/nms-patches/EntitySkeletonAbstract.patch
@@ -1,37 +1,37 @@
--- a/net/minecraft/server/EntitySkeletonAbstract.java
+++ b/net/minecraft/server/EntitySkeletonAbstract.java
-@@ -2,12 +2,13 @@
-
- import java.util.Calendar;
+@@ -3,12 +3,13 @@
+ import java.time.LocalDate;
+ import java.time.temporal.ChronoField;
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 static final DataWatcherObject<Boolean> a = DataWatcher.a(EntitySkeletonAbstract.class, DataWatcherRegistry.i);
private final PathfinderGoalBowShoot<EntitySkeletonAbstract> 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.p(false);
-@@ -80,7 +81,14 @@
- }
+ EntitySkeletonAbstract.this.s(false);
+@@ -78,7 +79,14 @@
+ }
- if (flag) {
-- this.setOnFire(8);
-+ // CraftBukkit start
-+ EntityCombustEvent event = new EntityCombustEvent(this.getBukkitEntity(), 8);
-+ this.world.getServer().getPluginManager().callEvent(event);
+ 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
- }
++ if (!event.isCancelled()) {
++ this.setOnFire(event.getDuration());
++ }
++ // CraftBukkit end
}
}
-@@ -152,8 +160,19 @@
+
+@@ -151,8 +159,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));
@@ -46,7 +46,7 @@
+ world.addEntity(entityarrow);
+ }
+ // CraftBukkit end
- this.a(SoundEffects.gW, 1.0F, 1.0F / (this.getRandom().nextFloat() * 0.4F + 0.8F));
+ this.a(SoundEffects.ENTITY_SKELETON_SHOOT, 1.0F, 1.0F / (this.getRandom().nextFloat() * 0.4F + 0.8F));
- this.world.addEntity(entityarrow);
+ // this.world.addEntity(entityarrow); // CraftBukkit - moved up
}
diff --git a/nms-patches/EntitySkeletonWither.patch b/nms-patches/EntitySkeletonWither.patch
index 25d7fc87..d66a1b59 100644
--- a/nms-patches/EntitySkeletonWither.patch
+++ b/nms-patches/EntitySkeletonWither.patch
@@ -1,6 +1,6 @@
--- a/net/minecraft/server/EntitySkeletonWither.java
+++ b/net/minecraft/server/EntitySkeletonWither.java
-@@ -36,7 +36,7 @@
+@@ -32,7 +32,7 @@
}
public void die(DamageSource damagesource) {
@@ -9,8 +9,8 @@
if (damagesource.getEntity() instanceof EntityCreeper) {
EntityCreeper entitycreeper = (EntityCreeper) damagesource.getEntity();
-@@ -45,6 +45,7 @@
- this.a(new ItemStack(Items.SKULL, 1, 1), 0.0F);
+@@ -41,6 +41,7 @@
+ this.a((IMaterial) Items.WITHER_SKELETON_SKULL);
}
}
+ super.die(damagesource); // CraftBukkit - moved from above
diff --git a/nms-patches/EntitySlime.patch b/nms-patches/EntitySlime.patch
index 6e55a144..0e817f25 100644
--- a/nms-patches/EntitySlime.patch
+++ b/nms-patches/EntitySlime.patch
@@ -10,6 +10,15 @@
public class EntitySlime extends EntityInsentient implements IMonster {
+@@ -134,7 +137,7 @@
+ }
+
+ public EntityTypes<? extends EntitySlime> P() {
+- return super.P();
++ return (EntityTypes<? extends EntitySlime>) super.P(); // CraftBukkit - decompile error
+ }
+
+ public void die() {
@@ -143,6 +146,18 @@
if (!this.world.isClientSide && i > 1 && this.getHealth() <= 0.0F) {
int j = 2 + this.random.nextInt(3);
diff --git a/nms-patches/EntitySmallFireball.patch b/nms-patches/EntitySmallFireball.patch
index 0833ca94..0a93a44c 100644
--- a/nms-patches/EntitySmallFireball.patch
+++ b/nms-patches/EntitySmallFireball.patch
@@ -8,10 +8,10 @@
public class EntitySmallFireball extends EntityFireball {
public EntitySmallFireball(World world) {
-@@ -10,6 +12,11 @@
+@@ -8,6 +10,11 @@
+
public EntitySmallFireball(World world, EntityLiving entityliving, double d0, double d1, double d2) {
- super(world, entityliving, d0, d1, d2);
- this.setSize(0.3125F, 0.3125F);
+ super(EntityTypes.SMALL_FIREBALL, entityliving, d0, d1, d2, world, 0.3125F, 0.3125F);
+ // CraftBukkit start
+ if (this.shooter != null && this.shooter instanceof EntityInsentient) {
+ isIncendiary = this.world.getGameRules().getBoolean("mobGriefing");
@@ -20,7 +20,7 @@
}
public EntitySmallFireball(World world, double d0, double d1, double d2, double d3, double d4, double d5) {
-@@ -27,10 +34,17 @@
+@@ -20,10 +27,17 @@
if (movingobjectposition.entity != null) {
if (!movingobjectposition.entity.isFireProof()) {
@@ -41,7 +41,7 @@
}
}
} else {
-@@ -39,11 +53,15 @@
+@@ -32,11 +46,15 @@
flag = this.world.getGameRules().getBoolean("mobGriefing");
}
@@ -52,7 +52,7 @@
if (this.world.isEmpty(blockposition)) {
- this.world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData());
-+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this).isCancelled()) {
++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition, this).isCancelled()) {
+ this.world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData());
+ }
+ // CraftBukkit end
diff --git a/nms-patches/EntitySnowman.patch b/nms-patches/EntitySnowman.patch
index bf919be5..d78d5726 100644
--- a/nms-patches/EntitySnowman.patch
+++ b/nms-patches/EntitySnowman.patch
@@ -11,25 +11,25 @@
public class EntitySnowman extends EntityGolem implements IRangedEntity {
-@@ -59,7 +63,7 @@
+@@ -55,7 +59,7 @@
}
- if (this.world.getBiome(new BlockPosition(i, 0, k)).a(new BlockPosition(i, j, k)) > 1.0F) {
+ if (this.world.getBiome(new BlockPosition(i, 0, k)).c(new BlockPosition(i, j, k)) > 1.0F) {
- this.damageEntity(DamageSource.BURN, 1.0F);
+ this.damageEntity(CraftEventFactory.MELTING, 1.0F); // CraftBukkit - DamageSource.BURN -> CraftEventFactory.MELTING
}
if (!this.world.getGameRules().getBoolean("mobGriefing")) {
-@@ -73,7 +77,7 @@
+@@ -71,7 +75,7 @@
BlockPosition blockposition = new BlockPosition(i, j, k);
- 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());
-+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this.world, blockposition, Blocks.SNOW_LAYER.getBlockData(), this); // CraftBukkit
+ if (this.world.getType(blockposition).isAir() && this.world.getBiome(blockposition).c(blockposition) < 0.8F && iblockdata.canPlace(this.world, blockposition)) {
+- this.world.setTypeUpdate(blockposition, iblockdata);
++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this.world, blockposition, iblockdata, this); // CraftBukkit
}
}
}
-@@ -106,6 +110,15 @@
+@@ -104,6 +108,15 @@
ItemStack itemstack = entityhuman.b(enumhand);
if (itemstack.getItem() == Items.SHEARS && this.hasPumpkin() && !this.world.isClientSide) {
diff --git a/nms-patches/EntitySpider.patch b/nms-patches/EntitySpider.patch
index 4c7b19b3..ce14684d 100644
--- a/nms-patches/EntitySpider.patch
+++ b/nms-patches/EntitySpider.patch
@@ -3,7 +3,7 @@
@@ -115,7 +115,7 @@
entityskeleton.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, 0.0F);
- entityskeleton.prepare(difficultydamagescaler, (GroupDataEntity) null);
+ entityskeleton.prepare(difficultydamagescaler, (GroupDataEntity) null, (NBTTagCompound) null);
- this.world.addEntity(entityskeleton);
+ this.world.addEntity(entityskeleton, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.JOCKEY); // CraftBukkit - add SpawnReason
entityskeleton.startRiding(this);
diff --git a/nms-patches/EntityTNTPrimed.patch b/nms-patches/EntityTNTPrimed.patch
index 0836702c..d5a2e2c3 100644
--- a/nms-patches/EntityTNTPrimed.patch
+++ b/nms-patches/EntityTNTPrimed.patch
@@ -16,7 +16,7 @@
+ public boolean isIncendiary = false; // CraftBukkit - add field
public EntityTNTPrimed(World world) {
- super(world);
+ super(EntityTypes.TNT, world);
@@ -64,10 +67,13 @@
--this.c;
@@ -30,8 +30,8 @@
+ this.die();
+ // CraftBukkit end
} else {
- this.aq();
- this.world.addParticle(EnumParticle.SMOKE_NORMAL, this.locX, this.locY + 0.5D, this.locZ, 0.0D, 0.0D, 0.0D, new int[0]);
+ this.at();
+ this.world.addParticle(Particles.M, this.locX, this.locY + 0.5D, this.locZ, 0.0D, 0.0D, 0.0D);
@@ -76,9 +82,17 @@
}
diff --git a/nms-patches/EntityThrownExpBottle.patch b/nms-patches/EntityThrownExpBottle.patch
index 256bf0ad..6f2cee21 100644
--- a/nms-patches/EntityThrownExpBottle.patch
+++ b/nms-patches/EntityThrownExpBottle.patch
@@ -1,6 +1,6 @@
--- a/net/minecraft/server/EntityThrownExpBottle.java
+++ b/net/minecraft/server/EntityThrownExpBottle.java
-@@ -24,9 +24,18 @@
+@@ -20,9 +20,18 @@
protected void a(MovingObjectPosition movingobjectposition) {
if (!this.world.isClientSide) {
diff --git a/nms-patches/EntityTracker.patch b/nms-patches/EntityTracker.patch
index 1e0a52a9..795c5f22 100644
--- a/nms-patches/EntityTracker.patch
+++ b/nms-patches/EntityTracker.patch
@@ -9,18 +9,3 @@
} else if (entity instanceof EntityEnderCrystal) {
this.addEntity(entity, 256, Integer.MAX_VALUE, false);
} else if (entity instanceof EntityEvokerFangs) {
-@@ -120,11 +120,12 @@
- CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Entity To Track");
-
- crashreportsystemdetails.a("Tracking range", (Object) (i + " blocks"));
-+ final int finalI = i; // CraftBukkit - fix decompile error
- crashreportsystemdetails.a("Update interval", new CrashReportCallable() {
- public String a() throws Exception {
-- String s = "Once per " + i + " ticks";
-+ String s = "Once per " + finalI + " ticks"; // CraftBukkit
-
-- if (i == Integer.MAX_VALUE) {
-+ if (finalI == Integer.MAX_VALUE) { // CraftBukkit
- s = "Maximum (" + s + ")";
- }
-
diff --git a/nms-patches/EntityTrackerEntry.patch b/nms-patches/EntityTrackerEntry.patch
index 88438c35..cb8903ad 100644
--- a/nms-patches/EntityTrackerEntry.patch
+++ b/nms-patches/EntityTrackerEntry.patch
@@ -28,7 +28,7 @@
- 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);
+ WorldMap worldmap = ItemWorldMap.getSavedMap(itemstack, this.tracker.world);
- Iterator iterator = list.iterator();
+ Iterator iterator = this.trackedPlayers.iterator(); // CraftBukkit
diff --git a/nms-patches/EntityTypes.patch b/nms-patches/EntityTypes.patch
new file mode 100644
index 00000000..8b0f7041
--- /dev/null
+++ b/nms-patches/EntityTypes.patch
@@ -0,0 +1,39 @@
+--- a/net/minecraft/server/EntityTypes.java
++++ b/net/minecraft/server/EntityTypes.java
+@@ -148,10 +148,16 @@
+
+ @Nullable
+ public T a(World world, @Nullable NBTTagCompound nbttagcompound, @Nullable IChatBaseComponent ichatbasecomponent, @Nullable EntityHuman entityhuman, BlockPosition blockposition, boolean flag, boolean flag1) {
++ // CraftBukkit start
++ return spawnCreature(world, nbttagcompound, ichatbasecomponent, entityhuman, blockposition, flag, flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG);
++ }
++
++ @Nullable
++ public T spawnCreature(World world, @Nullable NBTTagCompound nbttagcompound, @Nullable IChatBaseComponent ichatbasecomponent, @Nullable EntityHuman entityhuman, BlockPosition blockposition, boolean flag, boolean flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) {
+ Entity entity = this.b(world, nbttagcompound, ichatbasecomponent, entityhuman, blockposition, flag, flag1);
+
+- world.addEntity(entity);
+- return entity;
++ return world.addEntity(entity, spawnReason) ? (T) entity : null; // Don't return an entity when CreatureSpawnEvent is canceled
++ // CraftBukkit end
+ }
+
+ @Nullable
+@@ -185,7 +191,7 @@
+ }
+
+ a(world, entityhuman, entity, nbttagcompound);
+- return entity;
++ return (T) entity; // CraftBukkit - decompile error
+ }
+ }
+
+@@ -240,7 +246,7 @@
+
+ @Nullable
+ public T a(World world) {
+- return (Entity) this.aU.apply(world);
++ return this.aU.apply(world); // CraftBukkit - decompile error
+ }
+
+ @Nullable
diff --git a/nms-patches/EntityVex.patch b/nms-patches/EntityVex.patch
index 0c50e0e2..08fc317e 100644
--- a/nms-patches/EntityVex.patch
+++ b/nms-patches/EntityVex.patch
@@ -8,7 +8,7 @@
public class EntityVex extends EntityMonster {
-@@ -182,7 +183,7 @@
+@@ -178,7 +179,7 @@
}
public void c() {
diff --git a/nms-patches/EntityVillager.patch b/nms-patches/EntityVillager.patch
index 8693d0ff..201e9a2c 100644
--- a/nms-patches/EntityVillager.patch
+++ b/nms-patches/EntityVillager.patch
@@ -1,6 +1,6 @@
--- a/net/minecraft/server/EntityVillager.java
+++ b/net/minecraft/server/EntityVillager.java
-@@ -6,6 +6,14 @@
+@@ -7,6 +7,14 @@
import javax.annotation.Nullable;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -15,32 +15,16 @@
public class EntityVillager extends EntityAgeable implements NPC, IMerchant {
-@@ -18,13 +26,13 @@
- @Nullable
- private EntityHuman tradingPlayer;
- @Nullable
-- private MerchantRecipeList trades;
-+ public MerchantRecipeList trades; // PAIL private -> public
- private int bF;
- private boolean bG;
- private boolean bH;
- public int riches;
- private String bJ;
-- private int bK;
-+ public int bK; // PAIL private -> public // PAIL rename careerID
- private int bL;
- private boolean bM;
- private boolean bN;
-@@ -37,7 +45,7 @@
+@@ -38,7 +46,7 @@
public EntityVillager(World world, int i) {
- super(world);
-- this.inventory = new InventorySubcontainer("Items", false, 8);
-+ this.inventory = new InventorySubcontainer("Items", false, 8, (CraftVillager) this.getBukkitEntity()); // CraftBukkit add argument
+ super(EntityTypes.VILLAGER, world);
+- this.inventory = new InventorySubcontainer(new ChatComponentText("Items"), 8);
++ this.inventory = new InventorySubcontainer(new ChatComponentText("Items"), 8, (CraftVillager) this.getBukkitEntity()); // CraftBukkit add argument
this.setProfession(i);
this.setSize(0.6F, 1.95F);
((Navigation) this.getNavigation()).a(true);
-@@ -119,7 +127,14 @@
+@@ -120,7 +128,14 @@
MerchantRecipe merchantrecipe = (MerchantRecipe) iterator.next();
if (merchantrecipe.h()) {
@@ -56,16 +40,7 @@
}
}
-@@ -432,7 +447,7 @@
- return this.trades;
- }
-
-- private void dx() {
-+ public void dx() { // CraftBukkit private -> public // PAIL rename populateTrades
- EntityVillager.IMerchantRecipeOption[][][] aentityvillager_imerchantrecipeoption = EntityVillager.bP[this.getProfession()];
-
- if (this.bK != 0 && this.bL != 0) {
-@@ -460,7 +475,20 @@
+@@ -434,7 +449,20 @@
for (int l = 0; l < k; ++l) {
EntityVillager.IMerchantRecipeOption entityvillager_imerchantrecipeoption = aentityvillager_imerchantrecipeoption3[l];
diff --git a/nms-patches/EntityWither.patch b/nms-patches/EntityWither.patch
index c6a4a11e..26eb069d 100644
--- a/nms-patches/EntityWither.patch
+++ b/nms-patches/EntityWither.patch
@@ -1,7 +1,7 @@
--- a/net/minecraft/server/EntityWither.java
+++ b/net/minecraft/server/EntityWither.java
@@ -5,6 +5,12 @@
- import java.util.List;
+ import java.util.function.Predicate;
import javax.annotation.Nullable;
+// CraftBukkit start
@@ -13,9 +13,9 @@
public class EntityWither extends EntityMonster implements IRangedEntity {
private static final DataWatcherObject<Integer> a = DataWatcher.a(EntityWither.class, DataWatcherRegistry.b);
-@@ -192,13 +198,38 @@
- if (this.dm() > 0) {
- i = this.dm() - 1;
+@@ -181,13 +187,38 @@
+ if (this.dz() > 0) {
+ i = this.dz() - 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);
@@ -48,26 +48,26 @@
+ // CraftBukkit end
}
- this.g(i);
+ this.e(i);
if (this.ticksLived % 10 == 0) {
- this.heal(10.0F);
+ this.heal(10.0F, EntityRegainHealthEvent.RegainReason.WITHER_SPAWN); // CraftBukkit
}
} else {
-@@ -289,6 +320,11 @@
+@@ -278,6 +309,11 @@
Block block = iblockdata.getBlock();
- if (iblockdata.getMaterial() != Material.AIR && a(block)) {
+ if (!iblockdata.isAir() && a(block)) {
+ // CraftBukkit start
-+ if (CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, Blocks.AIR, 0).isCancelled()) {
++ if (CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, Blocks.AIR.getBlockData()).isCancelled()) {
+ continue;
+ }
+ // CraftBukkit end
flag = this.world.setAir(blockposition, true) || flag;
}
}
-@@ -302,7 +338,7 @@
+@@ -291,7 +327,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.bL.setProgress(this.getHealth() / this.getMaxHealth());
diff --git a/nms-patches/EntityWitherSkull.patch b/nms-patches/EntityWitherSkull.patch
index ba9d9478..c700d1a9 100644
--- a/nms-patches/EntityWitherSkull.patch
+++ b/nms-patches/EntityWitherSkull.patch
@@ -7,8 +7,8 @@
+
public class EntityWitherSkull extends EntityFireball {
- private static final DataWatcherObject<Boolean> e = DataWatcher.a(EntityWitherSkull.class, DataWatcherRegistry.h);
-@@ -41,11 +43,11 @@
+ private static final DataWatcherObject<Boolean> e = DataWatcher.a(EntityWitherSkull.class, DataWatcherRegistry.i);
+@@ -28,11 +30,11 @@
if (!this.world.isClientSide) {
if (movingobjectposition.entity != null) {
if (this.shooter != null) {
@@ -22,7 +22,7 @@
}
}
} else {
-@@ -67,7 +69,15 @@
+@@ -54,7 +56,15 @@
}
}
diff --git a/nms-patches/EntityWolf.patch b/nms-patches/EntityWolf.patch
index 1efa3ef5..69378f11 100644
--- a/nms-patches/EntityWolf.patch
+++ b/nms-patches/EntityWolf.patch
@@ -1,7 +1,7 @@
--- a/net/minecraft/server/EntityWolf.java
+++ b/net/minecraft/server/EntityWolf.java
@@ -4,6 +4,11 @@
- import java.util.UUID;
+ import java.util.function.Predicate;
import javax.annotation.Nullable;
+// CraftBukkit start
@@ -12,7 +12,7 @@
public class EntityWolf extends EntityTameableAnimal {
private static final DataWatcherObject<Float> DATA_HEALTH = DataWatcher.a(EntityWolf.class, DataWatcherRegistry.c);
-@@ -62,6 +67,22 @@
+@@ -57,6 +62,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) {
-@@ -200,9 +221,9 @@
+@@ -191,7 +212,8 @@
Entity entity = damagesource.getEntity();
if (this.goalSit != null) {
@@ -43,11 +43,9 @@
+ // CraftBukkit - moved into EntityLiving.d(DamageSource, float)
+ // this.goalSit.setSitting(false);
}
--
+
if (entity != null && !(entity instanceof EntityHuman) && !(entity instanceof EntityArrow)) {
- f = (f + 1.0F) / 2.0F;
- }
-@@ -245,7 +266,7 @@
+@@ -237,7 +259,7 @@
itemstack.subtract(1);
}
@@ -55,17 +53,17 @@
+ this.heal((float) itemfood.getNutrition(itemstack), org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.EATING); // CraftBukkit
return true;
}
- } else if (itemstack.getItem() == Items.DYE) {
-@@ -266,7 +287,7 @@
+ } else if (item instanceof ItemDye) {
+@@ -258,7 +280,7 @@
this.goalSit.setSitting(!this.isSitting());
- this.bd = false;
- this.navigation.p();
+ this.bg = false;
+ this.navigation.r();
- this.setGoalTarget((EntityLiving) null);
+ this.setGoalTarget((EntityLiving) null, TargetReason.FORGOT_TARGET, true); // CraftBukkit - reason
}
- } else if (itemstack.getItem() == Items.BONE && !this.isAngry()) {
+ } else if (item == Items.BONE && !this.isAngry()) {
if (!entityhuman.abilities.canInstantlyBuild) {
-@@ -274,12 +295,13 @@
+@@ -266,12 +288,13 @@
}
if (!this.world.isClientSide) {
@@ -73,11 +71,11 @@
+ // CraftBukkit - added event call and isCancelled check.
+ if (this.random.nextInt(3) == 0 && !CraftEventFactory.callEntityTameEvent(this, entityhuman).isCancelled()) {
this.c(entityhuman);
- this.navigation.p();
+ this.navigation.r();
this.setGoalTarget((EntityLiving) null);
this.goalSit.setSitting(true);
- this.setHealth(20.0F);
+ this.setHealth(this.getMaxHealth()); // CraftBukkit - 20.0 -> getMaxHealth()
- this.p(true);
+ this.s(true);
this.world.broadcastEntityEffect(this, (byte) 7);
} else {
diff --git a/nms-patches/EntityZombie.patch b/nms-patches/EntityZombie.patch
index 60c08876..4ae666cd 100644
--- a/nms-patches/EntityZombie.patch
+++ b/nms-patches/EntityZombie.patch
@@ -1,6 +1,6 @@
--- a/net/minecraft/server/EntityZombie.java
+++ b/net/minecraft/server/EntityZombie.java
-@@ -5,6 +5,13 @@
+@@ -6,6 +6,13 @@
import java.util.UUID;
import javax.annotation.Nullable;
@@ -13,36 +13,36 @@
+
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");
-@@ -133,7 +140,14 @@
- }
+ protected static final IAttribute c = (new AttributeRanged((IAttribute) null, "zombie.spawnReinforcements", 0.0D, 0.0D, 1.0D)).a("Spawn Reinforcements Chance");
+@@ -182,7 +189,14 @@
+ }
- if (flag) {
-- this.setOnFire(8);
-+ // CraftBukkit start
-+ EntityCombustEvent event = new EntityCombustEvent(this.getBukkitEntity(), 8);
-+ this.world.getServer().getPluginManager().callEvent(event);
+ 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
- }
++ if (!event.isCancelled()) {
++ this.setOnFire(event.getDuration());
++ }
++ // CraftBukkit end
}
}
-@@ -167,8 +181,8 @@
+
+@@ -251,8 +265,8 @@
if (this.world.getType(new BlockPosition(i1, j1 - 1, k1)).q() && 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())) {
+ if (!this.world.isPlayerNearby((double) i1, (double) j1, (double) k1, 7.0D) && this.world.b((Entity) entityzombie, entityzombie.getBoundingBox()) && this.world.getCubes(entityzombie, entityzombie.getBoundingBox()) && !this.world.containsLiquid(entityzombie.getBoundingBox())) {
- this.world.addEntity(entityzombie);
- entityzombie.setGoalTarget(entityliving);
+ this.world.addEntity(entityzombie, CreatureSpawnEvent.SpawnReason.REINFORCEMENTS); // CraftBukkit
-+ entityzombie.setGoalTarget(entityliving, EntityTargetEvent.TargetReason.REINFORCEMENT_TARGET, true);
- 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));
-@@ -191,7 +205,14 @@
- float f = this.world.D(new BlockPosition(this)).b();
++ entityzombie.setGoalTarget(entityliving, EntityTargetEvent.TargetReason.REINFORCEMENT_TARGET, true); // CraftBukkit
+ entityzombie.prepare(this.world.getDamageScaler(new BlockPosition(entityzombie)), (GroupDataEntity) null, (NBTTagCompound) null);
+ this.getAttributeInstance(EntityZombie.c).b(new AttributeModifier("Zombie reinforcement caller charge", -0.05000000074505806D, 0));
+ entityzombie.getAttributeInstance(EntityZombie.c).b(new AttributeModifier("Zombie reinforcement callee charge", -0.05000000074505806D, 0));
+@@ -275,7 +289,14 @@
+ float f = this.world.getDamageScaler(new BlockPosition(this)).b();
if (this.getItemInMainHand().isEmpty() && this.isBurning() && this.random.nextFloat() < f * 0.3F) {
- entity.setOnFire(2 * (int) f);
@@ -57,7 +57,7 @@
}
}
-@@ -284,7 +305,7 @@
+@@ -371,7 +392,7 @@
entityzombievillager.setCustomNameVisible(entityvillager.getCustomNameVisible());
}
@@ -66,16 +66,16 @@
this.world.a((EntityHuman) null, 1026, new BlockPosition(this), 0);
}
-@@ -334,7 +355,7 @@
+@@ -421,7 +442,7 @@
entitychicken1.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, 0.0F);
- entitychicken1.prepare(difficultydamagescaler, (GroupDataEntity) null);
- entitychicken1.p(true);
+ entitychicken1.prepare(difficultydamagescaler, (GroupDataEntity) null, (NBTTagCompound) null);
+ entitychicken1.s(true);
- this.world.addEntity(entitychicken1);
+ this.world.addEntity(entitychicken1, CreatureSpawnEvent.SpawnReason.MOUNT); // CraftBukkit
this.startRiding(entitychicken1);
}
}
-@@ -392,7 +413,7 @@
+@@ -494,7 +515,7 @@
}
public void die(DamageSource damagesource) {
@@ -84,7 +84,7 @@
if (damagesource.getEntity() instanceof EntityCreeper) {
EntityCreeper entitycreeper = (EntityCreeper) damagesource.getEntity();
-@@ -405,6 +426,7 @@
+@@ -507,6 +528,7 @@
}
}
}
diff --git a/nms-patches/EntityZombieVillager.patch b/nms-patches/EntityZombieVillager.patch
index 247d0227..c4d767bc 100644
--- a/nms-patches/EntityZombieVillager.patch
+++ b/nms-patches/EntityZombieVillager.patch
@@ -1,17 +1,17 @@
--- a/net/minecraft/server/EntityZombieVillager.java
+++ b/net/minecraft/server/EntityZombieVillager.java
@@ -9,6 +9,7 @@
- private static final DataWatcherObject<Integer> c = DataWatcher.a(EntityZombieVillager.class, DataWatcherRegistry.b);
+ private static final DataWatcherObject<Integer> b = DataWatcher.a(EntityZombieVillager.class, DataWatcherRegistry.b);
private int conversionTime;
- private UUID by;
+ private UUID bD;
+ private int lastTick = MinecraftServer.currentTick; // CraftBukkit - add field
public EntityZombieVillager(World world) {
- super(world);
-@@ -60,6 +61,11 @@
- public void B_() {
+ super(EntityTypes.ZOMBIE_VILLAGER, world);
+@@ -56,6 +57,11 @@
+ public void tick() {
if (!this.world.isClientSide && this.isConverting()) {
- int i = this.du();
+ int i = this.dK();
+ // CraftBukkit start - Use wall time instead of ticks for villager conversion
+ int elapsedTicks = MinecraftServer.currentTick - this.lastTick;
+ this.lastTick = MinecraftServer.currentTick;
@@ -26,6 +26,6 @@
- this.world.addEntity(entityvillager);
+ this.world.addEntity(entityvillager, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CURED); // CraftBukkit - add SpawnReason
- if (this.by != null) {
- EntityHuman entityhuman = this.world.b(this.by);
+ if (this.bD != null) {
+ EntityHuman entityhuman = this.world.b(this.bD);
diff --git a/nms-patches/ExpirableListEntry.patch b/nms-patches/ExpirableListEntry.patch
index aa81c824..6b07ceff 100644
--- a/nms-patches/ExpirableListEntry.patch
+++ b/nms-patches/ExpirableListEntry.patch
@@ -1,6 +1,6 @@
--- a/net/minecraft/server/ExpirableListEntry.java
+++ b/net/minecraft/server/ExpirableListEntry.java
-@@ -22,7 +22,7 @@
+@@ -23,7 +23,7 @@
}
protected ExpirableListEntry(T t0, JsonObject jsonobject) {
@@ -9,7 +9,7 @@
Date date;
-@@ -65,4 +65,30 @@
+@@ -72,4 +72,30 @@
jsonobject.addProperty("expires", this.d == null ? "forever" : ExpirableListEntry.a.format(this.d));
jsonobject.addProperty("reason", this.e);
}
diff --git a/nms-patches/Explosion.patch b/nms-patches/Explosion.patch
index ccc8d40f..be06f65b 100644
--- a/nms-patches/Explosion.patch
+++ b/nms-patches/Explosion.patch
@@ -14,13 +14,13 @@
public class Explosion {
private final boolean a;
-@@ -23,11 +30,12 @@
- private final float size;
+@@ -24,11 +31,12 @@
+ private DamageSource j;
private final List<BlockPosition> blocks = Lists.newArrayList();
- private final Map<EntityHuman, Vec3D> k = Maps.newHashMap();
+ private final Map<EntityHuman, Vec3D> l = Maps.newHashMap();
+ public boolean wasCanceled = false; // CraftBukkit - add field
- public Explosion(World world, Entity entity, double d0, double d1, double d2, float f, boolean flag, boolean flag1) {
+ public Explosion(World world, @Nullable Entity entity, double d0, double d1, double d2, float f, boolean flag, boolean flag1) {
this.world = world;
this.source = entity;
- this.size = f;
@@ -28,7 +28,7 @@
this.posX = d0;
this.posY = d1;
this.posZ = d2;
-@@ -36,6 +44,11 @@
+@@ -38,6 +46,11 @@
}
public void a() {
@@ -40,7 +40,7 @@
HashSet hashset = Sets.newHashSet();
boolean flag = true;
-@@ -69,7 +82,7 @@
+@@ -75,7 +88,7 @@
f -= (f2 + 0.3F) * 0.3F;
}
@@ -49,16 +49,16 @@
hashset.add(blockposition);
}
-@@ -113,7 +126,16 @@
+@@ -119,7 +132,16 @@
double d12 = (double) this.world.a(vec3d, entity.getBoundingBox());
double d13 = (1.0D - d7) * d12;
-- entity.damageEntity(DamageSource.explosion(this), (float) ((int) ((d13 * d13 + d13) / 2.0D * 7.0D * (double) f3 + 1.0D)));
+- entity.damageEntity(this.b(), (float) ((int) ((d13 * d13 + d13) / 2.0D * 7.0D * (double) f3 + 1.0D)));
+ // CraftBukkit start
-+ // entity.damageEntity(DamageSource.explosion(this), (float) ((int) ((d13 * d13 + d13) / 2.0D * 7.0D * (double) f3 + 1.0D)));
++ // entity.damageEntity(this.b(), (float) ((int) ((d13 * d13 + d13) / 2.0D * 7.0D * (double) f3 + 1.0D)));
+ CraftEventFactory.entityDamage = source;
+ entity.forceExplosionKnockback = false;
-+ boolean wasDamaged = entity.damageEntity(DamageSource.explosion(this), (float) ((int) ((d13 * d13 + d13) / 2.0D * 7.0D * (double) f3 + 1.0D)));
++ boolean wasDamaged = entity.damageEntity(this.b(), (float) ((int) ((d13 * d13 + d13) / 2.0D * 7.0D * (double) f3 + 1.0D)));
+ CraftEventFactory.entityDamage = null;
+ if (!wasDamaged && !(entity instanceof EntityTNTPrimed || entity instanceof EntityFallingBlock) && !entity.forceExplosionKnockback) {
+ continue;
@@ -67,7 +67,7 @@
double d14 = d13;
if (entity instanceof EntityLiving) {
-@@ -149,6 +171,50 @@
+@@ -155,6 +177,50 @@
BlockPosition blockposition;
if (this.b) {
@@ -118,20 +118,20 @@
iterator = this.blocks.iterator();
while (iterator.hasNext()) {
-@@ -180,7 +246,8 @@
+@@ -186,7 +252,8 @@
- if (iblockdata.getMaterial() != Material.AIR) {
+ if (!iblockdata.isAir()) {
if (block.a(this)) {
-- block.dropNaturally(this.world, blockposition, this.world.getType(blockposition), 1.0F / this.size, 0);
+- iblockdata.dropNaturally(this.world, blockposition, 1.0F / this.size, 0);
+ // CraftBukkit - add yield
-+ block.dropNaturally(this.world, blockposition, this.world.getType(blockposition), yield, 0);
++ iblockdata.dropNaturally(this.world, blockposition, yield, 0);
}
this.world.setTypeAndData(blockposition, Blocks.AIR.getBlockData(), 3);
-@@ -195,7 +262,11 @@
+@@ -201,7 +268,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) {
+ if (this.world.getType(blockposition).isAir() && this.world.getType(blockposition.down()).f(this.world, blockposition.down()) && this.c.nextInt(3) == 0) {
- this.world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData());
+ // CraftBukkit start - Ignition by explosion
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(this.world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this).isCancelled()) {
@@ -141,7 +141,7 @@
}
}
}
-@@ -208,7 +279,9 @@
+@@ -222,7 +293,9 @@
@Nullable
public EntityLiving getSource() {
diff --git a/nms-patches/FluidTypeFlowing.patch b/nms-patches/FluidTypeFlowing.patch
new file mode 100644
index 00000000..d1f69c07
--- /dev/null
+++ b/nms-patches/FluidTypeFlowing.patch
@@ -0,0 +1,46 @@
+--- a/net/minecraft/server/FluidTypeFlowing.java
++++ b/net/minecraft/server/FluidTypeFlowing.java
+@@ -5,6 +5,11 @@
+ import java.util.Iterator;
+ import java.util.Map;
+ import java.util.Map.Entry;
++// CraftBukkit start
++import org.bukkit.block.BlockFace;
++import org.bukkit.craftbukkit.block.CraftBlock;
++import org.bukkit.event.block.BlockFromToEvent;
++// CraftBukkit end
+
+ public abstract class FluidTypeFlowing extends FluidType {
+
+@@ -116,6 +121,15 @@
+ Fluid fluid1 = this.a((IWorldReader) generatoraccess, blockposition1, iblockdata1);
+
+ if (this.a(generatoraccess, blockposition, iblockdata, EnumDirection.DOWN, blockposition1, iblockdata1, generatoraccess.b(blockposition1), fluid1.c())) {
++ // CraftBukkit start
++ org.bukkit.block.Block source = CraftBlock.at(generatoraccess, blockposition);
++ BlockFromToEvent event = new BlockFromToEvent(source, BlockFace.DOWN);
++ generatoraccess.getMinecraftWorld().getServer().getPluginManager().callEvent(event);
++
++ if (event.isCancelled()) {
++ return;
++ }
++ // CraftBukkit end
+ this.a(generatoraccess, blockposition1, iblockdata1, EnumDirection.DOWN, fluid1);
+ if (this.a((IWorldReader) generatoraccess, blockposition) >= 3) {
+ this.a(generatoraccess, blockposition, fluid, iblockdata);
+@@ -146,6 +160,15 @@
+ IBlockData iblockdata1 = generatoraccess.getType(blockposition1);
+
+ if (this.a(generatoraccess, blockposition, iblockdata, enumdirection, blockposition1, iblockdata1, generatoraccess.b(blockposition1), fluid1.c())) {
++ // CraftBukkit start
++ org.bukkit.block.Block source = CraftBlock.at(generatoraccess, blockposition);
++ BlockFromToEvent event = new BlockFromToEvent(source, org.bukkit.craftbukkit.block.CraftBlock.notchToBlockFace(enumdirection));
++ generatoraccess.getMinecraftWorld().getServer().getPluginManager().callEvent(event);
++
++ if (event.isCancelled()) {
++ continue;
++ }
++ // CraftBukkit end
+ this.a(generatoraccess, blockposition1, iblockdata1, enumdirection, fluid1);
+ }
+ }
diff --git a/nms-patches/FluidTypeLava.patch b/nms-patches/FluidTypeLava.patch
new file mode 100644
index 00000000..ef36738d
--- /dev/null
+++ b/nms-patches/FluidTypeLava.patch
@@ -0,0 +1,44 @@
+--- a/net/minecraft/server/FluidTypeLava.java
++++ b/net/minecraft/server/FluidTypeLava.java
+@@ -35,6 +35,13 @@
+
+ if (iblockdata.isAir()) {
+ if (this.a((IWorldReader) world, blockposition1)) {
++ // CraftBukkit start - Prevent lava putting something on fire
++ if (world.getType(blockposition1) != Blocks.FIRE) {
++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition1, blockposition).isCancelled()) {
++ continue;
++ }
++ }
++ // CraftBukkit end
+ world.setTypeUpdate(blockposition1, Blocks.FIRE.getBlockData());
+ return;
+ }
+@@ -51,6 +58,14 @@
+ }
+
+ if (world.isEmpty(blockposition2.up()) && this.b(world, blockposition2)) {
++ // CraftBukkit start - Prevent lava putting something on fire
++ BlockPosition up = blockposition2.up();
++ if (world.getType(up) != Blocks.FIRE) {
++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, up, blockposition).isCancelled()) {
++ continue;
++ }
++ }
++ // CraftBukkit end
+ world.setTypeUpdate(blockposition2.up(), Blocks.FIRE.getBlockData());
+ }
+ }
+@@ -139,7 +154,11 @@
+
+ if (this.a(TagsFluid.b) && fluid1.a(TagsFluid.a)) {
+ if (iblockdata.getBlock() instanceof BlockFluids) {
+- generatoraccess.setTypeAndData(blockposition, Blocks.STONE.getBlockData(), 3);
++ // CraftBukkit start
++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(generatoraccess.getMinecraftWorld(), blockposition, Blocks.STONE.getBlockData(), 3)) {
++ return;
++ }
++ // CraftBukkit end
+ }
+
+ this.a(generatoraccess, blockposition);
diff --git a/nms-patches/FoodMetaData.patch b/nms-patches/FoodMetaData.patch
index 121f388b..3383084e 100644
--- a/nms-patches/FoodMetaData.patch
+++ b/nms-patches/FoodMetaData.patch
@@ -64,7 +64,7 @@
this.a(f);
this.foodTickTimer = 0;
}
- } else if (flag && this.foodLevel >= 18 && entityhuman.dj()) {
+ } else if (flag && this.foodLevel >= 18 && entityhuman.dw()) {
++this.foodTickTimer;
if (this.foodTickTimer >= 80) {
- entityhuman.heal(1.0F);
diff --git a/nms-patches/FurnaceRecipe.patch b/nms-patches/FurnaceRecipe.patch
new file mode 100644
index 00000000..30eb77a1
--- /dev/null
+++ b/nms-patches/FurnaceRecipe.patch
@@ -0,0 +1,44 @@
+--- a/net/minecraft/server/FurnaceRecipe.java
++++ b/net/minecraft/server/FurnaceRecipe.java
+@@ -2,6 +2,10 @@
+
+ import com.google.gson.JsonElement;
+ import com.google.gson.JsonObject;
++import org.bukkit.craftbukkit.inventory.CraftFurnaceRecipe;
++import org.bukkit.craftbukkit.inventory.CraftItemStack;
++import org.bukkit.craftbukkit.util.CraftNamespacedKey;
++import org.bukkit.inventory.Recipe;
+
+ public class FurnaceRecipe implements IRecipe {
+
+@@ -56,6 +60,16 @@
+ return this.key;
+ }
+
++ @Override
++ public Recipe toBukkitRecipe() {
++ CraftItemStack result = CraftItemStack.asCraftMirror(this.result);
++ RecipeItemStack list = this.ingredient;
++ list.buildChoices();
++ net.minecraft.server.ItemStack stack = list.choices[0];
++
++ return new CraftFurnaceRecipe(CraftNamespacedKey.fromMinecraft(this.key), result, CraftItemStack.asCraftMirror(stack), this.experience, this.cookingTime);
++ }
++
+ public static class a implements RecipeSerializer<FurnaceRecipe> {
+
+ public a() {}
+@@ -106,11 +120,11 @@
+ return "smelting";
+ }
+
+- public IRecipe a(MinecraftKey minecraftkey, PacketDataSerializer packetdataserializer) {
++ public FurnaceRecipe a(MinecraftKey minecraftkey, PacketDataSerializer packetdataserializer) { // CraftBukkit - decompile error
+ return this.b(minecraftkey, packetdataserializer);
+ }
+
+- public IRecipe a(MinecraftKey minecraftkey, JsonObject jsonobject) {
++ public FurnaceRecipe a(MinecraftKey minecraftkey, JsonObject jsonobject) { // CraftBukkit - decompile error
+ return this.b(minecraftkey, jsonobject);
+ }
+ }
diff --git a/nms-patches/HandshakeListener.patch b/nms-patches/HandshakeListener.patch
index 8799f9f0..0b5c975c 100644
--- a/nms-patches/HandshakeListener.patch
+++ b/nms-patches/HandshakeListener.patch
@@ -57,8 +57,8 @@
+ }
+ // CraftBukkit end
+
- if (packethandshakinginsetprotocol.b() > 340) {
- chatmessage = new ChatMessage("multiplayer.disconnect.outdated_server", new Object[] { "1.12.2"});
+ if (packethandshakinginsetprotocol.c() > 389) {
+ chatmessage = new ChatMessage("multiplayer.disconnect.outdated_server", new Object[] { "1.13-pre7"});
this.b.sendPacket(new PacketLoginOutDisconnect(chatmessage));
@@ -26,6 +71,7 @@
this.b.close(chatmessage);
diff --git a/nms-patches/ICommandListener.patch b/nms-patches/ICommandListener.patch
new file mode 100644
index 00000000..d1efb9cd
--- /dev/null
+++ b/nms-patches/ICommandListener.patch
@@ -0,0 +1,9 @@
+--- a/net/minecraft/server/ICommandListener.java
++++ b/net/minecraft/server/ICommandListener.java
+@@ -9,4 +9,6 @@
+ boolean b();
+
+ boolean B_();
++
++ org.bukkit.command.CommandSender getBukkitSender(CommandListenerWrapper wrapper); // CraftBukkit
+ }
diff --git a/nms-patches/IDataManager.patch b/nms-patches/IDataManager.patch
index 362ecd76..a02e77ba 100644
--- a/nms-patches/IDataManager.patch
+++ b/nms-patches/IDataManager.patch
@@ -1,9 +1,9 @@
--- a/net/minecraft/server/IDataManager.java
+++ b/net/minecraft/server/IDataManager.java
-@@ -25,4 +25,6 @@
- File getDataFile(String s);
-
+@@ -29,4 +29,6 @@
DefinedStructureManager h();
+
+ DataFixer i();
+
+ java.util.UUID getUUID(); // CraftBukkit
}
diff --git a/nms-patches/IInventory.patch b/nms-patches/IInventory.patch
index 0d2e884c..4dd0f897 100644
--- a/nms-patches/IInventory.patch
+++ b/nms-patches/IInventory.patch
@@ -8,10 +8,10 @@
public interface IInventory extends INamableTileEntity {
int getSize();
-@@ -33,4 +35,22 @@
- int h();
-
- void clear();
+@@ -41,4 +43,29 @@
+ default int U_() {
+ return 0;
+ }
+
+ // CraftBukkit start
+ java.util.List<ItemStack> getContents();
@@ -28,6 +28,13 @@
+
+ org.bukkit.Location getLocation();
+
++ default IRecipe getCurrentRecipe() {
++ return null;
++ }
++
++ default void setCurrentRecipe(IRecipe recipe) {
++ }
++
+ int MAX_STACK = 64;
+ // CraftBukkit end
}
diff --git a/nms-patches/IRecipe.patch b/nms-patches/IRecipe.patch
index 325b5b69..c6b88882 100644
--- a/nms-patches/IRecipe.patch
+++ b/nms-patches/IRecipe.patch
@@ -1,11 +1,9 @@
--- a/net/minecraft/server/IRecipe.java
+++ b/net/minecraft/server/IRecipe.java
-@@ -17,4 +17,8 @@
- default boolean c() {
- return false;
- }
+@@ -33,4 +33,6 @@
+ MinecraftKey getKey();
+
+ RecipeSerializer<?> a();
+
+ org.bukkit.inventory.Recipe toBukkitRecipe(); // CraftBukkit
-+
-+ void setKey(MinecraftKey key); // CraftBukkit
}
diff --git a/nms-patches/IWorldWriter.patch b/nms-patches/IWorldWriter.patch
new file mode 100644
index 00000000..2315ab9b
--- /dev/null
+++ b/nms-patches/IWorldWriter.patch
@@ -0,0 +1,11 @@
+--- a/net/minecraft/server/IWorldWriter.java
++++ b/net/minecraft/server/IWorldWriter.java
+@@ -6,6 +6,8 @@
+
+ boolean addEntity(Entity entity);
+
++ boolean addEntity(Entity entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason); // CraftBukkit
++
+ boolean setAir(BlockPosition blockposition);
+
+ void a(EnumSkyBlock enumskyblock, BlockPosition blockposition, int i);
diff --git a/nms-patches/InventoryCraftResult.patch b/nms-patches/InventoryCraftResult.patch
index 70c8e7f1..4f275b25 100644
--- a/nms-patches/InventoryCraftResult.patch
+++ b/nms-patches/InventoryCraftResult.patch
@@ -10,7 +10,7 @@
+import org.bukkit.entity.HumanEntity;
+// CraftBukkit end
- public class InventoryCraftResult implements IInventory {
+ public class InventoryCraftResult implements IInventory, RecipeHolder {
private final NonNullList<ItemStack> items;
private IRecipe b;
@@ -46,7 +46,7 @@
public InventoryCraftResult() {
this.items = NonNullList.a(1, ItemStack.a);
}
-@@ -61,7 +94,7 @@
+@@ -62,7 +95,7 @@
}
public int getMaxStackSize() {
diff --git a/nms-patches/InventoryCrafting.patch b/nms-patches/InventoryCrafting.patch
index 3ddb4a1c..336fdb19 100644
--- a/nms-patches/InventoryCrafting.patch
+++ b/nms-patches/InventoryCrafting.patch
@@ -1,9 +1,9 @@
--- a/net/minecraft/server/InventoryCrafting.java
+++ b/net/minecraft/server/InventoryCrafting.java
-@@ -1,6 +1,14 @@
- package net.minecraft.server;
+@@ -2,6 +2,14 @@
import java.util.Iterator;
+ import javax.annotation.Nullable;
+// CraftBukkit start
+import java.util.List;
+import org.bukkit.Location;
@@ -13,15 +13,15 @@
+import org.bukkit.event.inventory.InventoryType;
+// CraftBukkit end
- public class InventoryCrafting implements IInventory {
+ public class InventoryCrafting implements IInventory, AutoRecipeOutput {
-@@ -9,6 +17,53 @@
+@@ -10,6 +18,63 @@
private final int c;
public final Container container;
+ // CraftBukkit start - add fields
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
-+ public IRecipe currentRecipe;
++ private IRecipe currentRecipe;
+ public IInventory resultInventory;
+ private EntityHuman owner;
+ private int maxStack = MAX_STACK;
@@ -60,6 +60,16 @@
+ return owner.getBukkitEntity().getLocation();
+ }
+
++ @Override
++ public IRecipe getCurrentRecipe() {
++ return currentRecipe;
++ }
++
++ @Override
++ public void setCurrentRecipe(IRecipe currentRecipe) {
++ this.currentRecipe = currentRecipe;
++ }
++
+ public InventoryCrafting(Container container, int i, int j, EntityHuman player) {
+ this(container, i, j);
+ this.owner = player;
diff --git a/nms-patches/InventoryEnderChest.patch b/nms-patches/InventoryEnderChest.patch
index 18f4a07b..c31016ff 100644
--- a/nms-patches/InventoryEnderChest.patch
+++ b/nms-patches/InventoryEnderChest.patch
@@ -23,7 +23,7 @@
- public InventoryEnderChest() {
+ public InventoryEnderChest(EntityHuman owner) {
- super("container.enderchest", false, 27);
+ super(new ChatMessage("container.enderchest", new Object[0]), 27);
+ this.owner = owner;
+ // CraftBukkit end
}
diff --git a/nms-patches/InventoryHorseChest.patch b/nms-patches/InventoryHorseChest.patch
index 875dd670..05e5572c 100644
--- a/nms-patches/InventoryHorseChest.patch
+++ b/nms-patches/InventoryHorseChest.patch
@@ -4,11 +4,11 @@
public class InventoryHorseChest extends InventorySubcontainer {
-- public InventoryHorseChest(String s, int i) {
-- super(s, false, i);
+- public InventoryHorseChest(IChatBaseComponent ichatbasecomponent, int i) {
+- super(ichatbasecomponent, i);
+ // CraftBukkit start
-+ public InventoryHorseChest(String s, int i, EntityHorseAbstract owner) {
-+ super(s, false, i, (org.bukkit.entity.AbstractHorse) owner.getBukkitEntity());
++ public InventoryHorseChest(IChatBaseComponent ichatbasecomponent, int i, EntityHorseAbstract owner) {
++ super(ichatbasecomponent, i, (org.bukkit.entity.AbstractHorse) owner.getBukkitEntity());
+ // CraftBukkit end
}
}
diff --git a/nms-patches/InventoryLargeChest.patch b/nms-patches/InventoryLargeChest.patch
index 3ed9ccd8..f4fdba28 100644
--- a/nms-patches/InventoryLargeChest.patch
+++ b/nms-patches/InventoryLargeChest.patch
@@ -1,8 +1,9 @@
--- a/net/minecraft/server/InventoryLargeChest.java
+++ b/net/minecraft/server/InventoryLargeChest.java
-@@ -1,11 +1,62 @@
+@@ -1,6 +1,14 @@
package net.minecraft.server;
+ import javax.annotation.Nullable;
+// CraftBukkit start
+import java.util.ArrayList;
+import java.util.List;
@@ -11,10 +12,10 @@
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
+import org.bukkit.entity.HumanEntity;
+// CraftBukkit end
-+
+
public class InventoryLargeChest implements ITileInventory {
- private final String a;
+@@ -8,6 +16,48 @@
public final ITileInventory left;
public final ITileInventory right;
@@ -60,10 +61,10 @@
+ }
+ // CraftBukkit end
+
- public InventoryLargeChest(String s, ITileInventory itileinventory, ITileInventory itileinventory1) {
- this.a = s;
+ public InventoryLargeChest(IChatBaseComponent ichatbasecomponent, ITileInventory itileinventory, ITileInventory itileinventory1) {
+ this.a = ichatbasecomponent;
if (itileinventory == null) {
-@@ -72,7 +123,7 @@
+@@ -75,7 +125,7 @@
}
public int getMaxStackSize() {
diff --git a/nms-patches/InventoryMerchant.patch b/nms-patches/InventoryMerchant.patch
index 8c566307..30897b1d 100644
--- a/nms-patches/InventoryMerchant.patch
+++ b/nms-patches/InventoryMerchant.patch
@@ -1,9 +1,9 @@
--- a/net/minecraft/server/InventoryMerchant.java
+++ b/net/minecraft/server/InventoryMerchant.java
-@@ -1,6 +1,13 @@
- package net.minecraft.server;
+@@ -2,6 +2,13 @@
import java.util.Iterator;
+ import javax.annotation.Nullable;
+// CraftBukkit start
+import java.util.List;
+import org.bukkit.Location;
@@ -14,7 +14,7 @@
public class InventoryMerchant implements IInventory {
-@@ -10,6 +17,40 @@
+@@ -11,6 +18,40 @@
private MerchantRecipe recipe;
public int selectedIndex;
@@ -55,7 +55,7 @@
public InventoryMerchant(EntityHuman entityhuman, IMerchant imerchant) {
this.itemsInSlots = NonNullList.a(3, ItemStack.a);
this.player = entityhuman;
-@@ -89,7 +130,7 @@
+@@ -91,7 +132,7 @@
}
public int getMaxStackSize() {
diff --git a/nms-patches/InventorySubcontainer.patch b/nms-patches/InventorySubcontainer.patch
index ee8e435a..237b30c7 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;
+@@ -5,6 +5,13 @@
import java.util.List;
+ import javax.annotation.Nullable;
+// CraftBukkit start
+import java.util.List;
@@ -11,12 +11,12 @@
+import org.bukkit.entity.HumanEntity;
+// CraftBukkit end
+
- public class InventorySubcontainer implements IInventory {
+ public class InventorySubcontainer implements IInventory, AutoRecipeOutput {
- private String a;
-@@ -12,7 +19,47 @@
+ private final IChatBaseComponent a;
+@@ -13,7 +20,47 @@
private List<IInventoryListener> d;
- private boolean e;
+ private IChatBaseComponent e;
+ // CraftBukkit start - add fields and methods
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
@@ -52,13 +52,13 @@
+ return null;
+ }
+
- public InventorySubcontainer(String s, boolean flag, int i) {
-+ this(s, flag, i, null);
+ public InventorySubcontainer(IChatBaseComponent ichatbasecomponent, int i) {
++ this(ichatbasecomponent, i, null);
+ }
+
-+ public InventorySubcontainer(String s, boolean flag, int i, org.bukkit.inventory.InventoryHolder owner) {
++ public InventorySubcontainer(IChatBaseComponent ichatbasecomponent, int i, org.bukkit.inventory.InventoryHolder owner) {
+ this.bukkitOwner = owner;
+ // CraftBukkit end
- this.a = s;
- this.e = flag;
+ this.a = ichatbasecomponent;
this.b = i;
+ this.items = NonNullList.a(i, ItemStack.a);
diff --git a/nms-patches/ItemArmor.patch b/nms-patches/ItemArmor.patch
index 61627ea6..082ce788 100644
--- a/nms-patches/ItemArmor.patch
+++ b/nms-patches/ItemArmor.patch
@@ -1,6 +1,6 @@
--- a/net/minecraft/server/ItemArmor.java
+++ b/net/minecraft/server/ItemArmor.java
-@@ -5,6 +5,11 @@
+@@ -4,6 +4,11 @@
import java.util.List;
import java.util.UUID;
@@ -11,10 +11,10 @@
+
public class ItemArmor extends Item {
- private static final int[] n = new int[] { 13, 15, 16, 11};
-@@ -33,6 +38,32 @@
+ private static final UUID[] l = new UUID[] { UUID.fromString("845DB27C-C624-495F-8C9F-6020A9A58B6B"), UUID.fromString("D8499B04-0E66-4726-AB29-64469D734E0D"), UUID.fromString("9F3D476D-C118-4544-8365-64846904B48E"), UUID.fromString("2AD3F246-FEE1-4E67-B886-69FD380BB150")};
+@@ -29,6 +34,32 @@
EntityLiving entityliving = (EntityLiving) list.get(0);
- EnumItemSlot enumitemslot = EntityInsentient.d(itemstack);
+ EnumItemSlot enumitemslot = EntityInsentient.e(itemstack);
ItemStack itemstack1 = itemstack.cloneAndSubtract(1);
+ // CraftBukkit start
+ World world = isourceblock.getWorld();
@@ -36,8 +36,8 @@
+ // Chain to handler for new item
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem());
-+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != ItemArmor.b) {
-+ idispensebehavior.a(isourceblock, eventStack);
++ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != ItemArmor.a) {
++ idispensebehavior.dispense(isourceblock, eventStack);
+ return itemstack;
+ }
+ }
diff --git a/nms-patches/ItemBlock.patch b/nms-patches/ItemBlock.patch
index 859afa28..b0bf1a67 100644
--- a/nms-patches/ItemBlock.patch
+++ b/nms-patches/ItemBlock.patch
@@ -1,11 +1,39 @@
--- a/net/minecraft/server/ItemBlock.java
+++ b/net/minecraft/server/ItemBlock.java
-@@ -36,7 +36,7 @@
+@@ -2,6 +2,11 @@
- SoundEffectType soundeffecttype = this.a.getStepSound();
+ import java.util.Map;
+ import javax.annotation.Nullable;
++// CraftBukkit start
++import org.bukkit.craftbukkit.block.CraftBlock;
++import org.bukkit.craftbukkit.block.data.CraftBlockData;
++import org.bukkit.event.block.BlockCanBuildEvent;
++// CraftBukkit end
+
+ public class ItemBlock extends Item {
+
+@@ -45,7 +50,7 @@
+
+ SoundEffectType soundeffecttype = block.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.subtract(1);
+ return EnumInteractionResult.SUCCESS;
}
+@@ -64,7 +69,14 @@
+ }
+
+ protected boolean b(BlockActionContext blockactioncontext, IBlockData iblockdata) {
+- return iblockdata.canPlace(blockactioncontext.getWorld(), blockactioncontext.getClickPosition()) && blockactioncontext.getWorld().a(iblockdata, blockactioncontext.getClickPosition());
++ // CraftBukkit start - store default return
++ boolean defaultReturn = iblockdata.canPlace(blockactioncontext.getWorld(), blockactioncontext.getClickPosition()) && blockactioncontext.getWorld().a(iblockdata, blockactioncontext.getClickPosition());
++
++ BlockCanBuildEvent event = new BlockCanBuildEvent(CraftBlock.at(blockactioncontext.getWorld(), blockactioncontext.getClickPosition()), CraftBlockData.fromData(iblockdata), defaultReturn);
++ blockactioncontext.getWorld().getServer().getPluginManager().callEvent(event);
++
++ return event.isBuildable();
++ // CraftBukkit end
+ }
+ protected boolean a(BlockActionContext blockactioncontext, IBlockData iblockdata) {
diff --git a/nms-patches/ItemBoat.patch b/nms-patches/ItemBoat.patch
index e25ef73f..e51c9eb5 100644
--- a/nms-patches/ItemBoat.patch
+++ b/nms-patches/ItemBoat.patch
@@ -1,9 +1,9 @@
--- a/net/minecraft/server/ItemBoat.java
+++ b/net/minecraft/server/ItemBoat.java
-@@ -56,6 +56,13 @@
- } else if (movingobjectposition.type != MovingObjectPosition.EnumMovingObjectType.BLOCK) {
+@@ -52,6 +52,13 @@
+ if (flag) {
return new InteractionResultWrapper(EnumInteractionResult.PASS, itemstack);
- } else {
+ } else if (movingobjectposition.type == MovingObjectPosition.EnumMovingObjectType.BLOCK) {
+ // CraftBukkit start - Boat placement
+ org.bukkit.event.player.PlayerInteractEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent(entityhuman, org.bukkit.event.block.Action.RIGHT_CLICK_BLOCK, movingobjectposition.a(), movingobjectposition.direction, itemstack, enumhand);
+
@@ -11,10 +11,10 @@
+ return new InteractionResultWrapper(EnumInteractionResult.PASS, itemstack);
+ }
+ // CraftBukkit end
- Block block = world.getType(movingobjectposition.a()).getBlock();
- boolean flag1 = block == Blocks.WATER || block == Blocks.FLOWING_WATER;
- EntityBoat entityboat = new EntityBoat(world, movingobjectposition.pos.x, flag1 ? movingobjectposition.pos.y - 0.12D : movingobjectposition.pos.y, movingobjectposition.pos.z);
-@@ -66,7 +73,7 @@
+ BlockPosition blockposition = movingobjectposition.a();
+ Block block = world.getType(blockposition).getBlock();
+ EntityBoat entityboat = new EntityBoat(world, movingobjectposition.pos.x, movingobjectposition.pos.y, movingobjectposition.pos.z);
+@@ -62,7 +69,7 @@
return new InteractionResultWrapper(EnumInteractionResult.FAIL, itemstack);
} else {
if (!world.isClientSide) {
diff --git a/nms-patches/ItemBow.patch b/nms-patches/ItemBow.patch
index d17d8d15..4f227519 100644
--- a/nms-patches/ItemBow.patch
+++ b/nms-patches/ItemBow.patch
@@ -1,14 +1,28 @@
--- a/net/minecraft/server/ItemBow.java
+++ b/net/minecraft/server/ItemBow.java
-@@ -1,5 +1,7 @@
+@@ -1,15 +1,21 @@
package net.minecraft.server;
+import org.bukkit.event.entity.EntityCombustEvent; // CraftBukkit
+
public class ItemBow extends Item {
- public ItemBow() {
-@@ -73,7 +75,20 @@
+ public ItemBow(Item.Info item_info) {
+ super(item_info);
++ // CraftBukkit start - obfuscator went a little crazy
++ /*
+ this.a(new MinecraftKey("pull"), (itemstack, world, entityliving) -> {
+ return entityliving == null ? 0.0F : (entityliving.cV().getItem() != Items.BOW ? 0.0F : (float) (itemstack.k() - entityliving.cW()) / 20.0F);
+ });
+ this.a(new MinecraftKey("pulling"), (itemstack, world, entityliving) -> {
+ return entityliving != null && entityliving.isHandRaised() && entityliving.cV() == itemstack ? 1.0F : 0.0F;
+ });
++ */
++ // CraftBukkit end
+ }
+
+ private ItemStack a(EntityHuman entityhuman) {
+@@ -73,7 +79,20 @@
}
if (EnchantmentManager.getEnchantmentLevel(Enchantments.ARROW_FIRE, itemstack) > 0) {
@@ -30,7 +44,7 @@
}
itemstack.damage(1, entityhuman);
-@@ -81,7 +96,15 @@
+@@ -81,7 +100,15 @@
entityarrow.fromPlayer = EntityArrow.PickupStatus.CREATIVE_ONLY;
}
@@ -46,4 +60,4 @@
+ // CraftBukkit end
}
- 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);
+ world.a((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.ENTITY_ARROW_SHOOT, SoundCategory.PLAYERS, 1.0F, 1.0F / (ItemBow.k.nextFloat() * 0.4F + 1.2F) + f * 0.5F);
diff --git a/nms-patches/ItemBucket.patch b/nms-patches/ItemBucket.patch
index 0d6b49e1..029b2023 100644
--- a/nms-patches/ItemBucket.patch
+++ b/nms-patches/ItemBucket.patch
@@ -1,62 +1,53 @@
--- a/net/minecraft/server/ItemBucket.java
+++ b/net/minecraft/server/ItemBucket.java
-@@ -1,6 +1,12 @@
+@@ -1,6 +1,13 @@
package net.minecraft.server;
import javax.annotation.Nullable;
+// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
++import org.bukkit.craftbukkit.util.DummyGeneratorAccess;
+import org.bukkit.event.player.PlayerBucketEmptyEvent;
+import org.bukkit.event.player.PlayerBucketFillEvent;
+// CraftBukkit end
public class ItemBucket extends Item {
-@@ -34,15 +40,29 @@
- Material material = iblockdata.getMaterial();
-
- if (material == Material.WATER && ((Integer) iblockdata.get(BlockFluids.LEVEL)).intValue() == 0) {
-+ // CraftBukkit start
-+ PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent(entityhuman, blockposition.getX(), blockposition.getY(), blockposition.getZ(), null, itemstack, Items.WATER_BUCKET);
-+
-+ if (event.isCancelled()) {
-+ return new InteractionResultWrapper(EnumInteractionResult.FAIL, itemstack);
-+ }
-+ // CraftBukkit end
- world.setTypeAndData(blockposition, Blocks.AIR.getBlockData(), 11);
- entityhuman.b(StatisticList.b((Item) this));
- entityhuman.a(SoundEffects.S, 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
- } else if (material == Material.LAVA && ((Integer) iblockdata.get(BlockFluids.LEVEL)).intValue() == 0) {
+@@ -28,12 +35,20 @@
+ if (this.a == FluidTypes.a) {
+ iblockdata = world.getType(blockposition);
+ if (iblockdata.getBlock() instanceof IFluidSource) {
+ // CraftBukkit start
-+ PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent(entityhuman, blockposition.getX(), blockposition.getY(), blockposition.getZ(), null, itemstack, Items.LAVA_BUCKET);
++ FluidType dummyFluid = ((IFluidSource) iblockdata.getBlock()).b(DummyGeneratorAccess.INSTANCE, blockposition, iblockdata);
++ PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent(entityhuman, blockposition.getX(), blockposition.getY(), blockposition.getZ(), null, itemstack, dummyFluid.b());
+
+ if (event.isCancelled()) {
+ return new InteractionResultWrapper(EnumInteractionResult.FAIL, itemstack);
+ }
+ // CraftBukkit end
- entityhuman.a(SoundEffects.T, 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));
-+ return new InteractionResultWrapper(EnumInteractionResult.SUCCESS, this.a(itemstack, entityhuman, Items.LAVA_BUCKET, event.getItemStack())); // CraftBukkit
- } else {
- return new InteractionResultWrapper(EnumInteractionResult.FAIL, itemstack);
- }
-@@ -53,7 +73,7 @@
+ FluidType fluidtype = ((IFluidSource) iblockdata.getBlock()).b(world, blockposition, iblockdata);
- if (!entityhuman.a(blockposition1, movingobjectposition.direction, itemstack)) {
- return new InteractionResultWrapper(EnumInteractionResult.FAIL, itemstack);
-- } else if (this.a(entityhuman, world, blockposition1)) {
-+ } else if (this.a(entityhuman, world, blockposition1, movingobjectposition.direction, blockposition, itemstack)) { // CraftBukkit
- if (entityhuman instanceof EntityPlayer) {
- CriterionTriggers.x.a((EntityPlayer) entityhuman, blockposition1, itemstack);
- }
-@@ -67,16 +87,19 @@
- }
- }
+ if (fluidtype != FluidTypes.a) {
+ entityhuman.b(StatisticList.ITEM_USED.b(this));
+ entityhuman.a(fluidtype.a(TagsFluid.b) ? SoundEffects.ITEM_BUCKET_FILL_LAVA : SoundEffects.ITEM_BUCKET_FILL, 1.0F, 1.0F);
+- ItemStack itemstack1 = this.a(itemstack, entityhuman, fluidtype.b());
++ ItemStack itemstack1 = this.a(itemstack, entityhuman, fluidtype.b(), event.getItemStack()); // CraftBukkit
+
+ if (!world.isClientSide) {
+ CriterionTriggers.j.a((EntityPlayer) entityhuman, new ItemStack(fluidtype.b()));
+@@ -48,7 +63,7 @@
+ iblockdata = world.getType(blockposition);
+ BlockPosition blockposition1 = this.a(iblockdata, blockposition, movingobjectposition);
+
+- if (this.a(entityhuman, world, blockposition1, movingobjectposition)) {
++ if (this.a(entityhuman, world, blockposition1, movingobjectposition, blockposition, itemstack)) { // CraftBukkit
+ this.a(world, itemstack, blockposition1);
+ if (entityhuman instanceof EntityPlayer) {
+ CriterionTriggers.y.a((EntityPlayer) entityhuman, blockposition1, itemstack);
+@@ -76,16 +91,19 @@
+
+ public void a(World world, ItemStack itemstack, BlockPosition blockposition) {}
- private ItemStack a(ItemStack itemstack, EntityHuman entityhuman, Item item) {
+ // CraftBukkit - added ob.ItemStack result - TODO: Is this... the right way to handle this?
@@ -78,33 +69,33 @@
}
return itemstack;
-@@ -84,7 +107,13 @@
+@@ -93,7 +111,13 @@
}
}
+ // CraftBukkit start
- public boolean a(@Nullable EntityHuman entityhuman, World world, BlockPosition blockposition) {
-+ return a(entityhuman, world, blockposition, null, blockposition, null);
+ public boolean a(@Nullable EntityHuman entityhuman, World world, BlockPosition blockposition, @Nullable MovingObjectPosition movingobjectposition) {
++ return a(entityhuman, world, blockposition, movingobjectposition, null, null);
+ }
+
-+ public boolean a(EntityHuman entityhuman, World world, BlockPosition blockposition, EnumDirection enumdirection, BlockPosition clicked, ItemStack itemstack) {
++ public boolean a(EntityHuman entityhuman, World world, BlockPosition blockposition, @Nullable MovingObjectPosition movingobjectposition, BlockPosition clicked, ItemStack itemstack) {
+ // CraftBukkit end
- if (this.a == Blocks.AIR) {
+ if (!(this.a instanceof FluidTypeFlowing)) {
return false;
} else {
-@@ -96,6 +125,15 @@
- if (!world.isEmpty(blockposition) && !flag && !flag1) {
- return false;
+@@ -105,6 +129,15 @@
+ if (!world.isEmpty(blockposition) && !flag && !flag1 && (!(iblockdata.getBlock() instanceof IFluidContainer) || !((IFluidContainer) iblockdata.getBlock()).a((IBlockAccess) world, blockposition, iblockdata, this.a))) {
+ return movingobjectposition == null ? false : this.a(entityhuman, world, movingobjectposition.a().shift(movingobjectposition.direction), (MovingObjectPosition) null);
} else {
+ // CraftBukkit start
+ if (entityhuman != null) {
-+ PlayerBucketEmptyEvent event = CraftEventFactory.callPlayerBucketEmptyEvent(entityhuman, clicked.getX(), clicked.getY(), clicked.getZ(), enumdirection, itemstack);
++ PlayerBucketEmptyEvent event = CraftEventFactory.callPlayerBucketEmptyEvent(entityhuman, clicked.getX(), clicked.getY(), clicked.getZ(), movingobjectposition.direction, itemstack);
+ if (event.isCancelled()) {
+ // TODO: inventory not updated
+ return false;
+ }
+ }
+ // CraftBukkit end
- if (world.worldProvider.l() && this.a == Blocks.FLOWING_WATER) {
+ if (world.worldProvider.isNether() && this.a.a(TagsFluid.a)) {
int i = blockposition.getX();
int j = blockposition.getY();
diff --git a/nms-patches/ItemChorusFruit.patch b/nms-patches/ItemChorusFruit.patch
index c05c10b5..70f0423c 100644
--- a/nms-patches/ItemChorusFruit.patch
+++ b/nms-patches/ItemChorusFruit.patch
@@ -11,9 +11,9 @@
+
public class ItemChorusFruit extends ItemFood {
- public ItemChorusFruit(int i, float f) {
+ public ItemChorusFruit(int i, float f, Item.Info item_info) {
@@ -19,6 +25,20 @@
- double d4 = MathHelper.a(entityliving.locY + (double) (entityliving.getRandom().nextInt(16) - 8), 0.0D, (double) (world.ab() - 1));
+ double d4 = MathHelper.a(entityliving.locY + (double) (entityliving.getRandom().nextInt(16) - 8), 0.0D, (double) (world.aa() - 1));
double d5 = entityliving.locZ + (entityliving.getRandom().nextDouble() - 0.5D) * 16.0D;
+ // CraftBukkit start
diff --git a/nms-patches/ItemDye.patch b/nms-patches/ItemDye.patch
index e92fa188..ab3d4cd2 100644
--- a/nms-patches/ItemDye.patch
+++ b/nms-patches/ItemDye.patch
@@ -1,19 +1,21 @@
--- a/net/minecraft/server/ItemDye.java
+++ b/net/minecraft/server/ItemDye.java
-@@ -1,5 +1,7 @@
- package net.minecraft.server;
+@@ -3,6 +3,8 @@
+ import com.google.common.collect.Maps;
+ import java.util.Map;
+import org.bukkit.event.entity.SheepDyeWoolEvent; // CraftBukkit
+
public class ItemDye extends Item {
- public static final int[] a = new int[] { 1973019, 11743532, 3887386, 5320730, 2437522, 8073150, 2651799, 11250603, 4408131, 14188952, 4312372, 14602026, 6719955, 12801229, 15435844, 15790320};
-@@ -89,6 +91,17 @@
- EnumColor enumcolor = EnumColor.fromInvColorIndex(itemstack.getData());
+ private static final Map<EnumColor, ItemDye> a = Maps.newEnumMap(EnumColor.class);
+@@ -19,7 +21,17 @@
+ EntitySheep entitysheep = (EntitySheep) entityliving;
- if (!entitysheep.isSheared() && entitysheep.getColor() != enumcolor) {
+ if (!entitysheep.isSheared() && entitysheep.getColor() != this.b) {
+- entitysheep.setColor(this.b);
+ // CraftBukkit start
-+ byte bColor = (byte) enumcolor.getColorIndex();
++ byte bColor = (byte) this.b.getColorIndex();
+ SheepDyeWoolEvent event = new SheepDyeWoolEvent((org.bukkit.entity.Sheep) entitysheep.getBukkitEntity(), org.bukkit.DyeColor.getByWoolData(bColor));
+ entitysheep.world.getServer().getPluginManager().callEvent(event);
+
@@ -21,8 +23,8 @@
+ return false;
+ }
+
-+ enumcolor = EnumColor.fromColorIndex((byte) event.getColor().getWoolData());
++ entitysheep.setColor(EnumColor.fromColorIndex((byte) event.getColor().getWoolData()));
+ // CraftBukkit end
- entitysheep.setColor(enumcolor);
itemstack.subtract(1);
}
+
diff --git a/nms-patches/ItemEnderPearl.patch b/nms-patches/ItemEnderPearl.patch
index ea00f572..baec115c 100644
--- a/nms-patches/ItemEnderPearl.patch
+++ b/nms-patches/ItemEnderPearl.patch
@@ -1,6 +1,6 @@
--- a/net/minecraft/server/ItemEnderPearl.java
+++ b/net/minecraft/server/ItemEnderPearl.java
-@@ -10,18 +10,26 @@
+@@ -9,18 +9,26 @@
public InteractionResultWrapper<ItemStack> a(World world, EntityHuman entityhuman, EnumHand enumhand) {
ItemStack itemstack = entityhuman.b(enumhand);
@@ -21,7 +21,7 @@
itemstack.subtract(1);
}
- world.a((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.bn, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemEnderPearl.j.nextFloat() * 0.4F + 0.8F));
+ world.a((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.ENTITY_ENDER_PEARL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemEnderPearl.k.nextFloat() * 0.4F + 0.8F));
entityhuman.getCooldownTracker().a(this, 20);
- if (!world.isClientSide) {
- EntityEnderPearl entityenderpearl = new EntityEnderPearl(world, entityhuman);
@@ -31,5 +31,5 @@
- }
+ // CraftBukkit end
- entityhuman.b(StatisticList.b((Item) this));
+ entityhuman.b(StatisticList.ITEM_USED.b(this));
return new InteractionResultWrapper(EnumInteractionResult.SUCCESS, itemstack);
diff --git a/nms-patches/ItemFireball.patch b/nms-patches/ItemFireball.patch
index aa84efa1..fdab04fa 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
-@@ -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.subtract(1);
-+ }
-+ return EnumInteractionResult.PASS;
+@@ -15,6 +15,14 @@
+ BlockPosition blockposition = itemactioncontext.getClickPosition().shift(itemactioncontext.getClickedFace());
+
+ if (world.getType(blockposition).isAir()) {
++ // CraftBukkit start - fire BlockIgniteEvent
++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition, org.bukkit.event.block.BlockIgniteEvent.IgniteCause.FIREBALL, itemactioncontext.getEntity()).isCancelled()) {
++ if (!itemactioncontext.getEntity().abilities.canInstantlyBuild) {
++ itemactioncontext.getItemStack().subtract(1);
+ }
-+ // CraftBukkit end
- world.a((EntityHuman) null, blockposition, SoundEffects.bD, SoundCategory.BLOCKS, 1.0F, (ItemFireball.j.nextFloat() - ItemFireball.j.nextFloat()) * 0.2F + 1.0F);
- world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData());
- }
++ return EnumInteractionResult.PASS;
++ }
++ // CraftBukkit end
+ world.a((EntityHuman) null, blockposition, SoundEffects.ITEM_FIRECHARGE_USE, SoundCategory.BLOCKS, 1.0F, (ItemFireball.k.nextFloat() - ItemFireball.k.nextFloat()) * 0.2F + 1.0F);
+ world.setTypeUpdate(blockposition, ((BlockFire) Blocks.FIRE).a((IBlockAccess) world, blockposition));
+ }
diff --git a/nms-patches/ItemFishingRod.patch b/nms-patches/ItemFishingRod.patch
index ca728962..f9fd1bdc 100644
--- a/nms-patches/ItemFishingRod.patch
+++ b/nms-patches/ItemFishingRod.patch
@@ -1,35 +1,50 @@
--- a/net/minecraft/server/ItemFishingRod.java
+++ b/net/minecraft/server/ItemFishingRod.java
-@@ -1,5 +1,7 @@
+@@ -1,9 +1,13 @@
package net.minecraft.server;
+import org.bukkit.event.player.PlayerFishEvent; // CraftBukkit
+
public class ItemFishingRod extends Item {
- public ItemFishingRod() {
-@@ -20,7 +22,7 @@
+ public ItemFishingRod(Item.Info item_info) {
+ super(item_info);
++ // CraftBukkit start - obfuscator went a little crazy
++ /*
+ this.a(new MinecraftKey("cast"), (itemstack, world, entityliving) -> {
+ if (entityliving == null) {
+ return 0.0F;
+@@ -18,6 +22,8 @@
+ return (flag || flag1) && entityliving instanceof EntityHuman && ((EntityHuman) entityliving).hookedFish != null ? 1.0F : 0.0F;
+ }
+ });
++ */
++ // CraftBukkit end
+ }
+
+ public InteractionResultWrapper<ItemStack> a(World world, EntityHuman entityhuman, EnumHand enumhand) {
+@@ -30,7 +36,7 @@
entityhuman.a(enumhand);
- world.a((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.J, SoundCategory.NEUTRAL, 1.0F, 0.4F / (ItemFishingRod.j.nextFloat() * 0.4F + 0.8F));
+ world.a((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.ENTITY_FISHING_BOBBER_RETRIEVE, SoundCategory.NEUTRAL, 1.0F, 0.4F / (ItemFishingRod.k.nextFloat() * 0.4F + 0.8F));
} else {
-- world.a((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.L, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemFishingRod.j.nextFloat() * 0.4F + 0.8F));
-+ // world.a((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.L, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemFishingRod.j.nextFloat() * 0.4F + 0.8F)); // CraftBukkit - moved down
+- world.a((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.ENTITY_FISHING_BOBBER_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemFishingRod.k.nextFloat() * 0.4F + 0.8F));
++ // world.a((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.ENTITY_FISHING_BOBBER_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemFishingRod.k.nextFloat() * 0.4F + 0.8F));
if (!world.isClientSide) {
EntityFishingHook entityfishinghook = new EntityFishingHook(world, entityhuman);
int j = EnchantmentManager.c(itemstack);
-@@ -35,6 +37,17 @@
- entityfishinghook.c(k);
+@@ -45,6 +51,17 @@
+ entityfishinghook.b(k);
}
+ // CraftBukkit start
-+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), null, (org.bukkit.entity.Fish) entityfishinghook.getBukkitEntity(), PlayerFishEvent.State.FISHING);
++ PlayerFishEvent playerFishEvent = new PlayerFishEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), null, (org.bukkit.entity.FishHook) entityfishinghook.getBukkitEntity(), PlayerFishEvent.State.FISHING);
+ world.getServer().getPluginManager().callEvent(playerFishEvent);
+
+ if (playerFishEvent.isCancelled()) {
+ entityhuman.hookedFish = null;
+ return new InteractionResultWrapper(EnumInteractionResult.PASS, itemstack);
+ }
-+ world.a((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.L, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemFishingRod.j.nextFloat() * 0.4F + 0.8F));
++ world.a((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.ENTITY_FISHING_BOBBER_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemFishingRod.k.nextFloat() * 0.4F + 0.8F));
+ // CraftBukkit end
+
world.addEntity(entityfishinghook);
diff --git a/nms-patches/ItemFlintAndSteel.patch b/nms-patches/ItemFlintAndSteel.patch
index 7442ab6f..81a7ef48 100644
--- a/nms-patches/ItemFlintAndSteel.patch
+++ b/nms-patches/ItemFlintAndSteel.patch
@@ -1,15 +1,15 @@
--- a/net/minecraft/server/ItemFlintAndSteel.java
+++ b/net/minecraft/server/ItemFlintAndSteel.java
-@@ -16,6 +16,12 @@
- return EnumInteractionResult.FAIL;
- } else {
- if (world.getType(blockposition).getMaterial() == Material.AIR) {
-+ // CraftBukkit start - Store the clicked block
-+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), org.bukkit.event.block.BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL, entityhuman).isCancelled()) {
-+ itemstack.damage(1, entityhuman);
-+ return EnumInteractionResult.PASS;
-+ }
-+ // CraftBukkit end
- world.a(entityhuman, blockposition, SoundEffects.bO, SoundCategory.BLOCKS, 1.0F, ItemFlintAndSteel.j.nextFloat() * 0.4F + 0.8F);
- world.setTypeAndData(blockposition, Blocks.FIRE.getBlockData(), 11);
- }
+@@ -14,6 +14,12 @@
+ BlockPosition blockposition = itemactioncontext.getClickPosition().shift(itemactioncontext.getClickedFace());
+
+ if (a((GeneratorAccess) world, blockposition)) {
++ // CraftBukkit start - Store the clicked block
++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition, org.bukkit.event.block.BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL, entityhuman).isCancelled()) {
++ itemactioncontext.getItemStack().damage(1, entityhuman);
++ return EnumInteractionResult.PASS;
++ }
++ // CraftBukkit end
+ world.a(entityhuman, blockposition, SoundEffects.ITEM_FLINTANDSTEEL_USE, SoundCategory.BLOCKS, 1.0F, ItemFlintAndSteel.k.nextFloat() * 0.4F + 0.8F);
+ IBlockData iblockdata = ((BlockFire) Blocks.FIRE).a((IBlockAccess) world, blockposition);
+
diff --git a/nms-patches/ItemHanging.patch b/nms-patches/ItemHanging.patch
index f6826f00..2991d715 100644
--- a/nms-patches/ItemHanging.patch
+++ b/nms-patches/ItemHanging.patch
@@ -11,12 +11,12 @@
public class ItemHanging extends Item {
-@@ -20,6 +24,18 @@
+@@ -25,6 +29,18 @@
if (entityhanging != null && entityhanging.survives()) {
if (!world.isClientSide) {
+ // CraftBukkit start - fire HangingPlaceEvent
-+ Player who = (entityhuman == null) ? null : (Player) entityhuman.getBukkitEntity();
++ Player who = (itemactioncontext.getEntity() == null) ? null : (Player) itemactioncontext.getEntity().getBukkitEntity();
+ org.bukkit.block.Block blockClicked = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
+ org.bukkit.block.BlockFace blockFace = org.bukkit.craftbukkit.block.CraftBlock.notchToBlockFace(enumdirection);
+
@@ -27,6 +27,6 @@
+ return EnumInteractionResult.FAIL;
+ }
+ // CraftBukkit end
- entityhanging.p();
+ entityhanging.m();
world.addEntity(entityhanging);
}
diff --git a/nms-patches/ItemLeash.patch b/nms-patches/ItemLeash.patch
index d51c6786..6a695213 100644
--- a/nms-patches/ItemLeash.patch
+++ b/nms-patches/ItemLeash.patch
@@ -8,8 +8,8 @@
+
public class ItemLeash extends Item {
- public ItemLeash() {
-@@ -39,7 +41,23 @@
+ public ItemLeash(Item.Info item_info) {
+@@ -43,7 +45,23 @@
if (entityinsentient.isLeashed() && entityinsentient.getLeashHolder() == entityhuman) {
if (entityleash == null) {
entityleash = EntityLeash.a(world, blockposition);
diff --git a/nms-patches/ItemMinecart.patch b/nms-patches/ItemMinecart.patch
index 60c5b2e5..ef20cdf9 100644
--- a/nms-patches/ItemMinecart.patch
+++ b/nms-patches/ItemMinecart.patch
@@ -38,7 +38,7 @@
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem());
+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) {
-+ idispensebehavior.a(isourceblock, eventStack);
++ idispensebehavior.dispense(isourceblock, eventStack);
+ return itemstack;
+ }
+ }
@@ -58,7 +58,7 @@
return itemstack;
}
-@@ -83,7 +117,7 @@
+@@ -84,7 +118,7 @@
entityminecartabstract.setCustomName(itemstack.getName());
}
diff --git a/nms-patches/ItemMonsterEgg.patch b/nms-patches/ItemMonsterEgg.patch
deleted file mode 100644
index 2069ea11..00000000
--- a/nms-patches/ItemMonsterEgg.patch
+++ /dev/null
@@ -1,30 +0,0 @@
---- a/net/minecraft/server/ItemMonsterEgg.java
-+++ b/net/minecraft/server/ItemMonsterEgg.java
-@@ -152,6 +152,11 @@
-
- @Nullable
- 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);
-+ }
-+
-+ @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;
-
-@@ -164,8 +169,13 @@
- entityinsentient.aP = entityinsentient.yaw;
- entityinsentient.aN = entityinsentient.yaw;
- entityinsentient.prepare(world.D(new BlockPosition(entityinsentient)), (GroupDataEntity) null);
-- world.addEntity(entity);
-- entityinsentient.D();
-+ // CraftBukkit start - don't return an entity when CreatureSpawnEvent is canceled
-+ if (!world.addEntity(entity, spawnReason)) {
-+ entity = null;
-+ } else {
-+ entityinsentient.D();
-+ }
-+ // CraftBukkit end
- }
- }
-
diff --git a/nms-patches/ItemRecord.patch b/nms-patches/ItemRecord.patch
index 0dff1125..ab2b7647 100644
--- a/nms-patches/ItemRecord.patch
+++ b/nms-patches/ItemRecord.patch
@@ -1,10 +1,10 @@
--- a/net/minecraft/server/ItemRecord.java
+++ b/net/minecraft/server/ItemRecord.java
-@@ -22,6 +22,7 @@
+@@ -34,6 +34,7 @@
+ ItemStack itemstack = itemactioncontext.getItemStack();
- 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);
+ ((BlockJukeBox) Blocks.JUKEBOX).a((GeneratorAccess) world, blockposition, iblockdata, itemstack);
+ world.a((EntityHuman) null, 1010, blockposition, Item.getId(this));
+ itemstack.subtract(1);
diff --git a/nms-patches/ItemRedstone.patch b/nms-patches/ItemRedstone.patch
deleted file mode 100644
index 62cf2e35..00000000
--- a/nms-patches/ItemRedstone.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- a/net/minecraft/server/ItemRedstone.java
-+++ b/net/minecraft/server/ItemRedstone.java
-@@ -11,7 +11,7 @@
- BlockPosition blockposition1 = flag ? blockposition : blockposition.shift(enumdirection);
- ItemStack itemstack = entityhuman.b(enumhand);
-
-- if (entityhuman.a(blockposition1, enumdirection, itemstack) && world.a(world.getType(blockposition1).getBlock(), blockposition1, false, enumdirection, (Entity) null) && Blocks.REDSTONE_WIRE.canPlace(world, blockposition1)) {
-+ if (!itemstack.isEmpty() && entityhuman.a(blockposition1, enumdirection, itemstack) && world.a(world.getType(blockposition1).getBlock(), blockposition1, false, enumdirection, (Entity) null) && Blocks.REDSTONE_WIRE.canPlace(world, blockposition1)) { // CraftBukkit
- world.setTypeUpdate(blockposition1, Blocks.REDSTONE_WIRE.getBlockData());
- if (entityhuman instanceof EntityPlayer) {
- CriterionTriggers.x.a((EntityPlayer) entityhuman, blockposition1, itemstack);
diff --git a/nms-patches/ItemReed.patch b/nms-patches/ItemReed.patch
deleted file mode 100644
index c3c66584..00000000
--- a/nms-patches/ItemReed.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- a/net/minecraft/server/ItemReed.java
-+++ b/net/minecraft/server/ItemReed.java
-@@ -2,7 +2,7 @@
-
- public class ItemReed extends Item {
-
-- private final Block a;
-+ public final Block a; // PAIL: private->public
-
- public ItemReed(Block block) {
- this.a = block;
diff --git a/nms-patches/ItemSkull.patch b/nms-patches/ItemSkullPlayer.patch
index e0f0e443..0679f503 100644
--- a/nms-patches/ItemSkull.patch
+++ b/nms-patches/ItemSkullPlayer.patch
@@ -1,6 +1,6 @@
---- a/net/minecraft/server/ItemSkull.java
-+++ b/net/minecraft/server/ItemSkull.java
-@@ -133,6 +133,15 @@
+--- a/net/minecraft/server/ItemSkullPlayer.java
++++ b/net/minecraft/server/ItemSkullPlayer.java
+@@ -42,6 +42,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 77d48395..498fa712 100644
--- a/nms-patches/ItemSnowball.patch
+++ b/nms-patches/ItemSnowball.patch
@@ -1,6 +1,6 @@
--- a/net/minecraft/server/ItemSnowball.java
+++ b/net/minecraft/server/ItemSnowball.java
-@@ -10,17 +10,29 @@
+@@ -9,17 +9,29 @@
public InteractionResultWrapper<ItemStack> a(World world, EntityHuman entityhuman, EnumHand enumhand) {
ItemStack itemstack = entityhuman.b(enumhand);
@@ -10,7 +10,7 @@
itemstack.subtract(1);
}
- world.a((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.hp, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemSnowball.j.nextFloat() * 0.4F + 0.8F));
+ world.a((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.ENTITY_SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemSnowball.k.nextFloat() * 0.4F + 0.8F));
+ */
if (!world.isClientSide) {
EntitySnowball entitysnowball = new EntitySnowball(world, entityhuman);
@@ -22,12 +22,12 @@
+ itemstack.subtract(1);
+ }
+
-+ world.a((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.hp, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemSnowball.j.nextFloat() * 0.4F + 0.8F));
++ world.a((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.ENTITY_SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemSnowball.k.nextFloat() * 0.4F + 0.8F));
+ } else if (entityhuman instanceof EntityPlayer) {
+ ((EntityPlayer) entityhuman).getBukkitEntity().updateInventory();
+ }
}
+ // CraftBukkit end
- entityhuman.b(StatisticList.b((Item) this));
+ entityhuman.b(StatisticList.ITEM_USED.b(this));
return new InteractionResultWrapper(EnumInteractionResult.SUCCESS, itemstack);
diff --git a/nms-patches/ItemStack.patch b/nms-patches/ItemStack.patch
index 0e6dbd50..672002cd 100644
--- a/nms-patches/ItemStack.patch
+++ b/nms-patches/ItemStack.patch
@@ -1,10 +1,11 @@
--- a/net/minecraft/server/ItemStack.java
+++ b/net/minecraft/server/ItemStack.java
-@@ -6,6 +6,19 @@
- import java.util.Random;
- import javax.annotation.Nullable;
+@@ -16,6 +16,20 @@
+ import org.apache.logging.log4j.LogManager;
+ import org.apache.logging.log4j.Logger;
+// CraftBukkit start
++import com.mojang.datafixers.Dynamic;
+import java.util.List;
+import java.util.Map;
+
@@ -19,291 +20,211 @@
+
public final class ItemStack {
- public static final ItemStack a = new ItemStack((Item) null);
-@@ -42,32 +55,74 @@
- this(item, i, 0);
- }
-
-+ // CraftBukkit start
- public ItemStack(Item item, int i, int j) {
-+ this(item, i, j, true);
-+ }
-+
-+ public ItemStack(Item item, int i, int j, boolean convert) {
-+ // CraftBukkit end
- this.item = item;
- this.damage = j;
- this.count = i;
-+ // CraftBukkit start - Pass to setData to do filtering
-+ if (MinecraftServer.getServer() != null) {
-+ this.setData(j);
-+ }
-+ if (convert) {
-+ this.convertStack();
-+ }
-+ // CraftBukkit end
- if (this.damage < 0) {
-- this.damage = 0;
-+ // this.damage = 0; // CraftBukkit - remove this.
- }
-
- this.F();
+ private static final Logger c = LogManager.getLogger();
+@@ -50,25 +64,43 @@
+ this.E();
}
+ // Called to run this stack through the data converter to handle older storage methods and serialized items
+ public void convertStack() {
+ if (MinecraftServer.getServer() != null) {
-+ // Don't convert beds - both the old and new data values are valid
-+ // Conversion would make getting white beds (data value 0) impossible
-+ if (this.item == Items.BED) {
-+ return;
-+ }
-+
+ NBTTagCompound savedStack = new NBTTagCompound();
+ this.save(savedStack);
-+ MinecraftServer.getServer().dataConverterManager.a(DataConverterTypes.ITEM_INSTANCE, savedStack); // PAIL: convert
++ MinecraftServer.getServer().dataConverterManager.update(DataConverterTypes.ITEM_STACK, new Dynamic(DynamicOpsNBT.a, savedStack), -1, CraftMagicNumbers.DATA_VERSION);
+ this.load(savedStack);
+ }
+ }
+
- private void F() {
-+ if (this.g && this == ItemStack.a) throw new AssertionError("TRAP"); // CraftBukkit
- this.g = this.isEmpty();
+ private void E() {
++ if (this.h && this == ItemStack.a) throw new AssertionError("TRAP"); // CraftBukkit
+ this.h = false;
+ this.h = this.isEmpty();
}
-- public ItemStack(NBTTagCompound nbttagcompound) {
+- private ItemStack(NBTTagCompound nbttagcompound) {
+ // CraftBukkit - break into own method
-+ public void load(NBTTagCompound nbttagcompound) {
- this.item = Item.b(nbttagcompound.getString("id"));
++ private void load(NBTTagCompound nbttagcompound) {
+ Item item = (Item) Item.REGISTRY.get(new MinecraftKey(nbttagcompound.getString("id")));
+
+ this.item = item == null ? Items.AIR : item;
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(nbttagcompound.getShort("Damage"));
-+ // CraftBukkit end
-+
if (nbttagcompound.hasKeyOfType("tag", 10)) {
- this.tag = nbttagcompound.getCompound("tag");
+- this.getItem().a(nbttagcompound);
+ // 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
- }
++ this.getItem().a(this.tag);
++ // CraftBukkit end
+ }
+
+ if (this.getItem().usesDurability()) {
+ this.setDamage(this.getDamage());
}
+ }
-+ public ItemStack(NBTTagCompound nbttagcompound) {
++ private ItemStack(NBTTagCompound nbttagcompound) {
+ this.load(nbttagcompound);
+ // CraftBukkit end
- this.F();
+ this.E();
}
-@@ -94,11 +149,138 @@
+@@ -98,7 +130,7 @@
+ return this.h ? Items.AIR : this.item;
}
- 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 oldData = this.getData();
-+ int oldCount = this.getCount();
-+
-+ if (!(this.getItem() instanceof ItemBucket)) { // if not bucket
-+ world.captureBlockStates = true;
-+ // special case bonemeal
-+ if (this.getItem() instanceof ItemDye && this.getData() == 15) {
-+ Block block = world.getType(blockposition).getBlock();
-+ if (block == Blocks.SAPLING || block instanceof BlockMushroom) {
-+ world.captureTreeGeneration = true;
+- public EnumInteractionResult placeItem(ItemActionContext itemactioncontext) {
++ public EnumInteractionResult placeItem(ItemActionContext itemactioncontext, EnumHand enumhand) { // CraftBukkit - add hand
+ EntityHuman entityhuman = itemactioncontext.getEntity();
+ BlockPosition blockposition = itemactioncontext.getClickPosition();
+ ShapeDetectorBlock shapedetectorblock = new ShapeDetectorBlock(itemactioncontext.getWorld(), blockposition, false);
+@@ -106,12 +138,124 @@
+ if (entityhuman != null && !entityhuman.abilities.mayBuild && !this.b(itemactioncontext.getWorld().E(), shapedetectorblock)) {
+ return EnumInteractionResult.PASS;
+ } else {
++ // CraftBukkit start - handle all block place event logic here
++ int oldCount = this.getCount();
++ World world = itemactioncontext.getWorld();
++
++ if (!(this.getItem() instanceof ItemBucket)) { // if not bucket
++ world.captureBlockStates = true;
++ // special case bonemeal
++ if (this.getItem() == Items.BONE_MEAL) {
++ Block block = world.getType(blockposition).getBlock();
++ if (block instanceof BlockSapling || block instanceof BlockMushroom) {
++ world.captureTreeGeneration = true;
++ }
+ }
+ }
-+ }
- EnumInteractionResult enuminteractionresult = this.getItem().a(entityhuman, world, blockposition, enumhand, enumdirection, f, f1, f2);
-+ int newData = this.getData();
-+ 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;
-+ Location location = new Location(world.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ());
-+ TreeType treeType = BlockSapling.treeType;
-+ BlockSapling.treeType = null;
-+ List<BlockState> blocks = (List<BlockState>) world.capturedBlockStates.clone();
-+ world.capturedBlockStates.clear();
-+ StructureGrowEvent event = null;
-+ if (treeType != null) {
-+ 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.getCount() == oldCount && this.getData() == oldData) {
-+ this.setData(newData);
-+ this.setCount(newCount);
+ Item item = this.getItem();
+ EnumInteractionResult enuminteractionresult = item.a(itemactioncontext);
++ int newCount = this.getCount();
++ this.setCount(oldCount);
++ world.captureBlockStates = false;
++ if (enuminteractionresult == EnumInteractionResult.SUCCESS && world.captureTreeGeneration && world.capturedBlockStates.size() > 0) {
++ world.captureTreeGeneration = false;
++ Location location = new Location(world.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ());
++ TreeType treeType = BlockSapling.treeType;
++ BlockSapling.treeType = null;
++ List<BlockState> blocks = (List<BlockState>) world.capturedBlockStates.clone();
++ world.capturedBlockStates.clear();
++ StructureGrowEvent event = null;
++ if (treeType != null) {
++ boolean isBonemeal = getItem() == Items.BONE_MEAL;
++ event = new StructureGrowEvent(location, treeType, isBonemeal, (Player) entityhuman.getBukkitEntity(), blocks);
++ org.bukkit.Bukkit.getPluginManager().callEvent(event);
+ }
-+ for (BlockState blockstate : blocks) {
-+ blockstate.update(true);
++ if (event == null || !event.isCancelled()) {
++ // Change the stack to its new contents if it hasn't been tampered with.
++ if (this.getCount() == oldCount) {
++ this.setCount(newCount);
++ }
++ for (BlockState blockstate : blocks) {
++ blockstate.update(true);
++ }
+ }
-+ }
+
-+ return enuminteractionresult;
-+ }
-+ world.captureTreeGeneration = false;
-
- if (enuminteractionresult == EnumInteractionResult.SUCCESS) {
-- entityhuman.b(StatisticList.b(this.item));
-+ org.bukkit.event.block.BlockPlaceEvent placeEvent = null;
-+ List<BlockState> blocks = (List<BlockState>) world.capturedBlockStates.clone();
-+ world.capturedBlockStates.clear();
-+ if (blocks.size() > 1) {
-+ placeEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockMultiPlaceEvent(world, entityhuman, enumhand, blocks, blockposition.getX(), blockposition.getY(), blockposition.getZ());
-+ } else if (blocks.size() == 1) {
-+ placeEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPlaceEvent(world, entityhuman, enumhand, blocks.get(0), blockposition.getX(), blockposition.getY(), blockposition.getZ());
++ return enuminteractionresult;
+ }
-+
-+ if (placeEvent != null && (placeEvent.isCancelled() || !placeEvent.canBuild())) {
-+ enuminteractionresult = EnumInteractionResult.FAIL; // cancel placement
-+ // PAIL: Remove this when MC-99075 fixed
-+ placeEvent.getPlayer().updateInventory();
-+ // revert back all captured blocks
-+ for (BlockState blockstate : blocks) {
-+ blockstate.update(true, false);
-+ }
-+ } else {
-+ // Change the stack to its new contents if it hasn't been tampered with.
-+ if (this.getCount() == oldCount && this.getData() == oldData) {
-+ this.setData(newData);
-+ this.setCount(newCount);
-+ }
-+
-+ for (Map.Entry<BlockPosition, TileEntity> e : world.capturedTileEntities.entrySet()) {
-+ world.setTileEntity(e.getKey(), e.getValue());
++ world.captureTreeGeneration = false;
+
+ if (entityhuman != null && enuminteractionresult == EnumInteractionResult.SUCCESS) {
+- entityhuman.b(StatisticList.ITEM_USED.b(item));
++ org.bukkit.event.block.BlockPlaceEvent placeEvent = null;
++ List<BlockState> blocks = (List<BlockState>) world.capturedBlockStates.clone();
++ world.capturedBlockStates.clear();
++ if (blocks.size() > 1) {
++ placeEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockMultiPlaceEvent(world, entityhuman, enumhand, blocks, blockposition.getX(), blockposition.getY(), blockposition.getZ());
++ } else if (blocks.size() == 1) {
++ placeEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPlaceEvent(world, entityhuman, enumhand, blocks.get(0), blockposition.getX(), blockposition.getY(), blockposition.getZ());
+ }
+
-+ for (BlockState blockstate : blocks) {
-+ int x = blockstate.getX();
-+ int y = blockstate.getY();
-+ int z = blockstate.getZ();
-+ int updateFlag = ((CraftBlockState) blockstate).getFlag();
-+ org.bukkit.Material mat = blockstate.getType();
-+ Block oldBlock = CraftMagicNumbers.getBlock(mat);
-+ BlockPosition newblockposition = new BlockPosition(x, y, z);
-+ IBlockData block = world.getType(newblockposition);
++ if (placeEvent != null && (placeEvent.isCancelled() || !placeEvent.canBuild())) {
++ enuminteractionresult = EnumInteractionResult.FAIL; // cancel placement
++ // PAIL: Remove this when MC-99075 fixed
++ placeEvent.getPlayer().updateInventory();
++ // revert back all captured blocks
++ for (BlockState blockstate : blocks) {
++ blockstate.update(true, false);
++ }
++ } else {
++ // Change the stack to its new contents if it hasn't been tampered with.
++ if (this.getCount() == oldCount) {
++ this.setCount(newCount);
++ }
+
-+ if (!(block.getBlock() instanceof BlockTileEntity)) { // Containers get placed automatically
-+ block.getBlock().onPlace(world, newblockposition, block);
++ for (Map.Entry<BlockPosition, TileEntity> e : world.capturedTileEntities.entrySet()) {
++ world.setTileEntity(e.getKey(), e.getValue());
+ }
+
-+ world.notifyAndUpdatePhysics(newblockposition, null, oldBlock.getBlockData(), block, updateFlag); // send null chunk as chunk.k() returns false by this point
-+ }
++ for (BlockState blockstate : blocks) {
++ int x = blockstate.getX();
++ int y = blockstate.getY();
++ int z = blockstate.getZ();
++ int updateFlag = ((CraftBlockState) blockstate).getFlag();
++ IBlockData oldBlock = ((CraftBlockState) blockstate).getHandle();
++ BlockPosition newblockposition = new BlockPosition(x, y, z);
++ IBlockData block = world.getType(newblockposition);
++
++ if (!(block.getBlock() instanceof BlockTileEntity)) { // Containers get placed automatically
++ block.getBlock().onPlace(block, world, newblockposition, oldBlock);
++ }
+
-+ // Special case juke boxes as they update their tile entity. Copied from ItemRecord.
-+ // PAIL: checkme on updates.
-+ if (this.item instanceof ItemRecord) {
-+ ((BlockJukeBox) Blocks.JUKEBOX).a(world, blockposition, world.getType(blockposition), this);
-+ world.a((EntityHuman) null, 1010, blockposition, Item.getId(this.item));
-+ this.subtract(1);
-+ entityhuman.b(StatisticList.Z);
-+ }
++ world.notifyAndUpdatePhysics(newblockposition, null, oldBlock, block, world.getType(newblockposition), updateFlag); // send null chunk as chunk.k() returns false by this point
++ }
+
-+ if (this.item == Items.SKULL) { // Special case skulls to allow wither spawns to be cancelled
-+ BlockPosition bp = blockposition;
-+ if (!world.getType(blockposition).getBlock().a(world, blockposition)) {
-+ if (!world.getType(blockposition).getMaterial().isBuildable()) {
-+ bp = null;
-+ } else {
-+ bp = bp.shift(enumdirection);
-+ }
++ // Special case juke boxes as they update their tile entity. Copied from ItemRecord.
++ // PAIL: checkme on updates.
++ if (this.item instanceof ItemRecord) {
++ ((BlockJukeBox) Blocks.JUKEBOX).a(world, blockposition, world.getType(blockposition), this);
++ world.a((EntityHuman) null, 1010, blockposition, Item.getId(this.item));
++ this.subtract(1);
++ entityhuman.a(StatisticList.PLAY_RECORD);
+ }
-+ if (bp != null) {
-+ TileEntity te = world.getTileEntity(bp);
++
++ if (this.item == Items.WITHER_SKELETON_SKULL) { // Special case skulls to allow wither spawns to be cancelled
++ TileEntity te = world.getTileEntity(blockposition);
+ if (te instanceof TileEntitySkull) {
-+ Blocks.SKULL.a(world, bp, (TileEntitySkull) te);
++ BlockWitherSkull.a(world, blockposition, (TileEntitySkull) te);
+ }
+ }
-+ }
+
-+ // SPIGOT-1288 - play sound stripped from ItemBlock
-+ if (this.item instanceof ItemBlock) {
-+ SoundEffectType soundeffecttype = ((ItemBlock) this.item).getBlock().getStepSound();
-+ world.a(entityhuman, blockposition, soundeffecttype.e(), SoundCategory.BLOCKS, (soundeffecttype.a() + 1.0F) / 2.0F, soundeffecttype.b() * 0.8F);
-+ }
++ // SPIGOT-1288 - play sound stripped from ItemBlock
++ if (this.item instanceof ItemBlock) {
++ SoundEffectType soundeffecttype = ((ItemBlock) this.item).getBlock().getStepSound();
++ world.a(entityhuman, blockposition, soundeffecttype.e(), SoundCategory.BLOCKS, (soundeffecttype.a() + 1.0F) / 2.0F, soundeffecttype.b() * 0.8F);
++ }
+
-+ entityhuman.b(StatisticList.b(this.item));
-+ }
- }
-+ world.capturedTileEntities.clear();
-+ world.capturedBlockStates.clear();
-+ // CraftBukkit end
++ entityhuman.b(StatisticList.ITEM_USED.b(item));
++ }
+ }
++ world.capturedTileEntities.clear();
++ world.capturedBlockStates.clear();
++ // CraftBukkit end
- return enuminteractionresult;
- }
-@@ -122,7 +304,7 @@
+ return enuminteractionresult;
+ }
+@@ -135,7 +279,7 @@
+ nbttagcompound.setString("id", minecraftkey == null ? "minecraft:air" : minecraftkey.toString());
nbttagcompound.setByte("Count", (byte) this.count);
- nbttagcompound.setShort("Damage", (short) this.damage);
if (this.tag != null) {
- nbttagcompound.set("tag", this.tag);
+ nbttagcompound.set("tag", this.tag.clone()); // CraftBukkit - make defensive copy, data is going to another thread
}
return nbttagcompound;
-@@ -157,11 +339,30 @@
- }
-
- public void setData(int i) {
-+ // CraftBukkit start - Filter out data for items that shouldn't have it
-+ // The crafting system uses this value for a special purpose so we have to allow it
-+ if (i == 32767) {
-+ this.damage = i;
-+ return;
-+ }
-+
-+ // Is this a block?
-+ if (CraftMagicNumbers.getBlock(CraftMagicNumbers.getId(this.getItem())) != Blocks.AIR) {
-+ // If vanilla doesn't use data on it don't allow any
-+ if (!(this.usesData() || this.getItem().usesDurability())) {
-+ i = 0;
-+ }
-+ }
-+
-+ // Filter invalid plant data
-+ if (CraftMagicNumbers.getBlock(CraftMagicNumbers.getId(this.getItem())) == Blocks.DOUBLE_PLANT && (i > 5 || i < 0)) {
-+ i = 0;
-+ }
-+ // CraftBukkit end
- this.damage = i;
- if (this.damage < 0) {
-- this.damage = 0;
-+ // this.damage = 0; // CraftBukkit - remove this.
- }
--
- }
-
- public int k() {
-@@ -202,6 +403,11 @@
- if (this.f()) {
+@@ -213,6 +357,11 @@
if (this.isDamaged(i, entityliving.getRandom(), entityliving instanceof EntityPlayer ? (EntityPlayer) entityliving : null)) {
- entityliving.b(this);
+ entityliving.c(this);
+ Item item = this.getItem();
+ // CraftBukkit start - Check for item breaking
+ if (this.count == 1 && entityliving instanceof EntityHuman) {
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerItemBreakEvent((EntityHuman) entityliving, this);
+ }
+ // CraftBukkit end
+
this.subtract(1);
if (entityliving instanceof EntityHuman) {
- EntityHuman entityhuman = (EntityHuman) entityliving;
-@@ -243,7 +449,7 @@
- }
-
- public ItemStack cloneItemStack() {
-- ItemStack itemstack = new ItemStack(this.item, this.count, this.damage);
-+ ItemStack itemstack = new ItemStack(this.item, this.count, this.damage, false); // CraftBukkit
-
- itemstack.d(this.D());
- if (this.tag != null) {
-@@ -464,6 +670,14 @@
+@@ -480,6 +629,14 @@
}
public void setRepairCost(int i) {
@@ -315,19 +236,20 @@
+ return;
+ }
+ // CraftBukkit end
- if (!this.hasTag()) {
- this.tag = new NBTTagCompound();
- }
-@@ -513,6 +727,12 @@
- nbttaglist.add(nbttagcompound);
+ this.getOrCreateTag().setInt("RepairCost", i);
+ }
+
+@@ -522,6 +679,13 @@
+ nbttaglist.add((NBTBase) nbttagcompound);
}
++ // CraftBukkit start
+ @Deprecated
+ public void setItem(Item item) {
+ this.item = item;
-+ this.setData(this.getData()); // CraftBukkit - Set data again to ensure it is filtered properly
+ }
++ // CraftBukkit end
+
- public IChatBaseComponent C() {
- ChatComponentText chatcomponenttext = new ChatComponentText(this.getName());
+ public IChatBaseComponent A() {
+ IChatBaseComponent ichatbasecomponent = (new ChatComponentText("")).addSibling(this.getName());
diff --git a/nms-patches/ItemWaterLily.patch b/nms-patches/ItemWaterLily.patch
index 65b3ab61..0e9db92f 100644
--- a/nms-patches/ItemWaterLily.patch
+++ b/nms-patches/ItemWaterLily.patch
@@ -1,12 +1,12 @@
--- a/net/minecraft/server/ItemWaterLily.java
+++ b/net/minecraft/server/ItemWaterLily.java
-@@ -24,7 +24,15 @@
- IBlockData iblockdata = world.getType(blockposition);
+@@ -30,7 +30,15 @@
+ Fluid fluid = world.b(blockposition);
- if (iblockdata.getMaterial() == Material.WATER && ((Integer) iblockdata.get(BlockFluids.LEVEL)).intValue() == 0 && world.isEmpty(blockposition1)) {
+ if ((fluid.c() == FluidTypes.c || material == Material.ICE) && world.isEmpty(blockposition1)) {
+ // CraftBukkit start - special case for handling block placement with water lilies
-+ org.bukkit.block.BlockState blockstate = org.bukkit.craftbukkit.block.CraftBlockState.getBlockState(world, blockposition1.getX(), blockposition1.getY(), blockposition1.getZ());
- world.setTypeAndData(blockposition1, Blocks.WATERLILY.getBlockData(), 11);
++ org.bukkit.block.BlockState blockstate = org.bukkit.craftbukkit.block.CraftBlockState.getBlockState(world, blockposition1);
+ world.setTypeAndData(blockposition1, Blocks.LILY_PAD.getBlockData(), 11);
+ org.bukkit.event.block.BlockPlaceEvent placeEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPlaceEvent(world, entityhuman, enumhand, blockstate, blockposition.getX(), blockposition.getY(), blockposition.getZ());
+ if (placeEvent != null && (placeEvent.isCancelled() || !placeEvent.canBuild())) {
+ blockstate.update(true, false);
@@ -14,5 +14,5 @@
+ }
+ // CraftBukkit end
if (entityhuman instanceof EntityPlayer) {
- CriterionTriggers.x.a((EntityPlayer) entityhuman, blockposition1, itemstack);
+ CriterionTriggers.y.a((EntityPlayer) entityhuman, blockposition1, itemstack);
}
diff --git a/nms-patches/ItemWorldMap.patch b/nms-patches/ItemWorldMap.patch
index 8705b251..c5dfff5d 100644
--- a/nms-patches/ItemWorldMap.patch
+++ b/nms-patches/ItemWorldMap.patch
@@ -1,7 +1,7 @@
--- a/net/minecraft/server/ItemWorldMap.java
+++ b/net/minecraft/server/ItemWorldMap.java
-@@ -5,6 +5,11 @@
- import com.google.common.collect.Multisets;
+@@ -6,6 +6,11 @@
+ import java.util.function.Function;
import javax.annotation.Nullable;
+// CraftBukkit start
@@ -11,57 +11,62 @@
+
public class ItemWorldMap extends ItemWorldMapBase {
- protected ItemWorldMap() {
-@@ -12,41 +17,50 @@
+ public ItemWorldMap(Item.Info item_info) {
+@@ -15,7 +20,7 @@
+ public static ItemStack a(World world, int i, int j, byte b0, boolean flag, boolean flag1) {
+ ItemStack itemstack = new ItemStack(Items.FILLED_MAP);
+
+- a(itemstack, world, i, j, b0, flag, flag1, world.worldProvider.getDimensionManager().getDimensionID());
++ a(itemstack, world, i, j, b0, flag, flag1, ((WorldServer) world).dimension); // CraftBukkit - fixes Bukkit multiworld maps
+ return itemstack;
}
- 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);
+@@ -24,7 +29,7 @@
+ WorldMap worldmap = a((GeneratorAccess) world, "map_" + e(itemstack));
-- 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;
+ if (worldmap == null && !world.isClientSide) {
+- worldmap = a(itemstack, world, world.getWorldData().b(), world.getWorldData().d(), 3, false, false, world.worldProvider.getDimensionManager().getDimensionID());
++ worldmap = a(itemstack, world, world.getWorldData().b(), world.getWorldData().d(), 3, false, false, ((WorldServer) world).dimension); // CraftBukkit - fixes Bukkit multiworld maps
+ }
+
+ return worldmap;
+@@ -33,26 +38,40 @@
+ public static int e(ItemStack itemstack) {
+ NBTTagCompound nbttagcompound = itemstack.getTag();
+
+- return nbttagcompound != null && nbttagcompound.hasKeyOfType("map", 99) ? nbttagcompound.getInt("map") : 0;
++ return nbttagcompound != null && nbttagcompound.hasKeyOfType("map", 99) ? nbttagcompound.getInt("map") : -1; // CraftBukkit - make new maps for no tag
}
- @Nullable
- public WorldMap getSavedMap(ItemStack itemstack, World world) {
+ private static WorldMap a(ItemStack itemstack, World world, int i, int j, int k, boolean flag, boolean flag1, int l) {
+- int i1 = world.b("map");
+ World worldMain = world.getServer().getServer().worlds.get(0); // CraftBukkit - store reference to primary world
- String s = "map_" + itemstack.getData();
-- WorldMap worldmap = (WorldMap) world.a(WorldMap.class, s);
-+ WorldMap worldmap = (WorldMap) worldMain.a(WorldMap.class, s); // CraftBukkit - use primary world for maps
++ int i1 = worldMain.b("map"); // CraftBukkit - use primary world for maps
+ WorldMap worldmap = new WorldMap("map_" + i1);
- if (worldmap == null && !world.isClientSide) {
-- itemstack.setData(world.b("map"));
-+ itemstack.setData(worldMain.b("map")); // CraftBukkit - use primary world for maps
- s = "map_" + itemstack.getData();
- worldmap = new WorldMap(s);
- worldmap.scale = 3;
- worldmap.a((double) world.getWorldData().b(), (double) world.getWorldData().d(), worldmap.scale);
-- worldmap.map = (byte) world.worldProvider.getDimensionManager().getDimensionID();
-+ worldmap.map = (byte) ((WorldServer) world).dimension; // CraftBukkit - fixes Bukkit multiworld maps
- worldmap.c();
-- world.a(s, (PersistentBase) worldmap);
-+ worldMain.a(s, (PersistentBase) worldmap); // CraftBukkit - use primary world for maps
+ worldmap.a(i, j, k, flag, flag1, l);
+- world.a(worldmap.getId(), (PersistentBase) worldmap);
++ worldMain.a(worldmap.getId(), (PersistentBase) worldmap); // CraftBukkit - use primary world for maps
+ itemstack.getOrCreateTag().setInt("map", i1);
+
-+ // CraftBukkit start
++ // CraftBukkit start
++ MapInitializeEvent event = new MapInitializeEvent(worldmap.mapView);
++ Bukkit.getServer().getPluginManager().callEvent(event);
++ // CraftBukkit end
+ return worldmap;
+ }
+
+ @Nullable
+ public static WorldMap a(GeneratorAccess generatoraccess, String s) {
+- return (WorldMap) generatoraccess.a(WorldMap::new, s);
++ // CraftBukkit start
++ WorldMap worldmap = (WorldMap) MinecraftServer.getServer().worlds.get(0).a(WorldMap::new, s); // CraftBukkit - use primary world for maps
++ if (worldmap != null) {
+ MapInitializeEvent event = new MapInitializeEvent(worldmap.mapView);
+ Bukkit.getServer().getPluginManager().callEvent(event);
-+ // CraftBukkit end
- }
-
- return worldmap;
++ }
++ return worldmap;
++ // CraftBukkit end
}
public void a(World world, Entity entity, WorldMap worldmap) {
@@ -71,41 +76,13 @@
int i = 1 << worldmap.scale;
int j = worldmap.centerX;
int k = worldmap.centerZ;
-@@ -309,6 +323,7 @@
- protected static void a(ItemStack itemstack, World world, int i) {
- WorldMap worldmap = Items.FILLED_MAP.getSavedMap(itemstack, world);
-
-+ world = world.getServer().getServer().worlds.get(0); // CraftBukkit - use primary world for maps
- itemstack.setData(world.b("map"));
- WorldMap worldmap1 = new WorldMap("map_" + itemstack.getData());
-
-@@ -319,6 +334,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
- }
+@@ -199,7 +218,8 @@
+ WorldMap worldmap = getSavedMap(itemstack, world);
- }
-@@ -326,6 +345,7 @@
- protected static void b(ItemStack itemstack, World world) {
- WorldMap worldmap = Items.FILLED_MAP.getSavedMap(itemstack, world);
-
-+ world = world.getServer().getServer().worlds.get(0); // CraftBukkit - use primary world for maps
- itemstack.setData(world.b("map"));
- WorldMap worldmap1 = new WorldMap("map_" + itemstack.getData());
-
-@@ -337,6 +357,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
- }
-
- }
+ if (worldmap != null) {
+- if (world.worldProvider.getDimensionManager().getDimensionID() == worldmap.map) {
++ // CraftBukkit - world.worldProvider -> ((WorldServer) world)
++ if (((WorldServer) world).dimension == worldmap.map) {
+ int i = 1 << worldmap.scale;
+ int j = worldmap.centerX;
+ int k = worldmap.centerZ;
diff --git a/nms-patches/ItemWrittenBook.patch b/nms-patches/ItemWrittenBook.patch
index 3a4e4761..e43dd909 100644
--- a/nms-patches/ItemWrittenBook.patch
+++ b/nms-patches/ItemWrittenBook.patch
@@ -1,34 +1,34 @@
--- a/net/minecraft/server/ItemWrittenBook.java
+++ b/net/minecraft/server/ItemWrittenBook.java
-@@ -61,6 +61,23 @@
+@@ -62,6 +62,23 @@
- Object object;
+ Object object;
-+ // CraftBukkit start
-+ // Some commands use the worldserver variable but we leave it full of null values,
-+ // so we must temporarily populate it with the world of the commandsender
-+ WorldServer[] prev = MinecraftServer.getServer().worldServer;
-+ MinecraftServer server = MinecraftServer.getServer();
-+ server.worldServer = new WorldServer[server.worlds.size()];
-+ server.worldServer[0] = (WorldServer) entityhuman.getWorld();
-+ int bpos = 0;
-+ for (int pos = 1; pos < server.worldServer.length; pos++) {
-+ WorldServer world = server.worlds.get(bpos++);
-+ if (server.worldServer[0] == world) {
-+ pos--;
-+ continue;
-+ }
-+ server.worldServer[pos] = world;
++ // CraftBukkit start
++ // Some commands use the worldserver variable but we leave it full of null values,
++ // so we must temporarily populate it with the world of the commandsender
++ WorldServer[] prev = MinecraftServer.getServer().worldServer;
++ MinecraftServer server = MinecraftServer.getServer();
++ server.worldServer = new WorldServer[server.worlds.size()];
++ server.worldServer[0] = (WorldServer) entityhuman.getWorld();
++ int bpos = 0;
++ for (int pos = 1; pos < server.worldServer.length; pos++) {
++ WorldServer world = server.worlds.get(bpos++);
++ if (server.worldServer[0] == world) {
++ pos--;
++ continue;
+ }
-+ // CraftBukkit end
- try {
- IChatBaseComponent ichatbasecomponent = IChatBaseComponent.ChatSerializer.b(s);
++ server.worldServer[pos] = world;
++ }
++ // CraftBukkit end
+ try {
+ IChatBaseComponent ichatbasecomponent = IChatBaseComponent.ChatSerializer.b(s);
-@@ -68,6 +85,7 @@
- } catch (Exception exception) {
- object = new ChatComponentText(s);
- }
-+ finally { MinecraftServer.getServer().worldServer = prev; } // CraftBukkit
-
- nbttaglist.a(i, new NBTTagString(IChatBaseComponent.ChatSerializer.a((IChatBaseComponent) object)));
+@@ -69,6 +86,7 @@
+ } catch (Exception exception) {
+ object = new ChatComponentText(s);
}
++ finally { MinecraftServer.getServer().worldServer = prev; } // CraftBukkit
+
+ nbttaglist.set(i, (NBTBase) (new NBTTagString(IChatBaseComponent.ChatSerializer.a((IChatBaseComponent) object))));
+ }
diff --git a/nms-patches/JsonList.patch b/nms-patches/JsonList.patch
index 9cdf691b..0db0f198 100644
--- a/nms-patches/JsonList.patch
+++ b/nms-patches/JsonList.patch
@@ -1,7 +1,7 @@
--- a/net/minecraft/server/JsonList.java
+++ b/net/minecraft/server/JsonList.java
-@@ -84,7 +84,7 @@
-
+@@ -86,7 +86,7 @@
+ @Nullable
public V get(K k0) {
this.h();
- return (JsonListEntry) this.d.get(this.a(k0));
@@ -9,7 +9,7 @@
}
public void remove(K k0) {
-@@ -102,6 +102,12 @@
+@@ -108,6 +108,12 @@
return (String[]) this.d.keySet().toArray(new String[this.d.size()]);
}
@@ -22,16 +22,25 @@
public boolean isEmpty() {
return this.d.size() < 1;
}
-@@ -178,7 +184,7 @@
- JsonListEntry jsonlistentry = (JsonListEntry) iterator.next();
+@@ -137,7 +143,7 @@
+ while (iterator.hasNext()) {
+ Object object = iterator.next();
+
+- this.d.remove(this.a(object));
++ this.d.remove(this.a((K) object)); // CraftBukkit - decompile error
+ }
+
+ }
+@@ -180,7 +186,7 @@
+ JsonListEntry jsonlistentry = (JsonListEntry) iterator.next();
- if (jsonlistentry.getKey() != null) {
-- this.d.put(this.a(jsonlistentry.getKey()), jsonlistentry);
-+ this.d.put(this.a((K) jsonlistentry.getKey()), (V) jsonlistentry); // CraftBukkit - fix decompile error
+ if (jsonlistentry.getKey() != null) {
+- this.d.put(this.a(jsonlistentry.getKey()), jsonlistentry);
++ this.d.put(this.a((K) jsonlistentry.getKey()), (V) jsonlistentry); // CraftBukkit - fix decompile error
+ }
}
}
- }
-@@ -207,11 +213,11 @@
+@@ -212,11 +218,11 @@
}
}
diff --git a/nms-patches/LoginListener.patch b/nms-patches/LoginListener.patch
index 789331f0..f1671027 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
-@@ -22,6 +22,12 @@
+@@ -19,6 +19,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);
-@@ -36,6 +42,7 @@
+@@ -33,6 +39,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;
-@@ -64,6 +71,20 @@
+@@ -61,6 +68,20 @@
}
@@ -41,33 +41,24 @@
+
public void disconnect(IChatBaseComponent ichatbasecomponent) {
try {
- LoginListener.c.info("Disconnecting {}: {}", this.c(), ichatbasecomponent.toPlainText());
-@@ -80,10 +101,12 @@
+ LoginListener.c.info("Disconnecting {}: {}", this.c(), ichatbasecomponent.getString());
+@@ -77,10 +98,12 @@
this.i = this.a(this.i);
}
-- String s = this.server.getPlayerList().attemptLogin(this.networkManager.getSocketAddress(), this.i);
+- IChatBaseComponent ichatbasecomponent = this.server.getPlayerList().attemptLogin(this.networkManager.getSocketAddress(), this.i);
+ // CraftBukkit start - fire PlayerLoginEvent
+ EntityPlayer s = this.server.getPlayerList().attemptLogin(this, this.i, hostname);
-- if (s != null) {
-- this.disconnect(new ChatMessage(s, new Object[0]));
+- if (ichatbasecomponent != null) {
+- this.disconnect(ichatbasecomponent);
+ if (s == null) {
-+ // this.disconnect(new ChatMessage(s, new Object[0]));
++ // this.disconnect(ichatbasecomponent);
+ // CraftBukkit end
} else {
this.g = LoginListener.EnumProtocolState.ACCEPTED;
- if (this.server.aG() >= 0 && !this.networkManager.isLocal()) {
-@@ -92,7 +115,7 @@
- LoginListener.this.networkManager.setCompressionLevel(LoginListener.this.server.aG());
- }
-
-- public void operationComplete(Future future) throws Exception {
-+ public void operationComplete(ChannelFuture future) throws Exception { // CraftBukkit - fix decompile error
- this.a((ChannelFuture) future);
- }
- }, new GenericFutureListener[0]);
-@@ -103,9 +126,9 @@
+ if (this.server.ay() >= 0 && !this.networkManager.isLocal()) {
+@@ -94,9 +117,9 @@
if (entityplayer != null) {
this.g = LoginListener.EnumProtocolState.DELAY_ACCEPT;
@@ -79,9 +70,9 @@
}
}
-@@ -150,6 +173,43 @@
+@@ -141,6 +164,43 @@
- LoginListener.this.i = LoginListener.this.server.az().hasJoinedServer(new GameProfile((UUID) null, gameprofile.getName()), s, this.a());
+ LoginListener.this.i = LoginListener.this.server.ar().hasJoinedServer(new GameProfile((UUID) null, gameprofile.getName()), s, this.a());
if (LoginListener.this.i != null) {
+ // CraftBukkit start - fire PlayerPreLoginEvent
+ if (!networkManager.isConnected()) {
@@ -122,8 +113,8 @@
+ // CraftBukkit end
LoginListener.c.info("UUID of player {} is {}", LoginListener.this.i.getName(), LoginListener.this.i.getId());
LoginListener.this.g = LoginListener.EnumProtocolState.READY_TO_ACCEPT;
- } else if (LoginListener.this.server.R()) {
-@@ -169,6 +229,11 @@
+ } else if (LoginListener.this.server.J()) {
+@@ -160,6 +220,11 @@
LoginListener.this.disconnect(new ChatMessage("multiplayer.disconnect.authservers_down", new Object[0]));
LoginListener.c.error("Couldn\'t verify username because servers are unavailable");
}
diff --git a/nms-patches/MethodProfiler.patch b/nms-patches/MethodProfiler.patch
index b608e64a..97e1ed3f 100644
--- a/nms-patches/MethodProfiler.patch
+++ b/nms-patches/MethodProfiler.patch
@@ -5,63 +5,63 @@
public class MethodProfiler {
+ public static final boolean ENABLED = Boolean.getBoolean("enableDebugMethodProfiler"); // CraftBukkit - disable unless specified in JVM arguments
- private static final Logger b = LogManager.getLogger();
- private final List<String> c = Lists.newArrayList();
- private final List<Long> d = Lists.newArrayList();
-@@ -23,12 +24,14 @@
- public MethodProfiler() {}
+ private static final Logger a = LogManager.getLogger();
+ private final List<String> b = Lists.newArrayList();
+ private final List<Long> c = Lists.newArrayList();
+@@ -41,6 +42,7 @@
+ }
- public void a() {
-+ if (!ENABLED) return; // CraftBukkit
- this.f.clear();
- this.e = "";
- this.c.clear();
+ public void a(int i) {
++ if (!ENABLED) return; // CraftBukkit
+ if (!this.d) {
+ this.d = true;
+ this.f.clear();
+@@ -52,6 +54,7 @@
}
public void a(String s) {
-+ if (!ENABLED) return; // CraftBukkit
- if (this.a) {
++ if (!ENABLED) return; // CraftBukkit
+ if (this.d) {
if (!this.e.isEmpty()) {
this.e = this.e + ".";
-@@ -41,12 +44,14 @@
+@@ -64,12 +67,14 @@
}
public void a(Supplier<String> supplier) {
-+ if (!ENABLED) return; // CraftBukkit
- if (this.a) {
++ if (!ENABLED) return; // CraftBukkit
+ if (this.d) {
this.a((String) supplier.get());
}
}
- public void b() {
-+ if (!ENABLED) return; // CraftBukkit
- if (this.a) {
- long i = System.nanoTime();
- long j = ((Long) this.d.remove(this.d.size() - 1)).longValue();
-@@ -69,7 +74,7 @@
+ public void e() {
++ if (!ENABLED) return; // CraftBukkit
+ if (this.d && !this.c.isEmpty()) {
+ long i = SystemUtils.c();
+ long j = ((Long) this.c.remove(this.c.size() - 1)).longValue();
+@@ -92,6 +97,7 @@
}
public List<MethodProfiler.ProfilerInfo> b(String s) {
-- if (!this.a) {
-+ if (!ENABLED || !this.a) { // CraftBukkit
- return Collections.emptyList();
- } else {
- long i = this.f.containsKey("root") ? ((Long) this.f.get("root")).longValue() : 0L;
-@@ -135,11 +140,13 @@
++ if (!ENABLED) return Collections.emptyList(); // CraftBukkit
+ long i = this.f.containsKey("root") ? ((Long) this.f.get("root")).longValue() : 0L;
+ long j = this.f.containsKey(s) ? ((Long) this.f.get(s)).longValue() : -1L;
+ ArrayList arraylist = Lists.newArrayList();
+@@ -154,11 +160,13 @@
}
public void c(String s) {
-+ if (!ENABLED) return; // CraftBukkit
- this.b();
++ if (!ENABLED) return; // CraftBukkit
+ this.e();
this.a(s);
}
- public String c() {
-+ if (!ENABLED) return "[DISABLED]"; // CraftBukkit
- return this.c.isEmpty() ? "[UNKNOWN]" : (String) this.c.get(this.c.size() - 1);
+ public String f() {
++ if (!ENABLED) return "[DISABLED]"; // CraftBukkit
+ return this.b.isEmpty() ? "[UNKNOWN]" : (String) this.b.get(this.b.size() - 1);
}
-@@ -159,7 +166,7 @@
+@@ -178,7 +186,7 @@
return methodprofiler_profilerinfo.a < this.a ? -1 : (methodprofiler_profilerinfo.a > this.a ? 1 : methodprofiler_profilerinfo.c.compareTo(this.c));
}
diff --git a/nms-patches/MinecraftServer.patch b/nms-patches/MinecraftServer.patch
index 1493d7e5..5d140dd5 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
-@@ -41,6 +41,13 @@
+@@ -55,6 +55,13 @@
import org.apache.commons.lang3.Validate;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -12,13 +12,13 @@
+import org.bukkit.craftbukkit.Main;
+// CraftBukkit end
- public abstract class MinecraftServer implements ICommandListener, Runnable, IAsyncTaskHandler, IMojangStatistics {
+ public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStatistics, ICommandListener, Runnable {
-@@ -98,19 +105,61 @@
- private Thread serverThread;
- private long ab = aw();
+@@ -124,7 +131,22 @@
+ private boolean an;
+ private float ao;
-- public MinecraftServer(File file, Proxy proxy, DataConverterManager dataconvertermanager, YggdrasilAuthenticationService yggdrasilauthenticationservice, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache) {
+- public MinecraftServer(@Nullable File file, Proxy proxy, DataFixer datafixer, CommandDispatcher commanddispatcher, YggdrasilAuthenticationService yggdrasilauthenticationservice, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache) {
+ // CraftBukkit start
+ public List<WorldServer> worlds = new ArrayList<WorldServer>();
+ public org.bukkit.craftbukkit.CraftServer server;
@@ -30,21 +30,36 @@
+ public final Thread primaryThread;
+ public java.util.Queue<Runnable> processQueue = new java.util.concurrent.ConcurrentLinkedQueue<Runnable>();
+ public int autosavePeriod;
++ public File bukkitDataPackFolder;
+ // CraftBukkit end
+
-+ public MinecraftServer(OptionSet options, Proxy proxy, DataConverterManager dataconvertermanager, YggdrasilAuthenticationService yggdrasilauthenticationservice, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache) {
- this.e = proxy;
- this.V = yggdrasilauthenticationservice;
- this.W = minecraftsessionservice;
- this.X = gameprofilerepository;
- this.Y = usercache;
++ public MinecraftServer(OptionSet options, Proxy proxy, DataFixer datafixer, CommandDispatcher commanddispatcher, YggdrasilAuthenticationService yggdrasilauthenticationservice, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache) {
++ this.commandDispatcher = commanddispatcher; // CraftBukkit
+ this.ac = new ResourceManager(EnumResourcePackType.SERVER_DATA);
+ this.resourcePackRepository = new ResourcePackRepository(ResourcePackLoader::new);
+ this.ag = new CraftingManager();
+@@ -135,22 +157,51 @@
+ this.al = new AdvancementDataWorld();
+ this.am = new CustomFunctionData(this);
+ this.d = proxy;
+- this.commandDispatcher = commanddispatcher;
++ // this.commandDispatcher = commanddispatcher; // CraftBukkit - moved up
+ this.U = yggdrasilauthenticationservice;
+ this.V = minecraftsessionservice;
+ this.W = gameprofilerepository;
+ this.X = usercache;
- this.universe = file;
+- this.m = file == null ? null : new ServerConnection(this);
+- this.convertable = file == null ? null : new WorldLoaderServer(file.toPath(), file.toPath().resolve("../backups"), datafixer);
+ // this.universe = file; // CraftBukkit
- this.p = new ServerConnection(this);
- this.b = this.i();
-- this.convertable = new WorldLoaderServer(file, dataconvertermanager);
-+ // this.convertable = new WorldLoaderServer(file); // CraftBukkit - moved to DedicatedServer.init
- this.dataConverterManager = dataconvertermanager;
++ this.m = new ServerConnection(this); // CraftBukkit
++ // this.convertable = file == null ? null : new WorldLoaderServer(file.toPath(), file.toPath().resolve("../backups"), datafixer); // CraftBukkit - moved to DedicatedServer.init
+ this.dataConverterManager = datafixer;
+ this.ac.a((IResourcePackListener) this.ah);
+ this.ac.a((IResourcePackListener) this.ag);
+ this.ac.a((IResourcePackListener) this.ak);
+ this.ac.a((IResourcePackListener) this.am);
+ this.ac.a((IResourcePackListener) this.al);
+ // CraftBukkit start
+ this.options = options;
+ // Try to see if we're actually running in a terminal, disable jline if not
@@ -76,21 +91,21 @@
+ public abstract PropertyManager getPropertyManager();
+ // CraftBukkit end
+
- protected CommandDispatcher i() {
- return new CommandDispatcher(this);
- }
-@@ -148,6 +197,7 @@
+ public abstract boolean init() throws IOException;
+
+ protected void a(String s) {
+@@ -184,6 +235,7 @@
this.a(s);
- this.b("menu.loadingLevel");
+ this.b((IChatBaseComponent) (new ChatMessage("menu.loadingLevel", new Object[0])));
this.worldServer = new WorldServer[3];
+ /* CraftBukkit start - Remove ticktime arrays and worldsettings
- this.i = new long[this.worldServer.length][100];
- IDataManager idatamanager = this.convertable.a(s, true);
+ this.f = new long[this.worldServer.length][100];
+ IDataManager idatamanager = this.convertable.a(s, this);
-@@ -171,36 +221,108 @@
- worlddata.a(s1);
- worldsettings = new WorldSettings(worlddata);
+@@ -209,40 +261,115 @@
}
+
+ this.a(idatamanager.getDirectory(), worlddata);
+ */
+ int worldCount = 3;
@@ -98,6 +113,7 @@
- byte b0 = 0;
+ for (int j = 0; j < worldCount; ++j) {
+ WorldServer world;
++ WorldData worlddata;
+ byte dimension = 0;
if (j == 1) {
@@ -123,16 +139,16 @@
+
+ org.bukkit.generator.ChunkGenerator gen = this.server.getGenerator(name);
+ WorldSettings worldsettings = new WorldSettings(i, this.getGamemode(), this.getGenerateStructures(), this.isHardcore(), worldtype);
-+ worldsettings.setGeneratorSettings(s2);
++ worldsettings.setGeneratorSettings(jsonelement);
+
if (j == 0) {
-+ IDataManager idatamanager = new ServerNBTManager(server.getWorldContainer(), s1, true, this.dataConverterManager);
-+ WorldData worlddata = idatamanager.getWorldData();
++ IDataManager idatamanager = new ServerNBTManager(server.getWorldContainer(), s1, this, this.dataConverterManager);
++ worlddata = idatamanager.getWorldData();
+ if (worlddata == null) {
+ worlddata = new WorldData(worldsettings, s1);
+ }
+ worlddata.checkName(s1); // CraftBukkit - Migration did not rewrite the level.dat; This forces 1.8 to take the last loaded world as respawn (in this case the end)
- if (this.V()) {
+ if (this.N()) {
- this.worldServer[j] = (WorldServer) (new DemoWorldServer(this, idatamanager, worlddata, b0, this.methodProfiler)).b();
+ world = (WorldServer) (new DemoWorldServer(this, idatamanager, worlddata, dimension, this.methodProfiler)).b();
} else {
@@ -142,6 +158,7 @@
- this.worldServer[j].a(worldsettings);
+ world.a(worldsettings);
++ this.a(idatamanager.getDirectory(), worlddata);
+ this.server.scoreboardManager = new org.bukkit.craftbukkit.scoreboard.CraftScoreboardManager(this, world.getScoreboard());
} else {
- this.worldServer[j] = (WorldServer) (new SecondaryWorldServer(this, idatamanager, b0, this.worldServer[0], this.methodProfiler)).b();
@@ -180,9 +197,9 @@
+ }
+ }
+
-+ IDataManager idatamanager = new ServerNBTManager(server.getWorldContainer(), name, true, this.dataConverterManager);
++ IDataManager idatamanager = new ServerNBTManager(server.getWorldContainer(), name, this, this.dataConverterManager);
+ // world =, b0 to dimension, s1 to name, added Environment and gen
-+ WorldData worlddata = idatamanager.getWorldData();
++ worlddata = idatamanager.getWorldData();
+ if (worlddata == null) {
+ worlddata = new WorldData(worldsettings, name);
+ }
@@ -194,77 +211,136 @@
+ this.server.getPluginManager().callEvent(new org.bukkit.event.world.WorldInitEvent(world.getWorld()));
+
+ world.addIWorldAccess(new WorldManager(this, world));
- if (!this.R()) {
+ if (!this.J()) {
- this.worldServer[j].getWorldData().setGameType(this.getGamemode());
+ world.getWorldData().setGameType(this.getGamemode());
}
- }
+- this.s.setPlayerFileData(this.worldServer);
+- if (worlddata.P() != null) {
+- this.aR().a(worlddata.P());
+ worlds.add(world);
+ getPlayerList().setPlayerFileData(worlds.toArray(new WorldServer[worlds.size()]));
-+ }
++
++ if (worlddata.P() != null) {
++ this.aR().a(worlddata.P());
++ }
+ }
++ this.s.setPlayerFileData(this.worldServer);
+ // CraftBukkit end
- this.v.setPlayerFileData(this.worldServer);
+
this.a(this.getDifficulty());
- this.l();
-@@ -216,25 +338,38 @@
- this.b("menu.generatingTerrain");
- boolean flag4 = false;
+ this.g_();
+@@ -251,6 +378,25 @@
+ protected void a(File file, WorldData worlddata) {
+ this.resourcePackRepository.a((ResourcePackSource) (new ResourcePackSourceVanilla()));
+ this.resourcePackFolder = new ResourcePackSourceFolder(new File(file, "datapacks"));
++ // CraftBukkit start
++ bukkitDataPackFolder = new File(new File(file, "datapacks"), "bukkit");
++ if (!bukkitDataPackFolder.exists()) {
++ bukkitDataPackFolder.mkdirs();
++ }
++ File mcMeta = new File(bukkitDataPackFolder, "pack.mcmeta");
++ if (!mcMeta.exists()) {
++ try {
++ com.google.common.io.Files.write("{\n"
++ + " \"pack\": {\n"
++ + " \"description\": \"Data pack for resources provided by Bukkit plugins\",\n"
++ + " \"pack_format\": 1\n"
++ + " }\n"
++ + "}", mcMeta, com.google.common.base.Charsets.UTF_8);
++ } catch (IOException ex) {
++ throw new RuntimeException("Could not initialize Bukkit datapack", ex);
++ }
++ }
++ // CraftBukkit end
+ this.resourcePackRepository.a((ResourcePackSource) this.resourcePackFolder);
+ this.resourcePackRepository.a();
+ ArrayList arraylist = Lists.newArrayList();
+@@ -281,41 +427,52 @@
+ this.b((IChatBaseComponent) (new ChatMessage("menu.generatingTerrain", new Object[0])));
+ boolean flag5 = false;
- MinecraftServer.LOGGER.info("Preparing start region for level 0");
- WorldServer worldserver = this.worldServer[0];
- BlockPosition blockposition = worldserver.getSpawn();
-- 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 = aw();
--
-- if (i1 - j > 1000L) {
-- this.a_("Preparing spawn area", i * 100 / 625);
-- j = i1;
-- }
+- ArrayList arraylist = Lists.newArrayList();
+- Set set = Sets.newConcurrentHashSet();
+ // CraftBukkit start - fire WorldLoadEvent and handle whether or not to keep the spawn in memory
+ Stopwatch stopwatch = Stopwatch.createStarted();
+-
+- for (int i = -192; i <= 192 && this.isRunning(); i += 16) {
+- for (int j = -192; j <= 192 && this.isRunning(); j += 16) {
+- arraylist.add(new ChunkCoordIntPair(blockposition.getX() + i >> 4, blockposition.getZ() + j >> 4));
+ for (int m = 0; m < worlds.size(); m++) {
+ WorldServer worldserver = this.worlds.get(m);
+ MinecraftServer.LOGGER.info("Preparing start region for level " + m + " (Seed: " + worldserver.getSeed() + ")");
-+
+ if (!worldserver.getWorld().getKeepSpawnInMemory()) {
+ continue;
-+ }
-+
+ }
+
+- CompletableFuture completablefuture = worldserver.getChunkProviderServer().a((Iterable) arraylist, (chunk) -> {
+- set.add(chunk.getPos());
+- });
+ BlockPosition blockposition = worldserver.getSpawn();
-+ long j = aw();
-+ i = 0;
++ ArrayList arraylist = Lists.newArrayList();
++ Set set = Sets.newConcurrentHashSet();
+
-+ for (int k = -192; k <= 192 && this.isRunning(); k += 16) {
-+ for (int l = -192; l <= 192 && this.isRunning(); l += 16) {
-+ long i1 = aw();
++ for (int i = -192; i <= 192 && this.isRunning(); i += 16) {
++ for (int j = -192; j <= 192 && this.isRunning(); j += 16) {
++ arraylist.add(new ChunkCoordIntPair(blockposition.getX() + i >> 4, blockposition.getZ() + j >> 4));
++ }
+
+- while (!completablefuture.isDone()) {
+- try {
+- completablefuture.get(1L, TimeUnit.SECONDS);
+- } catch (InterruptedException interruptedexception) {
+- throw new RuntimeException(interruptedexception);
+- } catch (ExecutionException executionexception) {
+- if (executionexception.getCause() instanceof RuntimeException) {
+- throw (RuntimeException) executionexception.getCause();
+- }
++ CompletableFuture completablefuture = worldserver.getChunkProviderServer().a((Iterable) arraylist, (chunk) -> {
++ set.add(chunk.getPos());
++ });
+
+- throw new RuntimeException(executionexception.getCause());
+- } catch (TimeoutException timeoutexception) {
+- this.a(new ChatMessage("menu.preparingSpawn", new Object[0]), set.size() * 100 / 625);
++ while (!completablefuture.isDone()) {
++ try {
++ completablefuture.get(1L, TimeUnit.SECONDS);
++ } catch (InterruptedException interruptedexception) {
++ throw new RuntimeException(interruptedexception);
++ } catch (ExecutionException executionexception) {
++ if (executionexception.getCause() instanceof RuntimeException) {
++ throw (RuntimeException) executionexception.getCause();
++ }
+
-+ if (i1 - j > 1000L) {
-+ this.a_("Preparing spawn area", i * 100 / 625);
-+ j = i1;
++ throw new RuntimeException(executionexception.getCause());
++ } catch (TimeoutException timeoutexception) {
++ this.a(new ChatMessage("menu.preparingSpawn", new Object[0]), set.size() * 100 / 625);
+ }
+ }
+- }
-- ++i;
-- worldserver.getChunkProviderServer().getChunkAt(blockposition.getX() + k >> 4, blockposition.getZ() + l >> 4);
-+ ++i;
-+ worldserver.getChunkProviderServer().getChunkAt(blockposition.getX() + k >> 4, blockposition.getZ() + l >> 4);
-+ }
- }
+- this.a(new ChatMessage("menu.preparingSpawn", new Object[0]), set.size() * 100 / 625);
++ this.a(new ChatMessage("menu.preparingSpawn", new Object[0]), set.size() * 100 / 625);
++ }
}
+ for (WorldServer world : this.worlds) {
+ this.server.getPluginManager().callEvent(new org.bukkit.event.world.WorldLoadEvent(world.getWorld()));
+ }
+ // CraftBukkit end
- this.t();
+ this.m();
+ MinecraftServer.LOGGER.info("Time elapsed: {} ms", Long.valueOf(stopwatch.elapsed(TimeUnit.MILLISECONDS)));
}
-
-@@ -274,14 +409,17 @@
- protected void t() {
- this.f = null;
- this.g = 0;
+@@ -354,14 +511,17 @@
+ protected void m() {
+ this.w = null;
+ this.x = 0;
+ this.server.enablePlugins(org.bukkit.plugin.PluginLoadOrder.POSTWORLD); // CraftBukkit
}
@@ -281,15 +357,7 @@
if (worldserver != null) {
if (!flag) {
-@@ -290,6 +428,7 @@
-
- try {
- worldserver.save(true, (IProgressUpdate) null);
-+ worldserver.saveLevel(); // CraftBukkit
- } catch (ExceptionWorldConflict exceptionworldconflict) {
- MinecraftServer.LOGGER.warn(exceptionworldconflict.getMessage());
- }
-@@ -298,8 +437,24 @@
+@@ -378,8 +538,24 @@
}
@@ -312,55 +380,58 @@
+ this.server.disablePlugins();
+ }
+ // CraftBukkit end
- if (this.an() != null) {
- this.an().b();
+ if (this.getServerConnection() != null) {
+ this.getServerConnection().b();
}
-@@ -308,6 +463,7 @@
+@@ -388,6 +564,7 @@
MinecraftServer.LOGGER.info("Saving players");
- this.v.savePlayers();
- this.v.u();
+ this.s.savePlayers();
+ this.s.u();
+ try { Thread.sleep(100); } catch (InterruptedException ex) {} // CraftBukkit - SPIGOT-625 - give server at least a chance to send packets
}
if (this.worldServer != null) {
-@@ -329,12 +485,14 @@
+@@ -398,8 +575,10 @@
+ int j;
+ WorldServer worldserver;
+
+- for (j = 0; j < i; ++j) {
+- worldserver = aworldserver[j];
++ // CraftBukkit start
++ for (j = 0; j < worlds.size(); ++j) {
++ worldserver = worlds.get(j);
++ // CraftBukkit end
+ if (worldserver != null) {
+ worldserver.savingDisabled = false;
+ }
+@@ -409,8 +588,10 @@
aworldserver = this.worldServer;
i = aworldserver.length;
-+ /* CraftBukkit start - Handled in saveChunks
- for (j = 0; j < i; ++j) {
- worldserver = aworldserver[j];
+- for (j = 0; j < i; ++j) {
+- worldserver = aworldserver[j];
++ // CraftBukkit start
++ for (j = 0; j < worlds.size(); ++j) {
++ worldserver = worlds.get(j);
++ // CraftBukkit end
if (worldserver != null) {
- worldserver.saveLevel();
+ worldserver.close();
}
- }
-+ // CraftBukkit end */
- }
-
- if (this.m.d()) {
-@@ -374,6 +532,7 @@
- long k = j - this.ab;
+@@ -453,11 +634,13 @@
+ if (i > 2000L && this.aa - this.Q >= 15000L) {
+ long j = i / 50L;
- 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)", Long.valueOf(k), Long.valueOf(k / 50L));
- k = 2000L;
- this.R = this.ab;
-@@ -386,11 +545,12 @@
-
- i += k;
- this.ab = j;
-- if (this.worldServer[0].everyoneDeeplySleeping()) {
-+ if (this.worlds.get(0).everyoneDeeplySleeping()) { // CraftBukkit
- this.C();
- i = 0L;
- } else {
- while (i > 50L) {
-+ MinecraftServer.currentTick = (int) (System.currentTimeMillis() / 50); // CraftBukkit
- i -= 50L;
- this.C();
- }
-@@ -428,6 +588,12 @@
+ MinecraftServer.LOGGER.warn("Can\'t keep up! Is the server overloaded? Running {}ms or {} ticks behind", Long.valueOf(i), Long.valueOf(j));
+ this.aa += j * 50L;
+ this.Q = this.aa;
+ }
+
++ MinecraftServer.currentTick = (int) (System.currentTimeMillis() / 50); // CraftBukkit
+ this.v();
+ this.aa += 50L;
+
+@@ -496,6 +679,12 @@
} catch (Throwable throwable1) {
MinecraftServer.LOGGER.error("Exception stopping the server", throwable1);
} finally {
@@ -370,37 +441,28 @@
+ } catch (Exception ignored) {
+ }
+ // CraftBukkit end
- this.B();
+ this.u();
}
-@@ -471,7 +637,7 @@
-
- public void B() {}
-
-- protected void C() {
-+ protected void C() throws ExceptionWorldConflict { // CraftBukkit - added throws
- long i = System.nanoTime();
-
- ++this.ticks;
-@@ -497,7 +663,7 @@
- this.q.b().a(agameprofile);
+@@ -564,7 +753,7 @@
+ this.n.b().a(agameprofile);
}
- if (this.ticks % 900 == 0) {
+ if (autosavePeriod > 0 && this.ticks % autosavePeriod == 0) { // CraftBukkit
this.methodProfiler.a("save");
- this.v.savePlayers();
+ this.s.savePlayers();
this.saveChunks(true);
-@@ -521,6 +687,7 @@
+@@ -590,6 +779,7 @@
}
- public void D() {
+ public void w() {
+ this.server.getScheduler().mainThreadHeartbeat(this.ticks); // CraftBukkit
this.methodProfiler.a("jobs");
- Queue queue = this.j;
-
-@@ -532,22 +699,40 @@
+ FutureTask futuretask;
+@@ -602,22 +792,40 @@
+ this.aD().X_();
this.methodProfiler.c("levels");
+ // CraftBukkit start
@@ -423,11 +485,11 @@
- for (i = 0; i < this.worldServer.length; ++i) {
+ for (i = 0; i < this.worlds.size(); ++i) { // CraftBukkit
- long j = System.nanoTime();
+ long j = SystemUtils.c();
- if (i == 0 || this.getAllowNether()) {
- WorldServer worldserver = this.worldServer[i];
-+ // if (i == 0 || this.getAllowNether()) {
++ if (true || i == 0 || this.getAllowNether()) { // CraftBukkit
+ WorldServer worldserver = this.worlds.get(i);
this.methodProfiler.a(() -> {
@@ -436,27 +498,24 @@
+ /* Drop global time updates
if (this.ticks % 20 == 0) {
this.methodProfiler.a("timeSync");
- this.v.a((Packet) (new PacketPlayOutUpdateTime(worldserver.getTime(), worldserver.getDayTime(), worldserver.getGameRules().getBoolean("doDaylightCycle"))), worldserver.worldProvider.getDimensionManager().getDimensionID());
- this.methodProfiler.b();
+ this.s.a((Packet) (new PacketPlayOutUpdateTime(worldserver.getTime(), worldserver.getDayTime(), worldserver.getGameRules().getBoolean("doDaylightCycle"))), worldserver.worldProvider.getDimensionManager().getDimensionID());
+ this.methodProfiler.e();
}
+ // CraftBukkit end */
this.methodProfiler.a("tick");
-@@ -574,9 +759,9 @@
- worldserver.getTracker().updatePlayers();
- this.methodProfiler.b();
- this.methodProfiler.b();
-- }
-+ // } // CraftBukkit
+@@ -646,7 +854,7 @@
+ this.methodProfiler.e();
+ }
-- this.i[i][this.ticks % 100] = System.nanoTime() - j;
-+ // this.i[i][this.ticks % 100] = System.nanoTime() - j; // CraftBukkit
+- this.f[i][this.ticks % 100] = SystemUtils.c() - j;
++ // this.f[i][this.ticks % 100] = SystemUtils.c() - j; // CraftBukkit
}
this.methodProfiler.c("connection");
-@@ -602,10 +787,11 @@
- this.o.add(itickable);
+@@ -670,10 +878,11 @@
+ this.l.add(itickable);
}
- public static void main(String[] astring) {
@@ -468,7 +527,7 @@
boolean flag = true;
String s = null;
String s1 = ".";
-@@ -650,13 +836,16 @@
+@@ -718,13 +927,16 @@
++j;
}
}
@@ -484,12 +543,12 @@
+ /* CraftBukkit start
if (s != null) {
- dedicatedserver.i(s);
+ dedicatedserver.h(s);
}
-@@ -687,6 +876,25 @@
- dedicatedserver.stop();
- }
- });
+@@ -758,6 +970,25 @@
+
+ thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(MinecraftServer.LOGGER));
+ Runtime.getRuntime().addShutdownHook(thread);
+ */
+
+ if (options.has("port")) {
@@ -512,18 +571,21 @@
} catch (Exception exception) {
MinecraftServer.LOGGER.fatal("Failed to start the minecraft server", exception);
}
-@@ -694,8 +902,10 @@
+@@ -765,11 +996,13 @@
}
- public void F() {
+ public void y() {
+ /* CraftBukkit start - prevent abuse
this.serverThread = new Thread(this, "Server thread");
+ this.serverThread.setUncaughtExceptionHandler((thread, throwable) -> {
+ MinecraftServer.LOGGER.error(throwable);
+ });
this.serverThread.start();
+ // CraftBukkit end */
}
- public File d(String s) {
-@@ -711,7 +921,14 @@
+ public File c(String s) {
+@@ -785,11 +1018,18 @@
}
public WorldServer getWorldServer(int i) {
@@ -538,8 +600,13 @@
+ // CraftBukkit end
}
+ public WorldServer a(DimensionManager dimensionmanager) {
+- return dimensionmanager == DimensionManager.NETHER ? this.worldServer[1] : (dimensionmanager == DimensionManager.THE_END ? this.worldServer[2] : this.worldServer[0]);
++ return dimensionmanager == DimensionManager.NETHER ? this.worlds.get(1) : (dimensionmanager == DimensionManager.THE_END ? this.worlds.get(2) : this.worlds.get(0)); // CraftBukkit
+ }
+
public String getVersion() {
-@@ -735,7 +952,7 @@
+@@ -809,7 +1049,7 @@
}
public boolean isDebugging() {
@@ -547,8 +614,8 @@
+ return this.getPropertyManager().getBoolean("debug", false); // CraftBukkit - don't hardcode
}
- public void g(String s) {
-@@ -750,7 +967,7 @@
+ public void f(String s) {
+@@ -824,7 +1064,7 @@
}
public String getServerModName() {
@@ -557,30 +624,16 @@
}
public CrashReport b(CrashReport crashreport) {
-@@ -779,6 +996,7 @@
- }
-
- public List<String> tabCompleteCommand(ICommandListener icommandlistener, String s, @Nullable BlockPosition blockposition, boolean flag) {
-+ /* CraftBukkit start - Allow tab-completion of Bukkit commands
- ArrayList arraylist = Lists.newArrayList();
- boolean flag1 = s.startsWith("/");
-
-@@ -821,10 +1039,13 @@
-
- return arraylist;
- }
-+ */
-+ return server.tabComplete(icommandlistener, s, blockposition, flag);
-+ // CraftBukkit end
+@@ -860,7 +1100,7 @@
}
- public boolean M() {
+ public boolean F() {
- return this.universe != null;
+ return true; // CraftBukkit
}
- public String getName() {
-@@ -880,11 +1101,13 @@
+ public void sendMessage(IChatBaseComponent ichatbasecomponent) {
+@@ -904,11 +1144,13 @@
}
public void a(EnumDifficulty enumdifficulty) {
@@ -597,7 +650,7 @@
if (worldserver != null) {
if (worldserver.getWorldData().isHardcore()) {
-@@ -951,13 +1174,11 @@
+@@ -975,13 +1217,11 @@
int i = 0;
if (this.worldServer != null) {
@@ -615,8 +668,8 @@
WorldData worlddata = worldserver.getWorldData();
mojangstatisticsgenerator.a("world[" + i + "][dimension]", Integer.valueOf(worldserver.worldProvider.getDimensionManager().getDimensionID()));
-@@ -990,7 +1211,7 @@
- public abstract boolean aa();
+@@ -1007,7 +1247,7 @@
+ public abstract boolean S();
public boolean getOnlineMode() {
- return this.onlineMode;
@@ -624,8 +677,8 @@
}
public void setOnlineMode(boolean flag) {
-@@ -1070,13 +1291,9 @@
- }
+@@ -1089,13 +1329,9 @@
+ public abstract boolean af();
public void setGamemode(EnumGamemode enumgamemode) {
- WorldServer[] aworldserver = this.worldServer;
@@ -641,70 +694,65 @@
}
}
-@@ -1100,7 +1317,7 @@
- }
-
- public World getWorld() {
-- return this.worldServer[0];
-+ return this.worlds.get(0); // CraftBukkit
- }
-
- public int getSpawnProtection() {
-@@ -1160,8 +1377,10 @@
- WorldServer[] aworldserver = this.worldServer;
- int i = aworldserver.length;
-
-- for (int j = 0; j < i; ++j) {
-- WorldServer worldserver = aworldserver[j];
-+ // CraftBukkit start
-+ for (int j = 0; j < worlds.size(); ++j) {
-+ WorldServer worldserver = worlds.get(j);
-+ // CraftBukkit end
-
- if (worldserver != null) {
- Entity entity = worldserver.getEntity(uuid);
-@@ -1176,7 +1395,7 @@
- }
-
- public boolean getSendCommandFeedback() {
-- return this.worldServer[0].getGameRules().getBoolean("sendCommandFeedback");
-+ return worlds.get(0).getGameRules().getBoolean("sendCommandFeedback");
- }
-
- public MinecraftServer C_() {
-@@ -1189,7 +1408,7 @@
+@@ -1168,7 +1404,7 @@
public <V> ListenableFuture<V> a(Callable<V> callable) {
Validate.notNull(callable);
- if (!this.isMainThread() && !this.isStopped()) {
+ if (!this.isMainThread()) { // CraftBukkit && !this.isStopped()) {
ListenableFutureTask listenablefuturetask = ListenableFutureTask.create(callable);
- Queue queue = this.j;
-@@ -1232,17 +1451,17 @@
+ this.g.add(listenablefuturetask);
+@@ -1225,7 +1461,7 @@
+ } else {
+ this.getPlayerList().savePlayers();
+ this.resourcePackRepository.a();
+- this.a(this.worldServer[0].getWorldData());
++ this.a(this.worlds.get(0).getWorldData()); // CraftBukkit
+ this.getPlayerList().reload();
+ }
+ }
+@@ -1239,8 +1475,8 @@
+
+ if (!worlddata.N().contains(resourcepackloader.e()) && !arraylist.contains(resourcepackloader)) {
+ MinecraftServer.LOGGER.info("Found new data pack {}, loading it automatically", resourcepackloader.e());
+- resourcepackloader.h().a(arraylist, resourcepackloader, (resourcepackloader) -> {
+- return resourcepackloader;
++ resourcepackloader.h().a(arraylist, resourcepackloader, (resourcepackloader1) -> { // CraftBukkit - decompile error
++ return resourcepackloader1; // CraftBukkit - decompile error
+ }, false);
+ }
+ }
+@@ -1249,7 +1485,7 @@
+ ArrayList arraylist1 = Lists.newArrayList();
+
+ this.resourcePackRepository.d().forEach((resourcepackloader) -> {
+- list.add(resourcepackloader.d());
++ arraylist1.add(resourcepackloader.d()); // CraftBukkit - decompile error
+ });
+ this.ac.a((List) arraylist1);
+ worlddata.O().clear();
+@@ -1299,7 +1535,7 @@
}
- public AdvancementDataWorld getAdvancementData() {
-- return this.worldServer[0].z();
-+ return this.worlds.get(0).z(); // CraftBukkit
+ public CommandListenerWrapper getServerCommandListener() {
+- return new CommandListenerWrapper(this, this.worldServer[0] == null ? Vec3D.a : new Vec3D(this.worldServer[0].getSpawn()), Vec2F.a, this.worldServer[0], 4, "Server", new ChatComponentText("Server"), this, (Entity) null);
++ return new CommandListenerWrapper(this, this.worlds.isEmpty() ? Vec3D.a : new Vec3D(this.worlds.get(0).getSpawn()), Vec2F.a, this.worlds.isEmpty() ? null : this.worlds.get(0), 4, "Server", new ChatComponentText("Server"), this, (Entity) null); // CraftBukkit
}
- public CustomFunctionData aL() {
-- return this.worldServer[0].A();
-+ return this.worlds.get(0).A(); // CraftBukkit
+ public boolean a() {
+@@ -1327,7 +1563,7 @@
}
- public void reload() {
- if (this.isMainThread()) {
- this.getPlayerList().savePlayers();
-- this.worldServer[0].getLootTableRegistry().reload();
-+ this.worlds.get(0).getLootTableRegistry().reload(); // CraftBukkit
- this.getAdvancementData().reload();
- this.aL().f();
- this.getPlayerList().reload();
-@@ -1251,4 +1470,11 @@
- }
+ public GameRules aQ() {
+- return this.worldServer[0].getGameRules();
++ return this.worlds.get(0).getGameRules(); // CraftBukkit
+ }
+ public BossBattleCustomData aR() {
+@@ -1341,4 +1577,11 @@
+ public void k(boolean flag) {
+ this.an = flag;
}
+
+ // CraftBukkit start
diff --git a/nms-patches/MobEffectList.patch b/nms-patches/MobEffectList.patch
index cfe1bc3b..22ff3c21 100644
--- a/nms-patches/MobEffectList.patch
+++ b/nms-patches/MobEffectList.patch
@@ -1,7 +1,7 @@
--- a/net/minecraft/server/MobEffectList.java
+++ b/net/minecraft/server/MobEffectList.java
-@@ -7,6 +7,11 @@
- import java.util.Map.Entry;
+@@ -8,6 +8,11 @@
+ import java.util.function.Supplier;
import javax.annotation.Nullable;
+// CraftBukkit start
@@ -12,7 +12,7 @@
public class MobEffectList {
public static final RegistryMaterials<MinecraftKey, MobEffectList> REGISTRY = new RegistryMaterials();
-@@ -24,7 +29,7 @@
+@@ -26,7 +31,7 @@
}
public static int getId(MobEffectList mobeffectlist) {
@@ -20,8 +20,8 @@
+ return MobEffectList.REGISTRY.a(mobeffectlist); // CraftBukkit - decompile error
}
- @Nullable
-@@ -51,11 +56,11 @@
+ protected MobEffectList(boolean flag, int i) {
+@@ -48,11 +53,11 @@
public void tick(EntityLiving entityliving, int i) {
if (this == MobEffects.REGENERATION) {
if (entityliving.getHealth() < entityliving.getMaxHealth()) {
@@ -35,7 +35,7 @@
}
} else if (this == MobEffects.WITHER) {
entityliving.damageEntity(DamageSource.WITHER, 1.0F);
-@@ -63,14 +68,25 @@
+@@ -60,14 +65,25 @@
((EntityHuman) entityliving).applyExhaustion(0.005F * (float) (i + 1));
} else if (this == MobEffects.SATURATION && entityliving instanceof EntityHuman) {
if (!entityliving.world.isClientSide) {
@@ -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.cc()) && (this != MobEffects.HARM || !entityliving.cc())) {
- if (this == MobEffects.HARM && !entityliving.cc() || this == MobEffects.HEAL && entityliving.cc()) {
+ } else if ((this != MobEffects.HEAL || entityliving.co()) && (this != MobEffects.HARM || !entityliving.co())) {
+ if (this == MobEffects.HARM && !entityliving.co() || this == MobEffects.HEAL && entityliving.co()) {
entityliving.damageEntity(DamageSource.MAGIC, (float) (6 << i));
}
} else {
@@ -63,7 +63,7 @@
}
}
-@@ -89,7 +105,7 @@
+@@ -88,7 +104,7 @@
}
} else {
j = (int) (d0 * (double) (4 << i) + 0.5D);
@@ -72,14 +72,15 @@
}
}
-@@ -208,5 +224,10 @@
- MobEffectList.REGISTRY.a(25, new MinecraftKey("levitation"), (new MobEffectList(true, 13565951)).c("effect.levitation").b(3, 2));
- MobEffectList.REGISTRY.a(26, new MinecraftKey("luck"), (new MobEffectList(false, 3381504)).c("effect.luck").b(5, 2).j().a(GenericAttributes.j, "03C3C89D-7037-4B42-869F-B146BCB64D2E", 1.0D, 0));
- MobEffectList.REGISTRY.a(27, new MinecraftKey("unluck"), (new MobEffectList(true, 12624973)).c("effect.unluck").b(6, 2).a(GenericAttributes.j, "CC5AF142-2BD2-4215-B636-2605AED11727", -1.0D, 0));
+@@ -217,6 +233,11 @@
+ a(28, "slow_falling", (new MobEffectList(false, 16773073)).b(8, 0).l());
+ a(29, "conduit_power", (new MobEffectList(false, 1950417)).b(9, 0).l());
+ a(30, "dolphins_grace", (new MobEffectList(false, 8954814)).b(10, 0).l());
+ // CraftBukkit start
+ for (Object effect : REGISTRY) {
+ org.bukkit.potion.PotionEffectType.registerPotionEffectType(new org.bukkit.craftbukkit.potion.CraftPotionEffectType((MobEffectList) effect));
+ }
+ // CraftBukkit end
}
- }
+
+ private static void a(int i, String s, MobEffectList mobeffectlist) {
diff --git a/nms-patches/MobSpawnerAbstract.patch b/nms-patches/MobSpawnerAbstract.patch
index 9f63bb2a..abcecdf9 100644
--- a/nms-patches/MobSpawnerAbstract.patch
+++ b/nms-patches/MobSpawnerAbstract.patch
@@ -1,39 +1,19 @@
--- a/net/minecraft/server/MobSpawnerAbstract.java
+++ b/net/minecraft/server/MobSpawnerAbstract.java
-@@ -12,13 +12,13 @@
- private MobSpawnerData spawnData = new MobSpawnerData();
- private double d;
- private double e;
-- private int minSpawnDelay = 200;
-- private int maxSpawnDelay = 800;
-- private int spawnCount = 4;
-+ public int minSpawnDelay = 200; // CraftBukkit private -> public
-+ public int maxSpawnDelay = 800; // CraftBukkit private -> public
-+ public int spawnCount = 4; // CraftBukkit private -> public
- private Entity i;
-- private int maxNearbyEntities = 6;
-- private int requiredPlayerRange = 16;
-- private int spawnRange = 4;
-+ public int maxNearbyEntities = 6; // CraftBukkit private -> public
-+ public int requiredPlayerRange = 16; // CraftBukkit private -> public
-+ public int spawnRange = 4; // CraftBukkit private -> public
-
- public MobSpawnerAbstract() {}
-
-@@ -32,6 +32,7 @@
- public void setMobName(@Nullable MinecraftKey minecraftkey) {
- if (minecraftkey != null) {
- this.spawnData.b().setString("id", minecraftkey.toString());
-+ this.mobs.clear(); // CraftBukkit - SPIGOT-3496, MC-92282
- }
+@@ -41,6 +41,7 @@
+ public void setMobName(EntityTypes<?> entitytypes) {
+ this.spawnData.b().setString("id", ((MinecraftKey) EntityTypes.REGISTRY.b(entitytypes)).toString());
++ this.mobs.clear(); // CraftBukkit - SPIGOT-3496, MC-92282
}
-@@ -102,7 +103,7 @@
- ((EntityInsentient) entity).prepare(world.D(new BlockPosition(entity)), (GroupDataEntity) null);
+
+ private boolean h() {
+@@ -110,7 +111,7 @@
+ ((EntityInsentient) entity).prepare(world.getDamageScaler(new BlockPosition(entity)), (GroupDataEntity) null, (NBTTagCompound) null);
}
-- ChunkRegionLoader.a(entity, world);
-+ ChunkRegionLoader.a(entity, world, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER); // CraftBukkit
+- ChunkRegionLoader.a(entity, (GeneratorAccess) world);
++ ChunkRegionLoader.a(entity, (GeneratorAccess) world, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER); // CraftBukkit
world.triggerEffect(2004, blockposition, 0);
if (entityinsentient != null) {
entityinsentient.doSpawnEffect();
diff --git a/nms-patches/NameReferencingFileConverter.patch b/nms-patches/NameReferencingFileConverter.patch
index c7bd0f7e..b2978b2f 100644
--- a/nms-patches/NameReferencingFileConverter.patch
+++ b/nms-patches/NameReferencingFileConverter.patch
@@ -1,6 +1,6 @@
--- a/net/minecraft/server/NameReferencingFileConverter.java
+++ b/net/minecraft/server/NameReferencingFileConverter.java
-@@ -88,8 +88,9 @@
+@@ -83,8 +83,9 @@
if (gameprofilebanlist.c().exists()) {
try {
gameprofilebanlist.load();
@@ -12,7 +12,7 @@
}
}
-@@ -146,8 +147,9 @@
+@@ -141,8 +142,9 @@
if (ipbanlist.c().exists()) {
try {
ipbanlist.load();
@@ -24,7 +24,7 @@
}
}
-@@ -187,8 +189,9 @@
+@@ -182,8 +184,9 @@
if (oplist.c().exists()) {
try {
oplist.load();
@@ -36,7 +36,7 @@
}
}
-@@ -231,8 +234,9 @@
+@@ -226,8 +229,9 @@
if (whitelist.c().exists()) {
try {
whitelist.load();
@@ -48,7 +48,7 @@
}
}
-@@ -350,6 +354,30 @@
+@@ -345,6 +349,30 @@
File file1 = new File(file2, s + ".dat");
File file3 = new File(file, s1 + ".dat");
@@ -79,7 +79,7 @@
NameReferencingFileConverter.b(file);
if (!file1.renameTo(file3)) {
throw new NameReferencingFileConverter.FileConversionException("Could not convert file for " + s, null);
-@@ -358,7 +386,7 @@
+@@ -353,7 +381,7 @@
private String a(GameProfile gameprofile) {
String s = null;
@@ -88,7 +88,7 @@
int i = astring.length;
for (int j = 0; j < i; ++j) {
-@@ -471,7 +499,7 @@
+@@ -466,7 +494,7 @@
private static File d(PropertyManager propertymanager) {
String s = propertymanager.getString("level-name", "world");
diff --git a/nms-patches/NetworkManager.patch b/nms-patches/NetworkManager.patch
index 6e69467c..5caf383c 100644
--- a/nms-patches/NetworkManager.patch
+++ b/nms-patches/NetworkManager.patch
@@ -1,15 +1,24 @@
--- a/net/minecraft/server/NetworkManager.java
+++ b/net/minecraft/server/NetworkManager.java
-@@ -114,7 +114,7 @@
- protected void a(ChannelHandlerContext channelhandlercontext, Packet<?> packet) throws Exception {
- if (this.channel.isOpen()) {
- try {
-- packet.a(this.m);
-+ ((Packet) packet).a(this.m); // CraftBukkit - decompile error
- } catch (CancelledPacketHandleException cancelledpackethandleexception) {
- ;
- }
-@@ -236,7 +236,7 @@
+@@ -103,7 +103,7 @@
+ if (flag) {
+ NetworkManager.g.debug("Failed to sent packet", throwable);
+ this.sendPacket(new PacketPlayOutKickDisconnect(chatmessage), (future) -> {
+- this.close(ichatbasecomponent);
++ this.close(chatmessage); // CraftBukkit - decompile error
+ });
+ this.stopReading();
+ } else {
+@@ -130,7 +130,7 @@
+ }
+
+ private static <T extends PacketListener> void a(Packet<T> packet, PacketListener packetlistener) {
+- packet.a(packetlistener);
++ packet.a((T) packetlistener); // CraftBukkit - decompile error
+ }
+
+ public void setPacketListener(PacketListener packetlistener) {
+@@ -241,7 +241,7 @@
public void close(IChatBaseComponent ichatbasecomponent) {
if (this.channel.isOpen()) {
@@ -18,7 +27,7 @@
this.n = ichatbasecomponent;
}
-@@ -313,7 +313,7 @@
+@@ -319,7 +319,7 @@
}
}
diff --git a/nms-patches/PacketDataSerializer.patch b/nms-patches/PacketDataSerializer.patch
index 4348da94..acfca3b0 100644
--- a/nms-patches/PacketDataSerializer.patch
+++ b/nms-patches/PacketDataSerializer.patch
@@ -35,9 +35,9 @@
+ if (itemstack.isEmpty() || itemstack.getItem() == null) { // CraftBukkit - NPE fix itemstack.getItem()
this.writeShort(-1);
} else {
- this.writeShort(Item.getId(itemstack.getItem()));
+ Item item = itemstack.getItem();
@@ -263,6 +265,11 @@
- ItemStack itemstack = new ItemStack(Item.getById(short0), b0, short1);
+ ItemStack itemstack = new ItemStack(Item.getById(short0), b0);
itemstack.setTag(this.j());
+ // CraftBukkit start
diff --git a/nms-patches/PacketStatusListener.patch b/nms-patches/PacketStatusListener.patch
index c8a9a902..4d53d146 100644
--- a/nms-patches/PacketStatusListener.patch
+++ b/nms-patches/PacketStatusListener.patch
@@ -16,7 +16,7 @@
+
public class PacketStatusListener implements PacketStatusInListener {
- private static final IChatBaseComponent a = new ChatComponentText("Status request has been handled.");
+ private static final IChatBaseComponent a = new ChatMessage("multiplayer.status.request_handled", new Object[0]);
@@ -19,8 +30,96 @@
this.networkManager.close(PacketStatusListener.a);
} else {
diff --git a/nms-patches/PathfinderGoalBreakDoor.patch b/nms-patches/PathfinderGoalBreakDoor.patch
index e51d1569..9f16c309 100644
--- a/nms-patches/PathfinderGoalBreakDoor.patch
+++ b/nms-patches/PathfinderGoalBreakDoor.patch
@@ -1,9 +1,9 @@
--- a/net/minecraft/server/PathfinderGoalBreakDoor.java
+++ b/net/minecraft/server/PathfinderGoalBreakDoor.java
-@@ -63,6 +63,12 @@
+@@ -44,6 +44,12 @@
}
- if (this.g == 240 && this.a.world.getDifficulty() == EnumDifficulty.HARD) {
+ if (this.d == 240 && this.a.world.getDifficulty() == EnumDifficulty.HARD) {
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityBreakDoorEvent(this.a, this.b.getX(), this.b.getY(), this.b.getZ()).isCancelled()) {
+ this.c();
@@ -12,4 +12,4 @@
+ // CraftBukkit end
this.a.world.setAir(this.b);
this.a.world.triggerEffect(1021, this.b, 0);
- this.a.world.triggerEffect(2001, this.b, Block.getId(this.c));
+ this.a.world.triggerEffect(2001, this.b, Block.getCombinedId(this.a.world.getType(this.b)));
diff --git a/nms-patches/PathfinderGoalBreed.patch b/nms-patches/PathfinderGoalBreed.patch
index 2c169110..1504f5e3 100644
--- a/nms-patches/PathfinderGoalBreed.patch
+++ b/nms-patches/PathfinderGoalBreed.patch
@@ -24,24 +24,24 @@
+ // CraftBukkit end
if (entityplayer != null) {
- entityplayer.b(StatisticList.C);
+ entityplayer.a(StatisticList.ANIMALS_BRED);
@@ -92,7 +105,7 @@
this.partner.resetLove();
entityageable.setAgeRaw(-24000);
entityageable.setPositionRotation(this.animal.locX, this.animal.locY, this.animal.locZ, 0.0F, 0.0F);
-- this.a.addEntity(entityageable);
-+ this.a.addEntity(entityageable, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - added SpawnReason
+- this.b.addEntity(entityageable);
++ this.b.addEntity(entityageable, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - added SpawnReason
Random random = this.animal.getRandom();
for (int i = 0; i < 7; ++i) {
@@ -107,7 +120,11 @@
}
- if (this.a.getGameRules().getBoolean("doMobLoot")) {
-- this.a.addEntity(new EntityExperienceOrb(this.a, this.animal.locX, this.animal.locY, this.animal.locZ, random.nextInt(7) + 1));
+ if (this.b.getGameRules().getBoolean("doMobLoot")) {
+- this.b.addEntity(new EntityExperienceOrb(this.b, this.animal.locX, this.animal.locY, this.animal.locZ, random.nextInt(7) + 1));
+ // CraftBukkit start - use event experience
+ if (experience > 0) {
-+ this.a.addEntity(new EntityExperienceOrb(this.a, this.animal.locX, this.animal.locY, this.animal.locZ, experience));
++ this.b.addEntity(new EntityExperienceOrb(this.b, this.animal.locX, this.animal.locY, this.animal.locZ, experience));
+ }
+ // CraftBukkit end
}
diff --git a/nms-patches/PathfinderGoalEatTile.patch b/nms-patches/PathfinderGoalEatTile.patch
index f3d98e5c..ecefdb18 100644
--- a/nms-patches/PathfinderGoalEatTile.patch
+++ b/nms-patches/PathfinderGoalEatTile.patch
@@ -1,34 +1,33 @@
--- a/net/minecraft/server/PathfinderGoalEatTile.java
+++ b/net/minecraft/server/PathfinderGoalEatTile.java
-@@ -3,6 +3,11 @@
- import com.google.common.base.Predicate;
- import com.google.common.base.Predicates;
+@@ -2,6 +2,10 @@
+
+ import java.util.function.Predicate;
+// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
-+import org.bukkit.Material;
+// CraftBukkit end
+
public class PathfinderGoalEatTile extends PathfinderGoal {
- private static final Predicate<IBlockData> b = BlockStatePredicate.a((Block) Blocks.TALLGRASS).a(BlockLongGrass.TYPE, Predicates.equalTo(BlockLongGrass.EnumTallGrassType.GRASS));
-@@ -50,7 +55,8 @@
- BlockPosition blockposition = new BlockPosition(this.c.locX, this.c.locY, this.c.locZ);
+ private static final Predicate<IBlockData> a = BlockStatePredicate.a(Blocks.GRASS);
+@@ -49,7 +53,8 @@
+ BlockPosition blockposition = new BlockPosition(this.b.locX, this.b.locY, this.b.locZ);
- if (PathfinderGoalEatTile.b.apply(this.d.getType(blockposition))) {
-- if (this.d.getGameRules().getBoolean("mobGriefing")) {
+ if (PathfinderGoalEatTile.a.test(this.c.getType(blockposition))) {
+- if (this.c.getGameRules().getBoolean("mobGriefing")) {
+ // CraftBukkit
-+ if (!CraftEventFactory.callEntityChangeBlockEvent(this.c, this.c.world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), Material.AIR, !this.d.getGameRules().getBoolean("mobGriefing")).isCancelled()) {
- this.d.setAir(blockposition, false);
++ if (!CraftEventFactory.callEntityChangeBlockEvent(this.b, blockposition, Blocks.AIR.getBlockData(), !this.c.getGameRules().getBoolean("mobGriefing")).isCancelled()) {
+ this.c.setAir(blockposition, false);
}
-@@ -59,7 +65,8 @@
+@@ -58,7 +63,8 @@
BlockPosition blockposition1 = blockposition.down();
- if (this.d.getType(blockposition1).getBlock() == Blocks.GRASS) {
-- if (this.d.getGameRules().getBoolean("mobGriefing")) {
+ if (this.c.getType(blockposition1).getBlock() == Blocks.GRASS_BLOCK) {
+- if (this.c.getGameRules().getBoolean("mobGriefing")) {
+ // CraftBukkit
-+ if (!CraftEventFactory.callEntityChangeBlockEvent(this.c, this.c.world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), Material.AIR, !this.d.getGameRules().getBoolean("mobGriefing")).isCancelled()) {
- this.d.triggerEffect(2001, blockposition1, Block.getId(Blocks.GRASS));
- this.d.setTypeAndData(blockposition1, Blocks.DIRT.getBlockData(), 2);
++ if (!CraftEventFactory.callEntityChangeBlockEvent(this.b, blockposition, Blocks.AIR.getBlockData(), !this.c.getGameRules().getBoolean("mobGriefing")).isCancelled()) {
+ this.c.triggerEffect(2001, blockposition1, Block.getCombinedId(Blocks.GRASS_BLOCK.getBlockData()));
+ this.c.setTypeAndData(blockposition1, Blocks.DIRT.getBlockData(), 2);
}
diff --git a/nms-patches/PathfinderGoalFollowOwner.patch b/nms-patches/PathfinderGoalFollowOwner.patch
index 039f15a9..df21289c 100644
--- a/nms-patches/PathfinderGoalFollowOwner.patch
+++ b/nms-patches/PathfinderGoalFollowOwner.patch
@@ -11,24 +11,24 @@
+
public class PathfinderGoalFollowOwner extends PathfinderGoal {
- private final EntityTameableAnimal d;
+ private final EntityTameableAnimal b;
@@ -73,7 +79,18 @@
for (int l = 0; l <= 4; ++l) {
for (int i1 = 0; i1 <= 4; ++i1) {
if ((l < 1 || i1 < 1 || l > 3 || i1 > 3) && this.a(i, j, k, l, i1)) {
-- this.d.setPositionRotation((double) ((float) (i + l) + 0.5F), (double) k, (double) ((float) (j + i1) + 0.5F), this.d.yaw, this.d.pitch);
+- this.b.setPositionRotation((double) ((float) (i + l) + 0.5F), (double) k, (double) ((float) (j + i1) + 0.5F), this.b.yaw, this.b.pitch);
+ // CraftBukkit start
-+ CraftEntity entity = this.d.getBukkitEntity();
-+ Location to = new Location(entity.getWorld(), (double) ((float) (i + l) + 0.5F), (double) k, (double) ((float) (j + i1) + 0.5F), this.d.yaw, this.d.pitch);
++ CraftEntity entity = this.b.getBukkitEntity();
++ Location to = new Location(entity.getWorld(), (double) ((float) (i + l) + 0.5F), (double) k, (double) ((float) (j + i1) + 0.5F), this.b.yaw, this.b.pitch);
+ EntityTeleportEvent event = new EntityTeleportEvent(entity, entity.getLocation(), to);
-+ this.d.world.getServer().getPluginManager().callEvent(event);
++ this.b.world.getServer().getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ return;
+ }
+ to = event.getTo();
+
-+ this.d.setPositionRotation(to.getX(), to.getY(), to.getZ(), to.getYaw(), to.getPitch());
++ this.b.setPositionRotation(to.getX(), to.getY(), to.getZ(), to.getYaw(), to.getPitch());
+ // CraftBukkit end
- this.g.p();
+ this.e.r();
return;
}
diff --git a/nms-patches/PathfinderGoalHorseTrap.patch b/nms-patches/PathfinderGoalHorseTrap.patch
index 0aa10ae0..47730fe0 100644
--- a/nms-patches/PathfinderGoalHorseTrap.patch
+++ b/nms-patches/PathfinderGoalHorseTrap.patch
@@ -18,7 +18,7 @@
}
@@ -42,7 +43,7 @@
- entityhorseskeleton.cW();
+ entityhorseskeleton.di();
entityhorseskeleton.setTamed(true);
entityhorseskeleton.setAgeRaw(0);
- entityhorseskeleton.world.addEntity(entityhorseskeleton);
diff --git a/nms-patches/PathfinderGoalHurtByTarget.patch b/nms-patches/PathfinderGoalHurtByTarget.patch
index bd1581bb..37d9cc80 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.bT();
+ this.b = this.e.cf();
this.h = 300;
@@ -66,6 +66,6 @@
}
diff --git a/nms-patches/PathfinderGoalMakeLove.patch b/nms-patches/PathfinderGoalMakeLove.patch
index d7269cd0..4ef924b9 100644
--- a/nms-patches/PathfinderGoalMakeLove.patch
+++ b/nms-patches/PathfinderGoalMakeLove.patch
@@ -3,21 +3,21 @@
@@ -80,6 +80,11 @@
private void i() {
- EntityVillager entityvillager = this.b.b((EntityAgeable) this.c);
+ EntityVillager entityvillager = this.a.b((EntityAgeable) this.b);
+ // CraftBukkit start - call EntityBreedEvent
-+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityBreedEvent(entityvillager, this.b, this.c, null, null, 0).isCancelled()) {
++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityBreedEvent(entityvillager, this.a, this.b, null, null, 0).isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
- this.c.setAgeRaw(6000);
this.b.setAgeRaw(6000);
+ this.a.setAgeRaw(6000);
@@ -87,7 +92,7 @@
- this.b.s(false);
+ this.a.v(false);
entityvillager.setAgeRaw(-24000);
- entityvillager.setPositionRotation(this.b.locX, this.b.locY, this.b.locZ, 0.0F, 0.0F);
-- this.d.addEntity(entityvillager);
-+ this.d.addEntity(entityvillager, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - added SpawnReason
- this.d.broadcastEntityEffect(entityvillager, (byte) 12);
+ entityvillager.setPositionRotation(this.a.locX, this.a.locY, this.a.locZ, 0.0F, 0.0F);
+- this.c.addEntity(entityvillager);
++ this.c.addEntity(entityvillager, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - added SpawnReason
+ this.c.broadcastEntityEffect(entityvillager, (byte) 12);
}
}
diff --git a/nms-patches/PathfinderGoalNearestAttackableTarget.patch b/nms-patches/PathfinderGoalNearestAttackableTarget.patch
index d1ceb69a..7ca3e982 100644
--- a/nms-patches/PathfinderGoalNearestAttackableTarget.patch
+++ b/nms-patches/PathfinderGoalNearestAttackableTarget.patch
@@ -1,15 +1,6 @@
--- a/net/minecraft/server/PathfinderGoalNearestAttackableTarget.java
+++ b/net/minecraft/server/PathfinderGoalNearestAttackableTarget.java
-@@ -35,7 +35,7 @@
- }
-
- public boolean apply(@Nullable Object object) {
-- return this.a((EntityLiving) object);
-+ return this.a((T) object); // CraftBukkit - fix decompile error
- }
- };
- }
-@@ -50,11 +50,11 @@
+@@ -44,11 +44,11 @@
return false;
} else {
Collections.sort(list, this.b);
@@ -23,7 +14,7 @@
@Nullable
public Double a(@Nullable EntityHuman entityhuman) {
ItemStack itemstack = entityhuman.getEquipment(EnumItemSlot.HEAD);
-@@ -74,10 +74,10 @@
+@@ -57,10 +57,10 @@
}
@Nullable
@@ -36,7 +27,7 @@
return this.d != null;
}
}
-@@ -87,7 +87,7 @@
+@@ -70,7 +70,7 @@
}
public void c() {
@@ -45,7 +36,7 @@
super.c();
}
-@@ -106,7 +106,7 @@
+@@ -89,7 +89,7 @@
return d0 < d1 ? -1 : (d0 > d1 ? 1 : 0);
}
diff --git a/nms-patches/PathfinderGoalNearestAttackableTargetInsentient.patch b/nms-patches/PathfinderGoalNearestAttackableTargetInsentient.patch
index 9dad5d79..dcb68d54 100644
--- a/nms-patches/PathfinderGoalNearestAttackableTargetInsentient.patch
+++ b/nms-patches/PathfinderGoalNearestAttackableTargetInsentient.patch
@@ -1,6 +1,6 @@
--- a/net/minecraft/server/PathfinderGoalNearestAttackableTargetInsentient.java
+++ b/net/minecraft/server/PathfinderGoalNearestAttackableTargetInsentient.java
-@@ -69,7 +69,7 @@
+@@ -62,7 +62,7 @@
}
public void c() {
diff --git a/nms-patches/PathfinderGoalPanic.patch b/nms-patches/PathfinderGoalPanic.patch
index f5990487..f7030cd7 100644
--- a/nms-patches/PathfinderGoalPanic.patch
+++ b/nms-patches/PathfinderGoalPanic.patch
@@ -10,6 +10,6 @@
+ return false;
+ }
+ // CraftBukkit end
- return !this.a.getNavigation().o();
+ return !this.a.getNavigation().q();
}
diff --git a/nms-patches/PathfinderGoalSit.patch b/nms-patches/PathfinderGoalSit.patch
index 80597cfe..403a27af 100644
--- a/nms-patches/PathfinderGoalSit.patch
+++ b/nms-patches/PathfinderGoalSit.patch
@@ -6,6 +6,6 @@
if (!this.entity.isTamed()) {
- return false;
+ return this.willSit && this.entity.getGoalTarget() == null; // CraftBukkit - Allow sitting for wild animals
- } else if (this.entity.isInWater()) {
+ } else if (this.entity.aq()) {
return false;
} else if (!this.entity.onGround) {
diff --git a/nms-patches/PathfinderGoalTargetNearestPlayer.patch b/nms-patches/PathfinderGoalTargetNearestPlayer.patch
index 0b3f5342..560d9330 100644
--- a/nms-patches/PathfinderGoalTargetNearestPlayer.patch
+++ b/nms-patches/PathfinderGoalTargetNearestPlayer.patch
@@ -1,6 +1,6 @@
--- a/net/minecraft/server/PathfinderGoalTargetNearestPlayer.java
+++ b/net/minecraft/server/PathfinderGoalTargetNearestPlayer.java
-@@ -92,7 +92,7 @@
+@@ -85,7 +85,7 @@
}
public void c() {
diff --git a/nms-patches/PathfinderGoalTempt.patch b/nms-patches/PathfinderGoalTempt.patch
index ec9ecd26..06dfabbc 100644
--- a/nms-patches/PathfinderGoalTempt.patch
+++ b/nms-patches/PathfinderGoalTempt.patch
@@ -1,19 +1,19 @@
--- a/net/minecraft/server/PathfinderGoalTempt.java
+++ b/net/minecraft/server/PathfinderGoalTempt.java
-@@ -2,6 +2,12 @@
+@@ -1,5 +1,12 @@
+ package net.minecraft.server;
- import com.google.common.collect.Sets;
- import java.util.Set;
+// CraftBukkit start
+import org.bukkit.craftbukkit.entity.CraftLivingEntity;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.event.entity.EntityTargetEvent;
+import org.bukkit.event.entity.EntityTargetLivingEntityEvent;
+// CraftBukkit end
-
++
public class PathfinderGoalTempt extends PathfinderGoal {
-@@ -12,7 +18,7 @@
+ private final EntityCreature a;
+@@ -9,7 +16,7 @@
private double e;
private double f;
private double g;
@@ -21,8 +21,8 @@
+ private EntityLiving target; // CraftBukkit
private int i;
private boolean j;
- private final Set<Item> k;
-@@ -39,7 +45,17 @@
+ private final RecipeItemStack k;
+@@ -36,7 +43,17 @@
return false;
} else {
this.target = this.a.world.findNearbyPlayer(this.a, 10.0D);
diff --git a/nms-patches/PathfinderGoalVillagerFarm.patch b/nms-patches/PathfinderGoalVillagerFarm.patch
index 2600cea0..19116f1a 100644
--- a/nms-patches/PathfinderGoalVillagerFarm.patch
+++ b/nms-patches/PathfinderGoalVillagerFarm.patch
@@ -3,15 +3,15 @@
@@ -40,7 +40,11 @@
Block block = iblockdata.getBlock();
- if (this.f == 0 && block instanceof BlockCrops && ((BlockCrops) block).z(iblockdata)) {
+ if (this.i == 0 && block instanceof BlockCrops && ((BlockCrops) block).w(iblockdata)) {
- world.setAir(blockposition, true);
+ // CraftBukkit start
-+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.c, blockposition, Blocks.AIR, 0).isCancelled()) {
++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.f, blockposition, Blocks.AIR.getBlockData()).isCancelled()) {
+ world.setAir(blockposition, true);
+ }
+ // CraftBukkit end
- } else if (this.f == 1 && iblockdata.getMaterial() == Material.AIR) {
- InventorySubcontainer inventorysubcontainer = this.c.dq();
+ } else if (this.i == 1 && iblockdata.isAir()) {
+ InventorySubcontainer inventorysubcontainer = this.f.dD();
@@ -49,19 +53,28 @@
boolean flag = false;
@@ -32,12 +32,12 @@
+ planted = Blocks.CARROTS;
flag = true;
} else if (itemstack.getItem() == Items.BEETROOT_SEEDS) {
-- world.setTypeAndData(blockposition, Blocks.BEETROOT.getBlockData(), 3);
-+ planted = Blocks.BEETROOT;
+- world.setTypeAndData(blockposition, Blocks.BEETROOTS.getBlockData(), 3);
++ planted = Blocks.BEETROOTS;
flag = true;
}
+
-+ if (planted != null && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.c, blockposition, planted, 0).isCancelled()) {
++ if (planted != null && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.f, blockposition, planted.getBlockData()).isCancelled()) {
+ world.setTypeAndData(blockposition, planted.getBlockData(), 3);
+ } else {
+ flag = false;
diff --git a/nms-patches/PlayerChunk.patch b/nms-patches/PlayerChunk.patch
index 2dc88641..e9e5e79c 100644
--- a/nms-patches/PlayerChunk.patch
+++ b/nms-patches/PlayerChunk.patch
@@ -1,6 +1,6 @@
--- a/net/minecraft/server/PlayerChunk.java
+++ b/net/minecraft/server/PlayerChunk.java
-@@ -8,32 +8,48 @@
+@@ -7,21 +7,36 @@
import javax.annotation.Nullable;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -25,6 +25,8 @@
private boolean done;
+ // CraftBukkit start - add fields
++ // You know the drill, https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse
++ // All may seem good at first, but there's deeper issues if you play for a bit
+ private boolean loadInProgress = false;
+ private Runnable loadedRunnable = new Runnable() {
+ public void run() {
@@ -37,71 +39,3 @@
public PlayerChunk(PlayerChunkMap playerchunkmap, int i, int j) {
this.playerChunkMap = playerchunkmap;
this.location = new ChunkCoordIntPair(i, j);
-- this.chunk = playerchunkmap.getWorld().getChunkProviderServer().getOrLoadChunkAt(i, j);
-+ // CraftBukkit start
-+ loadInProgress = true;
-+ this.chunk = playerchunkmap.getWorld().getChunkProviderServer().getChunkAt(i, j, loadedRunnable, false);
-+ // CraftBukkit end
- }
-
- public ChunkCoordIntPair a() {
- return this.location;
- }
-
-- public void a(EntityPlayer entityplayer) {
-+ public void a(final EntityPlayer entityplayer) { // CraftBukkit - added final to argument
- if (this.c.contains(entityplayer)) {
- PlayerChunk.a.debug("Failed to add player. {} already is in chunk {}, {}", entityplayer, Integer.valueOf(this.location.x), Integer.valueOf(this.location.z));
- } else {
-@@ -42,15 +58,32 @@
- }
-
- this.c.add(entityplayer);
-+ // CraftBukkit start - use async chunk io
-+ // if (this.done) {
-+ // this.sendChunk(entityplayer);
-+ // }
- if (this.done) {
- this.sendChunk(entityplayer);
- }
-+ // CraftBukkit end
-
- }
- }
-
- public void b(EntityPlayer entityplayer) {
- if (this.c.contains(entityplayer)) {
-+ // CraftBukkit start - If we haven't loaded yet don't load the chunk just so we can clean it up
-+ if (!this.done) {
-+ this.c.remove(entityplayer);
-+
-+ if (this.c.isEmpty()) {
-+ ChunkIOExecutor.dropQueuedChunkLoad(this.playerChunkMap.getWorld(), this.location.x, this.location.z, this.loadedRunnable);
-+ this.playerChunkMap.b(this);
-+ }
-+
-+ return;
-+ }
-+ // CraftBukkit end
- if (this.done) {
- entityplayer.playerConnection.sendPacket(new PacketPlayOutUnloadChunk(this.location.x, this.location.z));
- }
-@@ -67,11 +100,18 @@
- if (this.chunk != null) {
- return true;
- } else {
-+ /* CraftBukkit start
- if (flag) {
- this.chunk = this.playerChunkMap.getWorld().getChunkProviderServer().getChunkAt(this.location.x, this.location.z);
- } else {
- this.chunk = this.playerChunkMap.getWorld().getChunkProviderServer().getOrLoadChunkAt(this.location.x, this.location.z);
- }
-+ */
-+ if (!loadInProgress) {
-+ loadInProgress = true;
-+ this.chunk = playerChunkMap.getWorld().getChunkProviderServer().getChunkAt(this.location.x, this.location.z, loadedRunnable, flag);
-+ }
-+ // CraftBukkit end
-
- return this.chunk != null;
- }
diff --git a/nms-patches/PlayerChunkMap.patch b/nms-patches/PlayerChunkMap.patch
index 37c4c474..40a1805e 100644
--- a/nms-patches/PlayerChunkMap.patch
+++ b/nms-patches/PlayerChunkMap.patch
@@ -1,7 +1,7 @@
--- a/net/minecraft/server/PlayerChunkMap.java
+++ b/net/minecraft/server/PlayerChunkMap.java
@@ -15,6 +15,10 @@
- import java.util.Set;
+ import java.util.function.Predicate;
import javax.annotation.Nullable;
+// CraftBukkit start
@@ -10,8 +10,8 @@
+
public class PlayerChunkMap {
- private static final Predicate<EntityPlayer> a = new Predicate() {
-@@ -46,6 +50,7 @@
+ private static final Predicate<EntityPlayer> a = (entityplayer) -> {
+@@ -34,6 +38,7 @@
private long k;
private boolean l = true;
private boolean m = true;
@@ -19,7 +19,30 @@
public PlayerChunkMap(WorldServer worldserver) {
this.world = worldserver;
-@@ -169,7 +174,11 @@
+@@ -107,16 +112,18 @@
+
+ if (this.l && i % 4L == 0L) {
+ this.l = false;
+- Collections.sort(this.h, (playerchunk, playerchunk1) -> {
+- return ComparisonChain.start().compare(playerchunk.g(), playerchunk1.g()).result();
++ // CraftBukkit start
++ Collections.sort(this.h, (playerchunkx, playerchunk1x) -> {
++ return ComparisonChain.start().compare(playerchunkx.g(), playerchunk1x.g()).result();
+ });
+ }
+
+ if (this.m && i % 4L == 2L) {
+ this.m = false;
+- Collections.sort(this.g, (playerchunk, playerchunk1) -> {
+- return ComparisonChain.start().compare(playerchunk.g(), playerchunk1.g()).result();
++ Collections.sort(this.g, (playerchunkx, playerchunk1x) -> {
++ return ComparisonChain.start().compare(playerchunkx.g(), playerchunk1x.g()).result();
+ });
++ // CraftBukkit end
+ }
+
+ if (!this.h.isEmpty()) {
+@@ -141,7 +148,11 @@
break;
}
}
@@ -31,7 +54,7 @@
}
}
-@@ -231,6 +240,16 @@
+@@ -203,6 +214,16 @@
return playerchunk;
}
@@ -48,7 +71,7 @@
public void flagDirty(BlockPosition blockposition) {
int i = blockposition.getX() >> 4;
int j = blockposition.getZ() >> 4;
-@@ -249,12 +268,22 @@
+@@ -221,12 +242,22 @@
entityplayer.d = entityplayer.locX;
entityplayer.e = entityplayer.locZ;
@@ -72,7 +95,7 @@
this.managedPlayers.add(entityplayer);
this.e();
}
-@@ -298,11 +327,14 @@
+@@ -270,11 +301,14 @@
int j1 = i - k;
int k1 = j - l;
@@ -88,7 +111,7 @@
}
if (!this.a(l1 - j1, i2 - k1, i, j, i1)) {
-@@ -318,6 +350,13 @@
+@@ -290,6 +324,13 @@
entityplayer.d = entityplayer.locX;
entityplayer.e = entityplayer.locZ;
this.e();
@@ -102,7 +125,7 @@
}
}
}
-@@ -402,4 +441,47 @@
+@@ -374,4 +415,47 @@
}
}
diff --git a/nms-patches/PlayerConnection.patch b/nms-patches/PlayerConnection.patch
index e67b4538..f5611f32 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
-@@ -15,6 +15,49 @@
+@@ -15,6 +15,50 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -14,6 +14,7 @@
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.craftbukkit.util.CraftChatMessage;
++import org.bukkit.craftbukkit.util.CraftMagicNumbers;
+import org.bukkit.craftbukkit.util.LazyPlayerSet;
+import org.bukkit.craftbukkit.util.Waitable;
+import org.bukkit.entity.Player;
@@ -50,7 +51,7 @@
public class PlayerConnection implements PacketListenerPlayIn, ITickable {
private static final Logger LOGGER = LogManager.getLogger();
-@@ -25,7 +68,10 @@
+@@ -25,7 +69,10 @@
private long f;
private boolean g;
private long h;
@@ -62,7 +63,7 @@
private int j;
private final IntHashMap<Short> k = new IntHashMap();
private double l;
-@@ -58,7 +104,34 @@
+@@ -57,7 +104,33 @@
networkmanager.setPacketListener(this);
this.player = entityplayer;
entityplayer.playerConnection = this;
@@ -92,24 +93,23 @@
+ public CraftPlayer getPlayer() {
+ return (this.player == null) ? null : (CraftPlayer) this.player.getBukkitEntity();
}
-+ private final static HashSet<Integer> invalidItems = new HashSet<Integer>(java.util.Arrays.asList(8, 9, 10, 11, 26, 34, 36, 43, 51, 55, 59, 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() {
+ public void X_() {
this.syncPosition();
-@@ -104,7 +177,7 @@
+@@ -103,7 +176,7 @@
this.minecraftServer.methodProfiler.a("keepAlive");
- long i = this.d();
+ long i = SystemUtils.b();
- if (i - this.f >= 15000L) {
+ if (i - this.f >= 25000L) { // CraftBukkit
if (this.g) {
this.disconnect(new ChatMessage("disconnect.timeout", new Object[0]));
} else {
-@@ -116,15 +189,21 @@
+@@ -115,15 +188,21 @@
}
- this.minecraftServer.methodProfiler.b();
+ this.minecraftServer.methodProfiler.e();
+ // CraftBukkit start
+ for (int spam; (spam = this.chatThrottle) > 0 && !chatSpamField.compareAndSet(this, spam, spam - 1); ) ;
+ /* Use thread-safe field access instead
@@ -123,22 +123,18 @@
--this.j;
}
- if (this.player.J() > 0L && this.minecraftServer.getIdleTimeout() > 0 && MinecraftServer.aw() - this.player.J() > (long) (this.minecraftServer.getIdleTimeout() * 1000 * 60)) {
+ if (this.player.F() > 0L && this.minecraftServer.getIdleTimeout() > 0 && SystemUtils.b() - this.player.F() > (long) (this.minecraftServer.getIdleTimeout() * 1000 * 60)) {
+ this.player.resetIdleTimer(); // CraftBukkit - SPIGOT-854
this.disconnect(new ChatMessage("multiplayer.disconnect.idling", new Object[0]));
}
-@@ -143,18 +222,48 @@
+@@ -142,16 +221,46 @@
return this.networkManager;
}
-- public void disconnect(final IChatBaseComponent ichatbasecomponent) {
-- this.networkManager.sendPacket(new PacketPlayOutKickDisconnect(ichatbasecomponent), new GenericFutureListener() {
-- public void operationComplete(Future<? super Void> future) throws Exception {
-- PlayerConnection.this.networkManager.close(ichatbasecomponent);
+ // CraftBukkit start
+ @Deprecated
-+ public void disconnect(IChatBaseComponent ichatbasecomponent) {
+ public void disconnect(IChatBaseComponent ichatbasecomponent) {
+ disconnect(CraftChatMessage.fromComponent(ichatbasecomponent, EnumChatFormat.WHITE));
+ }
+ // CraftBukkit end
@@ -163,31 +159,28 @@
+ // Send the possibly modified leave message
+ s = event.getReason();
+ // CraftBukkit end
-+ final ChatComponentText chatcomponenttext = new ChatComponentText(s);
++ final ChatComponentText ichatbasecomponent = new ChatComponentText(s);
+
-+ this.networkManager.sendPacket(new PacketPlayOutKickDisconnect(chatcomponenttext), new GenericFutureListener() {
-+ public void operationComplete(Future future) throws Exception { // CraftBukkit - decompile error
-+ PlayerConnection.this.networkManager.close(chatcomponenttext);
- }
- }, new GenericFutureListener[0]);
-+ this.a(chatcomponenttext); // CraftBukkit - fire quit instantly
+ this.networkManager.sendPacket(new PacketPlayOutKickDisconnect(ichatbasecomponent), (future) -> {
+ this.networkManager.close(ichatbasecomponent);
+ });
++ this.a(ichatbasecomponent); // CraftBukkit - fire quit instantly
this.networkManager.stopReading();
-- Futures.getUnchecked(this.minecraftServer.postToMainThread(new Runnable() {
+ MinecraftServer minecraftserver = this.minecraftServer;
+ NetworkManager networkmanager = this.networkManager;
+
+ this.networkManager.getClass();
+- Futures.getUnchecked(minecraftserver.postToMainThread(networkmanager::handleDisconnection));
+ // CraftBukkit - Don't wait
-+ this.minecraftServer.postToMainThread(new Runnable() {
- public void run() {
- PlayerConnection.this.networkManager.handleDisconnection();
- }
-- }));
-+ });
++ minecraftserver.postToMainThread(networkmanager::handleDisconnection);
}
public void a(PacketPlayInSteerVehicle packetplayinsteervehicle) {
-@@ -193,7 +302,34 @@
+@@ -190,7 +299,34 @@
double d9 = entity.motX * entity.motX + entity.motY * entity.motY + entity.motZ * entity.motZ;
double d10 = d6 * d6 + d7 * d7 + d8 * d8;
-- if (d10 - d9 > 100.0D && (!this.minecraftServer.R() || !this.minecraftServer.Q().equals(entity.getName()))) {
+- if (d10 - d9 > 100.0D && (!this.minecraftServer.J() || !this.minecraftServer.I().equals(entity.getDisplayName().getString()))) {
+
+ // CraftBukkit start - handle custom speeds and skipped ticks
+ this.allowedPlayerTicks += (System.currentTimeMillis() / 50) - this.lastTick;
@@ -206,7 +199,7 @@
+ } else {
+ allowedPlayerTicks = 20;
+ }
-+ float speed;
++ double speed;
+ if (player.abilities.isFlying) {
+ speed = player.abilities.flySpeed * 20f;
+ } else {
@@ -214,12 +207,12 @@
+ }
+ speed *= 2f; // TODO: Get the speed of the vehicle instead of the player
+
-+ 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()))) {
++ if (d10 - d9 > Math.max(100.0D, Math.pow((double) (10.0F * (float) i * speed), 2)) && (!this.minecraftServer.J() || !this.minecraftServer.I().equals(entity.getDisplayName().getString()))) {
+ // CraftBukkit end
- PlayerConnection.LOGGER.warn("{} (vehicle of {}) moved too quickly! {},{},{}", entity.getName(), this.player.getName(), Double.valueOf(d6), Double.valueOf(d7), Double.valueOf(d8));
+ PlayerConnection.LOGGER.warn("{} (vehicle of {}) moved too quickly! {},{},{}", entity.getDisplayName().getString(), this.player.getDisplayName().getString(), Double.valueOf(d6), Double.valueOf(d7), Double.valueOf(d8));
this.networkManager.sendPacket(new PacketPlayOutVehicleMove(entity));
return;
-@@ -231,6 +367,62 @@
+@@ -228,6 +364,62 @@
return;
}
@@ -281,17 +274,62 @@
+
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.c(entity.getBoundingBox().g(0.0625D).b(0.0D, -0.55D, 0.0D));
-@@ -244,7 +436,7 @@
+ this.D = d11 >= -0.03125D && !this.minecraftServer.getAllowFlight() && !worldserver.a(entity.getBoundingBox().g(0.0625D).b(0.0D, -0.55D, 0.0D));
+@@ -241,7 +433,7 @@
public void a(PacketPlayInTeleportAccept packetplayinteleportaccept) {
- PlayerConnectionUtils.ensureMainThread(packetplayinteleportaccept, this, this.player.x());
-- if (packetplayinteleportaccept.a() == this.teleportAwait) {
-+ if (packetplayinteleportaccept.a() == this.teleportAwait && this.teleportPos != null) { // CraftBukkit
+ PlayerConnectionUtils.ensureMainThread(packetplayinteleportaccept, this, this.player.getWorldServer());
+- if (packetplayinteleportaccept.b() == this.teleportAwait) {
++ if (packetplayinteleportaccept.b() == this.teleportAwait && this.teleportPos != null) { // CraftBukkit
this.player.setLocation(this.teleportPos.x, this.teleportPos.y, this.teleportPos.z, this.player.yaw, this.player.pitch);
- if (this.player.L()) {
+ if (this.player.H()) {
this.o = this.teleportPos.x;
-@@ -289,7 +481,7 @@
+@@ -287,10 +479,16 @@
+
+ public void a(PacketPlayInTabComplete packetplayintabcomplete) {
+ PlayerConnectionUtils.ensureMainThread(packetplayintabcomplete, this, this.player.getWorldServer());
++ // CraftBukkit start
++ if (chatSpamField.addAndGet(this, 5) > 500 && !this.minecraftServer.getPlayerList().isOp(this.player.getProfile())) {
++ this.disconnect(new ChatMessage("disconnect.spam", new Object[0]));
++ return;
++ }
++ // CraftBukkit end
+ ParseResults parseresults = this.minecraftServer.getCommandDispatcher().a().parse(packetplayintabcomplete.c(), this.player.getCommandListener());
+
+ this.minecraftServer.getCommandDispatcher().a().getCompletionSuggestions(parseresults).thenAccept((suggestions) -> {
+- this.networkManager.sendPacket(new PacketPlayOutTabComplete(packetplayintabcomplete.b(), suggestions));
++ this.networkManager.sendPacket(new PacketPlayOutTabComplete(packetplayintabcomplete.b(), (Suggestions) suggestions)); // CraftBukkit - decompile error
+ });
+ }
+
+@@ -484,6 +682,14 @@
+ }
+
+ public void a(PacketPlayInBEdit packetplayinbedit) {
++ // CraftBukkit start
++ PlayerConnectionUtils.ensureMainThread(packetplayinbedit, this, this.player.getWorldServer());
++ if (this.lastBookTick + 20 > MinecraftServer.currentTick) {
++ this.disconnect("Book edited too quickly!");
++ return;
++ }
++ this.lastBookTick = MinecraftServer.currentTick;
++ // CraftBukkit end
+ ItemStack itemstack = packetplayinbedit.b();
+
+ if (!itemstack.isEmpty()) {
+@@ -508,9 +714,10 @@
+ }
+
+ itemstack2.a("pages", (NBTBase) nbttaglist);
+- this.player.setSlot(EnumItemSlot.MAINHAND, itemstack2);
++ CraftEventFactory.handleEditBookEvent(player, itemstack2); // CraftBukkit
+ } else {
+ itemstack1.a("pages", (NBTBase) itemstack.getTag().getList("pages", 8));
++ CraftEventFactory.handleEditBookEvent(player, itemstack1); // CraftBukkit
+ }
+ }
+
+@@ -550,7 +757,7 @@
} else {
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
@@ -300,7 +338,7 @@
if (this.e == 0) {
this.syncPosition();
}
-@@ -299,13 +491,21 @@
+@@ -560,13 +767,21 @@
this.A = this.e;
this.a(this.teleportPos.x, this.teleportPos.y, this.teleportPos.z, this.player.yaw, this.player.pitch);
}
@@ -323,7 +361,7 @@
double d0 = this.player.locX;
double d1 = this.player.locY;
double d2 = this.player.locZ;
-@@ -330,15 +530,33 @@
+@@ -591,15 +806,33 @@
++this.receivedMovePackets;
int i = this.receivedMovePackets - this.processedMovePackets;
@@ -334,7 +372,7 @@
+ this.lastTick = (int) (System.currentTimeMillis() / 50);
+
+ if (i > Math.max(this.allowedPlayerTicks, 5)) {
- PlayerConnection.LOGGER.debug("{} is sending move packets too frequently ({} packets since last tick)", this.player.getName(), Integer.valueOf(i));
+ PlayerConnection.LOGGER.debug("{} is sending move packets too frequently ({} packets since last tick)", this.player.getDisplayName().getString(), Integer.valueOf(i));
i = 1;
}
@@ -343,23 +381,23 @@
+ } else {
+ allowedPlayerTicks = 20;
+ }
-+ float speed;
++ double speed;
+ if (player.abilities.isFlying) {
+ speed = player.abilities.flySpeed * 20f;
+ } else {
+ speed = player.abilities.walkSpeed * 10f;
+ }
+
- if (!this.player.L() && (!this.player.x().getGameRules().getBoolean("disableElytraMovementCheck") || !this.player.cP())) {
- float f2 = this.player.cP() ? 300.0F : 100.0F;
+ if (!this.player.H() && (!this.player.getWorldServer().getGameRules().getBoolean("disableElytraMovementCheck") || !this.player.db())) {
+ float f2 = this.player.db() ? 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(f2, Math.pow((double) (10.0F * (float) i * speed), 2)) && (!this.minecraftServer.R() || !this.minecraftServer.Q().equals(this.player.getName()))) {
+- if (d11 - d10 > (double) (f2 * (float) i) && (!this.minecraftServer.J() || !this.minecraftServer.I().equals(this.player.getProfile().getName()))) {
++ if (d11 - d10 > Math.max(f2, Math.pow((double) (10.0F * (float) i * speed), 2)) && (!this.minecraftServer.J() || !this.minecraftServer.I().equals(this.player.getProfile().getName()))) {
+ // CraftBukkit end
- PlayerConnection.LOGGER.warn("{} moved too quickly! {},{},{}", this.player.getName(), Double.valueOf(d7), Double.valueOf(d8), Double.valueOf(d9));
+ PlayerConnection.LOGGER.warn("{} moved too quickly! {},{},{}", this.player.getDisplayName().getString(), 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;
-@@ -384,6 +602,69 @@
+@@ -645,6 +878,69 @@
}
}
@@ -428,8 +466,8 @@
+
this.B = d12 >= -0.03125D;
this.B &= !this.minecraftServer.getAllowFlight() && !this.player.abilities.canFly;
- this.B &= !this.player.hasEffect(MobEffects.LEVITATION) && !this.player.cP() && !worldserver.c(this.player.getBoundingBox().g(0.0625D).b(0.0D, -0.55D, 0.0D));
-@@ -401,10 +682,76 @@
+ this.B &= !this.player.hasEffect(MobEffects.LEVITATION) && !this.player.db() && !worldserver.a(this.player.getBoundingBox().g(0.0625D).b(0.0D, -0.55D, 0.0D));
+@@ -662,10 +958,76 @@
}
public void a(double d0, double d1, double d2, float f, float f1) {
@@ -507,8 +545,8 @@
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;
-@@ -421,6 +768,14 @@
- f3 = f1 + this.player.pitch;
+@@ -677,6 +1039,14 @@
+ this.teleportAwait = 0;
}
+ // CraftBukkit start - update last location
@@ -519,35 +557,45 @@
+ this.lastPitch = f3;
+ // CraftBukkit end
+
- if (++this.teleportAwait == Integer.MAX_VALUE) {
- this.teleportAwait = 0;
- }
-@@ -432,6 +787,7 @@
+ this.A = this.e;
+ this.player.setLocation(d0, d1, d2, f, f1);
+ this.player.playerConnection.sendPacket(new PacketPlayOutPosition(d0 - d3, d1 - d4, d2 - d5, f - f2, f1 - f3, set, this.teleportAwait));
+@@ -684,6 +1054,7 @@
public void a(PacketPlayInBlockDig packetplayinblockdig) {
- PlayerConnectionUtils.ensureMainThread(packetplayinblockdig, this, this.player.x());
+ PlayerConnectionUtils.ensureMainThread(packetplayinblockdig, this, this.player.getWorldServer());
+ if (this.player.isFrozen()) return; // CraftBukkit
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
- BlockPosition blockposition = packetplayinblockdig.a();
+ BlockPosition blockposition = packetplayinblockdig.b();
-@@ -441,7 +797,15 @@
+@@ -693,14 +1064,46 @@
if (!this.player.isSpectator()) {
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(itemstack), CraftItemStack.asBukkitCopy(this.player.b(EnumHand.MAIN_HAND)));
+- this.player.a(EnumHand.MAIN_HAND, itemstack);
++ // CraftBukkit start - inspiration taken from DispenserRegistry (See SpigotCraft#394)
++ CraftItemStack mainHand = CraftItemStack.asCraftMirror(itemstack);
++ CraftItemStack offHand = CraftItemStack.asCraftMirror(this.player.b(EnumHand.MAIN_HAND));
++ PlayerSwapHandItemsEvent swapItemsEvent = new PlayerSwapHandItemsEvent(getPlayer(), mainHand.clone(), offHand.clone());
+ this.server.getPluginManager().callEvent(swapItemsEvent);
+ if (swapItemsEvent.isCancelled()) {
+ return;
+ }
-+ itemstack = CraftItemStack.asNMSCopy(swapItemsEvent.getMainHandItem());
-+ this.player.a(EnumHand.OFF_HAND, CraftItemStack.asNMSCopy(swapItemsEvent.getOffHandItem()));
++ if (swapItemsEvent.getOffHandItem().equals(offHand)) {
++ this.player.a(EnumHand.OFF_HAND, this.player.b(EnumHand.MAIN_HAND));
++ } else {
++ this.player.a(EnumHand.OFF_HAND, CraftItemStack.asNMSCopy(swapItemsEvent.getOffHandItem()));
++ }
++ if (swapItemsEvent.getMainHandItem().equals(mainHand)) {
++ this.player.a(EnumHand.MAIN_HAND, itemstack);
++ } else {
++ this.player.a(EnumHand.MAIN_HAND, CraftItemStack.asNMSCopy(swapItemsEvent.getMainHandItem()));
++ }
+ // CraftBukkit end
- this.player.a(EnumHand.MAIN_HAND, itemstack);
}
-@@ -449,6 +813,21 @@
+ return;
case DROP_ITEM:
if (!this.player.isSpectator()) {
@@ -569,12 +617,12 @@
this.player.a(false);
}
-@@ -482,7 +861,15 @@
+@@ -734,7 +1137,15 @@
if (!this.minecraftServer.a(worldserver, blockposition, this.player) && worldserver.getWorldBorder().a(blockposition)) {
- this.player.playerInteractManager.a(blockposition, packetplayinblockdig.b());
+ this.player.playerInteractManager.a(blockposition, packetplayinblockdig.c());
} else {
+ // CraftBukkit start - fire PlayerInteractEvent
-+ CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, blockposition, packetplayinblockdig.b(), this.player.inventory.getItemInHand(), EnumHand.MAIN_HAND);
++ CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, blockposition, packetplayinblockdig.c(), this.player.inventory.getItemInHand(), EnumHand.MAIN_HAND);
this.player.playerConnection.sendPacket(new PacketPlayOutBlockChange(worldserver, blockposition));
+ // Update any tile entity data for this block
+ TileEntity tileentity = worldserver.getTileEntity(blockposition);
@@ -584,8 +632,8 @@
+ // CraftBukkit end
}
} else {
- if (packetplayinblockdig.c() == PacketPlayInBlockDig.EnumPlayerDigType.STOP_DESTROY_BLOCK) {
-@@ -502,10 +889,12 @@
+ if (packetplayinblockdig.d() == PacketPlayInBlockDig.EnumPlayerDigType.STOP_DESTROY_BLOCK) {
+@@ -754,10 +1165,12 @@
default:
throw new IllegalArgumentException("Invalid player action");
}
@@ -593,14 +641,14 @@
}
public void a(PacketPlayInUseItem packetplayinuseitem) {
- PlayerConnectionUtils.ensureMainThread(packetplayinuseitem, this, this.player.x());
+ PlayerConnectionUtils.ensureMainThread(packetplayinuseitem, this, this.player.getWorldServer());
+ if (this.player.isFrozen()) return; // CraftBukkit
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
- EnumHand enumhand = packetplayinuseitem.c();
+ EnumHand enumhand = packetplayinuseitem.d();
ItemStack itemstack = this.player.b(enumhand);
-@@ -519,6 +908,13 @@
- chatmessage.getChatModifier().setColor(EnumChatFormat.RED);
- this.player.playerConnection.sendPacket(new PacketPlayOutChat(chatmessage, ChatMessageType.GAME_INFO));
+@@ -770,6 +1183,13 @@
+
+ this.player.playerConnection.sendPacket(new PacketPlayOutChat(ichatbasecomponent, ChatMessageType.GAME_INFO));
} 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();
@@ -609,16 +657,16 @@
+ return;
+ }
+ // CraftBukkit end
- this.player.playerInteractManager.a(this.player, worldserver, itemstack, enumhand, blockposition, enumdirection, packetplayinuseitem.d(), packetplayinuseitem.e(), packetplayinuseitem.f());
+ this.player.playerInteractManager.a(this.player, worldserver, itemstack, enumhand, blockposition, enumdirection, packetplayinuseitem.e(), packetplayinuseitem.f(), packetplayinuseitem.g());
}
-@@ -528,13 +924,52 @@
+@@ -779,13 +1199,52 @@
public void a(PacketPlayInBlockPlace packetplayinblockplace) {
- PlayerConnectionUtils.ensureMainThread(packetplayinblockplace, this, this.player.x());
+ PlayerConnectionUtils.ensureMainThread(packetplayinblockplace, this, this.player.getWorldServer());
+ if (this.player.isFrozen()) return; // CraftBukkit
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
- EnumHand enumhand = packetplayinblockplace.a();
+ EnumHand enumhand = packetplayinblockplace.b();
ItemStack itemstack = this.player.b(enumhand);
this.player.resetIdleTimer();
@@ -641,7 +689,7 @@
+ float f8 = f3 * f5;
+ double d3 = player.playerInteractManager.getGameMode()== EnumGamemode.CREATIVE ? 5.0D : 4.5D;
+ Vec3D vec3d1 = vec3d.add((double) f7 * d3, (double) f6 * d3, (double) f8 * d3);
-+ MovingObjectPosition movingobjectposition = this.player.world.rayTrace(vec3d, vec3d1, false);
++ MovingObjectPosition movingobjectposition = this.player.world.rayTrace(vec3d, vec3d1);
+
+ boolean cancelled;
+ if (movingobjectposition == null || movingobjectposition.type != MovingObjectPosition.EnumMovingObjectType.BLOCK) {
@@ -666,7 +714,7 @@
}
}
-@@ -545,8 +980,8 @@
+@@ -796,8 +1255,8 @@
WorldServer[] aworldserver = this.minecraftServer.worldServer;
int i = aworldserver.length;
@@ -677,38 +725,16 @@
if (worldserver != null) {
entity = packetplayinspectate.a(worldserver);
-@@ -559,6 +994,8 @@
+@@ -808,7 +1267,7 @@
+ }
+
if (entity != null) {
- this.player.setSpectatorTarget(this.player);
- this.player.stopRiding();
-+
-+ /* CraftBukkit start - replace with bukkit handling for multi-world
- if (entity.world == this.player.world) {
- this.player.enderTeleportTo(entity.locX, entity.locY, entity.locZ);
- } else {
-@@ -584,12 +1021,20 @@
- this.minecraftServer.getPlayerList().b(this.player, worldserver2);
- this.minecraftServer.getPlayerList().updateClient(this.player);
- }
-+ */
-+ this.player.getBukkitEntity().teleport(entity.getBukkitEntity(), PlayerTeleportEvent.TeleportCause.SPECTATE);
-+ // CraftBukkit end
+- this.player.a((WorldServer) entity.world, entity.locX, entity.locY, entity.locZ, entity.yaw, entity.pitch);
++ this.player.a((WorldServer) entity.world, entity.locX, entity.locY, entity.locZ, entity.yaw, entity.pitch, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.SPECTATE); // CraftBukkit
}
}
- }
-
-- public void a(PacketPlayInResourcePackStatus packetplayinresourcepackstatus) {}
-+ // CraftBukkit start
-+ public void a(PacketPlayInResourcePackStatus packetplayinresourcepackstatus) {
-+ PlayerConnectionUtils.ensureMainThread(packetplayinresourcepackstatus, this, this.player.x());
-+ this.server.getPluginManager().callEvent(new PlayerResourcePackStatusEvent(getPlayer(), PlayerResourcePackStatusEvent.Status.values()[packetplayinresourcepackstatus.status.ordinal()]));
-+ }
-+ // CraftBukkit end
-
- public void a(PacketPlayInBoatMove packetplayinboatmove) {
- PlayerConnectionUtils.ensureMainThread(packetplayinboatmove, this, this.player.x());
-@@ -602,14 +1047,29 @@
+@@ -827,11 +1286,26 @@
}
public void a(IChatBaseComponent ichatbasecomponent) {
@@ -719,27 +745,24 @@
+ this.processedDisconnect = true;
+ }
+ // CraftBukkit end
- PlayerConnection.LOGGER.info("{} lost connection: {}", this.player.getName(), ichatbasecomponent.toPlainText());
+ PlayerConnection.LOGGER.info("{} lost connection: {}", this.player.getDisplayName().getString(), ichatbasecomponent.getString());
+ // CraftBukkit start - Replace vanilla quit message handling with our own.
+ /*
- this.minecraftServer.aD();
- ChatMessage chatmessage = new ChatMessage("multiplayer.player.left", new Object[] { this.player.getScoreboardDisplayName()});
-
- chatmessage.getChatModifier().setColor(EnumChatFormat.YELLOW);
- this.minecraftServer.getPlayerList().sendMessage(chatmessage);
+ this.minecraftServer.av();
+ this.minecraftServer.getPlayerList().sendMessage((new ChatMessage("multiplayer.player.left", new Object[] { this.player.getScoreboardDisplayName()})).a(EnumChatFormat.YELLOW));
+ */
+
- this.player.s();
+ this.player.n();
- this.minecraftServer.getPlayerList().disconnect(this.player);
+ String quitMessage = this.minecraftServer.getPlayerList().disconnect(this.player);
+ if ((quitMessage != null) && (quitMessage.length() > 0)) {
+ this.minecraftServer.getPlayerList().sendMessage(CraftChatMessage.fromString(quitMessage));
+ }
+ // CraftBukkit end
- if (this.minecraftServer.R() && this.player.getName().equals(this.minecraftServer.Q())) {
+ if (this.minecraftServer.J() && this.player.getDisplayName().getString().equals(this.minecraftServer.I())) {
PlayerConnection.LOGGER.info("Stopping singleplayer server as player logged out");
this.minecraftServer.safeShutdown();
-@@ -631,6 +1091,15 @@
+@@ -857,6 +1331,15 @@
}
}
@@ -753,15 +776,15 @@
+ // CraftBukkit end
+
try {
- this.networkManager.sendPacket(packet);
+ this.networkManager.sendPacket(packet, genericfuturelistener);
} catch (Throwable throwable) {
-@@ -652,17 +1121,37 @@
+@@ -872,17 +1355,37 @@
public void a(PacketPlayInHeldItemSlot packetplayinhelditemslot) {
- PlayerConnectionUtils.ensureMainThread(packetplayinhelditemslot, this, this.player.x());
+ PlayerConnectionUtils.ensureMainThread(packetplayinhelditemslot, this, this.player.getWorldServer());
+ 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());
+ if (packetplayinhelditemslot.b() >= 0 && packetplayinhelditemslot.b() < PlayerInventory.getHotbarSize()) {
++ PlayerItemHeldEvent event = new PlayerItemHeldEvent(this.getPlayer(), this.player.inventory.itemInHandIndex, packetplayinhelditemslot.b());
+ this.server.getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ this.sendPacket(new PacketPlayOutHeldItemSlot(this.player.inventory.itemInHandIndex));
@@ -769,16 +792,16 @@
+ return;
+ }
+ // CraftBukkit end
- this.player.inventory.itemInHandIndex = packetplayinhelditemslot.a();
+ this.player.inventory.itemInHandIndex = packetplayinhelditemslot.b();
this.player.resetIdleTimer();
} else {
- PlayerConnection.LOGGER.warn("{} tried to set an invalid carried item", this.player.getName());
+ PlayerConnection.LOGGER.warn("{} tried to set an invalid carried item", this.player.getDisplayName().getString());
+ this.disconnect("Nope!"); // CraftBukkit
}
}
public void a(PacketPlayInChat packetplayinchat) {
-- PlayerConnectionUtils.ensureMainThread(packetplayinchat, this, this.player.x());
+- PlayerConnectionUtils.ensureMainThread(packetplayinchat, this, this.player.getWorldServer());
- if (this.player.getChatFlags() == EntityHuman.EnumChatVisibility.HIDDEN) {
+ // CraftBukkit start - async chat
+ // SPIGOT-3638
@@ -786,16 +809,16 @@
+ return;
+ }
+
-+ boolean isSync = packetplayinchat.a().startsWith("/");
-+ if (packetplayinchat.a().startsWith("/")) {
-+ PlayerConnectionUtils.ensureMainThread(packetplayinchat, this, this.player.x());
++ boolean isSync = packetplayinchat.b().startsWith("/");
++ if (packetplayinchat.b().startsWith("/")) {
++ PlayerConnectionUtils.ensureMainThread(packetplayinchat, this, this.player.getWorldServer());
+ }
+ // CraftBukkit end
+ if (this.player.dead || this.player.getChatFlags() == EntityHuman.EnumChatVisibility.HIDDEN) { // CraftBukkit - dead men tell no tales
- ChatMessage chatmessage = new ChatMessage("chat.cannotSend", new Object[0]);
-
- chatmessage.getChatModifier().setColor(EnumChatFormat.RED);
-@@ -675,39 +1164,249 @@
+ this.sendPacket(new PacketPlayOutChat((new ChatMessage("chat.cannotSend", new Object[0])).a(EnumChatFormat.RED)));
+ } else {
+ this.player.resetIdleTimer();
+@@ -892,39 +1395,249 @@
for (int i = 0; i < s.length(); ++i) {
if (!SharedConstants.isAllowedChatCharacter(s.charAt(i))) {
@@ -850,9 +873,9 @@
+ this.chat(s, true);
+ // CraftBukkit end - the below is for reference. :)
} else {
- ChatMessage chatmessage1 = new ChatMessage("chat.type.text", new Object[] { this.player.getScoreboardDisplayName(), s});
+ ChatMessage chatmessage = new ChatMessage("chat.type.text", new Object[] { this.player.getScoreboardDisplayName(), s});
- this.minecraftServer.getPlayerList().sendMessage(chatmessage1, false);
+ this.minecraftServer.getPlayerList().sendMessage(chatmessage, false);
}
- this.chatThrottle += 20;
@@ -963,8 +986,8 @@
+ // CraftBukkit end
+
private void handleCommand(String s) {
-- this.minecraftServer.getCommandHandler().a(this.player, s);
-+ // CraftBukkit start - whole method
+- this.minecraftServer.getCommandDispatcher().a(this.player.getCommandListener(), s);
++ // CraftBukkit start - whole method
+ this.LOGGER.info(this.player.getName() + " issued server command: " + s);
+
+ CraftPlayer player = this.getPlayer();
@@ -985,12 +1008,12 @@
+ java.util.logging.Logger.getLogger(PlayerConnection.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
+ return;
+ }
-+ // this.minecraftServer.getCommandHandler().a(this.player, s);
++ // this.minecraftServer.getCommandDispatcher().a(this.player.getCommandListener(), s);
+ // CraftBukkit end
}
public void a(PacketPlayInArmAnimation packetplayinarmanimation) {
- PlayerConnectionUtils.ensureMainThread(packetplayinarmanimation, this, this.player.x());
+ PlayerConnectionUtils.ensureMainThread(packetplayinarmanimation, this, this.player.getWorldServer());
+ if (this.player.isFrozen()) return; // CraftBukkit
this.player.resetIdleTimer();
+ // CraftBukkit start - Raytrace to look for 'rogue armswings'
@@ -1009,7 +1032,7 @@
+ float f8 = f3 * f5;
+ double d3 = player.playerInteractManager.getGameMode()== EnumGamemode.CREATIVE ? 5.0D : 4.5D;
+ Vec3D vec3d1 = vec3d.add((double) f7 * d3, (double) f6 * d3, (double) f8 * d3);
-+ MovingObjectPosition movingobjectposition = this.player.world.rayTrace(vec3d, vec3d1, false);
++ MovingObjectPosition movingobjectposition = this.player.world.rayTrace(vec3d, vec3d1);
+
+ if (movingobjectposition == null || movingobjectposition.type != MovingObjectPosition.EnumMovingObjectType.BLOCK) {
+ CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_AIR, this.player.inventory.getItemInHand(), EnumHand.MAIN_HAND);
@@ -1021,17 +1044,17 @@
+
+ if (event.isCancelled()) return;
+ // CraftBukkit end
- this.player.a(packetplayinarmanimation.a());
+ this.player.a(packetplayinarmanimation.b());
}
public void a(PacketPlayInEntityAction packetplayinentityaction) {
- PlayerConnectionUtils.ensureMainThread(packetplayinentityaction, this, this.player.x());
+ PlayerConnectionUtils.ensureMainThread(packetplayinentityaction, this, this.player.getWorldServer());
+ // CraftBukkit start
+ if (this.player.dead) return;
-+ switch (packetplayinentityaction.b()) {
++ switch (packetplayinentityaction.c()) {
+ case START_SNEAKING:
+ case STOP_SNEAKING:
-+ PlayerToggleSneakEvent event = new PlayerToggleSneakEvent(this.getPlayer(), packetplayinentityaction.b() == PacketPlayInEntityAction.EnumPlayerAction.START_SNEAKING);
++ PlayerToggleSneakEvent event = new PlayerToggleSneakEvent(this.getPlayer(), packetplayinentityaction.c() == PacketPlayInEntityAction.EnumPlayerAction.START_SNEAKING);
+ this.server.getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
@@ -1040,7 +1063,7 @@
+ break;
+ case START_SPRINTING:
+ case STOP_SPRINTING:
-+ PlayerToggleSprintEvent e2 = new PlayerToggleSprintEvent(this.getPlayer(), packetplayinentityaction.b() == PacketPlayInEntityAction.EnumPlayerAction.START_SPRINTING);
++ PlayerToggleSprintEvent e2 = new PlayerToggleSprintEvent(this.getPlayer(), packetplayinentityaction.c() == PacketPlayInEntityAction.EnumPlayerAction.START_SPRINTING);
+ this.server.getPluginManager().callEvent(e2);
+
+ if (e2.isCancelled()) {
@@ -1052,31 +1075,31 @@
this.player.resetIdleTimer();
IJumpable ijumpable;
-@@ -779,6 +1478,7 @@
+@@ -996,6 +1709,7 @@
public void a(PacketPlayInUseEntity packetplayinuseentity) {
- PlayerConnectionUtils.ensureMainThread(packetplayinuseentity, this, this.player.x());
+ PlayerConnectionUtils.ensureMainThread(packetplayinuseentity, this, this.player.getWorldServer());
+ if (this.player.isFrozen()) return; // CraftBukkit
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
Entity entity = packetplayinuseentity.a((World) worldserver);
-@@ -794,20 +1494,68 @@
+@@ -1011,20 +1725,68 @@
if (this.player.h(entity) < d0) {
EnumHand enumhand;
-+ ItemStack itemInHand = this.player.b(packetplayinuseentity.b() == null ? EnumHand.MAIN_HAND : packetplayinuseentity.b()); // CraftBukkit
++ ItemStack itemInHand = this.player.b(packetplayinuseentity.c() == null ? EnumHand.MAIN_HAND : packetplayinuseentity.c()); // CraftBukkit
+
-+ if (packetplayinuseentity.a() == PacketPlayInUseEntity.EnumEntityUseAction.INTERACT
-+ || packetplayinuseentity.a() == PacketPlayInUseEntity.EnumEntityUseAction.INTERACT_AT) {
++ if (packetplayinuseentity.b() == PacketPlayInUseEntity.EnumEntityUseAction.INTERACT
++ || packetplayinuseentity.b() == PacketPlayInUseEntity.EnumEntityUseAction.INTERACT_AT) {
+ // CraftBukkit start
+ boolean triggerLeashUpdate = itemInHand != null && itemInHand.getItem() == Items.LEAD && entity instanceof EntityInsentient;
+ Item origItem = this.player.inventory.getItemInHand() == null ? null : this.player.inventory.getItemInHand().getItem();
+ PlayerInteractEntityEvent event;
-+ if (packetplayinuseentity.a() == PacketPlayInUseEntity.EnumEntityUseAction.INTERACT) {
-+ event = new PlayerInteractEntityEvent((Player) this.getPlayer(), entity.getBukkitEntity(), (packetplayinuseentity.b() == EnumHand.OFF_HAND) ? EquipmentSlot.OFF_HAND : EquipmentSlot.HAND);
++ if (packetplayinuseentity.b() == PacketPlayInUseEntity.EnumEntityUseAction.INTERACT) {
++ event = new PlayerInteractEntityEvent((Player) this.getPlayer(), entity.getBukkitEntity(), (packetplayinuseentity.c() == EnumHand.OFF_HAND) ? EquipmentSlot.OFF_HAND : EquipmentSlot.HAND);
+ } else {
-+ Vec3D target = packetplayinuseentity.c();
-+ event = new PlayerInteractAtEntityEvent((Player) this.getPlayer(), entity.getBukkitEntity(), new org.bukkit.util.Vector(target.x, target.y, target.z), (packetplayinuseentity.b() == EnumHand.OFF_HAND) ? EquipmentSlot.OFF_HAND : EquipmentSlot.HAND);
++ Vec3D target = packetplayinuseentity.d();
++ event = new PlayerInteractAtEntityEvent((Player) this.getPlayer(), entity.getBukkitEntity(), new org.bukkit.util.Vector(target.x, target.y, target.z), (packetplayinuseentity.c() == EnumHand.OFF_HAND) ? EquipmentSlot.OFF_HAND : EquipmentSlot.HAND);
+ }
+ this.server.getPluginManager().callEvent(event);
+
@@ -1096,27 +1119,27 @@
+ // CraftBukkit end
+ }
+
- if (packetplayinuseentity.a() == PacketPlayInUseEntity.EnumEntityUseAction.INTERACT) {
- enumhand = packetplayinuseentity.b();
+ if (packetplayinuseentity.b() == PacketPlayInUseEntity.EnumEntityUseAction.INTERACT) {
+ enumhand = packetplayinuseentity.c();
this.player.a(entity, enumhand);
+ // CraftBukkit start
+ 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();
- entity.a(this.player, packetplayinuseentity.c(), enumhand);
+ } else if (packetplayinuseentity.b() == PacketPlayInUseEntity.EnumEntityUseAction.INTERACT_AT) {
+ enumhand = packetplayinuseentity.c();
+ entity.a(this.player, packetplayinuseentity.d(), enumhand);
+ // CraftBukkit start
+ if (!itemInHand.isEmpty() && itemInHand.getCount() <= -1) {
+ this.player.updateInventory(this.player.activeContainer);
+ }
+ // CraftBukkit end
- } else if (packetplayinuseentity.a() == PacketPlayInUseEntity.EnumEntityUseAction.ATTACK) {
+ } else if (packetplayinuseentity.b() == PacketPlayInUseEntity.EnumEntityUseAction.ATTACK) {
- if (entity instanceof EntityItem || entity instanceof EntityExperienceOrb || entity instanceof EntityArrow || entity == this.player) {
+ if (entity instanceof EntityItem || entity instanceof EntityExperienceOrb || entity instanceof EntityArrow || (entity == this.player && !player.isSpectator())) { // CraftBukkit
this.disconnect(new ChatMessage("multiplayer.disconnect.invalid_entity_attacked", new Object[0]));
- this.minecraftServer.warning("Player " + this.player.getName() + " tried to attack an invalid entity");
+ this.minecraftServer.warning("Player " + this.player.getDisplayName().getString() + " tried to attack an invalid entity");
return;
}
@@ -1130,49 +1153,49 @@
}
}
}
-@@ -823,7 +1571,8 @@
+@@ -1040,7 +1802,8 @@
case PERFORM_RESPAWN:
if (this.player.viewingCredits) {
this.player.viewingCredits = false;
- this.player = this.minecraftServer.getPlayerList().moveToWorld(this.player, 0, true);
+ // this.player = this.minecraftServer.getPlayerList().moveToWorld(this.player, 0, true);
+ this.minecraftServer.getPlayerList().changeDimension(this.player, 0, PlayerTeleportEvent.TeleportCause.END_PORTAL); // CraftBukkit - reroute logic through custom portal management
- CriterionTriggers.u.a(this.player, DimensionManager.THE_END, DimensionManager.OVERWORLD);
+ CriterionTriggers.v.a(this.player, DimensionManager.THE_END, DimensionManager.OVERWORLD);
} else {
if (this.player.getHealth() > 0.0F) {
-@@ -846,14 +1595,20 @@
+@@ -1063,14 +1826,20 @@
public void a(PacketPlayInCloseWindow packetplayinclosewindow) {
- PlayerConnectionUtils.ensureMainThread(packetplayinclosewindow, this, this.player.x());
+ PlayerConnectionUtils.ensureMainThread(packetplayinclosewindow, this, this.player.getWorldServer());
+
+ if (this.player.isFrozen()) return; // CraftBukkit
+ CraftEventFactory.handleInventoryCloseEvent(this.player); // CraftBukkit
+
- this.player.r();
+ this.player.m();
}
public void a(PacketPlayInWindowClick packetplayinwindowclick) {
- PlayerConnectionUtils.ensureMainThread(packetplayinwindowclick, this, this.player.x());
+ PlayerConnectionUtils.ensureMainThread(packetplayinwindowclick, this, this.player.getWorldServer());
+ 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.activeContainer.windowId == packetplayinwindowclick.b() && this.player.activeContainer.c(this.player)) {
- if (this.player.isSpectator()) {
-+ if (this.player.activeContainer.windowId == packetplayinwindowclick.a() && this.player.activeContainer.c(this.player) && this.player.activeContainer.canUse(this.player)) { // CraftBukkit
++ if (this.player.activeContainer.windowId == packetplayinwindowclick.b() && this.player.activeContainer.c(this.player) && this.player.activeContainer.canUse(this.player)) { // CraftBukkit
+ boolean cancelled = this.player.isSpectator(); // CraftBukkit - see below if
+ if (false/*this.player.isSpectator()*/) { // CraftBukkit
NonNullList nonnulllist = NonNullList.a();
for (int i = 0; i < this.player.activeContainer.slots.size(); ++i) {
-@@ -862,8 +1617,274 @@
+@@ -1079,8 +1848,274 @@
this.player.a(this.player.activeContainer, nonnulllist);
} else {
-- ItemStack itemstack = this.player.activeContainer.a(packetplayinwindowclick.b(), packetplayinwindowclick.c(), packetplayinwindowclick.f(), this.player);
+- ItemStack itemstack = this.player.activeContainer.a(packetplayinwindowclick.c(), packetplayinwindowclick.d(), packetplayinwindowclick.g(), this.player);
+ // CraftBukkit start - Call InventoryClickEvent
-+ if (packetplayinwindowclick.b() < -1 && packetplayinwindowclick.b() != -999) {
++ if (packetplayinwindowclick.c() < -1 && packetplayinwindowclick.c() != -999) {
+ return;
+ }
-+
+
+ InventoryView inventory = this.player.activeContainer.getBukkitView();
+ SlotType type = CraftInventoryView.getSlotType(inventory, packetplayinwindowclick.b());
+
@@ -1182,36 +1205,36 @@
+
+ ItemStack itemstack = ItemStack.a;
+
-+ switch (packetplayinwindowclick.f()) {
++ switch (packetplayinwindowclick.g()) {
+ case PICKUP:
-+ if (packetplayinwindowclick.c() == 0) {
++ if (packetplayinwindowclick.d() == 0) {
+ click = ClickType.LEFT;
-+ } else if (packetplayinwindowclick.c() == 1) {
++ } else if (packetplayinwindowclick.d() == 1) {
+ click = ClickType.RIGHT;
+ }
-+ if (packetplayinwindowclick.c() == 0 || packetplayinwindowclick.c() == 1) {
++ if (packetplayinwindowclick.d() == 0 || packetplayinwindowclick.d() == 1) {
+ action = InventoryAction.NOTHING; // Don't want to repeat ourselves
-+ if (packetplayinwindowclick.b() == -999) {
++ if (packetplayinwindowclick.c() == -999) {
+ if (!player.inventory.getCarried().isEmpty()) {
-+ action = packetplayinwindowclick.c() == 0 ? InventoryAction.DROP_ALL_CURSOR : InventoryAction.DROP_ONE_CURSOR;
++ action = packetplayinwindowclick.d() == 0 ? InventoryAction.DROP_ALL_CURSOR : InventoryAction.DROP_ONE_CURSOR;
+ }
-+ } else if (packetplayinwindowclick.b() < 0) {
++ } else if (packetplayinwindowclick.c() < 0) {
+ action = InventoryAction.NOTHING;
+ } else {
-+ Slot slot = this.player.activeContainer.getSlot(packetplayinwindowclick.b());
++ Slot slot = this.player.activeContainer.getSlot(packetplayinwindowclick.c());
+ if (slot != null) {
+ ItemStack clickedItem = slot.getItem();
+ ItemStack cursor = player.inventory.getCarried();
+ if (clickedItem.isEmpty()) {
+ if (!cursor.isEmpty()) {
-+ action = packetplayinwindowclick.c() == 0 ? InventoryAction.PLACE_ALL : InventoryAction.PLACE_ONE;
++ action = packetplayinwindowclick.d() == 0 ? InventoryAction.PLACE_ALL : InventoryAction.PLACE_ONE;
+ }
+ } else if (slot.isAllowed(player)) {
+ if (cursor.isEmpty()) {
-+ action = packetplayinwindowclick.c() == 0 ? InventoryAction.PICKUP_ALL : InventoryAction.PICKUP_HALF;
++ action = packetplayinwindowclick.d() == 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.getCount() : 1;
++ int toPlace = packetplayinwindowclick.d() == 0 ? cursor.getCount() : 1;
+ toPlace = Math.min(toPlace, clickedItem.getMaxStackSize() - clickedItem.getCount());
+ toPlace = Math.min(toPlace, slot.inventory.getMaxStackSize() - clickedItem.getCount());
+ if (toPlace == 1) {
@@ -1226,7 +1249,7 @@
+ } 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)) {
++ } else if (cursor.getItem() == clickedItem.getItem() && ItemStack.equals(cursor, clickedItem)) {
+ if (clickedItem.getCount() >= 0) {
+ if (clickedItem.getCount() + cursor.getCount() <= cursor.getMaxStackSize()) {
+ // As of 1.5, this is result slots only
@@ -1241,16 +1264,16 @@
+ break;
+ // TODO check on updates
+ case QUICK_MOVE:
-+ if (packetplayinwindowclick.c() == 0) {
++ if (packetplayinwindowclick.d() == 0) {
+ click = ClickType.SHIFT_LEFT;
-+ } else if (packetplayinwindowclick.c() == 1) {
++ } else if (packetplayinwindowclick.d() == 1) {
+ click = ClickType.SHIFT_RIGHT;
+ }
-+ if (packetplayinwindowclick.c() == 0 || packetplayinwindowclick.c() == 1) {
-+ if (packetplayinwindowclick.b() < 0) {
++ if (packetplayinwindowclick.d() == 0 || packetplayinwindowclick.d() == 1) {
++ if (packetplayinwindowclick.c() < 0) {
+ action = InventoryAction.NOTHING;
+ } else {
-+ Slot slot = this.player.activeContainer.getSlot(packetplayinwindowclick.b());
++ Slot slot = this.player.activeContainer.getSlot(packetplayinwindowclick.c());
+ if (slot != null && slot.isAllowed(this.player) && slot.hasItem()) {
+ action = InventoryAction.MOVE_TO_OTHER_INVENTORY;
+ } else {
@@ -1260,11 +1283,11 @@
+ }
+ break;
+ case SWAP:
-+ if (packetplayinwindowclick.c() >= 0 && packetplayinwindowclick.c() < 9) {
++ if (packetplayinwindowclick.d() >= 0 && packetplayinwindowclick.d() < 9) {
+ click = ClickType.NUMBER_KEY;
-+ Slot clickedSlot = this.player.activeContainer.getSlot(packetplayinwindowclick.b());
++ Slot clickedSlot = this.player.activeContainer.getSlot(packetplayinwindowclick.c());
+ if (clickedSlot.isAllowed(player)) {
-+ ItemStack hotbar = this.player.inventory.getItem(packetplayinwindowclick.c());
++ ItemStack hotbar = this.player.inventory.getItem(packetplayinwindowclick.d());
+ boolean canCleanSwap = hotbar.isEmpty() || (clickedSlot.inventory == player.inventory && clickedSlot.isAllowed(hotbar)); // the slot will accept the hotbar item
+ if (clickedSlot.hasItem()) {
+ if (canCleanSwap) {
@@ -1283,12 +1306,12 @@
+ }
+ break;
+ case CLONE:
-+ if (packetplayinwindowclick.c() == 2) {
++ if (packetplayinwindowclick.d() == 2) {
+ click = ClickType.MIDDLE;
-+ if (packetplayinwindowclick.b() == -999) {
++ if (packetplayinwindowclick.c() == -999) {
+ action = InventoryAction.NOTHING;
+ } else {
-+ Slot slot = this.player.activeContainer.getSlot(packetplayinwindowclick.b());
++ Slot slot = this.player.activeContainer.getSlot(packetplayinwindowclick.c());
+ if (slot != null && slot.hasItem() && player.abilities.canInstantlyBuild && player.inventory.getCarried().isEmpty()) {
+ action = InventoryAction.CLONE_STACK;
+ } else {
@@ -1301,18 +1324,18 @@
+ }
+ break;
+ case THROW:
-+ if (packetplayinwindowclick.b() >= 0) {
-+ if (packetplayinwindowclick.c() == 0) {
++ if (packetplayinwindowclick.c() >= 0) {
++ if (packetplayinwindowclick.d() == 0) {
+ click = ClickType.DROP;
-+ Slot slot = this.player.activeContainer.getSlot(packetplayinwindowclick.b());
++ Slot slot = this.player.activeContainer.getSlot(packetplayinwindowclick.c());
+ if (slot != null && slot.hasItem() && slot.isAllowed(player) && !slot.getItem().isEmpty() && slot.getItem().getItem() != Item.getItemOf(Blocks.AIR)) {
+ action = InventoryAction.DROP_ONE_SLOT;
+ } else {
+ action = InventoryAction.NOTHING;
+ }
-+ } else if (packetplayinwindowclick.c() == 1) {
++ } else if (packetplayinwindowclick.d() == 1) {
+ click = ClickType.CONTROL_DROP;
-+ Slot slot = this.player.activeContainer.getSlot(packetplayinwindowclick.b());
++ Slot slot = this.player.activeContainer.getSlot(packetplayinwindowclick.c());
+ if (slot != null && slot.hasItem() && slot.isAllowed(player) && !slot.getItem().isEmpty() && slot.getItem().getItem() != Item.getItemOf(Blocks.AIR)) {
+ action = InventoryAction.DROP_ALL_SLOT;
+ } else {
@@ -1322,23 +1345,23 @@
+ } else {
+ // Sane default (because this happens when they are holding nothing. Don't ask why.)
+ click = ClickType.LEFT;
-+ if (packetplayinwindowclick.c() == 1) {
++ if (packetplayinwindowclick.d() == 1) {
+ click = ClickType.RIGHT;
+ }
+ action = InventoryAction.NOTHING;
+ }
+ break;
+ case QUICK_CRAFT:
-+ itemstack = this.player.activeContainer.a(packetplayinwindowclick.b(), packetplayinwindowclick.c(), packetplayinwindowclick.f(), this.player);
++ itemstack = this.player.activeContainer.a(packetplayinwindowclick.c(), packetplayinwindowclick.d(), packetplayinwindowclick.g(), this.player);
+ break;
+ case PICKUP_ALL:
+ click = ClickType.DOUBLE_CLICK;
+ action = InventoryAction.NOTHING;
-+ if (packetplayinwindowclick.b() >= 0 && !this.player.inventory.getCarried().isEmpty()) {
++ if (packetplayinwindowclick.c() >= 0 && !this.player.inventory.getCarried().isEmpty()) {
+ ItemStack cursor = this.player.inventory.getCarried();
+ action = InventoryAction.NOTHING;
+ // Quick check for if we have any of the item
-+ if (inventory.getTopInventory().contains(org.bukkit.Material.getMaterial(Item.getId(cursor.getItem()))) || inventory.getBottomInventory().contains(org.bukkit.Material.getMaterial(Item.getId(cursor.getItem())))) {
++ if (inventory.getTopInventory().contains(CraftMagicNumbers.getMaterial(cursor.getItem())) || inventory.getBottomInventory().contains(CraftMagicNumbers.getMaterial(cursor.getItem()))) {
+ action = InventoryAction.COLLECT_TO_CURSOR;
+ }
+ }
@@ -1346,22 +1369,22 @@
+ default:
+ break;
+ }
-
-+ if (packetplayinwindowclick.f() != InventoryClickType.QUICK_CRAFT) {
++
++ if (packetplayinwindowclick.g() != InventoryClickType.QUICK_CRAFT) {
+ if (click == ClickType.NUMBER_KEY) {
-+ event = new InventoryClickEvent(inventory, type, packetplayinwindowclick.b(), click, action, packetplayinwindowclick.c());
++ event = new InventoryClickEvent(inventory, type, packetplayinwindowclick.c(), click, action, packetplayinwindowclick.d());
+ } else {
-+ event = new InventoryClickEvent(inventory, type, packetplayinwindowclick.b(), click, action);
++ event = new InventoryClickEvent(inventory, type, packetplayinwindowclick.c(), click, action);
+ }
+
+ org.bukkit.inventory.Inventory top = inventory.getTopInventory();
-+ if (packetplayinwindowclick.b() == 0 && top instanceof CraftingInventory) {
++ if (packetplayinwindowclick.c() == 0 && top instanceof CraftingInventory) {
+ org.bukkit.inventory.Recipe recipe = ((CraftingInventory) top).getRecipe();
+ if (recipe != null) {
+ if (click == ClickType.NUMBER_KEY) {
-+ event = new CraftItemEvent(recipe, inventory, type, packetplayinwindowclick.b(), click, action, packetplayinwindowclick.c());
++ event = new CraftItemEvent(recipe, inventory, type, packetplayinwindowclick.c(), click, action, packetplayinwindowclick.d());
+ } else {
-+ event = new CraftItemEvent(recipe, inventory, type, packetplayinwindowclick.b(), click, action);
++ event = new CraftItemEvent(recipe, inventory, type, packetplayinwindowclick.c(), click, action);
+ }
+ }
+ }
@@ -1376,7 +1399,7 @@
+ switch (event.getResult()) {
+ case ALLOW:
+ case DEFAULT:
-+ itemstack = this.player.activeContainer.a(packetplayinwindowclick.b(), packetplayinwindowclick.c(), packetplayinwindowclick.f(), this.player);
++ itemstack = this.player.activeContainer.a(packetplayinwindowclick.c(), packetplayinwindowclick.d(), packetplayinwindowclick.g(), this.player);
+ break;
+ case DENY:
+ /* Needs enum constructor in InventoryAction
@@ -1436,25 +1459,22 @@
+ }
+ }
+ // CraftBukkit end
- if (ItemStack.matches(packetplayinwindowclick.e(), itemstack)) {
- this.player.playerConnection.sendPacket(new PacketPlayOutTransaction(packetplayinwindowclick.a(), packetplayinwindowclick.d(), true));
+ if (ItemStack.matches(packetplayinwindowclick.f(), itemstack)) {
+ this.player.playerConnection.sendPacket(new PacketPlayOutTransaction(packetplayinwindowclick.b(), packetplayinwindowclick.e(), true));
this.player.f = true;
-@@ -900,6 +1921,7 @@
+@@ -1123,6 +2158,7 @@
public void a(PacketPlayInEnchantItem packetplayinenchantitem) {
- PlayerConnectionUtils.ensureMainThread(packetplayinenchantitem, this, this.player.x());
+ PlayerConnectionUtils.ensureMainThread(packetplayinenchantitem, this, this.player.getWorldServer());
+ 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());
-@@ -933,7 +1955,45 @@
- }
+ if (this.player.activeContainer.windowId == packetplayinenchantitem.b() && this.player.activeContainer.c(this.player) && !this.player.isSpectator()) {
+ this.player.activeContainer.a(this.player, packetplayinenchantitem.c());
+@@ -1154,6 +2190,43 @@
- boolean flag1 = packetplayinsetcreativeslot.a() >= 1 && packetplayinsetcreativeslot.a() <= 45;
-- boolean flag2 = itemstack.isEmpty() || itemstack.getData() >= 0 && itemstack.getCount() <= 64 && !itemstack.isEmpty();
-+ // CraftBukkit - Add invalidItems check
-+ 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
+ boolean flag1 = packetplayinsetcreativeslot.b() >= 1 && packetplayinsetcreativeslot.b() <= 45;
+ boolean flag2 = itemstack.isEmpty() || itemstack.getDamage() >= 0 && itemstack.getCount() <= 64 && !itemstack.isEmpty();
++ if (flag || (flag1 && !ItemStack.matches(this.player.defaultContainer.getSlot(packetplayinsetcreativeslot.b()).getItem(), packetplayinsetcreativeslot.getItemStack()))) { // Insist on valid slot
+ // CraftBukkit start - Call click event
+ InventoryView inventory = this.player.defaultContainer.getBukkitView();
+ org.bukkit.inventory.ItemStack item = CraftItemStack.asBukkitCopy(packetplayinsetcreativeslot.getItemStack());
@@ -1462,14 +1482,14 @@
+ SlotType type = SlotType.QUICKBAR;
+ if (flag) {
+ type = SlotType.OUTSIDE;
-+ } else if (packetplayinsetcreativeslot.a() < 36) {
-+ if (packetplayinsetcreativeslot.a() >= 5 && packetplayinsetcreativeslot.a() < 9) {
++ } else if (packetplayinsetcreativeslot.b() < 36) {
++ if (packetplayinsetcreativeslot.b() >= 5 && packetplayinsetcreativeslot.b() < 9) {
+ type = SlotType.ARMOR;
+ } else {
+ type = SlotType.CONTAINER;
+ }
+ }
-+ InventoryCreativeEvent event = new InventoryCreativeEvent(inventory, type, flag ? -999 : packetplayinsetcreativeslot.a(), item);
++ InventoryCreativeEvent event = new InventoryCreativeEvent(inventory, type, flag ? -999 : packetplayinsetcreativeslot.b(), item);
+ server.getPluginManager().callEvent(event);
+
+ itemstack = CraftItemStack.asNMSCopy(event.getCursor());
@@ -1483,8 +1503,8 @@
+ break;
+ case DENY:
+ // Reset the slot
-+ if (packetplayinsetcreativeslot.a() >= 0) {
-+ this.player.playerConnection.sendPacket(new PacketPlayOutSetSlot(this.player.defaultContainer.windowId, packetplayinsetcreativeslot.a(), this.player.defaultContainer.getSlot(packetplayinsetcreativeslot.a()).getItem()));
++ if (packetplayinsetcreativeslot.b() >= 0) {
++ this.player.playerConnection.sendPacket(new PacketPlayOutSetSlot(this.player.defaultContainer.windowId, packetplayinsetcreativeslot.b(), this.player.defaultContainer.getSlot(packetplayinsetcreativeslot.b()).getItem()));
+ this.player.playerConnection.sendPacket(new PacketPlayOutSetSlot(-1, -1, ItemStack.a));
+ }
+ return;
@@ -1494,42 +1514,42 @@
if (flag1 && flag2) {
if (itemstack.isEmpty()) {
-@@ -957,6 +2017,7 @@
+@@ -1177,6 +2250,7 @@
public void a(PacketPlayInTransaction packetplayintransaction) {
- PlayerConnectionUtils.ensureMainThread(packetplayintransaction, this, this.player.x());
+ PlayerConnectionUtils.ensureMainThread(packetplayintransaction, this, this.player.getWorldServer());
+ 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()) {
-@@ -967,6 +2028,7 @@
+ if (oshort != null && packetplayintransaction.c() == oshort.shortValue() && this.player.activeContainer.windowId == packetplayintransaction.b() && !this.player.activeContainer.c(this.player) && !this.player.isSpectator()) {
+@@ -1187,6 +2261,7 @@
public void a(PacketPlayInUpdateSign packetplayinupdatesign) {
- PlayerConnectionUtils.ensureMainThread(packetplayinupdatesign, this, this.player.x());
+ PlayerConnectionUtils.ensureMainThread(packetplayinupdatesign, this, this.player.getWorldServer());
+ if (this.player.isFrozen()) return; // CraftBukkit
this.player.resetIdleTimer();
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
- BlockPosition blockposition = packetplayinupdatesign.a();
-@@ -983,14 +2045,30 @@
+ BlockPosition blockposition = packetplayinupdatesign.b();
+@@ -1203,14 +2278,30 @@
- if (!tileentitysign.a() || tileentitysign.e() != this.player) {
- this.minecraftServer.warning("Player " + this.player.getName() + " just tried to change non-editable sign");
+ if (!tileentitysign.d() || tileentitysign.e() != this.player) {
+ this.minecraftServer.warning("Player " + this.player.getDisplayName().getString() + " just tried to change non-editable sign");
+ this.sendPacket(tileentity.getUpdatePacket()); // CraftBukkit
return;
}
- String[] astring = packetplayinupdatesign.b();
+ String[] astring = packetplayinupdatesign.c();
+ // CraftBukkit start
+ Player player = this.server.getPlayer(this.player);
-+ int x = packetplayinupdatesign.a().getX();
-+ int y = packetplayinupdatesign.a().getY();
-+ int z = packetplayinupdatesign.a().getZ();
++ int x = packetplayinupdatesign.b().getX();
++ int y = packetplayinupdatesign.b().getY();
++ int z = packetplayinupdatesign.b().getZ();
+ String[] lines = new String[4];
+
for (int i = 0; i < astring.length; ++i) {
-- tileentitysign.lines[i] = new ChatComponentText(EnumChatFormat.a(astring[i]));
-+ lines[i] = EnumChatFormat.a(new ChatComponentText(EnumChatFormat.a(astring[i])).toPlainText());
+- tileentitysign.lines[i] = new ChatComponentText(EnumChatFormat.b(astring[i]));
++ lines[i] = EnumChatFormat.b(new ChatComponentText(EnumChatFormat.b(astring[i])).getString());
}
+ SignChangeEvent event = new SignChangeEvent((org.bukkit.craftbukkit.block.CraftBlock) player.getWorld().getBlockAt(x, y, z), this.server.getPlayer(this.player), lines);
+ this.server.getPluginManager().callEvent(event);
@@ -1542,18 +1562,18 @@
tileentitysign.update();
worldserver.notify(blockposition, iblockdata, iblockdata, 3);
-@@ -999,6 +2077,7 @@
+@@ -1219,6 +2310,7 @@
}
public void a(PacketPlayInKeepAlive packetplayinkeepalive) {
-+ PlayerConnectionUtils.ensureMainThread(packetplayinkeepalive, this, this.player.x()); // CraftBukkit
- if (this.g && packetplayinkeepalive.a() == this.h) {
- int i = (int) (this.d() - this.f);
++ PlayerConnectionUtils.ensureMainThread(packetplayinkeepalive, this, this.player.getWorldServer()); // CraftBukkit
+ if (this.g && packetplayinkeepalive.b() == this.h) {
+ int i = (int) (SystemUtils.b() - this.f);
-@@ -1016,11 +2095,27 @@
+@@ -1232,7 +2324,17 @@
public void a(PacketPlayInAbilities packetplayinabilities) {
- PlayerConnectionUtils.ensureMainThread(packetplayinabilities, this, this.player.x());
+ PlayerConnectionUtils.ensureMainThread(packetplayinabilities, this, this.player.getWorldServer());
- this.player.abilities.isFlying = packetplayinabilities.isFlying() && this.player.abilities.canFly;
+ // CraftBukkit start
+ if (this.player.abilities.canFly && this.player.abilities.isFlying != packetplayinabilities.isFlying()) {
@@ -1568,155 +1588,53 @@
+ // CraftBukkit end
}
- public void a(PacketPlayInTabComplete packetplayintabcomplete) {
- PlayerConnectionUtils.ensureMainThread(packetplayintabcomplete, this, this.player.x());
-+ // CraftBukkit start
-+ if (chatSpamField.addAndGet(this, 10) > 500 && !this.minecraftServer.getPlayerList().isOp(this.player.getProfile())) {
-+ this.disconnect(new ChatMessage("disconnect.spam", new Object[0]));
-+ return;
-+ }
-+ // CraftBukkit end
- ArrayList arraylist = Lists.newArrayList();
- Iterator iterator = this.minecraftServer.tabCompleteCommand(this.player, packetplayintabcomplete.a(), packetplayintabcomplete.b(), packetplayintabcomplete.c()).iterator();
-
-@@ -1046,6 +2141,13 @@
- ItemStack itemstack1;
+ public void a(PacketPlayInSettings packetplayinsettings) {
+@@ -1240,5 +2342,47 @@
+ this.player.a(packetplayinsettings);
+ }
- if ("MC|BEdit".equals(s)) {
-+ // CraftBukkit start
-+ if (this.lastBookTick + 20 > MinecraftServer.currentTick) {
-+ this.disconnect("Book edited too quickly!");
-+ return;
+- public void a(PacketPlayInCustomPayload packetplayincustompayload) {}
++ // CraftBukkit start
++ private static final MinecraftKey CUSTOM_REGISTER = new MinecraftKey("register");
++ private static final MinecraftKey CUSTOM_UNREGISTER = new MinecraftKey("unregister");
++
++ public void a(PacketPlayInCustomPayload packetplayincustompayload) {
++ PlayerConnectionUtils.ensureMainThread(packetplayincustompayload, this, this.player.getWorldServer());
++ if (packetplayincustompayload.tag.equals(CUSTOM_REGISTER)) {
++ try {
++ String channels = packetplayincustompayload.data.toString(com.google.common.base.Charsets.UTF_8);
++ for (String channel : channels.split("\0")) {
++ getPlayer().addChannel(channel);
++ }
++ } catch (Exception ex) {
++ PlayerConnection.LOGGER.error("Couldn\'t register custom payload", ex);
++ this.disconnect("Invalid payload REGISTER!");
+ }
-+ this.lastBookTick = MinecraftServer.currentTick;
-+ // CraftBukkit end
- packetdataserializer = packetplayincustompayload.b();
-
- try {
-@@ -1065,14 +2167,23 @@
-
- if (itemstack.getItem() == Items.WRITABLE_BOOK && itemstack.getItem() == itemstack1.getItem()) {
- itemstack1.a("pages", (NBTBase) itemstack.getTag().getList("pages", 8));
-+ CraftEventFactory.handleEditBookEvent(player, itemstack1); // CraftBukkit
- }
- } catch (Exception exception) {
- PlayerConnection.LOGGER.error("Couldn\'t handle book info", exception);
-+ this.disconnect("Invalid book data!"); // CraftBukkit
- }
- } else {
- String s1;
-
- if ("MC|BSign".equals(s)) {
-+ // CraftBukkit start
-+ if (this.lastBookTick + 20 > MinecraftServer.currentTick) {
-+ this.disconnect("Book edited too quickly!");
-+ return;
++ } else if (packetplayincustompayload.tag.equals(CUSTOM_UNREGISTER)) {
++ try {
++ String channels = packetplayincustompayload.data.toString(com.google.common.base.Charsets.UTF_8);
++ for (String channel : channels.split("\0")) {
++ getPlayer().removeChannel(channel);
+ }
-+ this.lastBookTick = MinecraftServer.currentTick;
-+ // CraftBukkit end
- packetdataserializer = packetplayincustompayload.b();
-
- try {
-@@ -1106,10 +2217,11 @@
- }
-
- itemstack2.a("pages", (NBTBase) nbttaglist);
-- this.player.setSlot(EnumItemSlot.MAINHAND, itemstack2);
-+ CraftEventFactory.handleEditBookEvent(player, itemstack2); // CraftBukkit
- }
- } catch (Exception exception1) {
- PlayerConnection.LOGGER.error("Couldn\'t sign book", exception1);
-+ this.disconnect("Invalid book data!"); // CraftBukkit
- }
- } else if ("MC|TrSel".equals(s)) {
- try {
-@@ -1121,6 +2233,7 @@
- }
- } catch (Exception exception2) {
- PlayerConnection.LOGGER.error("Couldn\'t select trade", exception2);
-+ this.disconnect("Invalid trade data!"); // CraftBukkit
- }
- } else {
- TileEntity tileentity;
-@@ -1170,6 +2283,7 @@
- }
- } catch (Exception exception3) {
- PlayerConnection.LOGGER.error("Couldn\'t set command block", exception3);
-+ this.disconnect("Invalid command data!"); // CraftBukkit
- }
- } else if ("MC|AutoCmd".equals(s)) {
- if (!this.minecraftServer.getEnableCommandBlock()) {
-@@ -1237,6 +2351,7 @@
- }
- } catch (Exception exception4) {
- PlayerConnection.LOGGER.error("Couldn\'t set command block", exception4);
-+ this.disconnect("Invalid command data!"); // CraftBukkit
- }
- } else {
- int k;
-@@ -1260,6 +2375,7 @@
- }
- } catch (Exception exception5) {
- PlayerConnection.LOGGER.error("Couldn\'t set beacon", exception5);
-+ this.disconnect("Invalid beacon data!"); // CraftBukkit
- }
- }
- } else if ("MC|ItemName".equals(s)) {
-@@ -1346,6 +2462,7 @@
- }
- } catch (Exception exception6) {
- PlayerConnection.LOGGER.error("Couldn\'t set structure block", exception6);
-+ this.disconnect("Invalid structure data!"); // CraftBukkit
- }
- } else if ("MC|PickItem".equals(s)) {
- packetdataserializer = packetplayincustompayload.b();
-@@ -1358,11 +2475,49 @@
- this.player.playerConnection.sendPacket(new PacketPlayOutHeldItemSlot(this.player.inventory.itemInHandIndex));
- } catch (Exception exception7) {
- PlayerConnection.LOGGER.error("Couldn\'t pick item", exception7);
-+ this.disconnect("Invalid pick item!"); // CraftBukkit
- }
- }
-+ // CraftBukkit start
-+ else if (packetplayincustompayload.a().equals("REGISTER")) {
-+ try {
-+ String channels = packetplayincustompayload.b().toString(com.google.common.base.Charsets.UTF_8);
-+ for (String channel : channels.split("\0")) {
-+ getPlayer().addChannel(channel);
-+ }
-+ } catch (Exception ex) {
-+ PlayerConnection.LOGGER.error("Couldn\'t register custom payload", ex);
-+ this.disconnect("Invalid payload REGISTER!");
-+ }
-+ } else if (packetplayincustompayload.a().equals("UNREGISTER")) {
-+ try {
-+ String channels = packetplayincustompayload.b().toString(com.google.common.base.Charsets.UTF_8);
-+ for (String channel : channels.split("\0")) {
-+ getPlayer().removeChannel(channel);
-+ }
-+ } catch (Exception ex) {
-+ PlayerConnection.LOGGER.error("Couldn\'t unregister custom payload", ex);
-+ this.disconnect("Invalid payload UNREGISTER!");
-+ }
-+ } else {
-+ try {
-+ byte[] data = new byte[packetplayincustompayload.b().readableBytes()];
-+ packetplayincustompayload.b().readBytes(data);
-+ server.getMessenger().dispatchIncomingMessage(player.getBukkitEntity(), packetplayincustompayload.a(), data);
-+ } catch (Exception ex) {
-+ PlayerConnection.LOGGER.error("Couldn\'t dispatch custom payload", ex);
-+ this.disconnect("Invalid custom payload!");
-+ }
-+ }
-+ // CraftBukkit end
- }
- }
- }
-
- }
++ } catch (Exception ex) {
++ PlayerConnection.LOGGER.error("Couldn\'t unregister custom payload", ex);
++ this.disconnect("Invalid payload UNREGISTER!");
++ }
++ } else {
++ try {
++ byte[] data = new byte[packetplayincustompayload.data.readableBytes()];
++ packetplayincustompayload.data.readBytes(data);
++ server.getMessenger().dispatchIncomingMessage(player.getBukkitEntity(), packetplayincustompayload.tag.toString(), data);
++ } catch (Exception ex) {
++ PlayerConnection.LOGGER.error("Couldn\'t dispatch custom payload", ex);
++ this.disconnect("Invalid custom payload!");
++ }
++ }
++
++ }
+
-+ // CraftBukkit start - Add "isDisconnected" method
+ public final boolean isDisconnected() {
+ return !this.player.joining && !this.networkManager.isConnected();
+ }
++ // CraftBukkit end
}
diff --git a/nms-patches/PlayerInteractManager.patch b/nms-patches/PlayerInteractManager.patch
index 319bef8d..eccbf574 100644
--- a/nms-patches/PlayerInteractManager.patch
+++ b/nms-patches/PlayerInteractManager.patch
@@ -53,7 +53,7 @@
if (this.isCreative()) {
if (!this.world.douseFire((EntityHuman) null, blockposition, enumdirection)) {
this.breakBlock(blockposition);
-@@ -123,14 +145,48 @@
+@@ -122,15 +144,49 @@
}
}
@@ -61,23 +61,24 @@
+ // this.world.douseFire((EntityHuman) null, blockposition, enumdirection); // CraftBukkit - Moved down
this.lastDigTick = this.currentTick;
float f = 1.0F;
+ IBlockData iblockdata = this.world.getType(blockposition);
-- if (iblockdata.getMaterial() != Material.AIR) {
+- if (!iblockdata.isAir()) {
+ // CraftBukkit start - Swings at air do *NOT* exist.
+ if (event.useInteractedBlock() == Event.Result.DENY) {
+ // If we denied a door from opening, we need to send a correcting update to the client, as it already opened the door.
+ IBlockData data = this.world.getType(blockposition);
-+ if (block == Blocks.WOODEN_DOOR) {
++ if (data.getBlock() instanceof BlockDoor) {
+ // For some reason *BOTH* the bottom/top part have to be marked updated.
-+ boolean bottom = data.get(BlockDoor.HALF) == BlockDoor.EnumDoorHalf.LOWER;
++ boolean bottom = data.get(BlockDoor.HALF) == BlockPropertyDoubleBlockHalf.LOWER;
+ ((EntityPlayer) this.player).playerConnection.sendPacket(new PacketPlayOutBlockChange(this.world, blockposition));
+ ((EntityPlayer) this.player).playerConnection.sendPacket(new PacketPlayOutBlockChange(this.world, bottom ? blockposition.up() : blockposition.down()));
-+ } else if (block == Blocks.TRAPDOOR) {
++ } else if (data.getBlock() instanceof BlockTrapdoor) {
+ ((EntityPlayer) this.player).playerConnection.sendPacket(new PacketPlayOutBlockChange(this.world, blockposition));
+ }
-+ } else if (iblockdata.getMaterial() != Material.AIR) {
- block.attack(this.world, blockposition, this.player);
- f = iblockdata.a((EntityHuman) this.player, this.player.world, blockposition);
++ } else if (!iblockdata.isAir()) {
+ iblockdata.attack(this.world, blockposition, this.player);
+ f = iblockdata.getDamage(this.player, this.player.world, blockposition);
+ // Allow fire punching to be blocked
+ this.world.douseFire((EntityHuman) null, blockposition, enumdirection);
+ }
@@ -102,9 +103,9 @@
}
+ // CraftBukkit end
- if (iblockdata.getMaterial() != Material.AIR && f >= 1.0F) {
+ if (!iblockdata.isAir() && f >= 1.0F) {
this.breakBlock(blockposition);
-@@ -148,6 +204,7 @@
+@@ -149,6 +205,7 @@
public void a(BlockPosition blockposition) {
if (blockposition.equals(this.f)) {
@@ -112,7 +113,7 @@
int i = this.currentTick - this.lastDigTick;
IBlockData iblockdata = this.world.getType(blockposition);
-@@ -165,6 +222,10 @@
+@@ -166,6 +223,10 @@
this.j = this.lastDigTick;
}
}
@@ -123,11 +124,10 @@
}
}
-@@ -188,13 +249,86 @@
- }
+@@ -190,13 +251,88 @@
public boolean breakBlock(BlockPosition blockposition) {
-- if (this.gamemode.isCreative() && !this.player.getItemInMainHand().isEmpty() && this.player.getItemInMainHand().getItem() instanceof ItemSword) {
+ IBlockData iblockdata = this.world.getType(blockposition);
+ // 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().isEmpty() && this.player.getItemInMainHand().getItem() instanceof ItemSword;
++ boolean isSwordNoBreak = !this.player.getItemInMainHand().getItem().a(iblockdata, this.world, blockposition, (EntityHuman) this.player);
+
+ // 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!
@@ -159,13 +159,14 @@
+ if (nmsBlock != null && !event.isCancelled() && !this.isCreative() && this.player.hasBlock(nmsBlock.getBlockData())) {
+ // 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)) {
++ if (!(nmsBlock.k() && EnchantmentManager.getEnchantmentLevel(Enchantments.SILK_TOUCH, itemstack) > 0)) {
+ int bonusLevel = EnchantmentManager.getEnchantmentLevel(Enchantments.LOOT_BONUS_BLOCKS, itemstack);
+
-+ event.setExpToDrop(nmsBlock.getExpDrop(this.world, nmsData, bonusLevel));
++ event.setExpToDrop(nmsBlock.getExpDrop(nmsData, this.world, blockposition, bonusLevel));
+ }
+ }
-+
+
+- if (!this.player.getItemInMainHand().getItem().a(iblockdata, this.world, blockposition, (EntityHuman) this.player)) {
+ this.world.getServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
@@ -176,7 +177,7 @@
+ ((EntityPlayer) this.player).playerConnection.sendPacket(new PacketPlayOutBlockChange(this.world, blockposition));
+ // Send other half of the door
+ if (nmsBlock instanceof BlockDoor) {
-+ boolean bottom = nmsData.get(BlockDoor.HALF) == BlockDoor.EnumDoorHalf.LOWER;
++ boolean bottom = nmsData.get(BlockDoor.HALF) == BlockPropertyDoubleBlockHalf.LOWER;
+ ((EntityPlayer) this.player).playerConnection.sendPacket(new PacketPlayOutBlockChange(world, bottom ? blockposition.up() : blockposition.down()));
+ }
+ // Update any tile entity data for this block
@@ -187,23 +188,25 @@
+ return false;
+ }
+ }
-+ if (false && this.gamemode.isCreative() && !this.player.getItemInMainHand().isEmpty() && this.player.getItemInMainHand().getItem() instanceof ItemSword) { // CraftBukkit - false
++ // CraftBukkit end
++
++ if (false && !this.player.getItemInMainHand().getItem().a(iblockdata, this.world, blockposition, (EntityHuman) this.player)) { // CraftBukkit - false
return false;
} else {
- IBlockData iblockdata = this.world.getType(blockposition);
-+ if (iblockdata.getBlock() == Blocks.AIR) return false; // CraftBukkit - A plugin set block to air without cancelling
++ iblockdata = this.world.getType(blockposition); // CraftBukkit - update state from plugins
++ if (iblockdata.isAir()) return false; // CraftBukkit - A plugin set block to air without cancelling
TileEntity tileentity = this.world.getTileEntity(blockposition);
Block block = iblockdata.getBlock();
+ // CraftBukkit start - Special case skulls, their item data comes from a tile entity (Also check if block should drop items)
-+ if (iblockdata.getBlock() == Blocks.SKULL && !this.isCreative() && event.isDropItems()) {
-+ iblockdata.getBlock().dropNaturally(world, blockposition, iblockdata, 1.0F, 0);
++ if (iblockdata.getBlock() instanceof BlockSkull && !this.isCreative() && event.isDropItems()) {
++ iblockdata.getBlock().dropNaturally(iblockdata, world, blockposition, 1.0F, 0);
+ return this.c(blockposition);
+ }
+
+ // And shulker boxes too for duplication on cancel reasons (Also check if block should drop items)
+ if (iblockdata.getBlock() instanceof BlockShulkerBox && event.isDropItems()) {
-+ iblockdata.getBlock().dropNaturally(world, blockposition, iblockdata, 1.0F, 0);
++ iblockdata.getBlock().dropNaturally(iblockdata, world, blockposition, 1.0F, 0);
+ return this.c(blockposition);
+ }
+ // CraftBukkit end
@@ -211,10 +214,10 @@
if ((block instanceof BlockCommand || block instanceof BlockStructure) && !this.player.isCreativeAndOp()) {
this.world.notify(blockposition, iblockdata, iblockdata, 3);
return false;
-@@ -218,7 +352,16 @@
+@@ -221,19 +357,36 @@
+ }
}
- this.world.a(this.player, 2001, blockposition, Block.getCombinedId(iblockdata));
+ // CraftBukkit start
+ world.captureDrops = new ArrayList<>();
boolean flag = this.c(blockposition);
@@ -226,30 +229,30 @@
+ world.captureDrops = null;
+ // CraftBukkit end
- if (this.isCreative()) {
- this.player.playerConnection.sendPacket(new PacketPlayOutBlockChange(this.world, blockposition));
-@@ -231,11 +374,19 @@
- itemstack1.a(this.world, iblockdata, blockposition, this.player);
- }
+ if (!this.isCreative()) {
+ ItemStack itemstack1 = this.player.getItemInMainHand();
+ boolean flag1 = this.player.hasBlock(iblockdata);
+ itemstack1.a(this.world, iblockdata, blockposition, this.player);
- if (flag && flag1) {
+ // CraftBukkit start - Check if block should drop items
+ if (flag && flag1 && event.isDropItems()) {
+ ItemStack itemstack2 = itemstack1.isEmpty() ? ItemStack.a : itemstack1.cloneItemStack();
+
iblockdata.getBlock().a(this.world, this.player, blockposition, iblockdata, tileentity, itemstack2);
}
+ // CraftBukkit end
- }
-
++ }
++
+ // CraftBukkit start - Drop event experience
+ if (flag && event != null) {
+ iblockdata.getBlock().dropExperience(this.world, blockposition, event.getExpToDrop());
-+ }
+ }
+ // CraftBukkit end
-+
+
return flag;
}
- }
-@@ -278,63 +429,90 @@
+@@ -277,11 +430,40 @@
}
}
@@ -257,116 +260,67 @@
+ public boolean interactResult = false;
+ public boolean firedInteract = false;
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);
+ IBlockData iblockdata = world.getType(blockposition);
+ EnumInteractionResult enuminteractionresult = EnumInteractionResult.FAIL;
-+ if (blockdata.getBlock() != Blocks.AIR) {
-+ boolean cancelledBlock = false;
-+
-+ if (this.gamemode == EnumGamemode.SPECTATOR) {
-+ TileEntity tileentity = world.getTileEntity(blockposition);
-+ cancelledBlock = !(tileentity instanceof ITileInventory || tileentity instanceof IInventory);
-+ }
-
-- if (tileentity instanceof ITileInventory) {
-- Block block = world.getType(blockposition).getBlock();
-- ITileInventory itileinventory = (ITileInventory) tileentity;
-+ if (entityhuman.getCooldownTracker().a(itemstack.getItem())) {
-+ cancelledBlock = true;
-+ }
++ if (iblockdata.isAir()) return enuminteractionresult;
++ boolean cancelledBlock = false;
-- if (itileinventory instanceof TileEntityChest && block instanceof BlockChest) {
-- itileinventory = ((BlockChest) block).getInventory(world, blockposition);
-- }
-+ if (itemstack.getItem() instanceof ItemBlock && !entityhuman.isCreativeAndOp()) {
-+ Block block1 = ((ItemBlock) itemstack.getItem()).getBlock();
-
-- if (itileinventory != null) {
-- entityhuman.openContainer(itileinventory);
-- return EnumInteractionResult.SUCCESS;
-+ if (block1 instanceof BlockCommand || block1 instanceof BlockStructure) {
-+ cancelledBlock = true;
- }
-- } 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);
-+ PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(entityhuman, Action.RIGHT_CLICK_BLOCK, blockposition, enumdirection, itemstack, cancelledBlock, enumhand);
-+ firedInteract = true;
-+ interactResult = event.useItemInHand() == Event.Result.DENY;
+ if (this.gamemode == EnumGamemode.SPECTATOR) {
+ TileEntity tileentity = world.getTileEntity(blockposition);
++ cancelledBlock = !(tileentity instanceof ITileInventory || tileentity instanceof IInventory);
++ }
+
-+ if (event.useInteractedBlock() == Event.Result.DENY) {
-+ // If we denied a door from opening, we need to send a correcting update to the client, as it already opened the door.
-+ if (blockdata.getBlock() instanceof BlockDoor) {
-+ boolean bottom = blockdata.get(BlockDoor.HALF) == BlockDoor.EnumDoorHalf.LOWER;
-+ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutBlockChange(world, bottom ? blockposition.up() : blockposition.down()));
-+ } else if (blockdata.getBlock() instanceof BlockCake) {
-+ ((EntityPlayer) entityhuman).getBukkitEntity().sendHealthUpdate(); // SPIGOT-1341 - reset health for cake
-+ }
-+ ((EntityPlayer) entityhuman).getBukkitEntity().updateInventory(); // SPIGOT-2867
-+ enuminteractionresult = (event.useItemInHand() != Event.Result.ALLOW) ? EnumInteractionResult.SUCCESS : EnumInteractionResult.PASS;
-+ } else if (this.gamemode == EnumGamemode.SPECTATOR) {
-+ TileEntity tileentity = world.getTileEntity(blockposition);
-
-- if (iblockdata.getBlock().interact(world, blockposition, iblockdata, entityhuman, enumhand, enumdirection, f, f1, f2)) {
-+ if (tileentity instanceof ITileInventory) {
-+ Block block = world.getType(blockposition).getBlock();
-+ ITileInventory itileinventory = (ITileInventory) tileentity;
++ if (entityhuman.getCooldownTracker().a(itemstack.getItem())) {
++ cancelledBlock = true;
++ }
+
-+ if (itileinventory instanceof TileEntityChest && block instanceof BlockChest) {
-+ itileinventory = ((BlockChest) block).getInventory(world, blockposition);
-+ }
++ PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(entityhuman, Action.RIGHT_CLICK_BLOCK, blockposition, enumdirection, itemstack, cancelledBlock, enumhand);
++ firedInteract = true;
++ interactResult = event.useItemInHand() == Event.Result.DENY;
+
-+ if (itileinventory != null) {
-+ entityhuman.openContainer(itileinventory);
-+ return EnumInteractionResult.SUCCESS;
-+ }
-+ } else if (tileentity instanceof IInventory) {
-+ entityhuman.openContainer((IInventory) tileentity);
- return EnumInteractionResult.SUCCESS;
- }
-- }
++ if (event.useInteractedBlock() == Event.Result.DENY) {
++ // If we denied a door from opening, we need to send a correcting update to the client, as it already opened the door.
++ if (iblockdata.getBlock() instanceof BlockDoor) {
++ boolean bottom = iblockdata.get(BlockDoor.HALF) == BlockPropertyDoubleBlockHalf.LOWER;
++ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutBlockChange(world, bottom ? blockposition.up() : blockposition.down()));
++ } else if (iblockdata.getBlock() instanceof BlockCake) {
++ ((EntityPlayer) entityhuman).getBukkitEntity().sendHealthUpdate(); // SPIGOT-1341 - reset health for cake
++ }
++ ((EntityPlayer) entityhuman).getBukkitEntity().updateInventory(); // SPIGOT-2867
++ enuminteractionresult = (event.useItemInHand() != Event.Result.ALLOW) ? EnumInteractionResult.SUCCESS : EnumInteractionResult.PASS;
++ } else if (this.gamemode == EnumGamemode.SPECTATOR) {
++ TileEntity tileentity = world.getTileEntity(blockposition);
-- if (itemstack.isEmpty()) {
+ if (tileentity instanceof ITileInventory) {
+ Block block = iblockdata.getBlock();
+@@ -304,26 +486,26 @@
+ } else {
+ boolean flag = entityhuman.getItemInMainHand().isEmpty();
+
+- if ((!entityhuman.isSneaking() || flag && entityhuman.getItemInOffHand().isEmpty()) && iblockdata.interact(world, blockposition, entityhuman, enumhand, enumdirection, f, f1, f2)) {
+- return EnumInteractionResult.SUCCESS;
+- } else if (flag) {
- return EnumInteractionResult.PASS;
- } else if (entityhuman.getCooldownTracker().a(itemstack.getItem())) {
- return EnumInteractionResult.PASS;
- } else {
-- if (itemstack.getItem() instanceof ItemBlock && !entityhuman.isCreativeAndOp()) {
-- Block block1 = ((ItemBlock) itemstack.getItem()).getBlock();
-+ if (!entityhuman.isSneaking() || entityhuman.getItemInMainHand().isEmpty() && entityhuman.getItemInOffHand().isEmpty()) {
-+ IBlockData iblockdata = world.getType(blockposition);
-
-- if (block1 instanceof BlockCommand || block1 instanceof BlockStructure) {
-- return EnumInteractionResult.FAIL;
-- }
-+ enuminteractionresult = iblockdata.getBlock().interact(world, blockposition, iblockdata, entityhuman, enumhand, enumdirection, f, f1, f2) ? EnumInteractionResult.SUCCESS : EnumInteractionResult.PASS;
- }
+- return EnumInteractionResult.PASS;
+- } else {
++ if ((!entityhuman.isSneaking() || flag && entityhuman.getItemInOffHand().isEmpty())) {
++ enuminteractionresult = iblockdata.interact(world, blockposition, entityhuman, enumhand, enumdirection, f, f1, f2) ? EnumInteractionResult.SUCCESS : EnumInteractionResult.FAIL;
+ }
-
-- if (this.isCreative()) {
-- int i = itemstack.getData();
-- int j = itemstack.getCount();
-- EnumInteractionResult enuminteractionresult = itemstack.placeItem(entityhuman, world, blockposition, enumhand, enumdirection, f, f1, f2);
-+ if (!itemstack.isEmpty() && enuminteractionresult != EnumInteractionResult.SUCCESS && !interactResult) { // add !interactResult SPIGOT-764
-+ int i = itemstack.getData();
-+ int j = itemstack.getCount();
+
-+ enuminteractionresult = itemstack.placeItem(entityhuman, world, blockposition, enumhand, enumdirection, f, f1, f2);
++ if (!itemstack.isEmpty() && !flag && enuminteractionresult != EnumInteractionResult.SUCCESS && !interactResult) { // add !interactResult SPIGOT-764 // MC-133478 - add isEmpty
+ ItemActionContext itemactioncontext = new ItemActionContext(entityhuman, entityhuman.b(enumhand), blockposition, enumdirection, f, f1, f2);
+
+ if (this.isCreative()) {
+ int i = itemstack.getCount();
+- EnumInteractionResult enuminteractionresult = itemstack.placeItem(itemactioncontext);
++ enuminteractionresult = itemstack.placeItem(itemactioncontext, enumhand);
-+ // The item count should not decrement in Creative mode.
-+ if (this.isCreative()) {
- itemstack.setData(i);
- itemstack.setCount(j);
-- return enuminteractionresult;
-- } else {
-- return itemstack.placeItem(entityhuman, world, blockposition, enumhand, enumdirection, f, f1, f2);
+ itemstack.setCount(i);
+ return enuminteractionresult;
+ } else {
+- return itemstack.placeItem(itemactioncontext);
++ return itemstack.placeItem(itemactioncontext, enumhand);
}
}
}
diff --git a/nms-patches/PlayerInventory.patch b/nms-patches/PlayerInventory.patch
index 2b4f94a0..9058f988 100644
--- a/nms-patches/PlayerInventory.patch
+++ b/nms-patches/PlayerInventory.patch
@@ -1,7 +1,7 @@
--- a/net/minecraft/server/PlayerInventory.java
+++ b/net/minecraft/server/PlayerInventory.java
-@@ -5,6 +5,15 @@
- import java.util.List;
+@@ -6,6 +6,15 @@
+ import java.util.function.Predicate;
import javax.annotation.Nullable;
+// CraftBukkit start
@@ -16,7 +16,7 @@
public class PlayerInventory implements IInventory {
public final NonNullList<ItemStack> items;
-@@ -16,6 +25,49 @@
+@@ -17,6 +26,49 @@
private ItemStack carried;
private int h;
@@ -66,8 +66,8 @@
public PlayerInventory(EntityHuman entityhuman) {
this.items = NonNullList.a(36, ItemStack.a);
this.armor = NonNullList.a(4, ItemStack.a);
-@@ -41,6 +93,23 @@
- return itemstack.getItem() == itemstack1.getItem() && (!itemstack.usesData() || itemstack.getData() == itemstack1.getData()) && ItemStack.equals(itemstack, itemstack1);
+@@ -42,6 +94,23 @@
+ return itemstack.getItem() == itemstack1.getItem() && ItemStack.equals(itemstack, itemstack1);
}
+ // CraftBukkit start - Watch method above! :D
@@ -78,7 +78,7 @@
+ if (itemstack1.isEmpty()) return itemstack.getCount();
+
+ // Taken from firstPartial(ItemStack)
-+ 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)) {
++ if (!this.a(itemstack, itemstack1)) {
+ remains -= (itemstack1.getMaxStackSize() < this.getMaxStackSize() ? itemstack1.getMaxStackSize() : this.getMaxStackSize()) - itemstack1.getCount();
+ }
+ if (remains <= 0) return itemstack.getCount();
@@ -90,7 +90,7 @@
public int getFirstEmptySlotIndex() {
for (int i = 0; i < this.items.size(); ++i) {
if (((ItemStack) this.items.get(i)).isEmpty()) {
-@@ -524,7 +593,7 @@
+@@ -502,7 +571,7 @@
}
public int getMaxStackSize() {
@@ -99,7 +99,7 @@
}
public boolean b(IBlockData iblockdata) {
-@@ -580,6 +649,11 @@
+@@ -552,6 +621,11 @@
}
public ItemStack getCarried() {
diff --git a/nms-patches/PlayerList.patch b/nms-patches/PlayerList.patch
index b50031bc..29ed2522 100644
--- a/nms-patches/PlayerList.patch
+++ b/nms-patches/PlayerList.patch
@@ -74,8 +74,8 @@
+ // this.p = Maps.newHashMap();
+ // CraftBukkit end
this.server = minecraftserver;
- this.k.a(false);
- this.l.a(false);
+ this.getProfileBans().a(true);
+ this.getIPBans().a(true);
@@ -65,6 +100,12 @@
usercache.a(gameprofile);
@@ -93,9 +93,9 @@
s1 = networkmanager.getSocketAddress().toString();
}
-- PlayerList.f.info("{}[{}] logged in with entity id {} at ({}, {}, {})", entityplayer.getName(), s1, Integer.valueOf(entityplayer.getId()), Double.valueOf(entityplayer.locX), Double.valueOf(entityplayer.locY), Double.valueOf(entityplayer.locZ));
+- PlayerList.f.info("{}[{}] logged in with entity id {} at ({}, {}, {})", entityplayer.getDisplayName().getString(), s1, Integer.valueOf(entityplayer.getId()), Double.valueOf(entityplayer.locX), Double.valueOf(entityplayer.locY), Double.valueOf(entityplayer.locZ));
+ // CraftBukkit - Moved message to after join
-+ // PlayerList.f.info("{}[{}] logged in with entity id {} at ({}, {}, {})", entityplayer.getName(), s1, Integer.valueOf(entityplayer.getId()), Double.valueOf(entityplayer.locX), Double.valueOf(entityplayer.locY), Double.valueOf(entityplayer.locZ));
++ // PlayerList.f.info("{}[{}] logged in with entity id {} at ({}, {}, {})", entityplayer.getDisplayName().getString(), 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();
@@ -104,49 +104,32 @@
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 PacketPlayOutCustomPayload(PacketPlayOutCustomPayload.b, (new PacketDataSerializer(Unpooled.buffer())).a(this.getServer().getServerModName())));
playerconnection.sendPacket(new PacketPlayOutServerDifficulty(worlddata.getDifficulty(), worlddata.isDifficultyLocked()));
playerconnection.sendPacket(new PacketPlayOutAbilities(entityplayer.abilities));
-@@ -91,17 +134,23 @@
- entityplayer.F().a(entityplayer);
- this.sendScoreboard((ScoreboardServer) worldserver.getScoreboard(), entityplayer);
- this.server.aD();
-- ChatMessage chatmessage;
-+ // CraftBukkit start - login message is handled in the event
-+ // ChatMessage chatmessage;
-
-+ String joinMessage;
- if (entityplayer.getName().equalsIgnoreCase(s)) {
-- chatmessage = new ChatMessage("multiplayer.player.joined", new Object[] { entityplayer.getScoreboardDisplayName()});
-+ // chatmessage = new ChatMessage("multiplayer.player.joined", new Object[] { entityplayer.getScoreboardDisplayName()});
-+ joinMessage = "\u00A7e" + LocaleI18n.a("multiplayer.player.joined", entityplayer.getName());
- } else {
-- chatmessage = new ChatMessage("multiplayer.player.joined.renamed", new Object[] { entityplayer.getScoreboardDisplayName(), s});
-+ // chatmessage = new ChatMessage("multiplayer.player.joined.renamed", new Object[] { entityplayer.getScoreboardDisplayName(), s});
-+ joinMessage = "\u00A7e" + LocaleI18n.a("multiplayer.player.joined.renamed", entityplayer.getName(), s);
+@@ -101,8 +144,10 @@
+ chatmessage = new ChatMessage("multiplayer.player.joined.renamed", new Object[] { entityplayer.getScoreboardDisplayName(), s});
}
-- chatmessage.getChatModifier().setColor(EnumChatFormat.YELLOW);
-- this.sendMessage(chatmessage);
+- this.sendMessage(chatmessage.a(EnumChatFormat.YELLOW));
- this.onPlayerJoin(entityplayer);
-+ // chatmessage.getChatModifier().setColor(EnumChatFormat.YELLOW);
-+ // this.sendMessage(chatmessage);
-+ this.onPlayerJoin(entityplayer, joinMessage);
++ chatmessage.a(EnumChatFormat.YELLOW);
++ this.onPlayerJoin(entityplayer, CraftChatMessage.fromComponent(chatmessage));
+ // CraftBukkit end
+ worldserver = server.getWorldServer(entityplayer.dimension); // CraftBukkit - Update in case join event changed it
playerconnection.a(entityplayer.locX, entityplayer.locY, entityplayer.locZ, entityplayer.yaw, entityplayer.pitch);
this.b(entityplayer, worldserver);
if (!this.server.getResourcePack().isEmpty()) {
-@@ -153,6 +202,8 @@
+@@ -154,6 +199,8 @@
}
entityplayer.syncInventory();
+ // CraftBukkit - Moved from above, added world
-+ PlayerList.f.info(entityplayer.getName() + "[" + s1 + "] logged in with entity id " + entityplayer.getId() + " at ([" + entityplayer.world.worldData.getName() + "]" + entityplayer.locX + ", " + entityplayer.locY + ", " + entityplayer.locZ + ")");
++ PlayerList.f.info("{}[{}] logged in with entity id {} at ([{}]{}, {}, {})", entityplayer.getDisplayName().getString(), s1, Integer.valueOf(entityplayer.getId()), entityplayer.world.worldData.getName(), Double.valueOf(entityplayer.locX), Double.valueOf(entityplayer.locY), Double.valueOf(entityplayer.locZ));
}
public void sendScoreboard(ScoreboardServer scoreboardserver, EntityPlayer entityplayer) {
-@@ -185,26 +236,27 @@
+@@ -186,26 +233,27 @@
}
public void setPlayerFileData(WorldServer[] aworldserver) {
@@ -179,7 +162,7 @@
}
public void b(WorldBorder worldborder, double d0) {}
-@@ -237,7 +289,7 @@
+@@ -238,7 +286,7 @@
@Nullable
public NBTTagCompound a(EntityPlayer entityplayer) {
@@ -187,8 +170,8 @@
+ NBTTagCompound nbttagcompound = this.server.worlds.get(0).getWorldData().h(); // CraftBukkit
NBTTagCompound nbttagcompound1;
- if (entityplayer.getName().equals(this.server.Q()) && nbttagcompound != null) {
-@@ -253,13 +305,13 @@
+ if (entityplayer.getDisplayName().getString().equals(this.server.I()) && nbttagcompound != null) {
+@@ -254,13 +302,13 @@
protected void savePlayerFile(EntityPlayer entityplayer) {
this.playerFileData.save(entityplayer);
@@ -196,7 +179,7 @@
+ ServerStatisticManager serverstatisticmanager = (ServerStatisticManager) entityplayer.getStatisticManager(); // CraftBukkit
if (serverstatisticmanager != null) {
- serverstatisticmanager.b();
+ serverstatisticmanager.a();
}
- AdvancementDataPlayer advancementdataplayer = (AdvancementDataPlayer) this.p.get(entityplayer.getUniqueID());
@@ -204,7 +187,7 @@
if (advancementdataplayer != null) {
advancementdataplayer.c();
-@@ -267,28 +319,79 @@
+@@ -268,29 +316,80 @@
}
@@ -259,23 +242,25 @@
- worldserver.addEntity(entityplayer);
- this.a(entityplayer, (WorldServer) null);
+- this.server.aR().a(entityplayer);
+ // CraftBukkit start - Only add if the player wasn't moved in the event
+ if (entityplayer.world == worldserver && !worldserver.players.contains(entityplayer)) {
+ worldserver.addEntity(entityplayer);
+ this.a(entityplayer, (WorldServer) null);
++ this.server.aR().a(entityplayer);
+ }
+ // CraftBukkit end
}
public void d(EntityPlayer entityplayer) {
- entityplayer.x().getPlayerChunkMap().movePlayer(entityplayer);
+ entityplayer.getWorldServer().getPlayerChunkMap().movePlayer(entityplayer);
}
- public void disconnect(EntityPlayer entityplayer) {
+ public String disconnect(EntityPlayer entityplayer) { // CraftBukkit - return string
- WorldServer worldserver = entityplayer.x();
+ WorldServer worldserver = entityplayer.getWorldServer();
- entityplayer.b(StatisticList.f);
+ entityplayer.a(StatisticList.LEAVE_GAME);
+
+ // CraftBukkit start - Quitting must be before we do final save of data, in case plugins need to modify it
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleInventoryCloseEvent(entityplayer);
@@ -289,8 +274,8 @@
+
this.savePlayerFile(entityplayer);
if (entityplayer.isPassenger()) {
- Entity entity = entityplayer.getVehicle();
-@@ -318,17 +421,67 @@
+ Entity entity = entityplayer.getRootVehicle();
+@@ -321,18 +420,68 @@
if (entityplayer1 == entityplayer) {
this.j.remove(uuid);
@@ -324,9 +309,13 @@
+ return playerQuitEvent.getQuitMessage(); // CraftBukkit
}
-- public String attemptLogin(SocketAddress socketaddress, GameProfile gameprofile) {
+- @Nullable
+- public IChatBaseComponent attemptLogin(SocketAddress socketaddress, GameProfile gameprofile) {
+ // CraftBukkit start - Whole method, SocketAddress to LoginListener, added hostname to signature, return EntityPlayer
+ public EntityPlayer attemptLogin(LoginListener loginlistener, GameProfile gameprofile, String hostname) {
+ ChatMessage chatmessage;
+
+- if (this.k.isBanned(gameprofile)) {
+ // Moved from processLogin
+ UUID uuid = EntityHuman.a(gameprofile);
+ ArrayList arraylist = Lists.newArrayList();
@@ -353,52 +342,50 @@
+ // depending on the outcome.
+ SocketAddress socketaddress = loginlistener.networkManager.getSocketAddress();
+
-+ EntityPlayer entity = new EntityPlayer(server, server.getWorldServer(0), gameprofile, new PlayerInteractManager(server.getWorldServer(0)));
++ EntityPlayer entity = new EntityPlayer(this.server, this.server.a(DimensionManager.OVERWORLD), gameprofile, new PlayerInteractManager(this.server.a(DimensionManager.OVERWORLD)));
+ Player player = entity.getBukkitEntity();
+ PlayerLoginEvent event = new PlayerLoginEvent(player, hostname, ((java.net.InetSocketAddress) socketaddress).getAddress());
- String s;
-
-- if (this.k.isBanned(gameprofile)) {
++
+ if (getProfileBans().isBanned(gameprofile) && !getProfileBans().get(gameprofile).hasExpired()) {
GameProfileBanEntry gameprofilebanentry = (GameProfileBanEntry) this.k.get(gameprofile);
- s = "You are banned from this server!\nReason: " + gameprofilebanentry.getReason();
-@@ -336,10 +489,12 @@
- s = s + "\nYour ban will be removed on " + PlayerList.g.format(gameprofilebanentry.getExpires());
+ chatmessage = new ChatMessage("multiplayer.disconnect.banned.reason", new Object[] { gameprofilebanentry.getReason()});
+@@ -340,10 +489,12 @@
+ chatmessage.addSibling(new ChatMessage("multiplayer.disconnect.banned.expiration", new Object[] { PlayerList.g.format(gameprofilebanentry.getExpires())}));
}
-- return s;
-+ // return s;
-+ event.disallow(PlayerLoginEvent.Result.KICK_BANNED, s);
+- return chatmessage;
++ // return chatmessage;
++ event.disallow(PlayerLoginEvent.Result.KICK_BANNED, CraftChatMessage.fromComponent(chatmessage));
} else if (!this.isWhitelisted(gameprofile)) {
-- return "You are not white-listed on this server!";
+- return new ChatMessage("multiplayer.disconnect.not_whitelisted", new Object[0]);
- } else if (this.l.isBanned(socketaddress)) {
-+ // return "You are not white-listed on this server!";
-+ event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, "You are not white-listed on this server!");
++ chatmessage = new ChatMessage("multiplayer.disconnect.not_whitelisted", new Object[0]);
++ event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, CraftChatMessage.fromComponent(chatmessage));
+ } else if (getIPBans().isBanned(socketaddress) && !getIPBans().get(socketaddress).hasExpired()) {
IpBanEntry ipbanentry = this.l.get(socketaddress);
- s = "Your IP address is banned from this server!\nReason: " + ipbanentry.getReason();
-@@ -347,13 +502,25 @@
- s = s + "\nYour ban will be removed on " + PlayerList.g.format(ipbanentry.getExpires());
+ chatmessage = new ChatMessage("multiplayer.disconnect.banned_ip.reason", new Object[] { ipbanentry.getReason()});
+@@ -351,13 +502,25 @@
+ chatmessage.addSibling(new ChatMessage("multiplayer.disconnect.banned_ip.expiration", new Object[] { PlayerList.g.format(ipbanentry.getExpires())}));
}
-- return s;
-+ // return s;
-+ event.disallow(PlayerLoginEvent.Result.KICK_BANNED, s);
+- return chatmessage;
++ // return chatmessage;
++ event.disallow(PlayerLoginEvent.Result.KICK_BANNED, CraftChatMessage.fromComponent(chatmessage));
} else {
-- return this.players.size() >= this.maxPlayers && !this.f(gameprofile) ? "The server is full!" : null;
-+ // return this.players.size() >= this.maxPlayers && !this.f(gameprofile) ? "The server is full!" : null;
+- return this.players.size() >= this.maxPlayers && !this.f(gameprofile) ? new ChatMessage("multiplayer.disconnect.server_full", new Object[0]) : null;
++ // return this.players.size() >= this.maxPlayers && !this.f(gameprofile) ? new ChatMessage("multiplayer.disconnect.server_full", new Object[0]) : null;
+ if (this.players.size() >= this.maxPlayers && !this.f(gameprofile)) {
+ event.disallow(PlayerLoginEvent.Result.KICK_FULL, "The server is full");
+ }
- }
++ }
+
+ cserver.getPluginManager().callEvent(event);
+ if (event.getResult() != PlayerLoginEvent.Result.ALLOWED) {
+ loginlistener.disconnect(event.getKickMessage());
+ return null;
-+ }
+ }
+ return entity;
}
@@ -408,10 +395,10 @@
UUID uuid = EntityHuman.a(gameprofile);
ArrayList arraylist = Lists.newArrayList();
-@@ -388,17 +555,27 @@
+@@ -392,17 +555,27 @@
}
- return new EntityPlayer(this.server, this.server.getWorldServer(0), gameprofile, (PlayerInteractManager) object);
+ return new EntityPlayer(this.server, this.server.a(DimensionManager.OVERWORLD), gameprofile, (PlayerInteractManager) object);
+ */
+ return player;
+ // CraftBukkit end
@@ -424,10 +411,10 @@
+
+ public EntityPlayer moveToWorld(EntityPlayer entityplayer, int i, boolean flag, Location location, boolean avoidSuffocation) {
+ entityplayer.stopRiding(); // CraftBukkit
- entityplayer.x().getTracker().untrackPlayer(entityplayer);
-- entityplayer.x().getTracker().untrackEntity(entityplayer);
-+ // entityplayer.x().getTracker().untrackEntity(entityplayer); // CraftBukkit
- entityplayer.x().getPlayerChunkMap().removePlayer(entityplayer);
+ entityplayer.getWorldServer().getTracker().untrackPlayer(entityplayer);
+- entityplayer.getWorldServer().getTracker().untrackEntity(entityplayer);
++ // entityplayer.getWorldServer().getTracker().untrackEntity(entityplayer); // CraftBukkit
+ entityplayer.getWorldServer().getPlayerChunkMap().removePlayer(entityplayer);
this.players.remove(entityplayer);
this.server.getWorldServer(entityplayer.dimension).removeEntity(entityplayer);
BlockPosition blockposition = entityplayer.getBed();
@@ -437,7 +424,7 @@
entityplayer.dimension = i;
Object object;
-@@ -409,6 +586,11 @@
+@@ -413,6 +586,11 @@
}
EntityPlayer entityplayer1 = new EntityPlayer(this.server, this.server.getWorldServer(entityplayer.dimension), entityplayer.getProfile(), (PlayerInteractManager) object);
@@ -449,7 +436,7 @@
entityplayer1.playerConnection = entityplayer.playerConnection;
entityplayer1.copyFrom(entityplayer, flag);
-@@ -423,43 +605,166 @@
+@@ -426,43 +604,166 @@
entityplayer1.addScoreboardTag(s);
}
@@ -484,7 +471,7 @@
+
+ if (location == null) {
+ cworld = (CraftWorld) this.server.server.getWorlds().get(0);
-+ blockposition = entityplayer1.getSpawnPoint(this.server, cworld.getHandle());
++ blockposition = entityplayer1.getSpawnPoint(cworld.getHandle());
+ location = new Location(cworld, (double) ((float) blockposition.getX() + 0.5F), (double) ((float) blockposition.getY() + 0.1F), (double) ((float) blockposition.getZ() + 0.5F));
}
+
@@ -503,8 +490,8 @@
worldserver.getChunkProviderServer().getChunkAt((int) entityplayer1.locX >> 4, (int) entityplayer1.locZ >> 4);
-- while (!worldserver.getCubes(entityplayer1, entityplayer1.getBoundingBox()).isEmpty() && entityplayer1.locY < 256.0D) {
-+ while (avoidSuffocation && !worldserver.getCubes(entityplayer1, entityplayer1.getBoundingBox()).isEmpty() && entityplayer1.locY < 256.0D) {
+- while (!worldserver.getCubes(entityplayer1, entityplayer1.getBoundingBox()) && entityplayer1.locY < 256.0D) {
++ while (avoidSuffocation && !worldserver.getCubes(entityplayer1, entityplayer1.getBoundingBox()) && entityplayer1.locY < 256.0D) {
entityplayer1.setPosition(entityplayer1.locX, entityplayer1.locY + 1.0D, entityplayer1.locZ);
}
+ // CraftBukkit start
@@ -549,9 +536,9 @@
+ }
+
+ // Fire advancement trigger
-+ CriterionTriggers.u.a(entityplayer, ((CraftWorld) fromWorld).getHandle().worldProvider.getDimensionManager(), worldserver.worldProvider.getDimensionManager());
-+ if (((CraftWorld) fromWorld).getHandle().worldProvider.getDimensionManager() == DimensionManager.NETHER && worldserver.worldProvider.getDimensionManager() == DimensionManager.OVERWORLD && entityplayer.Q() != null) {
-+ CriterionTriggers.B.a(entityplayer, entityplayer.Q());
++ CriterionTriggers.v.a(entityplayer, ((CraftWorld) fromWorld).getHandle().worldProvider.getDimensionManager(), worldserver.worldProvider.getDimensionManager());
++ if (((CraftWorld) fromWorld).getHandle().worldProvider.getDimensionManager() == DimensionManager.NETHER && worldserver.worldProvider.getDimensionManager() == DimensionManager.OVERWORLD && entityplayer.M() != null) {
++ CriterionTriggers.C.a(entityplayer, entityplayer.M());
+ }
+
+ // Don't fire on respawn
@@ -588,7 +575,7 @@
+ // THE_END -> NORMAL; use bed if available, otherwise default spawn
+ exit = ((org.bukkit.craftbukkit.entity.CraftPlayer) entityplayer.getBukkitEntity()).getBedSpawnLocation();
+ if (exit == null || ((CraftWorld) exit.getWorld()).getHandle().dimension != 0) {
-+ BlockPosition randomSpawn = entityplayer.getSpawnPoint(server, exitWorld);
++ BlockPosition randomSpawn = entityplayer.getSpawnPoint(exitWorld);
+ exit = new Location(exitWorld.getWorld(), randomSpawn.getX(), randomSpawn.getY(), randomSpawn.getZ());
+ } else {
+ exit = exit.add(0.5F, 0.1F, 0.5F); // SPIGOT-3879
@@ -633,7 +620,16 @@
public void f(EntityPlayer entityplayer) {
GameProfile gameprofile = entityplayer.getProfile();
int i = this.isOp(gameprofile) ? this.operators.a(gameprofile) : 0;
-@@ -498,12 +803,111 @@
+@@ -470,7 +771,7 @@
+ boolean flag1 = flag && this.server.I().equalsIgnoreCase(entityplayer.getProfile().getName());
+ int j = flag1 ? 4 : 2;
+
+- i = flag && this.server.worldServer[0].getWorldData().u() ? j : i;
++ i = flag && this.server.worlds.get(0).getWorldData().u() ? j : i; // CraftBukkit
+ i = this.u ? j : i;
+ this.b(entityplayer, i);
+ }
+@@ -504,12 +805,111 @@
}
public void changeWorld(Entity entity, int i, WorldServer worldserver, WorldServer worldserver1) {
@@ -655,13 +651,13 @@
+ double d1 = enter.getZ();
+ double d2 = 8.0D;
+ /*
-+ double d0 = entity.locX;
-+ double d1 = entity.locZ;
-+ double d2 = 8.0D;
-+ float f = entity.yaw;
+ double d0 = entity.locX;
+ double d1 = entity.locZ;
+ double d2 = 8.0D;
+ float f = entity.yaw;
+ */
-+
-+ worldserver.methodProfiler.a("moving");
+
+ worldserver.methodProfiler.a("moving");
+ if (worldserver1.dimension == -1) {
+ d0 = MathHelper.a(d0 / d2, worldserver1.getWorldBorder().b()+ 16.0D, worldserver1.getWorldBorder().d() - 16.0D);
+ d1 = MathHelper.a(d1 / d2, worldserver1.getWorldBorder().c() + 16.0D, worldserver1.getWorldBorder().e() - 16.0D);
@@ -730,13 +726,13 @@
+ int i = worldserver.dimension;
+
+ /*
- double d0 = entity.locX;
- double d1 = entity.locZ;
- double d2 = 8.0D;
- float f = entity.yaw;
++ double d0 = entity.locX;
++ double d1 = entity.locZ;
++ double d2 = 8.0D;
++ float f = entity.yaw;
+ */
-
- worldserver.methodProfiler.a("moving");
++
++ worldserver.methodProfiler.a("moving");
+ entity.setPositionRotation(exit.getX(), exit.getY(), exit.getZ(), exit.getYaw(), exit.getPitch());
+ if (entity.isAlive()) {
+ worldserver.entityJoinedWorld(entity, false);
@@ -745,7 +741,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);
-@@ -522,6 +926,8 @@
+@@ -528,6 +928,8 @@
BlockPosition blockposition;
if (i == 1) {
@@ -754,13 +750,13 @@
blockposition = worldserver1.getSpawn();
} else {
blockposition = worldserver1.getDimensionSpawn();
-@@ -535,16 +941,27 @@
+@@ -541,16 +943,27 @@
worldserver.entityJoinedWorld(entity, false);
}
}
+ */
- worldserver.methodProfiler.b();
+ worldserver.methodProfiler.e();
if (i != 1) {
worldserver.methodProfiler.a("placing");
+ /*
@@ -785,7 +781,7 @@
worldserver1.entityJoinedWorld(entity, false);
}
-@@ -552,11 +969,23 @@
+@@ -558,11 +971,23 @@
}
entity.spawnIn(worldserver1);
@@ -810,7 +806,7 @@
this.v = 0;
}
-@@ -569,6 +998,25 @@
+@@ -575,6 +1000,25 @@
}
@@ -836,40 +832,24 @@
public void a(Packet<?> packet, int i) {
for (int j = 0; j < this.players.size(); ++j) {
EntityPlayer entityplayer = (EntityPlayer) this.players.get(j);
-@@ -667,11 +1115,23 @@
-
- this.operators.add(new OpListEntry(gameprofile, this.server.q(), this.operators.b(gameprofile)));
- this.b(this.a(gameprofile.getId()), i);
-+ // CraftBukkit start
-+ Player player = server.server.getPlayer(gameprofile.getId());
-+ if (player != null) {
-+ player.recalculatePermissions();
-+ }
-+ // CraftBukkit end
- }
+@@ -677,6 +1121,7 @@
+ entityplayer.playerConnection.sendPacket(new PacketPlayOutEntityStatus(entityplayer, b0));
+ }
- public void removeOp(GameProfile gameprofile) {
- this.operators.remove(gameprofile);
- this.b(this.a(gameprofile.getId()), 0);
-+ // CraftBukkit start
-+ Player player = server.server.getPlayer(gameprofile.getId());
-+ if (player != null) {
-+ player.recalculatePermissions();
-+ }
-+ // CraftBukkit end
++ entityplayer.getBukkitEntity().recalculatePermissions(); // CraftBukkit
+ this.server.getCommandDispatcher().a(entityplayer);
}
- private void b(EntityPlayer entityplayer, int i) {
-@@ -696,7 +1156,7 @@
+@@ -685,7 +1130,7 @@
}
public boolean isOp(GameProfile gameprofile) {
-- return this.operators.d(gameprofile) || this.server.R() && this.server.worldServer[0].getWorldData().u() && this.server.Q().equalsIgnoreCase(gameprofile.getName()) || this.u;
-+ return this.operators.d(gameprofile) || this.server.R() && this.server.worlds.get(0).getWorldData().u() && this.server.Q().equalsIgnoreCase(gameprofile.getName()) || this.u; // CraftBukkit
+- return this.operators.d(gameprofile) || this.server.J() && this.server.worldServer[0].getWorldData().u() && this.server.I().equalsIgnoreCase(gameprofile.getName()) || this.u;
++ return this.operators.d(gameprofile) || this.server.J() && this.server.worlds.get(0).getWorldData().u() && this.server.I().equalsIgnoreCase(gameprofile.getName()) || this.u; // CraftBukkit
}
@Nullable
-@@ -720,6 +1180,12 @@
+@@ -709,6 +1154,12 @@
for (int j = 0; j < this.players.size(); ++j) {
EntityPlayer entityplayer = (EntityPlayer) this.players.get(j);
@@ -882,7 +862,7 @@
if (entityplayer != entityhuman && entityplayer.dimension == i) {
double d4 = d0 - entityplayer.locX;
double d5 = d1 - entityplayer.locY;
-@@ -767,7 +1233,7 @@
+@@ -748,7 +1199,7 @@
public void reloadWhitelist() {}
public void b(EntityPlayer entityplayer, WorldServer worldserver) {
@@ -891,17 +871,17 @@
entityplayer.playerConnection.sendPacket(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.INITIALIZE));
entityplayer.playerConnection.sendPacket(new PacketPlayOutUpdateTime(worldserver.getTime(), worldserver.getDayTime(), worldserver.getGameRules().getBoolean("doDaylightCycle")));
-@@ -775,16 +1241,21 @@
+@@ -756,16 +1207,21 @@
entityplayer.playerConnection.sendPacket(new PacketPlayOutSpawnPosition(blockposition));
if (worldserver.isRaining()) {
- entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(1, 0.0F));
-- entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(7, worldserver.j(1.0F)));
-- entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(8, worldserver.h(1.0F)));
+- entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(7, worldserver.i(1.0F)));
+- entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(8, worldserver.g(1.0F)));
+ // CraftBukkit start - handle player weather
+ // entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(1, 0.0F));
-+ // entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(7, worldserver.j(1.0F)));
-+ // entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(8, worldserver.h(1.0F)));
++ // entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(7, worldserver.i(1.0F)));
++ // entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(8, worldserver.g(1.0F)));
+ entityplayer.setPlayerWeather(org.bukkit.WeatherType.DOWNFALL, false);
+ entityplayer.updateWeather(-worldserver.o, worldserver.o, -worldserver.q, worldserver.q);
+ // CraftBukkit end
@@ -917,7 +897,7 @@
entityplayer.playerConnection.sendPacket(new PacketPlayOutHeldItemSlot(entityplayer.inventory.itemInHandIndex));
}
-@@ -797,7 +1268,7 @@
+@@ -778,7 +1234,7 @@
}
public String[] getSeenPlayers() {
@@ -926,7 +906,7 @@
}
public boolean getHasWhitelist() {
-@@ -846,26 +1317,39 @@
+@@ -827,26 +1283,39 @@
}
public void u() {
@@ -970,17 +950,17 @@
+ // CraftBukkit end
if (serverstatisticmanager == null) {
- File file = new File(this.server.getWorldServer(0).getDataManager().getDirectory(), "stats");
-@@ -881,7 +1365,7 @@
+ File file = new File(this.server.a(DimensionManager.OVERWORLD).getDataManager().getDirectory(), "stats");
+@@ -861,7 +1330,7 @@
+ }
serverstatisticmanager = new ServerStatisticManager(this.server, file1);
- serverstatisticmanager.a();
- this.o.put(uuid, serverstatisticmanager);
+ // this.o.put(uuid, serverstatisticmanager); // CraftBukkit
}
return serverstatisticmanager;
-@@ -889,14 +1373,14 @@
+@@ -869,14 +1338,14 @@
public AdvancementDataPlayer h(EntityPlayer entityplayer) {
UUID uuid = entityplayer.getUniqueID();
@@ -988,7 +968,7 @@
+ AdvancementDataPlayer advancementdataplayer = (AdvancementDataPlayer) entityplayer.getAdvancementData(); // CraftBukkit
if (advancementdataplayer == null) {
- File file = new File(this.server.getWorldServer(0).getDataManager().getDirectory(), "advancements");
+ File file = new File(this.server.a(DimensionManager.OVERWORLD).getDataManager().getDirectory(), "advancements");
File file1 = new File(file, uuid + ".json");
advancementdataplayer = new AdvancementDataPlayer(this.server, file1, entityplayer);
@@ -997,7 +977,7 @@
}
advancementdataplayer.a(entityplayer);
-@@ -909,8 +1393,10 @@
+@@ -889,8 +1358,10 @@
WorldServer[] aworldserver = this.server.worldServer;
int j = aworldserver.length;
@@ -1010,7 +990,7 @@
if (worldserver != null) {
worldserver.getPlayerChunkMap().a(i);
-@@ -934,13 +1420,20 @@
+@@ -915,13 +1386,20 @@
}
public void reload() {
@@ -1030,5 +1010,5 @@
}
+ // CraftBukkit end
- }
- }
+ this.sendAll(new PacketPlayOutTags(this.server.getTagRegistry()));
+ PacketPlayOutRecipeUpdate packetplayoutrecipeupdate = new PacketPlayOutRecipeUpdate(this.server.getCraftingManager().b());
diff --git a/nms-patches/PortalTravelAgent.patch b/nms-patches/PortalTravelAgent.patch
index 0c1c4e78..fd81d2dc 100644
--- a/nms-patches/PortalTravelAgent.patch
+++ b/nms-patches/PortalTravelAgent.patch
@@ -12,7 +12,7 @@
public class PortalTravelAgent {
-@@ -26,8 +31,21 @@
+@@ -27,8 +32,21 @@
int i = MathHelper.floor(entity.locX);
int j = MathHelper.floor(entity.locY) - 1;
int k = MathHelper.floor(entity.locZ);
@@ -36,7 +36,7 @@
for (int l = -2; l <= 2; ++l) {
for (int i1 = -2; i1 <= 2; ++i1) {
-@@ -42,18 +60,63 @@
+@@ -43,18 +61,63 @@
}
}
@@ -94,7 +94,7 @@
+
+ public BlockPosition findPortal(double x, double y, double z, int radius) {
+ if (this.world.getWorld().getEnvironment() == org.bukkit.World.Environment.THE_END) {
-+ return this.findEndPortal(this.world.worldProvider.h());
++ return this.findEndPortal(this.world.worldProvider.d());
+ }
+ // CraftBukkit end
double d0 = -1.0D;
@@ -107,7 +107,7 @@
boolean flag1 = true;
Object object = BlockPosition.ZERO;
long k = ChunkCoordIntPair.a(i, j);
-@@ -66,12 +129,12 @@
+@@ -67,12 +130,12 @@
portaltravelagent_chunkcoordinatesportal.b = this.world.getTime();
flag1 = false;
} else {
@@ -120,12 +120,12 @@
- for (int i1 = -128; i1 <= 128; ++i1) {
+ for (int i1 = -radius; i1 <= radius; ++i1) {
- for (BlockPosition blockposition2 = blockposition.a(l, this.world.ab() - 1 - blockposition.getY(), i1); blockposition2.getY() >= 0; blockposition2 = blockposition1) {
+ for (BlockPosition blockposition2 = blockposition.a(l, this.world.aa() - 1 - blockposition.getY(), i1); blockposition2.getY() >= 0; blockposition2 = blockposition1) {
blockposition1 = blockposition2.down();
- if (this.world.getType(blockposition2).getBlock() == Blocks.PORTAL) {
-@@ -95,6 +158,29 @@
+ if (this.world.getType(blockposition2).getBlock() == PortalTravelAgent.a) {
+@@ -96,6 +159,29 @@
if (flag1) {
- this.c.put(k, new PortalTravelAgent.ChunkCoordinatesPortal((BlockPosition) object, this.world.getTime()));
+ this.d.put(k, new PortalTravelAgent.ChunkCoordinatesPortal((BlockPosition) object, this.world.getTime()));
}
+ // CraftBukkit start - Move entity teleportation logic into exit
+ return (BlockPosition) object;
@@ -153,7 +153,7 @@
double d2 = (double) ((BlockPosition) object).getX() + 0.5D;
double d3 = (double) ((BlockPosition) object).getZ() + 0.5D;
-@@ -132,30 +218,59 @@
+@@ -133,31 +219,59 @@
f4 = 1.0F;
}
@@ -165,6 +165,7 @@
- entity.yaw = f - (float) (entity.getPortalDirection().opposite().get2DRotationValue() * 90) + (float) (shapedetector_shapedetectorcollection.getFacing().get2DRotationValue() * 90);
- if (entity instanceof EntityPlayer) {
- ((EntityPlayer) entity).playerConnection.a(d2, d5, d3, entity.yaw, entity.pitch);
+- ((EntityPlayer) entity).playerConnection.syncPosition();
- } else {
- entity.setPositionRotation(d2, d5, d3, entity.yaw, entity.pitch);
- }
@@ -231,7 +232,7 @@
int l = i;
int i1 = j;
int j1 = k;
-@@ -180,10 +295,10 @@
+@@ -182,10 +296,10 @@
double d4;
for (i2 = i - 16; i2 <= i + 16; ++i2) {
@@ -242,9 +243,9 @@
- d2 = (double) j2 + 0.5D - entity.locZ;
+ d2 = (double) j2 + 0.5D - z; // CraftBukkit
- label271:
- for (k2 = this.world.ab() - 1; k2 >= 0; --k2) {
-@@ -215,7 +330,7 @@
+ label257:
+ for (k2 = this.world.aa() - 1; k2 >= 0; --k2) {
+@@ -217,7 +331,7 @@
}
}
@@ -253,7 +254,7 @@
d4 = d1 * d1 + d3 * d3 + d2 * d2;
if (d0 < 0.0D || d4 < d0) {
d0 = d4;
-@@ -232,10 +347,10 @@
+@@ -234,10 +348,10 @@
if (d0 < 0.0D) {
for (i2 = i - 16; i2 <= i + 16; ++i2) {
@@ -264,9 +265,9 @@
- d2 = (double) j2 + 0.5D - entity.locZ;
+ d2 = (double) j2 + 0.5D - z; // CraftBukkit
- label219:
- for (k2 = this.world.ab() - 1; k2 >= 0; --k2) {
-@@ -260,7 +375,7 @@
+ label205:
+ for (k2 = this.world.aa() - 1; k2 >= 0; --k2) {
+@@ -262,7 +376,7 @@
}
}
@@ -275,7 +276,7 @@
d4 = d1 * d1 + d3 * d3 + d2 * d2;
if (d0 < 0.0D || d4 < d0) {
d0 = d4;
-@@ -359,5 +474,10 @@
+@@ -354,5 +468,10 @@
super(blockposition.getX(), blockposition.getY(), blockposition.getZ());
this.b = i;
}
diff --git a/nms-patches/RecipeArmorDye.patch b/nms-patches/RecipeArmorDye.patch
index 02407e68..6a4959d5 100644
--- a/nms-patches/RecipeArmorDye.patch
+++ b/nms-patches/RecipeArmorDye.patch
@@ -1,18 +1,18 @@
--- a/net/minecraft/server/RecipeArmorDye.java
+++ b/net/minecraft/server/RecipeArmorDye.java
-@@ -3,9 +3,13 @@
+@@ -3,11 +3,13 @@
import com.google.common.collect.Lists;
import java.util.ArrayList;
--public class RecipeArmorDye implements IRecipe {
+-public class RecipeArmorDye extends IRecipeComplex {
+public class RecipeArmorDye extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends
-- public RecipeArmorDye() {}
+ // CraftBukkit start - Delegate to new parent class with bogus info
-+ public RecipeArmorDye() {
-+ super("", new ItemStack(Items.LEATHER_HELMET, 0, 0), NonNullList.a(RecipeItemStack.a, RecipeItemStack.a(Items.DYE)));
-+ }
+ public RecipeArmorDye(MinecraftKey minecraftkey) {
+- super(minecraftkey);
++ super(minecraftkey, "", new ItemStack(Items.LEATHER_HELMET, 0), NonNullList.a(RecipeItemStack.a, RecipeItemStack.a(Items.BONE_MEAL)));
+ }
+ // CraftBukkit end
- public boolean a(InventoryCrafting inventorycrafting, World world) {
- ItemStack itemstack = ItemStack.a;
+ public boolean a(IInventory iinventory, World world) {
+ if (!(iinventory instanceof InventoryCrafting)) {
diff --git a/nms-patches/RecipeBannerAdd.patch b/nms-patches/RecipeBannerAdd.patch
new file mode 100644
index 00000000..37205198
--- /dev/null
+++ b/nms-patches/RecipeBannerAdd.patch
@@ -0,0 +1,18 @@
+--- a/net/minecraft/server/RecipeBannerAdd.java
++++ b/net/minecraft/server/RecipeBannerAdd.java
+@@ -2,11 +2,13 @@
+
+ import javax.annotation.Nullable;
+
+-public class RecipeBannerAdd extends IRecipeComplex {
++public class RecipeBannerAdd extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends
+
++ // CraftBukkit start - Delegate to new parent class with bogus info
+ public RecipeBannerAdd(MinecraftKey minecraftkey) {
+- super(minecraftkey);
++ super(minecraftkey, "", new ItemStack(Items.WHITE_BANNER, 0), NonNullList.a(RecipeItemStack.a, RecipeItemStack.a(Items.WHITE_BANNER)));
+ }
++ // CraftBukkit end
+
+ public boolean a(IInventory iinventory, World world) {
+ if (!(iinventory instanceof InventoryCrafting)) {
diff --git a/nms-patches/RecipeBannerDuplicate.patch b/nms-patches/RecipeBannerDuplicate.patch
new file mode 100644
index 00000000..f4020aca
--- /dev/null
+++ b/nms-patches/RecipeBannerDuplicate.patch
@@ -0,0 +1,17 @@
+--- a/net/minecraft/server/RecipeBannerDuplicate.java
++++ b/net/minecraft/server/RecipeBannerDuplicate.java
+@@ -1,10 +1,12 @@
+ package net.minecraft.server;
+
+-public class RecipeBannerDuplicate extends IRecipeComplex {
++public class RecipeBannerDuplicate extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends
+
++ // CraftBukkit start - Delegate to new parent class with bogus info
+ public RecipeBannerDuplicate(MinecraftKey minecraftkey) {
+- super(minecraftkey);
++ super(minecraftkey, "", new ItemStack(Items.WHITE_BANNER, 0), NonNullList.a(RecipeItemStack.a, RecipeItemStack.a(Items.WHITE_BANNER)));
+ }
++ // CraftBukkit end
+
+ public boolean a(IInventory iinventory, World world) {
+ if (!(iinventory instanceof InventoryCrafting)) {
diff --git a/nms-patches/RecipeBookClone.patch b/nms-patches/RecipeBookClone.patch
index d5417aa5..3db88546 100644
--- a/nms-patches/RecipeBookClone.patch
+++ b/nms-patches/RecipeBookClone.patch
@@ -1,16 +1,17 @@
--- a/net/minecraft/server/RecipeBookClone.java
+++ b/net/minecraft/server/RecipeBookClone.java
-@@ -1,8 +1,11 @@
+@@ -1,10 +1,12 @@
package net.minecraft.server;
--public class RecipeBookClone implements IRecipe {
+-public class RecipeBookClone extends IRecipeComplex {
+public class RecipeBookClone extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends
-- public RecipeBookClone() {}
-+ public RecipeBookClone() {
-+ super("", new ItemStack(Items.WRITTEN_BOOK, 0, -1), NonNullList.a(RecipeItemStack.a, RecipeItemStack.a(Items.WRITABLE_BOOK)));
-+ }
++ // CraftBukkit start - Delegate to new parent class with bogus info
+ public RecipeBookClone(MinecraftKey minecraftkey) {
+- super(minecraftkey);
++ super(minecraftkey, "", new ItemStack(Items.WRITTEN_BOOK, 0), NonNullList.a(RecipeItemStack.a, RecipeItemStack.a(Items.WRITABLE_BOOK)));
+ }
+ // CraftBukkit end
- public boolean a(InventoryCrafting inventorycrafting, World world) {
- int i = 0;
+ public boolean a(IInventory iinventory, World world) {
+ if (!(iinventory instanceof InventoryCrafting)) {
diff --git a/nms-patches/RecipeFireworks.patch b/nms-patches/RecipeFireworks.patch
index 43478e02..22a7a3b8 100644
--- a/nms-patches/RecipeFireworks.patch
+++ b/nms-patches/RecipeFireworks.patch
@@ -1,20 +1,21 @@
--- a/net/minecraft/server/RecipeFireworks.java
+++ b/net/minecraft/server/RecipeFireworks.java
-@@ -3,13 +3,16 @@
- import com.google.common.collect.Lists;
- import java.util.ArrayList;
+@@ -1,14 +1,16 @@
+ package net.minecraft.server;
--public class RecipeFireworks implements IRecipe {
+-public class RecipeFireworks extends IRecipeComplex {
+public class RecipeFireworks extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends
- private ItemStack a;
+ private static final RecipeItemStack a = RecipeItemStack.a(new IMaterial[] { Items.PAPER});
+ private static final RecipeItemStack b = RecipeItemStack.a(new IMaterial[] { Items.GUNPOWDER});
+ private static final RecipeItemStack c = RecipeItemStack.a(new IMaterial[] { Items.FIREWORK_STAR});
+ // CraftBukkit start - Delegate to new parent class with bogus info
- public RecipeFireworks() {
-+ super("", new ItemStack(Items.FIREWORKS, 0, 0), NonNullList.a(RecipeItemStack.a, RecipeItemStack.a(Items.GUNPOWDER)));
- this.a = ItemStack.a;
+ public RecipeFireworks(MinecraftKey minecraftkey) {
+- super(minecraftkey);
++ super(minecraftkey, "", new ItemStack(Items.FIREWORK_ROCKET, 0), NonNullList.a(RecipeItemStack.a, RecipeItemStack.a(Items.GUNPOWDER)));
}
+ // CraftBukkit end
- public boolean a(InventoryCrafting inventorycrafting, World world) {
- this.a = ItemStack.a;
+ public boolean a(IInventory iinventory, World world) {
+ if (!(iinventory instanceof InventoryCrafting)) {
diff --git a/nms-patches/RecipeFireworksFade.patch b/nms-patches/RecipeFireworksFade.patch
new file mode 100644
index 00000000..31b863eb
--- /dev/null
+++ b/nms-patches/RecipeFireworksFade.patch
@@ -0,0 +1,20 @@
+--- a/net/minecraft/server/RecipeFireworksFade.java
++++ b/net/minecraft/server/RecipeFireworksFade.java
+@@ -4,13 +4,15 @@
+ import java.util.ArrayList;
+ import java.util.List;
+
+-public class RecipeFireworksFade extends IRecipeComplex {
++public class RecipeFireworksFade extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends
+
+ private static final RecipeItemStack a = RecipeItemStack.a(new IMaterial[] { Items.FIREWORK_STAR});
+
++ // CraftBukkit start - Delegate to new parent class with bogus info
+ public RecipeFireworksFade(MinecraftKey minecraftkey) {
+- super(minecraftkey);
++ super(minecraftkey, "", new ItemStack(Items.FIREWORK_STAR, 0), NonNullList.a(RecipeItemStack.a, RecipeItemStack.a(Items.FIREWORK_STAR, Items.BONE_MEAL)));
+ }
++ // CraftBukkit end
+
+ public boolean a(IInventory iinventory, World world) {
+ if (!(iinventory instanceof InventoryCrafting)) {
diff --git a/nms-patches/RecipeFireworksStar.patch b/nms-patches/RecipeFireworksStar.patch
new file mode 100644
index 00000000..e4900565
--- /dev/null
+++ b/nms-patches/RecipeFireworksStar.patch
@@ -0,0 +1,30 @@
+--- a/net/minecraft/server/RecipeFireworksStar.java
++++ b/net/minecraft/server/RecipeFireworksStar.java
+@@ -8,12 +8,12 @@
+ import java.util.Map;
+ import java.util.function.Consumer;
+
+-public class RecipeFireworksStar extends IRecipeComplex {
++public class RecipeFireworksStar extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends
+
+ private static final RecipeItemStack a = RecipeItemStack.a(new IMaterial[] { Items.FIRE_CHARGE, Items.FEATHER, Items.GOLD_NUGGET, Items.SKELETON_SKULL, Items.WITHER_SKELETON_SKULL, Items.CREEPER_HEAD, Items.PLAYER_HEAD, Items.DRAGON_HEAD, Items.ZOMBIE_HEAD});
+ private static final RecipeItemStack b = RecipeItemStack.a(new IMaterial[] { Items.DIAMOND});
+ private static final RecipeItemStack c = RecipeItemStack.a(new IMaterial[] { Items.GLOWSTONE_DUST});
+- private static final Map<Item, ItemFireworks.EffectType> d = (Map) SystemUtils.a((Object) Maps.newHashMap(), (hashmap) -> {
++ private static final Map<Item, ItemFireworks.EffectType> d = (Map) SystemUtils.a(Maps.newHashMap(), (hashmap) -> { // CraftBukkit - decompile error
+ hashmap.put(Items.FIRE_CHARGE, ItemFireworks.EffectType.LARGE_BALL);
+ hashmap.put(Items.FEATHER, ItemFireworks.EffectType.BURST);
+ hashmap.put(Items.GOLD_NUGGET, ItemFireworks.EffectType.STAR);
+@@ -26,9 +26,11 @@
+ });
+ private static final RecipeItemStack e = RecipeItemStack.a(new IMaterial[] { Items.GUNPOWDER});
+
++ // CraftBukkit start - Delegate to new parent class with bogus info
+ public RecipeFireworksStar(MinecraftKey minecraftkey) {
+- super(minecraftkey);
++ super(minecraftkey, "", new ItemStack(Items.FIREWORK_STAR, 0), NonNullList.a(RecipeItemStack.a, RecipeItemStack.a(Items.GUNPOWDER)));
+ }
++ // CraftBukkit end
+
+ public boolean a(IInventory iinventory, World world) {
+ if (!(iinventory instanceof InventoryCrafting)) {
diff --git a/nms-patches/RecipeMapClone.patch b/nms-patches/RecipeMapClone.patch
index 04057272..b8016765 100644
--- a/nms-patches/RecipeMapClone.patch
+++ b/nms-patches/RecipeMapClone.patch
@@ -1,17 +1,17 @@
--- a/net/minecraft/server/RecipeMapClone.java
+++ b/net/minecraft/server/RecipeMapClone.java
-@@ -1,8 +1,12 @@
+@@ -1,10 +1,12 @@
package net.minecraft.server;
--public class RecipeMapClone implements IRecipe {
+-public class RecipeMapClone extends IRecipeComplex {
+public class RecipeMapClone extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends
-- public RecipeMapClone() {}
+ // CraftBukkit start - Delegate to new parent class
-+ public RecipeMapClone() {
-+ super("", new ItemStack(Items.MAP, 0, -1), NonNullList.a(RecipeItemStack.a, RecipeItemStack.a(Items.MAP)));
-+ }
+ public RecipeMapClone(MinecraftKey minecraftkey) {
+- super(minecraftkey);
++ super(minecraftkey, "", new ItemStack(Items.MAP, 0), NonNullList.a(RecipeItemStack.a, RecipeItemStack.a(Items.MAP)));
+ }
+ // CraftBukkit end
- public boolean a(InventoryCrafting inventorycrafting, World world) {
- int i = 0;
+ public boolean a(IInventory iinventory, World world) {
+ if (!(iinventory instanceof InventoryCrafting)) {
diff --git a/nms-patches/RecipeRepair.patch b/nms-patches/RecipeRepair.patch
index 7deebd5c..388dbc10 100644
--- a/nms-patches/RecipeRepair.patch
+++ b/nms-patches/RecipeRepair.patch
@@ -1,38 +1,38 @@
--- a/net/minecraft/server/RecipeRepair.java
+++ b/net/minecraft/server/RecipeRepair.java
-@@ -3,9 +3,13 @@
+@@ -2,12 +2,15 @@
+
import com.google.common.collect.Lists;
import java.util.ArrayList;
++import java.util.stream.Stream;
--public class RecipeRepair implements IRecipe {
+-public class RecipeRepair extends IRecipeComplex {
+public class RecipeRepair extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends
-- public RecipeRepair() {}
+ // CraftBukkit start - Delegate to new parent class
-+ public RecipeRepair() {
-+ super("", new ItemStack(Items.LEATHER_HELMET), NonNullList.a(RecipeItemStack.a, RecipeItemStack.a(Items.LEATHER_HELMET)));
-+ }
+ public RecipeRepair(MinecraftKey minecraftkey) {
+- super(minecraftkey);
++ super(minecraftkey, "", new ItemStack(Items.LEATHER_HELMET), NonNullList.a(RecipeItemStack.a, RecipeItemStack.a(Items.LEATHER_HELMET)));
+ }
+ // CraftBukkit end
- public boolean a(InventoryCrafting inventorycrafting, World world) {
- ArrayList arraylist = Lists.newArrayList();
-@@ -62,7 +66,18 @@
- i1 = 0;
- }
+ public boolean a(IInventory iinventory, World world) {
+ if (!(iinventory instanceof InventoryCrafting)) {
+@@ -71,6 +74,17 @@
+ ItemStack itemstack3 = new ItemStack(itemstack2.getItem());
-- return new ItemStack(itemstack2.getItem(), 1, i1);
+ itemstack3.setDamage(i1);
+ // CraftBukkit start - Construct a dummy repair recipe
-+ ItemStack result = new ItemStack(itemstack.getItem(), 1, i1);
-+ NonNullList<RecipeItemStack> ingredients = NonNullList.a();
-+ ingredients.add(RecipeItemStack.a(new ItemStack[]{itemstack2.cloneItemStack()}));
-+ ingredients.add(RecipeItemStack.a(new ItemStack[]{itemstack.cloneItemStack()}));
-+ ShapelessRecipes recipe = new ShapelessRecipes("", result.cloneItemStack(), ingredients);
-+ recipe.key = new MinecraftKey("repairitem");
-+ inventorycrafting.currentRecipe = recipe;
-+ result = org.bukkit.craftbukkit.event.CraftEventFactory.callPreCraftEvent(inventorycrafting, result, inventorycrafting.container.getBukkitView(), true);
-+ return result;
-+ // return new ItemStack(itemstack2.getItem(), 1, i1);
++ if (iinventory instanceof InventoryCrafting) {
++ InventoryCrafting inventorycrafting = (InventoryCrafting) iinventory;
++ NonNullList<RecipeItemStack> ingredients = NonNullList.a();
++ ingredients.add(new RecipeItemStack(Stream.of(new RecipeItemStack.StackProvider(itemstack2.cloneItemStack()))));
++ ingredients.add(new RecipeItemStack(Stream.of(new RecipeItemStack.StackProvider(itemstack.cloneItemStack()))));
++ ShapelessRecipes recipe = new ShapelessRecipes(new MinecraftKey("repairitem"), "", itemstack3.cloneItemStack(), ingredients);
++ inventorycrafting.setCurrentRecipe(recipe);
++ itemstack3 = org.bukkit.craftbukkit.event.CraftEventFactory.callPreCraftEvent(inventorycrafting, inventorycrafting.resultInventory, itemstack3, inventorycrafting.container.getBukkitView(), true);
++ }
+ // CraftBukkit end
+ return itemstack3;
}
}
-
diff --git a/nms-patches/RecipeShulkerBox.patch b/nms-patches/RecipeShulkerBox.patch
index f3eab88b..65eefa1e 100644
--- a/nms-patches/RecipeShulkerBox.patch
+++ b/nms-patches/RecipeShulkerBox.patch
@@ -1,20 +1,17 @@
--- a/net/minecraft/server/RecipeShulkerBox.java
+++ b/net/minecraft/server/RecipeShulkerBox.java
-@@ -1,8 +1,15 @@
+@@ -1,10 +1,12 @@
package net.minecraft.server;
--public class RecipeShulkerBox { public static class Dye implements IRecipe {
-+// CraftBukkit - decompile weirdness
-+public class RecipeShulkerBox {
+-public class RecipeShulkerBox extends IRecipeComplex {
++public class RecipeShulkerBox extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends
-- public Dye() {}
-+ public static class Dye extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends
-+
-+ // CraftBukkit start - Delegate to new parent class with bogus info
-+ public Dye() {
-+ super("", new ItemStack(Blocks.WHITE_SHULKER_BOX, 0, 0), NonNullList.a(RecipeItemStack.a, RecipeItemStack.a(Items.DYE)));
-+ }
-+ // CraftBukkit end
++ // CraftBukkit start - Delegate to new parent class with bogus info
+ public RecipeShulkerBox(MinecraftKey minecraftkey) {
+- super(minecraftkey);
++ super(minecraftkey, "", new ItemStack(Blocks.WHITE_SHULKER_BOX, 0), NonNullList.a(RecipeItemStack.a, RecipeItemStack.a(Items.BONE_MEAL)));
+ }
++ // CraftBukkit end
- public boolean a(InventoryCrafting inventorycrafting, World world) {
- int i = 0;
+ public boolean a(IInventory iinventory, World world) {
+ if (!(iinventory instanceof InventoryCrafting)) {
diff --git a/nms-patches/RecipeTippedArrow.patch b/nms-patches/RecipeTippedArrow.patch
index 04840d4f..2e2e84ca 100644
--- a/nms-patches/RecipeTippedArrow.patch
+++ b/nms-patches/RecipeTippedArrow.patch
@@ -1,22 +1,22 @@
--- a/net/minecraft/server/RecipeTippedArrow.java
+++ b/net/minecraft/server/RecipeTippedArrow.java
-@@ -2,9 +2,17 @@
+@@ -2,11 +2,17 @@
import java.util.Collection;
--public class RecipeTippedArrow implements IRecipe {
+-public class RecipeTippedArrow extends IRecipeComplex {
+public class RecipeTippedArrow extends ShapedRecipes implements IRecipe { // CraftBukkit
-- public RecipeTippedArrow() {}
+ // CraftBukkit start
-+ public RecipeTippedArrow() {
-+ super("", 3, 3, NonNullList.a(RecipeItemStack.a,
+ public RecipeTippedArrow(MinecraftKey minecraftkey) {
+- super(minecraftkey);
++ super(minecraftkey, "", 3, 3, NonNullList.a(RecipeItemStack.a,
+ RecipeItemStack.a(Items.ARROW), RecipeItemStack.a(Items.ARROW), RecipeItemStack.a(Items.ARROW),
+ RecipeItemStack.a(Items.ARROW), RecipeItemStack.a(Items.LINGERING_POTION), RecipeItemStack.a(Items.ARROW),
+ RecipeItemStack.a(Items.ARROW), RecipeItemStack.a(Items.ARROW), RecipeItemStack.a(Items.ARROW)),
+ new ItemStack(Items.TIPPED_ARROW, 8));
-+ }
+ }
+ // CraftBukkit end
- public boolean a(InventoryCrafting inventorycrafting, World world) {
- if (inventorycrafting.j() == 3 && inventorycrafting.i() == 3) {
+ public boolean a(IInventory iinventory, World world) {
+ if (iinventory.U_() == 3 && iinventory.n() == 3) {
diff --git a/nms-patches/RecipesBanner.patch b/nms-patches/RecipesBanner.patch
deleted file mode 100644
index 293911af..00000000
--- a/nms-patches/RecipesBanner.patch
+++ /dev/null
@@ -1,37 +0,0 @@
---- a/net/minecraft/server/RecipesBanner.java
-+++ b/net/minecraft/server/RecipesBanner.java
-@@ -2,9 +2,16 @@
-
- import javax.annotation.Nullable;
-
--public class RecipesBanner { public static class AddRecipe implements IRecipe {
-+// CraftBukkit - decompile weirdness
-+public class RecipesBanner {
-
-- public AddRecipe() {}
-+ public static class AddRecipe extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends
-+
-+ // CraftBukkit start - Delegate to new parent class with bogus info
-+ public AddRecipe() {
-+ super("", new ItemStack(Items.BANNER, 0, 0), NonNullList.a(RecipeItemStack.a, RecipeItemStack.a(Items.BANNER)));
-+ }
-+ // CraftBukkit end
-
- public boolean a(InventoryCrafting inventorycrafting, World world) {
- boolean flag = false;
-@@ -186,9 +193,13 @@
- }
- }
-
-- public static class DuplicateRecipe implements IRecipe {
-+ public static class DuplicateRecipe extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends
-
-- public DuplicateRecipe() {}
-+ // CraftBukkit start - Delegate to new parent class with bogus info
-+ public DuplicateRecipe() {
-+ super("", new ItemStack(Items.BANNER, 0, 0), NonNullList.a(RecipeItemStack.a, RecipeItemStack.a(Items.DYE)));
-+ }
-+ // CraftBukkit end
-
- public boolean a(InventoryCrafting inventorycrafting, World world) {
- ItemStack itemstack = ItemStack.a;
diff --git a/nms-patches/RecipesFurnace.patch b/nms-patches/RecipesFurnace.patch
deleted file mode 100644
index ccc7b333..00000000
--- a/nms-patches/RecipesFurnace.patch
+++ /dev/null
@@ -1,80 +0,0 @@
---- a/net/minecraft/server/RecipesFurnace.java
-+++ b/net/minecraft/server/RecipesFurnace.java
-@@ -8,8 +8,10 @@
- public class RecipesFurnace {
-
- private static final RecipesFurnace a = new RecipesFurnace();
-- public final Map<ItemStack, ItemStack> recipes = Maps.newHashMap();
-+ public Map<ItemStack, ItemStack> recipes = Maps.newHashMap();
- private final Map<ItemStack, Float> experience = Maps.newHashMap();
-+ public Map<ItemStack,ItemStack> customRecipes = Maps.newHashMap(); // CraftBukkit - add field
-+ public Map<ItemStack,Float> customExperience = Maps.newHashMap(); // CraftBukkit - add field
-
- public static RecipesFurnace getInstance() {
- return RecipesFurnace.a;
-@@ -94,6 +96,13 @@
- this.a(new ItemStack(Blocks.STAINED_HARDENED_CLAY, 1, EnumColor.BLACK.getColorIndex()), new ItemStack(Blocks.dQ), 0.1F);
- }
-
-+ // CraftBukkit start - add method
-+ public void registerRecipe(ItemStack itemstack, ItemStack itemstack1, float f) {
-+ this.customRecipes.put(itemstack, itemstack1);
-+ this.customExperience.put(itemstack, f);
-+ }
-+ // CraftBukkit end
-+
- public void registerRecipe(Block block, ItemStack itemstack, float f) {
- this.a(Item.getItemOf(block), itemstack, f);
- }
-@@ -108,13 +117,23 @@
- }
-
- public ItemStack getResult(ItemStack itemstack) {
-- Iterator iterator = this.recipes.entrySet().iterator();
-+ // CraftBukkit start - initialize to customRecipes
-+ boolean vanilla = false;
-+ Iterator<Entry<ItemStack, ItemStack>> iterator = this.customRecipes.entrySet().iterator();
-+ // CraftBukkit end
-
- Entry entry;
-
- do {
- if (!iterator.hasNext()) {
-- return ItemStack.a;
-+ // CraftBukkit start - fall back to vanilla recipes
-+ if (!vanilla && !this.recipes.isEmpty()) {
-+ iterator = this.recipes.entrySet().iterator();
-+ vanilla = true;
-+ } else {
-+ return ItemStack.a;
-+ }
-+ // CraftBukkit end
- }
-
- entry = (Entry) iterator.next();
-@@ -132,13 +151,23 @@
- }
-
- public float b(ItemStack itemstack) {
-- Iterator iterator = this.experience.entrySet().iterator();
-+ // CraftBukkit start - initialize to customRecipes
-+ boolean vanilla = false;
-+ Iterator<Entry<ItemStack, Float>> iterator = this.customExperience.entrySet().iterator();
-+ // CraftBukkit end
-
- Entry entry;
-
- do {
- if (!iterator.hasNext()) {
-- return 0.0F;
-+ // CraftBukkit start - fall back to vanilla recipes
-+ if (!vanilla && !this.experience.isEmpty()) {
-+ iterator = this.experience.entrySet().iterator();
-+ vanilla = true;
-+ } else {
-+ return 0.0F;
-+ }
-+ // CraftBukkit end
- }
-
- entry = (Entry) iterator.next();
diff --git a/nms-patches/RecipiesShield.patch b/nms-patches/RecipiesShield.patch
index bfdd5ea2..39ab5d66 100644
--- a/nms-patches/RecipiesShield.patch
+++ b/nms-patches/RecipiesShield.patch
@@ -1,20 +1,17 @@
--- a/net/minecraft/server/RecipiesShield.java
+++ b/net/minecraft/server/RecipiesShield.java
-@@ -1,8 +1,15 @@
+@@ -1,10 +1,12 @@
package net.minecraft.server;
--public class RecipiesShield { public static class Decoration implements IRecipe {
-+// CraftBukkit - decompile weirdness
-+public class RecipiesShield {
+-public class RecipiesShield extends IRecipeComplex {
++public class RecipiesShield extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends
-- public Decoration() {}
-+ public static class Decoration extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends
-+
-+ // CraftBukkit start - Delegate to new parent class with bogus info
-+ public Decoration() {
-+ super("", new ItemStack(Items.SHIELD, 0, 0), NonNullList.a(RecipeItemStack.a, RecipeItemStack.a(Items.BANNER)));
-+ }
-+ // CraftBukkit end
++ // CraftBukkit start - Delegate to new parent class with bogus info
+ public RecipiesShield(MinecraftKey minecraftkey) {
+- super(minecraftkey);
++ super(minecraftkey, "", new ItemStack(Items.SHIELD, 0), NonNullList.a(RecipeItemStack.a, RecipeItemStack.a(Items.WHITE_BANNER)));
+ }
++ // CraftBukkit end
- public boolean a(InventoryCrafting inventorycrafting, World world) {
- ItemStack itemstack = ItemStack.a;
+ public boolean a(IInventory iinventory, World world) {
+ if (!(iinventory instanceof InventoryCrafting)) {
diff --git a/nms-patches/RegionFileCache.patch b/nms-patches/RegionFileCache.patch
index 84697d79..c91a0f60 100644
--- a/nms-patches/RegionFileCache.patch
+++ b/nms-patches/RegionFileCache.patch
@@ -1,9 +1,9 @@
--- a/net/minecraft/server/RegionFileCache.java
+++ b/net/minecraft/server/RegionFileCache.java
-@@ -74,17 +74,27 @@
- RegionFileCache.a.clear();
+@@ -76,18 +76,28 @@
}
+ @Nullable
- public static DataInputStream d(File file, int i, int j) {
+ // CraftBukkit start - call sites hoisted for synchronization
+ public static synchronized NBTTagCompound d(File file, int i, int j) throws IOException {
@@ -19,6 +19,7 @@
+ return NBTCompressedStreamTools.a(datainputstream);
}
+ @Nullable
- 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);
diff --git a/nms-patches/RegionLimitedWorldAccess.patch b/nms-patches/RegionLimitedWorldAccess.patch
new file mode 100644
index 00000000..7e68d926
--- /dev/null
+++ b/nms-patches/RegionLimitedWorldAccess.patch
@@ -0,0 +1,30 @@
+--- a/net/minecraft/server/RegionLimitedWorldAccess.java
++++ b/net/minecraft/server/RegionLimitedWorldAccess.java
+@@ -25,10 +25,10 @@
+ private final Random k;
+ private final WorldProvider l;
+ private final GeneratorSettings m;
+- private final TickList<Block> n = new TickListWorldGen((blockposition) -> {
++ private final TickList<Block> n = new TickListWorldGen<>((blockposition) -> { // CraftBukkit - decompile error
+ return this.y(blockposition).k();
+ });
+- private final TickList<FluidType> o = new TickListWorldGen((blockposition) -> {
++ private final TickList<FluidType> o = new TickListWorldGen<>((blockposition) -> { // CraftBukkit - decompile error
+ return this.y(blockposition).l();
+ });
+
+@@ -204,7 +204,14 @@
+ this.y(blockposition).e(blockposition);
+ }
+
++ // CraftBukkit start
+ public boolean addEntity(Entity entity) {
++ return addEntity(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT);
++ }
++
++ @Override
++ public boolean addEntity(Entity entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) {
++ // CraftBukkit end
+ int i = MathHelper.floor(entity.locX / 16.0D);
+ int j = MathHelper.floor(entity.locZ / 16.0D);
+
diff --git a/nms-patches/RemoteControlCommandListener.patch b/nms-patches/RemoteControlCommandListener.patch
index 22369f89..def02f17 100644
--- a/nms-patches/RemoteControlCommandListener.patch
+++ b/nms-patches/RemoteControlCommandListener.patch
@@ -1,15 +1,20 @@
--- a/net/minecraft/server/RemoteControlCommandListener.java
+++ b/net/minecraft/server/RemoteControlCommandListener.java
-@@ -21,6 +21,12 @@
- return "Rcon";
+@@ -23,6 +23,17 @@
+ return new CommandListenerWrapper(this, new Vec3D(worldserver.getSpawn()), Vec2F.a, worldserver, 4, "Recon", new ChatComponentText("Rcon"), this.b, (Entity) null);
}
+ // CraftBukkit start - Send a String
+ public void sendMessage(String message) {
+ this.a.append(message);
+ }
++
++ @Override
++ public org.bukkit.command.CommandSender getBukkitSender(CommandListenerWrapper wrapper) {
++ return b.remoteConsole;
++ }
+ // CraftBukkit end
+
public void sendMessage(IChatBaseComponent ichatbasecomponent) {
- this.a.append(ichatbasecomponent.toPlainText());
+ this.a.append(ichatbasecomponent.getString());
}
diff --git a/nms-patches/ScoreboardServer.patch b/nms-patches/ScoreboardServer.patch
index 36e6f5ec..d4418990 100644
--- a/nms-patches/ScoreboardServer.patch
+++ b/nms-patches/ScoreboardServer.patch
@@ -1,31 +1,32 @@
--- a/net/minecraft/server/ScoreboardServer.java
+++ b/net/minecraft/server/ScoreboardServer.java
-@@ -21,7 +21,7 @@
+@@ -22,7 +22,7 @@
public void handleScoreChanged(ScoreboardScore scoreboardscore) {
super.handleScoreChanged(scoreboardscore);
if (this.b.contains(scoreboardscore.getObjective())) {
-- this.a.getPlayerList().sendAll(new PacketPlayOutScoreboardScore(scoreboardscore));
-+ this.sendAll(new PacketPlayOutScoreboardScore(scoreboardscore));
+- this.a.getPlayerList().sendAll(new PacketPlayOutScoreboardScore(ScoreboardServer.Action.CHANGE, scoreboardscore.getObjective().getName(), scoreboardscore.getPlayerName(), scoreboardscore.getScore()));
++ this.sendAll(new PacketPlayOutScoreboardScore(ScoreboardServer.Action.CHANGE, scoreboardscore.getObjective().getName(), scoreboardscore.getPlayerName(), scoreboardscore.getScore()));
}
this.b();
-@@ -29,13 +29,13 @@
+@@ -30,14 +30,14 @@
public void handlePlayerRemoved(String s) {
super.handlePlayerRemoved(s);
-- this.a.getPlayerList().sendAll(new PacketPlayOutScoreboardScore(s));
-+ this.sendAll(new PacketPlayOutScoreboardScore(s));
+- this.a.getPlayerList().sendAll(new PacketPlayOutScoreboardScore(ScoreboardServer.Action.REMOVE, (String) null, s, 0));
++ this.sendAll(new PacketPlayOutScoreboardScore(ScoreboardServer.Action.REMOVE, (String) null, s, 0));
this.b();
}
public void a(String s, ScoreboardObjective scoreboardobjective) {
super.a(s, scoreboardobjective);
-- this.a.getPlayerList().sendAll(new PacketPlayOutScoreboardScore(s, scoreboardobjective));
-+ this.sendAll(new PacketPlayOutScoreboardScore(s, scoreboardobjective));
- this.b();
- }
+ if (this.b.contains(scoreboardobjective)) {
+- this.a.getPlayerList().sendAll(new PacketPlayOutScoreboardScore(ScoreboardServer.Action.REMOVE, scoreboardobjective.getName(), s, 0));
++ this.sendAll(new PacketPlayOutScoreboardScore(ScoreboardServer.Action.REMOVE, scoreboardobjective.getName(), s, 0));
+ }
-@@ -45,7 +45,7 @@
+ this.b();
+@@ -49,7 +49,7 @@
super.setDisplaySlot(i, scoreboardobjective);
if (scoreboardobjective1 != scoreboardobjective && scoreboardobjective1 != null) {
if (this.h(scoreboardobjective1) > 0) {
@@ -34,7 +35,7 @@
} else {
this.g(scoreboardobjective1);
}
-@@ -53,7 +53,7 @@
+@@ -57,7 +57,7 @@
if (scoreboardobjective != null) {
if (this.b.contains(scoreboardobjective)) {
@@ -43,16 +44,16 @@
} else {
this.e(scoreboardobjective);
}
-@@ -66,7 +66,7 @@
- if (super.addPlayerToTeam(s, s1)) {
- ScoreboardTeam scoreboardteam = this.getTeam(s1);
+@@ -68,7 +68,7 @@
+ public boolean addPlayerToTeam(String s, ScoreboardTeam scoreboardteam) {
+ if (super.addPlayerToTeam(s, scoreboardteam)) {
- this.a.getPlayerList().sendAll(new PacketPlayOutScoreboardTeam(scoreboardteam, Arrays.asList(new String[] { s}), 3));
+ this.sendAll(new PacketPlayOutScoreboardTeam(scoreboardteam, Arrays.asList(new String[] { s}), 3));
this.b();
return true;
} else {
-@@ -76,7 +76,7 @@
+@@ -78,7 +78,7 @@
public void removePlayerFromTeam(String s, ScoreboardTeam scoreboardteam) {
super.removePlayerFromTeam(s, scoreboardteam);
@@ -61,7 +62,7 @@
this.b();
}
-@@ -88,7 +88,7 @@
+@@ -90,7 +90,7 @@
public void handleObjectiveChanged(ScoreboardObjective scoreboardobjective) {
super.handleObjectiveChanged(scoreboardobjective);
if (this.b.contains(scoreboardobjective)) {
@@ -70,7 +71,7 @@
}
this.b();
-@@ -105,19 +105,19 @@
+@@ -107,19 +107,19 @@
public void handleTeamAdded(ScoreboardTeam scoreboardteam) {
super.handleTeamAdded(scoreboardteam);
@@ -93,7 +94,7 @@
this.b();
}
-@@ -166,6 +166,7 @@
+@@ -168,6 +168,7 @@
while (iterator.hasNext()) {
EntityPlayer entityplayer = (EntityPlayer) iterator.next();
@@ -101,7 +102,7 @@
Iterator iterator1 = list.iterator();
while (iterator1.hasNext()) {
-@@ -198,6 +199,7 @@
+@@ -200,6 +201,7 @@
while (iterator.hasNext()) {
EntityPlayer entityplayer = (EntityPlayer) iterator.next();
@@ -109,11 +110,10 @@
Iterator iterator1 = list.iterator();
while (iterator1.hasNext()) {
-@@ -221,4 +223,14 @@
-
+@@ -224,6 +226,16 @@
return i;
}
-+
+
+ // CraftBukkit start - Send to players
+ private void sendAll(Packet packet) {
+ for (EntityPlayer entityplayer : (List<EntityPlayer>) this.a.getPlayerList().players) {
@@ -123,4 +123,7 @@
+ }
+ }
+ // CraftBukkit end
- }
++
+ public static enum Action {
+
+ CHANGE, REMOVE;
diff --git a/nms-patches/ScoreboardTeam.patch b/nms-patches/ScoreboardTeam.patch
new file mode 100644
index 00000000..7e9da9c2
--- /dev/null
+++ b/nms-patches/ScoreboardTeam.patch
@@ -0,0 +1,47 @@
+--- a/net/minecraft/server/ScoreboardTeam.java
++++ b/net/minecraft/server/ScoreboardTeam.java
+@@ -36,7 +36,7 @@
+ }
+
+ public String getDisplayName() {
+- return this.d;
++ return this.prefix + this.d + this.suffix; // CraftBukkit
+ }
+
+ public IChatBaseComponent d() {
+@@ -165,4 +165,35 @@
+ public EnumChatFormat getColor() {
+ return this.k;
+ }
++
++ // CraftBukkit start
++ private String prefix;
++ private String suffix;
++
++ public String getPrefix() {
++ return prefix;
++ }
++
++ public void setPrefix(String prefix) {
++ if (prefix == null) {
++ throw new IllegalArgumentException("Prefix cannot be null");
++ }
++
++ this.prefix = prefix;
++ this.a.handleTeamChanged(this);
++ }
++
++ public String getSuffix() {
++ return suffix;
++ }
++
++ public void setSuffix(String suffix) {
++ if (prefix == null) {
++ throw new IllegalArgumentException("Suffix cannot be null");
++ }
++
++ this.suffix = suffix;
++ this.a.handleTeamChanged(this);
++ }
++ // CraftBukkit end
+ }
diff --git a/nms-patches/SecondaryWorldServer.patch b/nms-patches/SecondaryWorldServer.patch
index f05e64bb..f92f9531 100644
--- a/nms-patches/SecondaryWorldServer.patch
+++ b/nms-patches/SecondaryWorldServer.patch
@@ -1,6 +1,6 @@
--- a/net/minecraft/server/SecondaryWorldServer.java
+++ b/net/minecraft/server/SecondaryWorldServer.java
-@@ -4,9 +4,12 @@
+@@ -6,9 +6,12 @@
private final WorldServer a;
@@ -15,7 +15,7 @@
worldserver.getWorldBorder().a(new IWorldBorderListener() {
public void a(WorldBorder worldborder, double d0) {
SecondaryWorldServer.this.getWorldBorder().setSize(d0);
-@@ -36,9 +39,10 @@
+@@ -38,9 +41,10 @@
SecondaryWorldServer.this.getWorldBorder().setDamageBuffer(d0);
}
});
@@ -25,9 +25,9 @@
- protected void a() {}
+ // protected void a() {} // CraftBukkit
- public World b() {
- this.worldMaps = this.a.Z();
-@@ -56,7 +60,7 @@
+ public GeneratorAccess b() {
+ this.worldMaps = this.a.s_();
+@@ -55,7 +59,7 @@
this.villages.a((World) this);
}
@@ -35,4 +35,4 @@
+ return super.b(); // CraftBukkit
}
- public void c() {
+ public void t_() {
diff --git a/nms-patches/ShapedRecipes.patch b/nms-patches/ShapedRecipes.patch
index e5c8474d..b68788a1 100644
--- a/nms-patches/ShapedRecipes.patch
+++ b/nms-patches/ShapedRecipes.patch
@@ -1,9 +1,9 @@
--- a/net/minecraft/server/ShapedRecipes.java
+++ b/net/minecraft/server/ShapedRecipes.java
-@@ -14,6 +14,10 @@
+@@ -13,6 +13,10 @@
+ import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
- import javax.annotation.Nullable;
+// CraftBukkit start
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.craftbukkit.inventory.CraftShapedRecipe;
@@ -11,22 +11,7 @@
public class ShapedRecipes implements IRecipe {
-@@ -22,6 +26,14 @@
- private final NonNullList<RecipeItemStack> items;
- private final ItemStack result;
- private final String e;
-+ // CraftBukkit start
-+ public MinecraftKey key;
-+
-+ @Override
-+ public void setKey(MinecraftKey key) {
-+ this.key = key;
-+ }
-+ // CraftBukkit end
-
- public ShapedRecipes(String s, int i, int j, NonNullList<RecipeItemStack> nonnulllist, ItemStack itemstack) {
- this.e = s;
-@@ -31,6 +43,63 @@
+@@ -32,6 +36,64 @@
this.result = itemstack;
}
@@ -77,9 +62,10 @@
+ }
+ char c = 'a';
+ for (RecipeItemStack list : this.items) {
-+ if (list != null && list.choices.length > 0) {
++ list.buildChoices();
++ if (list.choices.length > 0) {
+ net.minecraft.server.ItemStack stack = list.choices[0];
-+ recipe.setIngredient(c, org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(stack.getItem()), (list.choices.length) > 1 ? 32767 : stack.getData());
++ recipe.setIngredient(c, org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(stack.getItem()), (list.choices.length) > 1 ? 32767 : 0);
+ }
+ c++;
+ }
@@ -87,6 +73,20 @@
+ }
+ // CraftBukkit end
+
- public ItemStack b() {
- return this.result;
+ public MinecraftKey getKey() {
+ return this.e;
+ }
+@@ -302,11 +364,11 @@
+ packetdataserializer.a(shapedrecipes.result);
+ }
+
+- public IRecipe a(MinecraftKey minecraftkey, PacketDataSerializer packetdataserializer) {
++ public ShapedRecipes a(MinecraftKey minecraftkey, PacketDataSerializer packetdataserializer) { // CraftBukkit - decompile error
+ return this.b(minecraftkey, packetdataserializer);
+ }
+
+- public IRecipe a(MinecraftKey minecraftkey, JsonObject jsonobject) {
++ public ShapedRecipes a(MinecraftKey minecraftkey, JsonObject jsonobject) { // CraftBukkit - decompile error
+ return this.b(minecraftkey, jsonobject);
+ }
}
diff --git a/nms-patches/ShapelessRecipes.patch b/nms-patches/ShapelessRecipes.patch
index d91e17c7..9f214f4c 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,12 +6,24 @@
+@@ -5,6 +5,10 @@
import com.google.gson.JsonParseException;
- import java.util.ArrayList;
+ import it.unimi.dsi.fastutil.ints.IntList;
import java.util.Iterator;
+// CraftBukkit start
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
@@ -11,21 +11,7 @@
public class ShapelessRecipes implements IRecipe {
- private final ItemStack result;
- private final NonNullList<RecipeItemStack> ingredients;
- private final String c;
-+ // CraftBukkit start
-+ public MinecraftKey key;
-+
-+ @Override
-+ public void setKey(MinecraftKey key) {
-+ this.key = key;
-+ }
-+ // CraftBukkit end
-
- public ShapelessRecipes(String s, ItemStack itemstack, NonNullList<RecipeItemStack> nonnulllist) {
- this.c = s;
-@@ -19,6 +31,21 @@
+@@ -20,6 +24,20 @@
this.ingredients = nonnulllist;
}
@@ -35,15 +21,28 @@
+ CraftItemStack result = CraftItemStack.asCraftMirror(this.result);
+ CraftShapelessRecipe recipe = new CraftShapelessRecipe(result, this);
+ for (RecipeItemStack list : this.ingredients) {
-+ if (list != null) {
-+ net.minecraft.server.ItemStack stack = list.choices[0];
-+ recipe.addIngredient(org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(stack.getItem()), (list.choices.length) > 1 ? 32767 : stack.getData());
-+ }
++ list.buildChoices();
++ net.minecraft.server.ItemStack stack = list.choices[0];
++ recipe.addIngredient(org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(stack.getItem()), (list.choices.length) > 1 ? 32767 : 0);
+ }
+ return recipe;
+ }
+ // CraftBukkit end
+
- public ItemStack b() {
- return this.result;
+ public MinecraftKey getKey() {
+ return this.a;
+ }
+@@ -127,11 +145,11 @@
+ packetdataserializer.a(shapelessrecipes.result);
+ }
+
+- public IRecipe a(MinecraftKey minecraftkey, PacketDataSerializer packetdataserializer) {
++ public ShapelessRecipes a(MinecraftKey minecraftkey, PacketDataSerializer packetdataserializer) { // CraftBukkit - decompile error
+ return this.b(minecraftkey, packetdataserializer);
+ }
+
+- public IRecipe a(MinecraftKey minecraftkey, JsonObject jsonobject) {
++ public ShapelessRecipes a(MinecraftKey minecraftkey, JsonObject jsonobject) { // CraftBukkit - decompile error
+ return this.b(minecraftkey, jsonobject);
+ }
}
diff --git a/nms-patches/SlotFurnaceResult.patch b/nms-patches/SlotFurnaceResult.patch
index bcc110d7..eee722f9 100644
--- a/nms-patches/SlotFurnaceResult.patch
+++ b/nms-patches/SlotFurnaceResult.patch
@@ -1,32 +1,32 @@
--- a/net/minecraft/server/SlotFurnaceResult.java
+++ b/net/minecraft/server/SlotFurnaceResult.java
-@@ -1,5 +1,10 @@
- package net.minecraft.server;
+@@ -2,6 +2,10 @@
+ import java.util.Iterator;
+ import java.util.Map.Entry;
+// CraftBukkit start
+import org.bukkit.entity.Player;
+import org.bukkit.event.inventory.FurnaceExtractEvent;
+// CraftBukkit end
-+
+
public class SlotFurnaceResult extends Slot {
- private final EntityHuman a;
-@@ -51,6 +56,18 @@
- i = j;
- }
+@@ -66,6 +70,18 @@
+ i = j;
+ }
-+ // CraftBukkit start - fire FurnaceExtractEvent
-+ Player player = (Player) a.getBukkitEntity();
-+ TileEntityFurnace furnace = ((TileEntityFurnace) this.inventory);
-+ org.bukkit.block.Block block = a.world.getWorld().getBlockAt(furnace.position.getX(), furnace.position.getY(), furnace.position.getZ());
++ // CraftBukkit start - fire FurnaceExtractEvent
++ Player player = (Player) a.getBukkitEntity();
++ TileEntityFurnace furnace = ((TileEntityFurnace) this.inventory);
++ org.bukkit.block.Block block = a.world.getWorld().getBlockAt(furnace.position.getX(), furnace.position.getY(), furnace.position.getZ());
+
-+ if (b != 0) {
-+ FurnaceExtractEvent event = new FurnaceExtractEvent(player, block, org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(itemstack.getItem()), b, i);
-+ a.world.getServer().getPluginManager().callEvent(event);
-+ i = event.getExpToDrop();
-+ }
-+ // CraftBukkit end
++ if (b != 0) {
++ FurnaceExtractEvent event = new FurnaceExtractEvent(player, block, org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(itemstack.getItem()), b, i);
++ a.world.getServer().getPluginManager().callEvent(event);
++ i = event.getExpToDrop();
++ }
++ // CraftBukkit end
+
- while (i > 0) {
- j = EntityExperienceOrb.getOrbValue(i);
- i -= j;
+ while (i > 0) {
+ j = EntityExperienceOrb.getOrbValue(i);
+ i -= j;
diff --git a/nms-patches/SpawnerCreature.patch b/nms-patches/SpawnerCreature.patch
index ce90948f..0bfac793 100644
--- a/nms-patches/SpawnerCreature.patch
+++ b/nms-patches/SpawnerCreature.patch
@@ -1,8 +1,8 @@
--- a/net/minecraft/server/SpawnerCreature.java
+++ b/net/minecraft/server/SpawnerCreature.java
-@@ -6,10 +6,16 @@
- import java.util.Random;
- import java.util.Set;
+@@ -9,11 +9,17 @@
+ import org.apache.logging.log4j.LogManager;
+ import org.apache.logging.log4j.Logger;
+// CraftBukkit start
+import org.bukkit.craftbukkit.util.LongHash;
@@ -12,32 +12,33 @@
+
public final class SpawnerCreature {
- private static final int a = (int) Math.pow(17.0D, 2.0D);
-- private final Set<ChunkCoordIntPair> b = Sets.newHashSet();
-+ private final LongHashSet b = new LongHashSet(); // CraftBukkit
+ private static final Logger a = LogManager.getLogger();
+ private static final int b = (int) Math.pow(17.0D, 2.0D);
+- private final Set<ChunkCoordIntPair> c = Sets.newHashSet();
++ private final LongHashSet c = new LongHashSet(); // CraftBukkit
public SpawnerCreature() {}
-@@ -38,13 +44,16 @@
+@@ -42,13 +48,16 @@
boolean flag4 = i1 == -8 || i1 == 8 || k == -8 || k == 8;
ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(i1 + l, k + j);
-- if (!this.b.contains(chunkcoordintpair)) {
+- if (!this.c.contains(chunkcoordintpair)) {
+ // CraftBukkit start - use LongHash and LongHashSet
+ long chunkCoords = LongHash.toLong(chunkcoordintpair.x, chunkcoordintpair.z);
-+ if (!this.b.contains(chunkCoords)) {
++ if (!this.c.contains(chunkCoords)) {
++i;
if (!flag4 && worldserver.getWorldBorder().isInBounds(chunkcoordintpair)) {
PlayerChunk playerchunk = worldserver.getPlayerChunkMap().getChunk(chunkcoordintpair.x, chunkcoordintpair.z);
if (playerchunk != null && playerchunk.e()) {
-- this.b.add(chunkcoordintpair);
-+ this.b.add(chunkCoords);
+- this.c.add(chunkcoordintpair);
++ this.c.add(chunkCoords);
+ // CraftBukkit end
}
}
}
-@@ -62,9 +71,31 @@
+@@ -66,9 +75,31 @@
for (int k1 = 0; k1 < j; ++k1) {
EnumCreatureType enumcreaturetype = aenumcreaturetype[k1];
@@ -63,16 +64,16 @@
+ }
+ // CraftBukkit end
+
- if ((!enumcreaturetype.d() || flag1) && (enumcreaturetype.d() || flag) && (!enumcreaturetype.e() || flag2)) {
+ if ((!enumcreaturetype.c() || flag1) && (enumcreaturetype.c() || flag) && (!enumcreaturetype.d() || flag2)) {
k = worldserver.a(enumcreaturetype.a());
-- int l1 = enumcreaturetype.b() * i / SpawnerCreature.a;
-+ int l1 = limit * i / a; // CraftBukkit - use per-world limits
+- int l1 = enumcreaturetype.b() * i / SpawnerCreature.b;
++ int l1 = limit * i / b; // CraftBukkit - use per-world limits
if (k <= l1) {
BlockPosition.MutableBlockPosition blockposition_mutableblockposition = new BlockPosition.MutableBlockPosition();
-@@ -72,8 +103,10 @@
+@@ -76,8 +107,10 @@
- label120:
+ label128:
while (iterator1.hasNext()) {
- ChunkCoordIntPair chunkcoordintpair1 = (ChunkCoordIntPair) iterator1.next();
- BlockPosition blockposition1 = getRandomPosition(worldserver, chunkcoordintpair1.x, chunkcoordintpair1.z);
@@ -83,29 +84,28 @@
int i2 = blockposition1.getX();
int j2 = blockposition1.getY();
int k2 = blockposition1.getZ();
-@@ -125,8 +158,11 @@
- if (entityinsentient.P() && entityinsentient.canSpawn()) {
- groupdataentity = entityinsentient.prepare(worldserver.D(new BlockPosition(entityinsentient)), groupdataentity);
- if (entityinsentient.canSpawn()) {
-- ++l2;
-- worldserver.addEntity(entityinsentient);
-+ // CraftBukkit start
-+ if (worldserver.addEntity(entityinsentient, SpawnReason.NATURAL)) {
-+ ++l2;
-+ }
-+ // CraftBukkit end
- } else {
- entityinsentient.die();
- }
-@@ -226,8 +262,10 @@
+@@ -136,9 +169,12 @@
+ if (entityinsentient.M() && entityinsentient.a((IWorldReader) worldserver)) {
+ groupdataentity = entityinsentient.prepare(worldserver.getDamageScaler(new BlockPosition(entityinsentient)), groupdataentity, (NBTTagCompound) null);
+ if (entityinsentient.a((IWorldReader) worldserver)) {
+- ++l2;
+- ++j4;
+- worldserver.addEntity(entityinsentient);
++ // CraftBukkit start
++ if (worldserver.addEntity(entityinsentient, SpawnReason.NATURAL)) {
++ ++l2;
++ ++j4;
++ }
++ // CraftBukkit end
+ } else {
+ entityinsentient.die();
+ }
+@@ -255,7 +291,7 @@
+ entityinsentient.setPositionRotation((double) f, (double) blockposition.getY(), (double) f1, random.nextFloat() * 360.0F, 0.0F);
+ if (entityinsentient.a(generatoraccess) && entityinsentient.a((IWorldReader) generatoraccess)) {
+ groupdataentity = entityinsentient.prepare(generatoraccess.getDamageScaler(new BlockPosition(entityinsentient)), groupdataentity, (NBTTagCompound) null);
+- generatoraccess.addEntity(entityinsentient);
++ generatoraccess.addEntity(entityinsentient, SpawnReason.CHUNK_GEN); // CraftBukkit
+ flag = true;
}
-
- entityinsentient.setPositionRotation((double) ((float) j1 + 0.5F), (double) blockposition.getY(), (double) ((float) k1 + 0.5F), random.nextFloat() * 360.0F, 0.0F);
-- world.addEntity(entityinsentient);
-+ // CraftBukkit start - Added a reason for spawning this creature, moved entityinsentient.prepare(groupdataentity) up
- groupdataentity = entityinsentient.prepare(world.D(new BlockPosition(entityinsentient)), groupdataentity);
-+ world.addEntity(entityinsentient, SpawnReason.CHUNK_GEN);
-+ // CraftBukkit end
- flag = true;
}
-
diff --git a/nms-patches/StatisticManager.patch b/nms-patches/StatisticManager.patch
index 93e6895a..1d6c4129 100644
--- a/nms-patches/StatisticManager.patch
+++ b/nms-patches/StatisticManager.patch
@@ -1,9 +1,9 @@
--- a/net/minecraft/server/StatisticManager.java
+++ b/net/minecraft/server/StatisticManager.java
-@@ -10,6 +10,12 @@
- public StatisticManager() {}
+@@ -13,6 +13,12 @@
+ }
- public void b(EntityHuman entityhuman, Statistic statistic, int i) {
+ public void b(EntityHuman entityhuman, Statistic<?> statistic, int i) {
+ // CraftBukkit start - fire Statistic events
+ org.bukkit.event.Cancellable cancellable = org.bukkit.craftbukkit.event.CraftEventFactory.handleStatisticsIncrease(entityhuman, statistic, this.getStatisticValue(statistic), i);
+ if (cancellable != null && cancellable.isCancelled()) {
diff --git a/nms-patches/TickListServer.patch b/nms-patches/TickListServer.patch
new file mode 100644
index 00000000..50a952e3
--- /dev/null
+++ b/nms-patches/TickListServer.patch
@@ -0,0 +1,111 @@
+--- a/net/minecraft/server/TickListServer.java
++++ b/net/minecraft/server/TickListServer.java
+@@ -11,14 +11,15 @@
+ import java.util.function.Consumer;
+ import java.util.function.Function;
+ import java.util.function.Predicate;
++import org.bukkit.craftbukkit.util.HashTreeSet; // CraftBukkit
+
+ public class TickListServer<T> implements TickList<T> {
+
+ protected final Predicate<T> a;
+ protected final Function<T, MinecraftKey> b;
+ protected final Function<MinecraftKey, T> c;
+- protected final Set<NextTickListEntry<T>> nextTickListHash = Sets.newHashSet();
+- protected final TreeSet<NextTickListEntry<T>> nextTickList = new TreeSet();
++ // protected final Set<NextTickListEntry<T>> nextTickListHash = Sets.newHashSet();
++ protected final HashTreeSet<NextTickListEntry> nextTickList = new HashTreeSet<>(); // CraftBukkit - HashTreeSet
+ private final WorldServer f;
+ private final List<NextTickListEntry<T>> g = Lists.newArrayList();
+ private final Consumer<NextTickListEntry<T>> h;
+@@ -34,16 +35,22 @@
+ public void a() {
+ int i = this.nextTickList.size();
+
+- if (i != this.nextTickListHash.size()) {
++ if (false) { // CraftBukkit
+ throw new IllegalStateException("TickNextTick list out of synch");
+ } else {
+ if (i > 65536) {
+- i = 65536;
++ // CraftBukkit start - If the server has too much to process over time, try to alleviate that
++ if (i > 20 * 65536) {
++ i = i / 20;
++ } else {
++ i = 65536;
++ }
++ // CraftBukkit end
+ }
+
+ this.f.methodProfiler.a("cleaning");
+
+- NextTickListEntry nextticklistentry;
++ NextTickListEntry<T> nextticklistentry; // CraftBukkit - decompile error
+
+ for (int j = 0; j < i; ++j) {
+ nextticklistentry = (NextTickListEntry) this.nextTickList.first();
+@@ -52,7 +59,7 @@
+ }
+
+ this.nextTickList.remove(nextticklistentry);
+- this.nextTickListHash.remove(nextticklistentry);
++ // this.nextTickListHash.remove(nextticklistentry); // CraftBukkit - use nextTickList
+ this.g.add(nextticklistentry);
+ }
+
+@@ -118,7 +125,7 @@
+ if (blockposition.getX() >= structureboundingbox.a && blockposition.getX() < structureboundingbox.d && blockposition.getZ() >= structureboundingbox.c && blockposition.getZ() < structureboundingbox.f) {
+ if (flag) {
+ if (i == 0) {
+- this.nextTickListHash.remove(nextticklistentry);
++ // this.nextTickListHash.remove(nextticklistentry); // CraftBukkit - removed
+ }
+
+ iterator.remove();
+@@ -141,7 +148,7 @@
+ Iterator iterator = list.iterator();
+
+ while (iterator.hasNext()) {
+- NextTickListEntry nextticklistentry = (NextTickListEntry) iterator.next();
++ NextTickListEntry<T> nextticklistentry = (NextTickListEntry) iterator.next(); // CraftBukkit - decompile error
+
+ if (structureboundingbox.b((BaseBlockPosition) nextticklistentry.a)) {
+ BlockPosition blockposition1 = nextticklistentry.a.a((BaseBlockPosition) blockposition);
+@@ -159,7 +166,7 @@
+ Iterator iterator = list.iterator();
+
+ while (iterator.hasNext()) {
+- NextTickListEntry nextticklistentry = (NextTickListEntry) iterator.next();
++ NextTickListEntry<T> nextticklistentry = (NextTickListEntry) iterator.next(); // CraftBukkit - decompile error
+ NBTTagCompound nbttagcompound = new NBTTagCompound();
+
+ nbttagcompound.setString("i", ((MinecraftKey) this.b.apply(nextticklistentry.a())).toString());
+@@ -177,7 +184,7 @@
+ public void a(NBTTagList nbttaglist) {
+ for (int i = 0; i < nbttaglist.size(); ++i) {
+ NBTTagCompound nbttagcompound = nbttaglist.getCompound(i);
+- Object object = this.c.apply(new MinecraftKey(nbttagcompound.getString("i")));
++ T object = this.c.apply(new MinecraftKey(nbttagcompound.getString("i"))); // CraftBukkit - decompile error
+
+ if (object != null) {
+ this.b(new BlockPosition(nbttagcompound.getInt("x"), nbttagcompound.getInt("y"), nbttagcompound.getInt("z")), object, nbttagcompound.getInt("t"), TickListPriority.a(nbttagcompound.getInt("p")));
+@@ -187,7 +194,7 @@
+ }
+
+ public boolean a(BlockPosition blockposition, T t0) {
+- return this.nextTickListHash.contains(new NextTickListEntry(blockposition, t0));
++ return this.nextTickList.contains(new NextTickListEntry(blockposition, t0)); // CraftBukkit
+ }
+
+ public void a(BlockPosition blockposition, T t0, int i, TickListPriority ticklistpriority) {
+@@ -209,8 +216,8 @@
+ private void c(BlockPosition blockposition, T t0, int i, TickListPriority ticklistpriority) {
+ NextTickListEntry nextticklistentry = new NextTickListEntry(blockposition, t0, (long) i + this.f.getTime(), ticklistpriority);
+
+- if (!this.nextTickListHash.contains(nextticklistentry)) {
+- this.nextTickListHash.add(nextticklistentry);
++ // CraftBukkit - use nextTickList
++ if (!this.nextTickList.contains(nextticklistentry)) {
+ this.nextTickList.add(nextticklistentry);
+ }
+
diff --git a/nms-patches/TileEntity.patch b/nms-patches/TileEntity.patch
index 6ebe08e9..b0dbdfbc 100644
--- a/nms-patches/TileEntity.patch
+++ b/nms-patches/TileEntity.patch
@@ -9,9 +9,33 @@
public abstract class TileEntity {
private static final Logger a = LogManager.getLogger();
-@@ -251,4 +253,13 @@
- a("shulker_box", TileEntityShulkerBox.class);
- a("bed", TileEntityBed.class);
+@@ -54,8 +56,15 @@
+ }
+ }
+
++ // CraftBukkit start
+ @Nullable
+ public static TileEntity create(NBTTagCompound nbttagcompound) {
++ return create(nbttagcompound, null);
++ }
++
++ @Nullable
++ public static TileEntity create(NBTTagCompound nbttagcompound, @Nullable World world) {
++ // CraftBukkit end
+ TileEntity tileentity = null;
+ String s = nbttagcompound.getString("id");
+
+@@ -67,6 +76,7 @@
+
+ if (tileentity != null) {
+ try {
++ tileentity.setWorld(world); // CraftBukkit
+ tileentity.load(nbttagcompound);
+ } catch (Throwable throwable1) {
+ TileEntity.a.error("Failed to load data for block entity {}", s, throwable1);
+@@ -156,4 +166,13 @@
+ public TileEntityTypes<?> C() {
+ return this.e;
}
+
+ // CraftBukkit start - add method
diff --git a/nms-patches/TileEntityBanner.patch b/nms-patches/TileEntityBanner.patch
index c9294ee0..4f501b82 100644
--- a/nms-patches/TileEntityBanner.patch
+++ b/nms-patches/TileEntityBanner.patch
@@ -1,9 +1,9 @@
--- a/net/minecraft/server/TileEntityBanner.java
+++ b/net/minecraft/server/TileEntityBanner.java
-@@ -23,6 +23,11 @@
+@@ -30,6 +30,11 @@
if (nbttagcompound != null && nbttagcompound.hasKeyOfType("Patterns", 9)) {
- this.patterns = nbttagcompound.getList("Patterns", 10).d();
+ this.patterns = nbttagcompound.getList("Patterns", 10).c();
+ // CraftBukkit start
+ while (this.patterns.size() > 20) {
+ this.patterns.remove(20);
@@ -11,16 +11,16 @@
+ // CraftBukkit end
}
- this.color = flag ? d(itemstack) : ItemBanner.c(itemstack);
-@@ -67,6 +72,11 @@
+ this.color = enumcolor;
+@@ -79,6 +84,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 477bd68e..84fcb11f 100644
--- a/nms-patches/TileEntityBeacon.patch
+++ b/nms-patches/TileEntityBeacon.patch
@@ -1,7 +1,7 @@
--- a/net/minecraft/server/TileEntityBeacon.java
+++ b/net/minecraft/server/TileEntityBeacon.java
@@ -9,6 +9,13 @@
- import java.util.Set;
+ import java.util.stream.Collectors;
import javax.annotation.Nullable;
+// CraftBukkit start
@@ -11,13 +11,13 @@
+import org.bukkit.potion.PotionEffect;
+// CraftBukkit end
+
- public class TileEntityBeacon extends TileEntityContainer implements ITickable, IWorldInventory {
+ public class TileEntityBeacon extends TileEntityContainer implements IWorldInventory, ITickable {
public static final MobEffectList[][] a = new MobEffectList[][] { { MobEffects.FASTER_MOVEMENT, MobEffects.FASTER_DIG}, { MobEffects.RESISTANCE, MobEffects.JUMP}, { MobEffects.INCREASE_DAMAGE}, { MobEffects.REGENERATION}};
-@@ -22,6 +29,38 @@
+@@ -23,6 +30,38 @@
public MobEffectList secondaryEffect;
private ItemStack inventorySlot;
- private String o;
+ private IChatBaseComponent o;
+ // CraftBukkit start - add fields and methods
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
+ private int maxStack = MAX_STACK;
@@ -52,13 +52,13 @@
+ // CraftBukkit end
public TileEntityBeacon() {
- this.inventorySlot = ItemStack.a;
-@@ -42,41 +81,79 @@
-
+ super(TileEntityTypes.o);
+@@ -56,41 +95,79 @@
+ this.world.a((EntityHuman) null, this.position, soundeffect, SoundCategory.BLOCKS, 1.0F, 1.0F);
}
-- private void E() {
-- if (this.j && this.levels > 0 && !this.world.isClientSide && this.primaryEffect != null) {
+- private void D() {
+- if (this.i && this.levels > 0 && !this.world.isClientSide && this.primaryEffect != null) {
- double d0 = (double) (this.levels * 10 + 10);
+ // CraftBukkit start - split into components
+ private byte getAmplification() {
@@ -123,8 +123,8 @@
+ }
+ }
+
-+ private void E() {
-+ if (this.j && this.levels > 0 && !this.world.isClientSide && this.primaryEffect != null) {
++ private void D() {
++ if (this.i && this.levels > 0 && !this.world.isClientSide && this.primaryEffect != null) {
+ byte b0 = getAmplification();
+
+ int i = getLevel();
@@ -140,14 +140,14 @@
}
+ // CraftBukkit end
- private void F() {
+ private void E() {
int i = this.position.getX();
-@@ -195,8 +272,10 @@
+@@ -210,8 +287,10 @@
public void load(NBTTagCompound nbttagcompound) {
super.load(nbttagcompound);
-- this.primaryEffect = f(nbttagcompound.getInt("Primary"));
-- this.secondaryEffect = f(nbttagcompound.getInt("Secondary"));
+- this.primaryEffect = e(nbttagcompound.getInt("Primary"));
+- this.secondaryEffect = e(nbttagcompound.getInt("Secondary"));
+ // Craftbukkit start - persist manually set non-default beacon effects (SPIGOT-3598)
+ this.primaryEffect = MobEffectList.fromId(nbttagcompound.getInt("Primary"));
+ this.secondaryEffect = MobEffectList.fromId(nbttagcompound.getInt("Secondary"));
diff --git a/nms-patches/TileEntityBrewingStand.patch b/nms-patches/TileEntityBrewingStand.patch
index fe3d21e3..bafd46ee 100644
--- a/nms-patches/TileEntityBrewingStand.patch
+++ b/nms-patches/TileEntityBrewingStand.patch
@@ -1,8 +1,8 @@
--- a/net/minecraft/server/TileEntityBrewingStand.java
+++ b/net/minecraft/server/TileEntityBrewingStand.java
-@@ -3,6 +3,16 @@
- import java.util.Arrays;
+@@ -4,6 +4,16 @@
import java.util.Iterator;
+ import javax.annotation.Nullable;
+// CraftBukkit start
+import java.util.List;
@@ -14,12 +14,12 @@
+import org.bukkit.inventory.InventoryHolder;
+// CraftBukkit end
+
- public class TileEntityBrewingStand extends TileEntityContainer implements ITickable, IWorldInventory {
+ public class TileEntityBrewingStand extends TileEntityContainer implements IWorldInventory, ITickable {
private static final int[] a = new int[] { 3};
-@@ -14,6 +24,31 @@
- private Item k;
- private String l;
+@@ -15,6 +25,31 @@
+ private Item j;
+ private IChatBaseComponent k;
private int fuelLevel;
+ // CraftBukkit start - add fields and methods
+ private int lastTick = MinecraftServer.currentTick;
@@ -48,8 +48,8 @@
+ // CraftBukkit end
public TileEntityBrewingStand() {
- this.items = NonNullList.a(5, ItemStack.a);
-@@ -55,8 +90,19 @@
+ super(TileEntityTypes.l);
+@@ -62,8 +97,19 @@
ItemStack itemstack = (ItemStack) this.items.get(4);
if (this.fuelLevel <= 0 && itemstack.getItem() == Items.BLAZE_POWDER) {
@@ -71,7 +71,7 @@
this.update();
}
-@@ -64,9 +110,14 @@
+@@ -71,9 +117,14 @@
boolean flag1 = this.brewTime > 0;
ItemStack itemstack1 = (ItemStack) this.items.get(3);
@@ -87,10 +87,10 @@
+ // CraftBukkit end
if (flag2 && flag) {
- this.p();
-@@ -140,6 +191,16 @@
+ this.r();
+@@ -147,6 +198,16 @@
- private void p() {
+ private void r() {
ItemStack itemstack = (ItemStack) this.items.get(3);
+ // CraftBukkit start
+ InventoryHolder owner = this.getOwner();
@@ -105,7 +105,7 @@
for (int i = 0; i < 3; ++i) {
this.items.set(i, PotionBrewer.d(itemstack, (ItemStack) this.items.get(i)));
-@@ -210,7 +271,7 @@
+@@ -213,7 +274,7 @@
}
public int getMaxStackSize() {
diff --git a/nms-patches/TileEntityChest.patch b/nms-patches/TileEntityChest.patch
index c302cf64..80ec4086 100644
--- a/nms-patches/TileEntityChest.patch
+++ b/nms-patches/TileEntityChest.patch
@@ -1,9 +1,9 @@
--- a/net/minecraft/server/TileEntityChest.java
+++ b/net/minecraft/server/TileEntityChest.java
-@@ -3,6 +3,10 @@
+@@ -2,6 +2,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;
@@ -11,9 +11,9 @@
public class TileEntityChest extends TileEntityLootable implements ITickable {
-@@ -18,6 +22,31 @@
- private int q;
- private BlockChest.Type r;
+@@ -11,6 +15,31 @@
+ protected int f;
+ private int k;
+ // CraftBukkit start - add fields and methods
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
@@ -40,10 +40,10 @@
+ }
+ // CraftBukkit end
+
- public TileEntityChest() {
+ protected TileEntityChest(TileEntityTypes<?> tileentitytypes) {
+ super(tileentitytypes);
this.items = NonNullList.a(27, ItemStack.a);
- }
-@@ -82,7 +111,7 @@
+@@ -75,7 +104,7 @@
}
public int getMaxStackSize() {
@@ -51,54 +51,50 @@
+ return maxStack; // CraftBukkit
}
- public void invalidateBlockCache() {
-@@ -258,9 +287,21 @@
- if (this.l < 0) {
- this.l = 0;
+ public void X_() {
+@@ -170,8 +199,20 @@
+ if (this.f < 0) {
+ this.f = 0;
}
-+ int oldPower = Math.max(0, Math.min(15, this.l)); // CraftBukkit - Get power before new viewer is added
++ int oldPower = Math.max(0, Math.min(15, this.f)); // CraftBukkit - Get power before new viewer is added
- ++this.l;
+ ++this.f;
+ if (this.world == null) return; // CraftBukkit
- this.world.playBlockAction(this.position, this.getBlock(), 1, this.l);
+
+ // CraftBukkit start - Call redstone event
+ if (this.getBlock() == Blocks.TRAPPED_CHEST) {
-+ int newPower = Math.max(0, Math.min(15, this.l));
++ int newPower = Math.max(0, Math.min(15, this.f));
+
+ if (oldPower != newPower) {
-+ org.bukkit.craftbukkit.event.CraftEventFactory.callRedstoneChange(world, position.getX(), position.getY(), position.getZ(), oldPower, newPower);
++ org.bukkit.craftbukkit.event.CraftEventFactory.callRedstoneChange(world, position, oldPower, newPower);
+ }
+ }
+ // CraftBukkit end
- 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 @@
+ this.p();
+ }
+
+@@ -179,7 +220,18 @@
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;
- this.world.playBlockAction(this.position, this.getBlock(), 1, this.l);
- this.world.applyPhysics(this.position, this.getBlock(), false);
+ if (!entityhuman.isSpectator()) {
++ int oldPower = Math.max(0, Math.min(15, this.f)); // CraftBukkit - Get power before new viewer is added
+ --this.f;
+
+ // CraftBukkit start - Call redstone event
- if (this.p() == BlockChest.Type.TRAP) {
-+ int newPower = Math.max(0, Math.min(15, this.l));
++ if (this.getBlock() == Blocks.TRAPPED_CHEST) {
++ int newPower = Math.max(0, Math.min(15, this.f));
+
+ if (oldPower != newPower) {
-+ org.bukkit.craftbukkit.event.CraftEventFactory.callRedstoneChange(world, position.getX(), position.getY(), position.getZ(), oldPower, newPower);
++ org.bukkit.craftbukkit.event.CraftEventFactory.callRedstoneChange(world, position, oldPower, newPower);
+ }
- this.world.applyPhysics(this.position.down(), this.getBlock(), false);
- }
++ }
+ // CraftBukkit end
+ this.p();
}
- }
-@@ -311,4 +361,11 @@
- protected NonNullList<ItemStack> q() {
- return this.items;
+@@ -232,4 +284,11 @@
+ tileentitychest.a(tileentitychest1.q());
+ tileentitychest1.a(nonnulllist);
}
+
+ // CraftBukkit start
diff --git a/nms-patches/TileEntityCommand.patch b/nms-patches/TileEntityCommand.patch
index c31a6b81..b23a8e4c 100644
--- a/nms-patches/TileEntityCommand.patch
+++ b/nms-patches/TileEntityCommand.patch
@@ -1,12 +1,16 @@
--- a/net/minecraft/server/TileEntityCommand.java
+++ b/net/minecraft/server/TileEntityCommand.java
-@@ -9,6 +9,9 @@
+@@ -9,6 +9,13 @@
+ private boolean f;
private boolean g;
- private boolean h;
- private final CommandBlockListenerAbstract i = new CommandBlockListenerAbstract() {
-+ {
-+ sender = new org.bukkit.craftbukkit.command.CraftBlockCommandSender(this); // CraftBukkit - add sender
+ private final CommandBlockListenerAbstract h = new CommandBlockListenerAbstract() {
++ // CraftBukkit start
++ @Override
++ public org.bukkit.command.CommandSender getBukkitSender(CommandListenerWrapper wrapper) {
++ return new org.bukkit.craftbukkit.command.CraftBlockCommandSender(wrapper);
+ }
- public BlockPosition getChunkCoordinates() {
- return TileEntityCommand.this.position;
- }
++ // CraftBukkit end
++
+ public void setCommand(String s) {
+ super.setCommand(s);
+ TileEntityCommand.this.update();
diff --git a/nms-patches/TileEntityContainer.patch b/nms-patches/TileEntityContainer.patch
index e49e2ca9..b01f8025 100644
--- a/nms-patches/TileEntityContainer.patch
+++ b/nms-patches/TileEntityContainer.patch
@@ -1,8 +1,8 @@
--- a/net/minecraft/server/TileEntityContainer.java
+++ b/net/minecraft/server/TileEntityContainer.java
-@@ -37,4 +37,12 @@
- public IChatBaseComponent getScoreboardDisplayName() {
- return (IChatBaseComponent) (this.hasCustomName() ? new ChatComponentText(this.getName()) : new ChatMessage(this.getName(), new Object[0]));
+@@ -34,4 +34,12 @@
+ public void setLock(ChestLock chestlock) {
+ this.a = chestlock;
}
+
+ // CraftBukkit start
diff --git a/nms-patches/TileEntityDispenser.patch b/nms-patches/TileEntityDispenser.patch
index 3414c8aa..54a13254 100644
--- a/nms-patches/TileEntityDispenser.patch
+++ b/nms-patches/TileEntityDispenser.patch
@@ -41,10 +41,10 @@
+ }
+ // CraftBukkit end
+
- public TileEntityDispenser() {
+ protected TileEntityDispenser(TileEntityTypes<?> tileentitytypes) {
+ super(tileentitytypes);
this.items = NonNullList.a(9, ItemStack.a);
- }
-@@ -92,7 +123,7 @@
+@@ -97,7 +128,7 @@
}
public int getMaxStackSize() {
diff --git a/nms-patches/TileEntityEndGateway.patch b/nms-patches/TileEntityEndGateway.patch
index 7fc375f1..585f0f16 100644
--- a/nms-patches/TileEntityEndGateway.patch
+++ b/nms-patches/TileEntityEndGateway.patch
@@ -13,9 +13,9 @@
public class TileEntityEndGateway extends TileEntityEnderPortal implements ITickable {
-@@ -111,6 +117,26 @@
+@@ -113,6 +119,26 @@
if (this.exitPortal != null) {
- BlockPosition blockposition = this.exactTeleport ? this.exitPortal : this.j();
+ BlockPosition blockposition = this.exactTeleport ? this.exitPortal : this.i();
+ // CraftBukkit start - Fire PlayerTeleportEvent
+ if (entity instanceof EntityPlayer) {
@@ -31,7 +31,7 @@
+ }
+
+ ((EntityPlayer) entity).playerConnection.teleport(teleEvent.getTo());
-+ this.h(); // CraftBukkit - call at end of method
++ this.f(); // CraftBukkit - call at end of method
+ return;
+
+ }
diff --git a/nms-patches/TileEntityFurnace.patch b/nms-patches/TileEntityFurnace.patch
index c3e32116..e5861798 100644
--- a/nms-patches/TileEntityFurnace.patch
+++ b/nms-patches/TileEntityFurnace.patch
@@ -1,9 +1,9 @@
--- a/net/minecraft/server/TileEntityFurnace.java
+++ b/net/minecraft/server/TileEntityFurnace.java
-@@ -1,6 +1,15 @@
- package net.minecraft.server;
-
- import java.util.Iterator;
+@@ -9,6 +9,15 @@
+ import java.util.Map;
+ import java.util.Map.Entry;
+ import javax.annotation.Nullable;
+// CraftBukkit start
+import java.util.List;
+
@@ -14,11 +14,11 @@
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
+// CraftBukkit end
- public class TileEntityFurnace extends TileEntityContainer implements ITickable, IWorldInventory {
+ public class TileEntityFurnace extends TileEntityContainer implements IWorldInventory, RecipeHolder, AutoRecipeOutput, ITickable {
-@@ -14,6 +23,32 @@
- private int cookTimeTotal;
- private String m;
+@@ -98,6 +107,32 @@
+ return linkedhashmap;
+ }
+ // CraftBukkit start - add fields and methods
+ private int lastTick = MinecraftServer.currentTick;
@@ -47,14 +47,14 @@
+ // CraftBukkit end
+
public TileEntityFurnace() {
+ super(TileEntityTypes.b);
this.items = NonNullList.a(3, ItemStack.a);
- }
-@@ -119,11 +154,29 @@
+@@ -225,11 +260,30 @@
}
- public void e() {
+ public void X_() {
- 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 flag = this.getBlock().get(BlockFurnace.LIT); // CraftBukkit - SPIGOT-844 - Check if furnace block is lit using the block instead of burn time
boolean flag1 = false;
+ // CraftBukkit start - Use wall time instead of ticks for cooking
@@ -62,12 +62,13 @@
+ this.lastTick = MinecraftServer.currentTick;
+
+ // CraftBukkit - moved from below - edited for wall time
-+ if (this.isBurning() && this.canBurn()) {
++ IRecipe irecipe = this.world.D().b(this, this.world);
++ if (this.isBurning() && this.canBurn(irecipe)) {
+ this.cookTime += elapsedTicks;
+ if (this.cookTime >= this.cookTimeTotal) {
+ this.cookTime = 0;
-+ this.cookTimeTotal = this.a((ItemStack) this.items.get(0));
-+ this.burn();
++ this.cookTimeTotal = this.s();
++ this.burn(irecipe);
+ flag1 = true;
+ }
+ } else {
@@ -81,21 +82,22 @@
}
if (!this.world.isClientSide) {
-@@ -134,10 +187,21 @@
+@@ -240,12 +294,21 @@
this.cookTime = MathHelper.clamp(this.cookTime - 2, 0, this.cookTimeTotal);
}
} else {
-- if (!this.isBurning() && this.canBurn()) {
-- this.burnTime = fuelTime(itemstack);
-- this.ticksForCurrentFuel = this.burnTime;
-- if (this.isBurning()) {
+- IRecipe irecipe = this.world.D().b(this, this.world);
+ // CraftBukkit start - Handle multiple elapsed ticks
-+ if (this.burnTime <= 0 && this.canBurn()) { // CraftBukkit - == to <=
++ if (this.burnTime <= 0 && this.canBurn(irecipe)) { // CraftBukkit - == to <=
+ CraftItemStack fuel = CraftItemStack.asCraftMirror(itemstack);
+
+ FurnaceBurnEvent furnaceBurnEvent = new FurnaceBurnEvent(this.world.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ()), fuel, fuelTime(itemstack));
+ this.world.getServer().getPluginManager().callEvent(furnaceBurnEvent);
-+
+
+- if (!this.isBurning() && this.canBurn(irecipe)) {
+- this.burnTime = fuelTime(itemstack);
+- this.ticksForCurrentFuel = this.burnTime;
+- if (this.isBurning()) {
+ if (furnaceBurnEvent.isCancelled()) {
+ return;
+ }
@@ -107,15 +109,15 @@
flag1 = true;
if (!itemstack.isEmpty()) {
Item item = itemstack.getItem();
-@@ -152,6 +216,7 @@
+@@ -260,6 +323,7 @@
}
}
+ /* CraftBukkit start - Moved up
- if (this.isBurning() && this.canBurn()) {
+ if (this.isBurning() && this.canBurn(irecipe)) {
++this.cookTime;
if (this.cookTime == this.cookTimeTotal) {
-@@ -163,11 +228,13 @@
+@@ -271,11 +335,13 @@
} else {
this.cookTime = 0;
}
@@ -124,12 +126,12 @@
if (flag != this.isBurning()) {
flag1 = true;
- BlockFurnace.a(this.isBurning(), this.world, this.position);
-+ this.invalidateBlockCache(); // CraftBukkit - Invalidate tile entity's cached block type
+ this.world.setTypeAndData(this.position, (IBlockData) this.world.getType(this.position).set(BlockFurnace.LIT, Boolean.valueOf(this.isBurning())), 3);
++ this.invalidateBlockCache(); // CraftBukkit - Invalidate tile entity's cached block type
}
}
-@@ -192,7 +259,8 @@
+@@ -300,7 +366,8 @@
} else {
ItemStack itemstack1 = (ItemStack) this.items.get(2);
@@ -137,10 +139,10 @@
+ // 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()));
}
- }
- }
-@@ -203,11 +271,38 @@
- ItemStack itemstack1 = RecipesFurnace.getInstance().getResult(itemstack);
+ } else {
+ return false;
+@@ -313,11 +380,38 @@
+ ItemStack itemstack1 = irecipe.d();
ItemStack itemstack2 = (ItemStack) this.items.get(2);
+ // CraftBukkit start - fire FurnaceSmeltEvent
@@ -176,5 +178,5 @@
+ */
+ // CraftBukkit end
- 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));
+ if (!this.world.isClientSide) {
+ this.a(this.world, (EntityPlayer) null, irecipe);
diff --git a/nms-patches/TileEntityHopper.patch b/nms-patches/TileEntityHopper.patch
index 17005f2a..467d842d 100644
--- a/nms-patches/TileEntityHopper.patch
+++ b/nms-patches/TileEntityHopper.patch
@@ -1,7 +1,7 @@
--- a/net/minecraft/server/TileEntityHopper.java
+++ b/net/minecraft/server/TileEntityHopper.java
-@@ -4,12 +4,46 @@
- import java.util.List;
+@@ -7,12 +7,46 @@
+ import java.util.stream.Collectors;
import javax.annotation.Nullable;
+// CraftBukkit start
@@ -17,7 +17,7 @@
private NonNullList<ItemStack> items;
private int f;
- private long g;
+ private long j;
+ // CraftBukkit start - add fields and methods
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
@@ -45,8 +45,8 @@
+ // CraftBukkit end
+
public TileEntityHopper() {
+ super(TileEntityTypes.r);
this.items = NonNullList.a(5, ItemStack.a);
- this.f = -1;
@@ -72,7 +106,7 @@
}
@@ -55,8 +55,8 @@
+ return maxStack; // CraftBukkit
}
- public void e() {
-@@ -163,10 +197,35 @@
+ public void X_() {
+@@ -165,10 +199,35 @@
for (int i = 0; i < this.getSize(); ++i) {
if (!this.getItem(i).isEmpty()) {
ItemStack itemstack = this.getItem(i).cloneItemStack();
@@ -94,7 +94,7 @@
return true;
}
-@@ -288,10 +347,41 @@
+@@ -290,10 +349,41 @@
if (!itemstack.isEmpty() && b(iinventory, itemstack, i, enumdirection)) {
ItemStack itemstack1 = itemstack.cloneItemStack();
@@ -138,17 +138,17 @@
return true;
}
-@@ -307,6 +397,13 @@
- if (entityitem == null) {
- return false;
- } else {
-+ // CraftBukkit start
-+ 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, iinventory1, itemstack, (EnumDirection) null);
+@@ -305,6 +395,13 @@
+
+ public static boolean a(IInventory iinventory, EntityItem entityitem) {
+ boolean flag = false;
++ // CraftBukkit start
++ InventoryPickupItemEvent event = new InventoryPickupItemEvent(iinventory.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) null, iinventory, itemstack, (EnumDirection) null);
diff --git a/nms-patches/TileEntityJukeBox.patch b/nms-patches/TileEntityJukeBox.patch
new file mode 100644
index 00000000..2fb37145
--- /dev/null
+++ b/nms-patches/TileEntityJukeBox.patch
@@ -0,0 +1,14 @@
+--- a/net/minecraft/server/TileEntityJukeBox.java
++++ b/net/minecraft/server/TileEntityJukeBox.java
+@@ -31,6 +31,11 @@
+ }
+
+ public void setRecord(ItemStack itemstack) {
++ // CraftBukkit start - There can only be one
++ if (!itemstack.isEmpty()) {
++ itemstack.setCount(1);
++ }
++ // CraftBukkit end
+ this.a = itemstack;
+ this.update();
+ }
diff --git a/nms-patches/TileEntityNote.patch b/nms-patches/TileEntityNote.patch
deleted file mode 100644
index e0498c39..00000000
--- a/nms-patches/TileEntityNote.patch
+++ /dev/null
@@ -1,16 +0,0 @@
---- a/net/minecraft/server/TileEntityNote.java
-+++ b/net/minecraft/server/TileEntityNote.java
-@@ -70,7 +70,12 @@
- b0 = 9;
- }
-
-- world.playBlockAction(blockposition, Blocks.NOTEBLOCK, b0, this.note);
-+ // CraftBukkit start
-+ org.bukkit.event.block.NotePlayEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callNotePlayEvent(this.world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), b0, this.note);
-+ if (!event.isCancelled()) {
-+ world.playBlockAction(blockposition, Blocks.NOTEBLOCK, event.getInstrument().getType(), event.getNote().getId());
-+ }
-+ // CraftBukkit end
- }
- }
- }
diff --git a/nms-patches/TileEntityShulkerBox.patch b/nms-patches/TileEntityShulkerBox.patch
index 6af5516b..1f77fc49 100644
--- a/nms-patches/TileEntityShulkerBox.patch
+++ b/nms-patches/TileEntityShulkerBox.patch
@@ -1,18 +1,18 @@
--- a/net/minecraft/server/TileEntityShulkerBox.java
+++ b/net/minecraft/server/TileEntityShulkerBox.java
-@@ -3,6 +3,10 @@
- import java.util.Iterator;
+@@ -4,6 +4,10 @@
import java.util.List;
+ import java.util.stream.IntStream;
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 {
+ public class TileEntityShulkerBox extends TileEntityLootable implements IWorldInventory, ITickable {
-@@ -16,6 +20,31 @@
- private EnumColor l;
+@@ -18,6 +22,31 @@
+ private boolean o;
private boolean p;
+ // CraftBukkit start - add fields and methods
@@ -20,7 +20,7 @@
+ private int maxStack = MAX_STACK;
+
+ public List<ItemStack> getContents() {
-+ return this.f;
++ return this.e;
+ }
+
+ public void onOpen(CraftHumanEntity who) {
@@ -40,10 +40,10 @@
+ }
+ // CraftBukkit end
+
- public TileEntityShulkerBox() {
- this((EnumColor) null);
- }
-@@ -144,7 +173,7 @@
+ public TileEntityShulkerBox(@Nullable EnumColor enumcolor) {
+ super(TileEntityTypes.x);
+ this.e = NonNullList.a(27, ItemStack.a);
+@@ -148,7 +177,7 @@
}
public int getMaxStackSize() {
diff --git a/nms-patches/TileEntitySign.patch b/nms-patches/TileEntitySign.patch
index 88ab4306..d25d0893 100644
--- a/nms-patches/TileEntitySign.patch
+++ b/nms-patches/TileEntitySign.patch
@@ -1,6 +1,6 @@
--- a/net/minecraft/server/TileEntitySign.java
+++ b/net/minecraft/server/TileEntitySign.java
-@@ -21,6 +21,12 @@
+@@ -23,6 +23,12 @@
nbttagcompound.setString("Text" + (i + 1), s);
}
@@ -10,12 +10,12 @@
+ }
+ // CraftBukkit end
+
- this.i.b(nbttagcompound);
return nbttagcompound;
}
-@@ -58,14 +64,34 @@
- }
- };
+
+@@ -30,18 +36,38 @@
+ this.isEditable = false;
+ super.load(nbttagcompound);
+ // CraftBukkit start - Add an option to convert signs correctly
+ // This is done with a flag instead of all the time because
@@ -30,10 +30,11 @@
+ s = "\"\"";
+ }
- try {
-- this.lines[i] = ChatComponentUtils.filterForDisplay(icommandlistener, ichatbasecomponent, (Entity) null);
-- } catch (CommandException commandexception) {
-- this.lines[i] = ichatbasecomponent;
+- if (this.world instanceof WorldServer) {
+- try {
+- this.lines[i] = ChatComponentUtils.filterForDisplay(this.a((EntityPlayer) null), ichatbasecomponent, (Entity) null);
+- } catch (CommandSyntaxException commandsyntaxexception) {
++ try {
+ IChatBaseComponent ichatbasecomponent = IChatBaseComponent.ChatSerializer.a(s);
+
+ if (oldSign) {
@@ -42,29 +43,33 @@
+ }
+ // CraftBukkit end
+
-+ try {
-+ this.lines[i] = ChatComponentUtils.filterForDisplay(icommandlistener, ichatbasecomponent, (Entity) null);
-+ } catch (CommandException commandexception) {
-+ this.lines[i] = ichatbasecomponent;
-+ }
++ if (this.world instanceof WorldServer) {
++ try {
++ this.lines[i] = ChatComponentUtils.filterForDisplay(this.a((EntityPlayer) null), ichatbasecomponent, (Entity) null);
++ } catch (CommandSyntaxException commandsyntaxexception) {
++ this.lines[i] = ichatbasecomponent;
++ }
++ } else {
+ this.lines[i] = ichatbasecomponent;
+ }
+- } else {
+- this.lines[i] = ichatbasecomponent;
+ } catch (com.google.gson.JsonParseException jsonparseexception) {
+ this.lines[i] = new ChatComponentText(s);
}
}
-@@ -155,7 +181,14 @@
- ChatClickable chatclickable = chatmodifier.h();
+@@ -94,6 +120,13 @@
- if (chatclickable.a() == ChatClickable.EnumClickAction.RUN_COMMAND) {
-- entityhuman.C_().getCommandHandler().a(icommandlistener, chatclickable.b());
-+ // CraftBukkit start
-+ // entityhuman.C_().getCommandHandler().a(icommandlistener, chatclickable.b());
-+ CommandBlockListenerAbstract.executeSafely(icommandlistener, new org.bukkit.craftbukkit.command.ProxiedNativeCommandSender(
-+ icommandlistener,
-+ new org.bukkit.craftbukkit.command.CraftBlockCommandSender(icommandlistener),
-+ entityhuman.getBukkitEntity()
-+ ), chatclickable.b());
-+ // CraftBukkit end
- }
- }
- }
+ public void sendMessage(IChatBaseComponent ichatbasecomponent) {}
+
++ // CraftBukkit start
++ @Override
++ public org.bukkit.command.CommandSender getBukkitSender(CommandListenerWrapper wrapper) {
++ return wrapper.f() != null ? wrapper.f().getBukkitSender(wrapper) : new org.bukkit.craftbukkit.command.CraftBlockCommandSender(wrapper);
++ }
++ // CraftBukkit end
++
+ public CommandListenerWrapper a(@Nullable EntityPlayer entityplayer) {
+ String s = entityplayer == null ? "Sign" : entityplayer.getDisplayName().getString();
+ Object object = entityplayer == null ? new ChatComponentText("Sign") : entityplayer.getScoreboardDisplayName();
diff --git a/nms-patches/TileEntitySkull.patch b/nms-patches/TileEntitySkull.patch
new file mode 100644
index 00000000..e7425b53
--- /dev/null
+++ b/nms-patches/TileEntitySkull.patch
@@ -0,0 +1,23 @@
+--- a/net/minecraft/server/TileEntitySkull.java
++++ b/net/minecraft/server/TileEntitySkull.java
+@@ -119,13 +119,19 @@
+ }
+ }
+
++ // CraftBukkit start
+ public static void a(IBlockAccess iblockaccess, BlockPosition blockposition) {
++ setShouldDrop(iblockaccess, blockposition, false);
++ }
++
++ public static void setShouldDrop(IBlockAccess iblockaccess, BlockPosition blockposition, boolean flag) {
++ // CraftBukkit end
+ TileEntity tileentity = iblockaccess.getTileEntity(blockposition);
+
+ if (tileentity instanceof TileEntitySkull) {
+ TileEntitySkull tileentityskull = (TileEntitySkull) tileentity;
+
+- tileentityskull.drop = false;
++ tileentityskull.drop = flag; // CraftBukkit
+ }
+
+ }
diff --git a/nms-patches/TileEntityStructure.patch b/nms-patches/TileEntityStructure.patch
deleted file mode 100644
index f7f05e4c..00000000
--- a/nms-patches/TileEntityStructure.patch
+++ /dev/null
@@ -1,36 +0,0 @@
---- a/net/minecraft/server/TileEntityStructure.java
-+++ b/net/minecraft/server/TileEntityStructure.java
-@@ -10,20 +10,20 @@
-
- public class TileEntityStructure extends TileEntity {
-
-- private String a = "";
-- private String f = "";
-- private String g = "";
-- private BlockPosition h = new BlockPosition(0, 1, 0);
-- private BlockPosition i;
-- private EnumBlockMirror j;
-- private EnumBlockRotation k;
-- private TileEntityStructure.UsageMode l;
-- private boolean m;
-+ private String a = ""; // PAIL: rename name
-+ public String f = ""; // PAIL: private -> public
-+ public String g = ""; // PAIL: private -> public
-+ public BlockPosition h = new BlockPosition(0, 1, 0); // PAIL: private -> public
-+ public BlockPosition i; // PAIL: private -> public
-+ public EnumBlockMirror j; // PAIL: private -> public
-+ public EnumBlockRotation k; // PAIL: private -> public
-+ private TileEntityStructure.UsageMode l; // PAIL: rename
-+ public boolean m; // PAIL: private -> public
- private boolean n;
-- private boolean o;
-- private boolean p;
-- private float q;
-- private long r;
-+ public boolean o; // PAIL: private -> public
-+ public boolean p; // PAIL: private -> public
-+ public float q; // PAIL: private -> public
-+ public long r; // PAIL: private -> public
-
- public TileEntityStructure() {
- this.i = BlockPosition.ZERO;
diff --git a/nms-patches/UserCache.patch b/nms-patches/UserCache.patch
index d04921fc..a91279c6 100644
--- a/nms-patches/UserCache.patch
+++ b/nms-patches/UserCache.patch
@@ -9,7 +9,7 @@
private final GameProfileRepository g;
protected final Gson b;
private final File h;
-@@ -337,11 +337,11 @@
+@@ -330,11 +330,11 @@
}
}
diff --git a/nms-patches/Village.patch b/nms-patches/Village.patch
index a142c50a..ea50abc5 100644
--- a/nms-patches/Village.patch
+++ b/nms-patches/Village.patch
@@ -1,11 +1,11 @@
--- a/net/minecraft/server/Village.java
+++ b/net/minecraft/server/Village.java
-@@ -64,7 +64,7 @@
- EntityIronGolem entityirongolem = new EntityIronGolem(this.a);
+@@ -73,7 +73,7 @@
+ BlockPosition blockposition1 = blockposition.a(this.a.random.nextInt(16) - 8, this.a.random.nextInt(6) - 3, this.a.random.nextInt(16) - 8);
- entityirongolem.setPosition(vec3d.x, vec3d.y, vec3d.z);
-- this.a.addEntity(entityirongolem);
-+ this.a.addEntity(entityirongolem, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.VILLAGE_DEFENSE); // CraftBukkit
- ++this.l;
- }
- }
+ if (this.a(blockposition1)) {
+- EntityIronGolem entityirongolem = (EntityIronGolem) EntityTypes.IRON_GOLEM.b(this.a, (NBTTagCompound) null, (IChatBaseComponent) null, (EntityHuman) null, blockposition1, false, false);
++ EntityIronGolem entityirongolem = (EntityIronGolem) EntityTypes.IRON_GOLEM.spawnCreature(this.a, (NBTTagCompound) null, (IChatBaseComponent) null, (EntityHuman) null, blockposition1, false, false, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.VILLAGE_DEFENSE); // CraftBukkit
+
+ if (entityirongolem != null) {
+ if (entityirongolem.M() && entityirongolem.a((IWorldReader) this.a)) {
diff --git a/nms-patches/World.patch b/nms-patches/World.patch
index e4f6e071..93eaaad1 100644
--- a/nms-patches/World.patch
+++ b/nms-patches/World.patch
@@ -1,8 +1,8 @@
--- a/net/minecraft/server/World.java
+++ b/net/minecraft/server/World.java
-@@ -14,6 +14,21 @@
- import java.util.function.Supplier;
- import javax.annotation.Nullable;
+@@ -15,6 +15,23 @@
+ import org.apache.logging.log4j.LogManager;
+ import org.apache.logging.log4j.Logger;
+// CraftBukkit start
+import com.google.common.collect.Maps;
@@ -11,6 +11,8 @@
+import org.bukkit.block.BlockState;
+import org.bukkit.craftbukkit.CraftServer;
+import org.bukkit.craftbukkit.CraftWorld;
++import org.bukkit.craftbukkit.block.CraftBlockState;
++import org.bukkit.craftbukkit.block.data.CraftBlockData;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.craftbukkit.util.CraftMagicNumbers;
+import org.bukkit.event.block.BlockCanBuildEvent;
@@ -19,12 +21,12 @@
+import org.bukkit.generator.ChunkGenerator;
+// CraftBukkit end
+
- public abstract class World implements IBlockAccess {
+ public abstract class World implements GeneratorAccess, IIBlockAccess, AutoCloseable {
- private int a = 63;
-@@ -59,7 +74,52 @@
- private final WorldBorder P;
- int[] J;
+ protected static final Logger e = LogManager.getLogger();
+@@ -55,7 +72,52 @@
+ private final WorldBorder K;
+ int[] F;
- protected World(IDataManager idatamanager, WorldData worlddata, WorldProvider worldprovider, MethodProfiler methodprofiler, boolean flag) {
+ // CraftBukkit start Added the following
@@ -35,18 +37,18 @@
+
+ public boolean captureBlockStates = false;
+ public boolean captureTreeGeneration = false;
-+ public ArrayList<BlockState> capturedBlockStates= new ArrayList<BlockState>(){
++ public ArrayList<CraftBlockState> capturedBlockStates = new ArrayList<CraftBlockState>() {
+ @Override
-+ public boolean add( BlockState blockState ) {
-+ Iterator<BlockState> blockStateIterator = this.iterator();
-+ while( blockStateIterator.hasNext() ) {
++ public boolean add(CraftBlockState blockState) {
++ Iterator<CraftBlockState> blockStateIterator = this.iterator();
++ while (blockStateIterator.hasNext()) {
+ BlockState blockState1 = blockStateIterator.next();
-+ if ( blockState1.getLocation().equals( blockState.getLocation() ) ) {
++ if (blockState1.getLocation().equals(blockState.getLocation())) {
+ return false;
+ }
+ }
+
-+ return super.add( blockState );
++ return super.add(blockState);
+ }
+ };
+ public List<EntityItem> captureDrops;
@@ -73,13 +75,13 @@
+ this.ticksPerAnimalSpawns = this.getServer().getTicksPerAnimalSpawns(); // CraftBukkit
+ this.ticksPerMonsterSpawns = this.getServer().getTicksPerMonsterSpawns(); // CraftBukkit
+ // CraftBukkit end
- this.u = Lists.newArrayList(new IWorldAccess[] { this.t});
- this.N = Calendar.getInstance();
- this.scoreboard = new Scoreboard();
-@@ -72,6 +132,36 @@
+ this.v = Lists.newArrayList(new IWorldAccess[] { this.u});
+ this.allowMonsters = true;
+ this.allowAnimals = true;
+@@ -66,6 +128,36 @@
this.worldProvider = worldprovider;
this.isClientSide = flag;
- this.P = worldprovider.getWorldBorder();
+ this.K = worldprovider.getWorldBorder();
+ // CraftBukkit start
+ getWorldBorder().world = (WorldServer) this;
+ // From PlayerList.setPlayerFileData
@@ -112,17 +114,17 @@
+ // CraftBukkit end
}
- public World b() {
-@@ -209,6 +299,27 @@
+ public GeneratorAccess b() {
+@@ -138,6 +230,26 @@
}
public boolean setTypeAndData(BlockPosition blockposition, IBlockData iblockdata, int i) {
+ // CraftBukkit start - tree generation
+ if (this.captureTreeGeneration) {
-+ BlockState blockstate = null;
-+ Iterator<BlockState> it = capturedBlockStates.iterator();
++ CraftBlockState blockstate = null;
++ Iterator<CraftBlockState> it = capturedBlockStates.iterator();
+ while (it.hasNext()) {
-+ BlockState previous = it.next();
++ CraftBlockState previous = it.next();
+ if (previous.getX() == blockposition.getX() && previous.getY() == blockposition.getY() && previous.getZ() == blockposition.getZ()) {
+ blockstate = previous;
+ it.remove();
@@ -130,31 +132,30 @@
+ }
+ }
+ if (blockstate == null) {
-+ blockstate = org.bukkit.craftbukkit.block.CraftBlockState.getBlockState(this, blockposition.getX(), blockposition.getY(), blockposition.getZ(), i);
++ blockstate = org.bukkit.craftbukkit.block.CraftBlockState.getBlockState(this, blockposition, i);
+ }
-+ blockstate.setTypeId(CraftMagicNumbers.getId(iblockdata.getBlock()));
-+ blockstate.setRawData((byte) iblockdata.getBlock().toLegacyData(iblockdata));
++ blockstate.setData(iblockdata);
+ this.capturedBlockStates.add(blockstate);
+ return true;
+ }
+ // CraftBukkit end
- if (this.E(blockposition)) {
+ if (k(blockposition)) {
return false;
} else if (!this.isClientSide && this.worldData.getType() == WorldType.DEBUG_ALL_BLOCK_STATES) {
-@@ -216,9 +327,23 @@
+@@ -145,9 +257,23 @@
} else {
Chunk chunk = this.getChunkAtWorldCoords(blockposition);
Block block = iblockdata.getBlock();
+
+ // CraftBukkit start - capture blockstates
-+ BlockState blockstate = null;
++ CraftBlockState blockstate = null;
+ if (this.captureBlockStates) {
-+ blockstate = org.bukkit.craftbukkit.block.CraftBlockState.getBlockState(this, blockposition.getX(), blockposition.getY(), blockposition.getZ(), i);
++ blockstate = org.bukkit.craftbukkit.block.CraftBlockState.getBlockState(this, blockposition, i);
+ this.capturedBlockStates.add(blockstate);
+ }
+ // CraftBukkit end
+
- IBlockData iblockdata1 = chunk.a(blockposition, iblockdata);
+ IBlockData iblockdata1 = chunk.a(blockposition, iblockdata, (i & 64) != 0);
if (iblockdata1 == null) {
+ // CraftBukkit start - remove blockstate if failed
@@ -164,25 +165,25 @@
+ // CraftBukkit end
return false;
} else {
- if (iblockdata.c() != iblockdata1.c() || iblockdata.d() != iblockdata1.d()) {
-@@ -227,6 +352,7 @@
- this.methodProfiler.b();
+ IBlockData iblockdata2 = this.getType(blockposition);
+@@ -158,6 +284,7 @@
+ this.methodProfiler.e();
}
+ /*
- if ((i & 2) != 0 && (!this.isClientSide || (i & 4) == 0) && chunk.isReady()) {
- this.notify(blockposition, iblockdata1, iblockdata, i);
- }
-@@ -239,12 +365,37 @@
- } else if (!this.isClientSide && (i & 16) == 0) {
- this.c(blockposition, block);
+ if (iblockdata2 == iblockdata) {
+ if (iblockdata1 != iblockdata2) {
+ this.a(blockposition, blockposition);
+@@ -182,12 +309,52 @@
+ iblockdata.b(this, blockposition, j);
+ }
}
+ */
+
+ // CraftBukkit start
+ if (!this.captureBlockStates) { // Don't notify clients or update physics while capturing blockstates
+ // Modularize client and physic updates
-+ notifyAndUpdatePhysics(blockposition, chunk, iblockdata1, iblockdata, i);
++ notifyAndUpdatePhysics(blockposition, chunk, iblockdata1, iblockdata, iblockdata2, i);
+ }
+ // CraftBukkit end
@@ -192,45 +193,60 @@
}
+ // 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);
-+ }
++ public void notifyAndUpdatePhysics(BlockPosition blockposition, Chunk chunk, IBlockData oldBlock, IBlockData newBlock, IBlockData actualBlock, int i) {
++ IBlockData iblockdata = newBlock;
++ IBlockData iblockdata1 = oldBlock;
++ IBlockData iblockdata2 = actualBlock;
++ if (iblockdata2 == iblockdata) {
++ if (iblockdata1 != iblockdata2) {
++ this.a(blockposition, blockposition);
++ }
+
-+ if (!this.isClientSide && (i & 1) != 0) {
-+ this.update(blockposition, oldBlock.getBlock(), true);
-+ if (newBlock.n()) {
-+ this.updateAdjacentComparators(blockposition, newBlock.getBlock());
++ 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, iblockdata1, iblockdata, i);
++ }
++
++ if (!this.isClientSide && (i & 1) != 0) {
++ this.update(blockposition, iblockdata1.getBlock());
++ if (iblockdata.isComplexRedstone()) {
++ this.updateAdjacentComparators(blockposition, newBlock.getBlock());
++ }
++ }
++
++ if ((i & 16) == 0) {
++ int j = i & -2;
++
++ iblockdata1.b(this, blockposition, j);
++ iblockdata.a((GeneratorAccess) this, blockposition, j);
++ iblockdata.b(this, blockposition, j);
+ }
-+ } else if (!this.isClientSide && (i & 16) == 0) {
-+ this.c(blockposition, newBlock.getBlock());
+ }
+ }
+ // CraftBukkit end
+
public boolean setAir(BlockPosition blockposition) {
- return this.setTypeAndData(blockposition, Blocks.AIR.getBlockData(), 3);
- }
-@@ -278,6 +429,11 @@
+ Fluid fluid = this.b(blockposition);
+
+@@ -224,6 +391,11 @@
- public void update(BlockPosition blockposition, Block block, boolean flag) {
+ public void update(BlockPosition blockposition, Block block) {
if (this.worldData.getType() != WorldType.DEBUG_ALL_BLOCK_STATES) {
+ // CraftBukkit start
+ if (populating) {
+ return;
+ }
+ // CraftBukkit end
- this.applyPhysics(blockposition, block, flag);
+ this.applyPhysics(blockposition, block);
}
-@@ -366,6 +522,17 @@
+@@ -299,6 +471,17 @@
IBlockData iblockdata = this.getType(blockposition);
try {
+ // CraftBukkit start
+ CraftWorld world = ((WorldServer) this).getWorld();
+ if (world != null) {
-+ BlockPhysicsEvent event = new BlockPhysicsEvent(world.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), CraftMagicNumbers.getId(block));
++ BlockPhysicsEvent event = new BlockPhysicsEvent(world.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), CraftBlockData.fromData(iblockdata));
+ this.getServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
@@ -241,25 +257,34 @@
iblockdata.doPhysics(this, blockposition, block, blockposition1);
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.a(throwable, "Exception while updating neighbours");
-@@ -583,6 +750,17 @@
+@@ -307,7 +490,7 @@
+ crashreportsystemdetails.a("Source block type", () -> {
+ try {
+ return String.format("ID #%s (%s // %s)", new Object[] { Block.REGISTRY.b(block), block.m(), block.getClass().getCanonicalName()});
+- } catch (Throwable throwable) {
++ } catch (Throwable throwablex) { // CraftBukkit - decompile error
+ return "ID #" + Block.REGISTRY.b(block);
+ }
+ });
+@@ -393,6 +576,17 @@
}
public IBlockData getType(BlockPosition blockposition) {
+ // CraftBukkit start - tree generation
+ if (captureTreeGeneration) {
-+ Iterator<BlockState> it = capturedBlockStates.iterator();
++ Iterator<CraftBlockState> it = capturedBlockStates.iterator();
+ while (it.hasNext()) {
-+ BlockState previous = it.next();
++ CraftBlockState previous = it.next();
+ if (previous.getX() == blockposition.getX() && previous.getY() == blockposition.getY() && previous.getZ() == blockposition.getZ()) {
-+ return CraftMagicNumbers.getBlock(previous.getTypeId()).fromLegacyData(previous.getRawData());
++ return previous.getHandle();
+ }
+ }
+ }
+ // CraftBukkit end
- if (this.E(blockposition)) {
- return Blocks.AIR.getBlockData();
+ if (k(blockposition)) {
+ return Blocks.VOID_AIR.getBlockData();
} else {
-@@ -788,6 +966,42 @@
+@@ -639,6 +833,42 @@
}
public boolean addEntity(Entity entity) {
@@ -302,23 +327,23 @@
int i = MathHelper.floor(entity.locX / 16.0D);
int j = MathHelper.floor(entity.locZ / 16.0D);
boolean flag = entity.attachedToPlayer;
-@@ -818,6 +1032,7 @@
- ((IWorldAccess) this.u.get(i)).a(entity);
+@@ -669,6 +899,7 @@
+ ((IWorldAccess) this.v.get(i)).a(entity);
}
+ entity.valid = true; // CraftBukkit
}
protected void c(Entity entity) {
-@@ -825,6 +1040,7 @@
- ((IWorldAccess) this.u.get(i)).b(entity);
+@@ -676,6 +907,7 @@
+ ((IWorldAccess) this.v.get(i)).b(entity);
}
+ entity.valid = false; // CraftBukkit
}
public void kill(Entity entity) {
-@@ -860,7 +1076,15 @@
+@@ -711,7 +943,15 @@
this.getChunkAt(i, j).b(entity);
}
@@ -335,19 +360,10 @@
this.c(entity);
}
-@@ -977,7 +1201,7 @@
- }
+@@ -746,6 +986,11 @@
- public boolean a(AxisAlignedBB axisalignedbb) {
-- return this.a((Entity) null, axisalignedbb, true, Lists.newArrayList());
-+ return this.a((Entity) null, axisalignedbb, true, Lists.<AxisAlignedBB>newArrayList()); // CraftBukkit - decompile error
- }
-
- public int a(float f) {
-@@ -1047,6 +1271,11 @@
-
- for (i = 0; i < this.j.size(); ++i) {
- entity = (Entity) this.j.get(i);
+ for (i = 0; i < this.k.size(); ++i) {
+ entity = (Entity) this.k.get(i);
+ // CraftBukkit start - Fixed an NPE
+ if (entity == null) {
+ continue;
@@ -356,7 +372,7 @@
try {
++entity.ticksLived;
-@@ -1095,8 +1324,10 @@
+@@ -794,8 +1039,10 @@
CrashReportSystemDetails crashreportsystemdetails1;
CrashReport crashreport1;
@@ -366,10 +382,10 @@
+ for (this.tickPosition = 0; this.tickPosition < this.entityList.size(); ++this.tickPosition) {
+ entity = (Entity) this.entityList.get(this.tickPosition);
+ // CraftBukkit end
- Entity entity1 = entity.bJ();
+ Entity entity1 = entity.getVehicle();
if (entity1 != null) {
-@@ -1129,7 +1360,7 @@
+@@ -828,7 +1075,7 @@
this.getChunkAt(j, l).b(entity);
}
@@ -378,10 +394,10 @@
this.c(entity);
}
-@@ -1184,9 +1415,11 @@
- TileEntity tileentity1 = (TileEntity) this.b.get(i1);
+@@ -883,9 +1130,11 @@
+ TileEntity tileentity1 = (TileEntity) this.c.get(i1);
- if (!tileentity1.y()) {
+ if (!tileentity1.x()) {
+ /* CraftBukkit start - Order matters, moved down
if (!this.tileEntityList.contains(tileentity1)) {
this.a(tileentity1);
@@ -390,7 +406,7 @@
if (this.isLoaded(tileentity1.getPosition())) {
Chunk chunk = this.getChunkAtWorldCoords(tileentity1.getPosition());
-@@ -1194,6 +1427,12 @@
+@@ -893,6 +1142,12 @@
chunk.a(tileentity1.getPosition(), tileentity1);
this.notify(tileentity1.getPosition(), iblockdata, iblockdata, 3);
@@ -403,7 +419,7 @@
}
}
}
-@@ -1247,15 +1486,13 @@
+@@ -946,15 +1201,13 @@
int i;
int j;
@@ -423,24 +439,24 @@
}
+ // CraftBukkit end
- entity.M = entity.locX;
- entity.N = entity.locY;
-@@ -1268,6 +1505,7 @@
- entity.aE();
+ entity.N = entity.locX;
+ entity.O = entity.locY;
+@@ -967,6 +1220,7 @@
+ entity.aH();
} else {
- entity.B_();
+ entity.tick();
+ entity.postTick(); // CraftBukkit
}
}
-@@ -1559,11 +1797,18 @@
+@@ -1296,11 +1550,18 @@
}
}
+ public Map<BlockPosition, TileEntity> capturedTileEntities = Maps.newHashMap();
@Nullable
public TileEntity getTileEntity(BlockPosition blockposition) {
- if (this.E(blockposition)) {
+ if (k(blockposition)) {
return null;
} else {
+ // CraftBukkit start
@@ -451,26 +467,26 @@
+
TileEntity tileentity = null;
- if (this.O) {
-@@ -1598,6 +1843,14 @@
+ if (this.J) {
+@@ -1335,6 +1596,14 @@
public void setTileEntity(BlockPosition blockposition, @Nullable TileEntity tileentity) {
- if (!this.E(blockposition)) {
- if (tileentity != null && !tileentity.y()) {
-+ // CraftBukkit start
-+ if (captureBlockStates) {
-+ tileentity.a(this);
-+ tileentity.setPosition(blockposition);
-+ capturedTileEntities.put(blockposition, tileentity);
-+ return;
-+ }
-+ // CraftBukkit end
- if (this.O) {
+ if (!k(blockposition)) {
+ if (tileentity != null && !tileentity.x()) {
++ // CraftBukkit start
++ if (captureBlockStates) {
++ tileentity.setWorld(this);
++ tileentity.setPosition(blockposition);
++ capturedTileEntities.put(blockposition, tileentity);
++ return;
++ }
++ // CraftBukkit end
+ if (this.J) {
tileentity.setPosition(blockposition);
- Iterator iterator = this.b.iterator();
-@@ -1757,6 +2010,14 @@
+ Iterator iterator = this.c.iterator();
+@@ -1494,6 +1763,14 @@
}
- this.o = MathHelper.a(this.o, 0.0F, 1.0F);
+ this.p = MathHelper.a(this.p, 0.0F, 1.0F);
+
+ // CraftBukkit start
+ for (int idx = 0; idx < this.players.size(); ++idx) {
@@ -482,7 +498,7 @@
}
}
}
-@@ -1894,7 +2155,10 @@
+@@ -1579,7 +1856,10 @@
}
public boolean c(EnumSkyBlock enumskyblock, BlockPosition blockposition) {
@@ -494,25 +510,25 @@
return false;
} else {
int i = 0;
-@@ -2061,7 +2325,7 @@
+@@ -1750,7 +2030,7 @@
while (iterator.hasNext()) {
Entity entity = (Entity) iterator.next();
-- if (oclass.isAssignableFrom(entity.getClass()) && predicate.apply(entity)) {
-+ if (oclass.isAssignableFrom(entity.getClass()) && predicate.apply((T) entity)) {
+- if (oclass.isAssignableFrom(entity.getClass()) && predicate.test(entity)) {
++ if (oclass.isAssignableFrom(entity.getClass()) && predicate.test((T) entity)) {
arraylist.add(entity);
}
}
-@@ -2076,7 +2340,7 @@
+@@ -1765,7 +2045,7 @@
while (iterator.hasNext()) {
Entity entity = (Entity) iterator.next();
-- if (oclass.isAssignableFrom(entity.getClass()) && predicate.apply(entity)) {
-+ if (oclass.isAssignableFrom(entity.getClass()) && predicate.apply((T) entity)) { // CraftBukkit - fix decompile error
+- if (oclass.isAssignableFrom(entity.getClass()) && predicate.test(entity)) {
++ if (oclass.isAssignableFrom(entity.getClass()) && predicate.test((T) entity)) { // CraftBukkit - fix decompile error
arraylist.add(entity);
}
}
-@@ -2125,7 +2389,7 @@
+@@ -1814,7 +2094,7 @@
}
}
@@ -521,7 +537,7 @@
}
@Nullable
-@@ -2146,8 +2410,17 @@
+@@ -1835,8 +2115,17 @@
while (iterator.hasNext()) {
Entity entity = (Entity) iterator.next();
@@ -540,7 +556,7 @@
++i;
}
}
-@@ -2156,12 +2429,18 @@
+@@ -1845,12 +2134,18 @@
}
public void a(Collection<Entity> collection) {
@@ -560,22 +576,7 @@
this.b(entity);
}
-@@ -2175,7 +2454,13 @@
- IBlockData iblockdata = this.getType(blockposition);
- AxisAlignedBB axisalignedbb = flag ? null : block.getBlockData().d(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));
-+ // 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));
-+ BlockCanBuildEvent event = new BlockCanBuildEvent(this.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), CraftMagicNumbers.getId(block), defaultReturn);
-+ this.getServer().getPluginManager().callEvent(event);
-+
-+ return event.isBuildable();
-+ // CraftBukkit end
- }
-
- public int getSeaLevel() {
-@@ -2285,6 +2570,11 @@
+@@ -1954,6 +2249,11 @@
for (int i = 0; i < this.players.size(); ++i) {
EntityHuman entityhuman1 = (EntityHuman) this.players.get(i);
@@ -585,9 +586,9 @@
+ }
+ // CraftBukkit end
- if (predicate.apply(entityhuman1)) {
+ if (predicate.test(entityhuman1)) {
double d5 = entityhuman1.d(d0, d1, d2);
-@@ -2453,6 +2743,16 @@
+@@ -2122,6 +2422,16 @@
public void everyoneSleeping() {}
@@ -601,10 +602,10 @@
+ }
+ // CraftBukkit end
+
- public float h(float f) {
- return (this.p + (this.q - this.p) * f) * this.j(f);
+ public float g(float f) {
+ return (this.q + (this.r - this.q) * f) * this.i(f);
}
-@@ -2670,7 +2970,7 @@
+@@ -2296,7 +2606,7 @@
int l = j * 16 + 8 - blockposition.getZ();
boolean flag = true;
diff --git a/nms-patches/WorldData.patch b/nms-patches/WorldData.patch
index d81876aa..568e11a8 100644
--- a/nms-patches/WorldData.patch
+++ b/nms-patches/WorldData.patch
@@ -1,7 +1,7 @@
--- a/net/minecraft/server/WorldData.java
+++ b/net/minecraft/server/WorldData.java
-@@ -5,6 +5,11 @@
- import java.util.Map;
+@@ -11,6 +11,11 @@
+ import java.util.Set;
import java.util.Map.Entry;
import javax.annotation.Nullable;
+// CraftBukkit start
@@ -12,15 +12,23 @@
public class WorldData {
-@@ -49,6 +54,7 @@
- private int M;
- private final Map<DimensionManager, NBTTagCompound> N;
- private GameRules O;
+@@ -62,6 +67,7 @@
+ private final Map<DimensionManager, NBTTagCompound> S;
+ private NBTTagCompound T;
+ private final GameRules U;
+ public WorldServer world; // CraftBukkit
protected WorldData() {
this.f = WorldType.NORMAL;
-@@ -437,6 +443,16 @@
+@@ -296,6 +302,7 @@
+ nbttagcompound2.setBoolean("Snapshot", true);
+ nbttagcompound.set("Version", nbttagcompound2);
+ nbttagcompound.setInt("DataVersion", 1513);
++ if (org.bukkit.craftbukkit.util.CraftMagicNumbers.DATA_VERSION != 1513) throw new AssertionError(); // CraftBukkit - sentinel
+ nbttagcompound.setLong("RandomSeed", this.e);
+ nbttagcompound.setString("generatorName", this.f.name());
+ nbttagcompound.setInt("generatorVersion", this.f.getVersion());
+@@ -466,6 +473,16 @@
}
public void setThundering(boolean flag) {
@@ -34,10 +42,10 @@
+ }
+ }
+ // CraftBukkit end
- this.v = flag;
+ this.y = flag;
}
-@@ -453,6 +469,16 @@
+@@ -482,6 +499,16 @@
}
public void setStorm(boolean flag) {
@@ -51,13 +59,13 @@
+ }
+ }
+ // CraftBukkit end
- this.t = flag;
+ this.w = flag;
}
-@@ -598,6 +624,12 @@
+@@ -631,6 +658,12 @@
public void setDifficulty(EnumDifficulty enumdifficulty) {
- this.C = enumdifficulty;
+ this.F = enumdifficulty;
+ // CraftBukkit start
+ PacketPlayOutServerDifficulty packet = new PacketPlayOutServerDifficulty(this.getDifficulty(), this.isDifficultyLocked());
+ for (EntityPlayer player : (java.util.List<EntityPlayer>) (java.util.List) world.players) {
@@ -67,9 +75,9 @@
}
public boolean isDifficultyLocked() {
-@@ -716,4 +748,12 @@
- public void a(DimensionManager dimensionmanager, NBTTagCompound nbttagcompound) {
- this.N.put(dimensionmanager, nbttagcompound);
+@@ -712,4 +745,12 @@
+ public void c(@Nullable NBTTagCompound nbttagcompound) {
+ this.T = nbttagcompound;
}
+
+ // CraftBukkit start - Check if the name stored in NBT is the correct one
diff --git a/nms-patches/WorldGenGroundBush.patch b/nms-patches/WorldGenGroundBush.patch
index bbd0306b..4afb31ce 100644
--- a/nms-patches/WorldGenGroundBush.patch
+++ b/nms-patches/WorldGenGroundBush.patch
@@ -1,6 +1,6 @@
--- a/net/minecraft/server/WorldGenGroundBush.java
+++ b/net/minecraft/server/WorldGenGroundBush.java
-@@ -45,7 +45,12 @@
+@@ -46,7 +46,12 @@
}
}
}
diff --git a/nms-patches/WorldGenMegaTreeAbstract.patch b/nms-patches/WorldGenMegaTreeAbstract.patch
deleted file mode 100644
index 99dd51eb..00000000
--- a/nms-patches/WorldGenMegaTreeAbstract.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- a/net/minecraft/server/WorldGenMegaTreeAbstract.java
-+++ b/net/minecraft/server/WorldGenMegaTreeAbstract.java
-@@ -42,7 +42,7 @@
-
- for (int k = -b0; k <= b0 && flag; ++k) {
- for (int l = -b0; l <= b0 && flag; ++l) {
-- if (blockposition.getY() + j < 0 || blockposition.getY() + j >= 256 || !this.a(world.getType(blockposition.a(k, j, l)).getBlock())) {
-+ if (blockposition.getY() + j < 0 || blockposition.getY() + j >= 256 || (!this.a(world.getType(blockposition.a(k, j, l)).getBlock()) && world.getType(blockposition.a(k, j, l)).getBlock() != Blocks.SAPLING)) { // CraftBukkit - ignore our own saplings
- flag = false;
- }
- }
diff --git a/nms-patches/WorldGenRegistration.patch b/nms-patches/WorldGenRegistration.patch
deleted file mode 100644
index 63364bcb..00000000
--- a/nms-patches/WorldGenRegistration.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- a/net/minecraft/server/WorldGenRegistration.java
-+++ b/net/minecraft/server/WorldGenRegistration.java
-@@ -157,7 +157,7 @@
- entitywitch.cW();
- 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);
-+ world.addEntity(entitywitch, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CHUNK_GEN); // CraftBukkit - add SpawnReason
- }
- }
-
diff --git a/nms-patches/WorldGenTreeProvider.patch b/nms-patches/WorldGenTreeProvider.patch
new file mode 100644
index 00000000..c8da90ac
--- /dev/null
+++ b/nms-patches/WorldGenTreeProvider.patch
@@ -0,0 +1,40 @@
+--- a/net/minecraft/server/WorldGenTreeProvider.java
++++ b/net/minecraft/server/WorldGenTreeProvider.java
+@@ -2,6 +2,7 @@
+
+ import java.util.Random;
+ import javax.annotation.Nullable;
++import org.bukkit.TreeType; // CraftBukkit
+
+ public abstract class WorldGenTreeProvider {
+
+@@ -16,6 +17,29 @@
+ if (worldgentreeabstract == null) {
+ return false;
+ } else {
++ // CraftBukkit start
++ if (worldgentreeabstract instanceof WorldGenAcaciaTree) {
++ BlockSapling.treeType = TreeType.ACACIA;
++ } else if (worldgentreeabstract instanceof WorldGenBigTree) {
++ BlockSapling.treeType = TreeType.BIG_TREE;
++ } else if (worldgentreeabstract instanceof WorldGenForest) {
++ BlockSapling.treeType = TreeType.BIRCH;
++ } else if (worldgentreeabstract instanceof WorldGenForestTree) {
++ BlockSapling.treeType = TreeType.DARK_OAK;
++ } else if (worldgentreeabstract instanceof WorldGenJungleTree) {
++ BlockSapling.treeType = TreeType.JUNGLE;
++ } else if (worldgentreeabstract instanceof WorldGenMegaTree) {
++ BlockSapling.treeType = TreeType.MEGA_REDWOOD;
++ } else if (worldgentreeabstract instanceof WorldGenTaiga1) {
++ BlockSapling.treeType = TreeType.REDWOOD;
++ } else if (worldgentreeabstract instanceof WorldGenTaiga2) {
++ BlockSapling.treeType = TreeType.REDWOOD;
++ } else if (worldgentreeabstract instanceof WorldGenTrees) {
++ BlockSapling.treeType = TreeType.TREE;
++ } else {
++ throw new IllegalArgumentException("Unknown tree generator " + worldgentreeabstract);
++ }
++ // CraftBukkit end
+ generatoraccess.setTypeAndData(blockposition, Blocks.AIR.getBlockData(), 4);
+ if (worldgentreeabstract.generate(generatoraccess, generatoraccess.getChunkProvider().getChunkGenerator(), random, blockposition, WorldGenFeatureConfiguration.e)) {
+ return true;
diff --git a/nms-patches/WorldGenVillagePieces.patch b/nms-patches/WorldGenVillagePieces.patch
index ca0efd5f..e55f15ce 100644
--- a/nms-patches/WorldGenVillagePieces.patch
+++ b/nms-patches/WorldGenVillagePieces.patch
@@ -1,45 +1,19 @@
--- a/net/minecraft/server/WorldGenVillagePieces.java
+++ b/net/minecraft/server/WorldGenVillagePieces.java
-@@ -238,10 +238,10 @@
-
- protected void a(NBTTagCompound nbttagcompound) {
- super.a(nbttagcompound);
-- nbttagcompound.setInt("CA", Block.REGISTRY.a((Object) this.a));
-- nbttagcompound.setInt("CB", Block.REGISTRY.a((Object) this.b));
-- nbttagcompound.setInt("CC", Block.REGISTRY.a((Object) this.c));
-- nbttagcompound.setInt("CD", Block.REGISTRY.a((Object) this.d));
-+ nbttagcompound.setInt("CA", Block.REGISTRY.a(this.a));
-+ nbttagcompound.setInt("CB", Block.REGISTRY.a(this.b));
-+ nbttagcompound.setInt("CC", Block.REGISTRY.a(this.c));
-+ nbttagcompound.setInt("CD", Block.REGISTRY.a(this.d));
- }
-
- protected void a(NBTTagCompound nbttagcompound, DefinedStructureManager definedstructuremanager) {
-@@ -371,8 +371,8 @@
-
- protected void a(NBTTagCompound nbttagcompound) {
- super.a(nbttagcompound);
-- nbttagcompound.setInt("CA", Block.REGISTRY.a((Object) this.a));
-- nbttagcompound.setInt("CB", Block.REGISTRY.a((Object) this.b));
-+ nbttagcompound.setInt("CA", Block.REGISTRY.a(this.a));
-+ nbttagcompound.setInt("CB", Block.REGISTRY.a(this.b));
- }
-
- protected void a(NBTTagCompound nbttagcompound, DefinedStructureManager definedstructuremanager) {
-@@ -1672,14 +1672,14 @@
- entityzombievillager.prepare(world.D(new BlockPosition(entityzombievillager)), (GroupDataEntity) null);
+@@ -1662,14 +1662,14 @@
+ entityzombievillager.prepare(generatoraccess.getDamageScaler(new BlockPosition(entityzombievillager)), (GroupDataEntity) null, (NBTTagCompound) null);
entityzombievillager.setProfession(this.c(i1, 0));
- entityzombievillager.cW();
-- world.addEntity(entityzombievillager);
-+ world.addEntity(entityzombievillager, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CHUNK_GEN); // CraftBukkit - add SpawnReason
+ entityzombievillager.di();
+- generatoraccess.addEntity(entityzombievillager);
++ generatoraccess.addEntity(entityzombievillager, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CHUNK_GEN); // CraftBukkit - add SpawnReason
} else {
- EntityVillager entityvillager = new EntityVillager(world);
+ EntityVillager entityvillager = new EntityVillager(generatoraccess.getMinecraftWorld());
entityvillager.setPositionRotation((double) j1 + 0.5D, (double) k1, (double) l1 + 0.5D, 0.0F, 0.0F);
- 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
+ entityvillager.setProfession(this.c(i1, generatoraccess.m().nextInt(6)));
+ entityvillager.a(generatoraccess.getDamageScaler(new BlockPosition(entityvillager)), (GroupDataEntity) null, (NBTTagCompound) null, false);
+- generatoraccess.addEntity(entityvillager);
++ generatoraccess.addEntity(entityvillager, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CHUNK_GEN); // CraftBukkit - add SpawnReason
}
}
diff --git a/nms-patches/WorldGenWitchHut.patch b/nms-patches/WorldGenWitchHut.patch
new file mode 100644
index 00000000..70c91680
--- /dev/null
+++ b/nms-patches/WorldGenWitchHut.patch
@@ -0,0 +1,11 @@
+--- a/net/minecraft/server/WorldGenWitchHut.java
++++ b/net/minecraft/server/WorldGenWitchHut.java
+@@ -86,7 +86,7 @@
+ entitywitch.di();
+ entitywitch.setPositionRotation((double) i + 0.5D, (double) j, (double) k + 0.5D, 0.0F, 0.0F);
+ entitywitch.prepare(generatoraccess.getDamageScaler(new BlockPosition(i, j, k)), (GroupDataEntity) null, (NBTTagCompound) null);
+- generatoraccess.addEntity(entitywitch);
++ generatoraccess.addEntity(entitywitch, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CHUNK_GEN); // CraftBukkit - add SpawnReason
+ }
+ }
+
diff --git a/nms-patches/WorldMap.patch b/nms-patches/WorldMap.patch
index 5c8d8157..622228b6 100644
--- a/nms-patches/WorldMap.patch
+++ b/nms-patches/WorldMap.patch
@@ -1,6 +1,6 @@
--- a/net/minecraft/server/WorldMap.java
+++ b/net/minecraft/server/WorldMap.java
-@@ -7,6 +7,14 @@
+@@ -7,6 +7,15 @@
import java.util.Map;
import javax.annotation.Nullable;
@@ -10,13 +10,14 @@
+import org.bukkit.craftbukkit.CraftServer;
+import org.bukkit.craftbukkit.CraftWorld;
+import org.bukkit.craftbukkit.map.CraftMapView;
++import org.bukkit.craftbukkit.util.CraftChatMessage;
+// CraftBukkit end
+
public class WorldMap extends PersistentBase {
public int centerX;
-@@ -20,8 +28,18 @@
- private final Map<EntityHuman, WorldMap.WorldMapHumanTracker> k = Maps.newHashMap();
+@@ -21,8 +30,18 @@
+ private final Map<String, MapIconBanner> k = Maps.newHashMap();
public Map<String, MapIcon> decorations = Maps.newLinkedHashMap();
+ // CraftBukkit start
@@ -33,8 +34,8 @@
+ // CraftBukkit end
}
- public void a(double d0, double d1, int i) {
-@@ -34,7 +52,30 @@
+ public void a(int i, int j, int k, boolean flag, boolean flag1, int l) {
+@@ -44,7 +63,30 @@
}
public void a(NBTTagCompound nbttagcompound) {
@@ -65,8 +66,8 @@
+ // CraftBukkit end
this.centerX = nbttagcompound.getInt("xCenter");
this.centerZ = nbttagcompound.getInt("zCenter");
- this.scale = nbttagcompound.getByte("scale");
-@@ -76,6 +117,25 @@
+ this.scale = (byte) MathHelper.clamp(nbttagcompound.getByte("scale"), 0, 4);
+@@ -67,6 +109,25 @@
}
public NBTTagCompound b(NBTTagCompound nbttagcompound) {
@@ -92,7 +93,7 @@
nbttagcompound.setByte("dimension", this.map);
nbttagcompound.setInt("xCenter", this.centerX);
nbttagcompound.setInt("zCenter", this.centerZ);
-@@ -265,12 +325,26 @@
+@@ -315,12 +376,25 @@
@Nullable
public Packet<?> a(ItemStack itemstack) {
@@ -104,18 +105,17 @@
+ for ( org.bukkit.map.MapCursor cursor : render.cursors) {
+
+ if (cursor.isVisible()) {
-+ icons.add(new MapIcon(MapIcon.Type.a(cursor.getRawType()), cursor.getX(), cursor.getY(), cursor.getDirection()));
++ icons.add(new MapIcon(MapIcon.Type.a(cursor.getRawType()), cursor.getX(), cursor.getY(), cursor.getDirection(), CraftChatMessage.fromStringOrNull(cursor.getCaption())));
+ }
+ }
+
if (this.d) {
this.d = false;
-- return new PacketPlayOutMap(itemstack.getData(), WorldMap.this.scale, WorldMap.this.track, WorldMap.this.decorations.values(), WorldMap.this.colors, this.e, this.f, this.g + 1 - this.e, this.h + 1 - this.f);
-+ // PAIL: this.e
-+ return new PacketPlayOutMap(itemstack.getData(), WorldMap.this.scale, WorldMap.this.track, icons, render.buffer, this.e, this.f, this.g + 1 - this.e, this.h + 1 - this.f);
+- return new PacketPlayOutMap(ItemWorldMap.e(itemstack), WorldMap.this.scale, WorldMap.this.track, WorldMap.this.decorations.values(), WorldMap.this.colors, this.e, this.f, this.g + 1 - this.e, this.h + 1 - this.f);
++ return new PacketPlayOutMap(ItemWorldMap.e(itemstack), WorldMap.this.scale, WorldMap.this.track, icons, render.buffer, this.e, this.f, this.g + 1 - this.e, this.h + 1 - this.f);
} else {
-- return this.i++ % 5 == 0 ? new PacketPlayOutMap(itemstack.getData(), WorldMap.this.scale, WorldMap.this.track, WorldMap.this.decorations.values(), WorldMap.this.colors, 0, 0, 0, 0) : null;
-+ return this.i++ % 5 == 0 ? new PacketPlayOutMap(itemstack.getData(), WorldMap.this.scale, WorldMap.this.track, icons, render.buffer, 0, 0, 0, 0) : null;
+- return this.i++ % 5 == 0 ? new PacketPlayOutMap(ItemWorldMap.e(itemstack), WorldMap.this.scale, WorldMap.this.track, WorldMap.this.decorations.values(), WorldMap.this.colors, 0, 0, 0, 0) : null;
++ return this.i++ % 5 == 0 ? new PacketPlayOutMap(ItemWorldMap.e(itemstack), WorldMap.this.scale, WorldMap.this.track, icons, render.buffer, 0, 0, 0, 0) : null;
}
+ // CraftBukkit end
}
diff --git a/nms-patches/WorldNBTStorage.patch b/nms-patches/WorldNBTStorage.patch
index c39f4ef7..675a06b5 100644
--- a/nms-patches/WorldNBTStorage.patch
+++ b/nms-patches/WorldNBTStorage.patch
@@ -1,6 +1,6 @@
--- a/net/minecraft/server/WorldNBTStorage.java
+++ b/net/minecraft/server/WorldNBTStorage.java
-@@ -12,6 +12,11 @@
+@@ -14,6 +14,11 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -12,15 +12,15 @@
public class WorldNBTStorage implements IDataManager, IPlayerFileData {
private static final Logger b = LogManager.getLogger();
-@@ -22,6 +27,7 @@
+@@ -24,6 +29,7 @@
private final String g;
private final DefinedStructureManager h;
- protected final DataConverterManager a;
+ protected final DataFixer a;
+ private UUID uuid = null; // CraftBukkit
- public WorldNBTStorage(File file, String s, boolean flag, DataConverterManager dataconvertermanager) {
- this.a = dataconvertermanager;
-@@ -168,12 +174,38 @@
+ public WorldNBTStorage(File file, String s, @Nullable MinecraftServer minecraftserver, DataFixer datafixer) {
+ this.a = datafixer;
+@@ -170,6 +176,16 @@
}
if (nbttagcompound != null) {
@@ -34,9 +34,10 @@
+ }
+ }
+ // CraftBukkit end
- entityhuman.f(this.a.a((DataConverterType) DataConverterTypes.PLAYER, nbttagcompound));
- }
+ int i = nbttagcompound.hasKeyOfType("DataVersion", 3) ? nbttagcompound.getInt("DataVersion") : -1;
+ entityhuman.f(GameProfileSerializer.a(this.a, DataFixTypes.PLAYER, nbttagcompound, i));
+@@ -178,6 +194,22 @@
return nbttagcompound;
}
@@ -59,9 +60,9 @@
public IPlayerFileData getPlayerFileData() {
return this;
}
-@@ -203,4 +235,50 @@
- public DefinedStructureManager h() {
- return this.h;
+@@ -211,4 +243,50 @@
+ public DataFixer i() {
+ return this.a;
}
+
+ // CraftBukkit start
diff --git a/nms-patches/WorldProviderHell.patch b/nms-patches/WorldProviderHell.patch
index 3b43b316..f3660cd7 100644
--- a/nms-patches/WorldProviderHell.patch
+++ b/nms-patches/WorldProviderHell.patch
@@ -1,6 +1,6 @@
--- a/net/minecraft/server/WorldProviderHell.java
+++ b/net/minecraft/server/WorldProviderHell.java
-@@ -44,11 +44,11 @@
+@@ -56,11 +56,11 @@
public WorldBorder getWorldBorder() {
return new WorldBorder() {
public double getCenterX() {
diff --git a/nms-patches/WorldServer.patch b/nms-patches/WorldServer.patch
index 682421ef..6c1c381e 100644
--- a/nms-patches/WorldServer.patch
+++ b/nms-patches/WorldServer.patch
@@ -1,6 +1,6 @@
--- a/net/minecraft/server/WorldServer.java
+++ b/net/minecraft/server/WorldServer.java
-@@ -20,14 +20,26 @@
+@@ -20,6 +20,18 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -19,22 +19,13 @@
public class WorldServer extends World implements IAsyncTaskHandler {
private static final Logger a = LogManager.getLogger();
- private final MinecraftServer server;
- public EntityTracker tracker;
- private final PlayerChunkMap manager;
-- private final Set<NextTickListEntry> nextTickListHash = Sets.newHashSet();
-- private final TreeSet<NextTickListEntry> nextTickList = new TreeSet();
-+ // private final Set<NextTickListEntry> nextTickListHash = Sets.newHashSet();
-+ private final HashTreeSet<NextTickListEntry> nextTickList = new HashTreeSet<NextTickListEntry>(); // CraftBukkit - HashTreeSet
- private final Map<UUID, Entity> entitiesByUUID = Maps.newHashMap();
- public boolean savingDisabled;
+@@ -38,28 +50,36 @@
+ ObjectLinkedOpenHashSet<BlockActionData> d;
private boolean Q;
-@@ -39,14 +51,22 @@
- private int V;
- private final List<NextTickListEntry> W = Lists.newArrayList();
- public WorldServer(MinecraftServer minecraftserver, IDataManager idatamanager, WorldData worlddata, int i, MethodProfiler methodprofiler) {
- super(idatamanager, worlddata, DimensionManager.a(i).d(), methodprofiler, false);
+- Predicate predicate = (block) -> {
+ // CraftBukkit start
+ public final int dimension;
+
@@ -45,52 +36,60 @@
+ this.pvpMode = minecraftserver.getPVP();
+ worlddata.world = this;
+ // CraftBukkit end
++ Predicate<Block> predicate = (block) -> { // CraftBukkit - decompile error
+ return block == null || block.getBlockData().isAir();
+ };
+ RegistryBlocks registryblocks = Block.REGISTRY;
+
+ Block.REGISTRY.getClass();
+ Function function = registryblocks::b;
+- RegistryBlocks registryblocks1 = Block.REGISTRY;
++ RegistryBlocks<MinecraftKey, Block> registryblocks1 = Block.REGISTRY; // CraftBukkit - decompile error
+
+ Block.REGISTRY.getClass();
+- this.nextTickListBlock = new TickListServer(this, predicate, function, registryblocks1::get, this::b);
+- predicate = (fluidtype) -> {
++ this.nextTickListBlock = new TickListServer<>(this, predicate, function, registryblocks1::get, this::b); // CraftBukkit - decompile error
++ Predicate<FluidType> predicate2 = (fluidtype) -> {
+ return fluidtype == null || fluidtype == FluidTypes.a;
+ };
+ registryblocks = FluidType.c;
+ FluidType.c.getClass();
+ function = registryblocks::b;
+- registryblocks1 = FluidType.c;
++ RegistryBlocks<MinecraftKey, FluidType> registryblocks2 = FluidType.c; // CraftBukkit - decompile error
+ FluidType.c.getClass();
+- this.nextTickListFluid = new TickListServer(this, predicate, function, registryblocks1::get, this::a);
++ this.nextTickListFluid = new TickListServer<>(this, predicate2, function, registryblocks2::get, this::a); // CraftBukkit - decompile error
+ this.siegeManager = new VillageSiege(this);
+ this.d = new ObjectLinkedOpenHashSet();
this.server = minecraftserver;
- this.tracker = new EntityTracker(this);
+@@ -67,7 +87,7 @@
this.manager = new PlayerChunkMap(this);
this.worldProvider.a((World) this);
- this.chunkProvider = this.n();
+ this.chunkProvider = this.q();
- this.portalTravelAgent = new PortalTravelAgent(this);
+ this.portalTravelAgent = new org.bukkit.craftbukkit.CraftTravelAgent(this); // CraftBukkit
- this.J();
- this.K();
- this.getWorldBorder().a(minecraftserver.aE());
-@@ -65,6 +85,7 @@
+ this.O();
+ this.P();
+ this.getWorldBorder().a(minecraftserver.aw());
+@@ -86,6 +106,7 @@
this.villages.a((World) this);
}
+ if (getServer().getScoreboardManager() == null) { // CraftBukkit
- this.scoreboard = new ScoreboardServer(this.server);
- PersistentScoreboard persistentscoreboard = (PersistentScoreboard) this.worldMaps.get(PersistentScoreboard.class, "scoreboard");
+ PersistentScoreboard persistentscoreboard = (PersistentScoreboard) this.worldMaps.get(PersistentScoreboard::new, "scoreboard");
-@@ -75,9 +96,24 @@
+ if (persistentscoreboard == null) {
+@@ -95,6 +116,7 @@
- persistentscoreboard.a(this.scoreboard);
- ((ScoreboardServer) this.scoreboard).a((Runnable) (new RunnableSaveScoreboard(persistentscoreboard)));
-+ // CraftBukkit start
-+ } else {
-+ this.scoreboard = getServer().getScoreboardManager().getMainScoreboard().getHandle();
-+ }
-+ // CraftBukkit end
-+
- this.B = new LootTableRegistry(new File(new File(this.dataManager.getDirectory(), "data"), "loot_tables"));
-- this.C = new AdvancementDataWorld(new File(new File(this.dataManager.getDirectory(), "data"), "advancements"));
-- this.D = new CustomFunctionData(new File(new File(this.dataManager.getDirectory(), "data"), "functions"), this.server);
-+ // CraftBukkit start
-+ if (this.dimension != 0) { // SPIGOT-3899 multiple worlds of advancements not supported
-+ this.C = this.server.getAdvancementData();
-+ }
-+ if (this.C == null) {
-+ this.C = new AdvancementDataWorld(new File(new File(this.dataManager.getDirectory(), "data"), "advancements"));
-+ }
-+ if (this.D == null) {
-+ this.D = new CustomFunctionData(new File(new File(this.dataManager.getDirectory(), "data"), "functions"), this.server);
-+ }
-+ // CraftBukkit end
+ persistentscoreboard.a((Scoreboard) this.server.getScoreboard());
+ this.server.getScoreboard().a((Runnable) (new RunnableSaveScoreboard(persistentscoreboard)));
++ } // CraftBukkit
this.getWorldBorder().setCenter(this.worldData.B(), this.worldData.C());
this.getWorldBorder().setDamageAmount(this.worldData.H());
this.getWorldBorder().setDamageBuffer(this.worldData.G());
-@@ -89,9 +125,146 @@
+@@ -106,9 +128,130 @@
this.getWorldBorder().setSize(this.worldData.D());
}
@@ -126,18 +125,14 @@
+ result = fixTileEntity(pos, type, result);
+ }
+ } else if (type == Blocks.JUKEBOX) {
-+ if (!(result instanceof BlockJukeBox.TileEntityRecordPlayer)) {
-+ result = fixTileEntity(pos, type, result);
-+ }
-+ } else if (type == Blocks.NOTEBLOCK) {
-+ if (!(result instanceof TileEntityNote)) {
++ if (!(result instanceof TileEntityJukeBox)) {
+ result = fixTileEntity(pos, type, result);
+ }
-+ } else if (type == Blocks.MOB_SPAWNER) {
++ } else if (type == Blocks.SPAWNER) {
+ if (!(result instanceof TileEntityMobSpawner)) {
+ result = fixTileEntity(pos, type, result);
+ }
-+ } else if ((type == Blocks.STANDING_SIGN) || (type == Blocks.WALL_SIGN)) {
++ } else if ((type == Blocks.SIGN) || (type == Blocks.WALL_SIGN)) {
+ if (!(result instanceof TileEntitySign)) {
+ result = fixTileEntity(pos, type, result);
+ }
@@ -165,23 +160,19 @@
+ if (!(result instanceof TileEntityEnderPortal)) {
+ result = fixTileEntity(pos, type, result);
+ }
-+ } else if (type == Blocks.SKULL) {
++ } else if (type instanceof BlockSkullAbstract) {
+ if (!(result instanceof TileEntitySkull)) {
+ result = fixTileEntity(pos, type, result);
+ }
-+ } else if (type == Blocks.DAYLIGHT_DETECTOR || type == Blocks.DAYLIGHT_DETECTOR_INVERTED) {
++ } else if (type == Blocks.DAYLIGHT_DETECTOR) {
+ if (!(result instanceof TileEntityLightDetector)) {
+ result = fixTileEntity(pos, type, result);
+ }
-+ } else if (type == Blocks.POWERED_COMPARATOR || type == Blocks.UNPOWERED_COMPARATOR) {
++ } else if (type == Blocks.COMPARATOR) {
+ if (!(result instanceof TileEntityComparator)) {
+ result = fixTileEntity(pos, type, result);
+ }
-+ } else if (type == Blocks.FLOWER_POT) {
-+ if (!(result instanceof TileEntityFlowerPot)) {
-+ result = fixTileEntity(pos, type, result);
-+ }
-+ } else if (type == Blocks.STANDING_BANNER || type == Blocks.WALL_BANNER) {
++ }else if (type instanceof BlockBannerAbstract) {
+ if (!(result instanceof TileEntityBanner)) {
+ result = fixTileEntity(pos, type, result);
+ }
@@ -201,7 +192,7 @@
+ if (!(result instanceof TileEntityStructure)) {
+ result = fixTileEntity(pos, type, result);
+ }
-+ } else if (type == Blocks.BED) {
++ } else if (type instanceof BlockBed) {
+ if (!(result instanceof TileEntityBed)) {
+ result = fixTileEntity(pos, type, result);
+ }
@@ -212,10 +203,10 @@
+
+ private TileEntity fixTileEntity(BlockPosition pos, Block type, TileEntity found) {
+ this.getServer().getLogger().log(Level.SEVERE, "Block at {0},{1},{2} is {3} but has {4}" + ". "
-+ + "Bukkit will attempt to fix this, but there may be additional damage that we cannot recover.", new Object[]{pos.getX(), pos.getY(), pos.getZ(), org.bukkit.Material.getMaterial(Block.getId(type)).toString(), found});
++ + "Bukkit will attempt to fix this, but there may be additional damage that we cannot recover.", new Object[]{pos.getX(), pos.getY(), pos.getZ(), type, found});
+
+ if (type instanceof ITileEntity) {
-+ TileEntity replacement = ((ITileEntity) type).a(this, type.toLegacyData(this.getType(pos)));
++ TileEntity replacement = ((ITileEntity) type).a(this);
+ replacement.world = this;
+ this.setTileEntity(pos, replacement);
+ return replacement;
@@ -224,43 +215,37 @@
+ return found;
+ }
+ }
-+
-+ private boolean canSpawn(int x, int z) {
-+ if (this.generator != null) {
-+ return this.generator.canSpawn(this.getWorld(), x, z);
-+ } else {
-+ return this.worldProvider.canSpawn(x, z);
-+ }
-+ }
+ // CraftBukkit end
+
public void doTick() {
+ this.Q = true;
super.doTick();
- if (this.getWorldData().isHardcore() && this.getDifficulty() != EnumDifficulty.HARD) {
-@@ -110,8 +283,11 @@
+@@ -128,9 +271,12 @@
}
- this.methodProfiler.a("mobSpawner");
+ this.methodProfiler.a("spawner");
- if (this.getGameRules().getBoolean("doMobSpawning") && this.worldData.getType() != WorldType.DEBUG_ALL_BLOCK_STATES) {
- this.spawnerCreature.a(this, this.allowMonsters, this.allowAnimals, this.worldData.getTime() % 400L == 0L);
+- this.getChunkProviderServer().a(this, this.allowMonsters, this.allowAnimals);
+ // CraftBukkit start - Only call spawner if we have players online and the world allows for mobs or animals
+ long time = this.worldData.getTime();
+ if (this.getGameRules().getBoolean("doMobSpawning") && this.worldData.getType() != WorldType.DEBUG_ALL_BLOCK_STATES && (this.allowMonsters || this.allowAnimals) && (this instanceof WorldServer && this.players.size() > 0)) {
+ this.spawnerCreature.a(this, this.allowMonsters && (this.ticksPerMonsterSpawns != 0 && time % this.ticksPerMonsterSpawns == 0L), this.allowAnimals && (this.ticksPerAnimalSpawns != 0 && time % this.ticksPerAnimalSpawns == 0L), this.worldData.getTime() % 400L == 0L);
++ this.getChunkProviderServer().a(this, this.allowMonsters && (this.ticksPerMonsterSpawns != 0 && time % this.ticksPerMonsterSpawns == 0L), this.allowAnimals && (this.ticksPerAnimalSpawns != 0 && time % this.ticksPerAnimalSpawns == 0L));
+ // CraftBukkit end
}
this.methodProfiler.c("chunkSource");
-@@ -140,6 +316,8 @@
- this.portalTravelAgent.a(this.getTime());
- this.methodProfiler.b();
- this.aq();
+@@ -160,6 +306,8 @@
+ this.methodProfiler.e();
+ this.am();
+ this.Q = false;
+
+ this.getWorld().processChunkGC(); // CraftBukkit
}
- @Nullable
-@@ -167,7 +345,7 @@
+ public boolean j_() {
+@@ -191,7 +339,7 @@
if (entityhuman.isSpectator()) {
++i;
@@ -269,14 +254,14 @@
++j;
}
}
-@@ -195,25 +373,46 @@
+@@ -223,25 +371,46 @@
}
- private void c() {
+ private void ai() {
- this.worldData.setWeatherDuration(0);
++ // CraftBukkit start
this.worldData.setStorm(false);
- this.worldData.setThunderDuration(0);
-+ // CraftBukkit start
+ // If we stop due to everyone sleeping we should reset the weather duration to some other random value.
+ // Not that everyone ever manages to get the whole server to sleep at the same time....
+ if (!this.worldData.hasStorm()) {
@@ -294,7 +279,7 @@
}
public boolean everyoneDeeplySleeping() {
- if (this.Q && !this.isClientSide) {
+ if (this.K && !this.isClientSide) {
Iterator iterator = this.players.iterator();
+ // CraftBukkit - This allows us to assume that some people are in bed but not really, allowing time to pass in spite of AFKers
@@ -320,8 +305,8 @@
return false;
} else {
-@@ -283,7 +482,7 @@
- entityhorseskeleton.p(true);
+@@ -315,7 +484,7 @@
+ entityhorseskeleton.s(true);
entityhorseskeleton.setAgeRaw(0);
entityhorseskeleton.setPosition((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ());
- this.addEntity(entityhorseskeleton);
@@ -329,51 +314,30 @@
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));
-@@ -299,11 +498,11 @@
- BlockPosition blockposition1 = blockposition.down();
+@@ -332,11 +501,11 @@
+ BiomeBase biomebase = this.getBiome(blockposition);
- if (this.v(blockposition1)) {
+ if (biomebase.a((IWorldReader) this, blockposition1)) {
- this.setTypeUpdate(blockposition1, Blocks.ICE.getBlockData());
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this, blockposition1, Blocks.ICE.getBlockData(), null); // CraftBukkit
}
- if (flag && this.f(blockposition, true)) {
-- this.setTypeUpdate(blockposition, Blocks.SNOW_LAYER.getBlockData());
-+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this, blockposition, Blocks.SNOW_LAYER.getBlockData(), null); // CraftBukkit
+ if (flag && biomebase.b(this, blockposition)) {
+- this.setTypeUpdate(blockposition, Blocks.SNOW.getBlockData());
++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this, blockposition1, Blocks.ICE.getBlockData(), null); // CraftBukkit
}
- if (flag && this.getBiome(blockposition1).d()) {
-@@ -378,7 +577,7 @@
- public boolean b(BlockPosition blockposition, Block block) {
- NextTickListEntry nextticklistentry = new NextTickListEntry(blockposition, block);
-
-- return this.nextTickListHash.contains(nextticklistentry);
-+ return this.nextTickList.contains(nextticklistentry); // CraftBukkit
- }
-
- public void a(BlockPosition blockposition, Block block, int i) {
-@@ -412,8 +611,8 @@
- nextticklistentry.a(j);
- }
-
-- if (!this.nextTickListHash.contains(nextticklistentry)) {
-- this.nextTickListHash.add(nextticklistentry);
-+ // CraftBukkit - use nextTickList
-+ if (!this.nextTickList.contains(nextticklistentry)) {
- this.nextTickList.add(nextticklistentry);
- }
- }
-@@ -430,15 +629,15 @@
- nextticklistentry.a((long) i + this.worldData.getTime());
- }
-
-- if (!this.nextTickListHash.contains(nextticklistentry)) {
-- this.nextTickListHash.add(nextticklistentry);
-+ // CraftBukkit - use nextTickList
-+ if (!this.nextTickList.contains(nextticklistentry)) {
- this.nextTickList.add(nextticklistentry);
- }
-
+ if (flag && this.getBiome(blockposition1).c() == BiomeBase.Precipitation.RAIN) {
+@@ -385,7 +554,7 @@
+ protected BlockPosition a(BlockPosition blockposition) {
+ BlockPosition blockposition1 = this.getHighestBlockYAt(HeightMap.Type.MOTION_BLOCKING, blockposition);
+ AxisAlignedBB axisalignedbb = (new AxisAlignedBB(blockposition1, new BlockPosition(blockposition1.getX(), this.getHeight(), blockposition1.getZ()))).g(3.0D);
+- List list = this.a(EntityLiving.class, axisalignedbb, (entityliving) -> {
++ List list = this.a(EntityLiving.class, axisalignedbb, (Predicate<EntityLiving>) (entityliving) -> { // CraftBukkit - decompile error
+ return entityliving != null && entityliving.isAlive() && this.e(entityliving.getChunkCoordinates());
+ });
+
+@@ -401,7 +570,7 @@
}
public void tickEntities() {
@@ -382,55 +346,15 @@
if (this.emptyTime++ >= 300) {
return;
}
-@@ -508,11 +707,17 @@
- } else {
- int i = this.nextTickList.size();
-
-- if (i != this.nextTickListHash.size()) {
-+ if (false) { // CraftBukkit
- throw new IllegalStateException("TickNextTick list out of synch");
- } else {
- if (i > 65536) {
-- i = 65536;
-+ // CraftBukkit start - If the server has too much to process over time, try to alleviate that
-+ if (i > 20 * 65536) {
-+ i = i / 20;
-+ } else {
-+ i = 65536;
-+ }
-+ // CraftBukkit end
- }
-
- this.methodProfiler.a("cleaning");
-@@ -525,8 +730,9 @@
- break;
- }
+@@ -490,6 +659,7 @@
-+ // CraftBukkit - use nextTickList
- this.nextTickList.remove(nextticklistentry);
-- this.nextTickListHash.remove(nextticklistentry);
-+ // this.nextTickListHash.remove(nextticklistentry);
- this.W.add(nextticklistentry);
- }
-
-@@ -596,7 +802,7 @@
- if (blockposition.getX() >= structureboundingbox.a && blockposition.getX() < structureboundingbox.d && blockposition.getZ() >= structureboundingbox.c && blockposition.getZ() < structureboundingbox.f) {
- if (flag) {
- if (i == 0) {
-- this.nextTickListHash.remove(nextticklistentry);
-+ // this.nextTickListHash.remove(nextticklistentry); // CraftBukkit - removed
- }
-
- iterator.remove();
-@@ -614,6 +820,7 @@
- return arraylist;
}
+ /* CraftBukkit start - We prevent spawning in general, so this butchering is not needed
public void entityJoinedWorld(Entity entity, boolean flag) {
if (!this.getSpawnAnimals() && (entity instanceof EntityAnimal || entity instanceof EntityWaterAnimal)) {
entity.die();
-@@ -625,6 +832,7 @@
+@@ -501,6 +671,7 @@
super.entityJoinedWorld(entity, flag);
}
@@ -438,11 +362,11 @@
private boolean getSpawnNPCs() {
return this.server.getSpawnNPCs();
-@@ -637,7 +845,54 @@
- protected IChunkProvider n() {
+@@ -513,7 +684,21 @@
+ protected IChunkProvider q() {
IChunkLoader ichunkloader = this.dataManager.createChunkLoader(this.worldProvider);
-- return new ChunkProviderServer(this, ichunkloader, this.worldProvider.getChunkGenerator());
+- return new ChunkProviderServer(this, ichunkloader, this.worldProvider.getChunkGenerator(), this.server);
+ // CraftBukkit start
+ org.bukkit.craftbukkit.generator.InternalChunkGenerator gen;
+
@@ -456,47 +380,14 @@
+ gen = new org.bukkit.craftbukkit.generator.NormalChunkGenerator(this, this.getSeed());
+ }
+
-+ return new ChunkProviderServer(this, ichunkloader, gen);
-+ // CraftBukkit end
-+ }
-+
-+ public List<TileEntity> getTileEntities(int i, int j, int k, int l, int i1, int j1) {
-+ ArrayList arraylist = Lists.newArrayList();
-+
-+ // CraftBukkit start - Get tile entities from chunks instead of world
-+ for (int chunkX = (i >> 4); chunkX <= ((l - 1) >> 4); chunkX++) {
-+ for (int chunkZ = (k >> 4); chunkZ <= ((j1 - 1) >> 4); chunkZ++) {
-+ Chunk chunk = getChunkAt(chunkX, chunkZ);
-+ if (chunk == null) {
-+ continue;
-+ }
-+ for (Object te : chunk.tileEntities.values()) {
-+ TileEntity tileentity = (TileEntity) te;
-+ if ((tileentity.position.getX() >= i) && (tileentity.position.getY() >= j) && (tileentity.position.getZ() >= k) && (tileentity.position.getX() < l) && (tileentity.position.getY() < i1) && (tileentity.position.getZ() < j1)) {
-+ arraylist.add(tileentity);
-+ }
-+ }
-+ }
-+ }
-+ /*
-+ for (int k1 = 0; k1 < this.tileEntityList.size(); ++k1) {
-+ TileEntity tileentity = (TileEntity) this.tileEntityList.get(k1);
-+ BlockPosition blockposition = tileentity.getPosition();
-+
-+ if (blockposition.getX() >= i && blockposition.getY() >= j && blockposition.getZ() >= k && blockposition.getX() < l && blockposition.getY() < i1 && blockposition.getZ() < j1) {
-+ arraylist.add(tileentity);
-+ }
-+ }
-+ */
++ return new ChunkProviderServer(this, ichunkloader, gen, this.server);
+ // CraftBukkit end
-+
-+ return arraylist;
}
public boolean a(EntityHuman entityhuman, BlockPosition blockposition) {
-@@ -699,6 +954,23 @@
- int j = this.worldProvider.getSeaLevel();
- int k = 8;
+@@ -572,6 +757,22 @@
+ BlockPosition blockposition = worldchunkmanager.a(0, 0, 256, list, random);
+ ChunkCoordIntPair chunkcoordintpair = blockposition == null ? new ChunkCoordIntPair(0, 0) : new ChunkCoordIntPair(blockposition);
+ // CraftBukkit start
+ if (this.generator != null) {
@@ -508,34 +399,24 @@
+ throw new IllegalStateException("Cannot set spawn point for " + this.worldData.getName() + " to be in another world (" + spawn.getWorld().getName() + ")");
+ } else {
+ this.worldData.setSpawn(new BlockPosition(spawn.getBlockX(), spawn.getBlockY(), spawn.getBlockZ()));
-+ this.isLoading = false;
+ return;
+ }
+ }
+ }
+ // CraftBukkit end
+
- if (blockposition != null) {
- i = blockposition.getX();
- k = blockposition.getZ();
-@@ -708,7 +980,7 @@
-
- int l = 0;
-
-- while (!this.worldProvider.canSpawn(i, k)) {
-+ while (!this.canSpawn(i, k)) { // CraftBukkit - use our own canSpawn
- i += random.nextInt(64) - random.nextInt(64);
- k += random.nextInt(64) - random.nextInt(64);
- ++l;
-@@ -750,6 +1022,7 @@
+ if (blockposition == null) {
+ WorldServer.a.warn("Unable to find spawn biome");
+ }
+@@ -647,6 +848,7 @@
ChunkProviderServer chunkproviderserver = this.getChunkProviderServer();
if (chunkproviderserver.e()) {
+ org.bukkit.Bukkit.getPluginManager().callEvent(new org.bukkit.event.world.WorldSaveEvent(getWorld())); // CraftBukkit
if (iprogressupdate != null) {
- iprogressupdate.a("Saving level");
+ iprogressupdate.a(new ChatMessage("menu.savingLevel", new Object[0]));
}
-@@ -760,7 +1033,8 @@
+@@ -657,7 +859,8 @@
}
chunkproviderserver.a(flag);
@@ -545,20 +426,20 @@
Iterator iterator = arraylist.iterator();
while (iterator.hasNext()) {
-@@ -795,6 +1069,12 @@
+@@ -692,6 +895,12 @@
}
}
+ // CraftBukkit start - Save secondary data for nether/end
+ if (this instanceof SecondaryWorldServer) {
-+ ((SecondaryWorldServer) this).c();
++ ((SecondaryWorldServer) this).c(); // As above
+ }
+ // CraftBukkit end
+
this.worldData.a(this.getWorldBorder().getSize());
this.worldData.d(this.getWorldBorder().getCenterX());
this.worldData.c(this.getWorldBorder().getCenterZ());
-@@ -808,9 +1088,13 @@
+@@ -706,9 +915,13 @@
this.worldMaps.a();
}
@@ -574,25 +455,25 @@
public void a(Collection<Entity> collection) {
ArrayList arraylist = Lists.newArrayList(collection);
-@@ -829,7 +1113,7 @@
+@@ -727,7 +940,7 @@
private boolean j(Entity entity) {
if (entity.dead) {
-- WorldServer.a.warn("Tried to add entity {} but it was marked as removed already", EntityTypes.a(entity));
-+ // WorldServer.a.warn("Tried to add entity {} but it was marked as removed already", EntityTypes.a(entity)); // CraftBukkit
+- WorldServer.a.warn("Tried to add entity {} but it was marked as removed already", EntityTypes.getName(entity.P()));
++ // WorldServer.a.warn("Tried to add entity {} but it was marked as removed already", EntityTypes.getName(entity.P())); // CraftBukkit
return false;
} else {
UUID uuid = entity.getUniqueID();
-@@ -841,7 +1125,7 @@
- this.f.remove(entity1);
+@@ -739,7 +952,7 @@
+ this.g.remove(entity1);
} else {
if (!(entity instanceof EntityHuman)) {
-- WorldServer.a.warn("Keeping entity {} that already exists with UUID {}", EntityTypes.a(entity1), uuid.toString());
-+ // WorldServer.a.warn("Keeping entity {} that already exists with UUID {}", EntityTypes.a(entity1), uuid.toString()); // CraftBukkit
+- WorldServer.a.warn("Keeping entity {} that already exists with UUID {}", EntityTypes.getName(entity1.P()), uuid.toString());
++ // WorldServer.a.warn("Keeping entity {} that already exists with UUID {}", EntityTypes.getName(entity1.P()), uuid.toString()); // CraftBukkit
return false;
}
-@@ -894,8 +1178,16 @@
+@@ -792,8 +1005,16 @@
}
public boolean strikeLightning(Entity entity) {
@@ -610,12 +491,12 @@
return true;
} else {
return false;
-@@ -911,10 +1203,20 @@
+@@ -809,6 +1030,14 @@
}
- public Explosion createExplosion(@Nullable Entity entity, double d0, double d1, double d2, float f, boolean flag, boolean flag1) {
+ public Explosion createExplosion(@Nullable Entity entity, DamageSource damagesource, double d0, double d1, double d2, float f, boolean flag, boolean flag1) {
+ // CraftBukkit start
-+ Explosion explosion = super.createExplosion(entity, d0, d1, d2, f, flag, flag1);
++ Explosion explosion = super.createExplosion(entity, damagesource, d0, d1, d2, f, flag, flag1);
+
+ if (explosion.wasCanceled) {
+ return explosion;
@@ -624,6 +505,9 @@
+ /* Remove
Explosion explosion = new Explosion(this, entity, d0, d1, d2, f, flag, flag1);
+ if (damagesource != null) {
+@@ -817,6 +1046,8 @@
+
explosion.a();
explosion.a(false);
+ */
@@ -631,27 +515,27 @@
if (!flag1) {
explosion.clearBlocks();
}
-@@ -960,7 +1262,8 @@
- BlockActionData blockactiondata = (BlockActionData) iterator.next();
+@@ -843,7 +1074,8 @@
+ BlockActionData blockactiondata = (BlockActionData) this.d.removeFirst();
- if (this.a(blockactiondata)) {
-- this.server.getPlayerList().sendPacketNearby((EntityHuman) null, (double) blockactiondata.a().getX(), (double) blockactiondata.a().getY(), (double) blockactiondata.a().getZ(), 64.0D, this.worldProvider.getDimensionManager().getDimensionID(), new PacketPlayOutBlockAction(blockactiondata.a(), blockactiondata.d(), blockactiondata.b(), blockactiondata.c()));
-+ // CraftBukkit - this.worldProvider.dimension -> this.dimension
-+ this.server.getPlayerList().sendPacketNearby((EntityHuman) null, (double) blockactiondata.a().getX(), (double) blockactiondata.a().getY(), (double) blockactiondata.a().getZ(), 64.0D, dimension, new PacketPlayOutBlockAction(blockactiondata.a(), blockactiondata.d(), blockactiondata.b(), blockactiondata.c()));
- }
+ if (this.a(blockactiondata)) {
+- this.server.getPlayerList().sendPacketNearby((EntityHuman) null, (double) blockactiondata.a().getX(), (double) blockactiondata.a().getY(), (double) blockactiondata.a().getZ(), 64.0D, this.worldProvider.getDimensionManager().getDimensionID(), new PacketPlayOutBlockAction(blockactiondata.a(), blockactiondata.b(), blockactiondata.c(), blockactiondata.d()));
++ // CraftBukkit - this.worldProvider.dimension -> this.dimension
++ this.server.getPlayerList().sendPacketNearby((EntityHuman) null, (double) blockactiondata.a().getX(), (double) blockactiondata.a().getY(), (double) blockactiondata.a().getZ(), 64.0D, dimension, new PacketPlayOutBlockAction(blockactiondata.a(), blockactiondata.b(), blockactiondata.c(), blockactiondata.d()));
}
+ }
-@@ -983,6 +1286,7 @@
+@@ -864,6 +1096,7 @@
boolean flag = this.isRaining();
- super.t();
+ super.v();
+ /* CraftBukkit start
- if (this.n != this.o) {
- this.server.getPlayerList().a((Packet) (new PacketPlayOutGameStateChange(7, this.o)), this.worldProvider.getDimensionManager().getDimensionID());
+ if (this.o != this.p) {
+ this.server.getPlayerList().a((Packet) (new PacketPlayOutGameStateChange(7, this.p)), this.worldProvider.getDimensionManager().getDimensionID());
}
-@@ -1001,6 +1305,21 @@
- this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(7, this.o));
- this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(8, this.q));
+@@ -882,6 +1115,21 @@
+ this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(7, this.p));
+ this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(8, this.r));
}
+ // */
+ if (flag != this.isRaining()) {
@@ -664,31 +548,29 @@
+ }
+ for (int i = 0; i < this.players.size(); ++i) {
+ if (((EntityPlayer) this.players.get(i)).world == this) {
-+ ((EntityPlayer) this.players.get(i)).updateWeather(this.n, this.o, this.p, this.q);
++ ((EntityPlayer) this.players.get(i)).updateWeather(this.o, this.p, this.q, this.r);
+ }
+ }
+ // CraftBukkit end
}
-@@ -1030,10 +1349,20 @@
+@@ -915,11 +1163,18 @@
}
- 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) {
+ public <T extends ParticleParam> int a(T t0, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6) {
+ // CraftBukkit - visibility api support
-+ sendParticles(null, enumparticle, flag, d0, d1, d2, i, d3, d4, d5, d6, aint);
++ return sendParticles(null, t0, d0, d1, d2, i, d3, d4, d5, d6);
+ }
+
-+ public void sendParticles(EntityPlayer sender, EnumParticle enumparticle, boolean flag, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6, int... aint) {
++ public <T extends ParticleParam> int sendParticles(EntityPlayer sender, T t0, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6) {
+ // CraftBukkit end
- PacketPlayOutWorldParticles packetplayoutworldparticles = new PacketPlayOutWorldParticles(enumparticle, flag, (float) d0, (float) d1, (float) d2, (float) d3, (float) d4, (float) d5, (float) d6, i, aint);
+ PacketPlayOutWorldParticles packetplayoutworldparticles = new PacketPlayOutWorldParticles(t0, false, (float) d0, (float) d1, (float) d2, (float) d3, (float) d4, (float) d5, (float) d6, i);
+ int j = 0;
- for (int j = 0; j < this.players.size(); ++j) {
- EntityPlayer entityplayer = (EntityPlayer) this.players.get(j);
+ for (int k = 0; k < this.players.size(); ++k) {
+ EntityPlayer entityplayer = (EntityPlayer) this.players.get(k);
+ if (sender != null && !entityplayer.getBukkitEntity().canSee(sender.getBukkitEntity())) continue; // CraftBukkit
-+ BlockPosition blockposition = entityplayer.getChunkCoordinates();
-+ double d7 = blockposition.distanceSquared(d0, d1, d2);
-+
- this.a(entityplayer, flag, d0, d1, d2, packetplayoutworldparticles);
- }
+ if (this.a(entityplayer, false, d0, d1, d2, packetplayoutworldparticles)) {
+ ++j;