summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--deprecation-mappings.at62
-rw-r--r--deprecation-mappings.csrg40
-rw-r--r--nms-patches/BiomeTheEndDecorator.patch11
-rw-r--r--nms-patches/Block.patch41
-rw-r--r--nms-patches/BlockBloodStone.patch28
-rw-r--r--nms-patches/BlockButtonAbstract.patch20
-rw-r--r--nms-patches/BlockCactus.patch4
-rw-r--r--nms-patches/BlockCake.patch6
-rw-r--r--nms-patches/BlockCauldron.patch144
-rw-r--r--nms-patches/BlockChorusFlower.patch92
-rw-r--r--nms-patches/BlockCocoa.patch6
-rw-r--r--nms-patches/BlockCommand.patch30
-rw-r--r--nms-patches/BlockCrops.patch16
-rw-r--r--nms-patches/BlockDaylightDetector.patch4
-rw-r--r--nms-patches/BlockDiodeAbstract.patch16
-rw-r--r--nms-patches/BlockDispenser.patch2
-rw-r--r--nms-patches/BlockDoor.patch14
-rw-r--r--nms-patches/BlockDragonEgg.patch4
-rw-r--r--nms-patches/BlockDropper.patch2
-rw-r--r--nms-patches/BlockEnderPortal.patch6
-rw-r--r--nms-patches/BlockFire.patch40
-rw-r--r--nms-patches/BlockFlowing.patch4
-rw-r--r--nms-patches/BlockGrass.patch12
-rw-r--r--nms-patches/BlockIce.patch23
-rw-r--r--nms-patches/BlockLeaves.patch6
-rw-r--r--nms-patches/BlockLever.patch8
-rw-r--r--nms-patches/BlockMinecartDetector.patch6
-rw-r--r--nms-patches/BlockMinecartTrackAbstract.patch15
-rw-r--r--nms-patches/BlockMobSpawner.patch2
-rw-r--r--nms-patches/BlockMonsterEggs.patch2
-rw-r--r--nms-patches/BlockMushroom.patch8
-rw-r--r--nms-patches/BlockMycel.patch8
-rw-r--r--nms-patches/BlockNetherWart.patch2
-rw-r--r--nms-patches/BlockOre.patch14
-rw-r--r--nms-patches/BlockPiston.patch44
-rw-r--r--nms-patches/BlockPlant.patch2
-rw-r--r--nms-patches/BlockPortal.patch30
-rw-r--r--nms-patches/BlockPressurePlateAbstract.patch4
-rw-r--r--nms-patches/BlockPressurePlateBinary.patch6
-rw-r--r--nms-patches/BlockPressurePlateWeighted.patch8
-rw-r--r--nms-patches/BlockPumpkin.patch2
-rw-r--r--nms-patches/BlockRedstoneOre.patch46
-rw-r--r--nms-patches/BlockRedstoneTorch.patch12
-rw-r--r--nms-patches/BlockRedstoneWire.patch2
-rw-r--r--nms-patches/BlockReed.patch2
-rw-r--r--nms-patches/BlockSapling.patch21
-rw-r--r--nms-patches/BlockSkull.patch33
-rw-r--r--nms-patches/BlockSnow.patch2
-rw-r--r--nms-patches/BlockSoil.patch54
-rw-r--r--nms-patches/BlockStationary.patch12
-rw-r--r--nms-patches/BlockStem.patch10
-rw-r--r--nms-patches/BlockTrapdoor.patch39
-rw-r--r--nms-patches/BlockTripwire.patch2
-rw-r--r--nms-patches/BlockTripwireHook.patch10
-rw-r--r--nms-patches/BlockVine.patch36
-rw-r--r--nms-patches/Chunk.patch72
-rw-r--r--nms-patches/ChunkProviderServer.patch219
-rw-r--r--nms-patches/ChunkRegionLoader.patch59
-rw-r--r--nms-patches/ChunkSection.patch14
-rw-r--r--nms-patches/CommandBlockListenerAbstract.patch25
-rw-r--r--nms-patches/CommandExecute.patch16
-rw-r--r--nms-patches/CommandGamemode.patch18
-rw-r--r--nms-patches/CommandGamerule.patch12
-rw-r--r--nms-patches/CommandSpreadPlayers.patch22
-rw-r--r--nms-patches/CommandTp.patch17
-rw-r--r--nms-patches/Container.patch68
-rw-r--r--nms-patches/ContainerAnvil.patch61
-rw-r--r--nms-patches/ContainerBrewingStand.patch15
-rw-r--r--nms-patches/ContainerEnchantTable.patch43
-rw-r--r--nms-patches/ContainerPlayer.patch62
-rw-r--r--nms-patches/CraftingManager.patch15
-rw-r--r--nms-patches/DataPaletteBlock.patch25
-rw-r--r--nms-patches/DataWatcher.patch20
-rw-r--r--nms-patches/DedicatedServer.patch128
-rw-r--r--nms-patches/DispenseBehaviorProjectile.patch4
-rw-r--r--nms-patches/DispenserRegistry.patch159
-rw-r--r--nms-patches/Enchantment.patch30
-rw-r--r--nms-patches/EnchantmentThorns.patch6
-rw-r--r--nms-patches/Entity.patch305
-rw-r--r--nms-patches/EntityAgeable.patch35
-rw-r--r--nms-patches/EntityAnimal.patch2
-rw-r--r--nms-patches/EntityArmorStand.patch51
-rw-r--r--nms-patches/EntityArrow.patch94
-rw-r--r--nms-patches/EntityBoat.patch198
-rw-r--r--nms-patches/EntityChicken.patch10
-rw-r--r--nms-patches/EntityCow.patch15
-rw-r--r--nms-patches/EntityCreature.patch8
-rw-r--r--nms-patches/EntityCreeper.patch67
-rw-r--r--nms-patches/EntityDamageSourceIndirect.patch2
-rw-r--r--nms-patches/EntityEnderCrystal.patch57
-rw-r--r--nms-patches/EntityEnderDragon.patch277
-rw-r--r--nms-patches/EntityEnderPearl.patch24
-rw-r--r--nms-patches/EntityEnderman.patch52
-rw-r--r--nms-patches/EntityExperienceOrb.patch24
-rw-r--r--nms-patches/EntityFallingBlock.patch23
-rw-r--r--nms-patches/EntityFireball.patch50
-rw-r--r--nms-patches/EntityFireworks.patch4
-rw-r--r--nms-patches/EntityFishingHook.patch126
-rw-r--r--nms-patches/EntityGhast.patch17
-rw-r--r--nms-patches/EntityHanging.patch95
-rw-r--r--nms-patches/EntityHorse.patch103
-rw-r--r--nms-patches/EntityHuman.patch285
-rw-r--r--nms-patches/EntityInsentient.patch84
-rw-r--r--nms-patches/EntityIronGolem.patch17
-rw-r--r--nms-patches/EntityItem.patch33
-rw-r--r--nms-patches/EntityItemFrame.patch6
-rw-r--r--nms-patches/EntityLeash.patch90
-rw-r--r--nms-patches/EntityLightning.patch69
-rw-r--r--nms-patches/EntityLiving.patch318
-rw-r--r--nms-patches/EntityMinecartAbstract.patch74
-rw-r--r--nms-patches/EntityMinecartCommandBlock.patch14
-rw-r--r--nms-patches/EntityMinecartContainer.patch14
-rw-r--r--nms-patches/EntityMonster.patch4
-rw-r--r--nms-patches/EntityMushroomCow.patch6
-rw-r--r--nms-patches/EntityOcelot.patch16
-rw-r--r--nms-patches/EntityPig.patch15
-rw-r--r--nms-patches/EntityPlayer.patch302
-rw-r--r--nms-patches/EntityPotion.patch142
-rw-r--r--nms-patches/EntityProjectile.patch14
-rw-r--r--nms-patches/EntityRabbit.patch18
-rw-r--r--nms-patches/EntitySheep.patch36
-rw-r--r--nms-patches/EntityShulkerBullet.patch23
-rw-r--r--nms-patches/EntitySilverfish.patch8
-rw-r--r--nms-patches/EntitySkeleton.patch56
-rw-r--r--nms-patches/EntitySlime.patch6
-rw-r--r--nms-patches/EntitySmallFireball.patch6
-rw-r--r--nms-patches/EntitySnowman.patch10
-rw-r--r--nms-patches/EntitySpider.patch4
-rw-r--r--nms-patches/EntitySquid.patch14
-rw-r--r--nms-patches/EntityTNTPrimed.patch19
-rw-r--r--nms-patches/EntityThrownExpBottle.patch2
-rw-r--r--nms-patches/EntityTracker.patch2
-rw-r--r--nms-patches/EntityTrackerEntry.patch96
-rw-r--r--nms-patches/EntityVillager.patch51
-rw-r--r--nms-patches/EntityWither.patch24
-rw-r--r--nms-patches/EntityWitherSkull.patch6
-rw-r--r--nms-patches/EntityWolf.patch72
-rw-r--r--nms-patches/EntityZombie.patch73
-rw-r--r--nms-patches/Explosion.patch25
-rw-r--r--nms-patches/FoodMetaData.patch7
-rw-r--r--nms-patches/HandshakeListener.patch14
-rw-r--r--nms-patches/IDataManager.patch2
-rw-r--r--nms-patches/IInventory.patch4
-rw-r--r--nms-patches/InventoryCraftResult.patch10
-rw-r--r--nms-patches/InventoryCrafting.patch10
-rw-r--r--nms-patches/InventoryLargeChest.patch10
-rw-r--r--nms-patches/InventoryMerchant.patch21
-rw-r--r--nms-patches/InventorySubcontainer.patch10
-rw-r--r--nms-patches/ItemArmor.patch81
-rw-r--r--nms-patches/ItemBoat.patch27
-rw-r--r--nms-patches/ItemBow.patch65
-rw-r--r--nms-patches/ItemBucket.patch108
-rw-r--r--nms-patches/ItemDye.patch2
-rw-r--r--nms-patches/ItemFireball.patch8
-rw-r--r--nms-patches/ItemFishingRod.patch10
-rw-r--r--nms-patches/ItemFlintAndSteel.patch14
-rw-r--r--nms-patches/ItemHanging.patch43
-rw-r--r--nms-patches/ItemLeash.patch4
-rw-r--r--nms-patches/ItemMapEmpty.patch10
-rw-r--r--nms-patches/ItemMinecart.patch4
-rw-r--r--nms-patches/ItemMonsterEgg.patch27
-rw-r--r--nms-patches/ItemRecord.patch19
-rw-r--r--nms-patches/ItemStack.patch49
-rw-r--r--nms-patches/ItemWaterLily.patch8
-rw-r--r--nms-patches/ItemWorldMap.patch54
-rw-r--r--nms-patches/LoginListener.patch16
-rw-r--r--nms-patches/MerchantRecipe.patch29
-rw-r--r--nms-patches/MethodProfiler.patch4
-rw-r--r--nms-patches/MinecraftServer.patch364
-rw-r--r--nms-patches/MobEffectList.patch44
-rw-r--r--nms-patches/MobSpawnerAbstract.patch57
-rw-r--r--nms-patches/NBTTagList.patch10
-rw-r--r--nms-patches/NameReferencingFileConverter.patch4
-rw-r--r--nms-patches/NetworkManager.patch13
-rw-r--r--nms-patches/PacketDataSerializer.patch37
-rw-r--r--nms-patches/PacketPlayInBlockPlace.patch25
-rw-r--r--nms-patches/PacketPlayInCloseWindow.patch9
-rw-r--r--nms-patches/PacketPlayInResourcePackStatus.patch22
-rw-r--r--nms-patches/PacketStatusListener.patch147
-rw-r--r--nms-patches/Path.patch11
-rw-r--r--nms-patches/PathfinderGoalBreakDoor.patch2
-rw-r--r--nms-patches/PathfinderGoalBreed.patch16
-rw-r--r--nms-patches/PathfinderGoalHurtByTarget.patch10
-rw-r--r--nms-patches/PathfinderGoalMakeLove.patch2
-rw-r--r--nms-patches/PathfinderGoalNearestAttackableTarget.patch33
-rw-r--r--nms-patches/PathfinderGoalPanic.patch6
-rw-r--r--nms-patches/PathfinderGoalSelector.patch30
-rw-r--r--nms-patches/PathfinderGoalSit.patch2
-rw-r--r--nms-patches/PathfinderGoalTame.patch27
-rw-r--r--nms-patches/PathfinderGoalTarget.patch28
-rw-r--r--nms-patches/PlayerChunk.patch116
-rw-r--r--nms-patches/PlayerChunkMap.patch197
-rw-r--r--nms-patches/PlayerConnection.patch1039
-rw-r--r--nms-patches/PlayerInteractManager.patch91
-rw-r--r--nms-patches/PlayerInventory.patch34
-rw-r--r--nms-patches/PlayerList.patch217
-rw-r--r--nms-patches/PortalTravelAgent.patch82
-rw-r--r--nms-patches/RecipeTippedArrow.patch20
-rw-r--r--nms-patches/RecipesFurnace.patch48
-rw-r--r--nms-patches/RecipiesShield.patch18
-rw-r--r--nms-patches/RegionFile.patch2
-rw-r--r--nms-patches/RemoteControlCommandListener.patch6
-rw-r--r--nms-patches/ScoreboardServer.patch6
-rw-r--r--nms-patches/SecondaryWorldServer.patch14
-rw-r--r--nms-patches/SpawnerCreature.patch45
-rw-r--r--nms-patches/TileEntity.patch6
-rw-r--r--nms-patches/TileEntityBanner.patch4
-rw-r--r--nms-patches/TileEntityBeacon.patch23
-rw-r--r--nms-patches/TileEntityBrewingStand.patch66
-rw-r--r--nms-patches/TileEntityChest.patch37
-rw-r--r--nms-patches/TileEntityCommand.patch8
-rw-r--r--nms-patches/TileEntityContainer.patch14
-rw-r--r--nms-patches/TileEntityDispenser.patch4
-rw-r--r--nms-patches/TileEntityFurnace.patch27
-rw-r--r--nms-patches/TileEntityHopper.patch16
-rw-r--r--nms-patches/TileEntityNote.patch2
-rw-r--r--nms-patches/TileEntityPiston.patch4
-rw-r--r--nms-patches/TileEntitySign.patch39
-rw-r--r--nms-patches/TileEntitySkull.patch2
-rw-r--r--nms-patches/UserCache.patch18
-rw-r--r--nms-patches/Village.patch2
-rw-r--r--nms-patches/VillageSiege.patch2
-rw-r--r--nms-patches/World.patch264
-rw-r--r--nms-patches/WorldData.patch38
-rw-r--r--nms-patches/WorldGenGroundBush.patch2
-rw-r--r--nms-patches/WorldGenRegistration.patch6
-rw-r--r--nms-patches/WorldGenVillagePieces.patch30
-rw-r--r--nms-patches/WorldManager.patch26
-rw-r--r--nms-patches/WorldMap.patch21
-rw-r--r--nms-patches/WorldNBTStorage.patch34
-rw-r--r--nms-patches/WorldServer.patch299
-rw-r--r--pom.xml46
-rw-r--r--src/main/java/org/bukkit/craftbukkit/CraftChunk.java38
-rw-r--r--src/main/java/org/bukkit/craftbukkit/CraftEquipmentSlot.java31
-rw-r--r--src/main/java/org/bukkit/craftbukkit/CraftParticle.java42
-rw-r--r--src/main/java/org/bukkit/craftbukkit/CraftServer.java29
-rw-r--r--src/main/java/org/bukkit/craftbukkit/CraftSound.java227
-rw-r--r--src/main/java/org/bukkit/craftbukkit/CraftStatistic.java27
-rw-r--r--src/main/java/org/bukkit/craftbukkit/CraftTravelAgent.java3
-rw-r--r--src/main/java/org/bukkit/craftbukkit/CraftWorld.java193
-rw-r--r--src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeInstance.java70
-rw-r--r--src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeMap.java37
-rw-r--r--src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java115
-rw-r--r--src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java8
-rw-r--r--src/main/java/org/bukkit/craftbukkit/block/CraftBrewingStand.java14
-rw-r--r--src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java11
-rw-r--r--src/main/java/org/bukkit/craftbukkit/block/CraftFurnace.java8
-rw-r--r--src/main/java/org/bukkit/craftbukkit/boss/CraftBossBar.java165
-rw-r--r--src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOProvider.java10
-rw-r--r--src/main/java/org/bukkit/craftbukkit/command/CraftBlockCommandSender.java15
-rw-r--r--src/main/java/org/bukkit/craftbukkit/command/CraftRemoteConsoleCommandSender.java9
-rw-r--r--src/main/java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java14
-rw-r--r--src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java14
-rw-r--r--src/main/java/org/bukkit/craftbukkit/entity/CraftAreaEffectCloud.java138
-rw-r--r--src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java7
-rw-r--r--src/main/java/org/bukkit/craftbukkit/entity/CraftDragonFireball.java17
-rw-r--r--src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java47
-rw-r--r--src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java6
-rw-r--r--src/main/java/org/bukkit/craftbukkit/entity/CraftHorse.java19
-rw-r--r--src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java19
-rw-r--r--src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java44
-rw-r--r--src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java2
-rw-r--r--src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java82
-rw-r--r--src/main/java/org/bukkit/craftbukkit/entity/CraftShulker.java24
-rw-r--r--src/main/java/org/bukkit/craftbukkit/entity/CraftShulkerBullet.java51
-rw-r--r--src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java4
-rw-r--r--src/main/java/org/bukkit/craftbukkit/entity/CraftTameableAnimal.java8
-rw-r--r--src/main/java/org/bukkit/craftbukkit/entity/CraftThrownPotion.java9
-rw-r--r--src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java65
-rw-r--r--src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java18
-rw-r--r--src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java20
-rw-r--r--src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java65
-rw-r--r--src/main/java/org/bukkit/craftbukkit/generator/InternalChunkGenerator.java2
-rw-r--r--src/main/java/org/bukkit/craftbukkit/generator/NormalChunkGenerator.java63
-rw-r--r--src/main/java/org/bukkit/craftbukkit/inventory/CraftEntityEquipment.java113
-rw-r--r--src/main/java/org/bukkit/craftbukkit/inventory/CraftFurnaceRecipe.java3
-rw-r--r--src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java6
-rw-r--r--src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryAnvil.java10
-rw-r--r--src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryBrewer.java10
-rw-r--r--src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCrafting.java14
-rw-r--r--src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java9
-rw-r--r--src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryMerchant.java17
-rw-r--r--src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryPlayer.java41
-rw-r--r--src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java4
-rw-r--r--src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java4
-rw-r--r--src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantRecipe.java79
-rw-r--r--src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java14
-rw-r--r--src/main/java/org/bukkit/craftbukkit/inventory/InventoryWrapper.java8
-rw-r--r--src/main/java/org/bukkit/craftbukkit/potion/CraftPotionBrewer.java11
-rw-r--r--src/main/java/org/bukkit/craftbukkit/potion/CraftPotionEffectType.java16
-rw-r--r--src/main/java/org/bukkit/craftbukkit/projectiles/CraftBlockProjectileSource.java9
-rw-r--r--src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardManager.java2
-rw-r--r--src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java3
-rw-r--r--src/main/java/org/bukkit/craftbukkit/util/LazyHashSet.java1
-rw-r--r--src/main/java/org/bukkit/craftbukkit/util/LazyPlayerSet.java9
-rw-r--r--src/main/resources/log4j2.xml2
-rw-r--r--src/test/java/org/bukkit/BiomeTest.java24
-rw-r--r--src/test/java/org/bukkit/ParticleTest.java19
-rw-r--r--src/test/java/org/bukkit/PerMaterialTest.java8
-rw-r--r--src/test/java/org/bukkit/SoundTest.java11
-rw-r--r--src/test/java/org/bukkit/craftbukkit/inventory/NMSCraftItemStackTest.java4
-rw-r--r--src/test/java/org/bukkit/potion/PotionTest.java17
-rw-r--r--src/test/java/org/bukkit/support/AbstractTestingBase.java7
-rw-r--r--src/test/java/org/bukkit/support/DummyEnchantments.java4
-rw-r--r--src/test/java/org/bukkit/support/DummyPotions.java4
305 files changed, 6637 insertions, 6058 deletions
diff --git a/deprecation-mappings.at b/deprecation-mappings.at
deleted file mode 100644
index 5858b488..00000000
--- a/deprecation-mappings.at
+++ /dev/null
@@ -1,62 +0,0 @@
-public+synthetic org/bukkit/Bukkit/getOnlinePlayers()[Lorg/bukkit/entity/Player;
-public+synthetic org/bukkit/Server/getOnlinePlayers()[Lorg/bukkit/entity/Player;
-
-public+synthetic org/bukkit/entity/Damageable/damage(I)V
-public+synthetic org/bukkit/entity/Damageable/damage(ILorg/bukkit/entity/Entity;)V
-public+synthetic org/bukkit/entity/Damageable/getHealth()I
-public+synthetic org/bukkit/entity/Damageable/getMaxHealth()I
-public+synthetic org/bukkit/entity/Damageable/setHealth(I)V
-public+synthetic org/bukkit/entity/Damageable/setMaxHealth(I)V
-
-public+synthetic org/bukkit/entity/LivingEntity/getLastDamage()I
-public+synthetic org/bukkit/entity/LivingEntity/setLastDamage(I)V
-
-public+synthetic org/bukkit/entity/Minecart/getDamage()I
-public+synthetic org/bukkit/entity/Minecart/setDamage(I)V
-
-public+synthetic org/bukkit/entity/Projectile/getShooter()Lorg/bukkit/entity/LivingEntity;
-public+synthetic org/bukkit/entity/Projectile/setShooter(Lorg/bukkit/entity/LivingEntity;)V
-
-public+synthetic org/bukkit/event/entity/EntityDamageEvent/getDamage()I
-public+synthetic org/bukkit/event/entity/EntityDamageEvent/setDamage(I)V
-
-public+synthetic org/bukkit/event/entity/EntityRegainHealthEvent/getAmount()I
-public+synthetic org/bukkit/event/entity/EntityRegainHealthEvent/setAmount(I)V
-
-public+synthetic org/bukkit/event/vehicle/VehicleDamageEvent/getDamage()I
-public+synthetic org/bukkit/event/vehicle/VehicleDamageEvent/setDamage(I)V
-
-# CraftBukkit
-public+synthetic org/bukkit/craftbukkit/v1_8_R3/CraftServer/getOnlinePlayers()[Lorg/bukkit/entity/Player;
-
-public+synthetic org/bukkit/craftbukkit/v1_8_R3/entity/CraftArrow/getShooter()Lorg/bukkit/entity/LivingEntity;
-public+synthetic org/bukkit/craftbukkit/v1_8_R3/entity/CraftArrow/setShooter(Lorg/bukkit/entity/LivingEntity;)V
-
-public+synthetic org/bukkit/craftbukkit/v1_8_R3/entity/CraftEnderDragonPart/damage(I)V
-public+synthetic org/bukkit/craftbukkit/v1_8_R3/entity/CraftEnderDragonPart/damage(ILorg/bukkit/entity/Entity;)V
-public+synthetic org/bukkit/craftbukkit/v1_8_R3/entity/CraftEnderDragonPart/getHealth()I
-public+synthetic org/bukkit/craftbukkit/v1_8_R3/entity/CraftEnderDragonPart/getMaxHealth()I
-public+synthetic org/bukkit/craftbukkit/v1_8_R3/entity/CraftEnderDragonPart/setHealth(I)V
-public+synthetic org/bukkit/craftbukkit/v1_8_R3/entity/CraftEnderDragonPart/setMaxHealth(I)V
-
-
-public+synthetic org/bukkit/craftbukkit/v1_8_R3/entity/CraftFireball/getShooter()Lorg/bukkit/entity/LivingEntity;
-public+synthetic org/bukkit/craftbukkit/v1_8_R3/entity/CraftFireball/setShooter(Lorg/bukkit/entity/LivingEntity;)V
-
-public+synthetic org/bukkit/craftbukkit/v1_8_R3/entity/CraftFish/getShooter()Lorg/bukkit/entity/LivingEntity;
-public+synthetic org/bukkit/craftbukkit/v1_8_R3/entity/CraftFish/setShooter(Lorg/bukkit/entity/LivingEntity;)V
-
-public+synthetic org/bukkit/craftbukkit/v1_8_R3/entity/CraftLivingEntity/damage(I)V
-public+synthetic org/bukkit/craftbukkit/v1_8_R3/entity/CraftLivingEntity/damage(ILorg/bukkit/entity/Entity;)V
-public+synthetic org/bukkit/craftbukkit/v1_8_R3/entity/CraftLivingEntity/getHealth()I
-public+synthetic org/bukkit/craftbukkit/v1_8_R3/entity/CraftLivingEntity/getMaxHealth()I
-public+synthetic org/bukkit/craftbukkit/v1_8_R3/entity/CraftLivingEntity/setHealth(I)V
-public+synthetic org/bukkit/craftbukkit/v1_8_R3/entity/CraftLivingEntity/setMaxHealth(I)V
-public+synthetic org/bukkit/craftbukkit/v1_8_R3/entity/CraftLivingEntity/getLastDamage()I
-public+synthetic org/bukkit/craftbukkit/v1_8_R3/entity/CraftLivingEntity/setLastDamage(I)V
-
-public+synthetic org/bukkit/craftbukkit/v1_8_R3/entity/CraftMinecart/getDamage()I
-public+synthetic org/bukkit/craftbukkit/v1_8_R3/entity/CraftMinecart/setDamage(I)V
-
-public+synthetic org/bukkit/craftbukkit/v1_8_R3/entity/CraftProjectile/getShooter()Lorg/bukkit/entity/LivingEntity;
-public+synthetic org/bukkit/craftbukkit/v1_8_R3/entity/CraftProjectile/setShooter(Lorg/bukkit/entity/LivingEntity;)V
diff --git a/deprecation-mappings.csrg b/deprecation-mappings.csrg
index 48bc5049..4c3077e0 100644
--- a/deprecation-mappings.csrg
+++ b/deprecation-mappings.csrg
@@ -1,27 +1,27 @@
-org/bukkit/Bukkit _INVALID_getOnlinePlayers ()[Lorg/bukkit/entity/Player; getOnlinePlayers
-org/bukkit/Server _INVALID_getOnlinePlayers ()[Lorg/bukkit/entity/Player; getOnlinePlayers
+org/bukkit/Bukkit getOnlinePlayers ()[Lorg/bukkit/entity/Player; _INVALID_getOnlinePlayers
+org/bukkit/Server getOnlinePlayers ()[Lorg/bukkit/entity/Player; _INVALID_getOnlinePlayers
-org/bukkit/entity/Damageable _INVALID_damage (I)V damage
-org/bukkit/entity/Damageable _INVALID_damage (ILorg/bukkit/entity/Entity;)V damage
-org/bukkit/entity/Damageable _INVALID_getHealth ()I getHealth
-org/bukkit/entity/Damageable _INVALID_getMaxHealth ()I getMaxHealth
-org/bukkit/entity/Damageable _INVALID_setHealth (I)V setHealth
-org/bukkit/entity/Damageable _INVALID_setMaxHealth (I)V setMaxHealth
+org/bukkit/entity/Damageable damage (I)V _INVALID_damage
+org/bukkit/entity/Damageable damage (ILorg/bukkit/entity/Entity;)V _INVALID_damage
+org/bukkit/entity/Damageable getHealth ()I _INVALID_getHealth
+org/bukkit/entity/Damageable getMaxHealth ()I _INVALID_getMaxHealth
+org/bukkit/entity/Damageable setHealth (I)V _INVALID_setHealth
+org/bukkit/entity/Damageable setMaxHealth (I)V _INVALID_setMaxHealth
-org/bukkit/entity/LivingEntity _INVALID_getLastDamage ()I getLastDamage
-org/bukkit/entity/LivingEntity _INVALID_setLastDamage (I)V setLastDamage
+org/bukkit/entity/LivingEntity getLastDamage ()I _INVALID_getLastDamage
+org/bukkit/entity/LivingEntity setLastDamage (I)V _INVALID_setLastDamage
-org/bukkit/entity/Minecart _INVALID_getDamage ()I getDamage
-org/bukkit/entity/Minecart _INVALID_setDamage (I)V setDamage
+org/bukkit/entity/Minecart getDamage ()I _INVALID_getDamage
+org/bukkit/entity/Minecart setDamage (I)V _INVALID_setDamage
-org/bukkit/entity/Projectile _INVALID_getShooter ()Lorg/bukkit/entity/LivingEntity; getShooter
-org/bukkit/entity/Projectile _INVALID_setShooter (Lorg/bukkit/entity/LivingEntity;)V setShooter
+org/bukkit/entity/Projectile getShooter ()Lorg/bukkit/entity/LivingEntity; _INVALID_getShooter
+org/bukkit/entity/Projectile setShooter (Lorg/bukkit/entity/LivingEntity;)V _INVALID_setShooter
-org/bukkit/event/entity/EntityDamageEvent _INVALID_getDamage ()I getDamage
-org/bukkit/event/entity/EntityDamageEvent _INVALID_setDamage (I)V setDamage
+org/bukkit/event/entity/EntityDamageEvent getDamage ()I _INVALID_getDamage
+org/bukkit/event/entity/EntityDamageEvent setDamage (I)V _INVALID_setDamage
-org/bukkit/event/entity/EntityRegainHealthEvent _INVALID_getAmount ()I getAmount
-org/bukkit/event/entity/EntityRegainHealthEvent _INVALID_setAmount (I)V setAmount
+org/bukkit/event/entity/EntityRegainHealthEvent getAmount ()I _INVALID_getAmount
+org/bukkit/event/entity/EntityRegainHealthEvent setAmount (I)V _INVALID_setAmount
-org/bukkit/event/vehicle/VehicleDamageEvent _INVALID_getDamage ()I getDamage
-org/bukkit/event/vehicle/VehicleDamageEvent _INVALID_setDamage (I)V setDamage
+org/bukkit/event/vehicle/VehicleDamageEvent getDamage ()I _INVALID_getDamage
+org/bukkit/event/vehicle/VehicleDamageEvent setDamage (I)V _INVALID_setDamage
diff --git a/nms-patches/BiomeTheEndDecorator.patch b/nms-patches/BiomeTheEndDecorator.patch
deleted file mode 100644
index 77ae8879..00000000
--- a/nms-patches/BiomeTheEndDecorator.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- a/net/minecraft/server/BiomeTheEndDecorator.java
-+++ b/net/minecraft/server/BiomeTheEndDecorator.java
-@@ -21,7 +21,7 @@
- EntityEnderDragon entityenderdragon = new EntityEnderDragon(this.a);
-
- entityenderdragon.setPositionRotation(0.0D, 128.0D, 0.0D, this.b.nextFloat() * 360.0F, 0.0F);
-- this.a.addEntity(entityenderdragon);
-+ this.a.addEntity(entityenderdragon, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CHUNK_GEN); // CraftBukkit - add SpawnReason
- }
-
- }
diff --git a/nms-patches/Block.patch b/nms-patches/Block.patch
index 360a2c0b..4980705c 100644
--- a/nms-patches/Block.patch
+++ b/nms-patches/Block.patch
@@ -1,6 +1,15 @@
--- a/net/minecraft/server/Block.java
+++ b/net/minecraft/server/Block.java
-@@ -336,7 +336,8 @@
+@@ -34,7 +34,7 @@
+ private String name;
+
+ public static int getId(Block block) {
+- return Block.REGISTRY.a((Object) block);
++ return Block.REGISTRY.a(block); // CraftBukkit - decompile error
+ }
+
+ public static int getCombinedId(IBlockData iblockdata) {
+@@ -301,7 +301,8 @@
int j = this.getDropCount(i, world.random);
for (int k = 0; k < j; ++k) {
@@ -10,14 +19,34 @@
Item item = this.getDropType(iblockdata, world.random, i);
if (item != null) {
-@@ -1002,4 +1003,10 @@
- return this.getBreakSound();
- }
+@@ -825,7 +826,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);
+ }
+@@ -834,7 +835,7 @@
+
+ while (iterator2.hasNext()) {
+ IBlockData iblockdata = (IBlockData) iterator2.next();
+- int k = Block.REGISTRY.a((Object) block16) << 4 | block16.toLegacyData(iblockdata);
++ int k = Block.REGISTRY.a(block16) << 4 | block16.toLegacyData(iblockdata); // CraftBukkit - decompile error
+
+ Block.REGISTRY_ID.a(iblockdata, k);
+ }
+@@ -843,6 +844,12 @@
+
}
-+
+
+ // CraftBukkit start
+ public int getExpDrop(World world, IBlockData data, int enchantmentLevel) {
+ return 0;
+ }
+ // CraftBukkit end
- }
++
+ private static void a(int i, MinecraftKey minecraftkey, Block block) {
+ Block.REGISTRY.a(i, minecraftkey, block);
+ }
diff --git a/nms-patches/BlockBloodStone.patch b/nms-patches/BlockBloodStone.patch
deleted file mode 100644
index 250ed8a3..00000000
--- a/nms-patches/BlockBloodStone.patch
+++ /dev/null
@@ -1,28 +0,0 @@
---- a/net/minecraft/server/BlockBloodStone.java
-+++ b/net/minecraft/server/BlockBloodStone.java
-@@ -1,5 +1,7 @@
- package net.minecraft.server;
-
-+import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
-+
- public class BlockBloodStone extends Block {
-
- public BlockBloodStone() {
-@@ -10,4 +12,17 @@
- public MaterialMapColor g(IBlockData iblockdata) {
- return MaterialMapColor.K;
- }
-+
-+ // CraftBukkit start
-+ @Override
-+ public void doPhysics(World world, BlockPosition position, IBlockData iblockdata, Block block) {
-+ if (block != null && block.isPowerSource()) {
-+ org.bukkit.block.Block bl = world.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ());
-+ int power = bl.getBlockPower();
-+
-+ BlockRedstoneEvent event = new BlockRedstoneEvent(bl, power, power);
-+ world.getServer().getPluginManager().callEvent(event);
-+ }
-+ }
-+ // CraftBukkit end
- }
diff --git a/nms-patches/BlockButtonAbstract.patch b/nms-patches/BlockButtonAbstract.patch
index 408baab4..27e38ee5 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 Block {
+ public abstract class BlockButtonAbstract extends BlockDirectional {
- public static final BlockStateDirection FACING = BlockStateDirection.of("facing");
-@@ -124,6 +129,19 @@
+ public static final BlockStateBoolean POWERED = BlockStateBoolean.of("powered");
+@@ -121,6 +126,19 @@
if (((Boolean) iblockdata.get(BlockButtonAbstract.POWERED)).booleanValue()) {
return true;
} else {
@@ -31,10 +31,10 @@
+ // CraftBukkit end
world.setTypeAndData(blockposition, iblockdata.set(BlockButtonAbstract.POWERED, Boolean.valueOf(true)), 3);
world.b(blockposition, blockposition);
- world.makeSound((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D, "random.click", 0.3F, 0.6F);
-@@ -161,6 +179,16 @@
- if (this.N) {
- this.f(world, blockposition, iblockdata);
+ this.a(entityhuman, world, blockposition);
+@@ -162,6 +180,16 @@
+ if (this.I) {
+ this.e(iblockdata, world, blockposition);
} else {
+ // CraftBukkit start
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
@@ -48,8 +48,8 @@
+ // CraftBukkit end
world.setTypeUpdate(blockposition, iblockdata.set(BlockButtonAbstract.POWERED, Boolean.valueOf(false)));
this.c(world, blockposition, (EnumDirection) iblockdata.get(BlockButtonAbstract.FACING));
- world.makeSound((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D, "random.click", 0.3F, 0.5F);
-@@ -195,7 +223,41 @@
+ this.b(world, blockposition);
+@@ -187,7 +215,41 @@
boolean flag = !list.isEmpty();
boolean flag1 = ((Boolean) iblockdata.get(BlockButtonAbstract.POWERED)).booleanValue();
@@ -91,7 +91,7 @@
world.setTypeUpdate(blockposition, iblockdata.set(BlockButtonAbstract.POWERED, Boolean.valueOf(true)));
this.c(world, blockposition, (EnumDirection) iblockdata.get(BlockButtonAbstract.FACING));
world.b(blockposition, blockposition);
-@@ -203,6 +265,16 @@
+@@ -195,6 +257,16 @@
}
if (!flag && flag1) {
diff --git a/nms-patches/BlockCactus.patch b/nms-patches/BlockCactus.patch
index b8b99b88..97f6078e 100644
--- a/nms-patches/BlockCactus.patch
+++ b/nms-patches/BlockCactus.patch
@@ -9,7 +9,7 @@
public class BlockCactus extends Block {
public static final BlockStateInteger AGE = BlockStateInteger.of("age", 0, 15);
-@@ -28,9 +30,10 @@
+@@ -30,9 +32,10 @@
int j = ((Integer) iblockdata.get(BlockCactus.AGE)).intValue();
if (j == 15) {
@@ -21,7 +21,7 @@
world.setTypeAndData(blockposition, iblockdata1, 4);
this.doPhysics(world, blockposition1, iblockdata1, this);
} else {
-@@ -83,7 +86,9 @@
+@@ -87,7 +90,9 @@
}
public void a(World world, BlockPosition blockposition, IBlockData iblockdata, Entity entity) {
diff --git a/nms-patches/BlockCake.patch b/nms-patches/BlockCake.patch
index 55459181..b3c6df05 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
-@@ -55,7 +55,18 @@
+@@ -33,7 +33,18 @@
private void b(World world, BlockPosition blockposition, IBlockData iblockdata, EntityHuman entityhuman) {
- if (entityhuman.j(false)) {
- entityhuman.b(StatisticList.H);
+ if (entityhuman.l(false)) {
+ entityhuman.b(StatisticList.J);
- 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
new file mode 100644
index 00000000..110e170d
--- /dev/null
+++ b/nms-patches/BlockCauldron.patch
@@ -0,0 +1,144 @@
+--- a/net/minecraft/server/BlockCauldron.java
++++ b/net/minecraft/server/BlockCauldron.java
+@@ -2,6 +2,7 @@
+
+ import java.util.List;
+ import java.util.Random;
++import org.bukkit.event.block.CauldronLevelChangeEvent; // CraftBukkit
+
+ public class BlockCauldron extends Block {
+
+@@ -42,8 +43,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) {
++ // CraftBukkit start
++ if (!this.changeLevel(world, blockposition, iblockdata, i - 1, entity, CauldronLevelChangeEvent.ChangeReason.EXTINGUISH)) {
++ return;
++ }
+ entity.extinguish();
+- this.a(world, blockposition, iblockdata, i - 1);
++ // this.a(world, blockposition, iblockdata, i - 1);
++ // CraftBukkit end
+ }
+
+ }
+@@ -57,17 +63,26 @@
+
+ if (item == Items.WATER_BUCKET) {
+ if (i < 3 && !world.isClientSide) {
++ // CraftBukkit start
++ if (!this.changeLevel(world, blockposition, iblockdata, 3, entityhuman, CauldronLevelChangeEvent.ChangeReason.BUCKET_EMPTY)) {
++ return true;
++ }
+ if (!entityhuman.abilities.canInstantlyBuild) {
+ entityhuman.a(enumhand, new ItemStack(Items.BUCKET));
+ }
+
+ entityhuman.b(StatisticList.K);
+- this.a(world, blockposition, iblockdata, 3);
++ // this.a(world, blockposition, iblockdata, 3);
++ // CraftBukkit end
+ }
+
+ return true;
+ } else if (item == Items.BUCKET) {
+ if (i == 3 && !world.isClientSide) {
++ // CraftBukkit start
++ if (!this.changeLevel(world, blockposition, iblockdata, 0, entityhuman, CauldronLevelChangeEvent.ChangeReason.BUCKET_FILL)) {
++ return true;
++ }
+ if (!entityhuman.abilities.canInstantlyBuild) {
+ --itemstack.count;
+ if (itemstack.count == 0) {
+@@ -78,7 +93,8 @@
+ }
+
+ entityhuman.b(StatisticList.L);
+- this.a(world, blockposition, iblockdata, 0);
++ // this.a(world, blockposition, iblockdata, 0);
++ // CraftBukkit end
+ }
+
+ return true;
+@@ -87,6 +103,10 @@
+
+ if (item == Items.GLASS_BOTTLE) {
+ if (i > 0 && !world.isClientSide) {
++ // CraftBukkit start
++ if (!this.changeLevel(world, blockposition, iblockdata, i - 1, entityhuman, CauldronLevelChangeEvent.ChangeReason.BOTTLE_FILL)) {
++ return true;
++ }
+ if (!entityhuman.abilities.canInstantlyBuild) {
+ itemstack1 = PotionUtil.a(new ItemStack(Items.POTION), Potions.b);
+ entityhuman.b(StatisticList.L);
+@@ -99,7 +119,8 @@
+ }
+ }
+
+- this.a(world, blockposition, iblockdata, i - 1);
++ // this.a(world, blockposition, iblockdata, i - 1);
++ // CraftBukkit end
+ }
+
+ return true;
+@@ -108,8 +129,13 @@
+ ItemArmor itemarmor = (ItemArmor) item;
+
+ if (itemarmor.d() == ItemArmor.EnumArmorMaterial.LEATHER && itemarmor.e_(itemstack) && !world.isClientSide) {
++ // CraftBukkit start
++ if (!this.changeLevel(world, blockposition, iblockdata, i - 1, entityhuman, CauldronLevelChangeEvent.ChangeReason.ARMOR_WASH)) {
++ return true;
++ }
+ itemarmor.c(itemstack);
+- this.a(world, blockposition, iblockdata, i - 1);
++ // this.a(world, blockposition, iblockdata, i - 1);
++ // CraftBukkit end
+ entityhuman.b(StatisticList.M);
+ return true;
+ }
+@@ -134,7 +160,7 @@
+ }
+
+ if (!entityhuman.abilities.canInstantlyBuild) {
+- this.a(world, blockposition, iblockdata, i - 1);
++ this.changeLevel(world, blockposition, iblockdata, i - 1, entityhuman, CauldronLevelChangeEvent.ChangeReason.BANNER_WASH); // CraftBukkit
+ }
+ }
+
+@@ -147,9 +173,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);
++ this.changeLevel(world, blockposition, iblockdata, i, null, CauldronLevelChangeEvent.ChangeReason.UNKNOWN);
++ }
++
++ private boolean changeLevel(World world, BlockPosition blockposition, IBlockData iblockdata, int i, Entity entity, CauldronLevelChangeEvent.ChangeReason reason) {
++ int newLevel = Integer.valueOf(MathHelper.clamp(i, 0, 3));
++ CauldronLevelChangeEvent event = new CauldronLevelChangeEvent(
++ world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()),
++ entity.getBukkitEntity(), reason, iblockdata.get(BlockCauldron.LEVEL), newLevel
++ );
++ world.getServer().getPluginManager().callEvent(event);
++ if (event.isCancelled()) {
++ return false;
++ }
++ world.setTypeAndData(blockposition, iblockdata.set(BlockCauldron.LEVEL, newLevel), 2);
+ world.updateAdjacentComparators(blockposition, this);
++ return true;
++ // CraftBukkit end
+ }
+
+ public void h(World world, BlockPosition blockposition) {
+@@ -160,7 +202,7 @@
+ IBlockData iblockdata = world.getType(blockposition);
+
+ if (((Integer) iblockdata.get(BlockCauldron.LEVEL)).intValue() < 3) {
+- world.setTypeAndData(blockposition, iblockdata.a((IBlockState) BlockCauldron.LEVEL), 2);
++ a(world, blockposition, iblockdata.a((IBlockState) BlockCauldron.LEVEL), 2); // CraftBukkit
+ }
+
+ }
diff --git a/nms-patches/BlockChorusFlower.patch b/nms-patches/BlockChorusFlower.patch
new file mode 100644
index 00000000..3ef5e834
--- /dev/null
+++ b/nms-patches/BlockChorusFlower.patch
@@ -0,0 +1,92 @@
+--- a/net/minecraft/server/BlockChorusFlower.java
++++ b/net/minecraft/server/BlockChorusFlower.java
+@@ -3,6 +3,8 @@
+ import java.util.Iterator;
+ import java.util.Random;
+
++import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
++
+ public class BlockChorusFlower extends Block {
+
+ public static final BlockStateInteger AGE = BlockStateInteger.of("age", 0, 5);
+@@ -66,8 +68,20 @@
+ }
+
+ 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);
++ // CraftBukkit start - add event
++ BlockPosition target = blockposition.up();
++ 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);
++ }
++ // CraftBukkit end
+ } else if (i < 4) {
+ j = random.nextInt(4);
+ boolean flag2 = false;
+@@ -81,18 +95,53 @@
+ BlockPosition blockposition2 = blockposition.shift(enumdirection);
+
+ if (world.isEmpty(blockposition2) && world.isEmpty(blockposition2.down()) && a(world, blockposition2, enumdirection.opposite())) {
+- this.a(world, blockposition2, i + 1);
+- flag2 = true;
++ // CraftBukkit start - add event
++ // this.a(world, blockposition2, i + 1);
++ 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 + 1)))
++ )) {
++ world.triggerEffect(1033, blockposition, 0);
++ flag2 = true;
++ }
++ // CraftBukkit end
+ }
+ }
+
+ if (flag2) {
+ world.setTypeAndData(blockposition, Blocks.CHORUS_PLANT.getBlockData(), 2);
+ } else {
+- this.c(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);
++ }
++ // this.c(world, blockposition);
++ // CraftBukkit end
+ }
+ } else if (i == 4) {
+- this.c(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);
++ }
++ // this.c(world, blockposition);
++ // CraftBukkit end
+ }
+
+ }
diff --git a/nms-patches/BlockCocoa.patch b/nms-patches/BlockCocoa.patch
index d7ba70e1..470a26f6 100644
--- a/nms-patches/BlockCocoa.patch
+++ b/nms-patches/BlockCocoa.patch
@@ -6,10 +6,10 @@
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
+
- public class BlockCocoa extends BlockDirectional implements IBlockFragilePlantElement {
+ public class BlockCocoa extends BlockFacingHorizontal implements IBlockFragilePlantElement {
public static final BlockStateInteger AGE = BlockStateInteger.of("age", 0, 2);
-@@ -19,7 +21,10 @@
+@@ -23,7 +25,10 @@
int i = ((Integer) iblockdata.get(BlockCocoa.AGE)).intValue();
if (i < 2) {
@@ -21,7 +21,7 @@
}
}
-@@ -125,7 +130,10 @@
+@@ -124,7 +129,10 @@
}
public void b(World world, Random random, BlockPosition blockposition, IBlockData iblockdata) {
diff --git a/nms-patches/BlockCommand.patch b/nms-patches/BlockCommand.patch
index 236e740f..94c248a6 100644
--- a/nms-patches/BlockCommand.patch
+++ b/nms-patches/BlockCommand.patch
@@ -6,15 +6,16 @@
+import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
+
- public class BlockCommand extends BlockContainer {
+ public class BlockCommand extends BlockTileEntity {
- public static final BlockStateBoolean TRIGGERED = BlockStateBoolean.of("triggered");
-@@ -20,10 +22,19 @@
- boolean flag = world.isBlockIndirectlyPowered(blockposition);
- boolean flag1 = ((Boolean) iblockdata.get(BlockCommand.TRIGGERED)).booleanValue();
+ public static final BlockStateDirection a = BlockDirectional.FACING;
+@@ -29,7 +31,17 @@
+ boolean flag1 = tileentitycommand.d();
+ boolean flag2 = tileentitycommand.e();
-- if (flag && !flag1) {
+- if (flag && !flag1) {
+ // CraftBukkit start
++ // PAIL: This section - renames, ordering
+ org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
+ int old = flag1 ? 15 : 0;
+ int current = flag ? 15 : 0;
@@ -24,10 +25,15 @@
+ // CraftBukkit end
+
+ if (eventRedstone.getNewCurrent() > 0 && !(eventRedstone.getOldCurrent() > 0)) { // CraftBukkit
- world.setTypeAndData(blockposition, iblockdata.set(BlockCommand.TRIGGERED, Boolean.valueOf(true)), 4);
- world.a(blockposition, (Block) this, this.a(world));
-- } else if (!flag && flag1) {
+ tileentitycommand.a(true);
+ if (tileentitycommand.i() != TileEntityCommand.Type.SEQUENCE && !flag2) {
+ boolean flag3 = !tileentitycommand.j() || this.e(world, blockposition, iblockdata);
+@@ -40,7 +52,7 @@
+ this.c(world, blockposition);
+ }
+ }
+- } else if (!flag && flag1) {
+ } else if (!(eventRedstone.getNewCurrent() > 0) && eventRedstone.getOldCurrent() > 0) { // CraftBukkit
- world.setTypeAndData(blockposition, iblockdata.set(BlockCommand.TRIGGERED, Boolean.valueOf(false)), 4);
- }
- }
+ tileentitycommand.a(false);
+ }
+
diff --git a/nms-patches/BlockCrops.patch b/nms-patches/BlockCrops.patch
index bc89bbd0..385751da 100644
--- a/nms-patches/BlockCrops.patch
+++ b/nms-patches/BlockCrops.patch
@@ -9,27 +9,27 @@
public class BlockCrops extends BlockPlant implements IBlockFragilePlantElement {
public static final BlockStateInteger AGE = BlockStateInteger.of("age", 0, 7);
-@@ -31,7 +33,10 @@
+@@ -53,7 +55,10 @@
float f = a((Block) this, world, blockposition);
if (random.nextInt((int) (25.0F / f) + 1) == 0) {
-- world.setTypeAndData(blockposition, iblockdata.set(BlockCrops.AGE, Integer.valueOf(i + 1)), 2);
+- world.setTypeAndData(blockposition, this.setAge(i + 1), 2);
+ // CraftBukkit start
-+ IBlockData data = iblockdata.set(AGE, Integer.valueOf(i + 1));
++ IBlockData data = this.setAge(i + 1);
+ CraftEventFactory.handleBlockGrowEvent(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this, toLegacyData(data));
+ // CraftBukkit end
}
}
}
-@@ -45,7 +50,10 @@
- i = 7;
+@@ -68,7 +73,10 @@
+ i = j;
}
-- world.setTypeAndData(blockposition, iblockdata.set(BlockCrops.AGE, Integer.valueOf(i)), 2);
+- world.setTypeAndData(blockposition, this.setAge(i), 2);
+ // CraftBukkit start
-+ IBlockData data = iblockdata.set(AGE, Integer.valueOf(i));
++ IBlockData data = this.setAge(i);
+ CraftEventFactory.handleBlockGrowEvent(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this, toLegacyData(data));
+ // CraftBukkit end
}
- protected static float a(Block block, World world, BlockPosition blockposition) {
+ protected int b(World world) {
diff --git a/nms-patches/BlockDaylightDetector.patch b/nms-patches/BlockDaylightDetector.patch
index ba111082..a9525a88 100644
--- a/nms-patches/BlockDaylightDetector.patch
+++ b/nms-patches/BlockDaylightDetector.patch
@@ -1,8 +1,8 @@
--- a/net/minecraft/server/BlockDaylightDetector.java
+++ b/net/minecraft/server/BlockDaylightDetector.java
-@@ -41,6 +41,7 @@
- }
+@@ -45,6 +45,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);
diff --git a/nms-patches/BlockDiodeAbstract.patch b/nms-patches/BlockDiodeAbstract.patch
index 8144ad41..36e5c204 100644
--- a/nms-patches/BlockDiodeAbstract.patch
+++ b/nms-patches/BlockDiodeAbstract.patch
@@ -6,25 +6,25 @@
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
+
- public abstract class BlockDiodeAbstract extends BlockDirectional {
+ public abstract class BlockDiodeAbstract extends BlockFacingHorizontal {
- protected final boolean N;
-@@ -31,8 +33,18 @@
+ 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);
- if (this.N && !flag) {
+ if (this.d && !flag) {
+ // CraftBukkit start
+ if (CraftEventFactory.callRedstoneChange(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), 15, 0).getNewCurrent() != 0) {
+ return;
+ }
+ // CraftBukkit end
- world.setTypeAndData(blockposition, this.k(iblockdata), 2);
- } else if (!this.N) {
+ world.setTypeAndData(blockposition, this.y(iblockdata), 2);
+ } else if (!this.d) {
+ // CraftBukkit start
+ if (CraftEventFactory.callRedstoneChange(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), 0, 15).getNewCurrent() != 15) {
+ return;
+ }
+ // CraftBukkit end
- world.setTypeAndData(blockposition, this.e(iblockdata), 2);
+ world.setTypeAndData(blockposition, this.x(iblockdata), 2);
if (!flag) {
- world.a(blockposition, this.e(iblockdata).getBlock(), this.m(iblockdata), -1);
+ world.a(blockposition, this.x(iblockdata).getBlock(), this.D(iblockdata), -1);
diff --git a/nms-patches/BlockDispenser.patch b/nms-patches/BlockDispenser.patch
index ff2bdb72..d0668995 100644
--- a/nms-patches/BlockDispenser.patch
+++ b/nms-patches/BlockDispenser.patch
@@ -3,7 +3,7 @@
@@ -8,6 +8,7 @@
public static final BlockStateBoolean TRIGGERED = BlockStateBoolean.of("triggered");
public static final RegistryDefault<Item, IDispenseBehavior> REGISTRY = new RegistryDefault(new DispenseBehaviorItem());
- protected Random O = new Random();
+ protected Random d = new Random();
+ public static boolean eventFired = false; // CraftBukkit
protected BlockDispenser() {
diff --git a/nms-patches/BlockDoor.patch b/nms-patches/BlockDoor.patch
index 5f6752c0..2e1dfe91 100644
--- a/nms-patches/BlockDoor.patch
+++ b/nms-patches/BlockDoor.patch
@@ -1,21 +1,21 @@
--- a/net/minecraft/server/BlockDoor.java
+++ b/net/minecraft/server/BlockDoor.java
-@@ -3,6 +3,8 @@
- import com.google.common.base.Predicate;
+@@ -2,6 +2,8 @@
+
import java.util.Random;
+import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
+
public class BlockDoor extends Block {
- public static final BlockStateDirection FACING = BlockStateDirection.of("facing", (Predicate) EnumDirection.EnumDirectionLimit.HORIZONTAL);
-@@ -155,9 +157,22 @@
+ public static final BlockStateDirection FACING = BlockFacingHorizontal.FACING;
+@@ -137,9 +139,22 @@
this.b(world, blockposition, iblockdata, 0);
}
} else {
- boolean flag1 = world.isBlockIndirectlyPowered(blockposition) || world.isBlockIndirectlyPowered(blockposition2);
-- if ((flag1 || block.isPowerSource()) && block != this && flag1 != ((Boolean) iblockdata2.get(BlockDoor.POWERED)).booleanValue()) {
+- 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());
@@ -34,8 +34,8 @@
world.setTypeAndData(blockposition2, 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);
-@@ -165,6 +180,7 @@
- world.a((EntityHuman) null, flag1 ? 1003 : 1006, blockposition, 0);
+@@ -147,6 +162,7 @@
+ world.a((EntityHuman) null, flag1 ? this.g() : this.e(), blockposition, 0);
}
}
+ // CraftBukkit end
diff --git a/nms-patches/BlockDragonEgg.patch b/nms-patches/BlockDragonEgg.patch
index e9860ee3..af397c67 100644
--- a/nms-patches/BlockDragonEgg.patch
+++ b/nms-patches/BlockDragonEgg.patch
@@ -8,8 +8,8 @@
+
public class BlockDragonEgg extends Block {
- public BlockDragonEgg() {
-@@ -61,6 +63,18 @@
+ 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));
if (world.getType(blockposition1).getBlock().material == Material.AIR) {
diff --git a/nms-patches/BlockDropper.patch b/nms-patches/BlockDropper.patch
index 9f4ff914..aa3c82ff 100644
--- a/nms-patches/BlockDropper.patch
+++ b/nms-patches/BlockDropper.patch
@@ -10,7 +10,7 @@
+
public class BlockDropper extends BlockDispenser {
- private final IDispenseBehavior P = new DispenseBehaviorItem();
+ private final IDispenseBehavior e = new DispenseBehaviorItem();
@@ -38,8 +43,25 @@
itemstack1 = null;
}
diff --git a/nms-patches/BlockEnderPortal.patch b/nms-patches/BlockEnderPortal.patch
index 8f130a95..0e141d99 100644
--- a/nms-patches/BlockEnderPortal.patch
+++ b/nms-patches/BlockEnderPortal.patch
@@ -6,13 +6,13 @@
+import org.bukkit.event.entity.EntityPortalEnterEvent; // CraftBukkit
+
- public class BlockEnderPortal extends BlockContainer {
+ public class BlockEnderPortal extends BlockTileEntity {
- protected BlockEnderPortal(Material material) {
+ protected static final AxisAlignedBB a = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 0.75D, 1.0D);
@@ -36,6 +38,10 @@
public void a(World world, BlockPosition blockposition, IBlockData iblockdata, Entity entity) {
- if (entity.vehicle == null && entity.passenger == null && !world.isClientSide) {
+ if (!entity.isPassenger() && !entity.isVehicle() && entity.aV() && !world.isClientSide && entity.getBoundingBox().b(iblockdata.c(world, blockposition).a(blockposition))) {
+ // CraftBukkit start - Entity in portal
+ EntityPortalEnterEvent event = new EntityPortalEnterEvent(entity.getBukkitEntity(), new org.bukkit.Location(world.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ()));
+ world.getServer().getPluginManager().callEvent(event);
diff --git a/nms-patches/BlockFire.patch b/nms-patches/BlockFire.patch
index db1a8fdf..a8d60ca0 100644
--- a/nms-patches/BlockFire.patch
+++ b/nms-patches/BlockFire.patch
@@ -13,7 +13,7 @@
public class BlockFire extends Block {
public static final BlockStateInteger AGE = BlockStateInteger.of("age", 0, 15);
-@@ -109,7 +115,7 @@
+@@ -93,7 +99,7 @@
public void b(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) {
if (world.getGameRules().getBoolean("doFireTick")) {
if (!this.canPlace(world, blockposition)) {
@@ -22,19 +22,19 @@
}
Block block = world.getType(blockposition.down()).getBlock();
-@@ -120,7 +126,7 @@
- }
+@@ -106,7 +112,7 @@
+ int i = ((Integer) iblockdata.get(BlockFire.AGE)).intValue();
- if (!flag && world.S() && this.e(world, blockposition)) {
+ if (!flag && world.W() && this.b(world, blockposition) && random.nextFloat() < 0.2F + (float) i * 0.03F) {
- world.setAir(blockposition);
+ fireExtinguished(world, blockposition); // CraftBukkit - extinguished by rain
} else {
- int i = ((Integer) iblockdata.get(BlockFire.AGE)).intValue();
-
-@@ -133,14 +139,14 @@
+ if (i < 15) {
+ iblockdata = iblockdata.set(BlockFire.AGE, Integer.valueOf(i + random.nextInt(3) / 2));
+@@ -117,14 +123,14 @@
if (!flag) {
- if (!this.f(world, blockposition)) {
- if (!World.a((IBlockAccess) world, blockposition.down()) || i > 3) {
+ if (!this.c(world, blockposition)) {
+ if (!world.getType(blockposition.down()).q() || i > 3) {
- world.setAir(blockposition);
+ fireExtinguished(world, blockposition); // CraftBukkit
}
@@ -42,13 +42,13 @@
return;
}
- if (!this.e((IBlockAccess) world, blockposition.down()) && i == 15 && random.nextInt(4) == 0) {
+ if (!this.c((IBlockAccess) world, blockposition.down()) && i == 15 && random.nextInt(4) == 0) {
- world.setAir(blockposition);
+ fireExtinguished(world, blockposition); // CraftBukkit
return;
}
}
-@@ -186,7 +192,26 @@
+@@ -170,7 +176,26 @@
l1 = 15;
}
@@ -76,7 +76,7 @@
}
}
}
-@@ -224,6 +249,17 @@
+@@ -208,6 +233,17 @@
if (random.nextInt(i) < k) {
IBlockData iblockdata = world.getType(blockposition);
@@ -94,7 +94,7 @@
if (random.nextInt(j + 10) < 5 && !world.isRainingAt(blockposition)) {
int l = j + random.nextInt(5) / 4;
-@@ -233,7 +269,7 @@
+@@ -217,7 +253,7 @@
world.setTypeAndData(blockposition, this.getBlockData().set(BlockFire.AGE, Integer.valueOf(l)), 3);
} else {
@@ -103,27 +103,27 @@
}
if (iblockdata.getBlock() == Blocks.TNT) {
-@@ -290,7 +326,7 @@
+@@ -274,7 +310,7 @@
public void doPhysics(World world, BlockPosition blockposition, IBlockData iblockdata, Block block) {
- if (!World.a((IBlockAccess) world, blockposition.down()) && !this.f(world, blockposition)) {
+ if (!world.getType(blockposition.down()).q() && !this.c(world, blockposition)) {
- world.setAir(blockposition);
+ fireExtinguished(world, blockposition); // CraftBukkit - fuel block gone
}
}
-@@ -298,7 +334,7 @@
+@@ -282,7 +318,7 @@
public void onPlace(World world, BlockPosition blockposition, IBlockData iblockdata) {
- if (world.worldProvider.getDimension() > 0 || !Blocks.PORTAL.e(world, blockposition)) {
- if (!World.a((IBlockAccess) world, blockposition.down()) && !this.f(world, blockposition)) {
+ 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));
}
-@@ -320,4 +356,12 @@
+@@ -304,4 +340,12 @@
protected BlockStateList getStateList() {
- return new BlockStateList(this, new IBlockState[] { BlockFire.AGE, BlockFire.NORTH, BlockFire.EAST, BlockFire.SOUTH, BlockFire.WEST, BlockFire.UPPER, BlockFire.FLIP, BlockFire.ALT});
+ return new BlockStateList(this, new IBlockState[] { BlockFire.AGE, BlockFire.NORTH, BlockFire.EAST, BlockFire.SOUTH, BlockFire.WEST, BlockFire.UPPER});
}
+
+ // CraftBukkit start
diff --git a/nms-patches/BlockFlowing.patch b/nms-patches/BlockFlowing.patch
index 38caee17..b2a52197 100644
--- a/nms-patches/BlockFlowing.patch
+++ b/nms-patches/BlockFlowing.patch
@@ -34,7 +34,7 @@
+ server.getPluginManager().callEvent(event);
+ }
+ if (!event.isCancelled()) {
- if (this.material == Material.LAVA && world.getType(blockposition.down()).getBlock().getMaterial() == Material.WATER) {
+ if (this.material == Material.LAVA && world.getType(blockposition.down()).getMaterial() == Material.WATER) {
world.setTypeUpdate(blockposition.down(), Blocks.STONE.getBlockData());
this.fizz(world, blockposition.down());
@@ -99,6 +115,8 @@
@@ -44,7 +44,7 @@
+ }
+ // CraftBukkit end
} else if (i >= 0 && (i == 0 || this.g(world, blockposition.down(), iblockdata2))) {
- Set set = this.f(world, blockposition);
+ Set set = this.c(world, blockposition);
@@ -116,14 +134,23 @@
while (iterator1.hasNext()) {
diff --git a/nms-patches/BlockGrass.patch b/nms-patches/BlockGrass.patch
index 7014deb3..040f26ae 100644
--- a/nms-patches/BlockGrass.patch
+++ b/nms-patches/BlockGrass.patch
@@ -18,7 +18,7 @@
@@ -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()).getBlock().p() > 2) {
+ 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());
@@ -36,10 +36,10 @@
} else {
if (world.getLightLevel(blockposition.up()) >= 9) {
for (int i = 0; i < 4; ++i) {
-@@ -31,7 +51,19 @@
- IBlockData iblockdata1 = world.getType(blockposition1);
+@@ -36,7 +56,19 @@
+ IBlockData iblockdata2 = world.getType(blockposition1);
- if (iblockdata1.getBlock() == Blocks.DIRT && iblockdata1.get(BlockDirt.VARIANT) == BlockDirt.EnumDirtVariant.DIRT && world.getLightLevel(blockposition1.up()) >= 4 && block.p() <= 2) {
+ 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());
@@ -57,8 +57,8 @@
}
}
}
-@@ -74,13 +106,15 @@
- IBlockData iblockdata1 = blockflowers.getBlockData().set(blockflowers.n(), blockflowers_enumflowervarient);
+@@ -79,13 +111,15 @@
+ IBlockData iblockdata1 = blockflowers.getBlockData().set(blockflowers.g(), blockflowers_enumflowervarient);
if (blockflowers.f(world, blockposition2, iblockdata1)) {
- world.setTypeAndData(blockposition2, iblockdata1, 3);
diff --git a/nms-patches/BlockIce.patch b/nms-patches/BlockIce.patch
index 05344a7e..b9d8696a 100644
--- a/nms-patches/BlockIce.patch
+++ b/nms-patches/BlockIce.patch
@@ -1,15 +1,14 @@
--- a/net/minecraft/server/BlockIce.java
+++ b/net/minecraft/server/BlockIce.java
-@@ -44,6 +44,12 @@
+@@ -50,6 +50,11 @@
+ }
- public void b(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) {
- if (world.b(EnumSkyBlock.BLOCK, blockposition) > 11 - this.p()) {
-+ // CraftBukkit start
-+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), world.worldProvider.n() ? Blocks.AIR : Blocks.WATER).isCancelled()) {
-+ return;
-+ }
-+ // CraftBukkit end
-+
- if (world.worldProvider.n()) {
- world.setAir(blockposition);
- } else {
+ protected void b(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()) {
++ return;
++ }
++ // CraftBukkit end
+ if (world.worldProvider.l()) {
+ world.setAir(blockposition);
+ } else {
diff --git a/nms-patches/BlockLeaves.patch b/nms-patches/BlockLeaves.patch
index ffdc77a1..bb3a479d 100644
--- a/nms-patches/BlockLeaves.patch
+++ b/nms-patches/BlockLeaves.patch
@@ -6,13 +6,13 @@
+import org.bukkit.event.block.LeavesDecayEvent; // CraftBukkit
+
- public abstract class BlockLeaves extends BlockTransparent {
+ public abstract class BlockLeaves extends Block {
public static final BlockStateBoolean DECAYABLE = BlockStateBoolean.of("decayable");
-@@ -130,6 +132,14 @@
+@@ -132,6 +134,14 @@
}
- private void e(World world, BlockPosition blockposition) {
+ 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);
diff --git a/nms-patches/BlockLever.patch b/nms-patches/BlockLever.patch
index c150122f..bded7ed0 100644
--- a/nms-patches/BlockLever.patch
+++ b/nms-patches/BlockLever.patch
@@ -9,7 +9,7 @@
public class BlockLever extends Block {
public static final BlockStateEnum<BlockLever.EnumLeverPosition> FACING = BlockStateEnum.of("facing", BlockLever.EnumLeverPosition.class);
-@@ -155,6 +157,20 @@
+@@ -127,6 +129,20 @@
if (world.isClientSide) {
return true;
} else {
@@ -26,7 +26,7 @@
+ return true;
+ }
+ // CraftBukkit end
-+
- iblockdata = iblockdata.a(BlockLever.POWERED);
++
+ iblockdata = iblockdata.a((IBlockState) BlockLever.POWERED);
world.setTypeAndData(blockposition, iblockdata, 3);
- world.makeSound((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D, "random.click", 0.3F, ((Boolean) iblockdata.get(BlockLever.POWERED)).booleanValue() ? 0.6F : 0.5F);
+ float f3 = ((Boolean) iblockdata.get(BlockLever.POWERED)).booleanValue() ? 0.6F : 0.5F;
diff --git a/nms-patches/BlockMinecartDetector.patch b/nms-patches/BlockMinecartDetector.patch
index 625436fc..56c9cd09 100644
--- a/nms-patches/BlockMinecartDetector.patch
+++ b/nms-patches/BlockMinecartDetector.patch
@@ -1,6 +1,6 @@
--- a/net/minecraft/server/BlockMinecartDetector.java
+++ b/net/minecraft/server/BlockMinecartDetector.java
-@@ -4,6 +4,8 @@
+@@ -5,6 +5,8 @@
import java.util.List;
import java.util.Random;
@@ -9,7 +9,7 @@
public class BlockMinecartDetector extends BlockMinecartTrackAbstract {
public static final BlockStateEnum<BlockMinecartTrackAbstract.EnumTrackPosition> SHAPE = BlockStateEnum.a("shape", BlockMinecartTrackAbstract.EnumTrackPosition.class, new Predicate() {
-@@ -64,6 +66,17 @@
+@@ -65,6 +67,17 @@
flag1 = true;
}
@@ -26,4 +26,4 @@
+
if (flag1 && !flag) {
world.setTypeAndData(blockposition, iblockdata.set(BlockMinecartDetector.POWERED, Boolean.valueOf(true)), 3);
- world.applyPhysics(blockposition, this);
+ this.b(world, blockposition, iblockdata, true);
diff --git a/nms-patches/BlockMinecartTrackAbstract.patch b/nms-patches/BlockMinecartTrackAbstract.patch
index 922347c7..755761e7 100644
--- a/nms-patches/BlockMinecartTrackAbstract.patch
+++ b/nms-patches/BlockMinecartTrackAbstract.patch
@@ -1,11 +1,10 @@
--- a/net/minecraft/server/BlockMinecartTrackAbstract.java
+++ b/net/minecraft/server/BlockMinecartTrackAbstract.java
-@@ -87,7 +87,7 @@
- flag = true;
- }
+@@ -10,6 +10,7 @@
+ protected static final AxisAlignedBB b = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 0.15625D, 1.0D);
+ protected final boolean c;
-- if (flag) {
-+ if (flag && !world.isEmpty(blockposition)) { // CraftBukkit - SPIGOT-424, MC-73474
- this.b(world, blockposition, iblockdata, 0);
- world.setAir(blockposition);
- } else {
++ // PAIL: We stage this entire file just to unsynthetic this method. We should rename and AT it in future
+ public static boolean b(World world, BlockPosition blockposition) {
+ return i(world.getType(blockposition));
+ }
diff --git a/nms-patches/BlockMobSpawner.patch b/nms-patches/BlockMobSpawner.patch
index 870a990c..67c46a90 100644
--- a/nms-patches/BlockMobSpawner.patch
+++ b/nms-patches/BlockMobSpawner.patch
@@ -19,4 +19,4 @@
+ // CraftBukkit end
}
- public boolean c() {
+ public boolean b(IBlockData iblockdata) {
diff --git a/nms-patches/BlockMonsterEggs.patch b/nms-patches/BlockMonsterEggs.patch
index 1a4ae342..ae60b27d 100644
--- a/nms-patches/BlockMonsterEggs.patch
+++ b/nms-patches/BlockMonsterEggs.patch
@@ -15,6 +15,6 @@
entitysilverfish.setPositionRotation((double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, 0.0F, 0.0F);
- world.addEntity(entitysilverfish);
+ world.addEntity(entitysilverfish, SpawnReason.SILVERFISH_BLOCK); // CraftBukkit - add SpawnReason
- entitysilverfish.y();
+ entitysilverfish.doSpawnEffect();
}
diff --git a/nms-patches/BlockMushroom.patch b/nms-patches/BlockMushroom.patch
index 20bdf91a..911f296f 100644
--- a/nms-patches/BlockMushroom.patch
+++ b/nms-patches/BlockMushroom.patch
@@ -12,8 +12,8 @@
+
public class BlockMushroom extends BlockPlant implements IBlockFragilePlantElement {
- protected BlockMushroom() {
-@@ -13,6 +19,7 @@
+ protected static final AxisAlignedBB a = new AxisAlignedBB(0.30000001192092896D, 0.0D, 0.30000001192092896D, 0.699999988079071D, 0.4000000059604645D, 0.699999988079071D);
+@@ -16,6 +22,7 @@
}
public void b(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) {
@@ -21,7 +21,7 @@
if (random.nextInt(25) == 0) {
int i = 5;
boolean flag = true;
-@@ -40,7 +47,19 @@
+@@ -43,7 +50,19 @@
}
if (world.isEmpty(blockposition2) && this.f(world, blockposition2, this.getBlockData())) {
@@ -42,7 +42,7 @@
}
}
-@@ -69,8 +88,10 @@
+@@ -72,8 +91,10 @@
WorldGenHugeMushroom worldgenhugemushroom = null;
if (this == Blocks.BROWN_MUSHROOM) {
diff --git a/nms-patches/BlockMycel.patch b/nms-patches/BlockMycel.patch
index 472975dc..626b81bf 100644
--- a/nms-patches/BlockMycel.patch
+++ b/nms-patches/BlockMycel.patch
@@ -17,10 +17,10 @@
@@ -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()).getBlock().p() > 2) {
+ 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, EnumDirtVariant.DIRT));
++ // 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));
@@ -36,9 +36,9 @@
if (world.getLightLevel(blockposition.up()) >= 9) {
for (int i = 0; i < 4; ++i) {
@@ -31,7 +50,19 @@
- Block block = world.getType(blockposition1.up()).getBlock();
+ IBlockData iblockdata2 = world.getType(blockposition1.up());
- if (iblockdata1.getBlock() == Blocks.DIRT && iblockdata1.get(BlockDirt.VARIANT) == BlockDirt.EnumDirtVariant.DIRT && world.getLightLevel(blockposition1.up()) >= 4 && block.p() <= 2) {
+ 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());
diff --git a/nms-patches/BlockNetherWart.patch b/nms-patches/BlockNetherWart.patch
index 79e98882..1af3f818 100644
--- a/nms-patches/BlockNetherWart.patch
+++ b/nms-patches/BlockNetherWart.patch
@@ -1,6 +1,6 @@
--- a/net/minecraft/server/BlockNetherWart.java
+++ b/net/minecraft/server/BlockNetherWart.java
-@@ -29,7 +29,8 @@
+@@ -31,7 +31,8 @@
if (i < 3 && random.nextInt(10) == 0) {
iblockdata = iblockdata.set(BlockNetherWart.AGE, Integer.valueOf(i + 1));
diff --git a/nms-patches/BlockOre.patch b/nms-patches/BlockOre.patch
index 4522722e..cbe3d905 100644
--- a/nms-patches/BlockOre.patch
+++ b/nms-patches/BlockOre.patch
@@ -8,7 +8,7 @@
if (this.getDropType(iblockdata, world.random, i) != Item.getItemOf(this)) {
int j = 0;
-@@ -54,9 +55,34 @@
+@@ -54,13 +55,42 @@
this.dropExperience(world, blockposition, j);
}
@@ -40,6 +40,14 @@
+ // CraftBukkit end
+ }
+
- public int getDropData(World world, BlockPosition blockposition) {
- return 0;
+ public ItemStack a(World world, BlockPosition blockposition, IBlockData iblockdata) {
+ return new ItemStack(this);
+ }
+
++ public int getDropData(World world, BlockPosition blockposition) {
++ return 0;
++ }
++
+ public int getDropData(IBlockData iblockdata) {
+ return this == Blocks.LAPIS_ORE ? EnumColor.BLUE.getInvColorIndex() : 0;
}
diff --git a/nms-patches/BlockPiston.patch b/nms-patches/BlockPiston.patch
index b19bcf46..58de3a2e 100644
--- a/nms-patches/BlockPiston.patch
+++ b/nms-patches/BlockPiston.patch
@@ -1,7 +1,7 @@
--- a/net/minecraft/server/BlockPiston.java
+++ b/net/minecraft/server/BlockPiston.java
-@@ -2,6 +2,18 @@
-
+@@ -4,6 +4,18 @@
+ import java.util.ArrayList;
import java.util.List;
+// CraftBukkit start
@@ -16,10 +16,10 @@
+import org.bukkit.event.block.BlockPistonExtendEvent;
+// CraftBukkit end
+
- public class BlockPiston extends Block {
+ public class BlockPiston extends BlockDirectional {
- public static final BlockStateDirection FACING = BlockStateDirection.of("facing");
-@@ -56,6 +68,17 @@
+ public static final BlockStateBoolean EXTENDED = BlockStateBoolean.of("extended");
+@@ -98,6 +110,18 @@
world.playBlockAction(blockposition, this, 0, enumdirection.a());
}
} else if (!flag && ((Boolean) iblockdata.get(BlockPiston.EXTENDED)).booleanValue()) {
@@ -33,23 +33,24 @@
+ return;
+ }
+ }
++ // PAIL: checkME - what happened to setTypeAndData?
+ // CraftBukkit end
- world.setTypeAndData(blockposition, iblockdata.set(BlockPiston.EXTENDED, Boolean.valueOf(false)), 2);
world.playBlockAction(blockposition, this, 1, enumdirection.a());
}
-@@ -146,7 +169,7 @@
+
+@@ -188,7 +212,7 @@
}
}
-- if (!flag1 && block.getMaterial() != Material.AIR && a(block, world, blockposition1, enumdirection.opposite(), false) && (block.k() == 0 || block == Blocks.PISTON || block == Blocks.STICKY_PISTON)) {
-+ if (!flag1 && a(block, world, blockposition1, enumdirection.opposite(), false) && (block.k() == 0 || block == Blocks.PISTON || block == Blocks.STICKY_PISTON)) { // CraftBukkit - remove 'block.getMaterial() != Material.AIR' condition
+- if (!flag1 && iblockdata1.getMaterial() != Material.AIR && a(iblockdata1, world, blockposition1, enumdirection.opposite(), false) && (iblockdata1.o() == EnumPistonReaction.NORMAL || block == Blocks.PISTON || block == Blocks.STICKY_PISTON)) {
++ if (!flag1 && a(iblockdata1, world, blockposition1, enumdirection.opposite(), false) && (iblockdata1.o() == EnumPistonReaction.NORMAL || block == Blocks.PISTON || block == Blocks.STICKY_PISTON)) { // CraftBukkit - remove 'block.getMaterial() != Material.AIR' condition
this.a(world, blockposition, enumdirection, false);
}
} else {
-@@ -286,10 +309,53 @@
- if (!pistonextendschecker.a()) {
- return false;
- } else {
+@@ -284,6 +308,48 @@
+ int j = list.size() + list1.size();
+ IBlockData[] aiblockdata = new IBlockData[j];
+ EnumDirection enumdirection1 = flag ? enumdirection : enumdirection.opposite();
+ // CraftBukkit start
+ final org.bukkit.block.Block bblock = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
+
@@ -72,11 +73,6 @@
+ return bblock.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ());
+ }
+ };
-+
- int i = list.size() + list1.size();
- Block[] ablock = new Block[i];
- EnumDirection enumdirection1 = flag ? enumdirection : enumdirection.opposite();
-
+ org.bukkit.event.block.BlockPistonEvent event;
+ if (flag) {
+ event = new BlockPistonExtendEvent(bblock, blocks, CraftBlock.notchToBlockFace(enumdirection1));
@@ -87,16 +83,16 @@
+
+ if (event.isCancelled()) {
+ for (BlockPosition b : broken) {
-+ world.notify(b);
++ world.notify(b, Blocks.AIR.getBlockData(), world.getType(b), 3);
+ }
+ for (BlockPosition b : moved) {
-+ world.notify(b);
-+ world.notify(b.shift(enumdirection1));
++ world.notify(b, Blocks.AIR.getBlockData(), world.getType(b), 3);
++ b = b.shift(enumdirection1);
++ world.notify(b, Blocks.AIR.getBlockData(), world.getType(b), 3);
+ }
+ return false;
+ }
+ // CraftBukkit end
-+
- int j;
- BlockPosition blockposition1;
+ int k;
+ BlockPosition blockposition2;
diff --git a/nms-patches/BlockPlant.patch b/nms-patches/BlockPlant.patch
index 29fb3af8..7e62b1ff 100644
--- a/nms-patches/BlockPlant.patch
+++ b/nms-patches/BlockPlant.patch
@@ -11,7 +11,7 @@
public class BlockPlant extends Block {
-@@ -40,6 +44,15 @@
+@@ -39,6 +43,15 @@
protected void e(World world, BlockPosition blockposition, IBlockData iblockdata) {
if (!this.f(world, blockposition, iblockdata)) {
diff --git a/nms-patches/BlockPortal.patch b/nms-patches/BlockPortal.patch
index d3d3a650..3ac6f992 100644
--- a/nms-patches/BlockPortal.patch
+++ b/nms-patches/BlockPortal.patch
@@ -10,17 +10,17 @@
public class BlockPortal extends BlockHalfTransparent {
public static final BlockStateEnum<EnumDirection.EnumAxis> AXIS = BlockStateEnum.of("axis", EnumDirection.EnumAxis.class, new EnumDirection.EnumAxis[] { EnumDirection.EnumAxis.X, EnumDirection.EnumAxis.Z});
-@@ -25,7 +28,8 @@
+@@ -42,7 +45,8 @@
}
- if (i > 0 && !world.getType(blockposition1.up()).getBlock().isOccluding()) {
-- Entity entity = ItemMonsterEgg.a(world, 57, (double) blockposition1.getX() + 0.5D, (double) blockposition1.getY() + 1.1D, (double) blockposition1.getZ() + 0.5D);
+ 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);
+ // CraftBukkit - set spawn reason to NETHER_PORTAL
-+ Entity entity = ItemMonsterEgg.spawnCreature(world, 57, (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 = 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);
if (entity != null) {
- entity.portalCooldown = entity.aq();
-@@ -67,14 +71,16 @@
+ entity.portalCooldown = entity.aC();
+@@ -68,14 +72,16 @@
BlockPortal.Shape blockportal_shape = new BlockPortal.Shape(world, blockposition, EnumDirection.EnumAxis.X);
if (blockportal_shape.d() && blockportal_shape.e == 0) {
@@ -41,18 +41,18 @@
} else {
return false;
}
-@@ -105,6 +111,10 @@
+@@ -106,6 +112,10 @@
public void a(World world, BlockPosition blockposition, IBlockData iblockdata, Entity entity) {
- if (entity.vehicle == null && entity.passenger == null) {
+ if (!entity.isPassenger() && !entity.isVehicle() && entity.aV()) {
+ // 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.d(blockposition);
+ entity.e(blockposition);
}
-@@ -185,6 +195,7 @@
+@@ -251,6 +261,7 @@
private BlockPosition position;
private int height;
private int width;
@@ -60,7 +60,7 @@
public Shape(World world, BlockPosition blockposition, EnumDirection.EnumAxis enumdirection_enumaxis) {
this.a = world;
-@@ -243,6 +254,10 @@
+@@ -309,6 +320,10 @@
}
protected int c() {
@@ -71,7 +71,7 @@
int i;
label56:
-@@ -263,11 +278,21 @@
+@@ -329,11 +344,21 @@
block = this.a.getType(blockposition.shift(this.d)).getBlock();
if (block != Blocks.OBSIDIAN) {
break label56;
@@ -93,7 +93,7 @@
}
}
}
-@@ -277,6 +302,11 @@
+@@ -343,6 +368,11 @@
if (this.a.getType(this.position.shift(this.c, i).up(this.height)).getBlock() != Blocks.OBSIDIAN) {
this.height = 0;
break;
@@ -105,7 +105,7 @@
}
}
-@@ -298,7 +328,27 @@
+@@ -364,7 +394,27 @@
return this.position != null && this.width >= 2 && this.width <= 21 && this.height >= 3 && this.height <= 21;
}
@@ -134,7 +134,7 @@
for (int i = 0; i < this.width; ++i) {
BlockPosition blockposition = this.position.shift(this.c, i);
-@@ -307,6 +357,7 @@
+@@ -373,6 +423,7 @@
}
}
diff --git a/nms-patches/BlockPressurePlateAbstract.patch b/nms-patches/BlockPressurePlateAbstract.patch
index 1260c22b..58ff2ff6 100644
--- a/nms-patches/BlockPressurePlateAbstract.patch
+++ b/nms-patches/BlockPressurePlateAbstract.patch
@@ -8,8 +8,8 @@
+
public abstract class BlockPressurePlateAbstract extends Block {
- protected BlockPressurePlateAbstract(Material material) {
-@@ -99,6 +101,19 @@
+ protected static final AxisAlignedBB a = new AxisAlignedBB(0.0625D, 0.0D, 0.0625D, 0.9375D, 0.03125D, 0.9375D);
+@@ -93,6 +95,19 @@
boolean flag = i > 0;
boolean flag1 = j > 0;
diff --git a/nms-patches/BlockPressurePlateBinary.patch b/nms-patches/BlockPressurePlateBinary.patch
index 37a87c15..c0855968 100644
--- a/nms-patches/BlockPressurePlateBinary.patch
+++ b/nms-patches/BlockPressurePlateBinary.patch
@@ -9,12 +9,12 @@
public class BlockPressurePlateBinary extends BlockPressurePlateAbstract {
public static final BlockStateBoolean POWERED = BlockStateBoolean.of("powered");
-@@ -45,6 +47,26 @@
+@@ -63,6 +65,26 @@
while (iterator.hasNext()) {
Entity entity = (Entity) iterator.next();
+ // CraftBukkit start - Call interact event when turning on a pressure plate
-+ if (this.e(world.getType(blockposition)) == 0) {
++ if (this.getPower(world.getType(blockposition)) == 0) {
+ org.bukkit.World bworld = world.getWorld();
+ org.bukkit.plugin.PluginManager manager = world.getServer().getPluginManager();
+ org.bukkit.event.Cancellable cancellable;
@@ -33,6 +33,6 @@
+ }
+ // CraftBukkit end
+
- if (!entity.aI()) {
+ if (!entity.isIgnoreBlockTrigger()) {
return 15;
}
diff --git a/nms-patches/BlockPressurePlateWeighted.patch b/nms-patches/BlockPressurePlateWeighted.patch
index 4b1f6e2d..2f044428 100644
--- a/nms-patches/BlockPressurePlateWeighted.patch
+++ b/nms-patches/BlockPressurePlateWeighted.patch
@@ -11,12 +11,12 @@
@@ -16,7 +18,31 @@
}
- protected int f(World world, BlockPosition blockposition) {
-- int i = Math.min(world.a(Entity.class, this.getBoundingBox(blockposition)).size(), this.weight);
+ protected int e(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, this.a(blockposition)).size(), this.b);
++ // int i = Math.min(world.a(Entity.class, BlockPressurePlateWeighted.c.a(blockposition)).size(), this.weight);
+ int i = 0;
-+ java.util.Iterator iterator = world.a(Entity.class, this.getBoundingBox(blockposition)).iterator();
++ java.util.Iterator iterator = world.a(Entity.class, BlockPressurePlateWeighted.c.a(blockposition)).iterator();
+
+ while (iterator.hasNext()) {
+ Entity entity = (Entity) iterator.next();
diff --git a/nms-patches/BlockPumpkin.patch b/nms-patches/BlockPumpkin.patch
index 224b1e9d..4ddb2b1b 100644
--- a/nms-patches/BlockPumpkin.patch
+++ b/nms-patches/BlockPumpkin.patch
@@ -10,7 +10,7 @@
+import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
+// CraftBukkit end
+
- public class BlockPumpkin extends BlockDirectional {
+ public class BlockPumpkin extends BlockFacingHorizontal {
private ShapeDetector snowGolemPart;
@@ -40,17 +46,24 @@
diff --git a/nms-patches/BlockRedstoneOre.patch b/nms-patches/BlockRedstoneOre.patch
index f9614c75..2a4c70e2 100644
--- a/nms-patches/BlockRedstoneOre.patch
+++ b/nms-patches/BlockRedstoneOre.patch
@@ -12,47 +12,49 @@
public class BlockRedstoneOre extends Block {
private final boolean a;
-@@ -20,23 +25,44 @@
+@@ -20,23 +25,46 @@
}
public void attack(World world, BlockPosition blockposition, EntityHuman entityhuman) {
-- this.e(world, blockposition);
-+ this.e(world, blockposition, entityhuman); // CraftBukkit - add entityhuman
+- this.interact(world, blockposition);
++ this.interact(world, blockposition, entityhuman); // CraftBukkit - add entityhuman
super.attack(world, blockposition, entityhuman);
}
- public void a(World world, BlockPosition blockposition, Entity entity) {
-- this.e(world, blockposition);
-- super.a(world, blockposition, entity);
+ public void stepOn(World world, BlockPosition blockposition, Entity entity) {
+- this.interact(world, blockposition);
+- super.stepOn(world, blockposition, entity);
+ // CraftBukkit start
-+ // this.e(world, blockposition);
-+ // super.a(world, blockposition, entity);
++ // PAIL: Rename this method
++ // this.interact(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);
+ if (!event.isCancelled()) {
-+ this.e(world, blockposition, entity); // add entity
-+ super.a(world, blockposition, entity);
++ this.interact(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.e(world, blockposition, entity); // add entity
-+ super.a(world, blockposition, entity);
++ this.interact(world, blockposition, entity); // add entity
++ super.stepOn(world, blockposition, entity);
+ }
+ }
+ // CraftBukkit end
}
- public boolean interact(World world, BlockPosition blockposition, IBlockData iblockdata, EntityHuman entityhuman, EnumDirection enumdirection, float f, float f1, float f2) {
-- this.e(world, blockposition);
-+ this.e(world, blockposition, entityhuman); // CraftBukkit - add entityhuman
- return super.interact(world, blockposition, iblockdata, entityhuman, enumdirection, f, f1, f2);
++
+ public boolean interact(World world, BlockPosition blockposition, IBlockData iblockdata, EntityHuman entityhuman, EnumHand enumhand, ItemStack itemstack, EnumDirection enumdirection, float f, float f1, float f2) {
+- this.interact(world, blockposition);
++ this.interact(world, blockposition, entityhuman); // CraftBukkit - add entityhuman
+ return super.interact(world, blockposition, iblockdata, entityhuman, enumhand, itemstack, enumdirection, f, f1, f2);
}
-- private void e(World world, BlockPosition blockposition) {
-+ private void e(World world, BlockPosition blockposition, Entity entity) { // CraftBukkit - add Entity
- this.f(world, blockposition);
+- 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) {
+ // CraftBukkit start
+ if (CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition.getX(), blockposition.getY(), blockposition.getZ(), Blocks.LIT_REDSTONE_ORE, 0).isCancelled()) {
@@ -62,7 +64,7 @@
world.setTypeUpdate(blockposition, Blocks.LIT_REDSTONE_ORE.getBlockData());
}
-@@ -44,6 +70,11 @@
+@@ -44,6 +72,11 @@
public void b(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) {
if (this == Blocks.LIT_REDSTONE_ORE) {
@@ -74,7 +76,7 @@
world.setTypeUpdate(blockposition, Blocks.REDSTONE_ORE.getBlockData());
}
-@@ -63,12 +94,24 @@
+@@ -63,12 +96,24 @@
public void dropNaturally(World world, BlockPosition blockposition, IBlockData iblockdata, float f, int i) {
super.dropNaturally(world, blockposition, iblockdata, f, i);
@@ -98,4 +100,4 @@
+ // CraftBukkit end
}
- private void f(World world, BlockPosition blockposition) {
+ private void playEffect(World world, BlockPosition blockposition) {
diff --git a/nms-patches/BlockRedstoneTorch.patch b/nms-patches/BlockRedstoneTorch.patch
index 2eea0e70..03c40f3c 100644
--- a/nms-patches/BlockRedstoneTorch.patch
+++ b/nms-patches/BlockRedstoneTorch.patch
@@ -8,16 +8,16 @@
+
public class BlockRedstoneTorch extends BlockTorch {
- private static Map<World, List<BlockRedstoneTorch.RedstoneUpdateInfo>> b = Maps.newHashMap();
+ private static Map<World, List<BlockRedstoneTorch.RedstoneUpdateInfo>> g = Maps.newHashMap();
@@ -13,7 +15,7 @@
private boolean a(World world, BlockPosition blockposition, boolean flag) {
- if (!BlockRedstoneTorch.b.containsKey(world)) {
-- BlockRedstoneTorch.b.put(world, Lists.newArrayList());
-+ BlockRedstoneTorch.b.put(world, Lists.<BlockRedstoneTorch.RedstoneUpdateInfo>newArrayList()); // CraftBukkit - fix decompile error
+ 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.b.get(world);
+ List list = (List) BlockRedstoneTorch.g.get(world);
@@ -96,8 +98,25 @@
list.remove(0);
}
@@ -43,7 +43,7 @@
+ // 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.makeSound((double) ((float) blockposition.getX() + 0.5F), (double) ((float) blockposition.getY() + 0.5F), (double) ((float) blockposition.getZ() + 0.5F), "random.fizz", 0.5F, 2.6F + (world.random.nextFloat() - world.random.nextFloat()) * 0.8F);
+ world.a((EntityHuman) null, blockposition, SoundEffects.eF, SoundCategory.BLOCKS, 0.5F, 2.6F + (world.random.nextFloat() - world.random.nextFloat()) * 0.8F);
@@ -114,6 +133,15 @@
}
}
diff --git a/nms-patches/BlockRedstoneWire.patch b/nms-patches/BlockRedstoneWire.patch
index ffd86e1d..18fdea9d 100644
--- a/nms-patches/BlockRedstoneWire.patch
+++ b/nms-patches/BlockRedstoneWire.patch
@@ -9,7 +9,7 @@
public class BlockRedstoneWire extends Block {
public static final BlockStateEnum<BlockRedstoneWire.EnumRedstoneWireConnection> NORTH = BlockStateEnum.of("north", BlockRedstoneWire.EnumRedstoneWireConnection.class);
-@@ -124,6 +126,15 @@
+@@ -166,6 +168,15 @@
j = k;
}
diff --git a/nms-patches/BlockReed.patch b/nms-patches/BlockReed.patch
index 6b9939e5..de1b755b 100644
--- a/nms-patches/BlockReed.patch
+++ b/nms-patches/BlockReed.patch
@@ -1,6 +1,6 @@
--- a/net/minecraft/server/BlockReed.java
+++ b/net/minecraft/server/BlockReed.java
-@@ -29,8 +29,12 @@
+@@ -31,8 +31,12 @@
int j = ((Integer) iblockdata.get(BlockReed.AGE)).intValue();
if (j == 15) {
diff --git a/nms-patches/BlockSapling.patch b/nms-patches/BlockSapling.patch
index bdb4074f..16b6d0cd 100644
--- a/nms-patches/BlockSapling.patch
+++ b/nms-patches/BlockSapling.patch
@@ -1,6 +1,6 @@
--- a/net/minecraft/server/BlockSapling.java
+++ b/net/minecraft/server/BlockSapling.java
-@@ -2,10 +2,20 @@
+@@ -2,11 +2,21 @@
import java.util.Random;
@@ -17,11 +17,12 @@
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 TreeType treeType; // CraftBukkit
protected BlockSapling() {
- this.j(this.blockStateList.getBlockData().set(BlockSapling.TYPE, BlockWood.EnumLogVariant.OAK).set(BlockSapling.STAGE, Integer.valueOf(0)));
-@@ -23,7 +33,30 @@
+ 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) {
@@ -52,10 +53,10 @@
}
}
-@@ -39,7 +72,17 @@
+@@ -41,7 +74,17 @@
}
- public void e(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) {
+ 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);
@@ -71,7 +72,7 @@
int i = 0;
int j = 0;
boolean flag = false;
-@@ -51,6 +94,7 @@
+@@ -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)) {
@@ -79,7 +80,7 @@
object = new WorldGenMegaTree(false, random.nextBoolean());
flag = true;
break label66;
-@@ -61,11 +105,13 @@
+@@ -63,11 +107,13 @@
if (!flag) {
j = 0;
i = 0;
@@ -93,7 +94,7 @@
object = new WorldGenForest(true, false);
break;
-@@ -77,6 +123,7 @@
+@@ -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)) {
@@ -101,7 +102,7 @@
object = new WorldGenJungleTree(true, 10, 20, iblockdata1, iblockdata2);
flag = true;
break label78;
-@@ -87,11 +134,13 @@
+@@ -89,11 +136,13 @@
if (!flag) {
j = 0;
i = 0;
@@ -115,7 +116,7 @@
object = new WorldGenAcaciaTree(true);
break;
-@@ -100,6 +149,7 @@
+@@ -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)) {
diff --git a/nms-patches/BlockSkull.patch b/nms-patches/BlockSkull.patch
index 84c1dc2a..914d423d 100644
--- a/nms-patches/BlockSkull.patch
+++ b/nms-patches/BlockSkull.patch
@@ -9,20 +9,20 @@
+import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
+// CraftBukkit end
+
- public class BlockSkull extends BlockContainer {
+ public class BlockSkull extends BlockTileEntity {
- public static final BlockStateDirection FACING = BlockStateDirection.of("facing");
-@@ -81,8 +86,26 @@
-
- return tileentity instanceof TileEntitySkull ? ((TileEntitySkull) tileentity).getSkullType() : super.getDropData(world, blockposition);
+ public static final BlockStateDirection FACING = BlockDirectional.FACING;
+@@ -81,7 +86,25 @@
+ 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) {
-+ ItemStack itemstack = new ItemStack(Items.SKULL, 1, this.getDropData(world, blockposition));
+ TileEntitySkull tileentityskull = (TileEntitySkull) world.getTileEntity(blockposition);
++ ItemStack itemstack = this.a(world, blockposition, iblockdata);
+
+ if (tileentityskull.getSkullType() == 3 && tileentityskull.getGameProfile() != null) {
+ itemstack.setTag(new NBTTagCompound());
@@ -31,8 +31,7 @@
+ GameProfileSerializer.serialize(nbttagcompound, tileentityskull.getGameProfile());
+ itemstack.getTag().set("SkullOwner", nbttagcompound);
+ }
-
-- public void dropNaturally(World world, BlockPosition blockposition, IBlockData iblockdata, float f, int i) {}
++
+ a(world, blockposition, itemstack);
+ }
+ }
@@ -40,7 +39,7 @@
public void a(World world, BlockPosition blockposition, IBlockData iblockdata, EntityHuman entityhuman) {
if (entityhuman.abilities.canInstantlyBuild) {
-@@ -95,7 +118,10 @@
+@@ -94,7 +117,10 @@
public void remove(World world, BlockPosition blockposition, IBlockData iblockdata) {
if (!world.isClientSide) {
@@ -52,13 +51,13 @@
TileEntity tileentity = world.getTileEntity(blockposition);
if (tileentity instanceof TileEntitySkull) {
-@@ -127,24 +153,36 @@
+@@ -126,24 +152,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.n();
+ ShapeDetector shapedetector = this.g();
ShapeDetector.ShapeDetectorCollection shapedetector_shapedetectorcollection = shapedetector.a(world, blockposition);
if (shapedetector_shapedetectorcollection != null) {
@@ -91,14 +90,14 @@
}
}
-@@ -157,14 +195,16 @@
- entitywither.n();
- Iterator iterator = world.a(EntityHuman.class, entitywither.getBoundingBox().grow(50.0D, 50.0D, 50.0D)).iterator();
+@@ -156,14 +194,16 @@
+ entitywither.o();
+ Iterator iterator = world.a(EntityHuman.class, entitywither.getBoundingBox().g(50.0D)).iterator();
+ // CraftBukkit start
+ if (world.addEntity(entitywither, SpawnReason.BUILD_WITHER)) {
+ blockList.updateList();
-+
++
while (iterator.hasNext()) {
EntityHuman entityhuman = (EntityHuman) iterator.next();
@@ -110,7 +109,7 @@
int k;
for (k = 0; k < 120; ++k) {
-@@ -178,6 +218,7 @@
+@@ -177,6 +217,7 @@
world.update(shapedetectorblock2.getPosition(), Blocks.AIR);
}
}
diff --git a/nms-patches/BlockSnow.patch b/nms-patches/BlockSnow.patch
index 19b864af..bbe41c9d 100644
--- a/nms-patches/BlockSnow.patch
+++ b/nms-patches/BlockSnow.patch
@@ -1,6 +1,6 @@
--- a/net/minecraft/server/BlockSnow.java
+++ b/net/minecraft/server/BlockSnow.java
-@@ -85,6 +85,11 @@
+@@ -79,6 +79,11 @@
public void b(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) {
if (world.b(EnumSkyBlock.BLOCK, blockposition) > 11) {
diff --git a/nms-patches/BlockSoil.patch b/nms-patches/BlockSoil.patch
index 6490edd3..51b19199 100644
--- a/nms-patches/BlockSoil.patch
+++ b/nms-patches/BlockSoil.patch
@@ -12,10 +12,10 @@
public class BlockSoil extends Block {
public static final BlockStateInteger MOISTURE = BlockStateInteger.of("moisture", 0, 7);
-@@ -34,6 +39,12 @@
+@@ -38,6 +43,12 @@
if (i > 0) {
world.setTypeAndData(blockposition, iblockdata.set(BlockSoil.MOISTURE, Integer.valueOf(i - 1)), 2);
- } else if (!this.e(world, blockposition)) {
+ } else if (!this.b(world, blockposition)) {
+ // CraftBukkit start
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
+ if (CraftEventFactory.callBlockFadeEvent(block, Blocks.DIRT).isCancelled()) {
@@ -25,40 +25,36 @@
world.setTypeUpdate(blockposition, Blocks.DIRT.getBlockData());
}
} else if (i < 7) {
-@@ -43,16 +54,35 @@
+@@ -47,11 +58,31 @@
}
public void fallOn(World world, BlockPosition blockposition, Entity entity, float f) {
+ super.fallOn(world, blockposition, entity, f); // CraftBukkit - moved here as game rules / events shouldn't affect fall damage.
- if (entity instanceof EntityLiving) {
- if (!world.isClientSide && world.random.nextFloat() < f - 0.5F) {
- if (!(entity instanceof EntityHuman) && !world.getGameRules().getBoolean("mobGriefing")) {
- return;
- }
-
-+ // CraftBukkit start - Interact soil
-+ org.bukkit.event.Cancellable cancellable;
-+ if (entity instanceof EntityHuman) {
-+ cancellable = CraftEventFactory.callPlayerInteractEvent((EntityHuman) entity, org.bukkit.event.block.Action.PHYSICAL, blockposition, null, null);
-+ } else {
-+ cancellable = new EntityInteractEvent(entity.getBukkitEntity(), world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()));
-+ world.getServer().getPluginManager().callEvent((EntityInteractEvent) cancellable);
-+ }
+ if (!world.isClientSide && world.random.nextFloat() < f - 0.5F && entity instanceof EntityLiving && (entity instanceof EntityHuman || world.getGameRules().getBoolean("mobGriefing")) && entity.width * entity.width * entity.length > 0.512F) {
+
-+ if (cancellable.isCancelled()) {
-+ return;
-+ }
++ // CraftBukkit start - Interact soil
++ org.bukkit.event.Cancellable cancellable;
++ if (entity instanceof EntityHuman) {
++ cancellable = CraftEventFactory.callPlayerInteractEvent((EntityHuman) entity, org.bukkit.event.block.Action.PHYSICAL, blockposition, null, null);
++ } else {
++ cancellable = new EntityInteractEvent(entity.getBukkitEntity(), world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()));
++ world.getServer().getPluginManager().callEvent((EntityInteractEvent) cancellable);
++ }
+
-+ if (CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition.getX(), blockposition.getY(), blockposition.getZ(), Blocks.DIRT, 0).isCancelled()) {
-+ return;
-+ }
-+ // CraftBukkit end
++ if (cancellable.isCancelled()) {
++ return;
++ }
+
- world.setTypeUpdate(blockposition, Blocks.DIRT.getBlockData());
- }
-
-- super.fallOn(world, blockposition, entity, f);
-+ // super.fallOn(world, blockposition, entity, f); // CraftBukkit - moved up
++ if (CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition.getX(), blockposition.getY(), blockposition.getZ(), Blocks.DIRT, 0).isCancelled()) {
++ return;
++ }
++ // CraftBukkit end
++
+ world.setTypeUpdate(blockposition, Blocks.DIRT.getBlockData());
}
+
+- super.fallOn(world, blockposition, entity, f);
++ // super.fallOn(world, blockposition, entity, f); // CraftBukkit - moved up
}
+ private boolean b(World world, BlockPosition blockposition) {
diff --git a/nms-patches/BlockStationary.patch b/nms-patches/BlockStationary.patch
index f58767ba..4f9bbe20 100644
--- a/nms-patches/BlockStationary.patch
+++ b/nms-patches/BlockStationary.patch
@@ -9,10 +9,10 @@
public class BlockStationary extends BlockFluids {
protected BlockStationary(Material material) {
-@@ -41,6 +43,13 @@
+@@ -45,6 +47,13 @@
if (block.material == Material.AIR) {
- if (this.f(world, blockposition1)) {
+ 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()) {
@@ -23,10 +23,12 @@
world.setTypeUpdate(blockposition1, Blocks.FIRE.getBlockData());
return;
}
-@@ -53,6 +62,14 @@
- BlockPosition blockposition2 = blockposition.a(random.nextInt(3) - 1, 0, random.nextInt(3) - 1);
+@@ -60,7 +69,16 @@
+ return;
+ }
- if (world.isEmpty(blockposition2.up()) && this.m(world, blockposition2)) {
++ // PAIL: rename
+ 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) {
diff --git a/nms-patches/BlockStem.patch b/nms-patches/BlockStem.patch
index df06ccfb..0fab7bdb 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.Iterator;
import java.util.Random;
@@ -9,7 +9,7 @@
public class BlockStem extends BlockPlant implements IBlockFragilePlantElement {
public static final BlockStateInteger AGE = BlockStateInteger.of("age", 0, 7);
-@@ -58,7 +60,8 @@
+@@ -53,7 +55,8 @@
if (i < 7) {
iblockdata = iblockdata.set(BlockStem.AGE, Integer.valueOf(i + 1));
@@ -19,7 +19,7 @@
} else {
Iterator iterator = EnumDirection.EnumDirectionLimit.HORIZONTAL.iterator();
-@@ -74,7 +77,8 @@
+@@ -69,7 +72,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)) {
@@ -29,7 +29,7 @@
}
}
}
-@@ -85,7 +89,8 @@
+@@ -80,7 +84,8 @@
public void g(World world, BlockPosition blockposition, IBlockData iblockdata) {
int i = ((Integer) iblockdata.get(BlockStem.AGE)).intValue() + MathHelper.nextInt(world.random, 2, 5);
@@ -38,4 +38,4 @@
+ CraftEventFactory.handleBlockGrowEvent(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this, Math.min(7, i)); // CraftBukkit
}
- public void j() {
+ public void dropNaturally(World world, BlockPosition blockposition, IBlockData iblockdata, float f, int i) {
diff --git a/nms-patches/BlockTrapdoor.patch b/nms-patches/BlockTrapdoor.patch
index 595644f3..90372d08 100644
--- a/nms-patches/BlockTrapdoor.patch
+++ b/nms-patches/BlockTrapdoor.patch
@@ -1,31 +1,30 @@
--- a/net/minecraft/server/BlockTrapdoor.java
+++ b/net/minecraft/server/BlockTrapdoor.java
-@@ -2,6 +2,8 @@
-
- import com.google.common.base.Predicate;
+@@ -1,5 +1,7 @@
+ package net.minecraft.server;
+import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
+
public class BlockTrapdoor extends Block {
- public static final BlockStateDirection FACING = BlockStateDirection.of("facing", (Predicate) EnumDirection.EnumDirectionLimit.HORIZONTAL);
-@@ -101,6 +103,19 @@
- boolean flag = world.isBlockIndirectlyPowered(blockposition);
+ public static final BlockStateDirection FACING = BlockFacingHorizontal.FACING;
+@@ -92,6 +94,19 @@
+ boolean flag = world.isBlockIndirectlyPowered(blockposition);
- if (flag || block.isPowerSource()) {
-+ // CraftBukkit start
-+ org.bukkit.World bworld = world.getWorld();
-+ org.bukkit.block.Block bblock = bworld.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
+ if (flag || block.getBlockData().m()) {
++ // CraftBukkit start
++ org.bukkit.World bworld = world.getWorld();
++ org.bukkit.block.Block bblock = bworld.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
+
-+ int power = bblock.getBlockPower();
-+ int oldPower = (Boolean) iblockdata.get(OPEN) ? 15 : 0;
++ int power = bblock.getBlockPower();
++ int oldPower = (Boolean) iblockdata.get(OPEN) ? 15 : 0;
+
-+ if (oldPower == 0 ^ power == 0 || block.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 (oldPower == 0 ^ power == 0 || block.getBlockData().n()) {
++ 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 (flag1 != flag) {
diff --git a/nms-patches/BlockTripwire.patch b/nms-patches/BlockTripwire.patch
index 524e1a79..22f5e313 100644
--- a/nms-patches/BlockTripwire.patch
+++ b/nms-patches/BlockTripwire.patch
@@ -9,7 +9,7 @@
public class BlockTripwire extends Block {
public static final BlockStateBoolean POWERED = BlockStateBoolean.of("powered");
-@@ -155,6 +157,40 @@
+@@ -136,6 +138,40 @@
}
}
diff --git a/nms-patches/BlockTripwireHook.patch b/nms-patches/BlockTripwireHook.patch
index d67644aa..16cb8927 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.Iterator;
import java.util.Random;
@@ -8,9 +8,9 @@
+
public class BlockTripwireHook extends Block {
- public static final BlockStateDirection FACING = BlockStateDirection.of("facing", (Predicate) EnumDirection.EnumDirectionLimit.HORIZONTAL);
-@@ -141,6 +143,17 @@
- this.a(world, blockposition1, flag5, flag6, flag2, flag3);
+ public static final BlockStateDirection FACING = BlockFacingHorizontal.FACING;
+@@ -153,6 +155,17 @@
+ this.a(world, blockposition1, flag4, flag5, flag2, flag3);
}
+ // CraftBukkit start
@@ -24,6 +24,6 @@
+ }
+ // CraftBukkit end
+
- this.a(world, blockposition, flag5, flag6, flag2, flag3);
+ this.a(world, blockposition, flag4, flag5, flag2, flag3);
if (!flag) {
world.setTypeAndData(blockposition, iblockdata3.set(BlockTripwireHook.FACING, enumdirection), 3);
diff --git a/nms-patches/BlockVine.patch b/nms-patches/BlockVine.patch
index e377c249..b0455671 100644
--- a/nms-patches/BlockVine.patch
+++ b/nms-patches/BlockVine.patch
@@ -9,7 +9,7 @@
public class BlockVine extends Block {
public static final BlockStateBoolean UP = BlockStateBoolean.of("up");
-@@ -200,7 +202,13 @@
+@@ -172,7 +174,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()) {
@@ -24,42 +24,42 @@
}
}
-@@ -220,17 +228,29 @@
- BlockPosition blockposition3 = blockposition2.shift(enumdirection1);
- BlockPosition blockposition4 = blockposition2.shift(enumdirection2);
+@@ -194,17 +202,29 @@
+ BlockPosition blockposition3 = blockposition2.shift(enumdirection2);
+ BlockPosition blockposition4 = blockposition2.shift(enumdirection3);
+ // 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());
+
- if (flag1 && this.c(world.getType(blockposition3).getBlock())) {
-- world.setTypeAndData(blockposition2, this.getBlockData().set(getDirection(enumdirection1), Boolean.valueOf(true)), 2);
-+ // world.setTypeAndData(blockposition2, this.getBlockData().set(a(enumdirection1), Boolean.valueOf(true)), 2);
-+ CraftEventFactory.handleBlockSpreadEvent(bukkitBlock, source, this, toLegacyData(this.getBlockData().set(getDirection(enumdirection1), Boolean.valueOf(true))));
- } else if (flag2 && this.c(world.getType(blockposition4).getBlock())) {
+ if (flag1 && this.x(world.getType(blockposition3))) {
- world.setTypeAndData(blockposition2, this.getBlockData().set(getDirection(enumdirection2), Boolean.valueOf(true)), 2);
-+ // world.setTypeAndData(blockposition2, this.getBlockData().set(a(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 (flag1 && world.isEmpty(blockposition3) && this.c(world.getType(blockposition.shift(enumdirection1)).getBlock())) {
+ } else if (flag2 && this.x(world.getType(blockposition4))) {
+- world.setTypeAndData(blockposition2, this.getBlockData().set(getDirection(enumdirection3), Boolean.valueOf(true)), 2);
++ // world.setTypeAndData(blockposition2, this.getBlockData().set(getDirection(enumdirection3), Boolean.valueOf(true)), 2);
++ CraftEventFactory.handleBlockSpreadEvent(bukkitBlock, source, this, toLegacyData(this.getBlockData().set(getDirection(enumdirection3), Boolean.valueOf(true))));
+ } else if (flag1 && world.isEmpty(blockposition3) && this.x(world.getType(blockposition.shift(enumdirection2)))) {
- world.setTypeAndData(blockposition3, this.getBlockData().set(getDirection(enumdirection.opposite()), Boolean.valueOf(true)), 2);
-+ // world.setTypeAndData(blockposition3, this.getBlockData().set(a(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 (flag2 && world.isEmpty(blockposition4) && this.c(world.getType(blockposition.shift(enumdirection2)).getBlock())) {
+ } else if (flag2 && world.isEmpty(blockposition4) && this.x(world.getType(blockposition.shift(enumdirection3)))) {
- world.setTypeAndData(blockposition4, this.getBlockData().set(getDirection(enumdirection.opposite()), Boolean.valueOf(true)), 2);
-+ // world.setTypeAndData(blockposition4, this.getBlockData().set(a(enumdirection.opposite()), Boolean.valueOf(true)), 2);
++ // world.setTypeAndData(blockposition4, this.getBlockData().set(getDirection(enumdirection.opposite()), Boolean.valueOf(true)), 2);
+ bukkitBlock = world.getWorld().getBlockAt(blockposition4.getX(), blockposition4.getY(), blockposition4.getZ());
+ CraftEventFactory.handleBlockSpreadEvent(bukkitBlock, source, this, toLegacyData(this.getBlockData().set(getDirection(enumdirection.opposite()), Boolean.valueOf(true))));
- } else if (this.c(world.getType(blockposition2.up()).getBlock())) {
+ } else if (this.x(world.getType(blockposition2.up()))) {
- world.setTypeAndData(blockposition2, this.getBlockData(), 2);
+ // world.setTypeAndData(blockposition2, this.getBlockData(), 2);
+ CraftEventFactory.handleBlockSpreadEvent(bukkitBlock, source, this, toLegacyData(this.getBlockData()));
}
+ // CraftBukkit end
- } else if (block.material.k() && block.d()) {
+ } else if (block.material.k() && iblockdata2.h()) {
world.setTypeAndData(blockposition, iblockdata.set(getDirection(enumdirection), Boolean.valueOf(true)), 2);
}
-@@ -257,7 +277,12 @@
+@@ -231,7 +251,12 @@
}
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()) {
@@ -71,5 +71,5 @@
+ CraftEventFactory.handleBlockSpreadEvent(bukkitBlock, source, this, toLegacyData(iblockdata3));
+ // CraftBukkit end
}
- } else if (block1 == this) {
+ } else if (block == this) {
iblockdata3 = iblockdata2;
diff --git a/nms-patches/Chunk.patch b/nms-patches/Chunk.patch
index 9ccf30c9..1772368b 100644
--- a/nms-patches/Chunk.patch
+++ b/nms-patches/Chunk.patch
@@ -9,10 +9,10 @@
+
public class Chunk {
- private static final Logger c = LogManager.getLogger();
-@@ -40,6 +43,34 @@
- private int v;
- private ConcurrentLinkedQueue<BlockPosition> w;
+ private static final Logger d = LogManager.getLogger();
+@@ -41,6 +44,34 @@
+ private int w;
+ private ConcurrentLinkedQueue<BlockPosition> x;
+ // CraftBukkit start - Neighbor loaded cache for chunk lighting and entity ticking
+ private int neighbors = 0x1 << 12;
@@ -44,16 +44,14 @@
+
public Chunk(World world, int i, int j) {
this.sections = new ChunkSection[16];
- this.e = new byte[256];
-@@ -60,8 +91,17 @@
+ this.f = new byte[256];
+@@ -61,8 +92,15 @@
- Arrays.fill(this.f, -999);
- Arrays.fill(this.e, (byte) -1);
+ Arrays.fill(this.g, -999);
+ Arrays.fill(this.f, (byte) -1);
+
+ // CraftBukkit start
-+ if (!(this instanceof EmptyChunk)) {
-+ this.bukkitChunk = new org.bukkit.craftbukkit.CraftChunk(this);
-+ }
++ this.bukkitChunk = new org.bukkit.craftbukkit.CraftChunk(this);
}
+ public org.bukkit.Chunk bukkitChunk;
@@ -63,30 +61,30 @@
public Chunk(World world, ChunkSnapshot chunksnapshot, int i, int j) {
this(world, i, j);
short short0 = 256;
-@@ -529,7 +569,8 @@
+@@ -463,7 +501,8 @@
}
}
- if (!this.world.isClientSide && block1 != block) {
+ // 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 BlockContainer)) {
++ if (!this.world.isClientSide && block1 != block && (!this.world.captureBlockStates || block instanceof BlockTileEntity)) {
block.onPlace(this.world, blockposition, iblockdata);
}
-@@ -610,7 +651,11 @@
+@@ -544,7 +583,11 @@
int j = MathHelper.floor(entity.locZ / 16.0D);
if (i != this.locX || j != this.locZ) {
-- Chunk.c.warn("Wrong location! (" + i + ", " + j + ") should be (" + this.locX + ", " + this.locZ + "), " + entity, new Object[] { entity});
+- Chunk.d.warn("Wrong location! (" + i + ", " + j + ") should be (" + this.locX + ", " + this.locZ + "), " + entity, new Object[] { entity});
+ // CraftBukkit start
+ Bukkit.getLogger().warning("Wrong location for " + entity + " in world '" + world.getWorld().getName() + "'!");
-+ // Chunk.c.warn("Wrong location! (" + i + ", " + j + ") should be (" + this.locX + ", " + this.locZ + "), " + entity, new Object[] { entity});
++ // Chunk.d.warn("Wrong location! (" + i + ", " + j + ") should be (" + this.locX + ", " + this.locZ + "), " + entity, new Object[] { entity});
+ Bukkit.getLogger().warning("Entity is at " + entity.locX + "," + entity.locZ + " (chunk " + i + "," + j + ") but was stored in chunk " + this.locX + "," + this.locZ);
+ // CraftBukkit end
entity.die();
}
-@@ -662,7 +707,15 @@
+@@ -597,7 +640,15 @@
}
public TileEntity a(BlockPosition blockposition, Chunk.EnumTileEntityState chunk_enumtileentitystate) {
@@ -103,21 +101,21 @@
if (tileentity == null) {
if (chunk_enumtileentitystate == Chunk.EnumTileEntityState.IMMEDIATE) {
-@@ -697,6 +750,13 @@
+@@ -632,6 +683,13 @@
- tileentity.D();
+ 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(getType(blockposition)) + ") where there was no entity tile!");
++ + " (" + org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(getBlockData(blockposition).getBlock()) + ") where there was no entity tile!");
+ System.out.println("Chunk coordinates: " + (this.locX * 16) + "," + (this.locZ * 16));
+ new Exception().printStackTrace();
+ // CraftBukkit end
}
}
-@@ -740,7 +800,21 @@
+@@ -675,7 +733,21 @@
}
for (int i = 0; i < this.entitySlices.length; ++i) {
@@ -140,7 +138,7 @@
}
}
-@@ -798,8 +872,8 @@
+@@ -733,8 +805,8 @@
while (iterator.hasNext()) {
Entity entity = (Entity) iterator.next();
@@ -151,3 +149,33 @@
}
}
}
+@@ -797,6 +869,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.e();
+ }
+
diff --git a/nms-patches/ChunkProviderServer.patch b/nms-patches/ChunkProviderServer.patch
index 65c21678..6c5d4e25 100644
--- a/nms-patches/ChunkProviderServer.patch
+++ b/nms-patches/ChunkProviderServer.patch
@@ -1,12 +1,21 @@
--- a/net/minecraft/server/ChunkProviderServer.java
+++ b/net/minecraft/server/ChunkProviderServer.java
-@@ -11,16 +11,27 @@
+@@ -1,24 +1,31 @@
+ package net.minecraft.server;
+
+-import com.google.common.collect.Lists;
+ import java.io.IOException;
+-import java.util.ArrayList;
+-import java.util.Collections;
+ import java.util.Iterator;
+ import java.util.List;
+-import java.util.Set;
+-import java.util.concurrent.ConcurrentHashMap;
++
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+// CraftBukkit start
-+import java.util.Random;
-+import java.util.logging.Level;
+
+import org.bukkit.Server;
+import org.bukkit.craftbukkit.chunkio.ChunkIOExecutor;
@@ -18,30 +27,30 @@
+
public class ChunkProviderServer implements IChunkProvider {
- private static final Logger b = LogManager.getLogger();
-- private Set<Long> unloadQueue = Collections.newSetFromMap(new ConcurrentHashMap());
-+ public LongHashSet unloadQueue = new LongHashSet(); // CraftBukkit - LongHashSet
- public Chunk emptyChunk;
- public IChunkProvider chunkProvider;
- private IChunkLoader chunkLoader;
-- public boolean forceChunkLoad = true;
-- private LongHashMap<Chunk> chunks = new LongHashMap();
-- private List<Chunk> chunkList = Lists.newArrayList();
-+ public boolean forceChunkLoad = false; // CraftBukkit - true -> false
-+ public LongObjectHashMap<Chunk> chunks = new LongObjectHashMap<Chunk>();
- public WorldServer world;
-
- public ChunkProviderServer(WorldServer worldserver, IChunkLoader ichunkloader, IChunkProvider ichunkprovider) {
-@@ -31,26 +42,43 @@
- }
+ private static final Logger a = LogManager.getLogger();
+- private final Set<Long> unloadQueue = Collections.newSetFromMap(new ConcurrentHashMap());
+- private final ChunkGenerator chunkGenerator;
++ public final LongHashSet unloadQueue = new LongHashSet(); // CraftBukkit - LongHashSet
++ public final ChunkGenerator chunkGenerator; // CraftBukkit - public
+ private final IChunkLoader chunkLoader;
+- private final LongHashMap<Chunk> chunks = new LongHashMap();
+- private final List<Chunk> chunkList = Lists.newArrayList();
++ public LongObjectHashMap<Chunk> chunks = new LongObjectHashMap<Chunk>(); // CraftBukkit
++ // private final LongHashMap<Chunk> chunks = new LongHashMap();
++ // private final List<Chunk> chunkList = Lists.newArrayList();
+ public final WorldServer world;
- public boolean isChunkLoaded(int i, int j) {
-- return this.chunks.contains(ChunkCoordIntPair.a(i, j));
-+ return this.chunks.containsKey(LongHash.toLong(i, j)); // CraftBukkit
+ public ChunkProviderServer(WorldServer worldserver, IChunkLoader ichunkloader, ChunkGenerator chunkgenerator) {
+@@ -27,19 +34,33 @@
+ this.chunkGenerator = chunkgenerator;
}
- public List<Chunk> a() {
- return this.chunkList;
++ public boolean isChunkLoaded(int i, int j) {
++ return this.chunks.containsKey(LongHash.toLong(i, j)); // CraftBukkit
++ }
++
+ // CraftBukkit start - Change return type to Collection and return the values of our chunk map
+ public java.util.Collection a() {
+ // return this.chunkList;
@@ -50,19 +59,7 @@
}
public void queueUnload(int i, int j) {
- if (this.world.worldProvider.e()) {
- if (!this.world.c(i, j)) {
-- this.unloadQueue.add(Long.valueOf(ChunkCoordIntPair.a(i, j)));
-+ // CraftBukkit start
-+ this.unloadQueue.add(i, j);
-+
-+ Chunk c = chunks.get(LongHash.toLong(i, j));
-+ if (c != null) {
-+ c.mustSave = true;
-+ }
-+ // CraftBukkit end
- }
- } else {
+ if (this.world.worldProvider.c(i, j)) {
- this.unloadQueue.add(Long.valueOf(ChunkCoordIntPair.a(i, j)));
+ // CraftBukkit start
+ this.unloadQueue.add(i, j);
@@ -78,11 +75,11 @@
public void b() {
- Iterator iterator = this.chunkList.iterator();
-+ Iterator iterator = this.chunks.values().iterator();
++ Iterator iterator = this.chunks.values().iterator(); // CraftBukkit
while (iterator.hasNext()) {
Chunk chunk = (Chunk) iterator.next();
-@@ -60,11 +88,48 @@
+@@ -49,11 +70,15 @@
}
@@ -91,8 +88,45 @@
+ return chunks.get(LongHash.toLong(x, z));
+ }
+
- public Chunk getChunkAt(int i, int j) {
+ public Chunk getLoadedChunkAt(int i, int j) {
- long k = ChunkCoordIntPair.a(i, j);
+- Chunk chunk = (Chunk) this.chunks.getEntry(k);
++ Chunk chunk = chunks.get(LongHash.toLong(i, j)); // CraftBukkit
+
+- this.unloadQueue.remove(Long.valueOf(k));
++ this.unloadQueue.remove(i, j); // CraftBukkit
+ return chunk;
+ }
+
+@@ -61,20 +86,66 @@
+ Chunk chunk = this.getLoadedChunkAt(i, j);
+
+ if (chunk == null) {
+- chunk = this.loadChunk(i, j);
++ // CraftBukkit start
++ ChunkRegionLoader loader = null;
++
++ if (this.chunkLoader instanceof ChunkRegionLoader) {
++ loader = (ChunkRegionLoader) this.chunkLoader;
++ }
++ if (loader != null && loader.chunkExists(world, i, j)) {
++ chunk = ChunkIOExecutor.syncChunkLoad(world, loader, this, i, j);
++ }
++ /* chunk = this.loadChunk(i, j);
+ if (chunk != null) {
+ this.chunks.put(ChunkCoordIntPair.a(i, j), chunk);
+ this.chunkList.add(chunk);
+ chunk.addEntities();
+ chunk.loadNearby(this, this.chunkGenerator);
+ }
++ */
++ // CraftBukkit end
+ }
+
+ return chunk;
+ }
+
+ public Chunk getChunkAt(int i, int j) {
+ return getChunkAt(i, j, null);
+ }
+
@@ -103,9 +137,7 @@
+
+ if (this.chunkLoader instanceof ChunkRegionLoader) {
+ loader = (ChunkRegionLoader) this.chunkLoader;
-
-- this.unloadQueue.remove(Long.valueOf(k));
-- Chunk chunk = (Chunk) this.chunks.getEntry(k);
++
+ }
+ // We can only use the queue for already generated chunks
+ if (chunk == null && loader != null && loader.chunkExists(world, i, j)) {
@@ -126,33 +158,26 @@
+
+ return chunk;
+ }
++
+ public Chunk originalGetChunkAt(int i, int j) {
-+ this.unloadQueue.remove(i, j);
-+ Chunk chunk = (Chunk) this.chunks.get(LongHash.toLong(i, j));
+ Chunk chunk = this.getOrLoadChunkAt(i, j);
+ boolean newChunk = false;
+ // CraftBukkit end
if (chunk == null) {
- chunk = this.loadChunk(i, j);
-@@ -79,16 +144,44 @@
- CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Chunk to be generated");
-
- crashreportsystemdetails.a("Location", (Object) String.format("%d,%d", new Object[] { Integer.valueOf(i), Integer.valueOf(j)}));
-- crashreportsystemdetails.a("Position hash", (Object) Long.valueOf(k));
-+ crashreportsystemdetails.a("Position hash", (Object) Long.valueOf(LongHash.toLong(i, j))); // CraftBukkit - Use LongHash
- crashreportsystemdetails.a("Generator", (Object) this.chunkProvider.getName());
- throw new ReportedException(crashreport);
- }
+ long k = ChunkCoordIntPair.a(i, j);
+@@ -92,11 +163,38 @@
+ crashreportsystemdetails.a("Generator", (Object) this.chunkGenerator);
+ throw new ReportedException(crashreport);
}
+ newChunk = true; // CraftBukkit
}
- this.chunks.put(k, chunk);
- this.chunkList.add(chunk);
-+ this.chunks.put(LongHash.toLong(i, j), chunk);
-+
++ this.chunks.put(LongHash.toLong(i, j), chunk); // CraftBukkit
chunk.addEntities();
-+
++
+ // CraftBukkit start
+ Server server = world.getServer();
+ if (server != null) {
@@ -179,68 +204,12 @@
+ }
+ }
+ // CraftBukkit end
- chunk.loadNearby(this, this, i, j);
+ chunk.loadNearby(this, this.chunkGenerator);
}
-@@ -96,9 +189,22 @@
- }
-
- public Chunk getOrCreateChunk(int i, int j) {
-- Chunk chunk = (Chunk) this.chunks.getEntry(ChunkCoordIntPair.a(i, j));
-+ // CraftBukkit start
-+ Chunk chunk = (Chunk) this.chunks.get(LongHash.toLong(i, j));
-+
-+ chunk = chunk == null ? (!this.world.ad() && !this.forceChunkLoad ? this.emptyChunk : this.getChunkAt(i, j)) : chunk;
-+
-+ if (chunk == emptyChunk) return chunk;
-+ if (i != chunk.locX || j != chunk.locZ) {
-+ b.error("Chunk (" + chunk.locX + ", " + chunk.locZ + ") stored at (" + i + ", " + j + ") in world '" + world.getWorld().getName() + "'");
-+ b.error(chunk.getClass().getName());
-+ Throwable ex = new Throwable();
-+ ex.fillInStackTrace();
-+ ex.printStackTrace();
-+ }
+@@ -142,10 +240,12 @@
-- return chunk == null ? (!this.world.ad() && !this.forceChunkLoad ? this.emptyChunk : this.getChunkAt(i, j)) : chunk;
-+ return chunk;
-+ // CraftBukkit end
- }
-
- public Chunk loadChunk(int i, int j) {
-@@ -155,6 +261,30 @@
- chunk.n();
- if (this.chunkProvider != null) {
- this.chunkProvider.getChunkAt(ichunkprovider, i, j);
-+
-+ // 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) i * xRand + (long) j * 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, chunk.bukkitChunk);
-+ }
-+ } finally {
-+ this.world.populating = false;
-+ }
-+ }
-+ BlockSand.instaFall = false;
-+ this.world.getServer().getPluginManager().callEvent(new org.bukkit.event.world.ChunkPopulateEvent(chunk.bukkitChunk));
-+ // CraftBukkit end
-+
- chunk.e();
- }
- }
-@@ -174,10 +304,12 @@
-
- public boolean saveChunks(boolean flag, IProgressUpdate iprogressupdate) {
+ public boolean a(boolean flag) {
int i = 0;
- ArrayList arraylist = Lists.newArrayList(this.chunkList);
@@ -254,7 +223,7 @@
if (flag) {
this.saveChunkNOP(chunk);
-@@ -205,22 +337,43 @@
+@@ -170,22 +270,43 @@
public boolean unloadChunks() {
if (!this.world.savingDisabled) {
@@ -303,9 +272,9 @@
}
+ // CraftBukkit end
- if (this.chunkLoader != null) {
- this.chunkLoader.a();
-@@ -235,7 +388,8 @@
+ this.chunkLoader.a();
+ }
+@@ -198,7 +319,8 @@
}
public String getName() {
@@ -314,14 +283,18 @@
+ return "ServerChunkCache: " + this.chunks.size() + " Drop: " + this.unloadQueue.size();
}
- public List<BiomeBase.BiomeMeta> getMobsFor(EnumCreatureType enumcreaturetype, BlockPosition blockposition) {
-@@ -247,7 +401,8 @@
+ public List<BiomeBase.BiomeMeta> a(EnumCreatureType enumcreaturetype, BlockPosition blockposition) {
+@@ -210,10 +332,11 @@
}
- public int getLoadedChunks() {
+ public int g() {
- return this.chunks.count();
+ // CraftBukkit - this.chunks.count() -> this.chunks.size()
+ return this.chunks.size();
}
- public void recreateStructures(Chunk chunk, int i, int j) {}
+ public boolean e(int i, int j) {
+- return this.chunks.contains(ChunkCoordIntPair.a(i, j));
++ return this.chunks.containsKey(LongHash.toLong(i, j)); // CraftBukkit
+ }
+ }
diff --git a/nms-patches/ChunkRegionLoader.patch b/nms-patches/ChunkRegionLoader.patch
index 47a50146..44998f47 100644
--- a/nms-patches/ChunkRegionLoader.patch
+++ b/nms-patches/ChunkRegionLoader.patch
@@ -1,7 +1,7 @@
--- a/net/minecraft/server/ChunkRegionLoader.java
+++ b/net/minecraft/server/ChunkRegionLoader.java
-@@ -26,7 +26,35 @@
- this.d = file;
+@@ -28,7 +28,35 @@
+ this.e = dataconvertermanager;
}
+ // CraftBukkit start
@@ -36,7 +36,7 @@
ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(i, j);
NBTTagCompound nbttagcompound = (NBTTagCompound) this.b.get(chunkcoordintpair);
-@@ -43,7 +71,7 @@
+@@ -45,7 +73,7 @@
return this.a(world, i, j, nbttagcompound);
}
@@ -45,7 +45,7 @@
if (!nbttagcompound.hasKeyOfType("Level", 10)) {
ChunkRegionLoader.a.error("Chunk file at " + i + "," + j + " is missing level data, skipping");
return null;
-@@ -60,10 +88,28 @@
+@@ -62,10 +90,28 @@
ChunkRegionLoader.a.error("Chunk file at " + i + "," + j + " is in the wrong location; relocating. (Expected " + i + ", " + j + ", got " + chunk.locX + ", " + chunk.locZ + ")");
nbttagcompound1.setInt("xPos", i);
nbttagcompound1.setInt("zPos", j);
@@ -75,35 +75,7 @@
}
}
}
-@@ -303,7 +349,26 @@
- int k1 = l >> 4 & 15;
- int l1 = nibblearray1 != null ? nibblearray1.a(i1, j1, k1) : 0;
-
-- achar[l] = (char) (l1 << 12 | (abyte[l] & 255) << 4 | nibblearray.a(i1, j1, k1));
-+ // CraftBukkit start - fix broken blocks
-+ // achar[l] = (char) (l1 << 12 | (abyte[l] & 255) << 4 | nibblearray.a(i1, j1, k1));
-+
-+ int ex = l1;
-+ int id = (abyte[l] & 255);
-+ int data = nibblearray.a(i1, j1, k1);
-+ int packed = ex << 12 | id << 4 | data;
-+ if (Block.d.a(packed) == null) {
-+ Block block = Block.getById(ex << 8 | id);
-+ if (block != null) {
-+ try {
-+ data = block.toLegacyData(block.fromLegacyData(data));
-+ } catch (Exception ignored) {
-+ data = block.toLegacyData(block.getBlockData());
-+ }
-+ packed = ex << 12 | id << 4 | data;
-+ }
-+ }
-+ achar[l] = (char) packed;
-+ // CraftBukkit end
- }
-
- chunksection.a(achar);
-@@ -321,6 +386,13 @@
+@@ -295,6 +341,13 @@
chunk.a(nbttagcompound.getByteArray("Biomes"));
}
@@ -117,11 +89,28 @@
NBTTagList nbttaglist1 = nbttagcompound.getList("Entities", 10);
if (nbttaglist1 != null) {
-@@ -379,6 +451,6 @@
+@@ -338,7 +391,7 @@
}
}
- return chunk;
+ // return chunk; // CraftBukkit
}
- }
+
+ public static Entity a(NBTTagCompound nbttagcompound, World world, Chunk chunk) {
+@@ -399,8 +452,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, World world, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) {
++ if (world.addEntity(entity, reason) && entity.isVehicle()) {
++ // CraftBukkit end
+ Iterator iterator = entity.bu().iterator();
+
+ while (iterator.hasNext()) {
diff --git a/nms-patches/ChunkSection.patch b/nms-patches/ChunkSection.patch
index 6a96a992..da356273 100644
--- a/nms-patches/ChunkSection.patch
+++ b/nms-patches/ChunkSection.patch
@@ -1,13 +1,19 @@
--- a/net/minecraft/server/ChunkSection.java
+++ b/net/minecraft/server/ChunkSection.java
-@@ -19,6 +19,18 @@
+@@ -19,6 +19,24 @@
}
+ // CraftBukkit start
+ public ChunkSection(int y, boolean flag, char[] blockIds) {
+ this.yPos = y;
-+ this.blockIds = blockIds;
++ 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();
@@ -17,5 +23,5 @@
+ // CraftBukkit end
+
public IBlockData getType(int i, int j, int k) {
- IBlockData iblockdata = (IBlockData) Block.d.a(this.blockIds[j << 8 | k << 4 | i]);
-
+ return this.blockIds.a(i, j, k);
+ }
diff --git a/nms-patches/CommandBlockListenerAbstract.patch b/nms-patches/CommandBlockListenerAbstract.patch
index c7dec989..f5f63044 100644
--- a/nms-patches/CommandBlockListenerAbstract.patch
+++ b/nms-patches/CommandBlockListenerAbstract.patch
@@ -22,20 +22,19 @@
public CommandBlockListenerAbstract() {}
-@@ -79,7 +87,10 @@
-
- try {
- this.d = null;
-- this.b = icommandhandler.a(this, this.e);
-+ // this.b = icommandhandler.a(this, this.e);
-+ // CraftBukkit start - Handle command block commands using Bukkit dispatcher
-+ this.b = executeCommand(this, sender, this.e);
-+ // CraftBukkit end
- } catch (Throwable throwable) {
- CrashReport crashreport = CrashReport.a(throwable, "Executing command block");
- CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Command to be executed");
-@@ -110,6 +121,130 @@
+@@ -91,7 +99,9 @@
+ try {
+ this.d = null;
+- this.b = icommandhandler.a(this, this.e);
++ // CraftBukkit start - Handle command block commands using Bukkit dispatcher
++ this.b = executeCommand(this, sender, this.e);
++ // CraftBukkit end
+ } catch (Throwable throwable) {
+ CrashReport crashreport = CrashReport.a(throwable, "Executing command block");
+ CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Command to be executed");
+@@ -123,6 +133,130 @@
+ }
}
+ // CraftBukkit start
diff --git a/nms-patches/CommandExecute.patch b/nms-patches/CommandExecute.patch
index 9f937961..28b0d55c 100644
--- a/nms-patches/CommandExecute.patch
+++ b/nms-patches/CommandExecute.patch
@@ -1,8 +1,8 @@
--- a/net/minecraft/server/CommandExecute.java
+++ b/net/minecraft/server/CommandExecute.java
-@@ -2,6 +2,10 @@
-
+@@ -3,6 +3,10 @@
import java.util.Collection;
+ import java.util.Collections;
import java.util.List;
+// CraftBukkit start
+import org.bukkit.craftbukkit.command.ProxiedNativeCommandSender;
@@ -11,8 +11,8 @@
public class CommandExecute extends CommandAbstract {
-@@ -94,12 +98,31 @@
- ICommandHandler icommandhandler = MinecraftServer.getServer().getCommandHandler();
+@@ -97,22 +101,48 @@
+ ICommandHandler icommandhandler = minecraftserver.getCommandHandler();
try {
- int j = icommandhandler.a(icommandlistener1, s);
@@ -44,7 +44,13 @@
throw new CommandException("commands.execute.failed", new Object[] { s, entity.getName()});
}
}
-@@ -112,4 +135,11 @@
+ }
+
+ public List<String> tabComplete(MinecraftServer minecraftserver, ICommandListener icommandlistener, String[] astring, 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;
}
diff --git a/nms-patches/CommandGamemode.patch b/nms-patches/CommandGamemode.patch
index 6280a4b1..f9e342f3 100644
--- a/nms-patches/CommandGamemode.patch
+++ b/nms-patches/CommandGamemode.patch
@@ -1,7 +1,7 @@
--- a/net/minecraft/server/CommandGamemode.java
+++ b/net/minecraft/server/CommandGamemode.java
-@@ -26,6 +26,13 @@
- EntityPlayer entityplayer = astring.length >= 2 ? a(icommandlistener, astring[1]) : b(icommandlistener);
+@@ -27,6 +27,12 @@
+ EntityPlayer entityplayer = astring.length >= 2 ? a(minecraftserver, icommandlistener, astring[1]) : a(icommandlistener);
entityplayer.a(worldsettings_enumgamemode);
+ // CraftBukkit start - handle event cancelling the change
@@ -10,11 +10,17 @@
+ return;
+ }
+ // CraftBukkit end
-+
- entityplayer.fallDistance = 0.0F;
+ ChatMessage chatmessage = new ChatMessage("gameMode." + worldsettings_enumgamemode.b(), new Object[0]);
+
if (icommandlistener.getWorld().getGameRules().getBoolean("sendCommandFeedback")) {
- entityplayer.sendMessage(new ChatMessage("gameMode.changed", new Object[0]));
-@@ -57,4 +64,11 @@
+@@ -49,10 +55,17 @@
+ }
+
+ public List<String> tabComplete(MinecraftServer minecraftserver, ICommandListener icommandlistener, String[] astring, 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;
}
diff --git a/nms-patches/CommandGamerule.patch b/nms-patches/CommandGamerule.patch
index c619010f..acb2de48 100644
--- a/nms-patches/CommandGamerule.patch
+++ b/nms-patches/CommandGamerule.patch
@@ -1,17 +1,17 @@
--- a/net/minecraft/server/CommandGamerule.java
+++ b/net/minecraft/server/CommandGamerule.java
-@@ -20,7 +20,7 @@
+@@ -21,7 +21,7 @@
}
- public void execute(ICommandListener icommandlistener, String[] astring) throws CommandException {
-- GameRules gamerules = this.d();
+ 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) : "";
-@@ -85,4 +85,11 @@
- private GameRules d() {
- return MinecraftServer.getServer().getWorldServer(0).getGameRules();
+@@ -86,4 +86,11 @@
+ private GameRules a(MinecraftServer minecraftserver) {
+ return minecraftserver.getWorldServer(0).getGameRules();
}
+
+ // CraftBukkit start - fix decompile error
diff --git a/nms-patches/CommandSpreadPlayers.patch b/nms-patches/CommandSpreadPlayers.patch
index 7f7a9383..03ecb614 100644
--- a/nms-patches/CommandSpreadPlayers.patch
+++ b/nms-patches/CommandSpreadPlayers.patch
@@ -1,7 +1,11 @@
--- a/net/minecraft/server/CommandSpreadPlayers.java
+++ b/net/minecraft/server/CommandSpreadPlayers.java
-@@ -237,6 +237,13 @@
- return astring.length >= 1 && astring.length <= 2 ? b(astring, 0, blockposition) : null;
+@@ -235,9 +235,16 @@
+ }
+
+ public List<String> tabComplete(MinecraftServer minecraftserver, ICommandListener icommandlistener, String[] astring, 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
@@ -14,25 +18,25 @@
static class Location2D {
double a;
-@@ -303,7 +310,7 @@
+@@ -304,7 +311,7 @@
}
blockposition = blockposition.down();
-- } while (world.getType(blockposition).getBlock().getMaterial() == Material.AIR);
-+ } while (getType(world, blockposition).getBlock().getMaterial() == Material.AIR); // CraftBukkit
+- } while (world.getType(blockposition).getMaterial() == Material.AIR);
++ } while (getType(world, blockposition).getMaterial() == Material.AIR); // CraftBukkit
return blockposition.getY() + 1;
}
-@@ -319,7 +326,7 @@
+@@ -320,7 +327,7 @@
}
blockposition = blockposition.down();
-- material = world.getType(blockposition).getBlock().getMaterial();
-+ material = getType(world, blockposition).getBlock().getMaterial(); // CraftBukkit
+- material = world.getType(blockposition).getMaterial();
++ material = getType(world, blockposition).getMaterial(); // CraftBukkit
} while (material == Material.AIR);
return !material.isLiquid() && material != Material.FIRE;
-@@ -329,5 +336,12 @@
+@@ -330,5 +337,12 @@
this.a = MathHelper.a(random, d0, d2);
this.b = MathHelper.a(random, d1, d3);
}
diff --git a/nms-patches/CommandTp.patch b/nms-patches/CommandTp.patch
index 13912dd7..de9d839e 100644
--- a/nms-patches/CommandTp.patch
+++ b/nms-patches/CommandTp.patch
@@ -1,29 +1,34 @@
--- a/net/minecraft/server/CommandTp.java
+++ b/net/minecraft/server/CommandTp.java
-@@ -105,17 +105,11 @@
+@@ -97,27 +97,28 @@
} else {
- Entity entity = b(icommandlistener, astring[astring.length - 1]);
+ Entity entity = b(minecraftserver, icommandlistener, astring[astring.length - 1]);
- if (entity.world != ((Entity) object).world) {
- throw new CommandException("commands.tp.notSameDimension", new Object[0]);
- } else {
-- ((Entity) object).mount((Entity) null);
+- ((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);
- }
-
-- a(icommandlistener, this, "commands.tp.success", new Object[] { ((Entity) object).getName(), entity.getName()});
+ // 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, this, "commands.tp.success", new Object[]{((Entity) object).getName(), entity.getName()});
+ a(icommandlistener, (ICommand) this, "commands.tp.success", new Object[] { ((Entity) object).getName(), entity.getName()});
+ // CraftBukkit End
}
}
}
-@@ -128,4 +122,11 @@
+ }
+
+ public List<String> tabComplete(MinecraftServer minecraftserver, ICommandListener icommandlistener, String[] astring, BlockPosition blockposition) {
+- return astring.length != 1 && astring.length != 2 ? Collections.emptyList() : a(astring, minecraftserver.getPlayers());
++ return astring.length != 1 && astring.length != 2 ? Collections.<String>emptyList() : a(astring, minecraftserver.getPlayers()); // CraftBukkit - decompile error
+ }
+
public boolean isListStart(String[] astring, int i) {
return i == 0;
}
diff --git a/nms-patches/Container.patch b/nms-patches/Container.patch
index 55fe26c7..cc1df43a 100644
--- a/nms-patches/Container.patch
+++ b/nms-patches/Container.patch
@@ -45,7 +45,7 @@
}
@@ -124,6 +147,7 @@
- l = playerinventory.getCarried().count;
+ k = playerinventory.getCarried().count;
Iterator iterator = this.h.iterator();
+ Map<Integer, ItemStack> draggedSlots = new HashMap<Integer, ItemStack>(); // CraftBukkit - Store slots from drag in map (raw slot id -> new stack)
@@ -55,20 +55,20 @@
@@ -141,16 +165,48 @@
}
- l -= itemstack2.count - j1;
+ k -= itemstack2.count - i1;
- slot1.set(itemstack2);
+ // slot1.set(itemstack2);
+ draggedSlots.put(slot1.rawSlotIndex, itemstack2); // CraftBukkit - Put in map instead of setting
}
}
-- itemstack1.count = l;
+- itemstack1.count = k;
- if (itemstack1.count <= 0) {
- itemstack1 = null;
+ // CraftBukkit start - InventoryDragEvent
+ InventoryView view = getBukkitView();
+ org.bukkit.inventory.ItemStack newcursor = CraftItemStack.asCraftMirror(itemstack1);
-+ newcursor.setAmount(l);
++ newcursor.setAmount(k);
+ Map<Integer, org.bukkit.inventory.ItemStack> eventmap = new HashMap<Integer, org.bukkit.inventory.ItemStack>();
+ for (Map.Entry<Integer, ItemStack> ditem : draggedSlots.entrySet()) {
+ eventmap.put(ditem.getKey(), CraftItemStack.asBukkitCopy(ditem.getValue()));
@@ -112,20 +112,20 @@
if (j == 1) {
- entityhuman.drop(playerinventory.getCarried().cloneAndSubtract(1), true);
- if (playerinventory.getCarried().count == 0) {
-+ // CraftBukkit start - Store a reference
-+ ItemStack itemstack4 = playerinventory.getCarried();
-+ if (itemstack4.count > 0) {
-+ entityhuman.drop(itemstack4.cloneAndSubtract(1), true);
++ // CraftBukkit start - Store a reference, don't drop unless > 0
++ ItemStack carried = playerinventory.getCarried();
++ if (carried.count > 0) {
++ entityhuman.drop(carried.cloneAndSubtract(1), true);
+ }
+
-+ if (itemstack4.count == 0) {
++ if (carried.count == 0) {
+ // CraftBukkit end
playerinventory.setCarried((ItemStack) null);
}
}
-@@ -223,7 +285,11 @@
-
- if (itemstack4.count == 0) {
+@@ -225,7 +287,11 @@
+ slot2.set(itemstack3.cloneAndSubtract(j1));
+ if (itemstack3.count == 0) {
playerinventory.setCarried((ItemStack) null);
+ // CraftBukkit start - Update client cursor if we didn't empty it
+ } else if (entityhuman instanceof EntityPlayer) {
@@ -134,10 +134,10 @@
+ // CraftBukkit end
}
} else if (slot2.isAllowed(entityhuman)) {
- if (itemstack4 == null) {
-@@ -249,7 +315,11 @@
- itemstack4.cloneAndSubtract(k1);
- if (itemstack4.count == 0) {
+ if (itemstack3 == null) {
+@@ -255,7 +321,11 @@
+ itemstack3.cloneAndSubtract(j1);
+ if (itemstack3.count == 0) {
playerinventory.setCarried((ItemStack) null);
+ // CraftBukkit start - Update client cursor if we didn't empty it
+ } else if (entityhuman instanceof EntityPlayer) {
@@ -145,20 +145,21 @@
}
+ // CraftBukkit end
- itemstack1.count += k1;
- } else if (itemstack4.count <= slot2.getMaxStackSize(itemstack4)) {
-@@ -258,7 +328,9 @@
+ itemstack1.count += j1;
+ } else if (itemstack3.count <= slot2.getMaxStackSize(itemstack3)) {
+@@ -264,7 +334,10 @@
}
- } else if (itemstack1.getItem() == itemstack4.getItem() && itemstack4.getMaxStackSize() > 1 && (!itemstack1.usesData() || itemstack1.getData() == itemstack4.getData()) && ItemStack.equals(itemstack1, itemstack4)) {
- k1 = itemstack1.count;
-- if (k1 > 0 && k1 + itemstack4.count <= itemstack4.getMaxStackSize()) {
-+ // CraftBukkit start - itemstack4.getMaxStackSize() -> maxStack
-+ int maxStack = Math.min(itemstack4.getMaxStackSize(), slot2.getMaxStackSize());
-+ if (k1 > 0 && k1 + itemstack4.count <= maxStack) {
- itemstack4.count += k1;
- itemstack1 = slot2.a(k1);
+ } else if (itemstack1.getItem() == itemstack3.getItem() && itemstack3.getMaxStackSize() > 1 && (!itemstack1.usesData() || itemstack1.getData() == itemstack3.getData()) && ItemStack.equals(itemstack1, itemstack3)) {
+ j1 = itemstack1.count;
+- if (j1 > 0 && j1 + itemstack3.count <= itemstack3.getMaxStackSize()) {
++ // CraftBukkit start - itemstack3.getMaxStackSize() -> maxStack
++ int maxStack = Math.min(itemstack3.getMaxStackSize(), slot2.getMaxStackSize());
++ if (j1 > 0 && j1 + itemstack3.count <= maxStack) {
++ // CraftBukkit end
+ itemstack3.count += j1;
+ itemstack1 = slot2.a(j1);
if (itemstack1.count == 0) {
-@@ -266,11 +338,24 @@
+@@ -272,11 +345,24 @@
}
slot2.a(entityhuman, playerinventory.getCarried());
@@ -182,9 +183,9 @@
+ // CraftBukkit end
}
}
- } else if (k == 2 && j >= 0 && j < 9) {
-@@ -411,17 +496,20 @@
- if (itemstack1 != null && itemstack1.getItem() == itemstack.getItem() && (!itemstack.usesData() || itemstack.getData() == itemstack1.getData()) && ItemStack.equals(itemstack, itemstack1)) {
+ } else if (inventoryclicktype == InventoryClickType.SWAP && j >= 0 && j < 9) {
+@@ -430,14 +516,17 @@
+ if (itemstack1 != null && a(itemstack, itemstack1)) {
int l = itemstack1.count + itemstack.count;
- if (l <= itemstack.getMaxStackSize()) {
@@ -201,10 +202,7 @@
+ } else if (itemstack1.count < maxStack) {
+ itemstack.count -= maxStack - itemstack1.count;
+ itemstack1.count = maxStack;
++ // CraftBukkit end
slot.f();
flag1 = true;
}
-+ // CraftBukkit end
- }
-
- if (flag) {
diff --git a/nms-patches/ContainerAnvil.patch b/nms-patches/ContainerAnvil.patch
index 003cc500..55856177 100644
--- a/nms-patches/ContainerAnvil.patch
+++ b/nms-patches/ContainerAnvil.patch
@@ -1,15 +1,19 @@
--- a/net/minecraft/server/ContainerAnvil.java
+++ b/net/minecraft/server/ContainerAnvil.java
-@@ -6,6 +6,8 @@
+@@ -6,6 +6,12 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
-+import org.bukkit.craftbukkit.inventory.CraftInventoryView; // CraftBukkit
++ // CraftBukkit start
++import org.bukkit.craftbukkit.inventory.CraftInventoryView;
++import org.bukkit.craftbukkit.inventory.CraftItemStack;
++import org.bukkit.event.inventory.PrepareAnvilEvent;
++// CraftBukkit end
+
public class ContainerAnvil extends Container {
private static final Logger f = LogManager.getLogger();
-@@ -22,8 +24,13 @@
+@@ -22,8 +28,13 @@
private int k;
private String l;
private final EntityHuman m;
@@ -23,7 +27,43 @@
this.j = blockposition;
this.i = world;
this.m = entityhuman;
-@@ -317,6 +324,7 @@
+@@ -109,7 +120,7 @@
+ byte b1 = 0;
+
+ if (itemstack == null) {
+- this.g.setItem(0, (ItemStack) null);
++ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), null); // CraftBukkit
+ this.a = 0;
+ } else {
+ ItemStack itemstack1 = itemstack.cloneItemStack();
+@@ -127,7 +138,7 @@
+ if (itemstack1.e() && itemstack1.getItem().a(itemstack, itemstack2)) {
+ k = Math.min(itemstack1.h(), itemstack1.j() / 4);
+ if (k <= 0) {
+- this.g.setItem(0, (ItemStack) null);
++ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), null); // CraftBukkit
+ this.a = 0;
+ return;
+ }
+@@ -142,7 +153,7 @@
+ this.k = l;
+ } else {
+ if (!flag && (itemstack1.getItem() != itemstack2.getItem() || !itemstack1.e())) {
+- this.g.setItem(0, (ItemStack) null);
++ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), null); // CraftBukkit
+ this.a = 0;
+ return;
+ }
+@@ -269,7 +280,7 @@
+ EnchantmentManager.a(map, itemstack1);
+ }
+
+- this.g.setItem(0, itemstack1);
++ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), itemstack1); // CraftBukkit
+ this.b();
+ }
+ }
+@@ -294,6 +305,7 @@
}
public boolean a(EntityHuman entityhuman) {
@@ -31,11 +71,10 @@
return this.i.getType(this.j).getBlock() != Blocks.ANVIL ? false : entityhuman.e((double) this.j.getX() + 0.5D, (double) this.j.getY() + 0.5D, (double) this.j.getZ() + 0.5D) <= 64.0D;
}
-@@ -372,4 +380,17 @@
-
+@@ -350,6 +362,20 @@
this.e();
}
-+
+
+ // CraftBukkit start
+ @Override
+ public CraftInventoryView getBukkitView() {
@@ -43,9 +82,13 @@
+ return bukkitEntity;
+ }
+
-+ org.bukkit.craftbukkit.inventory.CraftInventory inventory = new org.bukkit.craftbukkit.inventory.CraftInventoryAnvil(this.h, this.g);
++ org.bukkit.craftbukkit.inventory.CraftInventory inventory = new org.bukkit.craftbukkit.inventory.CraftInventoryAnvil(
++ new org.bukkit.Location(i.getWorld(), j.getX(), j.getY(), j.getZ()), this.h, this.g);
+ bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), inventory, this);
+ return bukkitEntity;
+ }
+ // CraftBukkit end
- }
++
+ static class SyntheticClass_1 {
+
+ static final int[] a = new int[Enchantment.Rarity.values().length];
diff --git a/nms-patches/ContainerBrewingStand.patch b/nms-patches/ContainerBrewingStand.patch
index 3de4d47e..91c9b24a 100644
--- a/nms-patches/ContainerBrewingStand.patch
+++ b/nms-patches/ContainerBrewingStand.patch
@@ -1,6 +1,6 @@
--- a/net/minecraft/server/ContainerBrewingStand.java
+++ b/net/minecraft/server/ContainerBrewingStand.java
-@@ -1,12 +1,23 @@
+@@ -1,5 +1,10 @@
package net.minecraft.server;
+// CraftBukkit start
@@ -11,8 +11,9 @@
public class ContainerBrewingStand extends Container {
private IInventory brewingStand;
- private final Slot f;
+@@ -7,7 +12,13 @@
private int g;
+ private int h;
+ // CraftBukkit start
+ private CraftInventoryView bukkitEntity = null;
@@ -22,9 +23,9 @@
public ContainerBrewingStand(PlayerInventory playerinventory, IInventory iinventory) {
+ player = playerinventory; // CraftBukkit
this.brewingStand = iinventory;
- this.a((Slot) (new ContainerBrewingStand.SlotPotionBottle(playerinventory.player, iinventory, 0, 56, 46)));
- this.a((Slot) (new ContainerBrewingStand.SlotPotionBottle(playerinventory.player, iinventory, 1, 79, 53)));
-@@ -47,6 +58,7 @@
+ this.a((Slot) (new ContainerBrewingStand.SlotPotionBottle(playerinventory.player, iinventory, 0, 56, 51)));
+ this.a((Slot) (new ContainerBrewingStand.SlotPotionBottle(playerinventory.player, iinventory, 1, 79, 58)));
+@@ -54,6 +65,7 @@
}
public boolean a(EntityHuman entityhuman) {
@@ -32,8 +33,8 @@
return this.brewingStand.a(entityhuman);
}
-@@ -146,4 +158,17 @@
- return itemstack != null && (itemstack.getItem() == Items.POTION || itemstack.getItem() == Items.GLASS_BOTTLE);
+@@ -182,4 +194,17 @@
+ }
}
}
+
diff --git a/nms-patches/ContainerEnchantTable.patch b/nms-patches/ContainerEnchantTable.patch
index 5e436ed1..40ddb908 100644
--- a/nms-patches/ContainerEnchantTable.patch
+++ b/nms-patches/ContainerEnchantTable.patch
@@ -1,11 +1,12 @@
--- a/net/minecraft/server/ContainerEnchantTable.java
+++ b/net/minecraft/server/ContainerEnchantTable.java
-@@ -3,9 +3,21 @@
+@@ -3,9 +3,22 @@
import java.util.List;
import java.util.Random;
+// CraftBukkit start
+import java.util.Map;
++import org.bukkit.Location;
+
+import org.bukkit.craftbukkit.inventory.CraftInventoryEnchanting;
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
@@ -23,10 +24,22 @@
public int getMaxStackSize() {
return 64;
}
-@@ -21,6 +33,10 @@
- public int f;
+@@ -14,6 +27,11 @@
+ super.update();
+ ContainerEnchantTable.this.a((IInventory) this);
+ }
++
++ @Override
++ public Location getLocation() {
++ return new org.bukkit.Location(world.getWorld(), position.getX(), position.getY(), position.getZ());
++ }
+ };
+ private World world;
+ private BlockPosition position;
+@@ -22,6 +40,10 @@
public int[] costs = new int[3];
public int[] h = new int[] { -1, -1, -1};
+ public int[] i = new int[] { -1, -1, -1};
+ // CraftBukkit start
+ private CraftInventoryView bukkitEntity = null;
+ private Player player;
@@ -34,7 +47,7 @@
public ContainerEnchantTable(PlayerInventory playerinventory, World world, BlockPosition blockposition) {
this.world = world;
-@@ -53,6 +69,9 @@
+@@ -54,6 +76,9 @@
this.a(new Slot(playerinventory, i, 8 + i * 18, 142));
}
@@ -43,8 +56,8 @@
+ // CraftBukkit end
}
- public void addSlotListener(ICrafting icrafting) {
-@@ -88,7 +107,7 @@
+ protected void c(ICrafting icrafting) {
+@@ -90,7 +115,7 @@
ItemStack itemstack = iinventory.getItem(0);
int i;
@@ -53,7 +66,7 @@
if (!this.world.isClientSide) {
i = 0;
-@@ -136,6 +155,20 @@
+@@ -139,6 +164,20 @@
}
}
@@ -74,7 +87,7 @@
for (j = 0; j < 3; ++j) {
if (this.costs[j] > 0) {
List list = this.a(itemstack, j, this.costs[j]);
-@@ -170,24 +203,55 @@
+@@ -175,24 +214,55 @@
} else if (this.costs[i] > 0 && itemstack != null && (entityhuman.expLevel >= j && entityhuman.expLevel >= this.costs[i] || entityhuman.abilities.canInstantlyBuild)) {
if (!this.world.isClientSide) {
List list = this.a(itemstack, i, this.costs[i]);
@@ -91,7 +104,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(instance.enchantment.id), instance.level);
++ enchants.put(org.bukkit.enchantments.Enchantment.getById(Enchantment.getId(instance.enchantment)), instance.level);
+ }
+ CraftItemStack item = CraftItemStack.asCraftMirror(itemstack);
+
@@ -112,7 +125,7 @@
+ try {
+ if (flag) {
+ int enchantId = entry.getKey().getId();
-+ if (Enchantment.getById(enchantId) == null) {
++ if (Enchantment.c(enchantId) == null) {
+ continue;
+ }
@@ -120,8 +133,8 @@
- Items.ENCHANTED_BOOK.a(itemstack, weightedrandomenchant);
- } else {
- itemstack.addEnchantment(weightedrandomenchant.enchantment, weightedrandomenchant.level);
-+ WeightedRandomEnchant enchantment = new WeightedRandomEnchant(Enchantment.getById(enchantId), entry.getValue());
-+ Items.ENCHANTED_BOOK.a(itemstack, enchantment);
++ WeightedRandomEnchant weightedrandomenchant = new WeightedRandomEnchant(Enchantment.c(enchantId), entry.getValue());
++ Items.ENCHANTED_BOOK.a(itemstack, weightedrandomenchant);
+ } else {
+ item.addUnsafeEnchantment(entry.getKey(), entry.getValue());
+ }
@@ -137,7 +150,7 @@
if (!entityhuman.abilities.canInstantlyBuild) {
itemstack1.count -= j;
if (itemstack1.count <= 0) {
-@@ -221,6 +285,11 @@
+@@ -226,6 +296,11 @@
public void b(EntityHuman entityhuman) {
super.b(entityhuman);
@@ -149,7 +162,7 @@
if (!this.world.isClientSide) {
for (int i = 0; i < this.enchantSlots.getSize(); ++i) {
ItemStack itemstack = this.enchantSlots.splitWithoutUpdate(i);
-@@ -234,6 +303,7 @@
+@@ -239,6 +314,7 @@
}
public boolean a(EntityHuman entityhuman) {
@@ -157,7 +170,7 @@
return this.world.getType(this.position).getBlock() != Blocks.ENCHANTING_TABLE ? false : entityhuman.e((double) this.position.getX() + 0.5D, (double) this.position.getY() + 0.5D, (double) this.position.getZ() + 0.5D) <= 64.0D;
}
-@@ -286,4 +356,17 @@
+@@ -291,4 +367,17 @@
return itemstack;
}
diff --git a/nms-patches/ContainerPlayer.patch b/nms-patches/ContainerPlayer.patch
index 482d8385..7bdf1448 100644
--- a/nms-patches/ContainerPlayer.patch
+++ b/nms-patches/ContainerPlayer.patch
@@ -1,6 +1,6 @@
--- a/net/minecraft/server/ContainerPlayer.java
+++ b/net/minecraft/server/ContainerPlayer.java
-@@ -1,28 +1,42 @@
+@@ -1,5 +1,10 @@
package net.minecraft.server;
+// CraftBukkit start
@@ -10,10 +10,11 @@
+
public class ContainerPlayer extends Container {
- public InventoryCrafting craftInventory = new InventoryCrafting(this, 2, 2);
+ private static final EnumItemSlot[] h = new EnumItemSlot[] { EnumItemSlot.HEAD, EnumItemSlot.CHEST, EnumItemSlot.LEGS, EnumItemSlot.FEET};
+@@ -7,10 +12,20 @@
public IInventory resultInventory = new InventoryCraftResult();
public boolean g;
- private final EntityHuman h;
+ private final EntityHuman owner;
+ // CraftBukkit start
+ private CraftInventoryView bukkitEntity = null;
+ private PlayerInventory player;
@@ -21,58 +22,39 @@
public ContainerPlayer(final PlayerInventory playerinventory, boolean flag, EntityHuman entityhuman) {
this.g = flag;
- this.h = entityhuman;
+ this.owner = entityhuman;
++ // CraftBukkit start
+ this.resultInventory = new InventoryCraftResult(); // CraftBukkit - moved to before InventoryCrafting construction
+ this.craftInventory = new InventoryCrafting(this, 2, 2, playerinventory.player); // CraftBukkit - pass player
+ this.craftInventory.resultInventory = this.resultInventory; // CraftBukkit - let InventoryCrafting know about its result slot
+ this.player = playerinventory; // CraftBukkit - save player
- this.a((Slot) (new SlotResult(playerinventory.player, this.craftInventory, this.resultInventory, 0, 144, 36)));
-
-- final int i;
-+ // CraftBukkit - fixed multiple decompiler errors below, good luck
- int j;
++ // CraftBukkit end
+ this.a((Slot) (new SlotResult(playerinventory.player, this.craftInventory, this.resultInventory, 0, 154, 28)));
-- for (i = 0; i < 2; ++i) {
-+ for (int i = 0; i < 2; ++i) {
- for (j = 0; j < 2; ++j) {
- this.a(new Slot(this.craftInventory, j + i * 2, 88 + j * 18, 26 + i * 18));
- }
+ int i;
+@@ -23,7 +38,7 @@
}
-- for (i = 0; i < 4; ++i) {
-- this.a(new Slot(playerinventory, playerinventory.getSize() - 1 - i, 8, 8 + i * 18) {
-+ for (int ii = 0; ii < 4; ++ii) {
-+ final int i = ii;
-+ this.a(new Slot(playerinventory, playerinventory.getSize() - 1 - ii, 8, 8 + ii * 18) {
- public int getMaxStackSize() {
- return 1;
- }
-@@ -33,21 +47,32 @@
- });
- }
+ for (i = 0; i < 4; ++i) {
+- final EnumItemSlot enumitemslot = ContainerPlayer.h[i];
++ final EnumItemSlot enumitemslot1 = ContainerPlayer.h[i];
-- for (i = 0; i < 3; ++i) {
-+ for (int i = 0; i < 3; ++i) {
- for (j = 0; j < 9; ++j) {
- this.a(new Slot(playerinventory, j + (i + 1) * 9, 8 + j * 18, 84 + i * 18));
+ this.a(new Slot(playerinventory, 36 + (3 - i), 8, 8 + i * 18) {
+ public int getMaxStackSize() {
+@@ -57,11 +72,22 @@
+ return super.isAllowed(itemstack);
}
- }
-
-- for (i = 0; i < 9; ++i) {
-+ for (int i = 0; i < 9; ++i) {
- this.a(new Slot(playerinventory, i, 8 + i * 18, 142));
- }
-
+ });
- this.a((IInventory) this.craftInventory);
+ // this.a((IInventory) this.craftInventory); // CraftBukkit - unneeded since it just sets result slot to empty
}
public void a(IInventory iinventory) {
-- this.resultInventory.setItem(0, CraftingManager.getInstance().craft(this.craftInventory, this.h.world));
-+ // this.resultInventory.setItem(0, CraftingManager.getInstance().craft(this.craftInventory, this.h.world));
+- this.resultInventory.setItem(0, CraftingManager.getInstance().craft(this.craftInventory, this.owner.world));
++ // this.resultInventory.setItem(0, CraftingManager.getInstance().craft(this.craftInventory, this.owner.world));
+ // CraftBukkit start (Note: the following line would cause an error if called during construction)
+ CraftingManager.getInstance().lastCraftView = getBukkitView();
-+ ItemStack craftResult = CraftingManager.getInstance().craft(this.craftInventory, this.h.world);
++ ItemStack craftResult = CraftingManager.getInstance().craft(this.craftInventory, this.owner.world);
+ this.resultInventory.setItem(0, craftResult);
+ if (super.listeners.size() < 1) {
+ return;
@@ -84,7 +66,7 @@
}
public void b(EntityHuman entityhuman) {
-@@ -127,4 +152,17 @@
+@@ -143,4 +169,17 @@
public boolean a(ItemStack itemstack, Slot slot) {
return slot.inventory != this.resultInventory && super.a(itemstack, slot);
}
diff --git a/nms-patches/CraftingManager.patch b/nms-patches/CraftingManager.patch
index 3a7c82ec..7435b9f8 100644
--- a/nms-patches/CraftingManager.patch
+++ b/nms-patches/CraftingManager.patch
@@ -17,10 +17,19 @@
public static CraftingManager getInstance() {
return CraftingManager.a;
-@@ -167,7 +173,12 @@
- this.registerShapedRecipe(new ItemStack(Blocks.DAYLIGHT_DETECTOR), new Object[] { "GGG", "QQQ", "WWW", Character.valueOf('G'), Blocks.GLASS, Character.valueOf('Q'), Items.QUARTZ, Character.valueOf('W'), Blocks.WOODEN_SLAB});
+@@ -32,7 +38,7 @@
+ this.recipes.add(new RecipeMapExtend());
+ this.recipes.add(new RecipeFireworks());
+ this.recipes.add(new RecipeRepair());
+- this.recipes.add(new RecipeTippedArrow());
++ // this.recipes.add(new RecipeTippedArrow());
+ (new RecipesBanner()).a(this);
+ (new RecipiesShield()).a(this);
+ this.registerShapedRecipe(new ItemStack(Items.PAPER, 3), new Object[] { "###", Character.valueOf('#'), Items.REEDS});
+@@ -176,7 +182,12 @@
this.registerShapedRecipe(new ItemStack(Blocks.HOPPER), new Object[] { "I I", "ICI", " I ", Character.valueOf('I'), Items.IRON_INGOT, Character.valueOf('C'), Blocks.CHEST});
this.registerShapedRecipe(new ItemStack(Items.ARMOR_STAND, 1), new Object[] { "///", " / ", "/_/", Character.valueOf('/'), Items.STICK, Character.valueOf('_'), new ItemStack(Blocks.STONE_SLAB, 1, BlockDoubleStepAbstract.EnumStoneSlabVariant.STONE.a())});
+ this.registerShapedRecipe(new ItemStack(Blocks.END_ROD, 4), new Object[] { "/", "#", Character.valueOf('/'), Items.BLAZE_ROD, Character.valueOf('#'), Items.CHORUS_FRUIT_POPPED});
- Collections.sort(this.recipes, new Comparator() {
+ sort();
+ }
@@ -31,7 +40,7 @@
public int a(IRecipe irecipe, IRecipe irecipe1) {
return irecipe instanceof ShapelessRecipes && irecipe1 instanceof ShapedRecipes ? 1 : (irecipe1 instanceof ShapelessRecipes && irecipe instanceof ShapedRecipes ? -1 : (irecipe1.a() < irecipe.a() ? -1 : (irecipe1.a() > irecipe.a() ? 1 : 0)));
}
-@@ -274,13 +285,18 @@
+@@ -283,13 +294,18 @@
do {
if (!iterator.hasNext()) {
diff --git a/nms-patches/DataPaletteBlock.patch b/nms-patches/DataPaletteBlock.patch
new file mode 100644
index 00000000..d761b41d
--- /dev/null
+++ b/nms-patches/DataPaletteBlock.patch
@@ -0,0 +1,25 @@
+--- a/net/minecraft/server/DataPaletteBlock.java
++++ b/net/minecraft/server/DataPaletteBlock.java
+@@ -109,7 +109,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
new file mode 100644
index 00000000..2afb3eb2
--- /dev/null
+++ b/nms-patches/DataWatcher.patch
@@ -0,0 +1,20 @@
+--- a/net/minecraft/server/DataWatcher.java
++++ b/net/minecraft/server/DataWatcher.java
+@@ -54,7 +54,7 @@
+ }
+ }
+
+- public <T> void register(DataWatcherObject<T> datawatcherobject, T t0) {
++ public <T> void register(DataWatcherObject<T> datawatcherobject, Object t0) { // CraftBukkit T -> Object
+ int i = datawatcherobject.a();
+
+ if (i > 254) {
+@@ -68,7 +68,7 @@
+ }
+ }
+
+- private <T> void registerObject(DataWatcherObject<T> datawatcherobject, T t0) {
++ private <T> void registerObject(DataWatcherObject<T> datawatcherobject, Object t0) { // CraftBukkit Object
+ DataWatcher.Item datawatcher_item = new DataWatcher.Item(datawatcherobject, t0);
+
+ this.d.writeLock().lock();
diff --git a/nms-patches/DedicatedServer.patch b/nms-patches/DedicatedServer.patch
index e1210d26..414085ff 100644
--- a/nms-patches/DedicatedServer.patch
+++ b/nms-patches/DedicatedServer.patch
@@ -1,6 +1,18 @@
--- a/net/minecraft/server/DedicatedServer.java
+++ b/net/minecraft/server/DedicatedServer.java
-@@ -15,10 +15,20 @@
+@@ -4,10 +4,9 @@
+ import com.mojang.authlib.GameProfileRepository;
+ import com.mojang.authlib.minecraft.MinecraftSessionService;
+ import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService;
+-import java.io.BufferedReader;
++
+ import java.io.File;
+ import java.io.IOException;
+-import java.io.InputStreamReader;
+ import java.net.InetAddress;
+ import java.net.Proxy;
+ import java.util.Collections;
+@@ -18,10 +17,20 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -17,25 +29,25 @@
public class DedicatedServer extends MinecraftServer implements IMinecraftServer {
private static final Logger LOGGER = LogManager.getLogger();
-- private final List<ServerCommand> l = Collections.synchronizedList(Lists.newArrayList());
-+ private final List<ServerCommand> l = Collections.synchronizedList(Lists.<ServerCommand>newArrayList()); // CraftBukkit - fix decompile error
+- 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 m;
- private RemoteControlListener n;
- public PropertyManager propertyManager;
-@@ -27,8 +37,10 @@
- private WorldSettings.EnumGamemode r;
- private boolean s;
-
-- public DedicatedServer(File file) {
-- super(file, Proxy.NO_PROXY, DedicatedServer.a);
+ public final RemoteControlCommandListener remoteControlCommandListener = new RemoteControlCommandListener(this);
+ private RemoteControlListener o;
+@@ -31,8 +40,10 @@
+ private WorldSettings.EnumGamemode s;
+ private boolean t;
+
+- public DedicatedServer(File file, DataConverterManager dataconvertermanager, YggdrasilAuthenticationService yggdrasilauthenticationservice, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache) {
+- super(file, Proxy.NO_PROXY, dataconvertermanager, yggdrasilauthenticationservice, minecraftsessionservice, gameprofilerepository, usercache);
+ // CraftBukkit start - Signature changed
-+ public DedicatedServer(joptsimple.OptionSet options) {
-+ super(options, Proxy.NO_PROXY, DedicatedServer.a);
++ 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);
+ // CraftBukkit end
Thread thread = new Thread("Server Infinisleeper") {
{
this.setDaemon(true);
-@@ -50,13 +62,27 @@
+@@ -54,13 +65,27 @@
protected boolean init() throws IOException {
Thread thread = new Thread("Server console handler") {
public void run() {
@@ -66,7 +78,7 @@
}
} catch (IOException ioexception) {
DedicatedServer.LOGGER.error("Exception handling console input", ioexception);
-@@ -65,6 +91,27 @@
+@@ -69,6 +94,27 @@
}
};
@@ -93,17 +105,17 @@
+
thread.setDaemon(true);
thread.start();
- DedicatedServer.LOGGER.info("Starting minecraft server version 1.8.8");
-@@ -73,7 +120,7 @@
+ DedicatedServer.LOGGER.info("Starting minecraft server version 1.9");
+@@ -77,7 +123,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.p = new EULA(new File("eula.txt"));
- if (!this.p.a()) {
+ this.q = new EULA(new File("eula.txt"));
+ if (!this.q.a()) {
DedicatedServer.LOGGER.info("You need to agree to the EULA in order to run the server. Go to eula.txt for more info.");
-@@ -129,6 +176,8 @@
+@@ -133,6 +179,8 @@
return false;
}
@@ -112,20 +124,20 @@
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.");
-@@ -143,7 +192,7 @@
+@@ -147,7 +195,7 @@
if (!NameReferencingFileConverter.a(this.propertyManager)) {
return false;
} else {
- this.a((PlayerList) (new DedicatedPlayerList(this)));
-+ this.convertable = new WorldLoaderServer(server.getWorldContainer()); // CraftBukkit - moved from MinecraftServer constructor
++ this.convertable = new WorldLoaderServer(server.getWorldContainer(), this.getDataConverterManager()); // CraftBukkit - moved from MinecraftServer constructor
long j = System.nanoTime();
- if (this.U() == null) {
-@@ -198,7 +247,18 @@
+ if (this.S() == null) {
+@@ -205,7 +253,18 @@
DedicatedServer.LOGGER.info("Starting remote control listener");
- this.n = new RemoteControlListener(this);
- this.n.a();
-+ this.remoteConsole = new org.bukkit.craftbukkit.command.CraftRemoteConsoleCommandSender(); // CraftBukkit
+ this.o = new RemoteControlListener(this);
+ this.o.a();
++ this.remoteConsole = new org.bukkit.craftbukkit.command.CraftRemoteConsoleCommandSender(this.remoteControlCommandListener); // CraftBukkit
+ }
+
+ // CraftBukkit start
@@ -138,39 +150,25 @@
}
+ // CraftBukkit end
- if (this.aS() > 0L) {
+ if (this.aP() > 0L) {
Thread thread1 = new Thread(new ThreadWatchdog(this));
-@@ -213,6 +273,12 @@
- }
- }
-
-+ // CraftBukkit start
-+ public PropertyManager getPropertyManager() {
-+ return this.propertyManager;
-+ }
-+ // CraftBukkit end
-+
- public void setGamemode(WorldSettings.EnumGamemode worldsettings_enumgamemode) {
- super.setGamemode(worldsettings_enumgamemode);
- this.r = worldsettings_enumgamemode;
-@@ -265,7 +331,7 @@
+@@ -298,7 +357,7 @@
System.exit(0);
}
-- protected void B() {
-+ public void B() { // CraftBukkit - fix decompile error
- super.B();
- this.aO();
+- protected void D() {
++ public void D() { // CraftBukkit - fix decompile error
+ super.D();
+ this.aL();
}
-@@ -296,7 +362,15 @@
- while (!this.l.isEmpty()) {
- ServerCommand servercommand = (ServerCommand) this.l.remove(0);
+@@ -329,7 +388,14 @@
+ while (!this.serverCommandQueue.isEmpty()) {
+ ServerCommand servercommand = (ServerCommand) this.serverCommandQueue.remove(0);
- this.getCommandHandler().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
@@ -179,7 +177,7 @@
}
}
-@@ -491,13 +565,60 @@
+@@ -536,16 +602,70 @@
}
public String getPlugins() {
@@ -200,17 +198,17 @@
+ if (i > 0) {
+ result.append("; ");
+ }
-
-- public String executeRemoteCommand(String s) {
-- RemoteControlCommandListener.getInstance().i();
-- this.b.a(RemoteControlCommandListener.getInstance(), s);
-- return RemoteControlCommandListener.getInstance().j();
++
+ 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
+ }
@@ -220,7 +218,7 @@
+ Waitable<String> waitable = new Waitable<String>() {
+ @Override
+ protected String evaluate() {
-+ RemoteControlCommandListener.getInstance().i();
++ remoteControlCommandListener.clearMessages();
+ // Event changes start
+ RemoteServerCommandEvent event = new RemoteServerCommandEvent(remoteConsole, s);
+ server.getPluginManager().callEvent(event);
@@ -228,9 +226,9 @@
+ return "";
+ }
+ // Event change end
-+ ServerCommand serverCommand = new ServerCommand(event.getCommand(), RemoteControlCommandListener.getInstance());
++ ServerCommand serverCommand = new ServerCommand(event.getCommand(), remoteControlCommandListener);
+ server.dispatchServerCommand(remoteConsole, serverCommand);
-+ return RemoteControlCommandListener.getInstance().j();
++ return remoteControlCommandListener.getMessages();
+ }
+ };
+ processQueue.add(waitable);
@@ -246,3 +244,13 @@
}
public PlayerList getPlayerList() {
+ return this.aM();
+ }
++
++ // CraftBukkit start
++ @Override
++ public PropertyManager getPropertyManager() {
++ return this.propertyManager;
++ }
++ // CraftBukkit end
+ }
diff --git a/nms-patches/DispenseBehaviorProjectile.patch b/nms-patches/DispenseBehaviorProjectile.patch
index 5cf558a8..2ce244de 100644
--- a/nms-patches/DispenseBehaviorProjectile.patch
+++ b/nms-patches/DispenseBehaviorProjectile.patch
@@ -12,8 +12,8 @@
public DispenseBehaviorProjectile() {}
@@ -10,9 +15,38 @@
- EnumDirection enumdirection = BlockDispenser.b(isourceblock.f());
- IProjectile iprojectile = this.a(world, iposition);
+ EnumDirection enumdirection = BlockDispenser.e(isourceblock.f());
+ IProjectile iprojectile = this.a(world, iposition, itemstack);
- iprojectile.shoot((double) enumdirection.getAdjacentX(), (double) ((float) enumdirection.getAdjacentY() + 0.1F), (double) enumdirection.getAdjacentZ(), this.getPower(), this.a());
+ // iprojectile.shoot((double) enumdirection.getAdjacentX(), (double) ((float) enumdirection.getAdjacentY() + 0.1F), (double) enumdirection.getAdjacentZ(), this.b(), this.a());
diff --git a/nms-patches/DispenserRegistry.patch b/nms-patches/DispenserRegistry.patch
index ba9e6a2f..66bb7d32 100644
--- a/nms-patches/DispenserRegistry.patch
+++ b/nms-patches/DispenserRegistry.patch
@@ -11,13 +11,31 @@
+
public class DispenserRegistry {
- private static final PrintStream a = System.out;
-@@ -74,13 +79,45 @@
+ public static final PrintStream a = System.out;
+@@ -69,7 +74,7 @@
+ BlockDispenser.REGISTRY.a(Items.SPLASH_POTION, new IDispenseBehavior() {
+ public ItemStack a(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());
+ }
+
+@@ -86,7 +91,7 @@
+ BlockDispenser.REGISTRY.a(Items.LINGERING_POTION, new IDispenseBehavior() {
+ public ItemStack a(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());
+ }
+
+@@ -106,14 +111,46 @@
double d0 = isourceblock.getX() + (double) enumdirection.getAdjacentX();
double d1 = (double) ((float) isourceblock.getBlockPosition().getY() + 0.2F);
double d2 = isourceblock.getZ() + (double) enumdirection.getAdjacentZ();
-- Entity entity = ItemMonsterEgg.a(isourceblock.getWorld(), itemstack.getData(), d0, d1, d2);
-+ // Entity entity = ItemMonsterEgg.a(isourceblock.getWorld(), itemstack.getData(), d0, d1, d2);
+- Entity entity = ItemMonsterEgg.a(isourceblock.getWorld(), ItemMonsterEgg.h(itemstack), d0, d1, d2);
++ // Entity entity = ItemMonsterEgg.a(isourceblock.getWorld(), ItemMonsterEgg.h(itemstack), d0, d1, d2);
+
+ // CraftBukkit start
+ World world = isourceblock.getWorld();
@@ -48,19 +66,20 @@
+
+ itemstack1 = CraftItemStack.asNMSCopy(event.getItem());
+
-+ Entity entity = ItemMonsterEgg.spawnCreature(isourceblock.getWorld(), itemstack.getData(), event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DISPENSE_EGG);
++ 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()) {
- ((EntityInsentient) entity).setCustomName(itemstack.getName());
+ entity.setCustomName(itemstack.getName());
}
+ ItemMonsterEgg.a(isourceblock.getWorld(), (EntityHuman) null, itemstack, entity);
- itemstack.cloneAndSubtract(1);
-+ // itemstack.a(1); // Handled during event processing
++ // itemstack.cloneAndSubtract(1);// Handled during event processing
+ // CraftBukkit end
return itemstack;
}
});
-@@ -90,10 +127,39 @@
+@@ -123,10 +160,39 @@
double d0 = isourceblock.getX() + (double) enumdirection.getAdjacentX();
double d1 = (double) ((float) isourceblock.getBlockPosition().getY() + 0.2F);
double d2 = isourceblock.getZ() + (double) enumdirection.getAdjacentZ();
@@ -97,12 +116,12 @@
isourceblock.getWorld().addEntity(entityfireworks);
- itemstack.cloneAndSubtract(1);
-+ // itemstack.a(1); // Handled during event processing
++ // itemstack.cloneAndSubtract(1); // Handled during event processing
+ // CraftBukkit end
return itemstack;
}
-@@ -114,8 +180,38 @@
+@@ -147,13 +213,44 @@
double d4 = random.nextGaussian() * 0.05D + (double) enumdirection.getAdjacentY();
double d5 = random.nextGaussian() * 0.05D + (double) enumdirection.getAdjacentZ();
@@ -134,66 +153,31 @@
+ }
+ }
+
-+ EntitySmallFireball entitysmallfireball = new EntitySmallFireball(world, d0, d1, d2, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ());
-+ entitysmallfireball.projectileSource = new org.bukkit.craftbukkit.projectiles.CraftBlockProjectileSource((TileEntityDispenser) isourceblock.getTileEntity());
++ EntitySmallFireball fireball = new EntitySmallFireball(world, d0, d1, d2, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ());
++ fireball.projectileSource = new org.bukkit.craftbukkit.projectiles.CraftBlockProjectileSource((TileEntityDispenser) isourceblock.getTileEntity());
+
-+ world.addEntity(entitysmallfireball);
++ world.addEntity(fireball);
+ // itemstack.a(1); // Handled during event processing
+ // CraftBukkit end
return itemstack;
}
-@@ -146,10 +242,38 @@
- d3 = 0.0D;
- }
-
-- EntityBoat entityboat = new EntityBoat(world, d0, d1 + d3, d2);
-+ // EntityBoat entityboat = new EntityBoat(world, d0, d1 + d3, d2);
-+ // CraftBukkit start
-+ 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 + d3, d2));
-+ if (!BlockDispenser.eventFired) {
-+ world.getServer().getPluginManager().callEvent(event);
-+ }
-+
-+ if (event.isCancelled()) {
-+ itemstack.count++;
-+ return itemstack;
-+ }
-+
-+ if (!event.getItem().equals(craftItem)) {
-+ itemstack.count++;
-+ // 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;
-+ }
-+ }
+ protected void a(ISourceBlock isourceblock) {
+ isourceblock.getWorld().triggerEffect(1018, isourceblock.getBlockPosition(), 0);
+
-+ EntityBoat entityboat = new EntityBoat(world, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ());
-+ // CraftBukkit end
-
- world.addEntity(entityboat);
-- itemstack.cloneAndSubtract(1);
-+ // itemstack.a(1); // CraftBukkit - handled during event processing
- return itemstack;
}
-
-@@ -164,9 +288,48 @@
+ });
+ BlockDispenser.REGISTRY.a(Items.aG, new DispenserRegistry.a(EntityBoat.EnumBoatType.OAK));
+@@ -169,9 +266,48 @@
ItemBucket itembucket = (ItemBucket) itemstack.getItem();
- BlockPosition blockposition = isourceblock.getBlockPosition().shift(BlockDispenser.b(isourceblock.f()));
+ BlockPosition blockposition = isourceblock.getBlockPosition().shift(BlockDispenser.e(isourceblock.f()));
+ // CraftBukkit start
+ World world = isourceblock.getWorld();
+ int x = blockposition.getX();
+ int y = blockposition.getY();
+ int z = blockposition.getZ();
-+ if (world.isEmpty(blockposition) || !world.getType(blockposition).getBlock().getMaterial().isBuildable()) {
++ if (world.isEmpty(blockposition) || !world.getType(blockposition).getMaterial().isBuildable()) {
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ());
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack);
+
@@ -218,9 +202,9 @@
+
+ itembucket = (ItemBucket) CraftItemStack.asNMSCopy(event.getItem()).getItem();
+ }
-+ // CraftBukkit end
++ // CraftBukkit end
+
- if (itembucket.a(isourceblock.getWorld(), blockposition)) {
+ if (itembucket.a((EntityHuman) null, isourceblock.getWorld(), blockposition)) {
- itemstack.setItem(Items.BUCKET);
- itemstack.count = 1;
+ // CraftBukkit start - Handle stacked buckets
@@ -235,7 +219,7 @@
return itemstack;
} else {
return this.b.a(isourceblock, itemstack);
-@@ -197,6 +360,30 @@
+@@ -202,6 +338,30 @@
item = Items.LAVA_BUCKET;
}
@@ -266,9 +250,9 @@
world.setAir(blockposition);
if (--itemstack.count == 0) {
itemstack.setItem(item);
-@@ -215,11 +402,39 @@
+@@ -220,11 +380,39 @@
World world = isourceblock.getWorld();
- BlockPosition blockposition = isourceblock.getBlockPosition().shift(BlockDispenser.b(isourceblock.f()));
+ BlockPosition blockposition = isourceblock.getBlockPosition().shift(BlockDispenser.e(isourceblock.f()));
+ // CraftBukkit start
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ());
@@ -309,9 +293,9 @@
} 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);
-@@ -247,6 +462,30 @@
+@@ -252,6 +440,30 @@
World world = isourceblock.getWorld();
- BlockPosition blockposition = isourceblock.getBlockPosition().shift(BlockDispenser.b(isourceblock.f()));
+ BlockPosition blockposition = isourceblock.getBlockPosition().shift(BlockDispenser.e(isourceblock.f()));
+ // CraftBukkit start
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ());
@@ -340,10 +324,10 @@
if (ItemDye.a(itemstack, world, blockposition)) {
if (!world.isClientSide) {
world.triggerEffect(2005, blockposition, 0);
-@@ -274,11 +513,40 @@
+@@ -279,11 +491,40 @@
protected ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) {
World world = isourceblock.getWorld();
- BlockPosition blockposition = isourceblock.getBlockPosition().shift(BlockDispenser.b(isourceblock.f()));
+ BlockPosition blockposition = isourceblock.getBlockPosition().shift(BlockDispenser.e(isourceblock.f()));
- EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(world, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, (EntityLiving) null);
+ // EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(world, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, (EntityLiving) null);
+
@@ -352,7 +336,7 @@
+ 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(blockposition.getX() + 0.5, blockposition.getY() + 0.5, blockposition.getZ() + 0.5));
++ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector((double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D));
+ if (!BlockDispenser.eventFired) {
+ world.getServer().getPluginManager().callEvent(event);
+ }
@@ -377,9 +361,52 @@
+ // CraftBukkit end
world.addEntity(entitytntprimed);
- world.makeSound(entitytntprimed, "game.tnt.primed", 1.0F, 1.0F);
+ world.a((EntityHuman) null, entitytntprimed.locX, entitytntprimed.locY, entitytntprimed.locZ, SoundEffects.gj, SoundCategory.BLOCKS, 1.0F, 1.0F);
- --itemstack.count;
+ // --itemstack.count; // CraftBukkit - handled above
return itemstack;
}
});
+@@ -437,12 +678,40 @@
+ d3 = 0.0D;
+ }
+
+- EntityBoat entityboat = new EntityBoat(world, d0, d1 + d3, d2);
++ // EntityBoat entityboat = new EntityBoat(world, d0, d1 + d3, d2);
++ // CraftBukkit start
++ 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 + d3, d2));
++ if (!BlockDispenser.eventFired) {
++ world.getServer().getPluginManager().callEvent(event);
++ }
++
++ if (event.isCancelled()) {
++ itemstack.count++;
++ return itemstack;
++ }
++
++ if (!event.getItem().equals(craftItem)) {
++ itemstack.count++;
++ // 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;
++ }
++ }
++
++ EntityBoat entityboat = new EntityBoat(world, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ());
++ // CraftBukkit end
+
+ entityboat.a(this.c);
+ entityboat.yaw = enumdirection.opposite().l();
+ world.addEntity(entityboat);
+- itemstack.cloneAndSubtract(1);
++ // itemstack.cloneAndSubtract(1); // CraftBukkit - handled during event processing
+ return itemstack;
+ }
+
diff --git a/nms-patches/Enchantment.patch b/nms-patches/Enchantment.patch
index 5e419c5f..ddddc8e0 100644
--- a/nms-patches/Enchantment.patch
+++ b/nms-patches/Enchantment.patch
@@ -1,19 +1,23 @@
--- a/net/minecraft/server/Enchantment.java
+++ b/net/minecraft/server/Enchantment.java
-@@ -8,6 +8,7 @@
+@@ -16,7 +16,7 @@
+ }
- public abstract class Enchantment {
+ public static int getId(Enchantment enchantment) {
+- return Enchantment.enchantments.a((Object) enchantment);
++ return Enchantment.enchantments.a(enchantment); // CraftBukkit - fix decompile error
+ }
-+ // CraftBukkit - update CraftEnchant.getName(i) if this changes
- private static final Enchantment[] byId = new Enchantment[256];
- public static final Enchantment[] b;
- private static final Map<MinecraftKey, Enchantment> E = Maps.newHashMap();
-@@ -55,6 +56,8 @@
- Enchantment.byId[i] = this;
- Enchantment.E.put(minecraftkey, this);
- }
-+
-+ org.bukkit.enchantments.Enchantment.registerEnchantment(new org.bukkit.craftbukkit.enchantments.CraftEnchantment(this)); // CraftBukkit
+ public static Enchantment b(String s) {
+@@ -135,6 +135,11 @@
+ Enchantment.enchantments.a(61, new MinecraftKey("luck_of_the_sea"), new EnchantmentLootBonus(Enchantment.Rarity.RARE, EnchantmentSlotType.FISHING_ROD, new EnumItemSlot[] { EnumItemSlot.MAINHAND}));
+ 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()));
++ // CraftBukkit start
++ for (Enchantment enchantment : Enchantment.enchantments) {
++ org.bukkit.enchantments.Enchantment.registerEnchantment(new org.bukkit.craftbukkit.enchantments.CraftEnchantment(enchantment));
++ }
++ // CraftBukkit end
}
- public static Enchantment getByName(String s) {
+ public static enum Rarity {
diff --git a/nms-patches/EnchantmentThorns.patch b/nms-patches/EnchantmentThorns.patch
index 1329a104..82ffbcd9 100644
--- a/nms-patches/EnchantmentThorns.patch
+++ b/nms-patches/EnchantmentThorns.patch
@@ -1,11 +1,11 @@
--- a/net/minecraft/server/EnchantmentThorns.java
+++ b/net/minecraft/server/EnchantmentThorns.java
@@ -29,7 +29,7 @@
- Random random = entityliving.bc();
- ItemStack itemstack = EnchantmentManager.a(Enchantment.THORNS, entityliving);
+ Random random = entityliving.getRandom();
+ ItemStack itemstack = EnchantmentManager.b(Enchantments.THORNS, entityliving);
- if (a(i, random)) {
+ if (entity != null && a(i, random)) { // CraftBukkit
if (entity != null) {
entity.damageEntity(DamageSource.a(entityliving), (float) b(i, random));
- entity.makeSound("damage.thorns", 0.5F, 1.0F);
+ }
diff --git a/nms-patches/Entity.patch b/nms-patches/Entity.patch
index 6e7195e1..d33d1882 100644
--- a/nms-patches/Entity.patch
+++ b/nms-patches/Entity.patch
@@ -1,8 +1,8 @@
--- a/net/minecraft/server/Entity.java
+++ b/net/minecraft/server/Entity.java
-@@ -6,8 +6,40 @@
- import java.util.UUID;
- import java.util.concurrent.Callable;
+@@ -15,8 +15,47 @@
+ import org.apache.logging.log4j.LogManager;
+ import org.apache.logging.log4j.Logger;
+// CraftBukkit start
+import org.bukkit.Bukkit;
@@ -12,11 +12,9 @@
+import org.bukkit.block.BlockFace;
+import org.bukkit.entity.Hanging;
+import org.bukkit.entity.LivingEntity;
-+import org.bukkit.entity.Painting;
+import org.bukkit.entity.Vehicle;
+import org.bukkit.event.entity.EntityCombustByEntityEvent;
+import org.bukkit.event.hanging.HangingBreakByEntityEvent;
-+import org.bukkit.event.painting.PaintingBreakByEntityEvent;
+import org.bukkit.event.vehicle.VehicleBlockCollisionEvent;
+import org.bukkit.event.vehicle.VehicleEnterEvent;
+import org.bukkit.event.vehicle.VehicleExitEvent;
@@ -36,22 +34,31 @@
+ static boolean isLevelAtLeast(NBTTagCompound tag, int level) {
+ return tag.hasKey("Bukkit.updateLevel") && tag.getInt("Bukkit.updateLevel") >= level;
+ }
++
++ protected CraftEntity bukkitEntity;
++
++ public CraftEntity getBukkitEntity() {
++ if (bukkitEntity == null) {
++ bukkitEntity = CraftEntity.getEntity(world.getServer(), this);
++ }
++ return bukkitEntity;
++ }
+ // CraftBukikt end
+
- private static final AxisAlignedBB a = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D);
- private static int entityCount;
- private int id;
-@@ -79,6 +111,9 @@
- private boolean invulnerable;
- protected UUID uniqueID;
- private final CommandObjectiveExecutor au;
+ private static final Logger a = LogManager.getLogger();
+ private static final AxisAlignedBB b = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D);
+ private static double c = 1.0D;
+@@ -97,6 +136,9 @@
+ public boolean glowing;
+ private final Set<String> aF;
+ private boolean aG;
+ public boolean valid; // CraftBukkit
+ public org.bukkit.projectiles.ProjectileSource projectileSource; // CraftBukkit - For projectiles only
+ public boolean forceExplosionKnockback; // CraftBukkit - SPIGOT-949
- public int getId() {
- return this.id;
-@@ -152,6 +187,33 @@
+ public Entity(World world) {
+ this.id = Entity.entityCount++;
+@@ -193,6 +235,33 @@
}
protected void setYawPitch(float f, float f1) {
@@ -85,16 +92,16 @@
this.yaw = f % 360.0F;
this.pitch = f1 % 360.0F;
}
-@@ -188,7 +250,7 @@
- int i = this.L();
-
+@@ -236,7 +305,7 @@
if (this.ak) {
+ MinecraftServer minecraftserver = this.world.getMinecraftServer();
+
- if (minecraftserver.getAllowNether()) {
+ if (true || minecraftserver.getAllowNether()) { // CraftBukkit
- if (this.vehicle == null && this.al++ >= i) {
- this.al = i;
- this.portalCooldown = this.aq();
-@@ -265,6 +327,27 @@
+ if (!this.isPassenger()) {
+ int i = this.V();
+
+@@ -321,6 +390,27 @@
protected void burnFromLava() {
if (!this.fireProof) {
this.damageEntity(DamageSource.LAVA, 4.0F);
@@ -122,7 +129,7 @@
this.setOnFire(15);
}
}
-@@ -302,6 +385,22 @@
+@@ -361,6 +451,22 @@
this.a(this.getBoundingBox().c(d0, d1, d2));
this.recalcPosition();
} else {
@@ -138,15 +145,15 @@
+ throw new ReportedException(crashreport);
+ }
+ // Check if we're moving
-+ if (d0 == 0 && d1 == 0 && d2 == 0 && this.vehicle == null && this.passenger == null) {
++ if (d0 == 0 && d1 == 0 && d2 == 0 && this.isVehicle() && this.isPassenger()) {
+ return;
+ }
+ // CraftBukkit end
this.world.methodProfiler.a("move");
double d3 = this.locX;
double d4 = this.locY;
-@@ -522,6 +621,26 @@
- block.a(this.world, this);
+@@ -585,6 +691,26 @@
+ block1.a(this.world, this);
}
+ // CraftBukkit start
@@ -169,23 +176,23 @@
+ }
+ // CraftBukkit end
+
- if (this.s_() && !flag && this.vehicle == null) {
+ if (this.playStepSound() && !flag && !this.isPassenger()) {
double d21 = this.locX - d3;
double d22 = this.locY - d4;
-@@ -532,7 +651,7 @@
+@@ -595,7 +721,7 @@
}
- if (block != null && this.onGround) {
-- block.a(this.world, blockposition, this);
-+ // block.a(this.world, blockposition, this); // CraftBukkit moved down
+ if (block1 != null && this.onGround) {
+- block1.stepOn(this.world, blockposition, this);
++ // block1.stepOn(this.world, blockposition, this); // CraftBukkit moved down
}
- this.M = (float) ((double) this.M + (double) MathHelper.sqrt(d21 * d21 + d23 * d23) * 0.6D);
-@@ -550,9 +669,12 @@
+ this.J = (float) ((double) this.J + (double) MathHelper.sqrt(d21 * d21 + d10 * d10) * 0.6D);
+@@ -613,9 +739,12 @@
}
- this.a(blockposition, block);
-+ block.a(this.world, blockposition, this); // CraftBukkit moved from above
+ this.a(blockposition, block1);
++ block1.stepOn(this.world, blockposition, this); // CraftBukkit moved from above
}
}
@@ -194,16 +201,16 @@
try {
this.checkBlockCollisions();
} catch (Throwable throwable) {
-@@ -562,6 +684,8 @@
+@@ -625,6 +754,8 @@
this.appendEntityCrashDetails(crashreportsystemdetails);
throw new ReportedException(crashreport);
}
+ */
+ // CraftBukkit end
- boolean flag2 = this.U();
+ boolean flag2 = this.ah();
-@@ -569,7 +693,16 @@
+@@ -632,7 +763,16 @@
this.burn(1);
if (!flag2) {
++this.fireTicks;
@@ -221,7 +228,7 @@
this.setOnFire(8);
}
}
-@@ -675,7 +808,7 @@
+@@ -745,7 +885,7 @@
return null;
}
@@ -230,7 +237,7 @@
if (!this.fireProof) {
this.damageEntity(DamageSource.FIRE, (float) i);
}
-@@ -818,6 +951,13 @@
+@@ -911,6 +1051,13 @@
}
public void spawnIn(World world) {
@@ -244,7 +251,7 @@
this.world = world;
}
-@@ -1010,6 +1150,18 @@
+@@ -1104,6 +1251,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}));
@@ -263,36 +270,37 @@
nbttagcompound.set("Rotation", this.a(new float[] { this.yaw, this.pitch}));
nbttagcompound.setFloat("FallDistance", this.fallDistance);
nbttagcompound.setShort("Fire", (short) this.fireTicks);
-@@ -1020,6 +1172,11 @@
+@@ -1113,6 +1272,12 @@
+ nbttagcompound.setBoolean("Invulnerable", this.invulnerable);
nbttagcompound.setInt("PortalCooldown", this.portalCooldown);
- nbttagcompound.setLong("UUIDMost", this.getUniqueID().getMostSignificantBits());
- nbttagcompound.setLong("UUIDLeast", this.getUniqueID().getLeastSignificantBits());
+ nbttagcompound.a("UUID", this.getUniqueID());
+ // CraftBukkit start
++ // PAIL: Check above UUID reads 1.8 properly, ie: UUIDMost / UUIDLeast
+ nbttagcompound.setLong("WorldUUIDLeast", this.world.getDataManager().getUUID().getLeastSignificantBits());
+ nbttagcompound.setLong("WorldUUIDMost", this.world.getDataManager().getUUID().getMostSignificantBits());
+ nbttagcompound.setInt("Bukkit.updateLevel", CURRENT_LEVEL);
+ // CraftBukkit end
- if (this.getCustomName() != null && this.getCustomName().length() > 0) {
+ if (this.getCustomName() != null && !this.getCustomName().isEmpty()) {
nbttagcompound.setString("CustomName", this.getCustomName());
- nbttagcompound.setBoolean("CustomNameVisible", this.getCustomNameVisible());
-@@ -1057,6 +1214,8 @@
- this.motX = nbttaglist1.d(0);
- this.motY = nbttaglist1.d(1);
- this.motZ = nbttaglist1.d(2);
+ }
+@@ -1183,6 +1348,8 @@
+ this.motX = nbttaglist1.e(0);
+ this.motY = nbttaglist1.e(1);
+ this.motZ = nbttaglist1.e(2);
+
+ /* CraftBukkit start - Moved section down
if (Math.abs(this.motX) > 10.0D) {
this.motX = 0.0D;
}
-@@ -1068,6 +1227,7 @@
+@@ -1194,6 +1361,7 @@
if (Math.abs(this.motZ) > 10.0D) {
this.motZ = 0.0D;
}
+ // CraftBukkit end */
- this.lastX = this.P = this.locX = nbttaglist.d(0);
- this.lastY = this.Q = this.locY = nbttaglist.d(1);
-@@ -1103,6 +1263,58 @@
+ this.lastX = this.M = this.locX = nbttaglist.e(0);
+ this.lastY = this.N = this.locY = nbttaglist.e(1);
+@@ -1241,6 +1409,58 @@
this.setPosition(this.locX, this.locY, this.locZ);
}
@@ -351,7 +359,7 @@
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.a(throwable, "Loading entity NBT");
CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Entity being loaded");
-@@ -1164,6 +1376,12 @@
+@@ -1302,6 +1522,12 @@
public EntityItem a(ItemStack itemstack, float f) {
if (itemstack.count != 0 && itemstack.getItem() != null) {
@@ -363,79 +371,54 @@
+ // CraftBukkit end
EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY + (double) f, this.locZ, itemstack);
- entityitem.p();
-@@ -1277,17 +1495,70 @@
- return (double) this.length * 0.75D;
- }
-
-+ // CraftBukkit start
-+ protected CraftEntity bukkitEntity;
-+
-+ public CraftEntity getBukkitEntity() {
-+ if (bukkitEntity == null) {
-+ bukkitEntity = CraftEntity.getEntity(world.getServer(), this);
-+ }
-+ return bukkitEntity;
-+ }
-+
- public void mount(Entity entity) {
-+ Entity originalVehicle = this.vehicle;
-+ Entity originalPassenger = this.vehicle == null ? null : this.vehicle.passenger;
-+ PluginManager pluginManager = Bukkit.getPluginManager();
-+ getBukkitEntity(); // make sure bukkitEntity is initialised
-+ // CraftBukkit end
- this.ar = 0.0D;
- this.as = 0.0D;
- if (entity == null) {
- if (this.vehicle != null) {
-+ // CraftBukkit start
-+ if ((this.bukkitEntity instanceof LivingEntity) && (this.vehicle.getBukkitEntity() instanceof Vehicle)) {
-+ VehicleExitEvent event = new VehicleExitEvent((Vehicle) this.vehicle.getBukkitEntity(), (LivingEntity) this.bukkitEntity);
-+ pluginManager.callEvent(event);
-+
-+ if (event.isCancelled() || vehicle != originalVehicle) {
-+ return;
-+ }
-+ }
-+ // CraftBukkit end
- this.setPositionRotation(this.vehicle.locX, this.vehicle.getBoundingBox().b + (double) this.vehicle.length, this.vehicle.locZ, this.yaw, this.pitch);
- this.vehicle.passenger = null;
- }
-
- this.vehicle = null;
+ entityitem.q();
+@@ -1422,6 +1648,22 @@
+ if (entity.by() != this) {
+ throw new IllegalStateException("Use x.startRiding(y), not y.addPassenger(x)");
} else {
+ // CraftBukkit start
-+ if ((this.bukkitEntity instanceof LivingEntity) && (entity.getBukkitEntity() instanceof Vehicle) && entity.world.isChunkLoaded((int) entity.locX >> 4, (int) entity.locZ >> 4, true)) {
-+ // It's possible to move from one vehicle to another. We need to check if they're already in a vehicle, and fire an exit event if they are.
-+ VehicleExitEvent exitEvent = null;
-+ if (this.vehicle != null && this.vehicle.getBukkitEntity() instanceof Vehicle) {
-+ exitEvent = new VehicleExitEvent((Vehicle) this.vehicle.getBukkitEntity(), (LivingEntity) this.bukkitEntity);
-+ pluginManager.callEvent(exitEvent);
-+
-+ if (exitEvent.isCancelled() || this.vehicle != originalVehicle || (this.vehicle != null && this.vehicle.passenger != originalPassenger)) {
-+ return;
-+ }
++ CraftEntity craft = (CraftEntity) entity.getBukkitEntity().getVehicle();
++ Entity orig = craft == null ? null : craft.getHandle();
++ if (getBukkitEntity() instanceof Vehicle && entity.getBukkitEntity() instanceof LivingEntity) {
++ VehicleEnterEvent event = new VehicleEnterEvent(
++ (Vehicle) getBukkitEntity(),
++ entity.getBukkitEntity()
++ );
++ Bukkit.getPluginManager().callEvent(event);
++ CraftEntity craftn = (CraftEntity) entity.getBukkitEntity().getVehicle();
++ Entity n = craftn == null ? null : craftn.getHandle();
++ if (event.isCancelled() || n != orig) {
++ return;
+ }
-+
-+ VehicleEnterEvent event = new VehicleEnterEvent((Vehicle) entity.getBukkitEntity(), this.bukkitEntity);
-+ pluginManager.callEvent(event);
-+
-+ // If a plugin messes with the vehicle or the vehicle's passenger
-+ if (event.isCancelled() || this.vehicle != originalVehicle || (this.vehicle != null && this.vehicle.passenger != originalPassenger)) {
-+ // If we only cancelled the enterevent then we need to put the player in a decent position.
-+ if (exitEvent != null && this.vehicle == originalVehicle && this.vehicle != null && this.vehicle.passenger == originalPassenger) {
-+ this.setPositionRotation(this.vehicle.locX, this.vehicle.getBoundingBox().b + (double) this.vehicle.length, this.vehicle.locZ, this.yaw, this.pitch);
-+ this.vehicle.passenger = null;
-+ this.vehicle = null;
-+ }
++ }
++ // CraftBukkit end
+ if (!this.world.isClientSide && entity instanceof EntityHuman && !(this.bt() instanceof EntityHuman)) {
+ this.passengers.add(0, entity);
+ } else {
+@@ -1435,6 +1677,22 @@
+ if (entity.by() == this) {
+ throw new IllegalStateException("Use x.stopRiding(y), not y.removePassenger(x)");
+ } else {
++ // CraftBukkit start
++ CraftEntity craft = (CraftEntity) entity.getBukkitEntity().getVehicle();
++ Entity orig = craft == null ? null : craft.getHandle();
++ if (getBukkitEntity() instanceof Vehicle && entity.getBukkitEntity() instanceof LivingEntity) {
++ VehicleExitEvent event = new VehicleExitEvent(
++ (Vehicle) getBukkitEntity(),
++ (LivingEntity) entity.getBukkitEntity()
++ );
++ Bukkit.getPluginManager().callEvent(event);
++ CraftEntity craftn = (CraftEntity) entity.getBukkitEntity().getVehicle();
++ Entity n = craftn == null ? null : craftn.getHandle();
++ if (event.isCancelled() || n != orig) {
+ return;
+ }
+ }
+ // CraftBukkit end
- if (this.vehicle != null) {
- this.vehicle.passenger = null;
- }
-@@ -1406,10 +1677,49 @@
+ this.passengers.remove(entity);
+ entity.j = 60;
+ }
+@@ -1577,10 +1835,38 @@
}
public void onLightningStrike(EntityLightning entitylightning) {
@@ -447,20 +430,9 @@
+
+ if (thisBukkitEntity instanceof Hanging) {
+ HangingBreakByEntityEvent hangingEvent = new HangingBreakByEntityEvent((Hanging) thisBukkitEntity, stormBukkitEntity);
-+ PaintingBreakByEntityEvent paintingEvent = null;
-+
-+ if (thisBukkitEntity instanceof Painting) {
-+ paintingEvent = new PaintingBreakByEntityEvent((Painting) thisBukkitEntity, stormBukkitEntity);
-+ }
-+
+ pluginManager.callEvent(hangingEvent);
+
-+ if (paintingEvent != null) {
-+ paintingEvent.setCancelled(hangingEvent.isCancelled());
-+ pluginManager.callEvent(paintingEvent);
-+ }
-+
-+ if (hangingEvent.isCancelled() || (paintingEvent != null && paintingEvent.isCancelled())) {
++ if (hangingEvent.isCancelled()) {
+ return;
+ }
+ }
@@ -487,14 +459,14 @@
}
}
-@@ -1550,32 +1860,83 @@
+@@ -1715,19 +2001,67 @@
if (!this.world.isClientSide && !this.dead) {
this.world.methodProfiler.a("changeDimension");
- MinecraftServer minecraftserver = MinecraftServer.getServer();
+ MinecraftServer minecraftserver = this.h();
- int j = this.dimension;
- WorldServer worldserver = minecraftserver.getWorldServer(j);
- WorldServer worldserver1 = minecraftserver.getWorldServer(i);
-+ // CraftBukkit start - Move logic into new function "teleportToLocation"
++ // CraftBukkit start - Move logic into new function "teleportTo(Location,boolean)"
+ // int j = this.dimension;
+ // WorldServer worldserver = minecraftserver.getWorldServer(j);
+ // WorldServer worldserver1 = minecraftserver.getWorldServer(i);
@@ -508,8 +480,19 @@
+ }
+ }
+
++ BlockPosition blockposition = null; // PAIL: CHECK
+ Location enter = this.getBukkitEntity().getLocation();
-+ Location exit = exitWorld != null ? minecraftserver.getPlayerList().calculateTarget(enter, minecraftserver.getWorldServer(i)) : null;
++ Location exit;
++ if (exitWorld != null) {
++ if (blockposition != null) {
++ exit = new Location(exitWorld.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ());
++ } else {
++ exit = minecraftserver.getPlayerList().calculateTarget(enter, minecraftserver.getWorldServer(i));
++ }
++ }
++ else {
++ exit = null;
++ }
+ boolean useTravelAgent = exitWorld != null && !(this.dimension == 1 && exitWorld.dimension == 1); // don't use agent for custom worlds or return from THE_END
+
+ TravelAgent agent = exit != null ? (TravelAgent) ((CraftWorld) exit.getWorld()).getHandle().getTravelAgent() : org.bukkit.craftbukkit.CraftTravelAgent.DEFAULT; // return arbitrary TA to compensate for implementation dependent plugins
@@ -517,14 +500,15 @@
+ event.useTravelAgent(useTravelAgent);
+ event.getEntity().getServer().getPluginManager().callEvent(event);
+ if (event.isCancelled() || event.getTo() == null || event.getTo().getWorld() == null || !this.isAlive()) {
-+ return;
++ return null;
+ }
+ exit = event.useTravelAgent() ? event.getPortalTravelAgent().findOrCreate(event.getTo()) : event.getTo();
-+ this.teleportTo(exit, true);
++ return this.teleportTo(exit, true);
+ }
++ return null;
+ }
+
-+ public void teleportTo(Location exit, boolean portal) {
++ public Entity teleportTo(Location exit, boolean portal) {
+ if (true) {
+ WorldServer worldserver = ((CraftWorld) getBukkitEntity().getLocation().getWorld()).getHandle();
+ WorldServer worldserver1 = ((CraftWorld) exit.getWorld()).getHandle();
@@ -542,28 +526,42 @@
this.world.kill(this);
this.dead = false;
this.world.methodProfiler.a("reposition");
-- minecraftserver.getPlayerList().changeWorld(this, j, worldserver, worldserver1);
++ /* CraftBukkit start - Handled in calculateTarget
+ BlockPosition blockposition;
+
+ if (i == 1) {
+@@ -1756,12 +2090,18 @@
+ blockposition = new BlockPosition(this);
+ }
+
+- worldserver.entityJoinedWorld(this, false);
++ // CraftBukkit end */
+ // CraftBukkit start - Ensure chunks are loaded in case TravelAgent is not used which would initially cause chunks to load during find/create
+ // minecraftserver.getPlayerList().changeWorld(this, j, worldserver, worldserver1);
-+ boolean before = worldserver1.chunkProviderServer.forceChunkLoad;
-+ worldserver1.chunkProviderServer.forceChunkLoad = true;
+ worldserver1.getMinecraftServer().getPlayerList().repositionEntity(this, exit, portal);
-+ worldserver1.chunkProviderServer.forceChunkLoad = before;
++ // worldserver.entityJoinedWorld(this, false); // Handled in repositionEntity
+ // CraftBukkit end
this.world.methodProfiler.c("reloading");
Entity entity = EntityTypes.createEntityByName(EntityTypes.b(this), worldserver1);
if (entity != null) {
- entity.n(this);
+ entity.a(this);
+ /* CraftBukkit start - We need to do this...
if (j == 1 && i == 1) {
- BlockPosition blockposition = this.world.r(worldserver1.getSpawn());
+ BlockPosition blockposition1 = worldserver1.q(worldserver1.getSpawn());
+@@ -1769,6 +2109,7 @@
+ } else {
entity.setPositionRotation(blockposition, entity.yaw, entity.pitch);
}
+ // CraftBukkit end */
+ boolean flag = entity.attachedToPlayer;
+
+@@ -1776,6 +2117,14 @@
worldserver1.addEntity(entity);
+ entity.attachedToPlayer = flag;
+ worldserver1.entityJoinedWorld(entity, false);
+ // CraftBukkit start - Forward the CraftEntity to the new entity
+ this.getBukkitEntity().setHandle(entity);
+ entity.bukkitEntity = this.getBukkitEntity();
@@ -575,7 +573,7 @@
}
this.dead = true;
-@@ -1670,6 +2031,11 @@
+@@ -1881,6 +2230,11 @@
}
public void setCustomName(String s) {
@@ -584,10 +582,10 @@
+ s = s.substring(0, 256);
+ }
+ // CraftBukkit end
- this.datawatcher.watch(2, s);
+ this.datawatcher.set(Entity.az, s);
}
-@@ -1721,7 +2087,26 @@
+@@ -1938,7 +2292,26 @@
}
public void a(AxisAlignedBB axisalignedbb) {
@@ -615,3 +613,12 @@
}
public float getHeadHeight() {
+@@ -2110,7 +2483,7 @@
+ for (Iterator iterator = this.bu().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 deef0f26..8aba8a6a 100644
--- a/nms-patches/EntityAgeable.patch
+++ b/nms-patches/EntityAgeable.patch
@@ -1,14 +1,14 @@
--- a/net/minecraft/server/EntityAgeable.java
+++ b/net/minecraft/server/EntityAgeable.java
-@@ -7,6 +7,7 @@
+@@ -8,6 +8,7 @@
protected int c;
- private float bm = -1.0F;
- private float bn;
-+ public boolean ageLocked = false; // CraftBukkit
+ private float bw = -1.0F;
+ private float bx;
++ public boolean ageLocked; // CraftBukkit
public EntityAgeable(World world) {
super(world);
-@@ -27,14 +28,14 @@
+@@ -26,13 +27,16 @@
if (entityageable != null) {
entityageable.setAgeRaw(-24000);
entityageable.setPositionRotation(this.locX, this.locY, this.locZ, 0.0F, 0.0F);
@@ -20,12 +20,13 @@
if (!entityhuman.abilities.canInstantlyBuild) {
--itemstack.count;
-- if (itemstack.count <= 0) {
+ if (itemstack.count == 0) { // CraftBukkit - allow less than 0 stacks as "infinite"
- entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, (ItemStack) null);
- }
++ entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, (ItemStack) null);
++ }
}
-@@ -99,17 +100,19 @@
+ }
+ }
+@@ -95,12 +99,14 @@
super.b(nbttagcompound);
nbttagcompound.setInt("Age", this.getAge());
nbttagcompound.setInt("ForcedAge", this.b);
@@ -39,19 +40,13 @@
+ this.ageLocked = nbttagcompound.getBoolean("AgeLocked"); // CraftBukkit
}
- public void m() {
- super.m();
+ public void a(DataWatcherObject<?> datawatcherobject) {
+@@ -113,7 +119,7 @@
+
+ public void n() {
+ super.n();
- 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]);
-@@ -146,7 +149,7 @@
- this.a(flag ? 0.5F : 1.0F);
- }
-
-- protected final void setSize(float f, float f1) {
-+ public final void setSize(float f, float f1) { // CraftBukkit - protected to public
- boolean flag = this.bm > 0.0F;
-
- this.bm = f;
diff --git a/nms-patches/EntityAnimal.patch b/nms-patches/EntityAnimal.patch
index ee030381..d289c413 100644
--- a/nms-patches/EntityAnimal.patch
+++ b/nms-patches/EntityAnimal.patch
@@ -17,4 +17,4 @@
+ // CraftBukkit end */
public float a(BlockPosition blockposition) {
- return this.world.getType(blockposition.down()).getBlock() == Blocks.GRASS ? 10.0F : this.world.o(blockposition) - 0.5F;
+ return this.world.getType(blockposition.down()).getBlock() == Blocks.GRASS ? 10.0F : this.world.n(blockposition) - 0.5F;
diff --git a/nms-patches/EntityArmorStand.patch b/nms-patches/EntityArmorStand.patch
index d7b6f74c..9eb9bb36 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
-@@ -2,6 +2,15 @@
-
+@@ -4,6 +4,15 @@
+ import java.util.Arrays;
import java.util.List;
+// CraftBukkit start
@@ -15,19 +15,19 @@
+
public class EntityArmorStand extends EntityLiving {
- private static final Vector3f a = new Vector3f(0.0F, 0.0F, 0.0F);
-@@ -332,6 +341,22 @@
- ItemStack itemstack1 = entityhuman.inventory.getItem(j);
+ private static final Vector3f bp = new Vector3f(0.0F, 0.0F, 0.0F);
+@@ -360,6 +369,21 @@
+ if (itemstack1 == null || (this.bz & 1 << enumitemslot.c() + 8) == 0) {
+ if (itemstack1 != null || (this.bz & 1 << enumitemslot.c() + 16) == 0) {
ItemStack itemstack2;
-
+ // CraftBukkit start
-+ org.bukkit.inventory.ItemStack armorStandItem = CraftItemStack.asCraftMirror(itemstack);
-+ org.bukkit.inventory.ItemStack playerHeldItem = CraftItemStack.asCraftMirror(itemstack1);
++ org.bukkit.inventory.ItemStack armorStandItem = CraftItemStack.asCraftMirror(itemstack1);
++ org.bukkit.inventory.ItemStack playerHeldItem = CraftItemStack.asCraftMirror(itemstack);
+
+ Player player = (Player) entityhuman.getBukkitEntity();
+ ArmorStand self = (ArmorStand) this.getBukkitEntity();
+
-+ EquipmentSlot slot = CraftEquipmentSlot.getSlot(i);
++ EquipmentSlot slot = CraftEquipmentSlot.getSlot(enumitemslot);
+ PlayerArmorStandManipulateEvent armorStandManipulateEvent = new PlayerArmorStandManipulateEvent(player,self,playerHeldItem,armorStandItem,slot);
+ this.world.getServer().getPluginManager().callEvent(armorStandManipulateEvent);
+
@@ -35,11 +35,10 @@
+ return;
+ }
+ // CraftBukkit end
-+
- if (entityhuman.abilities.canInstantlyBuild && (itemstack == null || itemstack.getItem() == Item.getItemOf(Blocks.AIR)) && itemstack1 != null) {
- itemstack2 = itemstack1.cloneItemStack();
- itemstack2.count = 1;
-@@ -352,6 +377,11 @@
+
+ if (entityhuman.abilities.canInstantlyBuild && (itemstack1 == null || itemstack1.getItem() == Item.getItemOf(Blocks.AIR)) && itemstack != null) {
+ itemstack2 = itemstack.cloneItemStack();
+@@ -381,6 +405,11 @@
}
public boolean damageEntity(DamageSource damagesource, float f) {
@@ -48,24 +47,6 @@
+ return false;
+ }
+ // CraftBukkit end
- if (this.world.isClientSide) {
- return false;
- } else if (DamageSource.OUT_OF_WORLD.equals(damagesource)) {
-@@ -616,7 +646,8 @@
- return (this.datawatcher.getByte(10) & 8) != 0;
- }
-
-- private void n(boolean flag) {
-+ // PAIL
-+ public void n(boolean flag) { // CraftBukkit - public
- byte b0 = this.datawatcher.getByte(10);
-
- if (flag) {
-@@ -628,6 +659,7 @@
- this.datawatcher.watch(10, Byte.valueOf(b0));
- }
-
-+ // PAIL
- public boolean s() {
- return (this.datawatcher.getByte(10) & 16) != 0;
- }
+ if (!this.world.isClientSide && !this.dead) {
+ if (DamageSource.OUT_OF_WORLD.equals(damagesource)) {
+ this.die();
diff --git a/nms-patches/EntityArrow.patch b/nms-patches/EntityArrow.patch
index de6af82d..cfda50e8 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
-@@ -2,6 +2,12 @@
-
+@@ -4,6 +4,12 @@
+ import com.google.common.base.Predicates;
import java.util.List;
+// CraftBukkit start
@@ -10,62 +10,54 @@
+import org.bukkit.event.player.PlayerPickupItemEvent;
+// CraftBukkit end
+
- public class EntityArrow extends Entity implements IProjectile {
+ public abstract class EntityArrow extends Entity implements IProjectile {
- private int d = -1;
-@@ -35,6 +41,7 @@
- super(world);
- this.j = 10.0D;
- this.shooter = entityliving;
-+ this.projectileSource = (LivingEntity) entityliving.getBukkitEntity(); // CraftBukkit
- if (entityliving instanceof EntityHuman) {
- this.fromPlayer = 1;
- }
-@@ -62,6 +69,7 @@
- super(world);
- this.j = 10.0D;
+ private static final Predicate<Entity> f = Predicates.and(new Predicate[] { IEntitySelector.e, IEntitySelector.a, new Predicate() {
+@@ -49,6 +55,7 @@
+ public EntityArrow(World world, EntityLiving entityliving) {
+ this(world, entityliving.locX, entityliving.locY + (double) entityliving.getHeadHeight() - 0.10000000149011612D, entityliving.locZ);
this.shooter = entityliving;
+ this.projectileSource = (LivingEntity) entityliving.getBukkitEntity(); // CraftBukkit
if (entityliving instanceof EntityHuman) {
- this.fromPlayer = 1;
+ this.fromPlayer = EntityArrow.PickupStatus.ALLOWED;
}
-@@ -201,6 +209,7 @@
- float f3;
+@@ -228,7 +235,7 @@
- if (movingobjectposition != null) {
-+ org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this); // CraftBukkit - Call event
- if (movingobjectposition.entity != null) {
- f2 = MathHelper.sqrt(this.motX * this.motX + this.motY * this.motY + this.motZ * this.motZ);
- int k = MathHelper.f((double) f2 * this.damage);
-@@ -217,11 +226,18 @@
- damagesource = DamageSource.arrow(this, this.shooter);
- }
+ protected void a(MovingObjectPosition movingobjectposition) {
+ Entity entity = movingobjectposition.entity;
+-
++ org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this); // 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);
+@@ -245,11 +252,18 @@
+ damagesource = DamageSource.arrow(this, this.shooter);
+ }
-- if (this.isBurning() && !(movingobjectposition.entity instanceof EntityEnderman)) {
-- movingobjectposition.entity.setOnFire(5);
-+ // CraftBukkit start - Moved damage call
-+ if (movingobjectposition.entity.damageEntity(damagesource, (float) k)) {
-+ if (this.isBurning() && !(movingobjectposition.entity instanceof EntityEnderman) && (!(movingobjectposition.entity instanceof EntityPlayer) || !(this.shooter instanceof EntityPlayer) || this.world.pvpMode)) { // CraftBukkit - abide by pvp setting if destination is a player
-+ EntityCombustByEntityEvent combustEvent = new EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), 5);
-+ org.bukkit.Bukkit.getPluginManager().callEvent(combustEvent);
-+ if (!combustEvent.isCancelled()) {
-+ movingobjectposition.entity.setOnFire(combustEvent.getDuration());
-+ }
-+ // CraftBukkit end
- }
++ // CraftBukkit start - Moved damage call
++ if (movingobjectposition.entity.damageEntity(damagesource, (float) i)) {
+ if (this.isBurning() && !(entity instanceof EntityEnderman)) {
+- entity.setOnFire(5);
++ 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 (movingobjectposition.entity.damageEntity(damagesource, (float) k)) {
-+ // if (movingobjectposition.entity.damageEntity(damagesource, (float) k)) { // CraftBukkit - moved up
- if (movingobjectposition.entity instanceof EntityLiving) {
- EntityLiving entityliving = (EntityLiving) movingobjectposition.entity;
+- if (entity.damageEntity(damagesource, (float) i)) {
++ // if (entity.damageEntity(damagesource, (float) i)) { // CraftBukkit - moved up
+ if (entity instanceof EntityLiving) {
+ EntityLiving entityliving = (EntityLiving) entity;
-@@ -383,6 +399,20 @@
+@@ -395,6 +409,20 @@
public void d(EntityHuman entityhuman) {
if (!this.world.isClientSide && this.inGround && this.shake <= 0) {
+ // CraftBukkit start
+ ItemStack itemstack = new ItemStack(Items.ARROW);
-+ if (this.fromPlayer == 1 && entityhuman.inventory.canHold(itemstack) > 0) {
++ if (this.fromPlayer == PickupStatus.ALLOWED && entityhuman.inventory.canHold(itemstack) > 0) {
+ EntityItem item = new EntityItem(this.world, this.locX, this.locY, this.locZ, itemstack);
+
+ PlayerPickupItemEvent event = new PlayerPickupItemEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), new org.bukkit.craftbukkit.entity.CraftItem(this.world.getServer(), this, item), 0);
@@ -77,17 +69,19 @@
+ }
+ }
+ // CraftBukkit end
- boolean flag = this.fromPlayer == 1 || this.fromPlayer == 2 && entityhuman.abilities.canInstantlyBuild;
-
- if (this.fromPlayer == 1 && !entityhuman.inventory.pickup(new ItemStack(Items.ARROW, 1))) {
-@@ -438,4 +468,10 @@
+ boolean flag = this.fromPlayer == EntityArrow.PickupStatus.ALLOWED || this.fromPlayer == EntityArrow.PickupStatus.CREATIVE_ONLY && entityhuman.abilities.canInstantlyBuild;
+ if (this.fromPlayer == EntityArrow.PickupStatus.ALLOWED && !entityhuman.inventory.pickup(this.j())) {
+@@ -453,6 +481,12 @@
return (b0 & 1) != 0;
}
-+
+
+ // CraftBukkit start
+ public boolean isInGround() {
+ return inGround;
+ }
+ // CraftBukkit end
- }
++
+ public static enum PickupStatus {
+
+ DISALLOWED, ALLOWED, CREATIVE_ONLY;
diff --git a/nms-patches/EntityBoat.patch b/nms-patches/EntityBoat.patch
index 8545c289..dc42b7a6 100644
--- a/nms-patches/EntityBoat.patch
+++ b/nms-patches/EntityBoat.patch
@@ -1,12 +1,11 @@
--- a/net/minecraft/server/EntityBoat.java
+++ b/net/minecraft/server/EntityBoat.java
-@@ -2,6 +2,16 @@
-
+@@ -4,6 +4,15 @@
+ import java.util.ArrayList;
import java.util.List;
+// CraftBukkit start
+import org.bukkit.Location;
-+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.entity.Vehicle;
+import org.bukkit.event.vehicle.VehicleDamageEvent;
+import org.bukkit.event.vehicle.VehicleDestroyEvent;
@@ -16,46 +15,32 @@
+
public class EntityBoat extends Entity {
- private boolean a;
-@@ -13,6 +23,27 @@
- private double g;
- private double h;
+ private static final DataWatcherObject<Integer> a = DataWatcher.a(EntityBoat.class, DataWatcherRegistry.b);
+@@ -31,6 +40,14 @@
+ private EntityBoat.EnumStatus aG;
+ private double aH;
+ // CraftBukkit start
++ // PAIL: Some of these haven't worked since a few updates, and since 1.9 they are less and less applicable.
+ public double maxSpeed = 0.4D;
+ public double occupiedDeceleration = 0.2D;
+ public double unoccupiedDeceleration = -1;
+ public boolean landBoats = false;
-+
-+ @Override
-+ public void collide(Entity entity) {
-+ org.bukkit.entity.Entity hitEntity = (entity == null) ? null : entity.getBukkitEntity();
-+
-+ VehicleEntityCollisionEvent event = new VehicleEntityCollisionEvent((Vehicle) this.getBukkitEntity(), hitEntity);
-+ this.world.getServer().getPluginManager().callEvent(event);
-+
-+ if (event.isCancelled()) {
-+ return;
-+ }
-+
-+ super.collide(entity);
-+ }
+ // CraftBukkit end
+
public EntityBoat(World world) {
super(world);
- this.a = true;
-@@ -52,6 +83,8 @@
+ this.f = new float[2];
+@@ -47,6 +64,7 @@
this.lastX = d0;
this.lastY = d1;
this.lastZ = d2;
-+
+ this.world.getServer().getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleCreateEvent((Vehicle) this.getBukkitEntity())); // CraftBukkit
}
- public double an() {
-@@ -65,6 +98,19 @@
- if (this.passenger != null && this.passenger == damagesource.getEntity() && damagesource instanceof EntityDamageSourceIndirect) {
+ protected boolean playStepSound() {
+@@ -88,6 +106,19 @@
+ if (damagesource instanceof EntityDamageSourceIndirect && damagesource.getEntity() != null && this.w(damagesource.getEntity())) {
return false;
} else {
+ // CraftBukkit start
@@ -71,13 +56,13 @@
+ // f = event.getDamage(); // TODO Why don't we do this?
+ // CraftBukkit end
+
- this.b(-this.m());
- this.a(10);
- this.setDamage(this.j() + f * 10.0F);
-@@ -72,6 +118,15 @@
+ this.d(-this.q());
+ this.b(10);
+ this.setDamage(this.n() + f * 10.0F);
+@@ -95,6 +126,15 @@
boolean flag = damagesource.getEntity() instanceof EntityHuman && ((EntityHuman) damagesource.getEntity()).abilities.canInstantlyBuild;
- if (flag || this.j() > 40.0F) {
+ if (flag || this.n() > 40.0F) {
+ // CraftBukkit start
+ VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, attacker);
+ this.world.getServer().getPluginManager().callEvent(destroyEvent);
@@ -87,101 +72,56 @@
+ return true;
+ }
+ // CraftBukkit end
- if (this.passenger != null) {
- this.passenger.mount(this);
+ if (!flag && this.world.getGameRules().getBoolean("doEntityDrops")) {
+ this.a(this.j(), 1, 0.0F);
}
-@@ -95,6 +150,13 @@
- }
-
- public void t_() {
-+ // CraftBukkit start
-+ double prevX = this.locX;
-+ double prevY = this.locY;
-+ double prevZ = this.locZ;
-+ float prevYaw = this.yaw;
-+ float prevPitch = this.pitch;
-+ // CraftBukkit end
- super.t_();
- if (this.l() > 0) {
- this.a(this.l() - 1);
-@@ -196,6 +258,19 @@
- this.motX += -Math.sin((double) (f * 3.1415927F / 180.0F)) * this.b * (double) entityliving.ba * 0.05000000074505806D;
- this.motZ += Math.cos((double) (f * 3.1415927F / 180.0F)) * this.b * (double) entityliving.ba * 0.05000000074505806D;
- }
-+ // CraftBukkit start - Support unoccupied deceleration
-+ else if (unoccupiedDeceleration >= 0) {
-+ this.motX *= unoccupiedDeceleration;
-+ this.motZ *= unoccupiedDeceleration;
-+ // Kill lingering speed
-+ if (motX <= 0.00001) {
-+ motX = 0;
-+ }
-+ if (motZ <= 0.00001) {
-+ motZ = 0;
+@@ -112,9 +152,25 @@
+ public void collide(Entity entity) {
+ if (entity instanceof EntityBoat) {
+ if (entity.getBoundingBox().b < this.getBoundingBox().e) {
++ // CraftBukkit start
++ VehicleEntityCollisionEvent event = new VehicleEntityCollisionEvent((Vehicle) this.getBukkitEntity(), entity.getBukkitEntity());
++ this.world.getServer().getPluginManager().callEvent(event);
++
++ if (event.isCancelled()) {
++ return;
+ }
++ // CraftBukkit end
+ super.collide(entity);
+ }
+ } else if (entity.getBoundingBox().b <= this.getBoundingBox().b) {
++ // CraftBukkit start
++ VehicleEntityCollisionEvent event = new VehicleEntityCollisionEvent((Vehicle) this.getBukkitEntity(), entity.getBukkitEntity());
++ this.world.getServer().getPluginManager().callEvent(event);
++
++ if (event.isCancelled()) {
++ return;
+ }
+ // CraftBukkit end
+ super.collide(entity);
+ }
- d4 = Math.sqrt(this.motX * this.motX + this.motZ * this.motZ);
- if (d4 > 0.35D) {
-@@ -230,16 +305,26 @@
- Block block = this.world.getType(blockposition).getBlock();
+@@ -172,6 +228,10 @@
+ this.setDamage(this.n() - 1.0F);
+ }
- if (block == Blocks.SNOW_LAYER) {
-+ // CraftBukkit start
-+ if (CraftEventFactory.callEntityChangeBlockEvent(this, l, j1, j, Blocks.AIR, 0).isCancelled()) {
-+ continue;
-+ }
-+ // CraftBukkit end
- this.world.setAir(blockposition);
- this.positionChanged = false;
- } else if (block == Blocks.WATERLILY) {
-+ // CraftBukkit start
-+ if (CraftEventFactory.callEntityChangeBlockEvent(this, l, j1, j, Blocks.AIR, 0).isCancelled()) {
-+ continue;
-+ }
-+ // CraftBukkit end
- this.world.setAir(blockposition, true);
- this.positionChanged = false;
- }
- }
++ // CraftBukkit start
++ float prevYaw = this.yaw;
++ float prevPitch = this.pitch;
++ // CraftBukkit end
+ this.lastX = this.locX;
+ this.lastY = this.locY;
+ this.lastZ = this.locZ;
+@@ -189,6 +249,22 @@
}
-- if (this.onGround) {
-+ if (this.onGround && !this.landBoats) { // CraftBukkit
- this.motX *= 0.5D;
- this.motY *= 0.5D;
- this.motZ *= 0.5D;
-@@ -248,6 +333,11 @@
this.move(this.motX, this.motY, this.motZ);
- if (this.positionChanged && d3 > 0.2975D) {
- if (!this.world.isClientSide && !this.dead) {
-+ // CraftBukkit start
-+ Vehicle vehicle = (Vehicle) this.getBukkitEntity();
-+ VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, null);
-+ this.world.getServer().getPluginManager().callEvent(destroyEvent);
-+ if (!destroyEvent.isCancelled()) {
- this.die();
- if (this.world.getGameRules().getBoolean("doEntityDrops")) {
- for (k = 0; k < 3; ++k) {
-@@ -258,6 +348,7 @@
- this.a(Items.STICK, 1, 0.0F);
- }
- }
-+ } // CraftBukkit end
- }
- } else {
- this.motX *= 0.9900000095367432D;
-@@ -285,6 +376,22 @@
-
- this.yaw = (float) ((double) this.yaw + d12);
- this.setYawPitch(this.yaw, this.pitch);
-+
+ // CraftBukkit start
++ // PAIL: CHECK ME
+ org.bukkit.Server server = this.world.getServer();
+ org.bukkit.World bworld = this.world.getWorld();
+
-+ Location from = new Location(bworld, prevX, prevY, prevZ, prevYaw, prevPitch);
++ Location from = new Location(bworld, this.lastX, this.lastY, this.lastZ, prevYaw, prevPitch);
+ Location to = new Location(bworld, this.locX, this.locY, this.locZ, this.yaw, this.pitch);
+ Vehicle vehicle = (Vehicle) this.getBukkitEntity();
+
@@ -192,31 +132,23 @@
+ server.getPluginManager().callEvent(event);
+ }
+ // CraftBukkit end
- if (!this.world.isClientSide) {
- List list = this.world.getEntities(this, this.getBoundingBox().grow(0.20000000298023224D, 0.0D, 0.20000000298023224D));
-
-@@ -299,6 +406,7 @@
- }
-
- if (this.passenger != null && this.passenger.dead) {
-+ this.passenger.vehicle = null; // CraftBukkit
- this.passenger = null;
- }
+ } else {
+ this.motX = 0.0D;
+ this.motY = 0.0D;
+@@ -591,6 +667,11 @@
-@@ -336,6 +444,11 @@
- if (this.fallDistance > 3.0F) {
- this.e(this.fallDistance, 1.0F);
- if (!this.world.isClientSide && !this.dead) {
+ this.e(this.fallDistance, 1.0F);
+ if (!this.world.isClientSide && !this.dead) {
+ // CraftBukkit start
+ Vehicle vehicle = (Vehicle) this.getBukkitEntity();
+ VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, null);
+ this.world.getServer().getPluginManager().callEvent(destroyEvent);
+ if (!destroyEvent.isCancelled()) {
- this.die();
- if (this.world.getGameRules().getBoolean("doEntityDrops")) {
- int i;
-@@ -348,6 +461,7 @@
- this.a(Items.STICK, 1, 0.0F);
+ this.die();
+ if (this.world.getGameRules().getBoolean("doEntityDrops")) {
+ int i;
+@@ -604,6 +685,7 @@
+ }
}
}
+ } // CraftBukkit end
diff --git a/nms-patches/EntityChicken.patch b/nms-patches/EntityChicken.patch
index 190c7252..fdad0420 100644
--- a/nms-patches/EntityChicken.patch
+++ b/nms-patches/EntityChicken.patch
@@ -1,14 +1,14 @@
--- a/net/minecraft/server/EntityChicken.java
+++ b/net/minecraft/server/EntityChicken.java
-@@ -35,6 +35,11 @@
+@@ -43,6 +43,11 @@
}
- public void m() {
+ public void n() {
+ // CraftBukkit start
+ if (this.isChickenJockey()) {
+ this.persistent = !this.isTypeNotPersistent();
+ }
+ // CraftBukkit end
- super.m();
- this.bq = this.bm;
- this.bp = this.bo;
+ super.n();
+ this.bz = this.bv;
+ this.bx = this.bw;
diff --git a/nms-patches/EntityCow.patch b/nms-patches/EntityCow.patch
index af9721a8..d702c87d 100644
--- a/nms-patches/EntityCow.patch
+++ b/nms-patches/EntityCow.patch
@@ -11,14 +11,10 @@
public class EntityCow extends EntityAnimal {
public EntityCow(World world) {
-@@ -71,11 +76,21 @@
- ItemStack itemstack = entityhuman.inventory.getItemInHand();
+@@ -50,12 +55,22 @@
+ public boolean a(EntityHuman entityhuman, EnumHand enumhand, ItemStack itemstack) {
if (itemstack != null && itemstack.getItem() == Items.BUCKET && !entityhuman.abilities.canInstantlyBuild && !this.isBaby()) {
-- if (itemstack.count-- == 1) {
-- entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, new ItemStack(Items.MILK_BUCKET));
-- } else if (!entityhuman.inventory.pickup(new ItemStack(Items.MILK_BUCKET))) {
-- entityhuman.drop(new ItemStack(Items.MILK_BUCKET, 1, 0), false);
+ // CraftBukkit start - Got milk?
+ org.bukkit.Location loc = this.getBukkitEntity().getLocation();
+ org.bukkit.event.player.PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent(entityhuman, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), null, itemstack, Items.MILK_BUCKET);
@@ -28,8 +24,13 @@
+ }
+
+ ItemStack result = CraftItemStack.asNMSCopy(event.getItemStack());
+ entityhuman.a(SoundEffects.ap, 1.0F, 1.0F);
+- if (--itemstack.count == 0) {
+- entityhuman.a(enumhand, new ItemStack(Items.MILK_BUCKET));
+- } else if (!entityhuman.inventory.pickup(new ItemStack(Items.MILK_BUCKET))) {
+- entityhuman.drop(new ItemStack(Items.MILK_BUCKET), false);
+ if (--itemstack.count <= 0) {
-+ entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, result);
++ entityhuman.a(enumhand, result);
+ } else if (!entityhuman.inventory.pickup(result)) {
+ entityhuman.drop(result, false);
}
diff --git a/nms-patches/EntityCreature.patch b/nms-patches/EntityCreature.patch
index 5101551c..ecc84756 100644
--- a/nms-patches/EntityCreature.patch
+++ b/nms-patches/EntityCreature.patch
@@ -10,8 +10,8 @@
+
public abstract class EntityCreature extends EntityInsentient {
- public static final UUID bk = UUID.fromString("E199AD21-BA8A-4C53-8D13-6182D5C69D3A");
-@@ -69,6 +73,7 @@
+ public static final UUID bt = UUID.fromString("E199AD21-BA8A-4C53-8D13-6182D5C69D3A");
+@@ -71,6 +75,7 @@
if (this instanceof EntityTameableAnimal && ((EntityTameableAnimal) this).isSitting()) {
if (f > 10.0F) {
@@ -19,11 +19,11 @@
this.unleash(true, true);
}
-@@ -100,6 +105,7 @@
+@@ -103,6 +108,7 @@
}
if (f > 10.0F) {
+ this.world.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE)); // CraftBukkit
this.unleash(true, true);
}
- } else if (!this.cc() && this.bm) {
+ } else if (!this.isLeashed() && this.bv) {
diff --git a/nms-patches/EntityCreeper.patch b/nms-patches/EntityCreeper.patch
index 3b023cba..121e3955 100644
--- a/nms-patches/EntityCreeper.patch
+++ b/nms-patches/EntityCreeper.patch
@@ -10,40 +10,42 @@
+
public class EntityCreeper extends EntityMonster {
- private int a;
-@@ -7,6 +12,7 @@
+ private static final DataWatcherObject<Integer> a = DataWatcher.a(EntityCreeper.class, DataWatcherRegistry.b);
+@@ -10,6 +15,7 @@
private int maxFuseTicks = 30;
private int explosionRadius = 3;
- private int bn = 0;
+ private int bz = 0;
+ private int record = -1; // CraftBukkit
public EntityCreeper(World world) {
super(world);
-@@ -110,19 +116,39 @@
+@@ -117,21 +123,41 @@
}
public void die(DamageSource damagesource) {
- super.die(damagesource);
+ // super.die(damagesource); // CraftBukkit - Moved to end
- if (damagesource.getEntity() instanceof EntitySkeleton) {
- int i = Item.getId(Items.RECORD_13);
- int j = Item.getId(Items.RECORD_WAIT);
- int k = i + this.random.nextInt(j - i + 1);
+ if (this.world.getGameRules().getBoolean("doMobLoot")) {
+ if (damagesource.getEntity() instanceof EntitySkeleton) {
+ int i = Item.getId(Items.RECORD_13);
+ int j = Item.getId(Items.RECORD_WAIT);
+ int k = i + this.random.nextInt(j - i + 1);
-- this.a(Item.getById(k), 1);
-+ // CraftBukkit start - Store record for now, drop in dropDeathLoot
-+ // this.a(Item.getById(k), 1);
-+ this.record = k;
-+ // CraftBukkit end
- } else if (damagesource.getEntity() instanceof EntityCreeper && damagesource.getEntity() != this && ((EntityCreeper) damagesource.getEntity()).isPowered() && ((EntityCreeper) damagesource.getEntity()).cp()) {
- ((EntityCreeper) damagesource.getEntity()).cq();
-- this.a(new ItemStack(Items.SKULL, 1, 4), 0.0F);
-+ // CraftBukkit start
-+ // this.a(new ItemStack(Items.SKULL, 1, 4), 0.0F);
-+ headDrop = new ItemStack(Items.SKULL, 1, 4);
-+ // CraftBukkit end
+- this.a(Item.getById(k), 1);
++ // CraftBukkit start - Store record for now, drop in dropDeathLoot
++ // this.a(Item.getById(k), 1);
++ this.record = k;
++ // CraftBukkit end
+ } else if (damagesource.getEntity() instanceof EntityCreeper && damagesource.getEntity() != this && ((EntityCreeper) damagesource.getEntity()).isPowered() && ((EntityCreeper) damagesource.getEntity()).canCauseHeadDrop()) {
+ ((EntityCreeper) damagesource.getEntity()).setCausedHeadDrop();
+- this.a(new ItemStack(Items.SKULL, 1, 4), 0.0F);
++ // CraftBukkit start
++ // this.a(new ItemStack(Items.SKULL, 1, 4), 0.0F);
++ headDrop = new ItemStack(Items.SKULL, 1, 4);
++ // CraftBukkit end
+ }
}
-+
+
+ super.die(damagesource); // CraftBukkit - Moved from above
+ }
+
@@ -51,7 +53,7 @@
+ @Override
+ protected void dropDeathLoot(boolean flag, int i) {
+ super.dropDeathLoot(flag, i);
-
++
+ // Drop a music disc?
+ if (this.record != -1) {
+ this.a(Item.getById(this.record), 1);
@@ -60,13 +62,12 @@
}
+ // CraftBukkit end
- public boolean r(Entity entity) {
+ public boolean B(Entity entity) {
return true;
-@@ -146,7 +172,21 @@
+@@ -155,8 +181,18 @@
public void onLightningStrike(EntityLightning entitylightning) {
super.onLightningStrike(entitylightning);
-- this.datawatcher.watch(17, Byte.valueOf((byte) 1));
+ // CraftBukkit start
+ if (CraftEventFactory.callCreeperPowerEvent(this, entitylightning, org.bukkit.event.entity.CreeperPowerEvent.PowerCause.LIGHTNING).isCancelled()) {
+ return;
@@ -76,24 +77,24 @@
+ }
+
+ public void setPowered(boolean powered) {
-+ if (!powered) {
-+ this.datawatcher.watch(17, Byte.valueOf((byte) 0));
-+ } else {
-+ this.datawatcher.watch(17, Byte.valueOf((byte) 1));
-+ }
-+ // CraftBukkit end
+ this.datawatcher.set(EntityCreeper.b, Boolean.valueOf(true));
}
++ // CraftBukkit end
- protected boolean a(EntityHuman entityhuman) {
-@@ -170,8 +210,15 @@
+ protected boolean a(EntityHuman entityhuman, EnumHand enumhand, ItemStack itemstack) {
+ if (itemstack != null && itemstack.getItem() == Items.FLINT_AND_STEEL) {
+@@ -177,9 +213,17 @@
boolean flag = this.world.getGameRules().getBoolean("mobGriefing");
float f = this.isPowered() ? 2.0F : 1.0F;
+- this.aT = true;
- this.world.explode(this, this.locX, this.locY, this.locZ, (float) this.explosionRadius * f, flag);
- this.die();
++ // CraftBukkit start
+ ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), this.explosionRadius * f, false);
+ this.world.getServer().getPluginManager().callEvent(event);
+ if (!event.isCancelled()) {
++ this.aT = true;
+ this.world.createExplosion(this, this.locX, this.locY, this.locZ, event.getRadius(), event.getFire(), flag);
+ this.die();
+ } else {
diff --git a/nms-patches/EntityDamageSourceIndirect.patch b/nms-patches/EntityDamageSourceIndirect.patch
index 6896c49c..fe6a74a9 100644
--- a/nms-patches/EntityDamageSourceIndirect.patch
+++ b/nms-patches/EntityDamageSourceIndirect.patch
@@ -2,7 +2,7 @@
+++ b/net/minecraft/server/EntityDamageSourceIndirect.java
@@ -25,4 +25,10 @@
- return itemstack != null && 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 != null && itemstack.hasName() && LocaleI18n.c(s1) ? new ChatMessage(s1, new Object[] { entityliving.getScoreboardDisplayName(), ichatbasecomponent, itemstack.B()}) : new ChatMessage(s, new Object[] { entityliving.getScoreboardDisplayName(), ichatbasecomponent});
}
+
+ // CraftBukkit start
diff --git a/nms-patches/EntityEnderCrystal.patch b/nms-patches/EntityEnderCrystal.patch
index 3e39d778..41f4cf39 100644
--- a/nms-patches/EntityEnderCrystal.patch
+++ b/nms-patches/EntityEnderCrystal.patch
@@ -1,7 +1,8 @@
--- a/net/minecraft/server/EntityEnderCrystal.java
+++ b/net/minecraft/server/EntityEnderCrystal.java
-@@ -1,5 +1,10 @@
- package net.minecraft.server;
+@@ -2,6 +2,11 @@
+
+ import com.google.common.base.Optional;
+// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
@@ -10,21 +11,21 @@
+
public class EntityEnderCrystal extends Entity {
- public int a;
-@@ -32,7 +37,11 @@
- int k = MathHelper.floor(this.locZ);
+ private static final DataWatcherObject<Optional<BlockPosition>> b = DataWatcher.a(EntityEnderCrystal.class, DataWatcherRegistry.k);
+@@ -38,7 +43,11 @@
+ BlockPosition blockposition = new BlockPosition(this);
- if (this.world.worldProvider instanceof WorldProviderTheEnd && this.world.getType(new BlockPosition(i, j, k)).getBlock() != Blocks.FIRE) {
-- this.world.setTypeUpdate(new BlockPosition(i, j, k), Blocks.FIRE.getBlockData());
-+ // CraftBukkit start
-+ if (!CraftEventFactory.callBlockIgniteEvent(this.world, i, j, k, this).isCancelled()) {
-+ this.world.setTypeUpdate(new BlockPosition(i, j, k), Blocks.FIRE.getBlockData());
-+ }
-+ // CraftBukkit end
+ if (this.world.worldProvider instanceof WorldProviderTheEnd && this.world.getType(blockposition).getBlock() != Blocks.FIRE) {
+- this.world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData());
++ // CraftBukkit start
++ if (!CraftEventFactory.callBlockIgniteEvent(this.world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this).isCancelled()) {
++ this.world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData());
++ }
++ // CraftBukkit end
+ }
}
- }
-@@ -50,11 +59,24 @@
+@@ -74,9 +83,22 @@
return false;
} else {
if (!this.dead && !this.world.isClientSide) {
@@ -33,20 +34,18 @@
+ return false;
+ }
+ // CraftBukkit end
- this.b = 0;
- if (this.b <= 0) {
- this.die();
- if (!this.world.isClientSide) {
-- this.world.explode((Entity) null, this.locX, this.locY, this.locZ, 6.0F, true);
-+ // CraftBukkit start
-+ ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), 6.0F, false);
-+ this.world.getServer().getPluginManager().callEvent(event);
-+ if (event.isCancelled()) {
-+ this.dead = false;
-+ return false;
-+ }
-+ this.world.createExplosion(this, this.locX, this.locY, this.locZ, event.getRadius(), event.getFire(), true);
-+ // CraftBukkit end
- }
+ this.die();
+ if (!this.world.isClientSide) {
+- this.world.explode((Entity) null, this.locX, this.locY, this.locZ, 6.0F, true);
++ // CraftBukkit start
++ ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), 6.0F, true);
++ this.world.getServer().getPluginManager().callEvent(event);
++ if (event.isCancelled()) {
++ this.dead = false;
++ return false;
++ }
++ this.world.explode(this, this.locX, this.locY, this.locZ, event.getRadius(), event.getFire());
++ // CraftBukkit end
+ this.a(damagesource);
}
}
diff --git a/nms-patches/EntityEnderDragon.patch b/nms-patches/EntityEnderDragon.patch
index 9572a005..b312c187 100644
--- a/nms-patches/EntityEnderDragon.patch
+++ b/nms-patches/EntityEnderDragon.patch
@@ -1,277 +1,10 @@
--- a/net/minecraft/server/EntityEnderDragon.java
+++ b/net/minecraft/server/EntityEnderDragon.java
-@@ -5,6 +5,17 @@
- import java.util.Iterator;
- import java.util.List;
+@@ -5,6 +5,7 @@
+ import org.apache.logging.log4j.LogManager;
+ import org.apache.logging.log4j.Logger;
-+// CraftBukkit start
-+import org.bukkit.block.BlockState;
-+import org.bukkit.craftbukkit.event.CraftEventFactory;
-+import org.bukkit.craftbukkit.util.BlockStateListPopulator;
-+import org.bukkit.event.entity.EntityCreatePortalEvent;
-+import org.bukkit.event.entity.EntityExplodeEvent;
-+import org.bukkit.event.entity.EntityRegainHealthEvent;
-+import org.bukkit.event.entity.EntityTargetEvent;
-+import org.bukkit.Bukkit;
-+// CraftBukkit end
-+
++// PAIL: Fixme
public class EntityEnderDragon extends EntityInsentient implements IComplex, IMonster {
- public double a;
-@@ -27,6 +38,7 @@
- public Entity target;
- public int by;
- public EntityEnderCrystal bz;
-+ 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);
-@@ -294,12 +306,21 @@
- if (this.bz != null) {
- if (this.bz.dead) {
- if (!this.world.isClientSide) {
-+ CraftEventFactory.entityDamage = this.bz; // CraftBukkit
- this.a(this.bn, DamageSource.explosion((Explosion) null), 10.0F);
-+ CraftEventFactory.entityDamage = null; // CraftBukkit
- }
-
- this.bz = null;
- } else if (this.ticksLived % 10 == 0 && this.getHealth() < this.getMaxHealth()) {
-- this.setHealth(this.getHealth() + 1.0F);
-+ // CraftBukkit start
-+ EntityRegainHealthEvent event = new EntityRegainHealthEvent(this.getBukkitEntity(), 1.0D, EntityRegainHealthEvent.RegainReason.ENDER_CRYSTAL);
-+ this.world.getServer().getPluginManager().callEvent(event);
-+
-+ if (!event.isCancelled()) {
-+ this.setHealth((float) (this.getHealth() + event.getAmount()));
-+ }
-+ // CraftBukkit end
- }
- }
-
-@@ -368,7 +389,19 @@
- }
-
- if (this.random.nextInt(2) == 0 && !arraylist.isEmpty()) {
-- this.target = (Entity) arraylist.get(this.random.nextInt(arraylist.size()));
-+ // CraftBukkit start
-+ Entity target = (Entity) this.world.players.get(this.random.nextInt(this.world.players.size()));
-+ EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), target.getBukkitEntity(), EntityTargetEvent.TargetReason.RANDOM_TARGET);
-+ this.world.getServer().getPluginManager().callEvent(event);
-+
-+ if (!event.isCancelled()) {
-+ if (event.getTarget() == null) {
-+ this.target = null;
-+ } else {
-+ this.target = ((org.bukkit.craftbukkit.entity.CraftEntity) event.getTarget()).getHandle();
-+ }
-+ }
-+ // CraftBukkit end
- } else {
- boolean flag;
-
-@@ -404,6 +437,11 @@
- boolean flag = false;
- boolean flag1 = false;
-
-+ // CraftBukkit start - Create a list to hold all the destroyed blocks
-+ List<org.bukkit.block.Block> destroyedBlocks = new java.util.ArrayList<org.bukkit.block.Block>();
-+ org.bukkit.craftbukkit.CraftWorld craftWorld = this.world.getWorld();
-+ // CraftBukkit end
-+
- for (int k1 = i; k1 <= l; ++k1) {
- for (int l1 = j; l1 <= i1; ++l1) {
- for (int i2 = k; i2 <= j1; ++i2) {
-@@ -412,7 +450,11 @@
-
- if (block.getMaterial() != Material.AIR) {
- if (block != Blocks.BARRIER && block != Blocks.OBSIDIAN && block != Blocks.END_STONE && block != Blocks.BEDROCK && block != Blocks.COMMAND_BLOCK && this.world.getGameRules().getBoolean("mobGriefing")) {
-- flag1 = this.world.setAir(blockposition) || flag1;
-+ // CraftBukkit start - Add blocks to list rather than destroying them
-+ // flag1 = this.world.setAir(new BlockPosition(blockposition)) || flag1;
-+ flag1 = true;
-+ destroyedBlocks.add(craftWorld.getBlockAt(k1, l1, i2));
-+ // CraftBukkit end
- } else {
- flag = true;
- }
-@@ -422,6 +464,40 @@
- }
-
- if (flag1) {
-+ // CraftBukkit start - Set off an EntityExplodeEvent for the dragon exploding all these blocks
-+ org.bukkit.entity.Entity bukkitEntity = this.getBukkitEntity();
-+ EntityExplodeEvent event = new EntityExplodeEvent(bukkitEntity, bukkitEntity.getLocation(), destroyedBlocks, 0F);
-+ Bukkit.getPluginManager().callEvent(event);
-+ if (event.isCancelled()) {
-+ // This flag literally means 'Dragon hit something hard' (Obsidian, White Stone or Bedrock) and will cause the dragon to slow down.
-+ // We should consider adding an event extension for it, or perhaps returning true if the event is cancelled.
-+ return flag;
-+ } else if (event.getYield() == 0F) {
-+ // Yield zero ==> no drops
-+ for (org.bukkit.block.Block block : event.blockList()) {
-+ this.world.setAir(new BlockPosition(block.getX(), block.getY(), block.getZ()));
-+ }
-+ } else {
-+ for (org.bukkit.block.Block block : event.blockList()) {
-+ org.bukkit.Material blockId = block.getType();
-+ if (blockId == org.bukkit.Material.AIR) {
-+ continue;
-+ }
-+
-+ int blockX = block.getX();
-+ int blockY = block.getY();
-+ int blockZ = block.getZ();
-+
-+ 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);
-+ }
-+ nmsBlock.wasExploded(world, new BlockPosition(blockX, blockY, blockZ), explosionSource);
-+
-+ this.world.setAir(new BlockPosition(blockX, blockY, blockZ));
-+ }
-+ }
-+ // CraftBukkit end
- double d0 = axisalignedbb.a + (axisalignedbb.d - axisalignedbb.a) * (double) this.random.nextFloat();
- double d1 = axisalignedbb.b + (axisalignedbb.e - axisalignedbb.b) * (double) this.random.nextFloat();
- double d2 = axisalignedbb.c + (axisalignedbb.f - axisalignedbb.c) * (double) this.random.nextFloat();
-@@ -469,6 +545,7 @@
- }
-
- protected void aZ() {
-+ if (this.dead) return; // CraftBukkit - can't kill what's already dead
- ++this.by;
- if (this.by >= 180 && this.by <= 200) {
- float f = (this.random.nextFloat() - 0.5F) * 8.0F;
-@@ -484,7 +561,7 @@
-
- if (!this.world.isClientSide) {
- if (this.by > 150 && this.by % 5 == 0 && flag) {
-- i = 1000;
-+ i = this.expToDrop / 12; // CraftBukkit - drop experience as dragon falls from sky. use experience drop from death event. This is now set in getExpReward()
-
- while (i > 0) {
- j = EntityExperienceOrb.getOrbValue(i);
-@@ -494,7 +571,23 @@
- }
-
- if (this.by == 1) {
-- this.world.a(1018, new BlockPosition(this), 0);
-+ // CraftBukkit start - Use relative location for far away sounds
-+ // this.world.a(1018, new BlockPosition(this), 0);
-+ int viewDistance = ((WorldServer) this.world).getServer().getViewDistance() * 16;
-+ for (EntityPlayer player : (List<EntityPlayer>) MinecraftServer.getServer().getPlayerList().players) {
-+ double deltaX = this.locX - player.locX;
-+ double deltaZ = this.locZ - player.locZ;
-+ double distanceSquared = deltaX * deltaX + deltaZ * deltaZ;
-+ if (distanceSquared > viewDistance * viewDistance) {
-+ double deltaLength = Math.sqrt(distanceSquared);
-+ double relativeX = player.locX + (deltaX / deltaLength) * viewDistance;
-+ double relativeZ = player.locZ + (deltaZ / deltaLength) * viewDistance;
-+ player.playerConnection.sendPacket(new PacketPlayOutWorldEvent(1018, new BlockPosition((int) relativeX, (int) this.locY, (int) relativeZ), 0, true));
-+ } else {
-+ player.playerConnection.sendPacket(new PacketPlayOutWorldEvent(1018, new BlockPosition((int) this.locX, (int) this.locY, (int) this.locZ), 0, true));
-+ }
-+ }
-+ // CraftBukkit end
- }
- }
-
-@@ -502,7 +595,7 @@
- this.aI = this.yaw += 20.0F;
- if (this.by == 200 && !this.world.isClientSide) {
- if (flag) {
-- i = 2000;
-+ i = this.expToDrop - (10 * this.expToDrop / 12); // CraftBukkit - drop the remaining experience
-
- while (i > 0) {
- j = EntityExperienceOrb.getOrbValue(i);
-@@ -522,6 +615,9 @@
- double d0 = 12.25D;
- double d1 = 6.25D;
-
-+ // CraftBukkit start - Replace any "this.world" in the following with just "world"!
-+ BlockStateListPopulator world = new BlockStateListPopulator(this.world.getWorld());
-+
- for (int i = -1; i <= 32; ++i) {
- for (int j = -4; j <= 4; ++j) {
- for (int k = -4; k <= 4; ++k) {
-@@ -532,31 +628,51 @@
-
- if (i < 0) {
- if (d2 <= 6.25D) {
-- this.world.setTypeUpdate(blockposition1, Blocks.BEDROCK.getBlockData());
-+ world.setTypeUpdate(blockposition1, Blocks.BEDROCK.getBlockData());
- }
- } else if (i > 0) {
-- this.world.setTypeUpdate(blockposition1, Blocks.AIR.getBlockData());
-+ world.setTypeUpdate(blockposition1, Blocks.AIR.getBlockData());
- } else if (d2 > 6.25D) {
-- this.world.setTypeUpdate(blockposition1, Blocks.BEDROCK.getBlockData());
-+ world.setTypeUpdate(blockposition1, Blocks.BEDROCK.getBlockData());
- } else {
-- this.world.setTypeUpdate(blockposition1, Blocks.END_PORTAL.getBlockData());
-+ world.setTypeUpdate(blockposition1, Blocks.END_PORTAL.getBlockData());
- }
- }
- }
- }
- }
-
-- this.world.setTypeUpdate(blockposition, Blocks.BEDROCK.getBlockData());
-- this.world.setTypeUpdate(blockposition.up(), Blocks.BEDROCK.getBlockData());
-+ world.setTypeUpdate(blockposition, Blocks.BEDROCK.getBlockData());
-+ world.setTypeUpdate(blockposition.up(), Blocks.BEDROCK.getBlockData());
- BlockPosition blockposition2 = blockposition.up(2);
-
-- this.world.setTypeUpdate(blockposition2, Blocks.BEDROCK.getBlockData());
-- this.world.setTypeUpdate(blockposition2.west(), Blocks.TORCH.getBlockData().set(BlockTorch.FACING, EnumDirection.EAST));
-- this.world.setTypeUpdate(blockposition2.east(), Blocks.TORCH.getBlockData().set(BlockTorch.FACING, EnumDirection.WEST));
-- this.world.setTypeUpdate(blockposition2.north(), Blocks.TORCH.getBlockData().set(BlockTorch.FACING, EnumDirection.SOUTH));
-- this.world.setTypeUpdate(blockposition2.south(), Blocks.TORCH.getBlockData().set(BlockTorch.FACING, EnumDirection.NORTH));
-- this.world.setTypeUpdate(blockposition.up(3), Blocks.BEDROCK.getBlockData());
-- this.world.setTypeUpdate(blockposition.up(4), Blocks.DRAGON_EGG.getBlockData());
-+ world.setTypeUpdate(blockposition2, Blocks.BEDROCK.getBlockData());
-+ world.setTypeUpdate(blockposition2.west(), Blocks.TORCH.getBlockData().set(BlockTorch.FACING, EnumDirection.EAST));
-+ world.setTypeUpdate(blockposition2.east(), Blocks.TORCH.getBlockData().set(BlockTorch.FACING, EnumDirection.WEST));
-+ world.setTypeUpdate(blockposition2.north(), Blocks.TORCH.getBlockData().set(BlockTorch.FACING, EnumDirection.SOUTH));
-+ world.setTypeUpdate(blockposition2.south(), Blocks.TORCH.getBlockData().set(BlockTorch.FACING, EnumDirection.NORTH));
-+ world.setTypeUpdate(blockposition.up(3), Blocks.BEDROCK.getBlockData());
-+ world.setTypeUpdate(blockposition.up(4), Blocks.DRAGON_EGG.getBlockData());
-+
-+ EntityCreatePortalEvent event = new EntityCreatePortalEvent((org.bukkit.entity.LivingEntity) this.getBukkitEntity(), java.util.Collections.unmodifiableList(world.getList()), org.bukkit.PortalType.ENDER);
-+ this.world.getServer().getPluginManager().callEvent(event);
-+
-+ if (!event.isCancelled()) {
-+ for (BlockState state : event.getBlocks()) {
-+ state.update(true);
-+ }
-+ } else {
-+ for (BlockState state : event.getBlocks()) {
-+ PacketPlayOutBlockChange packet = new PacketPlayOutBlockChange(this.world, new BlockPosition(state.getX(), state.getY(), state.getZ()));
-+ for (Iterator it = this.world.players.iterator(); it.hasNext();) {
-+ EntityHuman entity = (EntityHuman) it.next();
-+ if (entity instanceof EntityPlayer) {
-+ ((EntityPlayer) entity).playerConnection.sendPacket(packet);
-+ }
-+ }
-+ }
-+ }
-+ // CraftBukkit end
- }
-
- protected void D() {}
-@@ -584,4 +700,12 @@
- protected float bB() {
- return 5.0F;
- }
-+
-+ // CraftBukkit start
-+ public int getExpReward() {
-+ // This value is equal to the amount of experience dropped while falling from the sky (10 * 1000)
-+ // plus what is dropped when the dragon hits the ground (2000)
-+ return 12000;
-+ }
-+ // CraftBukkit end
- }
+ private static final Logger bH = LogManager.getLogger();
diff --git a/nms-patches/EntityEnderPearl.patch b/nms-patches/EntityEnderPearl.patch
index 760fad24..bc01356d 100644
--- a/nms-patches/EntityEnderPearl.patch
+++ b/nms-patches/EntityEnderPearl.patch
@@ -11,11 +11,11 @@
+
public class EntityEnderPearl extends EntityProjectile {
- private EntityLiving c;
-@@ -33,21 +39,35 @@
+ private EntityLiving d;
+@@ -51,13 +57,35 @@
EntityPlayer entityplayer = (EntityPlayer) entityliving;
- if (entityplayer.playerConnection.a().g() && entityplayer.world == this.world && !entityplayer.isSleeping()) {
+ if (entityplayer.playerConnection.a().isConnected() && entityplayer.world == this.world && !entityplayer.isSleeping()) {
- if (this.random.nextFloat() < 0.05F && this.world.getGameRules().getBoolean("doMobSpawning")) {
- EntityEndermite entityendermite = new EntityEndermite(this.world);
-
@@ -40,8 +40,8 @@
+ this.world.addEntity(entityendermite);
+ }
+
-+ if (entityliving.au()) {
-+ entityliving.mount((Entity) null);
++ if (entityliving.isPassenger()) {
++ entityliving.stopRiding();
+ }
+
+ entityplayer.playerConnection.teleport(teleEvent.getTo());
@@ -50,15 +50,7 @@
+ entityliving.damageEntity(DamageSource.FALL, 5.0F);
+ CraftEventFactory.entityDamage = null;
}
--
-- if (entityliving.au()) {
-- entityliving.mount((Entity) null);
-- }
--
-- entityliving.enderTeleportTo(this.locX, this.locY, this.locZ);
-- entityliving.fallDistance = 0.0F;
-- entityliving.damageEntity(DamageSource.FALL, 5.0F);
+ // CraftBukkit end
- }
- } else if (entityliving != null) {
- entityliving.enderTeleportTo(this.locX, this.locY, this.locZ);
+
+ if (entityliving.isPassenger()) {
+ this.stopRiding();
diff --git a/nms-patches/EntityEnderman.patch b/nms-patches/EntityEnderman.patch
index b14daaa8..3292a9e7 100644
--- a/nms-patches/EntityEnderman.patch
+++ b/nms-patches/EntityEnderman.patch
@@ -1,60 +1,28 @@
--- a/net/minecraft/server/EntityEnderman.java
+++ b/net/minecraft/server/EntityEnderman.java
-@@ -8,6 +8,12 @@
- import java.util.Set;
- import java.util.UUID;
+@@ -306,8 +306,12 @@
+ boolean flag = movingobjectposition != null && movingobjectposition.a().equals(blockposition);
-+// CraftBukkit start
-+import org.bukkit.Location;
-+import org.bukkit.craftbukkit.event.CraftEventFactory;
-+import org.bukkit.event.entity.EntityTeleportEvent;
-+// CraftBukkit end
-+
- public class EntityEnderman extends EntityMonster {
-
- private static final UUID a = UUID.fromString("020E0DFB-87AE-4653-9556-831010E291A0");
-@@ -177,7 +183,17 @@
- }
-
- if (flag1) {
-- super.enderTeleportTo(this.locX, this.locY, this.locZ);
-+ // CraftBukkit start - Teleport event
-+ // super.enderTeleportTo(this.locX, this.locY, this.locZ);
-+ EntityTeleportEvent teleport = new EntityTeleportEvent(this.getBukkitEntity(), new Location(this.world.getWorld(), d3, d4, d5), new Location(this.world.getWorld(), this.locX, this.locY, this.locZ));
-+ this.world.getServer().getPluginManager().callEvent(teleport);
-+ if (teleport.isCancelled()) {
-+ return false;
-+ }
-+
-+ Location to = teleport.getTo();
-+ this.enderTeleportTo(to.getX(), to.getY(), to.getZ());
-+ // CraftBukkit end
- if (this.world.getCubes(this, this.getBoundingBox()).isEmpty() && !this.world.containsLiquid(this.getBoundingBox())) {
- flag = true;
- }
-@@ -333,8 +349,12 @@
- Block block = iblockdata.getBlock();
-
- if (EntityEnderman.c.contains(block)) {
+ if (EntityEnderman.c.contains(block) && flag) {
- this.enderman.setCarried(iblockdata);
-- world.setTypeUpdate(blockposition, Blocks.AIR.getBlockData());
+- 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()) {
+ this.enderman.setCarried(iblockdata);
-+ world.setTypeUpdate(blockposition, Blocks.AIR.getBlockData());
++ world.setAir(blockposition);
+ }
+ // CraftBukkit end
}
}
-@@ -363,8 +383,12 @@
- Block block1 = world.getType(blockposition.down()).getBlock();
+@@ -337,8 +341,12 @@
+ IBlockData iblockdata2 = this.a.getCarried();
- if (this.a(world, blockposition, this.a.getCarried().getBlock(), block, block1)) {
+ if (iblockdata2 != null && this.a(world, blockposition, iblockdata2.getBlock(), iblockdata, iblockdata1)) {
+ // CraftBukkit start - Place event
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.a, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this.a.getCarried().getBlock(), this.a.getCarried().getBlock().toLegacyData(this.a.getCarried())).isCancelled()) {
- world.setTypeAndData(blockposition, this.a.getCarried(), 3);
- this.a.setCarried(Blocks.AIR.getBlockData());
+ world.setTypeAndData(blockposition, iblockdata2, 3);
+ this.a.setCarried((IBlockData) null);
+ }
+ // CraftBukkit end
}
diff --git a/nms-patches/EntityExperienceOrb.patch b/nms-patches/EntityExperienceOrb.patch
index b01b0c7f..c63e7c19 100644
--- a/nms-patches/EntityExperienceOrb.patch
+++ b/nms-patches/EntityExperienceOrb.patch
@@ -14,8 +14,8 @@
public int a;
@@ -34,6 +40,7 @@
- public void t_() {
- super.t_();
+ public void m() {
+ super.m();
+ EntityHuman prevTarget = this.targetPlayer;// CraftBukkit - store old target
if (this.c > 0) {
--this.c;
@@ -35,7 +35,7 @@
+
+ if (!cancelled && targetPlayer != null) {
double d1 = (this.targetPlayer.locX - this.locX) / d0;
- double d2 = (this.targetPlayer.locY + (double) this.targetPlayer.getHeadHeight() - this.locY) / d0;
+ double d2 = (this.targetPlayer.locY + (double) this.targetPlayer.getHeadHeight() / 2.0D - this.locY) / d0;
double d3 = (this.targetPlayer.locZ - this.locZ) / d0;
@@ -77,6 +94,8 @@
this.motY += d2 / d4 * d5 * 0.1D;
@@ -46,16 +46,16 @@
}
this.move(this.motX, this.motY, this.motZ);
-@@ -141,7 +160,7 @@
- entityhuman.bp = 2;
- this.world.makeSound(entityhuman, "random.orb", 0.1F, 0.5F * ((this.random.nextFloat() - this.random.nextFloat()) * 0.7F + 1.8F));
- entityhuman.receive(this, 1);
-- entityhuman.giveExp(this.value);
-+ entityhuman.giveExp(CraftEventFactory.callPlayerExpChangeEvent(entityhuman, this.value).getAmount()); // CraftBukkit - this.value -> event.getAmount()
- this.die();
- }
+@@ -151,7 +170,7 @@
+ }
-@@ -153,6 +172,24 @@
+ if (this.value > 0) {
+- entityhuman.giveExp(this.value);
++ entityhuman.giveExp(CraftEventFactory.callPlayerExpChangeEvent(entityhuman, this.value).getAmount()); // CraftBukkit - this.value -> event.getAmount()
+ }
+
+ this.die();
+@@ -173,6 +192,24 @@
}
public static int getOrbValue(int i) {
diff --git a/nms-patches/EntityFallingBlock.patch b/nms-patches/EntityFallingBlock.patch
index a0ffb880..43f43bb5 100644
--- a/nms-patches/EntityFallingBlock.patch
+++ b/nms-patches/EntityFallingBlock.patch
@@ -1,6 +1,6 @@
--- a/net/minecraft/server/EntityFallingBlock.java
+++ b/net/minecraft/server/EntityFallingBlock.java
-@@ -4,13 +4,15 @@
+@@ -4,6 +4,8 @@
import java.util.ArrayList;
import java.util.Iterator;
@@ -9,15 +9,7 @@
public class EntityFallingBlock extends Entity {
private IBlockData block;
- public int ticksLived;
- public boolean dropItem = true;
- private boolean e;
-- private boolean hurtEntities;
-+ public boolean hurtEntities; // PAIL: private -> public
- private int fallHurtMax = 40;
- private float fallHurtAmount = 2.0F;
- public NBTTagCompound tileEntityData;
-@@ -56,7 +58,7 @@
+@@ -64,7 +66,7 @@
if (this.ticksLived++ == 0) {
blockposition = new BlockPosition(this);
@@ -26,12 +18,11 @@
this.world.setAir(blockposition);
} else if (!this.world.isClientSide) {
this.die();
-@@ -78,7 +80,12 @@
- if (this.world.getType(blockposition).getBlock() != Blocks.PISTON_EXTENSION) {
+@@ -94,6 +96,12 @@
this.die();
- if (!this.e) {
-- if (this.world.a(block, blockposition, true, EnumDirection.UP, (Entity) null, (ItemStack) null) && !BlockFalling.canFall(this.world, blockposition.down()) && this.world.setTypeAndData(blockposition, this.block, 3)) {
-+ if (this.world.a(block, blockposition, true, EnumDirection.UP, (Entity) null, (ItemStack) null) && !BlockFalling.canFall(this.world, blockposition.down()) /* mimic the false conditions of setTypeIdAndData */ && blockposition.getX() >= -30000000 && blockposition.getZ() >= -30000000 && blockposition.getX() < 30000000 && blockposition.getZ() < 30000000 && blockposition.getY() >= 0 && blockposition.getY() < 256 && this.world.getType(blockposition) != this.block) {
+ if (!this.f) {
+ if (this.world.a(block, blockposition, true, EnumDirection.UP, (Entity) null, (ItemStack) null) && !BlockFalling.i(this.world.getType(blockposition.down())) && this.world.setTypeAndData(blockposition, this.block, 3)) {
++ // CraftBukkit start
+ if (CraftEventFactory.callEntityChangeBlockEvent(this, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this.block.getBlock(), this.block.getBlock().toLegacyData(this.block)).isCancelled()) {
+ return;
+ }
@@ -40,7 +31,7 @@
if (block instanceof BlockFalling) {
((BlockFalling) block).a_(this.world, blockposition);
}
-@@ -137,7 +144,9 @@
+@@ -152,7 +160,9 @@
while (iterator.hasNext()) {
Entity entity = (Entity) iterator.next();
diff --git a/nms-patches/EntityFireball.patch b/nms-patches/EntityFireball.patch
index 416b8ebe..c0780ae7 100644
--- a/nms-patches/EntityFireball.patch
+++ b/nms-patches/EntityFireball.patch
@@ -1,15 +1,14 @@
--- a/net/minecraft/server/EntityFireball.java
+++ b/net/minecraft/server/EntityFireball.java
-@@ -2,6 +2,8 @@
-
- import java.util.List;
+@@ -1,5 +1,7 @@
+ package net.minecraft.server;
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
+
public abstract class EntityFireball extends Entity {
private int e = -1;
-@@ -15,6 +17,8 @@
+@@ -13,6 +15,8 @@
public double dirX;
public double dirY;
public double dirZ;
@@ -18,7 +17,7 @@
public EntityFireball(World world) {
super(world);
-@@ -38,10 +42,17 @@
+@@ -36,10 +40,17 @@
public EntityFireball(World world, EntityLiving entityliving, double d0, double d1, double d2) {
super(world);
this.shooter = entityliving;
@@ -36,7 +35,7 @@
d0 += this.random.nextGaussian() * 0.4D;
d1 += this.random.nextGaussian() * 0.4D;
d2 += this.random.nextGaussian() * 0.4D;
-@@ -117,6 +128,12 @@
+@@ -83,6 +94,12 @@
if (movingobjectposition != null) {
this.a(movingobjectposition);
@@ -49,50 +48,19 @@
}
this.locX += this.motX;
-@@ -181,6 +198,8 @@
-
- nbttagcompound.setString("inTile", minecraftkey == null ? "" : minecraftkey.toString());
- nbttagcompound.setByte("inGround", (byte) (this.i ? 1 : 0));
-+ // CraftBukkit - Fix direction being mismapped to invalid variables
-+ nbttagcompound.set("power", this.a(new double[] { this.dirX, this.dirY, this.dirZ}));
- nbttagcompound.set("direction", this.a(new double[] { this.motX, this.motY, this.motZ}));
- }
-
-@@ -195,12 +214,20 @@
- }
-
- this.i = nbttagcompound.getByte("inGround") == 1;
-- if (nbttagcompound.hasKeyOfType("direction", 9)) {
-+ // CraftBukkit start - direction -> power
-+ if (nbttagcompound.hasKeyOfType("power", 9)) {
-+ NBTTagList nbttaglist = nbttagcompound.getList("power", 6);
-+
-+ this.dirX = nbttaglist.d(0);
-+ this.dirY = nbttaglist.d(1);
-+ this.dirZ = nbttaglist.d(2);
-+ } else if (nbttagcompound.hasKeyOfType("direction", 9)) {
- NBTTagList nbttaglist = nbttagcompound.getList("direction", 6);
-
- this.motX = nbttaglist.d(0);
- this.motY = nbttaglist.d(1);
- this.motZ = nbttaglist.d(2);
-+ // CraftBukkit end
- } else {
- this.die();
- }
-@@ -221,6 +248,11 @@
+@@ -187,6 +204,11 @@
} else {
- this.ac();
+ this.ao();
if (damagesource.getEntity() != null) {
+ // CraftBukkit start
+ if (CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f)) {
+ return false;
+ }
+ // CraftBukkit end
- Vec3D vec3d = damagesource.getEntity().ap();
+ Vec3D vec3d = damagesource.getEntity().aB();
if (vec3d != null) {
-@@ -234,6 +266,7 @@
+@@ -200,6 +222,7 @@
if (damagesource.getEntity() instanceof EntityLiving) {
this.shooter = (EntityLiving) damagesource.getEntity();
diff --git a/nms-patches/EntityFireworks.patch b/nms-patches/EntityFireworks.patch
index 4da644db..5e917620 100644
--- a/nms-patches/EntityFireworks.patch
+++ b/nms-patches/EntityFireworks.patch
@@ -1,11 +1,11 @@
--- a/net/minecraft/server/EntityFireworks.java
+++ b/net/minecraft/server/EntityFireworks.java
-@@ -78,7 +78,7 @@
+@@ -79,7 +79,7 @@
}
if (!this.world.isClientSide && this.ticksFlown > this.expectedLifespan) {
- this.world.broadcastEntityEffect(this, (byte) 17);
-+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callFireworkExplodeEvent(this).isCancelled()) this.world.broadcastEntityEffect(this, (byte) 17);
++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callFireworkExplodeEvent(this).isCancelled()) this.world.broadcastEntityEffect(this, (byte) 17); // CraftBukkit
this.die();
}
diff --git a/nms-patches/EntityFishingHook.patch b/nms-patches/EntityFishingHook.patch
index 899b0f44..952bba1d 100644
--- a/nms-patches/EntityFishingHook.patch
+++ b/nms-patches/EntityFishingHook.patch
@@ -1,7 +1,7 @@
--- a/net/minecraft/server/EntityFishingHook.java
+++ b/net/minecraft/server/EntityFishingHook.java
@@ -3,6 +3,12 @@
- import java.util.Arrays;
+ import java.util.Iterator;
import java.util.List;
+// CraftBukkit start
@@ -12,19 +12,44 @@
+
public class EntityFishingHook extends Entity {
- private static final List<PossibleFishingResult> d = Arrays.asList(new PossibleFishingResult[] { (new PossibleFishingResult(new ItemStack(Items.LEATHER_BOOTS), 10)).a(0.9F), new PossibleFishingResult(new ItemStack(Items.LEATHER), 10), new PossibleFishingResult(new ItemStack(Items.BONE), 10), new PossibleFishingResult(new ItemStack(Items.POTION), 10), new PossibleFishingResult(new ItemStack(Items.STRING), 5), (new PossibleFishingResult(new ItemStack(Items.FISHING_ROD), 2)).a(0.9F), new PossibleFishingResult(new ItemStack(Items.BOWL), 10), new PossibleFishingResult(new ItemStack(Items.STICK), 5), new PossibleFishingResult(new ItemStack(Items.DYE, 10, EnumColor.BLACK.getInvColorIndex()), 1), new PossibleFishingResult(new ItemStack(Blocks.TRIPWIRE_HOOK), 10), new PossibleFishingResult(new ItemStack(Items.ROTTEN_FLESH), 10)});
-@@ -182,6 +188,7 @@
- }
+ private static final DataWatcherObject<Integer> c = DataWatcher.a(EntityFishingHook.class, DataWatcherRegistry.b);
+@@ -193,6 +199,7 @@
+ }
- if (movingobjectposition != null) {
-+ org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this); // Craftbukkit - Call event
- if (movingobjectposition.entity != null) {
- if (movingobjectposition.entity.damageEntity(DamageSource.projectile(this, this.owner), 0.0F)) {
+ if (movingobjectposition != null) {
++ org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this); // Craftbukkit - Call event
+ if (movingobjectposition.entity != null) {
this.hooked = movingobjectposition.entity;
-@@ -381,6 +388,15 @@
- byte b0 = 0;
-
- if (this.hooked != null) {
+ this.getDataWatcher().set(EntityFishingHook.c, Integer.valueOf(this.hooked.getId() + 1));
+@@ -266,6 +273,10 @@
+ if (this.au <= 0) {
+ this.av = 0;
+ this.aw = 0;
++ // CraftBukkit start
++ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), null, (Fish) this.getBukkitEntity(), PlayerFishEvent.State.FAILED_ATTEMPT);
++ this.world.getServer().getPluginManager().callEvent(playerFishEvent);
++ // CraftBukkit end
+ }
+ } else {
+ double d10;
+@@ -278,6 +289,13 @@
+ if (this.aw > 0) {
+ this.aw -= l;
+ if (this.aw <= 0) {
++ // CraftBukkit start
++ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), null, (Fish) this.getBukkitEntity(), PlayerFishEvent.State.BITE);
++ this.world.getServer().getPluginManager().callEvent(playerFishEvent);
++ if (playerFishEvent.isCancelled()) {
++ return;
++ }
++ // CraftBukkit end
+ this.motY -= 0.20000000298023224D;
+ this.a(SoundEffects.G, 0.25F, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F);
+ f2 = (float) MathHelper.floor(this.getBoundingBox().b);
+@@ -391,6 +409,14 @@
+ this.k();
+ this.world.broadcastEntityEffect(this, (byte) 31);
+ i = this.hooked instanceof EntityItem ? 3 : 5;
+ // CraftBukkit start
+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), this.hooked.getBukkitEntity(), (Fish) this.getBukkitEntity(), PlayerFishEvent.State.CAUGHT_ENTITY);
+ this.world.getServer().getPluginManager().callEvent(playerFishEvent);
@@ -33,39 +58,41 @@
+ return 0;
+ }
+ // CraftBukkit end
-+
- double d0 = this.owner.locX - this.locX;
- double d1 = this.owner.locY - this.locY;
- double d2 = this.owner.locZ - this.locZ;
-@@ -393,6 +409,15 @@
- b0 = 3;
- } else if (this.av > 0) {
- EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY, this.locZ, this.m());
-+ // CraftBukkit start
-+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), entityitem.getBukkitEntity(), (Fish) this.getBukkitEntity(), PlayerFishEvent.State.CAUGHT_FISH);
-+ playerFishEvent.setExpToDrop(this.random.nextInt(6) + 1);
-+ this.world.getServer().getPluginManager().callEvent(playerFishEvent);
+ } else if (this.au > 0) {
+ LootTableInfo.a loottableinfo_a = new LootTableInfo.a((WorldServer) this.world);
+
+@@ -400,6 +426,15 @@
+ while (iterator.hasNext()) {
+ ItemStack itemstack = (ItemStack) iterator.next();
+ EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY, this.locZ, itemstack);
++ // CraftBukkit start
++ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), entityitem.getBukkitEntity(), (Fish) this.getBukkitEntity(), PlayerFishEvent.State.CAUGHT_FISH);
++ playerFishEvent.setExpToDrop(this.random.nextInt(6) + 1);
++ this.world.getServer().getPluginManager().callEvent(playerFishEvent);
+
-+ if (playerFishEvent.isCancelled()) {
-+ return 0;
-+ }
-+ // CraftBukkit end
- double d5 = this.owner.locX - this.locX;
- double d6 = this.owner.locY - this.locY;
- double d7 = this.owner.locZ - this.locZ;
-@@ -403,14 +428,35 @@
- entityitem.motY = d6 * d9 + (double) MathHelper.sqrt(d8) * 0.08D;
- entityitem.motZ = d7 * d9;
- this.world.addEntity(entityitem);
-- this.owner.world.addEntity(new EntityExperienceOrb(this.owner.world, this.owner.locX, this.owner.locY + 0.5D, this.owner.locZ + 0.5D, this.random.nextInt(6) + 1));
-+ // CraftBukkit start - this.random.nextInt(6) + 1 -> playerFishEvent.getExpToDrop()
-+ if (playerFishEvent.getExpToDrop() > 0) {
-+ this.owner.world.addEntity(new EntityExperienceOrb(this.owner.world, this.owner.locX, this.owner.locY + 0.5D, this.owner.locZ + 0.5D, playerFishEvent.getExpToDrop()));
-+ } // CraftBukkit end
- b0 = 1;
++ if (playerFishEvent.isCancelled()) {
++ return 0;
++ }
++ // CraftBukkit end
+ double d0 = this.owner.locX - this.locX;
+ double d1 = this.owner.locY - this.locY;
+ double d2 = this.owner.locZ - this.locZ;
+@@ -410,13 +445,25 @@
+ entityitem.motY = d1 * d4 + (double) MathHelper.sqrt(d3) * 0.08D;
+ entityitem.motZ = d2 * d4;
+ this.world.addEntity(entityitem);
+- this.owner.world.addEntity(new EntityExperienceOrb(this.owner.world, this.owner.locX, this.owner.locY + 0.5D, this.owner.locZ + 0.5D, this.random.nextInt(6) + 1));
++ // CraftBukkit start - this.random.nextInt(6) + 1 -> playerFishEvent.getExpToDrop()
++ if (playerFishEvent.getExpToDrop() > 0) {
++ this.owner.world.addEntity(new EntityExperienceOrb(this.owner.world, this.owner.locX, this.owner.locY + 0.5D, this.owner.locZ + 0.5D, playerFishEvent.getExpToDrop()));
++ }
++ // CraftBukkit end
+ }
+
+ i = 1;
}
- if (this.as) {
+ if (this.isInGround) {
+ // CraftBukkit start
+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), null, (Fish) this.getBukkitEntity(), PlayerFishEvent.State.IN_GROUND);
+ this.world.getServer().getPluginManager().callEvent(playerFishEvent);
@@ -74,19 +101,6 @@
+ return 0;
+ }
+ // CraftBukkit end
- b0 = 2;
+ i = 2;
}
-+ // CraftBukkit start
-+ if (b0 == 0) {
-+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), null, (Fish) this.getBukkitEntity(), PlayerFishEvent.State.FAILED_ATTEMPT);
-+ this.world.getServer().getPluginManager().callEvent(playerFishEvent);
-+ if (playerFishEvent.isCancelled()) {
-+ return 0;
-+ }
-+ }
-+ // CraftBukkit end
-+
- this.die();
- this.owner.hookedFish = null;
- return b0;
diff --git a/nms-patches/EntityGhast.patch b/nms-patches/EntityGhast.patch
index 681d72ef..3bee78d1 100644
--- a/nms-patches/EntityGhast.patch
+++ b/nms-patches/EntityGhast.patch
@@ -1,13 +1,12 @@
--- a/net/minecraft/server/EntityGhast.java
+++ b/net/minecraft/server/EntityGhast.java
-@@ -162,7 +162,9 @@
- world.a((EntityHuman) null, 1008, new BlockPosition(this.b), 0);
- EntityLargeFireball entitylargefireball = new EntityLargeFireball(world, this.b, d2, d3, d4);
+@@ -153,7 +153,8 @@
+ world.a((EntityHuman) null, 1016, new BlockPosition(this.ghast), 0);
+ EntityLargeFireball entitylargefireball = new EntityLargeFireball(world, this.ghast, d2, d3, d4);
-- entitylargefireball.yield = this.b.cf();
-+
+- entitylargefireball.yield = this.ghast.getPower();
+ // CraftBukkit - set bukkitYield when setting explosionpower
-+ entitylargefireball.bukkitYield = entitylargefireball.yield = this.b.cf();
- entitylargefireball.locX = this.b.locX + vec3d.a * d1;
- entitylargefireball.locY = this.b.locY + (double) (this.b.length / 2.0F) + 0.5D;
- entitylargefireball.locZ = this.b.locZ + vec3d.c * d1;
++ entitylargefireball.bukkitYield = entitylargefireball.yield = this.ghast.getPower();
+ entitylargefireball.locX = this.ghast.locX + vec3d.x * d1;
+ entitylargefireball.locY = this.ghast.locY + (double) (this.ghast.length / 2.0F) + 0.5D;
+ entitylargefireball.locZ = this.ghast.locZ + vec3d.z * d1;
diff --git a/nms-patches/EntityHanging.patch b/nms-patches/EntityHanging.patch
index aee058d5..086d3fa9 100644
--- a/nms-patches/EntityHanging.patch
+++ b/nms-patches/EntityHanging.patch
@@ -1,24 +1,22 @@
--- a/net/minecraft/server/EntityHanging.java
+++ b/net/minecraft/server/EntityHanging.java
-@@ -4,6 +4,13 @@
- import java.util.List;
+@@ -3,6 +3,11 @@
+ import com.google.common.base.Predicate;
import org.apache.commons.lang3.Validate;
+// CraftBukkit start
+import org.bukkit.entity.Hanging;
-+import org.bukkit.entity.Painting;
+import org.bukkit.event.hanging.HangingBreakEvent;
-+import org.bukkit.event.painting.PaintingBreakEvent;
+// CraftBukkit end
+
public abstract class EntityHanging extends Entity {
- private int c;
-@@ -30,30 +37,34 @@
+ private static final Predicate<Entity> c = new Predicate() {
+@@ -38,30 +43,39 @@
this.updateBoundingBox();
}
-- private void updateBoundingBox() {
+- protected void updateBoundingBox() {
- if (this.direction != null) {
- double d0 = (double) this.blockPosition.getX() + 0.5D;
- double d1 = (double) this.blockPosition.getY() + 0.5D;
@@ -31,15 +29,15 @@
+ Placing here as it's more likely to be noticed as something which needs to be updated
+ then something in a CraftBukkit file.
+ */
-+ public static AxisAlignedBB calculateBoundingBox(BlockPosition blockPosition, EnumDirection direction, int width, int height) {
++ public static AxisAlignedBB calculateBoundingBox(Entity entity, BlockPosition blockPosition, EnumDirection direction, int width, int height) {
+ double d0 = (double) blockPosition.getX() + 0.5D;
+ double d1 = (double) blockPosition.getY() + 0.5D;
+ double d2 = (double) blockPosition.getZ() + 0.5D;
double d3 = 0.46875D;
-- double d4 = this.a(this.l());
-- double d5 = this.a(this.m());
-+ double d4 = width % 32 == 0 ? 0.5D : 0.0D;
-+ double d5 = height % 32 == 0 ? 0.5D : 0.0D;
+- double d4 = this.a(this.getWidth());
+- double d5 = this.a(this.getHeight());
++ double d4 = a(width);
++ double d5 = a(height);
- d0 -= (double) this.direction.getAdjacentX() * 0.46875D;
- d2 -= (double) this.direction.getAdjacentZ() * 0.46875D;
@@ -54,9 +52,14 @@
- this.locX = d0;
- this.locY = d1;
- this.locZ = d2;
-- double d6 = (double) this.l();
-- double d7 = (double) this.m();
-- double d8 = (double) this.l();
+- double d6 = (double) this.getWidth();
+- double d7 = (double) this.getHeight();
+- double d8 = (double) this.getWidth();
++ if (entity != null) {
++ entity.locX = d0;
++ entity.locY = d1;
++ entity.locZ = d2;
++ }
+ double d6 = (double) width;
+ double d7 = (double) height;
+ double d8 = (double) width;
@@ -66,7 +69,7 @@
d8 = 1.0D;
} else {
d6 = 1.0D;
-@@ -62,7 +73,18 @@
+@@ -70,11 +84,18 @@
d6 /= 32.0D;
d7 /= 32.0D;
d8 /= 32.0D;
@@ -74,24 +77,25 @@
+ return new AxisAlignedBB(d0 - d6, d1 - d7, d2 - d8, d0 + d6, d1 + d7, d2 + d8);
+ }
+
-+ private void updateBoundingBox() {
++ protected void updateBoundingBox() {
+ if (this.direction != null) {
+ // CraftBukkit start code moved in to calculateBoundingBox
-+ AxisAlignedBB bb = calculateBoundingBox(this.blockPosition, this.direction, this.l(), this.m());
-+ this.locX = (bb.a + bb.d) / 2.0D;
-+ this.locY = (bb.b + bb.e) / 2.0D;
-+ this.locZ = (bb.c + bb.f) / 2.0D;
-+ this.a(bb);
++ this.a(calculateBoundingBox(this, this.blockPosition, this.direction, this.getWidth(), this.getHeight()));
+ // CraftBukkit end
}
}
-@@ -77,6 +99,32 @@
- if (this.c++ == 100 && !this.world.isClientSide) {
- this.c = 0;
+- private double a(int i) {
++ private static double a(int i) {
+ return i % 32 == 0 ? 0.5D : 0.0D;
+ }
+
+@@ -85,6 +106,24 @@
+ if (this.d++ == 100 && !this.world.isClientSide) {
+ this.d = 0;
if (!this.dead && !this.survives()) {
+ // CraftBukkit start - fire break events
-+ Material material = this.world.getType(new BlockPosition(this)).getBlock().getMaterial();
++ Material material = this.world.getType(new BlockPosition(this)).getMaterial();
+ HangingBreakEvent.RemoveCause cause;
+
+ if (!material.equals(Material.AIR)) {
@@ -104,55 +108,36 @@
+ HangingBreakEvent event = new HangingBreakEvent((Hanging) this.getBukkitEntity(), cause);
+ this.world.getServer().getPluginManager().callEvent(event);
+
-+ PaintingBreakEvent paintingEvent = null;
-+ if (this instanceof EntityPainting) {
-+ // Fire old painting event until it can be removed
-+ paintingEvent = new PaintingBreakEvent((Painting) this.getBukkitEntity(), PaintingBreakEvent.RemoveCause.valueOf(cause.name()));
-+ paintingEvent.setCancelled(event.isCancelled());
-+ this.world.getServer().getPluginManager().callEvent(paintingEvent);
-+ }
-+
-+ if (dead || event.isCancelled() || (paintingEvent != null && paintingEvent.isCancelled())) {
++ if (dead || event.isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
this.die();
- this.b((Entity) null);
+ this.a((Entity) null);
}
-@@ -138,6 +186,32 @@
+@@ -135,6 +174,21 @@
return false;
} else {
if (!this.dead && !this.world.isClientSide) {
+ // CraftBukkit start - fire break events
+ HangingBreakEvent event = new HangingBreakEvent((Hanging) this.getBukkitEntity(), HangingBreakEvent.RemoveCause.DEFAULT);
-+ PaintingBreakEvent paintingEvent = null;
+ if (damagesource.getEntity() != null) {
+ event = new org.bukkit.event.hanging.HangingBreakByEntityEvent((Hanging) this.getBukkitEntity(), damagesource.getEntity() == null ? null : damagesource.getEntity().getBukkitEntity());
-+
-+ if (this instanceof EntityPainting) {
-+ // Fire old painting event until it can be removed
-+ paintingEvent = new org.bukkit.event.painting.PaintingBreakByEntityEvent((Painting) this.getBukkitEntity(), damagesource.getEntity() == null ? null : damagesource.getEntity().getBukkitEntity());
-+ }
+ } else if (damagesource.isExplosion()) {
+ event = new HangingBreakEvent((Hanging) this.getBukkitEntity(), HangingBreakEvent.RemoveCause.EXPLOSION);
+ }
+
+ this.world.getServer().getPluginManager().callEvent(event);
+
-+ if (paintingEvent != null) {
-+ paintingEvent.setCancelled(event.isCancelled());
-+ this.world.getServer().getPluginManager().callEvent(paintingEvent);
-+ }
-+
-+ if (this.dead || event.isCancelled() || (paintingEvent != null && paintingEvent.isCancelled())) {
++ if (this.dead || event.isCancelled()) {
+ return true;
+ }
+ // CraftBukkit end
+
this.die();
- this.ac();
- this.b(damagesource.getEntity());
-@@ -149,6 +223,18 @@
+ this.ao();
+ this.a(damagesource.getEntity());
+@@ -146,6 +200,18 @@
public void move(double d0, double d1, double d2) {
if (!this.world.isClientSide && !this.dead && d0 * d0 + d1 * d1 + d2 * d2 > 0.0D) {
@@ -169,14 +154,14 @@
+ // CraftBukkit end
+
this.die();
- this.b((Entity) null);
+ this.a((Entity) null);
}
-@@ -156,7 +242,7 @@
+@@ -153,7 +219,7 @@
}
public void g(double d0, double d1, double d2) {
- if (!this.world.isClientSide && !this.dead && d0 * d0 + d1 * d1 + d2 * d2 > 0.0D) {
+ if (false && !this.world.isClientSide && !this.dead && d0 * d0 + d1 * d1 + d2 * d2 > 0.0D) { // CraftBukkit - not needed
this.die();
- this.b((Entity) null);
+ this.a((Entity) null);
}
diff --git a/nms-patches/EntityHorse.patch b/nms-patches/EntityHorse.patch
index 06eece5e..db8f0aad 100644
--- a/nms-patches/EntityHorse.patch
+++ b/nms-patches/EntityHorse.patch
@@ -1,39 +1,32 @@
--- a/net/minecraft/server/EntityHorse.java
+++ b/net/minecraft/server/EntityHorse.java
-@@ -4,6 +4,8 @@
- import java.util.Iterator;
+@@ -6,6 +6,8 @@
import java.util.List;
+ import java.util.UUID;
+import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; // CraftBukkit
+
- public class EntityHorse extends EntityAnimal implements IInventoryListener {
+ public class EntityHorse extends EntityAnimal implements IInventoryListener, IJumpable {
- private static final Predicate<Entity> bs = new Predicate() {
-@@ -44,6 +46,7 @@
- private String bO;
- private String[] bP = new String[3];
- private boolean bQ = false;
+ private static final Predicate<Entity> bB = new Predicate() {
+@@ -52,6 +54,7 @@
+ private String cd;
+ private String[] ce = new String[3];
+ private boolean cf = false;
+ public int maxDomestication = 100; // CraftBukkit - store max domestication value
public EntityHorse(World world) {
super(world);
-@@ -320,13 +323,13 @@
- private int cZ() {
- int i = this.getType();
-
-- return this.hasChest() && (i == 1 || i == 2) ? 17 : 2;
-+ return this.hasChest() /* && (i == 1 || i == 2) */ ? 17 : 2; // CraftBukkit - Remove type check
- }
-
+@@ -318,7 +321,7 @@
public void loadChest() {
InventoryHorseChest inventoryhorsechest = this.inventoryChest;
-- this.inventoryChest = new InventoryHorseChest("HorseChest", this.cZ());
-+ this.inventoryChest = new InventoryHorseChest("HorseChest", this.cZ(), this); // CraftBukkit - add this horse
+- this.inventoryChest = new InventoryHorseChest("HorseChest", this.dI());
++ this.inventoryChest = new InventoryHorseChest("HorseChest", this.dI(), this); // CraftBukkit
this.inventoryChest.a(this.getName());
if (inventoryhorsechest != null) {
inventoryhorsechest.b(this);
-@@ -491,7 +494,7 @@
+@@ -470,7 +473,7 @@
}
public int getMaxDomestication() {
@@ -41,8 +34,8 @@
+ return this.maxDomestication; // CraftBukkit - return stored max domestication instead of 100
}
- protected float bB() {
-@@ -591,7 +594,7 @@
+ protected float cd() {
+@@ -560,7 +563,7 @@
}
if (this.getHealth() < this.getMaxHealth() && f > 0.0F) {
@@ -51,7 +44,7 @@
flag = true;
}
-@@ -698,11 +701,24 @@
+@@ -652,11 +655,24 @@
public void die(DamageSource damagesource) {
super.die(damagesource);
@@ -61,12 +54,12 @@
}
+ // CraftBukkit end */
+ }
-
++
+ // CraftBukkit start - Add method
+ @Override
+ protected void dropDeathLoot(boolean flag, int i) {
+ super.dropDeathLoot(flag, i);
-+
+
+ // Moved from die method above
+ if (!this.world.isClientSide) {
+ this.dropChest();
@@ -74,27 +67,27 @@
}
+ // CraftBukkit end
- public void m() {
+ public void n() {
if (this.random.nextInt(200) == 0) {
-@@ -712,7 +728,7 @@
- super.m();
+@@ -666,7 +682,7 @@
+ super.n();
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.cy() && this.passenger == null && this.random.nextInt(300) == 0 && this.world.getType(new BlockPosition(MathHelper.floor(this.locX), MathHelper.floor(this.locY) - 1, MathHelper.floor(this.locZ))).getBlock() == Blocks.GRASS) {
-@@ -955,6 +971,7 @@
- nbttagcompound.setInt("Temper", this.getTemper());
- nbttagcompound.setBoolean("Tame", this.isTame());
- nbttagcompound.setString("OwnerUUID", this.getOwnerUUID());
+ if (!this.dm() && !this.isVehicle() && this.random.nextInt(300) == 0 && this.world.getType(new BlockPosition(MathHelper.floor(this.locX), MathHelper.floor(this.locY) - 1, MathHelper.floor(this.locZ))).getBlock() == Blocks.GRASS) {
+@@ -919,6 +935,7 @@
+ if (this.getOwnerUUID() != null) {
+ nbttagcompound.setString("OwnerUUID", this.getOwnerUUID().toString());
+ }
+ nbttagcompound.setInt("Bukkit.MaxDomestication", this.maxDomestication); // CraftBukkit
+
if (this.hasChest()) {
NBTTagList nbttaglist = new NBTTagList();
-
-@@ -1007,6 +1024,12 @@
- this.setOwnerUUID(s);
+@@ -974,6 +991,12 @@
+ this.setOwnerUUID(UUID.fromString(s));
}
+ // CraftBukkit start
@@ -106,34 +99,16 @@
AttributeInstance attributeinstance = this.getAttributeMap().a("Speed");
if (attributeinstance != null) {
-@@ -1172,18 +1195,25 @@
-
- public void v(int i) {
- if (this.cG()) {
-+ // CraftBukkit start - fire HorseJumpEvent, use event power
- if (i < 0) {
- i = 0;
-- } else {
-- this.bG = true;
-- this.dh();
- }
-
-+ float power;
- if (i >= 90) {
-- this.br = 1.0F;
-+ power = 1.0F;
- } else {
-- this.br = 0.4F + 0.4F * (float) i / 90.0F;
-+ power = 0.4F + 0.4F * (float) i / 90.0F;
-+ }
-+
-+ org.bukkit.event.entity.HorseJumpEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callHorseJumpEvent(this, power);
-+ if (!event.isCancelled()) {
-+ this.bG = true;
-+ this.dh();
-+ this.br = power;
- }
-+ // CraftBukkit end
- }
+@@ -1145,6 +1168,12 @@
+ }
+ public void b(int i) {
++ // CraftBukkit start
++ org.bukkit.event.entity.HorseJumpEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callHorseJumpEvent(this, this.jumpPower);
++ if (event.isCancelled()) {
++ return;
++ }
++ // CraftBukkit end
+ this.canSlide = true;
+ this.setStanding();
}
diff --git a/nms-patches/EntityHuman.patch b/nms-patches/EntityHuman.patch
index fad88539..cc60d246 100644
--- a/nms-patches/EntityHuman.patch
+++ b/nms-patches/EntityHuman.patch
@@ -1,36 +1,35 @@
--- a/net/minecraft/server/EntityHuman.java
+++ b/net/minecraft/server/EntityHuman.java
-@@ -8,13 +8,27 @@
+@@ -9,6 +9,18 @@
import java.util.List;
import java.util.UUID;
+// CraftBukkit start
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
+import org.bukkit.craftbukkit.entity.CraftItem;
-+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.entity.Player;
+import org.bukkit.event.entity.EntityCombustByEntityEvent;
+import org.bukkit.event.player.PlayerBedEnterEvent;
+import org.bukkit.event.player.PlayerBedLeaveEvent;
+import org.bukkit.event.player.PlayerDropItemEvent;
-+import org.bukkit.event.player.PlayerItemConsumeEvent;
+import org.bukkit.event.player.PlayerVelocityEvent;
+import org.bukkit.util.Vector;
+// CraftBukkit end
+
public abstract class EntityHuman extends EntityLiving {
- public PlayerInventory inventory = new PlayerInventory(this);
+ private static final DataWatcherObject<Float> a = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.c);
+@@ -19,7 +31,7 @@
private InventoryEnderChest enderChest = new InventoryEnderChest();
public Container defaultContainer;
public Container activeContainer;
- protected FoodMetaData foodData = new FoodMetaData();
+ protected FoodMetaData foodData = new FoodMetaData(this); // CraftBukkit - add "this" to constructor
- protected int bm;
- public float bn;
- public float bo;
-@@ -47,6 +61,17 @@
- private boolean bI = false;
+ protected int bv;
+ public float bw;
+ public float bx;
+@@ -52,6 +64,17 @@
+ private final ItemCooldown bU = this.l();
public EntityFishingHook hookedFish;
+ // CraftBukkit start
@@ -44,43 +43,10 @@
+ }
+ // CraftBukkit end
+
- public EntityHuman(World world, GameProfile gameprofile) {
- super(world);
- this.uniqueID = a(gameprofile);
-@@ -265,6 +290,32 @@
- if (this.g != null) {
- this.b(this.g, 16);
- int i = this.g.count;
-+
-+ // CraftBukkit start - fire PlayerItemConsumeEvent
-+ org.bukkit.inventory.ItemStack craftItem = CraftItemStack.asBukkitCopy(this.g);
-+ PlayerItemConsumeEvent event = new PlayerItemConsumeEvent((Player) this.getBukkitEntity(), craftItem);
-+ world.getServer().getPluginManager().callEvent(event);
-+
-+ if (event.isCancelled()) {
-+ // Update client
-+ if (this instanceof EntityPlayer) {
-+ ((EntityPlayer) this).playerConnection.sendPacket(new PacketPlayOutSetSlot((byte) 0, activeContainer.getSlot((IInventory) this.inventory, this.inventory.itemInHandIndex).index, this.g));
-+ }
-+ return;
-+ }
-+
-+ // Plugin modified the item, process it but don't remove it
-+ if (!craftItem.equals(event.getItem())) {
-+ CraftItemStack.asNMSCopy(event.getItem()).b(this.world, this);
-+
-+ // Update client
-+ if (this instanceof EntityPlayer) {
-+ ((EntityPlayer) this).playerConnection.sendPacket(new PacketPlayOutSetSlot((byte) 0, activeContainer.getSlot((IInventory) this.inventory, this.inventory.itemInHandIndex).index, this.g));
-+ }
-+ return;
-+ }
-+ // CraftBukkit end
-+
- ItemStack itemstack = this.g.b(this.world, this);
-
- if (itemstack != this.g || itemstack != null && itemstack.count != i) {
-@@ -324,7 +375,8 @@
+ protected ItemCooldown l() {
+ return new ItemCooldown();
+ }
+@@ -301,7 +324,8 @@
if (this.world.getDifficulty() == EnumDifficulty.PEACEFUL && this.world.getGameRules().getBoolean("naturalRegeneration")) {
if (this.getHealth() < this.getMaxHealth() && this.ticksLived % 20 == 0) {
@@ -90,50 +56,48 @@
}
if (this.foodData.c() && this.ticksLived % 10 == 0) {
-@@ -348,7 +400,7 @@
+@@ -325,7 +349,7 @@
- this.k((float) attributeinstance.getValue());
+ this.l((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;
-@@ -438,11 +490,13 @@
-
+@@ -416,16 +440,20 @@
public void b(Entity entity, int i) {
- this.addScore(i);
-- Collection collection = this.getScoreboard().getObjectivesForCriteria(IScoreboardCriteria.f);
-+ // CraftBukkit - Get our scores instead
-+ Collection<ScoreboardScore> collection = this.world.getServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.f, this.getName(), new java.util.ArrayList<ScoreboardScore>());
-
- if (entity instanceof EntityHuman) {
- this.b(StatisticList.B);
-- collection.addAll(this.getScoreboard().getObjectivesForCriteria(IScoreboardCriteria.e));
+ if (entity != this) {
+ this.addScore(i);
+- Collection collection = this.getScoreboard().getObjectivesForCriteria(IScoreboardCriteria.f);
+ // CraftBukkit - Get our scores instead
-+ this.world.getServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.e, this.getName(), collection);
- collection.addAll(this.e(entity));
- } else {
- this.b(StatisticList.z);
-@@ -451,15 +505,14 @@
- Iterator iterator = collection.iterator();
++ Collection collection = this.world.getServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.f, this.getName(), new java.util.ArrayList<ScoreboardScore>());
+
+ if (entity instanceof EntityHuman) {
+ this.b(StatisticList.D);
+- collection.addAll(this.getScoreboard().getObjectivesForCriteria(IScoreboardCriteria.e));
++ // CraftBukkit - Get our scores instead
++ this.world.getServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.e, this.getName(), collection);
++ // collection.addAll(this.getScoreboard().getObjectivesForCriteria(IScoreboardCriteria.e));
++ // CraftBukkit end
+ } else {
+ this.b(StatisticList.B);
+ }
- 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
+- collection.addAll(this.d(entity));
++ // collection.addAll(this.d(entity)); // PAIL
+ Iterator iterator = collection.iterator();
- scoreboardscore.incrementScore();
+ while (iterator.hasNext()) {
+@@ -438,6 +466,7 @@
}
-
}
-- private Collection<ScoreboardObjective> e(Entity entity) {
-+ private Collection e(Entity entity) { // CraftBukkit - TODO: Check me?
++ // PAIL - TODO: Check me?
+ private Collection<ScoreboardObjective> d(Entity entity) {
+ String s = entity instanceof EntityHuman ? entity.getName() : entity.getUniqueID().toString();
ScoreboardTeam scoreboardteam = this.getScoreboard().getPlayerTeam(this.getName());
-
- if (scoreboardteam != null) {
-@@ -491,6 +544,7 @@
+@@ -471,6 +500,7 @@
}
public EntityItem a(boolean flag) {
@@ -141,7 +105,7 @@
return this.a(this.inventory.splitStack(this.inventory.itemInHandIndex, flag && this.inventory.getItemInHand() != null ? this.inventory.getItemInHand().count : 1), false, true);
}
-@@ -533,6 +587,30 @@
+@@ -513,6 +543,30 @@
entityitem.motZ += Math.sin((double) f1) * (double) f;
}
@@ -169,10 +133,10 @@
+ }
+ // CraftBukkit end
+
- this.a(entityitem);
+ ItemStack itemstack1 = this.a(entityitem);
+
if (flag1) {
- this.b(StatisticList.v);
-@@ -624,6 +702,13 @@
+@@ -612,6 +666,13 @@
this.a(true, true, false);
}
@@ -184,17 +148,22 @@
+ // CraftBukkit end
+
if (nbttagcompound.hasKeyOfType("SpawnX", 99) && nbttagcompound.hasKeyOfType("SpawnY", 99) && nbttagcompound.hasKeyOfType("SpawnZ", 99)) {
- this.c = new BlockPosition(nbttagcompound.getInt("SpawnX"), nbttagcompound.getInt("SpawnY"), nbttagcompound.getInt("SpawnZ"));
- this.d = nbttagcompound.getBoolean("SpawnForced");
-@@ -665,6 +750,7 @@
- if (itemstack != null && itemstack.getItem() != null) {
- nbttagcompound.set("SelectedItem", itemstack.save(new NBTTagCompound()));
- }
+ this.e = new BlockPosition(nbttagcompound.getInt("SpawnX"), nbttagcompound.getInt("SpawnY"), nbttagcompound.getInt("SpawnZ"));
+ this.f = nbttagcompound.getBoolean("SpawnForced");
+@@ -649,6 +710,12 @@
+ this.foodData.b(nbttagcompound);
+ this.abilities.a(nbttagcompound);
+ nbttagcompound.set("EnderItems", this.enderChest.h());
++ ItemStack itemstack = this.inventory.getItemInHand();
++
++ if (itemstack != null && itemstack.getItem() != null) {
++ nbttagcompound.set("SelectedItem", itemstack.save(new NBTTagCompound()));
++ }
+ nbttagcompound.setString("SpawnWorld", spawnWorld); // CraftBukkit - fixes bed spawns for multiworld worlds
-
}
-@@ -684,7 +770,7 @@
+ public boolean damageEntity(DamageSource damagesource, float f) {
+@@ -667,7 +734,7 @@
if (damagesource.r()) {
if (this.world.getDifficulty() == EnumDifficulty.PEACEFUL) {
@@ -203,7 +172,7 @@
}
if (this.world.getDifficulty() == EnumDifficulty.EASY) {
-@@ -696,7 +782,7 @@
+@@ -679,7 +746,7 @@
}
}
@@ -212,12 +181,12 @@
return false;
} else {
Entity entity = damagesource.getEntity();
-@@ -712,10 +798,29 @@
+@@ -695,10 +762,29 @@
}
public boolean a(EntityHuman entityhuman) {
-- ScoreboardTeamBase scoreboardteambase = this.getScoreboardTeam();
-- ScoreboardTeamBase scoreboardteambase1 = entityhuman.getScoreboardTeam();
+- ScoreboardTeamBase scoreboardteambase = this.aO();
+- ScoreboardTeamBase scoreboardteambase1 = entityhuman.aO();
+ // 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;
@@ -245,21 +214,21 @@
}
protected void damageArmor(float f) {
-@@ -742,7 +847,12 @@
+@@ -742,7 +828,12 @@
return (float) i / (float) this.inventory.armor.length;
}
-- protected void d(DamageSource damagesource, float f) {
+- protected void damageEntity0(DamageSource damagesource, float f) {
+ // CraftBukkit start
-+ protected boolean d(DamageSource damagesource, float f) { // void -> boolean
++ protected boolean damageEntity0(DamageSource damagesource, float f) { // void -> boolean
+ if (true) {
-+ return super.d(damagesource, f);
++ return super.damageEntity0(damagesource, f);
+ }
+ // CraftBukkit end
if (!this.isInvulnerable(damagesource)) {
- if (!damagesource.ignoresArmor() && this.isBlocking() && f > 0.0F) {
- f = (1.0F + f) * 0.5F;
-@@ -766,6 +876,7 @@
+ f = this.applyArmorModifier(damagesource, f);
+ f = this.applyMagicModifier(damagesource, f);
+@@ -762,6 +853,7 @@
}
}
@@ -267,47 +236,31 @@
}
public void openSign(TileEntitySign tileentitysign) {}
-@@ -800,7 +911,8 @@
- }
-
- if (itemstack.a(this, (EntityLiving) entity)) {
-- if (itemstack.count <= 0 && !this.abilities.canInstantlyBuild) {
-+ // CraftBukkit - bypass infinite items; <= 0 -> == 0
-+ if (itemstack.count == 0 && !this.abilities.canInstantlyBuild) {
- this.ca();
- }
-
-@@ -866,8 +978,15 @@
- int j = EnchantmentManager.getFireAspectEnchantmentLevel(this);
-
- if (entity instanceof EntityLiving && j > 0 && !entity.isBurning()) {
-- flag1 = true;
-- entity.setOnFire(1);
-+ // CraftBukkit start - Call a combust event when somebody hits with a fire enchanted item
-+ EntityCombustByEntityEvent combustEvent = new EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), 1);
-+ org.bukkit.Bukkit.getPluginManager().callEvent(combustEvent);
+@@ -884,7 +976,15 @@
+ if (entity instanceof EntityLiving) {
+ f3 = ((EntityLiving) entity).getHealth();
+ if (j > 0 && !entity.isBurning()) {
+- flag4 = true;
++ // CraftBukkit start - Call a combust event when somebody hits with a fire enchanted item
++ EntityCombustByEntityEvent combustEvent = new EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), 1);
++ org.bukkit.Bukkit.getPluginManager().callEvent(combustEvent);
+
-+ if (!combustEvent.isCancelled()) {
-+ flag1 = true;
-+ entity.setOnFire(combustEvent.getDuration());
-+ }
-+ // CraftBukkit end
++ if (!combustEvent.isCancelled()) {
++ flag4 = true;
++ entity.setOnFire(combustEvent.getDuration());
++ }
++ // CraftBukkit end
+ entity.setOnFire(1);
+ }
}
-
- double d0 = entity.motX;
-@@ -884,11 +1003,28 @@
+@@ -925,11 +1025,28 @@
}
if (entity instanceof EntityPlayer && entity.velocityChanged) {
-- ((EntityPlayer) entity).playerConnection.sendPacket(new PacketPlayOutEntityVelocity(entity));
-- entity.velocityChanged = false;
-- entity.motX = d0;
-- entity.motY = d1;
-- entity.motZ = d2;
+ // CraftBukkit start - Add Velocity Event
+ boolean cancelled = false;
+ Player player = (Player) entity.getBukkitEntity();
-+ org.bukkit.util.Vector velocity = new Vector( d0, d1, d2 );
++ org.bukkit.util.Vector velocity = new Vector( d1, d2, d3 );
+
+ PlayerVelocityEvent event = new PlayerVelocityEvent(player, velocity.clone());
+ world.getServer().getPluginManager().callEvent(event);
@@ -319,29 +272,29 @@
+ }
+
+ if (!cancelled) {
-+ ( (EntityPlayer) entity ).playerConnection.sendPacket( new PacketPlayOutEntityVelocity( entity ) );
-+ entity.velocityChanged = false;
-+ entity.motX = d0;
-+ entity.motY = d1;
-+ entity.motZ = d2;
+ ((EntityPlayer) entity).playerConnection.sendPacket(new PacketPlayOutEntityVelocity(entity));
+ entity.velocityChanged = false;
+ entity.motX = d1;
+ entity.motY = d2;
+ entity.motZ = d3;
+ }
+ // CraftBukkit end
}
- if (flag) {
-@@ -922,7 +1058,8 @@
+ if (flag2) {
+@@ -991,7 +1108,8 @@
- if (itemstack != null && object instanceof EntityLiving) {
- itemstack.a((EntityLiving) object, this);
-- if (itemstack.count <= 0) {
+ if (itemstack3 != null && object instanceof EntityLiving) {
+ itemstack3.a((EntityLiving) object, this);
+- if (itemstack3.count <= 0) {
+ // CraftBukkit - bypass infinite items; <= 0 -> == 0
-+ if (itemstack.count == 0) {
- this.ca();
++ if (itemstack3.count == 0) {
+ this.a(EnumHand.MAIN_HAND, (ItemStack) null);
}
}
-@@ -930,7 +1067,14 @@
- if (entity instanceof EntityLiving) {
- this.a(StatisticList.w, Math.round(f * 10.0F));
+@@ -1001,7 +1119,14 @@
+
+ this.a(StatisticList.y, 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
@@ -353,10 +306,10 @@
+ }
+ // CraftBukkit end
}
- }
-@@ -996,6 +1140,20 @@
- this.mount((Entity) null);
+ if (this.world instanceof WorldServer && f5 > 2.0F) {
+@@ -1090,6 +1215,20 @@
+ this.stopRiding();
}
+ // CraftBukkit start - fire PlayerBedEnterEvent
@@ -375,8 +328,8 @@
+
this.setSize(0.2F, 0.2F);
if (this.world.isLoaded(blockposition)) {
- EnumDirection enumdirection = (EnumDirection) this.world.getType(blockposition).get(BlockDirectional.FACING);
-@@ -1078,6 +1236,23 @@
+ EnumDirection enumdirection = (EnumDirection) this.world.getType(blockposition).get(BlockFacingHorizontal.FACING);
+@@ -1172,6 +1311,23 @@
this.world.everyoneSleeping();
}
@@ -385,7 +338,7 @@
+ Player player = (Player) this.getBukkitEntity();
+
+ org.bukkit.block.Block bed;
-+ BlockPosition blockposition = this.bx;
++ BlockPosition blockposition = this.bedPosition;
+ if (blockposition != null) {
+ bed = this.world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
+ } else {
@@ -399,32 +352,16 @@
+
this.sleepTicks = flag ? 0 : 100;
if (flag2) {
- this.setRespawnPosition(this.bx, false);
-@@ -1090,6 +1265,7 @@
- }
-
- public static BlockPosition getBed(World world, BlockPosition blockposition, boolean flag) {
-+ ((ChunkProviderServer) world.chunkProvider).getChunkAt(blockposition.getX() >> 4, blockposition.getZ() >> 4); // CraftBukkit
- Block block = world.getType(blockposition).getBlock();
-
- if (block != Blocks.BED) {
-@@ -1128,9 +1304,11 @@
+ this.setRespawnPosition(this.bedPosition, false);
+@@ -1222,9 +1378,11 @@
if (blockposition != null) {
- this.c = blockposition;
- this.d = flag;
+ this.e = blockposition;
+ this.f = flag;
+ this.spawnWorld = this.world.worldData.getName(); // CraftBukkit
} else {
- this.c = null;
- this.d = false;
+ this.e = null;
+ this.f = false;
+ this.spawnWorld = ""; // CraftBukkit
}
}
-@@ -1480,6 +1658,7 @@
- }
-
- public IChatBaseComponent getScoreboardDisplayName() {
-+ // CraftBukkit - todo: fun
- ChatComponentText chatcomponenttext = new ChatComponentText(ScoreboardTeam.getPlayerDisplayName(this.getScoreboardTeam(), this.getName()));
-
- chatcomponenttext.getChatModifier().setChatClickable(new ChatClickable(ChatClickable.EnumClickAction.SUGGEST_COMMAND, "/msg " + this.getName() + " "));
diff --git a/nms-patches/EntityInsentient.patch b/nms-patches/EntityInsentient.patch
index 955ebec6..385bb3ce 100644
--- a/nms-patches/EntityInsentient.patch
+++ b/nms-patches/EntityInsentient.patch
@@ -1,7 +1,7 @@
--- a/net/minecraft/server/EntityInsentient.java
+++ b/net/minecraft/server/EntityInsentient.java
-@@ -4,6 +4,15 @@
- import java.util.List;
+@@ -8,6 +8,15 @@
+ import java.util.Random;
import java.util.UUID;
+// CraftBukkit start
@@ -15,9 +15,9 @@
+
public abstract class EntityInsentient extends EntityLiving {
- public int a_;
-@@ -40,6 +49,9 @@
- this.dropChances[i] = 0.085F;
+ private static final DataWatcherObject<Byte> a = DataWatcher.a(EntityInsentient.class, DataWatcherRegistry.a);
+@@ -60,6 +69,9 @@
+ this.r();
}
+ // CraftBukkit start - default persistance to type's persistance value
@@ -25,8 +25,8 @@
+ // CraftBukkit end
}
- protected void initAttributes() {
-@@ -76,7 +88,37 @@
+ protected void r() {}
+@@ -110,7 +122,37 @@
}
public void setGoalTarget(EntityLiving entityliving) {
@@ -63,8 +63,8 @@
+ // CraftBukkit end
}
- public boolean a(Class<? extends EntityLiving> oclass) {
-@@ -168,6 +210,7 @@
+ public boolean d(Class<? extends EntityLiving> oclass) {
+@@ -225,6 +267,7 @@
return null;
}
@@ -72,7 +72,7 @@
protected void dropDeathLoot(boolean flag, int i) {
Item item = this.getLoot();
-@@ -183,6 +226,12 @@
+@@ -240,6 +283,12 @@
}
}
@@ -85,17 +85,17 @@
}
public void b(NBTTagCompound nbttagcompound) {
-@@ -235,11 +284,20 @@
+@@ -321,11 +370,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.j(nbttagcompound.getBoolean("CanPickUpLoot"));
+- this.l(nbttagcompound.getBoolean("CanPickUpLoot"));
+ boolean data = nbttagcompound.getBoolean("CanPickUpLoot");
+ if (isLevelAtLeast(nbttagcompound, 1) || data) {
-+ this.j(data);
++ this.l(data);
+ }
}
@@ -108,7 +108,7 @@
NBTTagList nbttaglist;
int i;
-@@ -380,11 +438,11 @@
+@@ -549,11 +607,11 @@
double d2 = entityhuman.locZ - this.locZ;
double d3 = d0 * d0 + d1 * d1 + d2 * d2;
@@ -122,60 +122,44 @@
this.die();
} else if (d3 < 1024.0D) {
this.ticksFarFromPlayer = 0;
-@@ -707,6 +765,12 @@
+@@ -931,9 +989,21 @@
- public final boolean e(EntityHuman entityhuman) {
- if (this.cc() && this.getLeashHolder() == entityhuman) {
+ public final boolean a(EntityHuman entityhuman, ItemStack itemstack, EnumHand enumhand) {
+ if (this.isLeashed() && this.getLeashHolder() == entityhuman) {
+ // CraftBukkit start - fire PlayerUnleashEntityEvent
+ if (CraftEventFactory.callPlayerUnleashEntityEvent(this, entityhuman).isCancelled()) {
-+ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutAttachEntity(1, this, this.getLeashHolder()));
++ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutAttachEntity(this, this.getLeashHolder()));
+ return false;
+ }
+ // CraftBukkit end
this.unleash(true, !entityhuman.abilities.canInstantlyBuild);
return true;
- } else {
-@@ -714,12 +778,24 @@
-
- if (itemstack != null && itemstack.getItem() == Items.LEAD && this.cb()) {
- if (!(this instanceof EntityTameableAnimal) || !((EntityTameableAnimal) this).isTamed()) {
-+ // CraftBukkit start - fire PlayerLeashEntityEvent
-+ if (CraftEventFactory.callPlayerLeashEntityEvent(this, entityhuman, entityhuman).isCancelled()) {
-+ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutAttachEntity(1, this, this.getLeashHolder()));
-+ return false;
-+ }
-+ // CraftBukkit end
- this.setLeashHolder(entityhuman, true);
- --itemstack.count;
- return true;
- }
+ } else if (itemstack != null && itemstack.getItem() == Items.LEAD && this.a(entityhuman)) {
++ // CraftBukkit start - fire PlayerLeashEntityEvent
++ if (CraftEventFactory.callPlayerLeashEntityEvent(this, entityhuman, entityhuman).isCancelled()) {
++ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutAttachEntity(this, this.getLeashHolder()));
++ return false;
++ }
++ // CraftBukkit end
+ this.setLeashHolder(entityhuman, true);
+ --itemstack.count;
+ return true;
+@@ -953,10 +1023,12 @@
- if (((EntityTameableAnimal) this).e((EntityLiving) entityhuman)) {
-+ // CraftBukkit start - fire PlayerLeashEntityEvent
-+ if (CraftEventFactory.callPlayerLeashEntityEvent(this, entityhuman, entityhuman).isCancelled()) {
-+ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutAttachEntity(1, this, this.getLeashHolder()));
-+ return false;
-+ }
-+ // CraftBukkit end
- this.setLeashHolder(entityhuman, true);
- --itemstack.count;
- return true;
-@@ -741,10 +817,12 @@
-
- if (this.bo) {
+ if (this.bC) {
if (!this.isAlive()) {
+ this.world.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.PLAYER_UNLEASH)); // CraftBukkit
this.unleash(true, true);
}
- if (this.bp == null || this.bp.dead) {
+ if (this.leashHolder == null || this.leashHolder.dead) {
+ this.world.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.HOLDER_GONE)); // CraftBukkit
this.unleash(true, true);
}
}
-@@ -811,6 +889,7 @@
+@@ -1037,6 +1109,7 @@
- this.bp = entityleash;
+ this.leashHolder = entityleash;
} else {
+ this.world.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.UNKNOWN)); // CraftBukkit
this.unleash(false, true);
diff --git a/nms-patches/EntityIronGolem.patch b/nms-patches/EntityIronGolem.patch
index f05036e9..6fe4f58e 100644
--- a/nms-patches/EntityIronGolem.patch
+++ b/nms-patches/EntityIronGolem.patch
@@ -1,20 +1,11 @@
--- a/net/minecraft/server/EntityIronGolem.java
+++ b/net/minecraft/server/EntityIronGolem.java
-@@ -59,7 +59,7 @@
+@@ -71,7 +71,7 @@
- protected void s(Entity entity) {
- if (entity instanceof IMonster && !(entity instanceof EntityCreeper) && this.bc().nextInt(20) == 0) {
+ protected void C(Entity entity) {
+ if (entity instanceof IMonster && !(entity instanceof EntityCreeper) && this.getRandom().nextInt(20) == 0) {
- this.setGoalTarget((EntityLiving) entity);
+ this.setGoalTarget((EntityLiving) entity, org.bukkit.event.entity.EntityTargetLivingEntityEvent.TargetReason.COLLISION, true); // CraftBukkit - set reason
}
- super.s(entity);
-@@ -220,7 +220,7 @@
- }
-
- public boolean apply(Object object) {
-- return this.a((EntityLiving) object);
-+ return this.a((T) object); // CraftBukkit - fix decompiler error
- }
- };
- }
+ super.C(entity);
diff --git a/nms-patches/EntityItem.patch b/nms-patches/EntityItem.patch
index dc984456..5699d56e 100644
--- a/nms-patches/EntityItem.patch
+++ b/nms-patches/EntityItem.patch
@@ -1,6 +1,6 @@
--- a/net/minecraft/server/EntityItem.java
+++ b/net/minecraft/server/EntityItem.java
-@@ -3,6 +3,7 @@
+@@ -4,6 +4,7 @@
import java.util.Iterator;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -8,15 +8,15 @@
public class EntityItem extends Entity {
-@@ -13,6 +14,7 @@
- private String f;
+@@ -15,6 +16,7 @@
private String g;
+ private String h;
public float a;
+ private int lastTick = MinecraftServer.currentTick; // CraftBukkit
public EntityItem(World world, double d0, double d1, double d2) {
super(world);
-@@ -28,6 +30,11 @@
+@@ -30,6 +32,11 @@
public EntityItem(World world, double d0, double d1, double d2, ItemStack itemstack) {
this(world, d0, d1, d2);
@@ -28,10 +28,10 @@
this.setItemStack(itemstack);
}
-@@ -52,9 +59,12 @@
+@@ -54,9 +61,12 @@
this.die();
} else {
- super.t_();
+ super.m();
- if (this.pickupDelay > 0 && this.pickupDelay != 32767) {
- --this.pickupDelay;
- }
@@ -44,7 +44,7 @@
this.lastX = this.locX;
this.lastY = this.locY;
-@@ -90,12 +100,21 @@
+@@ -92,12 +102,20 @@
this.motY *= -0.5D;
}
@@ -53,9 +53,8 @@
++this.age;
}
+ // Craftbukkit end */
-+
- this.W();
+ this.aj();
if (!this.world.isClientSide && this.age >= 6000) {
+ // CraftBukkit start - fire ItemDespawnEvent
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callItemDespawnEvent(this).isCancelled()) {
@@ -66,7 +65,7 @@
this.die();
}
-@@ -137,6 +156,7 @@
+@@ -139,6 +157,7 @@
} else if (itemstack1.count + itemstack.count > itemstack1.getMaxStackSize()) {
return false;
} else {
@@ -74,7 +73,7 @@
itemstack1.count += itemstack.count;
entityitem.pickupDelay = Math.max(entityitem.pickupDelay, this.pickupDelay);
entityitem.age = Math.min(entityitem.age, this.age);
-@@ -183,6 +203,11 @@
+@@ -185,6 +204,11 @@
} else if (this.getItemStack() != null && this.getItemStack().getItem() == Items.NETHER_STAR && damagesource.isExplosion()) {
return false;
} else {
@@ -83,10 +82,10 @@
+ return false;
+ }
+ // CraftBukkit end
- this.ac();
- this.e = (int) ((float) this.e - f);
- if (this.e <= 0) {
-@@ -228,7 +253,18 @@
+ this.ao();
+ this.f = (int) ((float) this.f - f);
+ if (this.f <= 0) {
+@@ -230,7 +254,18 @@
NBTTagCompound nbttagcompound1 = nbttagcompound.getCompound("Item");
@@ -106,7 +105,7 @@
if (this.getItemStack() == null) {
this.die();
}
-@@ -240,6 +276,26 @@
+@@ -242,6 +277,26 @@
ItemStack itemstack = this.getItemStack();
int i = itemstack.count;
@@ -130,6 +129,6 @@
+ }
+ // CraftBukkit end
+
- if (this.pickupDelay == 0 && (this.g == null || 6000 - this.age <= 200 || this.g.equals(entityhuman.getName())) && entityhuman.inventory.pickup(itemstack)) {
+ if (this.pickupDelay == 0 && (this.h == null || 6000 - this.age <= 200 || this.h.equals(entityhuman.getName())) && entityhuman.inventory.pickup(itemstack)) {
if (itemstack.getItem() == Item.getItemOf(Blocks.LOG)) {
entityhuman.b((Statistic) AchievementList.g);
diff --git a/nms-patches/EntityItemFrame.patch b/nms-patches/EntityItemFrame.patch
index 1859a974..6f6c7b25 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
-@@ -27,6 +27,11 @@
+@@ -31,6 +31,11 @@
return false;
} else if (!damagesource.isExplosion() && this.getItem() != null) {
if (!this.world.isClientSide) {
@@ -9,6 +9,6 @@
+ return true;
+ }
+ // CraftBukkit end
- this.a(damagesource.getEntity(), false);
+ this.b(damagesource.getEntity(), false);
+ this.a(SoundEffects.cR, 1.0F, 1.0F);
this.setItem((ItemStack) null);
- }
diff --git a/nms-patches/EntityLeash.patch b/nms-patches/EntityLeash.patch
index 0496ad2f..190a9178 100644
--- a/nms-patches/EntityLeash.patch
+++ b/nms-patches/EntityLeash.patch
@@ -1,61 +1,59 @@
--- a/net/minecraft/server/EntityLeash.java
+++ b/net/minecraft/server/EntityLeash.java
-@@ -3,6 +3,8 @@
- import java.util.Iterator;
- import java.util.List;
+@@ -1,5 +1,7 @@
+ package net.minecraft.server;
-+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
++import org.bukkit.craftbukkit.event.CraftEventFactory;
+
- public class EntityLeash extends EntityHanging {
-
- public EntityLeash(World world) {
-@@ -63,6 +65,12 @@
- while (iterator.hasNext()) {
- entityinsentient = (EntityInsentient) iterator.next();
- if (entityinsentient.cc() && entityinsentient.getLeashHolder() == entityhuman) {
-+ // CraftBukkit start
-+ if (CraftEventFactory.callPlayerLeashEntityEvent(entityinsentient, this, entityhuman).isCancelled()) {
-+ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutAttachEntity(1, entityinsentient, entityinsentient.getLeashHolder()));
-+ continue;
-+ }
-+ // CraftBukkit end
- entityinsentient.setLeashHolder(this, true);
- flag = true;
- }
-@@ -70,8 +78,11 @@
- }
+ import java.util.Iterator;
+ import java.util.List;
- if (!this.world.isClientSide && !flag) {
-- this.die();
-- if (entityhuman.abilities.canInstantlyBuild) {
-+ // CraftBukkit start - Move below
-+ // this.die();
-+ boolean die = true;
-+ // CraftBukkit end
-+ if (true || entityhuman.abilities.canInstantlyBuild) { // CraftBukkit - Process for non-creative as well
- d0 = 7.0D;
- list = this.world.a(EntityInsentient.class, new AxisAlignedBB(this.locX - d0, this.locY - d0, this.locZ - d0, this.locX + d0, this.locY + d0, this.locZ + d0));
- iterator = list.iterator();
-@@ -79,10 +90,21 @@
+@@ -73,6 +75,12 @@
while (iterator.hasNext()) {
entityinsentient = (EntityInsentient) iterator.next();
- if (entityinsentient.cc() && entityinsentient.getLeashHolder() == this) {
-- entityinsentient.unleash(true, false);
+ if (entityinsentient.isLeashed() && entityinsentient.getLeashHolder() == entityhuman) {
+ // CraftBukkit start
-+ if (CraftEventFactory.callPlayerUnleashEntityEvent(entityinsentient, entityhuman).isCancelled()) {
-+ die = false;
++ if (CraftEventFactory.callPlayerLeashEntityEvent(entityinsentient, this, entityhuman).isCancelled()) {
++ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutAttachEntity(entityinsentient, entityinsentient.getLeashHolder()));
+ continue;
+ }
-+ entityinsentient.unleash(true, !entityhuman.abilities.canInstantlyBuild); // false -> survival mode boolean
+ // CraftBukkit end
+ entityinsentient.setLeashHolder(this, true);
+ flag = true;
+ }
+@@ -80,8 +88,11 @@
+ }
+
+ if (!flag) {
+- this.die();
+- if (entityhuman.abilities.canInstantlyBuild) {
++ // CraftBukkit start - Move below
++ // this.die();
++ boolean die = true;
++ // CraftBukkit end
++ if (true || entityhuman.abilities.canInstantlyBuild) { // CraftBukkit - Process for non-creative as well
+ d0 = 7.0D;
+ list = this.world.a(EntityInsentient.class, new AxisAlignedBB(this.locX - d0, this.locY - d0, this.locZ - d0, this.locX + d0, this.locY + d0, this.locZ + d0));
+ iterator = list.iterator();
+@@ -89,9 +100,20 @@
+ while (iterator.hasNext()) {
+ entityinsentient = (EntityInsentient) iterator.next();
+ if (entityinsentient.isLeashed() && entityinsentient.getLeashHolder() == this) {
+- entityinsentient.unleash(true, false);
++ // CraftBukkit start
++ if (CraftEventFactory.callPlayerUnleashEntityEvent(entityinsentient, entityhuman).isCancelled()) {
++ die = false;
++ continue;
++ }
++ entityinsentient.unleash(true, !entityhuman.abilities.canInstantlyBuild); // false -> survival mode boolean
++ // CraftBukkit end
+ }
}
++ // CraftBukkit start
++ if (die) {
++ this.die();
++ }
++ // CraftBukkit end
}
}
-+ // CraftBukkit start
-+ if (die) {
-+ this.die();
-+ }
-+ // CraftBukkit end
- }
- return true;
diff --git a/nms-patches/EntityLightning.patch b/nms-patches/EntityLightning.patch
index 61a28542..58617843 100644
--- a/nms-patches/EntityLightning.patch
+++ b/nms-patches/EntityLightning.patch
@@ -1,6 +1,6 @@
--- a/net/minecraft/server/EntityLightning.java
+++ b/net/minecraft/server/EntityLightning.java
-@@ -2,30 +2,53 @@
+@@ -2,15 +2,19 @@
import java.util.List;
@@ -11,31 +11,19 @@
private int lifeTicks;
public long a;
private int c;
+ private final boolean d;
++ public boolean isEffect; // CraftBukkit
-+ // CraftBukkit start
-+ public boolean isEffect = false;
-+
- public EntityLightning(World world, double d0, double d1, double d2) {
-+ this(world, d0, d1, d2, false);
-+ }
-+
-+ public EntityLightning(World world, double d0, double d1, double d2, boolean isEffect) {
-+ // CraftBukkit end
+ public EntityLightning(World world, double d0, double d1, double d2, boolean flag) {
super(world);
-+
-+ // CraftBukkit - Set isEffect
-+ this.isEffect = isEffect;
-+
++ this.isEffect = flag; // CraftBukkit
this.setPositionRotation(d0, d1, d2, 0.0F, 0.0F);
this.lifeTicks = 2;
this.a = this.random.nextLong();
- this.c = this.random.nextInt(3) + 1;
- BlockPosition blockposition = new BlockPosition(this);
+@@ -20,14 +24,22 @@
-- if (!world.isClientSide && world.getGameRules().getBoolean("doFireTick") && (world.getDifficulty() == EnumDifficulty.NORMAL || world.getDifficulty() == EnumDifficulty.HARD) && world.areChunksLoaded(blockposition, 10)) {
-+ // CraftBukkit - add "!isEffect"
-+ if (!isEffect && !world.isClientSide && world.getGameRules().getBoolean("doFireTick") && (world.getDifficulty() == EnumDifficulty.NORMAL || world.getDifficulty() == EnumDifficulty.HARD) && world.areChunksLoaded(blockposition, 10)) {
- if (world.getType(blockposition).getBlock().getMaterial() == Material.AIR && Blocks.FIRE.canPlace(world, blockposition)) {
+ 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()) {
@@ -47,7 +35,7 @@
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).getBlock().getMaterial() == Material.AIR && Blocks.FIRE.canPlace(world, blockposition1)) {
+ 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()) {
@@ -57,13 +45,13 @@
}
}
}
-@@ -35,7 +58,24 @@
- public void t_() {
- super.t_();
+@@ -41,7 +53,24 @@
+ public void m() {
+ super.m();
if (this.lifeTicks == 2) {
-- this.world.makeSound(this.locX, this.locY, this.locZ, "ambient.weather.thunder", 10000.0F, 0.8F + this.random.nextFloat() * 0.2F);
+- this.world.a((EntityHuman) null, this.locX, this.locY, this.locZ, SoundEffects.dh, SoundCategory.WEATHER, 10000.0F, 0.8F + this.random.nextFloat() * 0.2F);
+ // CraftBukkit start - Use relative location for far away sounds
-+ //this.world.makeSound(this.locX, this.locY, this.locZ, "ambient.weather.thunder", 10000.0F, 0.8F + this.random.nextFloat() * 0.2F);
++ // this.world.a((EntityHuman) null, this.locX, this.locY, this.locZ, SoundEffects.dc, SoundCategory.d, 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) {
@@ -74,27 +62,26 @@
+ double deltaLength = Math.sqrt(distanceSquared);
+ double relativeX = player.locX + (deltaX / deltaLength) * viewDistance;
+ double relativeZ = player.locZ + (deltaZ / deltaLength) * viewDistance;
-+ player.playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect("ambient.weather.thunder", relativeX, this.locY, relativeZ, 10000.0F, pitch));
++ player.playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect(SoundEffects.dh, SoundCategory.WEATHER, relativeX, this.locY, relativeZ, 10000.0F, pitch));
+ } else {
-+ player.playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect("ambient.weather.thunder", this.locX, this.locY, this.locZ, 10000.0F, pitch));
++ player.playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect(SoundEffects.dh, SoundCategory.WEATHER, this.locX, this.locY, this.locZ, 10000.0F, pitch));
+ }
+ }
+ // CraftBukkit end
- this.world.makeSound(this.locX, this.locY, this.locZ, "random.explode", 2.0F, 0.5F + this.random.nextFloat() * 0.2F);
+ this.world.a((EntityHuman) null, this.locX, this.locY, this.locZ, SoundEffects.dg, SoundCategory.WEATHER, 2.0F, 0.5F + this.random.nextFloat() * 0.2F);
}
-@@ -49,13 +89,18 @@
- this.a = this.random.nextLong();
- BlockPosition blockposition = new BlockPosition(this);
+@@ -57,13 +86,17 @@
+ BlockPosition blockposition = new BlockPosition(this);
-+ // CraftBukkit - add "!isEffect"
- if (!this.world.isClientSide && this.world.getGameRules().getBoolean("doFireTick") && this.world.areChunksLoaded(blockposition, 10) && this.world.getType(blockposition).getBlock().getMaterial() == Material.AIR && Blocks.FIRE.canPlace(this.world, blockposition)) {
-- this.world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData());
-+ // CraftBukkit start
-+ if (!isEffect && !CraftEventFactory.callBlockIgniteEvent(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this).isCancelled()) {
-+ this.world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData());
-+ }
-+ // CraftBukkit end
+ 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
+ }
}
}
}
@@ -103,4 +90,4 @@
+ if (this.lifeTicks >= 0 && !this.isEffect) { // CraftBukkit - add !this.isEffect
if (this.world.isClientSide) {
this.world.d(2);
- } else {
+ } else if (!this.d) {
diff --git a/nms-patches/EntityLiving.patch b/nms-patches/EntityLiving.patch
index c6c94912..f9e8cac3 100644
--- a/nms-patches/EntityLiving.patch
+++ b/nms-patches/EntityLiving.patch
@@ -1,6 +1,6 @@
--- a/net/minecraft/server/EntityLiving.java
+++ b/net/minecraft/server/EntityLiving.java
-@@ -10,12 +10,25 @@
+@@ -9,6 +9,20 @@
import java.util.Random;
import java.util.UUID;
@@ -8,49 +8,44 @@
+import java.util.ArrayList;
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
++import org.bukkit.craftbukkit.attribute.CraftAttributeMap;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
-+import org.bukkit.entity.LivingEntity;
-+import org.bukkit.entity.Vehicle;
++import org.bukkit.craftbukkit.inventory.CraftItemStack;
++import org.bukkit.entity.Player;
+import org.bukkit.event.entity.EntityDamageEvent;
+import org.bukkit.event.entity.EntityDamageEvent.DamageModifier;
+import org.bukkit.event.entity.EntityRegainHealthEvent;
-+import org.bukkit.event.vehicle.VehicleExitEvent;
++import org.bukkit.event.player.PlayerItemConsumeEvent;
+// CraftBukkit end
+
public abstract class EntityLiving extends Entity {
private static final UUID a = UUID.fromString("662A6B8D-DA3E-4C1C-8813-96EA6097278D");
- private static final AttributeModifier b = (new AttributeModifier(EntityLiving.a, "Sprinting speed boost", 0.30000001192092896D, 2)).a(false);
- private AttributeMapBase c;
-- public final CombatTracker combatTracker = new CombatTracker(this);
-+ public CombatTracker combatTracker = new CombatTracker(this);
- public final Map<Integer, MobEffect> effects = Maps.newHashMap();
- private final ItemStack[] h = new ItemStack[5];
- public boolean ar;
-@@ -69,6 +82,11 @@
- private float bm;
- private int bn;
- private float bo;
+@@ -80,6 +94,12 @@
+ protected int bn;
+ protected int bo;
+ private BlockPosition bC;
+ // CraftBukkit start
+ public int expToDrop;
+ public int maxAirTicks = 300;
-+ ArrayList<org.bukkit.inventory.ItemStack> drops = null;
++ ArrayList<org.bukkit.inventory.ItemStack> drops;
++ public org.bukkit.craftbukkit.attribute.CraftAttributeMap craftAttributes;
+ // CraftBukkit end
- public void G() {
+ public void Q() {
this.damageEntity(DamageSource.OUT_OF_WORLD, Float.MAX_VALUE);
-@@ -77,7 +95,8 @@
+@@ -88,7 +108,8 @@
public EntityLiving(World world) {
super(world);
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.watch(6, (float) this.getAttributeInstance(GenericAttributes.maxHealth).getValue());
- this.k = true;
- this.aH = (float) ((Math.random() + 1.0D) * 0.009999999776482582D);
++ this.datawatcher.set(EntityLiving.HEALTH, (float) this.getAttributeInstance(GenericAttributes.maxHealth).getValue());
+ this.i = true;
+ this.aL = (float) ((Math.random() + 1.0D) * 0.009999999776482582D);
this.setPosition(this.locX, this.locY, this.locZ);
-@@ -119,7 +138,13 @@
-
+@@ -125,7 +146,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)});
@@ -64,8 +59,8 @@
}
}
-@@ -177,7 +202,11 @@
- this.mount((Entity) null);
+@@ -183,7 +210,11 @@
+ this.stopRiding();
}
} else {
- this.setAirTicks(300);
@@ -75,9 +70,9 @@
+ }
+ // CraftBukkit end
}
- }
-@@ -225,25 +254,36 @@
+ if (!this.world.isClientSide) {
+@@ -240,6 +271,18 @@
this.world.methodProfiler.b();
}
@@ -85,7 +80,7 @@
+ public int getExpReward() {
+ int exp = this.getExpValue(this.killer);
+
-+ if (!this.world.isClientSide && (this.lastDamageByPlayerTime > 0 || this.alwaysGivesExp()) && this.ba() && this.world.getGameRules().getBoolean("doMobLoot")) {
++ if (!this.world.isClientSide && (this.lastDamageByPlayerTime > 0 || this.alwaysGivesExp()) && this.isDropExperience() && this.world.getGameRules().getBoolean("doMobLoot")) {
+ return exp;
+ } else {
+ return 0;
@@ -93,29 +88,30 @@
+ }
+ // CraftBukkit end
+
- public boolean isBaby() {
- return false;
- }
+ protected void b(BlockPosition blockposition) {
+ int i = EnchantmentManager.a(Enchantments.j, this);
- protected void aZ() {
+@@ -255,19 +298,19 @@
+
+ protected void bC() {
++this.deathTicks;
- if (this.deathTicks == 20) {
+ if (this.deathTicks >= 20 && !this.dead) { // CraftBukkit - (this.deathTicks == 20) -> (this.deathTicks >= 20 && !this.dead)
int i;
-- if (!this.world.isClientSide && (this.lastDamageByPlayerTime > 0 || this.alwaysGivesExp()) && this.ba() && this.world.getGameRules().getBoolean("doMobLoot")) {
+- if (!this.world.isClientSide && (this.alwaysGivesExp() || this.lastDamageByPlayerTime > 0 && this.isDropExperience() && this.world.getGameRules().getBoolean("doMobLoot"))) {
- i = this.getExpValue(this.killer);
--
++ // 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));
- }
-+ // CraftBukkit start - Update getExpReward() above if the removed if() changes!
-+ i = this.expToDrop;
-+ while (i > 0) {
-+ int j = EntityExperienceOrb.getOrbValue(i);
+ i -= j;
+ this.world.addEntity(new EntityExperienceOrb(this.world, this.locX, this.locY, this.locZ, j));
}
@@ -124,7 +120,7 @@
this.die();
-@@ -380,6 +420,17 @@
+@@ -421,6 +464,17 @@
}
}
@@ -139,11 +135,11 @@
+ }
+ // CraftBukkit end
+
- if (nbttagcompound.hasKeyOfType("HealF", 99)) {
- this.setHealth(nbttagcompound.getFloat("HealF"));
- } else {
-@@ -399,9 +450,15 @@
- this.hurtTimestamp = nbttagcompound.getInt("HurtByTimestamp");
+ if (nbttagcompound.hasKeyOfType("Health", 99)) {
+ this.setHealth(nbttagcompound.getFloat("Health"));
+ }
+@@ -436,9 +490,15 @@
+
}
+ // CraftBukkit start
@@ -151,14 +147,14 @@
+ private List<Object> effectsToProcess = Lists.newArrayList();
+ // CraftBukkit end
+
- protected void bi() {
+ protected void tickPotionEffects() {
Iterator iterator = this.effects.keySet().iterator();
+ isTickingEffects = true; // CraftBukkit
while (iterator.hasNext()) {
- Integer integer = (Integer) iterator.next();
- MobEffect mobeffect = (MobEffect) this.effects.get(integer);
-@@ -415,6 +472,16 @@
+ MobEffectList mobeffectlist = (MobEffectList) iterator.next();
+ MobEffect mobeffect = (MobEffect) this.effects.get(mobeffectlist);
+@@ -452,6 +512,16 @@
this.a(mobeffect, false);
}
}
@@ -168,24 +164,14 @@
+ if (e instanceof MobEffect) {
+ addEffect((MobEffect) e);
+ } else {
-+ removeEffect((Integer) e);
++ removeEffect((MobEffectList) e);
+ }
+ }
+ // CraftBukkit end
if (this.updateEffects) {
if (!this.world.isClientSide) {
-@@ -490,7 +557,8 @@
- }
-
- public boolean hasEffect(int i) {
-- return this.effects.containsKey(Integer.valueOf(i));
-+ // CraftBukkit - Add size check for efficiency
-+ return this.effects.size() != 0 && this.effects.containsKey(Integer.valueOf(i));
- }
-
- public boolean hasEffect(MobEffectList mobeffectlist) {
-@@ -502,6 +570,12 @@
+@@ -548,6 +618,12 @@
}
public void addEffect(MobEffect mobeffect) {
@@ -196,22 +182,22 @@
+ }
+ // CraftBukkit end
if (this.d(mobeffect)) {
- if (this.effects.containsKey(Integer.valueOf(mobeffect.getEffectId()))) {
- ((MobEffect) this.effects.get(Integer.valueOf(mobeffect.getEffectId()))).a(mobeffect);
-@@ -531,6 +605,12 @@
+ MobEffect mobeffect1 = (MobEffect) this.effects.get(mobeffect.getMobEffect());
+
+@@ -579,6 +655,12 @@
}
- public void removeEffect(int i) {
+ public MobEffect c(MobEffectList mobeffectlist) {
+ // CraftBukkit start
+ if (isTickingEffects) {
-+ effectsToProcess.add(i);
-+ return;
++ effectsToProcess.add(mobeffectlist);
++ return null;
+ }
+ // CraftBukkit end
- MobEffect mobeffect = (MobEffect) this.effects.remove(Integer.valueOf(i));
+ return (MobEffect) this.effects.remove(mobeffectlist);
+ }
- if (mobeffect != null) {
-@@ -564,20 +644,52 @@
+@@ -618,20 +700,52 @@
}
@@ -242,7 +228,7 @@
+ return (float) ((EntityPlayer) this).getBukkitEntity().getHealth();
+ }
+ // CraftBukkit end
- return this.datawatcher.getFloat(6);
+ return ((Float) this.datawatcher.get(EntityLiving.HEALTH)).floatValue();
}
public void setHealth(float f) {
@@ -258,24 +244,24 @@
+ player.setRealHealth(f);
+ }
+
-+ this.datawatcher.watch(6, Float.valueOf(player.getScaledHealth()));
++ this.datawatcher.set(EntityLiving.HEALTH, Float.valueOf(player.getScaledHealth()));
+ return;
+ }
+ // CraftBukkit end
- this.datawatcher.watch(6, Float.valueOf(MathHelper.a(f, 0.0F, this.getMaxHealth())));
+ this.datawatcher.set(EntityLiving.HEALTH, Float.valueOf(MathHelper.a(f, 0.0F, this.getMaxHealth())));
}
-@@ -593,7 +705,8 @@
- } else if (damagesource.o() && this.hasEffect(MobEffectList.FIRE_RESISTANCE)) {
+@@ -647,7 +761,8 @@
+ } else if (damagesource.o() && this.hasEffect(MobEffects.FIRE_RESISTANCE)) {
return false;
} else {
-- if ((damagesource == DamageSource.ANVIL || damagesource == DamageSource.FALLING_BLOCK) && this.getEquipment(4) != null) {
-+ // CraftBukkit - Moved into d(DamageSource, float)
-+ if (false && (damagesource == DamageSource.ANVIL || damagesource == DamageSource.FALLING_BLOCK) && this.getEquipment(4) != null) {
- this.getEquipment(4).damage((int) (f * 4.0F + this.random.nextFloat() * f * 2.0F), this);
+- if ((damagesource == DamageSource.ANVIL || damagesource == DamageSource.FALLING_BLOCK) && this.getEquipment(EnumItemSlot.HEAD) != null) {
++ // CraftBukkit - Moved into damageEntity0(DamageSource, float)
++ if (false && (damagesource == DamageSource.ANVIL || damagesource == DamageSource.FALLING_BLOCK) && this.getEquipment(EnumItemSlot.HEAD) != null) {
+ this.getEquipment(EnumItemSlot.HEAD).damage((int) (f * 4.0F + this.random.nextFloat() * f * 2.0F), this);
f *= 0.75F;
}
-@@ -603,19 +716,38 @@
+@@ -673,19 +788,38 @@
if ((float) this.noDamageTicks > (float) this.maxNoDamageTicks / 2.0F) {
if (f <= this.lastDamage) {
@@ -283,60 +269,57 @@
return false;
}
-- this.d(damagesource, f - this.lastDamage);
+- this.damageEntity0(damagesource, f - this.lastDamage);
+ // CraftBukkit start
-+ if (!this.d(damagesource, f - this.lastDamage)) {
++ if (!this.damageEntity0(damagesource, f - this.lastDamage)) {
+ return false;
+ }
+ // CraftBukkit end
this.lastDamage = f;
- flag = false;
+ flag1 = false;
} else {
+ // CraftBukkit start
-+ float previousHealth = this.getHealth();
-+ if (!this.d(damagesource, f)) {
++ if (!this.damageEntity0(damagesource, f)) {
+ return false;
+ }
this.lastDamage = f;
this.noDamageTicks = this.maxNoDamageTicks;
-- this.d(damagesource, f);
+- this.damageEntity0(damagesource, f);
++ // this.damageEntity0(damagesource, f);
+ // CraftBukkit end
- this.hurtTicks = this.av = 10;
+ this.hurtTicks = this.ay = 10;
}
+ // CraftBukkit start
+ if(this instanceof EntityAnimal){
-+ ((EntityAnimal)this).cq();
++ ((EntityAnimal)this).resetLove();
+ if(this instanceof EntityTameableAnimal){
+ ((EntityTameableAnimal)this).getGoalSit().setSitting(false);
+ }
+ }
+ // CraftBukkit end
+
- this.aw = 0.0F;
+ this.az = 0.0F;
Entity entity = damagesource.getEntity();
-@@ -721,11 +853,19 @@
- }
+@@ -822,9 +956,16 @@
+ }
+
+ if (this.isDropExperience() && this.world.getGameRules().getBoolean("doMobLoot")) {
++ this.drops = new ArrayList<org.bukkit.inventory.ItemStack>(); // CraftBukkit - Setup drop capture
+ boolean flag = this.lastDamageByPlayerTime > 0;
- if (this.ba() && this.world.getGameRules().getBoolean("doMobLoot")) {
-+ this.drops = new ArrayList<org.bukkit.inventory.ItemStack>(); // CraftBukkit - Setup drop capture
-+
- this.dropDeathLoot(this.lastDamageByPlayerTime > 0, i);
- this.dropEquipment(this.lastDamageByPlayerTime > 0, i);
- if (this.lastDamageByPlayerTime > 0 && this.random.nextFloat() < 0.025F + (float) i * 0.01F) {
- this.getRareDrop();
+ this.a(flag, i, damagesource);
++ // CraftBukkit start - Call death event
++ CraftEventFactory.callEntityDeathEvent(this, this.drops);
++ this.drops = null;
++ } else {
++ CraftEventFactory.callEntityDeathEvent(this);
++ // CraftBukkit end
}
-+ // CraftBukkit start - Call death event
-+ CraftEventFactory.callEntityDeathEvent(this, this.drops);
-+ this.drops = null;
-+ } else {
-+ CraftEventFactory.callEntityDeathEvent(this);
-+ // CraftBukkit end
}
- }
-@@ -785,8 +925,13 @@
+@@ -912,8 +1053,13 @@
int i = MathHelper.f((f - 3.0F - f2) * f1);
if (i > 0) {
@@ -345,52 +328,58 @@
+ return;
+ }
+ // CraftBukkit end
- this.makeSound(this.n(i), 1.0F, 1.0F);
+ this.a(this.e(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);
-@@ -830,7 +975,7 @@
- int i = 25 - this.br();
- float f1 = f * (float) i;
+@@ -940,20 +1086,20 @@
+ protected float applyArmorModifier(DamageSource damagesource, float f) {
+ if (!damagesource.ignoresArmor()) {
- this.damageArmor(f);
-+ // this.damageArmor(f); // CraftBukkit - Moved into d(DamageSource, float)
- f = f1 / 25.0F;
++ // this.damageArmor(f); // CraftBukkit - Moved into damageEntity0(DamageSource, float)
+ f = CombatMath.a(f, (float) this.getArmorStrength());
}
-@@ -844,8 +989,9 @@
- int i;
- int j;
- float f1;
+ return f;
+ }
-
-- if (this.hasEffect(MobEffectList.RESISTANCE) && damagesource != DamageSource.OUT_OF_WORLD) {
-+
-+ // CraftBukkit - Moved to d(DamageSource, float)
-+ if (false && this.hasEffect(MobEffectList.RESISTANCE) && damagesource != DamageSource.OUT_OF_WORLD) {
- i = (this.getEffect(MobEffectList.RESISTANCE).getAmplifier() + 1) * 5;
- j = 25 - i;
- f1 = f * (float) j;
-@@ -871,22 +1017,121 @@
+ protected float applyMagicModifier(DamageSource damagesource, float f) {
+ if (damagesource.isStarvation()) {
+ return f;
+ } else {
+ int i;
+
+- if (this.hasEffect(MobEffects.RESISTANCE) && damagesource != DamageSource.OUT_OF_WORLD) {
++ // CraftBukkit - Moved to damageEntity0(DamageSource, float)
++ if (false && this.hasEffect(MobEffects.RESISTANCE) && damagesource != DamageSource.OUT_OF_WORLD) {
+ i = (this.getEffect(MobEffects.RESISTANCE).getAmplifier() + 1) * 5;
+ int j = 25 - i;
+ float f1 = f * (float) j;
+@@ -974,22 +1120,122 @@
}
}
-- protected void d(DamageSource damagesource, float f) {
+- protected void damageEntity0(DamageSource damagesource, float f) {
- if (!this.isInvulnerable(damagesource)) {
- f = this.applyArmorModifier(damagesource, f);
- f = this.applyMagicModifier(damagesource, f);
- float f1 = f;
+ // CraftBukkit start
-+ protected boolean d(final DamageSource damagesource, float f) { // void -> boolean, add final
++ protected boolean damageEntity0(final DamageSource damagesource, float f) { // void -> boolean, add final
+ if (!this.isInvulnerable(damagesource)) {
+ final boolean human = this instanceof EntityHuman;
+ float originalDamage = f;
+ Function<Double, Double> hardHat = new Function<Double, Double>() {
+ @Override
+ public Double apply(Double f) {
-+ if ((damagesource == DamageSource.ANVIL || damagesource == DamageSource.FALLING_BLOCK) && EntityLiving.this.getEquipment(4) != null) {
++ if ((damagesource == DamageSource.ANVIL || damagesource == DamageSource.FALLING_BLOCK) && EntityLiving.this.getEquipment(EnumItemSlot.HEAD) != null) {
+ return -(f - (f * 0.75F));
+
+- f = Math.max(f - this.getAbsorptionHearts(), 0.0F);
+- this.setAbsorptionHearts(this.getAbsorptionHearts() - (f1 - f));
+ }
+ return -0.0;
+ }
@@ -424,8 +413,8 @@
+ Function<Double, Double> resistance = new Function<Double, Double>() {
+ @Override
+ public Double apply(Double f) {
-+ if (!damagesource.isStarvation() && EntityLiving.this.hasEffect(MobEffectList.RESISTANCE) && damagesource != DamageSource.OUT_OF_WORLD) {
-+ int i = (EntityLiving.this.getEffect(MobEffectList.RESISTANCE).getAmplifier() + 1) * 5;
++ if (!damagesource.isStarvation() && EntityLiving.this.hasEffect(MobEffects.RESISTANCE) && damagesource != DamageSource.OUT_OF_WORLD) {
++ int i = (EntityLiving.this.getEffect(MobEffects.RESISTANCE).getAmplifier() + 1) * 5;
+ int j = 25 - i;
+ float f1 = f.floatValue() * (float) j;
+ return -(f - (f1 / 25.0F));
@@ -461,8 +450,8 @@
+ f = (float) event.getFinalDamage();
+
+ // Apply damage to helmet
-+ if ((damagesource == DamageSource.ANVIL || damagesource == DamageSource.FALLING_BLOCK) && this.getEquipment(4) != null) {
-+ this.getEquipment(4).damage((int) (event.getDamage() * 4.0F + this.random.nextFloat() * event.getDamage() * 2.0F), this);
++ if ((damagesource == DamageSource.ANVIL || damagesource == DamageSource.FALLING_BLOCK) && this.getEquipment(EnumItemSlot.HEAD) != null) {
++ this.getEquipment(EnumItemSlot.HEAD).damage((int) (event.getDamage() * 4.0F + this.random.nextFloat() * event.getDamage() * 2.0F), this);
+ }
+
+ // Apply damage to armor
@@ -470,9 +459,7 @@
+ float armorDamage = (float) (event.getDamage() + event.getDamage(DamageModifier.BLOCKING) + event.getDamage(DamageModifier.HARD_HAT));
+ this.damageArmor(armorDamage);
+ }
-
-- f = Math.max(f - this.getAbsorptionHearts(), 0.0F);
-- this.setAbsorptionHearts(this.getAbsorptionHearts() - (f1 - f));
++
+ absorptionModifier = (float) -event.getDamage(DamageModifier.ABSORPTION);
+ this.setAbsorptionHearts(Math.max(this.getAbsorptionHearts() - absorptionModifier, 0.0F));
if (f != 0.0F) {
@@ -480,14 +467,14 @@
+ // 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.x, Math.round(f * 10.0F));
++ ((EntityHuman) this).a(StatisticList.z, Math.round(f * 10.0F));
+ }
+ }
+ // CraftBukkit end
float f2 = this.getHealth();
this.setHealth(f2 - f);
- this.bs().a(damagesource, f2, f);
+ this.getCombatTracker().trackDamage(damagesource, f2, f);
+ // CraftBukkit start
+ if (human) {
+ return true;
@@ -495,26 +482,24 @@
+ // CraftBukkit end
this.setAbsorptionHearts(this.getAbsorptionHearts() - f);
}
-+ return true; // CraftBukkit
++ return true;
}
+ return false; // CraftBukkit
}
- public CombatTracker bs() {
-@@ -1240,7 +1485,8 @@
- if (f > 0.0025000002F) {
- f3 = 1.0F;
- f2 = (float) Math.sqrt((double) f) * 3.0F;
-- f1 = (float) MathHelper.b(d1, d0) * 180.0F / 3.1415927F - 90.0F;
-+ // CraftBukkit - Math -> TrigMath
-+ f1 = (float) org.bukkit.craftbukkit.TrigMath.atan2(d1, d0) * 180.0F / 3.1415927F - 90.0F;
+ public CombatTracker getCombatTracker() {
+@@ -1055,6 +1301,7 @@
+ public AttributeMapBase getAttributeMap() {
+ if (this.bp == null) {
+ this.bp = new AttributeMapServer();
++ this.craftAttributes = new CraftAttributeMap(bp); // CraftBukkit
}
- if (this.az > 0.0F) {
-@@ -1413,6 +1659,13 @@
+ return this.bp;
+@@ -1702,6 +1949,13 @@
+ if (!list.isEmpty()) {
for (int i = 0; i < list.size(); ++i) {
Entity entity = (Entity) list.get(i);
-
+ // TODO better check now?
+ // CraftBukkit start - Only handle mob (non-player) collisions every other tick
+ if (entity instanceof EntityLiving && !(this instanceof EntityPlayer) && this.ticksLived % 2 == 0) {
@@ -522,25 +507,30 @@
+ }
+ // CraftBukkit end
+
- this.s(entity);
- }
- }
-@@ -1425,6 +1678,18 @@
- public void mount(Entity entity) {
- if (this.vehicle != null && entity == null) {
-+ // CraftBukkit start
-+ Entity originalVehicle = this.vehicle;
-+ if ((this.bukkitEntity instanceof LivingEntity) && (this.vehicle.getBukkitEntity() instanceof Vehicle)) {
-+ VehicleExitEvent event = new VehicleExitEvent((Vehicle) this.vehicle.getBukkitEntity(), (LivingEntity) this.bukkitEntity);
-+ getBukkitEntity().getServer().getPluginManager().callEvent(event);
+ this.C(entity);
+ }
+@@ -1918,7 +2172,22 @@
+ protected void v() {
+ if (this.bm != null && this.cs()) {
+ this.a(this.bm, 16);
+- ItemStack itemstack = this.bm.a(this.world, this);
++ // CraftBukkit start - fire PlayerItemConsumeEvent
++ org.bukkit.inventory.ItemStack craftItem = CraftItemStack.asBukkitCopy(this.bm); // PAIL: rename
++ PlayerItemConsumeEvent event = new PlayerItemConsumeEvent((Player) this.getBukkitEntity(), craftItem);
++ world.getServer().getPluginManager().callEvent(event);
+
-+ if (event.isCancelled() || vehicle != originalVehicle) {
-+ return;
++ if (event.isCancelled()) {
++ // Update client
++ if (this instanceof EntityPlayer) {
++ ((EntityPlayer) this).getBukkitEntity().updateInventory();
++ ((EntityPlayer) this).getBukkitEntity().updateScaledHealth();
+ }
++ return;
+ }
++
++ ItemStack itemstack = (craftItem.equals(event.getItem())) ? this.bm.a(this.world, this) : CraftItemStack.asNMSCopy(event.getItem()).a(world, this);
+ // CraftBukkit end
-+
- if (!this.world.isClientSide) {
- this.q(this.vehicle);
- }
+
+ if (itemstack != null && itemstack.count == 0) {
+ itemstack = null;
diff --git a/nms-patches/EntityMinecartAbstract.patch b/nms-patches/EntityMinecartAbstract.patch
index 252d080f..099aa1a2 100644
--- a/nms-patches/EntityMinecartAbstract.patch
+++ b/nms-patches/EntityMinecartAbstract.patch
@@ -15,10 +15,10 @@
+
public abstract class EntityMinecartAbstract extends Entity implements INamableTileEntity {
- private boolean a;
-@@ -16,6 +25,17 @@
- private double h;
- private double i;
+ private static final DataWatcherObject<Integer> a = DataWatcher.a(EntityMinecartAbstract.class, DataWatcherRegistry.b);
+@@ -21,6 +30,17 @@
+ private double aw;
+ private double ax;
+ // CraftBukkit start
+ public boolean slowWhenEmpty = true;
@@ -33,8 +33,8 @@
+
public EntityMinecartAbstract(World world) {
super(world);
- this.k = true;
-@@ -81,6 +101,8 @@
+ this.i = true;
+@@ -86,6 +106,8 @@
this.lastX = d0;
this.lastY = d1;
this.lastZ = d2;
@@ -42,8 +42,8 @@
+ this.world.getServer().getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleCreateEvent((Vehicle) this.getBukkitEntity())); // CraftBukkit
}
- public double an() {
-@@ -92,6 +114,19 @@
+ public double ay() {
+@@ -97,6 +119,19 @@
if (this.isInvulnerable(damagesource)) {
return false;
} else {
@@ -60,10 +60,10 @@
+
+ f = (float) event.getDamage();
+ // CraftBukkit end
- this.k(-this.r());
- this.j(10);
- this.ac();
-@@ -99,6 +134,15 @@
+ this.e(-this.u());
+ this.d(10);
+ this.ao();
+@@ -104,6 +139,15 @@
boolean flag = damagesource.getEntity() instanceof EntityHuman && ((EntityHuman) damagesource.getEntity()).abilities.canInstantlyBuild;
if (flag || this.getDamage() > 40.0F) {
@@ -76,13 +76,13 @@
+ return true;
+ }
+ // CraftBukkit end
- if (this.passenger != null) {
- this.passenger.mount((Entity) null);
- }
-@@ -140,6 +184,14 @@
+ this.az();
+ if (flag && !this.hasCustomName()) {
+ this.die();
+@@ -146,6 +190,14 @@
}
- public void t_() {
+ public void m() {
+ // CraftBukkit start
+ double prevX = this.locX;
+ double prevY = this.locY;
@@ -90,20 +90,20 @@
+ float prevYaw = this.yaw;
+ float prevPitch = this.pitch;
+ // CraftBukkit end
-+
++
if (this.getType() > 0) {
- this.j(this.getType() - 1);
+ this.d(this.getType() - 1);
}
-@@ -160,7 +212,7 @@
+@@ -166,7 +218,7 @@
- i = this.L();
+ i = this.V();
if (this.ak) {
- if (minecraftserver.getAllowNether()) {
+ if (true || minecraftserver.getAllowNether()) { // CraftBukkit - multi-world should still allow teleport even if default vanilla nether disabled
- if (this.vehicle == null && this.al++ >= i) {
+ if (!this.isPassenger() && this.al++ >= i) {
this.al = i;
- this.portalCooldown = this.aq();
-@@ -257,6 +309,20 @@
+ this.portalCooldown = this.aC();
+@@ -263,6 +315,20 @@
}
this.setYawPitch(this.yaw, this.pitch);
@@ -124,16 +124,16 @@
Iterator iterator = this.world.getEntities(this, this.getBoundingBox().grow(0.20000000298023224D, 0.0D, 0.20000000298023224D)).iterator();
while (iterator.hasNext()) {
-@@ -280,7 +346,7 @@
+@@ -278,7 +344,7 @@
}
- protected double m() {
+ protected double o() {
- return 0.4D;
+ return this.maxSpeed; // CraftBukkit
}
public void a(int i, int j, int k, boolean flag) {}
-@@ -291,16 +357,20 @@
+@@ -289,16 +355,20 @@
this.motX = MathHelper.a(this.motX, -d0, d0);
this.motZ = MathHelper.a(this.motZ, -d0, d0);
if (this.onGround) {
@@ -160,19 +160,19 @@
}
}
-@@ -488,7 +558,7 @@
+@@ -487,7 +557,7 @@
}
- protected void o() {
-- if (this.passenger != null) {
-+ if (this.passenger != null || !this.slowWhenEmpty) { // CraftBukkit - add !this.slowWhenEmpty
+ protected void r() {
+- if (this.isVehicle()) {
++ if (this.isVehicle() || !this.slowWhenEmpty) { // CraftBukkit - add !this.slowWhenEmpty
this.motX *= 0.996999979019165D;
this.motY *= 0.0D;
this.motZ *= 0.996999979019165D;
-@@ -616,6 +686,17 @@
+@@ -599,6 +669,17 @@
if (!this.world.isClientSide) {
if (!entity.noclip && !this.noclip) {
- if (entity != this.passenger) {
+ if (!this.w(entity)) {
+ // CraftBukkit start
+ Vehicle vehicle = (Vehicle) this.getBukkitEntity();
+ org.bukkit.entity.Entity hitEntity = (entity == null) ? null : entity.getBukkitEntity();
@@ -184,10 +184,10 @@
+ return;
+ }
+ // CraftBukkit end
- if (entity instanceof EntityLiving && !(entity instanceof EntityHuman) && !(entity instanceof EntityIronGolem) && this.s() == EntityMinecartAbstract.EnumMinecartType.RIDEABLE && this.motX * this.motX + this.motZ * this.motZ > 0.01D && this.passenger == null && entity.vehicle == null) {
- entity.mount(this);
+ if (entity instanceof EntityLiving && this.v() == EntityMinecartAbstract.EnumMinecartType.RIDEABLE && this.motX * this.motX + this.motZ * this.motZ > 0.01D && !(entity instanceof EntityHuman) && !(entity instanceof EntityIronGolem) && !this.isVehicle() && !entity.isPassenger()) {
+ entity.startRiding(this);
}
-@@ -624,7 +705,8 @@
+@@ -607,7 +688,8 @@
double d1 = entity.locZ - this.locZ;
double d2 = d0 * d0 + d1 * d1;
@@ -197,7 +197,7 @@
d2 = (double) MathHelper.sqrt(d2);
d0 /= d2;
d1 /= d2;
-@@ -891,4 +973,26 @@
+@@ -836,4 +918,26 @@
}
}
diff --git a/nms-patches/EntityMinecartCommandBlock.patch b/nms-patches/EntityMinecartCommandBlock.patch
index 33aa4bcd..811b2567 100644
--- a/nms-patches/EntityMinecartCommandBlock.patch
+++ b/nms-patches/EntityMinecartCommandBlock.patch
@@ -1,12 +1,12 @@
--- a/net/minecraft/server/EntityMinecartCommandBlock.java
+++ b/net/minecraft/server/EntityMinecartCommandBlock.java
-@@ -3,6 +3,9 @@
- public class EntityMinecartCommandBlock extends EntityMinecartAbstract {
-
- private final CommandBlockListenerAbstract a = new CommandBlockListenerAbstract() {
+@@ -5,6 +5,9 @@
+ private static final DataWatcherObject<String> a = DataWatcher.a(EntityMinecartCommandBlock.class, DataWatcherRegistry.d);
+ private static final DataWatcherObject<IChatBaseComponent> b = DataWatcher.a(EntityMinecartCommandBlock.class, DataWatcherRegistry.e);
+ private final CommandBlockListenerAbstract c = new CommandBlockListenerAbstract() {
+ {
+ this.sender = (org.bukkit.craftbukkit.entity.CraftMinecartCommand) EntityMinecartCommandBlock.this.getBukkitEntity(); // CraftBukkit - Set the sender
+ }
- public void h() {
- EntityMinecartCommandBlock.this.getDataWatcher().watch(23, this.getCommand());
- EntityMinecartCommandBlock.this.getDataWatcher().watch(24, IChatBaseComponent.ChatSerializer.a(this.k()));
+ public void i() {
+ EntityMinecartCommandBlock.this.getDataWatcher().set(EntityMinecartCommandBlock.a, this.getCommand());
+ EntityMinecartCommandBlock.this.getDataWatcher().set(EntityMinecartCommandBlock.b, this.l());
diff --git a/nms-patches/EntityMinecartContainer.patch b/nms-patches/EntityMinecartContainer.patch
index 2356daee..06b90287 100644
--- a/nms-patches/EntityMinecartContainer.patch
+++ b/nms-patches/EntityMinecartContainer.patch
@@ -1,21 +1,23 @@
--- a/net/minecraft/server/EntityMinecartContainer.java
+++ b/net/minecraft/server/EntityMinecartContainer.java
-@@ -1,10 +1,49 @@
+@@ -1,14 +1,51 @@
package net.minecraft.server;
+ import java.util.Random;
+// CraftBukkit start
+import java.util.List;
-+
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
+import org.bukkit.entity.HumanEntity;
+import org.bukkit.inventory.InventoryHolder;
+// CraftBukkit end
-+
- public abstract class EntityMinecartContainer extends EntityMinecartAbstract implements ITileInventory {
+
+ public abstract class EntityMinecartContainer extends EntityMinecartAbstract implements ITileInventory, ILootable {
- private ItemStack[] items = new ItemStack[36];
+ private ItemStack[] items = new ItemStack[27]; // CraftBukkit - 36 -> 27
private boolean b = true;
+ private MinecraftKey c;
+ private long d;
+ // CraftBukkit start
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
@@ -51,7 +53,7 @@
public EntityMinecartContainer(World world) {
super(world);
}
-@@ -84,7 +123,7 @@
+@@ -75,7 +112,7 @@
}
public int getMaxStackSize() {
@@ -59,4 +61,4 @@
+ return maxStack; // CraftBukkit
}
- public void c(int i) {
+ public Entity c(int i) {
diff --git a/nms-patches/EntityMonster.patch b/nms-patches/EntityMonster.patch
index 239b5701..0a19ca7d 100644
--- a/nms-patches/EntityMonster.patch
+++ b/nms-patches/EntityMonster.patch
@@ -8,7 +8,7 @@
public abstract class EntityMonster extends EntityCreature implements IMonster {
public EntityMonster(World world) {
-@@ -79,7 +81,14 @@
+@@ -75,7 +77,14 @@
int j = EnchantmentManager.getFireAspectEnchantmentLevel(this);
if (j > 0) {
@@ -23,4 +23,4 @@
+ // CraftBukkit end
}
- this.a((EntityLiving) this, entity);
+ if (entity instanceof EntityHuman) {
diff --git a/nms-patches/EntityMushroomCow.patch b/nms-patches/EntityMushroomCow.patch
index 7702e6d1..9ae6061f 100644
--- a/nms-patches/EntityMushroomCow.patch
+++ b/nms-patches/EntityMushroomCow.patch
@@ -8,10 +8,10 @@
public class EntityMushroomCow extends EntityCow {
public EntityMushroomCow(World world) {
-@@ -24,6 +26,14 @@
- }
+@@ -18,6 +20,14 @@
- if (itemstack != null && itemstack.getItem() == Items.SHEARS && this.getAge() >= 0) {
+ return true;
+ } else if (itemstack != null && itemstack.getItem() == Items.SHEARS && this.getAge() >= 0) {
+ // CraftBukkit start
+ PlayerShearEntityEvent event = new PlayerShearEntityEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), this.getBukkitEntity());
+ this.world.getServer().getPluginManager().callEvent(event);
diff --git a/nms-patches/EntityOcelot.patch b/nms-patches/EntityOcelot.patch
index 6f1a161d..1ce5a151 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
-@@ -51,7 +51,7 @@
+@@ -54,7 +54,7 @@
}
protected boolean isTypeNotPersistent() {
@@ -9,7 +9,7 @@
}
protected void initAttributes() {
-@@ -96,6 +96,9 @@
+@@ -95,6 +95,9 @@
return entity.damageEntity(DamageSource.mobAttack(this), 3.0F);
}
@@ -19,15 +19,15 @@
public boolean damageEntity(DamageSource damagesource, float f) {
if (this.isInvulnerable(damagesource)) {
return false;
-@@ -104,6 +107,7 @@
+@@ -106,6 +109,7 @@
return super.damageEntity(damagesource, f);
}
}
+ // CraftBukkit end */
- protected void dropDeathLoot(boolean flag, int i) {}
-
-@@ -124,7 +128,8 @@
+ protected MinecraftKey J() {
+ return LootTables.J;
+@@ -122,7 +126,8 @@
}
if (!this.world.isClientSide) {
@@ -36,8 +36,8 @@
+ if (this.random.nextInt(3) == 0 && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this, entityhuman).isCancelled()) {
this.setTamed(true);
this.setCatType(1 + this.world.random.nextInt(3));
- this.setOwnerUUID(entityhuman.getUniqueID().toString());
-@@ -231,7 +236,7 @@
+ this.setOwnerUUID(entityhuman.getUniqueID());
+@@ -230,7 +235,7 @@
entityocelot.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, 0.0F);
entityocelot.setAgeRaw(-24000);
diff --git a/nms-patches/EntityPig.patch b/nms-patches/EntityPig.patch
index 2f7637bb..77e77006 100644
--- a/nms-patches/EntityPig.patch
+++ b/nms-patches/EntityPig.patch
@@ -1,14 +1,15 @@
--- a/net/minecraft/server/EntityPig.java
+++ b/net/minecraft/server/EntityPig.java
-@@ -1,5 +1,7 @@
- package net.minecraft.server;
+@@ -4,6 +4,8 @@
+ import java.util.Iterator;
+ import java.util.Set;
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
+
public class EntityPig extends EntityAnimal {
- private final PathfinderGoalPassengerCarrotStick bm;
-@@ -112,6 +114,12 @@
+ private static final DataWatcherObject<Boolean> bv = DataWatcher.a(EntityPig.class, DataWatcherRegistry.h);
+@@ -130,6 +132,12 @@
if (!this.world.isClientSide && !this.dead) {
EntityPigZombie entitypigzombie = new EntityPigZombie(this.world);
@@ -18,10 +19,10 @@
+ }
+ // CraftBukkit end
+
- entitypigzombie.setEquipment(0, new ItemStack(Items.GOLDEN_SWORD));
+ entitypigzombie.setSlot(EnumItemSlot.MAINHAND, new ItemStack(Items.GOLDEN_SWORD));
entitypigzombie.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, this.pitch);
- entitypigzombie.k(this.ce());
-@@ -120,7 +128,8 @@
+ entitypigzombie.m(this.cR());
+@@ -138,7 +146,8 @@
entitypigzombie.setCustomNameVisible(this.getCustomNameVisible());
}
diff --git a/nms-patches/EntityPlayer.patch b/nms-patches/EntityPlayer.patch
index fe51ea53..7c4af058 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
-@@ -13,6 +13,17 @@
+@@ -11,6 +11,17 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -17,8 +17,8 @@
+
public class EntityPlayer extends EntityHuman implements ICrafting {
- private static final Logger bH = LogManager.getLogger();
-@@ -40,6 +51,18 @@
+ private static final Logger bQ = LogManager.getLogger();
+@@ -43,6 +54,18 @@
public int ping;
public boolean viewingCredits;
@@ -37,7 +37,7 @@
public EntityPlayer(MinecraftServer minecraftserver, WorldServer worldserver, GameProfile gameprofile, PlayerInteractManager playerinteractmanager) {
super(worldserver, gameprofile);
playerinteractmanager.player = this;
-@@ -70,6 +93,11 @@
+@@ -73,6 +96,11 @@
this.setPosition(this.locX, this.locY + 1.0D, this.locZ);
}
@@ -49,7 +49,7 @@
}
public void a(NBTTagCompound nbttagcompound) {
-@@ -82,12 +110,40 @@
+@@ -85,6 +113,7 @@
}
}
@@ -57,12 +57,13 @@
}
public void b(NBTTagCompound nbttagcompound) {
- super.b(nbttagcompound);
- nbttagcompound.setInt("playerGameType", this.playerInteractManager.getGameMode().getId());
-+
-+ this.getBukkitEntity().setExtraData(nbttagcompound); // CraftBukkit
+@@ -101,8 +130,33 @@
+ nbttagcompound1.set("Entity", nbttagcompound2);
+ nbttagcompound.set("RootVehicle", nbttagcompound1);
+ }
++ this.getBukkitEntity().setExtraData(nbttagcompound); // CraftBukkit
+ }
-+
+
+ // CraftBukkit start - World fallback code, either respawn location or global spawn
+ public void spawnIn(World world) {
+ super.spawnIn(world);
@@ -90,10 +91,10 @@
public void levelDown(int i) {
super.levelDown(i);
-@@ -114,6 +170,11 @@
+@@ -133,6 +187,11 @@
}
- public void t_() {
+ public void m() {
+ // CraftBukkit start
+ if (this.joining) {
+ this.joining = false;
@@ -102,43 +103,21 @@
this.playerInteractManager.a();
--this.invulnerableTicks;
if (this.noDamageTicks > 0) {
-@@ -155,7 +216,7 @@
- chunk = this.world.getChunkAt(chunkcoordintpair.x, chunkcoordintpair.z);
- if (chunk.isReady()) {
- arraylist.add(chunk);
-- arraylist1.addAll(((WorldServer) this.world).getTileEntities(chunkcoordintpair.x * 16, 0, chunkcoordintpair.z * 16, chunkcoordintpair.x * 16 + 16, 256, chunkcoordintpair.z * 16 + 16));
-+ arraylist1.addAll(chunk.tileEntities.values()); // CraftBukkit - Get tile entities directly from the chunk instead of the world
- iterator1.remove();
- }
- }
-@@ -220,8 +281,9 @@
- }
+@@ -213,6 +272,12 @@
+ this.a(IScoreboardCriteria.i, MathHelper.f((float) this.bW));
}
-+ // CraftBukkit - Optionally scale health
- if (this.getHealth() != this.bM || this.bN != this.foodData.getFoodLevel() || this.foodData.getSaturationLevel() == 0.0F != this.bO) {
-- 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()));
- this.bM = this.getHealth();
- this.bN = this.foodData.getFoodLevel();
- this.bO = this.foodData.getSaturationLevel() == 0.0F;
-@@ -237,7 +299,14 @@
-
- this.getScoreboard().getPlayerScoreForObjective(this.getName(), scoreboardobjective).updateForList(Arrays.asList(new EntityHuman[] { this}));
- }
-+ // CraftBukkit - Update ALL the scores!
-+ this.world.getServer().getScoreboardManager().updateAllScoresForList(IScoreboardCriteria.g, this.getName(), com.google.common.collect.ImmutableList.of(this));
-+ }
+ // CraftBukkit start - Force max health updates
+ if (this.maxHealthCache != this.getMaxHealth()) {
+ this.getBukkitEntity().updateScaledHealth();
- }
++ }
+ // CraftBukkit end
-
- if (this.expTotal != this.lastSentExp) {
- this.lastSentExp = this.expTotal;
-@@ -248,6 +317,16 @@
- this.i_();
++
+ if (this.getArmorStrength() != this.bX) {
+ this.bX = this.getArmorStrength();
+ this.a(IScoreboardCriteria.j, MathHelper.f((float) this.bX));
+@@ -237,6 +302,16 @@
+ this.o();
}
+ // CraftBukkit start - initialize oldLevel and fire PlayerLevelChangeEvent
@@ -154,12 +133,12 @@
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.a(throwable, "Ticking player");
CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Player being ticked");
-@@ -296,30 +375,63 @@
- }
+@@ -301,30 +376,79 @@
+ boolean flag = this.world.getGameRules().getBoolean("showDeathMessages");
- public void die(DamageSource damagesource) {
-- if (this.world.getGameRules().getBoolean("showDeathMessages")) {
-- ScoreboardTeamBase scoreboardteambase = this.getScoreboardTeam();
+ this.playerConnection.sendPacket(new PacketPlayOutCombatEvent(this.getCombatTracker(), PacketPlayOutCombatEvent.EnumCombatEventType.ENTITY_DIED, flag));
+- if (flag) {
+- ScoreboardTeamBase scoreboardteambase = this.aO();
+ // CraftBukkit start - fire PlayerDeathEvent
+ if (this.dead) {
+ return;
@@ -173,46 +152,62 @@
+ loot.add(CraftItemStack.asCraftMirror(this.inventory.items[i]));
+ }
+ }
-
-- if (scoreboardteambase != null && scoreboardteambase.j() != ScoreboardTeamBase.EnumNameTagVisibility.ALWAYS) {
-- if (scoreboardteambase.j() == ScoreboardTeamBase.EnumNameTagVisibility.HIDE_FOR_OTHER_TEAMS) {
-- this.server.getPlayerList().a((EntityHuman) this, this.bs().b());
-- } else if (scoreboardteambase.j() == ScoreboardTeamBase.EnumNameTagVisibility.HIDE_FOR_OWN_TEAM) {
-- this.server.getPlayerList().b((EntityHuman) this, this.bs().b());
+ for (int i = 0; i < this.inventory.armor.length; ++i) {
+ if (this.inventory.armor[i] != null) {
+ loot.add(CraftItemStack.asCraftMirror(this.inventory.armor[i]));
- }
++ }
++ }
++ for (int i = 0; i < this.inventory.extraSlots.length; ++i) {
++ if (this.inventory.extraSlots[i] != null) {
++ loot.add(CraftItemStack.asCraftMirror(this.inventory.extraSlots[i]));
++ }
+ }
+ }
+
-+ IChatBaseComponent chatmessage = this.bs().b();
++ IChatBaseComponent chatmessage = this.getCombatTracker().getDeathMessage();
+
-+ String deathmessage = chatmessage.c();
++ String deathmessage = chatmessage.toPlainText();
+ org.bukkit.event.entity.PlayerDeathEvent event = CraftEventFactory.callPlayerDeathEvent(this, loot, deathmessage, keepInventory);
-+
+
+- if (scoreboardteambase != null && scoreboardteambase.j() != ScoreboardTeamBase.EnumNameTagVisibility.ALWAYS) {
+- if (scoreboardteambase.j() == ScoreboardTeamBase.EnumNameTagVisibility.HIDE_FOR_OTHER_TEAMS) {
+- this.server.getPlayerList().a((EntityHuman) this, this.getCombatTracker().getDeathMessage());
+- } else if (scoreboardteambase.j() == ScoreboardTeamBase.EnumNameTagVisibility.HIDE_FOR_OWN_TEAM) {
+- this.server.getPlayerList().b((EntityHuman) this, this.getCombatTracker().getDeathMessage());
+ String deathMessage = event.getDeathMessage();
+
-+ if (deathMessage != null && deathMessage.length() > 0 && this.world.getGameRules().getBoolean("showDeathMessages")) { // TODO: allow plugins to override?
++ if (deathMessage != null && deathMessage.length() > 0 && flag) { // TODO: allow plugins to override?
+ if (deathMessage.equals(deathmessage)) {
-+ this.server.getPlayerList().sendMessage(chatmessage);
++ ScoreboardTeamBase scoreboardteambase = this.aO();
++
++ if (scoreboardteambase != null && scoreboardteambase.j() != ScoreboardTeamBase.EnumNameTagVisibility.ALWAYS) {
++ if (scoreboardteambase.j() == ScoreboardTeamBase.EnumNameTagVisibility.HIDE_FOR_OTHER_TEAMS) {
++ this.server.getPlayerList().a((EntityHuman) this, chatmessage);
++ } else if (scoreboardteambase.j() == ScoreboardTeamBase.EnumNameTagVisibility.HIDE_FOR_OWN_TEAM) {
++ this.server.getPlayerList().b((EntityHuman) this, chatmessage);
++ }
++ } else {
++ this.server.getPlayerList().sendMessage(chatmessage);
+ }
} else {
-- this.server.getPlayerList().sendMessage(this.bs().b());
+- this.server.getPlayerList().sendMessage(this.getCombatTracker().getDeathMessage());
+ this.server.getPlayerList().sendMessage(org.bukkit.craftbukkit.util.CraftChatMessage.fromString(deathMessage));
}
}
-- if (!this.world.getGameRules().getBoolean("keepInventory")) {
+- if (!this.world.getGameRules().getBoolean("keepInventory") && !this.isSpectator()) {
- this.inventory.n();
+ // we clean the player's inventory after the EntityDeathEvent is called so plugins can get the exact state of the inventory.
+ if (!event.getKeepInventory()) {
+ for (int i = 0; i < this.inventory.items.length; ++i) {
+ this.inventory.items[i] = null;
+ }
-+
+ for (int i = 0; i < this.inventory.armor.length; ++i) {
+ this.inventory.armor[i] = null;
+ }
++ for (int i = 0; i < this.inventory.extraSlots.length; ++i) {
++ this.inventory.extraSlots[i] = null;
++ }
}
- Collection collection = this.world.getScoreboard().getObjectivesForCriteria(IScoreboardCriteria.d);
@@ -231,83 +226,67 @@
scoreboardscore.incrementScore();
}
-@@ -376,7 +488,8 @@
+@@ -381,7 +505,8 @@
}
- private boolean cr() {
+ private boolean canPvP() {
- return this.server.getPVP();
+ // CraftBukkit - this.server.getPvP() -> this.world.pvpMode
+ return this.world.pvpMode;
}
- public void c(int i) {
-@@ -388,6 +501,8 @@
- } else {
- if (this.dimension == 0 && i == 1) {
- this.b((Statistic) AchievementList.C);
-+ // CraftBukkit start - Rely on custom portal management
-+ /*
- BlockPosition blockposition = this.server.getWorldServer(i).getDimensionSpawn();
-
- if (blockposition != null) {
-@@ -395,11 +510,16 @@
- }
-
- i = 1;
-+ */
-+ // CraftBukkit end
- } else {
+ public Entity c(int i) {
+@@ -407,7 +532,10 @@
this.b((Statistic) AchievementList.y);
}
-- this.server.getPlayerList().changeDimension(this, i);
+- this.server.getPlayerList().a(this, i);
+ // CraftBukkit start
+ TeleportCause cause = (this.dimension == 1 || i == 1) ? TeleportCause.END_PORTAL : TeleportCause.NETHER_PORTAL;
-+ this.server.getPlayerList().changeDimension(this, i, cause);
++ this.server.getPlayerList().changeDimension(this, i, cause); // PAIL: check all this
+ // CraftBukkit end
+ this.playerConnection.sendPacket(new PacketPlayOutWorldEvent(1032, BlockPosition.ZERO, 0, false));
this.lastSentExp = -1;
- this.bM = -1.0F;
- this.bN = -1;
-@@ -442,6 +562,7 @@
+ this.lastHealthSent = -1.0F;
+@@ -452,6 +580,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.u().getTracker().sendPacketToEntity(this, new PacketPlayOutAnimation(this, 2));
- }
-@@ -457,7 +578,7 @@
- Entity entity1 = this.vehicle;
-
- super.mount(entity);
-- if (entity != entity1) {
-+ if (this.vehicle != entity1) { // CraftBukkit
- this.playerConnection.sendPacket(new PacketPlayOutAttachEntity(0, this, this.vehicle));
- this.playerConnection.a(this.locX, this.locY, this.locZ, this.yaw, this.pitch);
+ this.x().getTracker().sendPacketToEntity(this, new PacketPlayOutAnimation(this, 2));
}
-@@ -490,19 +611,46 @@
+@@ -530,23 +659,48 @@
this.playerConnection.sendPacket(new PacketPlayOutOpenSignEditor(tileentitysign.getPosition()));
}
-- private void nextContainerCounter() {
-+ public int nextContainerCounter() { // CraftBukkit - private void -> public int
+- public void nextContainerCounter() {
++ public int nextContainerCounter() { // CraftBukkit - void -> int
this.containerCounter = this.containerCounter % 100 + 1;
+ return containerCounter; // CraftBukkit
}
public void openTileEntity(ITileEntityContainer itileentitycontainer) {
+- if (itileentitycontainer instanceof ILootable && ((ILootable) itileentitycontainer).b() != null && this.isSpectator()) {
+- this.sendMessage((new ChatMessage("container.spectatorCantOpen", new Object[0])).setChatModifier((new ChatModifier()).setColor(EnumChatFormat.RED)));
+- } else {
+- this.nextContainerCounter();
+- this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.containerCounter, itileentitycontainer.getContainerName(), itileentitycontainer.getScoreboardDisplayName()));
+- this.activeContainer = itileentitycontainer.createContainer(this.inventory, this);
+- this.activeContainer.windowId = this.containerCounter;
+- this.activeContainer.addSlotListener(this);
+ // CraftBukkit start - Inventory open hook
+ Container container = CraftEventFactory.callInventoryOpenEvent(this, itileentitycontainer.createContainer(this.inventory, this));
+ if (container == null) {
+ return;
-+ }
+ }
++
++ this.nextContainerCounter();
++ this.activeContainer = container;
++ this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.containerCounter, itileentitycontainer.getContainerName(), itileentitycontainer.getScoreboardDisplayName()));
+ // CraftBukkit end
- this.nextContainerCounter();
- this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.containerCounter, itileentitycontainer.getContainerName(), itileentitycontainer.getScoreboardDisplayName()));
-- this.activeContainer = itileentitycontainer.createContainer(this.inventory, this);
-+ this.activeContainer = container; // CraftBukkit
- this.activeContainer.windowId = this.containerCounter;
- this.activeContainer.addSlotListener(this);
++ this.activeContainer.windowId = this.containerCounter;
++ this.activeContainer.addSlotListener(this);
}
public void openContainer(IInventory iinventory) {
@@ -316,12 +295,12 @@
+ boolean cancelled = false;
+ if (iinventory instanceof ITileInventory) {
+ ITileInventory itileinventory = (ITileInventory) iinventory;
-+ cancelled = itileinventory.r_() && !this.a(itileinventory.i()) && !this.isSpectator();
++ cancelled = itileinventory.x_() && !this.a(itileinventory.y_()) && !this.isSpectator(); // PAIL: rename
+ }
+
+ Container container;
+ if (iinventory instanceof ITileEntityContainer) {
-+ container = ((ITileEntityContainer)iinventory).createContainer(this.inventory, this);
++ container = ((ITileEntityContainer) iinventory).createContainer(this.inventory, this);
+ } else {
+ container = new ContainerChest(this.inventory, iinventory, this);
+ }
@@ -331,36 +310,35 @@
+ return;
+ }
+ // CraftBukkit end
- if (this.activeContainer != this.defaultContainer) {
- this.closeInventory();
- }
-@@ -510,9 +658,11 @@
- if (iinventory instanceof ITileInventory) {
- ITileInventory itileinventory = (ITileInventory) iinventory;
-
-- if (itileinventory.r_() && !this.a(itileinventory.i()) && !this.isSpectator()) {
-+ if (itileinventory.r_() && !this.a(itileinventory.i()) && !this.isSpectator() && container == null) { // CraftBukkit - allow plugins to uncancel the lock
- this.playerConnection.sendPacket(new PacketPlayOutChat(new ChatMessage("container.isLocked", new Object[] { iinventory.getScoreboardDisplayName()}), (byte) 2));
- this.playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect("random.door_close", this.locX, this.locY, this.locZ, 1.0F, 1.0F));
+
-+ iinventory.closeContainer(this); // CraftBukkit
- return;
- }
- }
-@@ -520,10 +670,10 @@
- this.nextContainerCounter();
- if (iinventory instanceof ITileEntityContainer) {
- this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.containerCounter, ((ITileEntityContainer) iinventory).getContainerName(), iinventory.getScoreboardDisplayName(), iinventory.getSize()));
-- this.activeContainer = ((ITileEntityContainer) iinventory).createContainer(this.inventory, this);
-+ this.activeContainer = container; // CraftBukkit
+ if (iinventory instanceof ILootable && ((ILootable) iinventory).b() != null && this.isSpectator()) {
+ this.sendMessage((new ChatMessage("container.spectatorCantOpen", new Object[0])).setChatModifier((new ChatModifier()).setColor(EnumChatFormat.RED)));
} else {
- this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.containerCounter, "minecraft:container", iinventory.getScoreboardDisplayName(), iinventory.getSize()));
-- this.activeContainer = new ContainerChest(this.inventory, iinventory, this);
-+ this.activeContainer = container; // CraftBukkit
- }
+@@ -560,18 +714,21 @@
+ if (itileinventory.x_() && !this.a(itileinventory.y_()) && !this.isSpectator()) {
+ this.playerConnection.sendPacket(new PacketPlayOutChat(new ChatMessage("container.isLocked", new Object[] { iinventory.getScoreboardDisplayName()}), (byte) 2));
+ this.playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect(SoundEffects.W, SoundCategory.BLOCKS, this.locX, this.locY, this.locZ, 1.0F, 1.0F));
++ iinventory.closeContainer(this); // CraftBukkit
+ return;
+ }
+ }
- this.activeContainer.windowId = this.containerCounter;
-@@ -531,8 +681,14 @@
+ this.nextContainerCounter();
++ // CraftBukkit start
+ if (iinventory instanceof ITileEntityContainer) {
++ this.activeContainer = container;
+ this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.containerCounter, ((ITileEntityContainer) iinventory).getContainerName(), iinventory.getScoreboardDisplayName(), iinventory.getSize()));
+- this.activeContainer = ((ITileEntityContainer) iinventory).createContainer(this.inventory, this);
+ } else {
++ this.activeContainer = container;
+ this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.containerCounter, "minecraft:container", iinventory.getScoreboardDisplayName(), iinventory.getSize()));
+- this.activeContainer = new ContainerChest(this.inventory, iinventory, this);
+ }
++ // CraftBukkit end
+
+ this.activeContainer.windowId = this.containerCounter;
+ this.activeContainer.addSlotListener(this);
+@@ -579,8 +736,14 @@
}
public void openTrade(IMerchant imerchant) {
@@ -376,10 +354,12 @@
this.activeContainer.windowId = this.containerCounter;
this.activeContainer.addSlotListener(this);
InventoryMerchant inventorymerchant = ((ContainerMerchant) this.activeContainer).e();
-@@ -552,13 +708,20 @@
+@@ -599,14 +762,21 @@
+
}
- public void openHorseInventory(EntityHorse entityhorse, IInventory iinventory) {
+- public void openHorseInventory(EntityHorse entityhorse, IInventory iinventory) {
++ public void a(EntityHorse entityhorse, IInventory iinventory) {
+ // CraftBukkit start - Inventory open hook
+ Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerHorse(this.inventory, iinventory, entityhorse, this));
+ if (container == null) {
@@ -398,7 +378,7 @@
this.activeContainer.windowId = this.containerCounter;
this.activeContainer.addSlotListener(this);
}
-@@ -587,6 +750,11 @@
+@@ -646,6 +816,11 @@
public void a(Container container, List<ItemStack> list) {
this.playerConnection.sendPacket(new PacketPlayOutWindowItems(container.windowId, list));
this.playerConnection.sendPacket(new PacketPlayOutSetSlot(-1, -1, this.inventory.getCarried()));
@@ -410,33 +390,32 @@
}
public void setContainerData(Container container, int i, int j) {
-@@ -601,6 +769,7 @@
+@@ -660,6 +835,7 @@
}
public void closeInventory() {
+ CraftEventFactory.handleInventoryCloseEvent(this); // CraftBukkit
this.playerConnection.sendPacket(new PacketPlayOutCloseWindow(this.activeContainer.windowId));
- this.p();
+ this.s();
}
-@@ -681,8 +850,17 @@
+@@ -741,7 +917,16 @@
public void triggerHealthUpdate() {
- this.bM = -1.0E8F;
+ this.lastHealthSent = -1.0E8F;
+ this.lastSentExp = -1; // CraftBukkit - Added to reset
- }
-
++ }
++
+ // CraftBukkit start - Support multi-line messages
+ public void sendMessage(IChatBaseComponent[] ichatbasecomponent) {
+ for (IChatBaseComponent component : ichatbasecomponent) {
+ this.sendMessage(component);
+ }
-+ }
+ }
+ // CraftBukkit end
-+
+
public void b(IChatBaseComponent ichatbasecomponent) {
this.playerConnection.sendPacket(new PacketPlayOutChat(ichatbasecomponent));
- }
-@@ -747,6 +925,8 @@
+@@ -802,6 +987,8 @@
}
public void a(WorldSettings.EnumGamemode worldsettings_enumgamemode) {
@@ -445,25 +424,23 @@
this.playerInteractManager.setGameMode(worldsettings_enumgamemode);
this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(3, (float) worldsettings_enumgamemode.getId()));
if (worldsettings_enumgamemode == WorldSettings.EnumGamemode.SPECTATOR) {
-@@ -757,6 +937,7 @@
+@@ -812,6 +999,7 @@
this.updateAbilities();
- this.bP();
+ this.cq();
+ // CraftBukkit end */
}
public boolean isSpectator() {
-@@ -768,7 +949,8 @@
+@@ -827,6 +1015,7 @@
}
public boolean a(int i, String s) {
-- if ("seed".equals(s) && !this.server.ae()) {
+ /* CraftBukkit start
-+ if ("seed".equals(s) && !this.server.ad()) {
+ if ("seed".equals(s) && !this.server.aa()) {
return true;
} else if (!"tell".equals(s) && !"help".equals(s) && !"me".equals(s) && !"trigger".equals(s)) {
- if (this.server.getPlayerList().isOp(this.getProfile())) {
-@@ -781,6 +963,12 @@
+@@ -840,6 +1029,12 @@
} else {
return true;
}
@@ -475,14 +452,11 @@
+ // CraftBukkit end
}
- public String w() {
-@@ -867,6 +1055,129 @@
+ public String A() {
+@@ -962,4 +1157,127 @@
+ this.setFlag(7, true);
+ this.setFlag(7, false);
}
-
- public IChatBaseComponent getPlayerListName() {
-- return null;
-+ return listName; // CraftBukkit
-+ }
+
+ // CraftBukkit start - Add per-player time and weather.
+ public long timeOffset = 0;
@@ -604,6 +578,6 @@
+ @Override
+ public CraftPlayer getBukkitEntity() {
+ return (CraftPlayer) super.getBukkitEntity();
- }
++ }
+ // CraftBukkit end
}
diff --git a/nms-patches/EntityPotion.patch b/nms-patches/EntityPotion.patch
index d16a99c9..8d6ccdb5 100644
--- a/nms-patches/EntityPotion.patch
+++ b/nms-patches/EntityPotion.patch
@@ -1,8 +1,8 @@
--- a/net/minecraft/server/EntityPotion.java
+++ b/net/minecraft/server/EntityPotion.java
-@@ -3,6 +3,13 @@
- import java.util.Iterator;
- import java.util.List;
+@@ -6,6 +6,13 @@
+ import org.apache.logging.log4j.LogManager;
+ import org.apache.logging.log4j.Logger;
+// CraftBukkit start
+import java.util.HashMap;
@@ -13,59 +13,105 @@
+
public class EntityPotion extends EntityProjectile {
- public ItemStack item;
-@@ -57,13 +64,16 @@
- if (!this.world.isClientSide) {
- List list = Items.POTION.h(this.item);
+ private static final DataWatcherObject<Optional<ItemStack>> d = DataWatcher.a(EntityItem.class, DataWatcherRegistry.f);
+@@ -77,7 +84,7 @@
+ this.world.triggerEffect(2002, new BlockPosition(this), PotionRegistry.a(potionregistry));
+ this.die();
+ } else {
+- if (!list.isEmpty()) {
++ if (true || !list.isEmpty()) { // CraftBukkit - Call event even if no effects to apply
+ if (this.n()) {
+ EntityAreaEffectCloud entityareaeffectcloud = new EntityAreaEffectCloud(this.world, this.locX, this.locY, this.locZ);
-- if (list != null && !list.isEmpty()) {
-+ if (true || list != null && !list.isEmpty()) { // CraftBukkit - Call event even if no effects to apply
- AxisAlignedBB axisalignedbb = this.getBoundingBox().grow(4.0D, 2.0D, 4.0D);
- List list1 = this.world.a(EntityLiving.class, axisalignedbb);
+@@ -89,6 +96,7 @@
+ entityareaeffectcloud.a(potionregistry);
+ iterator = PotionUtil.b(itemstack).iterator();
-- if (!list1.isEmpty()) {
-+ if (true || !list1.isEmpty()) { // CraftBukkit - Run code even if there are no entities around
- Iterator iterator = list1.iterator();
++ // PAIL: Add events
+ while (iterator.hasNext()) {
+ MobEffect mobeffect = (MobEffect) iterator.next();
-+ // CraftBukkit
-+ HashMap<LivingEntity, Double> affected = new HashMap<LivingEntity, Double>();
+@@ -100,6 +108,9 @@
+ AxisAlignedBB axisalignedbb = this.getBoundingBox().grow(4.0D, 2.0D, 4.0D);
+ List list1 = this.world.a(EntityLiving.class, axisalignedbb);
+
++ // CraftBukkit
++ HashMap<LivingEntity, Double> affected = new HashMap<LivingEntity, Double>();
+
- while (iterator.hasNext()) {
- EntityLiving entityliving = (EntityLiving) iterator.next();
- double d0 = this.h(entityliving);
-@@ -75,12 +85,35 @@
- d1 = 1.0D;
- }
+ if (!list1.isEmpty()) {
+ Iterator iterator1 = list1.iterator();
+
+@@ -116,21 +127,45 @@
+ d1 = 1.0D;
+ }
-+ // CraftBukkit start
-+ affected.put((LivingEntity) entityliving.getBukkitEntity(), d1);
+- Iterator iterator2 = list.iterator();
++ // CraftBukkit start
++ affected.put((LivingEntity) entityliving.getBukkitEntity(), d1);
++ }
++ }
++ }
+ }
-+ }
+
-+ org.bukkit.event.entity.PotionSplashEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPotionSplashEvent(this, affected);
-+ if (!event.isCancelled() && list != null && !list.isEmpty()) { // do not process effects if there are no effects to process
-+ for (LivingEntity victim : event.getAffectedEntities()) {
-+ if (!(victim instanceof CraftLivingEntity)) {
-+ continue;
-+ }
++ org.bukkit.event.entity.PotionSplashEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPotionSplashEvent(this, affected);
++ if (!event.isCancelled() && list != null && !list.isEmpty()) { // do not process effects if there are no effects to process
++ for (LivingEntity victim : event.getAffectedEntities()) {
++ if (!(victim instanceof CraftLivingEntity)) {
++ continue;
++ }
+
-+ EntityLiving entityliving = ((CraftLivingEntity) victim).getHandle();
-+ double d1 = event.getIntensity(victim);
-+ // CraftBukkit end
++ EntityLiving entityliving = ((CraftLivingEntity) victim).getHandle();
++ double d1 = event.getIntensity(victim);
++ // CraftBukkit end
+
- Iterator iterator1 = list.iterator();
-
- while (iterator1.hasNext()) {
- MobEffect mobeffect = (MobEffect) iterator1.next();
- int i = mobeffect.getEffectId();
++ Iterator iterator2 = list.iterator();
++
++ while (iterator2.hasNext()) {
++ MobEffect mobeffect1 = (MobEffect) iterator2.next();
++ MobEffectList mobeffectlist = mobeffect1.getMobEffect();
++ // CraftBukkit start - Abide by PVP settings - for players only!
++ if (!this.world.pvpMode && this.getShooter() instanceof EntityPlayer && entityliving instanceof EntityPlayer && entityliving != this.getShooter()) {
++ int i = MobEffectList.getId(mobeffectlist);
++ // Block SLOWER_MOVEMENT, SLOWER_DIG, HARM, BLINDNESS, HUNGER, WEAKNESS and POISON potions
++ if (i == 2 || i == 4 || i == 7 || i == 15 || i == 17 || i == 18 || i == 19) {
++ continue;
++ }
++ }
++ // CraftBukkit end
++ if (mobeffectlist.isInstant()) {
++ mobeffectlist.applyInstantEffect(this, this.getShooter(), entityliving, mobeffect1.getAmplifier(), d1);
++ } else {
++ int i = (int) (d1 * (double) mobeffect1.getDuration() + 0.5D);
-+ // CraftBukkit start - Abide by PVP settings - for players only!
-+ if (!this.world.pvpMode && this.getShooter() instanceof EntityPlayer && entityliving instanceof EntityPlayer && entityliving != this.getShooter()) {
-+ // Block SLOWER_MOVEMENT, SLOWER_DIG, HARM, BLINDNESS, HUNGER, WEAKNESS and POISON potions
-+ if (i == 2 || i == 4 || i == 7 || i == 15 || i == 17 || i == 18 || i == 19) continue;
-+ }
-+ // CraftBukkit end
+- while (iterator2.hasNext()) {
+- MobEffect mobeffect1 = (MobEffect) iterator2.next();
+- MobEffectList mobeffectlist = mobeffect1.getMobEffect();
+-
+- if (mobeffectlist.isInstant()) {
+- mobeffectlist.applyInstantEffect(this, this.getShooter(), entityliving, mobeffect1.getAmplifier(), d1);
+- } else {
+- int i = (int) (d1 * (double) mobeffect1.getDuration() + 0.5D);
+-
+- if (i > 20) {
+- entityliving.addEffect(new MobEffect(mobeffectlist, i, mobeffect1.getAmplifier()));
+- }
+- }
++ if (i > 20) {
++ entityliving.addEffect(new MobEffect(mobeffectlist, i, mobeffect1.getAmplifier()));
+ }
+ }
+ }
+@@ -138,10 +173,10 @@
+ }
+ }
+ }
+-
+- this.world.triggerEffect(2002, new BlockPosition(this), PotionRegistry.a(potionregistry));
+- this.die();
+ }
+
- if (MobEffectList.byId[i].isInstant()) {
- MobEffectList.byId[i].applyInstantEffect(this, this.getShooter(), entityliving, mobeffect.getAmplifier(), d1);
- } else {
++ this.world.triggerEffect(2002, new BlockPosition(this), PotionRegistry.a(potionregistry));
++ this.die();
+ }
+ }
+
diff --git a/nms-patches/EntityProjectile.patch b/nms-patches/EntityProjectile.patch
index 460ea558..f5c27ca2 100644
--- a/nms-patches/EntityProjectile.patch
+++ b/nms-patches/EntityProjectile.patch
@@ -1,15 +1,15 @@
--- a/net/minecraft/server/EntityProjectile.java
+++ b/net/minecraft/server/EntityProjectile.java
-@@ -26,6 +26,7 @@
+@@ -34,6 +34,7 @@
public EntityProjectile(World world, EntityLiving entityliving) {
- super(world);
+ this(world, entityliving.locX, entityliving.locY + (double) entityliving.getHeadHeight() - 0.10000000149011612D, entityliving.locZ);
this.shooter = entityliving;
+ this.projectileSource = (org.bukkit.entity.LivingEntity) entityliving.getBukkitEntity(); // CraftBukkit
- this.setSize(0.25F, 0.25F);
- this.setPositionRotation(entityliving.locX, entityliving.locY + (double) entityliving.getHeadHeight(), entityliving.locZ, entityliving.yaw, entityliving.pitch);
- this.locX -= (double) (MathHelper.cos(this.yaw / 180.0F * 3.1415927F) * 0.16F);
-@@ -151,6 +152,11 @@
- this.d(movingobjectposition.a());
+ }
+
+ protected void i() {}
+@@ -161,6 +162,11 @@
+ this.e(movingobjectposition.a());
} else {
this.a(movingobjectposition);
+ // CraftBukkit start
diff --git a/nms-patches/EntityRabbit.patch b/nms-patches/EntityRabbit.patch
index 37dd6265..e32bf767 100644
--- a/nms-patches/EntityRabbit.patch
+++ b/nms-patches/EntityRabbit.patch
@@ -1,25 +1,17 @@
--- a/net/minecraft/server/EntityRabbit.java
+++ b/net/minecraft/server/EntityRabbit.java
-@@ -21,6 +21,12 @@
+@@ -14,8 +14,14 @@
+ this.setSize(0.4F, 0.5F);
this.g = new EntityRabbit.ControllerJumpRabbit(this);
this.moveController = new EntityRabbit.ControllerMoveRabbit(this);
- ((Navigation) this.getNavigation()).a(true);
+ this.initializePathFinderGoals(); // CraftBukkit - moved code
-+ this.b(0.0D);
+ }
+
+ // CraftBukkit start - code from constructor
+ public void initializePathFinderGoals(){
- this.navigation.a(2.5F);
- this.goalSelector.a(1, new PathfinderGoalFloat(this));
- this.goalSelector.a(1, new EntityRabbit.PathfinderGoalRabbitPanic(this, 1.33D));
-@@ -33,8 +39,8 @@
- this.goalSelector.a(11, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 10.0F));
- this.bm = new EntityRabbit.PathfinderGoalRabbitAvoidTarget(this, EntityWolf.class, 16.0F, 1.33D, 1.33D);
- this.goalSelector.a(4, this.bm);
-- this.b(0.0D);
+ this.c(0.0D);
}
+ // CraftBukkit end
- protected float bE() {
- return this.moveController.a() && this.moveController.e() > this.locY + 0.5D ? 0.5F : this.bt.b();
+ protected void r() {
+ this.goalSelector.a(1, new PathfinderGoalFloat(this));
diff --git a/nms-patches/EntitySheep.patch b/nms-patches/EntitySheep.patch
index a64b2a45..7ff88ab3 100644
--- a/nms-patches/EntitySheep.patch
+++ b/nms-patches/EntitySheep.patch
@@ -1,6 +1,6 @@
--- a/net/minecraft/server/EntitySheep.java
+++ b/net/minecraft/server/EntitySheep.java
-@@ -4,12 +4,25 @@
+@@ -4,6 +4,12 @@
import java.util.Map;
import java.util.Random;
@@ -12,7 +12,8 @@
+
public class EntitySheep extends EntityAnimal {
- private final InventoryCrafting bm = new InventoryCrafting(new Container() {
+ private static final DataWatcherObject<Byte> bv = DataWatcher.a(EntitySheep.class, DataWatcherRegistry.a);
+@@ -11,6 +17,13 @@
public boolean a(EntityHuman entityhuman) {
return false;
}
@@ -24,18 +25,18 @@
+ }
+ // CraftBukkit end
}, 2, 1);
- private static final Map<EnumColor, float[]> bo = Maps.newEnumMap(EnumColor.class);
- private int bp;
-@@ -34,6 +47,7 @@
- this.goalSelector.a(8, new PathfinderGoalRandomLookaround(this));
- this.bm.setItem(0, new ItemStack(Items.DYE, 1, 0));
- this.bm.setItem(1, new ItemStack(Items.DYE, 1, 0));
-+ this.bm.resultInventory = new InventoryCraftResult(); // CraftBukkit - add result slot for event
+ private static final Map<EnumColor, float[]> bx = Maps.newEnumMap(EnumColor.class);
+ private int bz;
+@@ -25,6 +38,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 E() {
-@@ -86,6 +100,15 @@
-
+ protected void r() {
+@@ -123,6 +137,15 @@
+ public boolean a(EntityHuman entityhuman, EnumHand enumhand, ItemStack itemstack) {
if (itemstack != null && itemstack.getItem() == Items.SHEARS && !this.isSheared() && !this.isBaby()) {
if (!this.world.isClientSide) {
+ // CraftBukkit start
@@ -50,19 +51,16 @@
this.setSheared(true);
int i = 1 + this.random.nextInt(3);
-@@ -173,7 +196,14 @@
+@@ -210,6 +233,12 @@
}
- public void v() {
-- this.setSheared(false);
+ public void B() {
+ // CraftBukkit start
+ SheepRegrowWoolEvent event = new SheepRegrowWoolEvent((org.bukkit.entity.Sheep) this.getBukkitEntity());
+ this.world.getServer().getPluginManager().callEvent(event);
+
-+ if (!event.isCancelled()) {
-+ this.setSheared(false);
-+ }
++ if (event.isCancelled()) return;
+ // CraftBukkit end
+ this.setSheared(false);
if (this.isBaby()) {
this.setAge(60);
- }
diff --git a/nms-patches/EntityShulkerBullet.patch b/nms-patches/EntityShulkerBullet.patch
new file mode 100644
index 00000000..c8e96033
--- /dev/null
+++ b/nms-patches/EntityShulkerBullet.patch
@@ -0,0 +1,23 @@
+--- a/net/minecraft/server/EntityShulkerBullet.java
++++ b/net/minecraft/server/EntityShulkerBullet.java
+@@ -10,6 +10,12 @@
+
+ private EntityLiving shooter;
+ private Entity target;
++ // CraftBukkit start
++ public EntityLiving getShooter() { return this.shooter; }
++ public void setShooter(EntityLiving e) { this.shooter = e; }
++ public Entity getTarget() { return this.target; }
++ public void setTarget(Entity e) { this.target = e; }
++ // CraftBukkit end
+ private EnumDirection c;
+ private int d;
+ private double e;
+@@ -42,6 +48,7 @@
+ this.target = entity;
+ this.c = EnumDirection.UP;
+ this.a(enumdirection_enumaxis);
++ projectileSource = (org.bukkit.entity.LivingEntity) entityliving.getBukkitEntity(); // CraftBukkit
+ }
+
+ protected void b(NBTTagCompound nbttagcompound) {
diff --git a/nms-patches/EntitySilverfish.patch b/nms-patches/EntitySilverfish.patch
index 9ea99cd9..10e635b5 100644
--- a/nms-patches/EntitySilverfish.patch
+++ b/nms-patches/EntitySilverfish.patch
@@ -1,18 +1,18 @@
--- a/net/minecraft/server/EntitySilverfish.java
+++ b/net/minecraft/server/EntitySilverfish.java
-@@ -144,6 +144,11 @@
+@@ -149,6 +149,11 @@
IBlockData iblockdata = world.getType(blockposition);
- if (BlockMonsterEggs.d(iblockdata)) {
+ if (BlockMonsterEggs.i(iblockdata)) {
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.silverfish, blockposition.getX(), blockposition.getY(), blockposition.getZ(), Blocks.MONSTER_EGG, Block.getId(BlockMonsterEggs.getById(iblockdata.getBlock().toLegacyData(iblockdata)))).isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
world.setTypeAndData(blockposition, Blocks.MONSTER_EGG.getBlockData().set(BlockMonsterEggs.VARIANT, BlockMonsterEggs.EnumMonsterEggVarient.a(iblockdata)), 3);
- this.silverfish.y();
+ this.silverfish.doSpawnEffect();
this.silverfish.die();
-@@ -187,6 +192,11 @@
+@@ -192,6 +197,11 @@
IBlockData iblockdata = world.getType(blockposition1);
if (iblockdata.getBlock() == Blocks.MONSTER_EGG) {
diff --git a/nms-patches/EntitySkeleton.patch b/nms-patches/EntitySkeleton.patch
index 6da92eb0..b606c11c 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
-@@ -2,6 +2,8 @@
+@@ -2,12 +2,14 @@
import java.util.Calendar;
@@ -8,8 +8,15 @@
+
public class EntitySkeleton extends EntityMonster implements IRangedEntity {
- private PathfinderGoalArrowAttack a = new PathfinderGoalArrowAttack(this, 1.0D, 20, 60, 15.0F);
-@@ -89,7 +91,14 @@
+ private static final DataWatcherObject<Integer> a = DataWatcher.a(EntitySkeleton.class, DataWatcherRegistry.b);
+ private static final DataWatcherObject<Boolean> b = DataWatcher.a(EntitySkeleton.class, DataWatcherRegistry.h);
+ private final PathfinderGoalBowShoot c = new PathfinderGoalBowShoot(this, 1.0D, 20, 15.0F);
+- private final PathfinderGoalMeleeAttack bv = new PathfinderGoalMeleeAttack(this, 1.2D, flag) {
++ private final PathfinderGoalMeleeAttack bv = new PathfinderGoalMeleeAttack(this, 1.2D, false) { // CraftBukkit decompile error flag -> false
+ public void d() {
+ super.d();
+ EntitySkeleton.this.a(false);
+@@ -102,7 +104,14 @@
}
if (flag) {
@@ -25,7 +32,7 @@
}
}
}
-@@ -112,7 +121,7 @@
+@@ -125,7 +134,7 @@
}
public void die(DamageSource damagesource) {
@@ -34,63 +41,52 @@
if (damagesource.i() instanceof EntityArrow && damagesource.getEntity() instanceof EntityHuman) {
EntityHuman entityhuman = (EntityHuman) damagesource.getEntity();
double d0 = entityhuman.locX - this.locX;
-@@ -123,16 +132,25 @@
+@@ -136,9 +145,14 @@
}
- } else if (damagesource.getEntity() instanceof EntityCreeper && ((EntityCreeper) damagesource.getEntity()).isPowered() && ((EntityCreeper) damagesource.getEntity()).cp()) {
- ((EntityCreeper) damagesource.getEntity()).cq();
+ } else if (damagesource.getEntity() instanceof EntityCreeper && ((EntityCreeper) damagesource.getEntity()).isPowered() && ((EntityCreeper) damagesource.getEntity()).canCauseHeadDrop()) {
+ ((EntityCreeper) damagesource.getEntity()).setCausedHeadDrop();
- this.a(new ItemStack(Items.SKULL, 1, this.getSkeletonType() == 1 ? 1 : 0), 0.0F);
+ // CraftBukkit start
+ // this.a(new ItemStack(Items.SKULL, 1, this.getSkeletonType() == 1 ? 1 : 0), 0.0F);
+ headDrop = new ItemStack(Items.SKULL, 1, this.getSkeletonType() == 1 ? 1 : 0);
+ // CraftBukkit end
-+
}
+ super.die(damagesource); // CraftBukkit - moved from above
+
}
-+ /* CraftBukkit start
- protected Item getLoot() {
- return Items.ARROW;
- }
-+ // CraftBukkit end */
-
- protected void dropDeathLoot(boolean flag, int i) {
-+ super.dropDeathLoot(flag, i); // CraftBukkit
- int j;
- int k;
-
-@@ -224,11 +242,30 @@
+ protected MinecraftKey J() {
+@@ -212,11 +226,30 @@
}
- if (EnchantmentManager.getEnchantmentLevel(Enchantment.ARROW_FIRE.id, this.bA()) > 0 || this.getSkeletonType() == 1) {
-- entityarrow.setOnFire(100);
+ if (EnchantmentManager.a(Enchantments.ARROW_FIRE, (EntityLiving) this) > 0 || this.getSkeletonType() == 1) {
+- entitytippedarrow.setOnFire(100);
+ // CraftBukkit start - call EntityCombustEvent
-+ EntityCombustEvent event = new EntityCombustEvent(entityarrow.getBukkitEntity(), 100);
++ EntityCombustEvent event = new EntityCombustEvent(entitytippedarrow.getBukkitEntity(), 100);
+ this.world.getServer().getPluginManager().callEvent(event);
+
+ if (!event.isCancelled()) {
-+ entityarrow.setOnFire(event.getDuration());
++ entitytippedarrow.setOnFire(event.getDuration());
+ }
+ // CraftBukkit end
+ }
+
+ // CraftBukkit start
-+ org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(this, this.bA(), entityarrow, 0.8F);
++ org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(this, this.getItemInMainHand(), entitytippedarrow, 0.8F);
+ if (event.isCancelled()) {
+ event.getProjectile().remove();
+ return;
+ }
+
-+ if (event.getProjectile() == entityarrow.getBukkitEntity()) {
-+ world.addEntity(entityarrow);
++ if (event.getProjectile() == entitytippedarrow.getBukkitEntity()) {
++ world.addEntity(entitytippedarrow);
}
+ // CraftBukkit end
- this.makeSound("random.bow", 1.0F, 1.0F / (this.bc().nextFloat() * 0.4F + 0.8F));
-- this.world.addEntity(entityarrow);
-+ // this.world.addEntity(entityarrow); // CraftBukkit - moved up
+ this.a(SoundEffects.fn, 1.0F, 1.0F / (this.getRandom().nextFloat() * 0.4F + 0.8F));
+- this.world.addEntity(entitytippedarrow);
++ // this.world.addEntity(entitytippedarrow); // CraftBukkit - moved up
}
public int getSkeletonType() {
diff --git a/nms-patches/EntitySlime.patch b/nms-patches/EntitySlime.patch
index 2e3333d6..c5cb1648 100644
--- a/nms-patches/EntitySlime.patch
+++ b/nms-patches/EntitySlime.patch
@@ -9,8 +9,8 @@
+
public class EntitySlime extends EntityInsentient implements IMonster {
- public float a;
-@@ -133,6 +137,18 @@
+ private static final DataWatcherObject<Integer> bt = DataWatcher.a(EntitySlime.class, DataWatcherRegistry.b);
+@@ -134,6 +138,18 @@
if (!this.world.isClientSide && i > 1 && this.getHealth() <= 0.0F) {
int j = 2 + this.random.nextInt(3);
@@ -29,7 +29,7 @@
for (int k = 0; k < j; ++k) {
float f = ((float) (k % 2) - 0.5F) * (float) i / 4.0F;
float f1 = ((float) (k / 2) - 0.5F) * (float) i / 4.0F;
-@@ -148,7 +164,7 @@
+@@ -149,7 +165,7 @@
entityslime.setSize(i / 2);
entityslime.setPositionRotation(this.locX + (double) f, this.locY + 0.5D, this.locZ + (double) f1, this.random.nextFloat() * 360.0F, 0.0F);
diff --git a/nms-patches/EntitySmallFireball.patch b/nms-patches/EntitySmallFireball.patch
index be58eb11..8e472c32 100644
--- a/nms-patches/EntitySmallFireball.patch
+++ b/nms-patches/EntitySmallFireball.patch
@@ -9,9 +9,9 @@
public EntitySmallFireball(World world) {
@@ -26,7 +28,14 @@
- if (flag) {
- this.a(this.shooter, movingobjectposition.entity);
- if (!movingobjectposition.entity.isFireProof()) {
+ flag = movingobjectposition.entity.damageEntity(DamageSource.fireball(this, this.shooter), 5.0F);
+ if (flag) {
+ this.a(this.shooter, movingobjectposition.entity);
- movingobjectposition.entity.setOnFire(5);
+ // CraftBukkit start - Entity damage by entity event + combust event
+ EntityCombustByEntityEvent event = new EntityCombustByEntityEvent((org.bukkit.entity.Projectile) this.getBukkitEntity(), movingobjectposition.entity.getBukkitEntity(), 5);
diff --git a/nms-patches/EntitySnowman.patch b/nms-patches/EntitySnowman.patch
index fbde5d23..47a97c9f 100644
--- a/nms-patches/EntitySnowman.patch
+++ b/nms-patches/EntitySnowman.patch
@@ -11,8 +11,8 @@
+
public class EntitySnowman extends EntityGolem implements IRangedEntity {
- public EntitySnowman(World world) {
-@@ -31,7 +37,7 @@
+ private static final DataWatcherObject<Byte> a = DataWatcher.a(EntitySnowman.class, DataWatcherRegistry.a);
+@@ -40,7 +46,7 @@
}
if (this.world.getBiome(new BlockPosition(i, 0, k)).a(new BlockPosition(i, j, k)) > 1.0F) {
@@ -20,11 +20,11 @@
+ this.damageEntity(CraftEventFactory.MELTING, 1.0F); // CraftBukkit - DamageSource.BURN -> CraftEventFactory.MELTING
}
- for (int l = 0; l < 4; ++l) {
-@@ -41,7 +47,17 @@
+ if (!this.world.getGameRules().getBoolean("mobGriefing")) {
+@@ -54,7 +60,17 @@
BlockPosition blockposition = new BlockPosition(i, j, k);
- if (this.world.getType(blockposition).getBlock().getMaterial() == Material.AIR && this.world.getBiome(new BlockPosition(i, 0, k)).a(blockposition) < 0.8F && Blocks.SNOW_LAYER.canPlace(this.world, blockposition)) {
+ if (this.world.getType(blockposition).getMaterial() == Material.AIR && this.world.getBiome(new BlockPosition(i, 0, k)).a(blockposition) < 0.8F && Blocks.SNOW_LAYER.canPlace(this.world, blockposition)) {
- this.world.setTypeUpdate(blockposition, Blocks.SNOW_LAYER.getBlockData());
+ // CraftBukkit start
+ org.bukkit.block.BlockState blockState = this.world.getWorld().getBlockAt(i, j, k).getState();
diff --git a/nms-patches/EntitySpider.patch b/nms-patches/EntitySpider.patch
index d4e19fdb..8688249b 100644
--- a/nms-patches/EntitySpider.patch
+++ b/nms-patches/EntitySpider.patch
@@ -1,11 +1,11 @@
--- a/net/minecraft/server/EntitySpider.java
+++ b/net/minecraft/server/EntitySpider.java
-@@ -112,7 +112,7 @@
+@@ -108,7 +108,7 @@
entityskeleton.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, 0.0F);
entityskeleton.prepare(difficultydamagescaler, (GroupDataEntity) null);
- this.world.addEntity(entityskeleton);
+ this.world.addEntity(entityskeleton, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.JOCKEY); // CraftBukkit - add SpawnReason
- entityskeleton.mount(this);
+ entityskeleton.startRiding(this);
}
diff --git a/nms-patches/EntitySquid.patch b/nms-patches/EntitySquid.patch
deleted file mode 100644
index da170738..00000000
--- a/nms-patches/EntitySquid.patch
+++ /dev/null
@@ -1,14 +0,0 @@
---- a/net/minecraft/server/EntitySquid.java
-+++ b/net/minecraft/server/EntitySquid.java
-@@ -67,9 +67,11 @@
-
- }
-
-+ /* CraftBukkit start - Delegate to Entity to use existing inWater value
- public boolean V() {
- return this.world.a(this.getBoundingBox().grow(0.0D, -0.6000000238418579D, 0.0D), Material.WATER, (Entity) this);
- }
-+ // CraftBukkit end */
-
- public void m() {
- super.m();
diff --git a/nms-patches/EntityTNTPrimed.patch b/nms-patches/EntityTNTPrimed.patch
index f9a1bf21..54037dc2 100644
--- a/nms-patches/EntityTNTPrimed.patch
+++ b/nms-patches/EntityTNTPrimed.patch
@@ -1,23 +1,24 @@
--- a/net/minecraft/server/EntityTNTPrimed.java
+++ b/net/minecraft/server/EntityTNTPrimed.java
-@@ -1,9 +1,13 @@
+@@ -1,10 +1,14 @@
package net.minecraft.server;
+import org.bukkit.event.entity.ExplosionPrimeEvent; // CraftBukkit
+
public class EntityTNTPrimed extends Entity {
- public int fuseTicks;
+ private static final DataWatcherObject<Integer> FUSE_TICKS = DataWatcher.a(EntityTNTPrimed.class, DataWatcherRegistry.b);
private EntityLiving source;
+ private int c;
+ public float yield = 4; // CraftBukkit - add field
+ public boolean isIncendiary = false; // CraftBukkit - add field
public EntityTNTPrimed(World world) {
super(world);
-@@ -52,10 +56,13 @@
- }
+@@ -57,10 +61,13 @@
- if (this.fuseTicks-- <= 0) {
+ --this.c;
+ if (this.c <= 0) {
- this.die();
+ // CraftBukkit start - Need to reverse the order of the explosion and the entity death so we have a location for the event
+ // this.die();
@@ -27,19 +28,19 @@
+ this.die();
+ // CraftBukkit end
} else {
- this.W();
+ this.aj();
this.world.addParticle(EnumParticle.SMOKE_NORMAL, this.locX, this.locY + 0.5D, this.locZ, 0.0D, 0.0D, 0.0D, new int[0]);
-@@ -64,9 +71,18 @@
+@@ -69,9 +76,18 @@
}
private void explode() {
- float f = 4.0F;
+ // CraftBukkit start
+ // float f = 4.0F;
-+
-+ org.bukkit.craftbukkit.CraftServer server = this.world.getServer();
- this.world.explode(this, this.locX, this.locY + (double) (this.length / 16.0F), this.locZ, f, true);
++ org.bukkit.craftbukkit.CraftServer server = this.world.getServer();
++
+ ExplosionPrimeEvent event = new ExplosionPrimeEvent((org.bukkit.entity.Explosive) org.bukkit.craftbukkit.entity.CraftEntity.getEntity(server, this));
+ server.getPluginManager().callEvent(event);
+
diff --git a/nms-patches/EntityThrownExpBottle.patch b/nms-patches/EntityThrownExpBottle.patch
index 2e688492..42c72d79 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
-@@ -28,9 +28,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 d42e4a60..56d5f158 100644
--- a/nms-patches/EntityTracker.patch
+++ b/nms-patches/EntityTracker.patch
@@ -1,6 +1,6 @@
--- a/net/minecraft/server/EntityTracker.java
+++ b/net/minecraft/server/EntityTracker.java
-@@ -113,11 +113,12 @@
+@@ -117,11 +117,12 @@
CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Entity To Track");
crashreportsystemdetails.a("Tracking range", (Object) (i + " blocks"));
diff --git a/nms-patches/EntityTrackerEntry.patch b/nms-patches/EntityTrackerEntry.patch
index 0a6cc779..295003e6 100644
--- a/nms-patches/EntityTrackerEntry.patch
+++ b/nms-patches/EntityTrackerEntry.patch
@@ -1,6 +1,6 @@
--- a/net/minecraft/server/EntityTrackerEntry.java
+++ b/net/minecraft/server/EntityTrackerEntry.java
-@@ -8,6 +8,11 @@
+@@ -9,6 +9,11 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -11,45 +11,46 @@
+
public class EntityTrackerEntry {
- private static final Logger p = LogManager.getLogger();
-@@ -74,13 +79,13 @@
- this.broadcast(new PacketPlayOutAttachEntity(0, this.tracker, this.tracker.vehicle));
+ private static final Logger c = LogManager.getLogger();
+@@ -79,13 +84,14 @@
+ this.broadcast(new PacketPlayOutMount(this.tracker));
}
-- if (this.tracker instanceof EntityItemFrame && this.m % 10 == 0) {
-+ if (this.tracker instanceof EntityItemFrame /*&& this.m % 10 == 0*/) { // CraftBukkit - Moved below, should always enter this block
+- if (this.tracker instanceof EntityItemFrame && this.a % 10 == 0) {
++ // PAIL : rename
++ if (this.tracker instanceof EntityItemFrame /*&& this.a % 10 == 0*/) { // CraftBukkit - Moved below, should always enter this block
EntityItemFrame entityitemframe = (EntityItemFrame) this.tracker;
ItemStack itemstack = entityitemframe.getItem();
- if (itemstack != null && itemstack.getItem() instanceof ItemWorldMap) {
-+ if (this.m % 10 == 0 && itemstack != null && itemstack.getItem() instanceof ItemWorldMap) { // CraftBukkit - Moved this.m % 10 logic here so item frames do not enter the other blocks
++ if (this.a % 10 == 0 && itemstack != null && itemstack.getItem() instanceof ItemWorldMap) { // CraftBukkit - Moved this.m % 10 logic here so item frames do not enter the other blocks
WorldMap worldmap = Items.FILLED_MAP.getSavedMap(itemstack, this.tracker.world);
- Iterator iterator = list.iterator();
+ Iterator iterator = this.trackedPlayers.iterator(); // CraftBukkit
while (iterator.hasNext()) {
EntityHuman entityhuman = (EntityHuman) iterator.next();
-@@ -116,6 +121,19 @@
- boolean flag = Math.abs(j1) >= 4 || Math.abs(k1) >= 4 || Math.abs(l1) >= 4 || this.m % 60 == 0;
- boolean flag1 = Math.abs(l - this.yRot) >= 4 || Math.abs(i1 - this.xRot) >= 4;
+@@ -120,6 +126,19 @@
+ boolean flag = k1 * k1 + l1 * l1 + i2 * i2 >= 128L || this.a % 60 == 0;
+ boolean flag1 = Math.abs(i1 - this.yRot) >= 1 || Math.abs(j1 - this.xRot) >= 1;
+ // CraftBukkit start - Code moved from below
+ if (flag) {
-+ this.xLoc = i;
-+ this.yLoc = j;
-+ this.zLoc = k;
++ this.xLoc = j;
++ this.yLoc = k;
++ this.zLoc = l;
+ }
+
+ if (flag1) {
-+ this.yRot = l;
-+ this.xRot = i1;
++ this.yRot = i1;
++ this.xRot = j1;
+ }
+ // CraftBukkit end
+
- if (this.m > 0 || this.tracker instanceof EntityArrow) {
- if (j1 >= -128 && j1 < 128 && k1 >= -128 && k1 < 128 && l1 >= -128 && l1 < 128 && this.v <= 400 && !this.x && this.y == this.tracker.onGround) {
+ if (this.a > 0 || this.tracker instanceof EntityArrow) {
+ if (k1 >= -32768L && k1 < 32768L && l1 >= -32768L && l1 < 32768L && i2 >= -32768L && i2 < 32768L && this.v <= 400 && !this.x && this.y == this.tracker.onGround) {
if ((!flag || !flag1) && !(this.tracker instanceof EntityArrow)) {
-@@ -130,6 +148,11 @@
+@@ -134,6 +153,11 @@
} else {
this.y = this.tracker.onGround;
this.v = 0;
@@ -58,28 +59,28 @@
+ this.scanPlayers(new java.util.ArrayList(this.trackedPlayers));
+ }
+ // CraftBukkit end
- object = new PacketPlayOutEntityTeleport(this.tracker.getId(), i, j, k, (byte) l, (byte) i1, this.tracker.onGround);
+ this.c();
+ object = new PacketPlayOutEntityTeleport(this.tracker);
}
- }
-@@ -154,6 +177,7 @@
+@@ -165,6 +189,7 @@
}
- this.b();
+ this.d();
+ /* CraftBukkit start - Code moved up
if (flag) {
- this.xLoc = i;
- this.yLoc = j;
-@@ -164,6 +188,7 @@
- this.yRot = l;
- this.xRot = i1;
+ this.xLoc = j;
+ this.yLoc = k;
+@@ -175,6 +200,7 @@
+ this.yRot = i1;
+ this.xRot = j1;
}
+ // CraftBukkit end */
this.x = false;
} else {
-@@ -195,7 +220,27 @@
+@@ -206,7 +232,27 @@
- ++this.m;
+ ++this.a;
if (this.tracker.velocityChanged) {
- this.broadcastIncludingSelf(new PacketPlayOutEntityVelocity(this.tracker));
+ // CraftBukkit start - Create PlayerVelocity event
@@ -106,7 +107,7 @@
this.tracker.velocityChanged = false;
}
-@@ -213,6 +258,11 @@
+@@ -224,6 +270,11 @@
Set set = attributemapserver.getAttributes();
if (!set.isEmpty()) {
@@ -118,7 +119,7 @@
this.broadcastIncludingSelf(new PacketPlayOutUpdateAttributes(this.tracker.getId(), set));
}
-@@ -263,6 +313,16 @@
+@@ -276,6 +327,16 @@
if (entityplayer != this.tracker) {
if (this.c(entityplayer)) {
if (!this.trackedPlayers.contains(entityplayer) && (this.e(entityplayer) || this.tracker.attachedToPlayer)) {
@@ -133,9 +134,9 @@
+ entityplayer.removeQueue.remove(Integer.valueOf(this.tracker.getId()));
+ // CraftBukkit end
this.trackedPlayers.add(entityplayer);
- Packet packet = this.c();
+ Packet packet = this.e();
-@@ -281,6 +341,12 @@
+@@ -290,6 +351,12 @@
AttributeMapServer attributemapserver = (AttributeMapServer) ((EntityLiving) this.tracker).getAttributeMap();
Collection collection = attributemapserver.c();
@@ -148,38 +149,25 @@
if (!collection.isEmpty()) {
entityplayer.playerConnection.sendPacket(new PacketPlayOutUpdateAttributes(this.tracker.getId(), collection));
}
-@@ -319,6 +385,11 @@
+@@ -328,6 +395,11 @@
}
}
+ // CraftBukkit start - Fix for nonsensical head yaw
-+ this.i = MathHelper.d(this.tracker.getHeadRotation() * 256.0F / 360.0F);
-+ this.broadcast(new PacketPlayOutEntityHeadRotation(this.tracker, (byte) i));
++ this.headYaw = MathHelper.d(this.tracker.getHeadRotation() * 256.0F / 360.0F);
++ this.broadcast(new PacketPlayOutEntityHeadRotation(this.tracker, (byte) headYaw));
+ // CraftBukkit end
+
if (this.tracker instanceof EntityLiving) {
EntityLiving entityliving = (EntityLiving) this.tracker;
Iterator iterator = entityliving.getEffects().iterator();
-@@ -339,8 +410,10 @@
- }
-
- public boolean c(EntityPlayer entityplayer) {
-- double d0 = entityplayer.locX - (double) (this.xLoc / 32);
-- double d1 = entityplayer.locZ - (double) (this.zLoc / 32);
-+ // CraftBukkit start - this.*Loc / 30 -> this.tracker.loc*
-+ double d0 = entityplayer.locX - this.tracker.locX;
-+ double d1 = entityplayer.locZ - this.tracker.locZ;
-+ // CraftBukkit end
-
- return d0 >= (double) (-this.b) && d0 <= (double) this.b && d1 >= (double) (-this.b) && d1 <= (double) this.b && this.tracker.a(entityplayer);
- }
-@@ -358,7 +431,10 @@
-
- private Packet c() {
+@@ -372,7 +444,10 @@
+
+ private Packet<?> e() {
if (this.tracker.dead) {
-- EntityTrackerEntry.p.warn("Fetching addPacket for removed entity");
+- EntityTrackerEntry.c.warn("Fetching addPacket for removed entity");
+ // CraftBukkit start - Remove useless error spam, just return
-+ // EntityTrackerEntry.p.warn("Fetching addPacket for removed entity");
++ // EntityTrackerEntry.d.warn("Fetching addPacket for removed entity");
+ return null;
+ // CraftBukkit end
}
diff --git a/nms-patches/EntityVillager.patch b/nms-patches/EntityVillager.patch
index 93c14397..8b66079e 100644
--- a/nms-patches/EntityVillager.patch
+++ b/nms-patches/EntityVillager.patch
@@ -1,19 +1,62 @@
--- a/net/minecraft/server/EntityVillager.java
+++ b/net/minecraft/server/EntityVillager.java
-@@ -2,6 +2,7 @@
+@@ -2,6 +2,12 @@
import java.util.Iterator;
import java.util.Random;
++import org.bukkit.Bukkit;
+import org.bukkit.craftbukkit.entity.CraftVillager; // CraftBukkit
++import org.bukkit.craftbukkit.inventory.CraftMerchantRecipe;
++import org.bukkit.entity.Villager;
++import org.bukkit.event.entity.VillagerAcquireTradeEvent;
++import org.bukkit.event.entity.VillagerReplenishTradeEvent;
public class EntityVillager extends EntityAgeable implements IMerchant, NPC {
-@@ -29,7 +30,7 @@
+@@ -30,7 +36,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
this.setProfession(i);
- this.setSize(0.6F, 1.8F);
- ((Navigation) this.getNavigation()).b(true);
+ this.setSize(0.6F, 1.95F);
+ ((Navigation) this.getNavigation()).a(true);
+@@ -109,7 +115,14 @@
+ MerchantRecipe merchantrecipe = (MerchantRecipe) iterator.next();
+
+ if (merchantrecipe.h()) {
+- merchantrecipe.a(this.random.nextInt(6) + this.random.nextInt(6) + 2);
++ // CraftBukkit start
++ int bonus = this.random.nextInt(6) + this.random.nextInt(6) + 2;
++ VillagerReplenishTradeEvent event = new VillagerReplenishTradeEvent((Villager) this.getBukkitEntity(), merchantrecipe.asBukkit(), bonus);
++ Bukkit.getPluginManager().callEvent(event);
++ if (!event.isCancelled()) {
++ merchantrecipe.a(event.getBonus());
++ }
++ // CraftBukkit end
+ }
+ }
+
+@@ -401,7 +414,20 @@
+ for (int l = 0; l < k; ++l) {
+ EntityVillager.IMerchantRecipeOption entityvillager_imerchantrecipeoption = aentityvillager_imerchantrecipeoption3[l];
+
+- entityvillager_imerchantrecipeoption.a(this.trades, this.random);
++ // CraftBukkit start
++ // this is a hack. this must be done because otherwise, if
++ // mojang adds a new type of villager merchant option, it will need to
++ // have event handling added manually. this is better than having to do that.
++ MerchantRecipeList list = new MerchantRecipeList();
++ entityvillager_imerchantrecipeoption.a(list, this.random);
++ for (MerchantRecipe recipe : list) {
++ VillagerAcquireTradeEvent event = new VillagerAcquireTradeEvent((Villager) getBukkitEntity(), recipe.asBukkit());
++ Bukkit.getPluginManager().callEvent(event);
++ if (!event.isCancelled()) {
++ this.trades.add(CraftMerchantRecipe.fromBukkit(event.getRecipe()).toMinecraft());
++ }
++ }
++ // CraftBukkit end
+ }
+ }
+
diff --git a/nms-patches/EntityWither.patch b/nms-patches/EntityWither.patch
index ec2eb5d0..1b925cd8 100644
--- a/nms-patches/EntityWither.patch
+++ b/nms-patches/EntityWither.patch
@@ -12,13 +12,13 @@
+
public class EntityWither extends EntityMonster implements IRangedEntity {
- private float[] a = new float[2];
-@@ -168,13 +174,38 @@
- if (this.cl() > 0) {
- i = this.cl() - 1;
+ private static final DataWatcherObject<Integer> a = DataWatcher.a(EntityWither.class, DataWatcherRegistry.b);
+@@ -179,13 +185,38 @@
+ if (this.cZ() > 0) {
+ i = this.cZ() - 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(1013, new BlockPosition(this), 0);
+- this.world.a(1023, new BlockPosition(this), 0);
+ // CraftBukkit start
+ // this.world.createExplosion(this, this.locX, this.locY + (double) this.getHeadHeight(), this.locZ, 7.0F, false, this.world.getGameRules().getBoolean("mobGriefing"));
+ ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), 7.0F, false);
@@ -30,7 +30,7 @@
+ // CraftBukkit end
+
+ // CraftBukkit start - Use relative location for far away sounds
-+ // this.world.a(1013, new BlockPosition(this), 0);
++ // this.world.a(1023, new BlockPosition(this), 0);
+ int viewDistance = ((WorldServer) this.world).getServer().getViewDistance() * 16;
+ for (EntityPlayer player : (List<EntityPlayer>) MinecraftServer.getServer().getPlayerList().players) {
+ double deltaX = this.locX - player.locX;
@@ -48,17 +48,17 @@
+ // CraftBukkit end
}
- this.r(i);
+ this.l(i);
if (this.ticksLived % 10 == 0) {
- this.heal(10.0F);
+ this.heal(10.0F, EntityRegainHealthEvent.RegainReason.WITHER_SPAWN); // CraftBukkit
}
} else {
-@@ -264,6 +295,11 @@
- Block block = this.world.getType(blockposition).getBlock();
+@@ -276,6 +307,11 @@
+ Block block = iblockdata.getBlock();
- if (block.getMaterial() != Material.AIR && a(block)) {
+ if (iblockdata.getMaterial() != Material.AIR && a(block)) {
+ // CraftBukkit start
+ if (CraftEventFactory.callEntityChangeBlockEvent(this, j2, k2, l2, Blocks.AIR, 0).isCancelled()) {
+ continue;
@@ -67,7 +67,7 @@
flag = this.world.setAir(blockposition, true) || flag;
}
}
-@@ -277,7 +313,7 @@
+@@ -289,7 +325,7 @@
}
if (this.ticksLived % 20 == 0) {
@@ -75,4 +75,4 @@
+ this.heal(1.0F, EntityRegainHealthEvent.RegainReason.REGEN); // CraftBukkit
}
- }
+ this.bE.setProgress(this.getHealth() / this.getMaxHealth());
diff --git a/nms-patches/EntityWitherSkull.patch b/nms-patches/EntityWitherSkull.patch
index 119a1b9a..f51429c1 100644
--- a/nms-patches/EntityWitherSkull.patch
+++ b/nms-patches/EntityWitherSkull.patch
@@ -7,8 +7,8 @@
+
public class EntityWitherSkull extends EntityFireball {
- public EntityWitherSkull(World world) {
-@@ -35,9 +37,9 @@
+ private static final DataWatcherObject<Boolean> e = DataWatcher.a(EntityWitherSkull.class, DataWatcherRegistry.h);
+@@ -37,9 +39,9 @@
if (!this.world.isClientSide) {
if (movingobjectposition.entity != null) {
if (this.shooter != null) {
@@ -20,7 +20,7 @@
} else {
this.a(this.shooter, movingobjectposition.entity);
}
-@@ -61,7 +63,15 @@
+@@ -63,7 +65,15 @@
}
}
diff --git a/nms-patches/EntityWolf.patch b/nms-patches/EntityWolf.patch
index d240d767..47efd69c 100644
--- a/nms-patches/EntityWolf.patch
+++ b/nms-patches/EntityWolf.patch
@@ -1,8 +1,8 @@
--- a/net/minecraft/server/EntityWolf.java
+++ b/net/minecraft/server/EntityWolf.java
-@@ -2,6 +2,11 @@
-
+@@ -3,6 +3,11 @@
import com.google.common.base.Predicate;
+ import java.util.UUID;
+// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
@@ -11,9 +11,9 @@
+
public class EntityWolf extends EntityTameableAnimal {
- private float bo;
-@@ -64,6 +69,18 @@
-
+ private static final DataWatcherObject<Float> DATA_HEALTH = DataWatcher.a(EntityWolf.class, DataWatcherRegistry.c);
+@@ -59,6 +64,18 @@
+ this.getAttributeMap().b(GenericAttributes.ATTACK_DAMAGE).setValue(2.0D);
}
+ // CraftBukkit - add overriden version
@@ -28,48 +28,41 @@
+ }
+ // CraftBukkit end
+
- protected void E() {
- this.datawatcher.watch(18, Float.valueOf(this.getHealth()));
- }
-@@ -95,7 +112,8 @@
- }
-
- protected String z() {
-- return this.isAngry() ? "mob.wolf.growl" : (this.random.nextInt(3) == 0 ? (this.isTamed() && this.datawatcher.getFloat(18) < 10.0F ? "mob.wolf.whine" : "mob.wolf.panting") : "mob.wolf.bark");
-+ // CraftBukkit - (getFloat(18) < 10) -> (getFloat(18) < this.getMaxHealth() / 2)
-+ return this.isAngry() ? "mob.wolf.growl" : (this.random.nextInt(3) == 0 ? (this.isTamed() && this.datawatcher.getFloat(18) < this.getMaxHealth() / 2 ? "mob.wolf.whine" : "mob.wolf.panting") : "mob.wolf.bark");
- }
-
- protected String bo() {
-@@ -186,7 +204,8 @@
- } else {
+ public void setGoalTarget(EntityLiving entityliving) {
+ super.setGoalTarget(entityliving);
+ if (entityliving == null) {
+@@ -192,9 +209,10 @@
Entity entity = damagesource.getEntity();
-- this.bm.setSitting(false);
-+ // CraftBukkit - moved into EntityLiving.d(DamageSource, float)
-+ // this.bm.setSitting(false);
+ if (this.goalSit != null) {
+- this.goalSit.setSitting(false);
++ // CraftBukkit - moved into EntityLiving.d(DamageSource, float)
++ // PAIL : checkme
++ // this.goalSit.setSitting(false);
+ }
+-
if (entity != null && !(entity instanceof EntityHuman) && !(entity instanceof EntityArrow)) {
f = (f + 1.0F) / 2.0F;
}
-@@ -229,7 +248,7 @@
+@@ -235,7 +253,7 @@
--itemstack.count;
}
- this.heal((float) itemfood.getNutrition(itemstack));
+ this.heal((float) itemfood.getNutrition(itemstack), org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.EATING); // CraftBukkit
- if (itemstack.count <= 0) {
- entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, (ItemStack) null);
- }
-@@ -254,7 +273,7 @@
- this.bm.setSitting(!this.isSitting());
- this.aY = false;
- this.navigation.n();
+ return true;
+ }
+ } else if (itemstack.getItem() == Items.DYE) {
+@@ -256,7 +274,7 @@
+ this.goalSit.setSitting(!this.isSitting());
+ this.bc = false;
+ this.navigation.o();
- this.setGoalTarget((EntityLiving) null);
+ this.setGoalTarget((EntityLiving) null, TargetReason.FORGOT_TARGET, true); // CraftBukkit - reason
}
} else if (itemstack != null && itemstack.getItem() == Items.BONE && !this.isAngry()) {
if (!entityhuman.abilities.canInstantlyBuild) {
-@@ -266,12 +285,13 @@
+@@ -264,12 +282,14 @@
}
if (!this.world.isClientSide) {
@@ -77,16 +70,15 @@
+ // CraftBukkit - added event call and isCancelled check.
+ if (this.random.nextInt(3) == 0 && !CraftEventFactory.callEntityTameEvent(this, entityhuman).isCancelled()) {
this.setTamed(true);
- this.navigation.n();
-- this.setGoalTarget((EntityLiving) null);
-+ this.setGoalTarget((EntityLiving) null, TargetReason.FORGOT_TARGET, true);
- this.bm.setSitting(true);
-- this.setHealth(20.0F);
+ this.navigation.o();
+ this.setGoalTarget((EntityLiving) null);
+ this.goalSit.setSitting(true);
+ this.setHealth(20.0F);
+ this.setHealth(this.getMaxHealth()); // CraftBukkit - 20.0 -> getMaxHealth()
- this.setOwnerUUID(entityhuman.getUniqueID().toString());
- this.l(true);
+ this.setOwnerUUID(entityhuman.getUniqueID());
+ this.o(true);
this.world.broadcastEntityEffect(this, (byte) 7);
-@@ -358,7 +378,7 @@
+@@ -351,7 +371,7 @@
}
protected boolean isTypeNotPersistent() {
diff --git a/nms-patches/EntityZombie.patch b/nms-patches/EntityZombie.patch
index 81e42311..d672aaca 100644
--- a/nms-patches/EntityZombie.patch
+++ b/nms-patches/EntityZombie.patch
@@ -1,11 +1,10 @@
--- a/net/minecraft/server/EntityZombie.java
+++ b/net/minecraft/server/EntityZombie.java
-@@ -4,6 +4,14 @@
+@@ -4,6 +4,13 @@
import java.util.List;
import java.util.UUID;
+//CraftBukkit start
-+import org.bukkit.craftbukkit.entity.CraftLivingEntity;
+import org.bukkit.event.entity.CreatureSpawnEvent;
+import org.bukkit.event.entity.EntityCombustByEntityEvent;
+import org.bukkit.event.entity.EntityCombustEvent;
@@ -15,15 +14,15 @@
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");
-@@ -14,6 +22,7 @@
- private boolean bo = false;
- private float bp = -1.0F;
- private float bq;
+@@ -18,6 +25,7 @@
+ private boolean bB = false;
+ private float bC = -1.0F;
+ private float bD;
+ private int lastTick = MinecraftServer.currentTick; // CraftBukkit - add field
public EntityZombie(World world) {
super(world);
-@@ -135,7 +144,14 @@
+@@ -152,7 +160,14 @@
}
if (flag) {
@@ -39,34 +38,33 @@
}
}
}
-@@ -169,8 +185,8 @@
- if (World.a((IBlockAccess) this.world, new BlockPosition(i1, j1 - 1, k1)) && this.world.getLightLevel(new BlockPosition(i1, j1, k1)) < 10) {
+@@ -182,8 +197,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())) {
- 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.E(new BlockPosition(entityzombie)), (GroupDataEntity) null);
+ 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));
-@@ -190,6 +206,12 @@
- if (!this.world.isClientSide && this.cp()) {
- int i = this.cr();
-
+@@ -202,6 +217,11 @@
+ public void m() {
+ if (!this.world.isClientSide && this.isConverting()) {
+ int i = this.getConversionTime();
+ // CraftBukkit start - Use wall time instead of ticks for villager conversion
+ int elapsedTicks = MinecraftServer.currentTick - this.lastTick;
+ this.lastTick = MinecraftServer.currentTick;
+ i *= elapsedTicks;
+ // CraftBukkit end
-+
- this.bn -= i;
- if (this.bn <= 0) {
- this.cq();
-@@ -206,7 +228,14 @@
+
+ this.bA -= i;
+ if (this.bA <= 0) {
+@@ -219,7 +239,14 @@
int i = this.world.getDifficulty().a();
- if (this.bA() == null && this.isBurning() && this.random.nextFloat() < (float) i * 0.3F) {
+ if (this.getItemInMainHand() == null && this.isBurning() && this.random.nextFloat() < (float) i * 0.3F) {
- entity.setOnFire(2 * i);
+ // CraftBukkit start
+ EntityCombustByEntityEvent event = new EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), 2 * i);
@@ -79,50 +77,41 @@
}
}
-@@ -322,7 +351,7 @@
- entityzombie.setCustomNameVisible(entityinsentient.getCustomNameVisible());
+@@ -321,7 +348,7 @@
+ entityzombie.setCustomNameVisible(entityvillager.getCustomNameVisible());
}
- this.world.addEntity(entityzombie);
+ this.world.addEntity(entityzombie, CreatureSpawnEvent.SpawnReason.INFECTION); // CraftBukkit - add SpawnReason
- this.world.a((EntityHuman) null, 1016, new BlockPosition((int) this.locX, (int) this.locY, (int) this.locZ), 0);
+ this.world.a((EntityHuman) null, 1026, new BlockPosition((int) this.locX, (int) this.locY, (int) this.locZ), 0);
}
-@@ -375,7 +404,7 @@
+@@ -374,7 +401,7 @@
entitychicken1.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, 0.0F);
entitychicken1.prepare(difficultydamagescaler, (GroupDataEntity) null);
- entitychicken1.l(true);
+ entitychicken1.o(true);
- this.world.addEntity(entitychicken1);
-+ this.world.addEntity(entitychicken1, CreatureSpawnEvent.SpawnReason.MOUNT);
- this.mount(entitychicken1);
++ this.world.addEntity(entitychicken1, CreatureSpawnEvent.SpawnReason.MOUNT); // CraftBukkit
+ this.startRiding(entitychicken1);
}
}
-@@ -464,7 +493,7 @@
+@@ -458,7 +485,7 @@
entityvillager.setCustomNameVisible(this.getCustomNameVisible());
}
- this.world.addEntity(entityvillager);
+ this.world.addEntity(entityvillager, CreatureSpawnEvent.SpawnReason.CURED); // CraftBukkit - add SpawnReason
- entityvillager.addEffect(new MobEffect(MobEffectList.CONFUSION.id, 200, 0));
- this.world.a((EntityHuman) null, 1017, new BlockPosition((int) this.locX, (int) this.locY, (int) this.locZ), 0);
+ entityvillager.addEffect(new MobEffect(MobEffects.CONFUSION, 200, 0));
+ this.world.a((EntityHuman) null, 1027, new BlockPosition((int) this.locX, (int) this.locY, (int) this.locZ), 0);
}
-@@ -500,7 +529,7 @@
- this.a(flag ? 0.5F : 1.0F);
- }
-
-- protected final void setSize(float f, float f1) {
-+ public final void setSize(float f, float f1) { // CraftBukkit - public
- boolean flag = this.bp > 0.0F && this.bq > 0.0F;
-
- this.bp = f;
-@@ -520,12 +549,16 @@
+@@ -514,12 +541,16 @@
}
public void die(DamageSource damagesource) {
- super.die(damagesource);
+ // super.die(damagesource); // CraftBukkit
- if (damagesource.getEntity() instanceof EntityCreeper && !(this instanceof EntityPigZombie) && ((EntityCreeper) damagesource.getEntity()).isPowered() && ((EntityCreeper) damagesource.getEntity()).cp()) {
- ((EntityCreeper) damagesource.getEntity()).cq();
+ if (damagesource.getEntity() instanceof EntityCreeper && !(this instanceof EntityPigZombie) && ((EntityCreeper) damagesource.getEntity()).isPowered() && ((EntityCreeper) damagesource.getEntity()).canCauseHeadDrop()) {
+ ((EntityCreeper) damagesource.getEntity()).setCausedHeadDrop();
- this.a(new ItemStack(Items.SKULL, 1, 2), 0.0F);
+ // CraftBukkit start
+ // this.a(new ItemStack(Items.SKULL, 1, 2), 0.0F);
diff --git a/nms-patches/Explosion.patch b/nms-patches/Explosion.patch
index 5ee04c65..85de23f8 100644
--- a/nms-patches/Explosion.patch
+++ b/nms-patches/Explosion.patch
@@ -49,24 +49,25 @@
hashset.add(blockposition);
}
-@@ -112,7 +125,15 @@
+@@ -112,7 +125,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 * 8.0D * (double) f3 + 1.0D)));
-+ // entity.damageEntity(DamageSource.explosion(this), (float) ((int) ((d13 * d13 + d13) / 2.0D * 8.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)));
++ // CraftBukkit start
++ // entity.damageEntity(DamageSource.explosion(this), (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 * 8.0D * (double) f3 + 1.0D)));
++ boolean wasDamaged = entity.damageEntity(DamageSource.explosion(this), (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;
+ }
+ // CraftBukkit end
- double d14 = EnchantmentProtection.a(entity, d13);
+ double d14 = 1.0D;
- entity.motX += d8 * d14;
-@@ -140,6 +161,50 @@
+ if (entity instanceof EntityLiving) {
+@@ -148,6 +170,50 @@
BlockPosition blockposition;
if (this.b) {
@@ -117,9 +118,9 @@
iterator = this.blocks.iterator();
while (iterator.hasNext()) {
-@@ -170,7 +235,8 @@
+@@ -179,7 +245,8 @@
- if (block.getMaterial() != Material.AIR) {
+ if (iblockdata.getMaterial() != Material.AIR) {
if (block.a(this)) {
- block.dropNaturally(this.world, blockposition, this.world.getType(blockposition), 1.0F / this.size, 0);
+ // CraftBukkit - add yield
@@ -127,10 +128,10 @@
}
this.world.setTypeAndData(blockposition, Blocks.AIR.getBlockData(), 3);
-@@ -185,7 +251,11 @@
+@@ -194,7 +261,11 @@
while (iterator.hasNext()) {
blockposition = (BlockPosition) iterator.next();
- if (this.world.getType(blockposition).getBlock().getMaterial() == Material.AIR && this.world.getType(blockposition.down()).getBlock().o() && this.c.nextInt(3) == 0) {
+ if (this.world.getType(blockposition).getMaterial() == Material.AIR && this.world.getType(blockposition.down()).b() && 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()) {
@@ -140,7 +141,7 @@
}
}
}
-@@ -197,7 +267,9 @@
+@@ -206,7 +277,9 @@
}
public EntityLiving getSource() {
diff --git a/nms-patches/FoodMetaData.patch b/nms-patches/FoodMetaData.patch
index aaeab266..657ac7fa 100644
--- a/nms-patches/FoodMetaData.patch
+++ b/nms-patches/FoodMetaData.patch
@@ -38,7 +38,7 @@
}
public void a(EntityHuman entityhuman) {
-@@ -28,14 +46,23 @@
+@@ -28,7 +46,15 @@
if (this.saturationLevel > 0.0F) {
this.saturationLevel = Math.max(this.saturationLevel - 1.0F, 0.0F);
} else if (enumdifficulty != EnumDifficulty.PEACEFUL) {
@@ -55,12 +55,13 @@
}
}
- if (entityhuman.world.getGameRules().getBoolean("naturalRegeneration") && this.foodLevel >= 18 && entityhuman.cm()) {
+@@ -46,7 +72,8 @@
+ } else if (flag && this.foodLevel >= 18 && entityhuman.cT()) {
++this.foodTickTimer;
if (this.foodTickTimer >= 80) {
- entityhuman.heal(1.0F);
+ // CraftBukkit - added RegainReason
+ entityhuman.heal(1.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.SATIATED);
- this.a(3.0F);
+ this.a(4.0F);
this.foodTickTimer = 0;
}
diff --git a/nms-patches/HandshakeListener.patch b/nms-patches/HandshakeListener.patch
index a30ece5b..f3340f59 100644
--- a/nms-patches/HandshakeListener.patch
+++ b/nms-patches/HandshakeListener.patch
@@ -19,7 +19,7 @@
private final NetworkManager b;
@@ -16,6 +26,41 @@
- this.b.a(EnumProtocol.LOGIN);
+ this.b.setProtocol(EnumProtocol.LOGIN);
ChatComponentText chatcomponenttext;
+ // CraftBukkit start - Connection throttle
@@ -32,7 +32,7 @@
+ if (throttleTracker.containsKey(address) && !"127.0.0.1".equals(address.getHostAddress()) && currentTime - throttleTracker.get(address) < connectionThrottle) {
+ throttleTracker.put(address, currentTime);
+ chatcomponenttext = new ChatComponentText("Connection throttled! Please wait before reconnecting.");
-+ this.b.handle(new PacketLoginOutDisconnect(chatcomponenttext));
++ this.b.sendPacket(new PacketLoginOutDisconnect(chatcomponenttext));
+ this.b.close(chatcomponenttext);
+ return;
+ }
@@ -57,14 +57,14 @@
+ }
+ // CraftBukkit end
+
- if (packethandshakinginsetprotocol.b() > 47) {
- chatcomponenttext = new ChatComponentText("Outdated server! I\'m still on 1.8.8");
- this.b.handle(new PacketLoginOutDisconnect(chatcomponenttext));
+ if (packethandshakinginsetprotocol.b() > 107) {
+ chatcomponenttext = new ChatComponentText("Outdated server! I\'m still on 1.9");
+ this.b.sendPacket(new PacketLoginOutDisconnect(chatcomponenttext));
@@ -26,6 +71,7 @@
this.b.close(chatcomponenttext);
} else {
- this.b.a((PacketListener) (new LoginListener(this.a, this.b)));
-+ ((LoginListener) this.b.getPacketListener()).hostname = packethandshakinginsetprotocol.hostname + ":" + packethandshakinginsetprotocol.port; // CraftBukkit - set hostname
+ this.b.setPacketListener(new LoginListener(this.a, this.b));
++ ((LoginListener) this.b.i()).hostname = packethandshakinginsetprotocol.hostname + ":" + packethandshakinginsetprotocol.port; // CraftBukkit - set hostname
}
break;
diff --git a/nms-patches/IDataManager.patch b/nms-patches/IDataManager.patch
index fb0b95c9..cdb07653 100644
--- a/nms-patches/IDataManager.patch
+++ b/nms-patches/IDataManager.patch
@@ -3,7 +3,7 @@
@@ -23,4 +23,6 @@
File getDataFile(String s);
- String g();
+ DefinedStructureManager h();
+
+ java.util.UUID getUUID(); // CraftBukkit
}
diff --git a/nms-patches/IInventory.patch b/nms-patches/IInventory.patch
index 9b2c12b2..548011fa 100644
--- a/nms-patches/IInventory.patch
+++ b/nms-patches/IInventory.patch
@@ -8,7 +8,7 @@
public interface IInventory extends INamableTileEntity {
int getSize();
-@@ -31,4 +33,20 @@
+@@ -31,4 +33,22 @@
int g();
void l();
@@ -26,6 +26,8 @@
+
+ void setMaxStackSize(int size);
+
++ org.bukkit.Location getLocation();
++
+ int MAX_STACK = 64;
+ // CraftBukkit end
}
diff --git a/nms-patches/InventoryCraftResult.patch b/nms-patches/InventoryCraftResult.patch
index de8cd9a6..18926273 100644
--- a/nms-patches/InventoryCraftResult.patch
+++ b/nms-patches/InventoryCraftResult.patch
@@ -1,9 +1,10 @@
--- a/net/minecraft/server/InventoryCraftResult.java
+++ b/net/minecraft/server/InventoryCraftResult.java
-@@ -1,9 +1,37 @@
+@@ -1,9 +1,43 @@
package net.minecraft.server;
+// CraftBukkit start
++import org.bukkit.Location;
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
+import org.bukkit.entity.HumanEntity;
+// CraftBukkit end
@@ -33,12 +34,17 @@
+ public void setMaxStackSize(int size) {
+ maxStack = size;
+ }
++
++ @Override
++ public Location getLocation() {
++ return null;
++ }
+ // CraftBukkit end
+
public InventoryCraftResult() {}
public int getSize() {
-@@ -53,7 +81,7 @@
+@@ -39,7 +73,7 @@
}
public int getMaxStackSize() {
diff --git a/nms-patches/InventoryCrafting.patch b/nms-patches/InventoryCrafting.patch
index 59e32a22..c51c6dde 100644
--- a/nms-patches/InventoryCrafting.patch
+++ b/nms-patches/InventoryCrafting.patch
@@ -1,10 +1,11 @@
--- a/net/minecraft/server/InventoryCrafting.java
+++ b/net/minecraft/server/InventoryCrafting.java
-@@ -1,5 +1,13 @@
+@@ -1,5 +1,14 @@
package net.minecraft.server;
+// CraftBukkit start
+import java.util.List;
++import org.bukkit.Location;
+
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
+import org.bukkit.entity.HumanEntity;
@@ -14,7 +15,7 @@
public class InventoryCrafting implements IInventory {
private final ItemStack[] items;
-@@ -7,6 +15,48 @@
+@@ -7,6 +16,53 @@
private final int c;
private final Container d;
@@ -54,6 +55,11 @@
+ resultInventory.setMaxStackSize(size);
+ }
+
++ @Override
++ public Location getLocation() {
++ return owner.getBukkitEntity().getLocation();
++ }
++
+ public InventoryCrafting(Container container, int i, int j, EntityHuman player) {
+ this(container, i, j);
+ this.owner = player;
diff --git a/nms-patches/InventoryLargeChest.patch b/nms-patches/InventoryLargeChest.patch
index a23b0cf5..2332ec3b 100644
--- a/nms-patches/InventoryLargeChest.patch
+++ b/nms-patches/InventoryLargeChest.patch
@@ -1,10 +1,11 @@
--- a/net/minecraft/server/InventoryLargeChest.java
+++ b/net/minecraft/server/InventoryLargeChest.java
-@@ -1,11 +1,55 @@
+@@ -1,11 +1,61 @@
package net.minecraft.server;
+// CraftBukkit start
+import java.util.List;
++import org.bukkit.Location;
+
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
+import org.bukkit.entity.HumanEntity;
@@ -51,12 +52,17 @@
+ this.left.setMaxStackSize(size);
+ this.right.setMaxStackSize(size);
+ }
++
++ @Override
++ public Location getLocation() {
++ return left.getLocation(); // TODO: right?
++ }
+ // CraftBukkit end
+
public InventoryLargeChest(String s, ITileInventory itileinventory, ITileInventory itileinventory1) {
this.a = s;
if (itileinventory == null) {
-@@ -68,7 +112,7 @@
+@@ -68,7 +118,7 @@
}
public int getMaxStackSize() {
diff --git a/nms-patches/InventoryMerchant.patch b/nms-patches/InventoryMerchant.patch
index 83227eb9..26027d36 100644
--- a/nms-patches/InventoryMerchant.patch
+++ b/nms-patches/InventoryMerchant.patch
@@ -1,10 +1,11 @@
--- a/net/minecraft/server/InventoryMerchant.java
+++ b/net/minecraft/server/InventoryMerchant.java
-@@ -1,5 +1,12 @@
+@@ -1,12 +1,54 @@
package net.minecraft.server;
+// CraftBukkit start
+import java.util.List;
++import org.bukkit.Location;
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
+import org.bukkit.craftbukkit.entity.CraftVillager;
+import org.bukkit.entity.HumanEntity;
@@ -13,10 +14,12 @@
public class InventoryMerchant implements IInventory {
private final IMerchant merchant;
-@@ -8,6 +15,35 @@
+ private ItemStack[] itemsInSlots = new ItemStack[3];
+ private final EntityHuman player;
private MerchantRecipe recipe;
- private int e;
-
+- private int e;
++ public int e; // PAIL: private -> public, selectedIndex
++
+ // CraftBukkit start - add fields and methods
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
+ private int maxStack = MAX_STACK;
@@ -44,12 +47,16 @@
+ public org.bukkit.inventory.InventoryHolder getOwner() {
+ return (CraftVillager) ((EntityVillager) this.merchant).getBukkitEntity();
+ }
-+ // CraftBukkit end
+
++ @Override
++ public Location getLocation() {
++ return ((EntityVillager) this.merchant).getBukkitEntity().getLocation();
++ }
++ // CraftBukkit end
+
public InventoryMerchant(EntityHuman entityhuman, IMerchant imerchant) {
this.player = entityhuman;
- this.merchant = imerchant;
-@@ -94,7 +130,7 @@
+@@ -68,7 +110,7 @@
}
public int getMaxStackSize() {
diff --git a/nms-patches/InventorySubcontainer.patch b/nms-patches/InventorySubcontainer.patch
index 5cb52434..efc31989 100644
--- a/nms-patches/InventorySubcontainer.patch
+++ b/nms-patches/InventorySubcontainer.patch
@@ -1,11 +1,12 @@
--- a/net/minecraft/server/InventorySubcontainer.java
+++ b/net/minecraft/server/InventorySubcontainer.java
-@@ -3,6 +3,12 @@
+@@ -3,6 +3,13 @@
import com.google.common.collect.Lists;
import java.util.List;
+// CraftBukkit start
+import java.util.List;
++import org.bukkit.Location;
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
+import org.bukkit.entity.HumanEntity;
+// CraftBukkit end
@@ -13,7 +14,7 @@
public class InventorySubcontainer implements IInventory {
private String a;
-@@ -11,7 +17,42 @@
+@@ -11,7 +18,47 @@
private List<IInventoryListener> d;
private boolean e;
@@ -46,6 +47,11 @@
+ return bukkitOwner;
+ }
+
++ @Override
++ public Location getLocation() {
++ return null;
++ }
++
public InventorySubcontainer(String s, boolean flag, int i) {
+ this(s, flag, i, null);
+ }
diff --git a/nms-patches/ItemArmor.patch b/nms-patches/ItemArmor.patch
index e6beb5ee..4750c060 100644
--- a/nms-patches/ItemArmor.patch
+++ b/nms-patches/ItemArmor.patch
@@ -1,8 +1,8 @@
--- a/net/minecraft/server/ItemArmor.java
+++ b/net/minecraft/server/ItemArmor.java
-@@ -3,6 +3,11 @@
- import com.google.common.base.Predicates;
+@@ -5,6 +5,11 @@
import java.util.List;
+ import java.util.UUID;
+// CraftBukkit start
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
@@ -11,49 +11,48 @@
+
public class ItemArmor extends Item {
- private static final int[] k = new int[] { 11, 16, 15, 13};
-@@ -20,7 +25,34 @@
- EntityLiving entityliving = (EntityLiving) list.get(0);
- int l = entityliving instanceof EntityHuman ? 1 : 0;
- int i1 = EntityInsentient.c(itemstack);
-- ItemStack itemstack1 = itemstack.cloneItemStack();
+ private static final int[] m = new int[] { 13, 15, 16, 11};
+@@ -35,7 +40,33 @@
+ } else {
+ EntityLiving entityliving = (EntityLiving) list.get(0);
+ EnumItemSlot enumitemslot = EntityInsentient.d(itemstack);
+- ItemStack itemstack1 = itemstack.cloneItemStack();
++ // CraftBukkit start
++ ItemStack itemstack1 = itemstack.cloneAndSubtract(1);
++ World world = isourceblock.getWorld();
++ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ());
++ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
+
-+ // CraftBukkit start
-+ ItemStack itemstack1 = itemstack.cloneAndSubtract(1);
-+ World world = isourceblock.getWorld();
-+ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ());
-+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
++ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0));
++ if (!BlockDispenser.eventFired) {
++ world.getServer().getPluginManager().callEvent(event);
++ }
+
-+ 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()) {
++ itemstack.count++;
++ return itemstack;
++ }
+
-+ if (event.isCancelled()) {
-+ itemstack.count++;
++ if (!event.getItem().equals(craftItem)) {
++ itemstack.count++;
++ // 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);
+ return itemstack;
+ }
-+
-+ if (!event.getItem().equals(craftItem)) {
-+ itemstack.count++;
-+ // 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;
-+ }
-+ }
-+ // CraftBukkit end
++ }
++ // CraftBukkit end
- itemstack1.count = 1;
- entityliving.setEquipment(i1 - l, itemstack1);
-@@ -28,7 +60,7 @@
- ((EntityInsentient) entityliving).a(i1, 2.0F);
- }
+ itemstack1.count = 1;
+ entityliving.setSlot(enumitemslot, itemstack1);
+@@ -43,7 +74,7 @@
+ ((EntityInsentient) entityliving).a(enumitemslot, 2.0F);
+ }
-- --itemstack.count;
-+ // --itemstack.count; // CraftBukkit - handled above
- return itemstack;
- } else {
- return super.b(isourceblock, itemstack);
+- --itemstack.count;
++ // --itemstack.count; // CraftBukkit - handled above
+ return itemstack;
+ }
+ }
diff --git a/nms-patches/ItemBoat.patch b/nms-patches/ItemBoat.patch
index 364ba055..daeabd5e 100644
--- a/nms-patches/ItemBoat.patch
+++ b/nms-patches/ItemBoat.patch
@@ -1,17 +1,16 @@
--- a/net/minecraft/server/ItemBoat.java
+++ b/net/minecraft/server/ItemBoat.java
-@@ -54,6 +54,14 @@
- if (movingobjectposition.type == MovingObjectPosition.EnumMovingObjectType.BLOCK) {
- BlockPosition blockposition = movingobjectposition.a();
-
-+ // 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, blockposition, movingobjectposition.direction, itemstack);
+@@ -55,6 +55,13 @@
+ } else if (movingobjectposition.type != MovingObjectPosition.EnumMovingObjectType.BLOCK) {
+ return new InteractionResultWrapper(EnumInteractionResult.PASS, itemstack);
+ } else {
++ // 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);
+
-+ if (event.isCancelled()) {
-+ return itemstack;
-+ }
-+ // CraftBukkit end
-+
- if (world.getType(blockposition).getBlock() == Blocks.SNOW_LAYER) {
- blockposition = blockposition.down();
- }
++ if (event.isCancelled()) {
++ 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);
diff --git a/nms-patches/ItemBow.patch b/nms-patches/ItemBow.patch
index b21506f0..64e6fd71 100644
--- a/nms-patches/ItemBow.patch
+++ b/nms-patches/ItemBow.patch
@@ -7,43 +7,38 @@
+
public class ItemBow extends Item {
- public static final String[] a = new String[] { "pulling_0", "pulling_1", "pulling_2"};
-@@ -45,9 +47,28 @@
- }
+ public ItemBow() {
+@@ -73,7 +75,20 @@
+ }
- if (EnchantmentManager.getEnchantmentLevel(Enchantment.ARROW_FIRE.id, itemstack) > 0) {
-- entityarrow.setOnFire(100);
-+ // CraftBukkit start - call EntityCombustEvent
-+ EntityCombustEvent event = new EntityCombustEvent(entityarrow.getBukkitEntity(), 100);
-+ entityarrow.world.getServer().getPluginManager().callEvent(event);
+ if (EnchantmentManager.getEnchantmentLevel(Enchantments.ARROW_FIRE, itemstack) > 0) {
+- entityarrow.setOnFire(100);
++ // CraftBukkit start - call EntityCombustEvent
++ EntityCombustEvent event = new EntityCombustEvent(entityarrow.getBukkitEntity(), 100);
++ entityarrow.world.getServer().getPluginManager().callEvent(event);
+
-+ if (!event.isCancelled()) {
-+ entityarrow.setOnFire(event.getDuration());
-+ }
-+ // CraftBukkit end
-+ }
-+
-+ // CraftBukkit start
-+ org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(entityhuman, itemstack, entityarrow, f);
-+ if (event.isCancelled()) {
-+ event.getProjectile().remove();
-+ return;
- }
++ if (!event.isCancelled()) {
++ entityarrow.setOnFire(event.getDuration());
++ }
++ // CraftBukkit end
++ }
++ // CraftBukkit start
++ org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(entityhuman, itemstack, entityarrow, f);
++ if (event.isCancelled()) {
++ event.getProjectile().remove();
++ return;
+ }
-+ if (event.getProjectile() == entityarrow.getBukkitEntity()) {
-+ world.addEntity(entityarrow);
-+ }
-+ // CraftBukkit end
-+
- itemstack.damage(1, entityhuman);
- world.makeSound(entityhuman, "random.bow", 1.0F, 1.0F / (ItemBow.g.nextFloat() * 0.4F + 1.2F) + f * 0.5F);
- if (flag) {
-@@ -58,7 +79,7 @@
+ itemstack.damage(1, entityhuman);
+@@ -81,7 +96,10 @@
+ entityarrow.fromPlayer = EntityArrow.PickupStatus.CREATIVE_ONLY;
+ }
- entityhuman.b(StatisticList.USE_ITEM_COUNT[Item.getId(this)]);
- if (!world.isClientSide) {
-- world.addEntity(entityarrow);
-+ // world.addEntity(entityarrow); // CraftBukkit - moved up
- }
- }
+- world.addEntity(entityarrow);
++ if (event.getProjectile() == entityarrow.getBukkitEntity()) {
++ world.addEntity(entityarrow);
++ }
++ // CraftBukkit end
+ }
+ world.a((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.v, SoundCategory.NEUTRAL, 1.0F, 1.0F / (ItemBow.i.nextFloat() * 0.4F + 1.2F) + f * 0.5F);
diff --git a/nms-patches/ItemBucket.patch b/nms-patches/ItemBucket.patch
index 955279c1..39938584 100644
--- a/nms-patches/ItemBucket.patch
+++ b/nms-patches/ItemBucket.patch
@@ -13,71 +13,48 @@
public class ItemBucket extends Item {
private Block a;
-@@ -33,19 +40,41 @@
- Material material = iblockdata.getBlock().getMaterial();
+@@ -31,15 +38,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 itemstack;
++ return new InteractionResultWrapper(EnumInteractionResult.FAIL, itemstack);
+ }
+ // CraftBukkit end
- world.setAir(blockposition);
- entityhuman.b(StatisticList.USE_ITEM_COUNT[Item.getId(this)]);
-- return this.a(itemstack, entityhuman, Items.WATER_BUCKET);
-+ return this.a(itemstack, entityhuman, Items.WATER_BUCKET, event.getItemStack()); // CraftBukkit - added Event stack
- }
-
- if (material == Material.LAVA && ((Integer) iblockdata.get(BlockFluids.LEVEL)).intValue() == 0) {
+ world.setTypeAndData(blockposition, Blocks.AIR.getBlockData(), 11);
+ entityhuman.b(StatisticList.b((Item) this));
+ entityhuman.a(SoundEffects.N, 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) {
+ // CraftBukkit start
+ PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent(entityhuman, blockposition.getX(), blockposition.getY(), blockposition.getZ(), null, itemstack, Items.LAVA_BUCKET);
+
+ if (event.isCancelled()) {
-+ return itemstack;
-+ }
-+ // CraftBukkit end
- world.setAir(blockposition);
- entityhuman.b(StatisticList.USE_ITEM_COUNT[Item.getId(this)]);
-- return this.a(itemstack, entityhuman, Items.LAVA_BUCKET);
-+ return this.a(itemstack, entityhuman, Items.LAVA_BUCKET, event.getItemStack()); // CraftBukkit - added Event stack
- }
- } else {
- if (this.a == Blocks.AIR) {
-- return new ItemStack(Items.BUCKET);
-+ // CraftBukkit start
-+ PlayerBucketEmptyEvent event = CraftEventFactory.callPlayerBucketEmptyEvent(entityhuman, blockposition.getX(), blockposition.getY(), blockposition.getZ(), movingobjectposition.direction, itemstack);
-+
-+ if (event.isCancelled()) {
-+ return itemstack;
++ return new InteractionResultWrapper(EnumInteractionResult.FAIL, itemstack);
+ }
-+
-+ return CraftItemStack.asNMSCopy(event.getItemStack());
+ // CraftBukkit end
+ entityhuman.a(SoundEffects.O, 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);
}
+@@ -50,7 +71,7 @@
- BlockPosition blockposition1 = blockposition.shift(movingobjectposition.direction);
-@@ -54,9 +83,17 @@
- return itemstack;
- }
-
-+ // CraftBukkit start
-+ PlayerBucketEmptyEvent event = CraftEventFactory.callPlayerBucketEmptyEvent(entityhuman, blockposition.getX(), blockposition.getY(), blockposition.getZ(), movingobjectposition.direction, itemstack);
-+
-+ if (event.isCancelled()) {
-+ return itemstack;
-+ }
-+ // CraftBukkit end
-+
- if (this.a(world, blockposition1) && !entityhuman.abilities.canInstantlyBuild) {
- entityhuman.b(StatisticList.USE_ITEM_COUNT[Item.getId(this)]);
-- return new ItemStack(Items.BUCKET);
-+ return CraftItemStack.asNMSCopy(event.getItemStack()); // CraftBukkit
- }
- }
- }
-@@ -65,14 +102,15 @@
+ 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, itemstack)) { // CraftBukkit
+ entityhuman.b(StatisticList.b((Item) this));
+ return !entityhuman.abilities.canInstantlyBuild ? new InteractionResultWrapper(EnumInteractionResult.SUCCESS, new ItemStack(Items.BUCKET)) : new InteractionResultWrapper(EnumInteractionResult.SUCCESS, itemstack);
+ } else {
+@@ -60,21 +81,28 @@
}
}
@@ -91,9 +68,38 @@
+ return CraftItemStack.asNMSCopy(result); // CraftBukkit
} else {
- if (!entityhuman.inventory.pickup(new ItemStack(item))) {
-- entityhuman.drop(new ItemStack(item, 1, 0), false);
+- entityhuman.drop(new ItemStack(item), false);
+ if (!entityhuman.inventory.pickup(CraftItemStack.asNMSCopy(result))) {
+ entityhuman.drop(CraftItemStack.asNMSCopy(result), false);
}
return itemstack;
+ }
+ }
+
++ // CraftBukkit start
+ public boolean a(EntityHuman entityhuman, World world, BlockPosition blockposition) {
++ return a(entityhuman, world, blockposition, null, null);
++ }
++
++ public boolean a(EntityHuman entityhuman, World world, BlockPosition blockposition, EnumDirection enumdirection, ItemStack itemstack) {
++ // CraftBukkit end
+ if (this.a == Blocks.AIR) {
+ return false;
+ } else {
+@@ -86,6 +114,15 @@
+ if (!world.isEmpty(blockposition) && !flag && !flag1) {
+ return false;
+ } else {
++ // CraftBukkit start
++ if (entityhuman != null) {
++ PlayerBucketEmptyEvent event = CraftEventFactory.callPlayerBucketEmptyEvent(entityhuman, blockposition.getX(), blockposition.getY(), blockposition.getZ(), enumdirection, itemstack);
++ if (event.isCancelled()) {
++ // TODO: inventory not updated
++ return false;
++ }
++ }
++ // CraftBukkit end
+ if (world.worldProvider.l() && this.a == Blocks.FLOWING_WATER) {
+ int i = blockposition.getX();
+ int j = blockposition.getY();
diff --git a/nms-patches/ItemDye.patch b/nms-patches/ItemDye.patch
index b01d80fa..0f537c0d 100644
--- a/nms-patches/ItemDye.patch
+++ b/nms-patches/ItemDye.patch
@@ -8,7 +8,7 @@
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 @@
+@@ -87,6 +89,17 @@
EnumColor enumcolor = EnumColor.fromInvColorIndex(itemstack.getData());
if (!entitysheep.isSheared() && entitysheep.getColor() != enumcolor) {
diff --git a/nms-patches/ItemFireball.patch b/nms-patches/ItemFireball.patch
index dc040d9f..6cf934f3 100644
--- a/nms-patches/ItemFireball.patch
+++ b/nms-patches/ItemFireball.patch
@@ -1,17 +1,17 @@
--- a/net/minecraft/server/ItemFireball.java
+++ b/net/minecraft/server/ItemFireball.java
@@ -15,6 +15,14 @@
- return false;
+ return EnumInteractionResult.FAIL;
} else {
- if (world.getType(blockposition).getBlock().getMaterial() == Material.AIR) {
+ if (world.getType(blockposition).getMaterial() == Material.AIR) {
+ // CraftBukkit start - fire BlockIgniteEvent
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), org.bukkit.event.block.BlockIgniteEvent.IgniteCause.FIREBALL, entityhuman).isCancelled()) {
+ if (!entityhuman.abilities.canInstantlyBuild) {
+ --itemstack.count;
+ }
-+ return false;
++ return EnumInteractionResult.PASS;
+ }
+ // CraftBukkit end
- world.makeSound((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D, "item.fireCharge.use", 1.0F, (ItemFireball.g.nextFloat() - ItemFireball.g.nextFloat()) * 0.2F + 1.0F);
+ world.a((EntityHuman) null, blockposition, SoundEffects.bl, SoundCategory.BLOCKS, 1.0F, (ItemFireball.i.nextFloat() - ItemFireball.i.nextFloat()) * 0.2F + 1.0F);
world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData());
}
diff --git a/nms-patches/ItemFishingRod.patch b/nms-patches/ItemFishingRod.patch
index 90910268..06921408 100644
--- a/nms-patches/ItemFishingRod.patch
+++ b/nms-patches/ItemFishingRod.patch
@@ -8,9 +8,9 @@
public class ItemFishingRod extends Item {
public ItemFishingRod() {
-@@ -15,9 +17,18 @@
+@@ -17,9 +19,18 @@
itemstack.damage(i, entityhuman);
- entityhuman.bw();
+ entityhuman.a(enumhand);
} else {
+ // CraftBukkit start
+ EntityFishingHook hook = new EntityFishingHook(world, entityhuman);
@@ -18,13 +18,13 @@
+ world.getServer().getPluginManager().callEvent(playerFishEvent);
+
+ if (playerFishEvent.isCancelled()) {
-+ return itemstack;
++ return new InteractionResultWrapper(EnumInteractionResult.PASS, itemstack);
+ }
+ // CraftBukkit end
- world.makeSound(entityhuman, "random.bow", 0.5F, 0.4F / (ItemFishingRod.g.nextFloat() * 0.4F + 0.8F));
+ world.a((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.H, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemFishingRod.i.nextFloat() * 0.4F + 0.8F));
if (!world.isClientSide) {
- world.addEntity(new EntityFishingHook(world, entityhuman));
+ world.addEntity(hook); // CraftBukkit - moved creation up
}
- entityhuman.bw();
+ entityhuman.a(enumhand);
diff --git a/nms-patches/ItemFlintAndSteel.patch b/nms-patches/ItemFlintAndSteel.patch
index ab3aef93..20d31fe8 100644
--- a/nms-patches/ItemFlintAndSteel.patch
+++ b/nms-patches/ItemFlintAndSteel.patch
@@ -14,30 +14,30 @@
@@ -9,13 +14,31 @@
}
- public boolean interactWith(ItemStack itemstack, EntityHuman entityhuman, World world, BlockPosition blockposition, EnumDirection enumdirection, float f, float f1, float f2) {
+ public EnumInteractionResult a(ItemStack itemstack, EntityHuman entityhuman, World world, BlockPosition blockposition, EnumHand enumhand, EnumDirection enumdirection, float f, float f1, float f2) {
+ BlockPosition clicked = blockposition; // CraftBukkit
blockposition = blockposition.shift(enumdirection);
if (!entityhuman.a(blockposition, enumdirection, itemstack)) {
- return false;
+ return EnumInteractionResult.FAIL;
} else {
- if (world.getType(blockposition).getBlock().getMaterial() == Material.AIR) {
+ if (world.getType(blockposition).getMaterial() == Material.AIR) {
+ // CraftBukkit start - Store the clicked block
+ if (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 false;
++ return EnumInteractionResult.PASS;
+ }
+
+ CraftBlockState blockState = CraftBlockState.getBlockState(world, blockposition.getX(), blockposition.getY(), blockposition.getZ());
+ // CraftBukkit end
- world.makeSound((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D, "fire.ignite", 1.0F, ItemFlintAndSteel.g.nextFloat() * 0.4F + 0.8F);
- world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData());
+ world.a(entityhuman, blockposition, SoundEffects.bw, SoundCategory.BLOCKS, 1.0F, ItemFlintAndSteel.i.nextFloat() * 0.4F + 0.8F);
+ world.setTypeAndData(blockposition, Blocks.FIRE.getBlockData(), 11);
+
+ // CraftBukkit start
+ org.bukkit.event.block.BlockPlaceEvent placeEvent = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, clicked.getX(), clicked.getY(), clicked.getZ());
+
+ if (placeEvent.isCancelled() || !placeEvent.canBuild()) {
+ placeEvent.getBlockPlaced().setTypeIdAndData(0, (byte) 0, false);
-+ return false;
++ return EnumInteractionResult.PASS;
+ }
+ // CraftBukkit end
}
diff --git a/nms-patches/ItemHanging.patch b/nms-patches/ItemHanging.patch
index d6ec92ab..0b517da4 100644
--- a/nms-patches/ItemHanging.patch
+++ b/nms-patches/ItemHanging.patch
@@ -1,41 +1,32 @@
--- a/net/minecraft/server/ItemHanging.java
+++ b/net/minecraft/server/ItemHanging.java
-@@ -1,5 +1,11 @@
+@@ -1,5 +1,10 @@
package net.minecraft.server;
+// CraftBukkit start
+import org.bukkit.entity.Player;
+import org.bukkit.event.hanging.HangingPlaceEvent;
-+import org.bukkit.event.painting.PaintingPlaceEvent;
+// CraftBukkit end
+
public class ItemHanging extends Item {
private final Class<? extends EntityHanging> a;
-@@ -24,6 +30,26 @@
+@@ -17,6 +22,18 @@
- if (entityhanging != null && entityhanging.survives()) {
- if (!world.isClientSide) {
-+ // CraftBukkit start - fire HangingPlaceEvent
-+ Player who = (entityhuman == null) ? null : (Player) entityhuman.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);
+ if (entityhanging != null && entityhanging.survives()) {
+ if (!world.isClientSide) {
++ // CraftBukkit start - fire HangingPlaceEvent
++ Player who = (entityhuman == null) ? null : (Player) entityhuman.getBukkitEntity();
++ org.bukkit.block.Block blockClicked = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
++ org.bukkit.block.BlockFace blockFace = org.bukkit.craftbukkit.block.CraftBlock.notchToBlockFace(enumdirection);
+
-+ HangingPlaceEvent event = new HangingPlaceEvent((org.bukkit.entity.Hanging) entityhanging.getBukkitEntity(), who, blockClicked, blockFace);
-+ world.getServer().getPluginManager().callEvent(event);
++ HangingPlaceEvent event = new HangingPlaceEvent((org.bukkit.entity.Hanging) entityhanging.getBukkitEntity(), who, blockClicked, blockFace);
++ world.getServer().getPluginManager().callEvent(event);
+
-+ PaintingPlaceEvent paintingEvent = null;
-+ if (entityhanging instanceof EntityPainting) {
-+ // Fire old painting event until it can be removed
-+ paintingEvent = new PaintingPlaceEvent((org.bukkit.entity.Painting) entityhanging.getBukkitEntity(), who, blockClicked, blockFace);
-+ paintingEvent.setCancelled(event.isCancelled());
-+ world.getServer().getPluginManager().callEvent(paintingEvent);
-+ }
-+
-+ if (event.isCancelled() || (paintingEvent != null && paintingEvent.isCancelled())) {
-+ return false;
-+ }
-+ // CraftBukkit end
- world.addEntity(entityhanging);
- }
-
++ if (event.isCancelled()) {
++ return EnumInteractionResult.FAIL;
++ }
++ // CraftBukkit end
+ entityhanging.o();
+ world.addEntity(entityhanging);
+ }
diff --git a/nms-patches/ItemLeash.patch b/nms-patches/ItemLeash.patch
index c9713f22..d51c6786 100644
--- a/nms-patches/ItemLeash.patch
+++ b/nms-patches/ItemLeash.patch
@@ -9,8 +9,8 @@
public class ItemLeash extends Item {
public ItemLeash() {
-@@ -40,7 +42,23 @@
- if (entityinsentient.cc() && entityinsentient.getLeashHolder() == entityhuman) {
+@@ -39,7 +41,23 @@
+ if (entityinsentient.isLeashed() && entityinsentient.getLeashHolder() == entityhuman) {
if (entityleash == null) {
entityleash = EntityLeash.a(world, blockposition);
+
diff --git a/nms-patches/ItemMapEmpty.patch b/nms-patches/ItemMapEmpty.patch
index cc593bb8..6edb2d9b 100644
--- a/nms-patches/ItemMapEmpty.patch
+++ b/nms-patches/ItemMapEmpty.patch
@@ -1,9 +1,9 @@
--- a/net/minecraft/server/ItemMapEmpty.java
+++ b/net/minecraft/server/ItemMapEmpty.java
-@@ -7,15 +7,19 @@
+@@ -7,16 +7,20 @@
}
- public ItemStack a(ItemStack itemstack, World world, EntityHuman entityhuman) {
+ public InteractionResultWrapper<ItemStack> a(ItemStack itemstack, World world, EntityHuman entityhuman, EnumHand enumhand) {
- ItemStack itemstack1 = new ItemStack(Items.FILLED_MAP, 1, world.b("map"));
+ World worldMain = world.getServer().getServer().worlds.get(0); // CraftBukkit - store reference to primary world
+ ItemStack itemstack1 = new ItemStack(Items.FILLED_MAP, 1, worldMain.b("map")); // CraftBukkit - use primary world for maps
@@ -14,12 +14,12 @@
+ worldMain.a(s, (PersistentBase) worldmap); // CraftBukkit
worldmap.scale = 0;
worldmap.a(entityhuman.locX, entityhuman.locZ, worldmap.scale);
-- worldmap.map = (byte) world.worldProvider.getDimension();
-+ worldmap.map = (byte) ((WorldServer) world).dimension; // CraftBukkit - use bukkit dimension
+ worldmap.map = (byte) world.worldProvider.getDimensionManager().getDimensionID();
+ worldmap.track = true;
worldmap.c();
+
+ org.bukkit.craftbukkit.event.CraftEventFactory.callEvent(new org.bukkit.event.server.MapInitializeEvent(worldmap.mapView)); // CraftBukkit
+
--itemstack.count;
if (itemstack.count <= 0) {
- return itemstack1;
+ return new InteractionResultWrapper(EnumInteractionResult.SUCCESS, itemstack1);
diff --git a/nms-patches/ItemMinecart.patch b/nms-patches/ItemMinecart.patch
index ed8f094a..ea190ef9 100644
--- a/nms-patches/ItemMinecart.patch
+++ b/nms-patches/ItemMinecart.patch
@@ -57,7 +57,7 @@
return itemstack;
}
-@@ -73,6 +107,14 @@
+@@ -75,6 +109,14 @@
d0 = 0.5D;
}
@@ -65,7 +65,7 @@
+ org.bukkit.event.player.PlayerInteractEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent(entityhuman, org.bukkit.event.block.Action.RIGHT_CLICK_BLOCK, blockposition, enumdirection, itemstack);
+
+ if (event.isCancelled()) {
-+ return false;
++ return EnumInteractionResult.PASS;
+ }
+ // CraftBukkit end
+
diff --git a/nms-patches/ItemMonsterEgg.patch b/nms-patches/ItemMonsterEgg.patch
index e4236317..bba43c1f 100644
--- a/nms-patches/ItemMonsterEgg.patch
+++ b/nms-patches/ItemMonsterEgg.patch
@@ -1,29 +1,28 @@
--- a/net/minecraft/server/ItemMonsterEgg.java
+++ b/net/minecraft/server/ItemMonsterEgg.java
-@@ -109,6 +109,12 @@
+@@ -131,6 +131,11 @@
}
- public static Entity a(World world, int i, double d0, double d1, double d2) {
+ public static Entity a(World world, String s, double d0, double d1, double d2) {
+ // CraftBukkit start - delegate to spawnCreature
-+ return spawnCreature(world, i, d0, d1, d2, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG);
++ return spawnCreature(world, s, d0, d1, d2, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG);
+ }
+
-+ public static Entity spawnCreature(World world, int i, double d0, double d1, double d2, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) {
-+ // CraftBukkit end
- if (!EntityTypes.eggInfo.containsKey(Integer.valueOf(i))) {
- return null;
- } else {
-@@ -123,8 +129,13 @@
- entityinsentient.aK = entityinsentient.yaw;
- entityinsentient.aI = entityinsentient.yaw;
- entityinsentient.prepare(world.E(new BlockPosition(entityinsentient)), (GroupDataEntity) null);
++ public static Entity spawnCreature(World world, String s, double d0, double d1, double d2, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) {
+ if (s != null && EntityTypes.eggInfo.containsKey(s)) {
+ Entity entity = null;
+
+@@ -143,8 +148,13 @@
+ entityinsentient.aO = entityinsentient.yaw;
+ entityinsentient.aM = entityinsentient.yaw;
+ entityinsentient.prepare(world.D(new BlockPosition(entityinsentient)), (GroupDataEntity) null);
- world.addEntity(entity);
-- entityinsentient.x();
+- entityinsentient.D();
+ // CraftBukkit start - don't return an entity when CreatureSpawnEvent is canceled
+ if (!world.addEntity(entity, spawnReason)) {
+ entity = null;
+ } else {
-+ entityinsentient.x();
++ entityinsentient.D();
+ }
+ // CraftBukkit end
}
diff --git a/nms-patches/ItemRecord.patch b/nms-patches/ItemRecord.patch
index 0698a9df..ef571447 100644
--- a/nms-patches/ItemRecord.patch
+++ b/nms-patches/ItemRecord.patch
@@ -1,17 +1,10 @@
--- a/net/minecraft/server/ItemRecord.java
+++ b/net/minecraft/server/ItemRecord.java
-@@ -22,10 +22,14 @@
- if (world.isClientSide) {
- return true;
- } else {
-+ // CraftBukkit Start
-+ /*
+@@ -22,6 +22,7 @@
+
+ if (iblockdata.getBlock() == Blocks.JUKEBOX && !((Boolean) iblockdata.get(BlockJukeBox.HAS_RECORD)).booleanValue()) {
+ if (!world.isClientSide) {
++ if (true) return EnumInteractionResult.SUCCESS; // CraftBukkit - handled in ItemStack
((BlockJukeBox) Blocks.JUKEBOX).a(world, blockposition, iblockdata, itemstack);
- world.a((EntityHuman) null, 1005, blockposition, Item.getId(this));
+ world.a((EntityHuman) null, 1010, blockposition, Item.getId(this));
--itemstack.count;
- entityhuman.b(StatisticList.X);
-+ */
-+ // CraftBukkit End
- return true;
- }
- } else {
diff --git a/nms-patches/ItemStack.patch b/nms-patches/ItemStack.patch
index 9a2c9a54..7750c2d3 100644
--- a/nms-patches/ItemStack.patch
+++ b/nms-patches/ItemStack.patch
@@ -19,7 +19,7 @@
+
public final class ItemStack {
- public static final DecimalFormat a = new DecimalFormat("#.###");
+ public static final DecimalFormat a = new DecimalFormat("#.##");
@@ -46,10 +59,14 @@
this.k = false;
this.item = item;
@@ -39,10 +39,10 @@
}
-@@ -83,11 +100,128 @@
+@@ -84,11 +101,128 @@
}
- public boolean placeItem(EntityHuman entityhuman, World world, BlockPosition blockposition, EnumDirection enumdirection, float f, float f1, float f2) {
+ public EnumInteractionResult placeItem(EntityHuman entityhuman, World world, BlockPosition blockposition, EnumHand enumhand, EnumDirection enumdirection, float f, float f1, float f2) {
+ // CraftBukkit start - handle all block place event logic here
+ int data = this.getData();
+ int count = this.count;
@@ -57,13 +57,13 @@
+ }
+ }
+ }
- boolean flag = this.getItem().interactWith(this, entityhuman, world, blockposition, enumdirection, f, f1, f2);
+ EnumInteractionResult enuminteractionresult = this.getItem().a(this, entityhuman, world, blockposition, enumhand, enumdirection, f, f1, f2);
+ int newData = this.getData();
+ int newCount = this.count;
+ this.count = count;
+ this.setData(data);
+ world.captureBlockStates = false;
-+ if (flag && world.captureTreeGeneration && world.capturedBlockStates.size() > 0) {
++ 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;
@@ -87,12 +87,12 @@
+ }
+ }
+
-+ return flag;
++ return enuminteractionresult;
+ }
+ world.captureTreeGeneration = false;
- if (flag) {
-- entityhuman.b(StatisticList.USE_ITEM_COUNT[Item.getId(this.item)]);
+ 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();
@@ -103,7 +103,7 @@
+ }
+
+ if (placeEvent != null && (placeEvent.isCancelled() || !placeEvent.canBuild())) {
-+ flag = false; // cancel placement
++ enuminteractionresult = EnumInteractionResult.FAIL; // cancel placement
+ // revert back all captured blocks
+ for (BlockState blockstate : blocks) {
+ blockstate.update(true, false);
@@ -124,11 +124,11 @@
+ BlockPosition newblockposition = new BlockPosition(x, y, z);
+ IBlockData block = world.getType(newblockposition);
+
-+ if (!(block instanceof BlockContainer)) { // Containers get placed automatically
++ if (!(block instanceof BlockTileEntity)) { // Containers get placed automatically
+ block.getBlock().onPlace(world, newblockposition, block);
+ }
+
-+ world.notifyAndUpdatePhysics(newblockposition, null, oldBlock, block.getBlock(), updateFlag); // send null chunk as chunk.k() returns false by this point
++ world.notifyAndUpdatePhysics(newblockposition, null, oldBlock.getBlockData(), block, updateFlag); // send null chunk as chunk.k() returns false by this point
+ }
+
+ for (Map.Entry<BlockPosition, TileEntity> e : world.capturedTileEntities.entrySet()) {
@@ -146,7 +146,7 @@
+ if (this.getItem() == 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).getBlock().getMaterial().isBuildable()) {
++ if (!world.getType(blockposition).getMaterial().isBuildable()) {
+ bp = null;
+ } else {
+ bp = bp.shift(enumdirection);
@@ -160,16 +160,16 @@
+ }
+ }
+
-+ entityhuman.b(StatisticList.USE_ITEM_COUNT[Item.getId(this.item)]);
++ entityhuman.b(StatisticList.b(this.item));
+ }
}
+ world.capturedTileEntities.clear();
+ world.capturedBlockStates.clear();
+ // CraftBukkit end
- return flag;
+ return enuminteractionresult;
}
-@@ -111,7 +245,7 @@
+@@ -112,7 +246,7 @@
nbttagcompound.setByte("Count", (byte) this.count);
nbttagcompound.setShort("Damage", (short) this.damage);
if (this.tag != null) {
@@ -178,9 +178,9 @@
}
return nbttagcompound;
-@@ -125,13 +259,18 @@
- }
-
+@@ -121,13 +255,18 @@
+ public void c(NBTTagCompound nbttagcompound) {
+ this.item = Item.d(nbttagcompound.getString("id"));
this.count = nbttagcompound.getByte("Count");
+ /* CraftBukkit start - Route through setData for filtering
this.damage = nbttagcompound.getShort("Damage");
@@ -198,7 +198,7 @@
if (this.item != null) {
this.item.a(this.tag);
}
-@@ -168,8 +307,28 @@
+@@ -164,6 +303,26 @@
}
public void setData(int i) {
@@ -223,12 +223,9 @@
+ }
+ // CraftBukkit end
this.damage = i;
-- if (this.damage < 0) {
-+ if (this.damage < -1) { // CraftBukkit
+ if (this.damage < 0) {
this.damage = 0;
- }
-
-@@ -223,6 +382,12 @@
+@@ -216,6 +375,12 @@
this.count = 0;
}
@@ -241,11 +238,11 @@
this.damage = 0;
}
-@@ -489,6 +654,7 @@
+@@ -513,6 +678,7 @@
public void setItem(Item item) {
this.item = item;
+ this.setData(this.getData()); // CraftBukkit - Set data again to ensure it is filtered properly
}
- public IChatBaseComponent C() {
+ public IChatBaseComponent B() {
diff --git a/nms-patches/ItemWaterLily.patch b/nms-patches/ItemWaterLily.patch
index d4e7af04..18718a90 100644
--- a/nms-patches/ItemWaterLily.patch
+++ b/nms-patches/ItemWaterLily.patch
@@ -1,16 +1,16 @@
--- a/net/minecraft/server/ItemWaterLily.java
+++ b/net/minecraft/server/ItemWaterLily.java
-@@ -27,7 +27,15 @@
+@@ -23,7 +23,15 @@
IBlockData iblockdata = world.getType(blockposition);
- if (iblockdata.getBlock().getMaterial() == Material.WATER && ((Integer) iblockdata.get(BlockFluids.LEVEL)).intValue() == 0 && world.isEmpty(blockposition1)) {
+ if (iblockdata.getMaterial() == Material.WATER && ((Integer) iblockdata.get(BlockFluids.LEVEL)).intValue() == 0 && 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.setTypeUpdate(blockposition1, Blocks.WATERLILY.getBlockData());
+ world.setTypeAndData(blockposition1, Blocks.WATERLILY.getBlockData(), 11);
+ org.bukkit.event.block.BlockPlaceEvent placeEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockstate, blockposition.getX(), blockposition.getY(), blockposition.getZ());
+ if (placeEvent != null && (placeEvent.isCancelled() || !placeEvent.canBuild())) {
+ blockstate.update(true, false);
-+ return itemstack;
++ return new InteractionResultWrapper(EnumInteractionResult.PASS, itemstack);
+ }
+ // CraftBukkit end
if (!entityhuman.abilities.canInstantlyBuild) {
diff --git a/nms-patches/ItemWorldMap.patch b/nms-patches/ItemWorldMap.patch
index f40ea524..edee7580 100644
--- a/nms-patches/ItemWorldMap.patch
+++ b/nms-patches/ItemWorldMap.patch
@@ -27,8 +27,8 @@
s = "map_" + itemstack.getData();
worldmap = new WorldMap(s);
worldmap.scale = 3;
- worldmap.a((double) world.getWorldData().c(), (double) world.getWorldData().e(), worldmap.scale);
-- worldmap.map = (byte) world.worldProvider.getDimension();
+ 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);
@@ -44,30 +44,44 @@
}
public void a(World world, Entity entity, WorldMap worldmap) {
-- if (world.worldProvider.getDimension() == worldmap.map && entity instanceof EntityHuman) {
+- if (world.worldProvider.getDimensionManager().getDimensionID() == worldmap.map && entity instanceof EntityHuman) {
+ // CraftBukkit - world.worldProvider -> ((WorldServer) world)
+ if (((WorldServer) world).dimension == worldmap.map && entity instanceof EntityHuman) {
int i = 1 << worldmap.scale;
int j = worldmap.centerX;
int k = worldmap.centerZ;
-@@ -181,6 +193,8 @@
- if (itemstack.hasTag() && itemstack.getTag().getBoolean("map_is_scaling")) {
- WorldMap worldmap = Items.FILLED_MAP.getSavedMap(itemstack, world);
+@@ -195,6 +207,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());
++ 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());
-@@ -193,6 +207,11 @@
- 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
- }
+@@ -204,11 +217,16 @@
+ worldmap1.map = worldmap.map;
+ worldmap1.c();
+ world.a("map_" + itemstack.getData(), (PersistentBase) worldmap1);
++ // CraftBukkit start
++ MapInitializeEvent event = new MapInitializeEvent(worldmap1.mapView);
++ Bukkit.getServer().getPluginManager().callEvent(event);
++ // CraftBukkit end
+ }
+
+ 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());
+@@ -219,5 +237,9 @@
+ worldmap1.map = worldmap.map;
+ worldmap1.c();
+ world.a("map_" + itemstack.getData(), (PersistentBase) worldmap1);
++ // CraftBukkit start
++ MapInitializeEvent event = new MapInitializeEvent(worldmap1.mapView);
++ Bukkit.getServer().getPluginManager().callEvent(event);
++ // CraftBukkit end
}
+ }
diff --git a/nms-patches/LoginListener.patch b/nms-patches/LoginListener.patch
index e44493cf..8daab679 100644
--- a/nms-patches/LoginListener.patch
+++ b/nms-patches/LoginListener.patch
@@ -10,7 +10,7 @@
+import org.bukkit.event.player.PlayerPreLoginEvent;
+// CraftBukkit end
+
- public class LoginListener implements PacketLoginInListener, IUpdatePlayerListBox {
+ public class LoginListener implements PacketLoginInListener, ITickable {
private static final AtomicInteger b = new AtomicInteger(0);
@@ -32,6 +38,7 @@
@@ -36,9 +36,9 @@
+ // CraftBukkit end
} else {
this.g = LoginListener.EnumProtocolState.ACCEPTED;
- if (this.server.aK() >= 0 && !this.networkManager.c()) {
+ if (this.server.aF() >= 0 && !this.networkManager.isLocal()) {
@@ -90,7 +99,7 @@
- LoginListener.this.networkManager.a(LoginListener.this.server.aK());
+ LoginListener.this.networkManager.setCompressionLevel(LoginListener.this.server.aF());
}
- public void operationComplete(Future future) throws Exception {
@@ -49,7 +49,7 @@
@@ -101,9 +110,9 @@
if (entityplayer != null) {
- this.g = LoginListener.EnumProtocolState.e;
+ this.g = LoginListener.EnumProtocolState.DELAY_ACCEPT;
- this.l = this.server.getPlayerList().processLogin(this.i);
+ this.l = this.server.getPlayerList().processLogin(this.i, s); // CraftBukkit - add player reference
} else {
@@ -60,10 +60,10 @@
@@ -148,6 +157,43 @@
- LoginListener.this.i = LoginListener.this.server.aD().hasJoinedServer(new GameProfile((UUID) null, gameprofile.getName()), s);
+ LoginListener.this.i = LoginListener.this.server.ay().hasJoinedServer(new GameProfile((UUID) null, gameprofile.getName()), s);
if (LoginListener.this.i != null) {
+ // CraftBukkit start - fire PlayerPreLoginEvent
-+ if (!networkManager.g()) {
++ if (!networkManager.isConnected()) {
+ return;
+ }
+
@@ -101,7 +101,7 @@
+ // CraftBukkit end
LoginListener.c.info("UUID of player " + LoginListener.this.i.getName() + " is " + LoginListener.this.i.getId());
LoginListener.this.g = LoginListener.EnumProtocolState.READY_TO_ACCEPT;
- } else if (LoginListener.this.server.T()) {
+ } else if (LoginListener.this.server.R()) {
@@ -156,7 +202,7 @@
LoginListener.this.g = LoginListener.EnumProtocolState.READY_TO_ACCEPT;
} else {
@@ -110,7 +110,7 @@
+ LoginListener.c.error("Username \'" + gameprofile.getName() + "\' tried to join with an invalid session"); // CraftBukkit - fix null pointer
}
} catch (AuthenticationUnavailableException authenticationunavailableexception) {
- if (LoginListener.this.server.T()) {
+ if (LoginListener.this.server.R()) {
@@ -167,6 +213,11 @@
LoginListener.this.disconnect("Authentication servers are down. Please try again later, sorry!");
LoginListener.c.error("Couldn\'t verify username because servers are unavailable");
diff --git a/nms-patches/MerchantRecipe.patch b/nms-patches/MerchantRecipe.patch
new file mode 100644
index 00000000..a5a3a802
--- /dev/null
+++ b/nms-patches/MerchantRecipe.patch
@@ -0,0 +1,29 @@
+--- a/net/minecraft/server/MerchantRecipe.java
++++ b/net/minecraft/server/MerchantRecipe.java
+@@ -1,5 +1,7 @@
+ package net.minecraft.server;
+
++import org.bukkit.craftbukkit.inventory.CraftMerchantRecipe;
++
+ public class MerchantRecipe {
+
+ public ItemStack buyingItem1;
+@@ -8,6 +10,18 @@
+ public int uses;
+ public int maxUses;
+ public boolean rewardExp;
++ // CraftBukkit start
++ private CraftMerchantRecipe bukkitHandle;
++
++ public CraftMerchantRecipe asBukkit() {
++ return (bukkitHandle == null) ? bukkitHandle = new CraftMerchantRecipe(this) : bukkitHandle;
++ }
++
++ public MerchantRecipe(ItemStack itemstack, ItemStack itemstack1, ItemStack itemstack2, int i, int j, CraftMerchantRecipe bukkit) {
++ this(itemstack, itemstack1, itemstack2, i, j);
++ this.bukkitHandle = bukkit;
++ }
++ // CraftBukkit end
+
+ public MerchantRecipe(NBTTagCompound nbttagcompound) {
+ this.a(nbttagcompound);
diff --git a/nms-patches/MethodProfiler.patch b/nms-patches/MethodProfiler.patch
index 71b91ba1..0b080a61 100644
--- a/nms-patches/MethodProfiler.patch
+++ b/nms-patches/MethodProfiler.patch
@@ -58,7 +58,7 @@
public List<MethodProfiler.ProfilerInfo> b(String s) {
- if (!this.a) {
-- return null;
+- return Collections.emptyList();
- } else {
- 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;
@@ -139,7 +139,7 @@
}
- public int compareTo(Object object) {
-+ public int compareTo(MethodProfiler.ProfilerInfo object) {
++ public int compareTo(MethodProfiler.ProfilerInfo object) { // CraftBukkit: decompile error
return this.a((MethodProfiler.ProfilerInfo) object);
}
}
diff --git a/nms-patches/MinecraftServer.patch b/nms-patches/MinecraftServer.patch
index 2568fdd3..c0edea57 100644
--- a/nms-patches/MinecraftServer.patch
+++ b/nms-patches/MinecraftServer.patch
@@ -1,26 +1,51 @@
--- a/net/minecraft/server/MinecraftServer.java
+++ b/net/minecraft/server/MinecraftServer.java
-@@ -38,6 +38,15 @@
- import org.apache.logging.log4j.LogManager;
- import org.apache.logging.log4j.Logger;
-
-+// CraftBukkit start
-+import java.io.IOException;
-+
+@@ -14,7 +14,15 @@
+ import io.netty.buffer.ByteBufOutputStream;
+ import io.netty.buffer.Unpooled;
+ import io.netty.handler.codec.base64.Base64;
+-import java.awt.GraphicsEnvironment;
+import jline.console.ConsoleReader;
+import joptsimple.OptionSet;
-+
++import org.apache.commons.lang3.Validate;
++import org.apache.logging.log4j.LogManager;
++import org.apache.logging.log4j.Logger;
+import org.bukkit.craftbukkit.Main;
-+// CraftBukkit end
+
++import javax.imageio.ImageIO;
++import java.awt.*;
+ import java.awt.image.BufferedImage;
+ import java.io.File;
+ import java.io.IOException;
+@@ -25,7 +33,6 @@
+ import java.util.Arrays;
+ import java.util.Collections;
+ import java.util.Date;
+-import java.util.Iterator;
+ import java.util.List;
+ import java.util.Queue;
+ import java.util.Random;
+@@ -33,10 +40,11 @@
+ import java.util.concurrent.Callable;
+ import java.util.concurrent.Executors;
+ import java.util.concurrent.FutureTask;
+-import javax.imageio.ImageIO;
+-import org.apache.commons.lang3.Validate;
+-import org.apache.logging.log4j.LogManager;
+-import org.apache.logging.log4j.Logger;
++import org.bukkit.Bukkit;
++import org.bukkit.craftbukkit.CraftServer;
++
++// CraftBukkit start
++// CraftBukkit end
+
public abstract class MinecraftServer implements Runnable, ICommandListener, IAsyncTaskHandler, IMojangStatistics {
- public static final Logger LOGGER = LogManager.getLogger();
-@@ -94,19 +103,61 @@
+@@ -93,19 +101,61 @@
private Thread serverThread;
- private long ab = az();
+ private long aa = av();
-- public MinecraftServer(File file, Proxy proxy, File file1) {
+- public MinecraftServer(File file, Proxy proxy, DataConverterManager dataconvertermanager, YggdrasilAuthenticationService yggdrasilauthenticationservice, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache) {
+ // CraftBukkit start
+ public List<WorldServer> worlds = new ArrayList<WorldServer>();
+ public org.bukkit.craftbukkit.CraftServer server;
@@ -34,19 +59,19 @@
+ public int autosavePeriod;
+ // CraftBukkit end
+
-+ public MinecraftServer(OptionSet options, Proxy proxy, File file1) {
++ public MinecraftServer(OptionSet options, Proxy proxy, DataConverterManager dataconvertermanager, YggdrasilAuthenticationService yggdrasilauthenticationservice, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache) {
this.e = proxy;
- MinecraftServer.l = this;
+ this.U = yggdrasilauthenticationservice;
+ this.V = minecraftsessionservice;
+ this.W = gameprofilerepository;
+ this.X = usercache;
- this.universe = file;
+ // this.universe = file; // CraftBukkit
- this.q = new ServerConnection(this);
- this.Z = new UserCache(this, file1);
- this.b = this.h();
-- this.convertable = new WorldLoaderServer(file);
+ 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.V = new YggdrasilAuthenticationService(proxy, UUID.randomUUID().toString());
- this.W = this.V.createMinecraftSessionService();
- this.Y = this.V.createProfileRepository();
+ this.dataConverterManager = dataconvertermanager;
+ // CraftBukkit start
+ this.options = options;
+ // Try to see if we're actually running in a terminal, disable jline if not
@@ -78,10 +103,10 @@
+ public abstract PropertyManager getPropertyManager();
+ // CraftBukkit end
+
- protected CommandDispatcher h() {
- return new CommandDispatcher();
+ protected CommandDispatcher i() {
+ return new CommandDispatcher(this);
}
-@@ -144,6 +195,7 @@
+@@ -143,6 +193,7 @@
this.a(s);
this.b("menu.loadingLevel");
this.worldServer = new WorldServer[3];
@@ -89,7 +114,7 @@
this.i = new long[this.worldServer.length][100];
IDataManager idatamanager = this.convertable.a(s, true);
-@@ -167,37 +219,108 @@
+@@ -166,36 +217,107 @@
worlddata.a(s1);
worldsettings = new WorldSettings(worlddata);
}
@@ -128,13 +153,13 @@
+ worldsettings.setGeneratorSettings(s2);
+
if (j == 0) {
-+ IDataManager idatamanager = new ServerNBTManager(server.getWorldContainer(), s1, true);
++ IDataManager idatamanager = new ServerNBTManager(server.getWorldContainer(), s1, true, this.dataConverterManager);
+ WorldData 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.X()) {
+ if (this.V()) {
- 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 {
@@ -181,7 +206,7 @@
+ }
+ }
+
-+ IDataManager idatamanager = new ServerNBTManager(server.getWorldContainer(), name, true);
++ IDataManager idatamanager = new ServerNBTManager(server.getWorldContainer(), name, true, this.dataConverterManager);
+ // world =, b0 to dimension, s1 to name, added Environment and gen
+ WorldData worlddata = idatamanager.getWorldData();
+ if (worlddata == null) {
@@ -195,32 +220,31 @@
+ this.server.getPluginManager().callEvent(new org.bukkit.event.world.WorldInitEvent(world.getWorld()));
+
+ world.addIWorldAccess(new WorldManager(this, world));
- if (!this.T()) {
+ if (!this.R()) {
- this.worldServer[j].getWorldData().setGameType(this.getGamemode());
+ world.getWorldData().setGameType(this.getGamemode());
}
-+
+- }
+
+ worlds.add(world);
+ getPlayerList().setPlayerFileData(worlds.toArray(new WorldServer[worlds.size()]));
- }
-
-- this.v.setPlayerFileData(this.worldServer);
++ }
+ // CraftBukkit end
+ this.v.setPlayerFileData(this.worldServer);
this.a(this.getDifficulty());
- this.k();
- }
-@@ -212,25 +335,38 @@
+ this.l();
+@@ -211,25 +333,38 @@
this.b("menu.generatingTerrain");
byte b0 = 0;
- MinecraftServer.LOGGER.info("Preparing start region for level " + b0);
- WorldServer worldserver = this.worldServer[b0];
- BlockPosition blockposition = worldserver.getSpawn();
-- long j = az();
+- long j = av();
-
- for (int k = -192; k <= 192 && this.isRunning(); k += 16) {
- for (int l = -192; l <= 192 && this.isRunning(); l += 16) {
-- long i1 = az();
+- long i1 = av();
-
- if (i1 - j > 1000L) {
- this.a_("Preparing spawn area", i * 100 / 625);
@@ -229,19 +253,19 @@
+ // CraftBukkit start - fire WorldLoadEvent and handle whether or not to keep the spawn in memory
+ for (int m = 0; m < worlds.size(); m++) {
+ WorldServer worldserver = this.worlds.get(m);
-+ LOGGER.info("Preparing start region for level " + m + " (Seed: " + worldserver.getSeed() + ")");
++ MinecraftServer.LOGGER.info("Preparing start region for level " + m + " (Seed: " + worldserver.getSeed() + ")");
+
+ if (!worldserver.getWorld().getKeepSpawnInMemory()) {
+ continue;
+ }
+
+ BlockPosition blockposition = worldserver.getSpawn();
-+ long j = az();
++ long j = av();
+ i = 0;
+
+ for (int k = -192; k <= 192 && this.isRunning(); k += 16) {
+ for (int l = -192; l <= 192 && this.isRunning(); l += 16) {
-+ long i1 = az();
++ long i1 = av();
+
+ if (i1 - j > 1000L) {
+ this.a_("Preparing spawn area", i * 100 / 625);
@@ -249,9 +273,9 @@
+ }
- ++i;
-- worldserver.chunkProviderServer.getChunkAt(blockposition.getX() + k >> 4, blockposition.getZ() + l >> 4);
+- worldserver.getChunkProviderServer().getChunkAt(blockposition.getX() + k >> 4, blockposition.getZ() + l >> 4);
+ ++i;
-+ worldserver.chunkProviderServer.getChunkAt(blockposition.getX() + k >> 4, blockposition.getZ() + l >> 4);
++ worldserver.getChunkProviderServer().getChunkAt(blockposition.getX() + k >> 4, blockposition.getZ() + l >> 4);
+ }
}
}
@@ -260,42 +284,39 @@
+ this.server.getPluginManager().callEvent(new org.bukkit.event.world.WorldLoadEvent(world.getWorld()));
+ }
+ // CraftBukkit end
- this.s();
+ this.t();
}
-@@ -266,15 +402,19 @@
- protected void s() {
+@@ -265,14 +400,17 @@
+ protected void t() {
this.f = null;
this.g = 0;
-+
+ this.server.enablePlugins(org.bukkit.plugin.PluginLoadOrder.POSTWORLD); // CraftBukkit
}
-- protected void saveChunks(boolean flag) {
-+ protected void saveChunks(boolean flag) throws ExceptionWorldConflict { // CraftBukkit - added throws
- if (!this.N) {
- WorldServer[] aworldserver = this.worldServer;
- int i = aworldserver.length;
+ protected void saveChunks(boolean flag) {
+ 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
+- 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) {
+ if (!flag) {
+@@ -281,6 +419,7 @@
+
+ try {
+ worldserver.save(true, (IProgressUpdate) null);
++ worldserver.saveLevel(); // CraftBukkit
+ } catch (ExceptionWorldConflict exceptionworldconflict) {
+ MinecraftServer.LOGGER.warn(exceptionworldconflict.getMessage());
+ }
+@@ -289,7 +428,18 @@
- if (worldserver != null) {
- if (!flag) {
-@@ -283,6 +423,7 @@
-
- try {
- worldserver.save(true, (IProgressUpdate) null);
-+ worldserver.saveLevel(); // CraftBukkit
- } catch (ExceptionWorldConflict exceptionworldconflict) {
- MinecraftServer.LOGGER.warn(exceptionworldconflict.getMessage());
- }
-@@ -292,9 +433,25 @@
- }
}
- protected void stop() {
@@ -311,60 +332,54 @@
+ hasStopped = true;
+ }
+ // CraftBukkit end
- if (!this.N) {
- MinecraftServer.LOGGER.info("Stopping server");
-+ // CraftBukkit start
-+ if (this.server != null) {
-+ this.server.disablePlugins();
-+ }
-+ // CraftBukkit end
- if (this.aq() != null) {
- this.aq().b();
- }
-@@ -303,17 +460,20 @@
- MinecraftServer.LOGGER.info("Saving players");
- this.v.savePlayers();
- this.v.u();
-+ try { Thread.sleep(100); } catch (InterruptedException ex) {} // CraftBukkit - SPIGOT-625 - give server at least a chance to send packets
- }
+ MinecraftServer.LOGGER.info("Stopping server");
+ if (this.am() != null) {
+ this.am().b();
+@@ -299,6 +449,7 @@
+ MinecraftServer.LOGGER.info("Saving players");
+ this.v.savePlayers();
+ this.v.u();
++ try { Thread.sleep(100); } catch (InterruptedException ex) {} // CraftBukkit - SPIGOT-625 - give server at least a chance to send packets
+ }
- if (this.worldServer != null) {
- MinecraftServer.LOGGER.info("Saving worlds");
- this.saveChunks(false);
+ if (this.worldServer != null) {
+@@ -314,11 +465,13 @@
-+ /* CraftBukkit start - Handled in saveChunks
- for (int i = 0; i < this.worldServer.length; ++i) {
- WorldServer worldserver = this.worldServer[i];
+ this.saveChunks(false);
- worldserver.saveLevel();
++ /* CraftBukkit start - Handled in saveChunks
+ for (i = 0; i < this.worldServer.length; ++i) {
+ if (this.worldServer[i] != null) {
+ this.worldServer[i].saveLevel();
}
-+ // CraftBukkit end */
}
++ // CraftBukkit end */
+ }
- if (this.n.d()) {
-@@ -354,6 +514,7 @@
- long k = j - this.ab;
+ if (this.m.d()) {
+@@ -358,6 +511,7 @@
+ long k = j - this.aa;
- if (k > 2000L && this.ab - this.R >= 15000L) {
+ if (k > 2000L && this.aa - this.Q >= 15000L) {
+ if (server.getWarnOnOverload()) // CraftBukkit
MinecraftServer.LOGGER.warn("Can\'t keep up! Did the system time change, or is the server overloaded? Running {}ms behind, skipping {} tick(s)", new Object[] { Long.valueOf(k), Long.valueOf(k / 50L)});
k = 2000L;
- this.R = this.ab;
-@@ -366,11 +527,12 @@
+ this.Q = this.aa;
+@@ -370,11 +524,12 @@
i += k;
- this.ab = j;
+ this.aa = j;
- if (this.worldServer[0].everyoneDeeplySleeping()) {
+ if (this.worlds.get(0).everyoneDeeplySleeping()) { // CraftBukkit
- this.A();
+ this.C();
i = 0L;
} else {
while (i > 50L) {
+ MinecraftServer.currentTick = (int) (System.currentTimeMillis() / 50); // CraftBukkit
i -= 50L;
- this.A();
+ this.C();
}
-@@ -408,6 +570,12 @@
+@@ -412,6 +567,12 @@
} catch (Throwable throwable1) {
MinecraftServer.LOGGER.error("Exception stopping the server", throwable1);
} finally {
@@ -374,20 +389,20 @@
+ } catch (Exception ignored) {
+ }
+ // CraftBukkit end
- this.z();
+ this.B();
}
-@@ -447,7 +615,7 @@
+@@ -455,7 +616,7 @@
- protected void z() {}
+ protected void B() {}
-- protected void A() {
-+ protected void A() throws ExceptionWorldConflict { // CraftBukkit - added throws
+- protected void C() {
++ protected void C() throws ExceptionWorldConflict { // CraftBukkit - added throws
long i = System.nanoTime();
++this.ticks;
-@@ -473,7 +641,7 @@
- this.r.b().a(agameprofile);
+@@ -481,7 +642,7 @@
+ this.q.b().a(agameprofile);
}
- if (this.ticks % 900 == 0) {
@@ -395,7 +410,7 @@
this.methodProfiler.a("save");
this.v.savePlayers();
this.saveChunks(true);
-@@ -508,20 +676,40 @@
+@@ -516,20 +677,40 @@
this.methodProfiler.c("levels");
@@ -420,7 +435,7 @@
int i;
- for (i = 0; i < this.worldServer.length; ++i) {
-+ for (i = 0; i < this.worlds.size(); ++i) {
++ for (i = 0; i < this.worlds.size(); ++i) { // CraftBukkit
long j = System.nanoTime();
- if (i == 0 || this.getAllowNether()) {
@@ -432,14 +447,14 @@
+ /* Drop global time updates
if (this.ticks % 20 == 0) {
this.methodProfiler.a("timeSync");
- this.v.a(new PacketPlayOutUpdateTime(worldserver.getTime(), worldserver.getDayTime(), worldserver.getGameRules().getBoolean("doDaylightCycle")), worldserver.worldProvider.getDimension());
+ this.v.a((Packet) (new PacketPlayOutUpdateTime(worldserver.getTime(), worldserver.getDayTime(), worldserver.getGameRules().getBoolean("doDaylightCycle"))), worldserver.worldProvider.getDimensionManager().getDimensionID());
this.methodProfiler.b();
}
+ // CraftBukkit end */
this.methodProfiler.a("tick");
-@@ -548,9 +736,9 @@
+@@ -556,9 +737,9 @@
worldserver.getTracker().updatePlayers();
this.methodProfiler.b();
this.methodProfiler.b();
@@ -451,8 +466,8 @@
}
this.methodProfiler.c("connection");
-@@ -574,10 +762,11 @@
- this.p.add(iupdateplayerlistbox);
+@@ -582,10 +763,11 @@
+ this.o.add(itickable);
}
- public static void main(String[] astring) {
@@ -464,14 +479,30 @@
boolean flag = true;
String s = null;
String s1 = ".";
-@@ -655,15 +844,38 @@
+@@ -630,13 +812,16 @@
+ ++j;
+ }
+ }
++ */ // CraftBukkit end
+
++ String s1 = "."; // PAIL?
+ YggdrasilAuthenticationService yggdrasilauthenticationservice = new YggdrasilAuthenticationService(Proxy.NO_PROXY, UUID.randomUUID().toString());
+ MinecraftSessionService minecraftsessionservice = yggdrasilauthenticationservice.createMinecraftSessionService();
+ GameProfileRepository gameprofilerepository = yggdrasilauthenticationservice.createProfileRepository();
+ UserCache usercache = new UserCache(gameprofilerepository, new File(s1, MinecraftServer.a.getName()));
+- final DedicatedServer dedicatedserver = new DedicatedServer(new File(s1), DataConverterRegistry.a(), yggdrasilauthenticationservice, minecraftsessionservice, gameprofilerepository, usercache);
++ final DedicatedServer dedicatedserver = new DedicatedServer(options, DataConverterRegistry.a(), yggdrasilauthenticationservice, minecraftsessionservice, gameprofilerepository, usercache);
+
++ /* CraftBukkit start
+ if (s != null) {
+ dedicatedserver.i(s);
+ }
+@@ -667,6 +852,25 @@
dedicatedserver.stop();
}
});
+ */
+
-+ DedicatedServer dedicatedserver = new DedicatedServer(options);
-+
+ if (options.has("port")) {
+ int port = (Integer) options.valueOf("port");
+ if (port > 0) {
@@ -492,11 +523,10 @@
} catch (Exception exception) {
MinecraftServer.LOGGER.fatal("Failed to start the minecraft server", exception);
}
-
+@@ -674,8 +878,10 @@
}
-- public void D() {
-+ public void C() {
+ public void F() {
+ /* CraftBukkit start - prevent abuse
this.serverThread = new Thread(this, "Server thread");
this.serverThread.start();
@@ -504,7 +534,7 @@
}
public File d(String s) {
-@@ -679,7 +891,14 @@
+@@ -691,7 +897,14 @@
}
public WorldServer getWorldServer(int i) {
@@ -519,8 +549,8 @@
+ // CraftBukkit end
}
- public String E() {
-@@ -715,7 +934,7 @@
+ public String getVersion() {
+@@ -715,7 +928,7 @@
}
public boolean isDebugging() {
@@ -529,7 +559,7 @@
}
public void g(String s) {
-@@ -730,7 +949,7 @@
+@@ -730,7 +943,7 @@
}
public String getServerModName() {
@@ -538,34 +568,30 @@
}
public CrashReport b(CrashReport crashreport) {
-@@ -759,6 +978,7 @@
+@@ -759,6 +972,7 @@
}
- public List<String> tabCompleteCommand(ICommandListener icommandlistener, String s, BlockPosition blockposition) {
+ public List<String> tabCompleteCommand(ICommandListener icommandlistener, String s, BlockPosition blockposition, boolean flag) {
+ /* CraftBukkit start - Allow tab-completion of Bukkit commands
ArrayList arraylist = Lists.newArrayList();
+ boolean flag1 = s.startsWith("/");
- if (s.startsWith("/")) {
-@@ -797,6 +1017,9 @@
+@@ -801,10 +1015,13 @@
return arraylist;
}
+ */
-+ return server.tabComplete(icommandlistener, s);
++ return server.tabComplete(icommandlistener, s); // PAIL : todo args
+ // CraftBukkit end
}
- public static MinecraftServer getServer() {
-@@ -804,7 +1027,7 @@
- }
-
- public boolean O() {
+ public boolean M() {
- return this.universe != null;
+ return true; // CraftBukkit
}
public String getName() {
-@@ -860,8 +1083,10 @@
+@@ -860,8 +1077,10 @@
}
public void a(EnumDifficulty enumdifficulty) {
@@ -578,29 +604,7 @@
if (worldserver != null) {
if (worldserver.getWorldData().isHardcore()) {
-@@ -903,15 +1128,17 @@
- this.N = true;
- this.getConvertable().d();
-
-- for (int i = 0; i < this.worldServer.length; ++i) {
-- WorldServer worldserver = this.worldServer[i];
--
-+ // CraftBukkit start
-+ for (int i = 0; i < this.worlds.size(); ++i) {
-+ WorldServer worldserver = this.worlds.get(i);
-+ // CraftBukkit end
-+
- if (worldserver != null) {
- worldserver.saveLevel();
- }
- }
-
-- this.getConvertable().e(this.worldServer[0].getDataManager().g());
-+ this.getConvertable().e(this.worlds.get(0).getDataManager().g()); // CraftBukkit
- this.safeShutdown();
- }
-
-@@ -944,9 +1171,11 @@
+@@ -928,9 +1147,11 @@
int i = 0;
if (this.worldServer != null) {
@@ -614,9 +618,9 @@
+ // CraftBukkit end
WorldData worlddata = worldserver.getWorldData();
- mojangstatisticsgenerator.a("world[" + i + "][dimension]", Integer.valueOf(worldserver.worldProvider.getDimension()));
-@@ -979,7 +1208,7 @@
- public abstract boolean ae();
+ mojangstatisticsgenerator.a("world[" + i + "][dimension]", Integer.valueOf(worldserver.worldProvider.getDimensionManager().getDimensionID()));
+@@ -963,7 +1184,7 @@
+ public abstract boolean aa();
public boolean getOnlineMode() {
- return this.onlineMode;
@@ -624,19 +628,19 @@
}
public void setOnlineMode(boolean flag) {
-@@ -1051,8 +1280,9 @@
+@@ -1035,8 +1256,9 @@
}
public void setGamemode(WorldSettings.EnumGamemode worldsettings_enumgamemode) {
- for (int i = 0; i < this.worldServer.length; ++i) {
-- getServer().worldServer[i].getWorldData().setGameType(worldsettings_enumgamemode);
+- this.worldServer[i].getWorldData().setGameType(worldsettings_enumgamemode);
+ // CraftBukkit start
+ for (int i = 0; i < this.worlds.size(); ++i) {
-+ getServer().worlds.get(i).getWorldData().setGameType(worldsettings_enumgamemode);
++ worlds.get(i).getWorldData().setGameType(worldsettings_enumgamemode);
}
}
-@@ -1084,7 +1314,7 @@
+@@ -1068,7 +1290,7 @@
}
public World getWorld() {
@@ -645,7 +649,7 @@
}
public Entity f() {
-@@ -1155,8 +1385,10 @@
+@@ -1139,8 +1361,10 @@
WorldServer[] aworldserver = this.worldServer;
int i = aworldserver.length;
@@ -658,16 +662,16 @@
if (worldserver != null) {
Entity entity = worldserver.getEntity(uuid);
-@@ -1171,7 +1403,7 @@
+@@ -1155,7 +1379,7 @@
}
public boolean getSendCommandFeedback() {
-- return getServer().worldServer[0].getGameRules().getBoolean("sendCommandFeedback");
-+ return getServer().worlds.get(0).getGameRules().getBoolean("sendCommandFeedback");
+- return this.worldServer[0].getGameRules().getBoolean("sendCommandFeedback");
++ return worlds.get(0).getGameRules().getBoolean("sendCommandFeedback");
}
public void a(CommandObjectiveExecutor.EnumCommandResult commandobjectiveexecutor_enumcommandresult, int i) {}
-@@ -1182,7 +1414,7 @@
+@@ -1170,7 +1394,7 @@
public <V> ListenableFuture<V> a(Callable<V> callable) {
Validate.notNull(callable);
@@ -676,3 +680,15 @@
ListenableFutureTask listenablefuturetask = ListenableFutureTask.create(callable);
Queue queue = this.j;
+@@ -1215,4 +1439,11 @@
+ public int a(WorldServer worldserver) {
+ return worldserver != null ? worldserver.getGameRules().c("spawnRadius") : 10;
+ }
++
++ // CraftBukkit start
++ @Deprecated
++ public static MinecraftServer getServer() {
++ return ((CraftServer) Bukkit.getServer()).getServer();
++ }
++ // CraftBukkit end
+ }
diff --git a/nms-patches/MobEffectList.patch b/nms-patches/MobEffectList.patch
index dae68b40..4276f69d 100644
--- a/nms-patches/MobEffectList.patch
+++ b/nms-patches/MobEffectList.patch
@@ -1,6 +1,6 @@
--- a/net/minecraft/server/MobEffectList.java
+++ b/net/minecraft/server/MobEffectList.java
-@@ -7,6 +7,11 @@
+@@ -6,6 +6,11 @@
import java.util.UUID;
import java.util.Map.Entry;
@@ -11,32 +11,33 @@
+
public class MobEffectList {
- public static final MobEffectList[] byId = new MobEffectList[32];
-@@ -64,6 +69,7 @@
- }
+ public static final RegistryMaterials<MinecraftKey, MobEffectList> REGISTRY = new RegistryMaterials();
+@@ -22,7 +27,7 @@
+ }
- this.L = j;
-+ org.bukkit.potion.PotionEffectType.registerPotionEffectType(new org.bukkit.craftbukkit.potion.CraftPotionEffectType(this)); // CraftBukkit
+ public static int getId(MobEffectList mobeffectlist) {
+- return MobEffectList.REGISTRY.a((Object) mobeffectlist);
++ return MobEffectList.REGISTRY.a(mobeffectlist); // CraftBukkit - decompile error
}
- public static MobEffectList b(String s) {
-@@ -86,11 +92,11 @@
+ public static MobEffectList getByName(String s) {
+@@ -48,11 +53,11 @@
public void tick(EntityLiving entityliving, int i) {
- if (this.id == MobEffectList.REGENERATION.id) {
+ if (this == MobEffects.REGENERATION) {
if (entityliving.getHealth() < entityliving.getMaxHealth()) {
- entityliving.heal(1.0F);
+ entityliving.heal(1.0F, RegainReason.MAGIC_REGEN); // CraftBukkit
}
- } else if (this.id == MobEffectList.POISON.id) {
+ } else if (this == MobEffects.POISON) {
if (entityliving.getHealth() > 1.0F) {
- entityliving.damageEntity(DamageSource.MAGIC, 1.0F);
+ entityliving.damageEntity(CraftEventFactory.POISON, 1.0F); // CraftBukkit - DamageSource.MAGIC -> CraftEventFactory.POISON
}
- } else if (this.id == MobEffectList.WITHER.id) {
+ } else if (this == MobEffects.WITHER) {
entityliving.damageEntity(DamageSource.WITHER, 1.0F);
-@@ -98,14 +104,25 @@
+@@ -60,14 +65,25 @@
((EntityHuman) entityliving).applyExhaustion(0.025F * (float) (i + 1));
- } else if (this.id == MobEffectList.SATURATION.id && entityliving instanceof EntityHuman) {
+ } else if (this == MobEffects.SATURATION && entityliving instanceof EntityHuman) {
if (!entityliving.world.isClientSide) {
- ((EntityHuman) entityliving).getFoodData().eat(i + 1, 1.0F);
+ // CraftBukkit start
@@ -52,8 +53,8 @@
+ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutUpdateHealth(((EntityPlayer) entityhuman).getBukkitEntity().getScaledHealth(), entityhuman.getFoodData().foodLevel, entityhuman.getFoodData().saturationLevel));
+ // CraftBukkit end
}
- } else if ((this.id != MobEffectList.HEAL.id || entityliving.bm()) && (this.id != MobEffectList.HARM.id || !entityliving.bm())) {
- if (this.id == MobEffectList.HARM.id && !entityliving.bm() || this.id == MobEffectList.HEAL.id && entityliving.bm()) {
+ } else if ((this != MobEffects.HEAL || entityliving.bP()) && (this != MobEffects.HARM || !entityliving.bP())) {
+ if (this == MobEffects.HARM && !entityliving.bP() || this == MobEffects.HEAL && entityliving.bP()) {
entityliving.damageEntity(DamageSource.MAGIC, (float) (6 << i));
}
} else {
@@ -62,7 +63,7 @@
}
}
-@@ -124,7 +141,7 @@
+@@ -86,7 +102,7 @@
}
} else {
j = (int) (d0 * (double) (4 << i) + 0.5D);
@@ -71,3 +72,14 @@
}
}
+@@ -205,5 +221,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.h, "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.h, "CC5AF142-2BD2-4215-B636-2605AED11727", -1.0D, 0));
++ // CraftBukkit start
++ for (MobEffectList effect : REGISTRY) {
++ org.bukkit.potion.PotionEffectType.registerPotionEffectType(new org.bukkit.craftbukkit.potion.CraftPotionEffectType(effect));
++ }
++ // CraftBukkit end
+ }
+ }
diff --git a/nms-patches/MobSpawnerAbstract.patch b/nms-patches/MobSpawnerAbstract.patch
index ccf99ef2..408e3a46 100644
--- a/nms-patches/MobSpawnerAbstract.patch
+++ b/nms-patches/MobSpawnerAbstract.patch
@@ -1,50 +1,11 @@
--- a/net/minecraft/server/MobSpawnerAbstract.java
+++ b/net/minecraft/server/MobSpawnerAbstract.java
-@@ -4,6 +4,8 @@
- import java.util.Iterator;
- import java.util.List;
-
-+import org.bukkit.event.entity.CreatureSpawnEvent; // CraftBukkit
-+
- public abstract class MobSpawnerAbstract {
-
- public int spawnDelay = 20;
-@@ -24,6 +26,11 @@
-
- public String getMobName() {
- if (this.i() == null) {
-+ // CraftBukkit start - fix NPE
-+ if (this.mobName == null) {
-+ this.mobName = "Pig";
-+ }
-+ // CraftBukkit end
- if (this.mobName != null && this.mobName.equals("Minecart")) {
- this.mobName = "MinecartRideable";
- }
-@@ -129,7 +136,7 @@
-
- entity.f(nbttagcompound);
- if (entity.world != null && flag) {
-- entity.world.addEntity(entity);
-+ entity.world.addEntity(entity, CreatureSpawnEvent.SpawnReason.SPAWNER); // CraftBukkit
- }
-
- NBTTagCompound nbttagcompound1;
-@@ -154,7 +161,7 @@
- entity2.f(nbttagcompound2);
- entity2.setPositionRotation(entity1.locX, entity1.locY, entity1.locZ, entity1.yaw, entity1.pitch);
- if (entity.world != null && flag) {
-- entity.world.addEntity(entity2);
-+ entity.world.addEntity(entity2, CreatureSpawnEvent.SpawnReason.SPAWNER); // CraftBukkit
- }
-
- entity1.mount(entity2);
-@@ -167,7 +174,7 @@
- ((EntityInsentient) entity).prepare(entity.world.E(new BlockPosition(entity)), (GroupDataEntity) null);
- }
-
-- entity.world.addEntity(entity);
-+ entity.world.addEntity(entity, CreatureSpawnEvent.SpawnReason.SPAWNER); // CraftBukkit
- }
-
- return entity;
+@@ -95,7 +95,7 @@
+ ((EntityInsentient) entity).prepare(world.D(new BlockPosition(entity)), (GroupDataEntity) null);
+ }
+
+- ChunkRegionLoader.a(entity, world);
++ ChunkRegionLoader.a(entity, world, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER); // CraftBukkit
+ world.triggerEffect(2004, blockposition, 0);
+ if (entityinsentient != null) {
+ entityinsentient.doSpawnEffect();
diff --git a/nms-patches/NBTTagList.patch b/nms-patches/NBTTagList.patch
deleted file mode 100644
index a91a3e34..00000000
--- a/nms-patches/NBTTagList.patch
+++ /dev/null
@@ -1,10 +0,0 @@
---- a/net/minecraft/server/NBTTagList.java
-+++ b/net/minecraft/server/NBTTagList.java
-@@ -40,6 +40,7 @@
- } else {
- this.type = datainput.readByte();
- int j = datainput.readInt();
-+ nbtreadlimiter.a(j * 8); // CraftBukkit
-
- if (this.type == 0 && j > 0) {
- throw new RuntimeException("Missing type on ListTag");
diff --git a/nms-patches/NameReferencingFileConverter.patch b/nms-patches/NameReferencingFileConverter.patch
index 2d49bf12..4d7fed98 100644
--- a/nms-patches/NameReferencingFileConverter.patch
+++ b/nms-patches/NameReferencingFileConverter.patch
@@ -48,7 +48,7 @@
}
}
-@@ -350,6 +354,30 @@
+@@ -349,6 +353,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);
-@@ -467,7 +495,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 b41fb161..f4de26f0 100644
--- a/nms-patches/NetworkManager.patch
+++ b/nms-patches/NetworkManager.patch
@@ -1,6 +1,15 @@
--- a/net/minecraft/server/NetworkManager.java
+++ b/net/minecraft/server/NetworkManager.java
-@@ -231,7 +231,7 @@
+@@ -113,7 +113,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) {
+ ;
+ }
+@@ -232,7 +232,7 @@
public void close(IChatBaseComponent ichatbasecomponent) {
if (this.channel.isOpen()) {
@@ -9,7 +18,7 @@
this.n = ichatbasecomponent;
}
-@@ -308,7 +308,7 @@
+@@ -309,7 +309,7 @@
}
}
diff --git a/nms-patches/PacketDataSerializer.patch b/nms-patches/PacketDataSerializer.patch
index c66b7b58..3208a310 100644
--- a/nms-patches/PacketDataSerializer.patch
+++ b/nms-patches/PacketDataSerializer.patch
@@ -1,6 +1,6 @@
--- a/net/minecraft/server/PacketDataSerializer.java
+++ b/net/minecraft/server/PacketDataSerializer.java
-@@ -21,6 +21,8 @@
+@@ -20,6 +20,8 @@
import java.nio.charset.Charset;
import java.util.UUID;
@@ -9,16 +9,16 @@
public class PacketDataSerializer extends ByteBuf {
private final ByteBuf a;
-@@ -68,7 +70,7 @@
+@@ -99,7 +101,7 @@
}
public <T extends Enum<T>> T a(Class<T> oclass) {
-- return ((Enum[]) oclass.getEnumConstants())[this.e()];
-+ return ((T[]) oclass.getEnumConstants())[this.e()]; // CraftBukkit - fix decompile error
+- return ((Enum[]) oclass.getEnumConstants())[this.g()];
++ return ((T[]) oclass.getEnumConstants())[this.g()]; // CraftBukkit - fix decompile error
}
- public void a(Enum<?> oenum) {
-@@ -142,7 +144,7 @@
+ public PacketDataSerializer a(Enum<?> oenum) {
+@@ -176,7 +178,7 @@
} else {
try {
NBTCompressedStreamTools.a(nbttagcompound, (DataOutput) (new ByteBufOutputStream(this)));
@@ -27,19 +27,19 @@
throw new EncoderException(ioexception);
}
}
-@@ -162,7 +164,7 @@
+@@ -202,7 +204,7 @@
}
- public void a(ItemStack itemstack) {
+ public PacketDataSerializer a(ItemStack itemstack) {
- if (itemstack == null) {
+ if (itemstack == null || itemstack.getItem() == null) { // CraftBukkit - NPE fix itemstack.getItem()
this.writeShort(-1);
} else {
this.writeShort(Item.getId(itemstack.getItem()));
-@@ -189,6 +191,11 @@
+@@ -230,6 +232,11 @@
itemstack = new ItemStack(Item.getById(short0), b0, short1);
- itemstack.setTag(this.h());
+ itemstack.setTag(this.j());
+ // CraftBukkit start
+ if (itemstack.getTag() != null) {
+ CraftItemStack.setItemMeta(itemstack, CraftItemStack.getItemMeta(itemstack));
@@ -48,20 +48,3 @@
}
return itemstack;
-@@ -803,16 +810,4 @@
- public boolean release(int i) {
- return this.a.release(i);
- }
--
-- public ReferenceCounted retain(int i) {
-- return this.retain(i);
-- }
--
-- public ReferenceCounted retain() {
-- return this.retain();
-- }
--
-- public int compareTo(Object object) {
-- return this.compareTo((ByteBuf) object);
-- }
- }
diff --git a/nms-patches/PacketPlayInBlockPlace.patch b/nms-patches/PacketPlayInBlockPlace.patch
index c0081922..247e93c2 100644
--- a/nms-patches/PacketPlayInBlockPlace.patch
+++ b/nms-patches/PacketPlayInBlockPlace.patch
@@ -1,28 +1,19 @@
--- a/net/minecraft/server/PacketPlayInBlockPlace.java
+++ b/net/minecraft/server/PacketPlayInBlockPlace.java
-@@ -12,6 +12,8 @@
- private float f;
- private float g;
+@@ -6,6 +6,8 @@
+
+ private EnumHand a;
+ public long timestamp; // CraftBukkit
+
public PacketPlayInBlockPlace() {}
- public PacketPlayInBlockPlace(ItemStack itemstack) {
-@@ -28,6 +30,7 @@
+ public PacketPlayInBlockPlace(EnumHand enumhand) {
+@@ -13,6 +15,7 @@
}
public void a(PacketDataSerializer packetdataserializer) throws IOException {
-+ timestamp = System.currentTimeMillis(); // CraftBukkit
- this.b = packetdataserializer.c();
- this.c = packetdataserializer.readUnsignedByte();
- this.d = packetdataserializer.i();
-@@ -72,8 +75,4 @@
- public float f() {
- return this.g;
++ this.timestamp = System.currentTimeMillis(); // CraftBukkit
+ this.a = (EnumHand) packetdataserializer.a(EnumHand.class);
}
--
-- public void a(PacketListener packetlistener) {
-- this.a((PacketListenerPlayIn) packetlistener);
-- }
- }
+
diff --git a/nms-patches/PacketPlayInCloseWindow.patch b/nms-patches/PacketPlayInCloseWindow.patch
index b7678c6d..c17757e8 100644
--- a/nms-patches/PacketPlayInCloseWindow.patch
+++ b/nms-patches/PacketPlayInCloseWindow.patch
@@ -13,12 +13,3 @@
public void a(PacketListenerPlayIn packetlistenerplayin) {
packetlistenerplayin.a(this);
}
-@@ -19,8 +25,4 @@
- public void b(PacketDataSerializer packetdataserializer) throws IOException {
- packetdataserializer.writeByte(this.id);
- }
--
-- public void a(PacketListener packetlistener) {
-- this.a((PacketListenerPlayIn) packetlistener);
-- }
- }
diff --git a/nms-patches/PacketPlayInResourcePackStatus.patch b/nms-patches/PacketPlayInResourcePackStatus.patch
deleted file mode 100644
index b6bbd0d4..00000000
--- a/nms-patches/PacketPlayInResourcePackStatus.patch
+++ /dev/null
@@ -1,22 +0,0 @@
---- a/net/minecraft/server/PacketPlayInResourcePackStatus.java
-+++ b/net/minecraft/server/PacketPlayInResourcePackStatus.java
-@@ -5,7 +5,7 @@
- public class PacketPlayInResourcePackStatus implements Packet<PacketListenerPlayIn> {
-
- private String a;
-- private PacketPlayInResourcePackStatus.EnumResourcePackStatus b;
-+ public PacketPlayInResourcePackStatus.EnumResourcePackStatus b; // PAIL: private -> public, rename: status
-
- public PacketPlayInResourcePackStatus() {}
-
-@@ -23,10 +23,6 @@
- packetlistenerplayin.a(this);
- }
-
-- public void a(PacketListener packetlistener) {
-- this.a((PacketListenerPlayIn) packetlistener);
-- }
--
- public static enum EnumResourcePackStatus {
-
- SUCCESSFULLY_LOADED, DECLINED, FAILED_DOWNLOAD, ACCEPTED;
diff --git a/nms-patches/PacketStatusListener.patch b/nms-patches/PacketStatusListener.patch
index 075488ff..e660bf8b 100644
--- a/nms-patches/PacketStatusListener.patch
+++ b/nms-patches/PacketStatusListener.patch
@@ -17,102 +17,99 @@
public class PacketStatusListener implements PacketStatusInListener {
private static final IChatBaseComponent a = new ChatComponentText("Status request has been handled.");
-@@ -17,10 +28,96 @@
- public void a(PacketStatusInStart packetstatusinstart) {
- if (this.d) {
+@@ -19,8 +30,95 @@
this.networkManager.close(PacketStatusListener.a);
-- } else {
-- this.d = true;
-- this.networkManager.handle(new PacketStatusOutServerInfo(this.minecraftServer.aG()));
-+ // CraftBukkit start - fire ping event
-+ return;
-+ }
-+ this.d = true;
-+ // this.networkManager.handle(new PacketStatusOutServerInfo(this.minecraftServer.aG()));
-+ final Object[] players = minecraftServer.getPlayerList().players.toArray();
-+ class ServerListPingEvent extends org.bukkit.event.server.ServerListPingEvent {
-+ CraftIconCache icon = minecraftServer.server.getServerIcon();
+ } else {
+ this.d = true;
+- this.networkManager.sendPacket(new PacketStatusOutServerInfo(this.minecraftServer.getServerPing()));
++ // CraftBukkit start
++ // this.networkManager.sendPacket(new PacketStatusOutServerInfo(this.minecraftServer.getServerPing()));
++ final Object[] players = minecraftServer.getPlayerList().players.toArray();
++ class ServerListPingEvent extends org.bukkit.event.server.ServerListPingEvent {
+
-+ ServerListPingEvent() {
-+ super(((InetSocketAddress) networkManager.getSocketAddress()).getAddress(), minecraftServer.getMotd(), minecraftServer.getPlayerList().getMaxPlayers());
-+ }
++ CraftIconCache icon = minecraftServer.server.getServerIcon();
+
-+ @Override
-+ public void setServerIcon(org.bukkit.util.CachedServerIcon icon) {
-+ if (!(icon instanceof CraftIconCache)) {
-+ throw new IllegalArgumentException(icon + " was not created by " + org.bukkit.craftbukkit.CraftServer.class);
++ ServerListPingEvent() {
++ super(((InetSocketAddress) networkManager.getSocketAddress()).getAddress(), minecraftServer.getMotd(), minecraftServer.getPlayerList().getMaxPlayers());
++ }
++
++ @Override
++ public void setServerIcon(org.bukkit.util.CachedServerIcon icon) {
++ if (!(icon instanceof CraftIconCache)) {
++ throw new IllegalArgumentException(icon + " was not created by " + org.bukkit.craftbukkit.CraftServer.class);
++ }
++ this.icon = (CraftIconCache) icon;
+ }
-+ this.icon = (CraftIconCache) icon;
-+ }
+
-+ @Override
-+ public Iterator<Player> iterator() throws UnsupportedOperationException {
-+ return new Iterator<Player>() {
-+ int i;
-+ int ret = Integer.MIN_VALUE;
-+ EntityPlayer player;
++ @Override
++ public Iterator<Player> iterator() throws UnsupportedOperationException {
++ return new Iterator<Player>() {
++ int i;
++ int ret = Integer.MIN_VALUE;
++ EntityPlayer player;
+
-+ @Override
-+ public boolean hasNext() {
-+ if (player != null) {
-+ return true;
-+ }
-+ final Object[] currentPlayers = players;
-+ for (int length = currentPlayers.length, i = this.i; i < length; i++) {
-+ final EntityPlayer player = (EntityPlayer) currentPlayers[i];
++ @Override
++ public boolean hasNext() {
+ if (player != null) {
-+ this.i = i + 1;
-+ this.player = player;
+ return true;
+ }
++ final Object[] currentPlayers = players;
++ for (int length = currentPlayers.length, i = this.i; i < length; i++) {
++ final EntityPlayer player = (EntityPlayer) currentPlayers[i];
++ if (player != null) {
++ this.i = i + 1;
++ this.player = player;
++ return true;
++ }
++ }
++ return false;
+ }
-+ return false;
-+ }
+
-+ @Override
-+ public Player next() {
-+ if (!hasNext()) {
-+ throw new java.util.NoSuchElementException();
++ @Override
++ public Player next() {
++ if (!hasNext()) {
++ throw new java.util.NoSuchElementException();
++ }
++ final EntityPlayer player = this.player;
++ this.player = null;
++ this.ret = this.i - 1;
++ return player.getBukkitEntity();
+ }
-+ final EntityPlayer player = this.player;
-+ this.player = null;
-+ this.ret = this.i - 1;
-+ return player.getBukkitEntity();
-+ }
+
-+ @Override
-+ public void remove() {
-+ final Object[] currentPlayers = players;
-+ final int i = this.ret;
-+ if (i < 0 || currentPlayers[i] == null) {
-+ throw new IllegalStateException();
++ @Override
++ public void remove() {
++ final Object[] currentPlayers = players;
++ final int i = this.ret;
++ if (i < 0 || currentPlayers[i] == null) {
++ throw new IllegalStateException();
++ }
++ currentPlayers[i] = null;
+ }
-+ currentPlayers[i] = null;
-+ }
-+ };
++ };
++ }
+ }
-+ }
+
-+ ServerListPingEvent event = new ServerListPingEvent();
-+ this.minecraftServer.server.getPluginManager().callEvent(event);
++ ServerListPingEvent event = new ServerListPingEvent();
++ this.minecraftServer.server.getPluginManager().callEvent(event);
+
-+ java.util.List<GameProfile> profiles = new java.util.ArrayList<GameProfile>(players.length);
-+ for (Object player : players) {
-+ if (player != null) {
-+ profiles.add(((EntityPlayer) player).getProfile());
++ java.util.List<GameProfile> profiles = new java.util.ArrayList<GameProfile>(players.length);
++ for (Object player : players) {
++ if (player != null) {
++ profiles.add(((EntityPlayer) player).getProfile());
++ }
+ }
- }
+
-+ ServerPing.ServerPingPlayerSample playerSample = new ServerPing.ServerPingPlayerSample(event.getMaxPlayers(), profiles.size());
-+ playerSample.a(profiles.toArray(new GameProfile[profiles.size()]));
++ ServerPing.ServerPingPlayerSample playerSample = new ServerPing.ServerPingPlayerSample(event.getMaxPlayers(), profiles.size());
++ playerSample.a(profiles.toArray(new GameProfile[profiles.size()]));
+
-+ ServerPing ping = new ServerPing();
-+ ping.setFavicon(event.icon.value);
-+ ping.setMOTD(new ChatComponentText(event.getMotd()));
-+ ping.setPlayerSample(playerSample);
-+ ping.setServerInfo(new ServerPing.ServerData(minecraftServer.getServerModName() + " " + minecraftServer.getVersion(), 47)); // TODO: Update when protocol changes
++ ServerPing ping = new ServerPing();
++ ping.setFavicon(event.icon.value);
++ ping.setMOTD(new ChatComponentText(event.getMotd()));
++ ping.setPlayerSample(playerSample);
++ ping.setServerInfo(new ServerPing.ServerData(minecraftServer.getServerModName() + " " + minecraftServer.getVersion(), minecraftServer.getServerPing().getServerData().getProtocolVersion()));
+
-+ this.networkManager.handle(new PacketStatusOutServerInfo(ping));
++ this.networkManager.sendPacket(new PacketStatusOutServerInfo(ping));
+ }
+ // CraftBukkit end
}
diff --git a/nms-patches/Path.patch b/nms-patches/Path.patch
deleted file mode 100644
index caa54590..00000000
--- a/nms-patches/Path.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- a/net/minecraft/server/Path.java
-+++ b/net/minecraft/server/Path.java
-@@ -2,7 +2,7 @@
-
- public class Path {
-
-- private PathPoint[] a = new PathPoint[1024];
-+ private PathPoint[] a = new PathPoint[128]; // CraftBukkit - reduce default size
- private int b;
-
- public Path() {}
diff --git a/nms-patches/PathfinderGoalBreakDoor.patch b/nms-patches/PathfinderGoalBreakDoor.patch
index 3f61dbea..e51d1569 100644
--- a/nms-patches/PathfinderGoalBreakDoor.patch
+++ b/nms-patches/PathfinderGoalBreakDoor.patch
@@ -11,5 +11,5 @@
+ }
+ // CraftBukkit end
this.a.world.setAir(this.b);
- this.a.world.triggerEffect(1012, this.b, 0);
+ this.a.world.triggerEffect(1021, this.b, 0);
this.a.world.triggerEffect(2001, this.b, Block.getId(this.c));
diff --git a/nms-patches/PathfinderGoalBreed.patch b/nms-patches/PathfinderGoalBreed.patch
index 3ae9587d..3f74b1ac 100644
--- a/nms-patches/PathfinderGoalBreed.patch
+++ b/nms-patches/PathfinderGoalBreed.patch
@@ -1,7 +1,7 @@
--- a/net/minecraft/server/PathfinderGoalBreed.java
+++ b/net/minecraft/server/PathfinderGoalBreed.java
-@@ -70,6 +70,11 @@
- EntityAgeable entityageable = this.d.createChild(this.e);
+@@ -69,6 +69,11 @@
+ EntityAgeable entityageable = this.animal.createChild(this.partner);
if (entityageable != null) {
+ // CraftBukkit start - set persistence for tame animals
@@ -9,15 +9,15 @@
+ entityageable.persistent = true;
+ }
+ // CraftBukkit end
- EntityHuman entityhuman = this.d.cq();
+ EntityHuman entityhuman = this.animal.getBreedCause();
- if (entityhuman == null && this.e.cq() != null) {
-@@ -89,7 +94,7 @@
- this.e.cs();
+ if (entityhuman == null && this.partner.getBreedCause() != null) {
+@@ -88,7 +93,7 @@
+ this.partner.resetLove();
entityageable.setAgeRaw(-24000);
- entityageable.setPositionRotation(this.d.locX, this.d.locY, this.d.locZ, 0.0F, 0.0F);
+ 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
- Random random = this.d.bc();
+ Random random = this.animal.getRandom();
for (int i = 0; i < 7; ++i) {
diff --git a/nms-patches/PathfinderGoalHurtByTarget.patch b/nms-patches/PathfinderGoalHurtByTarget.patch
index e3855668..cb3fcfd8 100644
--- a/nms-patches/PathfinderGoalHurtByTarget.patch
+++ b/nms-patches/PathfinderGoalHurtByTarget.patch
@@ -1,15 +1,15 @@
--- a/net/minecraft/server/PathfinderGoalHurtByTarget.java
+++ b/net/minecraft/server/PathfinderGoalHurtByTarget.java
-@@ -23,7 +23,7 @@
+@@ -24,7 +24,7 @@
}
public void c() {
- 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.b = this.e.be();
- if (this.a) {
- double d0 = this.f();
-@@ -58,6 +58,6 @@
+ this.g = this.e.getGoalTarget();
+ this.b = this.e.bH();
+ this.h = 300;
+@@ -61,6 +61,6 @@
}
protected void a(EntityCreature entitycreature, EntityLiving entityliving) {
diff --git a/nms-patches/PathfinderGoalMakeLove.patch b/nms-patches/PathfinderGoalMakeLove.patch
index 2673a6b2..5edee4cc 100644
--- a/nms-patches/PathfinderGoalMakeLove.patch
+++ b/nms-patches/PathfinderGoalMakeLove.patch
@@ -1,7 +1,7 @@
--- a/net/minecraft/server/PathfinderGoalMakeLove.java
+++ b/net/minecraft/server/PathfinderGoalMakeLove.java
@@ -87,7 +87,7 @@
- this.b.o(false);
+ this.b.r(false);
entityvillager.setAgeRaw(-24000);
entityvillager.setPositionRotation(this.b.locX, this.b.locY, this.b.locZ, 0.0F, 0.0F);
- this.d.addEntity(entityvillager);
diff --git a/nms-patches/PathfinderGoalNearestAttackableTarget.patch b/nms-patches/PathfinderGoalNearestAttackableTarget.patch
index 860671e2..4f44f3ab 100644
--- a/nms-patches/PathfinderGoalNearestAttackableTarget.patch
+++ b/nms-patches/PathfinderGoalNearestAttackableTarget.patch
@@ -1,6 +1,6 @@
--- a/net/minecraft/server/PathfinderGoalNearestAttackableTarget.java
+++ b/net/minecraft/server/PathfinderGoalNearestAttackableTarget.java
-@@ -60,7 +60,7 @@
+@@ -34,7 +34,7 @@
}
public boolean apply(Object object) {
@@ -9,7 +9,34 @@
}
};
}
-@@ -83,7 +83,7 @@
+@@ -49,11 +49,11 @@
+ return false;
+ } else {
+ Collections.sort(list, this.b);
+- this.d = (EntityLiving) list.get(0);
++ this.d = (T) list.get(0); // CraftBukkit - fix decompile error
+ return true;
+ }
+ } else {
+- this.d = this.e.world.a(this.e.locX, this.e.locY + (double) this.e.getHeadHeight(), this.e.locZ, this.f(), this.f(), new Function() {
++ this.d = (T) this.e.world.a(this.e.locX, this.e.locY + (double) this.e.getHeadHeight(), this.e.locZ, this.f(), this.f(), new Function<EntityHuman, Double>() { // CraftBukkit - fix decompile error
+ public Double a(EntityHuman entityhuman) {
+ ItemStack itemstack = entityhuman.getEquipment(EnumItemSlot.HEAD);
+
+@@ -71,10 +71,10 @@
+ return Double.valueOf(1.0D);
+ }
+
+- public Object apply(Object object) {
++ public Double apply(EntityHuman object) { // CraftBukkit - fix decompile error
+ return this.a((EntityHuman) object);
+ }
+- }, this.c);
++ }, (Predicate<EntityHuman>) this.c); // CraftBukkit - fix decompile error
+ return this.d != null;
+ }
+ }
+@@ -84,7 +84,7 @@
}
public void c() {
@@ -18,7 +45,7 @@
super.c();
}
-@@ -102,7 +102,7 @@
+@@ -103,7 +103,7 @@
return d0 < d1 ? -1 : (d0 > d1 ? 1 : 0);
}
diff --git a/nms-patches/PathfinderGoalPanic.patch b/nms-patches/PathfinderGoalPanic.patch
index 8725c766..0ecc9b00 100644
--- a/nms-patches/PathfinderGoalPanic.patch
+++ b/nms-patches/PathfinderGoalPanic.patch
@@ -1,6 +1,6 @@
--- a/net/minecraft/server/PathfinderGoalPanic.java
+++ b/net/minecraft/server/PathfinderGoalPanic.java
-@@ -36,6 +36,12 @@
+@@ -46,6 +46,12 @@
}
public boolean b() {
@@ -10,6 +10,6 @@
+ return false;
+ }
+ // CraftBukkit end
- return !this.b.getNavigation().m();
+ return !this.b.getNavigation().n();
}
- }
+
diff --git a/nms-patches/PathfinderGoalSelector.patch b/nms-patches/PathfinderGoalSelector.patch
deleted file mode 100644
index 27aa2304..00000000
--- a/nms-patches/PathfinderGoalSelector.patch
+++ /dev/null
@@ -1,30 +0,0 @@
---- a/net/minecraft/server/PathfinderGoalSelector.java
-+++ b/net/minecraft/server/PathfinderGoalSelector.java
-@@ -6,11 +6,13 @@
- import org.apache.logging.log4j.LogManager;
- import org.apache.logging.log4j.Logger;
-
-+import org.bukkit.craftbukkit.util.UnsafeList; // CraftBukkit
-+
- public class PathfinderGoalSelector {
-
- private static final Logger a = LogManager.getLogger();
-- private List<PathfinderGoalSelector.PathfinderGoalSelectorItem> b = Lists.newArrayList();
-- private List<PathfinderGoalSelector.PathfinderGoalSelectorItem> c = Lists.newArrayList();
-+ private List<PathfinderGoalSelector.PathfinderGoalSelectorItem> b = new UnsafeList<PathfinderGoalSelector.PathfinderGoalSelectorItem>();
-+ private List<PathfinderGoalSelector.PathfinderGoalSelectorItem> c = new UnsafeList<PathfinderGoalSelector.PathfinderGoalSelectorItem>();
- private final MethodProfiler d;
- private int e;
- private int f = 3;
-@@ -107,9 +109,11 @@
- if (pathfindergoalselector_pathfindergoalselectoritem1 != pathfindergoalselector_pathfindergoalselectoritem) {
- if (pathfindergoalselector_pathfindergoalselectoritem.b >= pathfindergoalselector_pathfindergoalselectoritem1.b) {
- if (!this.a(pathfindergoalselector_pathfindergoalselectoritem, pathfindergoalselector_pathfindergoalselectoritem1) && this.c.contains(pathfindergoalselector_pathfindergoalselectoritem1)) {
-+ ((UnsafeList.Itr) iterator).valid = false; // CraftBukkit - mark iterator for reuse
- return false;
- }
- } else if (!pathfindergoalselector_pathfindergoalselectoritem1.a.i() && this.c.contains(pathfindergoalselector_pathfindergoalselectoritem1)) {
-+ ((UnsafeList.Itr) iterator).valid = false; // CraftBukkit - mark iterator for reuse
- return false;
- }
- }
diff --git a/nms-patches/PathfinderGoalSit.patch b/nms-patches/PathfinderGoalSit.patch
index e6ee998e..80597cfe 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.V()) {
+ } else if (this.entity.isInWater()) {
return false;
} else if (!this.entity.onGround) {
diff --git a/nms-patches/PathfinderGoalTame.patch b/nms-patches/PathfinderGoalTame.patch
index 2d4f3e99..395bffec 100644
--- a/nms-patches/PathfinderGoalTame.patch
+++ b/nms-patches/PathfinderGoalTame.patch
@@ -1,31 +1,12 @@
--- a/net/minecraft/server/PathfinderGoalTame.java
+++ b/net/minecraft/server/PathfinderGoalTame.java
-@@ -45,7 +45,8 @@
+@@ -51,7 +51,8 @@
int i = this.entity.getTemper();
int j = this.entity.getMaxDomestication();
-- if (j > 0 && this.entity.bc().nextInt(j) < i) {
+- if (j > 0 && this.entity.getRandom().nextInt(j) < i) {
+ // CraftBukkit - fire EntityTameEvent
-+ if (j > 0 && this.entity.bc().nextInt(j) < i && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this.entity, (EntityHuman) this.entity.passenger).isCancelled() && this.entity.passenger instanceof EntityHuman) {
- this.entity.h((EntityHuman) this.entity.passenger);
++ if (j > 0 && this.entity.getRandom().nextInt(j) < i && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this.entity, ((org.bukkit.craftbukkit.entity.CraftHumanEntity) this.entity.getBukkitEntity().getPassenger()).getHandle()).isCancelled()) {
+ this.entity.g((EntityHuman) entity);
this.entity.world.broadcastEntityEffect(this.entity, (byte) 7);
return;
-@@ -54,8 +55,16 @@
- this.entity.u(5);
- }
-
-- this.entity.passenger.mount((Entity) null);
-- this.entity.passenger = null;
-+ // CraftBukkit start - Handle dismounting to account for VehicleExitEvent being fired.
-+ if (this.entity.passenger != null) {
-+ this.entity.passenger.mount((Entity) null);
-+ // If the entity still has a passenger, then a plugin cancelled the event.
-+ if (this.entity.passenger != null) {
-+ return;
-+ }
-+ }
-+ // this.entity.passenger = null;
-+ // CraftBukkit end
- this.entity.cW();
- this.entity.world.broadcastEntityEffect(this.entity, (byte) 6);
- }
diff --git a/nms-patches/PathfinderGoalTarget.patch b/nms-patches/PathfinderGoalTarget.patch
new file mode 100644
index 00000000..6aade4c9
--- /dev/null
+++ b/nms-patches/PathfinderGoalTarget.patch
@@ -0,0 +1,28 @@
+--- a/net/minecraft/server/PathfinderGoalTarget.java
++++ b/net/minecraft/server/PathfinderGoalTarget.java
+@@ -1,5 +1,7 @@
+ package net.minecraft.server;
+
++import org.bukkit.event.entity.EntityTargetEvent;
++
+ public abstract class PathfinderGoalTarget extends PathfinderGoal {
+
+ protected final EntityCreature e;
+@@ -56,7 +58,7 @@
+ if (entityliving instanceof EntityHuman && ((EntityHuman) entityliving).abilities.isInvulnerable) {
+ return false;
+ } else {
+- this.e.setGoalTarget(entityliving);
++ this.e.setGoalTarget(entityliving, EntityTargetEvent.TargetReason.CLOSEST_ENTITY, true); // CraftBukkit
+ return true;
+ }
+ }
+@@ -77,7 +79,7 @@
+ }
+
+ public void d() {
+- this.e.setGoalTarget((EntityLiving) null);
++ this.e.setGoalTarget((EntityLiving) null, EntityTargetEvent.TargetReason.FORGOT_TARGET, true); // CraftBukkit
+ this.g = null;
+ }
+
diff --git a/nms-patches/PlayerChunk.patch b/nms-patches/PlayerChunk.patch
new file mode 100644
index 00000000..47fee211
--- /dev/null
+++ b/nms-patches/PlayerChunk.patch
@@ -0,0 +1,116 @@
+--- a/net/minecraft/server/PlayerChunk.java
++++ b/net/minecraft/server/PlayerChunk.java
+@@ -4,16 +4,18 @@
+ import com.google.common.collect.Iterables;
+ import com.google.common.collect.Lists;
+ import java.util.ArrayList;
++import java.util.HashMap;
+ import java.util.Iterator;
+ import java.util.List;
+ import org.apache.logging.log4j.LogManager;
+ import org.apache.logging.log4j.Logger;
++import org.bukkit.craftbukkit.chunkio.ChunkIOExecutor;
+
+ public class PlayerChunk {
+
+ private static final Logger a = LogManager.getLogger();
+ private final PlayerChunkMap playerChunkMap;
+- private final List<EntityPlayer> c = Lists.newArrayList();
++ public final List<EntityPlayer> c = Lists.newArrayList(); // CraftBukkit - public
+ private final ChunkCoordIntPair location;
+ private final short[] dirtyBlocks = new short[64];
+ private Chunk chunk;
+@@ -22,17 +24,28 @@
+ private long i;
+ private boolean done;
+
++ // CraftBukkit start - add fields
++ private final HashMap<EntityPlayer, Runnable> players = new HashMap<EntityPlayer, Runnable>();
++ private Runnable loadedRunnable = new Runnable() {
++ public void run() {
++ PlayerChunk.this.chunk = PlayerChunk.this.playerChunkMap.getWorld().getChunkProviderServer().getOrLoadChunkAt(location.x, location.z);
++ }
++ };
++ // CraftBukkit end
++
+ 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
++ this.chunk = playerchunkmap.getWorld().getChunkProviderServer().getChunkAt(i, j, loadedRunnable);
++ // 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 {}, {}", new Object[] { entityplayer, Integer.valueOf(this.location.x), Integer.valueOf(this.location.z)});
+ } else {
+@@ -41,19 +54,50 @@
+ }
+
+ this.c.add(entityplayer);
++ // CraftBukkit start - use async chunk io
++ // if (this.j) {
++ // this.sendChunk(entityplayer);
++ // }
++ Runnable playerRunnable;
+ if (this.done) {
+- this.sendChunk(entityplayer);
++ playerRunnable = null;
++ sendChunk(entityplayer);
++ } else {
++ playerRunnable = new Runnable() {
++ public void run() {
++ sendChunk(entityplayer);
++ }
++ };
++ playerChunkMap.getWorld().getChunkProviderServer().getChunkAt(this.location.x, this.location.z, playerRunnable);
+ }
+
++ this.players.put(entityplayer, playerRunnable);
++ // 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) {
++ ChunkIOExecutor.dropQueuedChunkLoad(this.playerChunkMap.getWorld(), this.location.x, this.location.z, this.players.get(entityplayer));
++ this.c.remove(entityplayer);
++ this.players.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));
+ }
+
++ this.players.remove(entityplayer); // CraftBukkit
+ this.c.remove(entityplayer);
+ if (this.c.isEmpty()) {
+ this.playerChunkMap.b(this);
+@@ -63,8 +107,8 @@
+ }
+
+ public boolean a(boolean flag) {
+- if (this.chunk != null) {
+- return true;
++ if (this.chunk != null || true) { // CraftBukkit
++ return done; // CraftBukkit
+ } else {
+ if (flag) {
+ this.chunk = this.playerChunkMap.getWorld().getChunkProviderServer().getChunkAt(this.location.x, this.location.z);
diff --git a/nms-patches/PlayerChunkMap.patch b/nms-patches/PlayerChunkMap.patch
index 1c9ec1d8..81a15a41 100644
--- a/nms-patches/PlayerChunkMap.patch
+++ b/nms-patches/PlayerChunkMap.patch
@@ -1,86 +1,33 @@
--- a/net/minecraft/server/PlayerChunkMap.java
+++ b/net/minecraft/server/PlayerChunkMap.java
-@@ -7,17 +7,26 @@
- import org.apache.logging.log4j.LogManager;
- import org.apache.logging.log4j.Logger;
+@@ -12,6 +12,10 @@
+ import java.util.List;
+ import java.util.Set;
+// CraftBukkit start
-+import java.util.Collections;
-+import java.util.Queue;
+import java.util.LinkedList;
-+import org.bukkit.craftbukkit.chunkio.ChunkIOExecutor;
-+import java.util.HashMap;
+// CraftBukkit end
+
public class PlayerChunkMap {
- private static final Logger a = LogManager.getLogger();
- private final WorldServer world;
- private final List<EntityPlayer> managedPlayers = Lists.newArrayList();
- private final LongHashMap<PlayerChunkMap.PlayerChunk> d = new LongHashMap();
-- private final List<PlayerChunkMap.PlayerChunk> e = Lists.newArrayList();
-- private final List<PlayerChunkMap.PlayerChunk> f = Lists.newArrayList();
-+ private final Queue<PlayerChunkMap.PlayerChunk> e = new java.util.concurrent.ConcurrentLinkedQueue<PlayerChunkMap.PlayerChunk>(); // CraftBukkit ArrayList -> ConcurrentLinkedQueue
-+ private final Queue<PlayerChunkMap.PlayerChunk> f = new java.util.concurrent.ConcurrentLinkedQueue<PlayerChunkMap.PlayerChunk>(); // CraftBukkit ArrayList -> ConcurrentLinkedQueue
- private int g;
- private long h;
- private final int[][] i = new int[][] { { 1, 0}, { 0, 1}, { -1, 0}, { 0, -1}};
+ private static final Predicate<EntityPlayer> a = new Predicate() {
+@@ -43,6 +47,7 @@
+ private long k;
+ private boolean l = true;
+ private boolean m = true;
+ private boolean wasNotEmpty; // CraftBukkit - add field
public PlayerChunkMap(WorldServer worldserver) {
this.world = worldserver;
-@@ -36,26 +45,37 @@
- if (i - this.h > 8000L) {
- this.h = i;
-
-- for (j = 0; j < this.f.size(); ++j) {
-- playerchunkmap_playerchunk = (PlayerChunkMap.PlayerChunk) this.f.get(j);
-+ // CraftBukkit start - Use iterator
-+ java.util.Iterator iterator = this.f.iterator();
-+ while (iterator.hasNext()) {
-+ playerchunkmap_playerchunk = (PlayerChunk) iterator.next();
- playerchunkmap_playerchunk.b();
- playerchunkmap_playerchunk.a();
- }
- } else {
-- for (j = 0; j < this.e.size(); ++j) {
-- playerchunkmap_playerchunk = (PlayerChunkMap.PlayerChunk) this.e.get(j);
-+ java.util.Iterator iterator = this.e.iterator();
-+ while (iterator.hasNext()) {
-+ playerchunkmap_playerchunk = (PlayerChunk) iterator.next();
- playerchunkmap_playerchunk.b();
-+ iterator.remove();
-+ // CraftBukkit end
- }
- }
-
-- this.e.clear();
-+ // this.e.clear(); //CraftBukkit - Removals are already covered
- if (this.managedPlayers.isEmpty()) {
-+ if (!wasNotEmpty) return; // CraftBukkit - Only do unload when we go from non-empty to empty
- WorldProvider worldprovider = this.world.worldProvider;
-
- if (!worldprovider.e()) {
- this.world.chunkProviderServer.b();
- }
-+ // CraftBukkit start
-+ wasNotEmpty = false;
-+ } else {
-+ wasNotEmpty = true;
- }
-+ // CraftBukkit end
-
- }
-
-@@ -78,6 +98,16 @@
- return playerchunkmap_playerchunk;
+@@ -227,6 +232,16 @@
+ return playerchunk;
}
+ // CraftBukkit start - add method
+ public final boolean isChunkInUse(int x, int z) {
-+ PlayerChunk pi = a(x, z, false);
++ PlayerChunk pi = b(x, z);
+ if (pi != null) {
-+ return (pi.b.size() > 0);
++ return (pi.c.size() > 0);
+ }
+ return false;
+ }
@@ -89,141 +36,63 @@
public void flagDirty(BlockPosition blockposition) {
int i = blockposition.getX() >> 4;
int j = blockposition.getZ() >> 4;
-@@ -96,11 +126,20 @@
+@@ -245,12 +260,22 @@
entityplayer.d = entityplayer.locX;
entityplayer.e = entityplayer.locZ;
++
+ // CraftBukkit start - Load nearby chunks first
+ List<ChunkCoordIntPair> chunkList = new LinkedList<ChunkCoordIntPair>();
+
- for (int k = i - this.g; k <= i + this.g; ++k) {
- for (int l = j - this.g; l <= j + this.g; ++l) {
-- this.a(k, l, true).a(entityplayer);
+ for (int k = i - this.j; k <= i + this.j; ++k) {
+ for (int l = j - this.j; l <= j + this.j; ++l) {
+- this.c(k, l).a(entityplayer);
+ chunkList.add(new ChunkCoordIntPair(k, l));
}
}
-+
+
+ Collections.sort(chunkList, new ChunkCoordComparator(entityplayer));
+ for (ChunkCoordIntPair pair : chunkList) {
-+ this.a(pair.x, pair.z, true).a(entityplayer);
++ this.c(pair.x, pair.z).a(entityplayer);
+ }
+ // CraftBukkit end
-
++
this.managedPlayers.add(entityplayer);
- this.b(entityplayer);
-@@ -188,12 +227,13 @@
- int i1 = this.g;
+ this.e();
+ }
+@@ -294,11 +319,14 @@
int j1 = i - k;
int k1 = j - l;
-+ List<ChunkCoordIntPair> chunksToLoad = new LinkedList<ChunkCoordIntPair>(); // CraftBukkit
++ List<ChunkCoordIntPair> chunksToLoad = new LinkedList<ChunkCoordIntPair>(); // CraftBukkit
++
if (j1 != 0 || k1 != 0) {
for (int l1 = i - i1; l1 <= i + i1; ++l1) {
for (int i2 = j - i1; i2 <= j + i1; ++i2) {
if (!this.a(l1, i2, k, l, i1)) {
-- this.a(l1, i2, true).a(entityplayer);
+- this.c(l1, i2).a(entityplayer);
++ // this.c(l1, i2).a(entityplayer);
+ chunksToLoad.add(new ChunkCoordIntPair(l1, i2)); // CraftBukkit
}
if (!this.a(l1 - j1, i2 - k1, i, j, i1)) {
-@@ -209,6 +249,17 @@
- this.b(entityplayer);
+@@ -314,6 +342,13 @@
entityplayer.d = entityplayer.locX;
entityplayer.e = entityplayer.locZ;
+ this.e();
+
+ // CraftBukkit start - send nearest chunks first
+ Collections.sort(chunksToLoad, new ChunkCoordComparator(entityplayer));
+ for (ChunkCoordIntPair pair : chunksToLoad) {
-+ this.a(pair.x, pair.z, true).a(entityplayer);
-+ }
-+
-+ if (j1 > 1 || j1 < -1 || k1 > 1 || k1 < -1) {
-+ Collections.sort(entityplayer.chunkCoordIntPairQueue, new ChunkCoordComparator(entityplayer));
++ this.c(pair.x, pair.z).a(entityplayer);
+ }
+ // CraftBukkit end
}
}
}
-@@ -271,12 +322,22 @@
- private int f;
- private long g;
-
-+ // CraftBukkit start - add fields
-+ private final HashMap<EntityPlayer, Runnable> players = new HashMap<EntityPlayer, Runnable>();
-+ private boolean loaded = false;
-+ private Runnable loadedRunnable = new Runnable() {
-+ public void run() {
-+ PlayerChunk.this.loaded = true;
-+ }
-+ };
-+ // CraftBukkit end
-+
- public PlayerChunk(int i, int j) {
- this.location = new ChunkCoordIntPair(i, j);
-- PlayerChunkMap.this.a().chunkProviderServer.getChunkAt(i, j);
-+ PlayerChunkMap.this.a().chunkProviderServer.getChunkAt(i, j, loadedRunnable); // CraftBukkit
- }
-
-- public void a(EntityPlayer entityplayer) {
-+ public void a(final EntityPlayer entityplayer) { // CraftBukkit - added final to argument
- if (this.b.contains(entityplayer)) {
- PlayerChunkMap.a.debug("Failed to add player. {} already is in chunk {}, {}", new Object[] { entityplayer, Integer.valueOf(this.location.x), Integer.valueOf(this.location.z)});
- } else {
-@@ -285,18 +346,50 @@
- }
-
- this.b.add(entityplayer);
-- entityplayer.chunkCoordIntPairQueue.add(this.location);
-+ // CraftBukkit start - use async chunk io
-+ Runnable playerRunnable;
-+ if (this.loaded) {
-+ playerRunnable = null;
-+ entityplayer.chunkCoordIntPairQueue.add(this.location);
-+ } else {
-+ playerRunnable = new Runnable() {
-+ public void run() {
-+ entityplayer.chunkCoordIntPairQueue.add(PlayerChunk.this.location);
-+ }
-+ };
-+ PlayerChunkMap.this.a().chunkProviderServer.getChunkAt(this.location.x, this.location.z, playerRunnable);
-+ }
-+
-+ this.players.put(entityplayer, playerRunnable);
-+ // CraftBukkit end
- }
- }
-
- public void b(EntityPlayer entityplayer) {
- if (this.b.contains(entityplayer)) {
-+ // CraftBukkit start - If we haven't loaded yet don't load the chunk just so we can clean it up
-+ if (!this.loaded) {
-+ ChunkIOExecutor.dropQueuedChunkLoad(PlayerChunkMap.this.a(), this.location.x, this.location.z, this.players.get(entityplayer));
-+ this.b.remove(entityplayer);
-+ this.players.remove(entityplayer);
-+
-+ if (this.b.isEmpty()) {
-+ ChunkIOExecutor.dropQueuedChunkLoad(PlayerChunkMap.this.a(), this.location.x, this.location.z, this.loadedRunnable);
-+ long i = (long) this.location.x + 2147483647L | (long) this.location.z + 2147483647L << 32;
-+ PlayerChunkMap.this.d.remove(i);
-+ PlayerChunkMap.this.f.remove(this);
-+ }
-+
-+ return;
-+ }
-+ // CraftBukkit end
- Chunk chunk = PlayerChunkMap.this.world.getChunkAt(this.location.x, this.location.z);
-
- if (chunk.isReady()) {
- entityplayer.playerConnection.sendPacket(new PacketPlayOutMapChunk(chunk, true, 0));
- }
-
-+ this.players.remove(entityplayer); // CraftBukkit
- this.b.remove(entityplayer);
- entityplayer.chunkCoordIntPairQueue.remove(this.location);
- if (this.b.isEmpty()) {
-@@ -421,4 +514,47 @@
-
- }
+@@ -393,4 +428,47 @@
+ this.h.remove(playerchunk);
+ this.getWorld().getChunkProviderServer().queueUnload(chunkcoordintpair.x, chunkcoordintpair.z);
}
+
+ // CraftBukkit start - Sorter to load nearby chunks first
diff --git a/nms-patches/PlayerConnection.patch b/nms-patches/PlayerConnection.patch
index a1f3b528..019ef20b 100644
--- a/nms-patches/PlayerConnection.patch
+++ b/nms-patches/PlayerConnection.patch
@@ -1,14 +1,22 @@
--- a/net/minecraft/server/PlayerConnection.java
+++ b/net/minecraft/server/PlayerConnection.java
-@@ -19,6 +19,49 @@
+@@ -3,7 +3,6 @@
+ import com.google.common.collect.Lists;
+ import com.google.common.primitives.Doubles;
+ import com.google.common.primitives.Floats;
+-import com.google.common.util.concurrent.Futures;
+ import io.netty.buffer.Unpooled;
+ import io.netty.util.concurrent.Future;
+ import io.netty.util.concurrent.GenericFutureListener;
+@@ -18,6 +17,47 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+// CraftBukkit start
++import java.util.HashSet;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
-+import java.util.HashSet;
-+
++import org.bukkit.Location;
+import org.bukkit.craftbukkit.entity.CraftPlayer;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.craftbukkit.inventory.CraftInventoryView;
@@ -16,8 +24,6 @@
+import org.bukkit.craftbukkit.util.CraftChatMessage;
+import org.bukkit.craftbukkit.util.LazyPlayerSet;
+import org.bukkit.craftbukkit.util.Waitable;
-+
-+import org.bukkit.Location;
+import org.bukkit.entity.Player;
+import org.bukkit.event.Event;
+import org.bukkit.event.block.Action;
@@ -32,8 +38,8 @@
+import org.bukkit.event.player.PlayerAnimationEvent;
+import org.bukkit.event.player.PlayerChatEvent;
+import org.bukkit.event.player.PlayerCommandPreprocessEvent;
-+import org.bukkit.event.player.PlayerInteractEntityEvent;
+import org.bukkit.event.player.PlayerInteractAtEntityEvent;
++import org.bukkit.event.player.PlayerInteractEntityEvent;
+import org.bukkit.event.player.PlayerItemHeldEvent;
+import org.bukkit.event.player.PlayerKickEvent;
+import org.bukkit.event.player.PlayerMoveEvent;
@@ -47,30 +53,31 @@
+import org.bukkit.util.NumberConversions;
+// CraftBukkit end
+
- public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerListBox {
+ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
- private static final Logger c = LogManager.getLogger();
-@@ -32,13 +75,17 @@
- private int i;
- private long j;
- private long k;
+ private static final Logger LOGGER = LogManager.getLogger();
+@@ -28,7 +68,10 @@
+ private int f;
+ private long g;
+ private long h;
- private int chatThrottle;
+ // CraftBukkit start - multithreaded fields
+ private volatile int chatThrottle;
+ private static final AtomicIntegerFieldUpdater chatSpamField = AtomicIntegerFieldUpdater.newUpdater(PlayerConnection.class, "chatThrottle");
+ // CraftBukkit end
- private int m;
- private IntHashMap<Short> n = new IntHashMap();
- private double o;
- private double p;
- private double q;
- private boolean checkMovement = true;
-+ private boolean processedDisconnect; // CraftBukkit - added
+ private int j;
+ private final IntHashMap<Short> k = new IntHashMap();
+ private double l;
+@@ -53,6 +96,7 @@
+ private int E;
+ private int F;
+ private int G;
++ private boolean processedDisconnect; // CraftBukkit - Added
public PlayerConnection(MinecraftServer minecraftserver, NetworkManager networkmanager, EntityPlayer entityplayer) {
this.minecraftServer = minecraftserver;
-@@ -46,7 +93,31 @@
- networkmanager.a((PacketListener) this);
+@@ -60,7 +104,32 @@
+ networkmanager.setPacketListener(this);
this.player = entityplayer;
entityplayer.playerConnection = this;
+
@@ -80,6 +87,7 @@
+
+ private final org.bukkit.craftbukkit.CraftServer server;
+ private int lastTick = MinecraftServer.currentTick;
++ private int allowedPlayerTicks = 1;
+ private int lastDropTick = MinecraftServer.currentTick;
+ private int dropCount = 0;
+ private static final int SURVIVAL_PLACE_DISTANCE_SQUARED = 6 * 6;
@@ -100,8 +108,8 @@
+ // CraftBukkit end
public void c() {
- this.h = false;
-@@ -60,15 +131,21 @@
+ this.d();
+@@ -112,15 +181,21 @@
}
this.minecraftServer.methodProfiler.b();
@@ -114,16 +122,16 @@
+ */
+ // CraftBukkit end
- if (this.m > 0) {
- --this.m;
+ if (this.j > 0) {
+ --this.j;
}
- if (this.player.D() > 0L && this.minecraftServer.getIdleTimeout() > 0 && MinecraftServer.az() - this.player.D() > (long) (this.minecraftServer.getIdleTimeout() * 1000 * 60)) {
+ if (this.player.I() > 0L && this.minecraftServer.getIdleTimeout() > 0 && MinecraftServer.av() - this.player.I() > (long) (this.minecraftServer.getIdleTimeout() * 1000 * 60)) {
+ this.player.resetIdleTimer(); // CraftBukkit - SPIGOT-854
this.disconnect("You have been idle for too long!");
}
-@@ -79,19 +156,37 @@
+@@ -140,19 +215,37 @@
}
public void disconnect(String s) {
@@ -145,54 +153,49 @@
+ // CraftBukkit end
final ChatComponentText chatcomponenttext = new ChatComponentText(s);
- this.networkManager.a(new PacketPlayOutKickDisconnect(chatcomponenttext), new GenericFutureListener() {
+ this.networkManager.sendPacket(new PacketPlayOutKickDisconnect(chatcomponenttext), new GenericFutureListener() {
- public void operationComplete(Future<? super Void> future) throws Exception {
-+ public void operationComplete(Future future) throws Exception { // CraftBukkit - fix decompile error
++ 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.k();
+ this.networkManager.stopReading();
- Futures.getUnchecked(this.minecraftServer.postToMainThread(new Runnable() {
-- public void run() {
-- PlayerConnection.this.networkManager.l();
+ // CraftBukkit - Don't wait
+ this.minecraftServer.postToMainThread(new Runnable() {
-+ public void run() {
-+ PlayerConnection.this.networkManager.l();
+ public void run() {
+ PlayerConnection.this.networkManager.handleDisconnection();
}
- }));
+ });
}
public void a(PacketPlayInSteerVehicle packetplayinsteervehicle) {
-@@ -126,8 +221,66 @@
- this.checkMovement = true;
- }
+@@ -229,6 +322,62 @@
+ return;
}
+
+ // CraftBukkit start - fire PlayerMoveEvent
+ Player player = this.getPlayer();
+ Location from = new Location(player.getWorld(), lastPosX, lastPosY, lastPosZ, lastYaw, lastPitch); // Get the Players previous Event location.
+ Location to = player.getLocation().clone(); // Start off the To location as the Players current location.
+
+ // If the packet contains movement information then we update the To location with the correct XYZ.
-+ if (packetplayinflying.hasPos && !(packetplayinflying.hasPos && packetplayinflying.y == -999.0D)) {
-+ to.setX(packetplayinflying.x);
-+ to.setY(packetplayinflying.y);
-+ to.setZ(packetplayinflying.z);
-+ }
++ to.setX(packetplayinvehiclemove.getX());
++ to.setY(packetplayinvehiclemove.getY());
++ to.setZ(packetplayinvehiclemove.getZ());
++
+
+ // If the packet contains look information then we update the To location with the correct Yaw & Pitch.
-+ if (packetplayinflying.hasLook) {
-+ to.setYaw(packetplayinflying.yaw);
-+ to.setPitch(packetplayinflying.pitch);
-+ }
++ to.setYaw(packetplayinvehiclemove.getYaw());
++ to.setPitch(packetplayinvehiclemove.getPitch());
+
+ // Prevent 40 event-calls for less than a single pixel of movement >.>
+ double delta = Math.pow(this.lastPosX - to.getX(), 2) + Math.pow(this.lastPosY - to.getY(), 2) + Math.pow(this.lastPosZ - to.getZ(), 2);
+ float deltaAngle = Math.abs(this.lastYaw - to.getYaw()) + Math.abs(this.lastPitch - to.getPitch());
+
-+ if ((delta > 1f / 256 || deltaAngle > 10f) && (this.checkMovement && !this.player.dead)) {
++ if ((delta > 1f / 256 || deltaAngle > 10f) && !this.player.dead) {
+ this.lastPosX = to.getX();
+ this.lastPosY = to.getY();
+ this.lastPosZ = to.getZ();
@@ -207,75 +210,159 @@
+
+ // If the event is cancelled we move the player back to their old location.
+ if (event.isCancelled()) {
-+ this.player.playerConnection.sendPacket(new PacketPlayOutPosition(from.getX(), from.getY(), from.getZ(), from.getYaw(), from.getPitch(), Collections.<PacketPlayOutPosition.EnumPlayerTeleportFlags>emptySet()));
++ this.player.playerConnection.sendPacket(new PacketPlayOutPosition(from.getX(), from.getY(), from.getZ(), from.getYaw(), from.getPitch(), Collections.<PacketPlayOutPosition.EnumPlayerTeleportFlags>emptySet(), this.teleportAwait));
+ return;
+ }
-
-- if (this.checkMovement) {
-+ /* If a Plugin has changed the To destination then we teleport the Player
-+ there to avoid any 'Moved wrongly' or 'Moved too quickly' errors.
-+ We only do this if the Event was not cancelled. */
++
++ // If a Plugin has changed the To destination then we teleport the Player
++ // there to avoid any 'Moved wrongly' or 'Moved too quickly' errors.
++ // We only do this if the Event was not cancelled.
+ if (!oldTo.equals(event.getTo()) && !event.isCancelled()) {
+ this.player.getBukkitEntity().teleport(event.getTo(), PlayerTeleportEvent.TeleportCause.UNKNOWN);
+ return;
+ }
+
-+ /* Check to see if the Players Location has some how changed during the call of the event.
-+ This can happen due to a plugin teleporting the player instead of using .setTo() */
++ // Check to see if the Players Location has some how changed during the call of the event.
++ // This can happen due to a plugin teleporting the player instead of using .setTo()
+ if (!from.equals(this.getPlayer().getLocation()) && this.justTeleported) {
+ this.justTeleported = false;
+ return;
+ }
+ }
+ }
++ // CraftBukkit end
+
-+ if (this.checkMovement && !this.player.dead) {
-+ // CraftBukkit end
- this.f = this.e;
- double d7;
- double d8;
-@@ -155,6 +308,7 @@
-
+ this.minecraftServer.getPlayerList().d(this.player);
+ this.player.checkMovement(this.player.locX - d0, this.player.locY - d1, this.player.locZ - d2);
+ this.D = d11 >= -0.03125D && !this.minecraftServer.getAllowFlight() && !worldserver.d(entity.getBoundingBox().g(0.0625D).a(0.0D, -0.55D, 0.0D));
+@@ -273,12 +422,13 @@
+ this.A = this.e;
+ this.a(this.teleportPos.x, this.teleportPos.y, this.teleportPos.z, this.player.yaw, this.player.pitch);
+ }
+-
++ this.allowedPlayerTicks = 20; // CraftBukkit
+ } else {
+ this.A = this.e;
+ if (this.player.isPassenger()) {
+ this.player.setLocation(this.player.locX, this.player.locY, this.player.locZ, packetplayinflying.a(this.player.yaw), packetplayinflying.b(this.player.pitch));
this.minecraftServer.getPlayerList().d(this.player);
- if (this.player.vehicle != null) {
-+ this.player.vehicle.ai = true; // CraftBukkit - moved from below
- if (d3 > 4.0D) {
- Entity entity = this.player.vehicle;
++ this.allowedPlayerTicks = 20; // CraftBukkit
+ } else {
+ double d0 = this.player.locX;
+ double d1 = this.player.locY;
+@@ -298,15 +448,32 @@
+ ++this.F;
+ int i = this.F - this.G;
+
+- if (i > 5) {
++ // CraftBukkit start - handle custom speeds and skipped ticks
++ this.allowedPlayerTicks += (System.currentTimeMillis() / 50) - this.lastTick;
++ this.allowedPlayerTicks = Math.max(this.allowedPlayerTicks, 1);
++ this.lastTick = (int) (System.currentTimeMillis() / 50);
++
++ if (i > Math.max(this.allowedPlayerTicks, 5)) {
+ PlayerConnection.LOGGER.debug(this.player.getName() + " is sending move packets too frequently (" + i + " packets since last tick)");
+ i = 1;
+ }
-@@ -162,7 +316,7 @@
++ if (packetplayinflying.hasLook || d11 > 0) {
++ allowedPlayerTicks -= 1;
++ } else {
++ allowedPlayerTicks = 20;
++ }
++ float speed;
++ if (player.abilities.isFlying) {
++ speed = player.abilities.flySpeed * 20f;
++ } else {
++ speed = player.abilities.walkSpeed * 10f;
++ }
++
+ if (!this.player.K() && (!this.player.x().getGameRules().getBoolean("disableElytraMovementCheck") || !this.player.cB())) {
+ float f2 = this.player.cB() ? 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.pow((double) (10.0F * (float) i * speed), 2) && (!this.minecraftServer.R() || !this.minecraftServer.Q().equals(this.player.getName()))) {
+ PlayerConnection.LOGGER.warn(this.player.getName() + " moved too quickly! " + d7 + "," + d8 + "," + d9);
this.a(this.player.locX, this.player.locY, this.player.locZ, this.player.yaw, this.player.pitch);
+ return;
+@@ -352,6 +519,65 @@
}
-
-- this.player.vehicle.ai = true;
-+ // this.player.vehicle.ai = true; // CraftBukkit - moved up
}
- if (this.checkMovement) {
-@@ -224,7 +378,7 @@
- double d14 = this.player.motX * this.player.motX + this.player.motY * this.player.motY + this.player.motZ * this.player.motZ;
- double d15 = d11 * d11 + d12 * d12 + d13 * d13;
-
-- if (d15 - d14 > 100.0D && (!this.minecraftServer.T() || !this.minecraftServer.S().equals(this.player.getName()))) {
-+ if (d15 - d14 > 100.0D && this.checkMovement && (!this.minecraftServer.T() || !this.minecraftServer.S().equals(this.player.getName()))) { // CraftBukkit - Added this.checkMovement condition to solve this check being triggered by teleports
- PlayerConnection.c.warn(this.player.getName() + " moved too quickly! " + d11 + "," + d12 + "," + d13 + " (" + d11 + ", " + d12 + ", " + d13 + ")");
- this.a(this.o, this.p, this.q, this.player.yaw, this.player.pitch);
- return;
-@@ -288,16 +442,73 @@
- } else if (this.e - this.f > 20) {
- this.a(this.o, this.p, this.q, this.player.yaw, this.player.pitch);
- }
--
- }
++ // CraftBukkit start - fire PlayerMoveEvent
++ Player player = this.getPlayer();
++ Location from = new Location(player.getWorld(), lastPosX, lastPosY, lastPosZ, lastYaw, lastPitch); // Get the Players previous Event location.
++ Location to = player.getLocation().clone(); // Start off the To location as the Players current location.
+
- }
++ // If the packet contains movement information then we update the To location with the correct XYZ.
++ if (packetplayinflying.hasPos) {
++ to.setX(packetplayinflying.x);
++ to.setY(packetplayinflying.y);
++ to.setZ(packetplayinflying.z);
++ }
++
++ // If the packet contains look information then we update the To location with the correct Yaw & Pitch.
++ if (packetplayinflying.hasLook) {
++ to.setYaw(packetplayinflying.yaw);
++ to.setPitch(packetplayinflying.pitch);
++ }
++
++ // Prevent 40 event-calls for less than a single pixel of movement >.>
++ double delta = Math.pow(this.lastPosX - to.getX(), 2) + Math.pow(this.lastPosY - to.getY(), 2) + Math.pow(this.lastPosZ - to.getZ(), 2);
++ float deltaAngle = Math.abs(this.lastYaw - to.getYaw()) + Math.abs(this.lastPitch - to.getPitch());
++
++ if ((delta > 1f / 256 || deltaAngle > 10f) && !this.player.dead) {
++ this.lastPosX = to.getX();
++ this.lastPosY = to.getY();
++ this.lastPosZ = to.getZ();
++ this.lastYaw = to.getYaw();
++ this.lastPitch = to.getPitch();
++
++ // Skip the first time we do this
++ if (from.getX() != Double.MAX_VALUE) {
++ Location oldTo = to.clone();
++ PlayerMoveEvent event = new PlayerMoveEvent(player, from, to);
++ this.server.getPluginManager().callEvent(event);
++
++ // If the event is cancelled we move the player back to their old location.
++ if (event.isCancelled()) {
++ this.player.playerConnection.sendPacket(new PacketPlayOutPosition(from.getX(), from.getY(), from.getZ(), from.getYaw(), from.getPitch(), Collections.<PacketPlayOutPosition.EnumPlayerTeleportFlags>emptySet(), this.teleportAwait));
++ return;
++ }
++
++ // If a Plugin has changed the To destination then we teleport the Player
++ // there to avoid any 'Moved wrongly' or 'Moved too quickly' errors.
++ // We only do this if the Event was not cancelled.
++ if (!oldTo.equals(event.getTo()) && !event.isCancelled()) {
++ this.player.getBukkitEntity().teleport(event.getTo(), PlayerTeleportEvent.TeleportCause.UNKNOWN);
++ return;
++ }
++
++ // Check to see if the Players Location has some how changed during the call of the event.
++ // This can happen due to a plugin teleporting the player instead of using .setTo()
++ if (!from.equals(this.getPlayer().getLocation()) && this.justTeleported) {
++ this.justTeleported = false;
++ return;
++ }
++ }
++ }
++ // CraftBukkit end
++
+ this.B = d12 >= -0.03125D;
+ this.B &= !this.minecraftServer.getAllowFlight() && !this.player.abilities.canFly;
+ this.B &= !this.player.hasEffect(MobEffects.LEVITATION) && !this.player.cB() && !worldserver.d(this.player.getBoundingBox().g(0.0625D).a(0.0D, -0.55D, 0.0D));
+@@ -368,15 +594,79 @@
}
public void a(double d0, double d1, double d2, float f, float f1) {
- this.a(d0, d1, d2, f, f1, Collections.emptySet());
-+ this.a(d0, d1, d2, f, f1, Collections.<PacketPlayOutPosition.EnumPlayerTeleportFlags>emptySet()); // CraftBukkit fix decompile errors
++ this.a(d0, d1, d2, f, f1, Collections.<PacketPlayOutPosition.EnumPlayerTeleportFlags>emptySet());
}
public void a(double d0, double d1, double d2, float f, float f1, Set<PacketPlayOutPosition.EnumPlayerTeleportFlags> set) {
+- double d3 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.X) ? this.player.locX : 0.0D;
+- double d4 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.Y) ? this.player.locY : 0.0D;
+- double d5 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.Z) ? this.player.locZ : 0.0D;
+ // CraftBukkit start - Delegate to teleport(Location)
+ Player player = this.getPlayer();
+ Location from = player.getLocation();
@@ -318,7 +405,8 @@
+
+ this.internalTeleport(d0, d1, d2, f, f1, set);
+ }
-+
+
+- this.teleportPos = new Vec3D(d0 + d3, d1 + d4, d2 + d5);
+ public void teleport(Location dest) {
+ internalTeleport(dest.getX(), dest.getY(), dest.getZ(), dest.getYaw(), dest.getPitch(), Collections.emptySet());
+ }
@@ -332,33 +420,48 @@
+ f1 = 0;
+ }
+ this.justTeleported = true;
++ this.teleportPos = new Vec3D(d0, d1, d2);
++ if (set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.X)) {
++ this.teleportPos = this.teleportPos.add(this.player.locX, 0.0D, 0.0D);
++ }
++
++ if (set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.Y)) {
++ this.teleportPos = this.teleportPos.add(0.0D, this.player.locY, 0.0D);
++ }
++
++ if (set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.Z)) {
++ this.teleportPos = this.teleportPos.add(0.0D, 0.0D, this.player.locZ);
++ }
+ // CraftBukkit end
- this.checkMovement = false;
- this.o = d0;
- this.p = d1;
-@@ -325,38 +536,63 @@
+ float f2 = f;
+ float f3 = f1;
+
+@@ -388,6 +678,14 @@
f3 = f1 + this.player.pitch;
}
+ // CraftBukkit start - update last location
-+ this.lastPosX = this.o;
-+ this.lastPosY = this.p;
-+ this.lastPosZ = this.q;
++ this.lastPosX = this.teleportPos.x;
++ this.lastPosY = this.teleportPos.y;
++ this.lastPosZ = this.teleportPos.z;
+ this.lastYaw = f2;
+ this.lastPitch = f3;
+ // CraftBukkit end
+
- this.player.setLocation(this.o, this.p, this.q, f2, f3);
- this.player.playerConnection.sendPacket(new PacketPlayOutPosition(d0, d1, d2, f, f1, set));
- }
+ if (++this.teleportAwait == Integer.MAX_VALUE) {
+ this.teleportAwait = 0;
+ }
+@@ -399,15 +697,32 @@
public void a(PacketPlayInBlockDig packetplayinblockdig) {
- PlayerConnectionUtils.ensureMainThread(packetplayinblockdig, this, this.player.u());
+ PlayerConnectionUtils.ensureMainThread(packetplayinblockdig, this, this.player.x());
+ if (this.player.dead) return; // CraftBukkit
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
BlockPosition blockposition = packetplayinblockdig.a();
this.player.resetIdleTimer();
+ ItemStack itemstack;
+
+ // CraftBukkit start
switch (PlayerConnection.SyntheticClass_1.a[packetplayinblockdig.c().ordinal()]) {
- case 1:
@@ -373,40 +476,52 @@
+ // Else we increment the drop count and check the amount.
+ this.dropCount++;
+ if (this.dropCount >= 20) {
-+ this.c.warn(this.player.getName() + " dropped their items too quickly!");
++ this.LOGGER.warn(this.player.getName() + " dropped their items too quickly!");
+ this.disconnect("You dropped your items too quickly (Hacking?)");
+ return;
+ }
+ }
+ // CraftBukkit end
- this.player.a(false);
- }
+ itemstack = this.player.b(EnumHand.OFF_HAND);
+ this.player.a(EnumHand.OFF_HAND, this.player.b(EnumHand.MAIN_HAND));
+ this.player.a(EnumHand.MAIN_HAND, itemstack);
+@@ -415,21 +730,21 @@
return;
- case 2:
+ case 2: // DROP_ALL_ITEMS
if (!this.player.isSpectator()) {
- this.player.a(true);
+ this.player.a(false);
}
return;
- case 3:
+ case 3: // RELEASE_USE_ITEM
- this.player.bU();
+ if (!this.player.isSpectator()) {
+ this.player.a(true);
+ }
+
return;
- case 4:
++ case 4: // START_DESTROY_BLOCK
+ this.player.clearActiveItem();
+ itemstack = this.player.getItemInMainHand();
+ if (itemstack != null && itemstack.count == 0) {
+@@ -438,8 +753,8 @@
+
+ return;
+
- case 5:
- case 6:
-+ case 4: // START_DESTROY_BLOCK
+ case 5: // ABORT_DESTROY_BLOCK
+ case 6: // STOP_DESTROY_BLOCK
+ case 7:
double d0 = this.player.locX - ((double) blockposition.getX() + 0.5D);
double d1 = this.player.locY - ((double) blockposition.getY() + 0.5D) + 1.5D;
- double d2 = this.player.locZ - ((double) blockposition.getZ() + 0.5D);
-@@ -371,7 +607,15 @@
+@@ -455,7 +770,15 @@
if (!this.minecraftServer.a(worldserver, blockposition, this.player) && worldserver.getWorldBorder().a(blockposition)) {
this.player.playerInteractManager.a(blockposition, packetplayinblockdig.b());
} else {
@@ -422,37 +537,50 @@
}
} else {
if (packetplayinblockdig.c() == PacketPlayInBlockDig.EnumPlayerDigType.STOP_DESTROY_BLOCK) {
-@@ -391,11 +635,22 @@
+@@ -475,10 +798,12 @@
default:
throw new IllegalArgumentException("Invalid player action");
}
+ // CraftBukkit end
}
+ public void a(PacketPlayInUseItem packetplayinuseitem) {
+ PlayerConnectionUtils.ensureMainThread(packetplayinuseitem, this, this.player.x());
++ if (this.player.dead) return; // CraftBukkit
+ WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
+ EnumHand enumhand = packetplayinuseitem.c();
+ ItemStack itemstack = this.player.b(enumhand);
+@@ -492,6 +817,13 @@
+ chatmessage.getChatModifier().setColor(EnumChatFormat.RED);
+ this.player.playerConnection.sendPacket(new PacketPlayOutChat(chatmessage));
+ } else if (this.teleportPos == null && this.player.e((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) < 64.0D && !this.minecraftServer.a(worldserver, blockposition, this.player) && worldserver.getWorldBorder().a(blockposition)) {
++ // CraftBukkit start - Check if we can actually do something over this large a distance
++ Location eyeLoc = this.getPlayer().getEyeLocation();
++ double reachDistance = NumberConversions.square(eyeLoc.getX() - blockposition.getX()) + NumberConversions.square(eyeLoc.getY() - blockposition.getY()) + NumberConversions.square(eyeLoc.getZ() - blockposition.getZ());
++ if (reachDistance > (this.getPlayer().getGameMode() == org.bukkit.GameMode.CREATIVE ? CREATIVE_PLACE_DISTANCE_SQUARED : SURVIVAL_PLACE_DISTANCE_SQUARED)) {
++ return;
++ }
++ // CraftBukkit end
+ this.player.playerInteractManager.a(this.player, worldserver, itemstack, enumhand, blockposition, enumdirection, packetplayinuseitem.d(), packetplayinuseitem.e(), packetplayinuseitem.f());
+ }
+
+@@ -507,19 +839,55 @@
+
public void a(PacketPlayInBlockPlace packetplayinblockplace) {
- PlayerConnectionUtils.ensureMainThread(packetplayinblockplace, this, this.player.u());
+ PlayerConnectionUtils.ensureMainThread(packetplayinblockplace, this, this.player.x());
++ if (this.player.dead) return; // CraftBukkit
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
-+
-+ // CraftBukkit start
-+ if (this.player.dead) return;
-+
-+ // CraftBukkit - if rightclick decremented the item, always send the update packet. */
-+ // this is not here for CraftBukkit's own functionality; rather it is to fix
-+ // a notch bug where the item doesn't update correctly.
-+ boolean always = false;
-+ // CraftBukkit end
-+
- ItemStack itemstack = this.player.inventory.getItemInHand();
- boolean flag = false;
- BlockPosition blockposition = packetplayinblockplace.a();
-@@ -407,7 +662,50 @@
- return;
- }
+ EnumHand enumhand = packetplayinblockplace.a();
+ ItemStack itemstack = this.player.b(enumhand);
-- this.player.playerInteractManager.useItem(this.player, worldserver, itemstack);
+ this.player.resetIdleTimer();
+ if (itemstack != null) {
+- this.player.playerInteractManager.a(this.player, worldserver, itemstack, enumhand);
+- itemstack = this.player.b(enumhand);
+- if (itemstack != null && itemstack.count == 0) {
+- this.player.a(enumhand, (ItemStack) null);
+- itemstack = null;
+ // CraftBukkit start
-+ int itemstackAmount = itemstack.count;
-+
+ // Raytrace to look for 'rogue armswings'
+ float f1 = this.player.pitch;
+ float f2 = this.player.yaw;
@@ -483,52 +611,21 @@
+ org.bukkit.event.player.PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(player, Action.RIGHT_CLICK_BLOCK, movingobjectposition.a(), movingobjectposition.direction, itemstack, true);
+ cancelled = event.useItemInHand() == Event.Result.DENY;
+ }
-+ }
-+
+ }
+
+ if (!cancelled) {
-+ this.player.playerInteractManager.useItem(this.player, this.player.world, itemstack);
++ this.player.playerInteractManager.a(this.player, worldserver, itemstack, enumhand);
++ itemstack = this.player.b(enumhand);
++ if (itemstack != null && itemstack.count == 0) {
++ this.player.a(enumhand, (ItemStack) null);
++ itemstack = null;
++ }
+ }
-+
-+ // CraftBukkit - notch decrements the counter by 1 in the above method with food,
-+ // snowballs and so forth, but he does it in a place that doesn't cause the
-+ // inventory update packet to get sent
-+ always = (itemstack.count != itemstackAmount) || itemstack.getItem() == Item.getItemOf(Blocks.WATERLILY);
+ // CraftBukkit end
- } else if (blockposition.getY() >= this.minecraftServer.getMaxBuildHeight() - 1 && (enumdirection == EnumDirection.UP || blockposition.getY() >= this.minecraftServer.getMaxBuildHeight())) {
- ChatMessage chatmessage = new ChatMessage("build.tooHigh", new Object[] { Integer.valueOf(this.minecraftServer.getMaxBuildHeight())});
-
-@@ -415,8 +713,19 @@
- this.player.playerConnection.sendPacket(new PacketPlayOutChat(chatmessage));
- flag = true;
- } else {
-+ // CraftBukkit start - Check if we can actually do something over this large a distance
-+ Location eyeLoc = this.getPlayer().getEyeLocation();
-+ double reachDistance = NumberConversions.square(eyeLoc.getX() - blockposition.getX()) + NumberConversions.square(eyeLoc.getY() - blockposition.getY()) + NumberConversions.square(eyeLoc.getZ() - blockposition.getZ());
-+ if (reachDistance > (this.getPlayer().getGameMode() == org.bukkit.GameMode.CREATIVE ? CREATIVE_PLACE_DISTANCE_SQUARED : SURVIVAL_PLACE_DISTANCE_SQUARED)) {
-+ return;
-+ }
-+
-+ if (!worldserver.getWorldBorder().a(blockposition)) {
-+ return;
-+ }
-+
- if (this.checkMovement && this.player.e((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) < 64.0D && !this.minecraftServer.a(worldserver, blockposition, this.player) && worldserver.getWorldBorder().a(blockposition)) {
-- this.player.playerInteractManager.interact(this.player, worldserver, itemstack, blockposition, enumdirection, packetplayinblockplace.d(), packetplayinblockplace.e(), packetplayinblockplace.f());
-+ always = !this.player.playerInteractManager.interact(this.player, worldserver, itemstack, blockposition, enumdirection, packetplayinblockplace.d(), packetplayinblockplace.e(), packetplayinblockplace.f());
- }
-
- flag = true;
-@@ -440,7 +749,8 @@
-
- this.player.activeContainer.b();
- this.player.g = false;
-- if (!ItemStack.matches(this.player.inventory.getItemInHand(), packetplayinblockplace.getItemStack())) {
-+ // CraftBukkit - TODO CHECK IF NEEDED -- new if structure might not need 'always'. Kept it in for now, but may be able to remove in future
-+ if (!ItemStack.matches(this.player.inventory.getItemInHand(), packetplayinblockplace.getItemStack()) || always) {
- this.sendPacket(new PacketPlayOutSetSlot(this.player.activeContainer.windowId, slot.rawSlotIndex, this.player.inventory.getItemInHand()));
- }
}
-@@ -454,8 +764,8 @@
+ }
+
+@@ -530,8 +898,8 @@
WorldServer[] aworldserver = this.minecraftServer.worldServer;
int i = aworldserver.length;
@@ -539,16 +636,16 @@
if (worldserver != null) {
entity = packetplayinspectate.a(worldserver);
-@@ -468,6 +778,8 @@
+@@ -544,6 +912,8 @@
if (entity != null) {
this.player.setSpectatorTarget(this.player);
- this.player.mount((Entity) null);
+ this.player.stopRiding();
+
+ /* CraftBukkit start - replace with bukkit handling for multi-world
if (entity.world != this.player.world) {
- WorldServer worldserver1 = this.player.u();
+ WorldServer worldserver1 = this.player.x();
WorldServer worldserver2 = (WorldServer) entity.world;
-@@ -492,22 +804,44 @@
+@@ -569,12 +939,19 @@
} else {
this.player.enderTeleportTo(entity.locX, entity.locY, entity.locZ);
}
@@ -563,12 +660,17 @@
- public void a(PacketPlayInResourcePackStatus packetplayinresourcepackstatus) {}
+ // CraftBukkit start
+ public void a(PacketPlayInResourcePackStatus packetplayinresourcepackstatus) {
-+ this.server.getPluginManager().callEvent(new PlayerResourcePackStatusEvent(getPlayer(), PlayerResourcePackStatusEvent.Status.values()[packetplayinresourcepackstatus.b.ordinal()]));
++ 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());
+@@ -587,14 +964,29 @@
+ }
+
public void a(IChatBaseComponent ichatbasecomponent) {
-- PlayerConnection.c.info(this.player.getName() + " lost connection: " + ichatbasecomponent);
+- PlayerConnection.LOGGER.info(this.player.getName() + " lost connection: " + ichatbasecomponent);
+ // CraftBukkit start - Rarely it would send a disconnect line twice
+ if (this.processedDisconnect) {
+ return;
@@ -576,27 +678,27 @@
+ this.processedDisconnect = true;
+ }
+ // CraftBukkit end
-+ PlayerConnection.c.info(this.player.getName() + " lost connection: " + ichatbasecomponent.c()); // CraftBukkit: Don't toString(). // PAIL: Rename
++ PlayerConnection.LOGGER.info(this.player.getName() + " lost connection: " + ichatbasecomponent.toPlainText()); // CraftBukkit: Don't toString().
+ // CraftBukkit start - Replace vanilla quit message handling with our own.
+ /*
- this.minecraftServer.aH();
+ this.minecraftServer.aC();
ChatMessage chatmessage = new ChatMessage("multiplayer.player.left", new Object[] { this.player.getScoreboardDisplayName()});
chatmessage.getChatModifier().setColor(EnumChatFormat.YELLOW);
this.minecraftServer.getPlayerList().sendMessage(chatmessage);
+ */
+
- this.player.q();
+ this.player.t();
- 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.T() && this.player.getName().equals(this.minecraftServer.S())) {
- PlayerConnection.c.info("Stopping singleplayer server as player logged out");
+ if (this.minecraftServer.R() && this.player.getName().equals(this.minecraftServer.Q())) {
+ PlayerConnection.LOGGER.info("Stopping singleplayer server as player logged out");
this.minecraftServer.safeShutdown();
-@@ -529,6 +863,15 @@
+@@ -616,6 +1008,15 @@
}
}
@@ -610,15 +712,13 @@
+ // CraftBukkit end
+
try {
- this.networkManager.handle(packet);
+ this.networkManager.sendPacket(packet);
} catch (Throwable throwable) {
-@@ -549,18 +892,34 @@
- }
+@@ -637,17 +1038,32 @@
public void a(PacketPlayInHeldItemSlot packetplayinhelditemslot) {
-+ // CraftBukkit start
-+ if (this.player.dead) return;
- PlayerConnectionUtils.ensureMainThread(packetplayinhelditemslot, this, this.player.u());
+ PlayerConnectionUtils.ensureMainThread(packetplayinhelditemslot, this, this.player.x());
++ if (this.player.dead) return; // CraftBukkit
if (packetplayinhelditemslot.a() >= 0 && packetplayinhelditemslot.a() < PlayerInventory.getHotbarSize()) {
+ PlayerItemHeldEvent event = new PlayerItemHeldEvent(this.getPlayer(), this.player.inventory.itemInHandIndex, packetplayinhelditemslot.a());
+ this.server.getPluginManager().callEvent(event);
@@ -631,25 +731,25 @@
this.player.inventory.itemInHandIndex = packetplayinhelditemslot.a();
this.player.resetIdleTimer();
} else {
- PlayerConnection.c.warn(this.player.getName() + " tried to set an invalid carried item");
+ PlayerConnection.LOGGER.warn(this.player.getName() + " tried to set an invalid carried item");
+ this.disconnect("Nope!"); // CraftBukkit
}
}
public void a(PacketPlayInChat packetplayinchat) {
-- PlayerConnectionUtils.ensureMainThread(packetplayinchat, this, this.player.u());
+- PlayerConnectionUtils.ensureMainThread(packetplayinchat, this, this.player.x());
- if (this.player.getChatFlags() == EntityHuman.EnumChatVisibility.HIDDEN) {
+ // CraftBukkit start - async chat
+ boolean isSync = packetplayinchat.a().startsWith("/");
+ if (packetplayinchat.a().startsWith("/")) {
-+ PlayerConnectionUtils.ensureMainThread(packetplayinchat, this, this.player.u());
++ PlayerConnectionUtils.ensureMainThread(packetplayinchat, this, this.player.x());
+ }
+ // 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);
-@@ -573,39 +932,249 @@
+@@ -660,39 +1076,249 @@
for (int i = 0; i < s.length(); ++i) {
if (!SharedConstants.isAllowedChatCharacter(s.charAt(i))) {
@@ -692,7 +792,7 @@
+ this.minecraftServer.server.playerCommandState = false;
+ }
+ } else if (s.isEmpty()) {
-+ c.warn(this.player.getName() + " tried to send an empty message");
++ LOGGER.warn(this.player.getName() + " tried to send an empty message");
+ } else if (getPlayer().isConversing()) {
+ getPlayer().acceptConversationInput(s);
+ } else if (this.player.getChatFlags() == EntityHuman.EnumChatVisibility.SYSTEM) { // Re-add "Command Only" flag check
@@ -756,7 +856,7 @@
+ // Do nothing, this is coming from a plugin
+ } else {
+ Player player = this.getPlayer();
-+ AsyncPlayerChatEvent event = new AsyncPlayerChatEvent(async, player, s, new LazyPlayerSet());
++ AsyncPlayerChatEvent event = new AsyncPlayerChatEvent(async, player, s, new LazyPlayerSet(minecraftServer));
+ this.server.getPluginManager().callEvent(event);
+
+ if (PlayerChatEvent.getHandlerList().getRegisteredListeners().length != 0) {
@@ -820,11 +920,11 @@
+
+ private void handleCommand(String s) {
+ // CraftBukkit start - whole method
-+ this.c.info(this.player.getName() + " issued server command: " + s);
++ this.LOGGER.info(this.player.getName() + " issued server command: " + s);
+
+ CraftPlayer player = this.getPlayer();
+
-+ PlayerCommandPreprocessEvent event = new PlayerCommandPreprocessEvent(player, s, new LazyPlayerSet());
++ PlayerCommandPreprocessEvent event = new PlayerCommandPreprocessEvent(player, s, new LazyPlayerSet(minecraftServer));
+ this.server.getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
@@ -845,8 +945,8 @@
}
public void a(PacketPlayInArmAnimation packetplayinarmanimation) {
+ PlayerConnectionUtils.ensureMainThread(packetplayinarmanimation, this, this.player.x());
+ if (this.player.dead) return; // CraftBukkit
- PlayerConnectionUtils.ensureMainThread(packetplayinarmanimation, this, this.player.u());
this.player.resetIdleTimer();
+ // CraftBukkit start - Raytrace to look for 'rogue armswings'
+ float f1 = this.player.pitch;
@@ -876,11 +976,11 @@
+
+ if (event.isCancelled()) return;
+ // CraftBukkit end
- this.player.bw();
+ this.player.a(packetplayinarmanimation.a());
}
public void a(PacketPlayInEntityAction packetplayinentityaction) {
- PlayerConnectionUtils.ensureMainThread(packetplayinentityaction, this, this.player.u());
+ PlayerConnectionUtils.ensureMainThread(packetplayinentityaction, this, this.player.x());
+ // CraftBukkit start
+ if (this.player.dead) return;
+ switch (packetplayinentityaction.b()) {
@@ -905,30 +1005,21 @@
+ }
+ // CraftBukkit end
this.player.resetIdleTimer();
- switch (PlayerConnection.SyntheticClass_1.b[packetplayinentityaction.b().ordinal()]) {
- case 1:
-@@ -626,7 +1195,7 @@
+ IJumpable ijumpable;
- case 5:
- this.player.a(false, true, true);
-- this.checkMovement = false;
-+ // this.checkMovement = false; // CraftBukkit - this is handled in teleport
- break;
-
- case 6:
-@@ -648,6 +1217,7 @@
- }
+@@ -762,6 +1388,7 @@
public void a(PacketPlayInUseEntity packetplayinuseentity) {
+ PlayerConnectionUtils.ensureMainThread(packetplayinuseentity, this, this.player.x());
+ if (this.player.dead) return; // CraftBukkit
- PlayerConnectionUtils.ensureMainThread(packetplayinuseentity, this, this.player.u());
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
Entity entity = packetplayinuseentity.a((World) worldserver);
-@@ -662,18 +1232,67 @@
- }
- if (this.player.h(entity) < d0) {
-+ ItemStack itemInHand = this.player.inventory.getItemInHand(); // CraftBukkit
+@@ -778,22 +1405,72 @@
+ EnumHand enumhand;
+ ItemStack itemstack;
+
++ ItemStack itemInHand = this.player.b(packetplayinuseentity.b() == null ? EnumHand.MAIN_HAND : packetplayinuseentity.b()); // CraftBukkit
+
+ if (packetplayinuseentity.a() == PacketPlayInUseEntity.EnumEntityUseAction.INTERACT
+ || packetplayinuseentity.a() == PacketPlayInUseEntity.EnumEntityUseAction.INTERACT_AT) {
@@ -939,14 +1030,14 @@
+ if (packetplayinuseentity.a() == PacketPlayInUseEntity.EnumEntityUseAction.INTERACT) {
+ event = new PlayerInteractEntityEvent((Player) this.getPlayer(), entity.getBukkitEntity());
+ } else {
-+ Vec3D target = packetplayinuseentity.b();
-+ event = new PlayerInteractAtEntityEvent((Player) this.getPlayer(), entity.getBukkitEntity(), new org.bukkit.util.Vector(target.a, target.b, target.c));
++ Vec3D target = packetplayinuseentity.c();
++ event = new PlayerInteractAtEntityEvent((Player) this.getPlayer(), entity.getBukkitEntity(), new org.bukkit.util.Vector(target.x, target.y, target.z));
+ }
+ this.server.getPluginManager().callEvent(event);
+
+ if (triggerLeashUpdate && (event.isCancelled() || this.player.inventory.getItemInHand() == null || this.player.inventory.getItemInHand().getItem() != Items.LEAD)) {
+ // Refresh the current leash state
-+ this.sendPacket(new PacketPlayOutAttachEntity(1, entity, ((EntityInsentient) entity).getLeashHolder()));
++ this.sendPacket(new PacketPlayOutAttachEntity(entity, ((EntityInsentient) entity).getLeashHolder()));
+ }
+
+ if (event.isCancelled() || this.player.inventory.getItemInHand() == null || this.player.inventory.getItemInHand().getItem() != origItem) {
@@ -959,8 +1050,11 @@
+ }
+ // CraftBukkit end
+ }
++
if (packetplayinuseentity.a() == PacketPlayInUseEntity.EnumEntityUseAction.INTERACT) {
- this.player.u(entity);
+ enumhand = packetplayinuseentity.b();
+ itemstack = this.player.b(enumhand);
+ this.player.a(entity, itemstack, enumhand);
+
+ // CraftBukkit start
+ if (itemInHand != null && itemInHand.count <= -1) {
@@ -968,7 +1062,9 @@
+ }
+ // CraftBukkit end
} else if (packetplayinuseentity.a() == PacketPlayInUseEntity.EnumEntityUseAction.INTERACT_AT) {
- entity.a((EntityHuman) this.player, packetplayinuseentity.b());
+ enumhand = packetplayinuseentity.b();
+ itemstack = this.player.b(enumhand);
+ entity.a((EntityHuman) this.player, packetplayinuseentity.c(), itemstack, enumhand);
+
+ // CraftBukkit start
+ if (itemInHand != null && itemInHand.count <= -1) {
@@ -993,45 +1089,43 @@
}
}
}
-@@ -688,7 +1307,8 @@
- switch (PlayerConnection.SyntheticClass_1.c[packetplayinclientcommand_enumclientcommand.ordinal()]) {
+@@ -809,7 +1486,8 @@
case 1:
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
- } else if (this.player.u().getWorldData().isHardcore()) {
- if (this.minecraftServer.T() && this.player.getName().equals(this.minecraftServer.S())) {
- this.player.playerConnection.disconnect("You have died. Game over, man, it\'s game over!");
-@@ -719,15 +1339,21 @@
- }
+ } else {
+ if (this.player.getHealth() > 0.0F) {
+ return;
+@@ -835,14 +1513,20 @@
public void a(PacketPlayInCloseWindow packetplayinclosewindow) {
-+ if (this.player.dead) return; // CraftBukkit
- PlayerConnectionUtils.ensureMainThread(packetplayinclosewindow, this, this.player.u());
+ PlayerConnectionUtils.ensureMainThread(packetplayinclosewindow, this, this.player.x());
+
++ if (this.player.dead) return; // CraftBukkit
+ CraftEventFactory.handleInventoryCloseEvent(this.player); // CraftBukkit
+
- this.player.p();
+ this.player.s();
}
public void a(PacketPlayInWindowClick packetplayinwindowclick) {
+ PlayerConnectionUtils.ensureMainThread(packetplayinwindowclick, this, this.player.x());
+ if (this.player.dead) return; // CraftBukkit
- PlayerConnectionUtils.ensureMainThread(packetplayinwindowclick, this, this.player.u());
this.player.resetIdleTimer();
if (this.player.activeContainer.windowId == packetplayinwindowclick.a() && this.player.activeContainer.c(this.player)) {
- if (this.player.isSpectator()) {
+ boolean cancelled = this.player.isSpectator(); // CraftBukkit - see below if
-+ if (false) { // this.player.isSpectator()) {
++ if (false/*this.player.isSpectator()*/) { // CraftBukkit
ArrayList arraylist = Lists.newArrayList();
for (int i = 0; i < this.player.activeContainer.c.size(); ++i) {
-@@ -736,7 +1362,270 @@
+@@ -851,8 +1535,273 @@
this.player.a(this.player.activeContainer, (List) arraylist);
} else {
-- ItemStack itemstack = this.player.activeContainer.clickItem(packetplayinwindowclick.b(), packetplayinwindowclick.c(), packetplayinwindowclick.f(), this.player);
-+ // ItemStack itemstack = this.player.activeContainer.clickItem(packetplayinwindowclick.b(), packetplayinwindowclick.c(), packetplayinwindowclick.f(), this.player);
+- ItemStack itemstack = this.player.activeContainer.a(packetplayinwindowclick.b(), packetplayinwindowclick.c(), packetplayinwindowclick.f(), this.player);
+ // CraftBukkit start - Call InventoryClickEvent
+ if (packetplayinwindowclick.b() < -1 && packetplayinwindowclick.b() != -999) {
+ return;
@@ -1040,177 +1134,181 @@
+ InventoryView inventory = this.player.activeContainer.getBukkitView();
+ SlotType type = CraftInventoryView.getSlotType(inventory, packetplayinwindowclick.b());
+
-+ InventoryClickEvent event = null;
++ InventoryClickEvent event;
+ ClickType click = ClickType.UNKNOWN;
+ InventoryAction action = InventoryAction.UNKNOWN;
+
+ ItemStack itemstack = null;
+
-+ if (packetplayinwindowclick.b() == -1) {
-+ type = SlotType.OUTSIDE; // override
-+ click = packetplayinwindowclick.c() == 0 ? ClickType.WINDOW_BORDER_LEFT : ClickType.WINDOW_BORDER_RIGHT;
-+ action = InventoryAction.NOTHING;
-+ } else if (packetplayinwindowclick.f() == 0) {
-+ if (packetplayinwindowclick.c() == 0) {
-+ click = ClickType.LEFT;
-+ } else if (packetplayinwindowclick.c() == 1) {
-+ click = ClickType.RIGHT;
-+ }
-+ if (packetplayinwindowclick.c() == 0 || packetplayinwindowclick.c() == 1) {
-+ action = InventoryAction.NOTHING; // Don't want to repeat ourselves
-+ if (packetplayinwindowclick.b() == -999) {
-+ if (player.inventory.getCarried() != null) {
-+ action = packetplayinwindowclick.c() == 0 ? InventoryAction.DROP_ALL_CURSOR : InventoryAction.DROP_ONE_CURSOR;
-+ }
-+ } else {
-+ Slot slot = this.player.activeContainer.getSlot(packetplayinwindowclick.b());
-+ if (slot != null) {
-+ ItemStack clickedItem = slot.getItem();
-+ ItemStack cursor = player.inventory.getCarried();
-+ if (clickedItem == null) {
-+ if (cursor != null) {
-+ action = packetplayinwindowclick.c() == 0 ? InventoryAction.PLACE_ALL : InventoryAction.PLACE_ONE;
-+ }
-+ } else if (slot.isAllowed(player)) {
-+ if (cursor == null) {
-+ action = packetplayinwindowclick.c() == 0 ? InventoryAction.PICKUP_ALL : InventoryAction.PICKUP_HALF;
-+ } else if (slot.isAllowed(cursor)) {
-+ if (clickedItem.doMaterialsMatch(cursor) && ItemStack.equals(clickedItem, cursor)) {
-+ int toPlace = packetplayinwindowclick.c() == 0 ? cursor.count : 1;
-+ toPlace = Math.min(toPlace, clickedItem.getMaxStackSize() - clickedItem.count);
-+ toPlace = Math.min(toPlace, slot.inventory.getMaxStackSize() - clickedItem.count);
-+ if (toPlace == 1) {
-+ action = InventoryAction.PLACE_ONE;
-+ } else if (toPlace == cursor.count) {
-+ action = InventoryAction.PLACE_ALL;
-+ } else if (toPlace < 0) {
-+ action = toPlace != -1 ? InventoryAction.PICKUP_SOME : InventoryAction.PICKUP_ONE; // this happens with oversized stacks
-+ } else if (toPlace != 0) {
-+ action = InventoryAction.PLACE_SOME;
-+ }
-+ } else if (cursor.count <= slot.getMaxStackSize()) {
-+ action = InventoryAction.SWAP_WITH_CURSOR;
++ switch (packetplayinwindowclick.f()) {
++ case PICKUP:
++ if (packetplayinwindowclick.c() == 0) {
++ click = ClickType.LEFT;
++ } else if (packetplayinwindowclick.c() == 1) {
++ click = ClickType.RIGHT;
++ }
++ if (packetplayinwindowclick.c() == 0 || packetplayinwindowclick.c() == 1) {
++ action = InventoryAction.NOTHING; // Don't want to repeat ourselves
++ if (packetplayinwindowclick.b() == -999) {
++ if (player.inventory.getCarried() != null) {
++ action = packetplayinwindowclick.c() == 0 ? InventoryAction.DROP_ALL_CURSOR : InventoryAction.DROP_ONE_CURSOR;
++ }
++ } else {
++ Slot slot = this.player.activeContainer.getSlot(packetplayinwindowclick.b());
++ if (slot != null) {
++ ItemStack clickedItem = slot.getItem();
++ ItemStack cursor = player.inventory.getCarried();
++ if (clickedItem == null) {
++ if (cursor != null) {
++ action = packetplayinwindowclick.c() == 0 ? InventoryAction.PLACE_ALL : InventoryAction.PLACE_ONE;
+ }
-+ } else if (cursor.getItem() == clickedItem.getItem() && (!cursor.usesData() || cursor.getData() == clickedItem.getData()) && ItemStack.equals(cursor, clickedItem)) {
-+ if (clickedItem.count >= 0) {
-+ if (clickedItem.count + cursor.count <= cursor.getMaxStackSize()) {
-+ // As of 1.5, this is result slots only
-+ action = InventoryAction.PICKUP_ALL;
++ } else if (slot.isAllowed(player)) {
++ if (cursor == null) {
++ action = packetplayinwindowclick.c() == 0 ? InventoryAction.PICKUP_ALL : InventoryAction.PICKUP_HALF;
++ } else if (slot.isAllowed(cursor)) {
++ if (clickedItem.doMaterialsMatch(cursor) && ItemStack.equals(clickedItem, cursor)) {
++ int toPlace = packetplayinwindowclick.c() == 0 ? cursor.count : 1;
++ toPlace = Math.min(toPlace, clickedItem.getMaxStackSize() - clickedItem.count);
++ toPlace = Math.min(toPlace, slot.inventory.getMaxStackSize() - clickedItem.count);
++ if (toPlace == 1) {
++ action = InventoryAction.PLACE_ONE;
++ } else if (toPlace == cursor.count) {
++ action = InventoryAction.PLACE_ALL;
++ } else if (toPlace < 0) {
++ action = toPlace != -1 ? InventoryAction.PICKUP_SOME : InventoryAction.PICKUP_ONE; // this happens with oversized stacks
++ } else if (toPlace != 0) {
++ action = InventoryAction.PLACE_SOME;
++ }
++ } else if (cursor.count <= slot.getMaxStackSize()) {
++ action = InventoryAction.SWAP_WITH_CURSOR;
++ }
++ } else if (cursor.getItem() == clickedItem.getItem() && (!cursor.usesData() || cursor.getData() == clickedItem.getData()) && ItemStack.equals(cursor, clickedItem)) {
++ if (clickedItem.count >= 0) {
++ if (clickedItem.count + cursor.count <= cursor.getMaxStackSize()) {
++ // As of 1.5, this is result slots only
++ action = InventoryAction.PICKUP_ALL;
++ }
+ }
+ }
+ }
+ }
+ }
+ }
-+ }
-+ } else if (packetplayinwindowclick.f() == 1) {
-+ if (packetplayinwindowclick.c() == 0) {
-+ click = ClickType.SHIFT_LEFT;
-+ } else if (packetplayinwindowclick.c() == 1) {
-+ click = ClickType.SHIFT_RIGHT;
-+ }
-+ if (packetplayinwindowclick.c() == 0 || packetplayinwindowclick.c() == 1) {
-+ if (packetplayinwindowclick.b() < 0) {
-+ action = InventoryAction.NOTHING;
-+ } else {
-+ Slot slot = this.player.activeContainer.getSlot(packetplayinwindowclick.b());
-+ if (slot != null && slot.isAllowed(this.player) && slot.hasItem()) {
-+ action = InventoryAction.MOVE_TO_OTHER_INVENTORY;
-+ } else {
++ break;
++ // TODO check on updates
++ case QUICK_MOVE:
++ if (packetplayinwindowclick.c() == 0) {
++ click = ClickType.SHIFT_LEFT;
++ } else if (packetplayinwindowclick.c() == 1) {
++ click = ClickType.SHIFT_RIGHT;
++ }
++ if (packetplayinwindowclick.c() == 0 || packetplayinwindowclick.c() == 1) {
++ if (packetplayinwindowclick.b() < 0) {
+ action = InventoryAction.NOTHING;
++ } else {
++ Slot slot = this.player.activeContainer.getSlot(packetplayinwindowclick.b());
++ if (slot != null && slot.isAllowed(this.player) && slot.hasItem()) {
++ action = InventoryAction.MOVE_TO_OTHER_INVENTORY;
++ } else {
++ action = InventoryAction.NOTHING;
++ }
+ }
+ }
-+ }
-+ } else if (packetplayinwindowclick.f() == 2) {
-+ if (packetplayinwindowclick.c() >= 0 && packetplayinwindowclick.c() < 9) {
-+ click = ClickType.NUMBER_KEY;
-+ Slot clickedSlot = this.player.activeContainer.getSlot(packetplayinwindowclick.b());
-+ if (clickedSlot.isAllowed(player)) {
-+ ItemStack hotbar = this.player.inventory.getItem(packetplayinwindowclick.c());
-+ boolean canCleanSwap = hotbar == null || (clickedSlot.inventory == player.inventory && clickedSlot.isAllowed(hotbar)); // the slot will accept the hotbar item
-+ if (clickedSlot.hasItem()) {
-+ if (canCleanSwap) {
-+ action = InventoryAction.HOTBAR_SWAP;
-+ } else {
-+ int firstEmptySlot = player.inventory.getFirstEmptySlotIndex();
-+ if (firstEmptySlot > -1) {
-+ action = InventoryAction.HOTBAR_MOVE_AND_READD;
++ break;
++ case SWAP:
++ if (packetplayinwindowclick.c() >= 0 && packetplayinwindowclick.c() < 9) {
++ click = ClickType.NUMBER_KEY;
++ Slot clickedSlot = this.player.activeContainer.getSlot(packetplayinwindowclick.b());
++ if (clickedSlot.isAllowed(player)) {
++ ItemStack hotbar = this.player.inventory.getItem(packetplayinwindowclick.c());
++ boolean canCleanSwap = hotbar == null || (clickedSlot.inventory == player.inventory && clickedSlot.isAllowed(hotbar)); // the slot will accept the hotbar item
++ if (clickedSlot.hasItem()) {
++ if (canCleanSwap) {
++ action = InventoryAction.HOTBAR_SWAP;
+ } else {
-+ action = InventoryAction.NOTHING; // This is not sane! Mojang: You should test for other slots of same type
++ int firstEmptySlot = player.inventory.getFirstEmptySlotIndex();
++ if (firstEmptySlot > -1) {
++ action = InventoryAction.HOTBAR_MOVE_AND_READD;
++ } else {
++ action = InventoryAction.NOTHING; // This is not sane! Mojang: You should test for other slots of same type
++ }
+ }
++ } else if (!clickedSlot.hasItem() && hotbar != null && clickedSlot.isAllowed(hotbar)) {
++ action = InventoryAction.HOTBAR_SWAP;
++ } else {
++ action = InventoryAction.NOTHING;
+ }
-+ } else if (!clickedSlot.hasItem() && hotbar != null && clickedSlot.isAllowed(hotbar)) {
-+ action = InventoryAction.HOTBAR_SWAP;
+ } else {
+ action = InventoryAction.NOTHING;
+ }
-+ } else {
-+ action = InventoryAction.NOTHING;
+ }
-+ // Special constructor for number key
-+ event = new InventoryClickEvent(inventory, type, packetplayinwindowclick.b(), click, action, packetplayinwindowclick.c());
-+ }
-+ } else if (packetplayinwindowclick.f() == 3) {
-+ if (packetplayinwindowclick.c() == 2) {
-+ click = ClickType.MIDDLE;
-+ if (packetplayinwindowclick.b() == -999) {
-+ action = InventoryAction.NOTHING;
-+ } else {
-+ Slot slot = this.player.activeContainer.getSlot(packetplayinwindowclick.b());
-+ if (slot != null && slot.hasItem() && player.abilities.canInstantlyBuild && player.inventory.getCarried() == null) {
-+ action = InventoryAction.CLONE_STACK;
-+ } else {
++ break;
++ case CLONE:
++ if (packetplayinwindowclick.c() == 2) {
++ click = ClickType.MIDDLE;
++ if (packetplayinwindowclick.b() == -999) {
+ action = InventoryAction.NOTHING;
++ } else {
++ Slot slot = this.player.activeContainer.getSlot(packetplayinwindowclick.b());
++ if (slot != null && slot.hasItem() && player.abilities.canInstantlyBuild && player.inventory.getCarried() == null) {
++ action = InventoryAction.CLONE_STACK;
++ } else {
++ action = InventoryAction.NOTHING;
++ }
+ }
++ } else {
++ click = ClickType.UNKNOWN;
++ action = InventoryAction.UNKNOWN;
+ }
-+ } else {
-+ click = ClickType.UNKNOWN;
-+ action = InventoryAction.UNKNOWN;
-+ }
-+ } else if (packetplayinwindowclick.f() == 4) {
-+ if (packetplayinwindowclick.b() >= 0) {
-+ if (packetplayinwindowclick.c() == 0) {
-+ click = ClickType.DROP;
-+ Slot slot = this.player.activeContainer.getSlot(packetplayinwindowclick.b());
-+ if (slot != null && slot.hasItem() && slot.isAllowed(player) && slot.getItem() != null && slot.getItem().getItem() != Item.getItemOf(Blocks.AIR)) {
-+ action = InventoryAction.DROP_ONE_SLOT;
-+ } else {
-+ action = InventoryAction.NOTHING;
++ break;
++ case THROW:
++ if (packetplayinwindowclick.b() >= 0) {
++ if (packetplayinwindowclick.c() == 0) {
++ click = ClickType.DROP;
++ Slot slot = this.player.activeContainer.getSlot(packetplayinwindowclick.b());
++ if (slot != null && slot.hasItem() && slot.isAllowed(player) && slot.getItem() != null && slot.getItem().getItem() != Item.getItemOf(Blocks.AIR)) {
++ action = InventoryAction.DROP_ONE_SLOT;
++ } else {
++ action = InventoryAction.NOTHING;
++ }
++ } else if (packetplayinwindowclick.c() == 1) {
++ click = ClickType.CONTROL_DROP;
++ Slot slot = this.player.activeContainer.getSlot(packetplayinwindowclick.b());
++ if (slot != null && slot.hasItem() && slot.isAllowed(player) && slot.getItem() != null && slot.getItem().getItem() != Item.getItemOf(Blocks.AIR)) {
++ action = InventoryAction.DROP_ALL_SLOT;
++ } else {
++ action = InventoryAction.NOTHING;
++ }
+ }
-+ } else if (packetplayinwindowclick.c() == 1) {
-+ click = ClickType.CONTROL_DROP;
-+ Slot slot = this.player.activeContainer.getSlot(packetplayinwindowclick.b());
-+ if (slot != null && slot.hasItem() && slot.isAllowed(player) && slot.getItem() != null && slot.getItem().getItem() != Item.getItemOf(Blocks.AIR)) {
-+ action = InventoryAction.DROP_ALL_SLOT;
-+ } else {
-+ action = InventoryAction.NOTHING;
++ } else {
++ // Sane default (because this happens when they are holding nothing. Don't ask why.)
++ click = ClickType.LEFT;
++ if (packetplayinwindowclick.c() == 1) {
++ click = ClickType.RIGHT;
+ }
++ action = InventoryAction.NOTHING;
+ }
-+ } else {
-+ // Sane default (because this happens when they are holding nothing. Don't ask why.)
-+ click = ClickType.LEFT;
-+ if (packetplayinwindowclick.c() == 1) {
-+ click = ClickType.RIGHT;
-+ }
-+ action = InventoryAction.NOTHING;
-+ }
-+ } else if (packetplayinwindowclick.f() == 5) {
-+ itemstack = this.player.activeContainer.clickItem(packetplayinwindowclick.b(), packetplayinwindowclick.c(), 5, this.player);
-+ } else if (packetplayinwindowclick.f() == 6) {
-+ click = ClickType.DOUBLE_CLICK;
-+ action = InventoryAction.NOTHING;
-+ if (packetplayinwindowclick.b() >= 0 && this.player.inventory.getCarried() != null) {
-+ ItemStack cursor = this.player.inventory.getCarried();
++ break;
++ case QUICK_CRAFT:
++ itemstack = this.player.activeContainer.a(packetplayinwindowclick.b(), packetplayinwindowclick.c(), packetplayinwindowclick.f(), this.player);
++ break;
++ case PICKUP_ALL:
++ click = ClickType.DOUBLE_CLICK;
+ 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())))) {
-+ action = InventoryAction.COLLECT_TO_CURSOR;
++ if (packetplayinwindowclick.b() >= 0 && this.player.inventory.getCarried() != null) {
++ 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())))) {
++ action = InventoryAction.COLLECT_TO_CURSOR;
++ }
+ }
-+ }
++ break;
++ default:
++ break;
+ }
-+ // TODO check on updates
+
-+ if (packetplayinwindowclick.f() != 5) {
++ if (packetplayinwindowclick.f() != InventoryClickType.QUICK_CRAFT) {
+ if (click == ClickType.NUMBER_KEY) {
+ event = new InventoryClickEvent(inventory, type, packetplayinwindowclick.b(), click, action, packetplayinwindowclick.c());
+ } else {
@@ -1235,12 +1333,12 @@
+ switch (event.getResult()) {
+ case ALLOW:
+ case DEFAULT:
-+ itemstack = this.player.activeContainer.clickItem(packetplayinwindowclick.b(), packetplayinwindowclick.c(), packetplayinwindowclick.f(), this.player);
++ itemstack = this.player.activeContainer.a(packetplayinwindowclick.b(), packetplayinwindowclick.c(), packetplayinwindowclick.f(), this.player);
+ break;
+ case DENY:
+ /* Needs enum constructor in InventoryAction
+ if (action.modifiesOtherSlots()) {
-+
+
+ } else {
+ if (action.modifiesCursor()) {
+ this.player.playerConnection.sendPacket(new Packet103SetSlot(-1, -1, this.player.inventory.getCarried()));
@@ -1295,13 +1393,13 @@
+ }
+ }
+ // CraftBukkit end
-
if (ItemStack.matches(packetplayinwindowclick.e(), itemstack)) {
this.player.playerConnection.sendPacket(new PacketPlayOutTransaction(packetplayinwindowclick.a(), packetplayinwindowclick.d(), true));
-@@ -797,8 +1686,48 @@
+ this.player.f = true;
+@@ -915,8 +1864,48 @@
}
- boolean flag1 = packetplayinsetcreativeslot.a() >= 1 && packetplayinsetcreativeslot.a() < 36 + PlayerInventory.getHotbarSize();
+ boolean flag1 = packetplayinsetcreativeslot.a() >= 1 && packetplayinsetcreativeslot.a() <= 45;
- boolean flag2 = itemstack == null || itemstack.getItem() != null;
+ // CraftBukkit - Add invalidItems check
+ boolean flag2 = itemstack == null || itemstack.getItem() != null && !invalidItems.contains(Item.getId(itemstack.getItem()));
@@ -1348,23 +1446,23 @@
if (flag1 && flag2 && flag3) {
if (itemstack == null) {
-@@ -821,6 +1750,7 @@
- }
+@@ -940,6 +1929,7 @@
public void a(PacketPlayInTransaction packetplayintransaction) {
+ PlayerConnectionUtils.ensureMainThread(packetplayintransaction, this, this.player.x());
+ if (this.player.dead) return; // CraftBukkit
- PlayerConnectionUtils.ensureMainThread(packetplayintransaction, this, this.player.u());
- Short oshort = (Short) this.n.get(this.player.activeContainer.windowId);
+ Short oshort = (Short) this.k.get(this.player.activeContainer.windowId);
-@@ -831,6 +1761,7 @@
- }
+ if (oshort != null && packetplayintransaction.b() == oshort.shortValue() && this.player.activeContainer.windowId == packetplayintransaction.a() && !this.player.activeContainer.c(this.player) && !this.player.isSpectator()) {
+@@ -950,6 +1940,7 @@
public void a(PacketPlayInUpdateSign packetplayinupdatesign) {
+ PlayerConnectionUtils.ensureMainThread(packetplayinupdatesign, this, this.player.x());
+ if (this.player.dead) return; // CraftBukkit
- PlayerConnectionUtils.ensureMainThread(packetplayinupdatesign, this, this.player.u());
this.player.resetIdleTimer();
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
-@@ -847,14 +1778,30 @@
+ BlockPosition blockposition = packetplayinupdatesign.a();
+@@ -966,14 +1957,30 @@
if (!tileentitysign.b() || tileentitysign.c() != this.player) {
this.minecraftServer.warning("Player " + this.player.getName() + " just tried to change non-editable sign");
@@ -1372,7 +1470,7 @@
return;
}
- IChatBaseComponent[] aichatbasecomponent = packetplayinupdatesign.b();
+ String[] astring = packetplayinupdatesign.b();
+ // CraftBukkit start
+ Player player = this.server.getPlayer(this.player);
@@ -1381,9 +1479,9 @@
+ int z = packetplayinupdatesign.a().getZ();
+ String[] lines = new String[4];
+
- for (int i = 0; i < aichatbasecomponent.length; ++i) {
-- tileentitysign.lines[i] = new ChatComponentText(EnumChatFormat.a(aichatbasecomponent[i].c()));
-+ lines[i] = EnumChatFormat.a(aichatbasecomponent[i].c());
+ 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());
}
+ 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);
@@ -1395,11 +1493,11 @@
+ // CraftBukkit end
tileentitysign.update();
- worldserver.notify(blockposition);
-@@ -877,11 +1824,27 @@
+ worldserver.notify(blockposition, iblockdata, iblockdata, 3);
+@@ -996,11 +2003,27 @@
public void a(PacketPlayInAbilities packetplayinabilities) {
- PlayerConnectionUtils.ensureMainThread(packetplayinabilities, this, this.player.u());
+ PlayerConnectionUtils.ensureMainThread(packetplayinabilities, this, this.player.x());
- this.player.abilities.isFlying = packetplayinabilities.isFlying() && this.player.abilities.canFly;
+ // CraftBukkit start
+ if (this.player.abilities.canFly && this.player.abilities.isFlying != packetplayinabilities.isFlying()) {
@@ -1415,7 +1513,7 @@
}
public void a(PacketPlayInTabComplete packetplayintabcomplete) {
- PlayerConnectionUtils.ensureMainThread(packetplayintabcomplete, this, this.player.u());
+ PlayerConnectionUtils.ensureMainThread(packetplayintabcomplete, this, this.player.x());
+ // CraftBukkit start
+ if (chatSpamField.addAndGet(this, 10) > 500 && !this.minecraftServer.getPlayerList().isOp(this.player.getProfile())) {
+ this.disconnect("disconnect.spam");
@@ -1423,18 +1521,18 @@
+ }
+ // CraftBukkit end
ArrayList arraylist = Lists.newArrayList();
- Iterator iterator = this.minecraftServer.tabCompleteCommand(this.player, packetplayintabcomplete.a(), packetplayintabcomplete.b()).iterator();
+ Iterator iterator = this.minecraftServer.tabCompleteCommand(this.player, packetplayintabcomplete.a(), packetplayintabcomplete.b(), packetplayintabcomplete.c()).iterator();
-@@ -905,6 +1868,7 @@
+@@ -1025,6 +2048,7 @@
ItemStack itemstack;
ItemStack itemstack1;
-+ try { // CraftBukkit
- if ("MC|BEdit".equals(packetplayincustompayload.a())) {
++ try { // CraftBukkit - Make sure the buffer is freed
+ if ("MC|BEdit".equals(s)) {
packetdataserializer = new PacketDataSerializer(Unpooled.wrappedBuffer(packetplayincustompayload.b()));
-@@ -921,13 +1885,16 @@
- itemstack1 = this.player.inventory.getItemInHand();
+@@ -1041,13 +2065,16 @@
+ itemstack1 = this.player.getItemInMainHand();
if (itemstack1 != null) {
if (itemstack.getItem() == Items.WRITABLE_BOOK && itemstack.getItem() == itemstack1.getItem()) {
+ itemstack1 = new ItemStack(Items.WRITABLE_BOOK); // CraftBukkit
@@ -1445,96 +1543,95 @@
return;
}
} catch (Exception exception) {
- PlayerConnection.c.error("Couldn\'t handle book info", exception);
+ PlayerConnection.LOGGER.error("Couldn\'t handle book info", exception);
+ this.disconnect("Invalid book data!"); // CraftBukkit
return;
} finally {
packetdataserializer.release();
-@@ -950,16 +1917,21 @@
- itemstack1 = this.player.inventory.getItemInHand();
- if (itemstack1 != null) {
- if (itemstack.getItem() == Items.WRITTEN_BOOK && itemstack1.getItem() == Items.WRITABLE_BOOK) {
-+ // CraftBukkit start
-+ itemstack1 = new ItemStack(Items.WRITTEN_BOOK);
- itemstack1.a("author", (NBTBase) (new NBTTagString(this.player.getName())));
- itemstack1.a("title", (NBTBase) (new NBTTagString(itemstack.getTag().getString("title"))));
- itemstack1.a("pages", (NBTBase) itemstack.getTag().getList("pages", 8));
- itemstack1.setItem(Items.WRITTEN_BOOK);
-+ CraftEventFactory.handleEditBookEvent(player, itemstack1);
-+ // CraftBukkit end
- }
+@@ -1073,6 +2100,8 @@
+ itemstack1 = this.player.getItemInMainHand();
+ if (itemstack1 != null) {
+ if (itemstack.getItem() == Items.WRITABLE_BOOK && itemstack1.getItem() == Items.WRITABLE_BOOK) {
++ // CraftBukkit start
++ itemstack1 = new ItemStack(Items.WRITABLE_BOOK);
+ itemstack1.a("author", (NBTBase) (new NBTTagString(this.player.getName())));
+ itemstack1.a("title", (NBTBase) (new NBTTagString(itemstack.getTag().getString("title"))));
+ NBTTagList nbttaglist = itemstack.getTag().getList("pages", 8);
+@@ -1087,12 +2116,15 @@
+
+ itemstack1.a("pages", (NBTBase) nbttaglist);
+ itemstack1.setItem(Items.WRITTEN_BOOK);
++ CraftEventFactory.handleEditBookEvent(player, itemstack1);
++ // CraftBukkit end
+ }
- return;
- }
- } catch (Exception exception1) {
- PlayerConnection.c.error("Couldn\'t sign book", exception1);
-+ this.disconnect("Invalid book data!"); // CraftBukkit
- return;
- } finally {
- packetdataserializer.release();
-@@ -976,11 +1948,12 @@
- }
- } catch (Exception exception2) {
- PlayerConnection.c.error("Couldn\'t select trade", exception2);
-+ this.disconnect("Invalid trade data!"); // CraftBukkit
- }
- } else if ("MC|AdvCdm".equals(packetplayincustompayload.a())) {
- if (!this.minecraftServer.getEnableCommandBlock()) {
- this.player.sendMessage(new ChatMessage("advMode.notEnabled", new Object[0]));
-- } else if (this.player.a(2, "") && this.player.abilities.canInstantlyBuild) {
-+ } else if (this.player.getBukkitEntity().isOp() && this.player.abilities.canInstantlyBuild) { // CraftBukkit - Change to Bukkit OP versus Vanilla OP
- packetdataserializer = packetplayincustompayload.b();
-
- try {
-@@ -1016,6 +1989,7 @@
+ return;
}
- } catch (Exception exception3) {
- PlayerConnection.c.error("Couldn\'t set command block", exception3);
-+ this.disconnect("Invalid CommandBlock data!"); // CraftBukkit
+ } catch (Exception exception1) {
+ PlayerConnection.LOGGER.error("Couldn\'t sign book", exception1);
++ this.disconnect("Invalid book data!"); // CraftBukkit
+ return;
} finally {
packetdataserializer.release();
- }
-@@ -1041,6 +2015,7 @@
+@@ -1158,6 +2190,7 @@
+ }
+ } catch (Exception exception3) {
+ PlayerConnection.LOGGER.error("Couldn\'t set command block", exception3);
++ this.disconnect("Invalid CommandBlock data!"); // CraftBukkit
+ } finally {
+ packetdataserializer.release();
+ }
+@@ -1227,6 +2260,7 @@
+ }
+ } catch (Exception exception4) {
+ PlayerConnection.LOGGER.error("Couldn\'t set command block", exception4);
++ this.disconnect("Invalid CommandBlock data!"); // CraftBukkit
+ } finally {
+ packetdataserializer.release();
}
- } catch (Exception exception4) {
- PlayerConnection.c.error("Couldn\'t set beacon", exception4);
-+ this.disconnect("Invalid beacon data!"); // CraftBukkit
+@@ -1252,6 +2286,7 @@
+ }
+ } catch (Exception exception5) {
+ PlayerConnection.LOGGER.error("Couldn\'t set beacon", exception5);
++ this.disconnect("Invalid beacon data!"); // CraftBukkit
+ }
+ }
+ } else if ("MC|ItemName".equals(s)) {
+@@ -1334,10 +2369,37 @@
+ packetdataserializer.release();
+ }
+ }
++ // CraftBukkit start
++ else if (packetplayincustompayload.a().equals("REGISTER")) {
++ String channels = packetplayincustompayload.b().toString(com.google.common.base.Charsets.UTF_8);
++ for (String channel : channels.split("\0")) {
++ getPlayer().addChannel(channel);
++ }
++ } else if (packetplayincustompayload.a().equals("UNREGISTER")) {
++ String channels = packetplayincustompayload.b().toString(com.google.common.base.Charsets.UTF_8);
++ for (String channel : channels.split("\0")) {
++ getPlayer().removeChannel(channel);
++ }
++ } else {
++ byte[] data = new byte[packetplayincustompayload.b().readableBytes()];
++ packetplayincustompayload.b().readBytes(data);
++ server.getMessenger().dispatchIncomingMessage(player.getBukkitEntity(), packetplayincustompayload.a(), data);
++ }
++ // CraftBukkit end
}
}
- } else if ("MC|ItemName".equals(packetplayincustompayload.a()) && this.player.activeContainer instanceof ContainerAnvil) {
-@@ -1056,7 +2031,35 @@
- containeranvil.a("");
- }
}
+ // CraftBukkit start
-+ else if (packetplayincustompayload.a().equals("REGISTER")) {
-+ String channels = packetplayincustompayload.b().toString(com.google.common.base.Charsets.UTF_8);
-+ for (String channel : channels.split("\0")) {
-+ getPlayer().addChannel(channel);
-+ }
-+ } else if (packetplayincustompayload.a().equals("UNREGISTER")) {
-+ String channels = packetplayincustompayload.b().toString(com.google.common.base.Charsets.UTF_8);
-+ for (String channel : channels.split("\0")) {
-+ getPlayer().removeChannel(channel);
-+ }
-+ } else {
-+ byte[] data = new byte[packetplayincustompayload.b().readableBytes()];
-+ packetplayincustompayload.b().readBytes(data);
-+ server.getMessenger().dispatchIncomingMessage(player.getBukkitEntity(), packetplayincustompayload.a(), data);
-+ }
-+ // CraftBukkit end
-+ // CraftBukkit start
+ } finally {
+ if (packetplayincustompayload.b().refCnt() > 0) {
+ packetplayincustompayload.b().release();
+ }
+ }
-+ // CraftBukkit end
+ }
+ // CraftBukkit start - Add "isDisconnected" method
+ public final boolean isDisconnected() {
-+ return !this.player.joining && !this.networkManager.channel.config().isAutoRead();
++ return !this.player.joining && !this.networkManager.isConnected();
}
static class SyntheticClass_1 {
diff --git a/nms-patches/PlayerInteractManager.patch b/nms-patches/PlayerInteractManager.patch
index c4b0f192..237508ad 100644
--- a/nms-patches/PlayerInteractManager.patch
+++ b/nms-patches/PlayerInteractManager.patch
@@ -20,10 +20,10 @@
this.player.updateAbilities();
- this.player.server.getPlayerList().sendAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_GAME_MODE, new EntityPlayer[] { this.player}));
+ this.player.server.getPlayerList().sendAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_GAME_MODE, new EntityPlayer[] { this.player}), this.player); // CraftBukkit
+ this.world.everyoneSleeping();
}
- public WorldSettings.EnumGamemode getGameMode() {
-@@ -50,7 +58,7 @@
+@@ -51,7 +59,7 @@
}
public void a() {
@@ -32,7 +32,7 @@
float f;
int i;
-@@ -95,6 +103,19 @@
+@@ -98,6 +106,19 @@
}
public void a(BlockPosition blockposition, EnumDirection enumdirection) {
@@ -52,7 +52,7 @@
if (this.isCreative()) {
if (!this.world.douseFire((EntityHuman) null, blockposition, enumdirection)) {
this.breakBlock(blockposition);
-@@ -121,14 +142,48 @@
+@@ -125,14 +146,48 @@
}
}
@@ -61,7 +61,7 @@
this.lastDigTick = this.currentTick;
float f = 1.0F;
-- if (block.getMaterial() != Material.AIR) {
+- if (iblockdata.getMaterial() != Material.AIR) {
+ // 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.
@@ -74,9 +74,9 @@
+ } else if (block == Blocks.TRAPDOOR) {
+ ((EntityPlayer) this.player).playerConnection.sendPacket(new PacketPlayOutBlockChange(this.world, blockposition));
+ }
-+ } else if (block.getMaterial() != Material.AIR) {
++ } else if (iblockdata.getMaterial() != Material.AIR) {
block.attack(this.world, blockposition, this.player);
- f = block.getDamage(this.player, this.player.world, blockposition);
+ f = iblockdata.a((EntityHuman) this.player, this.player.world, blockposition);
+ // Allow fire punching to be blocked
+ this.world.douseFire((EntityHuman) null, blockposition, enumdirection);
+ }
@@ -101,17 +101,17 @@
}
+ // CraftBukkit end
- if (block.getMaterial() != Material.AIR && f >= 1.0F) {
+ if (iblockdata.getMaterial() != Material.AIR && f >= 1.0F) {
this.breakBlock(blockposition);
-@@ -146,6 +201,7 @@
+@@ -150,6 +205,7 @@
public void a(BlockPosition blockposition) {
if (blockposition.equals(this.f)) {
+ this.currentTick = MinecraftServer.currentTick; // CraftBukkit
int i = this.currentTick - this.lastDigTick;
- Block block = this.world.getType(blockposition).getBlock();
+ IBlockData iblockdata = this.world.getType(blockposition);
-@@ -163,6 +219,10 @@
+@@ -167,6 +223,10 @@
this.j = this.lastDigTick;
}
}
@@ -122,11 +122,11 @@
}
}
-@@ -186,12 +246,72 @@
+@@ -190,12 +250,75 @@
}
public boolean breakBlock(BlockPosition blockposition) {
-- if (this.gamemode.d() && this.player.bA() != null && this.player.bA().getItem() instanceof ItemSword) {
+- if (this.gamemode.isCreative() && this.player.getItemInMainHand() != null && this.player.getItemInMainHand().getItem() instanceof ItemSword) {
+ // CraftBukkit start - fire BlockBreakEvent
+ BlockBreakEvent event = null;
+
@@ -134,7 +134,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.d() && this.player.bA() != null && this.player.bA().getItem() instanceof ItemSword;
++ boolean isSwordNoBreak = this.gamemode.isCreative() && this.player.getItemInMainHand() != null && this.player.getItemInMainHand().getItem() instanceof ItemSword;
+
+ // Tell client the block is gone immediately then process events
+ // Don't tell the client if its a creative sword break because its not broken!
@@ -153,11 +153,14 @@
+ IBlockData nmsData = this.world.getType(blockposition);
+ Block nmsBlock = nmsData.getBlock();
+
-+ if (nmsBlock != null && !event.isCancelled() && !this.isCreative() && this.player.b(nmsBlock)) {
++ ItemStack itemstack = this.player.getEquipment(EnumItemSlot.MAINHAND);
++
++ if (nmsBlock != null && !event.isCancelled() && !this.isCreative() && this.player.hasBlock(nmsBlock.getBlockData())) {
+ // Copied from block.a(World world, EntityHuman entityhuman, BlockPosition blockposition, IBlockData iblockdata, TileEntity tileentity)
-+ if (!(nmsBlock.I() && EnchantmentManager.hasSilkTouchEnchantment(this.player))) {
++ // PAIL: checkme each update
++ if (!(nmsBlock.p() && EnchantmentManager.getEnchantmentLevel(Enchantments.SILK_TOUCH, itemstack) > 0)) {
+ int data = block.getData();
-+ int bonusLevel = EnchantmentManager.getBonusBlockLootEnchantmentLevel(this.player);
++ int bonusLevel = EnchantmentManager.getEnchantmentLevel(Enchantments.LOOT_BONUS_BLOCKS, itemstack);
+
+ event.setExpToDrop(nmsBlock.getExpDrop(this.world, nmsData, bonusLevel));
+ }
@@ -179,7 +182,7 @@
+ return false;
+ }
+ }
-+ if (false && this.gamemode.d() && this.player.bA() != null && this.player.bA().getItem() instanceof ItemSword) {
++ if (false && this.gamemode.isCreative() && this.player.getItemInMainHand() != null && this.player.getItemInMainHand().getItem() instanceof ItemSword) { // CraftBukkit - false
return false;
} else {
IBlockData iblockdata = this.world.getType(blockposition);
@@ -193,23 +196,23 @@
+ }
+ // CraftBukkit end
+
- if (this.gamemode.c()) {
- if (this.gamemode == WorldSettings.EnumGamemode.SPECTATOR) {
- return false;
-@@ -230,6 +350,12 @@
- iblockdata.getBlock().a(this.world, this.player, blockposition, iblockdata, tileentity);
+ if (iblockdata.getBlock() instanceof BlockCommand && !this.player.a(2, "")) {
+ this.world.notify(blockposition, iblockdata, iblockdata, 3);
+ return false;
+@@ -240,6 +363,12 @@
+ }
}
- }
-+
-+ // CraftBukkit start - Drop event experience
-+ if (flag && event != null) {
-+ iblockdata.getBlock().dropExperience(this.world, blockposition, event.getExpToDrop());
-+ }
-+ // CraftBukkit end
- return flag;
++ // CraftBukkit start - Drop event experience
++ if (flag && event != null) {
++ iblockdata.getBlock().dropExperience(this.world, blockposition, event.getExpToDrop());
++ }
++ // CraftBukkit end
++
+ return flag;
+ }
}
-@@ -267,7 +393,13 @@
+@@ -280,7 +409,13 @@
}
}
@@ -218,18 +221,18 @@
+ public boolean firedInteract = false;
+ // CraftBukkit end
+
- public boolean interact(EntityHuman entityhuman, World world, ItemStack itemstack, BlockPosition blockposition, EnumDirection enumdirection, float f, float f1, float f2) {
+ public EnumInteractionResult a(EntityHuman entityhuman, World world, ItemStack itemstack, EnumHand enumhand, BlockPosition blockposition, EnumDirection enumdirection, float f, float f1, float f2) {
+ /* CraftBukkit start - whole method
if (this.gamemode == WorldSettings.EnumGamemode.SPECTATOR) {
TileEntity tileentity = world.getTileEntity(blockposition);
-@@ -312,6 +444,72 @@
- return itemstack.placeItem(entityhuman, world, blockposition, enumdirection, f, f1, f2);
+@@ -329,6 +464,72 @@
+ return itemstack.placeItem(entityhuman, world, blockposition, enumhand, enumdirection, f, f1, f2);
}
}
+ // Interract event */
+ IBlockData blockdata = world.getType(blockposition);
-+ boolean result = false;
++ EnumInteractionResult result = EnumInteractionResult.FAIL;
+ if (blockdata.getBlock() != Blocks.AIR) {
+ boolean cancelledBlock = false;
+
@@ -252,7 +255,7 @@
+ boolean bottom = blockdata.get(BlockDoor.HALF) == BlockDoor.EnumDoorHalf.LOWER;
+ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutBlockChange(world, bottom ? blockposition.up() : blockposition.down()));
+ }
-+ result = (event.useItemInHand() != Event.Result.ALLOW);
++ result = (event.useItemInHand() != Event.Result.ALLOW) ? EnumInteractionResult.SUCCESS : EnumInteractionResult.PASS;
+ } else if (this.gamemode == WorldSettings.EnumGamemode.SPECTATOR) {
+ TileEntity tileentity = world.getTileEntity(blockposition);
+
@@ -261,28 +264,28 @@
+ ITileInventory itileinventory = (ITileInventory) tileentity;
+
+ if (itileinventory instanceof TileEntityChest && block instanceof BlockChest) {
-+ itileinventory = ((BlockChest) block).f(world, blockposition);
++ itileinventory = ((BlockChest) block).c(world, blockposition); // PAIL: rename
+ }
+
+ if (itileinventory != null) {
+ entityhuman.openContainer(itileinventory);
-+ return true;
++ return EnumInteractionResult.SUCCESS;
+ }
+ } else if (tileentity instanceof IInventory) {
+ entityhuman.openContainer((IInventory) tileentity);
-+ return true;
++ return EnumInteractionResult.SUCCESS;
+ }
+
-+ return false;
++ return EnumInteractionResult.PASS;
+ } else if (!entityhuman.isSneaking() || itemstack == null) {
-+ result = blockdata.getBlock().interact(world, blockposition, blockdata, entityhuman, enumdirection, f, f1, f2);
++ result = blockdata.getBlock().interact(world, blockposition, blockdata, entityhuman, enumhand, itemstack, enumdirection, f, f1, f2) ? EnumInteractionResult.SUCCESS : EnumInteractionResult.PASS;
+ }
+
-+ if (itemstack != null && !result && !interactResult) { // add !interactResult SPIGOT-764
++ if (itemstack != null && result != EnumInteractionResult.SUCCESS && !interactResult) { // add !interactResult SPIGOT-764
+ int j1 = itemstack.getData();
+ int k1 = itemstack.count;
+
-+ result = itemstack.placeItem(entityhuman, world, blockposition, enumdirection, f, f1, f2);
++ result = itemstack.placeItem(entityhuman, world, blockposition, enumhand, enumdirection, f, f1, f2);
+
+ // The item count should not decrement in Creative mode.
+ if (this.isCreative()) {
diff --git a/nms-patches/PlayerInventory.patch b/nms-patches/PlayerInventory.patch
index cf269568..285ff230 100644
--- a/nms-patches/PlayerInventory.patch
+++ b/nms-patches/PlayerInventory.patch
@@ -1,11 +1,12 @@
--- a/net/minecraft/server/PlayerInventory.java
+++ b/net/minecraft/server/PlayerInventory.java
-@@ -2,6 +2,13 @@
-
+@@ -3,6 +3,14 @@
+ import java.util.Arrays;
import java.util.concurrent.Callable;
+// CraftBukkit start
+import java.util.List;
++import org.bukkit.Location;
+
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
+import org.bukkit.entity.HumanEntity;
@@ -13,10 +14,10 @@
+
public class PlayerInventory implements IInventory {
- public ItemStack[] items = new ItemStack[36];
-@@ -11,6 +18,39 @@
- private ItemStack f;
- public boolean e;
+ public final ItemStack[] items = new ItemStack[36];
+@@ -14,6 +22,44 @@
+ private ItemStack carried;
+ public boolean f;
+ // CraftBukkit start - add fields and methods
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
@@ -49,13 +50,18 @@
+ public void setMaxStackSize(int size) {
+ maxStack = size;
+ }
++
++ @Override
++ public Location getLocation() {
++ return player.getBukkitEntity().getLocation();
++ }
+ // CraftBukkit end
+
public PlayerInventory(EntityHuman entityhuman) {
+ this.g = new ItemStack[][] { this.items, this.armor, this.extraSlots};
this.player = entityhuman;
- }
-@@ -43,6 +83,22 @@
- return -1;
+@@ -35,6 +81,22 @@
+ return itemstack.getItem() == itemstack1.getItem() && (!itemstack.usesData() || itemstack.getData() == itemstack1.getData()) && ItemStack.equals(itemstack, itemstack1);
}
+ // CraftBukkit start - Watch method above! :D
@@ -77,7 +83,7 @@
public int getFirstEmptySlotIndex() {
for (int i = 0; i < this.items.length; ++i) {
if (this.items[i] == null) {
-@@ -390,7 +446,7 @@
+@@ -455,7 +517,7 @@
}
public int getMaxStackSize() {
@@ -85,16 +91,16 @@
+ return maxStack; // CraftBukkit
}
- public boolean b(Block block) {
-@@ -466,6 +522,11 @@
+ public boolean b(IBlockData iblockdata) {
+@@ -511,6 +573,11 @@
}
public ItemStack getCarried() {
+ // CraftBukkit start
-+ if (this.f != null && this.f.count == 0) {
++ if (this.carried != null && this.carried.count == 0) {
+ this.setCarried(null);
+ }
+ // CraftBukkit end
- return this.f;
+ return this.carried;
}
diff --git a/nms-patches/PlayerList.patch b/nms-patches/PlayerList.patch
index 52d22e6f..6afc1220 100644
--- a/nms-patches/PlayerList.patch
+++ b/nms-patches/PlayerList.patch
@@ -75,20 +75,18 @@
WorldServer worldserver = this.server.getWorldServer(entityplayer.dimension);
WorldData worlddata = worldserver.getWorldData();
BlockPosition blockposition = worldserver.getSpawn();
-@@ -79,7 +114,8 @@
- this.a(entityplayer, (EntityPlayer) null, worldserver);
+@@ -80,6 +115,7 @@
PlayerConnection playerconnection = new PlayerConnection(this.server, networkmanager, entityplayer);
-- playerconnection.sendPacket(new PacketPlayOutLogin(entityplayer.getId(), entityplayer.playerInteractManager.getGameMode(), worlddata.isHardcore(), worldserver.worldProvider.getDimension(), worldserver.getDifficulty(), this.getMaxPlayers(), worlddata.getType(), worldserver.getGameRules().getBoolean("reducedDebugInfo")));
-+ playerconnection.sendPacket(new PacketPlayOutLogin(entityplayer.getId(), entityplayer.playerInteractManager.getGameMode(), worlddata.isHardcore(), worldserver.worldProvider.getDimension(), worldserver.getDifficulty(), Math.min(this.getMaxPlayers(), 60), worlddata.getType(), worldserver.getGameRules().getBoolean("reducedDebugInfo"))); // CraftBukkit - cap player list to 60
+ playerconnection.sendPacket(new PacketPlayOutLogin(entityplayer.getId(), entityplayer.playerInteractManager.getGameMode(), worlddata.isHardcore(), worldserver.worldProvider.getDimensionManager().getDimensionID(), worldserver.getDifficulty(), this.getMaxPlayers(), worlddata.getType(), worldserver.getGameRules().getBoolean("reducedDebugInfo")));
+ entityplayer.getBukkitEntity().sendSupportedChannels(); // CraftBukkit
playerconnection.sendPacket(new PacketPlayOutCustomPayload("MC|Brand", (new PacketDataSerializer(Unpooled.buffer())).a(this.getServer().getServerModName())));
playerconnection.sendPacket(new PacketPlayOutServerDifficulty(worlddata.getDifficulty(), worlddata.isDifficultyLocked()));
playerconnection.sendPacket(new PacketPlayOutSpawnPosition(blockposition));
-@@ -89,17 +125,23 @@
+@@ -90,17 +126,23 @@
entityplayer.getStatisticManager().updateStatistics(entityplayer);
this.sendScoreboard((ScoreboardServer) worldserver.getScoreboard(), entityplayer);
- this.server.aH();
+ this.server.aC();
- ChatMessage chatmessage;
+ // CraftBukkit start - login message is handled in the event
+ // ChatMessage chatmessage;
@@ -114,17 +112,17 @@
+ 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().length() > 0) {
-@@ -126,6 +168,8 @@
- }
+ if (!this.server.getResourcePack().isEmpty()) {
+@@ -160,6 +202,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 + ")");
}
public void sendScoreboard(ScoreboardServer scoreboardserver, EntityPlayer entityplayer) {
-@@ -158,6 +202,7 @@
+@@ -192,26 +236,27 @@
}
public void setPlayerFileData(WorldServer[] aworldserver) {
@@ -132,16 +130,41 @@
this.playerFileData = aworldserver[0].getDataManager().getPlayerFileData();
aworldserver[0].getWorldBorder().a(new IWorldBorderListener() {
public void a(WorldBorder worldborder, double d0) {
-@@ -202,7 +247,7 @@
+- PlayerList.this.sendAll(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.SET_SIZE));
++ PlayerList.this.sendAll(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.SET_SIZE), worldborder.world);
+ }
+
+ public void a(WorldBorder worldborder, double d0, double d1, long i) {
+- PlayerList.this.sendAll(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.LERP_SIZE));
++ PlayerList.this.sendAll(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.LERP_SIZE), worldborder.world);
+ }
+
+ public void a(WorldBorder worldborder, double d0, double d1) {
+- PlayerList.this.sendAll(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.SET_CENTER));
++ PlayerList.this.sendAll(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.SET_CENTER), worldborder.world);
+ }
+
+ public void a(WorldBorder worldborder, int i) {
+- PlayerList.this.sendAll(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.SET_WARNING_TIME));
++ PlayerList.this.sendAll(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.SET_WARNING_TIME), worldborder.world);
+ }
+
+ public void b(WorldBorder worldborder, int i) {
+- PlayerList.this.sendAll(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.SET_WARNING_BLOCKS));
++ PlayerList.this.sendAll(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.SET_WARNING_BLOCKS), worldborder.world);
+ }
+
+ public void b(WorldBorder worldborder, double d0) {}
+@@ -236,7 +281,7 @@
}
public NBTTagCompound a(EntityPlayer entityplayer) {
-- NBTTagCompound nbttagcompound = this.server.worldServer[0].getWorldData().i();
-+ NBTTagCompound nbttagcompound = this.server.worlds.get(0).getWorldData().i(); // CraftBukkit
+- NBTTagCompound nbttagcompound = this.server.worldServer[0].getWorldData().h();
++ NBTTagCompound nbttagcompound = this.server.worlds.get(0).getWorldData().h(); // CraftBukkit
NBTTagCompound nbttagcompound1;
- if (entityplayer.getName().equals(this.server.S()) && nbttagcompound != null) {
-@@ -226,33 +271,72 @@
+ if (entityplayer.getName().equals(this.server.Q()) && nbttagcompound != null) {
+@@ -260,28 +305,70 @@
}
@@ -153,8 +176,6 @@
+ // this.sendAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, new EntityPlayer[] { entityplayer})); // CraftBukkit - replaced with loop below
WorldServer worldserver = this.server.getWorldServer(entityplayer.dimension);
-- worldserver.addEntity(entityplayer);
-- this.a(entityplayer, (WorldServer) null);
+ // CraftBukkit start
+ PlayerJoinEvent playerJoinEvent = new PlayerJoinEvent(cserver.getPlayer(entityplayer), joinMessage);
+ cserver.getPluginManager().callEvent(playerJoinEvent);
@@ -172,10 +193,11 @@
+
+ // CraftBukkit start - sendAll above replaced with this loop
+ PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, entityplayer);
-
++
for (int i = 0; i < this.players.size(); ++i) {
- EntityPlayer entityplayer1 = (EntityPlayer) this.players.get(i);
-
+- entityplayer.playerConnection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, new EntityPlayer[] { (EntityPlayer) this.players.get(i)}));
++ EntityPlayer entityplayer1 = (EntityPlayer) this.players.get(i);
++
+ if (entityplayer1.getBukkitEntity().canSee(entityplayer.getBukkitEntity())) {
+ entityplayer1.playerConnection.sendPacket(packet);
+ }
@@ -184,10 +206,12 @@
+ continue;
+ }
+
- entityplayer.playerConnection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, new EntityPlayer[] { entityplayer1}));
++ entityplayer.playerConnection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, new EntityPlayer[] { entityplayer1}));
}
+ // CraftBukkit end
+- worldserver.addEntity(entityplayer);
+- this.a(entityplayer, (WorldServer) null);
+ // CraftBukkit start - Only add if the player wasn't moved in the event
+ if (entityplayer.world == worldserver && !worldserver.players.contains(entityplayer)) {
+ worldserver.addEntity(entityplayer);
@@ -197,11 +221,13 @@
}
public void d(EntityPlayer entityplayer) {
- entityplayer.u().getPlayerChunkMap().movePlayer(entityplayer);
+ entityplayer.x().getPlayerChunkMap().movePlayer(entityplayer);
}
- public void disconnect(EntityPlayer entityplayer) {
+ public String disconnect(EntityPlayer entityplayer) { // CraftBukkit - return string
+ WorldServer worldserver = entityplayer.x();
+
entityplayer.b(StatisticList.f);
+
+ // CraftBukkit start - Quitting must be before we do final save of data, in case plugins need to modify it
@@ -213,14 +239,9 @@
+ // CraftBukkit end
+
this.savePlayerFile(entityplayer);
- WorldServer worldserver = entityplayer.u();
-
-- if (entityplayer.vehicle != null) {
-+ if (entityplayer.vehicle != null && !(entityplayer.vehicle instanceof EntityPlayer)) { // CraftBukkit - Don't remove players
- worldserver.removeEntity(entityplayer.vehicle);
- PlayerList.f.debug("removing player mount");
- }
-@@ -268,13 +352,61 @@
+ if (entityplayer.isPassenger()) {
+ Entity entity = entityplayer.getVehicle();
+@@ -313,13 +400,61 @@
this.o.remove(uuid);
}
@@ -285,7 +306,7 @@
GameProfileBanEntry gameprofilebanentry = (GameProfileBanEntry) this.k.get(gameprofile);
s = "You are banned from this server!\nReason: " + gameprofilebanentry.getReason();
-@@ -282,10 +414,12 @@
+@@ -327,10 +462,12 @@
s = s + "\nYour ban will be removed on " + PlayerList.g.format(gameprofilebanentry.getExpires());
}
@@ -301,7 +322,7 @@
IpBanEntry ipbanentry = this.l.get(socketaddress);
s = "Your IP address is banned from this server!\nReason: " + ipbanentry.getReason();
-@@ -293,13 +427,25 @@
+@@ -338,13 +475,25 @@
s = s + "\nYour ban will be removed on " + PlayerList.g.format(ipbanentry.getExpires());
}
@@ -314,13 +335,13 @@
+ 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;
}
@@ -330,7 +351,7 @@
UUID uuid = EntityHuman.a(gameprofile);
ArrayList arraylist = Lists.newArrayList();
-@@ -334,17 +480,25 @@
+@@ -379,17 +528,25 @@
}
return new EntityPlayer(this.server, this.server.getWorldServer(0), gameprofile, (PlayerInteractManager) object);
@@ -344,10 +365,10 @@
+ return this.moveToWorld(entityplayer, i, flag, null, true);
+ }
+ public EntityPlayer moveToWorld(EntityPlayer entityplayer, int i, boolean flag, Location location, boolean avoidSuffocation) {
- entityplayer.u().getTracker().untrackPlayer(entityplayer);
-- entityplayer.u().getTracker().untrackEntity(entityplayer);
-+ // entityplayer.u().getTracker().untrackEntity(entityplayer); // CraftBukkit
- entityplayer.u().getPlayerChunkMap().removePlayer(entityplayer);
+ entityplayer.x().getTracker().untrackPlayer(entityplayer);
+- entityplayer.x().getTracker().untrackEntity(entityplayer);
++ // entityplayer.x().getTracker().untrackEntity(entityplayer); // CraftBukkit
+ entityplayer.x().getPlayerChunkMap().removePlayer(entityplayer);
this.players.remove(entityplayer);
this.server.getWorldServer(entityplayer.dimension).removeEntity(entityplayer);
BlockPosition blockposition = entityplayer.getBed();
@@ -357,21 +378,22 @@
entityplayer.dimension = i;
Object object;
-@@ -355,80 +509,276 @@
+@@ -400,6 +557,11 @@
}
EntityPlayer entityplayer1 = new EntityPlayer(this.server, this.server.getWorldServer(entityplayer.dimension), entityplayer.getProfile(), (PlayerInteractManager) object);
--
+ // */
+ EntityPlayer entityplayer1 = entityplayer;
+ org.bukkit.World fromWorld = entityplayer.getBukkitEntity().getWorld();
+ entityplayer.viewingCredits = false;
+ // CraftBukkit end
-+
+
entityplayer1.playerConnection = entityplayer.playerConnection;
entityplayer1.copyTo(entityplayer, flag);
- entityplayer1.d(entityplayer.getId());
- entityplayer1.o(entityplayer);
+@@ -414,43 +576,157 @@
+ entityplayer1.a(s);
+ }
+
- WorldServer worldserver = this.server.getWorldServer(entityplayer.dimension);
+ // WorldServer worldserver = this.server.getWorldServer(entityplayer.dimension); // CraftBukkit - handled later
@@ -420,7 +442,7 @@
+ entityplayer1.setLocation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
+ // CraftBukkit end
- worldserver.chunkProviderServer.getChunkAt((int) entityplayer1.locX >> 4, (int) entityplayer1.locZ >> 4);
+ 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) {
@@ -445,6 +467,7 @@
entityplayer1.playerConnection.sendPacket(new PacketPlayOutSpawnPosition(blockposition1));
entityplayer1.playerConnection.sendPacket(new PacketPlayOutExperience(entityplayer1.exp, entityplayer1.expTotal, entityplayer1.expLevel));
this.b(entityplayer1, worldserver);
+- this.f(entityplayer1);
- worldserver.getPlayerChunkMap().addPlayer(entityplayer1);
- worldserver.addEntity(entityplayer1);
- this.players.add(entityplayer1);
@@ -483,9 +506,6 @@
return entityplayer1;
}
-- public void changeDimension(EntityPlayer entityplayer, int i) {
-- int j = entityplayer.dimension;
-- WorldServer worldserver = this.server.getWorldServer(entityplayer.dimension);
+ // CraftBukkit start - Replaced the standard handling of portals with a more customised method.
+ public void changeDimension(EntityPlayer entityplayer, int i, TeleportCause cause) {
+ WorldServer exitWorld = null;
@@ -497,9 +517,7 @@
+ }
+ }
+ }
-
-- entityplayer.dimension = i;
-- WorldServer worldserver1 = this.server.getWorldServer(entityplayer.dimension);
++
+ Location enter = entityplayer.getBukkitEntity().getLocation();
+ Location exit = null;
+ boolean useTravelAgent = false; // don't use agent for custom worlds or return from THE_END
@@ -516,17 +534,7 @@
+ useTravelAgent = true;
+ }
+ }
-
-- entityplayer.playerConnection.sendPacket(new PacketPlayOutRespawn(entityplayer.dimension, entityplayer.world.getDifficulty(), entityplayer.world.getWorldData().getType(), entityplayer.playerInteractManager.getGameMode()));
-- worldserver.removeEntity(entityplayer);
-- entityplayer.dead = false;
-- this.changeWorld(entityplayer, j, worldserver, worldserver1);
-- this.a(entityplayer, worldserver);
-- entityplayer.playerConnection.a(entityplayer.locX, entityplayer.locY, entityplayer.locZ, entityplayer.yaw, entityplayer.pitch);
-- entityplayer.playerInteractManager.a(worldserver1);
-- this.b(entityplayer, worldserver1);
-- this.updateClient(entityplayer);
-- Iterator iterator = entityplayer.getEffects().iterator();
++
+ TravelAgent agent = exit != null ? (TravelAgent) ((CraftWorld) exit.getWorld()).getHandle().getTravelAgent() : org.bukkit.craftbukkit.CraftTravelAgent.DEFAULT; // return arbitrary TA to compensate for implementation dependent plugins
+ PlayerPortalEvent event = new PlayerPortalEvent(entityplayer.getBukkitEntity(), enter, exit, agent, cause);
+ event.useTravelAgent(useTravelAgent);
@@ -534,32 +542,32 @@
+ if (event.isCancelled() || event.getTo() == null) {
+ return;
+ }
-
-- while (iterator.hasNext()) {
-- MobEffect mobeffect = (MobEffect) iterator.next();
++
+ exit = event.useTravelAgent() ? event.getPortalTravelAgent().findOrCreate(event.getTo()) : event.getTo();
+ if (exit == null) {
+ return;
+ }
+ exitWorld = ((CraftWorld) exit.getWorld()).getHandle();
-
-- entityplayer.playerConnection.sendPacket(new PacketPlayOutEntityEffect(entityplayer.getId(), mobeffect));
++
+ org.bukkit.event.player.PlayerTeleportEvent tpEvent = new org.bukkit.event.player.PlayerTeleportEvent(entityplayer.getBukkitEntity(), enter, exit, cause);
+ Bukkit.getServer().getPluginManager().callEvent(tpEvent);
+ if (tpEvent.isCancelled() || tpEvent.getTo() == null) {
+ return;
- }
-
++ }
++
+ Vector velocity = entityplayer.getBukkitEntity().getVelocity();
-+ boolean before = exitWorld.chunkProviderServer.forceChunkLoad;
-+ exitWorld.chunkProviderServer.forceChunkLoad = true;
+ exitWorld.getTravelAgent().adjustExit(entityplayer, exit, velocity);
-+ exitWorld.chunkProviderServer.forceChunkLoad = before;
+
+ this.moveToWorld(entityplayer, exitWorld.dimension, true, exit, false); // Vanilla doesn't check for suffocation when handling portals, so neither should we
+ if (entityplayer.motX != velocity.getX() || entityplayer.motY != velocity.getY() || entityplayer.motZ != velocity.getZ()) {
+ entityplayer.getBukkitEntity().setVelocity(velocity);
+ }
++ }
++
+ public void f(EntityPlayer entityplayer) {
+ GameProfile gameprofile = entityplayer.getProfile();
+ int i = this.isOp(gameprofile) ? this.operators.a(gameprofile) : 0;
+@@ -489,12 +765,111 @@
}
public void changeWorld(Entity entity, int i, WorldServer worldserver, WorldServer worldserver1) {
@@ -581,12 +589,12 @@
+ double d1 = enter.getZ();
+ double d2 = 8.0D;
+ /*
- double d0 = entity.locX;
- double d1 = entity.locZ;
- double d2 = 8.0D;
- float f = entity.yaw;
-
- worldserver.methodProfiler.a("moving");
++ double d0 = entity.locX;
++ double d1 = entity.locZ;
++ double d2 = 8.0D;
++ float f = entity.yaw;
++
++ worldserver.methodProfiler.a("moving");
+ */
+ if (worldserver1.dimension == -1) {
+ d0 = MathHelper.a(d0 / d2, worldserver1.getWorldBorder().b()+ 16.0D, worldserver1.getWorldBorder().d() - 16.0D);
@@ -656,12 +664,12 @@
+ int i = worldserver.dimension;
+
+ /*
-+ double d0 = entity.locX;
-+ double d1 = entity.locZ;
-+ double d2 = 8.0D;
-+ float f = entity.yaw;
-+
-+ worldserver.methodProfiler.a("moving");
+ double d0 = entity.locX;
+ double d1 = entity.locZ;
+ double d2 = 8.0D;
+ float f = entity.yaw;
+
+ worldserver.methodProfiler.a("moving");
+ */
+ entity.setPositionRotation(exit.getX(), exit.getY(), exit.getZ(), exit.getYaw(), exit.getPitch());
+ if (entity.isAlive()) {
@@ -671,7 +679,7 @@
if (entity.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);
-@@ -447,6 +797,8 @@
+@@ -513,6 +888,8 @@
BlockPosition blockposition;
if (i == 1) {
@@ -680,7 +688,7 @@
blockposition = worldserver1.getSpawn();
} else {
blockposition = worldserver1.getDimensionSpawn();
-@@ -460,15 +812,26 @@
+@@ -526,15 +903,26 @@
worldserver.entityJoinedWorld(entity, false);
}
}
@@ -709,7 +717,7 @@
worldserver1.addEntity(entity);
worldserver1.entityJoinedWorld(entity, false);
}
-@@ -477,6 +840,7 @@
+@@ -543,6 +931,7 @@
}
entity.spawnIn(worldserver1);
@@ -717,7 +725,7 @@
}
public void tick() {
-@@ -494,6 +858,25 @@
+@@ -560,6 +949,25 @@
}
@@ -740,14 +748,13 @@
+ }
+ // CraftBukkit end
+
- public void a(Packet packet, int i) {
+ public void a(Packet<?> packet, int i) {
for (int j = 0; j < this.players.size(); ++j) {
EntityPlayer entityplayer = (EntityPlayer) this.players.get(j);
-@@ -589,10 +972,24 @@
+@@ -658,11 +1066,23 @@
- public void addOp(GameProfile gameprofile) {
- this.operators.add(new OpListEntry(gameprofile, this.server.p(), this.operators.b(gameprofile)));
-+
+ 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) {
@@ -758,7 +765,7 @@
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) {
@@ -767,17 +774,17 @@
+ // CraftBukkit end
}
- public boolean isWhitelisted(GameProfile gameprofile) {
-@@ -600,7 +997,7 @@
+ private void b(EntityPlayer entityplayer, int i) {
+@@ -687,7 +1107,7 @@
}
public boolean isOp(GameProfile gameprofile) {
-- return this.operators.d(gameprofile) || this.server.T() && this.server.worldServer[0].getWorldData().v() && this.server.S().equalsIgnoreCase(gameprofile.getName()) || this.t;
-+ return this.operators.d(gameprofile) || this.server.T() && this.server.worlds.get(0).getWorldData().v() && this.server.S().equalsIgnoreCase(gameprofile.getName()) || this.t; // CraftBukkit
+- return this.operators.d(gameprofile) || this.server.R() && this.server.worldServer[0].getWorldData().u() && this.server.Q().equalsIgnoreCase(gameprofile.getName()) || this.t;
++ return this.operators.d(gameprofile) || this.server.R() && this.server.worlds.get(0).getWorldData().u() && this.server.Q().equalsIgnoreCase(gameprofile.getName()) || this.t; // CraftBukkit
}
public EntityPlayer getPlayer(String s) {
-@@ -627,6 +1024,12 @@
+@@ -710,6 +1130,12 @@
for (int j = 0; j < this.players.size(); ++j) {
EntityPlayer entityplayer = (EntityPlayer) this.players.get(j);
@@ -790,7 +797,7 @@
if (entityplayer != entityhuman && entityplayer.dimension == i) {
double d4 = d0 - entityplayer.locX;
double d5 = d1 - entityplayer.locY;
-@@ -674,21 +1077,26 @@
+@@ -757,21 +1183,26 @@
public void reloadWhitelist() {}
public void b(EntityPlayer entityplayer, WorldServer worldserver) {
@@ -799,7 +806,7 @@
entityplayer.playerConnection.sendPacket(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.INITIALIZE));
entityplayer.playerConnection.sendPacket(new PacketPlayOutUpdateTime(worldserver.getTime(), worldserver.getDayTime(), worldserver.getGameRules().getBoolean("doDaylightCycle")));
- if (worldserver.S()) {
+ if (worldserver.W()) {
- 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)));
@@ -808,7 +815,7 @@
+ // entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(7, worldserver.j(1.0F)));
+ // entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(8, worldserver.h(1.0F)));
+ entityplayer.setPlayerWeather(org.bukkit.WeatherType.DOWNFALL, false);
-+ entityplayer.updateWeather(-worldserver.p, worldserver.p, -worldserver.r, worldserver.r);
++ entityplayer.updateWeather(-worldserver.o, worldserver.o, -worldserver.q, worldserver.q);
+ // CraftBukkit end
}
@@ -822,7 +829,7 @@
entityplayer.playerConnection.sendPacket(new PacketPlayOutHeldItemSlot(entityplayer.inventory.itemInHandIndex));
}
-@@ -701,7 +1109,7 @@
+@@ -784,7 +1215,7 @@
}
public String[] getSeenPlayers() {
@@ -831,7 +838,7 @@
}
public boolean getHasWhitelist() {
-@@ -751,16 +1159,26 @@
+@@ -834,16 +1265,26 @@
public void u() {
for (int i = 0; i < this.players.size(); ++i) {
@@ -860,7 +867,7 @@
}
public void sendMessage(IChatBaseComponent ichatbasecomponent) {
-@@ -797,8 +1215,10 @@
+@@ -880,8 +1321,10 @@
WorldServer[] aworldserver = this.server.worldServer;
int j = aworldserver.length;
diff --git a/nms-patches/PortalTravelAgent.patch b/nms-patches/PortalTravelAgent.patch
index 73698d3b..eef8a8d6 100644
--- a/nms-patches/PortalTravelAgent.patch
+++ b/nms-patches/PortalTravelAgent.patch
@@ -1,19 +1,17 @@
--- a/net/minecraft/server/PortalTravelAgent.java
+++ b/net/minecraft/server/PortalTravelAgent.java
-@@ -5,6 +5,12 @@
- import java.util.List;
- import java.util.Random;
+@@ -1,6 +1,10 @@
+ package net.minecraft.server;
-+// CraftBukkit start
+ import com.google.common.collect.Lists;
+import org.bukkit.Location;
+import org.bukkit.event.entity.EntityPortalExitEvent;
+import org.bukkit.util.Vector;
-+// CraftBukkit end
+
- public class PortalTravelAgent {
-
- private final WorldServer a;
-@@ -27,6 +33,19 @@
+ import java.util.Iterator;
+ import java.util.List;
+ import java.util.Random;
+@@ -27,6 +31,19 @@
int i = MathHelper.floor(entity.locX);
int j = MathHelper.floor(entity.locY) - 1;
int k = MathHelper.floor(entity.locZ);
@@ -33,7 +31,7 @@
byte b0 = 1;
byte b1 = 0;
-@@ -43,16 +62,63 @@
+@@ -43,16 +60,63 @@
}
}
@@ -59,7 +57,7 @@
+ int i2 = k + i1 * b1 - l * b0;
+ boolean flag = j1 < 0;
+
-+ if (this.a.getType(new BlockPosition(k1, l1, i2)).getBlock() != (flag ? Blocks.OBSIDIAN : Blocks.AIR)) {
++ if (this.world.getType(new BlockPosition(k1, l1, i2)).getBlock() != (flag ? Blocks.OBSIDIAN : Blocks.AIR)) {
+ return null;
+ }
+ }
@@ -77,7 +75,7 @@
+ return false;
+ }
+
-+ Location exit = new Location(this.a.getWorld(), found.getX(), found.getY(), found.getZ(), f, entity.pitch);
++ Location exit = new Location(this.world.getWorld(), found.getX(), found.getY(), found.getZ(), f, entity.pitch);
+ Vector velocity = entity.getBukkitEntity().getVelocity();
+ this.adjustExit(entity, exit, velocity);
+ entity.setPositionRotation(exit.getX(), exit.getY(), exit.getZ(), exit.getYaw(), exit.getPitch());
@@ -88,8 +86,8 @@
+ }
+
+ public BlockPosition findPortal(double x, double y, double z, int short1) {
-+ if (this.a.getWorld().getEnvironment() == org.bukkit.World.Environment.THE_END) {
-+ return this.findEndPortal(this.a.worldProvider.h());
++ if (this.world.getWorld().getEnvironment() == org.bukkit.World.Environment.THE_END) {
++ return this.findEndPortal(this.world.worldProvider.h());
+ }
+ // CraftBukkit end
double d0 = -1.0D;
@@ -102,17 +100,17 @@
boolean flag1 = true;
Object object = BlockPosition.ZERO;
long k = ChunkCoordIntPair.a(i, j);
-@@ -65,7 +131,7 @@
- portaltravelagent_chunkcoordinatesportal.c = this.a.getTime();
+@@ -65,7 +129,7 @@
+ portaltravelagent_chunkcoordinatesportal.c = this.world.getTime();
flag1 = false;
} else {
- BlockPosition blockposition = new BlockPosition(entity);
-+ BlockPosition blockposition = new BlockPosition(x, y, z);
++ BlockPosition blockposition = new BlockPosition(x, y, z); // CraftBukkit
for (int l = -128; l <= 128; ++l) {
BlockPosition blockposition1;
-@@ -95,6 +161,29 @@
- this.c.put(k, new PortalTravelAgent.ChunkCoordinatesPortal((BlockPosition) object, this.a.getTime()));
+@@ -95,6 +159,29 @@
+ this.c.put(k, new PortalTravelAgent.ChunkCoordinatesPortal((BlockPosition) object, this.world.getTime()));
this.d.add(Long.valueOf(k));
}
+ // CraftBukkit start - Move entity teleportation logic into exit
@@ -129,7 +127,7 @@
+ BlockPosition object = new BlockPosition(position.getBlockX(), position.getBlockY(), position.getBlockZ());
+ float f = position.getYaw();
+
-+ if (this.a.getWorld().getEnvironment() == org.bukkit.World.Environment.THE_END || entity.getBukkitEntity().getWorld().getEnvironment() == org.bukkit.World.Environment.THE_END || entity.aG() == null) {
++ if (this.world.getWorld().getEnvironment() == org.bukkit.World.Environment.THE_END || entity.getBukkitEntity().getWorld().getEnvironment() == org.bukkit.World.Environment.THE_END || entity.getPortalOffset() == null) {
+ // entity.setPositionRotation((double) i, (double) j, (double) k, entity.yaw, 0.0F);
+ // entity.motX = entity.motY = entity.motZ = 0.0D;
+ position.setPitch(0.0F);
@@ -141,20 +139,23 @@
double d2 = (double) ((BlockPosition) object).getX() + 0.5D;
double d3 = (double) ((BlockPosition) object).getY() + 0.5D;
-@@ -132,26 +221,60 @@
- f3 = -1.0F;
+@@ -133,30 +220,59 @@
f4 = 1.0F;
}
--
+
- double d6 = entity.motX;
- double d7 = entity.motZ;
-
- entity.motX = d6 * (double) f1 + d7 * (double) f4;
- entity.motZ = d6 * (double) f3 + d7 * (double) f2;
-- entity.yaw = f - (float) (entity.aH().opposite().b() * 90) + (float) (shapedetector_shapedetectorcollection.b().b() * 90);
-- entity.setPositionRotation(d2, d3, d4, entity.yaw, entity.pitch);
+- entity.yaw = f - (float) (entity.getPortalDirection().opposite().get2DRotationValue() * 90) + (float) (shapedetector_shapedetectorcollection.getFacing().get2DRotationValue() * 90);
+- if (entity instanceof EntityPlayer) {
+- ((EntityPlayer) entity).playerConnection.a(d2, d3, d4, entity.yaw, entity.pitch);
+- } else {
+- entity.setPositionRotation(d2, d3, d4, entity.yaw, entity.pitch);
+- }
+-
- return true;
-+
+ // CraftBukkit start
+ double d6 = velocity.getX();
+ double d7 = velocity.getZ();
@@ -163,7 +164,7 @@
+ // CraftBukkit start - Adjust position and velocity instances instead of entity
+ velocity.setX(d6 * (double) f1 + d7 * (double) f4);
+ velocity.setZ(d6 * (double) f3 + d7 * (double) f2);
-+ f = f - (float) (entity.aH().opposite().b() * 90) + (float) (shapedetector_shapedetectorcollection.b().b() * 90);
++ f = f - (float) (entity.getPortalDirection().opposite().get2DRotationValue() * 90) + (float) (shapedetector_shapedetectorcollection.getFacing().get2DRotationValue() * 90);
+ // entity.setPositionRotation(d2, d3, d4, entity.yaw, entity.pitch);
+ position.setX(d2);
+ position.setY(d3);
@@ -171,7 +172,7 @@
+ position.setYaw(f);
+ }
+ EntityPortalExitEvent event = new EntityPortalExitEvent(entity.getBukkitEntity(), from, position, before, velocity);
-+ this.a.getServer().getPluginManager().callEvent(event);
++ this.world.getServer().getPluginManager().callEvent(event);
+ Location to = event.getTo();
+ if (event.isCancelled() || to == null || !entity.isAlive()) {
+ position.setX(from.getX());
@@ -199,7 +200,7 @@
+ }
+
+ public boolean createPortal(double x, double y, double z, int b0) {
-+ if (this.a.getWorld().getEnvironment() == org.bukkit.World.Environment.THE_END) {
++ if (this.world.getWorld().getEnvironment() == org.bukkit.World.Environment.THE_END) {
+ createEndPortal(x, y, z);
+ return true;
+ }
@@ -216,7 +217,7 @@
int l = i;
int i1 = j;
int j1 = k;
-@@ -176,10 +299,10 @@
+@@ -181,10 +297,10 @@
double d4;
for (i2 = i - b0; i2 <= i + b0; ++i2) {
@@ -228,8 +229,8 @@
+ d2 = (double) j2 + 0.5D - z; // CraftBukkit
label271:
- for (k2 = this.a.V() - 1; k2 >= 0; --k2) {
-@@ -211,7 +334,7 @@
+ for (k2 = this.world.Z() - 1; k2 >= 0; --k2) {
+@@ -216,7 +332,7 @@
}
}
@@ -238,7 +239,7 @@
d4 = d1 * d1 + d3 * d3 + d2 * d2;
if (d0 < 0.0D || d4 < d0) {
d0 = d4;
-@@ -228,10 +351,10 @@
+@@ -233,10 +349,10 @@
if (d0 < 0.0D) {
for (i2 = i - b0; i2 <= i + b0; ++i2) {
@@ -250,8 +251,8 @@
+ d2 = (double) j2 + 0.5D - z; // CraftBukkit
label219:
- for (k2 = this.a.V() - 1; k2 >= 0; --k2) {
-@@ -256,7 +379,7 @@
+ for (k2 = this.world.Z() - 1; k2 >= 0; --k2) {
+@@ -261,7 +377,7 @@
}
}
@@ -260,3 +261,14 @@
d4 = d1 * d1 + d3 * d3 + d2 * d2;
if (d0 < 0.0D || d4 < d0) {
d0 = d4;
+@@ -362,5 +478,10 @@
+ super(blockposition.getX(), blockposition.getY(), blockposition.getZ());
+ this.c = i;
+ }
++
++ @Override
++ public int compareTo(BaseBlockPosition o) {
++ return this.i(o);
++ }
+ }
+ }
diff --git a/nms-patches/RecipeTippedArrow.patch b/nms-patches/RecipeTippedArrow.patch
new file mode 100644
index 00000000..5fa5a86d
--- /dev/null
+++ b/nms-patches/RecipeTippedArrow.patch
@@ -0,0 +1,20 @@
+--- a/net/minecraft/server/RecipeTippedArrow.java
++++ b/net/minecraft/server/RecipeTippedArrow.java
+@@ -2,11 +2,15 @@
+
+ import java.util.Collection;
+
+-class RecipeTippedArrow implements IRecipe {
++class RecipeTippedArrow extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends
+
+ private static final ItemStack[] a = new ItemStack[9];
+
+- RecipeTippedArrow() {}
++ // CraftBukkit start - Delegate to new parent class with bogus info
++ public RecipeTippedArrow() {
++ super(new ItemStack(Items.TIPPED_ARROW, 0, -1), java.util.Arrays.asList(new ItemStack(Items.ARROW, 8, 0), new ItemStack(Items.LINGERING_POTION, 0, 0)));
++ }
++ // CraftBukkit end
+
+ public boolean a(InventoryCrafting inventorycrafting, World world) {
+ if (inventorycrafting.i() == 3 && inventorycrafting.h() == 3) {
diff --git a/nms-patches/RecipesFurnace.patch b/nms-patches/RecipesFurnace.patch
index 79bae8ab..f166bfb8 100644
--- a/nms-patches/RecipesFurnace.patch
+++ b/nms-patches/RecipesFurnace.patch
@@ -1,26 +1,22 @@
--- a/net/minecraft/server/RecipesFurnace.java
+++ b/net/minecraft/server/RecipesFurnace.java
-@@ -10,12 +10,13 @@
+@@ -9,7 +9,9 @@
+
private static final RecipesFurnace a = new RecipesFurnace();
public Map<ItemStack, ItemStack> recipes = Maps.newHashMap();
- private Map<ItemStack, Float> c = Maps.newHashMap();
+- private Map<ItemStack, Float> c = Maps.newHashMap();
++ private Map<ItemStack, Float> c = Maps.newHashMap(); // PAIL: rename
+ public Map customRecipes = Maps.newHashMap(); // CraftBukkit - add field
++ public Map customExperience = Maps.newHashMap(); // CraftBukkit - add field
public static RecipesFurnace getInstance() {
return RecipesFurnace.a;
- }
-
-- private RecipesFurnace() {
-+ public RecipesFurnace() { // PAIL: Public
- this.registerRecipe(Blocks.IRON_ORE, new ItemStack(Items.IRON_INGOT), 0.7F);
- this.registerRecipe(Blocks.GOLD_ORE, new ItemStack(Items.GOLD_INGOT), 1.0F);
- this.registerRecipe(Blocks.DIAMOND_ORE, new ItemStack(Items.DIAMOND), 1.0F);
-@@ -53,6 +54,12 @@
+@@ -54,6 +56,12 @@
this.registerRecipe(Blocks.QUARTZ_ORE, new ItemStack(Items.QUARTZ), 0.2F);
}
+ // CraftBukkit start - add method
-+ public void registerRecipe(ItemStack itemstack, ItemStack itemstack1) {
++ public void registerRecipe(ItemStack itemstack, ItemStack itemstack1, float f) {
+ this.customRecipes.put(itemstack, itemstack1);
+ }
+ // CraftBukkit end
@@ -28,7 +24,7 @@
public void registerRecipe(Block block, ItemStack itemstack, float f) {
this.a(Item.getItemOf(block), itemstack, f);
}
-@@ -67,13 +74,23 @@
+@@ -68,13 +76,23 @@
}
public ItemStack getResult(ItemStack itemstack) {
@@ -44,7 +40,7 @@
if (!iterator.hasNext()) {
- return null;
+ // CraftBukkit start - fall back to vanilla recipes
-+ if (!vanilla && !recipes.isEmpty()) {
++ if (!vanilla && !this.recipes.isEmpty()) {
+ iterator = this.recipes.entrySet().iterator();
+ vanilla = true;
+ } else {
@@ -54,3 +50,29 @@
}
entry = (Entry) iterator.next();
+@@ -92,13 +110,23 @@
+ }
+
+ public float b(ItemStack itemstack) {
+- Iterator iterator = this.c.entrySet().iterator();
++ // CraftBukkit start - initialize to customRecipes
++ boolean vanilla = false;
++ Iterator iterator = this.customRecipes.entrySet().iterator();
++ // CraftBukkit end
+
+ Entry entry;
+
+ do {
+ if (!iterator.hasNext()) {
+- return 0.0F;
++ // CraftBukkit start - fall back to vanilla recipes
++ if (!vanilla && !this.c.isEmpty()) {
++ iterator = this.c.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
new file mode 100644
index 00000000..d1ef9efe
--- /dev/null
+++ b/nms-patches/RecipiesShield.patch
@@ -0,0 +1,18 @@
+--- a/net/minecraft/server/RecipiesShield.java
++++ b/net/minecraft/server/RecipiesShield.java
+@@ -11,9 +11,13 @@
+
+ static class SyntheticClass_1 { }
+
+- static class Decoration implements IRecipe {
++ static class Decoration extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends
+
+- private Decoration() {}
++ // CraftBukkit start - Delegate to new parent class with bogus info
++ private Decoration() {
++ super(new ItemStack(Items.SHIELD, 0 ,0), java.util.Arrays.asList(new ItemStack(Items.BANNER, 0, 0)));
++ }
++ // CraftBukkit end
+
+ public boolean a(InventoryCrafting inventorycrafting, World world) {
+ ItemStack itemstack = null;
diff --git a/nms-patches/RegionFile.patch b/nms-patches/RegionFile.patch
index 6153576b..5dd5c60a 100644
--- a/nms-patches/RegionFile.patch
+++ b/nms-patches/RegionFile.patch
@@ -1,6 +1,6 @@
--- a/net/minecraft/server/RegionFile.java
+++ b/net/minecraft/server/RegionFile.java
-@@ -90,6 +90,45 @@
+@@ -85,6 +85,45 @@
}
diff --git a/nms-patches/RemoteControlCommandListener.patch b/nms-patches/RemoteControlCommandListener.patch
index 6331f69e..bcbbeb0c 100644
--- a/nms-patches/RemoteControlCommandListener.patch
+++ b/nms-patches/RemoteControlCommandListener.patch
@@ -1,15 +1,15 @@
--- a/net/minecraft/server/RemoteControlCommandListener.java
+++ b/net/minecraft/server/RemoteControlCommandListener.java
-@@ -27,6 +27,12 @@
+@@ -25,6 +25,12 @@
return new ChatComponentText(this.getName());
}
+ // CraftBukkit start - Send a String
+ public void sendMessage(String message) {
-+ this.b.append(message);
++ this.a.append(message);
+ }
+ // CraftBukkit end
+
public void sendMessage(IChatBaseComponent ichatbasecomponent) {
- this.b.append(ichatbasecomponent.c());
+ this.a.append(ichatbasecomponent.toPlainText());
}
diff --git a/nms-patches/ScoreboardServer.patch b/nms-patches/ScoreboardServer.patch
index c480fff1..500a4c9c 100644
--- a/nms-patches/ScoreboardServer.patch
+++ b/nms-patches/ScoreboardServer.patch
@@ -93,7 +93,7 @@
this.b();
}
-@@ -160,6 +160,7 @@
+@@ -161,6 +161,7 @@
while (iterator.hasNext()) {
EntityPlayer entityplayer = (EntityPlayer) iterator.next();
@@ -101,7 +101,7 @@
Iterator iterator1 = list.iterator();
while (iterator1.hasNext()) {
-@@ -192,6 +193,7 @@
+@@ -193,6 +194,7 @@
while (iterator.hasNext()) {
EntityPlayer entityplayer = (EntityPlayer) iterator.next();
@@ -109,7 +109,7 @@
Iterator iterator1 = list.iterator();
while (iterator1.hasNext()) {
-@@ -215,4 +217,14 @@
+@@ -216,4 +218,14 @@
return i;
}
diff --git a/nms-patches/SecondaryWorldServer.patch b/nms-patches/SecondaryWorldServer.patch
index a26d9cd0..cde0aaa9 100644
--- a/nms-patches/SecondaryWorldServer.patch
+++ b/nms-patches/SecondaryWorldServer.patch
@@ -15,7 +15,7 @@
worldserver.getWorldBorder().a(new IWorldBorderListener() {
public void a(WorldBorder worldborder, double d0) {
SecondaryWorldServer.this.getWorldBorder().setSize(d0);
-@@ -36,13 +39,14 @@
+@@ -36,9 +39,10 @@
SecondaryWorldServer.this.getWorldBorder().setDamageBuffer(d0);
}
});
@@ -26,17 +26,13 @@
+ // protected void a() {} // CraftBukkit
public World b() {
- this.worldMaps = this.a.T();
-- this.scoreboard = this.a.getScoreboard();
-+ // this.scoreboard = this.a.getScoreboard(); // CraftBukkit
- String s = PersistentVillage.a(this.worldProvider);
- PersistentVillage persistentvillage = (PersistentVillage) this.worldMaps.get(PersistentVillage.class, s);
-
-@@ -54,6 +58,6 @@
+ this.worldMaps = this.a.X();
+@@ -55,7 +59,7 @@
this.villages.a((World) this);
}
- return this;
+ return super.b(); // CraftBukkit
}
- }
+
+ public void c() {
diff --git a/nms-patches/SpawnerCreature.patch b/nms-patches/SpawnerCreature.patch
index be143f6c..e9dea5c1 100644
--- a/nms-patches/SpawnerCreature.patch
+++ b/nms-patches/SpawnerCreature.patch
@@ -1,15 +1,20 @@
--- a/net/minecraft/server/SpawnerCreature.java
+++ b/net/minecraft/server/SpawnerCreature.java
-@@ -6,10 +6,16 @@
- import java.util.Random;
- import java.util.Set;
+@@ -1,15 +1,19 @@
+ package net.minecraft.server;
+-import com.google.common.collect.Sets;
+ import java.util.Iterator;
+ import java.util.List;
+ import java.util.Random;
+-import java.util.Set;
++
+// CraftBukkit start
+import org.bukkit.craftbukkit.util.LongHash;
+import org.bukkit.craftbukkit.util.LongHashSet;
+import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
+// CraftBukkit end
-+
+
public final class SpawnerCreature {
private static final int a = (int) Math.pow(17.0D, 2.0D);
@@ -18,7 +23,7 @@
public SpawnerCreature() {}
-@@ -36,14 +42,17 @@
+@@ -36,18 +40,21 @@
for (int i1 = -b0; i1 <= b0; ++i1) {
for (k = -b0; k <= b0; ++k) {
boolean flag3 = i1 == -b0 || i1 == b0 || k == -b0 || k == b0;
@@ -31,16 +36,21 @@
+ if (!this.b.contains(chunkCoords)) {
++i;
- if (!flag3 && worldserver.getWorldBorder().isInBounds(chunkcoordintpair)) {
-- this.b.add(chunkcoordintpair);
-+ if (!flag3 && worldserver.getWorldBorder().isInBounds(i1 + l, k + j)) {
-+ this.b.add(chunkCoords);
+- PlayerChunk playerchunk = worldserver.getPlayerChunkMap().b(chunkcoordintpair.x, chunkcoordintpair.z);
++ if (!flag3 && worldserver.getWorldBorder().isInBounds(i1 + l, k + j)) { // CraftBukkit
++ PlayerChunk playerchunk = worldserver.getPlayerChunkMap().b(i1 + l, k + j); // CraftBukkit
+
+ if (playerchunk != null && playerchunk.e()) {
+- this.b.add(chunkcoordintpair);
++ this.b.add(chunkCoords);
+ }
}
}
+ // CraftBukkit end
}
}
}
-@@ -58,17 +67,41 @@
+@@ -62,9 +69,31 @@
for (int k1 = 0; k1 < j; ++k1) {
EnumCreatureType enumcreaturetype = aenumcreaturetype[k1];
@@ -72,9 +82,10 @@
+ int l1 = limit * i / a; // CraftBukkit - use per-world limits
if (k <= l1) {
- Iterator iterator1 = this.b.iterator();
+ BlockPosition.MutableBlockPosition blockposition_mutableblockposition = new BlockPosition.MutableBlockPosition();
+@@ -72,8 +101,10 @@
- label115:
+ label120:
while (iterator1.hasNext()) {
- ChunkCoordIntPair chunkcoordintpair1 = (ChunkCoordIntPair) iterator1.next();
- BlockPosition blockposition1 = getRandomPosition(worldserver, chunkcoordintpair1.x, chunkcoordintpair1.z);
@@ -85,22 +96,22 @@
int i2 = blockposition1.getX();
int j2 = blockposition1.getY();
int k2 = blockposition1.getZ();
-@@ -120,7 +153,7 @@
- groupdataentity = entityinsentient.prepare(worldserver.E(new BlockPosition(entityinsentient)), groupdataentity);
+@@ -126,7 +157,7 @@
+ groupdataentity = entityinsentient.prepare(worldserver.D(new BlockPosition(entityinsentient)), groupdataentity);
if (entityinsentient.canSpawn()) {
++l2;
- worldserver.addEntity(entityinsentient);
+ worldserver.addEntity(entityinsentient, SpawnReason.NATURAL); // CraftBukkit - Added a reason for spawning this creature
+ } else {
+ entityinsentient.die();
}
-
- if (l2 >= entityinsentient.bV()) {
-@@ -214,8 +247,10 @@
+@@ -226,8 +257,10 @@
}
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.E(new BlockPosition(entityinsentient)), groupdataentity);
+ groupdataentity = entityinsentient.prepare(world.D(new BlockPosition(entityinsentient)), groupdataentity);
+ world.addEntity(entityinsentient, SpawnReason.CHUNK_GEN);
+ // CraftBukkit end
flag = true;
diff --git a/nms-patches/TileEntity.patch b/nms-patches/TileEntity.patch
index c4c4ea66..0086c128 100644
--- a/nms-patches/TileEntity.patch
+++ b/nms-patches/TileEntity.patch
@@ -9,9 +9,9 @@
public abstract class TileEntity {
private static final Logger a = LogManager.getLogger();
-@@ -221,4 +223,13 @@
- a(TileEntityFlowerPot.class, "FlowerPot");
- a(TileEntityBanner.class, "Banner");
+@@ -234,4 +236,13 @@
+ a(TileEntityEndGateway.class, "EndGateway");
+ a(TileEntityCommand.class, "Control");
}
+
+ // CraftBukkit start - add method
diff --git a/nms-patches/TileEntityBanner.patch b/nms-patches/TileEntityBanner.patch
index f8cd7bc2..d22bca51 100644
--- a/nms-patches/TileEntityBanner.patch
+++ b/nms-patches/TileEntityBanner.patch
@@ -6,7 +6,7 @@
this.patterns = (NBTTagList) nbttagcompound.getList("Patterns", 10).clone();
+ // CraftBukkit start
+ while (this.patterns.size() > 20) {
-+ this.patterns.a(20); // PAIL Rename remove
++ this.patterns.remove(20);
+ }
+ // CraftBukkit end
}
@@ -18,7 +18,7 @@
this.patterns = nbttagcompound.getList("Patterns", 10);
+ // CraftBukkit start
+ while (this.patterns.size() > 20) {
-+ this.patterns.a(20); // PAIL Rename remove
++ this.patterns.remove(20);
+ }
+ // CraftBukkit end
this.h = null;
diff --git a/nms-patches/TileEntityBeacon.patch b/nms-patches/TileEntityBeacon.patch
index 7b81e98c..f60dcd39 100644
--- a/nms-patches/TileEntityBeacon.patch
+++ b/nms-patches/TileEntityBeacon.patch
@@ -1,21 +1,21 @@
--- a/net/minecraft/server/TileEntityBeacon.java
+++ b/net/minecraft/server/TileEntityBeacon.java
-@@ -5,6 +5,11 @@
- import java.util.Iterator;
+@@ -8,6 +8,11 @@
import java.util.List;
+ import java.util.Set;
+// CraftBukkit start
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
+import org.bukkit.entity.HumanEntity;
+// CraftBukkit end
+
- public class TileEntityBeacon extends TileEntityContainer implements IUpdatePlayerListBox, IInventory {
+ public class TileEntityBeacon extends TileEntityContainer implements ITickable, IWorldInventory {
- public static final MobEffectList[][] a = new MobEffectList[][] { { MobEffectList.FASTER_MOVEMENT, MobEffectList.FASTER_DIG}, { MobEffectList.RESISTANCE, MobEffectList.JUMP}, { MobEffectList.INCREASE_DAMAGE}, { MobEffectList.REGENERATION}};
-@@ -15,6 +20,30 @@
- private int l;
+ public static final MobEffectList[][] a = new MobEffectList[][] { { MobEffects.FASTER_MOVEMENT, MobEffects.FASTER_DIG}, { MobEffects.RESISTANCE, MobEffects.JUMP}, { MobEffects.INCREASE_DAMAGE}, { MobEffects.REGENERATION}};
+@@ -19,6 +24,30 @@
+ private MobEffectList m;
private ItemStack inventorySlot;
- private String n;
+ private String o;
+ // CraftBukkit start - add fields and methods
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
+ private int maxStack = MAX_STACK;
@@ -43,12 +43,3 @@
public TileEntityBeacon() {}
-@@ -246,7 +275,7 @@
- }
-
- public int getMaxStackSize() {
-- return 1;
-+ return maxStack; // CraftBukkit
- }
-
- public boolean a(EntityHuman entityhuman) {
diff --git a/nms-patches/TileEntityBrewingStand.patch b/nms-patches/TileEntityBrewingStand.patch
index d0158f54..09127560 100644
--- a/nms-patches/TileEntityBrewingStand.patch
+++ b/nms-patches/TileEntityBrewingStand.patch
@@ -1,22 +1,23 @@
--- a/net/minecraft/server/TileEntityBrewingStand.java
+++ b/net/minecraft/server/TileEntityBrewingStand.java
-@@ -3,6 +3,12 @@
+@@ -2,6 +2,13 @@
+
import java.util.Arrays;
- import java.util.List;
+// CraftBukkit start
++import java.util.List;
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
+import org.bukkit.entity.HumanEntity;
+import org.bukkit.event.inventory.BrewEvent;
+// CraftBukkit end
+
- public class TileEntityBrewingStand extends TileEntityContainer implements IUpdatePlayerListBox, IWorldInventory {
+ public class TileEntityBrewingStand extends TileEntityContainer implements ITickable, IWorldInventory {
private static final int[] a = new int[] { 3};
-@@ -12,9 +18,35 @@
- private boolean[] i;
- private Item j;
- private String k;
+@@ -13,9 +20,35 @@
+ private Item k;
+ private String l;
+ private int m;
+ private int lastTick = MinecraftServer.currentTick; // CraftBukkit - add field
public TileEntityBrewingStand() {}
@@ -47,43 +48,42 @@
+ // CraftBukkit end
+
public String getName() {
- return this.hasCustomName() ? this.k : "container.brewing";
- }
-@@ -32,9 +64,14 @@
+ return this.hasCustomName() ? this.l : "container.brewing";
}
+@@ -46,9 +79,14 @@
+ boolean flag = this.n();
+ boolean flag1 = this.brewTime > 0;
- public void c() {
+ // CraftBukkit start - Use wall time instead of ticks for brewing
+ int elapsedTicks = MinecraftServer.currentTick - this.lastTick;
+ this.lastTick = MinecraftServer.currentTick;
+
- if (this.brewTime > 0) {
+ if (flag1) {
- --this.brewTime;
-- if (this.brewTime == 0) {
+- boolean flag2 = this.brewTime == 0;
+ this.brewTime -= elapsedTicks;
-+ if (this.brewTime <= 0) { // == -> <=
-+ // CraftBukkit end
++ boolean flag2 = this.brewTime <= 0; // == -> <=
++ // CraftBukkit end
+
+ if (flag2 && flag) {
this.o();
- this.update();
- } else if (!this.n()) {
-@@ -110,6 +147,16 @@
- if (this.n()) {
- ItemStack itemstack = this.items[3];
+@@ -124,6 +162,15 @@
-+ // CraftBukkit start
-+ if (getOwner() != null) {
-+ BrewEvent event = new BrewEvent(world.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ()), (org.bukkit.inventory.BrewerInventory) this.getOwner().getInventory());
-+ org.bukkit.Bukkit.getPluginManager().callEvent(event);
-+ if (event.isCancelled()) {
-+ return;
-+ }
+ private void o() {
+ ItemStack itemstack = this.items[3];
++ // CraftBukkit start
++ if (getOwner() != null) {
++ BrewEvent event = new BrewEvent(world.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ()), (org.bukkit.inventory.BrewerInventory) this.getOwner().getInventory());
++ org.bukkit.Bukkit.getPluginManager().callEvent(event);
++ if (event.isCancelled()) {
++ return;
+ }
-+ // CraftBukkit end
-+
- for (int i = 0; i < 3; ++i) {
- if (this.items[i] != null && this.items[i].getItem() == Items.POTION) {
- int j = this.items[i].getData();
-@@ -221,7 +268,7 @@
++ }
++ // CraftBukkit end
+
+ for (int i = 0; i < 3; ++i) {
+ this.items[i] = PotionBrewer.d(itemstack, this.items[i]);
+@@ -216,7 +263,7 @@
}
public int getMaxStackSize() {
diff --git a/nms-patches/TileEntityChest.patch b/nms-patches/TileEntityChest.patch
index 605ced78..a9d933db 100644
--- a/nms-patches/TileEntityChest.patch
+++ b/nms-patches/TileEntityChest.patch
@@ -9,7 +9,7 @@
+import org.bukkit.entity.HumanEntity;
+// CraftBukkit end
+
- public class TileEntityChest extends TileEntityContainer implements IUpdatePlayerListBox, IInventory {
+ public class TileEntityChest extends TileEntityLootable implements ITickable, IInventory {
private ItemStack[] items = new ItemStack[27];
@@ -20,6 +25,31 @@
@@ -41,10 +41,10 @@
+ }
+ // CraftBukkit end
+
- public int getSize() {
- return 27;
+ public TileEntityChest(BlockChest.Type blockchest_type) {
+ this.q = blockchest_type;
}
-@@ -125,10 +155,11 @@
+@@ -118,10 +148,11 @@
}
public int getMaxStackSize() {
@@ -57,7 +57,7 @@
return this.world.getTileEntity(this.position) != this ? false : entityhuman.e((double) this.position.getX() + 0.5D, (double) this.position.getY() + 0.5D, (double) this.position.getZ() + 0.5D) <= 64.0D;
}
-@@ -304,9 +335,21 @@
+@@ -297,9 +328,21 @@
if (this.l < 0) {
this.l = 0;
}
@@ -65,10 +65,10 @@
++this.l;
+ if (this.world == null) return; // CraftBukkit
- this.world.playBlockAction(this.position, this.w(), 1, this.l);
+ this.world.playBlockAction(this.position, this.getBlock(), 1, this.l);
+
+ // CraftBukkit start - Call redstone event
-+ if (this.w() == Blocks.TRAPPED_CHEST) {
++ if (this.getBlock() == Blocks.TRAPPED_CHEST) {
+ int newPower = Math.max(0, Math.min(15, this.l));
+
+ if (oldPower != newPower) {
@@ -76,20 +76,20 @@
+ }
+ }
+ // CraftBukkit end
- this.world.applyPhysics(this.position, this.w());
- this.world.applyPhysics(this.position.down(), this.w());
+ this.world.applyPhysics(this.position, this.getBlock());
+ this.world.applyPhysics(this.position.down(), this.getBlock());
}
-@@ -315,8 +358,20 @@
+@@ -308,8 +351,20 @@
public void closeContainer(EntityHuman entityhuman) {
- if (!entityhuman.isSpectator() && this.w() instanceof BlockChest) {
+ if (!entityhuman.isSpectator() && this.getBlock() instanceof BlockChest) {
+ int oldPower = Math.max(0, Math.min(15, this.l)); // CraftBukkit - Get power before new viewer is added
--this.l;
+ if (this.world == null) return; // CraftBukkit
- this.world.playBlockAction(this.position, this.w(), 1, this.l);
+ this.world.playBlockAction(this.position, this.getBlock(), 1, this.l);
+
+ // CraftBukkit start - Call redstone event
-+ if (this.w() == Blocks.TRAPPED_CHEST) {
++ if (this.getBlock() == Blocks.TRAPPED_CHEST) {
+ int newPower = Math.max(0, Math.min(15, this.l));
+
+ if (oldPower != newPower) {
@@ -97,17 +97,16 @@
+ }
+ }
+ // CraftBukkit end
- this.world.applyPhysics(this.position, this.w());
- this.world.applyPhysics(this.position.down(), this.w());
+ this.world.applyPhysics(this.position, this.getBlock());
+ this.world.applyPhysics(this.position.down(), this.getBlock());
}
-@@ -370,6 +425,14 @@
-
+@@ -371,6 +426,13 @@
+ this.n = i;
}
+ // CraftBukkit start
-+ // PAIL
+ @Override
-+ public boolean F() {
++ public boolean isFilteredNBT() {
+ return true;
+ }
+ // CraftBukkit end
diff --git a/nms-patches/TileEntityCommand.patch b/nms-patches/TileEntityCommand.patch
index 9ef1c0a6..04405163 100644
--- a/nms-patches/TileEntityCommand.patch
+++ b/nms-patches/TileEntityCommand.patch
@@ -1,9 +1,9 @@
--- a/net/minecraft/server/TileEntityCommand.java
+++ b/net/minecraft/server/TileEntityCommand.java
-@@ -3,6 +3,9 @@
- public class TileEntityCommand extends TileEntity {
-
- private final CommandBlockListenerAbstract a = new CommandBlockListenerAbstract() {
+@@ -7,6 +7,9 @@
+ private boolean g;
+ private boolean h;
+ private final CommandBlockListenerAbstract i = new CommandBlockListenerAbstract() {
+ {
+ sender = new org.bukkit.craftbukkit.command.CraftBlockCommandSender(this); // CraftBukkit - add sender
+ }
diff --git a/nms-patches/TileEntityContainer.patch b/nms-patches/TileEntityContainer.patch
new file mode 100644
index 00000000..4d49bebb
--- /dev/null
+++ b/nms-patches/TileEntityContainer.patch
@@ -0,0 +1,14 @@
+--- a/net/minecraft/server/TileEntityContainer.java
++++ b/net/minecraft/server/TileEntityContainer.java
+@@ -36,4 +36,11 @@
+ public IChatBaseComponent getScoreboardDisplayName() {
+ return (IChatBaseComponent) (this.hasCustomName() ? new ChatComponentText(this.getName()) : new ChatMessage(this.getName(), new Object[0]));
+ }
++
++ // CraftBukkit start
++ @Override
++ public org.bukkit.Location getLocation() {
++ return new org.bukkit.Location(world.getWorld(), position.getX(), position.getY(), position.getZ());
++ }
++ // CraftBukkit end
+ }
diff --git a/nms-patches/TileEntityDispenser.patch b/nms-patches/TileEntityDispenser.patch
index ec176e9d..778f2f8c 100644
--- a/nms-patches/TileEntityDispenser.patch
+++ b/nms-patches/TileEntityDispenser.patch
@@ -45,7 +45,7 @@
public TileEntityDispenser() {}
public int getSize() {
-@@ -58,6 +90,7 @@
+@@ -38,6 +70,7 @@
for (int k = 0; k < this.items.length; ++k) {
if (this.items[k] != null && TileEntityDispenser.f.nextInt(j++) == 0) {
@@ -53,7 +53,7 @@
i = k;
}
}
-@@ -140,7 +173,7 @@
+@@ -120,7 +153,7 @@
}
public int getMaxStackSize() {
diff --git a/nms-patches/TileEntityFurnace.patch b/nms-patches/TileEntityFurnace.patch
index 796d323f..39fba988 100644
--- a/nms-patches/TileEntityFurnace.patch
+++ b/nms-patches/TileEntityFurnace.patch
@@ -13,7 +13,7 @@
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
+// CraftBukkit end
+
- public class TileEntityFurnace extends TileEntityContainer implements IUpdatePlayerListBox, IWorldInventory {
+ public class TileEntityFurnace extends TileEntityContainer implements ITickable, IWorldInventory {
private static final int[] a = new int[] { 0};
@@ -12,6 +22,32 @@
@@ -49,21 +49,12 @@
public TileEntityFurnace() {}
public int getSize() {
-@@ -132,7 +168,7 @@
- }
-
- public int getMaxStackSize() {
-- return 64;
-+ return maxStack; // CraftBukkit
- }
-
- public boolean isBurning() {
-@@ -140,11 +176,29 @@
+@@ -116,11 +152,29 @@
}
public void c() {
- boolean flag = this.isBurning();
-+ boolean flag = (this.w() == Blocks.LIT_FURNACE); // CraftBukkit - SPIGOT-844 - Check if furnace block is lit using the block instead of burn time // PAIL: Rename
++ boolean flag = (this.getBlock() == Blocks.LIT_FURNACE); // CraftBukkit - SPIGOT-844 - Check if furnace block is lit using the block instead of burn time
boolean flag1 = false;
+ // CraftBukkit start - Use wall time instead of ticks for cooking
@@ -90,7 +81,7 @@
}
if (!this.world.isClientSide) {
-@@ -153,9 +207,21 @@
+@@ -129,9 +183,21 @@
this.cookTime = MathHelper.clamp(this.cookTime - 2, 0, this.cookTimeTotal);
}
} else {
@@ -115,7 +106,7 @@
flag1 = true;
if (this.items[1] != null) {
--this.items[1].count;
-@@ -168,6 +234,7 @@
+@@ -144,6 +210,7 @@
}
}
@@ -123,7 +114,7 @@
if (this.isBurning() && this.canBurn()) {
++this.cookTime;
if (this.cookTime == this.cookTimeTotal) {
-@@ -179,11 +246,13 @@
+@@ -155,11 +222,13 @@
} else {
this.cookTime = 0;
}
@@ -133,11 +124,11 @@
if (flag != this.isBurning()) {
flag1 = true;
BlockFurnace.a(this.isBurning(), this.world, this.position);
-+ this.E(); // CraftBukkit - Invalidate tile entity's cached block type // PAIL: Rename
++ this.invalidateBlockCache(); // CraftBukkit - Invalidate tile entity's cached block type
}
}
-@@ -203,7 +272,8 @@
+@@ -179,7 +248,8 @@
} else {
ItemStack itemstack = RecipesFurnace.getInstance().getResult(this.items[0]);
@@ -147,7 +138,7 @@
}
}
-@@ -211,11 +281,38 @@
+@@ -187,11 +257,38 @@
if (this.canBurn()) {
ItemStack itemstack = RecipesFurnace.getInstance().getResult(this.items[0]);
diff --git a/nms-patches/TileEntityHopper.patch b/nms-patches/TileEntityHopper.patch
index e3ed30c2..9e6e3a18 100644
--- a/nms-patches/TileEntityHopper.patch
+++ b/nms-patches/TileEntityHopper.patch
@@ -13,7 +13,7 @@
+import org.bukkit.inventory.Inventory;
+// CraftBukkit end
+
- public class TileEntityHopper extends TileEntityContainer implements IHopper, IUpdatePlayerListBox {
+ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITickable {
private ItemStack[] items = new ItemStack[5];
private String f;
@@ -47,7 +47,7 @@
public TileEntityHopper() {}
public void a(NBTTagCompound nbttagcompound) {
-@@ -120,7 +154,7 @@
+@@ -100,7 +134,7 @@
}
public int getMaxStackSize() {
@@ -56,7 +56,7 @@
}
public boolean a(EntityHuman entityhuman) {
-@@ -216,10 +250,35 @@
+@@ -196,10 +230,35 @@
for (int i = 0; i < this.getSize(); ++i) {
if (this.getItem(i) != null) {
ItemStack itemstack = this.getItem(i).cloneItemStack();
@@ -78,7 +78,7 @@
+ this.getWorld().getServer().getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ this.setItem(i, itemstack);
-+ this.d(8); // Delay hopper checks
++ this.setCooldown(8); // Delay hopper checks
+ return false;
+ }
+ ItemStack itemstack1 = addItem(iinventory, CraftItemStack.asNMSCopy(event.getItem()), enumdirection);
@@ -94,7 +94,7 @@
return true;
}
-@@ -330,10 +389,41 @@
+@@ -310,10 +369,41 @@
if (itemstack != null && b(iinventory, itemstack, i, enumdirection)) {
ItemStack itemstack1 = itemstack.cloneItemStack();
@@ -118,9 +118,9 @@
+ iinventory.setItem(i, itemstack1);
+
+ if (ihopper instanceof TileEntityHopper) {
-+ ((TileEntityHopper) ihopper).d(8); // Delay hopper checks
++ ((TileEntityHopper) ihopper).setCooldown(8); // Delay hopper checks
+ } else if (ihopper instanceof EntityMinecartHopper) {
-+ ((EntityMinecartHopper) ihopper).m(4); // Delay hopper minecart checks
++ ((EntityMinecartHopper) ihopper).setCooldown(4); // Delay hopper minecart checks
+ }
+
+ return false;
@@ -138,7 +138,7 @@
return true;
}
-@@ -349,6 +439,13 @@
+@@ -329,6 +419,13 @@
if (entityitem == null) {
return false;
} else {
diff --git a/nms-patches/TileEntityNote.patch b/nms-patches/TileEntityNote.patch
index 3e969b7f..a702d495 100644
--- a/nms-patches/TileEntityNote.patch
+++ b/nms-patches/TileEntityNote.patch
@@ -1,6 +1,6 @@
--- a/net/minecraft/server/TileEntityNote.java
+++ b/net/minecraft/server/TileEntityNote.java
-@@ -44,7 +44,12 @@
+@@ -46,7 +46,12 @@
b0 = 4;
}
diff --git a/nms-patches/TileEntityPiston.patch b/nms-patches/TileEntityPiston.patch
index 6e1f13a7..5b4302d0 100644
--- a/nms-patches/TileEntityPiston.patch
+++ b/nms-patches/TileEntityPiston.patch
@@ -1,10 +1,10 @@
--- a/net/minecraft/server/TileEntityPiston.java
+++ b/net/minecraft/server/TileEntityPiston.java
-@@ -104,6 +104,7 @@
+@@ -132,6 +132,7 @@
}
public void c() {
+ if (this.world == null) return; // CraftBukkit
this.j = this.i;
if (this.j >= 1.0F) {
- this.a(1.0F, 0.25F);
+ this.i();
diff --git a/nms-patches/TileEntitySign.patch b/nms-patches/TileEntitySign.patch
index e03d6705..7f6f556f 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 @@
+@@ -19,6 +19,12 @@
nbttagcompound.setString("Text" + (i + 1), s);
}
@@ -13,8 +13,8 @@
this.i.b(nbttagcompound);
}
-@@ -65,12 +71,27 @@
- public void a(CommandObjectiveExecutor.EnumCommandResult commandobjectiveexecutor_enumcommandresult, int i) {}
+@@ -67,14 +73,34 @@
+ }
};
+ // CraftBukkit start - Add an option to convert signs correctly
@@ -25,30 +25,45 @@
+
for (int i = 0; i < 4; ++i) {
String s = nbttagcompound.getString("Text" + (i + 1));
+- IChatBaseComponent ichatbasecomponent = IChatBaseComponent.ChatSerializer.a(s);
+ if (s != null && s.length() > 2048) {
+ s = "\"\"";
+ }
try {
- IChatBaseComponent ichatbasecomponent = IChatBaseComponent.ChatSerializer.a(s);
-
+- this.lines[i] = ChatComponentUtils.filterForDisplay(icommandlistener, ichatbasecomponent, (Entity) null);
+- } catch (CommandException commandexception) {
+- this.lines[i] = ichatbasecomponent;
++ IChatBaseComponent ichatbasecomponent = IChatBaseComponent.ChatSerializer.a(s);
++
+ if (oldSign) {
+ lines[i] = org.bukkit.craftbukkit.util.CraftChatMessage.fromString(s)[0];
+ continue;
+ }
+ // CraftBukkit end
+
- try {
- this.lines[i] = ChatComponentUtils.filterForDisplay(icommandlistener, ichatbasecomponent, (Entity) null);
- } catch (CommandException commandexception) {
-@@ -155,7 +176,10 @@
++ try {
++ this.lines[i] = ChatComponentUtils.filterForDisplay(icommandlistener, ichatbasecomponent, (Entity) null);
++ } catch (CommandException commandexception) {
++ this.lines[i] = ichatbasecomponent;
++ }
++ } catch (com.google.gson.JsonParseException jsonparseexception) {
++ this.lines[i] = new ChatComponentText(s);
+ }
+ }
+
+@@ -159,7 +185,14 @@
ChatClickable chatclickable = chatmodifier.h();
if (chatclickable.a() == ChatClickable.EnumClickAction.RUN_COMMAND) {
-- MinecraftServer.getServer().getCommandHandler().a(icommandlistener, chatclickable.b());
+- entityhuman.h().getCommandHandler().a(icommandlistener, chatclickable.b());
+ // CraftBukkit start
-+ // MinecraftServer.getServer().getCommandHandler().a(tileentitysignplayerwrapper, chatclickable.b());
-+ CommandBlockListenerAbstract.executeCommand(entityhuman, (org.bukkit.entity.Player) entityhuman.getBukkitEntity(), chatclickable.b());
++ // entityhuman.h().getCommandHandler().a(icommandlistener, chatclickable.b());
++ CommandBlockListenerAbstract.executeCommand(icommandlistener, new org.bukkit.craftbukkit.command.ProxiedNativeCommandSender(
++ icommandlistener,
++ new org.bukkit.craftbukkit.command.CraftBlockCommandSender(icommandlistener),
++ entityhuman.getBukkitEntity()
++ ), chatclickable.b());
+ // CraftBukkit end
}
}
diff --git a/nms-patches/TileEntitySkull.patch b/nms-patches/TileEntitySkull.patch
index c4201967..3cf99060 100644
--- a/nms-patches/TileEntitySkull.patch
+++ b/nms-patches/TileEntitySkull.patch
@@ -1,6 +1,6 @@
--- a/net/minecraft/server/TileEntitySkull.java
+++ b/net/minecraft/server/TileEntitySkull.java
-@@ -105,4 +105,10 @@
+@@ -130,4 +130,10 @@
public void setRotation(int i) {
this.rotation = i;
}
diff --git a/nms-patches/UserCache.patch b/nms-patches/UserCache.patch
index 1433fce9..622bff44 100644
--- a/nms-patches/UserCache.patch
+++ b/nms-patches/UserCache.patch
@@ -1,15 +1,15 @@
--- a/net/minecraft/server/UserCache.java
+++ b/net/minecraft/server/UserCache.java
-@@ -42,7 +42,7 @@
- public static final SimpleDateFormat a = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z");
- private final Map<String, UserCache.UserCacheEntry> c = Maps.newHashMap();
- private final Map<UUID, UserCache.UserCacheEntry> d = Maps.newHashMap();
-- private final LinkedList<GameProfile> e = Lists.newLinkedList();
-+ private final java.util.Deque<GameProfile> e = new java.util.concurrent.LinkedBlockingDeque<GameProfile>(); // CraftBukkit
- private final MinecraftServer f;
+@@ -44,7 +44,7 @@
+ private static boolean c;
+ private final Map<String, UserCache.UserCacheEntry> d = Maps.newHashMap();
+ private final Map<UUID, UserCache.UserCacheEntry> e = Maps.newHashMap();
+- private final LinkedList<GameProfile> f = Lists.newLinkedList();
++ private final java.util.Deque<GameProfile> f = new java.util.concurrent.LinkedBlockingDeque<GameProfile>(); // CraftBukkit
+ private final GameProfileRepository g;
protected final Gson b;
- private final File g;
-@@ -323,11 +323,11 @@
+ private final File h;
+@@ -335,11 +335,11 @@
}
}
diff --git a/nms-patches/Village.patch b/nms-patches/Village.patch
index ee57a438..ca9591e2 100644
--- a/nms-patches/Village.patch
+++ b/nms-patches/Village.patch
@@ -3,7 +3,7 @@
@@ -62,7 +62,7 @@
EntityIronGolem entityirongolem = new EntityIronGolem(this.a);
- entityirongolem.setPosition(vec3d.a, vec3d.b, vec3d.c);
+ 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;
diff --git a/nms-patches/VillageSiege.patch b/nms-patches/VillageSiege.patch
index 9b174abf..626a008a 100644
--- a/nms-patches/VillageSiege.patch
+++ b/nms-patches/VillageSiege.patch
@@ -3,7 +3,7 @@
@@ -140,7 +140,7 @@
}
- entityzombie.setPositionRotation(vec3d.a, vec3d.b, vec3d.c, this.a.random.nextFloat() * 360.0F, 0.0F);
+ entityzombie.setPositionRotation(vec3d.x, vec3d.y, vec3d.z, this.a.random.nextFloat() * 360.0F, 0.0F);
- this.a.addEntity(entityzombie);
+ this.a.addEntity(entityzombie, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.VILLAGE_INVASION); // CraftBukkit
BlockPosition blockposition = this.f.a();
diff --git a/nms-patches/World.patch b/nms-patches/World.patch
index 484a9e04..9e81b625 100644
--- a/nms-patches/World.patch
+++ b/nms-patches/World.patch
@@ -1,60 +1,28 @@
--- a/net/minecraft/server/World.java
+++ b/net/minecraft/server/World.java
-@@ -13,6 +13,25 @@
+@@ -13,6 +13,21 @@
import java.util.UUID;
import java.util.concurrent.Callable;
+// CraftBukkit start
+import com.google.common.collect.Maps;
+import java.util.Map;
-+
+import org.bukkit.Bukkit;
+import org.bukkit.block.BlockState;
-+import org.bukkit.craftbukkit.util.CraftMagicNumbers;
-+import org.bukkit.craftbukkit.util.LongHashSet;
-+import org.bukkit.generator.ChunkGenerator;
+import org.bukkit.craftbukkit.CraftServer;
+import org.bukkit.craftbukkit.CraftWorld;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
++import org.bukkit.craftbukkit.util.CraftMagicNumbers;
+import org.bukkit.event.block.BlockCanBuildEvent;
+import org.bukkit.event.block.BlockPhysicsEvent;
+import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
-+import org.bukkit.event.weather.WeatherChangeEvent;
-+import org.bukkit.event.weather.ThunderChangeEvent;
++import org.bukkit.generator.ChunkGenerator;
+// CraftBukkit end
+
public abstract class World implements IBlockAccess {
private int a = 63;
-@@ -36,27 +55,72 @@
- protected float r;
- private int J;
- public final Random random = new Random();
-- public final WorldProvider worldProvider;
-+ public WorldProvider worldProvider; // CraftBukkit - remove final
- protected List<IWorldAccess> u = Lists.newArrayList();
- protected IChunkProvider chunkProvider;
- protected final IDataManager dataManager;
-- protected WorldData worldData;
-+ public WorldData worldData; // CraftBukkit - public
- protected boolean isLoading;
-- protected PersistentCollection worldMaps;
-+ public PersistentCollection worldMaps; // CraftBukkit - public
- protected PersistentVillage villages;
- public final MethodProfiler methodProfiler;
- private final Calendar K = Calendar.getInstance();
-- protected Scoreboard scoreboard = new Scoreboard();
-+ public Scoreboard scoreboard = new Scoreboard(); // CraftBukkit - public
- public final boolean isClientSide;
-- protected Set<ChunkCoordIntPair> chunkTickList = Sets.newHashSet();
-+ // CraftBukkit - longhashset
-+ protected LongHashSet chunkTickList = new LongHashSet();
- private int L;
-- protected boolean allowMonsters;
-- protected boolean allowAnimals;
-+ public boolean allowMonsters; // CraftBukkit - public
-+ public boolean allowAnimals; // CraftBukkit - public
- private boolean M;
+@@ -56,7 +71,51 @@
private final WorldBorder N;
int[] H;
@@ -104,46 +72,18 @@
+ this.ticksPerAnimalSpawns = this.getServer().getTicksPerAnimalSpawns(); // CraftBukkit
+ this.ticksPerMonsterSpawns = this.getServer().getTicksPerMonsterSpawns(); // CraftBukkit
+ // CraftBukkit end
- this.L = this.random.nextInt(12000);
- this.allowMonsters = true;
- this.allowAnimals = true;
-@@ -67,6 +131,35 @@
+ this.u = Lists.newArrayList(new IWorldAccess[] { this.t});
+ this.L = Calendar.getInstance();
+ this.scoreboard = new Scoreboard();
+@@ -69,6 +128,7 @@
this.worldProvider = worldprovider;
this.isClientSide = flag;
this.N = worldprovider.getWorldBorder();
-+ // CraftBukkit start
-+ // Moved from PlayerList
-+ this.N.a(new IWorldBorderListener() {
-+ public void a(WorldBorder worldborder, double d0) {
-+ getServer().getHandle().sendAll(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.SET_SIZE), World.this);
-+ }
-+
-+ public void a(WorldBorder worldborder, double d0, double d1, long i) {
-+ getServer().getHandle().sendAll(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.LERP_SIZE), World.this);
-+ }
-+
-+ public void a(WorldBorder worldborder, double d0, double d1) {
-+ getServer().getHandle().sendAll(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.SET_CENTER), World.this);
-+ }
-+
-+ public void a(WorldBorder worldborder, int i) {
-+ getServer().getHandle().sendAll(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.SET_WARNING_TIME), World.this);
-+ }
-+
-+ public void b(WorldBorder worldborder, int i) {
-+ getServer().getHandle().sendAll(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.SET_WARNING_BLOCKS), World.this);
-+ }
-+
-+ public void b(WorldBorder worldborder, double d0) {}
-+
-+ public void c(WorldBorder worldborder, double d0) {}
-+ });
-+ this.getServer().addWorld(this.world);
-+ // CraftBukkit end
++ this.getServer().addWorld(this.world); // CraftBukkit
}
public World b() {
-@@ -193,6 +286,27 @@
+@@ -197,6 +257,27 @@
}
public boolean setTypeAndData(BlockPosition blockposition, IBlockData iblockdata, int i) {
@@ -171,7 +111,7 @@
if (!this.isValidLocation(blockposition)) {
return false;
} else if (!this.isClientSide && this.worldData.getType() == WorldType.DEBUG_ALL_BLOCK_STATES) {
-@@ -200,9 +314,23 @@
+@@ -204,9 +285,23 @@
} else {
Chunk chunk = this.getChunkAtWorldCoords(blockposition);
Block block = iblockdata.getBlock();
@@ -194,16 +134,16 @@
+ // CraftBukkit end
return false;
} else {
- Block block1 = iblockdata1.getBlock();
-@@ -213,6 +341,7 @@
+ if (iblockdata.c() != iblockdata1.c() || iblockdata.d() != iblockdata1.d()) {
+@@ -215,6 +310,7 @@
this.methodProfiler.b();
}
+ /*
if ((i & 2) != 0 && (!this.isClientSide || (i & 4) == 0) && chunk.isReady()) {
- this.notify(blockposition);
+ this.notify(blockposition, iblockdata1, iblockdata, i);
}
-@@ -223,12 +352,35 @@
+@@ -225,12 +321,35 @@
this.updateAdjacentComparators(blockposition, block);
}
}
@@ -212,7 +152,7 @@
+ // CraftBukkit start
+ if (!this.captureBlockStates) { // Don't notify clients or update physics while capturing blockstates
+ // Modularize client and physic updates
-+ notifyAndUpdatePhysics(blockposition, chunk, block1, block, i);
++ notifyAndUpdatePhysics(blockposition, chunk, iblockdata1, iblockdata, i);
+ }
+ // CraftBukkit end
@@ -222,15 +162,15 @@
}
+ // CraftBukkit start - Split off from original setTypeAndData(int i, int j, int k, Block block, int l, int i1) method in order to directly send client and physic updates
-+ public void notifyAndUpdatePhysics(BlockPosition blockposition, Chunk chunk, Block oldBlock, Block newBLock, int flag) {
++ public void notifyAndUpdatePhysics(BlockPosition blockposition, Chunk chunk, IBlockData oldBlock, IBlockData newBlock, int flag) {
+ if ((flag & 2) != 0 && (chunk == null || chunk.isReady())) { // allow chunk to be null here as chunk.isReady() is false when we send our notification during block placement
-+ this.notify(blockposition);
++ this.notify(blockposition, oldBlock, newBlock, flag);
+ }
+
+ if (!this.isClientSide && (flag & 1) != 0) {
-+ this.update(blockposition, oldBlock);
-+ if (newBLock.isComplexRedstone()) {
-+ this.updateAdjacentComparators(blockposition, newBLock);
++ this.update(blockposition, oldBlock.getBlock());
++ if (newBlock.n()) {
++ this.updateAdjacentComparators(blockposition, newBlock.getBlock());
+ }
+ }
+ }
@@ -239,7 +179,7 @@
public boolean setAir(BlockPosition blockposition) {
return this.setTypeAndData(blockposition, Blocks.AIR.getBlockData(), 3);
}
-@@ -262,6 +414,11 @@
+@@ -264,6 +383,11 @@
public void update(BlockPosition blockposition, Block block) {
if (this.worldData.getType() != WorldType.DEBUG_ALL_BLOCK_STATES) {
@@ -251,7 +191,7 @@
this.applyPhysics(blockposition, block);
}
-@@ -337,6 +494,17 @@
+@@ -339,6 +463,17 @@
IBlockData iblockdata = this.getType(blockposition);
try {
@@ -269,7 +209,7 @@
iblockdata.getBlock().doPhysics(this, blockposition, iblockdata, block);
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.a(throwable, "Exception while updating neighbours");
-@@ -518,6 +686,17 @@
+@@ -520,6 +655,17 @@
}
public IBlockData getType(BlockPosition blockposition) {
@@ -287,7 +227,7 @@
if (!this.isValidLocation(blockposition)) {
return Blocks.AIR.getBlockData();
} else {
-@@ -723,6 +902,13 @@
+@@ -715,6 +861,13 @@
}
public boolean addEntity(Entity entity) {
@@ -301,7 +241,7 @@
int i = MathHelper.floor(entity.locX / 16.0D);
int j = MathHelper.floor(entity.locZ / 16.0D);
boolean flag = entity.attachedToPlayer;
-@@ -731,7 +917,35 @@
+@@ -723,6 +876,34 @@
flag = true;
}
@@ -332,28 +272,19 @@
+ }
+ // CraftBukkit end
+
- if (!flag && !this.isChunkLoaded(i, j, true)) {
-+ entity.dead = true;
++
+ if (!flag && !this.isChunkLoaded(i, j, false)) {
return false;
} else {
- if (entity instanceof EntityHuman) {
-@@ -753,6 +967,7 @@
+@@ -745,6 +926,7 @@
((IWorldAccess) this.u.get(i)).a(entity);
}
+ entity.valid = true; // CraftBukkit
}
- protected void b(Entity entity) {
-@@ -760,6 +975,7 @@
- ((IWorldAccess) this.u.get(i)).b(entity);
- }
-
-+ entity.valid = false; // CraftBukkit
- }
-
- public void kill(Entity entity) {
-@@ -794,7 +1010,15 @@
+ protected void c(Entity entity) {
+@@ -787,7 +969,15 @@
this.getChunkAt(i, j).b(entity);
}
@@ -367,13 +298,13 @@
+ this.entityList.remove(index);
+ }
+ // CraftBukkit end
- this.b(entity);
+ this.c(entity);
}
-@@ -978,6 +1202,11 @@
+@@ -1039,6 +1229,11 @@
- for (i = 0; i < this.k.size(); ++i) {
- entity = (Entity) this.k.get(i);
+ for (i = 0; i < this.j.size(); ++i) {
+ entity = (Entity) this.j.get(i);
+ // CraftBukkit start - Fixed an NPE
+ if (entity == null) {
+ continue;
@@ -382,9 +313,9 @@
try {
++entity.ticksLived;
-@@ -1021,8 +1250,10 @@
- this.g.clear();
- this.methodProfiler.c("regular");
+@@ -1087,8 +1282,10 @@
+ CrashReportSystemDetails crashreportsystemdetails1;
+ CrashReport crashreport1;
- for (i = 0; i < this.entityList.size(); ++i) {
- entity = (Entity) this.entityList.get(i);
@@ -392,59 +323,59 @@
+ for (this.tickPosition = 0; this.tickPosition < this.entityList.size(); ++this.tickPosition) {
+ entity = (Entity) this.entityList.get(this.tickPosition);
+ // CraftBukkit end
- if (entity.vehicle != null) {
- if (!entity.vehicle.dead && entity.vehicle.passenger == entity) {
- continue;
-@@ -1053,7 +1284,7 @@
- this.getChunkAt(j, k).b(entity);
+ Entity entity1 = entity.by();
+
+ if (entity1 != null) {
+@@ -1121,7 +1318,7 @@
+ this.getChunkAt(j, l).b(entity);
}
- this.entityList.remove(i--);
+ this.entityList.remove(this.tickPosition--); // CraftBukkit - Use field for loop variable
- this.b(entity);
+ this.c(entity);
}
-@@ -1062,6 +1293,13 @@
+@@ -1130,6 +1327,13 @@
this.methodProfiler.c("blockEntities");
this.M = true;
+ // CraftBukkit start - From below, clean up tile entities before ticking them
-+ if (!this.c.isEmpty()) {
-+ this.tileEntityList.removeAll(this.c);
-+ this.h.removeAll(this.c);
-+ this.c.clear();
++ if (!this.tileEntityListUnload.isEmpty()) {
++ this.tileEntityListTick.removeAll(this.tileEntityListUnload);
++ this.tileEntityList.removeAll(this.tileEntityListUnload);
++ this.tileEntityListUnload.clear();
+ }
+ // CraftBukkit end
- Iterator iterator = this.tileEntityList.iterator();
+ Iterator iterator = this.tileEntityListTick.iterator();
while (iterator.hasNext()) {
-@@ -1093,11 +1331,13 @@
+@@ -1162,11 +1366,13 @@
}
this.M = false;
+ /* CraftBukkit start - Moved up
- if (!this.c.isEmpty()) {
- this.tileEntityList.removeAll(this.c);
- this.h.removeAll(this.c);
- this.c.clear();
+ if (!this.tileEntityListUnload.isEmpty()) {
+ this.tileEntityListTick.removeAll(this.tileEntityListUnload);
+ this.tileEntityList.removeAll(this.tileEntityListUnload);
+ this.tileEntityListUnload.clear();
}
+ // CraftBukkit end */
this.methodProfiler.c("pendingBlockEntities");
if (!this.b.isEmpty()) {
-@@ -1105,9 +1345,11 @@
- TileEntity tileentity1 = (TileEntity) this.b.get(l);
+@@ -1174,9 +1380,11 @@
+ TileEntity tileentity1 = (TileEntity) this.b.get(i1);
if (!tileentity1.x()) {
+ /* CraftBukkit start - Order matters, moved down
- if (!this.h.contains(tileentity1)) {
+ if (!this.tileEntityList.contains(tileentity1)) {
this.a(tileentity1);
}
+ // CraftBukkit end */
if (this.isLoaded(tileentity1.getPosition())) {
- this.getChunkAtWorldCoords(tileentity1.getPosition()).a(tileentity1.getPosition(), tileentity1);
-@@ -1161,7 +1403,10 @@
+ Chunk chunk = this.getChunkAtWorldCoords(tileentity1.getPosition());
+@@ -1231,7 +1439,10 @@
int j = MathHelper.floor(entity.locZ);
byte b0 = 32;
@@ -453,10 +384,10 @@
+ Chunk startingChunk = this.getChunkIfLoaded(i >> 4, j >> 4);
+ if (!flag || (startingChunk != null && startingChunk.areNeighborsLoaded(2)) /* this.isAreaLoaded(i - b0, 0, j - b0, i + b0, 0, j + b0) */) {
+ // CraftBukkit end
- entity.P = entity.locX;
- entity.Q = entity.locY;
- entity.R = entity.locZ;
-@@ -1479,10 +1724,18 @@
+ entity.M = entity.locX;
+ entity.N = entity.locY;
+ entity.O = entity.locZ;
+@@ -1570,10 +1781,18 @@
}
}
@@ -475,7 +406,7 @@
TileEntity tileentity = null;
int i;
TileEntity tileentity1;
-@@ -1517,6 +1770,14 @@
+@@ -1608,6 +1827,14 @@
public void setTileEntity(BlockPosition blockposition, TileEntity tileentity) {
if (tileentity != null && !tileentity.x()) {
@@ -490,10 +421,10 @@
if (this.M) {
tileentity.a(blockposition);
Iterator iterator = this.b.iterator();
-@@ -1679,12 +1940,20 @@
+@@ -1762,6 +1989,14 @@
}
- this.p = MathHelper.a(this.p, 0.0F, 1.0F);
+ this.o = MathHelper.a(this.o, 0.0F, 1.0F);
+
+ // CraftBukkit start
+ for (int idx = 0; idx < this.players.size(); ++idx) {
@@ -505,23 +436,7 @@
}
}
}
-
- protected void D() {
-- this.chunkTickList.clear();
-+ // this.chunkTickList.clear(); // CraftBukkit - removed
- this.methodProfiler.a("buildList");
-
- int i;
-@@ -1701,7 +1970,7 @@
-
- for (int i1 = -l; i1 <= l; ++i1) {
- for (int j1 = -l; j1 <= l; ++j1) {
-- this.chunkTickList.add(new ChunkCoordIntPair(i1 + j, j1 + k));
-+ this.chunkTickList.add(org.bukkit.craftbukkit.util.LongHash.toLong(i1 + j, j1 + k));
- }
- }
- }
-@@ -1879,7 +2148,10 @@
+@@ -1893,7 +2128,10 @@
}
public boolean c(EnumSkyBlock enumskyblock, BlockPosition blockposition) {
@@ -533,16 +448,16 @@
return false;
} else {
int i = 0;
-@@ -2042,7 +2314,7 @@
+@@ -2058,7 +2296,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.apply((T) entity)) {
arraylist.add(entity);
}
}
-@@ -2057,7 +2329,7 @@
+@@ -2073,7 +2311,7 @@
while (iterator.hasNext()) {
Entity entity = (Entity) iterator.next();
@@ -551,7 +466,7 @@
arraylist.add(entity);
}
}
-@@ -2105,7 +2377,7 @@
+@@ -2121,7 +2359,7 @@
}
}
@@ -559,8 +474,8 @@
+ return (T) entity; // CraftBukkit fix decompile error
}
- public Entity a(int i) {
-@@ -2125,8 +2397,17 @@
+ public Entity getEntity(int i) {
+@@ -2141,8 +2379,17 @@
while (iterator.hasNext()) {
Entity entity = (Entity) iterator.next();
@@ -580,10 +495,10 @@
++i;
}
}
-@@ -2135,12 +2416,18 @@
+@@ -2151,12 +2398,18 @@
}
- public void b(Collection<Entity> collection) {
+ public void a(Collection<Entity> collection) {
- this.entityList.addAll(collection);
+ // CraftBukkit start
+ // this.entityList.addAll(collection);
@@ -597,16 +512,16 @@
+ }
+ this.entityList.add(entity);
+ // CraftBukkit end
- this.a(entity);
+ this.b(entity);
}
-@@ -2154,7 +2441,13 @@
- Block block1 = this.getType(blockposition).getBlock();
- AxisAlignedBB axisalignedbb = flag ? null : block.a(this, blockposition, block.getBlockData());
+@@ -2170,7 +2423,13 @@
+ IBlockData iblockdata = this.getType(blockposition);
+ AxisAlignedBB axisalignedbb = flag ? null : block.getBlockData().d(this, blockposition);
-- return axisalignedbb != null && !this.a(axisalignedbb, entity) ? false : (block1.getMaterial() == Material.ORIENTABLE && block == Blocks.ANVIL ? true : block1.getMaterial().isReplaceable() && block.canPlace(this, blockposition, enumdirection, itemstack));
+- return axisalignedbb != Block.k && !this.a(axisalignedbb.a(blockposition), entity) ? false : (iblockdata.getMaterial() == Material.ORIENTABLE && block == Blocks.ANVIL ? true : iblockdata.getMaterial().isReplaceable() && block.canPlace(this, blockposition, enumdirection, itemstack));
+ // CraftBukkit start - store default return
-+ boolean defaultReturn = axisalignedbb != null && !this.a(axisalignedbb, entity) ? false : (block1.getMaterial() == Material.ORIENTABLE && block == Blocks.ANVIL ? true : block1.getMaterial().isReplaceable() && block.canPlace(this, blockposition, enumdirection, itemstack));
++ boolean defaultReturn = axisalignedbb != null && !this.a(axisalignedbb, entity) ? false : (iblockdata.getMaterial() == Material.ORIENTABLE && block == Blocks.ANVIL ? true : iblockdata.getMaterial().isReplaceable() && block.canPlace(this, blockposition, enumdirection, itemstack));
+ BlockCanBuildEvent event = new BlockCanBuildEvent(this.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), CraftMagicNumbers.getId(block), defaultReturn);
+ this.getServer().getPluginManager().callEvent(event);
+
@@ -614,8 +529,8 @@
+ // CraftBukkit end
}
- public int F() {
-@@ -2253,6 +2546,11 @@
+ public int K() {
+@@ -2270,6 +2529,11 @@
for (int i = 0; i < this.players.size(); ++i) {
EntityHuman entityhuman1 = (EntityHuman) this.players.get(i);
@@ -625,9 +540,9 @@
+ }
+ // CraftBukkit end
- if (IEntitySelector.d.apply(entityhuman1)) {
+ if ((IEntitySelector.d.apply(entityhuman1) || !flag) && (IEntitySelector.e.apply(entityhuman1) || flag)) {
double d5 = entityhuman1.e(d0, d1, d2);
-@@ -2369,6 +2667,16 @@
+@@ -2433,6 +2697,16 @@
public void everyoneSleeping() {}
@@ -642,13 +557,14 @@
+ // CraftBukkit end
+
public float h(float f) {
- return (this.q + (this.r - this.q) * f) * this.j(f);
+ return (this.p + (this.q - this.p) * f) * this.j(f);
}
-@@ -2592,6 +2900,6 @@
+@@ -2648,7 +2922,7 @@
int l = j * 16 + 8 - blockposition.getZ();
short short0 = 128;
- return k >= -short0 && k <= short0 && l >= -short0 && l <= short0;
+ return k >= -short0 && k <= short0 && l >= -short0 && l <= short0 && this.keepSpawnInMemory; // CraftBukkit - Added 'this.keepSpawnInMemory'
}
- }
+
+ public void a(Packet<?> packet) {
diff --git a/nms-patches/WorldData.patch b/nms-patches/WorldData.patch
index d2250682..6c9b12c9 100644
--- a/nms-patches/WorldData.patch
+++ b/nms-patches/WorldData.patch
@@ -1,8 +1,8 @@
--- a/net/minecraft/server/WorldData.java
+++ b/net/minecraft/server/WorldData.java
-@@ -1,6 +1,11 @@
- package net.minecraft.server;
-
+@@ -5,6 +5,11 @@
+ import java.util.Map;
+ import java.util.Map.Entry;
import java.util.concurrent.Callable;
+// CraftBukkit start
+import org.bukkit.Bukkit;
@@ -12,15 +12,15 @@
public class WorldData {
-@@ -41,6 +46,7 @@
- private int I;
- private int J;
- private GameRules K;
+@@ -49,6 +54,7 @@
+ private int M;
+ private final Map<DimensionManager, NBTTagCompound> N;
+ private GameRules O;
+ public WorldServer world; // CraftBukkit
protected WorldData() {
- this.c = WorldType.NORMAL;
-@@ -395,6 +401,18 @@
+ this.f = WorldType.NORMAL;
+@@ -441,6 +447,18 @@
}
public void setThundering(boolean flag) {
@@ -36,10 +36,10 @@
+ setThunderDuration(0); // Will force a time reset
+ }
+ // CraftBukkit end
- this.s = flag;
+ this.v = flag;
}
-@@ -411,6 +429,18 @@
+@@ -457,6 +475,18 @@
}
public void setStorm(boolean flag) {
@@ -55,13 +55,13 @@
+ setWeatherDuration(0); // Will force a time reset
+ }
+ // CraftBukkit end
- this.q = flag;
+ this.t = flag;
}
-@@ -556,6 +586,12 @@
+@@ -602,6 +632,12 @@
public void setDifficulty(EnumDifficulty enumdifficulty) {
- this.z = enumdifficulty;
+ this.C = enumdifficulty;
+ // CraftBukkit start
+ PacketPlayOutServerDifficulty packet = new PacketPlayOutServerDifficulty(this.getDifficulty(), this.isDifficultyLocked());
+ for (EntityPlayer player : (java.util.List<EntityPlayer>) (java.util.List) world.players) {
@@ -71,15 +71,15 @@
}
public boolean isDifficultyLocked() {
-@@ -664,4 +700,12 @@
- }
- });
+@@ -720,4 +756,12 @@
+ public void a(DimensionManager dimensionmanager, NBTTagCompound nbttagcompound) {
+ this.N.put(dimensionmanager, nbttagcompound);
}
+
+ // CraftBukkit start - Check if the name stored in NBT is the correct one
+ public void checkName( String name ) {
-+ if ( !this.n.equals( name ) ) {
-+ this.n = name;
++ if ( !this.levelName.equals( name ) ) {
++ this.levelName = name;
+ }
+ }
+ // CraftBukkit end
diff --git a/nms-patches/WorldGenGroundBush.patch b/nms-patches/WorldGenGroundBush.patch
index 4afb31ce..6fa45dfb 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
-@@ -46,7 +46,12 @@
+@@ -47,7 +47,12 @@
}
}
}
diff --git a/nms-patches/WorldGenRegistration.patch b/nms-patches/WorldGenRegistration.patch
index 736860c6..55e33641 100644
--- a/nms-patches/WorldGenRegistration.patch
+++ b/nms-patches/WorldGenRegistration.patch
@@ -1,9 +1,9 @@
--- a/net/minecraft/server/WorldGenRegistration.java
+++ b/net/minecraft/server/WorldGenRegistration.java
-@@ -108,7 +108,7 @@
+@@ -160,7 +160,7 @@
- entitywitch.setPositionRotation((double) i1 + 0.5D, (double) j1, (double) k1 + 0.5D, 0.0F, 0.0F);
- entitywitch.prepare(world.E(new BlockPosition(i1, j1, k1)), (GroupDataEntity) null);
+ 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/WorldGenVillagePieces.patch b/nms-patches/WorldGenVillagePieces.patch
index 4c46ae38..77e049f8 100644
--- a/nms-patches/WorldGenVillagePieces.patch
+++ b/nms-patches/WorldGenVillagePieces.patch
@@ -1,8 +1,34 @@
--- a/net/minecraft/server/WorldGenVillagePieces.java
+++ b/net/minecraft/server/WorldGenVillagePieces.java
-@@ -1559,7 +1559,7 @@
+@@ -282,10 +282,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 b(NBTTagCompound nbttagcompound) {
+@@ -413,8 +413,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 b(NBTTagCompound nbttagcompound) {
+@@ -1602,7 +1602,7 @@
entityvillager.setPositionRotation((double) j1 + 0.5D, (double) k1, (double) l1 + 0.5D, 0.0F, 0.0F);
- entityvillager.prepare(world.E(new BlockPosition(entityvillager)), (GroupDataEntity) null);
+ entityvillager.prepare(world.D(new BlockPosition(entityvillager)), (GroupDataEntity) null);
entityvillager.setProfession(this.c(i1, entityvillager.getProfession()));
- world.addEntity(entityvillager);
+ world.addEntity(entityvillager, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CHUNK_GEN); // CraftBukkit - add SpawnReason
diff --git a/nms-patches/WorldManager.patch b/nms-patches/WorldManager.patch
index 4a9fa5b4..606d551e 100644
--- a/nms-patches/WorldManager.patch
+++ b/nms-patches/WorldManager.patch
@@ -1,45 +1,39 @@
--- a/net/minecraft/server/WorldManager.java
+++ b/net/minecraft/server/WorldManager.java
-@@ -24,11 +24,13 @@
+@@ -32,7 +32,8 @@
}
- public void a(String s, double d0, double d1, double d2, float f, float f1) {
-- this.a.getPlayerList().sendPacketNearby(d0, d1, d2, f > 1.0F ? (double) (16.0F * f) : 16.0D, this.world.worldProvider.getDimension(), new PacketPlayOutNamedSoundEffect(s, d0, d1, d2, f, f1));
+ public void a(EntityHuman entityhuman, SoundEffect soundeffect, SoundCategory soundcategory, double d0, double d1, double d2, float f, float f1) {
+- this.a.getPlayerList().sendPacketNearby(entityhuman, d0, d1, d2, f > 1.0F ? (double) (16.0F * f) : 16.0D, this.world.worldProvider.getDimensionManager().getDimensionID(), new PacketPlayOutNamedSoundEffect(soundeffect, soundcategory, d0, d1, d2, f, f1));
+ // CraftBukkit - this.world.dimension
-+ this.a.getPlayerList().sendPacketNearby(d0, d1, d2, f > 1.0F ? (double) (16.0F * f) : 16.0D, this.world.dimension, new PacketPlayOutNamedSoundEffect(s, d0, d1, d2, f, f1));
- }
-
- public void a(EntityHuman entityhuman, String s, double d0, double d1, double d2, float f, float f1) {
-- this.a.getPlayerList().sendPacketNearby(entityhuman, d0, d1, d2, f > 1.0F ? (double) (16.0F * f) : 16.0D, this.world.worldProvider.getDimension(), new PacketPlayOutNamedSoundEffect(s, d0, d1, d2, f, f1));
-+ // CraftBukkit - this.world.dimension
-+ this.a.getPlayerList().sendPacketNearby(entityhuman, d0, d1, d2, f > 1.0F ? (double) (16.0F * f) : 16.0D, this.world.dimension, new PacketPlayOutNamedSoundEffect(s, d0, d1, d2, f, f1));
++ this.a.getPlayerList().sendPacketNearby(entityhuman, d0, d1, d2, f > 1.0F ? (double) (16.0F * f) : 16.0D, this.world.dimension, new PacketPlayOutNamedSoundEffect(soundeffect, soundcategory, d0, d1, d2, f, f1));
}
public void a(int i, int j, int k, int l, int i1, int j1) {}
-@@ -42,7 +44,8 @@
- public void a(String s, BlockPosition blockposition) {}
+@@ -46,7 +47,8 @@
+ public void a(SoundEffect soundeffect, BlockPosition blockposition) {}
public void a(EntityHuman entityhuman, int i, BlockPosition blockposition, int j) {
-- this.a.getPlayerList().sendPacketNearby(entityhuman, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), 64.0D, this.world.worldProvider.getDimension(), new PacketPlayOutWorldEvent(i, blockposition, j, false));
+- this.a.getPlayerList().sendPacketNearby(entityhuman, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), 64.0D, this.world.worldProvider.getDimensionManager().getDimensionID(), new PacketPlayOutWorldEvent(i, blockposition, j, false));
+ // CraftBukkit - this.world.dimension
+ this.a.getPlayerList().sendPacketNearby(entityhuman, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), 64.0D, this.world.dimension, new PacketPlayOutWorldEvent(i, blockposition, j, false));
}
public void a(int i, BlockPosition blockposition, int j) {
-@@ -52,6 +55,12 @@
+@@ -56,6 +58,12 @@
public void b(int i, BlockPosition blockposition, int j) {
Iterator iterator = this.a.getPlayerList().v().iterator();
+ // CraftBukkit start
+ EntityHuman entityhuman = null;
-+ Entity entity = world.a(i); // PAIL Rename getEntity
++ Entity entity = world.getEntity(i);
+ if (entity instanceof EntityHuman) entityhuman = (EntityHuman) entity;
+ // CraftBukkit end
+
while (iterator.hasNext()) {
EntityPlayer entityplayer = (EntityPlayer) iterator.next();
-@@ -60,6 +69,12 @@
+@@ -64,6 +72,12 @@
double d1 = (double) blockposition.getY() - entityplayer.locY;
double d2 = (double) blockposition.getZ() - entityplayer.locZ;
diff --git a/nms-patches/WorldMap.patch b/nms-patches/WorldMap.patch
index ab9784f5..be793710 100644
--- a/nms-patches/WorldMap.patch
+++ b/nms-patches/WorldMap.patch
@@ -15,8 +15,8 @@
public class WorldMap extends PersistentBase {
public int centerX;
-@@ -17,8 +25,18 @@
- private Map<EntityHuman, WorldMap.WorldMapHumanTracker> i = Maps.newHashMap();
+@@ -18,8 +26,18 @@
+ private Map<EntityHuman, WorldMap.WorldMapHumanTracker> j = Maps.newHashMap();
public Map<String, MapIcon> decorations = Maps.newLinkedHashMap();
+ // CraftBukkit start
@@ -34,7 +34,7 @@
}
public void a(double d0, double d1, int i) {
-@@ -31,7 +49,30 @@
+@@ -32,7 +50,30 @@
}
public void a(NBTTagCompound nbttagcompound) {
@@ -66,7 +66,7 @@
this.centerX = nbttagcompound.getInt("xCenter");
this.centerZ = nbttagcompound.getInt("zCenter");
this.scale = nbttagcompound.getByte("scale");
-@@ -66,6 +107,25 @@
+@@ -73,6 +114,25 @@
}
public void b(NBTTagCompound nbttagcompound) {
@@ -92,10 +92,10 @@
nbttagcompound.setByte("dimension", this.map);
nbttagcompound.setInt("xCenter", this.centerX);
nbttagcompound.setInt("zCenter", this.centerZ);
-@@ -212,12 +272,25 @@
+@@ -220,12 +280,26 @@
}
- public Packet a(ItemStack itemstack) {
+ public Packet<?> a(ItemStack itemstack) {
+ // CraftBukkit start
+ org.bukkit.craftbukkit.map.RenderData render = WorldMap.this.mapView.render((org.bukkit.craftbukkit.entity.CraftPlayer) this.trackee.getBukkitEntity()); // CraftBukkit
+
@@ -110,11 +110,12 @@
+
if (this.d) {
this.d = false;
-- return new PacketPlayOutMap(itemstack.getData(), WorldMap.this.scale, WorldMap.this.decorations.values(), WorldMap.this.colors, this.e, this.f, this.g + 1 - this.e, this.h + 1 - this.f);
-+ return new PacketPlayOutMap(itemstack.getData(), WorldMap.this.scale, icons, render.buffer, this.e, this.f, this.g + 1 - this.e, this.h + 1 - this.f);
+- 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);
} else {
-- return this.i++ % 5 == 0 ? new PacketPlayOutMap(itemstack.getData(), WorldMap.this.scale, WorldMap.this.decorations.values(), WorldMap.this.colors, 0, 0, 0, 0) : null;
-+ return this.i++ % 5 == 0 ? new PacketPlayOutMap(itemstack.getData(), WorldMap.this.scale, icons, render.buffer, 0, 0, 0, 0) : null;
+- 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;
}
+ // CraftBukkit end
}
diff --git a/nms-patches/WorldNBTStorage.patch b/nms-patches/WorldNBTStorage.patch
index 549de015..c52ffef2 100644
--- a/nms-patches/WorldNBTStorage.patch
+++ b/nms-patches/WorldNBTStorage.patch
@@ -1,27 +1,26 @@
--- a/net/minecraft/server/WorldNBTStorage.java
+++ b/net/minecraft/server/WorldNBTStorage.java
-@@ -11,6 +11,12 @@
+@@ -11,6 +11,11 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+// CraftBukkit start
+import java.util.UUID;
-+
+import org.bukkit.craftbukkit.entity.CraftPlayer;
+// CraftBukkit end
+
public class WorldNBTStorage implements IDataManager, IPlayerFileData {
- private static final Logger a = LogManager.getLogger();
-@@ -19,6 +25,7 @@
- private final File dataDir;
- private final long sessionId = MinecraftServer.az();
- private final String f;
+ private static final Logger b = LogManager.getLogger();
+@@ -21,6 +26,7 @@
+ private final String g;
+ private final DefinedStructureManager h;
+ protected final DataConverterManager a;
+ private UUID uuid = null; // CraftBukkit
- public WorldNBTStorage(File file, String s, boolean flag) {
- this.baseDir = new File(file, s);
-@@ -202,12 +209,39 @@
+ public WorldNBTStorage(File file, String s, boolean flag, DataConverterManager dataconvertermanager) {
+ this.a = dataconvertermanager;
+@@ -167,12 +173,38 @@
}
if (nbttagcompound != null) {
@@ -35,8 +34,7 @@
+ }
+ }
+ // CraftBukkit end
-+
- entityhuman.f(nbttagcompound);
+ entityhuman.f(this.a.a((DataConverterType) DataConverterTypes.PLAYER, nbttagcompound));
}
return nbttagcompound;
@@ -51,7 +49,7 @@
+ return NBTCompressedStreamTools.a((InputStream) (new FileInputStream(file1)));
+ }
+ } catch (Exception exception) {
-+ a.warn("Failed to load player data for " + s);
++ b.warn("Failed to load player data for " + s);
+ }
+
+ return null;
@@ -61,9 +59,9 @@
public IPlayerFileData getPlayerFileData() {
return this;
}
-@@ -237,4 +271,50 @@
- public String g() {
- return this.f;
+@@ -202,4 +234,50 @@
+ public DefinedStructureManager h() {
+ return this.h;
}
+
+ // CraftBukkit start
@@ -76,7 +74,7 @@
+ dis = new DataInputStream(new FileInputStream(file1));
+ return uuid = new UUID(dis.readLong(), dis.readLong());
+ } catch (IOException ex) {
-+ a.warn("Failed to read " + file1 + ", generating new random UUID", ex);
++ b.warn("Failed to read " + file1 + ", generating new random UUID", ex);
+ } finally {
+ if (dis != null) {
+ try {
@@ -94,7 +92,7 @@
+ dos.writeLong(uuid.getMostSignificantBits());
+ dos.writeLong(uuid.getLeastSignificantBits());
+ } catch (IOException ex) {
-+ a.warn("Failed to write " + file1, ex);
++ b.warn("Failed to write " + file1, ex);
+ } finally {
+ if (dos != null) {
+ try {
diff --git a/nms-patches/WorldServer.patch b/nms-patches/WorldServer.patch
index 5acbfbda..4789cf2e 100644
--- a/nms-patches/WorldServer.patch
+++ b/nms-patches/WorldServer.patch
@@ -1,16 +1,28 @@
--- a/net/minecraft/server/WorldServer.java
+++ b/net/minecraft/server/WorldServer.java
-@@ -16,14 +16,27 @@
+@@ -3,7 +3,6 @@
+ import com.google.common.base.Predicate;
+ import com.google.common.collect.Lists;
+ import com.google.common.collect.Maps;
+-import com.google.common.collect.Sets;
+ import com.google.common.util.concurrent.ListenableFuture;
+ import java.io.File;
+ import java.util.ArrayList;
+@@ -12,20 +11,29 @@
+ import java.util.List;
+ import java.util.Map;
+ import java.util.Random;
+-import java.util.Set;
+-import java.util.TreeSet;
+ import java.util.UUID;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+// CraftBukkit start
-+import java.util.*;
+import java.util.logging.Level;
+
+import org.bukkit.WeatherType;
+import org.bukkit.block.BlockState;
-+import org.bukkit.craftbukkit.util.LongHash;
+import org.bukkit.craftbukkit.util.HashTreeSet;
+
+import org.bukkit.event.block.BlockFormEvent;
@@ -23,25 +35,25 @@
private final MinecraftServer server;
public EntityTracker tracker;
private final PlayerChunkMap manager;
-- private final Set<NextTickListEntry> L = Sets.newHashSet();
-- private final TreeSet<NextTickListEntry> M = new TreeSet();
-+ // private final Set<NextTickListEntry> L = Sets.newHashSet(); // PAIL: Rename nextTickListHash
-+ private final HashTreeSet<NextTickListEntry> M = new HashTreeSet<NextTickListEntry>(); // CraftBukkit - HashTreeSet // PAIL: Rename nextTickList
+- 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 ChunkProviderServer chunkProviderServer;
public boolean savingDisabled;
-@@ -37,14 +50,22 @@
- private static final List<StructurePieceTreasure> U = Lists.newArrayList(new StructurePieceTreasure[] { new StructurePieceTreasure(Items.STICK, 0, 1, 3, 10), new StructurePieceTreasure(Item.getItemOf(Blocks.PLANKS), 0, 1, 3, 10), new StructurePieceTreasure(Item.getItemOf(Blocks.LOG), 0, 1, 3, 10), new StructurePieceTreasure(Items.STONE_AXE, 0, 1, 1, 3), new StructurePieceTreasure(Items.WOODEN_AXE, 0, 1, 1, 5), new StructurePieceTreasure(Items.STONE_PICKAXE, 0, 1, 1, 3), new StructurePieceTreasure(Items.WOODEN_PICKAXE, 0, 1, 1, 5), new StructurePieceTreasure(Items.APPLE, 0, 2, 3, 5), new StructurePieceTreasure(Items.BREAD, 0, 2, 3, 3), new StructurePieceTreasure(Item.getItemOf(Blocks.LOG2), 0, 1, 3, 10)});
- private List<NextTickListEntry> V = Lists.newArrayList();
+ private boolean O;
+@@ -37,14 +45,22 @@
+ private int T;
+ private List<NextTickListEntry> U = Lists.newArrayList();
- public WorldServer(MinecraftServer minecraftserver, IDataManager idatamanager, WorldData worlddata, int i, MethodProfiler methodprofiler) {
-- super(idatamanager, worlddata, WorldProvider.byDimension(i), methodprofiler, false);
+- super(idatamanager, worlddata, DimensionManager.a(i).d(), methodprofiler, false);
+ // CraftBukkit start
+ public final int dimension;
+
+ // Add env and gen to constructor
+ public WorldServer(MinecraftServer minecraftserver, IDataManager idatamanager, WorldData worlddata, int i, MethodProfiler methodprofiler, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen) {
-+ super(idatamanager, worlddata, WorldProvider.byDimension(env.getId()), methodprofiler, false, gen, env);
++ super(idatamanager, worlddata, DimensionManager.a(env.getId()).d(), methodprofiler, false, gen, env);
+ this.dimension = i;
+ this.pvpMode = minecraftserver.getPVP();
+ worlddata.world = this;
@@ -49,14 +61,14 @@
this.server = minecraftserver;
this.tracker = new EntityTracker(this);
this.manager = new PlayerChunkMap(this);
- this.worldProvider.a(this);
- this.chunkProvider = this.k();
-- this.Q = new PortalTravelAgent(this);
-+ this.Q = new org.bukkit.craftbukkit.CraftTravelAgent(this); // CraftBukkit
- this.B();
- this.C();
- this.getWorldBorder().a(minecraftserver.aI());
-@@ -63,6 +84,7 @@
+ this.worldProvider.a((World) this);
+ this.chunkProvider = this.n();
+- this.portalTravelAgent = new PortalTravelAgent(this);
++ this.portalTravelAgent = new org.bukkit.craftbukkit.CraftTravelAgent(this); // CraftBukkit
+ this.H();
+ this.I();
+ this.getWorldBorder().a(minecraftserver.aD());
+@@ -63,6 +79,7 @@
this.villages.a((World) this);
}
@@ -64,20 +76,20 @@
this.scoreboard = new ScoreboardServer(this.server);
PersistentScoreboard persistentscoreboard = (PersistentScoreboard) this.worldMaps.get(PersistentScoreboard.class, "scoreboard");
-@@ -73,6 +95,11 @@
+@@ -73,6 +90,11 @@
persistentscoreboard.a(this.scoreboard);
- ((ScoreboardServer) this.scoreboard).a(persistentscoreboard);
+ ((ScoreboardServer) this.scoreboard).a((Runnable) (new RunnableSaveScoreboard(persistentscoreboard)));
+ // CraftBukkit start
+ } else {
+ this.scoreboard = getServer().getScoreboardManager().getMainScoreboard().getHandle();
+ }
+ // CraftBukkit end
- this.getWorldBorder().setCenter(this.worldData.C(), this.worldData.D());
- this.getWorldBorder().setDamageAmount(this.worldData.I());
- this.getWorldBorder().setDamageBuffer(this.worldData.H());
-@@ -84,9 +111,98 @@
- this.getWorldBorder().setSize(this.worldData.E());
+ this.B = new LootTableRegistry(new File(new File(this.dataManager.getDirectory(), "data"), "loot_tables"));
+ this.getWorldBorder().setCenter(this.worldData.B(), this.worldData.C());
+ this.getWorldBorder().setDamageAmount(this.worldData.H());
+@@ -85,9 +107,98 @@
+ this.getWorldBorder().setSize(this.worldData.D());
}
+ // CraftBukkit start
@@ -152,8 +164,8 @@
+ 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});
+
-+ if (type instanceof IContainer) {
-+ TileEntity replacement = ((IContainer) type).a(this, type.toLegacyData(this.getType(pos)));
++ if (type instanceof ITileEntity) {
++ TileEntity replacement = ((ITileEntity) type).a(this, type.toLegacyData(this.getType(pos)));
+ replacement.world = this;
+ this.setTileEntity(pos, replacement);
+ return replacement;
@@ -175,31 +187,31 @@
public void doTick() {
super.doTick();
if (this.getWorldData().isHardcore() && this.getDifficulty() != EnumDifficulty.HARD) {
-@@ -104,9 +220,11 @@
- this.e();
+@@ -105,9 +216,11 @@
+ this.f();
}
- this.methodProfiler.a("mobSpawner");
- if (this.getGameRules().getBoolean("doMobSpawning") && this.worldData.getType() != WorldType.DEBUG_ALL_BLOCK_STATES) {
-- this.R.a(this, this.allowMonsters, this.allowAnimals, this.worldData.getTime() % 400L == 0L);
+- this.spawnerCreature.a(this, this.allowMonsters, this.allowAnimals, this.worldData.getTime() % 400L == 0L);
+ // 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.R.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.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);
+ // CraftBukkit end
}
this.methodProfiler.c("chunkSource");
-@@ -135,6 +253,8 @@
- this.Q.a(this.getTime());
+@@ -136,6 +249,8 @@
+ this.portalTravelAgent.a(this.getTime());
this.methodProfiler.b();
- this.ak();
+ this.ao();
+
+ this.getWorld().processChunkGC(); // CraftBukkit
}
public BiomeBase.BiomeMeta a(EnumCreatureType enumcreaturetype, BlockPosition blockposition) {
-@@ -161,7 +281,7 @@
+@@ -162,7 +277,7 @@
if (entityhuman.isSpectator()) {
++i;
@@ -208,10 +220,10 @@
++j;
}
}
-@@ -187,25 +307,46 @@
+@@ -188,25 +303,46 @@
}
- private void ag() {
+ private void c() {
- this.worldData.setWeatherDuration(0);
this.worldData.setStorm(false);
- this.worldData.setThunderDuration(0);
@@ -248,7 +260,7 @@
}
entityhuman = (EntityHuman) iterator.next();
-- } while (!entityhuman.isSpectator() && entityhuman.isDeeplySleeping());
+- } while (entityhuman.isSpectator() || entityhuman.isDeeplySleeping());
+
+ // CraftBukkit start
+ if (entityhuman.isDeeplySleeping()) {
@@ -259,36 +271,10 @@
return false;
} else {
-@@ -228,13 +369,20 @@
- int i = 0;
- int j = 0;
-
-- for (Iterator iterator1 = this.chunkTickList.iterator(); iterator1.hasNext(); this.methodProfiler.b()) {
-- ChunkCoordIntPair chunkcoordintpair1 = (ChunkCoordIntPair) iterator1.next();
-- int k = chunkcoordintpair1.x * 16;
-- int l = chunkcoordintpair1.z * 16;
-+ // CraftBukkit start
-+ //for (Iterator iterator1 = this.chunkTickList.iterator(); iterator1.hasNext(); this.methodProfiler.b()) {
-+ // ChunkCoordIntPair chunkcoordintpair1 = (ChunkCoordIntPair) iterator1.next();
-+ // int k = chunkcoordintpair1.x * 16;
-+ // int l = chunkcoordintpair1.z * 16;
-+ for (long chunkCoord : chunkTickList.popAll()) {
-+ int chunkX = LongHash.msw(chunkCoord);
-+ int chunkZ = LongHash.lsw(chunkCoord);
-+ int k = chunkX * 16;
-+ int l = chunkZ * 16;
-
- this.methodProfiler.a("getChunk");
-- Chunk chunk = this.getChunkAt(chunkcoordintpair1.x, chunkcoordintpair1.z);
-+ Chunk chunk = this.getChunkAt(chunkX, chunkZ);
-+ // CraftBukkit end
-
- this.a(k, l, chunk);
- this.methodProfiler.c("tickChunk");
-@@ -260,11 +408,29 @@
+@@ -293,11 +429,29 @@
BlockPosition blockposition1 = blockposition.down();
- if (this.w(blockposition1)) {
+ if (this.v(blockposition1)) {
- this.setTypeUpdate(blockposition1, Blocks.ICE.getBlockData());
+ // CraftBukkit start
+ BlockState blockState = this.getWorld().getBlockAt(blockposition1.getX(), blockposition1.getY(), blockposition1.getZ()).getState();
@@ -302,7 +288,7 @@
+ // CraftBukkit end
}
- if (this.S() && this.f(blockposition, true)) {
+ if (flag && this.f(blockposition, true)) {
- this.setTypeUpdate(blockposition, Blocks.SNOW_LAYER.getBlockData());
+ // CraftBukkit start
+ BlockState blockState = this.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()).getState();
@@ -316,27 +302,36 @@
+ // CraftBukkit end
}
- if (this.S() && this.getBiome(blockposition1).e()) {
-@@ -359,8 +525,8 @@
+ if (flag && this.getBiome(blockposition1).d()) {
+@@ -372,7 +526,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) {
+@@ -413,8 +567,8 @@
nextticklistentry.a(j);
}
-- if (!this.L.contains(nextticklistentry)) {
-- this.L.add(nextticklistentry);
-+ // CraftBukkit - use M, PAIL: Rename nextTickList
-+ if (!this.M.contains(nextticklistentry)) {
- this.M.add(nextticklistentry);
+- if (!this.nextTickListHash.contains(nextticklistentry)) {
+- this.nextTickListHash.add(nextticklistentry);
++ // CraftBukkit - use nextTickList
++ if (!this.nextTickList.contains(nextticklistentry)) {
+ this.nextTickList.add(nextticklistentry);
}
}
-@@ -375,15 +541,15 @@
+@@ -436,15 +590,15 @@
nextticklistentry.a((long) i + this.worldData.getTime());
}
-- if (!this.L.contains(nextticklistentry)) {
-- this.L.add(nextticklistentry);
-+ // CraftBukkit - use M, PAIL: Rename nextTickList
-+ if (!this.M.contains(nextticklistentry)) {
- this.M.add(nextticklistentry);
+- if (!this.nextTickListHash.contains(nextticklistentry)) {
+- this.nextTickListHash.add(nextticklistentry);
++ // CraftBukkit - use nextTickList
++ if (!this.nextTickList.contains(nextticklistentry)) {
+ this.nextTickList.add(nextticklistentry);
}
}
@@ -344,14 +339,14 @@
public void tickEntities() {
- if (this.players.isEmpty()) {
+ if (false && this.players.isEmpty()) { // CraftBukkit - this prevents entity cleanup, other issues on servers with no players
- if (this.emptyTime++ >= 1200) {
+ if (this.emptyTime++ >= 300) {
return;
}
-@@ -404,11 +570,17 @@
+@@ -514,11 +668,17 @@
} else {
- int i = this.M.size();
+ int i = this.nextTickList.size();
-- if (i != this.L.size()) {
+- if (i != this.nextTickListHash.size()) {
+ if (false) { // CraftBukkit
throw new IllegalStateException("TickNextTick list out of synch");
} else {
@@ -367,26 +362,27 @@
}
this.methodProfiler.a("cleaning");
-@@ -421,8 +593,8 @@
+@@ -531,8 +691,9 @@
break;
}
-+ // CraftBukkit - use M, PAIL: Rename nextTickList
- this.M.remove(nextticklistentry);
-- this.L.remove(nextticklistentry);
- this.V.add(nextticklistentry);
++ // CraftBukkit - use nextTickList
+ this.nextTickList.remove(nextticklistentry);
+- this.nextTickListHash.remove(nextticklistentry);
++ // this.nextTickListHash.remove(nextticklistentry);
+ this.U.add(nextticklistentry);
}
-@@ -489,7 +661,7 @@
-
+@@ -600,7 +761,7 @@
if (blockposition.getX() >= structureboundingbox.a && blockposition.getX() < structureboundingbox.d && blockposition.getZ() >= structureboundingbox.c && blockposition.getZ() < structureboundingbox.f) {
if (flag) {
-- this.L.remove(nextticklistentry);
-+ // CraftBukkit - use M
- iterator.remove();
- }
+ if (i == 0) {
+- this.nextTickListHash.remove(nextticklistentry);
++ // this.nextTickListHash.remove(nextticklistentry); // CraftBukkit - removed
+ }
-@@ -505,6 +677,7 @@
+ iterator.remove();
+@@ -618,6 +779,7 @@
return arraylist;
}
@@ -394,7 +390,7 @@
public void entityJoinedWorld(Entity entity, boolean flag) {
if (!this.getSpawnAnimals() && (entity instanceof EntityAnimal || entity instanceof EntityWaterAnimal)) {
entity.die();
-@@ -516,6 +689,7 @@
+@@ -629,6 +791,7 @@
super.entityJoinedWorld(entity, flag);
}
@@ -402,11 +398,11 @@
private boolean getSpawnNPCs() {
return this.server.getSpawnNPCs();
-@@ -528,13 +702,43 @@
- protected IChunkProvider k() {
+@@ -641,12 +804,42 @@
+ protected IChunkProvider n() {
IChunkLoader ichunkloader = this.dataManager.createChunkLoader(this.worldProvider);
-- this.chunkProviderServer = new ChunkProviderServer(this, ichunkloader, this.worldProvider.getChunkProvider());
+- return new ChunkProviderServer(this, ichunkloader, this.worldProvider.getChunkGenerator());
+ // CraftBukkit start
+ org.bukkit.craftbukkit.generator.InternalChunkGenerator gen;
+
@@ -420,9 +416,8 @@
+ gen = new org.bukkit.craftbukkit.generator.NormalChunkGenerator(this, this.getSeed());
+ }
+
-+ this.chunkProviderServer = new ChunkProviderServer(this, ichunkloader, gen);
++ return new ChunkProviderServer(this, ichunkloader, gen);
+ // CraftBukkit end
- return this.chunkProviderServer;
}
public List<TileEntity> getTileEntities(int i, int j, int k, int l, int i1, int j1) {
@@ -444,10 +439,10 @@
+ }
+ }
+ /*
- for (int k1 = 0; k1 < this.h.size(); ++k1) {
- TileEntity tileentity = (TileEntity) this.h.get(k1);
+ for (int k1 = 0; k1 < this.tileEntityList.size(); ++k1) {
+ TileEntity tileentity = (TileEntity) this.tileEntityList.get(k1);
BlockPosition blockposition = tileentity.getPosition();
-@@ -543,6 +747,8 @@
+@@ -655,6 +848,8 @@
arraylist.add(tileentity);
}
}
@@ -456,9 +451,9 @@
return arraylist;
}
-@@ -606,6 +812,23 @@
+@@ -718,6 +913,23 @@
int j = this.worldProvider.getSeaLevel();
- int k = 0;
+ int k = 8;
+ // CraftBukkit start
+ if (this.generator != null) {
@@ -480,7 +475,7 @@
if (blockposition != null) {
i = blockposition.getX();
k = blockposition.getZ();
-@@ -615,7 +838,7 @@
+@@ -727,7 +939,7 @@
int l = 0;
@@ -489,25 +484,25 @@
i += random.nextInt(64) - random.nextInt(64);
k += random.nextInt(64) - random.nextInt(64);
++l;
-@@ -654,6 +877,7 @@
+@@ -768,6 +980,7 @@
+ ChunkProviderServer chunkproviderserver = this.getChunkProviderServer();
- public void save(boolean flag, IProgressUpdate iprogressupdate) throws ExceptionWorldConflict {
- if (this.chunkProvider.canSave()) {
+ if (chunkproviderserver.e()) {
+ org.bukkit.Bukkit.getPluginManager().callEvent(new org.bukkit.event.world.WorldSaveEvent(getWorld())); // CraftBukkit
if (iprogressupdate != null) {
iprogressupdate.a("Saving level");
}
-@@ -664,7 +888,8 @@
+@@ -778,7 +991,8 @@
}
- this.chunkProvider.saveChunks(flag, iprogressupdate);
-- ArrayList arraylist = Lists.newArrayList(this.chunkProviderServer.a());
+ chunkproviderserver.a(flag);
+- ArrayList arraylist = Lists.newArrayList(chunkproviderserver.a());
+ // CraftBukkit - ArrayList -> Collection
-+ Collection arraylist = this.chunkProviderServer.a();
++ Collection arraylist = chunkproviderserver.a();
Iterator iterator = arraylist.iterator();
while (iterator.hasNext()) {
-@@ -695,8 +920,12 @@
+@@ -822,8 +1036,12 @@
this.worldData.k(this.getWorldBorder().getWarningTime());
this.worldData.b(this.getWorldBorder().j());
this.worldData.e(this.getWorldBorder().i());
@@ -520,8 +515,26 @@
+ // CraftBukkit end
}
- protected void a(Entity entity) {
-@@ -728,8 +957,16 @@
+ public boolean addEntity(Entity entity) {
+@@ -847,7 +1065,7 @@
+
+ private boolean i(Entity entity) {
+ if (entity.dead) {
+- WorldServer.a.warn("Tried to add entity " + EntityTypes.b(entity) + " but it was marked as removed already");
++ // WorldServer.a.warn("Tried to add entity " + EntityTypes.b(entity) + " but it was marked as removed already"); // CraftBukkit
+ return false;
+ } else {
+ UUID uuid = entity.getUniqueID();
+@@ -859,7 +1077,7 @@
+ this.f.remove(entity1);
+ } else {
+ if (!(entity instanceof EntityHuman)) {
+- WorldServer.a.warn("Keeping entity " + EntityTypes.b(entity1) + " that already exists with UUID " + uuid.toString());
++ // WorldServer.a.warn("Keeping entity " + EntityTypes.b(entity1) + " that already exists with UUID " + uuid.toString()); // CraftBukkit
+ return false;
+ }
+
+@@ -902,6 +1120,14 @@
}
public boolean strikeLightning(Entity entity) {
@@ -532,14 +545,11 @@
+ if (lightning.isCancelled()) {
+ return false;
+ }
++ // CraftBukkit end
if (super.strikeLightning(entity)) {
-- this.server.getPlayerList().sendPacketNearby(entity.locX, entity.locY, entity.locZ, 512.0D, this.worldProvider.getDimension(), new PacketPlayOutSpawnEntityWeather(entity));
-+ this.server.getPlayerList().sendPacketNearby(entity.locX, entity.locY, entity.locZ, 512.0D, dimension, new PacketPlayOutSpawnEntityWeather(entity));
-+ // CraftBukkit end
+ this.server.getPlayerList().sendPacketNearby((EntityHuman) null, entity.locX, entity.locY, entity.locZ, 512.0D, this.worldProvider.getDimensionManager().getDimensionID(), new PacketPlayOutSpawnEntityWeather(entity));
return true;
- } else {
- return false;
-@@ -741,10 +978,20 @@
+@@ -919,10 +1145,20 @@
}
public Explosion createExplosion(Entity entity, double d0, double d1, double d2, float f, boolean flag, boolean flag1) {
@@ -560,30 +570,30 @@
if (!flag1) {
explosion.clearBlocks();
}
-@@ -790,7 +1037,8 @@
+@@ -968,7 +1204,8 @@
BlockActionData blockactiondata = (BlockActionData) iterator.next();
if (this.a(blockactiondata)) {
-- this.server.getPlayerList().sendPacketNearby((double) blockactiondata.a().getX(), (double) blockactiondata.a().getY(), (double) blockactiondata.a().getZ(), 64.0D, this.worldProvider.getDimension(), new PacketPlayOutBlockAction(blockactiondata.a(), blockactiondata.d(), blockactiondata.b(), blockactiondata.c()));
+- 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((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()));
++ 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()));
}
}
-@@ -813,6 +1061,7 @@
- boolean flag = this.S();
+@@ -991,6 +1228,7 @@
+ boolean flag = this.W();
- super.p();
+ super.t();
+ /* CraftBukkit start
- if (this.o != this.p) {
- this.server.getPlayerList().a(new PacketPlayOutGameStateChange(7, this.p), this.worldProvider.getDimension());
+ if (this.n != this.o) {
+ this.server.getPlayerList().a((Packet) (new PacketPlayOutGameStateChange(7, this.o)), this.worldProvider.getDimensionManager().getDimensionID());
}
-@@ -831,6 +1080,21 @@
- this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(7, this.p));
- this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(8, this.r));
+@@ -1009,6 +1247,21 @@
+ this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(7, this.o));
+ this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(8, this.q));
}
+ // */
-+ if (flag != this.S()) {
++ if (flag != this.W()) {
+ // Only send weather packets to those affected
+ for (int i = 0; i < this.players.size(); ++i) {
+ if (((EntityPlayer) this.players.get(i)).world == this) {
@@ -593,14 +603,14 @@
+ }
+ for (int i = 0; i < this.players.size(); ++i) {
+ if (((EntityPlayer) this.players.get(i)).world == this) {
-+ ((EntityPlayer) this.players.get(i)).updateWeather(this.o, this.p, this.q, this.r);
++ ((EntityPlayer) this.players.get(i)).updateWeather(this.n, this.o, this.p, this.q);
+ }
+ }
+ // CraftBukkit end
}
-@@ -859,10 +1123,17 @@
+@@ -1037,10 +1290,20 @@
}
public void a(EnumParticle enumparticle, boolean flag, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6, int... aint) {
@@ -615,6 +625,9 @@
for (int j = 0; j < this.players.size(); ++j) {
EntityPlayer entityplayer = (EntityPlayer) this.players.get(j);
+ if (sender != null && !entityplayer.getBukkitEntity().canSee(sender.getBukkitEntity())) continue; // CraftBukkit
- BlockPosition blockposition = entityplayer.getChunkCoordinates();
- double d7 = blockposition.c(d0, d1, d2);
++ BlockPosition blockposition = entityplayer.getChunkCoordinates();
++ double d7 = blockposition.distanceSquared(d0, d1, d2);
++
+ this.a(entityplayer, flag, d0, d1, d2, packetplayoutworldparticles);
+ }
diff --git a/pom.xml b/pom.xml
index f1fb28f7..5afb2b80 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,16 +4,15 @@
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<packaging>jar</packaging>
- <version>1.8.8-R0.1-SNAPSHOT</version>
+ <version>1.9-SNAPSHOT</version>
<name>CraftBukkit</name>
<url>http://www.bukkit.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<api.version>unknown</api.version>
- <junit.version>4.11</junit.version>
- <minecraft.version>1.8.8</minecraft.version>
- <minecraft_version>1_8_R3</minecraft_version>
+ <minecraft.version>1.9</minecraft.version>
+ <minecraft_version>1_9_R1</minecraft_version>
<buildtag.prefix>git-Bukkit-</buildtag.prefix>
<buildtag.suffix></buildtag.suffix>
<maven.compiler.source>1.6</maven.compiler.source>
@@ -25,49 +24,43 @@
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>${project.version}</version>
- <type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>minecraft-server</artifactId>
<version>${minecraft.version}-SNAPSHOT</version>
- <type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.sf.jopt-simple</groupId>
<artifactId>jopt-simple</artifactId>
- <version>3.2</version>
- <type>jar</type>
+ <version>4.9</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>jline</groupId>
<artifactId>jline</artifactId>
<version>2.12</version>
- <type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.7.2</version>
- <type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
- <version>5.1.14</version>
- <type>jar</type>
+ <version>5.1.37</version>
<scope>compile</scope>
</dependency>
<!-- testing -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>${junit.version}</version>
+ <version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -88,7 +81,6 @@
<!-- This builds a completely 'ready to start' jar with all dependencies inside -->
<build>
- <defaultGoal>clean install</defaultGoal>
<plugins>
<plugin>
<groupId>net.md-5</groupId>
@@ -109,7 +101,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
- <version>2.5</version>
+ <version>2.6</version>
<configuration>
<archive>
<manifestEntries>
@@ -147,7 +139,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>animal-sniffer-maven-plugin</artifactId>
- <version>1.13</version>
+ <version>1.14</version>
<executions>
<execution>
<phase>process-classes</phase>
@@ -167,7 +159,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
- <version>2.3</version>
+ <version>2.4.1</version>
<executions>
<execution>
<phase>package</phase>
@@ -208,24 +200,6 @@
</execution>
</executions>
</plugin>
- <!-- Gotta go after shade plugin -->
- <plugin>
- <groupId>net.md-5</groupId>
- <artifactId>specialsource-maven-plugin</artifactId>
- <version>1.2.1</version>
- <executions>
- <execution>
- <phase>package</phase>
- <goals>
- <goal>remap</goal>
- </goals>
- <configuration>
- <srgIn>${project.basedir}/deprecation-mappings.csrg</srgIn>
- <accessIn>${project.basedir}/deprecation-mappings.at</accessIn>
- </configuration>
- </execution>
- </executions>
- </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
@@ -249,7 +223,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
- <version>2.18</version>
+ <version>2.19</version>
<configuration>
<workingDirectory>${basedir}/target/test-server</workingDirectory>
<excludes>
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java
index 8a33e282..f7d8decb 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java
@@ -23,9 +23,7 @@ public class CraftChunk implements Chunk {
private static final byte[] emptySkyLight = new byte[2048];
public CraftChunk(net.minecraft.server.Chunk chunk) {
- if (!(chunk instanceof EmptyChunk)) {
- this.weakChunk = new WeakReference<net.minecraft.server.Chunk>(chunk);
- }
+ this.weakChunk = new WeakReference<net.minecraft.server.Chunk>(chunk);
worldServer = (WorldServer) getHandle().world;
x = getHandle().locX;
@@ -46,9 +44,7 @@ public class CraftChunk implements Chunk {
if (c == null) {
c = worldServer.getChunkAt(x, z);
- if (!(c instanceof EmptyChunk)) {
- weakChunk = new WeakReference<net.minecraft.server.Chunk>(c);
- }
+ weakChunk = new WeakReference<net.minecraft.server.Chunk>(c);
}
return c;
@@ -164,22 +160,16 @@ public class CraftChunk implements Chunk {
sectionEmpty[i] = true;
} else { // Not empty
short[] blockids = new short[4096];
- char[] baseids = cs[i].getIdArray();
- byte[] dataValues = sectionBlockData[i] = new byte[2048];
+
+ byte[] rawIds = new byte[4096];
+ NibbleArray data = new NibbleArray();
+ cs[i].getBlocks().exportData(rawIds, data);
+
+ byte[] dataValues = sectionBlockData[i] = data.asBytes();
// Copy base IDs
for (int j = 0; j < 4096; j++) {
- if (baseids[j] == 0) continue;
- IBlockData blockData = (IBlockData) net.minecraft.server.Block.d.a(baseids[j]);
- if (blockData == null) continue;
- blockids[j] = (short) net.minecraft.server.Block.getId(blockData.getBlock());
- int data = blockData.getBlock().toLegacyData(blockData);
- int jj = j >> 1;
- if ((j & 1) == 0) {
- dataValues[jj] = (byte) ((dataValues[jj] & 0xF0) | (data & 0xF));
- } else {
- dataValues[jj] = (byte) ((dataValues[jj] & 0xF) | ((data & 0xF) << 4));
- }
+ blockids[j] = (short) (rawIds[j] & 0xFF);
}
sectionBlockIDs[i] = blockids;
@@ -188,10 +178,10 @@ public class CraftChunk implements Chunk {
sectionSkyLights[i] = emptyData;
} else {
sectionSkyLights[i] = new byte[2048];
- System.arraycopy(cs[i].getSkyLightArray().a(), 0, sectionSkyLights[i], 0, 2048);
+ System.arraycopy(cs[i].getSkyLightArray().asBytes(), 0, sectionSkyLights[i], 0, 2048);
}
sectionEmitLights[i] = new byte[2048];
- System.arraycopy(cs[i].getEmittedLightArray().a(), 0, sectionEmitLights[i], 0, 2048);
+ System.arraycopy(cs[i].getEmittedLightArray().asBytes(), 0, sectionEmitLights[i], 0, 2048);
}
}
@@ -225,11 +215,13 @@ public class CraftChunk implements Chunk {
biomeTemp[i] = dat[i];
}
+ /* Removed 15w46a
dat = wcm.getWetness(null, getX() << 4, getZ() << 4, 16, 16);
for (int i = 0; i < 256; i++) {
biomeRain[i] = dat[i];
}
+ */
}
}
@@ -261,11 +253,13 @@ public class CraftChunk implements Chunk {
biomeTemp[i] = dat[i];
}
+ /* Removed 15w46a
dat = wcm.getWetness(null, x << 4, z << 4, 16, 16);
for (int i = 0; i < 256; i++) {
biomeRain[i] = dat[i];
}
+ */
}
}
@@ -293,7 +287,7 @@ public class CraftChunk implements Chunk {
float[] temps = new float[biomes.length];
for (int i = 0; i < biomes.length; i++) {
- float temp = biomes[i].temperature; // Vanilla of olde: ((int) biomes[i].temperature * 65536.0F) / 65536.0F
+ float temp = biomes[i].getTemperature(); // Vanilla of olde: ((int) biomes[i].temperature * 65536.0F) / 65536.0F
if (temp > 1F) {
temp = 1F;
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftEquipmentSlot.java b/src/main/java/org/bukkit/craftbukkit/CraftEquipmentSlot.java
index a33f446f..339ae6b7 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftEquipmentSlot.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftEquipmentSlot.java
@@ -1,35 +1,32 @@
package org.bukkit.craftbukkit;
+import net.minecraft.server.EnumItemSlot;
import org.bukkit.inventory.EquipmentSlot;
public class CraftEquipmentSlot {
- private static final int[] slots = new int[EquipmentSlot.values().length];
- private static final EquipmentSlot[] enums = new EquipmentSlot[EquipmentSlot.values().length];
+ private static final EnumItemSlot[] slots = new EnumItemSlot[EquipmentSlot.values().length];
+ private static final EquipmentSlot[] enums = new EquipmentSlot[EnumItemSlot.values().length];
static {
- set(EquipmentSlot.HAND, 0);
- set(EquipmentSlot.FEET, 1);
- set(EquipmentSlot.LEGS, 2);
- set(EquipmentSlot.CHEST, 3);
- set(EquipmentSlot.HEAD, 4);
+ set(EquipmentSlot.HAND, EnumItemSlot.MAINHAND);
+ set(EquipmentSlot.OFF_HAND, EnumItemSlot.OFFHAND);
+ set(EquipmentSlot.FEET, EnumItemSlot.FEET);
+ set(EquipmentSlot.LEGS, EnumItemSlot.LEGS);
+ set(EquipmentSlot.CHEST, EnumItemSlot.CHEST);
+ set(EquipmentSlot.HEAD, EnumItemSlot.HEAD);
}
- private static void set(EquipmentSlot type, int value) {
+ private static void set(EquipmentSlot type, EnumItemSlot value) {
slots[type.ordinal()] = value;
- if (value < enums.length) {
- enums[value] = type;
- }
+ enums[value.ordinal()] = type;
}
- public static EquipmentSlot getSlot(int magic) {
- if (magic > 0 && magic < enums.length) {
- return enums[magic];
- }
- return null;
+ public static EquipmentSlot getSlot(EnumItemSlot nms) {
+ return enums[nms.ordinal()];
}
- public static int getSlotIndex(EquipmentSlot slot) {
+ public static EnumItemSlot getNMS(EquipmentSlot slot) {
return slots[slot.ordinal()];
}
}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftParticle.java b/src/main/java/org/bukkit/craftbukkit/CraftParticle.java
new file mode 100644
index 00000000..9c2540f2
--- /dev/null
+++ b/src/main/java/org/bukkit/craftbukkit/CraftParticle.java
@@ -0,0 +1,42 @@
+package org.bukkit.craftbukkit;
+
+import net.minecraft.server.Block;
+import net.minecraft.server.EnumParticle;
+import net.minecraft.server.IBlockData;
+import org.bukkit.Particle;
+import org.bukkit.craftbukkit.util.CraftMagicNumbers;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.material.MaterialData;
+
+public class CraftParticle {
+
+ public static EnumParticle toNMS(Particle bukkit) {
+ return EnumParticle.valueOf(bukkit.name());
+ }
+
+ public static Particle toBukkit(EnumParticle nms) {
+ return Particle.valueOf(nms.name());
+ }
+
+ public static int[] toData(Particle particle, Object obj) {
+ if (particle.getDataType().equals(Void.class)) {
+ return new int[0];
+ }
+ if (particle.getDataType().equals(ItemStack.class)) {
+ if (obj == null) {
+ return new int[]{0, 0};
+ }
+ ItemStack itemStack = (ItemStack) obj;
+ return new int[]{itemStack.getType().getId(), itemStack.getDurability()};
+ }
+ if (particle.getDataType().equals(MaterialData.class)) {
+ if (obj == null) {
+ return new int[]{0};
+ }
+ MaterialData data = (MaterialData) obj;
+ IBlockData nms = CraftMagicNumbers.getBlock(data.getItemType()).fromLegacyData(data.getData());
+ return new int[]{Block.REGISTRY_ID.getId(nms)};
+ }
+ throw new IllegalArgumentException(particle.getDataType().toString());
+ }
+}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 90064eae..d330226d 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -36,6 +36,10 @@ import org.bukkit.Warning.WarningState;
import org.bukkit.World;
import org.bukkit.World.Environment;
import org.bukkit.WorldCreator;
+import org.bukkit.boss.BarColor;
+import org.bukkit.boss.BarFlag;
+import org.bukkit.boss.BarStyle;
+import org.bukkit.boss.BossBar;
import org.bukkit.command.Command;
import org.bukkit.command.CommandException;
import org.bukkit.command.CommandSender;
@@ -46,6 +50,7 @@ import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.configuration.serialization.ConfigurationSerialization;
import org.bukkit.conversations.Conversable;
+import org.bukkit.craftbukkit.boss.CraftBossBar;
import org.bukkit.craftbukkit.command.VanillaCommandWrapper;
import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.craftbukkit.generator.CraftChunkData;
@@ -74,7 +79,6 @@ import org.bukkit.event.inventory.InventoryType;
import org.bukkit.event.player.PlayerChatTabCompleteEvent;
import org.bukkit.event.world.WorldInitEvent;
import org.bukkit.event.world.WorldLoadEvent;
-import org.bukkit.event.world.WorldSaveEvent;
import org.bukkit.event.world.WorldUnloadEvent;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.help.HelpMap;
@@ -188,11 +192,11 @@ public final class CraftServer implements Server {
Bukkit.setServer(this);
// Register all the Enchantments and PotionTypes now so we can stop new registration immediately after
- Enchantment.DAMAGE_ALL.getClass();
+ Enchantments.DAMAGE_ALL.getClass();
org.bukkit.enchantments.Enchantment.stopAcceptingRegistrations();
Potion.setPotionBrewer(new CraftPotionBrewer());
- MobEffectList.BLINDNESS.getClass();
+ MobEffects.BLINDNESS.getClass();
PotionEffectType.stopAcceptingRegistrations();
// Ugly hack :(
@@ -331,7 +335,7 @@ public final class CraftServer implements Server {
}
private void setVanillaCommands() {
- Map<String, ICommand> commands = new CommandDispatcher().getCommands();
+ Map<String, ICommand> commands = new CommandDispatcher(console).getCommands();
for (ICommand cmd : commands.values()) {
commandMap.register("minecraft", new VanillaCommandWrapper((CommandAbstract) cmd, LocaleI18n.get(cmd.getUsage(null))));
}
@@ -467,7 +471,7 @@ public final class CraftServer implements Server {
return playerList.getMaxPlayers();
}
- // NOTE: These are dependent on the corrisponding call in MinecraftServer
+ // NOTE: These are dependent on the corresponding call in MinecraftServer
// so if that changes this will need to as well
@Override
public int getPort() {
@@ -823,7 +827,7 @@ public final class CraftServer implements Server {
generator = getGenerator(name);
}
- Convertable converter = new WorldLoaderServer(getWorldContainer());
+ Convertable converter = new WorldLoaderServer(getWorldContainer(), getHandle().getServer().getDataConverterManager());
if (converter.isConvertable(name)) {
getLogger().info("Converting world '" + name + "'");
converter.convert(name, new IProgressUpdate() {
@@ -856,7 +860,7 @@ public final class CraftServer implements Server {
} while(used);
boolean hardcore = false;
- IDataManager sdm = new ServerNBTManager(getWorldContainer(), name, true);
+ IDataManager sdm = new ServerNBTManager(getWorldContainer(), name, true, getHandle().getServer().getDataConverterManager());
WorldData worlddata = sdm.getWorldData();
if (worlddata == null) {
WorldSettings worldSettings = new WorldSettings(creator.seed(), WorldSettings.EnumGamemode.getById(getDefaultGameMode().getValue()), generateStructures, hardcore, type);
@@ -905,7 +909,7 @@ public final class CraftServer implements Server {
}
BlockPosition chunkcoordinates = internal.getSpawn();
- internal.chunkProviderServer.getChunkAt(chunkcoordinates.getX() + j >> 4, chunkcoordinates.getZ() + k >> 4);
+ internal.getChunkProviderServer().getChunkAt(chunkcoordinates.getX() + j >> 4, chunkcoordinates.getZ() + k >> 4);
}
}
}
@@ -1084,6 +1088,7 @@ public final class CraftServer implements Server {
CraftingManager.getInstance().recipes.clear();
RecipesFurnace.getInstance().recipes.clear();
RecipesFurnace.getInstance().customRecipes.clear();
+ RecipesFurnace.getInstance().customExperience.clear();
}
@Override
@@ -1091,6 +1096,7 @@ public final class CraftServer implements Server {
CraftingManager.getInstance().recipes = new CraftingManager().recipes;
RecipesFurnace.getInstance().recipes = new RecipesFurnace().recipes;
RecipesFurnace.getInstance().customRecipes.clear();
+ RecipesFurnace.getInstance().customExperience.clear();
}
@Override
@@ -1250,7 +1256,7 @@ public final class CraftServer implements Server {
OfflinePlayer result = getPlayerExact(name);
if (result == null) {
// This is potentially blocking :(
- GameProfile profile = MinecraftServer.getServer().getUserCache().getProfile(name);
+ GameProfile profile = console.getUserCache().getProfile(name);
if (profile == null) {
// Make an OfflinePlayer using an offline mode UUID since the name has no profile
result = getOfflinePlayer(new GameProfile(UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(Charsets.UTF_8)), name));
@@ -1637,6 +1643,11 @@ public final class CraftServer implements Server {
return new CraftChunkData(world);
}
+ @Override
+ public BossBar createBossBar(String title, BarColor color, BarStyle style, BarFlag... flags) {
+ return new CraftBossBar(title, color, style, flags);
+ }
+
@Deprecated
@Override
public UnsafeValues getUnsafe() {
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftSound.java b/src/main/java/org/bukkit/craftbukkit/CraftSound.java
index 0cc8f9ba..2c85e1b5 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftSound.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftSound.java
@@ -1,230 +1,25 @@
package org.bukkit.craftbukkit;
-import static org.bukkit.Sound.*;
+import com.google.common.base.Preconditions;
+import net.minecraft.server.MinecraftKey;
+import net.minecraft.server.SoundEffect;
import org.apache.commons.lang.Validate;
import org.bukkit.Sound;
public class CraftSound {
- private static final String[] sounds = new String[Sound.values().length];
- static {
- // Ambient
- set(AMBIENCE_CAVE, "ambient.cave.cave");
- set(AMBIENCE_RAIN, "ambient.weather.rain");
- set(AMBIENCE_THUNDER, "ambient.weather.thunder");
- // Damage
- set(HURT_FLESH, "game.neutral.hurt");
- set(FALL_BIG, "game.neutral.hurt.fall.big");
- set(FALL_SMALL, "game.neutral.hurt.fall.small");
- // Dig Sounds
- set(DIG_WOOL, "dig.cloth");
- set(DIG_GRASS, "dig.grass");
- set(DIG_GRAVEL, "dig.gravel");
- set(DIG_SAND, "dig.sand");
- set(DIG_SNOW, "dig.snow");
- set(DIG_STONE, "dig.stone");
- set(DIG_WOOD, "dig.wood");
- // Fire
- set(FIRE, "fire.fire");
- set(FIRE_IGNITE, "fire.ignite");
- // Fireworks
- set(FIREWORK_BLAST, "fireworks.blast");
- set(FIREWORK_BLAST2, "fireworks.blast_far");
- set(FIREWORK_LARGE_BLAST, "fireworks.largeBlast");
- set(FIREWORK_LARGE_BLAST2, "fireworks.largeBlast_far");
- set(FIREWORK_TWINKLE, "fireworks.twinkle");
- set(FIREWORK_TWINKLE2, "fireworks.twinkle_far");
- set(FIREWORK_LAUNCH, "fireworks.launch");
- // Liquid
- set(SPLASH2, "game.neutral.swim.splash");
- set(SWIM, "game.neutral.swim");
- set(WATER, "liquid.water");
- set(LAVA, "liquid.lava");
- set(LAVA_POP, "liquid.lavapop");
- // Minecart
- set(MINECART_BASE, "minecart.base");
- set(MINECART_INSIDE, "minecart.inside");
- // Mob
- set(BAT_DEATH, "mob.bat.death");
- set(BAT_HURT, "mob.bat.hurt");
- set(BAT_IDLE, "mob.bat.idle");
- set(BAT_LOOP, "mob.bat.loop");
- set(BAT_TAKEOFF, "mob.bat.takeoff");
- set(BLAZE_BREATH, "mob.blaze.breathe");
- set(BLAZE_DEATH, "mob.blaze.death");
- set(BLAZE_HIT, "mob.blaze.hit");
- set(CAT_HISS, "mob.cat.hiss");
- set(CAT_HIT, "mob.cat.hitt");
- set(CAT_MEOW, "mob.cat.meow");
- set(CAT_PURR, "mob.cat.purr");
- set(CAT_PURREOW, "mob.cat.purreow");
- set(CHICKEN_IDLE, "mob.chicken.say");
- set(CHICKEN_HURT, "mob.chicken.hurt");
- set(CHICKEN_EGG_POP, "mob.chicken.plop");
- set(CHICKEN_WALK, "mob.chicken.step");
- set(COW_HURT, "mob.cow.hurt");
- set(COW_IDLE, "mob.cow.say");
- set(COW_WALK, "mob.cow.step");
- set(CREEPER_DEATH, "mob.creeper.death");
- set(CREEPER_HISS, "mob.creeper.say");
- set(ENDERDRAGON_DEATH, "mob.enderdragon.end");
- set(ENDERDRAGON_GROWL, "mob.enderdragon.growl");
- set(ENDERDRAGON_HIT, "mob.enderdragon.hit");
- set(ENDERDRAGON_WINGS, "mob.enderdragon.wings");
- set(ENDERMAN_DEATH, "mob.endermen.death");
- set(ENDERMAN_HIT, "mob.endermen.hit");
- set(ENDERMAN_IDLE, "mob.endermen.idle");
- set(ENDERMAN_TELEPORT, "mob.endermen.portal");
- set(ENDERMAN_SCREAM, "mob.endermen.scream");
- set(ENDERMAN_STARE, "mob.endermen.stare");
- set(GHAST_SCREAM2, "mob.ghast.affectionate_scream");
- set(GHAST_CHARGE, "mob.ghast.charge");
- set(GHAST_DEATH, "mob.ghast.death");
- set(GHAST_FIREBALL, "mob.ghast.fireball");
- set(GHAST_MOAN, "mob.ghast.moan");
- set(GHAST_SCREAM, "mob.ghast.scream");
- set(HORSE_ANGRY, "mob.horse.angry");
- set(HORSE_ARMOR, "mob.horse.armor");
- set(HORSE_BREATHE, "mob.horse.breathe");
- set(HORSE_DEATH, "mob.horse.death");
- set(HORSE_GALLOP, "mob.horse.gallop");
- set(HORSE_HIT, "mob.horse.hit");
- set(HORSE_IDLE, "mob.horse.idle");
- set(HORSE_JUMP, "mob.horse.jump");
- set(HORSE_LAND, "mob.horse.land");
- set(HORSE_SADDLE, "mob.horse.leather");
- set(HORSE_SOFT, "mob.horse.soft");
- set(HORSE_WOOD, "mob.horse.wood");
- set(DONKEY_ANGRY, "mob.horse.donkey.angry");
- set(DONKEY_DEATH, "mob.horse.donkey.death");
- set(DONKEY_HIT, "mob.horse.donkey.hit");
- set(DONKEY_IDLE, "mob.horse.donkey.idle");
- set(HORSE_SKELETON_DEATH, "mob.horse.skeleton.death");
- set(HORSE_SKELETON_HIT, "mob.horse.skeleton.hit");
- set(HORSE_SKELETON_IDLE, "mob.horse.skeleton.idle");
- set(HORSE_ZOMBIE_DEATH, "mob.horse.zombie.death");
- set(HORSE_ZOMBIE_HIT, "mob.horse.zombie.hit");
- set(HORSE_ZOMBIE_IDLE, "mob.horse.zombie.idle");
- set(IRONGOLEM_DEATH, "mob.irongolem.death");
- set(IRONGOLEM_HIT, "mob.irongolem.hit");
- set(IRONGOLEM_THROW, "mob.irongolem.throw");
- set(IRONGOLEM_WALK, "mob.irongolem.walk");
- set(MAGMACUBE_WALK, "mob.magmacube.small");
- set(MAGMACUBE_WALK2, "mob.magmacube.big");
- set(MAGMACUBE_JUMP, "mob.magmacube.jump");
- set(PIG_IDLE, "mob.pig.say");
- set(PIG_DEATH, "mob.pig.death");
- set(PIG_WALK, "mob.pig.step");
- set(SHEEP_IDLE, "mob.sheep.say");
- set(SHEEP_SHEAR, "mob.sheep.shear");
- set(SHEEP_WALK, "mob.sheep.step");
- set(SILVERFISH_HIT, "mob.silverfish.hit");
- set(SILVERFISH_KILL, "mob.silverfish.kill");
- set(SILVERFISH_IDLE, "mob.silverfish.say");
- set(SILVERFISH_WALK, "mob.silverfish.step");
- set(SKELETON_IDLE, "mob.skeleton.say");
- set(SKELETON_DEATH, "mob.skeleton.death");
- set(SKELETON_HURT, "mob.skeleton.hurt");
- set(SKELETON_WALK, "mob.skeleton.step");
- set(SLIME_ATTACK, "mob.slime.attack");
- set(SLIME_WALK, "mob.slime.small");
- set(SLIME_WALK2, "mob.slime.big");
- set(SPIDER_IDLE, "mob.spider.say");
- set(SPIDER_DEATH, "mob.spider.death");
- set(SPIDER_WALK, "mob.spider.step");
- set(VILLAGER_DEATH, "mob.villager.death");
- set(VILLAGER_HAGGLE, "mob.villager.haggle");
- set(VILLAGER_HIT, "mob.villager.hit");
- set(VILLAGER_IDLE, "mob.villager.idle");
- set(VILLAGER_NO, "mob.villager.no");
- set(VILLAGER_YES, "mob.villager.yes");
- set(WITHER_DEATH, "mob.wither.death");
- set(WITHER_HURT, "mob.wither.hurt");
- set(WITHER_IDLE, "mob.wither.idle");
- set(WITHER_SHOOT, "mob.wither.shoot");
- set(WITHER_SPAWN, "mob.wither.spawn");
- set(WOLF_BARK, "mob.wolf.bark");
- set(WOLF_DEATH, "mob.wolf.death");
- set(WOLF_GROWL, "mob.wolf.growl");
- set(WOLF_HOWL, "mob.wolf.howl");
- set(WOLF_HURT, "mob.wolf.hurt");
- set(WOLF_PANT, "mob.wolf.panting");
- set(WOLF_SHAKE, "mob.wolf.shake");
- set(WOLF_WALK, "mob.wolf.step");
- set(WOLF_WHINE, "mob.wolf.whine");
- set(ZOMBIE_METAL, "mob.zombie.metal");
- set(ZOMBIE_WOOD, "mob.zombie.wood");
- set(ZOMBIE_WOODBREAK, "mob.zombie.woodbreak");
- set(ZOMBIE_IDLE, "mob.zombie.say");
- set(ZOMBIE_DEATH, "mob.zombie.death");
- set(ZOMBIE_HURT, "mob.zombie.hurt");
- set(ZOMBIE_INFECT, "mob.zombie.infect");
- set(ZOMBIE_UNFECT, "mob.zombie.unfect");
- set(ZOMBIE_REMEDY, "mob.zombie.remedy");
- set(ZOMBIE_WALK, "mob.zombie.step");
- set(ZOMBIE_PIG_IDLE, "mob.zombiepig.zpig");
- set(ZOMBIE_PIG_ANGRY, "mob.zombiepig.zpigangry");
- set(ZOMBIE_PIG_DEATH, "mob.zombiepig.zpigdeath");
- set(ZOMBIE_PIG_HURT, "mob.zombiepig.zpighurt");
- // Note (blocks)
- set(NOTE_BASS_GUITAR, "note.bassattack");
- set(NOTE_SNARE_DRUM, "note.snare");
- set(NOTE_PLING, "note.pling");
- set(NOTE_BASS, "note.bass");
- set(NOTE_PIANO, "note.harp");
- set(NOTE_BASS_DRUM, "note.bd");
- set(NOTE_STICKS, "note.hat");
- // Portal
- set(PORTAL, "portal.portal");
- set(PORTAL_TRAVEL, "portal.travel");
- set(PORTAL_TRIGGER, "portal.trigger");
- // Random
- set(ANVIL_BREAK, "random.anvil_break");
- set(ANVIL_LAND, "random.anvil_land");
- set(ANVIL_USE, "random.anvil_use");
- set(SHOOT_ARROW, "random.bow");
- set(ARROW_HIT, "random.bowhit");
- set(ITEM_BREAK, "random.break");
- set(BURP, "random.burp");
- set(CHEST_CLOSE, "random.chestclosed");
- set(CHEST_OPEN, "random.chestopen");
- set(CLICK, "random.click");
- set(DOOR_CLOSE, "random.door_close");
- set(DOOR_OPEN, "random.door_open");
- set(DRINK, "random.drink");
- set(EAT, "random.eat");
- set(EXPLODE, "random.explode");
- set(FIZZ, "random.fizz");
- set(FUSE, "creeper.primed");
- set(GLASS, "dig.glass");
- set(LEVEL_UP, "random.levelup");
- set(ORB_PICKUP, "random.orb");
- set(ITEM_PICKUP, "random.pop");
- set(SPLASH, "random.splash");
- set(SUCCESSFUL_HIT, "random.successful_hit");
- set(WOOD_CLICK, "random.wood_click");
- // Step
- set(STEP_WOOL, "step.cloth");
- set(STEP_GRASS, "step.grass");
- set(STEP_GRAVEL, "step.gravel");
- set(STEP_LADDER, "step.ladder");
- set(STEP_SAND, "step.sand");
- set(STEP_SNOW, "step.snow");
- set(STEP_STONE, "step.stone");
- set(STEP_WOOD, "step.wood");
- // Tile
- set(PISTON_EXTEND, "tile.piston.out");
- set(PISTON_RETRACT, "tile.piston.in");
- }
+ public static String getSound(final Sound sound) {
+ Validate.notNull(sound, "Sound cannot be null");
- private static void set(Sound sound, String key) {
- sounds[sound.ordinal()] = key;
+ return sound.name().replace('_', '.').toLowerCase();
}
- public static String getSound(final Sound sound) {
- Validate.notNull(sound, "Sound cannot be null");
- return sounds[sound.ordinal()];
+ public static SoundEffect getSoundEffect(String s) {
+ SoundEffect effect = SoundEffect.a.get(new MinecraftKey(s));
+ Preconditions.checkArgument(effect != null, "Sound effect %s does not exist", s);
+
+ return effect;
}
private CraftSound() {}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftStatistic.java b/src/main/java/org/bukkit/craftbukkit/CraftStatistic.java
index 3341c994..905cebe9 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftStatistic.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftStatistic.java
@@ -16,6 +16,7 @@ import com.google.common.collect.ImmutableMap;
import net.minecraft.server.Block;
import net.minecraft.server.Item;
import net.minecraft.server.MinecraftKey;
+import org.bukkit.craftbukkit.util.CraftMagicNumbers;
public class CraftStatistic {
private static final BiMap<String, org.bukkit.Statistic> statistics;
@@ -69,24 +70,30 @@ public class CraftStatistic {
}
public static org.bukkit.Statistic getBukkitStatisticByName(String name) {
- if (name.startsWith("stat.killEntity")) {
+ if (name.startsWith("stat.killEntity.")) {
name = "stat.killEntity";
}
- if (name.startsWith("stat.entityKilledBy")) {
+ if (name.startsWith("stat.entityKilledBy.")) {
name = "stat.entityKilledBy";
}
- if (name.startsWith("stat.breakItem")) {
+ if (name.startsWith("stat.breakItem.")) {
name = "stat.breakItem";
}
- if (name.startsWith("stat.useItem")) {
+ if (name.startsWith("stat.useItem.")) {
name = "stat.useItem";
}
- if (name.startsWith("stat.mineBlock")) {
+ if (name.startsWith("stat.mineBlock.")) {
name = "stat.mineBlock";
}
- if (name.startsWith("stat.craftItem")) {
+ if (name.startsWith("stat.craftItem.")) {
name = "stat.craftItem";
}
+ if (name.startsWith("stat.drop.")) {
+ name = "stat.drop";
+ }
+ if (name.startsWith("stat.pickup.")) {
+ name = "stat.pickup";
+ }
return statistics.get(name);
}
@@ -101,16 +108,16 @@ public class CraftStatistic {
public static net.minecraft.server.Statistic getMaterialStatistic(org.bukkit.Statistic stat, Material material) {
try {
if (stat == Statistic.MINE_BLOCK) {
- return StatisticList.MINE_BLOCK_COUNT[material.getId()];
+ return StatisticList.a(CraftMagicNumbers.getBlock(material)); // PAIL: getMineBlockStatistic
}
if (stat == Statistic.CRAFT_ITEM) {
- return StatisticList.CRAFT_BLOCK_COUNT[material.getId()];
+ return StatisticList.a(CraftMagicNumbers.getItem(material)); // PAIL: getCraftItemStatistic
}
if (stat == Statistic.USE_ITEM) {
- return StatisticList.USE_ITEM_COUNT[material.getId()];
+ return StatisticList.b(CraftMagicNumbers.getItem(material)); // PAIL: getUseItemStatistic
}
if (stat == Statistic.BREAK_ITEM) {
- return StatisticList.BREAK_ITEM_COUNT[material.getId()];
+ return StatisticList.c(CraftMagicNumbers.getItem(material)); // PAIL: getBreakItemStatistic
}
} catch (ArrayIndexOutOfBoundsException e) {
return null;
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftTravelAgent.java b/src/main/java/org/bukkit/craftbukkit/CraftTravelAgent.java
index cae65cf8..1d5dce10 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftTravelAgent.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftTravelAgent.java
@@ -25,8 +25,6 @@ public class CraftTravelAgent extends PortalTravelAgent implements TravelAgent {
@Override
public Location findOrCreate(Location target) {
WorldServer worldServer = ((CraftWorld) target.getWorld()).getHandle();
- boolean before = worldServer.chunkProviderServer.forceChunkLoad;
- worldServer.chunkProviderServer.forceChunkLoad = true;
Location found = this.findPortal(target);
if (found == null) {
@@ -37,7 +35,6 @@ public class CraftTravelAgent extends PortalTravelAgent implements TravelAgent {
}
}
- worldServer.chunkProviderServer.forceChunkLoad = before;
return found;
}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index d4c1a123..45b5de6a 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -22,6 +22,7 @@ import org.bukkit.ChunkSnapshot;
import org.bukkit.Difficulty;
import org.bukkit.Effect;
import org.bukkit.Location;
+import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.TreeType;
import org.bukkit.World;
@@ -45,8 +46,6 @@ import org.bukkit.entity.minecart.PoweredMinecart;
import org.bukkit.entity.minecart.SpawnerMinecart;
import org.bukkit.entity.minecart.StorageMinecart;
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
-import org.bukkit.event.weather.ThunderChangeEvent;
-import org.bukkit.event.weather.WeatherChangeEvent;
import org.bukkit.event.world.SpawnChangeEvent;
import org.bukkit.generator.BlockPopulator;
import org.bukkit.generator.ChunkGenerator;
@@ -123,7 +122,7 @@ public class CraftWorld implements World {
}
public Chunk getChunkAt(int x, int z) {
- return this.world.chunkProviderServer.getChunkAt(x, z).bukkitChunk;
+ return this.world.getChunkProviderServer().getChunkAt(x, z).bukkitChunk;
}
public Chunk getChunkAt(Block block) {
@@ -131,11 +130,11 @@ public class CraftWorld implements World {
}
public boolean isChunkLoaded(int x, int z) {
- return world.chunkProviderServer.isChunkLoaded(x, z);
+ return world.getChunkProviderServer().isChunkLoaded(x, z);
}
public Chunk[] getLoadedChunks() {
- Object[] chunks = world.chunkProviderServer.chunks.values().toArray();
+ Object[] chunks = world.getChunkProviderServer().chunks.values().toArray();
org.bukkit.Chunk[] craftChunks = new CraftChunk[chunks.length];
for (int i = 0; i < chunks.length; i++) {
@@ -171,7 +170,7 @@ public class CraftWorld implements World {
return false;
}
- world.chunkProviderServer.queueUnload(x, z);
+ world.getChunkProviderServer().queueUnload(x, z);
return true;
}
@@ -181,20 +180,20 @@ public class CraftWorld implements World {
return false;
}
- net.minecraft.server.Chunk chunk = world.chunkProviderServer.getOrCreateChunk(x, z);
+ net.minecraft.server.Chunk chunk = world.getChunkProviderServer().getChunkAt(x, z);
if (chunk.mustSave) { // If chunk had previously been queued to save, must do save to avoid loss of that data
save = true;
}
chunk.removeEntities(); // Always remove entities - even if discarding, need to get them out of world table
- if (save && !(chunk instanceof EmptyChunk)) {
- world.chunkProviderServer.saveChunk(chunk);
- world.chunkProviderServer.saveChunkNOP(chunk);
+ if (save) {
+ world.getChunkProviderServer().saveChunk(chunk);
+ world.getChunkProviderServer().saveChunkNOP(chunk);
}
- world.chunkProviderServer.unloadQueue.remove(x, z);
- world.chunkProviderServer.chunks.remove(LongHash.toLong(x, z));
+ world.getChunkProviderServer().unloadQueue.remove(x, z);
+ world.getChunkProviderServer().chunks.remove(LongHash.toLong(x, z));
return true;
}
@@ -202,15 +201,11 @@ public class CraftWorld implements World {
public boolean regenerateChunk(int x, int z) {
unloadChunk(x, z, false, false);
- world.chunkProviderServer.unloadQueue.remove(x, z);
+ world.getChunkProviderServer().unloadQueue.remove(x, z);
net.minecraft.server.Chunk chunk = null;
- if (world.chunkProviderServer.chunkProvider == null) {
- chunk = world.chunkProviderServer.emptyChunk;
- } else {
- chunk = world.chunkProviderServer.chunkProvider.getOrCreateChunk(x, z);
- }
+ chunk = world.getChunkProviderServer().chunkGenerator.getOrCreateChunk(x, z);
chunkLoadPostProcess(chunk, x, z);
@@ -232,9 +227,9 @@ public class CraftWorld implements World {
// This flags 65 blocks distributed across all the sections of the chunk, so that everything is sent, including biomes
int height = getMaxHeight() / 16;
for (int idx = 0; idx < 64; idx++) {
- world.notify(new BlockPosition(px + (idx / height), ((idx % height) * 16), pz));
+ world.notify(new BlockPosition(px + (idx / height), ((idx % height) * 16), pz), Blocks.AIR.getBlockData(), Blocks.STONE.getBlockData(), 3);
}
- world.notify(new BlockPosition(px + 15, (height * 16) - 1, pz + 15));
+ world.notify(new BlockPosition(px + 15, (height * 16) - 1, pz + 15), Blocks.AIR.getBlockData(), Blocks.STONE.getBlockData(), 3);
return true;
}
@@ -247,23 +242,21 @@ public class CraftWorld implements World {
chunkLoadCount++;
if (generate) {
// Use the default variant of loadChunk when generate == true.
- return world.chunkProviderServer.getChunkAt(x, z) != null;
+ return world.getChunkProviderServer().getChunkAt(x, z) != null;
}
- world.chunkProviderServer.unloadQueue.remove(x, z);
- net.minecraft.server.Chunk chunk = world.chunkProviderServer.chunks.get(LongHash.toLong(x, z));
+ world.getChunkProviderServer().unloadQueue.remove(x, z);
+ net.minecraft.server.Chunk chunk = world.getChunkProviderServer().chunks.get(LongHash.toLong(x, z));
if (chunk == null) {
- chunk = world.chunkProviderServer.loadChunk(x, z);
-
- chunkLoadPostProcess(chunk, x, z);
+ chunk = world.getChunkProviderServer().getOrLoadChunkAt(x, z);
}
return chunk != null;
}
private void chunkLoadPostProcess(net.minecraft.server.Chunk chunk, int cx, int cz) {
if (chunk != null) {
- world.chunkProviderServer.chunks.put(LongHash.toLong(cx, cz), chunk);
+ world.getChunkProviderServer().chunks.put(LongHash.toLong(cx, cz), chunk);
chunk.addEntities();
@@ -274,7 +267,7 @@ public class CraftWorld implements World {
continue;
}
- net.minecraft.server.Chunk neighbor = world.chunkProviderServer.getChunkIfLoaded(chunk.locX + x, chunk.locZ + z);
+ net.minecraft.server.Chunk neighbor = world.getChunkProviderServer().getChunkIfLoaded(chunk.locX + x, chunk.locZ + z);
if (neighbor != null) {
neighbor.setNeighborLoaded(-x, -z);
chunk.setNeighborLoaded(x, z);
@@ -283,7 +276,7 @@ public class CraftWorld implements World {
}
// CraftBukkit end
- chunk.loadNearby(world.chunkProviderServer, world.chunkProviderServer, cx, cz);
+ chunk.loadNearby(world.getChunkProviderServer(), world.getChunkProviderServer().chunkGenerator);
}
}
@@ -351,30 +344,19 @@ public class CraftWorld implements World {
Validate.notNull(loc, "Can not spawn arrow with a null location");
Validate.notNull(velocity, "Can not spawn arrow with a null velocity");
- EntityArrow arrow = new EntityArrow(world);
+ EntityArrow arrow = new EntityTippedArrow(world);
arrow.setPositionRotation(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch());
arrow.shoot(velocity.getX(), velocity.getY(), velocity.getZ(), speed, spread);
world.addEntity(arrow);
return (Arrow) arrow.getBukkitEntity();
}
- @Deprecated
- public LivingEntity spawnCreature(Location loc, CreatureType creatureType) {
- return spawnCreature(loc, creatureType.toEntityType());
- }
-
- @Deprecated
- public LivingEntity spawnCreature(Location loc, EntityType creatureType) {
- Validate.isTrue(creatureType.isAlive(), "EntityType not instance of LivingEntity");
- return (LivingEntity) spawnEntity(loc, creatureType);
- }
-
public Entity spawnEntity(Location loc, EntityType entityType) {
return spawn(loc, entityType.getEntityClass());
}
public LightningStrike strikeLightning(Location loc) {
- EntityLightning lightning = new EntityLightning(world, loc.getX(), loc.getY(), loc.getZ());
+ EntityLightning lightning = new EntityLightning(world, loc.getX(), loc.getY(), loc.getZ(), false);
world.strikeLightning(lightning);
return new CraftLightningStrike(server, lightning);
}
@@ -462,12 +444,12 @@ public class CraftWorld implements World {
int y = blockstate.getY();
int z = blockstate.getZ();
BlockPosition position = new BlockPosition(x, y, z);
- net.minecraft.server.Block oldBlock = world.getType(position).getBlock();
+ net.minecraft.server.IBlockData oldBlock = world.getType(position);
int typeId = blockstate.getTypeId();
int data = blockstate.getRawData();
int flag = ((CraftBlockState)blockstate).getFlag();
delegate.setTypeIdAndData(x, y, z, typeId, data);
- net.minecraft.server.Block newBlock = world.getType(position).getBlock();
+ net.minecraft.server.IBlockData newBlock = world.getType(position);
world.notifyAndUpdatePhysics(position, null, oldBlock, newBlock, flag);
}
world.capturedBlockStates.clear();
@@ -555,7 +537,17 @@ public class CraftWorld implements World {
public void setEnvironment(Environment env) {
if (environment != env) {
environment = env;
- world.worldProvider = WorldProvider.byDimension(environment.getId());
+ switch (env) {
+ case NORMAL:
+ world.worldProvider = new WorldProviderNormal();
+ break;
+ case NETHER:
+ world.worldProvider = new WorldProviderHell();
+ break;
+ case THE_END:
+ world.worldProvider = new WorldProviderTheEnd();
+ break;
+ }
}
}
@@ -602,17 +594,17 @@ public class CraftWorld implements World {
if (chunk != null) {
byte[] biomevals = chunk.getBiomeIndex();
- biomevals[((z & 0xF) << 4) | (x & 0xF)] = (byte)bb.id;
+ biomevals[((z & 0xF) << 4) | (x & 0xF)] = (byte) BiomeBase.REGISTRY_ID.a(bb);
}
}
}
public double getTemperature(int x, int z) {
- return this.world.getBiome(new BlockPosition(x, 0, z)).temperature;
+ return this.world.getBiome(new BlockPosition(x, 0, z)).getTemperature();
}
public double getHumidity(int x, int z) {
- return this.world.getBiome(new BlockPosition(x, 0, z)).humidity;
+ return this.world.getBiome(new BlockPosition(x, 0, z)).getHumidity();
}
public List<Entity> getEntities() {
@@ -911,7 +903,7 @@ public class CraftWorld implements World {
} else if (Egg.class.isAssignableFrom(clazz)) {
entity = new EntityEgg(world, x, y, z);
} else if (Arrow.class.isAssignableFrom(clazz)) {
- entity = new EntityArrow(world);
+ entity = new EntityTippedArrow(world);
entity.setPositionRotation(x, y, z, 0, 0);
} else if (ThrownExpBottle.class.isAssignableFrom(clazz)) {
entity = new EntityThrownExpBottle(world);
@@ -926,12 +918,17 @@ public class CraftWorld implements World {
entity = new EntitySmallFireball(world);
} else if (WitherSkull.class.isAssignableFrom(clazz)) {
entity = new EntityWitherSkull(world);
- } else {
+ } else if (DragonFireball.class.isAssignableFrom(clazz)){
+ entity = new EntityDragonFireball(world);
+ }else{
entity = new EntityLargeFireball(world);
}
entity.setPositionRotation(x, y, z, yaw, pitch);
Vector direction = location.getDirection().multiply(10);
((EntityFireball) entity).setDirection(direction.getX(), direction.getY(), direction.getZ());
+ } else if (ShulkerBullet.class.isAssignableFrom(clazz)) {
+ entity = new EntityShulkerBullet(world);
+ entity.setPositionRotation(x, y, z, yaw, pitch);
}
} else if (Minecart.class.isAssignableFrom(clazz)) {
if (PoweredMinecart.class.isAssignableFrom(clazz)) {
@@ -966,6 +963,8 @@ public class CraftWorld implements World {
entity = new EntitySnowman(world);
} else if (IronGolem.class.isAssignableFrom(clazz)) {
entity = new EntityIronGolem(world);
+ } else if (Shulker.class.isAssignableFrom(clazz)) {
+ entity = new EntityShulker(world);
}
} else if (Creeper.class.isAssignableFrom(clazz)) {
entity = new EntityCreeper(world);
@@ -1059,9 +1058,9 @@ public class CraftWorld implements World {
final BlockPosition pos = new BlockPosition((int) x, (int) y, (int) z);
for (BlockFace dir : faces) {
net.minecraft.server.Block nmsBlock = CraftMagicNumbers.getBlock(block.getRelative(dir));
- if (nmsBlock.getMaterial().isBuildable() || BlockDiodeAbstract.d(nmsBlock)) {
+ if (nmsBlock.getBlockData().getMaterial().isBuildable() || BlockDiodeAbstract.isDiode(nmsBlock.getBlockData())) {
boolean taken = false;
- AxisAlignedBB bb = EntityHanging.calculateBoundingBox(pos,CraftBlock.blockFaceToNotch(dir).opposite(),width,height);
+ AxisAlignedBB bb = EntityHanging.calculateBoundingBox(null, pos,CraftBlock.blockFaceToNotch(dir).opposite(),width,height);
List<net.minecraft.server.Entity> list = (List<net.minecraft.server.Entity>) world.getEntities(null, bb);
for (Iterator<net.minecraft.server.Entity> it = list.iterator(); !taken && it.hasNext();) {
net.minecraft.server.Entity e = it.next();
@@ -1098,11 +1097,13 @@ public class CraftWorld implements World {
} else if (Weather.class.isAssignableFrom(clazz)) {
// not sure what this can do
if (LightningStrike.class.isAssignableFrom(clazz)) {
- entity = new EntityLightning(world, x, y, z);
+ entity = new EntityLightning(world, x, y, z, false);
// what is this, I don't even
}
} else if (Firework.class.isAssignableFrom(clazz)) {
entity = new EntityFireworks(world, x, y, z, null);
+ } else if (AreaEffectCloud.class.isAssignableFrom(clazz)) {
+ entity = new EntityAreaEffectCloud(world, x, y, z);
}
if (entity != null) {
@@ -1117,7 +1118,7 @@ public class CraftWorld implements World {
Preconditions.checkArgument(entity != null, "Cannot spawn null entity");
if (entity instanceof EntityInsentient) {
- ((EntityInsentient) entity).prepare(getHandle().E(new BlockPosition(entity)), (GroupDataEntity) null);
+ ((EntityInsentient) entity).prepare(getHandle().D(new BlockPosition(entity)), (GroupDataEntity) null);
}
world.addEntity(entity, reason);
@@ -1171,11 +1172,7 @@ public class CraftWorld implements World {
loadChunk(chunkCoordX + x, chunkCoordZ + z);
} else {
if (isChunkLoaded(chunkCoordX + x, chunkCoordZ + z)) {
- if (this.getHandle().getChunkAt(chunkCoordX + x, chunkCoordZ + z) instanceof EmptyChunk) {
- unloadChunk(chunkCoordX + x, chunkCoordZ + z, false);
- } else {
- unloadChunk(chunkCoordX + x, chunkCoordZ + z);
- }
+ unloadChunk(chunkCoordX + x, chunkCoordZ + z);
}
}
}
@@ -1319,7 +1316,7 @@ public class CraftWorld implements World {
double y = loc.getY();
double z = loc.getZ();
- getHandle().makeSound(x, y, z, CraftSound.getSound(sound), volume, pitch);
+ getHandle().a(null, x, y, z, CraftSound.getSoundEffect(CraftSound.getSound(sound)), SoundCategory.MASTER, volume, pitch); // PAIL: rename
}
public String getGameRuleValue(String rule) {
@@ -1353,6 +1350,80 @@ public class CraftWorld implements World {
return this.worldBorder;
}
+ @Override
+ public void spawnParticle(Particle particle, Location location, int count) {
+ spawnParticle(particle, location.getX(), location.getY(), location.getZ(), count);
+ }
+
+ @Override
+ public void spawnParticle(Particle particle, double x, double y, double z, int count) {
+ spawnParticle(particle, x, y, z, count, null);
+ }
+
+ @Override
+ public <T> void spawnParticle(Particle particle, Location location, int count, T data) {
+ spawnParticle(particle, location.getX(), location.getY(), location.getZ(), count, data);
+ }
+
+ @Override
+ public <T> void spawnParticle(Particle particle, double x, double y, double z, int count, T data) {
+ spawnParticle(particle, x, y, z, count, 0, 0, 0);
+ }
+
+ @Override
+ public void spawnParticle(Particle particle, Location location, int count, double offsetX, double offsetY, double offsetZ) {
+ spawnParticle(particle, location.getX(), location.getY(), location.getZ(), count, offsetX, offsetY, offsetZ);
+ }
+
+ @Override
+ public void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ) {
+ spawnParticle(particle, x, y, z, count, offsetX, offsetY, offsetZ, null);
+ }
+
+ @Override
+ public <T> void spawnParticle(Particle particle, Location location, int count, double offsetX, double offsetY, double offsetZ, T data) {
+ spawnParticle(particle, location.getX(), location.getY(), location.getZ(), count, offsetX, offsetY, offsetZ, data);
+ }
+
+ @Override
+ public <T> void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, T data) {
+ spawnParticle(particle, x, y, z, count, offsetX, offsetY, offsetZ, 1, data);
+ }
+
+ @Override
+ public void spawnParticle(Particle particle, Location location, int count, double offsetX, double offsetY, double offsetZ, double extra) {
+ spawnParticle(particle, location.getX(), location.getY(), location.getZ(), count, offsetX, offsetY, offsetZ, extra);
+ }
+
+ @Override
+ public void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra) {
+ spawnParticle(particle, x, y, z, count, offsetX, offsetY, offsetZ, extra, null);
+ }
+
+ @Override
+ public <T> void spawnParticle(Particle particle, Location location, int count, double offsetX, double offsetY, double offsetZ, double extra, T data) {
+ spawnParticle(particle, location.getX(), location.getY(), location.getZ(), count, offsetX, offsetY, offsetZ, extra, data);
+ }
+
+ @Override
+ public <T> void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra, T data) {
+ if (data != null && !particle.getDataType().isInstance(data)) {
+ throw new IllegalArgumentException("data should be " + particle.getDataType() + " got " + data.getClass());
+ }
+ getHandle().sendParticles(
+ null, // Sender
+ CraftParticle.toNMS(particle), // Particle
+ true, // Extended range
+ x, y, z, // Position
+ count, // Count
+ offsetX, offsetY, offsetZ, // Random offset
+ extra, // Speed?
+ CraftParticle.toData(particle, data)
+
+ );
+
+ }
+
public void processChunkGC() {
chunkGCTickCount++;
@@ -1364,7 +1435,7 @@ public class CraftWorld implements World {
return;
}
- ChunkProviderServer cps = world.chunkProviderServer;
+ ChunkProviderServer cps = world.getChunkProviderServer();
for (net.minecraft.server.Chunk chunk : cps.chunks.values()) {
// If in use, skip it
if (isChunkInUse(chunk.locX, chunk.locZ)) {
diff --git a/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeInstance.java b/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeInstance.java
new file mode 100644
index 00000000..1ed4aa94
--- /dev/null
+++ b/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeInstance.java
@@ -0,0 +1,70 @@
+package org.bukkit.craftbukkit.attribute;
+
+import com.google.common.base.Preconditions;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import org.bukkit.attribute.Attribute;
+import org.bukkit.attribute.AttributeInstance;
+import org.bukkit.attribute.AttributeModifier;
+
+public class CraftAttributeInstance implements AttributeInstance {
+
+ private final net.minecraft.server.AttributeInstance handle;
+ private final Attribute attribute;
+
+ public CraftAttributeInstance(net.minecraft.server.AttributeInstance handle, Attribute attribute) {
+ this.handle = handle;
+ this.attribute = attribute;
+ }
+
+ @Override
+ public Attribute getAttribute() {
+ return attribute;
+ }
+
+ @Override
+ public double getBaseValue() {
+ return handle.b();
+ }
+
+ @Override
+ public void setBaseValue(double d) {
+ handle.setValue(d);
+ }
+
+ @Override
+ public Collection<AttributeModifier> getModifiers() {
+ List<AttributeModifier> result = new ArrayList<AttributeModifier>();
+ for (net.minecraft.server.AttributeModifier nms : handle.c()) {
+ result.add(convert(nms));
+ }
+
+ return result;
+ }
+
+ @Override
+ public void addModifier(AttributeModifier modifier) {
+ Preconditions.checkArgument(modifier != null, "modifier");
+ handle.b(convert(modifier));
+ }
+
+ @Override
+ public void removeModifier(AttributeModifier modifier) {
+ Preconditions.checkArgument(modifier != null, "modifier");
+ handle.c(convert(modifier));
+ }
+
+ @Override
+ public double getValue() {
+ return handle.getValue();
+ }
+
+ private static net.minecraft.server.AttributeModifier convert(AttributeModifier bukkit) {
+ return new net.minecraft.server.AttributeModifier(bukkit.getUniqueId(), bukkit.getName(), bukkit.getAmount(), bukkit.getOperation().ordinal());
+ }
+
+ private static AttributeModifier convert(net.minecraft.server.AttributeModifier nms) {
+ return new AttributeModifier(nms.a(), nms.b(), nms.d(), AttributeModifier.Operation.values()[nms.c()]);
+ }
+}
diff --git a/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeMap.java b/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeMap.java
new file mode 100644
index 00000000..0412470b
--- /dev/null
+++ b/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeMap.java
@@ -0,0 +1,37 @@
+package org.bukkit.craftbukkit.attribute;
+
+import com.google.common.base.Preconditions;
+import net.minecraft.server.AttributeMapBase;
+import org.bukkit.attribute.Attributable;
+import org.bukkit.attribute.Attribute;
+import org.bukkit.attribute.AttributeInstance;
+
+public class CraftAttributeMap implements Attributable {
+
+ private final AttributeMapBase handle;
+
+ public CraftAttributeMap(AttributeMapBase handle) {
+ this.handle = handle;
+ }
+
+ @Override
+ public AttributeInstance getAttribute(Attribute attribute) {
+ Preconditions.checkArgument(attribute != null, "attribute");
+ net.minecraft.server.AttributeInstance nms = handle.a(toMinecraft(attribute.name()));
+
+ return (nms == null) ? null : new CraftAttributeInstance(nms, attribute);
+ }
+
+ static String toMinecraft(String bukkit) {
+ int first = bukkit.indexOf('_');
+ int second = bukkit.indexOf('_', first + 1);
+
+ StringBuilder sb = new StringBuilder(bukkit.toLowerCase());
+
+ sb.setCharAt(first, '.');
+ sb.deleteCharAt(second);
+ sb.setCharAt(second, bukkit.charAt(second + 1));
+
+ return sb.toString();
+ }
+}
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
index 22a80551..dc258975 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
@@ -29,8 +29,6 @@ public class CraftBlock implements Block {
private final int x;
private final int y;
private final int z;
- private static final Biome BIOME_MAPPING[];
- private static final BiomeBase BIOMEBASE_MAPPING[];
public CraftBlock(CraftChunk chunk, int x, int y, int z) {
this.x = x;
@@ -107,6 +105,10 @@ public class CraftBlock implements Block {
world.setTypeAndData(position, blockData.getBlock().fromLegacyData(data), flag);
}
+ private IBlockData getData0() {
+ return chunk.getHandle().getBlockData(new BlockPosition(x, y, z));
+ }
+
public byte getData() {
IBlockData blockData = chunk.getHandle().getBlockData(new BlockPosition(x, y, z));
return (byte) blockData.getBlock().toLegacyData(blockData);
@@ -136,9 +138,15 @@ public class CraftBlock implements Block {
if (applyPhysics) {
return chunk.getHandle().getWorld().setTypeAndData(position, blockData, 3);
} else {
+ IBlockData old = chunk.getHandle().getBlockData(position);
boolean success = chunk.getHandle().getWorld().setTypeAndData(position, blockData, 2);
if (success) {
- chunk.getHandle().getWorld().notify(position);
+ chunk.getHandle().getWorld().notify(
+ position,
+ old,
+ blockData,
+ 3
+ );
}
return success;
}
@@ -151,7 +159,7 @@ public class CraftBlock implements Block {
@Deprecated
@Override
public int getTypeId() {
- return CraftMagicNumbers.getId(chunk.getHandle().getType(new BlockPosition(this.x, this.y, this.z)));
+ return CraftMagicNumbers.getId(chunk.getHandle().getBlockData(new BlockPosition(this.x, this.y, this.z)).getBlock());
}
public byte getLightLevel() {
@@ -302,14 +310,15 @@ public class CraftBlock implements Block {
return null;
}
- return BIOME_MAPPING[base.id];
+ return Biome.valueOf(BiomeBase.REGISTRY_ID.b(base).a().toUpperCase());
}
public static BiomeBase biomeToBiomeBase(Biome bio) {
if (bio == null) {
return null;
}
- return BIOMEBASE_MAPPING[bio.ordinal()];
+
+ return BiomeBase.REGISTRY_ID.get(new MinecraftKey(bio.name().toLowerCase()));
}
public double getTemperature() {
@@ -383,13 +392,13 @@ public class CraftBlock implements Block {
}
public PistonMoveReaction getPistonMoveReaction() {
- return PistonMoveReaction.getById(getNMSBlock().getMaterial().getPushReaction());
+ return PistonMoveReaction.getById(getNMSBlock().getBlockData().getMaterial().getPushReaction().ordinal());
}
private boolean itemCausesDrops(ItemStack item) {
net.minecraft.server.Block block = this.getNMSBlock();
net.minecraft.server.Item itemType = item != null ? net.minecraft.server.Item.getById(item.getTypeId()) : null;
- return block != null && (block.getMaterial().isAlwaysDestroyable() || (itemType != null && itemType.canDestroySpecialBlock(block)));
+ return block != null && (block.getBlockData().getMaterial().isAlwaysDestroyable() || (itemType != null && itemType.canDestroySpecialBlock(block.getBlockData())));
}
public boolean breakNaturally() {
@@ -420,15 +429,15 @@ public class CraftBlock implements Block {
net.minecraft.server.Block block = this.getNMSBlock();
if (block != Blocks.AIR) {
- byte data = getData();
+ IBlockData data = getData0();
// based on nms.Block.dropNaturally
int count = block.getDropCount(0, chunk.getHandle().getWorld().random);
for (int i = 0; i < count; ++i) {
- Item item = block.getDropType(block.fromLegacyData(data), chunk.getHandle().getWorld().random, 0);
+ Item item = block.getDropType(data, chunk.getHandle().getWorld().random, 0);
if (item != null) {
// Skulls are special, their data is based on the tile entity
if (Blocks.SKULL == block) {
- net.minecraft.server.ItemStack nmsStack = new net.minecraft.server.ItemStack(item, 1, block.getDropData(chunk.getHandle().getWorld(), new BlockPosition(x, y, z)));
+ net.minecraft.server.ItemStack nmsStack = new net.minecraft.server.ItemStack(item, 1, block.getDropData(data));
TileEntitySkull tileentityskull = (TileEntitySkull) chunk.getHandle().getWorld().getTileEntity(new BlockPosition(x, y, z));
if (tileentityskull.getSkullType() == 3 && tileentityskull.getGameProfile() != null) {
@@ -442,13 +451,13 @@ public class CraftBlock implements Block {
drops.add(CraftItemStack.asBukkitCopy(nmsStack));
// We don't want to drop cocoa blocks, we want to drop cocoa beans.
} else if (Blocks.COCOA == block) {
- int age = (Integer) block.fromLegacyData(data).get(BlockCocoa.AGE);
+ int age = (Integer) data.get(BlockCocoa.AGE);
int dropAmount = (age >= 2 ? 3 : 1);
for (int j = 0; j < dropAmount; ++j) {
drops.add(new ItemStack(Material.INK_SACK, 1, (short) 3));
}
} else {
- drops.add(new ItemStack(org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(item), 1, (short) block.getDropData(block.fromLegacyData(data))));
+ drops.add(new ItemStack(org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(item), 1, (short) block.getDropData(data)));
}
}
}
@@ -464,86 +473,6 @@ public class CraftBlock implements Block {
}
}
- /* Build biome index based lookup table for BiomeBase to Biome mapping */
- static {
- BIOME_MAPPING = new Biome[BiomeBase.getBiomes().length];
- BIOMEBASE_MAPPING = new BiomeBase[Biome.values().length];
- BIOME_MAPPING[BiomeBase.OCEAN.id] = Biome.OCEAN;
- BIOME_MAPPING[BiomeBase.PLAINS.id] = Biome.PLAINS;
- BIOME_MAPPING[BiomeBase.DESERT.id] = Biome.DESERT;
- BIOME_MAPPING[BiomeBase.EXTREME_HILLS.id] = Biome.EXTREME_HILLS;
- BIOME_MAPPING[BiomeBase.FOREST.id] = Biome.FOREST;
- BIOME_MAPPING[BiomeBase.TAIGA.id] = Biome.TAIGA;
- BIOME_MAPPING[BiomeBase.SWAMPLAND.id] = Biome.SWAMPLAND;
- BIOME_MAPPING[BiomeBase.RIVER.id] = Biome.RIVER;
- BIOME_MAPPING[BiomeBase.HELL.id] = Biome.HELL;
- BIOME_MAPPING[BiomeBase.SKY.id] = Biome.SKY;
- BIOME_MAPPING[BiomeBase.FROZEN_OCEAN.id] = Biome.FROZEN_OCEAN;
- BIOME_MAPPING[BiomeBase.FROZEN_RIVER.id] = Biome.FROZEN_RIVER;
- BIOME_MAPPING[BiomeBase.ICE_PLAINS.id] = Biome.ICE_PLAINS;
- BIOME_MAPPING[BiomeBase.ICE_MOUNTAINS.id] = Biome.ICE_MOUNTAINS;
- BIOME_MAPPING[BiomeBase.MUSHROOM_ISLAND.id] = Biome.MUSHROOM_ISLAND;
- BIOME_MAPPING[BiomeBase.MUSHROOM_SHORE.id] = Biome.MUSHROOM_SHORE;
- BIOME_MAPPING[BiomeBase.BEACH.id] = Biome.BEACH;
- BIOME_MAPPING[BiomeBase.DESERT_HILLS.id] = Biome.DESERT_HILLS;
- BIOME_MAPPING[BiomeBase.FOREST_HILLS.id] = Biome.FOREST_HILLS;
- BIOME_MAPPING[BiomeBase.TAIGA_HILLS.id] = Biome.TAIGA_HILLS;
- BIOME_MAPPING[BiomeBase.SMALL_MOUNTAINS.id] = Biome.SMALL_MOUNTAINS;
- BIOME_MAPPING[BiomeBase.JUNGLE.id] = Biome.JUNGLE;
- BIOME_MAPPING[BiomeBase.JUNGLE_HILLS.id] = Biome.JUNGLE_HILLS;
- BIOME_MAPPING[BiomeBase.JUNGLE_EDGE.id] = Biome.JUNGLE_EDGE;
- BIOME_MAPPING[BiomeBase.DEEP_OCEAN.id] = Biome.DEEP_OCEAN;
- BIOME_MAPPING[BiomeBase.STONE_BEACH.id] = Biome.STONE_BEACH;
- BIOME_MAPPING[BiomeBase.COLD_BEACH.id] = Biome.COLD_BEACH;
- BIOME_MAPPING[BiomeBase.BIRCH_FOREST.id] = Biome.BIRCH_FOREST;
- BIOME_MAPPING[BiomeBase.BIRCH_FOREST_HILLS.id] = Biome.BIRCH_FOREST_HILLS;
- BIOME_MAPPING[BiomeBase.ROOFED_FOREST.id] = Biome.ROOFED_FOREST;
- BIOME_MAPPING[BiomeBase.COLD_TAIGA.id] = Biome.COLD_TAIGA;
- BIOME_MAPPING[BiomeBase.COLD_TAIGA_HILLS.id] = Biome.COLD_TAIGA_HILLS;
- BIOME_MAPPING[BiomeBase.MEGA_TAIGA.id] = Biome.MEGA_TAIGA;
- BIOME_MAPPING[BiomeBase.MEGA_TAIGA_HILLS.id] = Biome.MEGA_TAIGA_HILLS;
- BIOME_MAPPING[BiomeBase.EXTREME_HILLS_PLUS.id] = Biome.EXTREME_HILLS_PLUS;
- BIOME_MAPPING[BiomeBase.SAVANNA.id] = Biome.SAVANNA;
- BIOME_MAPPING[BiomeBase.SAVANNA_PLATEAU.id] = Biome.SAVANNA_PLATEAU;
- BIOME_MAPPING[BiomeBase.MESA.id] = Biome.MESA;
- BIOME_MAPPING[BiomeBase.MESA_PLATEAU_F.id] = Biome.MESA_PLATEAU_FOREST;
- BIOME_MAPPING[BiomeBase.MESA_PLATEAU.id] = Biome.MESA_PLATEAU;
-
- // Extended Biomes
- BIOME_MAPPING[BiomeBase.PLAINS.id + 128] = Biome.SUNFLOWER_PLAINS;
- BIOME_MAPPING[BiomeBase.DESERT.id + 128] = Biome.DESERT_MOUNTAINS;
- BIOME_MAPPING[BiomeBase.FOREST.id + 128] = Biome.FLOWER_FOREST;
- BIOME_MAPPING[BiomeBase.TAIGA.id + 128] = Biome.TAIGA_MOUNTAINS;
- BIOME_MAPPING[BiomeBase.SWAMPLAND.id + 128] = Biome.SWAMPLAND_MOUNTAINS;
- BIOME_MAPPING[BiomeBase.ICE_PLAINS.id + 128] = Biome.ICE_PLAINS_SPIKES;
- BIOME_MAPPING[BiomeBase.JUNGLE.id + 128] = Biome.JUNGLE_MOUNTAINS;
- BIOME_MAPPING[BiomeBase.JUNGLE_EDGE.id + 128] = Biome.JUNGLE_EDGE_MOUNTAINS;
- BIOME_MAPPING[BiomeBase.COLD_TAIGA.id + 128] = Biome.COLD_TAIGA_MOUNTAINS;
- BIOME_MAPPING[BiomeBase.SAVANNA.id + 128] = Biome.SAVANNA_MOUNTAINS;
- BIOME_MAPPING[BiomeBase.SAVANNA_PLATEAU.id + 128] = Biome.SAVANNA_PLATEAU_MOUNTAINS;
- BIOME_MAPPING[BiomeBase.MESA.id + 128] = Biome.MESA_BRYCE;
- BIOME_MAPPING[BiomeBase.MESA_PLATEAU_F.id + 128] = Biome.MESA_PLATEAU_FOREST_MOUNTAINS;
- BIOME_MAPPING[BiomeBase.MESA_PLATEAU.id + 128] = Biome.MESA_PLATEAU_MOUNTAINS;
- BIOME_MAPPING[BiomeBase.BIRCH_FOREST.id + 128] = Biome.BIRCH_FOREST_MOUNTAINS;
- BIOME_MAPPING[BiomeBase.BIRCH_FOREST_HILLS.id + 128] = Biome.BIRCH_FOREST_HILLS_MOUNTAINS;
- BIOME_MAPPING[BiomeBase.ROOFED_FOREST.id + 128] = Biome.ROOFED_FOREST_MOUNTAINS;
- BIOME_MAPPING[BiomeBase.MEGA_TAIGA.id + 128] = Biome.MEGA_SPRUCE_TAIGA;
- BIOME_MAPPING[BiomeBase.EXTREME_HILLS.id + 128] = Biome.EXTREME_HILLS_MOUNTAINS;
- BIOME_MAPPING[BiomeBase.EXTREME_HILLS_PLUS.id + 128] = Biome.EXTREME_HILLS_PLUS_MOUNTAINS;
- BIOME_MAPPING[BiomeBase.MEGA_TAIGA_HILLS.id + 128] = Biome.MEGA_SPRUCE_TAIGA_HILLS;
-
- /* Sanity check - we should have a record for each record in the BiomeBase.a table */
- /* Helps avoid missed biomes when we upgrade bukkit to new code with new biomes */
- for (int i = 0; i < BIOME_MAPPING.length; i++) {
- if ((BiomeBase.getBiome(i) != null) && (BIOME_MAPPING[i] == null)) {
- throw new IllegalArgumentException("Missing Biome mapping for BiomeBase[" + i + ", " + BiomeBase.getBiome(i) + "]");
- }
- if (BIOME_MAPPING[i] != null) { /* Build reverse mapping for setBiome */
- BIOMEBASE_MAPPING[BIOME_MAPPING[i].ordinal()] = BiomeBase.getBiome(i);
- }
- }
- }
-
public void setMetadata(String metadataKey, MetadataValue newMetadataValue) {
chunk.getCraftWorld().getBlockMetadata().setMetadata(this, metadataKey, newMetadataValue);
}
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java
index 4a8c8141..7da6218b 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java
@@ -9,6 +9,7 @@ import org.bukkit.World;
import org.bukkit.block.BlockState;
import org.bukkit.craftbukkit.CraftChunk;
import org.bukkit.craftbukkit.CraftWorld;
+import org.bukkit.craftbukkit.util.CraftMagicNumbers;
import org.bukkit.material.MaterialData;
import org.bukkit.metadata.MetadataValue;
import org.bukkit.plugin.Plugin;
@@ -159,7 +160,12 @@ public class CraftBlockState implements BlockState {
}
block.setTypeIdAndData(getTypeId(), getRawData(), applyPhysics);
- world.getHandle().notify(new BlockPosition(x, y, z));
+ world.getHandle().notify(
+ new BlockPosition(x, y, z),
+ CraftMagicNumbers.getBlock(block).fromLegacyData(block.getData()),
+ CraftMagicNumbers.getBlock(getType()).fromLegacyData(getRawData()),
+ 3
+ );
return true;
}
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBrewingStand.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBrewingStand.java
index a910da2b..b3f9c64e 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBrewingStand.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBrewingStand.java
@@ -38,15 +38,25 @@ public class CraftBrewingStand extends CraftBlockState implements BrewingStand {
}
public int getBrewingTime() {
- return brewingStand.brewTime;
+ return brewingStand.getProperty(0);
}
public void setBrewingTime(int brewTime) {
- brewingStand.brewTime = brewTime;
+ brewingStand.setProperty(0, brewTime);
}
@Override
public TileEntityBrewingStand getTileEntity() {
return brewingStand;
}
+
+ @Override
+ public int getFuelLevel() {
+ return brewingStand.getProperty(1);
+ }
+
+ @Override
+ public void setFuelLevel(int level) {
+ brewingStand.setProperty(1, level);
+ }
}
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java b/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java
index 697cd91c..2472dc66 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java
@@ -6,7 +6,6 @@ import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.CreatureSpawner;
import org.bukkit.craftbukkit.CraftWorld;
-import org.bukkit.entity.CreatureType;
import org.bukkit.entity.EntityType;
public class CraftCreatureSpawner extends CraftBlockState implements CreatureSpawner {
@@ -23,20 +22,10 @@ public class CraftCreatureSpawner extends CraftBlockState implements CreatureSpa
spawner = te;
}
- @Deprecated
- public CreatureType getCreatureType() {
- return CreatureType.fromName(spawner.getSpawner().getMobName());
- }
-
public EntityType getSpawnedType() {
return EntityType.fromName(spawner.getSpawner().getMobName());
}
- @Deprecated
- public void setCreatureType(CreatureType creatureType) {
- spawner.getSpawner().setMobName(creatureType.getName());
- }
-
public void setSpawnedType(EntityType entityType) {
if (entityType == null || entityType.getName() == null) {
throw new IllegalArgumentException("Can't spawn EntityType " + entityType + " from mobspawners!");
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftFurnace.java b/src/main/java/org/bukkit/craftbukkit/block/CraftFurnace.java
index e58aabca..f17fb6f7 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftFurnace.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftFurnace.java
@@ -38,19 +38,19 @@ public class CraftFurnace extends CraftBlockState implements Furnace {
}
public short getBurnTime() {
- return (short) furnace.burnTime;
+ return (short) furnace.getProperty(0);
}
public void setBurnTime(short burnTime) {
- furnace.burnTime = burnTime;
+ furnace.setProperty(0, burnTime);
}
public short getCookTime() {
- return (short) furnace.cookTime;
+ return (short) furnace.getProperty(2);
}
public void setCookTime(short cookTime) {
- furnace.cookTime = cookTime;
+ furnace.setProperty(2, cookTime);
}
@Override
diff --git a/src/main/java/org/bukkit/craftbukkit/boss/CraftBossBar.java b/src/main/java/org/bukkit/craftbukkit/boss/CraftBossBar.java
new file mode 100644
index 00000000..2f63796a
--- /dev/null
+++ b/src/main/java/org/bukkit/craftbukkit/boss/CraftBossBar.java
@@ -0,0 +1,165 @@
+package org.bukkit.craftbukkit.boss;
+
+import com.google.common.collect.ImmutableList;
+import net.minecraft.server.BossBattle;
+import net.minecraft.server.BossBattleServer;
+import net.minecraft.server.EntityPlayer;
+import net.minecraft.server.PacketPlayOutBoss;
+import org.bukkit.boss.BarColor;
+import org.bukkit.boss.BarFlag;
+import org.bukkit.boss.BarStyle;
+import org.bukkit.boss.BossBar;
+import org.bukkit.craftbukkit.entity.CraftPlayer;
+import org.bukkit.craftbukkit.util.CraftChatMessage;
+import org.bukkit.entity.Player;
+
+import java.util.EnumSet;
+import java.util.List;
+import java.util.Set;
+
+public class CraftBossBar implements BossBar {
+
+ private final BossBattleServer handle;
+ private final Set<BarFlag> flags;
+ private BarColor color;
+ private BarStyle style;
+
+ public CraftBossBar(String title, BarColor color, BarStyle style, BarFlag... flags) {
+ this.flags = flags.length > 0 ? EnumSet.of(flags[0], flags) : EnumSet.noneOf(BarFlag.class);
+ this.color = color;
+ this.style = style;
+
+ handle = new BossBattleServer(
+ CraftChatMessage.fromString(title, true)[0],
+ convertColor(color),
+ convertStyle(style)
+ );
+
+ updateFlags();
+ }
+
+ private BossBattle.BarColor convertColor(BarColor color) {
+ BossBattle.BarColor nmsColor = BossBattle.BarColor.valueOf(color.name());
+ return (nmsColor == null) ? BossBattle.BarColor.WHITE : nmsColor;
+ }
+
+ private BossBattle.BarStyle convertStyle(BarStyle style) {
+ switch (style) {
+ default:
+ case SOLID:
+ return BossBattle.BarStyle.PROGRESS;
+ case SEGMENTED_6:
+ return BossBattle.BarStyle.NOTCHED_6;
+ case SEGMENTED_10:
+ return BossBattle.BarStyle.NOTCHED_10;
+ case SEGMENTED_12:
+ return BossBattle.BarStyle.NOTCHED_12;
+ case SEGMENTED_20:
+ return BossBattle.BarStyle.NOTCHED_20;
+ }
+ }
+
+ private void updateFlags() {
+ handle.a(hasFlag(BarFlag.DARKEN_SKY));
+ handle.b(hasFlag(BarFlag.PLAY_BOSS_MUSIC));
+ handle.c(hasFlag(BarFlag.CREATE_FOG));
+ }
+
+ @Override
+ public String getTitle() {
+ return CraftChatMessage.fromComponent(handle.e());
+ }
+
+ @Override
+ public void setTitle(String title) {
+ handle.title = CraftChatMessage.fromString(title, true)[0];
+ handle.sendUpdate(PacketPlayOutBoss.Action.UPDATE_NAME);
+ }
+
+ @Override
+ public BarColor getColor() {
+ return color;
+ }
+
+ @Override
+ public void setColor(BarColor color) {
+ this.color = color;
+ handle.color = convertColor(color);
+ handle.sendUpdate(PacketPlayOutBoss.Action.UPDATE_STYLE);
+ }
+
+ @Override
+ public BarStyle getStyle() {
+ return style;
+ }
+
+ @Override
+ public void setStyle(BarStyle style) {
+ this.style = style;
+ handle.style = convertStyle(style);
+ handle.sendUpdate(PacketPlayOutBoss.Action.UPDATE_STYLE);
+ }
+
+ @Override
+ public void addFlag(BarFlag flag) {
+ flags.remove(flag);
+ updateFlags();
+ }
+
+ @Override
+ public void removeFlag(BarFlag flag) {
+ flags.add(flag);
+ updateFlags();
+ }
+
+ @Override
+ public boolean hasFlag(BarFlag flag) {
+ return flags.contains(flag);
+ }
+
+ @Override
+ public void setProgress(double progress) {
+ handle.setProgress((float) progress);
+ }
+
+ @Override
+ public double getProgress() {
+ return handle.getProgress();
+ }
+
+ @Override
+ public void addPlayer(Player player) {
+ handle.addPlayer(((CraftPlayer) player).getHandle());
+ }
+
+ @Override
+ public void removePlayer(Player player) {
+ handle.removePlayer(((CraftPlayer) player).getHandle());
+ }
+
+ @Override
+ public List<Player> getPlayers() {
+ ImmutableList.Builder<Player> players = ImmutableList.builder();
+ for (EntityPlayer p : handle.getPlayers()) {
+ players.add(p.getBukkitEntity());
+ }
+ return players.build();
+ }
+
+ @Override
+ public void show() {
+ handle.setVisible(true);
+ }
+
+ @Override
+ public void hide() {
+ handle.setVisible(false);
+ }
+
+ @Override
+ public void removeAll() {
+ for (Player player : getPlayers()) {
+ removePlayer(player);
+ }
+ }
+}
diff --git a/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOProvider.java b/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOProvider.java
index c31f17f7..6dfef44a 100644
--- a/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOProvider.java
+++ b/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOProvider.java
@@ -10,10 +10,6 @@ import org.bukkit.craftbukkit.util.AsynchronousExecutor;
import org.bukkit.craftbukkit.util.LongHash;
import java.util.concurrent.atomic.AtomicInteger;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import net.minecraft.server.Entity;
-import net.minecraft.server.EntitySlice;
class ChunkIOProvider implements AsynchronousExecutor.CallBackProvider<QueuedChunk, Chunk, Runnable, RuntimeException> {
private final AtomicInteger threadNumber = new AtomicInteger(1);
@@ -48,8 +44,8 @@ class ChunkIOProvider implements AsynchronousExecutor.CallBackProvider<QueuedChu
queuedChunk.provider.chunks.put(LongHash.toLong(queuedChunk.x, queuedChunk.z), chunk);
chunk.addEntities();
- if (queuedChunk.provider.chunkProvider != null) {
- queuedChunk.provider.chunkProvider.recreateStructures(chunk, queuedChunk.x, queuedChunk.z);
+ if (queuedChunk.provider.chunkGenerator != null) {
+ queuedChunk.provider.chunkGenerator.recreateStructures(chunk, queuedChunk.x, queuedChunk.z);
}
Server server = queuedChunk.provider.world.getServer();
@@ -72,7 +68,7 @@ class ChunkIOProvider implements AsynchronousExecutor.CallBackProvider<QueuedChu
}
}
- chunk.loadNearby(queuedChunk.provider, queuedChunk.provider, queuedChunk.x, queuedChunk.z);
+ chunk.loadNearby(queuedChunk.provider, queuedChunk.provider.chunkGenerator);
}
public void callStage3(QueuedChunk queuedChunk, Chunk chunk, Runnable runnable) throws RuntimeException {
diff --git a/src/main/java/org/bukkit/craftbukkit/command/CraftBlockCommandSender.java b/src/main/java/org/bukkit/craftbukkit/command/CraftBlockCommandSender.java
index 01f616bb..251ea5e0 100644
--- a/src/main/java/org/bukkit/craftbukkit/command/CraftBlockCommandSender.java
+++ b/src/main/java/org/bukkit/craftbukkit/command/CraftBlockCommandSender.java
@@ -1,7 +1,6 @@
package org.bukkit.craftbukkit.command;
import net.minecraft.server.ICommandListener;
-import net.minecraft.server.CommandBlockListenerAbstract;
import net.minecraft.server.IChatBaseComponent;
import org.bukkit.block.Block;
@@ -12,20 +11,20 @@ import org.bukkit.craftbukkit.util.CraftChatMessage;
* Represents input from a command block
*/
public class CraftBlockCommandSender extends ServerCommandSender implements BlockCommandSender {
- private final CommandBlockListenerAbstract commandBlock;
+ private final ICommandListener block;
- public CraftBlockCommandSender(CommandBlockListenerAbstract commandBlockListenerAbstract) {
+ public CraftBlockCommandSender(ICommandListener commandBlockListenerAbstract) {
super();
- this.commandBlock = commandBlockListenerAbstract;
+ this.block = commandBlockListenerAbstract;
}
public Block getBlock() {
- return commandBlock.getWorld().getWorld().getBlockAt(commandBlock.getChunkCoordinates().getX(), commandBlock.getChunkCoordinates().getY(), commandBlock.getChunkCoordinates().getZ());
+ return block.getWorld().getWorld().getBlockAt(block.getChunkCoordinates().getX(), block.getChunkCoordinates().getY(), block.getChunkCoordinates().getZ());
}
public void sendMessage(String message) {
for (IChatBaseComponent component : CraftChatMessage.fromString(message)) {
- commandBlock.sendMessage(component);
+ block.sendMessage(component);
}
}
@@ -36,7 +35,7 @@ public class CraftBlockCommandSender extends ServerCommandSender implements Bloc
}
public String getName() {
- return commandBlock.getName();
+ return block.getName();
}
public boolean isOp() {
@@ -48,6 +47,6 @@ public class CraftBlockCommandSender extends ServerCommandSender implements Bloc
}
public ICommandListener getTileEntity() {
- return commandBlock;
+ return block;
}
}
diff --git a/src/main/java/org/bukkit/craftbukkit/command/CraftRemoteConsoleCommandSender.java b/src/main/java/org/bukkit/craftbukkit/command/CraftRemoteConsoleCommandSender.java
index 7c5523b0..228e88a6 100644
--- a/src/main/java/org/bukkit/craftbukkit/command/CraftRemoteConsoleCommandSender.java
+++ b/src/main/java/org/bukkit/craftbukkit/command/CraftRemoteConsoleCommandSender.java
@@ -5,13 +5,16 @@ import net.minecraft.server.RemoteControlCommandListener;
import org.bukkit.command.RemoteConsoleCommandSender;
public class CraftRemoteConsoleCommandSender extends ServerCommandSender implements RemoteConsoleCommandSender {
- public CraftRemoteConsoleCommandSender() {
- super();
+
+ private final RemoteControlCommandListener listener;
+
+ public CraftRemoteConsoleCommandSender(RemoteControlCommandListener listener) {
+ this.listener = listener;
}
@Override
public void sendMessage(String message) {
- RemoteControlCommandListener.getInstance().sendMessage(new ChatComponentText(message + "\n")); // Send a newline after each message, to preserve formatting.
+ listener.sendMessage(new ChatComponentText(message + "\n")); // Send a newline after each message, to preserve formatting.
}
@Override
diff --git a/src/main/java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java b/src/main/java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java
index de788d61..100d84ae 100644
--- a/src/main/java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java
+++ b/src/main/java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java
@@ -49,7 +49,7 @@ public final class VanillaCommandWrapper extends VanillaCommand {
Validate.notNull(sender, "Sender cannot be null");
Validate.notNull(args, "Arguments cannot be null");
Validate.notNull(alias, "Alias cannot be null");
- return (List<String>) vanillaCommand.tabComplete(getListener(sender), args, new BlockPosition(0, 0, 0));
+ return (List<String>) vanillaCommand.tabComplete(MinecraftServer.getServer(), getListener(sender), args, new BlockPosition(0, 0, 0));
}
public static CommandSender lastSender = null; // Nasty :(
@@ -75,7 +75,7 @@ public final class VanillaCommandWrapper extends VanillaCommand {
}
try {
- if (vanillaCommand.canUse(icommandlistener)) {
+ if (vanillaCommand.canUse(server, icommandlistener)) {
if (i > -1) {
List<Entity> list = ((List<Entity>)PlayerSelector.getPlayers(icommandlistener, as[i], Entity.class));
String s2 = as[i];
@@ -90,14 +90,14 @@ public final class VanillaCommandWrapper extends VanillaCommand {
lastSender = bSender;
try {
as[i] = entity.getUniqueID().toString();
- vanillaCommand.execute(icommandlistener, as);
+ vanillaCommand.execute(server, icommandlistener, as);
j++;
} catch (ExceptionUsage exceptionusage) {
ChatMessage chatmessage = new ChatMessage("commands.generic.usage", new Object[] { new ChatMessage(exceptionusage.getMessage(), exceptionusage.getArgs())});
chatmessage.getChatModifier().setColor(EnumChatFormat.RED);
icommandlistener.sendMessage(chatmessage);
} catch (CommandException commandexception) {
- CommandAbstract.a(icommandlistener, vanillaCommand, 1, commandexception.getMessage(), commandexception.getArgs());
+ CommandAbstract.a(icommandlistener, vanillaCommand, 0, commandexception.getMessage(), commandexception.getArgs());
} finally {
lastSender = oldSender;
}
@@ -105,7 +105,7 @@ public final class VanillaCommandWrapper extends VanillaCommand {
as[i] = s2;
} else {
icommandlistener.a(CommandObjectiveExecutor.EnumCommandResult.AFFECTED_ENTITIES, 1);
- vanillaCommand.execute(icommandlistener, as);
+ vanillaCommand.execute(server, icommandlistener, as);
j++;
}
} else {
@@ -118,7 +118,7 @@ public final class VanillaCommandWrapper extends VanillaCommand {
chatmessage1.getChatModifier().setColor(EnumChatFormat.RED);
icommandlistener.sendMessage(chatmessage1);
} catch (CommandException commandexception) {
- CommandAbstract.a(icommandlistener, vanillaCommand, 1, commandexception.getMessage(), commandexception.getArgs());
+ CommandAbstract.a(icommandlistener, vanillaCommand, 0, commandexception.getMessage(), commandexception.getArgs());
} catch (Throwable throwable) {
ChatMessage chatmessage3 = new ChatMessage("commands.generic.exception", new Object[0]);
chatmessage3.getChatModifier().setColor(EnumChatFormat.RED);
@@ -149,7 +149,7 @@ public final class VanillaCommandWrapper extends VanillaCommand {
return ((EntityMinecartCommandBlock) ((CraftMinecartCommand) sender).getHandle()).getCommandBlock();
}
if (sender instanceof RemoteConsoleCommandSender) {
- return RemoteControlCommandListener.getInstance();
+ return ((DedicatedServer)MinecraftServer.getServer()).remoteControlCommandListener;
}
if (sender instanceof ConsoleCommandSender) {
return ((CraftServer) sender.getServer()).getServer();
diff --git a/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java b/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java
index 8a559499..24cd4763 100644
--- a/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java
+++ b/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java
@@ -10,7 +10,7 @@ public class CraftEnchantment extends Enchantment {
private final net.minecraft.server.Enchantment target;
public CraftEnchantment(net.minecraft.server.Enchantment target) {
- super(target.id);
+ super(net.minecraft.server.Enchantment.getId(target));
this.target = target;
}
@@ -26,7 +26,7 @@ public class CraftEnchantment extends Enchantment {
@Override
public EnchantmentTarget getItemTarget() {
- switch (target.slot) {
+ switch (target.itemTarget) {
case ALL:
return EnchantmentTarget.ALL;
case ARMOR:
@@ -37,7 +37,7 @@ public class CraftEnchantment extends Enchantment {
return EnchantmentTarget.ARMOR_HEAD;
case ARMOR_LEGS:
return EnchantmentTarget.ARMOR_LEGS;
- case ARMOR_TORSO:
+ case ARMOR_CHEST:
return EnchantmentTarget.ARMOR_TORSO;
case DIGGER:
return EnchantmentTarget.TOOL;
@@ -59,7 +59,7 @@ public class CraftEnchantment extends Enchantment {
@Override
public String getName() {
- switch (target.id) {
+ switch (getId()) {
case 0:
return "PROTECTION_ENVIRONMENTAL";
case 1:
@@ -111,7 +111,7 @@ public class CraftEnchantment extends Enchantment {
case 62:
return "LURE";
default:
- return "UNKNOWN_ENCHANT_" + target.id;
+ return "UNKNOWN_ENCHANT_" + getId();
}
}
@@ -138,4 +138,8 @@ public class CraftEnchantment extends Enchantment {
CraftEnchantment ench = (CraftEnchantment) other;
return !target.a(ench.target);
}
+
+ public net.minecraft.server.Enchantment getHandle() {
+ return target;
+ }
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftAreaEffectCloud.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftAreaEffectCloud.java
new file mode 100644
index 00000000..f32b9e2f
--- /dev/null
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftAreaEffectCloud.java
@@ -0,0 +1,138 @@
+package org.bukkit.craftbukkit.entity;
+
+import java.util.List;
+import net.minecraft.server.EntityAreaEffectCloud;
+import org.bukkit.Color;
+import org.bukkit.Particle;
+import org.bukkit.craftbukkit.CraftParticle;
+import org.bukkit.craftbukkit.CraftServer;
+import org.bukkit.entity.AreaEffectCloud;
+import org.bukkit.entity.EntityType;
+import org.bukkit.potion.PotionEffect;
+
+public class CraftAreaEffectCloud extends CraftEntity implements AreaEffectCloud {
+
+ public CraftAreaEffectCloud(CraftServer server, EntityAreaEffectCloud entity) {
+ super(server, entity);
+ }
+
+ @Override
+ public EntityAreaEffectCloud getHandle() {
+ return (EntityAreaEffectCloud) super.getHandle();
+ }
+
+ @Override
+ public EntityType getType() {
+ return EntityType.AREA_EFFECT_CLOUD;
+ }
+
+ @Override
+ public int getDuration() {
+ return getHandle().getDuration();
+ }
+
+ @Override
+ public void setDuration(int duration) {
+ getHandle().setDuration(duration);
+ }
+
+ @Override
+ public int getWaitTime() {
+ return getHandle().waitTime;
+ }
+
+ @Override
+ public void setWaitTime(int waitTime) {
+ getHandle().setWaitTime(waitTime);
+ }
+
+ @Override
+ public int getReapplicationDelay() {
+ return getHandle().reapplicationDelay;
+ }
+
+ @Override
+ public void setReapplicationDelay(int delay) {
+ getHandle().reapplicationDelay = delay;
+ }
+
+ @Override
+ public int getDurationOnUse() {
+ return getHandle().durationOnUse;
+ }
+
+ @Override
+ public void setDurationOnUse(int duration) {
+ getHandle().durationOnUse = duration;
+ }
+
+ @Override
+ public float getRadius() {
+ return getHandle().getRadius();
+ }
+
+ @Override
+ public void setRadius(float radius) {
+ getHandle().setRadius(radius);
+ }
+
+ @Override
+ public float getRadiusOnUse() {
+ return getHandle().radiusOnUse;
+ }
+
+ @Override
+ public void setRadiusOnUse(float radius) {
+ getHandle().setRadiusOnUse(radius);
+ }
+
+ @Override
+ public float getRadiusPerTick() {
+ return getHandle().radiusPerTick;
+ }
+
+ @Override
+ public void setRadiusPerTick(float radius) {
+ getHandle().setRadiusPerTick(radius);
+ }
+
+ @Override
+ public Particle getParticle() {
+ return CraftParticle.toBukkit(getHandle().getParticle());
+ }
+
+ @Override
+ public void setParticle(Particle particle) {
+ getHandle().setParticle(CraftParticle.toNMS(particle));
+ }
+
+ @Override
+ public List<PotionEffect> getEffects() {
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ }
+
+ @Override
+ public void addEffect(PotionEffect effect) {
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ }
+
+ @Override
+ public void removeEffect(PotionEffect effect) {
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ }
+
+ @Override
+ public void setEffects(List<PotionEffect> effects) {
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ }
+
+ @Override
+ public Color getColor() {
+ return Color.fromRGB(getHandle().getColor());
+ }
+
+ @Override
+ public void setColor(Color color) {
+ getHandle().setColor(color.asRGB());
+ }
+}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java
index 09443fe1..06e2c18b 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java
@@ -157,6 +157,7 @@ public class CraftArmorStand extends CraftLivingEntity implements ArmorStand {
@Override
public void setGravity(boolean gravity) {
getHandle().setGravity(!gravity);
+ getHandle().noclip = !gravity;
}
@Override
@@ -207,13 +208,11 @@ public class CraftArmorStand extends CraftLivingEntity implements ArmorStand {
@Override
public boolean isMarker() {
- // PAIL
- return getHandle().s();
+ return getHandle().isMarker();
}
@Override
public void setMarker(boolean marker) {
- // PAIL
- getHandle().n(marker);
+ getHandle().setMarker(marker);
}
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftDragonFireball.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftDragonFireball.java
new file mode 100644
index 00000000..f1fa649b
--- /dev/null
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftDragonFireball.java
@@ -0,0 +1,17 @@
+package org.bukkit.craftbukkit.entity;
+
+import net.minecraft.server.EntityDragonFireball;
+import org.bukkit.craftbukkit.CraftServer;
+import org.bukkit.entity.DragonFireball;
+import org.bukkit.entity.EntityType;
+
+public class CraftDragonFireball extends CraftFireball implements DragonFireball {
+ public CraftDragonFireball(CraftServer server, EntityDragonFireball entity) {
+ super(server, entity);
+ }
+
+ @Override
+ public EntityType getType() {
+ return EntityType.DRAGON_FIREBALL;
+ }
+}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
index 5693e3a7..22d08a20 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
@@ -1,8 +1,6 @@
package org.bukkit.craftbukkit.entity;
import com.google.common.base.Preconditions;
-import java.util.ArrayList;
-import java.util.Collection;
import java.util.List;
import java.util.Set;
import java.util.UUID;
@@ -39,7 +37,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
}
});
-
+
protected final CraftServer server;
protected Entity entity;
private EntityDamageEvent lastDamageEvent;
@@ -108,6 +106,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
else if (entity instanceof EntityGolem) {
if (entity instanceof EntitySnowman) { return new CraftSnowman(server, (EntitySnowman) entity); }
else if (entity instanceof EntityIronGolem) { return new CraftIronGolem(server, (EntityIronGolem) entity); }
+ else if (entity instanceof EntityShulker) { return new CraftShulker(server, (EntityShulker) entity); }
}
else if (entity instanceof EntityVillager) { return new CraftVillager(server, (EntityVillager) entity); }
else { return new CraftCreature(server, (EntityCreature) entity); }
@@ -153,6 +152,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
if (entity instanceof EntitySmallFireball) { return new CraftSmallFireball(server, (EntitySmallFireball) entity); }
else if (entity instanceof EntityLargeFireball) { return new CraftLargeFireball(server, (EntityLargeFireball) entity); }
else if (entity instanceof EntityWitherSkull) { return new CraftWitherSkull(server, (EntityWitherSkull) entity); }
+ else if (entity instanceof EntityDragonFireball) { return new CraftDragonFireball(server, (EntityDragonFireball) entity); }
else { return new CraftFireball(server, (EntityFireball) entity); }
}
else if (entity instanceof EntityEnderSignal) { return new CraftEnderSignal(server, (EntityEnderSignal) entity); }
@@ -179,6 +179,8 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
}
else if (entity instanceof EntityTNTPrimed) { return new CraftTNTPrimed(server, (EntityTNTPrimed) entity); }
else if (entity instanceof EntityFireworks) { return new CraftFirework(server, (EntityFireworks) entity); }
+ else if (entity instanceof EntityShulkerBullet) { return new CraftShulkerBullet(server, (EntityShulkerBullet) entity); }
+ else if (entity instanceof EntityAreaEffectCloud) { return new CraftAreaEffectCloud(server, (EntityAreaEffectCloud) entity); }
throw new AssertionError("Unknown entity " + (entity == null ? null : entity.getClass()));
}
@@ -227,12 +229,12 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
}
public boolean teleport(Location location, TeleportCause cause) {
- if (entity.passenger != null || entity.dead) {
+ if (entity.isVehicle() || entity.dead) {
return false;
}
// If this entity is riding another entity, we must dismount before teleporting.
- entity.mount(null);
+ entity.stopRiding();
entity.world = ((CraftWorld) location.getWorld()).getHandle();
entity.setLocation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
@@ -299,13 +301,14 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
}
public org.bukkit.entity.Entity getPassenger() {
- return isEmpty() ? null : getHandle().passenger.getBukkitEntity();
+ return isEmpty() ? null : getHandle().passengers.get(0).getBukkitEntity();
}
public boolean setPassenger(org.bukkit.entity.Entity passenger) {
Preconditions.checkArgument(!this.equals(passenger), "Entity cannot ride itself.");
if (passenger instanceof CraftEntity) {
- ((CraftEntity) passenger).getHandle().mount(getHandle());
+ eject();
+ ((CraftEntity) passenger).getHandle().startRiding(getHandle());
return true;
} else {
return false;
@@ -313,15 +316,15 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
}
public boolean isEmpty() {
- return getHandle().passenger == null;
+ return !getHandle().isVehicle();
}
public boolean eject() {
- if (getHandle().passenger == null) {
+ if (isEmpty()) {
return false;
}
- getHandle().passenger.mount(null);
+ getPassenger().leaveVehicle();
return true;
}
@@ -409,24 +412,24 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
}
public boolean isInsideVehicle() {
- return getHandle().vehicle != null;
+ return getHandle().isPassenger();
}
public boolean leaveVehicle() {
- if (getHandle().vehicle == null) {
+ if (!isInsideVehicle()) {
return false;
}
- getHandle().mount(null);
+ getHandle().stopRiding();
return true;
}
public org.bukkit.entity.Entity getVehicle() {
- if (getHandle().vehicle == null) {
+ if (!isInsideVehicle()) {
return null;
}
- return getHandle().vehicle.getBukkitEntity();
+ return getHandle().getVehicle().getBukkitEntity();
}
@Override
@@ -538,4 +541,18 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
public void setOp(boolean value) {
perm.setOp(value);
}
+
+ @Override
+ public void setGlowing(boolean flag) {
+ getHandle().glowing = flag;
+ Entity e = getHandle();
+ if (e.getFlag(6) != flag) {
+ e.setFlag(6, flag);
+ }
+ }
+
+ @Override
+ public boolean isGlowing() {
+ return getHandle().glowing;
+ }
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java
index 76a9bdba..6a5c4480 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java
@@ -22,11 +22,11 @@ public class CraftFirework extends CraftEntity implements Firework {
public CraftFirework(CraftServer server, EntityFireworks entity) {
super(server, entity);
- ItemStack item = getHandle().getDataWatcher().getItemStack(FIREWORK_ITEM_INDEX);
+ ItemStack item = getHandle().getDataWatcher().get(EntityFireworks.FIREWORK_ITEM).orNull();
if (item == null) {
item = new ItemStack(Items.FIREWORKS);
- getHandle().getDataWatcher().watch(FIREWORK_ITEM_INDEX, item);
+ getHandle().getDataWatcher().register(EntityFireworks.FIREWORK_ITEM, item);
}
this.item = CraftItemStack.asCraftMirror(item);
@@ -64,7 +64,7 @@ public class CraftFirework extends CraftEntity implements Firework {
// Copied from EntityFireworks constructor, update firework lifetime/power
getHandle().expectedLifespan = 10 * (1 + meta.getPower()) + random.nextInt(6) + random.nextInt(7);
- getHandle().getDataWatcher().update(FIREWORK_ITEM_INDEX);
+ getHandle().getDataWatcher().markDirty(EntityFireworks.FIREWORK_ITEM);
}
@Override
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHorse.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHorse.java
index 230ae9ee..26b1814a 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHorse.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHorse.java
@@ -1,6 +1,7 @@
package org.bukkit.craftbukkit.entity;
import net.minecraft.server.EntityHorse;
+import net.minecraft.server.EnumHorseType;
import org.apache.commons.lang.Validate;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.inventory.CraftInventoryHorse;
@@ -23,12 +24,12 @@ public class CraftHorse extends CraftAnimals implements Horse {
}
public Variant getVariant() {
- return Variant.values()[getHandle().getType()];
+ return Variant.values()[getHandle().getType().ordinal()];
}
public void setVariant(Variant variant) {
Validate.notNull(variant, "Variant cannot be null");
- getHandle().setType(variant.ordinal());
+ getHandle().setType(EnumHorseType.values()[variant.ordinal()]);
}
public Color getColor() {
@@ -89,7 +90,7 @@ public class CraftHorse extends CraftAnimals implements Horse {
@Override
public boolean isTamed() {
- return getHandle().isTame();
+ return getHandle().isTamed();
}
@Override
@@ -116,19 +117,11 @@ public class CraftHorse extends CraftAnimals implements Horse {
}
public UUID getOwnerUUID() {
- try {
- return UUID.fromString(getHandle().getOwnerUUID());
- } catch (IllegalArgumentException ex) {
- return null;
- }
+ return getHandle().getOwnerUUID();
}
public void setOwnerUUID(UUID uuid) {
- if (uuid == null) {
- getHandle().setOwnerUUID("");
- } else {
- getHandle().setOwnerUUID(uuid.toString());
- }
+ getHandle().setOwnerUUID(uuid);
}
public HorseInventory getInventory() {
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
index 8a08babc..14751d8b 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
@@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.entity;
+import com.google.common.base.Preconditions;
import java.util.Set;
import net.minecraft.server.*;
@@ -21,6 +22,7 @@ import org.bukkit.craftbukkit.inventory.CraftInventoryPlayer;
import org.bukkit.craftbukkit.inventory.CraftInventoryView;
import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.craftbukkit.CraftServer;
+import org.bukkit.entity.Villager;
import org.bukkit.inventory.EntityEquipment;
import org.bukkit.permissions.PermissibleBase;
import org.bukkit.permissions.Permission;
@@ -347,6 +349,23 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
player.activeContainer.addSlotListener(player);
}
+ @Override
+ public InventoryView openMerchant(Villager villager, boolean force) {
+ Preconditions.checkNotNull(villager, "villager cannot be null");
+ if (!force && villager.isTrading()) {
+ return null;
+ } else if (villager.isTrading()) {
+ // we're not supposed to have multiple people using the same villager, so we have to close it.
+ villager.getTrader().closeInventory();
+ }
+
+ EntityVillager ev = ((CraftVillager) villager).getHandle();
+ ev.setTradingPlayer(this.getHandle());
+ this.getHandle().openTrade(ev);
+
+ return this.getHandle().activeContainer.getBukkitView();
+ }
+
public void closeInventory() {
getHandle().closeInventory();
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
index 5317cff6..28956287 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
@@ -9,9 +9,8 @@ import java.util.Set;
import net.minecraft.server.DamageSource;
import net.minecraft.server.EntityArmorStand;
-import net.minecraft.server.EntityArrow;
+import net.minecraft.server.EntityDragonFireball;
import net.minecraft.server.EntityEgg;
-import net.minecraft.server.EntityEnderDragon;
import net.minecraft.server.EntityEnderPearl;
import net.minecraft.server.EntityFishingHook;
import net.minecraft.server.EntityHuman;
@@ -24,6 +23,7 @@ import net.minecraft.server.EntityPotion;
import net.minecraft.server.EntitySmallFireball;
import net.minecraft.server.EntitySnowball;
import net.minecraft.server.EntityThrownExpBottle;
+import net.minecraft.server.EntityTippedArrow;
import net.minecraft.server.EntityWither;
import net.minecraft.server.EntityWitherSkull;
import net.minecraft.server.GenericAttributes;
@@ -33,12 +33,15 @@ import net.minecraft.server.MobEffectList;
import org.apache.commons.lang.Validate;
import org.bukkit.Location;
import org.bukkit.Material;
+import org.bukkit.attribute.Attribute;
+import org.bukkit.attribute.AttributeInstance;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.craftbukkit.inventory.CraftEntityEquipment;
import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.entity.Arrow;
+import org.bukkit.entity.DragonFireball;
import org.bukkit.entity.Egg;
import org.bukkit.entity.EnderPearl;
import org.bukkit.entity.Entity;
@@ -108,16 +111,6 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
setMaxHealth(getHandle().getMaxHealth());
}
- @Deprecated
- public Egg throwEgg() {
- return launchProjectile(Egg.class);
- }
-
- @Deprecated
- public Snowball throwSnowball() {
- return launchProjectile(Snowball.class);
- }
-
public double getEyeHeight() {
return getHandle().getHeadHeight();
}
@@ -204,11 +197,6 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
return getLineOfSight(transparent, maxDistance, 2);
}
- @Deprecated
- public Arrow shootArrow() {
- return launchProjectile(Arrow.class);
- }
-
public int getRemainingAir() {
return getHandle().getAirTicks();
}
@@ -300,7 +288,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
}
removePotionEffect(effect.getType());
}
- getHandle().addEffect(new MobEffect(effect.getType().getId(), effect.getDuration(), effect.getAmplifier(), effect.isAmbient(), effect.hasParticles()));
+ getHandle().addEffect(new MobEffect(MobEffectList.fromId(effect.getType().getId()), effect.getDuration(), effect.getAmplifier(), effect.isAmbient(), effect.hasParticles()));
return true;
}
@@ -313,20 +301,17 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
}
public boolean hasPotionEffect(PotionEffectType type) {
- return getHandle().hasEffect(MobEffectList.byId[type.getId()]);
+ return getHandle().hasEffect(MobEffectList.fromId(type.getId()));
}
public void removePotionEffect(PotionEffectType type) {
- getHandle().removeEffect(type.getId());
+ getHandle().removeEffect(MobEffectList.fromId(type.getId()));
}
public Collection<PotionEffect> getActivePotionEffects() {
List<PotionEffect> effects = new ArrayList<PotionEffect>();
- for (Object raw : getHandle().effects.values()) {
- if (!(raw instanceof MobEffect))
- continue;
- MobEffect handle = (MobEffect) raw;
- effects.add(new PotionEffect(PotionEffectType.getById(handle.getEffectId()), handle.getDuration(), handle.getAmplifier(), handle.isAmbient(), handle.isShowParticles()));
+ for (MobEffect handle : getHandle().effects.values()) {
+ effects.add(new PotionEffect(PotionEffectType.getById(MobEffectList.getId(handle.getMobEffect())), handle.getDuration(), handle.getAmplifier(), handle.isAmbient(), handle.isShowParticles()));
}
return effects;
}
@@ -347,7 +332,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
} else if (EnderPearl.class.isAssignableFrom(projectile)) {
launch = new EntityEnderPearl(world, getHandle());
} else if (Arrow.class.isAssignableFrom(projectile)) {
- launch = new EntityArrow(world, getHandle(), 1);
+ launch = new EntityTippedArrow(world, getHandle());
} else if (ThrownPotion.class.isAssignableFrom(projectile)) {
launch = new EntityPotion(world, getHandle(), CraftItemStack.asNMSCopy(new ItemStack(Material.POTION, 1)));
} else if (ThrownExpBottle.class.isAssignableFrom(projectile)) {
@@ -362,6 +347,8 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
launch = new EntitySmallFireball(world, getHandle(), direction.getX(), direction.getY(), direction.getZ());
} else if (WitherSkull.class.isAssignableFrom(projectile)) {
launch = new EntityWitherSkull(world, getHandle(), direction.getX(), direction.getY(), direction.getZ());
+ } else if (DragonFireball.class.isAssignableFrom(projectile)) {
+ launch = new EntityDragonFireball(world, getHandle(), direction.getX(), direction.getY(), direction.getZ());
} else {
launch = new EntityLargeFireball(world, getHandle(), direction.getX(), direction.getY(), direction.getZ());
}
@@ -500,4 +487,9 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
public void _INVALID_setMaxHealth(int health) {
setMaxHealth(health);
}
+
+ @Override
+ public AttributeInstance getAttribute(Attribute attribute) {
+ return getHandle().craftAttributes.getAttribute(attribute);
+ }
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java
index 03e0730b..8a72fd23 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java
@@ -91,7 +91,7 @@ public abstract class CraftMinecart extends CraftVehicle implements Minecart {
}
public void setDisplayBlockOffset(int offset) {
- getHandle().SetDisplayBlockOffset(offset);
+ getHandle().setDisplayBlockOffset(offset);
}
public int getDisplayBlockOffset() {
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index bffb0389..fb81a28d 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -36,6 +36,7 @@ import org.bukkit.configuration.serialization.DelegateDeserialization;
import org.bukkit.conversations.Conversation;
import org.bukkit.conversations.ConversationAbandonedEvent;
import org.bukkit.conversations.ManuallyAbandonedConversationCanceller;
+import org.bukkit.craftbukkit.CraftParticle;
import org.bukkit.craftbukkit.block.CraftSign;
import org.bukkit.craftbukkit.conversations.ConversationTracker;
import org.bukkit.craftbukkit.CraftEffect;
@@ -264,7 +265,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
}
float f = (float) Math.pow(2.0D, (note - 12.0D) / 12.0D);
- getHandle().playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect("note."+instrumentName, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), 3.0f, f));
+ getHandle().playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect(CraftSound.getSoundEffect("note." + instrumentName), SoundCategory.MUSIC, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), 3.0f, f));
}
@Override
@@ -290,7 +291,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
break;
}
float f = (float) Math.pow(2.0D, (note.getId() - 12.0D) / 12.0D);
- getHandle().playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect("note."+instrumentName, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), 3.0f, f));
+ getHandle().playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect(CraftSound.getSoundEffect("note." + instrumentName), SoundCategory.MUSIC, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), 3.0f, f));
}
@Override
@@ -309,7 +310,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
double y = loc.getBlockY() + 0.5;
double z = loc.getBlockZ() + 0.5;
- PacketPlayOutNamedSoundEffect packet = new PacketPlayOutNamedSoundEffect(sound, x, y, z, volume, pitch);
+ PacketPlayOutNamedSoundEffect packet = new PacketPlayOutNamedSoundEffect(CraftSound.getSoundEffect(sound), SoundCategory.MASTER, x, y, z, volume, pitch);
getHandle().playerConnection.sendPacket(packet);
}
@@ -415,7 +416,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
}
}
- PacketPlayOutMap packet = new PacketPlayOutMap(map.getId(), map.getScale().getValue(), icons, data.buffer, 0, 0, 0, 0);
+ PacketPlayOutMap packet = new PacketPlayOutMap(map.getId(), map.getScale().getValue(), true, icons, data.buffer, 0, 0, 0, 0);
getHandle().playerConnection.sendPacket(packet);
}
@@ -431,7 +432,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
return false;
}
- if (entity.passenger != null) {
+ if (entity.isVehicle()) {
return false;
}
@@ -449,7 +450,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
}
// If this player is riding another entity, we must dismount before teleporting.
- entity.mount(null);
+ entity.stopRiding();
// Update the From Location
from = event.getFrom();
@@ -1288,7 +1289,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
injectScaledMaxHealth(set, true);
- getHandle().getDataWatcher().watch(6, (float) getScaledHealth());
+ getHandle().getDataWatcher().set(EntityLiving.HEALTH, (float) getScaledHealth());
getHandle().playerConnection.sendPacket(new PacketPlayOutUpdateHealth(getScaledHealth(), getHandle().getFoodData().getFoodLevel(), getHandle().getFoodData().getSaturationLevel()));
getHandle().playerConnection.sendPacket(new PacketPlayOutUpdateAttributes(getHandle().getId(), set));
@@ -1312,7 +1313,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@Override
public org.bukkit.entity.Entity getSpectatorTarget() {
- Entity followed = getHandle().C(); // PAIL
+ Entity followed = getHandle().getSpecatorTarget();
return followed == getHandle() ? null : followed.getBukkitEntity();
}
@@ -1340,4 +1341,69 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
PacketPlayOutTitle packetReset = new PacketPlayOutTitle(EnumTitleAction.RESET, null);
getHandle().playerConnection.sendPacket(packetReset);
}
+
+ @Override
+ public void spawnParticle(Particle particle, Location location, int count) {
+ spawnParticle(particle, location.getX(), location.getY(), location.getZ(), count);
+ }
+
+ @Override
+ public void spawnParticle(Particle particle, double x, double y, double z, int count) {
+ spawnParticle(particle, x, y, z, count, null);
+ }
+
+ @Override
+ public <T> void spawnParticle(Particle particle, Location location, int count, T data) {
+ spawnParticle(particle, location.getX(), location.getY(), location.getZ(), count, data);
+ }
+
+ @Override
+ public <T> void spawnParticle(Particle particle, double x, double y, double z, int count, T data) {
+ spawnParticle(particle, x, y, z, count, 0, 0, 0);
+ }
+
+ @Override
+ public void spawnParticle(Particle particle, Location location, int count, double offsetX, double offsetY, double offsetZ) {
+ spawnParticle(particle, location.getX(), location.getY(), location.getZ(), count, offsetX, offsetY, offsetZ);
+ }
+
+ @Override
+ public void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ) {
+ spawnParticle(particle, x, y, z, count, offsetX, offsetY, offsetZ, null);
+ }
+
+ @Override
+ public <T> void spawnParticle(Particle particle, Location location, int count, double offsetX, double offsetY, double offsetZ, T data) {
+ spawnParticle(particle, location.getX(), location.getY(), location.getZ(), count, offsetX, offsetY, offsetZ, data);
+ }
+
+ @Override
+ public <T> void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, T data) {
+ spawnParticle(particle, x, y, z, count, offsetX, offsetY, offsetZ, 1, data);
+ }
+
+ @Override
+ public void spawnParticle(Particle particle, Location location, int count, double offsetX, double offsetY, double offsetZ, double extra) {
+ spawnParticle(particle, location.getX(), location.getY(), location.getZ(), count, offsetX, offsetY, offsetZ, extra);
+ }
+
+ @Override
+ public void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra) {
+ spawnParticle(particle, x, y, z, count, offsetX, offsetY, offsetZ, extra, null);
+ }
+
+ @Override
+ public <T> void spawnParticle(Particle particle, Location location, int count, double offsetX, double offsetY, double offsetZ, double extra, T data) {
+ spawnParticle(particle, location.getX(), location.getY(), location.getZ(), count, offsetX, offsetY, offsetZ, extra, data);
+ }
+
+ @Override
+ public <T> void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra, T data) {
+ if (data != null && !particle.getDataType().isInstance(data)) {
+ throw new IllegalArgumentException("data should be " + particle.getDataType() + " got " + data.getClass());
+ }
+ PacketPlayOutWorldParticles packetplayoutworldparticles = new PacketPlayOutWorldParticles(CraftParticle.toNMS(particle), true, (float) x, (float) y, (float) z, (float) offsetX, (float) offsetY, (float) offsetZ, (float) extra, count, CraftParticle.toData(particle, data));
+ getHandle().playerConnection.sendPacket(packetplayoutworldparticles);
+
+ }
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftShulker.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftShulker.java
new file mode 100644
index 00000000..eef9d3c5
--- /dev/null
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftShulker.java
@@ -0,0 +1,24 @@
+package org.bukkit.craftbukkit.entity;
+
+import net.minecraft.server.EntityGolem;
+import net.minecraft.server.EntityShulker;
+import org.bukkit.craftbukkit.CraftServer;
+import org.bukkit.entity.EntityType;
+import org.bukkit.entity.Shulker;
+
+public class CraftShulker extends CraftGolem implements Shulker {
+
+ public CraftShulker(CraftServer server, EntityShulker entity) {
+ super(server, entity);
+ }
+
+ @Override
+ public EntityType getType() {
+ return EntityType.SHULKER;
+ }
+
+ @Override
+ public EntityShulker getHandle() {
+ return (EntityShulker) entity;
+ }
+}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftShulkerBullet.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftShulkerBullet.java
new file mode 100644
index 00000000..91476970
--- /dev/null
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftShulkerBullet.java
@@ -0,0 +1,51 @@
+package org.bukkit.craftbukkit.entity;
+
+import net.minecraft.server.Entity;
+import net.minecraft.server.EntityShulkerBullet;
+import org.bukkit.craftbukkit.CraftServer;
+import org.bukkit.entity.EntityType;
+import org.bukkit.entity.LivingEntity;
+import org.bukkit.entity.ShulkerBullet;
+import org.bukkit.projectiles.ProjectileSource;
+
+public class CraftShulkerBullet extends CraftEntity implements ShulkerBullet {
+
+ public CraftShulkerBullet(CraftServer server, EntityShulkerBullet entity) {
+ super(server, entity);
+ }
+
+ @Override
+ public ProjectileSource getShooter() {
+ return getHandle().projectileSource;
+ }
+
+ @Override
+ public void setShooter(ProjectileSource shooter) {
+ if (shooter instanceof LivingEntity) {
+ getHandle().setShooter(((CraftLivingEntity) shooter).getHandle());
+ } else {
+ getHandle().setShooter(null);
+ }
+ getHandle().projectileSource = shooter;
+ }
+
+ @Override
+ public org.bukkit.entity.Entity getTarget() {
+ return getHandle().getTarget() != null ? getHandle().getTarget().getBukkitEntity() : null;
+ }
+
+ @Override
+ public void setTarget(org.bukkit.entity.Entity target) {
+ getHandle().setTarget(target == null ? null : ((CraftEntity) target).getHandle());
+ }
+
+ @Override
+ public EntityType getType() {
+ return EntityType.SHULKER_BULLET;
+ }
+
+ @Override
+ public EntityShulkerBullet getHandle() {
+ return (EntityShulkerBullet) entity;
+ }
+}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java
index e08ad471..c493c9c0 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java
@@ -31,11 +31,11 @@ public class CraftTNTPrimed extends CraftEntity implements TNTPrimed {
}
public int getFuseTicks() {
- return getHandle().fuseTicks;
+ return getHandle().getFuseTicks();
}
public void setFuseTicks(int fuseTicks) {
- getHandle().fuseTicks = fuseTicks;
+ getHandle().setFuseTicks(fuseTicks);
}
@Override
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftTameableAnimal.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftTameableAnimal.java
index ea1d10b3..0800d73a 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftTameableAnimal.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftTameableAnimal.java
@@ -20,18 +20,14 @@ public class CraftTameableAnimal extends CraftAnimals implements Tameable, Creat
public UUID getOwnerUUID() {
try {
- return UUID.fromString(getHandle().getOwnerUUID());
+ return getHandle().getOwnerUUID();
} catch (IllegalArgumentException ex) {
return null;
}
}
public void setOwnerUUID(UUID uuid) {
- if (uuid == null) {
- getHandle().setOwnerUUID("");
- } else {
- getHandle().setOwnerUUID(uuid.toString());
- }
+ getHandle().setOwnerUUID(uuid);
}
public AnimalTamer getOwner() {
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownPotion.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownPotion.java
index 18da4266..092e9fba 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownPotion.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownPotion.java
@@ -22,14 +22,11 @@ public class CraftThrownPotion extends CraftProjectile implements ThrownPotion {
// TODO: This one does not handle custom NBT potion effects does it?
// In that case this method could be said to be misleading or incorrect
public Collection<PotionEffect> getEffects() {
- return Potion.getBrewer().getEffectsFromDamage(getHandle().getPotionValue());
+ return Potion.getBrewer().getEffectsFromDamage(getHandle().getItem().getData());
}
public ItemStack getItem() {
- // We run this method once since it will set the item stack if there is none.
- getHandle().getPotionValue();
-
- return CraftItemStack.asBukkitCopy(getHandle().item);
+ return CraftItemStack.asBukkitCopy(getHandle().getItem());
}
public void setItem(ItemStack item) {
@@ -39,7 +36,7 @@ public class CraftThrownPotion extends CraftProjectile implements ThrownPotion {
// The ItemStack must be a potion.
Validate.isTrue(item.getType() == Material.POTION, "ItemStack must be a potion. This item stack was " + item.getType() + ".");
- getHandle().item = CraftItemStack.asNMSCopy(item);
+ getHandle().setItem(CraftItemStack.asNMSCopy(item));
}
@Override
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java
index 6fe21cce..95ffdf67 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java
@@ -1,15 +1,25 @@
package org.bukkit.craftbukkit.entity;
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
+import java.util.Collections;
+import java.util.List;
+import net.minecraft.server.EntityHuman;
import net.minecraft.server.EntityVillager;
+import net.minecraft.server.MerchantRecipeList;
import org.apache.commons.lang.Validate;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.inventory.CraftInventory;
+import org.bukkit.craftbukkit.inventory.CraftMerchantRecipe;
import org.bukkit.entity.EntityType;
+import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Villager;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
+import org.bukkit.inventory.MerchantRecipe;
public class CraftVillager extends CraftAgeable implements Villager, InventoryHolder {
+
public CraftVillager(CraftServer server, EntityVillager entity) {
super(server, entity);
}
@@ -41,4 +51,59 @@ public class CraftVillager extends CraftAgeable implements Villager, InventoryHo
public Inventory getInventory() {
return new CraftInventory(getHandle().inventory);
}
+
+ @Override
+ public List<MerchantRecipe> getRecipes() {
+ return Collections.unmodifiableList(Lists.transform(getHandle().getOffers(null), new Function<net.minecraft.server.MerchantRecipe, MerchantRecipe>() {
+ @Override
+ public MerchantRecipe apply(net.minecraft.server.MerchantRecipe recipe) {
+ return recipe.asBukkit();
+ }
+ }));
+ }
+
+ @Override
+ public void setRecipes(List<MerchantRecipe> list) {
+ MerchantRecipeList recipes = getHandle().getOffers(null);
+ recipes.clear();
+ for (MerchantRecipe m : list) {
+ recipes.add(CraftMerchantRecipe.fromBukkit(m).toMinecraft());
+ }
+ }
+
+ @Override
+ public MerchantRecipe getRecipe(int i) {
+ return getHandle().getOffers(null).get(i).asBukkit();
+ }
+
+ @Override
+ public void setRecipe(int i, MerchantRecipe merchantRecipe) {
+ getHandle().getOffers(null).set(i, CraftMerchantRecipe.fromBukkit(merchantRecipe).toMinecraft());
+ }
+
+ @Override
+ public int getRecipeCount() {
+ return getHandle().getOffers(null).size();
+ }
+
+ @Override
+ public boolean isTrading() {
+ return getTrader() != null;
+ }
+
+ @Override
+ public HumanEntity getTrader() {
+ EntityHuman eh = getHandle().t_(); // PAIL: rename t_ -> getTrader
+ return eh == null ? null : eh.getBukkitEntity();
+ }
+
+ @Override
+ public int getRiches() {
+ return getHandle().riches;
+ }
+
+ @Override
+ public void setRiches(int riches) {
+ getHandle().riches = riches;
+ }
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java
index 619579d4..c9e68350 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java
@@ -4,6 +4,7 @@ import net.minecraft.server.EntityZombie;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.EntityType;
+import org.bukkit.entity.Villager;
import org.bukkit.entity.Zombie;
public class CraftZombie extends CraftMonster implements Zombie {
@@ -39,6 +40,21 @@ public class CraftZombie extends CraftMonster implements Zombie {
}
public void setVillager(boolean flag) {
- getHandle().setVillager(flag);
+ getHandle().setVillagerType(0);
+ }
+
+ @Override
+ public void setVillagerProfession(Villager.Profession profession) {
+ if (profession == null) {
+ getHandle().clearVillagerType();
+ } else {
+ getHandle().setVillagerType(profession.getId());
+ }
+ }
+
+ @Override
+ public Villager.Profession getVillagerProfession() {
+ if (!isVillager()) return null;
+ return Villager.Profession.getProfession(getHandle().getVillagerType());
}
}
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
index f0d3f754..86820c23 100644
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
@@ -54,6 +54,7 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityDamageEvent.DamageModifier;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.inventory.InventoryOpenEvent;
+import org.bukkit.event.inventory.PrepareAnvilEvent;
import org.bukkit.event.inventory.PrepareItemCraftEvent;
import org.bukkit.event.player.*;
import org.bukkit.event.server.ServerListPingEvent;
@@ -337,7 +338,7 @@ public class CraftEventFactory {
return event;
}
- public static void handleBlockSpreadEvent(Block block, Block source, net.minecraft.server.Block type, int data) {
+ public static boolean handleBlockSpreadEvent(Block block, Block source, net.minecraft.server.Block type, int data) {
BlockState state = block.getState();
state.setTypeId(net.minecraft.server.Block.getId(type));
state.setRawData((byte) data);
@@ -348,6 +349,7 @@ public class CraftEventFactory {
if (!event.isCancelled()) {
state.update(true);
}
+ return !event.isCancelled();
}
public static EntityDeathEvent callEntityDeathEvent(EntityLiving victim) {
@@ -414,7 +416,7 @@ public class CraftEventFactory {
EntityDamageEvent event;
if (damager == null) {
event = new EntityDamageByBlockEvent(null, entity.getBukkitEntity(), DamageCause.BLOCK_EXPLOSION, modifiers, modifierFunctions);
- } else if (entity instanceof EntityEnderDragon && ((EntityEnderDragon) entity).target == damager) {
+ } else if (entity instanceof EntityEnderDragon && /*PAIL FIXME ((EntityEnderDragon) entity).target == damager*/ false) {
event = new EntityDamageEvent(entity.getBukkitEntity(), DamageCause.ENTITY_EXPLOSION, modifiers, modifierFunctions);
} else {
if (damager instanceof org.bukkit.entity.TNTPrimed) {
@@ -483,6 +485,8 @@ public class CraftEventFactory {
cause = DamageCause.LIGHTNING;
} else if (source == DamageSource.FALL) {
cause = DamageCause.FALL;
+ } else if (source == DamageSource.DRAGON_BREATH) {
+ cause = DamageCause.DRAGON_BREATH;
} else {
throw new AssertionError(String.format("Unhandled damage of %s by %s from %s", entity, damager.getHandle(), source.translationIndex));
}
@@ -604,7 +608,7 @@ public class CraftEventFactory {
return event;
}
- public static void handleBlockGrowEvent(World world, int x, int y, int z, net.minecraft.server.Block type, int data) {
+ public static boolean handleBlockGrowEvent(World world, int x, int y, int z, net.minecraft.server.Block type, int data) {
Block block = world.getWorld().getBlockAt(x, y, z);
CraftBlockState state = (CraftBlockState) block.getState();
state.setTypeId(net.minecraft.server.Block.getId(type));
@@ -616,6 +620,8 @@ public class CraftEventFactory {
if (!event.isCancelled()) {
state.update(true);
}
+
+ return !event.isCancelled();
}
public static FoodLevelChangeEvent callFoodLevelChangeEvent(EntityHuman entity, int level) {
@@ -930,6 +936,7 @@ public class CraftEventFactory {
case SPRINT_ONE_CM:
case CROUCH_ONE_CM:
case TIME_SINCE_DEATH:
+ case SNEAK_TIME:
// Do not process event for these - too spammy
return null;
default:
@@ -953,4 +960,11 @@ public class CraftEventFactory {
firework.world.getServer().getPluginManager().callEvent(event);
return event;
}
+
+ public static PrepareAnvilEvent callPrepareAnvilEvent(InventoryView view, ItemStack item) {
+ PrepareAnvilEvent event = new PrepareAnvilEvent(view, CraftItemStack.asCraftMirror(item).clone());
+ event.getView().getPlayer().getServer().getPluginManager().callEvent(event);
+ event.getInventory().setItem(2, event.getResult());
+ return event;
+ }
}
diff --git a/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java b/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java
index 04dd15db..c7081e34 100644
--- a/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java
+++ b/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java
@@ -19,10 +19,12 @@ public class CustomChunkGenerator extends InternalChunkGenerator {
private static class CustomBiomeGrid implements BiomeGrid {
BiomeBase[] biome;
+ @Override
public Biome getBiome(int x, int z) {
return CraftBlock.biomeBaseToBiome(biome[(z << 4) | x]);
}
+ @Override
public void setBiome(int x, int z, Biome bio) {
biome[(z << 4) | x] = CraftBlock.biomeToBiomeBase(bio);
}
@@ -35,10 +37,7 @@ public class CustomChunkGenerator extends InternalChunkGenerator {
this.random = new Random(seed);
}
- public boolean isChunkLoaded(int x, int z) {
- return true;
- }
-
+ @Override
public Chunk getOrCreateChunk(int x, int z) {
random.setSeed((long) x * 341873128712L + (long) z * 132897987541L);
@@ -67,7 +66,7 @@ public class CustomChunkGenerator extends InternalChunkGenerator {
char emptyTest = 0;
for (int i = 0; i < 4096; i++) {
// Filter invalid block id & data values.
- if (Block.d.a(section[i]) == null) {
+ if (Block.REGISTRY_ID.fromId(section[i]) == null) {
section[i] = 0;
}
emptyTest |= section[i];
@@ -96,7 +95,7 @@ public class CustomChunkGenerator extends InternalChunkGenerator {
short[] bdata = xbtypes[sec];
for (int i = 0; i < bdata.length; i++) {
Block b = Block.getById(bdata[i]);
- secBlkID[i] = (char) Block.d.b(b.getBlockData());
+ secBlkID[i] = (char) Block.REGISTRY_ID.getId(b.getBlockData());
}
// Build chunk section
csect[sec] = new ChunkSection(sec << 4, true, secBlkID);
@@ -119,7 +118,7 @@ public class CustomChunkGenerator extends InternalChunkGenerator {
char[] secBlkID = new char[4096]; // Allocate block ID bytes
for (int i = 0; i < secBlkID.length; i++) {
Block b = Block.getById(btypes[sec][i] & 0xFF);
- secBlkID[i] = (char) Block.d.b(b.getBlockData());
+ secBlkID[i] = (char) Block.REGISTRY_ID.getId(b.getBlockData());
}
csect[sec] = new ChunkSection(sec << 4, true, secBlkID);
}
@@ -137,8 +136,7 @@ public class CustomChunkGenerator extends InternalChunkGenerator {
scnt = Math.min(scnt, csect.length);
// Loop through sections
for (int sec = 0; sec < scnt; sec++) {
- ChunkSection cs = null; // Add sections when needed
- char[] csbytes = null;
+ char[] csbytes = null; // Add sections when needed
for (int cy = 0; cy < 16; cy++) {
int cyoff = cy | (sec << 4);
@@ -150,19 +148,19 @@ public class CustomChunkGenerator extends InternalChunkGenerator {
byte blk = types[cxyoff + (cz * ydim)];
if (blk != 0) { // If non-empty
- if (cs == null) { // If no section yet, get one
- cs = csect[sec] = new ChunkSection(sec << 4, true);
- csbytes = cs.getIdArray();
+ if (csbytes == null) { // If no section yet, get one
+ csbytes = new char[16*16*16];
}
Block b = Block.getById(blk & 0xFF);
- csbytes[(cy << 8) | (cz << 4) | cx] = (char) Block.d.b(b.getBlockData());
+ csbytes[(cy << 8) | (cz << 4) | cx] = (char) Block.REGISTRY_ID.getId(b.getBlockData());
}
}
}
}
// If section built, finish prepping its state
- if (cs != null) {
+ if (csbytes != null) {
+ ChunkSection cs = csect[sec] = new ChunkSection(sec << 4, true, csbytes);
cs.recalcBlockCounts();
}
}
@@ -172,7 +170,7 @@ public class CustomChunkGenerator extends InternalChunkGenerator {
// Set biome grid
byte[] biomeIndex = chunk.getBiomeIndex();
for (int i = 0; i < biomeIndex.length; i++) {
- biomeIndex[i] = (byte) (biomegrid.biome[i].id & 0xFF);
+ biomeIndex[i] = (byte) (BiomeBase.REGISTRY_ID.a(biomegrid.biome[i]) & 0xFF); // PAIL : rename
}
// Initialize lighting
chunk.initLighting();
@@ -181,40 +179,22 @@ public class CustomChunkGenerator extends InternalChunkGenerator {
}
@Override
- public Chunk getChunkAt(BlockPosition blockPosition) {
- return getChunkAt(blockPosition.getX() >> 4, blockPosition.getZ() >> 4);
- }
-
- public void getChunkAt(IChunkProvider icp, int i, int i1) {
- // Nothing!
- }
-
- @Override
- public boolean a(IChunkProvider iChunkProvider, Chunk chunk, int i, int i1) {
- return false;
- }
-
- public boolean saveChunks(boolean bln, IProgressUpdate ipu) {
- return true;
- }
-
- public boolean unloadChunks() {
+ public boolean a(Chunk chunk, int i, int i1) {
return false;
}
- public boolean canSave() {
- return true;
- }
-
@SuppressWarnings("deprecation")
+ @Override
public byte[] generate(org.bukkit.World world, Random random, int x, int z) {
return generator.generate(world, random, x, z);
}
+ @Override
public byte[][] generateBlockSections(org.bukkit.World world, Random random, int x, int z, BiomeGrid biomes) {
return generator.generateBlockSections(world, random, x, z, biomes);
}
+ @Override
public short[][] generateExtBlockSections(org.bukkit.World world, Random random, int x, int z, BiomeGrid biomes) {
return generator.generateExtBlockSections(world, random, x, z, biomes);
}
@@ -245,20 +225,11 @@ public class CustomChunkGenerator extends InternalChunkGenerator {
return "Stronghold".equals(type) && this.strongholdGen != null ? this.strongholdGen.getNearestGeneratedFeature(world, position) : null;
}
+ @Override
public void recreateStructures(int i, int j) {}
- public int getLoadedChunks() {
- return 0;
- }
-
@Override
public void recreateStructures(Chunk chunk, int i, int i1) {
}
-
- public String getName() {
- return "CustomChunkGenerator";
- }
-
- public void c() {}
}
diff --git a/src/main/java/org/bukkit/craftbukkit/generator/InternalChunkGenerator.java b/src/main/java/org/bukkit/craftbukkit/generator/InternalChunkGenerator.java
index 19565e52..d2e71b87 100644
--- a/src/main/java/org/bukkit/craftbukkit/generator/InternalChunkGenerator.java
+++ b/src/main/java/org/bukkit/craftbukkit/generator/InternalChunkGenerator.java
@@ -4,5 +4,5 @@ import net.minecraft.server.IChunkProvider;
import org.bukkit.generator.ChunkGenerator;
// Do not implement functions to this class, add to NormalChunkGenerator
-public abstract class InternalChunkGenerator extends ChunkGenerator implements IChunkProvider {
+public abstract class InternalChunkGenerator extends ChunkGenerator implements net.minecraft.server.ChunkGenerator {
}
diff --git a/src/main/java/org/bukkit/craftbukkit/generator/NormalChunkGenerator.java b/src/main/java/org/bukkit/craftbukkit/generator/NormalChunkGenerator.java
index fc4bc81f..cbcca41c 100644
--- a/src/main/java/org/bukkit/craftbukkit/generator/NormalChunkGenerator.java
+++ b/src/main/java/org/bukkit/craftbukkit/generator/NormalChunkGenerator.java
@@ -10,10 +10,10 @@ import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.generator.BlockPopulator;
public class NormalChunkGenerator extends InternalChunkGenerator {
- private final IChunkProvider provider;
+ private final ChunkGenerator generator;
public NormalChunkGenerator(World world, long seed) {
- provider = world.worldProvider.getChunkProvider();
+ generator = world.worldProvider.getChunkGenerator();
}
@Override
@@ -32,71 +32,32 @@ public class NormalChunkGenerator extends InternalChunkGenerator {
}
@Override
- public boolean isChunkLoaded(int i, int i1) {
- return provider.isChunkLoaded(i, i1);
- }
-
- @Override
public Chunk getOrCreateChunk(int i, int i1) {
- return provider.getOrCreateChunk(i, i1);
- }
-
- @Override
- public Chunk getChunkAt(BlockPosition blockPosition) {
- return provider.getChunkAt(blockPosition);
- }
-
- @Override
- public void getChunkAt(IChunkProvider icp, int i, int i1) {
- provider.getChunkAt(icp, i, i1);
- }
-
- @Override
- public boolean a(IChunkProvider iChunkProvider, Chunk chunk, int i, int i1) {
- return provider.a(provider, chunk, i, i1);
+ return generator.getOrCreateChunk(i, i1);
}
@Override
- public boolean saveChunks(boolean bln, IProgressUpdate ipu) {
- return provider.saveChunks(bln, ipu);
+ public void recreateStructures(int i, int i1) {
+ generator.recreateStructures(i, i1);
}
@Override
- public boolean unloadChunks() {
- return provider.unloadChunks();
+ public boolean a(Chunk chunk, int i, int i1) {
+ return generator.a(chunk, i, i1);
}
@Override
- public boolean canSave() {
- return provider.canSave();
+ public List<BiomeBase.BiomeMeta> getMobsFor(EnumCreatureType enumCreatureType, BlockPosition blockPosition) {
+ return generator.getMobsFor(enumCreatureType, blockPosition);
}
@Override
- public List<BiomeBase.BiomeMeta> getMobsFor(EnumCreatureType ect, BlockPosition position) {
- return provider.getMobsFor(ect, position);
- }
-
- @Override
- public BlockPosition findNearestMapFeature(World world, String string, BlockPosition position) {
- return provider.findNearestMapFeature(world, string, position);
- }
-
- // n.m.s implementations always return 0. (The true implementation is in ChunkProviderServer)
- @Override
- public int getLoadedChunks() {
- return 0;
+ public BlockPosition findNearestMapFeature(World world, String s, BlockPosition blockPosition) {
+ return generator.findNearestMapFeature(world, s, blockPosition);
}
@Override
public void recreateStructures(Chunk chunk, int i, int i1) {
- provider.recreateStructures(chunk, i, i1);
+ generator.recreateStructures(chunk, i, i1);
}
-
- @Override
- public String getName() {
- return "NormalWorldGenerator";
- }
-
- @Override
- public void c() {}
}
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftEntityEquipment.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftEntityEquipment.java
index 22134820..e95fb3a8 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftEntityEquipment.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftEntityEquipment.java
@@ -1,6 +1,7 @@
package org.bukkit.craftbukkit.inventory;
import net.minecraft.server.EntityInsentient;
+import net.minecraft.server.EnumItemSlot;
import org.bukkit.craftbukkit.entity.CraftLivingEntity;
import org.bukkit.entity.Entity;
@@ -8,12 +9,6 @@ import org.bukkit.inventory.EntityEquipment;
import org.bukkit.inventory.ItemStack;
public class CraftEntityEquipment implements EntityEquipment {
- private static final int WEAPON_SLOT = 0;
- private static final int HELMET_SLOT = 4;
- private static final int CHEST_SLOT = 3;
- private static final int LEG_SLOT = 2;
- private static final int BOOT_SLOT = 1;
- private static final int INVENTORY_SLOTS = 5;
private final CraftLivingEntity entity;
@@ -21,72 +16,96 @@ public class CraftEntityEquipment implements EntityEquipment {
this.entity = entity;
}
+ @Override
+ public ItemStack getItemInMainHand() {
+ return getEquipment(EnumItemSlot.MAINHAND);
+ }
+
+ @Override
+ public void setItemInMainHand(ItemStack item) {
+ setEquipment(EnumItemSlot.MAINHAND, item);
+ }
+
+ @Override
+ public ItemStack getItemInOffHand() {
+ return getEquipment(EnumItemSlot.OFFHAND);
+ }
+
+ @Override
+ public void setItemInOffHand(ItemStack item) {
+ setEquipment(EnumItemSlot.OFFHAND, item);
+ }
+
+ @Override
public ItemStack getItemInHand() {
- return getEquipment(WEAPON_SLOT);
+ return getItemInMainHand();
}
+ @Override
public void setItemInHand(ItemStack stack) {
- setEquipment(WEAPON_SLOT, stack);
+ setItemInMainHand(stack);
}
public ItemStack getHelmet() {
- return getEquipment(HELMET_SLOT);
+ return getEquipment(EnumItemSlot.HEAD);
}
public void setHelmet(ItemStack helmet) {
- setEquipment(HELMET_SLOT, helmet);
+ setEquipment(EnumItemSlot.HEAD, helmet);
}
public ItemStack getChestplate() {
- return getEquipment(CHEST_SLOT);
+ return getEquipment(EnumItemSlot.CHEST);
}
public void setChestplate(ItemStack chestplate) {
- setEquipment(CHEST_SLOT, chestplate);
+ setEquipment(EnumItemSlot.CHEST, chestplate);
}
public ItemStack getLeggings() {
- return getEquipment(LEG_SLOT);
+ return getEquipment(EnumItemSlot.LEGS);
}
public void setLeggings(ItemStack leggings) {
- setEquipment(LEG_SLOT, leggings);
+ setEquipment(EnumItemSlot.LEGS, leggings);
}
public ItemStack getBoots() {
- return getEquipment(BOOT_SLOT);
+ return getEquipment(EnumItemSlot.FEET);
}
public void setBoots(ItemStack boots) {
- setEquipment(BOOT_SLOT, boots);
+ setEquipment(EnumItemSlot.FEET, boots);
}
public ItemStack[] getArmorContents() {
- ItemStack[] armor = new ItemStack[INVENTORY_SLOTS - 1];
- for(int slot = WEAPON_SLOT + 1; slot < INVENTORY_SLOTS; slot++) {
- armor[slot - 1] = getEquipment(slot);
- }
+ ItemStack[] armor = new ItemStack[]{
+ getEquipment(EnumItemSlot.FEET),
+ getEquipment(EnumItemSlot.LEGS),
+ getEquipment(EnumItemSlot.CHEST),
+ getEquipment(EnumItemSlot.HEAD),
+ };
return armor;
}
public void setArmorContents(ItemStack[] items) {
- for(int slot = WEAPON_SLOT + 1; slot < INVENTORY_SLOTS; slot++) {
- ItemStack equipment = items != null && slot <= items.length ? items[slot - 1] : null;
- setEquipment(slot, equipment);
- }
+ setEquipment(EnumItemSlot.FEET, items.length >= 1 ? items[0] : null);
+ setEquipment(EnumItemSlot.LEGS, items.length >= 2 ? items[1] : null);
+ setEquipment(EnumItemSlot.CHEST, items.length >= 3 ? items[2] : null);
+ setEquipment(EnumItemSlot.HEAD, items.length >= 4 ? items[3] : null);
}
- private ItemStack getEquipment(int slot) {
+ private ItemStack getEquipment(EnumItemSlot slot) {
return CraftItemStack.asBukkitCopy(entity.getHandle().getEquipment(slot));
}
- private void setEquipment(int slot, ItemStack stack) {
- entity.getHandle().setEquipment(slot, CraftItemStack.asNMSCopy(stack));
+ private void setEquipment(EnumItemSlot slot, ItemStack stack) {
+ entity.getHandle().setSlot(slot, CraftItemStack.asNMSCopy(stack));
}
public void clear() {
- for(int i = 0; i < INVENTORY_SLOTS; i++) {
- setEquipment(i, null);
+ for (EnumItemSlot slot : EnumItemSlot.values()) {
+ setEquipment(slot, null);
}
}
@@ -95,50 +114,58 @@ public class CraftEntityEquipment implements EntityEquipment {
}
public float getItemInHandDropChance() {
- return getDropChance(WEAPON_SLOT);
+ return getDropChance(EnumItemSlot.MAINHAND);
}
public void setItemInHandDropChance(float chance) {
- setDropChance(WEAPON_SLOT, chance);
+ setDropChance(EnumItemSlot.MAINHAND, chance);
}
public float getHelmetDropChance() {
- return getDropChance(HELMET_SLOT);
+ return getDropChance(EnumItemSlot.HEAD);
}
public void setHelmetDropChance(float chance) {
- setDropChance(HELMET_SLOT, chance);
+ setDropChance(EnumItemSlot.HEAD, chance);
}
public float getChestplateDropChance() {
- return getDropChance(CHEST_SLOT);
+ return getDropChance(EnumItemSlot.CHEST);
}
public void setChestplateDropChance(float chance) {
- setDropChance(CHEST_SLOT, chance);
+ setDropChance(EnumItemSlot.CHEST, chance);
}
public float getLeggingsDropChance() {
- return getDropChance(LEG_SLOT);
+ return getDropChance(EnumItemSlot.LEGS);
}
public void setLeggingsDropChance(float chance) {
- setDropChance(LEG_SLOT, chance);
+ setDropChance(EnumItemSlot.LEGS, chance);
}
public float getBootsDropChance() {
- return getDropChance(BOOT_SLOT);
+ return getDropChance(EnumItemSlot.FEET);
}
public void setBootsDropChance(float chance) {
- setDropChance(BOOT_SLOT, chance);
+ setDropChance(EnumItemSlot.FEET, chance);
}
- private void setDropChance(int slot, float chance) {
- ((EntityInsentient) entity.getHandle()).dropChances[slot] = chance - 0.1F;
+ private void setDropChance(EnumItemSlot slot, float chance) {
+ if (slot == EnumItemSlot.MAINHAND || slot == EnumItemSlot.OFFHAND) {
+ ((EntityInsentient) entity.getHandle()).dropChanceHand[slot.b()] = chance - 0.1F;
+ } else {
+ ((EntityInsentient) entity.getHandle()).dropChanceArmor[slot.b()] = chance - 0.1F;
+ }
}
- private float getDropChance(int slot) {
- return ((EntityInsentient) entity.getHandle()).dropChances[slot] + 0.1F;
+ private float getDropChance(EnumItemSlot slot) {
+ if (slot == EnumItemSlot.MAINHAND || slot == EnumItemSlot.OFFHAND) {
+ return ((EntityInsentient) entity.getHandle()).dropChanceHand[slot.b()] + 0.1F;
+ } else {
+ return ((EntityInsentient) entity.getHandle()).dropChanceArmor[slot.b()] + 0.1F;
+ }
}
}
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftFurnaceRecipe.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftFurnaceRecipe.java
index 69f17db8..ef3b8045 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftFurnaceRecipe.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftFurnaceRecipe.java
@@ -2,7 +2,6 @@ package org.bukkit.craftbukkit.inventory;
import net.minecraft.server.RecipesFurnace;
-import org.bukkit.craftbukkit.util.CraftMagicNumbers;
import org.bukkit.inventory.FurnaceRecipe;
import org.bukkit.inventory.ItemStack;
@@ -22,6 +21,6 @@ public class CraftFurnaceRecipe extends FurnaceRecipe implements CraftRecipe {
public void addToCraftingManager() {
ItemStack result = this.getResult();
ItemStack input = this.getInput();
- RecipesFurnace.getInstance().registerRecipe(CraftItemStack.asNMSCopy(input), CraftItemStack.asNMSCopy(result));
+ RecipesFurnace.getInstance().registerRecipe(CraftItemStack.asNMSCopy(input), CraftItemStack.asNMSCopy(result), getExperience());
}
}
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java
index e9a3c501..91b8e4af 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java
@@ -17,6 +17,7 @@ import net.minecraft.server.TileEntityDropper;
import net.minecraft.server.TileEntityFurnace;
import org.apache.commons.lang.Validate;
+import org.bukkit.Location;
import org.bukkit.entity.HumanEntity;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.Inventory;
@@ -479,4 +480,9 @@ public class CraftInventory implements Inventory {
public boolean equals(final Object obj) {
return obj instanceof CraftInventory && ((CraftInventory) obj).inventory.equals(this.inventory);
}
+
+ @Override
+ public Location getLocation() {
+ return inventory.getLocation();
+ }
}
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryAnvil.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryAnvil.java
index 46a1d387..00f9bb5e 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryAnvil.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryAnvil.java
@@ -1,15 +1,18 @@
package org.bukkit.craftbukkit.inventory;
import net.minecraft.server.IInventory;
+import org.bukkit.Location;
import org.bukkit.inventory.AnvilInventory;
import org.bukkit.inventory.ItemStack;
public class CraftInventoryAnvil extends CraftInventory implements AnvilInventory {
+ private final Location location;
private final IInventory resultInventory;
- public CraftInventoryAnvil(IInventory inventory, IInventory resultInventory) {
+ public CraftInventoryAnvil(Location location, IInventory inventory, IInventory resultInventory) {
super(inventory);
+ this.location = location;
this.resultInventory = resultInventory;
}
@@ -45,4 +48,9 @@ public class CraftInventoryAnvil extends CraftInventory implements AnvilInventor
public int getSize() {
return getResultInventory().getSize() + getIngredientsInventory().getSize();
}
+
+ @Override
+ public Location getLocation() {
+ return location;
+ }
}
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryBrewer.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryBrewer.java
index 6de6e6e6..86c89e86 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryBrewer.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryBrewer.java
@@ -23,4 +23,14 @@ public class CraftInventoryBrewer extends CraftInventory implements BrewerInvent
public BrewingStand getHolder() {
return (BrewingStand) inventory.getOwner();
}
+
+ @Override
+ public ItemStack getFuel() {
+ return getItem(4);
+ }
+
+ @Override
+ public void setFuel(ItemStack fuel) {
+ setItem(4, fuel);
+ }
}
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCrafting.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCrafting.java
index e155329e..e085351f 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCrafting.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCrafting.java
@@ -55,7 +55,7 @@ public class CraftInventoryCrafting extends CraftInventory implements CraftingIn
for (int j = 0; j < mcItems.length; j++) {
items[i + j] = CraftItemStack.asCraftMirror(mcItems[j]);
}
-
+
return items;
}
@@ -85,10 +85,10 @@ public class CraftInventoryCrafting extends CraftInventory implements CraftingIn
}
public ItemStack[] getMatrix() {
- ItemStack[] items = new ItemStack[getSize()];
net.minecraft.server.ItemStack[] matrix = getMatrixInventory().getContents();
+ ItemStack[] items = new ItemStack[matrix.length];
- for (int i = 0; i < matrix.length; i++ ) {
+ for (int i = 0; i < matrix.length; i++) {
items[i] = CraftItemStack.asCraftMirror(matrix[i]);
}
@@ -108,16 +108,16 @@ public class CraftInventoryCrafting extends CraftInventory implements CraftingIn
net.minecraft.server.ItemStack[] mcItems = getMatrixInventory().getContents();
- for (int i = 0; i < mcItems.length; i++ ) {
+ for (int i = 0; i < mcItems.length; i++) {
if (i < contents.length) {
ItemStack item = contents[i];
if (item == null || item.getTypeId() <= 0) {
- mcItems[i] = null;
+ getMatrixInventory().setItem(i, null);
} else {
- mcItems[i] = CraftItemStack.asNMSCopy(item);
+ getMatrixInventory().setItem(i, CraftItemStack.asNMSCopy(item));
}
} else {
- mcItems[i] = null;
+ getMatrixInventory().setItem(i, null);
}
}
}
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java
index e99b8cca..2b396782 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java
@@ -14,6 +14,7 @@ import org.bukkit.inventory.InventoryHolder;
import net.minecraft.server.EntityHuman;
import net.minecraft.server.IInventory;
import net.minecraft.server.ItemStack;
+import org.bukkit.Location;
public class CraftInventoryCustom extends CraftInventory {
public CraftInventoryCustom(InventoryHolder owner, InventoryType type) {
@@ -165,8 +166,7 @@ public class CraftInventoryCustom extends CraftInventory {
}
@Override
- public void b(int i, int i1) {
-
+ public void setProperty(int i, int j) {
}
@Override
@@ -193,5 +193,10 @@ public class CraftInventoryCustom extends CraftInventory {
public IChatBaseComponent getScoreboardDisplayName() {
return new ChatComponentText(title);
}
+
+ @Override
+ public Location getLocation() {
+ return null;
+ }
}
}
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryMerchant.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryMerchant.java
index 7f89c2ad..9051d75c 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryMerchant.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryMerchant.java
@@ -2,9 +2,26 @@ package org.bukkit.craftbukkit.inventory;
import net.minecraft.server.InventoryMerchant;
import org.bukkit.inventory.MerchantInventory;
+import org.bukkit.inventory.MerchantRecipe;
public class CraftInventoryMerchant extends CraftInventory implements MerchantInventory {
+
public CraftInventoryMerchant(InventoryMerchant merchant) {
super(merchant);
}
+
+ @Override
+ public int getSelectedRecipeIndex() {
+ return getInventory().e;
+ }
+
+ @Override
+ public MerchantRecipe getSelectedRecipe() {
+ return getInventory().getRecipe().asBukkit();
+ }
+
+ @Override
+ public InventoryMerchant getInventory() {
+ return (InventoryMerchant) inventory;
+ }
}
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryPlayer.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryPlayer.java
index dba8d5ba..a7a6d948 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryPlayer.java
@@ -22,16 +22,33 @@ public class CraftInventoryPlayer extends CraftInventory implements org.bukkit.i
}
@Override
- public int getSize() {
- return super.getSize() - 4;
+ public ItemStack getItemInMainHand() {
+ return CraftItemStack.asCraftMirror(getInventory().getItemInHand());
+ }
+
+ @Override
+ public void setItemInMainHand(ItemStack item) {
+ setItem(getHeldItemSlot(), item);
+ }
+
+ @Override
+ public ItemStack getItemInOffHand() {
+ return CraftItemStack.asCraftMirror(getInventory().extraSlots[0]);
}
+ @Override
+ public void setItemInOffHand(ItemStack item) {
+ getInventory().extraSlots[0] = CraftItemStack.asNMSCopy(item);
+ }
+
+ @Override
public ItemStack getItemInHand() {
- return CraftItemStack.asCraftMirror(getInventory().getItemInHand());
+ return getItemInMainHand();
}
+ @Override
public void setItemInHand(ItemStack stack) {
- setItem(getHeldItemSlot(), stack);
+ setItemInMainHand(stack);
}
@Override
@@ -86,35 +103,35 @@ public class CraftInventoryPlayer extends CraftInventory implements org.bukkit.i
}
public ItemStack getHelmet() {
- return getItem(getSize() + 3);
+ return getItem(getSize() - 2);
}
public ItemStack getChestplate() {
- return getItem(getSize() + 2);
+ return getItem(getSize() - 3);
}
public ItemStack getLeggings() {
- return getItem(getSize() + 1);
+ return getItem(getSize() - 4);
}
public ItemStack getBoots() {
- return getItem(getSize() + 0);
+ return getItem(getSize() - 5);
}
public void setHelmet(ItemStack helmet) {
- setItem(getSize() + 3, helmet);
+ setItem(getSize() - 2, helmet);
}
public void setChestplate(ItemStack chestplate) {
- setItem(getSize() + 2, chestplate);
+ setItem(getSize() - 3, chestplate);
}
public void setLeggings(ItemStack leggings) {
- setItem(getSize() + 1, leggings);
+ setItem(getSize() - 4, leggings);
}
public void setBoots(ItemStack boots) {
- setItem(getSize() + 0, boots);
+ setItem(getSize() - 5, boots);
}
public ItemStack[] getArmorContents() {
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java
index 5404ee91..82f20455 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java
@@ -21,11 +21,14 @@ public final class CraftItemFactory implements ItemFactory {
instance = new CraftItemFactory();
ConfigurationSerialization.registerClass(CraftMetaItem.SerializableMeta.class);
KNOWN_NBT_ATTRIBUTE_NAMES = ImmutableSet.<String>builder()
+ .add("generic.armor")
.add("generic.attackDamage")
.add("generic.followRange")
.add("generic.knockbackResistance")
.add("generic.maxHealth")
.add("generic.movementSpeed")
+ .add("generic.attackSpeed")
+ .add("generic.luck")
.add("horse.jumpStrength")
.add("zombie.spawnReinforcements")
.build();
@@ -103,6 +106,7 @@ public final class CraftItemFactory implements ItemFactory {
case HOPPER:
case REDSTONE_COMPARATOR:
case FLOWER_POT_ITEM:
+ case SHIELD:
return new CraftMetaBlockState(meta, material);
default:
return new CraftMetaItem(meta);
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
index 23f05f4d..8bb128e6 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
@@ -23,6 +23,7 @@ import com.google.common.collect.ImmutableMap;
import net.minecraft.server.IChatBaseComponent.ChatSerializer;
import net.minecraft.server.Items;
import net.minecraft.server.NBTTagString;
+import org.bukkit.craftbukkit.enchantments.CraftEnchantment;
import org.bukkit.craftbukkit.util.CraftChatMessage;
@DelegateDeserialization(ItemStack.class)
@@ -230,7 +231,7 @@ public final class CraftItemStack extends ItemStack {
if (handle == null) {
return 0;
}
- return EnchantmentManager.getEnchantmentLevel(ench.getId(), handle);
+ return EnchantmentManager.getEnchantmentLevel(CraftEnchantment.getRaw(ench), handle);
}
@Override
@@ -367,6 +368,7 @@ public final class CraftItemStack extends ItemStack {
case HOPPER:
case REDSTONE_COMPARATOR:
case FLOWER_POT_ITEM:
+ case SHIELD:
return new CraftMetaBlockState(item.getTag(), CraftMagicNumbers.getMaterial(item.getItem()));
default:
return new CraftMetaItem(item.getTag());
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantRecipe.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantRecipe.java
new file mode 100644
index 00000000..964f7080
--- /dev/null
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantRecipe.java
@@ -0,0 +1,79 @@
+package org.bukkit.craftbukkit.inventory;
+
+import com.google.common.base.Preconditions;
+import java.util.List;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.inventory.MerchantRecipe;
+
+public class CraftMerchantRecipe extends MerchantRecipe {
+
+ private final net.minecraft.server.MerchantRecipe handle;
+
+ public CraftMerchantRecipe(net.minecraft.server.MerchantRecipe merchantRecipe) {
+ super(null, 0);
+ this.handle = merchantRecipe;
+ }
+
+ public CraftMerchantRecipe(ItemStack result, int uses, int maxUses, boolean experienceReward) {
+ super(result, uses, maxUses, experienceReward);
+ this.handle = new net.minecraft.server.MerchantRecipe(
+ CraftItemStack.asNMSCopy(result),
+ null,
+ null,
+ uses,
+ maxUses,
+ this
+ );
+ }
+
+ @Override
+ public int getUses() {
+ return handle.uses;
+ }
+
+ @Override
+ public void setUses(int uses) {
+ handle.uses = uses;
+ }
+
+ @Override
+ public int getMaxUses() {
+ return handle.maxUses;
+ }
+
+ @Override
+ public void setMaxUses(int maxUses) {
+ handle.maxUses = maxUses;
+ }
+
+ @Override
+ public boolean hasExperienceReward() {
+ return handle.rewardExp;
+ }
+
+ @Override
+ public void setExperienceReward(boolean flag) {
+ handle.rewardExp = flag;
+ }
+
+ public net.minecraft.server.MerchantRecipe toMinecraft() {
+ List<ItemStack> ingredients = getIngredients();
+ Preconditions.checkState(!ingredients.isEmpty(), "No offered ingredients");
+ handle.buyingItem1 = CraftItemStack.asNMSCopy(ingredients.get(0));
+ if (ingredients.size() > 1) {
+ handle.buyingItem2 = CraftItemStack.asNMSCopy(ingredients.get(1));
+ }
+ return handle;
+ }
+
+ public static CraftMerchantRecipe fromBukkit(MerchantRecipe recipe) {
+ if (recipe instanceof CraftMerchantRecipe) {
+ return (CraftMerchantRecipe) recipe;
+ } else {
+ CraftMerchantRecipe craft = new CraftMerchantRecipe(recipe.getResult(), recipe.getUses(), recipe.getMaxUses(), recipe.hasExperienceReward());
+ craft.setIngredients(recipe.getIngredients());
+
+ return craft;
+ }
+ }
+}
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java
index d60686d6..4f1415b7 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java
@@ -4,6 +4,7 @@ import com.google.common.base.Objects;
import com.google.common.collect.ImmutableMap;
import java.util.Map;
import net.minecraft.server.BlockJukeBox;
+import net.minecraft.server.MinecraftServer;
import net.minecraft.server.NBTBase;
import net.minecraft.server.NBTTagCompound;
import net.minecraft.server.TileEntity;
@@ -55,9 +56,7 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta
this.material = material;
if (!(meta instanceof CraftMetaBlockState)
- || ((CraftMetaBlockState) meta).material != material
- || material == Material.SIGN
- || material == Material.COMMAND) {
+ || ((CraftMetaBlockState) meta).material != material) {
blockEntityTag = null;
return;
}
@@ -153,7 +152,7 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta
@Override
boolean applicableTo(Material type) {
- switch(type){
+ switch(type){
case FURNACE:
case CHEST:
case TRAPPED_CHEST:
@@ -173,6 +172,7 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta
case HOPPER:
case REDSTONE_COMPARATOR:
case FLOWER_POT_ITEM:
+ case SHIELD:
return true;
}
return false;
@@ -185,7 +185,7 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta
@Override
public BlockState getBlockState() {
- TileEntity te = blockEntityTag == null ? null : TileEntity.c(blockEntityTag);
+ TileEntity te = blockEntityTag == null ? null : TileEntity.a(MinecraftServer.getServer(), blockEntityTag);
switch (material) {
case SIGN:
@@ -257,6 +257,7 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta
te = new TileEntityBeacon();
}
return new CraftBeacon(material, (TileEntityBeacon) te);
+ case SHIELD:
case BANNER:
case WALL_BANNER:
case STANDING_BANNER:
@@ -320,6 +321,7 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta
case BEACON:
valid = te instanceof TileEntityBeacon;
break;
+ case SHIELD:
case BANNER:
case WALL_BANNER:
case STANDING_BANNER:
@@ -333,6 +335,6 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta
Validate.isTrue(valid, "Invalid blockState for " + material);
blockEntityTag = new NBTTagCompound();
- te.b(blockEntityTag);
+ te.save(blockEntityTag);
}
}
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/InventoryWrapper.java b/src/main/java/org/bukkit/craftbukkit/inventory/InventoryWrapper.java
index 5e449667..125f7e1a 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/InventoryWrapper.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/InventoryWrapper.java
@@ -6,6 +6,7 @@ import net.minecraft.server.EntityHuman;
import net.minecraft.server.IChatBaseComponent;
import net.minecraft.server.IInventory;
import net.minecraft.server.ItemStack;
+import org.bukkit.Location;
import org.bukkit.craftbukkit.entity.CraftHumanEntity;
import org.bukkit.craftbukkit.util.CraftChatMessage;
import org.bukkit.entity.HumanEntity;
@@ -106,7 +107,7 @@ public class InventoryWrapper implements IInventory {
}
@Override
- public void b(int i, int j) {
+ public void setProperty(int i, int j) {
}
@Override
@@ -170,4 +171,9 @@ public class InventoryWrapper implements IInventory {
public IChatBaseComponent getScoreboardDisplayName() {
return CraftChatMessage.fromString(getName())[0];
}
+
+ @Override
+ public Location getLocation() {
+ return inventory.getLocation();
+ }
}
diff --git a/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionBrewer.java b/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionBrewer.java
index bb16958a..5305f9ad 100644
--- a/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionBrewer.java
+++ b/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionBrewer.java
@@ -5,8 +5,13 @@ import java.util.Collection;
import java.util.List;
import java.util.Map;
+import net.minecraft.server.ItemStack;
+import net.minecraft.server.Items;
import net.minecraft.server.MobEffect;
+import net.minecraft.server.MobEffectList;
+import net.minecraft.server.PotionUtil;
+import org.bukkit.Color;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.potion.PotionBrewer;
import org.bukkit.potion.PotionEffect;
@@ -20,7 +25,7 @@ public class CraftPotionBrewer implements PotionBrewer {
if (cache.containsKey(damage))
return cache.get(damage);
- List<?> mcEffects = net.minecraft.server.PotionBrewer.getEffects(damage, false);
+ List<?> mcEffects = PotionUtil.getEffects(new ItemStack(Items.POTION, 1, damage));
List<PotionEffect> effects = new ArrayList<PotionEffect>();
if (mcEffects == null)
return effects;
@@ -29,8 +34,8 @@ public class CraftPotionBrewer implements PotionBrewer {
if (raw == null || !(raw instanceof MobEffect))
continue;
MobEffect mcEffect = (MobEffect) raw;
- PotionEffect effect = new PotionEffect(PotionEffectType.getById(mcEffect.getEffectId()),
- mcEffect.getDuration(), mcEffect.getAmplifier());
+ PotionEffect effect = new PotionEffect(PotionEffectType.getById(MobEffectList.getId(mcEffect.getMobEffect())),
+ mcEffect.getDuration(), mcEffect.getAmplifier(), true, true, Color.fromRGB(mcEffect.getMobEffect().getColor()));
// Minecraft PotionBrewer applies duration modifiers automatically.
effects.add(effect);
}
diff --git a/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionEffectType.java b/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionEffectType.java
index b59d142a..8ce39c6d 100644
--- a/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionEffectType.java
+++ b/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionEffectType.java
@@ -8,13 +8,13 @@ public class CraftPotionEffectType extends PotionEffectType {
private final MobEffectList handle;
public CraftPotionEffectType(MobEffectList handle) {
- super(handle.id);
+ super(MobEffectList.getId(handle));
this.handle = handle;
}
@Override
public double getDurationModifier() {
- return handle.getDurationModifier();
+ return handle.durationModifier;
}
public MobEffectList getHandle() {
@@ -23,7 +23,7 @@ public class CraftPotionEffectType extends PotionEffectType {
@Override
public String getName() {
- switch (handle.id) {
+ switch (getId()) {
case 1:
return "SPEED";
case 2:
@@ -70,8 +70,16 @@ public class CraftPotionEffectType extends PotionEffectType {
return "ABSORPTION";
case 23:
return "SATURATION";
+ case 24:
+ return "GLOWING";
+ case 25:
+ return "LEVITATION";
+ case 26:
+ return "LUCK";
+ case 27:
+ return "UNLUCK";
default:
- return "UNKNOWN_EFFECT_TYPE_" + handle.id;
+ return "UNKNOWN_EFFECT_TYPE_" + getId();
}
}
diff --git a/src/main/java/org/bukkit/craftbukkit/projectiles/CraftBlockProjectileSource.java b/src/main/java/org/bukkit/craftbukkit/projectiles/CraftBlockProjectileSource.java
index b8bf7541..6c3c1eae 100644
--- a/src/main/java/org/bukkit/craftbukkit/projectiles/CraftBlockProjectileSource.java
+++ b/src/main/java/org/bukkit/craftbukkit/projectiles/CraftBlockProjectileSource.java
@@ -31,6 +31,7 @@ import net.minecraft.server.EntityProjectile;
import net.minecraft.server.EntitySmallFireball;
import net.minecraft.server.EntitySnowball;
import net.minecraft.server.EntityThrownExpBottle;
+import net.minecraft.server.EntityTippedArrow;
import net.minecraft.server.EntityWitherSkull;
import net.minecraft.server.EnumDirection;
import net.minecraft.server.IPosition;
@@ -63,7 +64,7 @@ public class CraftBlockProjectileSource implements BlockProjectileSource {
SourceBlock isourceblock = new SourceBlock(dispenserBlock.getWorld(), dispenserBlock.getPosition());
// Copied from DispenseBehaviorProjectile
IPosition iposition = BlockDispenser.a(isourceblock);
- EnumDirection enumdirection = BlockDispenser.b(isourceblock.f());
+ EnumDirection enumdirection = BlockDispenser.e(isourceblock.f());
net.minecraft.server.World world = dispenserBlock.getWorld();
net.minecraft.server.Entity launch = null;
@@ -79,8 +80,8 @@ public class CraftBlockProjectileSource implements BlockProjectileSource {
} else if (ThrownPotion.class.isAssignableFrom(projectile)) {
launch = new EntityPotion(world, iposition.getX(), iposition.getY(), iposition.getZ(), CraftItemStack.asNMSCopy(new ItemStack(Material.POTION, 1)));
} else if (Arrow.class.isAssignableFrom(projectile)) {
- launch = new EntityArrow(world, iposition.getX(), iposition.getY(), iposition.getZ());
- ((EntityArrow) launch).fromPlayer = 1;
+ launch = new EntityTippedArrow(world, iposition.getX(), iposition.getY(), iposition.getZ());
+ ((EntityArrow) launch).fromPlayer = EntityArrow.PickupStatus.ALLOWED;
((EntityArrow) launch).projectileSource = this;
} else if (Fireball.class.isAssignableFrom(projectile)) {
double d0 = iposition.getX() + (double) ((float) enumdirection.getAdjacentX() * 0.3F);
@@ -92,7 +93,7 @@ public class CraftBlockProjectileSource implements BlockProjectileSource {
double d5 = random.nextGaussian() * 0.05D + (double) enumdirection.getAdjacentZ();
if (SmallFireball.class.isAssignableFrom(projectile)) {
- launch = new EntitySmallFireball(world, d0, d1, d2, d3, d4, d5);
+ launch = new EntitySmallFireball(world, null, d0, d1, d2);
} else if (WitherSkull.class.isAssignableFrom(projectile)) {
launch = new EntityWitherSkull(world);
launch.setPosition(d0, d1, d2);
diff --git a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardManager.java b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardManager.java
index 197086e3..db4c1db1 100644
--- a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardManager.java
+++ b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardManager.java
@@ -112,7 +112,7 @@ public final class CraftScoreboardManager implements ScoreboardManager {
// CraftBukkit method
public void updateAllScoresForList(IScoreboardCriteria criteria, String name, List<EntityPlayer> of) {
for (ScoreboardScore score : getScoreboardScores(criteria, name, new ArrayList<ScoreboardScore>())) {
- score.updateForList((List) of);
+ // PAIL: FIXME score.updateForList((List) of);
}
}
}
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
index 589dba72..492c4b55 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
@@ -82,6 +82,9 @@ public final class CraftMagicNumbers implements UnsafeValues {
}
public static Block getBlock(Material material) {
+ if (material == null) {
+ return null;
+ }
// TODO: Don't use ID
Block block = Block.getById(material.getId());
diff --git a/src/main/java/org/bukkit/craftbukkit/util/LazyHashSet.java b/src/main/java/org/bukkit/craftbukkit/util/LazyHashSet.java
index ad83fd87..dc76c616 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/LazyHashSet.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/LazyHashSet.java
@@ -4,7 +4,6 @@ import java.util.Collection;
import java.util.Iterator;
import java.util.Set;
-
public abstract class LazyHashSet<E> implements Set<E> {
Set<E> reference = null;
diff --git a/src/main/java/org/bukkit/craftbukkit/util/LazyPlayerSet.java b/src/main/java/org/bukkit/craftbukkit/util/LazyPlayerSet.java
index ae19da4d..457d19e9 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/LazyPlayerSet.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/LazyPlayerSet.java
@@ -9,17 +9,22 @@ import org.bukkit.entity.Player;
public class LazyPlayerSet extends LazyHashSet<Player> {
+ private final MinecraftServer server;
+
+ public LazyPlayerSet(MinecraftServer server) {
+ this.server = server;
+ }
+
@Override
HashSet<Player> makeReference() {
if (reference != null) {
throw new IllegalStateException("Reference already created!");
}
- List<EntityPlayer> players = MinecraftServer.getServer().getPlayerList().players;
+ List<EntityPlayer> players = server.getPlayerList().players;
HashSet<Player> reference = new HashSet<Player>(players.size());
for (EntityPlayer player : players) {
reference.add(player.getBukkitEntity());
}
return reference;
}
-
}
diff --git a/src/main/resources/log4j2.xml b/src/main/resources/log4j2.xml
index 36eff853..08d68aa8 100644
--- a/src/main/resources/log4j2.xml
+++ b/src/main/resources/log4j2.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<Configuration status="WARN" packages="net.minecraft,com.mojang">
+<Configuration status="WARN" packages="com.mojang.util">
<Appenders>
<Console name="WINDOWS_COMPAT" target="SYSTEM_OUT"></Console>
<Queue name="TerminalConsole">
diff --git a/src/test/java/org/bukkit/BiomeTest.java b/src/test/java/org/bukkit/BiomeTest.java
new file mode 100644
index 00000000..8c6d40ae
--- /dev/null
+++ b/src/test/java/org/bukkit/BiomeTest.java
@@ -0,0 +1,24 @@
+package org.bukkit;
+
+import net.minecraft.server.BiomeBase;
+import org.bukkit.block.Biome;
+import org.bukkit.craftbukkit.block.CraftBlock;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class BiomeTest {
+
+ @Test
+ public void testBukkitToMinecraft() {
+ for (Biome biome : Biome.values()) {
+ Assert.assertNotNull("No NMS mapping for " + biome, CraftBlock.biomeToBiomeBase(biome));
+ }
+ }
+
+ @Test
+ public void testMinecraftToBukkit() {
+ for (BiomeBase biome : BiomeBase.REGISTRY_ID) {
+ Assert.assertNotNull("No Bukkit mapping for " + biome, CraftBlock.biomeBaseToBiome(biome));
+ }
+ }
+}
diff --git a/src/test/java/org/bukkit/ParticleTest.java b/src/test/java/org/bukkit/ParticleTest.java
new file mode 100644
index 00000000..c00869ba
--- /dev/null
+++ b/src/test/java/org/bukkit/ParticleTest.java
@@ -0,0 +1,19 @@
+package org.bukkit;
+
+import net.minecraft.server.EnumParticle;
+import org.bukkit.craftbukkit.CraftParticle;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class ParticleTest {
+
+ @Test
+ public void verifyMapping() {
+ for (Particle bukkit : Particle.values()) {
+ Assert.assertNotNull("Missing Bukkit->NMS particle mapping", CraftParticle.toNMS(bukkit));
+ }
+ for (EnumParticle nms : EnumParticle.values()) {
+ Assert.assertNotNull("Missing NMS->Bukkit particle mapping", CraftParticle.toBukkit(nms));
+ }
+ }
+}
diff --git a/src/test/java/org/bukkit/PerMaterialTest.java b/src/test/java/org/bukkit/PerMaterialTest.java
index 2cbf4ecb..b727d1d4 100644
--- a/src/test/java/org/bukkit/PerMaterialTest.java
+++ b/src/test/java/org/bukkit/PerMaterialTest.java
@@ -53,7 +53,7 @@ public class PerMaterialTest extends AbstractTestingBase {
if (material == Material.AIR) {
assertFalse(material.isSolid());
} else if (material.isBlock()) {
- assertThat(material.isSolid(), is(CraftMagicNumbers.getBlock(material).getMaterial().isSolid()));
+ assertThat(material.isSolid(), is(CraftMagicNumbers.getBlock(material).getBlockData().getMaterial().isSolid()));
} else {
assertFalse(material.isSolid());
}
@@ -104,7 +104,7 @@ public class PerMaterialTest extends AbstractTestingBase {
if (material == Material.AIR) {
assertTrue(material.isTransparent());
} else if (material.isBlock()) {
- assertThat(material.isTransparent(), is(not(CraftMagicNumbers.getBlock(material).getMaterial().blocksLight())));
+ assertThat(material.isTransparent(), is(not(CraftMagicNumbers.getBlock(material).getBlockData().getMaterial().blocksLight())));
} else {
assertFalse(material.isTransparent());
}
@@ -113,7 +113,7 @@ public class PerMaterialTest extends AbstractTestingBase {
@Test
public void isFlammable() {
if (material != Material.AIR && material.isBlock()) {
- assertThat(material.isFlammable(), is(CraftMagicNumbers.getBlock(material).getMaterial().isBurnable()));
+ assertThat(material.isFlammable(), is(CraftMagicNumbers.getBlock(material).getBlockData().getMaterial().isBurnable()));
} else {
assertFalse(material.isFlammable());
}
@@ -132,7 +132,7 @@ public class PerMaterialTest extends AbstractTestingBase {
@Test
public void isOccluding() {
if (material.isBlock()) {
- assertThat(material.isOccluding(), is(CraftMagicNumbers.getBlock(material).isOccluding()));
+ assertThat(material.isOccluding(), is(CraftMagicNumbers.getBlock(material).isOccluding(CraftMagicNumbers.getBlock(material).getBlockData())));
} else {
assertFalse(material.isOccluding());
}
diff --git a/src/test/java/org/bukkit/SoundTest.java b/src/test/java/org/bukkit/SoundTest.java
index c9865fa0..2b00b4bf 100644
--- a/src/test/java/org/bukkit/SoundTest.java
+++ b/src/test/java/org/bukkit/SoundTest.java
@@ -1,12 +1,14 @@
package org.bukkit;
+import net.minecraft.server.MinecraftKey;
+import net.minecraft.server.SoundEffect;
+
import static org.junit.Assert.*;
import static org.hamcrest.Matchers.*;
import org.bukkit.craftbukkit.CraftSound;
import org.junit.Test;
-
public class SoundTest {
@Test
@@ -15,4 +17,11 @@ public class SoundTest {
assertThat(sound.name(), CraftSound.getSound(sound), is(not(nullValue())));
}
}
+
+ @Test
+ public void testReverse() {
+ for (MinecraftKey effect : SoundEffect.a.keySet()) {
+ assertNotNull(effect + "", Sound.valueOf(effect.a().replace('.', '_').toUpperCase()));
+ }
+ }
}
diff --git a/src/test/java/org/bukkit/craftbukkit/inventory/NMSCraftItemStackTest.java b/src/test/java/org/bukkit/craftbukkit/inventory/NMSCraftItemStackTest.java
index a1838437..1f5a6a32 100644
--- a/src/test/java/org/bukkit/craftbukkit/inventory/NMSCraftItemStackTest.java
+++ b/src/test/java/org/bukkit/craftbukkit/inventory/NMSCraftItemStackTest.java
@@ -3,7 +3,7 @@ package org.bukkit.craftbukkit.inventory;
import static org.junit.Assert.*;
import static org.hamcrest.Matchers.*;
-import net.minecraft.server.Enchantment;
+import net.minecraft.server.Enchantments;
import org.bukkit.inventory.ItemStack;
import org.bukkit.support.AbstractTestingBase;
@@ -14,7 +14,7 @@ public class NMSCraftItemStackTest extends AbstractTestingBase {
@Test
public void testCloneEnchantedItem() throws Exception {
net.minecraft.server.ItemStack nmsItemStack = new net.minecraft.server.ItemStack(net.minecraft.server.Items.POTION);
- nmsItemStack.addEnchantment(Enchantment.DAMAGE_ALL, 1);
+ nmsItemStack.addEnchantment(Enchantments.DAMAGE_ALL, 1);
ItemStack itemStack = CraftItemStack.asCraftMirror(nmsItemStack);
ItemStack clone = itemStack.clone();
assertThat(clone.getType(), is(itemStack.getType()));
diff --git a/src/test/java/org/bukkit/potion/PotionTest.java b/src/test/java/org/bukkit/potion/PotionTest.java
index a9df7d19..691c3e50 100644
--- a/src/test/java/org/bukkit/potion/PotionTest.java
+++ b/src/test/java/org/bukkit/potion/PotionTest.java
@@ -4,10 +4,13 @@ import static org.junit.Assert.*;
import static org.hamcrest.Matchers.*;
import java.util.EnumMap;
+import java.util.List;
import java.util.Map;
+import net.minecraft.server.MobEffect;
+import net.minecraft.server.MobEffectList;
+import net.minecraft.server.PotionRegistry;
import org.bukkit.support.AbstractTestingBase;
-import org.bukkit.support.Util;
import org.junit.Test;
public class PotionTest extends AbstractTestingBase {
@@ -26,20 +29,20 @@ public class PotionTest extends AbstractTestingBase {
@Test
public void testEffectCompleteness() throws Throwable {
- Map<Integer, ?> effectDurations = Util.getInternalState(net.minecraft.server.PotionBrewer.class, null, "effectDurations");
-
Map<PotionType, String> effects = new EnumMap(PotionType.class);
- for (int id : effectDurations.keySet()) {
+ for (PotionRegistry reg : PotionRegistry.a) {
+ List<MobEffect> eff = reg.a();
+ if (eff.size() != 1) continue;
+ int id = MobEffectList.getId(eff.get(0).getMobEffect());
PotionEffectType type = PotionEffectType.getById(id);
assertNotNull(String.valueOf(id), PotionEffectType.getById(id));
PotionType enumType = PotionType.getByEffect(type);
assertNotNull(type.getName(), enumType);
- assertThat(enumType.name(), effects.put(enumType, enumType.name()), is(nullValue()));
+ effects.put(enumType, enumType.name());
}
- assertThat(effects.entrySet(), hasSize(effectDurations.size()));
- assertThat(effectDurations.entrySet(), hasSize(PotionType.values().length - /* WATER */ 1));
+ assertEquals(effects.entrySet().size(), PotionType.values().length - /* WATER */ 1);
}
}
diff --git a/src/test/java/org/bukkit/support/AbstractTestingBase.java b/src/test/java/org/bukkit/support/AbstractTestingBase.java
index 3a362b75..37869feb 100644
--- a/src/test/java/org/bukkit/support/AbstractTestingBase.java
+++ b/src/test/java/org/bukkit/support/AbstractTestingBase.java
@@ -64,7 +64,12 @@ public abstract class AbstractTestingBase {
Material.BIRCH_DOOR,
Material.JUNGLE_DOOR,
Material.ACACIA_DOOR,
- Material.DARK_OAK_DOOR
+ Material.DARK_OAK_DOOR,
+ Material.PURPUR_DOUBLE_SLAB,
+ Material.BEETROOT_BLOCK,
+ Material.END_GATEWAY,
+ Material.STRUCTURE_BLOCK,
+ Material.BURNING_FURNACE
).build();
@BeforeClass
diff --git a/src/test/java/org/bukkit/support/DummyEnchantments.java b/src/test/java/org/bukkit/support/DummyEnchantments.java
index ac34a438..f3cc27e7 100644
--- a/src/test/java/org/bukkit/support/DummyEnchantments.java
+++ b/src/test/java/org/bukkit/support/DummyEnchantments.java
@@ -1,10 +1,10 @@
package org.bukkit.support;
-import net.minecraft.server.Enchantment;
+import net.minecraft.server.Enchantments;
public class DummyEnchantments {
static {
- Enchantment.getEffects();
+ Enchantments.DAMAGE_ALL.getClass();
org.bukkit.enchantments.Enchantment.stopAcceptingRegistrations();
}
diff --git a/src/test/java/org/bukkit/support/DummyPotions.java b/src/test/java/org/bukkit/support/DummyPotions.java
index 30666abd..9c5cdec2 100644
--- a/src/test/java/org/bukkit/support/DummyPotions.java
+++ b/src/test/java/org/bukkit/support/DummyPotions.java
@@ -1,6 +1,6 @@
package org.bukkit.support;
-import net.minecraft.server.MobEffectList;
+import net.minecraft.server.MobEffects;
import org.bukkit.craftbukkit.potion.CraftPotionBrewer;
import org.bukkit.potion.Potion;
@@ -9,7 +9,7 @@ import org.bukkit.potion.PotionEffectType;
public class DummyPotions {
static {
Potion.setPotionBrewer(new CraftPotionBrewer());
- MobEffectList.BLINDNESS.getClass();
+ MobEffects.BLINDNESS.getClass();
PotionEffectType.stopAcceptingRegistrations();
}