From a2d787f6ebeb72fa7d5750788221fb9a0d838ac4 Mon Sep 17 00:00:00 2001 From: md_5 Date: Tue, 23 Apr 2019 12:00:00 +1000 Subject: [PATCH] Update to Minecraft 1.14-pre5 --- nms-patches/Advancement.patch | 2 +- nms-patches/AdvancementDataPlayer.patch | 4 +- nms-patches/ArgumentBlock.patch | 4 +- nms-patches/ArgumentEntity.patch | 4 +- nms-patches/ArgumentParserSelector.patch | 26 +- nms-patches/AttributeRanged.patch | 4 +- nms-patches/BehaviorFarm.patch | 68 ++ nms-patches/BehaviorInteractDoor.patch | 33 + nms-patches/BehaviorMakeLove.patch | 31 + nms-patches/Block.patch | 33 +- nms-patches/BlockBeacon.patch | 19 - nms-patches/BlockBed.patch | 36 +- nms-patches/BlockButtonAbstract.patch | 18 +- nms-patches/BlockCactus.patch | 10 +- nms-patches/BlockCake.patch | 2 +- nms-patches/BlockCauldron.patch | 28 +- nms-patches/BlockChorusFlower.patch | 10 +- nms-patches/BlockCocoa.patch | 10 +- nms-patches/BlockCommand.patch | 16 +- nms-patches/BlockComposter.patch | 55 ++ nms-patches/BlockConcretePowder.patch | 16 +- nms-patches/BlockCoral.patch | 6 +- nms-patches/BlockCoralFan.patch | 6 +- nms-patches/BlockCoralFanWall.patch | 6 +- nms-patches/BlockCoralPlant.patch | 6 +- nms-patches/BlockCrops.patch | 6 +- nms-patches/BlockDaylightDetector.patch | 2 +- nms-patches/BlockDiodeAbstract.patch | 4 +- nms-patches/BlockDirtSnowSpreadable.patch | 18 +- nms-patches/BlockDispenser.patch | 4 +- nms-patches/BlockDoor.patch | 16 +- nms-patches/BlockDragonEgg.patch | 4 +- nms-patches/BlockDropper.patch | 2 +- nms-patches/BlockEnderPortal.patch | 13 +- nms-patches/BlockFire.patch | 59 +- nms-patches/BlockFluids.patch | 6 +- nms-patches/BlockGrass.patch | 2 +- nms-patches/BlockIce.patch | 6 +- nms-patches/BlockJukeBox.patch | 2 +- nms-patches/BlockKelp.patch | 2 +- nms-patches/BlockLeaves.patch | 16 +- nms-patches/BlockLever.patch | 6 +- nms-patches/BlockMagma.patch | 4 +- nms-patches/BlockMinecartDetector.patch | 4 +- nms-patches/BlockMobSpawner.patch | 20 +- nms-patches/BlockMonsterEggs.patch | 8 +- nms-patches/BlockMushroom.patch | 8 +- nms-patches/BlockNetherWart.patch | 4 +- nms-patches/BlockNote.patch | 16 +- nms-patches/BlockObserver.patch | 8 +- nms-patches/BlockOre.patch | 45 +- nms-patches/BlockPiston.patch | 6 +- nms-patches/BlockPlant.patch | 6 +- nms-patches/BlockPortal.patch | 34 +- nms-patches/BlockPoweredRail.patch | 4 +- nms-patches/BlockPressurePlateAbstract.patch | 2 +- nms-patches/BlockPressurePlateBinary.patch | 4 +- nms-patches/BlockPressurePlateWeighted.patch | 6 +- nms-patches/BlockPumpkinCarved.patch | 44 +- nms-patches/BlockRedstoneComparator.patch | 4 +- nms-patches/BlockRedstoneLamp.patch | 8 +- nms-patches/BlockRedstoneOre.patch | 48 +- nms-patches/BlockRedstoneTorch.patch | 10 +- nms-patches/BlockRedstoneWire.patch | 16 +- nms-patches/BlockReed.patch | 2 +- nms-patches/BlockSapling.patch | 8 +- nms-patches/BlockShulkerBox.patch | 54 -- nms-patches/BlockSkullAbstract.patch | 45 -- nms-patches/BlockSnow.patch | 10 +- nms-patches/BlockSnowBlock.patch | 14 - nms-patches/BlockSoil.patch | 15 +- nms-patches/BlockSponge.patch | 21 +- nms-patches/BlockStem.patch | 10 +- nms-patches/BlockSweetBerryBush.patch | 32 + nms-patches/BlockTNT.patch | 6 +- nms-patches/BlockTallPlant.patch | 8 +- nms-patches/BlockTrapdoor.patch | 14 +- nms-patches/BlockTripwire.patch | 4 +- nms-patches/BlockTurtleEgg.patch | 8 +- nms-patches/BlockVine.patch | 24 +- nms-patches/BlockWaterLily.patch | 6 +- nms-patches/BlockWitherSkull.patch | 80 ++- nms-patches/Chunk.patch | 187 ++---- nms-patches/ChunkMap.patch | 26 - nms-patches/ChunkProviderGenerate.patch | 29 +- nms-patches/ChunkProviderServer.patch | 163 ++--- nms-patches/ChunkRegionLoader.patch | 305 --------- nms-patches/ChunkTaskScheduler.patch | 15 - .../CommandBlockListenerAbstract.patch | 18 +- nms-patches/CommandDebug.patch | 32 - nms-patches/CommandDispatcher.patch | 18 +- nms-patches/CommandForceload.patch | 28 +- nms-patches/CommandGamerule.patch | 6 +- nms-patches/CommandListenerWrapper.patch | 14 +- nms-patches/CommandSpreadPlayers.patch | 2 +- nms-patches/Container.patch | 48 +- nms-patches/ContainerAccess.patch | 42 ++ nms-patches/ContainerAnvil.patch | 86 ++- nms-patches/ContainerBeacon.patch | 31 +- nms-patches/ContainerBrewingStand.patch | 26 +- nms-patches/ContainerCartography.patch | 59 ++ nms-patches/ContainerChest.patch | 23 +- nms-patches/ContainerDispenser.patch | 30 +- nms-patches/ContainerEnchantTable.patch | 135 ++-- nms-patches/ContainerFurnace.patch | 45 +- nms-patches/ContainerGrindstone.patch | 63 ++ nms-patches/ContainerHopper.patch | 17 +- nms-patches/ContainerHorse.patch | 17 +- nms-patches/ContainerLectern.patch | 60 ++ nms-patches/ContainerLoom.patch | 85 +++ nms-patches/ContainerMerchant.patch | 23 +- nms-patches/ContainerPlayer.patch | 35 +- nms-patches/ContainerShulkerBox.patch | 16 +- nms-patches/ContainerStonecutter.patch | 49 ++ nms-patches/ContainerWorkbench.patch | 70 +- nms-patches/Containers.patch | 31 + nms-patches/CraftingManager.patch | 89 ++- nms-patches/CrashReport.patch | 2 +- nms-patches/CustomFunction.patch | 2 +- nms-patches/CustomFunctionData.patch | 2 +- nms-patches/DamageSource.patch | 4 +- nms-patches/DataConverterMap.patch | 4 +- nms-patches/DataConverterRegistry.patch | 16 +- nms-patches/DataWatcher.patch | 2 +- nms-patches/DedicatedServer.patch | 187 +++--- nms-patches/DedicatedServerProperties.patch | 46 ++ nms-patches/DedicatedServerSettings.patch | 27 + nms-patches/DefinedStructure.patch | 38 ++ nms-patches/DimensionManager.patch | 11 + nms-patches/DispenseBehaviorBoat.patch | 57 ++ nms-patches/DispenseBehaviorItem.patch | 19 +- nms-patches/DispenseBehaviorProjectile.patch | 2 +- nms-patches/DispenseBehaviorShulkerBox.patch | 44 ++ nms-patches/DispenserRegistry.patch | 522 +------------- nms-patches/Enchantment.patch | 19 - nms-patches/EnchantmentFrostWalker.patch | 14 +- nms-patches/EnchantmentThorns.patch | 4 +- nms-patches/EnchantmentWeaponDamage.patch | 2 +- nms-patches/Enchantments.patch | 19 + nms-patches/Entity.patch | 451 +++++-------- nms-patches/EntityAgeable.patch | 31 +- nms-patches/EntityAnimal.patch | 21 +- nms-patches/EntityAreaEffectCloud.patch | 14 +- nms-patches/EntityArmorStand.patch | 64 +- nms-patches/EntityArrow.patch | 43 +- nms-patches/EntityBat.patch | 14 +- nms-patches/EntityBoat.patch | 38 +- nms-patches/EntityCat.patch | 32 + nms-patches/EntityCaveSpider.patch | 2 +- nms-patches/EntityChicken.patch | 18 +- nms-patches/EntityCow.patch | 8 +- nms-patches/EntityCreature.patch | 8 +- nms-patches/EntityCreeper.patch | 41 +- nms-patches/EntityDamageSourceIndirect.patch | 4 +- nms-patches/EntityDolphin.patch | 17 +- nms-patches/EntityEgg.patch | 8 +- nms-patches/EntityEnderCrystal.patch | 10 +- nms-patches/EntityEnderDragon.patch | 89 +-- nms-patches/EntityEnderPearl.patch | 8 +- nms-patches/EntityEnderman.patch | 20 +- nms-patches/EntityEvokerFangs.patch | 4 +- nms-patches/EntityExperienceOrb.patch | 68 +- nms-patches/EntityFallingBlock.patch | 32 +- nms-patches/EntityFireball.patch | 30 +- nms-patches/EntityFireworks.patch | 24 +- nms-patches/EntityFish.patch | 14 +- nms-patches/EntityFishingHook.patch | 50 +- nms-patches/EntityGhast.patch | 4 +- nms-patches/EntityGuardianElder.patch | 2 +- nms-patches/EntityHanging.patch | 48 +- nms-patches/EntityHorseAbstract.patch | 63 +- nms-patches/EntityHorseChestedAbstract.patch | 23 - nms-patches/EntityHuman.patch | 189 +++--- nms-patches/EntityIllagerIllusioner.patch | 19 +- nms-patches/EntityInsentient.patch | 131 ++-- nms-patches/EntityIronGolem.patch | 8 +- nms-patches/EntityItem.patch | 81 ++- nms-patches/EntityItemFrame.patch | 8 +- nms-patches/EntityLargeFireball.patch | 18 +- nms-patches/EntityLeash.patch | 10 +- nms-patches/EntityLightning.patch | 28 +- nms-patches/EntityLiving.patch | 212 +++--- nms-patches/EntityLlamaSpit.patch | 14 +- nms-patches/EntityMinecartAbstract.patch | 108 ++- nms-patches/EntityMinecartCommandBlock.patch | 4 +- nms-patches/EntityMinecartContainer.patch | 28 +- nms-patches/EntityMushroomCow.patch | 67 +- nms-patches/EntityOcelot.patch | 58 +- nms-patches/EntityPainting.patch | 4 +- nms-patches/EntityParrot.patch | 20 +- nms-patches/EntityPhantom.patch | 4 +- nms-patches/EntityPig.patch | 42 +- nms-patches/EntityPigZombie.patch | 6 +- nms-patches/EntityPillager.patch | 19 + nms-patches/EntityPlayer.patch | 479 ++++++------- nms-patches/EntityPotion.patch | 16 +- nms-patches/EntityProjectile.patch | 26 +- nms-patches/EntityPufferFish.patch | 4 +- nms-patches/EntityRabbit.patch | 25 +- nms-patches/EntityRaider.patch | 29 + nms-patches/EntitySelector.patch | 15 +- nms-patches/EntitySheep.patch | 99 +-- nms-patches/EntityShulker.patch | 23 +- nms-patches/EntityShulkerBullet.patch | 30 +- nms-patches/EntitySilverfish.patch | 21 +- nms-patches/EntitySkeleton.patch | 19 - nms-patches/EntitySkeletonAbstract.patch | 4 +- nms-patches/EntitySkeletonWither.patch | 19 +- nms-patches/EntitySlice.patch | 38 -- nms-patches/EntitySlime.patch | 22 +- nms-patches/EntitySmallFireball.patch | 49 +- nms-patches/EntitySnowman.patch | 10 +- nms-patches/EntitySpectralArrow.patch | 4 +- nms-patches/EntitySpider.patch | 10 +- nms-patches/EntityTNTPrimed.patch | 24 +- nms-patches/EntityThrownExpBottle.patch | 4 +- nms-patches/EntityThrownTrident.patch | 2 +- nms-patches/EntityTippedArrow.patch | 12 +- nms-patches/EntityTracker.patch | 11 - nms-patches/EntityTrackerEntry.patch | 202 +++--- nms-patches/EntityTurtle.patch | 35 +- nms-patches/EntityTypes.patch | 53 +- nms-patches/EntityVex.patch | 21 +- nms-patches/EntityVillager.patch | 127 ++-- nms-patches/EntityVillagerAbstract.patch | 42 ++ nms-patches/EntityVillagerTrader.patch | 33 + nms-patches/EntityWitch.patch | 2 +- nms-patches/EntityWither.patch | 40 +- nms-patches/EntityWitherSkull.patch | 30 +- nms-patches/EntityWolf.patch | 39 +- nms-patches/EntityZombie.patch | 87 +-- nms-patches/EntityZombieVillager.patch | 51 +- nms-patches/ExpirableListEntry.patch | 2 +- nms-patches/ExpiringMap.patch | 51 -- nms-patches/Explosion.patch | 35 +- nms-patches/FluidTypeFlowing.patch | 16 +- nms-patches/FluidTypeLava.patch | 10 +- nms-patches/FoodMetaData.patch | 36 +- nms-patches/FurnaceRecipe.patch | 22 +- nms-patches/HandshakeListener.patch | 8 +- nms-patches/IChunkLoader.patch | 55 ++ nms-patches/ICommandListener.patch | 20 +- nms-patches/IDataManager.patch | 9 - nms-patches/IDispenseBehavior.patch | 484 +++++++++++++ nms-patches/IInventory.patch | 25 +- nms-patches/IRecipe.patch | 6 +- nms-patches/IWorldWriter.patch | 18 +- nms-patches/InventoryCraftResult.patch | 18 +- nms-patches/InventoryCrafting.patch | 11 +- nms-patches/InventoryEnderChest.patch | 2 +- nms-patches/InventoryHorseChest.patch | 14 - nms-patches/InventoryLargeChest.patch | 24 +- nms-patches/InventoryMerchant.patch | 35 +- nms-patches/InventorySubcontainer.patch | 26 +- nms-patches/ItemArmor.patch | 4 +- nms-patches/ItemArmorStand.patch | 4 +- nms-patches/ItemBlock.patch | 32 +- nms-patches/ItemBoat.patch | 19 +- nms-patches/ItemBow.patch | 15 +- nms-patches/ItemBucket.patch | 26 +- nms-patches/ItemChorusFruit.patch | 8 +- nms-patches/ItemCrossbow.patch | 49 ++ nms-patches/ItemDye.patch | 4 +- nms-patches/ItemEndCrystal.patch | 4 +- nms-patches/ItemEnderPearl.patch | 39 +- nms-patches/ItemFireball.patch | 40 +- nms-patches/ItemFish.patch | 17 - nms-patches/ItemFishingRod.patch | 17 +- nms-patches/ItemFlintAndSteel.patch | 18 +- nms-patches/ItemFood.patch | 11 - nms-patches/ItemGoldenApple.patch | 15 - nms-patches/ItemGoldenAppleEnchanted.patch | 19 - nms-patches/ItemHanging.patch | 16 +- nms-patches/ItemLeash.patch | 4 +- nms-patches/ItemMilkBucket.patch | 2 +- nms-patches/ItemMinecart.patch | 4 +- nms-patches/ItemPotion.patch | 2 +- nms-patches/ItemRecord.patch | 2 +- nms-patches/ItemSign.patch | 6 +- nms-patches/ItemSkullPlayer.patch | 2 +- nms-patches/ItemSnowball.patch | 3 +- nms-patches/ItemStack.patch | 71 +- nms-patches/ItemTrident.patch | 28 +- nms-patches/ItemWaterLily.patch | 4 +- nms-patches/ItemWorldMap.patch | 31 +- nms-patches/LoginListener.patch | 16 +- nms-patches/LootContextParameters.patch | 10 + nms-patches/LootEnchantFunction.patch | 15 +- ...ItemConditionRandomChanceWithLooting.patch | 12 +- .../LootItemConditionSurvivesExplosion.patch | 12 + nms-patches/LootTableInfo.patch | 53 -- nms-patches/MerchantRecipe.patch | 14 +- nms-patches/MethodProfiler.patch | 63 -- nms-patches/MinecraftServer.patch | 539 +++++++-------- nms-patches/MobEffectList.patch | 26 +- nms-patches/MobEffects.patch | 17 + nms-patches/MobSpawnerAbstract.patch | 18 +- nms-patches/MobSpawnerPhantom.patch | 6 +- .../NameReferencingFileConverter.patch | 4 +- nms-patches/NetworkManager.patch | 2 +- nms-patches/PacketDataSerializer.patch | 6 +- nms-patches/PacketPlayOutWorldBorder.patch | 4 +- nms-patches/PacketStatusListener.patch | 6 +- nms-patches/PathfinderGoalBreakDoor.patch | 12 +- nms-patches/PathfinderGoalBreed.patch | 13 +- nms-patches/PathfinderGoalDefendVillage.patch | 4 +- nms-patches/PathfinderGoalDoorInteract.patch | 17 - nms-patches/PathfinderGoalEatTile.patch | 10 +- nms-patches/PathfinderGoalFollowOwner.patch | 22 +- nms-patches/PathfinderGoalHorseTrap.patch | 12 +- nms-patches/PathfinderGoalHurtByTarget.patch | 14 +- nms-patches/PathfinderGoalMakeLove.patch | 23 - ...athfinderGoalNearestAttackableTarget.patch | 32 +- ...oalNearestAttackableTargetInsentient.patch | 11 - .../PathfinderGoalOwnerHurtByTarget.patch | 4 +- .../PathfinderGoalOwnerHurtTarget.patch | 4 +- nms-patches/PathfinderGoalPanic.patch | 6 +- nms-patches/PathfinderGoalRemoveBlock.patch | 6 +- nms-patches/PathfinderGoalSit.patch | 6 +- nms-patches/PathfinderGoalTame.patch | 2 +- nms-patches/PathfinderGoalTarget.patch | 6 +- .../PathfinderGoalTargetNearestPlayer.patch | 11 - nms-patches/PathfinderGoalTempt.patch | 26 +- nms-patches/PathfinderGoalVillagerFarm.patch | 48 -- nms-patches/PlayerChunk.patch | 48 ++ nms-patches/PlayerChunkMap.patch | 348 ++++++---- nms-patches/PlayerConnection.patch | 272 ++++---- nms-patches/PlayerConnectionUtils.patch | 6 +- nms-patches/PlayerInteractManager.patch | 90 +-- nms-patches/PlayerInventory.patch | 35 +- nms-patches/PlayerList.patch | 537 +++++---------- nms-patches/PortalTravelAgent.patch | 278 -------- nms-patches/PropertyManager.patch | 137 ++-- nms-patches/RayTrace.patch | 20 + nms-patches/RecipeArmorDye.patch | 6 +- nms-patches/RecipeBannerAdd.patch | 18 - nms-patches/RecipeBannerDuplicate.patch | 6 +- nms-patches/RecipeBlasting.patch | 33 + nms-patches/RecipeBookClone.patch | 6 +- nms-patches/RecipeBookServer.patch | 14 +- nms-patches/RecipeCampfire.patch | 33 + nms-patches/RecipeFireworks.patch | 6 +- nms-patches/RecipeFireworksFade.patch | 6 +- nms-patches/RecipeFireworksStar.patch | 6 +- nms-patches/RecipeMapClone.patch | 6 +- nms-patches/RecipeRepair.patch | 38 -- nms-patches/RecipeShulkerBox.patch | 6 +- nms-patches/RecipeSmoking.patch | 33 + nms-patches/RecipeStonecutting.patch | 33 + nms-patches/RecipeSuspiciousStew.patch | 17 + nms-patches/RecipeTippedArrow.patch | 6 +- nms-patches/RecipiesShield.patch | 6 +- nms-patches/RegionFileCache.patch | 101 ++- nms-patches/RegionLimitedWorldAccess.patch | 7 +- .../RemoteControlCommandListener.patch | 10 +- nms-patches/ScoreboardServer.patch | 33 +- nms-patches/SecondaryWorldServer.patch | 36 +- nms-patches/ShapedRecipes.patch | 4 +- nms-patches/ShapelessRecipes.patch | 4 +- nms-patches/SlotFurnaceResult.patch | 37 +- nms-patches/SpawnerCreature.patch | 118 +--- nms-patches/StructureGenerator.patch | 16 +- nms-patches/TagRegistry.patch | 30 +- nms-patches/TagsServer.patch | 4 +- nms-patches/TickListServer.patch | 24 +- nms-patches/TicketType.patch | 10 + nms-patches/TileEntity.patch | 20 +- nms-patches/TileEntityBanner.patch | 14 +- nms-patches/TileEntityBarrel.patch | 58 ++ nms-patches/TileEntityBeacon.patch | 89 +-- nms-patches/TileEntityBrewingStand.patch | 34 +- nms-patches/TileEntityCampfire.patch | 35 + nms-patches/TileEntityChest.patch | 56 +- nms-patches/TileEntityCommand.patch | 4 +- nms-patches/TileEntityConduit.patch | 24 +- nms-patches/TileEntityContainer.patch | 6 +- nms-patches/TileEntityDispenser.patch | 16 +- nms-patches/TileEntityEndGateway.patch | 4 +- nms-patches/TileEntityFurnace.patch | 95 ++- nms-patches/TileEntityHopper.patch | 28 +- nms-patches/TileEntityLectern.patch | 126 ++++ nms-patches/TileEntityShulkerBox.patch | 24 +- nms-patches/TileEntitySign.patch | 56 +- nms-patches/TileEntitySkull.patch | 23 - nms-patches/Village.patch | 11 - nms-patches/VillageSiege.patch | 6 +- nms-patches/World.patch | 348 ++-------- nms-patches/WorldBorder.patch | 2 +- nms-patches/WorldData.patch | 36 +- nms-patches/WorldGenGroundBush.patch | 2 +- nms-patches/WorldGenMegaTreeProvider.patch | 4 +- nms-patches/WorldGenVillagePieces.patch | 19 - nms-patches/WorldGenWitchHut.patch | 6 +- nms-patches/WorldManager.patch | 48 -- nms-patches/WorldMap.patch | 26 +- nms-patches/WorldNBTStorage.patch | 20 +- nms-patches/WorldProviderHell.patch | 5 +- nms-patches/WorldServer.patch | 634 ++++++++++-------- nms-patches/WorldUpgrader.patch | 11 + pom.xml | 31 +- .../org/bukkit/craftbukkit/CraftChunk.java | 53 +- .../craftbukkit/CraftFluidCollisionMode.java | 6 +- .../bukkit/craftbukkit/CraftLootTable.java | 20 +- .../org/bukkit/craftbukkit/CraftParticle.java | 10 +- .../org/bukkit/craftbukkit/CraftServer.java | 170 ++--- .../org/bukkit/craftbukkit/CraftSound.java | 133 ++++ .../bukkit/craftbukkit/CraftStatistic.java | 13 +- .../bukkit/craftbukkit/CraftTravelAgent.java | 86 --- .../org/bukkit/craftbukkit/CraftWorld.java | 374 +++++------ .../java/org/bukkit/craftbukkit/TrigMath.java | 47 -- .../attribute/CraftAttributeInstance.java | 4 +- .../bukkit/craftbukkit/block/CraftBarrel.java | 33 + .../bukkit/craftbukkit/block/CraftBeacon.java | 36 +- .../bukkit/craftbukkit/block/CraftBell.java | 16 + .../craftbukkit/block/CraftBlastFurnace.java | 17 + .../bukkit/craftbukkit/block/CraftBlock.java | 128 ++-- .../craftbukkit/block/CraftBrewingStand.java | 28 +- .../craftbukkit/block/CraftCampfire.java | 55 ++ .../bukkit/craftbukkit/block/CraftChest.java | 2 +- .../craftbukkit/block/CraftContainer.java | 27 +- .../block/CraftCreatureSpawner.java | 2 +- .../craftbukkit/block/CraftFurnace.java | 41 +- .../block/CraftFurnaceFurnace.java | 16 + .../bukkit/craftbukkit/block/CraftJigsaw.java | 17 + .../craftbukkit/block/CraftLectern.java | 43 ++ .../craftbukkit/block/CraftLootable.java | 23 +- .../bukkit/craftbukkit/block/CraftSkull.java | 2 +- .../bukkit/craftbukkit/block/CraftSmoker.java | 17 + .../block/data/CraftBlockData.java | 26 +- .../block/data/type/CraftBamboo.java | 19 + .../block/data/type/CraftCampfire.java | 19 + .../block/data/type/CraftLantern.java | 19 + .../block/data/type/CraftLectern.java | 14 + .../block/data/type/CraftScaffolding.java | 35 + .../craftbukkit/block/impl/CraftBamboo.java | 67 ++ .../craftbukkit/block/impl/CraftBarrel.java | 34 + .../craftbukkit/block/impl/CraftBell.java | 34 + .../block/impl/CraftBlastFurnace.java | 48 ++ .../craftbukkit/block/impl/CraftCampfire.java | 57 ++ .../block/impl/CraftComposter.java | 34 + .../block/impl/CraftFurnaceFurace.java | 48 ++ .../block/impl/CraftGlassPane.java | 71 -- .../block/impl/CraftGrindstone.java | 34 + .../craftbukkit/block/impl/CraftJigsaw.java | 34 + .../craftbukkit/block/impl/CraftLantern.java | 29 + .../craftbukkit/block/impl/CraftLectern.java | 57 ++ .../craftbukkit/block/impl/CraftLoom.java | 34 + .../block/impl/CraftScaffolding.java | 59 ++ .../{CraftFurnace.java => CraftSmoker.java} | 10 +- .../block/impl/CraftStonecutter.java | 34 + .../block/impl/CraftSweetBerryBush.java | 34 + ...lantShearable.java => CraftTallPlant.java} | 8 +- .../craftbukkit/chunkio/ChunkIOExecutor.java | 36 - .../craftbukkit/chunkio/ChunkIOProvider.java | 57 -- .../craftbukkit/chunkio/QueuedChunk.java | 38 -- .../enchantments/CraftEnchantment.java | 12 +- .../entity/CraftAbstractVillager.java | 76 +++ .../craftbukkit/entity/CraftAnimals.java | 4 +- .../bukkit/craftbukkit/entity/CraftArrow.java | 7 +- .../bukkit/craftbukkit/entity/CraftCat.java | 41 ++ .../craftbukkit/entity/CraftComplexPart.java | 2 +- .../craftbukkit/entity/CraftEntity.java | 42 +- .../bukkit/craftbukkit/entity/CraftFox.java | 28 + .../craftbukkit/entity/CraftHumanEntity.java | 163 +++-- .../craftbukkit/entity/CraftIllager.java | 2 +- .../entity/CraftLingeringPotion.java | 42 -- .../craftbukkit/entity/CraftLivingEntity.java | 15 +- .../entity/CraftMinecartContainer.java | 4 +- .../craftbukkit/entity/CraftOcelot.java | 8 +- .../craftbukkit/entity/CraftPainting.java | 3 +- .../bukkit/craftbukkit/entity/CraftPanda.java | 61 ++ .../craftbukkit/entity/CraftPillager.java | 35 + .../craftbukkit/entity/CraftPlayer.java | 36 +- .../craftbukkit/entity/CraftRabbit.java | 4 +- .../craftbukkit/entity/CraftRaider.java | 52 ++ .../craftbukkit/entity/CraftRavager.java | 28 + .../craftbukkit/entity/CraftSplashPotion.java | 43 -- .../craftbukkit/entity/CraftThrownPotion.java | 18 +- .../craftbukkit/entity/CraftTippedArrow.java | 2 +- .../craftbukkit/entity/CraftTraderLlama.java | 28 + .../bukkit/craftbukkit/entity/CraftVex.java | 4 +- .../craftbukkit/entity/CraftVillager.java | 137 +--- .../entity/CraftVillagerZombie.java | 9 +- .../entity/CraftWanderingTrader.java | 28 + .../craftbukkit/entity/CraftWeather.java | 26 - .../bukkit/craftbukkit/entity/CraftWitch.java | 2 +- .../craftbukkit/event/CraftEventFactory.java | 75 ++- .../craftbukkit/generator/CraftChunkData.java | 2 +- .../generator/CustomChunkGenerator.java | 69 +- .../generator/InternalChunkGenerator.java | 11 +- .../generator/NetherChunkGenerator.java | 12 - .../generator/NormalChunkGenerator.java | 114 ---- .../generator/SkyLandsChunkGenerator.java | 12 - .../inventory/CraftBlastingRecipe.java | 30 + .../inventory/CraftBlockInventoryHolder.java | 30 + .../inventory/CraftCampfireRecipe.java | 30 + .../craftbukkit/inventory/CraftContainer.java | 108 ++- .../inventory/CraftCustomTagTypeRegistry.java | 6 +- .../inventory/CraftFurnaceRecipe.java | 2 +- .../craftbukkit/inventory/CraftInventory.java | 30 +- .../inventory/CraftInventoryAnvil.java | 4 +- .../inventory/CraftInventoryBeacon.java | 4 +- .../inventory/CraftInventoryCartography.java | 11 + .../inventory/CraftInventoryCustom.java | 45 +- .../inventory/CraftInventoryDoubleChest.java | 4 +- .../inventory/CraftInventoryGrindstone.java | 14 + .../inventory/CraftInventoryLectern.java | 17 + .../inventory/CraftInventoryLoom.java | 14 + .../inventory/CraftInventoryStonecutter.java | 11 + .../inventory/CraftInventoryView.java | 6 + .../inventory/CraftItemFactory.java | 24 +- .../craftbukkit/inventory/CraftItemStack.java | 26 +- .../craftbukkit/inventory/CraftMerchant.java | 10 +- .../inventory/CraftMerchantCustom.java | 25 +- .../inventory/CraftMerchantRecipe.java | 28 +- .../inventory/CraftMetaBlockState.java | 121 +++- .../craftbukkit/inventory/CraftMetaItem.java | 104 ++- .../inventory/CraftMetaLeatherArmor.java | 1 + .../inventory/CraftShapedRecipe.java | 2 +- .../inventory/CraftShapelessRecipe.java | 2 +- .../inventory/CraftSmokingRecipe.java | 30 + .../inventory/CraftStonecuttingRecipe.java | 30 + .../inventory/InventoryWrapper.java | 36 +- .../craftbukkit/inventory/RecipeIterator.java | 4 +- .../inventory/util/CraftInventoryCreator.java | 10 +- .../util/CraftTileInventoryConverter.java | 71 +- .../bukkit/craftbukkit/map/CraftMapView.java | 10 + .../potion/CraftPotionEffectType.java | 2 +- .../CraftBlockProjectileSource.java | 13 +- .../craftbukkit/scheduler/CraftScheduler.java | 18 +- .../util/AsynchronousExecutor.java | 354 ---------- .../util/BlockStateListPopulator.java | 5 + .../bukkit/craftbukkit/util/Commodore.java | 22 + .../bukkit/craftbukkit/util/CraftLegacy.java | 14 +- .../craftbukkit/util/CraftMagicNumbers.java | 46 +- .../util/CraftNBTTagConfigSerializer.java | 2 +- .../craftbukkit/util/CraftRayTraceResult.java | 23 +- .../bukkit/craftbukkit/util/CraftVector.java | 15 + .../util/DummyGeneratorAccess.java | 82 +-- .../org/bukkit/craftbukkit/util/LongHash.java | 15 - .../bukkit/craftbukkit/util/LongHashSet.java | 302 --------- .../craftbukkit/util/LongObjectHashMap.java | 422 ------------ .../craftbukkit/util/MojangNameLookup.java | 63 -- .../util/ServerShutdownThread.java | 5 +- .../util/ShortConsoleLogFormatter.java | 61 -- .../util/TerminalConsoleWriterThread.java | 4 +- src/main/resources/configurations/bukkit.yml | 3 - src/main/resources/log4j2.xml | 2 +- src/test/java/org/bukkit/ArtTest.java | 6 +- src/test/java/org/bukkit/LegacyTest.java | 12 + src/test/java/org/bukkit/ParticleTest.java | 4 +- src/test/java/org/bukkit/PerMaterialTest.java | 13 +- .../bukkit/StatisticsAndAchievementsTest.java | 4 +- .../java/org/bukkit/StructureTypeTest.java | 15 +- .../inventory/InventoryWrapperTest.java | 2 +- .../inventory/ItemFactoryTest.java | 4 +- .../craftbukkit/inventory/ItemMetaTest.java | 11 +- .../org/bukkit/entity/EntityTypesTest.java | 3 +- .../java/org/bukkit/entity/PandaGeneTest.java | 31 + .../bukkit/support/AbstractTestingBase.java | 11 +- 560 files changed, 10642 insertions(+), 10867 deletions(-) create mode 100644 nms-patches/BehaviorFarm.patch create mode 100644 nms-patches/BehaviorInteractDoor.patch create mode 100644 nms-patches/BehaviorMakeLove.patch delete mode 100644 nms-patches/BlockBeacon.patch create mode 100644 nms-patches/BlockComposter.patch delete mode 100644 nms-patches/BlockShulkerBox.patch delete mode 100644 nms-patches/BlockSkullAbstract.patch delete mode 100644 nms-patches/BlockSnowBlock.patch create mode 100644 nms-patches/BlockSweetBerryBush.patch delete mode 100644 nms-patches/ChunkMap.patch delete mode 100644 nms-patches/ChunkRegionLoader.patch delete mode 100644 nms-patches/ChunkTaskScheduler.patch delete mode 100644 nms-patches/CommandDebug.patch create mode 100644 nms-patches/ContainerAccess.patch create mode 100644 nms-patches/ContainerCartography.patch create mode 100644 nms-patches/ContainerGrindstone.patch create mode 100644 nms-patches/ContainerLectern.patch create mode 100644 nms-patches/ContainerLoom.patch create mode 100644 nms-patches/ContainerStonecutter.patch create mode 100644 nms-patches/Containers.patch create mode 100644 nms-patches/DedicatedServerProperties.patch create mode 100644 nms-patches/DedicatedServerSettings.patch create mode 100644 nms-patches/DefinedStructure.patch create mode 100644 nms-patches/DimensionManager.patch create mode 100644 nms-patches/DispenseBehaviorBoat.patch create mode 100644 nms-patches/DispenseBehaviorShulkerBox.patch delete mode 100644 nms-patches/Enchantment.patch create mode 100644 nms-patches/Enchantments.patch create mode 100644 nms-patches/EntityCat.patch delete mode 100644 nms-patches/EntityHorseChestedAbstract.patch create mode 100644 nms-patches/EntityPillager.patch create mode 100644 nms-patches/EntityRaider.patch delete mode 100644 nms-patches/EntitySkeleton.patch delete mode 100644 nms-patches/EntitySlice.patch delete mode 100644 nms-patches/EntityTracker.patch create mode 100644 nms-patches/EntityVillagerAbstract.patch create mode 100644 nms-patches/EntityVillagerTrader.patch delete mode 100644 nms-patches/ExpiringMap.patch create mode 100644 nms-patches/IChunkLoader.patch delete mode 100644 nms-patches/IDataManager.patch create mode 100644 nms-patches/IDispenseBehavior.patch delete mode 100644 nms-patches/InventoryHorseChest.patch create mode 100644 nms-patches/ItemCrossbow.patch delete mode 100644 nms-patches/ItemFish.patch delete mode 100644 nms-patches/ItemFood.patch delete mode 100644 nms-patches/ItemGoldenApple.patch delete mode 100644 nms-patches/ItemGoldenAppleEnchanted.patch create mode 100644 nms-patches/LootContextParameters.patch create mode 100644 nms-patches/LootItemConditionSurvivesExplosion.patch delete mode 100644 nms-patches/LootTableInfo.patch delete mode 100644 nms-patches/MethodProfiler.patch create mode 100644 nms-patches/MobEffects.patch delete mode 100644 nms-patches/PathfinderGoalDoorInteract.patch delete mode 100644 nms-patches/PathfinderGoalMakeLove.patch delete mode 100644 nms-patches/PathfinderGoalNearestAttackableTargetInsentient.patch delete mode 100644 nms-patches/PathfinderGoalTargetNearestPlayer.patch delete mode 100644 nms-patches/PathfinderGoalVillagerFarm.patch create mode 100644 nms-patches/PlayerChunk.patch delete mode 100644 nms-patches/PortalTravelAgent.patch create mode 100644 nms-patches/RayTrace.patch delete mode 100644 nms-patches/RecipeBannerAdd.patch create mode 100644 nms-patches/RecipeBlasting.patch create mode 100644 nms-patches/RecipeCampfire.patch delete mode 100644 nms-patches/RecipeRepair.patch create mode 100644 nms-patches/RecipeSmoking.patch create mode 100644 nms-patches/RecipeStonecutting.patch create mode 100644 nms-patches/RecipeSuspiciousStew.patch create mode 100644 nms-patches/TicketType.patch create mode 100644 nms-patches/TileEntityBarrel.patch create mode 100644 nms-patches/TileEntityCampfire.patch create mode 100644 nms-patches/TileEntityLectern.patch delete mode 100644 nms-patches/TileEntitySkull.patch delete mode 100644 nms-patches/Village.patch delete mode 100644 nms-patches/WorldGenVillagePieces.patch delete mode 100644 nms-patches/WorldManager.patch create mode 100644 nms-patches/WorldUpgrader.patch delete mode 100644 src/main/java/org/bukkit/craftbukkit/CraftTravelAgent.java delete mode 100644 src/main/java/org/bukkit/craftbukkit/TrigMath.java create mode 100644 src/main/java/org/bukkit/craftbukkit/block/CraftBarrel.java create mode 100644 src/main/java/org/bukkit/craftbukkit/block/CraftBell.java create mode 100644 src/main/java/org/bukkit/craftbukkit/block/CraftBlastFurnace.java create mode 100644 src/main/java/org/bukkit/craftbukkit/block/CraftCampfire.java create mode 100644 src/main/java/org/bukkit/craftbukkit/block/CraftFurnaceFurnace.java create mode 100644 src/main/java/org/bukkit/craftbukkit/block/CraftJigsaw.java create mode 100644 src/main/java/org/bukkit/craftbukkit/block/CraftLectern.java create mode 100644 src/main/java/org/bukkit/craftbukkit/block/CraftSmoker.java create mode 100644 src/main/java/org/bukkit/craftbukkit/block/data/type/CraftBamboo.java create mode 100644 src/main/java/org/bukkit/craftbukkit/block/data/type/CraftCampfire.java create mode 100644 src/main/java/org/bukkit/craftbukkit/block/data/type/CraftLantern.java create mode 100644 src/main/java/org/bukkit/craftbukkit/block/data/type/CraftLectern.java create mode 100644 src/main/java/org/bukkit/craftbukkit/block/data/type/CraftScaffolding.java create mode 100644 src/main/java/org/bukkit/craftbukkit/block/impl/CraftBamboo.java create mode 100644 src/main/java/org/bukkit/craftbukkit/block/impl/CraftBarrel.java create mode 100644 src/main/java/org/bukkit/craftbukkit/block/impl/CraftBell.java create mode 100644 src/main/java/org/bukkit/craftbukkit/block/impl/CraftBlastFurnace.java create mode 100644 src/main/java/org/bukkit/craftbukkit/block/impl/CraftCampfire.java create mode 100644 src/main/java/org/bukkit/craftbukkit/block/impl/CraftComposter.java create mode 100644 src/main/java/org/bukkit/craftbukkit/block/impl/CraftFurnaceFurace.java delete mode 100644 src/main/java/org/bukkit/craftbukkit/block/impl/CraftGlassPane.java create mode 100644 src/main/java/org/bukkit/craftbukkit/block/impl/CraftGrindstone.java create mode 100644 src/main/java/org/bukkit/craftbukkit/block/impl/CraftJigsaw.java create mode 100644 src/main/java/org/bukkit/craftbukkit/block/impl/CraftLantern.java create mode 100644 src/main/java/org/bukkit/craftbukkit/block/impl/CraftLectern.java create mode 100644 src/main/java/org/bukkit/craftbukkit/block/impl/CraftLoom.java create mode 100644 src/main/java/org/bukkit/craftbukkit/block/impl/CraftScaffolding.java rename src/main/java/org/bukkit/craftbukkit/block/impl/{CraftFurnace.java => CraftSmoker.java} (69%) create mode 100644 src/main/java/org/bukkit/craftbukkit/block/impl/CraftStonecutter.java create mode 100644 src/main/java/org/bukkit/craftbukkit/block/impl/CraftSweetBerryBush.java rename src/main/java/org/bukkit/craftbukkit/block/impl/{CraftTallPlantShearable.java => CraftTallPlant.java} (57%) delete mode 100644 src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOExecutor.java delete mode 100644 src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOProvider.java delete mode 100644 src/main/java/org/bukkit/craftbukkit/chunkio/QueuedChunk.java create mode 100644 src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractVillager.java create mode 100644 src/main/java/org/bukkit/craftbukkit/entity/CraftCat.java create mode 100644 src/main/java/org/bukkit/craftbukkit/entity/CraftFox.java delete mode 100644 src/main/java/org/bukkit/craftbukkit/entity/CraftLingeringPotion.java create mode 100644 src/main/java/org/bukkit/craftbukkit/entity/CraftPanda.java create mode 100644 src/main/java/org/bukkit/craftbukkit/entity/CraftPillager.java create mode 100644 src/main/java/org/bukkit/craftbukkit/entity/CraftRaider.java create mode 100644 src/main/java/org/bukkit/craftbukkit/entity/CraftRavager.java delete mode 100644 src/main/java/org/bukkit/craftbukkit/entity/CraftSplashPotion.java create mode 100644 src/main/java/org/bukkit/craftbukkit/entity/CraftTraderLlama.java create mode 100644 src/main/java/org/bukkit/craftbukkit/entity/CraftWanderingTrader.java delete mode 100644 src/main/java/org/bukkit/craftbukkit/entity/CraftWeather.java delete mode 100644 src/main/java/org/bukkit/craftbukkit/generator/NetherChunkGenerator.java delete mode 100644 src/main/java/org/bukkit/craftbukkit/generator/NormalChunkGenerator.java delete mode 100644 src/main/java/org/bukkit/craftbukkit/generator/SkyLandsChunkGenerator.java create mode 100644 src/main/java/org/bukkit/craftbukkit/inventory/CraftBlastingRecipe.java create mode 100644 src/main/java/org/bukkit/craftbukkit/inventory/CraftBlockInventoryHolder.java create mode 100644 src/main/java/org/bukkit/craftbukkit/inventory/CraftCampfireRecipe.java create mode 100644 src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCartography.java create mode 100644 src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryGrindstone.java create mode 100644 src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryLectern.java create mode 100644 src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryLoom.java create mode 100644 src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryStonecutter.java create mode 100644 src/main/java/org/bukkit/craftbukkit/inventory/CraftSmokingRecipe.java create mode 100644 src/main/java/org/bukkit/craftbukkit/inventory/CraftStonecuttingRecipe.java delete mode 100644 src/main/java/org/bukkit/craftbukkit/util/AsynchronousExecutor.java create mode 100644 src/main/java/org/bukkit/craftbukkit/util/CraftVector.java delete mode 100644 src/main/java/org/bukkit/craftbukkit/util/LongHash.java delete mode 100644 src/main/java/org/bukkit/craftbukkit/util/LongHashSet.java delete mode 100644 src/main/java/org/bukkit/craftbukkit/util/LongObjectHashMap.java delete mode 100644 src/main/java/org/bukkit/craftbukkit/util/MojangNameLookup.java delete mode 100644 src/main/java/org/bukkit/craftbukkit/util/ShortConsoleLogFormatter.java create mode 100644 src/test/java/org/bukkit/entity/PandaGeneTest.java diff --git a/nms-patches/Advancement.patch b/nms-patches/Advancement.patch index 29a78647f2..1930cf5666 100644 --- a/nms-patches/Advancement.patch +++ b/nms-patches/Advancement.patch @@ -8,7 +8,7 @@ public Advancement(MinecraftKey minecraftkey, @Nullable Advancement advancement, @Nullable AdvancementDisplay advancementdisplay, AdvancementRewards advancementrewards, Map map, String[][] astring) { this.d = minecraftkey; -@@ -206,7 +207,7 @@ +@@ -210,7 +211,7 @@ } public Advancement b(MinecraftKey minecraftkey) { diff --git a/nms-patches/AdvancementDataPlayer.patch b/nms-patches/AdvancementDataPlayer.patch index e2c4774c1e..b14455b6e1 100644 --- a/nms-patches/AdvancementDataPlayer.patch +++ b/nms-patches/AdvancementDataPlayer.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/AdvancementDataPlayer.java +++ b/net/minecraft/server/AdvancementDataPlayer.java -@@ -158,7 +158,11 @@ +@@ -160,7 +160,11 @@ Advancement advancement = this.d.getAdvancementData().a((MinecraftKey) entry.getKey()); if (advancement == null) { @@ -13,7 +13,7 @@ } else { this.a(advancement, (AdvancementProgress) entry.getValue()); } -@@ -227,6 +231,7 @@ +@@ -275,6 +279,7 @@ this.i.add(advancement); flag = true; if (!flag1 && advancementprogress.isDone()) { diff --git a/nms-patches/ArgumentBlock.patch b/nms-patches/ArgumentBlock.patch index 320f3f4214..18c4e7144f 100644 --- a/nms-patches/ArgumentBlock.patch +++ b/nms-patches/ArgumentBlock.patch @@ -18,7 +18,7 @@ if (t0 instanceof Integer) { suggestionsbuilder.suggest((Integer) t0); -@@ -488,7 +488,7 @@ +@@ -486,7 +486,7 @@ Optional optional = iblockstate.b(s); if (optional.isPresent()) { @@ -27,7 +27,7 @@ this.k.put(iblockstate, optional.get()); } else { this.i.setCursor(i); -@@ -526,7 +526,7 @@ +@@ -520,7 +520,7 @@ private static > void a(StringBuilder stringbuilder, IBlockState iblockstate, Comparable comparable) { stringbuilder.append(iblockstate.a()); stringbuilder.append('='); diff --git a/nms-patches/ArgumentEntity.patch b/nms-patches/ArgumentEntity.patch index 0af88bf603..4609ed35a7 100644 --- a/nms-patches/ArgumentEntity.patch +++ b/nms-patches/ArgumentEntity.patch @@ -12,8 +12,8 @@ + // CraftBukkit end boolean flag = false; ArgumentParserSelector argumentparserselector = new ArgumentParserSelector(stringreader); -- EntitySelector entityselector = argumentparserselector.s(); -+ EntitySelector entityselector = argumentparserselector.s(overridePermissions); // CraftBukkit +- EntitySelector entityselector = argumentparserselector.parse(); ++ EntitySelector entityselector = argumentparserselector.parse(overridePermissions); // CraftBukkit if (entityselector.a() > 1 && this.h) { if (this.i) { diff --git a/nms-patches/ArgumentParserSelector.patch b/nms-patches/ArgumentParserSelector.patch index 8dafb3eb1a..91abf6dc5c 100644 --- a/nms-patches/ArgumentParserSelector.patch +++ b/nms-patches/ArgumentParserSelector.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/ArgumentParserSelector.java +++ b/net/minecraft/server/ArgumentParserSelector.java -@@ -126,7 +126,7 @@ +@@ -127,7 +127,7 @@ axisalignedbb = this.a(this.v == null ? 0.0D : this.v, this.w == null ? 0.0D : this.w, this.x == null ? 0.0D : this.x); } @@ -9,38 +9,38 @@ if (this.s == null && this.t == null && this.u == null) { function = (vec3d) -> { -@@ -187,8 +187,10 @@ +@@ -188,8 +188,10 @@ }; } -- protected void b() throws CommandSyntaxException { -- this.T = true; +- protected void parseSelector() throws CommandSyntaxException { +- this.checkPermissions = true; + // CraftBukkit start -+ protected void b(boolean overridePermissions) throws CommandSyntaxException { -+ this.T = !overridePermissions; ++ protected void parseSelector(boolean overridePermissions) throws CommandSyntaxException { ++ this.checkPermissions = !overridePermissions; + // CraftBukkit end this.G = this::d; if (!this.l.canRead()) { throw ArgumentParserSelector.d.createWithContext(this.l); -@@ -431,6 +433,12 @@ +@@ -443,6 +445,12 @@ } - public EntitySelector s() throws CommandSyntaxException { + public EntitySelector parse() throws CommandSyntaxException { + // CraftBukkit start -+ return s(false); ++ return parse(false); + } + -+ public EntitySelector s(boolean overridePermissions) throws CommandSyntaxException { ++ public EntitySelector parse(boolean overridePermissions) throws CommandSyntaxException { + // CraftBukkit end this.E = this.l.getCursor(); this.G = this::b; if (this.l.canRead() && this.l.peek() == '@') { -@@ -439,7 +447,7 @@ +@@ -451,7 +459,7 @@ } this.l.skip(); -- this.b(); -+ this.b(overridePermissions); // CraftBukkit +- this.parseSelector(); ++ this.parseSelector(overridePermissions); // CraftBukkit } else { this.c(); } diff --git a/nms-patches/AttributeRanged.patch b/nms-patches/AttributeRanged.patch index f71634b576..e579b8744b 100644 --- a/nms-patches/AttributeRanged.patch +++ b/nms-patches/AttributeRanged.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/AttributeRanged.java +++ b/net/minecraft/server/AttributeRanged.java -@@ -31,6 +31,8 @@ - } +@@ -32,6 +32,8 @@ + @Override public double a(double d0) { + if (d0 != d0) return getDefault(); // CraftBukkit + diff --git a/nms-patches/BehaviorFarm.patch b/nms-patches/BehaviorFarm.patch new file mode 100644 index 0000000000..4b7d1c9862 --- /dev/null +++ b/nms-patches/BehaviorFarm.patch @@ -0,0 +1,68 @@ +--- a/net/minecraft/server/BehaviorFarm.java ++++ b/net/minecraft/server/BehaviorFarm.java +@@ -31,7 +31,7 @@ + } else if (entityvillager.getVillagerData().getProfession() != VillagerProfession.FARMER) { + return false; + } else { +- Set set = (Set) ((List) entityvillager.getBehaviorController().c(MemoryModuleType.SECONDARY_JOB_SITE).get()).stream().map(GlobalPos::b).collect(Collectors.toSet()); ++ Set set = (Set) (entityvillager.getBehaviorController().c(MemoryModuleType.SECONDARY_JOB_SITE).get()).stream().map(GlobalPos::b).collect(Collectors.toSet()); // CraftBukkit - decompile error + BlockPosition blockposition = new BlockPosition(entityvillager); + Stream stream = ImmutableList.of(blockposition.down(), blockposition.south(), blockposition.north(), blockposition.east(), blockposition.west()).stream(); + +@@ -61,8 +61,8 @@ + + protected void a(WorldServer worldserver, EntityVillager entityvillager, long i) { + if (i > this.d && this.a != null) { +- entityvillager.getBehaviorController().a(MemoryModuleType.LOOK_TARGET, (Object) (new BehaviorTarget(this.a))); +- entityvillager.getBehaviorController().a(MemoryModuleType.WALK_TARGET, (Object) (new MemoryTarget(new BehaviorTarget(this.a), 0.5F, 1))); ++ entityvillager.getBehaviorController().a(MemoryModuleType.LOOK_TARGET, (new BehaviorTarget(this.a))); // CraftBukkit - decompile error ++ entityvillager.getBehaviorController().a(MemoryModuleType.WALK_TARGET, (new MemoryTarget(new BehaviorTarget(this.a), 0.5F, 1))); // CraftBukkit - decompile error + } + + } +@@ -80,7 +80,11 @@ + Block block = iblockdata.getBlock(); + + if (block instanceof BlockCrops && ((BlockCrops) block).isRipe(iblockdata) && this.c) { +- worldserver.b(this.a, true); ++ // CraftBukkit start ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entityvillager, this.a, Blocks.AIR.getBlockData()).isCancelled()) { ++ worldserver.b(this.a, true); ++ } ++ // CraftBukkit end + } else if (iblockdata.isAir() && this.b) { + InventorySubcontainer inventorysubcontainer = entityvillager.getInventory(); + +@@ -89,19 +93,28 @@ + boolean flag = false; + + if (!itemstack.isEmpty()) { ++ // CraftBukkit start ++ Block planted = null; + if (itemstack.getItem() == Items.WHEAT_SEEDS) { +- worldserver.setTypeAndData(this.a, Blocks.WHEAT.getBlockData(), 3); ++ planted = Blocks.WHEAT; + flag = true; + } else if (itemstack.getItem() == Items.POTATO) { +- worldserver.setTypeAndData(this.a, Blocks.POTATOES.getBlockData(), 3); ++ planted = Blocks.POTATOES; + flag = true; + } else if (itemstack.getItem() == Items.CARROT) { +- worldserver.setTypeAndData(this.a, Blocks.CARROTS.getBlockData(), 3); ++ planted = Blocks.CARROTS; + flag = true; + } else if (itemstack.getItem() == Items.BEETROOT_SEEDS) { +- worldserver.setTypeAndData(this.a, Blocks.BEETROOTS.getBlockData(), 3); ++ planted = Blocks.BEETROOTS; + flag = true; + } ++ ++ if (planted != null && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entityvillager, this.a, planted.getBlockData()).isCancelled()) { ++ worldserver.setTypeAndData(this.a, planted.getBlockData(), 3); ++ } else { ++ flag = false; ++ } ++ // CraftBukkit end + } + + if (flag) { diff --git a/nms-patches/BehaviorInteractDoor.patch b/nms-patches/BehaviorInteractDoor.patch new file mode 100644 index 0000000000..97ec9002b8 --- /dev/null +++ b/nms-patches/BehaviorInteractDoor.patch @@ -0,0 +1,33 @@ +--- a/net/minecraft/server/BehaviorInteractDoor.java ++++ b/net/minecraft/server/BehaviorInteractDoor.java +@@ -27,7 +27,7 @@ + Set set = this.a(worldserver, list, list1); + int j = pathentity.f() - 1; + +- this.a(worldserver, list1, set, j); ++ this.a(worldserver, list1, set, j, entityliving); // CraftBukkit - add entity + } + + private Set a(WorldServer worldserver, List list, List list1) { +@@ -39,13 +39,20 @@ + return (Set) stream.filter(list1::contains).collect(Collectors.toSet()); + } + +- private void a(WorldServer worldserver, List list, Set set, int i) { ++ private void a(WorldServer worldserver, List list, Set set, int i, EntityLiving entityliving) { // CraftBukkit - add entity + set.forEach((blockposition) -> { + int j = list.indexOf(blockposition); + IBlockData iblockdata = worldserver.getType(blockposition); + Block block = iblockdata.getBlock(); + + if (TagsBlock.WOODEN_DOORS.isTagged(block) && block instanceof BlockDoor) { ++ // CraftBukkit start - entities opening doors ++ org.bukkit.event.entity.EntityInteractEvent event = new org.bukkit.event.entity.EntityInteractEvent(entityliving.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(entityliving.world, blockposition)); ++ entityliving.world.getServer().getPluginManager().callEvent(event); ++ if (event.isCancelled()) { ++ return; ++ } ++ // CaftBukkit end + ((BlockDoor) block).setDoor(worldserver, blockposition, j >= i); + } + diff --git a/nms-patches/BehaviorMakeLove.patch b/nms-patches/BehaviorMakeLove.patch new file mode 100644 index 0000000000..a0cefad904 --- /dev/null +++ b/nms-patches/BehaviorMakeLove.patch @@ -0,0 +1,31 @@ +--- a/net/minecraft/server/BehaviorMakeLove.java ++++ b/net/minecraft/server/BehaviorMakeLove.java +@@ -100,6 +100,11 @@ + + private Optional a(EntityVillager entityvillager, EntityVillager entityvillager1) { + EntityVillager entityvillager2 = entityvillager.createChild(entityvillager1); ++ // CraftBukkit start - call EntityBreedEvent ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityBreedEvent(entityvillager2, entityvillager, entityvillager1, null, null, 0).isCancelled()) { ++ return Optional.empty(); ++ } ++ // CraftBukkit end + + if (entityvillager2 == null) { + return Optional.empty(); +@@ -108,7 +113,7 @@ + entityvillager1.setAgeRaw(6000); + entityvillager2.setAgeRaw(-24000); + entityvillager2.setPositionRotation(entityvillager.locX, entityvillager.locY, entityvillager.locZ, 0.0F, 0.0F); +- entityvillager.world.addEntity(entityvillager2); ++ entityvillager.world.addEntity(entityvillager2, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - added SpawnReason + entityvillager.world.broadcastEntityEffect(entityvillager2, (byte) 12); + return Optional.of(entityvillager2); + } +@@ -117,6 +122,6 @@ + private void a(WorldServer worldserver, EntityVillager entityvillager, BlockPosition blockposition) { + GlobalPos globalpos = GlobalPos.a(worldserver.getWorldProvider().getDimensionManager(), blockposition); + +- entityvillager.getBehaviorController().a(MemoryModuleType.HOME, (Object) globalpos); ++ entityvillager.getBehaviorController().a(MemoryModuleType.HOME, globalpos); // CraftBukkit - decompile error + } + } diff --git a/nms-patches/Block.patch b/nms-patches/Block.patch index e59d629c1b..1936e3406f 100644 --- a/nms-patches/Block.patch +++ b/nms-patches/Block.patch @@ -1,19 +1,19 @@ --- a/net/minecraft/server/Block.java +++ b/net/minecraft/server/Block.java -@@ -405,7 +405,8 @@ - int j = this.getDropCount(iblockdata, i, world, blockposition, world.random); +@@ -427,7 +427,8 @@ + } - for (int k = 0; k < j; ++k) { -- if (f >= 1.0F || world.random.nextFloat() <= f) { -+ // CraftBukkit - <= to < to allow for plugins to completely disable block drops from explosions -+ if (f >= 1.0F || world.random.nextFloat() < f) { - Item item = this.getDropType(iblockdata, world, blockposition, i).getItem(); + public static List getDrops(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, @Nullable TileEntity tileentity, Entity entity, ItemStack itemstack) { +- LootTableInfo.Builder loottableinfo_builder = (new LootTableInfo.Builder(worldserver)).a(worldserver.random).set(LootContextParameters.POSITION, blockposition).set(LootContextParameters.TOOL, itemstack).set(LootContextParameters.THIS_ENTITY, entity).setOptional(LootContextParameters.BLOCK_ENTITY, tileentity); ++ // CraftBukkit - make entity optional ++ LootTableInfo.Builder loottableinfo_builder = (new LootTableInfo.Builder(worldserver)).a(worldserver.random).set(LootContextParameters.POSITION, blockposition).set(LootContextParameters.TOOL, itemstack).setOptional(LootContextParameters.THIS_ENTITY, entity).setOptional(LootContextParameters.BLOCK_ENTITY, tileentity); - if (item != Items.AIR) { -@@ -426,7 +427,13 @@ + return iblockdata.a(loottableinfo_builder); + } +@@ -481,7 +482,13 @@ EntityItem entityitem = new EntityItem(world, (double) blockposition.getX() + d0, (double) blockposition.getY() + d1, (double) blockposition.getZ() + d2, itemstack); - entityitem.n(); + entityitem.defaultPickupDelay(); - world.addEntity(entityitem); + // CraftBukkit start + if (world.captureDrops != null) { @@ -25,19 +25,16 @@ } } -@@ -1394,8 +1401,14 @@ - +@@ -678,6 +685,12 @@ + return block == Blocks.DIRT || block == Blocks.COARSE_DIRT || block == Blocks.PODZOL; } + // CraftBukkit start -+ public int getExpDrop(IBlockData iblockdata, World world, BlockPosition blockposition, int enchantmentLevel) { ++ public int getExpDrop(IBlockData iblockdata, World world, BlockPosition blockposition, ItemStack itemstack) { + return 0; + } + // CraftBukkit end + - private static void a(MinecraftKey minecraftkey, Block block) { -- IRegistry.BLOCK.a(minecraftkey, (Object) block); -+ IRegistry.BLOCK.a(minecraftkey, block); // CraftBukkit - decompile error - } + public static enum EnumRandomOffset { - private static void a(String s, Block block) { + NONE, XZ, XYZ; diff --git a/nms-patches/BlockBeacon.patch b/nms-patches/BlockBeacon.patch deleted file mode 100644 index 8f58b71dc2..0000000000 --- a/nms-patches/BlockBeacon.patch +++ /dev/null @@ -1,19 +0,0 @@ ---- a/net/minecraft/server/BlockBeacon.java -+++ b/net/minecraft/server/BlockBeacon.java -@@ -49,7 +49,7 @@ - } - - public static void a(World world, BlockPosition blockposition) { -- HttpUtilities.a.submit(() -> { -+ // HttpUtilities.a.submit(() -> { // CraftBukkit - dangerously threaded - Chunk chunk = world.getChunkAtWorldCoords(blockposition); - - for (int i = blockposition.getY() - 1; i >= 0; --i) { -@@ -74,6 +74,6 @@ - } - } - -- }); -+ // }); // CraftBukkit - } - } diff --git a/nms-patches/BlockBed.patch b/nms-patches/BlockBed.patch index 344cff1ac6..9a104607b7 100644 --- a/nms-patches/BlockBed.patch +++ b/nms-patches/BlockBed.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/BlockBed.java +++ b/net/minecraft/server/BlockBed.java -@@ -32,7 +32,8 @@ +@@ -41,20 +41,37 @@ } } @@ -8,18 +8,24 @@ + // CraftBukkit - moved world and biome check into EntityHuman + if (true || world.worldProvider.canRespawn() && world.getBiome(blockposition) != Biomes.NETHER) { if ((Boolean) iblockdata.get(BlockBed.OCCUPIED)) { - EntityHuman entityhuman1 = this.a(world, blockposition); - -@@ -59,10 +60,22 @@ - } else if (entityhuman_enumbedresult == EntityHuman.EnumBedResult.TOO_FAR_AWAY) { - entityhuman.a((IChatBaseComponent) (new ChatMessage("block.minecraft.bed.too_far_away", new Object[0])), true); - } -+ // CraftBukkit start - handling bed explosion from below here -+ else if (entityhuman_enumbedresult == EntityHuman.EnumBedResult.NOT_POSSIBLE_HERE) { -+ this.explodeBed(iblockdata, world, blockposition); -+ } + entityhuman.a((IChatBaseComponent) (new ChatMessage("block.minecraft.bed.occupied", new Object[0])), true); + return true; + } else { ++ // CraftBukkit start ++ IBlockData finaliblockdata = iblockdata; ++ BlockPosition finalblockposition = blockposition; + // CraftBukkit end + entityhuman.sleep(blockposition).ifLeft((entityhuman_enumbedresult) -> { + if (entityhuman_enumbedresult != null) { + entityhuman.a(entityhuman_enumbedresult.a(), true); + } ++ // CraftBukkit start - handling bed explosion from below here ++ else if (entityhuman_enumbedresult == EntityHuman.EnumBedResult.NOT_POSSIBLE_HERE) { ++ this.explodeBed(finaliblockdata, world, finalblockposition); ++ } ++ // CraftBukkit end + }); return true; } + // CraftBukkit start - moved bed explosion into separate method @@ -30,16 +36,16 @@ + } + + private boolean explodeBed(IBlockData iblockdata, World world, BlockPosition blockposition) { - world.setAir(blockposition); + world.a(blockposition, false); BlockPosition blockposition1 = blockposition.shift(((EnumDirection) iblockdata.get(BlockBed.FACING)).opposite()); -@@ -72,8 +85,7 @@ +@@ -64,8 +81,7 @@ - world.createExplosion((Entity) null, DamageSource.a(), (double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D, 5.0F, true, true); + world.createExplosion((Entity) null, DamageSource.a(), (double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D, 5.0F, true, Explosion.Effect.DESTROY); return true; - } - } + // CraftBukkit end } - @Nullable + @Override diff --git a/nms-patches/BlockButtonAbstract.patch b/nms-patches/BlockButtonAbstract.patch index 1700b69406..2ab32ecbf4 100644 --- a/nms-patches/BlockButtonAbstract.patch +++ b/nms-patches/BlockButtonAbstract.patch @@ -11,8 +11,8 @@ + public abstract class BlockButtonAbstract extends BlockAttachable { - public static final BlockStateBoolean POWERED = BlockProperties.t; -@@ -72,6 +77,19 @@ + public static final BlockStateBoolean POWERED = BlockProperties.w; +@@ -71,6 +76,19 @@ if ((Boolean) iblockdata.get(BlockButtonAbstract.POWERED)) { return true; } else { @@ -31,10 +31,10 @@ + // CraftBukkit end world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockButtonAbstract.POWERED, true), 3); this.a(entityhuman, world, blockposition, true); - this.c(iblockdata, world, blockposition); -@@ -113,6 +131,16 @@ - if (this.E) { - this.b(iblockdata, world, blockposition); + this.e(iblockdata, world, blockposition); +@@ -117,6 +135,16 @@ + if (this.D) { + this.d(iblockdata, world, blockposition); } else { + // CraftBukkit start + org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); @@ -47,9 +47,9 @@ + } + // CraftBukkit end world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockButtonAbstract.POWERED, false), 3); - this.c(iblockdata, world, blockposition); + this.e(iblockdata, world, blockposition); this.a((EntityHuman) null, world, blockposition, false); -@@ -132,7 +160,44 @@ +@@ -137,7 +165,44 @@ boolean flag = !list.isEmpty(); boolean flag1 = (Boolean) iblockdata.get(BlockButtonAbstract.POWERED); @@ -92,5 +92,5 @@ + } + // CraftBukkit end world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockButtonAbstract.POWERED, flag), 3); - this.c(iblockdata, world, blockposition); + this.e(iblockdata, world, blockposition); this.a((EntityHuman) null, world, blockposition, flag); diff --git a/nms-patches/BlockCactus.patch b/nms-patches/BlockCactus.patch index b98d62b037..58f6e31d08 100644 --- a/nms-patches/BlockCactus.patch +++ b/nms-patches/BlockCactus.patch @@ -8,8 +8,8 @@ + public class BlockCactus extends Block { - public static final BlockStateInteger AGE = BlockProperties.X; -@@ -31,7 +33,7 @@ + public static final BlockStateInteger AGE = BlockProperties.ad; +@@ -32,7 +34,7 @@ int j = (Integer) iblockdata.get(BlockCactus.AGE); if (j == 15) { @@ -18,13 +18,13 @@ IBlockData iblockdata1 = (IBlockData) iblockdata.set(BlockCactus.AGE, 0); world.setTypeAndData(blockposition, iblockdata1, 4); -@@ -92,7 +94,9 @@ - } +@@ -95,7 +97,9 @@ + @Override public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { + CraftEventFactory.blockDamage = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); // CraftBukkit entity.damageEntity(DamageSource.CACTUS, 1.0F); + CraftEventFactory.blockDamage = null; // CraftBukkit } - public TextureType c() { + @Override diff --git a/nms-patches/BlockCake.patch b/nms-patches/BlockCake.patch index cb5c7675a4..d08e6c8aaf 100644 --- a/nms-patches/BlockCake.patch +++ b/nms-patches/BlockCake.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/BlockCake.java +++ b/net/minecraft/server/BlockCake.java -@@ -33,7 +33,18 @@ +@@ -31,7 +31,18 @@ return false; } else { entityhuman.a(StatisticList.EAT_CAKE_SLICE); diff --git a/nms-patches/BlockCauldron.patch b/nms-patches/BlockCauldron.patch index fdea61417d..1a47f4c641 100644 --- a/nms-patches/BlockCauldron.patch +++ b/nms-patches/BlockCauldron.patch @@ -7,7 +7,7 @@ + public class BlockCauldron extends Block { - public static final BlockStateInteger LEVEL = BlockProperties.af; + public static final BlockStateInteger LEVEL = BlockProperties.al; @@ -32,8 +34,13 @@ float f = (float) blockposition.getY() + (6.0F + (float) (3 * i)) / 16.0F; @@ -23,7 +23,7 @@ } } -@@ -49,18 +56,27 @@ +@@ -50,18 +57,27 @@ if (item == Items.WATER_BUCKET) { if (i < 3 && !world.isClientSide) { @@ -52,7 +52,7 @@ if (!entityhuman.abilities.canInstantlyBuild) { itemstack.subtract(1); if (itemstack.isEmpty()) { -@@ -71,7 +87,8 @@ +@@ -72,7 +88,8 @@ } entityhuman.a(StatisticList.USE_CAULDRON); @@ -62,7 +62,7 @@ world.a((EntityHuman) null, blockposition, SoundEffects.ITEM_BUCKET_FILL, SoundCategory.BLOCKS, 1.0F, 1.0F); } -@@ -81,6 +98,10 @@ +@@ -82,6 +99,10 @@ if (item == Items.GLASS_BOTTLE) { if (i > 0 && !world.isClientSide) { @@ -73,7 +73,7 @@ if (!entityhuman.abilities.canInstantlyBuild) { itemstack1 = PotionUtil.a(new ItemStack(Items.POTION), Potions.b); entityhuman.a(StatisticList.USE_CAULDRON); -@@ -95,12 +116,17 @@ +@@ -96,12 +117,17 @@ } world.a((EntityHuman) null, blockposition, SoundEffects.ITEM_BOTTLE_FILL, SoundCategory.BLOCKS, 1.0F, 1.0F); @@ -92,7 +92,7 @@ if (!entityhuman.abilities.canInstantlyBuild) { itemstack1 = new ItemStack(Items.GLASS_BOTTLE); entityhuman.a(StatisticList.USE_CAULDRON); -@@ -111,7 +137,8 @@ +@@ -112,7 +138,8 @@ } world.a((EntityHuman) null, blockposition, SoundEffects.ITEM_BOTTLE_EMPTY, SoundCategory.BLOCKS, 1.0F, 1.0F); @@ -102,22 +102,22 @@ } return true; -@@ -120,8 +147,13 @@ - ItemArmorColorable itemarmorcolorable = (ItemArmorColorable) item; +@@ -121,8 +148,13 @@ + IDyeable idyeable = (IDyeable) item; - if (itemarmorcolorable.e(itemstack) && !world.isClientSide) { + if (idyeable.a(itemstack) && !world.isClientSide) { + // CraftBukkit start + if (!this.changeLevel(world, blockposition, iblockdata, i - 1, entityhuman, CauldronLevelChangeEvent.ChangeReason.ARMOR_WASH)) { + return true; + } - itemarmorcolorable.g(itemstack); + idyeable.c(itemstack); - this.a(world, blockposition, iblockdata, i - 1); + // this.a(world, blockposition, iblockdata, i - 1); + // CraftBukkit end entityhuman.a(StatisticList.CLEAN_ARMOR); return true; } -@@ -129,13 +161,18 @@ +@@ -130,13 +162,18 @@ if (i > 0 && item instanceof ItemBanner) { if (TileEntityBanner.a(itemstack) > 0 && !world.isClientSide) { @@ -137,7 +137,7 @@ } if (itemstack.isEmpty()) { -@@ -172,9 +209,25 @@ +@@ -173,9 +210,25 @@ } } @@ -163,8 +163,8 @@ + // CraftBukkit end } - public void c(World world, BlockPosition blockposition) { -@@ -185,7 +238,7 @@ + @Override +@@ -187,7 +240,7 @@ IBlockData iblockdata = world.getType(blockposition); if ((Integer) iblockdata.get(BlockCauldron.LEVEL) < 3) { diff --git a/nms-patches/BlockChorusFlower.patch b/nms-patches/BlockChorusFlower.patch index 168e4364ac..585fcf5490 100644 --- a/nms-patches/BlockChorusFlower.patch +++ b/nms-patches/BlockChorusFlower.patch @@ -8,11 +8,11 @@ + public class BlockChorusFlower extends Block { - public static final BlockStateInteger AGE = BlockProperties.V; -@@ -61,8 +63,12 @@ + public static final BlockStateInteger AGE = BlockProperties.ab; +@@ -58,8 +60,12 @@ } - if (flag && a((IWorldReader) world, blockposition1, (EnumDirection) null) && world.isEmpty(blockposition.up(2))) { + if (flag && b((IWorldReader) world, blockposition1, (EnumDirection) null) && world.isEmpty(blockposition.up(2))) { - world.setTypeAndData(blockposition, this.b.a((IBlockAccess) world, blockposition), 2); - this.b(world, blockposition1, i); + // CraftBukkit start - add event @@ -24,10 +24,10 @@ } else if (i < 4) { j = random.nextInt(4); if (flag1) { -@@ -76,18 +82,30 @@ +@@ -73,18 +79,30 @@ BlockPosition blockposition2 = blockposition.shift(enumdirection); - if (world.isEmpty(blockposition2) && world.isEmpty(blockposition2.down()) && a((IWorldReader) world, blockposition2, enumdirection.opposite())) { + if (world.isEmpty(blockposition2) && world.isEmpty(blockposition2.down()) && b((IWorldReader) world, blockposition2, enumdirection.opposite())) { - this.b(world, blockposition2, i + 1); - flag2 = true; + // CraftBukkit start - add event diff --git a/nms-patches/BlockCocoa.patch b/nms-patches/BlockCocoa.patch index 7ee24a9589..6ad7df1a1c 100644 --- a/nms-patches/BlockCocoa.patch +++ b/nms-patches/BlockCocoa.patch @@ -8,8 +8,8 @@ + public class BlockCocoa extends BlockFacingHorizontal implements IBlockFragilePlantElement { - public static final BlockStateInteger AGE = BlockProperties.T; -@@ -21,7 +23,7 @@ + public static final BlockStateInteger AGE = BlockProperties.Z; +@@ -22,7 +24,7 @@ int i = (Integer) iblockdata.get(BlockCocoa.AGE); if (i < 2) { @@ -18,12 +18,12 @@ } } -@@ -106,7 +108,7 @@ - } +@@ -92,7 +94,7 @@ + @Override public void b(World world, Random random, BlockPosition blockposition, IBlockData iblockdata) { - world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockCocoa.AGE, (Integer) iblockdata.get(BlockCocoa.AGE) + 1), 2); + CraftEventFactory.handleBlockGrowEvent(world, blockposition, (IBlockData) iblockdata.set(BlockCocoa.AGE, (Integer) iblockdata.get(BlockCocoa.AGE) + 1), 2); // CraftBukkit } - public TextureType c() { + @Override diff --git a/nms-patches/BlockCommand.patch b/nms-patches/BlockCommand.patch index 4f0974f244..75b5e602c8 100644 --- a/nms-patches/BlockCommand.patch +++ b/nms-patches/BlockCommand.patch @@ -9,19 +9,19 @@ public class BlockCommand extends BlockTileEntity { private static final Logger c = LogManager.getLogger(); -@@ -30,6 +32,15 @@ +@@ -32,6 +34,15 @@ TileEntityCommand tileentitycommand = (TileEntityCommand) tileentity; - boolean flag = world.isBlockIndirectlyPowered(blockposition); - boolean flag1 = tileentitycommand.d(); + boolean flag1 = world.isBlockIndirectlyPowered(blockposition); + boolean flag2 = tileentitycommand.d(); + // CraftBukkit start + org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); -+ int old = flag1 ? 15 : 0; -+ int current = flag ? 15 : 0; ++ int old = flag2 ? 15 : 0; ++ int current = flag1 ? 15 : 0; + + BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bukkitBlock, old, current); + world.getServer().getPluginManager().callEvent(eventRedstone); -+ flag = eventRedstone.getNewCurrent() > 0; ++ flag1 = eventRedstone.getNewCurrent() > 0; + // CraftBukkit end - tileentitycommand.a(flag); - if (!flag1 && !tileentitycommand.e() && tileentitycommand.j() != TileEntityCommand.Type.SEQUENCE) { + tileentitycommand.a(flag1); + if (!flag2 && !tileentitycommand.f() && tileentitycommand.t() != TileEntityCommand.Type.SEQUENCE) { diff --git a/nms-patches/BlockComposter.patch b/nms-patches/BlockComposter.patch new file mode 100644 index 0000000000..40a299aef3 --- /dev/null +++ b/nms-patches/BlockComposter.patch @@ -0,0 +1,55 @@ +--- a/net/minecraft/server/BlockComposter.java ++++ b/net/minecraft/server/BlockComposter.java +@@ -4,13 +4,14 @@ + import it.unimi.dsi.fastutil.objects.Object2FloatOpenHashMap; + import java.util.Random; + import javax.annotation.Nullable; ++import org.bukkit.craftbukkit.inventory.CraftBlockInventoryHolder; // CraftBukkit + + public class BlockComposter extends Block implements IInventoryHolder { + + public static final BlockStateInteger a = BlockProperties.am; + public static final Object2FloatMap b = new Object2FloatOpenHashMap(); + public static final VoxelShape c = VoxelShapes.b(); +- private static final VoxelShape[] d = (VoxelShape[]) SystemUtils.a((Object) (new VoxelShape[9]), (avoxelshape) -> { ++ private static final VoxelShape[] d = (VoxelShape[]) SystemUtils.a((new VoxelShape[9]), (avoxelshape) -> { // CraftBukkit - decompile error + for (int i = 0; i < 8; ++i) { + avoxelshape[i] = VoxelShapes.a(BlockComposter.c, Block.a(2.0D, (double) Math.max(2, 1 + i * 2), 2.0D, 14.0D, 16.0D, 14.0D), OperatorBoolean.ONLY_FIRST); + } +@@ -220,7 +221,8 @@ + public IWorldInventory a(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition) { + int i = (Integer) iblockdata.get(BlockComposter.a); + +- return (IWorldInventory) (i == 8 ? new BlockComposter.ContainerOutput(iblockdata, generatoraccess, blockposition, new ItemStack(Items.BONE_MEAL)) : (i < 7 ? new BlockComposter.ContainerInput(iblockdata, generatoraccess, blockposition) : new BlockComposter.ContainerEmpty())); ++ // CraftBukkit - empty generatoraccess, blockposition ++ return (IWorldInventory) (i == 8 ? new BlockComposter.ContainerOutput(iblockdata, generatoraccess, blockposition, new ItemStack(Items.BONE_MEAL)) : (i < 7 ? new BlockComposter.ContainerInput(iblockdata, generatoraccess, blockposition) : new BlockComposter.ContainerEmpty(generatoraccess, blockposition))); + } + + static class ContainerInput extends InventorySubcontainer implements IWorldInventory { +@@ -232,6 +234,7 @@ + + public ContainerInput(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition) { + super(1); ++ this.bukkitOwner = new CraftBlockInventoryHolder(generatoraccess, blockposition, this); // CraftBukkit + this.a = iblockdata; + this.b = generatoraccess; + this.c = blockposition; +@@ -282,6 +285,7 @@ + this.a = iblockdata; + this.b = generatoraccess; + this.c = blockposition; ++ this.bukkitOwner = new CraftBlockInventoryHolder(generatoraccess, blockposition, this); // CraftBukkit + } + + @Override +@@ -313,8 +317,9 @@ + + static class ContainerEmpty extends InventorySubcontainer implements IWorldInventory { + +- public ContainerEmpty() { ++ public ContainerEmpty(GeneratorAccess generatoraccess, BlockPosition blockposition) { // CraftBukkit + super(0); ++ this.bukkitOwner = new CraftBlockInventoryHolder(generatoraccess, blockposition, this); // CraftBukkit + } + + @Override diff --git a/nms-patches/BlockConcretePowder.patch b/nms-patches/BlockConcretePowder.patch index bebc324a8c..c525720fd2 100644 --- a/nms-patches/BlockConcretePowder.patch +++ b/nms-patches/BlockConcretePowder.patch @@ -11,22 +11,22 @@ public class BlockConcretePowder extends BlockFalling { private final IBlockData a; -@@ -11,7 +16,7 @@ - +@@ -12,7 +17,7 @@ + @Override public void a(World world, BlockPosition blockposition, IBlockData iblockdata, IBlockData iblockdata1) { - if (x(iblockdata1)) { + if (canHarden(iblockdata1)) { - world.setTypeAndData(blockposition, this.a, 3); + org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition, this.a, 3); // CraftBukkit } } -@@ -20,7 +25,24 @@ +@@ -22,7 +27,24 @@ World world = blockactioncontext.getWorld(); BlockPosition blockposition = blockactioncontext.getClickPosition(); -- return !x(world.getType(blockposition)) && !a((IBlockAccess) world, blockposition) ? super.getPlacedState(blockactioncontext) : this.a; +- return !canHarden(world.getType(blockposition)) && !a((IBlockAccess) world, blockposition) ? super.getPlacedState(blockactioncontext) : this.a; + // CraftBukkit start -+ if (!x(world.getType(blockposition)) && !a((IBlockAccess) world, blockposition)) { ++ if (!canHarden(world.getType(blockposition)) && !a((IBlockAccess) world, blockposition)) { + return super.getPlacedState(blockactioncontext); + } + @@ -46,9 +46,9 @@ } private static boolean a(IBlockAccess iblockaccess, BlockPosition blockposition) { -@@ -51,6 +73,20 @@ - } +@@ -54,6 +76,20 @@ + @Override public IBlockData updateState(IBlockData iblockdata, EnumDirection enumdirection, IBlockData iblockdata1, GeneratorAccess generatoraccess, BlockPosition blockposition, BlockPosition blockposition1) { - return a((IBlockAccess) generatoraccess, blockposition) ? this.a : super.updateState(iblockdata, enumdirection, iblockdata1, generatoraccess, blockposition, blockposition1); + // CraftBukkit start diff --git a/nms-patches/BlockCoral.patch b/nms-patches/BlockCoral.patch index 6b5b5afc99..aef0dabc42 100644 --- a/nms-patches/BlockCoral.patch +++ b/nms-patches/BlockCoral.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/BlockCoral.java +++ b/net/minecraft/server/BlockCoral.java -@@ -14,6 +14,11 @@ - - public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) { +@@ -15,6 +15,11 @@ + @Override + public void tick(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) { if (!this.a((IBlockAccess) world, blockposition)) { + // CraftBukkit start + if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(world, blockposition, this.a.getBlockData()).isCancelled()) { diff --git a/nms-patches/BlockCoralFan.patch b/nms-patches/BlockCoralFan.patch index 94a22488d9..7653ce24fe 100644 --- a/nms-patches/BlockCoralFan.patch +++ b/nms-patches/BlockCoralFan.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/BlockCoralFan.java +++ b/net/minecraft/server/BlockCoralFan.java -@@ -17,6 +17,11 @@ - - public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) { +@@ -19,6 +19,11 @@ + @Override + public void tick(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) { if (!b_(iblockdata, world, blockposition)) { + // CraftBukkit start + if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(world, blockposition, this.a.getBlockData().set(BlockCoralFan.b, false)).isCancelled()) { diff --git a/nms-patches/BlockCoralFanWall.patch b/nms-patches/BlockCoralFanWall.patch index 224ce09c18..a65bc7fedf 100644 --- a/nms-patches/BlockCoralFanWall.patch +++ b/nms-patches/BlockCoralFanWall.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/BlockCoralFanWall.java +++ b/net/minecraft/server/BlockCoralFanWall.java -@@ -17,6 +17,11 @@ - - public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) { +@@ -19,6 +19,11 @@ + @Override + public void tick(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) { if (!b_(iblockdata, world, blockposition)) { + // CraftBukkit start + if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(world, blockposition, this.c.getBlockData().set(BlockCoralFanWall.b, false).set(BlockCoralFanWall.a, iblockdata.get(BlockCoralFanWall.a))).isCancelled()) { diff --git a/nms-patches/BlockCoralPlant.patch b/nms-patches/BlockCoralPlant.patch index 65177b8385..5cb15ebbdd 100644 --- a/nms-patches/BlockCoralPlant.patch +++ b/nms-patches/BlockCoralPlant.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/BlockCoralPlant.java +++ b/net/minecraft/server/BlockCoralPlant.java -@@ -18,6 +18,11 @@ - - public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) { +@@ -20,6 +20,11 @@ + @Override + public void tick(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) { if (!b_(iblockdata, world, blockposition)) { + // CraftBukkit start + if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(world, blockposition, this.c.getBlockData().set(BlockCoralPlant.b, false)).isCancelled()) { diff --git a/nms-patches/BlockCrops.patch b/nms-patches/BlockCrops.patch index da3a8644f0..bca03cda73 100644 --- a/nms-patches/BlockCrops.patch +++ b/nms-patches/BlockCrops.patch @@ -8,8 +8,8 @@ + public class BlockCrops extends BlockPlant implements IBlockFragilePlantElement { - public static final BlockStateInteger AGE = BlockProperties.W; -@@ -49,7 +51,7 @@ + public static final BlockStateInteger AGE = BlockProperties.ac; +@@ -52,7 +54,7 @@ float f = a((Block) this, (IBlockAccess) world, blockposition); if (random.nextInt((int) (25.0F / f) + 1) == 0) { @@ -18,7 +18,7 @@ } } } -@@ -64,7 +66,7 @@ +@@ -67,7 +69,7 @@ i = j; } diff --git a/nms-patches/BlockDaylightDetector.patch b/nms-patches/BlockDaylightDetector.patch index 83622a4c56..a1263c21d1 100644 --- a/nms-patches/BlockDaylightDetector.patch +++ b/nms-patches/BlockDaylightDetector.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/BlockDaylightDetector.java +++ b/net/minecraft/server/BlockDaylightDetector.java -@@ -36,6 +36,7 @@ +@@ -43,6 +43,7 @@ i = MathHelper.clamp(i, 0, 15); if ((Integer) iblockdata.get(BlockDaylightDetector.POWER) != i) { diff --git a/nms-patches/BlockDiodeAbstract.patch b/nms-patches/BlockDiodeAbstract.patch index 2ecd9be0c7..c512f2e5e5 100644 --- a/nms-patches/BlockDiodeAbstract.patch +++ b/nms-patches/BlockDiodeAbstract.patch @@ -9,7 +9,7 @@ public abstract class BlockDiodeAbstract extends BlockFacingHorizontal { protected static final VoxelShape b = Block.a(0.0D, 0.0D, 0.0D, 16.0D, 2.0D, 16.0D); -@@ -29,8 +31,18 @@ +@@ -28,8 +30,18 @@ boolean flag1 = this.a(world, blockposition, iblockdata); if (flag && !flag1) { @@ -27,4 +27,4 @@ + // CraftBukkit end world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockDiodeAbstract.c, true), 2); if (!flag1) { - world.getBlockTickList().a(blockposition, this, this.k(iblockdata), TickListPriority.HIGH); + world.getBlockTickList().a(blockposition, this, this.j(iblockdata), TickListPriority.HIGH); diff --git a/nms-patches/BlockDirtSnowSpreadable.patch b/nms-patches/BlockDirtSnowSpreadable.patch index af18d01d07..8fc77afd0d 100644 --- a/nms-patches/BlockDirtSnowSpreadable.patch +++ b/nms-patches/BlockDirtSnowSpreadable.patch @@ -1,23 +1,23 @@ --- a/net/minecraft/server/BlockDirtSnowSpreadable.java +++ b/net/minecraft/server/BlockDirtSnowSpreadable.java -@@ -23,6 +23,11 @@ - public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) { +@@ -31,6 +31,11 @@ + public void tick(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) { if (!world.isClientSide) { - if (!a((IWorldReader) world, blockposition)) { + if (!b(iblockdata, (IWorldReader) world, blockposition)) { + // CraftBukkit start + if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(world, blockposition, Blocks.DIRT.getBlockData()).isCancelled()) { + return; + } + // CraftBukkit end world.setTypeUpdate(blockposition, Blocks.DIRT.getBlockData()); - } else { + } else if (world.getLightLevel(blockposition.up()) >= 4) { if (world.getLightLevel(blockposition.up()) >= 9) { -@@ -34,7 +39,7 @@ - } +@@ -40,7 +45,7 @@ + BlockPosition blockposition1 = blockposition.b(random.nextInt(3) - 1, random.nextInt(5) - 3, random.nextInt(3) - 1); - if (world.getType(blockposition1).getBlock() == Blocks.DIRT && b(world, blockposition1)) { -- world.setTypeUpdate(blockposition1, this.getBlockData()); -+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(world, blockposition, blockposition1, this.getBlockData()); // CraftBukkit + if (world.getType(blockposition1).getBlock() == Blocks.DIRT && c(iblockdata1, (IWorldReader) world, blockposition1)) { +- world.setTypeUpdate(blockposition1, (IBlockData) iblockdata1.set(BlockDirtSnowSpreadable.a, world.getType(blockposition1.up()).getBlock() == Blocks.SNOW)); ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(world, blockposition, blockposition1, (IBlockData) iblockdata1.set(BlockDirtSnowSpreadable.a, world.getType(blockposition1.up()).getBlock() == Blocks.SNOW)); // CraftBukkit } } } diff --git a/nms-patches/BlockDispenser.patch b/nms-patches/BlockDispenser.patch index 7add46ebe3..1f9fe300f6 100644 --- a/nms-patches/BlockDispenser.patch +++ b/nms-patches/BlockDispenser.patch @@ -3,7 +3,7 @@ @@ -8,9 +8,10 @@ public static final BlockStateDirection FACING = BlockDirectional.FACING; - public static final BlockStateBoolean TRIGGERED = BlockProperties.w; + public static final BlockStateBoolean TRIGGERED = BlockProperties.A; - public static final Map REGISTRY = (Map) SystemUtils.a((Object) (new Object2ObjectOpenHashMap()), (object2objectopenhashmap) -> { + public static final Map REGISTRY = (Map) SystemUtils.a((new Object2ObjectOpenHashMap()), (object2objectopenhashmap) -> { // CraftBukkit - decompile error object2objectopenhashmap.defaultReturnValue(new DispenseBehaviorItem()); @@ -12,7 +12,7 @@ public static void a(IMaterial imaterial, IDispenseBehavior idispensebehavior) { BlockDispenser.REGISTRY.put(imaterial.getItem(), idispensebehavior); -@@ -56,6 +57,7 @@ +@@ -58,6 +59,7 @@ IDispenseBehavior idispensebehavior = this.a(itemstack); if (idispensebehavior != IDispenseBehavior.NONE) { diff --git a/nms-patches/BlockDoor.patch b/nms-patches/BlockDoor.patch index 2ace0dc84e..b7d9728788 100644 --- a/nms-patches/BlockDoor.patch +++ b/nms-patches/BlockDoor.patch @@ -9,11 +9,11 @@ public class BlockDoor extends Block { public static final BlockStateDirection FACING = BlockFacingHorizontal.FACING; -@@ -163,9 +165,24 @@ - } +@@ -171,9 +173,24 @@ - public void doPhysics(IBlockData iblockdata, World world, BlockPosition blockposition, Block block, BlockPosition blockposition1) { -- boolean flag = world.isBlockIndirectlyPowered(blockposition) || world.isBlockIndirectlyPowered(blockposition.shift(iblockdata.get(BlockDoor.HALF) == BlockPropertyDoubleBlockHalf.LOWER ? EnumDirection.UP : EnumDirection.DOWN)); + @Override + public void doPhysics(IBlockData iblockdata, World world, BlockPosition blockposition, Block block, BlockPosition blockposition1, boolean flag) { +- boolean flag1 = world.isBlockIndirectlyPowered(blockposition) || world.isBlockIndirectlyPowered(blockposition.shift(iblockdata.get(BlockDoor.HALF) == BlockPropertyDoubleBlockHalf.LOWER ? EnumDirection.UP : EnumDirection.DOWN)); + // CraftBukkit start + BlockPosition otherHalf = blockposition.shift(iblockdata.get(BlockDoor.HALF) == BlockPropertyDoubleBlockHalf.LOWER ? EnumDirection.UP : EnumDirection.DOWN); + @@ -30,9 +30,9 @@ + BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bukkitBlock, oldPower, power); + world.getServer().getPluginManager().callEvent(eventRedstone); -- if (block != this && flag != (Boolean) iblockdata.get(BlockDoor.POWERED)) { -+ boolean flag = eventRedstone.getNewCurrent() > 0; +- if (block != this && flag1 != (Boolean) iblockdata.get(BlockDoor.POWERED)) { ++ boolean flag1 = eventRedstone.getNewCurrent() > 0; + // CraftBukkit end - if (flag != (Boolean) iblockdata.get(BlockDoor.OPEN)) { - this.b(world, blockposition, flag); + if (flag1 != (Boolean) iblockdata.get(BlockDoor.OPEN)) { + this.b(world, blockposition, flag1); } diff --git a/nms-patches/BlockDragonEgg.patch b/nms-patches/BlockDragonEgg.patch index 1533b9bd76..5cfda88ff7 100644 --- a/nms-patches/BlockDragonEgg.patch +++ b/nms-patches/BlockDragonEgg.patch @@ -8,8 +8,8 @@ public class BlockDragonEgg extends BlockFalling { protected static final VoxelShape a = Block.a(1.0D, 0.0D, 1.0D, 15.0D, 16.0D, 15.0D); -@@ -26,6 +28,18 @@ - BlockPosition blockposition1 = blockposition.a(world.random.nextInt(16) - world.random.nextInt(16), world.random.nextInt(8) - world.random.nextInt(8), world.random.nextInt(16) - world.random.nextInt(16)); +@@ -29,6 +31,18 @@ + BlockPosition blockposition1 = blockposition.b(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).isAir()) { + // CraftBukkit start diff --git a/nms-patches/BlockDropper.patch b/nms-patches/BlockDropper.patch index ba4ddc9b16..23ac1e1846 100644 --- a/nms-patches/BlockDropper.patch +++ b/nms-patches/BlockDropper.patch @@ -11,7 +11,7 @@ public class BlockDropper extends BlockDispenser { private static final IDispenseBehavior c = new DispenseBehaviorItem(); -@@ -34,8 +39,25 @@ +@@ -37,8 +42,25 @@ if (iinventory == null) { itemstack1 = BlockDropper.c.dispense(sourceblock, itemstack); } else { diff --git a/nms-patches/BlockEnderPortal.patch b/nms-patches/BlockEnderPortal.patch index 0ffb11e0c8..a5e6e64921 100644 --- a/nms-patches/BlockEnderPortal.patch +++ b/nms-patches/BlockEnderPortal.patch @@ -1,22 +1,21 @@ --- a/net/minecraft/server/BlockEnderPortal.java +++ b/net/minecraft/server/BlockEnderPortal.java -@@ -2,6 +2,8 @@ - - import java.util.Random; +@@ -1,5 +1,7 @@ + package net.minecraft.server; +import org.bukkit.event.entity.EntityPortalEnterEvent; // CraftBukkit + public class BlockEnderPortal extends BlockTileEntity { protected static final VoxelShape a = Block.a(0.0D, 0.0D, 0.0D, 16.0D, 12.0D, 16.0D); -@@ -28,6 +30,10 @@ - +@@ -21,6 +23,10 @@ + @Override public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { - if (!world.isClientSide && !entity.isPassenger() && !entity.isVehicle() && entity.bm() && VoxelShapes.c(VoxelShapes.a(entity.getBoundingBox().d((double) (-blockposition.getX()), (double) (-blockposition.getY()), (double) (-blockposition.getZ()))), iblockdata.getShape(world, blockposition), OperatorBoolean.AND)) { + if (!world.isClientSide && !entity.isPassenger() && !entity.isVehicle() && entity.canPortal() && VoxelShapes.c(VoxelShapes.a(entity.getBoundingBox().d((double) (-blockposition.getX()), (double) (-blockposition.getY()), (double) (-blockposition.getZ()))), iblockdata.getShape(world, blockposition), OperatorBoolean.AND)) { + // CraftBukkit start - Entity in portal + EntityPortalEnterEvent event = new EntityPortalEnterEvent(entity.getBukkitEntity(), new org.bukkit.Location(world.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ())); + world.getServer().getPluginManager().callEvent(event); + // CraftBukkit end - entity.a(DimensionManager.THE_END); + entity.a(world.worldProvider.getDimensionManager() == DimensionManager.THE_END ? DimensionManager.OVERWORLD : DimensionManager.THE_END); } diff --git a/nms-patches/BlockFire.patch b/nms-patches/BlockFire.patch index 399b8d34fd..1db0b9bf6c 100644 --- a/nms-patches/BlockFire.patch +++ b/nms-patches/BlockFire.patch @@ -1,11 +1,10 @@ --- a/net/minecraft/server/BlockFire.java +++ b/net/minecraft/server/BlockFire.java -@@ -7,6 +7,16 @@ +@@ -7,6 +7,15 @@ import java.util.Map.Entry; import javax.annotation.Nullable; +// CraftBukkit start -+ +import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.block.CraftBlockState; +import org.bukkit.craftbukkit.event.CraftEventFactory; @@ -16,10 +15,10 @@ + public class BlockFire extends Block { - public static final BlockStateInteger AGE = BlockProperties.X; -@@ -31,7 +41,20 @@ - } + public static final BlockStateInteger AGE = BlockProperties.ad; +@@ -33,7 +42,20 @@ + @Override public IBlockData updateState(IBlockData iblockdata, EnumDirection enumdirection, IBlockData iblockdata1, GeneratorAccess generatoraccess, BlockPosition blockposition, BlockPosition blockposition1) { - return this.canPlace(iblockdata, generatoraccess, blockposition) ? (IBlockData) this.a((IBlockAccess) generatoraccess, blockposition).set(BlockFire.AGE, iblockdata.get(BlockFire.AGE)) : Blocks.AIR.getBlockData(); + // CraftBukkit start @@ -39,43 +38,43 @@ } @Nullable -@@ -81,7 +104,7 @@ - public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) { +@@ -82,7 +104,7 @@ + public void tick(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) { if (world.getGameRules().getBoolean("doFireTick")) { if (!iblockdata.canPlace(world, blockposition)) { -- world.setAir(blockposition); +- world.a(blockposition, false); + fireExtinguished(world, blockposition); // CraftBukkit - invalid place location } Block block = world.getType(blockposition.down()).getBlock(); -@@ -89,7 +112,7 @@ +@@ -90,7 +112,7 @@ int i = (Integer) iblockdata.get(BlockFire.AGE); if (!flag && world.isRaining() && this.a(world, blockposition) && random.nextFloat() < 0.2F + (float) i * 0.03F) { -- world.setAir(blockposition); +- world.a(blockposition, false); + fireExtinguished(world, blockposition); // CraftBukkit - extinguished by rain } else { int j = Math.min(15, i + random.nextInt(3) / 2); -@@ -102,14 +125,14 @@ - world.getBlockTickList().a(blockposition, this, this.a((IWorldReader) world) + random.nextInt(10)); - if (!this.d(world, blockposition)) { - if (!world.getType(blockposition.down()).q() || i > 3) { -- world.setAir(blockposition); +@@ -105,14 +127,14 @@ + BlockPosition blockposition1 = blockposition.down(); + + if (!Block.d(world.getType(blockposition1), world, blockposition1, EnumDirection.UP) || i > 3) { +- world.a(blockposition, false); + fireExtinguished(world, blockposition); // CraftBukkit } return; } - if (i == 15 && random.nextInt(4) == 0 && !this.k(world.getType(blockposition.down()))) { -- world.setAir(blockposition); + if (i == 15 && random.nextInt(4) == 0 && !this.j(world.getType(blockposition.down()))) { +- world.a(blockposition, false); + fireExtinguished(world, blockposition); // CraftBukkit return; } } -@@ -117,12 +140,14 @@ - boolean flag1 = world.x(blockposition); +@@ -120,12 +142,14 @@ + boolean flag1 = world.t(blockposition); int k = flag1 ? -50 : 0; - this.a(world, blockposition.east(), 300 + k, random, i); @@ -95,13 +94,13 @@ BlockPosition.MutableBlockPosition blockposition_mutableblockposition = new BlockPosition.MutableBlockPosition(); for (int l = -1; l <= 1; ++l) { -@@ -148,7 +173,15 @@ +@@ -151,7 +175,15 @@ if (i2 > 0 && random.nextInt(k1) <= i2 && (!world.isRaining() || !this.a(world, (BlockPosition) blockposition_mutableblockposition))) { int j2 = Math.min(15, i + random.nextInt(5) / 4); - world.setTypeAndData(blockposition_mutableblockposition, (IBlockData) this.a((IBlockAccess) world, (BlockPosition) blockposition_mutableblockposition).set(BlockFire.AGE, j2), 3); + // CraftBukkit start - Call to stop spread of fire -+ if (world.getType(blockposition_mutableblockposition) != Blocks.FIRE) { ++ if (world.getType(blockposition_mutableblockposition).getBlock() != Blocks.FIRE) { + if (CraftEventFactory.callBlockIgniteEvent(world, blockposition_mutableblockposition, blockposition).isCancelled()) { + continue; + } @@ -112,13 +111,13 @@ } } } -@@ -172,12 +205,24 @@ - return this.flameChances.getInt(block); +@@ -175,12 +207,24 @@ + return iblockdata.b((IBlockState) BlockProperties.C) && (Boolean) iblockdata.get(BlockProperties.C) ? 0 : this.flameChances.getInt(iblockdata.getBlock()); } - private void a(World world, BlockPosition blockposition, int i, Random random, int j) { + private void a(World world, BlockPosition blockposition, int i, Random random, int j, BlockPosition sourceposition) { // CraftBukkit add sourceposition - int k = this.f(world.getType(blockposition).getBlock()); + int k = this.q(world.getType(blockposition)); if (random.nextInt(i) < k) { IBlockData iblockdata = world.getType(blockposition); @@ -138,24 +137,24 @@ if (random.nextInt(j + 10) < 5 && !world.isRainingAt(blockposition)) { int l = Math.min(j + random.nextInt(5) / 4, 15); -@@ -240,7 +285,7 @@ +@@ -243,7 +287,7 @@ if (iblockdata1.getBlock() != iblockdata.getBlock()) { if (world.worldProvider.getDimensionManager() != DimensionManager.OVERWORLD && world.worldProvider.getDimensionManager() != DimensionManager.NETHER || !((BlockPortal) Blocks.NETHER_PORTAL).a((GeneratorAccess) world, blockposition)) { if (!iblockdata.canPlace(world, blockposition)) { -- world.setAir(blockposition); +- world.a(blockposition, false); + fireExtinguished(world, blockposition); // CraftBukkit - fuel block broke } else { world.getBlockTickList().a(blockposition, this, this.a((IWorldReader) world) + world.random.nextInt(10)); } -@@ -386,4 +431,12 @@ - blockfire.a(Blocks.BLACK_CARPET, 60, 20); - blockfire.a(Blocks.DRIED_KELP_BLOCK, 30, 60); +@@ -395,4 +439,12 @@ + blockfire.a(Blocks.COMPOSTER, 5, 20); + blockfire.a(Blocks.SWEET_BERRY_BUSH, 60, 100); } + + // CraftBukkit start + private void fireExtinguished(GeneratorAccess world, BlockPosition position) { + if (!CraftEventFactory.callBlockFadeEvent(world, position, Blocks.AIR.getBlockData()).isCancelled()) { -+ world.setAir(position); ++ world.a(position, false); + } + } + // CraftBukkit end diff --git a/nms-patches/BlockFluids.patch b/nms-patches/BlockFluids.patch index b46d9e2cd7..62d0d908f9 100644 --- a/nms-patches/BlockFluids.patch +++ b/nms-patches/BlockFluids.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/server/BlockFluids.java +++ b/net/minecraft/server/BlockFluids.java -@@ -116,14 +116,20 @@ +@@ -111,14 +111,20 @@ Fluid fluid = world.getFluid(blockposition); - if (fluid.d()) { + if (fluid.isSource()) { - world.setTypeUpdate(blockposition, Blocks.OBSIDIAN.getBlockData()); - this.fizz(world, blockposition); + // CraftBukkit start @@ -14,7 +14,7 @@ return false; } - if (fluid.getHeight() >= 0.44444445F) { + if (fluid.getHeight(world, blockposition) >= 0.44444445F) { - world.setTypeUpdate(blockposition, Blocks.COBBLESTONE.getBlockData()); - this.fizz(world, blockposition); + // CraftBukkit start diff --git a/nms-patches/BlockGrass.patch b/nms-patches/BlockGrass.patch index 7b03779517..4d344f2528 100644 --- a/nms-patches/BlockGrass.patch +++ b/nms-patches/BlockGrass.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/BlockGrass.java +++ b/net/minecraft/server/BlockGrass.java -@@ -58,7 +58,7 @@ +@@ -61,7 +61,7 @@ } if (iblockdata3.canPlace(world, blockposition2)) { diff --git a/nms-patches/BlockIce.patch b/nms-patches/BlockIce.patch index e7a337606f..0f732e5a1a 100644 --- a/nms-patches/BlockIce.patch +++ b/nms-patches/BlockIce.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/server/BlockIce.java +++ b/net/minecraft/server/BlockIce.java -@@ -52,6 +52,11 @@ +@@ -41,6 +41,11 @@ } - protected void b(IBlockData iblockdata, World world, BlockPosition blockposition) { + protected void melt(IBlockData iblockdata, World world, BlockPosition blockposition) { + // CraftBukkit start + if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(world, blockposition, world.worldProvider.isNether() ? Blocks.AIR.getBlockData() : Blocks.WATER.getBlockData()).isCancelled()) { + return; + } + // CraftBukkit end if (world.worldProvider.isNether()) { - world.setAir(blockposition); + world.a(blockposition, false); } else { diff --git a/nms-patches/BlockJukeBox.patch b/nms-patches/BlockJukeBox.patch index 456b3e9284..531fbd700d 100644 --- a/nms-patches/BlockJukeBox.patch +++ b/nms-patches/BlockJukeBox.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/BlockJukeBox.java +++ b/net/minecraft/server/BlockJukeBox.java -@@ -24,7 +24,13 @@ +@@ -25,7 +25,13 @@ TileEntity tileentity = generatoraccess.getTileEntity(blockposition); if (tileentity instanceof TileEntityJukeBox) { diff --git a/nms-patches/BlockKelp.patch b/nms-patches/BlockKelp.patch index b73d089ab3..7f4dc57f10 100644 --- a/nms-patches/BlockKelp.patch +++ b/nms-patches/BlockKelp.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/BlockKelp.java +++ b/net/minecraft/server/BlockKelp.java -@@ -52,7 +52,7 @@ +@@ -49,7 +49,7 @@ IBlockData iblockdata1 = world.getType(blockposition1); if (iblockdata1.getBlock() == Blocks.WATER && (Integer) iblockdata.get(BlockKelp.a) < 25 && random.nextDouble() < 0.14D) { diff --git a/nms-patches/BlockLeaves.patch b/nms-patches/BlockLeaves.patch index 673d04fd77..81ceb76dc7 100644 --- a/nms-patches/BlockLeaves.patch +++ b/nms-patches/BlockLeaves.patch @@ -1,17 +1,17 @@ --- a/net/minecraft/server/BlockLeaves.java +++ b/net/minecraft/server/BlockLeaves.java -@@ -3,6 +3,8 @@ +@@ -2,6 +2,8 @@ + import java.util.Random; - import javax.annotation.Nullable; +import org.bukkit.event.block.LeavesDecayEvent; // CraftBukkit + public class BlockLeaves extends Block { - public static final BlockStateInteger DISTANCE = BlockProperties.ab; -@@ -20,6 +22,14 @@ - - public void b(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) { + public static final BlockStateInteger DISTANCE = BlockProperties.ah; +@@ -21,6 +23,14 @@ + @Override + public void c(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) { if (!(Boolean) iblockdata.get(BlockLeaves.PERSISTENT) && (Integer) iblockdata.get(BlockLeaves.DISTANCE) == 7) { + // CraftBukkit start + LeavesDecayEvent event = new LeavesDecayEvent(world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ())); @@ -21,6 +21,6 @@ + return; + } + // CraftBukkit end - iblockdata.a(world, blockposition, 0); - world.setAir(blockposition); + c(iblockdata, world, blockposition); + world.a(blockposition, false); } diff --git a/nms-patches/BlockLever.patch b/nms-patches/BlockLever.patch index 1470d8a011..4fe672c458 100644 --- a/nms-patches/BlockLever.patch +++ b/nms-patches/BlockLever.patch @@ -7,8 +7,8 @@ + public class BlockLever extends BlockAttachable { - public static final BlockStateBoolean POWERED = BlockProperties.t; -@@ -66,6 +68,20 @@ + public static final BlockStateBoolean POWERED = BlockProperties.w; +@@ -64,6 +66,20 @@ return true; } else { @@ -27,5 +27,5 @@ + // CraftBukkit end + world.setTypeAndData(blockposition, iblockdata, 3); - float f3 = flag ? 0.6F : 0.5F; + float f = flag ? 0.6F : 0.5F; diff --git a/nms-patches/BlockMagma.patch b/nms-patches/BlockMagma.patch index 6e1cc11c38..dae5fe4c5c 100644 --- a/nms-patches/BlockMagma.patch +++ b/nms-patches/BlockMagma.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/server/BlockMagma.java +++ b/net/minecraft/server/BlockMagma.java -@@ -10,7 +10,9 @@ - +@@ -11,7 +11,9 @@ + @Override public void stepOn(World world, BlockPosition blockposition, Entity entity) { if (!entity.isFireProof() && entity instanceof EntityLiving && !EnchantmentManager.i((EntityLiving) entity)) { + org.bukkit.craftbukkit.event.CraftEventFactory.blockDamage = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); // CraftBukkit diff --git a/nms-patches/BlockMinecartDetector.patch b/nms-patches/BlockMinecartDetector.patch index b186b00db2..ff1bbc5916 100644 --- a/nms-patches/BlockMinecartDetector.patch +++ b/nms-patches/BlockMinecartDetector.patch @@ -8,8 +8,8 @@ + public class BlockMinecartDetector extends BlockMinecartTrackAbstract { - public static final BlockStateEnum SHAPE = BlockProperties.S; -@@ -55,6 +57,17 @@ + public static final BlockStateEnum SHAPE = BlockProperties.X; +@@ -61,6 +63,17 @@ flag1 = true; } diff --git a/nms-patches/BlockMobSpawner.patch b/nms-patches/BlockMobSpawner.patch index 2b95d6b1db..19ce837bad 100644 --- a/nms-patches/BlockMobSpawner.patch +++ b/nms-patches/BlockMobSpawner.patch @@ -1,22 +1,22 @@ --- a/net/minecraft/server/BlockMobSpawner.java +++ b/net/minecraft/server/BlockMobSpawner.java -@@ -16,9 +16,19 @@ - - public void dropNaturally(IBlockData iblockdata, World world, BlockPosition blockposition, float f, int i) { - super.dropNaturally(iblockdata, world, blockposition, f, i); +@@ -14,9 +14,19 @@ + @Override + public void dropNaturally(IBlockData iblockdata, World world, BlockPosition blockposition, ItemStack itemstack) { + super.dropNaturally(iblockdata, world, blockposition, itemstack); + /* CraftBukkit start - Delegate to getExpDrop - int j = 15 + world.random.nextInt(15) + world.random.nextInt(15); + int i = 15 + world.random.nextInt(15) + world.random.nextInt(15); - this.dropExperience(world, blockposition, j); + this.dropExperience(world, blockposition, i); + */ + } + + @Override -+ public int getExpDrop(IBlockData iblockdata, World world, BlockPosition blockposition, int enchantmentLevel) { -+ int j = 15 + world.random.nextInt(15) + world.random.nextInt(15); ++ public int getExpDrop(IBlockData iblockdata, World world, BlockPosition blockposition, ItemStack itemstack) { ++ int i = 15 + world.random.nextInt(15) + world.random.nextInt(15); + -+ return j; ++ return i; + // CraftBukkit end } - public EnumRenderType c(IBlockData iblockdata) { + @Override diff --git a/nms-patches/BlockMonsterEggs.patch b/nms-patches/BlockMonsterEggs.patch index 7b493438b3..21da5e70cf 100644 --- a/nms-patches/BlockMonsterEggs.patch +++ b/nms-patches/BlockMonsterEggs.patch @@ -1,16 +1,16 @@ --- a/net/minecraft/server/BlockMonsterEggs.java +++ b/net/minecraft/server/BlockMonsterEggs.java -@@ -4,6 +4,8 @@ +@@ -3,6 +3,8 @@ + import com.google.common.collect.Maps; import java.util.Map; - import java.util.Random; +import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; // CraftBukkit + public class BlockMonsterEggs extends Block { private final Block a; -@@ -36,7 +38,7 @@ - EntitySilverfish entitysilverfish = new EntitySilverfish(world); +@@ -29,7 +31,7 @@ + EntitySilverfish entitysilverfish = (EntitySilverfish) EntityTypes.SILVERFISH.a(world); entitysilverfish.setPositionRotation((double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, 0.0F, 0.0F); - world.addEntity(entitysilverfish); diff --git a/nms-patches/BlockMushroom.patch b/nms-patches/BlockMushroom.patch index 9db3c94c77..b660edc74f 100644 --- a/nms-patches/BlockMushroom.patch +++ b/nms-patches/BlockMushroom.patch @@ -11,7 +11,7 @@ public class BlockMushroom extends BlockPlant implements IBlockFragilePlantElement { protected static final VoxelShape a = Block.a(5.0D, 0.0D, 5.0D, 11.0D, 6.0D, 11.0D); -@@ -43,7 +47,7 @@ +@@ -45,7 +49,7 @@ } if (world.isEmpty(blockposition2) && iblockdata.canPlace(world, blockposition2)) { @@ -20,14 +20,14 @@ } } -@@ -66,8 +70,10 @@ +@@ -70,8 +74,10 @@ WorldGenerator worldgenerator = null; if (this == Blocks.BROWN_MUSHROOM) { + BlockSapling.treeType = TreeType.BROWN_MUSHROOM; // CraftBukkit - worldgenerator = WorldGenerator.U; + worldgenerator = WorldGenerator.HUGE_BROWN_MUSHROOM; } else if (this == Blocks.RED_MUSHROOM) { + BlockSapling.treeType = TreeType.RED_MUSHROOM; // CraftBukkit - worldgenerator = WorldGenerator.T; + worldgenerator = WorldGenerator.HUGE_RED_MUSHROOM; } diff --git a/nms-patches/BlockNetherWart.patch b/nms-patches/BlockNetherWart.patch index 04fc82896a..4fba9280b0 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 -@@ -25,7 +25,7 @@ +@@ -28,7 +28,7 @@ if (i < 3 && random.nextInt(10) == 0) { iblockdata = (IBlockData) iblockdata.set(BlockNetherWart.AGE, i + 1); @@ -8,4 +8,4 @@ + org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(world, blockposition, iblockdata, 2); // CraftBukkit } - super.a(iblockdata, world, blockposition, random); + super.tick(iblockdata, world, blockposition, random); diff --git a/nms-patches/BlockNote.patch b/nms-patches/BlockNote.patch index 5d8f67d5e7..61ab2ef1f7 100644 --- a/nms-patches/BlockNote.patch +++ b/nms-patches/BlockNote.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/server/BlockNote.java +++ b/net/minecraft/server/BlockNote.java -@@ -24,7 +24,7 @@ +@@ -27,7 +27,7 @@ - if (flag != (Boolean) iblockdata.get(BlockNote.POWERED)) { - if (flag) { + if (flag1 != (Boolean) iblockdata.get(BlockNote.POWERED)) { + if (flag1) { - this.play(world, blockposition); + this.play(world, blockposition, iblockdata); // CraftBukkit } - world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockNote.POWERED, flag), 3); -@@ -32,9 +32,14 @@ + world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockNote.POWERED, flag1), 3); +@@ -35,9 +35,14 @@ } @@ -26,7 +26,7 @@ } } -@@ -45,7 +50,7 @@ +@@ -49,7 +54,7 @@ } else { iblockdata = (IBlockData) iblockdata.a((IBlockState) BlockNote.NOTE); world.setTypeAndData(blockposition, iblockdata, 3); @@ -35,8 +35,8 @@ entityhuman.a(StatisticList.TUNE_NOTEBLOCK); return true; } -@@ -53,7 +58,7 @@ - +@@ -58,7 +63,7 @@ + @Override public void attack(IBlockData iblockdata, World world, BlockPosition blockposition, EntityHuman entityhuman) { if (!world.isClientSide) { - this.play(world, blockposition); diff --git a/nms-patches/BlockObserver.patch b/nms-patches/BlockObserver.patch index f3bf60c475..35901b134d 100644 --- a/nms-patches/BlockObserver.patch +++ b/nms-patches/BlockObserver.patch @@ -8,10 +8,10 @@ + public class BlockObserver extends BlockDirectional { - public static final BlockStateBoolean b = BlockProperties.t; -@@ -25,8 +27,18 @@ - - public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) { + public static final BlockStateBoolean b = BlockProperties.w; +@@ -29,8 +31,18 @@ + @Override + public void tick(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) { if ((Boolean) iblockdata.get(BlockObserver.b)) { + // CraftBukkit start + if (CraftEventFactory.callRedstoneChange(world, blockposition, 15, 0).getNewCurrent() != 0) { diff --git a/nms-patches/BlockOre.patch b/nms-patches/BlockOre.patch index 38a989393a..9ac9284134 100644 --- a/nms-patches/BlockOre.patch +++ b/nms-patches/BlockOre.patch @@ -1,45 +1,32 @@ --- a/net/minecraft/server/BlockOre.java +++ b/net/minecraft/server/BlockOre.java -@@ -32,6 +32,7 @@ - - public void dropNaturally(IBlockData iblockdata, World world, BlockPosition blockposition, float f, int i) { - super.dropNaturally(iblockdata, world, blockposition, f, i); +@@ -15,6 +15,7 @@ + @Override + public void dropNaturally(IBlockData iblockdata, World world, BlockPosition blockposition, ItemStack itemstack) { + super.dropNaturally(iblockdata, world, blockposition, itemstack); + /* CraftBukkit start - Delegated to getExpDrop - if (this.getDropType(iblockdata, world, blockposition, i) != this) { - int j = 0; + if (EnchantmentManager.getEnchantmentLevel(Enchantments.SILK_TOUCH, itemstack) == 0) { + int i = this.a(world.random); -@@ -49,9 +50,34 @@ - - this.dropExperience(world, blockposition, j); +@@ -22,6 +23,21 @@ + this.dropExperience(world, blockposition, i); + } } + // */ } - ++ + @Override -+ public int getExpDrop(IBlockData iblockdata, World world, BlockPosition blockposition, int enchantmentLevel) { -+ if (this.getDropType(iblockdata, world, blockposition, enchantmentLevel) != this) { -+ int j = 0; ++ public int getExpDrop(IBlockData iblockdata, World world, BlockPosition blockposition, ItemStack itemstack) { ++ if (EnchantmentManager.getEnchantmentLevel(Enchantments.SILK_TOUCH, itemstack) == 0) { ++ int i = this.a(world.random); + -+ if (this == Blocks.COAL_ORE) { -+ j = MathHelper.nextInt(world.random, 0, 2); -+ } else if (this == Blocks.DIAMOND_ORE) { -+ j = MathHelper.nextInt(world.random, 3, 7); -+ } else if (this == Blocks.EMERALD_ORE) { -+ j = MathHelper.nextInt(world.random, 3, 7); -+ } else if (this == Blocks.LAPIS_ORE) { -+ j = MathHelper.nextInt(world.random, 2, 5); -+ } else if (this == Blocks.NETHER_QUARTZ_ORE) { -+ j = MathHelper.nextInt(world.random, 2, 5); ++ if (i > 0) { ++ return i; + } -+ -+ return j; + } + + return 0; + // CraftBukkit end + } -+ - public ItemStack a(IBlockAccess iblockaccess, BlockPosition blockposition, IBlockData iblockdata) { - return new ItemStack(this); - } + } diff --git a/nms-patches/BlockPiston.patch b/nms-patches/BlockPiston.patch index 30a00535d1..ebdcfaca90 100644 --- a/nms-patches/BlockPiston.patch +++ b/nms-patches/BlockPiston.patch @@ -18,8 +18,8 @@ + public class BlockPiston extends BlockDirectional { - public static final BlockStateBoolean EXTENDED = BlockProperties.f; -@@ -105,6 +117,18 @@ + public static final BlockStateBoolean EXTENDED = BlockProperties.g; +@@ -112,6 +124,18 @@ } } @@ -38,7 +38,7 @@ world.playBlockAction(blockposition, this, b0, enumdirection.a()); } -@@ -277,6 +301,48 @@ +@@ -281,6 +305,48 @@ IBlockData[] aiblockdata = new IBlockData[j]; EnumDirection enumdirection1 = flag ? enumdirection : enumdirection.opposite(); Set set = Sets.newHashSet(list); diff --git a/nms-patches/BlockPlant.patch b/nms-patches/BlockPlant.patch index d3ff331e3d..5c02045770 100644 --- a/nms-patches/BlockPlant.patch +++ b/nms-patches/BlockPlant.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/BlockPlant.java +++ b/net/minecraft/server/BlockPlant.java -@@ -13,7 +13,14 @@ - } +@@ -14,7 +14,14 @@ + @Override public IBlockData updateState(IBlockData iblockdata, EnumDirection enumdirection, IBlockData iblockdata1, GeneratorAccess generatoraccess, BlockPosition blockposition, BlockPosition blockposition1) { - return !iblockdata.canPlace(generatoraccess, blockposition) ? Blocks.AIR.getBlockData() : super.updateState(iblockdata, enumdirection, iblockdata1, generatoraccess, blockposition, blockposition1); + // CraftBukkit start @@ -15,4 +15,4 @@ + // CraftBukkit end } - public boolean canPlace(IBlockData iblockdata, IWorldReader iworldreader, BlockPosition blockposition) { + @Override diff --git a/nms-patches/BlockPortal.patch b/nms-patches/BlockPortal.patch index 571debd1b5..636d1da946 100644 --- a/nms-patches/BlockPortal.patch +++ b/nms-patches/BlockPortal.patch @@ -12,18 +12,18 @@ + public class BlockPortal extends Block { - public static final BlockStateEnum AXIS = BlockProperties.z; -@@ -36,7 +42,8 @@ + public static final BlockStateEnum AXIS = BlockProperties.D; +@@ -34,7 +40,8 @@ } - if (i > 0 && !world.getType(blockposition1.up()).isOccluding()) { -- Entity entity = EntityTypes.ZOMBIE_PIGMAN.a(world, (NBTTagCompound) null, (IChatBaseComponent) null, (EntityHuman) null, blockposition1.up(), false, false); + if (world.getType(blockposition).a((IBlockAccess) world, blockposition, EntityTypes.ZOMBIE_PIGMAN)) { +- Entity entity = EntityTypes.ZOMBIE_PIGMAN.spawnCreature(world, (NBTTagCompound) null, (IChatBaseComponent) null, (EntityHuman) null, blockposition.up(), EnumMobSpawn.STRUCTURE, false, false); + // CraftBukkit - set spawn reason to NETHER_PORTAL -+ Entity entity = EntityTypes.ZOMBIE_PIGMAN.spawnCreature(world, (NBTTagCompound) null, (IChatBaseComponent) null, (EntityHuman) null, blockposition1.up(), false, false, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NETHER_PORTAL); ++ Entity entity = EntityTypes.ZOMBIE_PIGMAN.spawnCreature(world, (NBTTagCompound) null, (IChatBaseComponent) null, (EntityHuman) null, blockposition.up(), EnumMobSpawn.STRUCTURE, false, false, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NETHER_PORTAL); if (entity != null) { - entity.portalCooldown = entity.aQ(); -@@ -54,8 +61,10 @@ + entity.portalCooldown = entity.aW(); +@@ -48,8 +55,10 @@ BlockPortal.Shape blockportal_shape = this.b(generatoraccess, blockposition); if (blockportal_shape != null) { @@ -36,18 +36,18 @@ } else { return false; } -@@ -92,6 +101,10 @@ - +@@ -85,6 +94,10 @@ + @Override public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { - if (!entity.isPassenger() && !entity.isVehicle() && entity.bm()) { + if (!entity.isPassenger() && !entity.isVehicle() && entity.canPortal()) { + // 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.e(blockposition); + entity.c(blockposition); } -@@ -189,6 +202,7 @@ +@@ -177,6 +190,7 @@ private BlockPosition position; private int height; private int width; @@ -55,7 +55,7 @@ public Shape(GeneratorAccess generatoraccess, BlockPosition blockposition, EnumDirection.EnumAxis enumdirection_enumaxis) { this.a = generatoraccess; -@@ -247,6 +261,9 @@ +@@ -235,6 +249,9 @@ } protected int c() { @@ -65,7 +65,7 @@ int i; label56: -@@ -269,11 +286,21 @@ +@@ -257,11 +274,21 @@ block = this.a.getType(blockposition.shift(this.d)).getBlock(); if (block != Blocks.OBSIDIAN) { break label56; @@ -87,7 +87,7 @@ } } } -@@ -283,6 +310,11 @@ +@@ -271,6 +298,11 @@ if (this.a.getType(this.position.shift(this.c, i).up(this.height)).getBlock() != Blocks.OBSIDIAN) { this.height = 0; break; @@ -99,7 +99,7 @@ } } -@@ -306,7 +338,27 @@ +@@ -294,7 +326,27 @@ return this.position != null && this.width >= 2 && this.width <= 21 && this.height >= 3 && this.height <= 21; } @@ -128,7 +128,7 @@ for (int i = 0; i < this.width; ++i) { BlockPosition blockposition = this.position.shift(this.c, i); -@@ -315,6 +367,7 @@ +@@ -303,6 +355,7 @@ } } diff --git a/nms-patches/BlockPoweredRail.patch b/nms-patches/BlockPoweredRail.patch index fa6a5cb28f..37989fad64 100644 --- a/nms-patches/BlockPoweredRail.patch +++ b/nms-patches/BlockPoweredRail.patch @@ -7,8 +7,8 @@ + public class BlockPoweredRail extends BlockMinecartTrackAbstract { - public static final BlockStateEnum SHAPE = BlockProperties.S; -@@ -101,6 +103,13 @@ + public static final BlockStateEnum SHAPE = BlockProperties.X; +@@ -102,6 +104,13 @@ boolean flag1 = world.isBlockIndirectlyPowered(blockposition) || this.a(world, blockposition, iblockdata, true, 0) || this.a(world, blockposition, iblockdata, false, 0); if (flag1 != flag) { diff --git a/nms-patches/BlockPressurePlateAbstract.patch b/nms-patches/BlockPressurePlateAbstract.patch index 08fea30f90..50850c9b45 100644 --- a/nms-patches/BlockPressurePlateAbstract.patch +++ b/nms-patches/BlockPressurePlateAbstract.patch @@ -9,7 +9,7 @@ public abstract class BlockPressurePlateAbstract extends Block { protected static final VoxelShape a = Block.a(1.0D, 0.0D, 1.0D, 15.0D, 0.5D, 15.0D); -@@ -65,6 +67,19 @@ +@@ -68,6 +70,19 @@ boolean flag = i > 0; boolean flag1 = j > 0; diff --git a/nms-patches/BlockPressurePlateBinary.patch b/nms-patches/BlockPressurePlateBinary.patch index 1ceb7dd8d6..0d2fc3eef2 100644 --- a/nms-patches/BlockPressurePlateBinary.patch +++ b/nms-patches/BlockPressurePlateBinary.patch @@ -8,8 +8,8 @@ + public class BlockPressurePlateBinary extends BlockPressurePlateAbstract { - public static final BlockStateBoolean POWERED = BlockProperties.t; -@@ -61,6 +63,26 @@ + public static final BlockStateBoolean POWERED = BlockProperties.w; +@@ -66,6 +68,26 @@ while (iterator.hasNext()) { Entity entity = (Entity) iterator.next(); diff --git a/nms-patches/BlockPressurePlateWeighted.patch b/nms-patches/BlockPressurePlateWeighted.patch index 376a6c23ed..a2527a5816 100644 --- a/nms-patches/BlockPressurePlateWeighted.patch +++ b/nms-patches/BlockPressurePlateWeighted.patch @@ -7,10 +7,10 @@ + public class BlockPressurePlateWeighted extends BlockPressurePlateAbstract { - public static final BlockStateInteger POWER = BlockProperties.al; -@@ -12,7 +14,31 @@ - } + public static final BlockStateInteger POWER = BlockProperties.as; +@@ -13,7 +15,31 @@ + @Override protected int b(World world, BlockPosition blockposition) { - int i = Math.min(world.a(Entity.class, BlockPressurePlateWeighted.c.a(blockposition)).size(), this.weight); + // CraftBukkit start diff --git a/nms-patches/BlockPumpkinCarved.patch b/nms-patches/BlockPumpkinCarved.patch index b4d7417fc3..43fea9cb43 100644 --- a/nms-patches/BlockPumpkinCarved.patch +++ b/nms-patches/BlockPumpkinCarved.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/BlockPumpkinCarved.java +++ b/net/minecraft/server/BlockPumpkinCarved.java -@@ -3,6 +3,12 @@ - import java.util.Iterator; +@@ -4,6 +4,12 @@ import java.util.function.Predicate; + import javax.annotation.Nullable; +// CraftBukkit start +import org.bukkit.craftbukkit.util.BlockStateListPopulator; @@ -13,20 +13,22 @@ public class BlockPumpkinCarved extends BlockFacingHorizontal { public static final BlockStateDirection a = BlockFacingHorizontal.FACING; -@@ -38,18 +44,24 @@ - ShapeDetectorBlock shapedetectorblock; - int k; +@@ -42,19 +48,28 @@ + EntityPlayer entityplayer; + int j; + BlockStateListPopulator blockList = new BlockStateListPopulator(world); // CraftBukkit - Use BlockStateListPopulator if (shapedetector_shapedetectorcollection != null) { - for (i = 0; i < this.e().b(); ++i) { - ShapeDetectorBlock shapedetectorblock1 = shapedetector_shapedetectorcollection.a(0, i, 0); + for (i = 0; i < this.getSnowmanShape().b(); ++i) { + ShapeDetectorBlock shapedetectorblock = shapedetector_shapedetectorcollection.a(0, i, 0); -- world.setTypeAndData(shapedetectorblock1.getPosition(), Blocks.AIR.getBlockData(), 2); -+ blockList.setTypeAndData(shapedetectorblock1.getPosition(), Blocks.AIR.getBlockData(), 2); // CraftBukkit +- world.setTypeAndData(shapedetectorblock.getPosition(), Blocks.AIR.getBlockData(), 2); +- world.triggerEffect(2001, shapedetectorblock.getPosition(), Block.getCombinedId(shapedetectorblock.a())); ++ blockList.setTypeAndData(shapedetectorblock.getPosition(), Blocks.AIR.getBlockData(), 2); // CraftBukkit ++ // world.triggerEffect(2001, shapedetectorblock.getPosition(), Block.getCombinedId(shapedetectorblock.a())); // CraftBukkit } - EntitySnowman entitysnowman = new EntitySnowman(world); + EntitySnowman entitysnowman = (EntitySnowman) EntityTypes.SNOW_GOLEM.a(world); BlockPosition blockposition1 = shapedetector_shapedetectorcollection.a(0, 2, 0).getPosition(); entitysnowman.setPositionRotation((double) blockposition1.getX() + 0.5D, (double) blockposition1.getY() + 0.05D, (double) blockposition1.getZ() + 0.5D, 0.0F, 0.0F); @@ -35,21 +37,26 @@ + if (!world.addEntity(entitysnowman, SpawnReason.BUILD_SNOWMAN)) { + return; + } ++ for (BlockPosition pos : blockList.getBlocks()) { ++ world.triggerEffect(2001, pos, Block.getCombinedId(world.getType(pos))); ++ } + blockList.updateList(); + // CraftBukkit end iterator = world.a(EntityPlayer.class, entitysnowman.getBoundingBox().g(5.0D)).iterator(); while (iterator.hasNext()) { -@@ -70,7 +82,7 @@ - if (shapedetector_shapedetectorcollection != null) { - for (i = 0; i < this.g().c(); ++i) { - for (int l = 0; l < this.g().b(); ++l) { -- world.setTypeAndData(shapedetector_shapedetectorcollection.a(i, l, 0).getPosition(), Blocks.AIR.getBlockData(), 2); -+ blockList.setTypeAndData(shapedetector_shapedetectorcollection.a(i, l, 0).getPosition(), Blocks.AIR.getBlockData(), 2); // CraftBukkit +@@ -74,8 +89,8 @@ + for (int k = 0; k < this.getIronGolemShape().b(); ++k) { + ShapeDetectorBlock shapedetectorblock2 = shapedetector_shapedetectorcollection.a(i, k, 0); + +- world.setTypeAndData(shapedetectorblock2.getPosition(), Blocks.AIR.getBlockData(), 2); +- world.triggerEffect(2001, shapedetectorblock2.getPosition(), Block.getCombinedId(shapedetectorblock2.a())); ++ blockList.setTypeAndData(shapedetectorblock2.getPosition(), Blocks.AIR.getBlockData(), 2); // CraftBukkit ++ // world.triggerEffect(2001, shapedetectorblock2.getPosition(), Block.getCombinedId(shapedetectorblock2.a())); // CraftBukkit } } -@@ -79,7 +91,12 @@ +@@ -84,7 +99,15 @@ entityirongolem.setPlayerCreated(true); entityirongolem.setPositionRotation((double) blockposition2.getX() + 0.5D, (double) blockposition2.getY() + 0.05D, (double) blockposition2.getZ() + 0.5D, 0.0F, 0.0F); @@ -58,6 +65,9 @@ + if (!world.addEntity(entityirongolem, SpawnReason.BUILD_IRONGOLEM)) { + return; + } ++ for (BlockPosition pos : blockList.getBlocks()) { ++ world.triggerEffect(2001, pos, Block.getCombinedId(world.getType(pos))); ++ } + blockList.updateList(); + // CraftBukkit end iterator = world.a(EntityPlayer.class, entityirongolem.getBoundingBox().g(5.0D)).iterator(); diff --git a/nms-patches/BlockRedstoneComparator.patch b/nms-patches/BlockRedstoneComparator.patch index 9eac7be6e1..e39e8b2a35 100644 --- a/nms-patches/BlockRedstoneComparator.patch +++ b/nms-patches/BlockRedstoneComparator.patch @@ -8,7 +8,7 @@ + public class BlockRedstoneComparator extends BlockDiodeAbstract implements ITileEntity { - public static final BlockStateEnum MODE = BlockProperties.aq; + public static final BlockStateEnum MODE = BlockProperties.ay; @@ -64,7 +66,8 @@ @Nullable @@ -19,7 +19,7 @@ return entityitemframe != null && entityitemframe.getDirection() == enumdirection; }); -@@ -117,8 +120,18 @@ +@@ -119,8 +122,18 @@ boolean flag1 = (Boolean) iblockdata.get(BlockRedstoneComparator.c); if (flag1 && !flag) { diff --git a/nms-patches/BlockRedstoneLamp.patch b/nms-patches/BlockRedstoneLamp.patch index 422cfd5566..422c277191 100644 --- a/nms-patches/BlockRedstoneLamp.patch +++ b/nms-patches/BlockRedstoneLamp.patch @@ -9,8 +9,8 @@ public class BlockRedstoneLamp extends Block { public static final BlockStateBoolean a = BlockRedstoneTorch.LIT; -@@ -33,6 +35,11 @@ - if (flag) { +@@ -37,6 +39,11 @@ + if (flag1) { world.getBlockTickList().a(blockposition, this, 4); } else { + // CraftBukkit start @@ -21,8 +21,8 @@ world.setTypeAndData(blockposition, (IBlockData) iblockdata.a((IBlockState) BlockRedstoneLamp.a), 2); } } -@@ -43,6 +50,11 @@ - public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) { +@@ -48,6 +55,11 @@ + public void tick(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) { if (!world.isClientSide) { if ((Boolean) iblockdata.get(BlockRedstoneLamp.a) && !world.isBlockIndirectlyPowered(blockposition)) { + // CraftBukkit start diff --git a/nms-patches/BlockRedstoneOre.patch b/nms-patches/BlockRedstoneOre.patch index 01d88722ff..5b724cd3cc 100644 --- a/nms-patches/BlockRedstoneOre.patch +++ b/nms-patches/BlockRedstoneOre.patch @@ -12,15 +12,16 @@ public class BlockRedstoneOre extends Block { public static final BlockStateBoolean a = BlockRedstoneTorch.LIT; -@@ -16,23 +21,44 @@ - } +@@ -18,25 +23,46 @@ + @Override public void attack(IBlockData iblockdata, World world, BlockPosition blockposition, EntityHuman entityhuman) { - interact(iblockdata, world, blockposition); + interact(iblockdata, world, blockposition, entityhuman); // CraftBukkit - add entityhuman super.attack(iblockdata, world, blockposition, entityhuman); } + @Override public void stepOn(World world, BlockPosition blockposition, Entity entity) { - interact(world.getType(blockposition), world, blockposition); - super.stepOn(world, blockposition, entity); @@ -44,10 +45,11 @@ + // CraftBukkit end } - public boolean interact(IBlockData iblockdata, World world, BlockPosition blockposition, EntityHuman entityhuman, EnumHand enumhand, EnumDirection enumdirection, float f, float f1, float f2) { + @Override + public boolean interact(IBlockData iblockdata, World world, BlockPosition blockposition, EntityHuman entityhuman, EnumHand enumhand, MovingObjectPositionBlock movingobjectpositionblock) { - interact(iblockdata, world, blockposition); + interact(iblockdata, world, blockposition, entityhuman); // CraftBukkit - add entityhuman - return super.interact(iblockdata, world, blockposition, entityhuman, enumhand, enumdirection, f, f1, f2); + return super.interact(iblockdata, world, blockposition, entityhuman, enumhand, movingobjectpositionblock); } - private static void interact(IBlockData iblockdata, World world, BlockPosition blockposition) { @@ -62,9 +64,9 @@ world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockRedstoneOre.a, true), 3); } -@@ -40,6 +66,11 @@ - - public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) { +@@ -45,6 +71,11 @@ + @Override + public void tick(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) { if ((Boolean) iblockdata.get(BlockRedstoneOre.a)) { + // CraftBukkit start + if (CraftEventFactory.callBlockFadeEvent(world, blockposition, iblockdata.set(BlockRedstoneOre.a, false)).isCancelled()) { @@ -74,29 +76,31 @@ world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockRedstoneOre.a, false), 3); } -@@ -59,12 +90,25 @@ - - public void dropNaturally(IBlockData iblockdata, World world, BlockPosition blockposition, float f, int i) { - super.dropNaturally(iblockdata, world, blockposition, f, i); +@@ -53,14 +84,27 @@ + @Override + public void dropNaturally(IBlockData iblockdata, World world, BlockPosition blockposition, ItemStack itemstack) { + super.dropNaturally(iblockdata, world, blockposition, itemstack); + /* CraftBukkit start - Delegated to getExpDrop - if (this.getDropType(iblockdata, world, blockposition, i) != this) { - int j = 1 + world.random.nextInt(5); + if (EnchantmentManager.getEnchantmentLevel(Enchantments.SILK_TOUCH, itemstack) == 0) { + int i = 1 + world.random.nextInt(5); - this.dropExperience(world, blockposition, j); + this.dropExperience(world, blockposition, i); } + // */ -+ -+ } + + } + @Override -+ public int getExpDrop(IBlockData iblockdata, World world, BlockPosition blockposition, int enchantmentLevel) { -+ if (this.getDropType(iblockdata, world, blockposition, enchantmentLevel) != this) { -+ int j = 1 + world.random.nextInt(5); ++ public int getExpDrop(IBlockData iblockdata, World world, BlockPosition blockposition, ItemStack itemstack) { ++ if (EnchantmentManager.getEnchantmentLevel(Enchantments.SILK_TOUCH, itemstack) == 0) { ++ int i = 1 + world.random.nextInt(5); + -+ return j; ++ return i; + } + return 0; + // CraftBukkit end - } - ++ } ++ private static void playEffect(World world, BlockPosition blockposition) { + double d0 = 0.5625D; + Random random = world.random; diff --git a/nms-patches/BlockRedstoneTorch.patch b/nms-patches/BlockRedstoneTorch.patch index b1d4f34088..1a9942cc07 100644 --- a/nms-patches/BlockRedstoneTorch.patch +++ b/nms-patches/BlockRedstoneTorch.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/server/BlockRedstoneTorch.java +++ b/net/minecraft/server/BlockRedstoneTorch.java @@ -6,6 +6,8 @@ - import java.util.Map; import java.util.Random; + import java.util.WeakHashMap; +import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit + public class BlockRedstoneTorch extends BlockTorch { - public static final BlockStateBoolean LIT = BlockProperties.o; -@@ -65,8 +67,24 @@ + public static final BlockStateBoolean LIT = BlockProperties.r; +@@ -70,8 +72,24 @@ list.remove(0); } @@ -33,8 +33,8 @@ + // CraftBukkit end world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockRedstoneTorch.LIT, false), 3); if (a(world, blockposition, true)) { - world.a((EntityHuman) null, blockposition, SoundEffects.BLOCK_REDSTONE_TORCH_BURNOUT, SoundCategory.BLOCKS, 0.5F, 2.6F + (world.random.nextFloat() - world.random.nextFloat()) * 0.8F); -@@ -83,6 +101,15 @@ + world.triggerEffect(1502, blockposition, 0); +@@ -79,6 +97,15 @@ } } } else if (!flag && !a(world, blockposition, false)) { diff --git a/nms-patches/BlockRedstoneWire.patch b/nms-patches/BlockRedstoneWire.patch index d3568cb32a..eae998a1a4 100644 --- a/nms-patches/BlockRedstoneWire.patch +++ b/nms-patches/BlockRedstoneWire.patch @@ -8,20 +8,20 @@ + public class BlockRedstoneWire extends Block { - public static final BlockStateEnum NORTH = BlockProperties.M; -@@ -216,6 +218,15 @@ - j = k; + public static final BlockStateEnum NORTH = BlockProperties.R; +@@ -206,6 +208,15 @@ + l = j; } + // CraftBukkit start -+ if (i != j) { -+ BlockRedstoneEvent event = new BlockRedstoneEvent(world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), i, j); ++ if (i != l) { ++ BlockRedstoneEvent event = new BlockRedstoneEvent(world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), i, l); + world.getServer().getPluginManager().callEvent(event); + -+ j = event.getNewCurrent(); ++ l = event.getNewCurrent(); + } + // CraftBukkit end + - if (i != j) { - iblockdata = (IBlockData) iblockdata.set(BlockRedstoneWire.POWER, j); + if (i != l) { + iblockdata = (IBlockData) iblockdata.set(BlockRedstoneWire.POWER, l); if (world.getType(blockposition) == iblockdata1) { diff --git a/nms-patches/BlockReed.patch b/nms-patches/BlockReed.patch index f7713a700f..44c392da6b 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,7 +29,7 @@ +@@ -33,7 +33,7 @@ int j = (Integer) iblockdata.get(BlockReed.AGE); if (j == 15) { diff --git a/nms-patches/BlockSapling.patch b/nms-patches/BlockSapling.patch index 2f9f896644..e0ee45f963 100644 --- a/nms-patches/BlockSapling.patch +++ b/nms-patches/BlockSapling.patch @@ -15,16 +15,16 @@ + public class BlockSapling extends BlockPlant implements IBlockFragilePlantElement { - public static final BlockStateInteger STAGE = BlockProperties.am; + public static final BlockStateInteger STAGE = BlockProperties.at; protected static final VoxelShape b = Block.a(2.0D, 0.0D, 2.0D, 14.0D, 12.0D, 14.0D); private final WorldGenTreeProvider c; + public static TreeType treeType; // CraftBukkit protected BlockSapling(WorldGenTreeProvider worldgentreeprovider, Block.Info block_info) { super(block_info); -@@ -21,7 +31,30 @@ - public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) { - super.a(iblockdata, world, blockposition, random); +@@ -23,7 +33,30 @@ + public void tick(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) { + super.tick(iblockdata, world, blockposition, random); if (world.getLightLevel(blockposition.up()) >= 9 && random.nextInt(7) == 0) { + // CraftBukkit start + world.captureTreeGeneration = true; diff --git a/nms-patches/BlockShulkerBox.patch b/nms-patches/BlockShulkerBox.patch deleted file mode 100644 index e4c24bc972..0000000000 --- a/nms-patches/BlockShulkerBox.patch +++ /dev/null @@ -1,54 +0,0 @@ ---- a/net/minecraft/server/BlockShulkerBox.java -+++ b/net/minecraft/server/BlockShulkerBox.java -@@ -81,7 +81,31 @@ - super.a(world, blockposition, iblockdata, entityhuman); - } - -- public void dropNaturally(IBlockData iblockdata, World world, BlockPosition blockposition, float f, int i) {} -+ // CraftBukkit start - override to prevent duplication when dropping -+ @Override -+ public void dropNaturally(IBlockData iblockdata, World world, BlockPosition blockposition, float f, int i) { -+ if (true) { -+ TileEntity tileentity = world.getTileEntity(blockposition); -+ -+ if (tileentity instanceof TileEntityShulkerBox) { -+ TileEntityShulkerBox tileentityshulkerbox = (TileEntityShulkerBox) tileentity; -+ -+ if (!tileentityshulkerbox.s() && tileentityshulkerbox.G()) { -+ ItemStack itemstack = new ItemStack(this); -+ -+ itemstack.getOrCreateTag().set("BlockEntityTag", ((TileEntityShulkerBox) tileentity).g(new NBTTagCompound())); -+ if (tileentityshulkerbox.hasCustomName()) { -+ itemstack.a(tileentityshulkerbox.getCustomName()); -+ tileentityshulkerbox.setCustomName((IChatBaseComponent) null); -+ } -+ -+ a(world, blockposition, itemstack); -+ } -+ } -+ world.updateAdjacentComparators(blockposition, iblockdata.getBlock()); -+ } -+ } -+ // CraftBukkit end - - public void postPlace(World world, BlockPosition blockposition, IBlockData iblockdata, EntityLiving entityliving, ItemStack itemstack) { - if (itemstack.hasName()) { -@@ -98,7 +122,7 @@ - if (iblockdata.getBlock() != iblockdata1.getBlock()) { - TileEntity tileentity = world.getTileEntity(blockposition); - -- if (tileentity instanceof TileEntityShulkerBox) { -+ if (false && tileentity instanceof TileEntityShulkerBox) { // CraftBukkit - moved up - TileEntityShulkerBox tileentityshulkerbox = (TileEntityShulkerBox) tileentity; - - if (!tileentityshulkerbox.s() && tileentityshulkerbox.G()) { -@@ -113,8 +137,8 @@ - a(world, blockposition, itemstack); - } - -- world.updateAdjacentComparators(blockposition, iblockdata.getBlock()); - } -+ world.updateAdjacentComparators(blockposition, iblockdata.getBlock()); // CraftBukkit - moved down - - super.remove(iblockdata, world, blockposition, iblockdata1, flag); - } diff --git a/nms-patches/BlockSkullAbstract.patch b/nms-patches/BlockSkullAbstract.patch deleted file mode 100644 index 84a88f4b78..0000000000 --- a/nms-patches/BlockSkullAbstract.patch +++ /dev/null @@ -1,45 +0,0 @@ ---- a/net/minecraft/server/BlockSkullAbstract.java -+++ b/net/minecraft/server/BlockSkullAbstract.java -@@ -17,7 +17,32 @@ - return new TileEntitySkull(); - } - -- public void dropNaturally(IBlockData iblockdata, World world, BlockPosition blockposition, float f, int i) {} -+ // CraftBukkit start - Special case dropping so we can get info from the tile entity -+ @Override -+ public void dropNaturally(IBlockData iblockdata, World world, BlockPosition blockposition, float f, int i) { -+ if (world.random.nextFloat() < f) { -+ TileEntity tileentity = world.getTileEntity(blockposition); -+ -+ if (tileentity instanceof TileEntitySkull) { -+ TileEntitySkull tileentityskull = (TileEntitySkull) tileentity; -+ -+ if (tileentityskull.shouldDrop()) { -+ ItemStack itemstack = this.a((IBlockAccess) world, blockposition, iblockdata); -+ Block block = tileentityskull.getBlock().getBlock(); -+ -+ if ((block == Blocks.PLAYER_HEAD || block == Blocks.PLAYER_WALL_HEAD) && tileentityskull.getGameProfile() != null) { -+ NBTTagCompound nbttagcompound = new NBTTagCompound(); -+ -+ GameProfileSerializer.serialize(nbttagcompound, tileentityskull.getGameProfile()); -+ itemstack.getOrCreateTag().set("SkullOwner", nbttagcompound); -+ } -+ -+ a(world, blockposition, itemstack); -+ } -+ } -+ } -+ } -+ // CraftBukkit end - - public void a(World world, BlockPosition blockposition, IBlockData iblockdata, EntityHuman entityhuman) { - if (!world.isClientSide && entityhuman.abilities.canInstantlyBuild) { -@@ -35,7 +60,7 @@ - if (iblockdata.getBlock() != iblockdata1.getBlock() && !world.isClientSide) { - TileEntity tileentity = world.getTileEntity(blockposition); - -- if (tileentity instanceof TileEntitySkull) { -+ if (false && tileentity instanceof TileEntitySkull) { // CraftBukkit - Drop item in code above, not here - TileEntitySkull tileentityskull = (TileEntitySkull) tileentity; - - if (tileentityskull.shouldDrop()) { diff --git a/nms-patches/BlockSnow.patch b/nms-patches/BlockSnow.patch index 70e7ffc858..a4f4a81c2c 100644 --- a/nms-patches/BlockSnow.patch +++ b/nms-patches/BlockSnow.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/server/BlockSnow.java +++ b/net/minecraft/server/BlockSnow.java -@@ -85,6 +85,11 @@ - - public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) { +@@ -58,6 +58,11 @@ + @Override + public void tick(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) { if (world.getBrightness(EnumSkyBlock.BLOCK, blockposition) > 11) { + // CraftBukkit start + if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(world, blockposition, Blocks.AIR.getBlockData()).isCancelled()) { + return; + } + // CraftBukkit end - iblockdata.a(world, blockposition, 0); - world.setAir(blockposition); + c(iblockdata, world, blockposition); + world.a(blockposition, false); } diff --git a/nms-patches/BlockSnowBlock.patch b/nms-patches/BlockSnowBlock.patch deleted file mode 100644 index 0bd8cb6986..0000000000 --- a/nms-patches/BlockSnowBlock.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- a/net/minecraft/server/BlockSnowBlock.java -+++ b/net/minecraft/server/BlockSnowBlock.java -@@ -18,6 +18,11 @@ - - public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) { - if (world.getBrightness(EnumSkyBlock.BLOCK, blockposition) > 11) { -+ // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(world, blockposition, Blocks.AIR.getBlockData()).isCancelled()) { -+ return; -+ } -+ // CraftBukkit end - iblockdata.a(world, blockposition, 0); - world.setAir(blockposition); - } diff --git a/nms-patches/BlockSoil.patch b/nms-patches/BlockSoil.patch index e562c66d42..7af361a848 100644 --- a/nms-patches/BlockSoil.patch +++ b/nms-patches/BlockSoil.patch @@ -11,15 +11,15 @@ + public class BlockSoil extends Block { - public static final BlockStateInteger MOISTURE = BlockProperties.ai; -@@ -51,26 +56,49 @@ + public static final BlockStateInteger MOISTURE = BlockProperties.ap; +@@ -53,12 +58,12 @@ if (!a((IWorldReader) world, blockposition) && !world.isRainingAt(blockposition.up())) { if (i > 0) { - world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockSoil.MOISTURE, i - 1), 2); + org.bukkit.craftbukkit.event.CraftEventFactory.handleMoistureChangeEvent(world, blockposition, (IBlockData) iblockdata.set(BlockSoil.MOISTURE, i - 1), 2); // CraftBukkit } else if (!a((IBlockAccess) world, blockposition)) { - b(iblockdata, world, blockposition); + fade(iblockdata, world, blockposition); } } else if (i < 7) { - world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockSoil.MOISTURE, 7), 2); @@ -27,11 +27,12 @@ } } - } +@@ -66,14 +71,37 @@ + @Override public void fallOn(World world, BlockPosition blockposition, Entity entity, float f) { + super.fallOn(world, blockposition, entity, f); // CraftBukkit - moved here as game rules / events shouldn't affect fall damage. - if (!world.isClientSide && world.random.nextFloat() < f - 0.5F && entity instanceof EntityLiving && (entity instanceof EntityHuman || world.getGameRules().getBoolean("mobGriefing")) && entity.width * entity.width * entity.length > 0.512F) { + if (!world.isClientSide && world.random.nextFloat() < f - 0.5F && entity instanceof EntityLiving && (entity instanceof EntityHuman || world.getGameRules().getBoolean("mobGriefing")) && entity.getWidth() * entity.getWidth() * entity.getHeight() > 0.512F) { + // CraftBukkit start - Interact soil + org.bukkit.event.Cancellable cancellable; + if (entity instanceof EntityHuman) { @@ -49,14 +50,14 @@ + return; + } + // CraftBukkit end - b(world.getType(blockposition), world, blockposition); + fade(world.getType(blockposition), world, blockposition); } - super.fallOn(world, blockposition, entity, f); + // super.fallOn(world, blockposition, entity, f); // CraftBukkit - moved up } - public static void b(IBlockData iblockdata, World world, BlockPosition blockposition) { + public static void fade(IBlockData iblockdata, World world, BlockPosition blockposition) { + // CraftBukkit start + if (CraftEventFactory.callBlockFadeEvent(world, blockposition, Blocks.DIRT.getBlockData()).isCancelled()) { + return; diff --git a/nms-patches/BlockSponge.patch b/nms-patches/BlockSponge.patch index b9efc64f46..0fafa5f3bc 100644 --- a/nms-patches/BlockSponge.patch +++ b/nms-patches/BlockSponge.patch @@ -13,7 +13,7 @@ public class BlockSponge extends Block { -@@ -33,6 +39,7 @@ +@@ -35,6 +41,7 @@ queue.add(new Tuple<>(blockposition, 0)); int i = 0; @@ -21,7 +21,7 @@ while (!queue.isEmpty()) { Tuple tuple = (Tuple) queue.poll(); -@@ -49,20 +56,20 @@ +@@ -51,22 +58,24 @@ Material material = iblockdata.getMaterial(); if (fluid.a(TagsFluid.WATER)) { @@ -39,14 +39,19 @@ queue.add(new Tuple<>(blockposition2, j + 1)); } } else if (material == Material.WATER_PLANT || material == Material.REPLACEABLE_WATER_PLANT) { -- iblockdata.a(world, blockposition2, 0); +- TileEntity tileentity = iblockdata.getBlock().isTileEntity() ? world.getTileEntity(blockposition2) : null; ++ // CraftBukkit start ++ // TileEntity tileentity = iblockdata.getBlock().isTileEntity() ? world.getTileEntity(blockposition2) : null; + +- a(iblockdata, world, blockposition2, tileentity); - world.setTypeAndData(blockposition2, Blocks.AIR.getBlockData(), 3); -+ // iblockdata.a(world, blockposition2, 0); -+ blockList.setTypeAndData(blockposition2, Blocks.AIR.getBlockData(), 3); // CraftBukkit ++ // a(iblockdata, world, blockposition2, tileentity); ++ blockList.setTypeAndData(blockposition2, Blocks.AIR.getBlockData(), 3); ++ // CraftBukkit end ++i; if (j < 6) { queue.add(new Tuple<>(blockposition2, j + 1)); -@@ -75,6 +82,37 @@ +@@ -79,6 +88,39 @@ break; } } @@ -74,7 +79,9 @@ + } else if (iblockdata.getBlock() instanceof BlockFluids) { + // NOP + } else if (material == Material.WATER_PLANT || material == Material.REPLACEABLE_WATER_PLANT) { -+ iblockdata.a(world, blockposition2, 0); ++ TileEntity tileentity = iblockdata.getBlock().isTileEntity() ? world.getTileEntity(blockposition2) : null; ++ ++ a(iblockdata, world, blockposition2, tileentity); + } + } + world.setTypeAndData(blockposition2, block.getHandle(), block.getFlag()); diff --git a/nms-patches/BlockStem.patch b/nms-patches/BlockStem.patch index 89d850bf1f..d52c3f8cf2 100644 --- a/nms-patches/BlockStem.patch +++ b/nms-patches/BlockStem.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/server/BlockStem.java +++ b/net/minecraft/server/BlockStem.java -@@ -3,6 +3,8 @@ +@@ -2,6 +2,8 @@ + import java.util.Random; - import javax.annotation.Nullable; +import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit + public class BlockStem extends BlockPlant implements IBlockFragilePlantElement { - public static final BlockStateInteger AGE = BlockProperties.W; -@@ -33,14 +35,18 @@ + public static final BlockStateInteger AGE = BlockProperties.ac; +@@ -35,14 +37,18 @@ if (i < 7) { iblockdata = (IBlockData) iblockdata.set(BlockStem.AGE, i + 1); @@ -30,7 +30,7 @@ world.setTypeUpdate(blockposition, (IBlockData) this.blockFruit.e().getBlockData().set(BlockFacingHorizontal.FACING, enumdirection)); } } -@@ -94,7 +100,7 @@ +@@ -66,7 +72,7 @@ int i = Math.min(7, (Integer) iblockdata.get(BlockStem.AGE) + MathHelper.nextInt(world.random, 2, 5)); IBlockData iblockdata1 = (IBlockData) iblockdata.set(BlockStem.AGE, i); diff --git a/nms-patches/BlockSweetBerryBush.patch b/nms-patches/BlockSweetBerryBush.patch new file mode 100644 index 0000000000..b275e53b94 --- /dev/null +++ b/nms-patches/BlockSweetBerryBush.patch @@ -0,0 +1,32 @@ +--- a/net/minecraft/server/BlockSweetBerryBush.java ++++ b/net/minecraft/server/BlockSweetBerryBush.java +@@ -1,6 +1,10 @@ + package net.minecraft.server; + + import java.util.Random; ++// CraftBukkit start ++import org.bukkit.craftbukkit.block.CraftBlock; ++import org.bukkit.craftbukkit.event.CraftEventFactory; ++// CraftBukkit end + + public class BlockSweetBerryBush extends BlockPlant implements IBlockFragilePlantElement { + +@@ -24,7 +28,7 @@ + int i = (Integer) iblockdata.get(BlockSweetBerryBush.a); + + if (i < 3 && random.nextInt(5) == 0 && world.getLightLevel(blockposition.up(), 0) >= 9) { +- world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockSweetBerryBush.a, i + 1), 2); ++ CraftEventFactory.handleBlockGrowEvent(world, blockposition, (IBlockData) iblockdata.set(BlockSweetBerryBush.a, i + 1), 2); // CraftBukkit + } + + } +@@ -38,7 +42,9 @@ + double d1 = Math.abs(entity.locZ - entity.J); + + if (d0 >= 0.003000000026077032D || d1 >= 0.003000000026077032D) { ++ CraftEventFactory.blockDamage = CraftBlock.at(world, blockposition); // CraftBukkit + entity.damageEntity(DamageSource.SWEET_BERRY_BUSH, 1.0F); ++ CraftEventFactory.blockDamage = null; // CraftBukkit + } + } + diff --git a/nms-patches/BlockTNT.patch b/nms-patches/BlockTNT.patch index 0e087adbb8..85fa622873 100644 --- a/nms-patches/BlockTNT.patch +++ b/nms-patches/BlockTNT.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/BlockTNT.java +++ b/net/minecraft/server/BlockTNT.java -@@ -90,6 +90,11 @@ +@@ -92,6 +92,11 @@ Entity entity1 = entityarrow.getShooter(); if (entityarrow.isBurning()) { @@ -9,6 +9,6 @@ + return; + } + // CraftBukkit end - this.a(world, blockposition, entity1 instanceof EntityLiving ? (EntityLiving) entity1 : null); - world.setAir(blockposition); + a(world, blockposition, entity1 instanceof EntityLiving ? (EntityLiving) entity1 : null); + world.a(blockposition, false); } diff --git a/nms-patches/BlockTallPlant.patch b/nms-patches/BlockTallPlant.patch index 70676d56d8..be83c6b592 100644 --- a/nms-patches/BlockTallPlant.patch +++ b/nms-patches/BlockTallPlant.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/BlockTallPlant.java +++ b/net/minecraft/server/BlockTallPlant.java -@@ -48,6 +48,11 @@ - } +@@ -54,6 +54,11 @@ + @Override public void a(World world, BlockPosition blockposition, IBlockData iblockdata, EntityHuman entityhuman) { + // CraftBukkit start + if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPhysicsEvent(world, blockposition).isCancelled()) { @@ -10,5 +10,5 @@ + } + // CraftBukkit end BlockPropertyDoubleBlockHalf blockpropertydoubleblockhalf = (BlockPropertyDoubleBlockHalf) iblockdata.get(BlockTallPlant.HALF); - boolean flag = blockpropertydoubleblockhalf == BlockPropertyDoubleBlockHalf.LOWER; - BlockPosition blockposition1 = flag ? blockposition.up() : blockposition.down(); + BlockPosition blockposition1 = blockpropertydoubleblockhalf == BlockPropertyDoubleBlockHalf.LOWER ? blockposition.up() : blockposition.down(); + IBlockData iblockdata1 = world.getType(blockposition1); diff --git a/nms-patches/BlockTrapdoor.patch b/nms-patches/BlockTrapdoor.patch index 7625283df7..7955e533f4 100644 --- a/nms-patches/BlockTrapdoor.patch +++ b/nms-patches/BlockTrapdoor.patch @@ -6,12 +6,12 @@ import javax.annotation.Nullable; +import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit - public class BlockTrapdoor extends BlockFacingHorizontal implements IFluidSource, IFluidContainer { + public class BlockTrapdoor extends BlockFacingHorizontal implements IBlockWaterlogged { @@ -88,6 +89,19 @@ - boolean flag = world.isBlockIndirectlyPowered(blockposition); + boolean flag1 = world.isBlockIndirectlyPowered(blockposition); - if (flag != (Boolean) iblockdata.get(BlockTrapdoor.c)) { + if (flag1 != (Boolean) iblockdata.get(BlockTrapdoor.c)) { + // CraftBukkit start + org.bukkit.World bworld = world.getWorld(); + org.bukkit.block.Block bblock = bworld.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); @@ -22,9 +22,9 @@ + if (oldPower == 0 ^ power == 0 || block.getBlockData().isPowerSource()) { + BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bblock, oldPower, power); + world.getServer().getPluginManager().callEvent(eventRedstone); -+ flag = eventRedstone.getNewCurrent() > 0; ++ flag1 = eventRedstone.getNewCurrent() > 0; + } + // CraftBukkit end - if ((Boolean) iblockdata.get(BlockTrapdoor.OPEN) != flag) { - iblockdata = (IBlockData) iblockdata.set(BlockTrapdoor.OPEN, flag); - this.a((EntityHuman) null, world, blockposition, flag); + if ((Boolean) iblockdata.get(BlockTrapdoor.OPEN) != flag1) { + iblockdata = (IBlockData) iblockdata.set(BlockTrapdoor.OPEN, flag1); + this.a((EntityHuman) null, world, blockposition, flag1); diff --git a/nms-patches/BlockTripwire.patch b/nms-patches/BlockTripwire.patch index 9b2c04bd5e..fc625ea4ca 100644 --- a/nms-patches/BlockTripwire.patch +++ b/nms-patches/BlockTripwire.patch @@ -8,8 +8,8 @@ + public class BlockTripwire extends Block { - public static final BlockStateBoolean POWERED = BlockProperties.t; -@@ -134,6 +136,40 @@ + public static final BlockStateBoolean POWERED = BlockProperties.w; +@@ -139,6 +141,40 @@ } } diff --git a/nms-patches/BlockTurtleEgg.patch b/nms-patches/BlockTurtleEgg.patch index 13b7e6144f..c66ad9b63d 100644 --- a/nms-patches/BlockTurtleEgg.patch +++ b/nms-patches/BlockTurtleEgg.patch @@ -13,7 +13,7 @@ public class BlockTurtleEgg extends Block { -@@ -33,6 +39,19 @@ +@@ -35,6 +41,19 @@ super.stepOn(world, blockposition, entity); } else { if (!world.isClientSide && world.random.nextInt(i) == 0) { @@ -33,7 +33,7 @@ this.a(world, blockposition, world.getType(blockposition)); } -@@ -57,9 +76,19 @@ +@@ -60,9 +79,19 @@ int i = (Integer) iblockdata.get(BlockTurtleEgg.a); if (i < 2) { @@ -52,9 +52,9 @@ + } + // CraftBukkit end world.a((EntityHuman) null, blockposition, SoundEffects.ENTITY_TURTLE_EGG_HATCH, SoundCategory.BLOCKS, 0.7F, 0.9F + random.nextFloat() * 0.2F); - world.setAir(blockposition); + world.a(blockposition, false); if (!world.isClientSide) { -@@ -70,7 +99,7 @@ +@@ -73,7 +102,7 @@ entityturtle.setAgeRaw(-24000); entityturtle.g(blockposition); entityturtle.setPositionRotation((double) blockposition.getX() + 0.3D + (double) j * 0.2D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.3D, 0.0F, 0.0F); diff --git a/nms-patches/BlockVine.patch b/nms-patches/BlockVine.patch index 41c930d1ee..2f0036af60 100644 --- a/nms-patches/BlockVine.patch +++ b/nms-patches/BlockVine.patch @@ -8,50 +8,50 @@ + public class BlockVine extends Block { - public static final BlockStateBoolean UP = BlockSprawling.p; -@@ -182,20 +184,24 @@ + public static final BlockStateBoolean UP = BlockSprawling.e; +@@ -178,20 +180,24 @@ BlockPosition blockposition3 = blockposition2.shift(enumdirection1); BlockPosition blockposition4 = blockposition2.shift(enumdirection2); + // CraftBukkit start - Call BlockSpreadEvent + BlockPosition source = blockposition; + - if (flag && this.b((IBlockAccess) world, blockposition3, enumdirection1)) { + if (flag && a((IBlockAccess) world, blockposition3, enumdirection1)) { - world.setTypeAndData(blockposition2, (IBlockData) this.getBlockData().set(getDirection(enumdirection1), true), 2); + CraftEventFactory.handleBlockSpreadEvent(world, source, blockposition2, (IBlockData) this.getBlockData().set(getDirection(enumdirection1), true), 2); - } else if (flag1 && this.b((IBlockAccess) world, blockposition4, enumdirection2)) { + } else if (flag1 && a((IBlockAccess) world, blockposition4, enumdirection2)) { - world.setTypeAndData(blockposition2, (IBlockData) this.getBlockData().set(getDirection(enumdirection2), true), 2); + CraftEventFactory.handleBlockSpreadEvent(world, source, blockposition2, (IBlockData) this.getBlockData().set(getDirection(enumdirection2), true), 2); } else { EnumDirection enumdirection3 = enumdirection.opposite(); - if (flag && world.isEmpty(blockposition3) && this.b((IBlockAccess) world, blockposition.shift(enumdirection1), enumdirection3)) { + if (flag && world.isEmpty(blockposition3) && a((IBlockAccess) world, blockposition.shift(enumdirection1), enumdirection3)) { - world.setTypeAndData(blockposition3, (IBlockData) this.getBlockData().set(getDirection(enumdirection3), true), 2); + CraftEventFactory.handleBlockSpreadEvent(world, source, blockposition3, (IBlockData) this.getBlockData().set(getDirection(enumdirection3), true), 2); - } else if (flag1 && world.isEmpty(blockposition4) && this.b((IBlockAccess) world, blockposition.shift(enumdirection2), enumdirection3)) { + } else if (flag1 && world.isEmpty(blockposition4) && a((IBlockAccess) world, blockposition.shift(enumdirection2), enumdirection3)) { - world.setTypeAndData(blockposition4, (IBlockData) this.getBlockData().set(getDirection(enumdirection3), true), 2); + CraftEventFactory.handleBlockSpreadEvent(world, source, blockposition4, (IBlockData) this.getBlockData().set(getDirection(enumdirection3), true), 2); - } else if ((double) world.random.nextFloat() < 0.05D && this.b((IBlockAccess) world, blockposition2.up(), EnumDirection.UP)) { + } else if ((double) world.random.nextFloat() < 0.05D && a((IBlockAccess) world, blockposition2.up(), EnumDirection.UP)) { - world.setTypeAndData(blockposition2, (IBlockData) this.getBlockData().set(BlockVine.UP, true), 2); + CraftEventFactory.handleBlockSpreadEvent(world, source, blockposition2, (IBlockData) this.getBlockData().set(BlockVine.UP, true), 2); } + // CraftBukkit end } - } else if (this.b((IBlockAccess) world, blockposition2, enumdirection)) { + } else if (a((IBlockAccess) world, blockposition2, enumdirection)) { world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(getDirection(enumdirection), true), 2); -@@ -225,7 +231,7 @@ +@@ -221,7 +227,7 @@ } - if (this.x(iblockdata3)) { + if (this.canSpread(iblockdata3)) { - world.setTypeAndData(blockposition1, iblockdata3, 2); + CraftEventFactory.handleBlockSpreadEvent(world, blockposition, blockposition1, iblockdata3, 2); // CraftBukkit } return; -@@ -240,7 +246,7 @@ +@@ -236,7 +242,7 @@ IBlockData iblockdata5 = this.a(iblockdata, iblockdata4, random); - if (iblockdata4 != iblockdata5 && this.x(iblockdata5)) { + if (iblockdata4 != iblockdata5 && this.canSpread(iblockdata5)) { - world.setTypeAndData(blockposition2, iblockdata5, 2); + CraftEventFactory.handleBlockSpreadEvent(world, blockposition, blockposition2, iblockdata5, 2); // CraftBukkit } diff --git a/nms-patches/BlockWaterLily.patch b/nms-patches/BlockWaterLily.patch index e055a69661..95c8f06666 100644 --- a/nms-patches/BlockWaterLily.patch +++ b/nms-patches/BlockWaterLily.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/server/BlockWaterLily.java +++ b/net/minecraft/server/BlockWaterLily.java -@@ -10,7 +10,7 @@ - +@@ -11,7 +11,7 @@ + @Override public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { super.a(iblockdata, world, blockposition, entity); - if (entity instanceof EntityBoat) { + if (entity instanceof EntityBoat && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, Blocks.AIR.getBlockData()).isCancelled()) { // CraftBukkit - world.setAir(new BlockPosition(blockposition), true); + world.b(new BlockPosition(blockposition), true); } diff --git a/nms-patches/BlockWitherSkull.patch b/nms-patches/BlockWitherSkull.patch index bc921119fa..5c104366c7 100644 --- a/nms-patches/BlockWitherSkull.patch +++ b/nms-patches/BlockWitherSkull.patch @@ -11,56 +11,54 @@ + public class BlockWitherSkull extends BlockSkull { - private static ShapeDetector c; -@@ -23,6 +28,7 @@ + @Nullable +@@ -26,6 +31,7 @@ } public static void a(World world, BlockPosition blockposition, TileEntitySkull tileentityskull) { + if (world.captureBlockStates) return; // CraftBukkit - Block block = tileentityskull.getBlock().getBlock(); - boolean flag = block == Blocks.WITHER_SKELETON_SKULL || block == Blocks.WITHER_SKELETON_WALL_SKULL; + if (!world.isClientSide) { + Block block = tileentityskull.getBlock().getBlock(); + boolean flag = block == Blocks.WITHER_SKELETON_SKULL || block == Blocks.WITHER_SKELETON_WALL_SKULL; +@@ -35,12 +41,14 @@ + ShapeDetector.ShapeDetectorCollection shapedetector_shapedetectorcollection = shapedetector.a(world, blockposition); -@@ -31,6 +37,8 @@ - ShapeDetector.ShapeDetectorCollection shapedetector_shapedetectorcollection = shapedetector.a(world, blockposition); + if (shapedetector_shapedetectorcollection != null) { ++ // CraftBukkit start - Use BlockStateListPopulator ++ BlockStateListPopulator blockList = new BlockStateListPopulator(world); + for (int i = 0; i < shapedetector.c(); ++i) { + for (int j = 0; j < shapedetector.b(); ++j) { + ShapeDetectorBlock shapedetectorblock = shapedetector_shapedetectorcollection.a(i, j, 0); - if (shapedetector_shapedetectorcollection != null) { -+ // CraftBukkit start - Use BlockStateListPopulator -+ BlockStateListPopulator blockList = new BlockStateListPopulator(world); - int i; - - for (i = 0; i < 3; ++i) { -@@ -39,7 +47,7 @@ - - for (i = 0; i < shapedetector.c(); ++i) { - for (int j = 0; j < shapedetector.b(); ++j) { -- world.setTypeAndData(shapedetector_shapedetectorcollection.a(i, j, 0).getPosition(), Blocks.AIR.getBlockData(), 2); -+ blockList.setTypeAndData(shapedetector_shapedetectorcollection.a(i, j, 0).getPosition(), Blocks.AIR.getBlockData(), 2); // CraftBukkit +- world.setTypeAndData(shapedetectorblock.getPosition(), Blocks.AIR.getBlockData(), 2); +- world.triggerEffect(2001, shapedetectorblock.getPosition(), Block.getCombinedId(shapedetectorblock.a())); ++ blockList.setTypeAndData(shapedetectorblock.getPosition(), Blocks.AIR.getBlockData(), 2); // CraftBukkit ++ // world.triggerEffect(2001, shapedetectorblock.getPosition(), Block.getCombinedId(shapedetectorblock.a())); // CraftBukkit + } } - } -@@ -50,6 +58,16 @@ - entitywither.setPositionRotation((double) blockposition2.getX() + 0.5D, (double) blockposition2.getY() + 0.55D, (double) blockposition2.getZ() + 0.5D, shapedetector_shapedetectorcollection.getFacing().k() == EnumDirection.EnumAxis.X ? 0.0F : 90.0F, 0.0F); - entitywither.aQ = shapedetector_shapedetectorcollection.getFacing().k() == EnumDirection.EnumAxis.X ? 0.0F : 90.0F; - entitywither.l(); -+ // CraftBukkit start -+ if (!world.addEntity(entitywither, SpawnReason.BUILD_WITHER)) { -+ // Restore drop status from above -+ for (i = 0; i < 3; ++i) { -+ TileEntitySkull.setShouldDrop(world, shapedetector_shapedetectorcollection.a(i, 0, 0).getPosition(), true); +@@ -50,6 +58,15 @@ + entitywither.setPositionRotation((double) blockposition1.getX() + 0.5D, (double) blockposition1.getY() + 0.55D, (double) blockposition1.getZ() + 0.5D, shapedetector_shapedetectorcollection.getFacing().k() == EnumDirection.EnumAxis.X ? 0.0F : 90.0F, 0.0F); + entitywither.aK = shapedetector_shapedetectorcollection.getFacing().k() == EnumDirection.EnumAxis.X ? 0.0F : 90.0F; + entitywither.l(); ++ // CraftBukkit start ++ if (!world.addEntity(entitywither, SpawnReason.BUILD_WITHER)) { ++ return; + } -+ return; -+ } -+ blockList.updateList(); -+ // CraftBukkit end - Iterator iterator = world.a(EntityPlayer.class, entitywither.getBoundingBox().g(50.0D)).iterator(); ++ for (BlockPosition pos : blockList.getBlocks()) { ++ world.triggerEffect(2001, pos, Block.getCombinedId(world.getType(pos))); ++ } ++ blockList.updateList(); ++ // CraftBukkit end + Iterator iterator = world.a(EntityPlayer.class, entitywither.getBoundingBox().g(50.0D)).iterator(); - while (iterator.hasNext()) { -@@ -58,7 +76,7 @@ - CriterionTriggers.n.a(entityplayer, (Entity) entitywither); - } + while (iterator.hasNext()) { +@@ -58,7 +75,7 @@ + CriterionTriggers.n.a(entityplayer, (Entity) entitywither); + } -- world.addEntity(entitywither); -+ // world.addEntity(entitywither); // CraftBukkit - moved up - - int k; +- world.addEntity(entitywither); ++ // world.addEntity(entitywither); // CraftBukkit - moved up + for (int k = 0; k < shapedetector.c(); ++k) { + for (int l = 0; l < shapedetector.b(); ++l) { diff --git a/nms-patches/Chunk.patch b/nms-patches/Chunk.patch index c6d4e6707e..251c2a92e6 100644 --- a/nms-patches/Chunk.patch +++ b/nms-patches/Chunk.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/Chunk.java +++ b/net/minecraft/server/Chunk.java -@@ -21,6 +21,13 @@ +@@ -22,6 +22,13 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -13,74 +13,42 @@ + public class Chunk implements IChunkAccess { - private static final Logger d = LogManager.getLogger(); -@@ -56,6 +63,35 @@ - private final AtomicInteger E; - private final ChunkCoordIntPair F; + private static final Logger b = LogManager.getLogger(); +@@ -91,8 +98,19 @@ + } + } -+ // CraftBukkit start - Neighbor loaded cache for chunk lighting and entity ticking -+ private int neighbors = 0x1 << 12; -+ public long chunkKey; -+ -+ public boolean areNeighborsLoaded(final int radius) { -+ switch (radius) { -+ case 2: -+ return this.neighbors == Integer.MAX_VALUE >> 6; -+ case 1: -+ final int mask = -+ // x z offset x z offset x z offset -+ (0x1 << (1 * 5 + 1 + 12)) | (0x1 << (0 * 5 + 1 + 12)) | (0x1 << (-1 * 5 + 1 + 12)) | -+ (0x1 << (1 * 5 + 0 + 12)) | (0x1 << (0 * 5 + 0 + 12)) | (0x1 << (-1 * 5 + 0 + 12)) | -+ (0x1 << (1 * 5 + -1 + 12)) | (0x1 << (0 * 5 + -1 + 12)) | (0x1 << (-1 * 5 + -1 + 12)); -+ return (this.neighbors & mask) == mask; -+ default: -+ throw new UnsupportedOperationException(String.valueOf(radius)); -+ } -+ } -+ -+ public void setNeighborLoaded(final int x, final int z) { -+ this.neighbors |= 0x1 << (x * 5 + 12 + z); -+ } -+ -+ public void setNeighborUnloaded(final int x, final int z) { -+ this.neighbors &= ~(0x1 << (x * 5 + 12 + z)); -+ } -+ // CraftBukkit end -+ - public Chunk(World world, int i, int j, BiomeBase[] abiomebase, ChunkConverter chunkconverter, TickList ticklist, TickList ticklist1, long k) { - this.sections = new ChunkSection[16]; - this.g = new boolean[256]; -@@ -94,8 +130,16 @@ - this.s = ticklist; - this.t = ticklist1; - this.z = k; + // CraftBukkit start + this.bukkitChunk = new org.bukkit.craftbukkit.CraftChunk(this); -+ this.chunkKey = ChunkCoordIntPair.a(this.locX, this.locZ); ++ } ++ ++ public org.bukkit.Chunk bukkitChunk; ++ public org.bukkit.Chunk getBukkitChunk() { ++ return bukkitChunk; } -+ public org.bukkit.Chunk bukkitChunk; -+ public boolean mustSave; -+ private boolean needsDecoration; ++ public boolean mustNotSave; ++ public boolean needsDecoration; + // CraftBukkit end + - public Chunk(World world, ProtoChunk protochunk, int i, int j) { - this(world, i, j, protochunk.getBiomeIndex(), protochunk.v(), protochunk.k(), protochunk.l(), protochunk.m()); + public Chunk(World world, ProtoChunk protochunk) { + this(world, protochunk.getPos(), protochunk.getBiomeIndex(), protochunk.p(), protochunk.n(), protochunk.o(), protochunk.q(), protochunk.getSections(), (Consumer) null); + Iterator iterator = protochunk.y().iterator(); +@@ -134,6 +152,7 @@ -@@ -143,6 +187,7 @@ - - this.x = true; - this.a(ChunkStatus.FULLCHUNK); + this.b(protochunk.r()); + this.s = true; + this.needsDecoration = true; // CraftBukkit } - public Set t() { -@@ -412,8 +457,15 @@ + @Override +@@ -224,9 +243,16 @@ } } + // CraftBukkit start @Nullable + @Override public IBlockData setType(BlockPosition blockposition, IBlockData iblockdata, boolean flag) { + return this.setType(blockposition, iblockdata, flag, true); + } @@ -91,17 +59,17 @@ int i = blockposition.getX() & 15; int j = blockposition.getY(); int k = blockposition.getZ() & 15; -@@ -473,7 +525,8 @@ +@@ -278,7 +304,8 @@ } } - if (!this.world.isClientSide) { + // CraftBukkit - Don't place while processing the BlockPlaceEvent, unless it's a BlockContainer. Prevents blocks such as TNT from activating when cancelled. + if (!this.world.isClientSide && doPlace && (!this.world.captureBlockStates || block instanceof BlockTileEntity)) { - iblockdata.onPlace(this.world, blockposition, iblockdata1); + iblockdata.onPlace(this.world, blockposition, iblockdata1, flag); } -@@ -653,7 +706,12 @@ +@@ -378,7 +405,12 @@ @Nullable public TileEntity a(BlockPosition blockposition, Chunk.EnumTileEntityState chunk_enumtileentitystate) { @@ -114,39 +82,27 @@ + // CraftBukkit end if (tileentity == null) { - NBTTagCompound nbttagcompound = (NBTTagCompound) this.h.remove(blockposition); -@@ -700,6 +758,13 @@ + NBTTagCompound nbttagcompound = (NBTTagCompound) this.e.remove(blockposition); +@@ -425,6 +457,13 @@ + tileentity1.m(); + } - tileentity.z(); - this.tileEntities.put(blockposition.h(), tileentity); + // CraftBukkit start + } else { + System.out.println("Attempted to place a tile entity (" + tileentity + ") at " + tileentity.position.getX() + "," + tileentity.position.getY() + "," + tileentity.position.getZ() + + " (" + getType(blockposition) + ") where there was no entity tile!"); -+ System.out.println("Chunk coordinates: " + (this.locX * 16) + "," + (this.locZ * 16)); ++ System.out.println("Chunk coordinates: " + (this.loc.x * 16) + "," + (this.loc.z * 16)); + new Exception().printStackTrace(); + // CraftBukkit end } } -@@ -727,11 +792,53 @@ - for (int j = 0; j < i; ++j) { - EntitySlice entityslice = aentityslice[j]; +@@ -453,6 +492,41 @@ -+ // CraftBukkit start -+ List toRemove = new LinkedList<>(); - this.world.a(entityslice.stream().filter((entity) -> { -+ if (this.needsDecoration && !CraftEventFactory.doEntityAddEventCalling(this.world, entity, CreatureSpawnEvent.SpawnReason.CHUNK_GEN)) { // Only call for new chunks -+ toRemove.add(entity); -+ return false; -+ } - return !(entity instanceof EntityHuman); - })); -+ entityslice.removeAll(toRemove); -+ // CraftBukkit end - } + } -+ // CraftBukkit start ++ // CraftBukkit start ++ public void loadCallback() { + org.bukkit.Server server = this.world.getServer(); + if (server != null) { + /* @@ -157,12 +113,11 @@ + server.getPluginManager().callEvent(new org.bukkit.event.world.ChunkLoadEvent(this.bukkitChunk, this.needsDecoration)); + + if (this.needsDecoration) { -+ BlockSand.instaFall = true; + java.util.Random random = new java.util.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()); ++ random.setSeed((long) this.loc.x * xRand + (long) this.loc.z * zRand ^ world.getSeed()); + + org.bukkit.World world = this.world.getWorld(); + if (world != null) { @@ -175,40 +130,17 @@ + this.world.populating = false; + } + } -+ BlockSand.instaFall = false; + server.getPluginManager().callEvent(new org.bukkit.event.world.ChunkPopulateEvent(bukkitChunk)); + } + } -+ // CraftBukkit end - } - - public void removeEntities() { -@@ -748,9 +855,21 @@ - int i = aentityslice.length; - - for (int j = 0; j < i; ++j) { -- EntitySlice entityslice = aentityslice[j]; -+ // CraftBukkit start -+ List newList = Lists.newArrayList(aentityslice[j]); -+ java.util.Iterator iter = newList.iterator(); -+ while (iter.hasNext()) { -+ Entity entity = iter.next(); ++ } ++ // CraftBukkit end + -+ // Do not pass along players, as doing so can get them stuck outside of time. -+ // (which for example disables inventory icon updates and prevents block breaking) -+ if (entity instanceof EntityPlayer) { -+ iter.remove(); -+ } -+ } - -- this.world.b((Collection) entityslice); -+ this.world.b((Collection) newList); -+ // CraftBukkit end - } - + public void markDirty() { + this.s = true; } -@@ -810,7 +929,7 @@ - Iterator iterator = this.entitySlices[k].c(oclass).iterator(); +@@ -527,7 +601,7 @@ + Iterator iterator = this.entitySlices[k].a(oclass).iterator(); while (iterator.hasNext()) { - T t0 = (Entity) iterator.next(); @@ -216,19 +148,30 @@ if (t0.getBoundingBox().c(axisalignedbb) && (predicate == null || predicate.test(t0))) { list.add(t0); -@@ -1073,13 +1192,13 @@ - } +@@ -601,7 +675,7 @@ - if (this.s instanceof ProtoChunkTickList) { -- ((ProtoChunkTickList) this.s).a(this.world.getBlockTickList(), (blockposition1) -> { -+ ((ProtoChunkTickList) this.s).a(this.world.getBlockTickList(), (blockposition1) -> { // CraftBukkit - decompile error - return this.world.getType(blockposition1).getBlock(); - }); - } + @Override + public boolean isNeedsSaving() { +- return this.s || this.q && this.world.getTime() != this.lastSaved; ++ return (this.s || this.q && this.world.getTime() != this.lastSaved) && !this.mustNotSave; // CraftBukkit + } - if (this.t instanceof ProtoChunkTickList) { -- ((ProtoChunkTickList) this.t).a(this.world.getFluidTickList(), (blockposition1) -> { -+ ((ProtoChunkTickList) this.t).a(this.world.getFluidTickList(), (blockposition1) -> { // CraftBukkit - decompile error - return this.world.getFluid(blockposition1).c(); - }); - } + public void d(boolean flag) { +@@ -691,7 +765,7 @@ + } + + if (this.o instanceof ProtoChunkTickList) { +- ((ProtoChunkTickList) this.o).a(this.world.getBlockTickList(), (blockposition1) -> { ++ ((ProtoChunkTickList) this.o).a(this.world.getBlockTickList(), (blockposition1) -> { // CraftBukkit - decompile error + return this.getType(blockposition1).getBlock(); + }); + } else if (this.o instanceof TickListChunk) { +@@ -700,7 +774,7 @@ + } + + if (this.p instanceof ProtoChunkTickList) { +- ((ProtoChunkTickList) this.p).a(this.world.getFluidTickList(), (blockposition1) -> { ++ ((ProtoChunkTickList) this.p).a(this.world.getFluidTickList(), (blockposition1) -> { // CraftBukkit - decompile error + return this.getFluid(blockposition1).getType(); + }); + } else if (this.p instanceof TickListChunk) { diff --git a/nms-patches/ChunkMap.patch b/nms-patches/ChunkMap.patch deleted file mode 100644 index 19e3aad4ee..0000000000 --- a/nms-patches/ChunkMap.patch +++ /dev/null @@ -1,26 +0,0 @@ ---- a/net/minecraft/server/ChunkMap.java -+++ b/net/minecraft/server/ChunkMap.java -@@ -31,6 +31,23 @@ - } - } - -+ // CraftBukkit start -+ // Update neighbor counts -+ for (int x = -2; x < 3; x++) { -+ for (int z = -2; z < 3; z++) { -+ if (x == 0 && z == 0) { -+ continue; -+ } -+ -+ Chunk neighbor = this.get(ChunkCoordIntPair.a(chunkcoordintpair.x + x, chunkcoordintpair.z + z)); -+ if (neighbor != null) { -+ neighbor.setNeighborLoaded(-x, -z); -+ chunk.setNeighborLoaded(x, z); -+ } -+ } -+ } -+ // CraftBukkit end -+ - return chunk1; - } - diff --git a/nms-patches/ChunkProviderGenerate.patch b/nms-patches/ChunkProviderGenerate.patch index 403f7a373b..b9cb61bc5b 100644 --- a/nms-patches/ChunkProviderGenerate.patch +++ b/nms-patches/ChunkProviderGenerate.patch @@ -1,14 +1,23 @@ --- a/net/minecraft/server/ChunkProviderGenerate.java +++ b/net/minecraft/server/ChunkProviderGenerate.java -@@ -166,6 +166,11 @@ - f5 = 1.0F + f5 * 2.0F; - f6 = 1.0F + f6 * 4.0F; - } -+ // CraftBukkit start - fix MC-54738 -+ if (f5 < -1.8F) { -+ f5 = -1.8F; -+ } -+ // CraftBukkit end +@@ -4,7 +4,7 @@ - float f7 = this.o[l1 + 2 + (i2 + 2) * 5] / (f5 + 2.0F); + public class ChunkProviderGenerate extends ChunkGeneratorAbstract { + +- private static final float[] h = (float[]) SystemUtils.a((Object) (new float[25]), (afloat) -> { ++ private static final float[] h = (float[]) SystemUtils.a((new float[25]), (afloat) -> { // CraftBukkit - decompile error + for (int i = -2; i <= 2; ++i) { + for (int j = -2; j <= 2; ++j) { + float f = 10.0F / MathHelper.c((float) (i * i + j * j) + 0.2F); +@@ -81,6 +81,11 @@ + f4 = 1.0F + f4 * 2.0F; + f5 = 1.0F + f5 * 4.0F; + } ++ // CraftBukkit start - fix MC-54738 ++ if (f4 < -1.8F) { ++ f4 = -1.8F; ++ } ++ // CraftBukkit end + + float f6 = ChunkProviderGenerate.h[k + 2 + (l + 2) * 5] / (f4 + 2.0F); diff --git a/nms-patches/ChunkProviderServer.patch b/nms-patches/ChunkProviderServer.patch index ac09c231f0..65a05a2ea8 100644 --- a/nms-patches/ChunkProviderServer.patch +++ b/nms-patches/ChunkProviderServer.patch @@ -1,109 +1,78 @@ --- a/net/minecraft/server/ChunkProviderServer.java +++ b/net/minecraft/server/ChunkProviderServer.java -@@ -16,6 +16,11 @@ - import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; +@@ -82,7 +82,7 @@ -+// CraftBukkit start -+import org.bukkit.craftbukkit.chunkio.ChunkIOExecutor; -+import org.bukkit.event.world.ChunkUnloadEvent; -+// CraftBukkit end -+ - public class ChunkProviderServer implements IChunkProvider { - - private static final Logger a = LogManager.getLogger(); -@@ -34,7 +39,7 @@ - this.chunkLoader = ichunkloader; - this.chunkGenerator = chunkgenerator; - this.asyncTaskHandler = iasynctaskhandler; -- this.chunkScheduler = new ChunkTaskScheduler(2, worldserver, chunkgenerator, ichunkloader, iasynctaskhandler); -+ this.chunkScheduler = new ChunkTaskScheduler(0, worldserver, chunkgenerator, ichunkloader, iasynctaskhandler); // CraftBukkit - very buggy, broken in lots of __subtle__ ways. Same goes for async chunk loading. Also Bukkit API / plugins can't handle async events at all anyway. - this.batchScheduler = new SchedulerBatch<>(this.chunkScheduler); + if (flag1) { + completablefuture = this.getChunkFutureMainThread(i, j, chunkstatus, flag); +- this.serverThreadQueue.c(completablefuture::isDone); ++ this.serverThreadQueue.c((BooleanSupplier) completablefuture::isDone); // CraftBukkit - decompile error + } else { + completablefuture = CompletableFuture.supplyAsync(() -> { + return this.getChunkFutureMainThread(i, j, chunkstatus, flag); +@@ -193,6 +193,17 @@ + this.playerChunkMap.close(); } -@@ -112,6 +117,25 @@ - } - } - -+ // CraftBukkit start -+ public Chunk generateChunk(int x, int z) { -+ try { -+ this.batchScheduler.b(); -+ ChunkCoordIntPair pos = new ChunkCoordIntPair(x, z); -+ this.chunkScheduler.forcePolluteCache(pos); -+ ((ChunkRegionLoader) this.chunkLoader).blacklist.add(pos.a()); -+ this.batchScheduler.a(pos); -+ CompletableFuture completablefuture = this.batchScheduler.c(); -+ -+ Chunk chunk = (Chunk) completablefuture.thenApply(this::a).join(); -+ ((ChunkRegionLoader) this.chunkLoader).blacklist.remove(pos.a()); -+ return chunk; -+ } catch (RuntimeException runtimeexception) { -+ throw this.a(x, z, (Throwable) runtimeexception); -+ } ++ // CraftBukkit start - modelled on below ++ public void purgeUnload() { ++ this.world.getMethodProfiler().enter("purge"); ++ this.chunkMapDistance.purgeTickets(); ++ this.tickDistanceManager(); ++ this.world.getMethodProfiler().exitEnter("unload"); ++ this.playerChunkMap.unloadChunks(() -> true); ++ this.world.getMethodProfiler().exit(); + } + // CraftBukkit end + - public IChunkAccess a(int i, int j, boolean flag) { - Chunk chunk = this.getChunkAt(i, j, true, false); + public void tick(BooleanSupplier booleansupplier) { + this.world.getMethodProfiler().enter("purge"); + this.chunkMapDistance.purgeTickets(); +@@ -211,14 +222,14 @@ + this.lastTickTime = i; + WorldData worlddata = this.world.getWorldData(); + boolean flag = worlddata.getType() == WorldType.DEBUG_ALL_BLOCK_STATES; +- boolean flag1 = this.world.getGameRules().getBoolean("doMobSpawning"); ++ boolean flag1 = this.world.getGameRules().getBoolean("doMobSpawning") && !world.getPlayers().isEmpty(); // CraftBukkit -@@ -249,10 +273,12 @@ - Chunk chunk = (Chunk) this.chunks.get(olong); + if (!flag) { + this.world.getMethodProfiler().enter("pollingChunks"); + int k = this.chunkMapDistance.b(); + int l = this.world.getGameRules().c("randomTickSpeed"); + BlockPosition blockposition = this.world.getSpawn(); +- boolean flag2 = worlddata.getTime() % 400L == 0L; ++ boolean flag2 = world.ticksPerAnimalSpawns != 0L && worlddata.getTime() % world.ticksPerAnimalSpawns == 0L; // CraftBukkit // PAIL: TODO monster ticks + EnumCreatureType[] aenumcreaturetype = EnumCreatureType.values(); + Object2IntMap object2intmap = this.world.l(); + ObjectBidirectionalIterator objectbidirectionaliterator = this.playerChunkMap.f(); +@@ -244,8 +255,30 @@ + for (int j1 = 0; j1 < i1; ++j1) { + EnumCreatureType enumcreaturetype = aenumcreaturetype1[j1]; - if (chunk != null) { -- chunk.removeEntities(); -- this.saveChunk(chunk); -- this.chunks.remove(olong); -- this.lastChunk = null; -+ // CraftBukkit start - move unload logic to own method -+ if (!unloadChunk(chunk, true)) { -+ continue; -+ } -+ // CraftBukkit end ++ // CraftBukkit start - Use per-world spawn limits ++ int limit = enumcreaturetype.b(); ++ switch (enumcreaturetype) { ++ case MONSTER: ++ limit = world.getWorld().getMonsterSpawnLimit(); ++ break; ++ case CREATURE: ++ limit = world.getWorld().getAnimalSpawnLimit(); ++ break; ++ case WATER_CREATURE: ++ limit = world.getWorld().getWaterAnimalSpawnLimit(); ++ break; ++ case AMBIENT: ++ limit = world.getWorld().getAmbientSpawnLimit(); ++ break; ++ } + - ++i; - } - } -@@ -265,6 +291,42 @@ - return false; - } ++ if (limit == 0) { ++ continue; ++ } ++ // CraftBukkit end ++ + if (enumcreaturetype != EnumCreatureType.MISC && (!enumcreaturetype.c() || this.allowAnimals) && (enumcreaturetype.c() || this.allowMonsters) && (!enumcreaturetype.d() || flag2)) { +- int k1 = enumcreaturetype.b() * k / ChunkProviderServer.b; ++ int k1 = limit * k / ChunkProviderServer.b; // CraftBukkit - use per-world limits -+ // CraftBukkit start -+ public boolean unloadChunk(Chunk chunk, boolean save) { -+ ChunkUnloadEvent event = new ChunkUnloadEvent(chunk.bukkitChunk, save); -+ this.world.getServer().getPluginManager().callEvent(event); -+ if (event.isCancelled()) { -+ return false; -+ } -+ save = event.isSaveChunk(); -+ -+ // Update neighbor counts -+ for (int x = -2; x < 3; x++) { -+ for (int z = -2; z < 3; z++) { -+ if (x == 0 && z == 0) { -+ continue; -+ } -+ -+ Chunk neighbor = this.getChunkAt(chunk.locX + x, chunk.locZ + z, false, false); -+ if (neighbor != null) { -+ neighbor.setNeighborUnloaded(-x, -z); -+ chunk.setNeighborUnloaded(x, z); -+ } -+ } -+ } -+ // Moved from unloadChunks above -+ synchronized (this.chunkLoader) { -+ chunk.removeEntities(); -+ if (save) { -+ this.saveChunk(chunk); -+ } -+ this.chunks.remove(chunk.chunkKey); -+ this.lastChunk = null; -+ } -+ return true; -+ } -+ // CraftBukkit end -+ - public boolean d() { - return !this.world.savingDisabled; - } + if (object2intmap.getInt(enumcreaturetype) <= k1) { + SpawnerCreature.a(enumcreaturetype, (World) this.world, chunk, blockposition); diff --git a/nms-patches/ChunkRegionLoader.patch b/nms-patches/ChunkRegionLoader.patch deleted file mode 100644 index f9fde031cb..0000000000 --- a/nms-patches/ChunkRegionLoader.patch +++ /dev/null @@ -1,305 +0,0 @@ ---- a/net/minecraft/server/ChunkRegionLoader.java -+++ b/net/minecraft/server/ChunkRegionLoader.java -@@ -29,7 +29,8 @@ - private final File c; - private final DataFixer d; - private PersistentStructureLegacy e; -- private boolean f; -+ // private boolean f; // CraftBukkit -+ public final LongSet blacklist = new LongOpenHashSet(); - - public ChunkRegionLoader(File file, DataFixer datafixer) { - this.c = file; -@@ -38,25 +39,69 @@ - - @Nullable - private NBTTagCompound a(GeneratorAccess generatoraccess, int i, int j) throws IOException { -- return this.a(generatoraccess.o().getDimensionManager(), generatoraccess.h(), i, j); -+ return this.a(generatoraccess.o().getDimensionManager(), generatoraccess.h(), i, j, generatoraccess); // CraftBukkit -+ } -+ -+ // CraftBukkit start -+ private boolean check(ChunkProviderServer cps, int x, int z) throws IOException { -+ if (cps != null) { -+ com.google.common.base.Preconditions.checkState(org.bukkit.Bukkit.isPrimaryThread(), "primary thread"); -+ if (cps.isLoaded(x, z)) { -+ return true; -+ } -+ } -+ -+ if (this.chunkExists(x, z)) { -+ NBTTagCompound nbt = RegionFileCache.read(this.c, x, z); -+ if (nbt != null) { -+ NBTTagCompound level = nbt.getCompound("Level"); -+ if (level.getBoolean("TerrainPopulated")) { -+ return true; -+ } -+ -+ ChunkStatus status = ChunkStatus.a(level.getString("Status")); -+ if (status != null && status.a(ChunkStatus.DECORATED)) { -+ return true; -+ } -+ } -+ } -+ -+ return false; -+ } -+ -+ public boolean chunkExists(int x, int z) { -+ return RegionFileCache.chunkExists(this.c, x, z); - } - - @Nullable -- private NBTTagCompound a(DimensionManager dimensionmanager, @Nullable PersistentCollection persistentcollection, int i, int j) throws IOException { -+ private NBTTagCompound a(DimensionManager dimensionmanager, @Nullable PersistentCollection persistentcollection, int i, int j, @Nullable GeneratorAccess generatoraccess) throws IOException { -+ // CraftBukkit start -+ if (blacklist.contains(ChunkCoordIntPair.a(i, j))) { -+ return null; -+ } -+ // CraftBukkit end - NBTTagCompound nbttagcompound = (NBTTagCompound) this.b.get(new ChunkCoordIntPair(i, j)); - - if (nbttagcompound != null) { - return nbttagcompound; - } else { -- DataInputStream datainputstream = RegionFileCache.read(this.c, i, j); -+ NBTTagCompound nbttagcompound1 = RegionFileCache.read(this.c, i, j); - -- if (datainputstream == null) { -+ if (nbttagcompound1 == null) { - return null; - } else { -- NBTTagCompound nbttagcompound1 = NBTCompressedStreamTools.a(datainputstream); -- -- datainputstream.close(); - int k = nbttagcompound1.hasKeyOfType("DataVersion", 99) ? nbttagcompound1.getInt("DataVersion") : -1; -+ // CraftBukkit start -+ if (k < 1466) { -+ NBTTagCompound level = nbttagcompound1.getCompound("Level"); -+ if (level.getBoolean("TerrainPopulated") && !level.getBoolean("LightPopulated")) { -+ ChunkProviderServer cps = (generatoraccess == null) ? null : ((WorldServer) generatoraccess).getChunkProvider(); -+ if (check(cps, i - 1, j) && check(cps, i - 1, j - 1) && check(cps, i, j - 1)) { -+ level.setBoolean("LightPopulated", true); -+ } -+ } -+ } -+ // CraftBukkit end - - if (k < 1493) { - nbttagcompound1 = GameProfileSerializer.a(this.d, DataFixTypes.CHUNK, nbttagcompound1, k, 1493); -@@ -84,13 +129,29 @@ - - } - -+ // CraftBukkit start - Add async variant, provide compatibility - @Nullable - public Chunk a(GeneratorAccess generatoraccess, int i, int j, Consumer consumer) throws IOException { -+ Object[] data = loadChunk(generatoraccess, i, j, consumer); -+ if (data != null) { -+ Chunk chunk = (Chunk) data[0]; -+ NBTTagCompound nbttagcompound = (NBTTagCompound) data[1]; -+ consumer.accept(chunk); -+ this.loadEntities(nbttagcompound.getCompound("Level"), chunk); -+ return chunk; -+ } -+ -+ return null; -+ } -+ -+ public Object[] loadChunk(GeneratorAccess generatoraccess, int i, int j, Consumer consumer) throws IOException { -+ // CraftBukkit end - NBTTagCompound nbttagcompound = this.a(generatoraccess, i, j); - - if (nbttagcompound == null) { - return null; - } else { -+ /* - Chunk chunk = this.a(generatoraccess, i, j, nbttagcompound); - - if (chunk != null) { -@@ -99,6 +160,9 @@ - } - - return chunk; -+ */ -+ -+ return this.a(generatoraccess, i, j, nbttagcompound); - } - } - -@@ -130,7 +194,7 @@ - } - - @Nullable -- protected Chunk a(GeneratorAccess generatoraccess, int i, int j, NBTTagCompound nbttagcompound) { -+ protected Object[] a(GeneratorAccess generatoraccess, int i, int j, NBTTagCompound nbttagcompound) { // CraftBukkit - return Chunk -> Object[] - if (nbttagcompound.hasKeyOfType("Level", 10) && nbttagcompound.getCompound("Level").hasKeyOfType("Status", 8)) { - ChunkStatus.Type chunkstatus_type = this.a(nbttagcompound); - -@@ -149,10 +213,28 @@ - ChunkRegionLoader.a.error("Chunk file at {},{} is in the wrong location; relocating. (Expected {}, {}, got {}, {})", i, j, i, j, chunk.locX, chunk.locZ); - nbttagcompound1.setInt("xPos", i); - nbttagcompound1.setInt("zPos", j); -+ -+ // CraftBukkit start - Have to move tile entities since we don't load them at this stage -+ NBTTagList tileEntities = nbttagcompound.getCompound("Level").getList("TileEntities", 10); -+ if (tileEntities != null) { -+ for (int te = 0; te < tileEntities.size(); te++) { -+ NBTTagCompound tileEntity = (NBTTagCompound) tileEntities.get(te); -+ int x = tileEntity.getInt("x") - chunk.locX * 16; -+ int z = tileEntity.getInt("z") - chunk.locZ * 16; -+ tileEntity.setInt("x", i * 16 + x); -+ tileEntity.setInt("z", j * 16 + z); -+ } -+ } -+ // CraftBukkit end - chunk = this.a(generatoraccess, nbttagcompound1); - } - -- return chunk; -+ // CraftBukkit start -+ Object[] data = new Object[2]; -+ data[0] = chunk; -+ data[1] = nbttagcompound; -+ return data; -+ // CraftBukkit end - } - } - } else { -@@ -167,7 +249,7 @@ - ChunkStatus.Type chunkstatus_type = this.a(nbttagcompound); - - if (chunkstatus_type == ChunkStatus.Type.LEVELCHUNK) { -- return new ProtoChunkExtension(this.a(generatoraccess, i, j, nbttagcompound)); -+ return new ProtoChunkExtension((IChunkAccess) this.a(generatoraccess, i, j, nbttagcompound)[0]); // CraftBukkit - fix up access - } else { - NBTTagCompound nbttagcompound1 = nbttagcompound.getCompound("Level"); - -@@ -215,10 +297,15 @@ - } - - public boolean a() { -+ // CraftBukkit start -+ return this.processSaveQueueEntry(false); -+ } -+ -+ private boolean processSaveQueueEntry(boolean logCompletion) { - Iterator> iterator = this.b.entrySet().iterator(); - - if (!iterator.hasNext()) { -- if (this.f) { -+ if (logCompletion) { // CraftBukkit - ChunkRegionLoader.a.info("ThreadedAnvilChunkStorage ({}): All chunks are saved", this.c.getName()); - } - -@@ -234,10 +321,14 @@ - return true; - } else { - try { -- DataOutputStream dataoutputstream = RegionFileCache.write(this.c, chunkcoordintpair.x, chunkcoordintpair.z); -+ // CraftBukkit start -+ RegionFileCache.write(this.c, chunkcoordintpair.x, chunkcoordintpair.z, nbttagcompound); - -+ /* - NBTCompressedStreamTools.a(nbttagcompound, (DataOutput) dataoutputstream); - dataoutputstream.close(); -+ */ -+ // CraftBukkit end - if (this.e != null) { - this.e.a(chunkcoordintpair.a()); - } -@@ -264,15 +355,16 @@ - - public void b() { - try { -- this.f = true; -+ // this.f = true; // CraftBukkit - - while (true) { -- if (this.a()) { -+ if (this.processSaveQueueEntry(true)) { // CraftBukkit - continue; - } -+ break; // CraftBukkit - Fix infinite loop when saving chunks - } - } finally { -- this.f = false; -+ // this.f = false; // CraftBukkit - } - - } -@@ -301,7 +393,7 @@ - - if (abiomebase != null) { - for (int k = 0; k < abiomebase.length; ++k) { -- aint[k] = IRegistry.BIOME.a((Object) abiomebase[k]); -+ aint[k] = IRegistry.BIOME.a(abiomebase[k]); // CraftBukkit - decompile error - } - } - -@@ -383,7 +475,7 @@ - int[] aint = new int[abiomebase.length]; - - for (int i = 0; i < abiomebase.length; ++i) { -- aint[i] = IRegistry.BIOME.a((Object) abiomebase[i]); -+ aint[i] = IRegistry.BIOME.a(abiomebase[i]); // CraftBukkit - decompile error - } - - nbttagcompound.setIntArray("Biomes", aint); -@@ -833,17 +925,29 @@ - } - - @Nullable -+ // CraftBukkit start - public static Entity a(NBTTagCompound nbttagcompound, World world, double d0, double d1, double d2, boolean flag) { -+ return spawnEntity(nbttagcompound, world, d0, d1, d2, flag, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT); -+ } -+ -+ public static Entity spawnEntity(NBTTagCompound nbttagcompound, World world, double d0, double d1, double d2, boolean flag, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) { -+ // CraftBukkit end - return a(nbttagcompound, world, (entity) -> { - entity.setPositionRotation(d0, d1, d2, entity.yaw, entity.pitch); -- return flag && !world.addEntity(entity) ? null : entity; -+ return flag && !world.addEntity(entity, spawnReason) ? null : entity; - }); - } - - @Nullable -+ // CraftBukkit start - public static Entity a(NBTTagCompound nbttagcompound, World world, boolean flag) { -+ return spawnEntity(nbttagcompound, world, flag, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT); -+ } -+ -+ public static Entity spawnEntity(NBTTagCompound nbttagcompound, World world, boolean flag, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) { -+ // CraftBukkit end - return a(nbttagcompound, world, (entity) -> { -- return flag && !world.addEntity(entity) ? null : entity; -+ return flag && !world.addEntity(entity, spawnReason) ? null : entity; // CraftBukkit - }); - } - -@@ -857,8 +961,14 @@ - } - } - -+ // CraftBukkit start - public static void a(Entity entity, GeneratorAccess generatoraccess) { -- if (generatoraccess.addEntity(entity) && entity.isVehicle()) { -+ a(entity, generatoraccess, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT); -+ } -+ -+ public static void a(Entity entity, GeneratorAccess generatoraccess, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) { -+ if (generatoraccess.addEntity(entity, reason) && entity.isVehicle()) { -+ // CraftBukkit end - Iterator iterator = entity.bP().iterator(); - - while (iterator.hasNext()) { -@@ -874,7 +984,7 @@ - boolean flag = false; - - try { -- this.a(dimensionmanager, persistentcollection, chunkcoordintpair.x, chunkcoordintpair.z); -+ this.a(dimensionmanager, persistentcollection, chunkcoordintpair.x, chunkcoordintpair.z, null); // CraftBukkit - - while (this.a()) { - flag = true; diff --git a/nms-patches/ChunkTaskScheduler.patch b/nms-patches/ChunkTaskScheduler.patch deleted file mode 100644 index f94778aaf8..0000000000 --- a/nms-patches/ChunkTaskScheduler.patch +++ /dev/null @@ -1,15 +0,0 @@ ---- a/net/minecraft/server/ChunkTaskScheduler.java -+++ b/net/minecraft/server/ChunkTaskScheduler.java -@@ -37,6 +37,12 @@ - this.f = iasynctaskhandler; - } - -+ // CraftBukkit start -+ public void forcePolluteCache(ChunkCoordIntPair chunkcoordintpair) { -+ this.progressCache.put(chunkcoordintpair.a(), new Scheduler.a(chunkcoordintpair, new ProtoChunk(chunkcoordintpair, ChunkConverter.a), ChunkStatus.EMPTY)); -+ } -+ // CraftBukkit end -+ - @Nullable - protected Scheduler.a a(ChunkCoordIntPair chunkcoordintpair, boolean flag) { - IChunkLoader ichunkloader = this.e; diff --git a/nms-patches/CommandBlockListenerAbstract.patch b/nms-patches/CommandBlockListenerAbstract.patch index 6bf30152d8..42b2f97820 100644 --- a/nms-patches/CommandBlockListenerAbstract.patch +++ b/nms-patches/CommandBlockListenerAbstract.patch @@ -9,9 +9,9 @@ public abstract class CommandBlockListenerAbstract implements ICommandListener { @@ -15,6 +16,10 @@ - private IChatBaseComponent f; - private String g = ""; - private IChatBaseComponent h = new ChatComponentText("@"); + private IChatBaseComponent lastOutput; + private String command = ""; + private IChatBaseComponent customName = new ChatComponentText("@"); + // CraftBukkit start + @Override + public abstract CommandSender getBukkitSender(CommandListenerWrapper wrapper); @@ -20,18 +20,18 @@ public CommandBlockListenerAbstract() {} @@ -102,14 +107,7 @@ - if (minecraftserver != null && minecraftserver.D() && minecraftserver.getEnableCommandBlock() && !UtilColor.b(this.g)) { + if (minecraftserver != null && minecraftserver.E() && minecraftserver.getEnableCommandBlock() && !UtilColor.b(this.command)) { try { - this.f = null; + this.lastOutput = null; - CommandListenerWrapper commandlistenerwrapper = this.getWrapper().a((commandcontext, flag, i) -> { - if (flag) { -- ++this.d; +- ++this.successCount; - } - - }); - -- minecraftserver.getCommandDispatcher().a(commandlistenerwrapper, this.g); -+ this.d = minecraftserver.getCommandDispatcher().dispatchServerCommand(this.getWrapper(), this.g); // CraftBukkit +- minecraftserver.getCommandDispatcher().a(commandlistenerwrapper, this.command); ++ this.successCount = minecraftserver.getCommandDispatcher().dispatchServerCommand(this.getWrapper(), this.command); // CraftBukkit } catch (Throwable throwable) { CrashReport crashreport = CrashReport.a(throwable, "Executing command block"); CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Command to be executed"); @@ -44,6 +44,6 @@ + ichatbasecomponent = new ChatComponentText("@"); + } + // CraftBukkit end - this.h = ichatbasecomponent; + this.customName = ichatbasecomponent; } diff --git a/nms-patches/CommandDebug.patch b/nms-patches/CommandDebug.patch deleted file mode 100644 index 797a6c8c2f..0000000000 --- a/nms-patches/CommandDebug.patch +++ /dev/null @@ -1,32 +0,0 @@ ---- a/net/minecraft/server/CommandDebug.java -+++ b/net/minecraft/server/CommandDebug.java -@@ -33,6 +33,14 @@ - } - - private static int a(CommandListenerWrapper commandlistenerwrapper) throws CommandSyntaxException { -+ // CraftBukkit start - only allow use when enabled (so that no blank profile results occur) -+ if (!commandlistenerwrapper.getServer().methodProfiler.ENABLED) { -+ commandlistenerwrapper.sendFailureMessage(new ChatComponentText("Vanilla debug profiling is disabled.")); -+ commandlistenerwrapper.sendFailureMessage(new ChatComponentText("To enable, restart the server with `-DenableDebugMethodProfiler=true' before `-jar'.")); -+ commandlistenerwrapper.sendFailureMessage(new ChatComponentText("Use `/timings' for plugin timings.")); -+ return 0; -+ } -+ // CraftBukkit end - MinecraftServer minecraftserver = commandlistenerwrapper.getServer(); - MethodProfiler methodprofiler = minecraftserver.methodProfiler; - -@@ -46,6 +54,14 @@ - } - - private static int b(CommandListenerWrapper commandlistenerwrapper) throws CommandSyntaxException { -+ // CraftBukkit start - only allow use when enabled (so that no blank profile results occur) -+ if (!commandlistenerwrapper.getServer().methodProfiler.ENABLED) { -+ commandlistenerwrapper.sendFailureMessage(new ChatComponentText("Vanilla debug profiling is disabled.")); -+ commandlistenerwrapper.sendFailureMessage(new ChatComponentText("To enable, restart the server with `-DenableDebugMethodProfiler=true' before `-jar'.")); -+ commandlistenerwrapper.sendFailureMessage(new ChatComponentText("Use `/timings' for plugin timings.")); -+ return 0; -+ } -+ // CraftBukkit end - MinecraftServer minecraftserver = commandlistenerwrapper.getServer(); - MethodProfiler methodprofiler = minecraftserver.methodProfiler; - diff --git a/nms-patches/CommandDispatcher.patch b/nms-patches/CommandDispatcher.patch index 95782935b4..1454f31d76 100644 --- a/nms-patches/CommandDispatcher.patch +++ b/nms-patches/CommandDispatcher.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/CommandDispatcher.java +++ b/net/minecraft/server/CommandDispatcher.java -@@ -22,12 +22,21 @@ +@@ -17,12 +17,21 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -23,7 +23,7 @@ CommandAdvancement.a(this.b); CommandExecute.a(this.b); CommandBossBar.a(this.b); -@@ -95,8 +104,13 @@ +@@ -93,14 +102,59 @@ } this.b.findAmbiguities((commandnode, commandnode1, commandnode2, collection) -> { @@ -38,8 +38,6 @@ this.b.setConsumer((commandcontext, flag1, i) -> { ((CommandListenerWrapper) commandcontext.getSource()).a(commandcontext, flag1, i); }); -@@ -111,7 +125,47 @@ - } + // CraftBukkit start @@ -86,7 +84,7 @@ StringReader stringreader = new StringReader(s); if (stringreader.canRead() && stringreader.peek() == '/') { -@@ -123,7 +177,6 @@ +@@ -112,7 +166,6 @@ byte b0; try { @@ -94,7 +92,7 @@ ChatComponentText chatcomponenttext; try { -@@ -132,52 +185,56 @@ +@@ -121,52 +174,56 @@ return i; } catch (CommandException commandexception) { commandlistenerwrapper.sendFailureMessage(commandexception.a()); @@ -176,9 +174,9 @@ + return b1; + } } finally { - commandlistenerwrapper.getServer().methodProfiler.exit(); + commandlistenerwrapper.getServer().getMethodProfiler().exit(); } -@@ -186,11 +243,36 @@ +@@ -175,11 +232,36 @@ } public void a(EntityPlayer entityplayer) { @@ -216,7 +214,7 @@ entityplayer.playerConnection.sendPacket(new PacketPlayOutCommands(rootcommandnode)); } -@@ -201,7 +283,7 @@ +@@ -190,7 +272,7 @@ CommandNode commandnode2 = (CommandNode) iterator.next(); if (commandnode2.canUse(commandlistenerwrapper)) { @@ -225,7 +223,7 @@ argumentbuilder.requires((icompletionprovider) -> { return true; -@@ -224,7 +306,7 @@ +@@ -213,7 +295,7 @@ argumentbuilder.redirect((CommandNode) map.get(argumentbuilder.getRedirect())); } diff --git a/nms-patches/CommandForceload.patch b/nms-patches/CommandForceload.patch index 1d03a10a75..de27c6df86 100644 --- a/nms-patches/CommandForceload.patch +++ b/nms-patches/CommandForceload.patch @@ -1,42 +1,42 @@ --- a/net/minecraft/server/CommandForceload.java +++ b/net/minecraft/server/CommandForceload.java -@@ -43,7 +43,7 @@ +@@ -47,7 +47,7 @@ - private static int a(CommandListenerWrapper commandlistenerwrapper, ArgumentVec2I.a argumentvec2i_a) throws CommandSyntaxException { - ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(argumentvec2i_a.a >> 4, argumentvec2i_a.b >> 4); -- DimensionManager dimensionmanager = commandlistenerwrapper.getWorld().o().getDimensionManager(); + private static int a(CommandListenerWrapper commandlistenerwrapper, BlockPosition2D blockposition2d) throws CommandSyntaxException { + ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(blockposition2d.a >> 4, blockposition2d.b >> 4); +- DimensionManager dimensionmanager = commandlistenerwrapper.getWorld().getWorldProvider().getDimensionManager(); + DimensionManager dimensionmanager = commandlistenerwrapper.getWorld().dimension; // CraftBukkit - boolean flag = commandlistenerwrapper.getServer().getWorldServer(dimensionmanager).isForceLoaded(chunkcoordintpair.x, chunkcoordintpair.z); + boolean flag = commandlistenerwrapper.getServer().getWorldServer(dimensionmanager).getForceLoadedChunks().contains(chunkcoordintpair.pair()); if (flag) { -@@ -55,7 +55,7 @@ +@@ -59,7 +59,7 @@ } private static int a(CommandListenerWrapper commandlistenerwrapper) { -- DimensionManager dimensionmanager = commandlistenerwrapper.getWorld().o().getDimensionManager(); +- DimensionManager dimensionmanager = commandlistenerwrapper.getWorld().getWorldProvider().getDimensionManager(); + DimensionManager dimensionmanager = commandlistenerwrapper.getWorld().dimension; // CraftBukkit - LongSet longset = commandlistenerwrapper.getServer().getWorldServer(dimensionmanager).ag(); + LongSet longset = commandlistenerwrapper.getServer().getWorldServer(dimensionmanager).getForceLoadedChunks(); int i = longset.size(); -@@ -75,11 +75,11 @@ +@@ -79,11 +79,11 @@ } private static int b(CommandListenerWrapper commandlistenerwrapper) { -- DimensionManager dimensionmanager = commandlistenerwrapper.getWorld().o().getDimensionManager(); +- DimensionManager dimensionmanager = commandlistenerwrapper.getWorld().getWorldProvider().getDimensionManager(); + DimensionManager dimensionmanager = commandlistenerwrapper.getWorld().dimension; // CraftBukkit WorldServer worldserver = commandlistenerwrapper.getServer().getWorldServer(dimensionmanager); - LongSet longset = worldserver.ag(); + LongSet longset = worldserver.getForceLoadedChunks(); - longset.forEach((i) -> { + longset.forEach((java.util.function.LongConsumer) (i) -> { // CraftBukkit - decompile error - worldserver.setForceLoaded(ChunkCoordIntPair.a(i), ChunkCoordIntPair.b(i), false); + worldserver.setForceLoaded(ChunkCoordIntPair.getX(i), ChunkCoordIntPair.getZ(i), false); }); commandlistenerwrapper.sendMessage(new ChatMessage("commands.forceload.removed.all", new Object[] { dimensionmanager}), true); -@@ -102,7 +102,7 @@ +@@ -106,7 +106,7 @@ if (i2 > 256L) { throw CommandForceload.a.create(256, i2); } else { -- DimensionManager dimensionmanager = commandlistenerwrapper.getWorld().o().getDimensionManager(); +- DimensionManager dimensionmanager = commandlistenerwrapper.getWorld().getWorldProvider().getDimensionManager(); + DimensionManager dimensionmanager = commandlistenerwrapper.getWorld().dimension; // CraftBukkit WorldServer worldserver = commandlistenerwrapper.getServer().getWorldServer(dimensionmanager); ChunkCoordIntPair chunkcoordintpair = null; diff --git a/nms-patches/CommandGamerule.patch b/nms-patches/CommandGamerule.patch index 614b56a6ed..19639cb53f 100644 --- a/nms-patches/CommandGamerule.patch +++ b/nms-patches/CommandGamerule.patch @@ -8,7 +8,7 @@ + GameRules.GameRuleValue gamerules_gamerulevalue = commandlistenerwrapper.getWorld().getGameRules().get(s); // CraftBukkit gamerules_gamerulevalue.getType().a(commandcontext, "value", gamerules_gamerulevalue); - commandlistenerwrapper.sendMessage(new ChatMessage("commands.gamerule.set", new Object[] { s, gamerules_gamerulevalue.a()}), true); + commandlistenerwrapper.sendMessage(new ChatMessage("commands.gamerule.set", new Object[] { s, gamerules_gamerulevalue.getValue()}), true); @@ -35,7 +35,7 @@ } @@ -16,5 +16,5 @@ - GameRules.GameRuleValue gamerules_gamerulevalue = commandlistenerwrapper.getServer().getGameRules().get(s); + GameRules.GameRuleValue gamerules_gamerulevalue = commandlistenerwrapper.getWorld().getGameRules().get(s); // CraftBukkit - commandlistenerwrapper.sendMessage(new ChatMessage("commands.gamerule.query", new Object[] { s, gamerules_gamerulevalue.a()}), false); - return gamerules_gamerulevalue.c(); + commandlistenerwrapper.sendMessage(new ChatMessage("commands.gamerule.query", new Object[] { s, gamerules_gamerulevalue.getValue()}), false); + return gamerules_gamerulevalue.getIntValue(); diff --git a/nms-patches/CommandListenerWrapper.patch b/nms-patches/CommandListenerWrapper.patch index 5f069a42cb..0a344c8502 100644 --- a/nms-patches/CommandListenerWrapper.patch +++ b/nms-patches/CommandListenerWrapper.patch @@ -6,8 +6,8 @@ import com.mojang.brigadier.suggestion.SuggestionsBuilder; +import com.mojang.brigadier.tree.CommandNode; import java.util.Collection; - import java.util.Collections; import java.util.Iterator; + import java.util.concurrent.CompletableFuture; @@ -31,6 +32,7 @@ private final ResultConsumer l; private final ArgumentAnchor.Anchor m; @@ -16,9 +16,9 @@ public CommandListenerWrapper(ICommandListener icommandlistener, Vec3D vec3d, Vec2F vec2f, WorldServer worldserver, int i, String s, IChatBaseComponent ichatbasecomponent, MinecraftServer minecraftserver, @Nullable Entity entity) { this(icommandlistener, vec3d, vec2f, worldserver, i, s, ichatbasecomponent, minecraftserver, entity, false, (commandcontext, flag, j) -> { -@@ -119,9 +121,22 @@ - } +@@ -120,9 +122,22 @@ + @Override public boolean hasPermission(int i) { + // CraftBukkit start + if (currentCommand != null) { @@ -39,7 +39,7 @@ public Vec3D getPosition() { return this.d; } -@@ -183,7 +198,7 @@ +@@ -184,7 +199,7 @@ while (iterator.hasNext()) { EntityPlayer entityplayer = (EntityPlayer) iterator.next(); @@ -48,9 +48,9 @@ entityplayer.sendMessage(ichatbasecomponent1); } } -@@ -232,4 +247,10 @@ - public Collection a(boolean flag) { - return Collections.singleton(ICompletionProvider.a.b); +@@ -234,4 +249,10 @@ + public CompletableFuture a(CommandContext commandcontext, SuggestionsBuilder suggestionsbuilder) { + return null; } + + // CraftBukkit start diff --git a/nms-patches/CommandSpreadPlayers.patch b/nms-patches/CommandSpreadPlayers.patch index c3042535dc..1a75511121 100644 --- a/nms-patches/CommandSpreadPlayers.patch +++ b/nms-patches/CommandSpreadPlayers.patch @@ -34,7 +34,7 @@ + + // CraftBukkit start - add a version of getType which force loads chunks + private static IBlockData getType(IBlockAccess iblockaccess, BlockPosition position) { -+ ((ChunkProviderServer) ((World) iblockaccess).chunkProvider).getChunkAt(position.getX() >> 4, position.getZ() >> 4, true, true); ++ ((ChunkProviderServer) ((World) iblockaccess).chunkProvider).getChunkAt(position.getX() >> 4, position.getZ() >> 4, true); + return iblockaccess.getType(position); + } + // CraftBukkit end diff --git a/nms-patches/Container.patch b/nms-patches/Container.patch index 71abe39460..44939b13d0 100644 --- a/nms-patches/Container.patch +++ b/nms-patches/Container.patch @@ -1,10 +1,11 @@ --- a/net/minecraft/server/Container.java +++ b/net/minecraft/server/Container.java -@@ -7,6 +7,17 @@ +@@ -7,6 +7,18 @@ import java.util.Set; import javax.annotation.Nullable; +// CraftBukkit start ++import com.google.common.base.Preconditions; +import java.util.HashMap; +import java.util.Map; +import org.bukkit.craftbukkit.inventory.CraftInventory; @@ -18,9 +19,9 @@ public abstract class Container { public NonNullList items = NonNullList.a(); -@@ -18,6 +29,18 @@ - protected List listeners = Lists.newArrayList(); - private final Set i = Sets.newHashSet(); +@@ -21,6 +33,27 @@ + private final List listeners = Lists.newArrayList(); + private final Set k = Sets.newHashSet(); + // CraftBukkit start + public boolean checkReachable = true; @@ -32,20 +33,29 @@ + ((CraftInventory) destination.getTopInventory()).getInventory().onOpen(player); + ((CraftInventory) destination.getBottomInventory()).getInventory().onOpen(player); + } ++ private IChatBaseComponent title; ++ public IChatBaseComponent getTitle() { ++ Preconditions.checkState(this.title != null, "Title not set"); ++ return this.title; ++ } ++ public void setTitle(IChatBaseComponent title) { ++ Preconditions.checkState(this.title == null, "Title already set"); ++ this.title = title; ++ } + // CraftBukkit end + - public Container() {} - - protected Slot a(Slot slot) { -@@ -128,6 +151,7 @@ + protected Container(@Nullable Containers containers, int i) { + this.e = containers; + this.windowId = i; +@@ -180,6 +213,7 @@ k = playerinventory.getCarried().getCount(); - Iterator iterator = this.h.iterator(); + Iterator iterator = this.i.iterator(); + Map draggedSlots = new HashMap(); // CraftBukkit - Store slots from drag in map (raw slot id -> new stack) while (iterator.hasNext()) { Slot slot1 = (Slot) iterator.next(); ItemStack itemstack3 = playerinventory.getCarried(); -@@ -143,12 +167,48 @@ +@@ -195,12 +229,48 @@ } k -= itemstack4.getCount() - j1; @@ -96,8 +106,8 @@ + // CraftBukkit end } - this.c(); -@@ -165,8 +225,11 @@ + this.d(); +@@ -217,8 +287,11 @@ if (i == -999) { if (!playerinventory.getCarried().isEmpty()) { if (j == 0) { @@ -110,10 +120,10 @@ } if (j == 1) { -@@ -254,6 +317,15 @@ +@@ -306,6 +379,15 @@ } - slot2.f(); + slot2.d(); + // CraftBukkit start - Make sure the client has the right slot contents + if (entityhuman instanceof EntityPlayer && slot2.getMaxStackSize() != 64) { + ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutSetSlot(this.windowId, slot2.rawSlotIndex, slot2.getItem())); @@ -126,7 +136,7 @@ } } } else if (inventoryclicktype == InventoryClickType.SWAP && j >= 0 && j < 9) { -@@ -356,8 +428,11 @@ +@@ -408,8 +490,11 @@ PlayerInventory playerinventory = entityhuman.inventory; if (!playerinventory.getCarried().isEmpty()) { @@ -139,11 +149,3 @@ } } -@@ -565,6 +640,7 @@ - if (inventorycraftresult.a(world, entityplayer, irecipe) && irecipe != null) { - itemstack = irecipe.craftItem(iinventory); - } -+ itemstack = org.bukkit.craftbukkit.event.CraftEventFactory.callPreCraftEvent(iinventory, inventorycraftresult, itemstack, getBukkitView(), false); // CraftBukkit - - inventorycraftresult.setItem(0, itemstack); - entityplayer.playerConnection.sendPacket(new PacketPlayOutSetSlot(this.windowId, 0, itemstack)); diff --git a/nms-patches/ContainerAccess.patch b/nms-patches/ContainerAccess.patch new file mode 100644 index 0000000000..a07ee31326 --- /dev/null +++ b/nms-patches/ContainerAccess.patch @@ -0,0 +1,42 @@ +--- a/net/minecraft/server/ContainerAccess.java ++++ b/net/minecraft/server/ContainerAccess.java +@@ -6,6 +6,20 @@ + + public interface ContainerAccess { + ++ // CraftBukkit start ++ default World getWorld() { ++ throw new UnsupportedOperationException("Not supported yet."); ++ } ++ ++ default BlockPosition getPosition() { ++ throw new UnsupportedOperationException("Not supported yet."); ++ } ++ ++ default org.bukkit.Location getLocation() { ++ return new org.bukkit.Location(getWorld().getWorld(), getPosition().getX(), getPosition().getY(), getPosition().getZ()); ++ } ++ // CraftBukkit end ++ + ContainerAccess a = new ContainerAccess() { + @Override + public Optional a(BiFunction bifunction) { +@@ -15,6 +29,18 @@ + + static ContainerAccess at(final World world, final BlockPosition blockposition) { + return new ContainerAccess() { ++ // CraftBukkit start ++ @Override ++ public World getWorld() { ++ return world; ++ } ++ ++ @Override ++ public BlockPosition getPosition() { ++ return blockposition; ++ } ++ // CraftBukkit end ++ + @Override + public Optional a(BiFunction bifunction) { + return Optional.of(bifunction.apply(world, blockposition)); diff --git a/nms-patches/ContainerAnvil.patch b/nms-patches/ContainerAnvil.patch index 54caf0ad2a..e5cfa8f4fa 100644 --- a/nms-patches/ContainerAnvil.patch +++ b/nms-patches/ContainerAnvil.patch @@ -10,9 +10,9 @@ + public class ContainerAnvil extends Container { - private static final Logger f = LogManager.getLogger(); -@@ -22,8 +26,15 @@ - private int k; + private static final Logger c = LogManager.getLogger(); +@@ -16,6 +20,12 @@ + private int h; public String renameText; private final EntityHuman player; + // CraftBukkit start @@ -22,108 +22,98 @@ + private PlayerInventory playerInventory; + // CraftBukkit end - public ContainerAnvil(PlayerInventory playerinventory, final World world, final BlockPosition blockposition, EntityHuman entityhuman) { + public ContainerAnvil(int i, PlayerInventory playerinventory) { + this(i, playerinventory, ContainerAccess.a); +@@ -23,6 +33,7 @@ + + public ContainerAnvil(int i, PlayerInventory playerinventory, final ContainerAccess containeraccess) { + super(Containers.ANVIL, i); + this.playerInventory = playerinventory; // CraftBukkit - this.position = blockposition; - this.world = world; - this.player = entityhuman; -@@ -111,7 +122,7 @@ + this.resultInventory = new InventoryCraftResult(); + this.repairInventory = new InventorySubcontainer(2) { + @Override +@@ -123,7 +134,7 @@ byte b1 = 0; if (itemstack.isEmpty()) { - this.resultInventory.setItem(0, ItemStack.a); + org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.a); // CraftBukkit - this.levelCost = 0; + this.levelCost.a(0); } else { ItemStack itemstack1 = itemstack.cloneItemStack(); -@@ -129,7 +140,7 @@ +@@ -141,7 +152,7 @@ if (itemstack1.e() && itemstack1.getItem().a(itemstack, itemstack2)) { k = Math.min(itemstack1.getDamage(), itemstack1.h() / 4); if (k <= 0) { - this.resultInventory.setItem(0, ItemStack.a); + org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.a); // CraftBukkit - this.levelCost = 0; + this.levelCost.a(0); return; } -@@ -144,7 +155,7 @@ - this.k = i1; +@@ -156,7 +167,7 @@ + this.h = i1; } else { if (!flag && (itemstack1.getItem() != itemstack2.getItem() || !itemstack1.e())) { - this.resultInventory.setItem(0, ItemStack.a); + org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.a); // CraftBukkit - this.levelCost = 0; + this.levelCost.a(0); return; } -@@ -234,7 +245,7 @@ +@@ -246,7 +257,7 @@ } if (flag2 && !flag1) { - this.resultInventory.setItem(0, ItemStack.a); + org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.a); // CraftBukkit - this.levelCost = 0; + this.levelCost.a(0); return; } -@@ -258,11 +269,11 @@ +@@ -270,11 +281,11 @@ itemstack1 = ItemStack.a; } -- if (b1 == i && b1 > 0 && this.levelCost >= 40) { -- this.levelCost = 39; -+ if (b1 == i && b1 > 0 && this.levelCost >= maximumRepairCost) { // CraftBukkit -+ this.levelCost = maximumRepairCost - 1; // CraftBukkit +- if (b1 == i && b1 > 0 && this.levelCost.b() >= 40) { +- this.levelCost.a(39); ++ if (b1 == i && b1 > 0 && this.levelCost.b() >= maximumRepairCost) { // CraftBukkit ++ this.levelCost.a(maximumRepairCost - 1); // CraftBukkit } -- if (this.levelCost >= 40 && !this.player.abilities.canInstantlyBuild) { -+ if (this.levelCost >= maximumRepairCost && !this.player.abilities.canInstantlyBuild) { // CraftBukkit +- if (this.levelCost.b() >= 40 && !this.player.abilities.canInstantlyBuild) { ++ if (this.levelCost.b() >= maximumRepairCost && !this.player.abilities.canInstantlyBuild) { // CraftBukkit itemstack1 = ItemStack.a; } -@@ -281,7 +292,7 @@ +@@ -293,7 +304,7 @@ EnchantmentManager.a(map, itemstack1); } - this.resultInventory.setItem(0, itemstack1); + org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), itemstack1); // CraftBukkit - this.b(); + this.c(); } } -@@ -299,6 +310,7 @@ - } +@@ -312,6 +323,7 @@ + @Override public boolean canUse(EntityHuman entityhuman) { + if (!this.checkReachable) return true; // CraftBukkit - return !this.world.getType(this.position).a(TagsBlock.ANVIL) ? false : entityhuman.d((double) this.position.getX() + 0.5D, (double) this.position.getY() + 0.5D, (double) this.position.getZ() + 0.5D) <= 64.0D; - } + return (Boolean) this.containerAccess.a((world, blockposition) -> { + return !world.getType(blockposition).a(TagsBlock.ANVIL) ? false : entityhuman.e((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) <= 64.0D; + }, true); +@@ -370,4 +382,18 @@ -@@ -354,4 +366,33 @@ - - this.d(); + this.e(); } + + // CraftBukkit start + @Override -+ public void b() { -+ super.b(); -+ -+ for (int i = 0; i < this.listeners.size(); ++i) { -+ ICrafting icrafting = (ICrafting) this.listeners.get(i); -+ -+ if (this.lastLevelCost != this.levelCost) { -+ icrafting.setContainerData(this, 0, this.levelCost); -+ } -+ } -+ -+ this.lastLevelCost = this.levelCost; -+ } -+ -+ @Override + public CraftInventoryView getBukkitView() { + if (bukkitEntity != null) { + return bukkitEntity; + } + + org.bukkit.craftbukkit.inventory.CraftInventory inventory = new org.bukkit.craftbukkit.inventory.CraftInventoryAnvil( -+ new org.bukkit.Location(world.getWorld(), position.getX(), position.getY(), position.getZ()), this.repairInventory, this.resultInventory, this); ++ containerAccess.getLocation(), this.repairInventory, this.resultInventory, this); + bukkitEntity = new CraftInventoryView(this.player.getBukkitEntity(), inventory, this); + return bukkitEntity; + } diff --git a/nms-patches/ContainerBeacon.patch b/nms-patches/ContainerBeacon.patch index bd8adc0223..fe376ff026 100644 --- a/nms-patches/ContainerBeacon.patch +++ b/nms-patches/ContainerBeacon.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/ContainerBeacon.java +++ b/net/minecraft/server/ContainerBeacon.java -@@ -1,11 +1,18 @@ +@@ -1,11 +1,17 @@ package net.minecraft.server; +import org.bukkit.craftbukkit.inventory.CraftInventoryView; // CraftBukkit @@ -8,26 +8,33 @@ public class ContainerBeacon extends Container { private final IInventory beacon; - private final ContainerBeacon.SlotBeacon f; + private final ContainerBeacon.SlotBeacon d; + private final ContainerAccess containerAccess; + private final IContainerProperties containerProperties; + // CraftBukkit start + private CraftInventoryView bukkitEntity = null; + private PlayerInventory player; + // CraftBukkit end - public ContainerBeacon(IInventory iinventory, IInventory iinventory1) { -+ player = (PlayerInventory) iinventory; // CraftBukkit - TODO: check this - this.beacon = iinventory1; - this.f = new ContainerBeacon.SlotBeacon(iinventory1, 0, 136, 110); - this.a((Slot) this.f); -@@ -48,6 +55,7 @@ - } + public ContainerBeacon(int i, IInventory iinventory) { + this(i, iinventory, new ContainerProperties(3), ContainerAccess.a); +@@ -13,6 +19,7 @@ + public ContainerBeacon(int i, IInventory iinventory, IContainerProperties icontainerproperties, ContainerAccess containeraccess) { + super(Containers.BEACON, i); ++ player = (PlayerInventory) iinventory; // CraftBukkit - TODO: check this + this.beacon = new InventorySubcontainer(1) { + @Override + public boolean b(int j, ItemStack itemstack) { +@@ -62,6 +69,7 @@ + + @Override public boolean canUse(EntityHuman entityhuman) { + if (!this.checkReachable) return true; // CraftBukkit - return this.beacon.a(entityhuman); + return a(this.containerAccess, entityhuman, Blocks.BEACON); } -@@ -113,4 +121,17 @@ +@@ -145,4 +153,17 @@ return 1; } } @@ -39,7 +46,7 @@ + return bukkitEntity; + } + -+ org.bukkit.craftbukkit.inventory.CraftInventory inventory = new org.bukkit.craftbukkit.inventory.CraftInventoryBeacon((TileEntityBeacon) this.beacon); // TODO - check this ++ org.bukkit.craftbukkit.inventory.CraftInventory inventory = new org.bukkit.craftbukkit.inventory.CraftInventoryBeacon(this.beacon); + bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), inventory, this); + return bukkitEntity; + } diff --git a/nms-patches/ContainerBrewingStand.patch b/nms-patches/ContainerBrewingStand.patch index aa2b973733..a10f4faa25 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,5 +1,10 @@ +@@ -1,17 +1,28 @@ package net.minecraft.server; +// CraftBukkit start @@ -11,29 +11,33 @@ public class ContainerBrewingStand extends Container { private final IInventory brewingStand; -@@ -7,7 +12,13 @@ - private int g; - private int h; + private final IContainerProperties d; + private final Slot e; + // CraftBukkit start + private CraftInventoryView bukkitEntity = null; + private PlayerInventory player; + // CraftBukkit end + - public ContainerBrewingStand(PlayerInventory playerinventory, IInventory iinventory) { -+ player = playerinventory; // CraftBukkit - this.brewingStand = iinventory; - this.a((Slot) (new ContainerBrewingStand.SlotPotionBottle(iinventory, 0, 56, 51))); - this.a((Slot) (new ContainerBrewingStand.SlotPotionBottle(iinventory, 1, 79, 58))); -@@ -54,6 +65,7 @@ + public ContainerBrewingStand(int i, PlayerInventory playerinventory) { + this(i, playerinventory, new InventorySubcontainer(5), new ContainerProperties(2)); } + public ContainerBrewingStand(int i, PlayerInventory playerinventory, IInventory iinventory, IContainerProperties icontainerproperties) { + super(Containers.BREWING_STAND, i); ++ player = playerinventory; // CraftBukkit + a(iinventory, 5); + a(icontainerproperties, 2); + this.brewingStand = iinventory; +@@ -39,6 +50,7 @@ + + @Override public boolean canUse(EntityHuman entityhuman) { + if (!this.checkReachable) return true; // CraftBukkit return this.brewingStand.a(entityhuman); } -@@ -178,4 +190,17 @@ +@@ -171,4 +183,17 @@ return item == Items.POTION || item == Items.SPLASH_POTION || item == Items.LINGERING_POTION || item == Items.GLASS_BOTTLE; } } diff --git a/nms-patches/ContainerCartography.patch b/nms-patches/ContainerCartography.patch new file mode 100644 index 0000000000..9fa8dd76ca --- /dev/null +++ b/nms-patches/ContainerCartography.patch @@ -0,0 +1,59 @@ +--- a/net/minecraft/server/ContainerCartography.java ++++ b/net/minecraft/server/ContainerCartography.java +@@ -1,7 +1,29 @@ + package net.minecraft.server; + ++// CraftBukkit start ++import org.bukkit.Location; ++import org.bukkit.craftbukkit.inventory.CraftInventoryCartography; ++import org.bukkit.craftbukkit.inventory.CraftInventoryView; ++import org.bukkit.entity.Player; ++// CraftBukkit end ++ + public class ContainerCartography extends Container { + ++ // CraftBukkit start ++ private CraftInventoryView bukkitEntity = null; ++ private Player player; ++ ++ @Override ++ public CraftInventoryView getBukkitView() { ++ if (bukkitEntity != null) { ++ return bukkitEntity; ++ } ++ ++ CraftInventoryCartography inventory = new CraftInventoryCartography(this.inventory); ++ bukkitEntity = new CraftInventoryView(this.player, inventory, this); ++ return bukkitEntity; ++ } ++ // CraftBukkit end + private final ContainerAccess containerAccess; + private boolean e; + public final IInventory inventory; +@@ -26,6 +48,13 @@ + ContainerCartography.this.a((IInventory) this); + super.update(); + } ++ ++ // CraftBukkit start ++ @Override ++ public Location getLocation() { ++ return containeraccess.getLocation(); ++ } ++ // CraftBukkit end + }; + this.containerAccess = containeraccess; + this.a(new Slot(this.inventory, 0, 15, 15) { +@@ -97,10 +126,12 @@ + this.a(new Slot(playerinventory, j, 8 + j * 18, 142)); + } + ++ player = (Player) playerinventory.player.getBukkitEntity(); // CraftBukkit + } + + @Override + public boolean canUse(EntityHuman entityhuman) { ++ if (!this.checkReachable) return true; // CraftBukkit + return a(this.containerAccess, entityhuman, Blocks.CARTOGRAPHY_TABLE); + } + diff --git a/nms-patches/ContainerChest.patch b/nms-patches/ContainerChest.patch index 43f85e757b..0387d3c5f1 100644 --- a/nms-patches/ContainerChest.patch +++ b/nms-patches/ContainerChest.patch @@ -11,7 +11,7 @@ public class ContainerChest extends Container { private final IInventory container; - private final int f; + private final int d; + // CraftBukkit start + private CraftInventoryView bukkitEntity = null; + private PlayerInventory player; @@ -36,23 +36,22 @@ + } + // CraftBukkit end - public ContainerChest(IInventory iinventory, IInventory iinventory1, EntityHuman entityhuman) { - this.container = iinventory1; -@@ -11,6 +39,11 @@ - iinventory1.startOpen(entityhuman); - int i = (this.f - 4) * 18; + private ContainerChest(Containers containers, int i, PlayerInventory playerinventory, int j) { + this(containers, i, playerinventory, new InventorySubcontainer(9 * j), j); +@@ -49,6 +77,10 @@ + iinventory.startOpen(playerinventory.player); + int k = (this.d - 4) * 18; + // CraftBukkit start - Save player -+ // TODO: Should we check to make sure it really is an InventoryPlayer? -+ this.player = (PlayerInventory) iinventory; ++ this.player = playerinventory; + // CraftBukkit end + - int j; - int k; + int l; + int i1; -@@ -33,6 +66,7 @@ - } +@@ -72,6 +104,7 @@ + @Override public boolean canUse(EntityHuman entityhuman) { + if (!this.checkReachable) return true; // CraftBukkit return this.container.a(entityhuman); diff --git a/nms-patches/ContainerDispenser.patch b/nms-patches/ContainerDispenser.patch index fb1f4f1a81..5c5283c831 100644 --- a/nms-patches/ContainerDispenser.patch +++ b/nms-patches/ContainerDispenser.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/ContainerDispenser.java +++ b/net/minecraft/server/ContainerDispenser.java -@@ -1,11 +1,24 @@ +@@ -1,8 +1,17 @@ package net.minecraft.server; +// CraftBukkit start @@ -16,26 +16,30 @@ + private PlayerInventory player; + // CraftBukkit end - public ContainerDispenser(IInventory iinventory, IInventory iinventory1) { - this.items = iinventory1; + public ContainerDispenser(int i, PlayerInventory playerinventory) { + this(i, playerinventory, new InventorySubcontainer(9)); +@@ -10,6 +19,10 @@ + + public ContainerDispenser(int i, PlayerInventory playerinventory, IInventory iinventory) { + super(Containers.GENERIC_3X3, i); + // CraftBukkit start - Save player -+ // TODO: Should we check to make sure it really is an InventoryPlayer? -+ this.player = (PlayerInventory)iinventory; ++ this.player = playerinventory; + // CraftBukkit end ++ + a(iinventory, 9); + this.items = iinventory; + iinventory.startOpen(playerinventory.player); +@@ -37,6 +50,7 @@ - int i; - int j; -@@ -29,6 +42,7 @@ - } - + @Override public boolean canUse(EntityHuman entityhuman) { + if (!this.checkReachable) return true; // CraftBukkit return this.items.a(entityhuman); } -@@ -63,4 +77,17 @@ - - return itemstack; +@@ -78,4 +92,17 @@ + super.b(entityhuman); + this.items.closeContainer(entityhuman); } + + // CraftBukkit start diff --git a/nms-patches/ContainerEnchantTable.patch b/nms-patches/ContainerEnchantTable.patch index 93d4b63c57..619e6638de 100644 --- a/nms-patches/ContainerEnchantTable.patch +++ b/nms-patches/ContainerEnchantTable.patch @@ -21,58 +21,58 @@ + public class ContainerEnchantTable extends Container { - public IInventory enchantSlots = new InventorySubcontainer(new ChatComponentText("Enchant"), 2) { -@@ -14,6 +29,13 @@ - super.update(); - ContainerEnchantTable.this.a((IInventory) this); - } -+ -+ // CraftBukkit start -+ @Override -+ public Location getLocation() { -+ return new org.bukkit.Location(world.getWorld(), position.getX(), position.getY(), position.getZ()); -+ } -+ // CraftBukkit end - }; - public World world; - private final BlockPosition position; -@@ -22,6 +44,10 @@ - public int[] costs = new int[3]; - public int[] h = new int[] { -1, -1, -1}; - public int[] i = new int[] { -1, -1, -1}; + private final IInventory enchantSlots; +@@ -12,6 +27,10 @@ + public final int[] costs; + public final int[] enchantments; + public final int[] levels; + // CraftBukkit start + private CraftInventoryView bukkitEntity = null; + private Player player; + // CraftBukkit end - public ContainerEnchantTable(PlayerInventory playerinventory, World world, BlockPosition blockposition) { - this.world = world; -@@ -54,6 +80,9 @@ - this.a(new Slot(playerinventory, i, 8 + i * 18, 142)); - } - + public ContainerEnchantTable(int i, PlayerInventory playerinventory) { + this(i, playerinventory, ContainerAccess.a); +@@ -25,6 +44,13 @@ + super.update(); + ContainerEnchantTable.this.a((IInventory) this); + } ++ ++ // CraftBukkit start ++ @Override ++ public Location getLocation() { ++ return containeraccess.getLocation(); ++ } ++ // CraftBukkit end + }; + this.h = new Random(); + this.i = ContainerProperty.a(); +@@ -72,6 +98,9 @@ + this.a(ContainerProperty.a(this.levels, 0)); + this.a(ContainerProperty.a(this.levels, 1)); + this.a(ContainerProperty.a(this.levels, 2)); + // CraftBukkit start + player = (Player) playerinventory.player.getBukkitEntity(); + // CraftBukkit end } - protected void c(ICrafting icrafting) { -@@ -90,7 +119,7 @@ + @Override +@@ -79,7 +108,7 @@ + if (iinventory == this.enchantSlots) { ItemStack itemstack = iinventory.getItem(0); - int i; - if (!itemstack.isEmpty() && itemstack.canEnchant()) { + if (!itemstack.isEmpty()) { // CraftBukkit - relax condition - if (!this.world.isClientSide) { - i = 0; + this.containerAccess.a((world, blockposition) -> { + int i = 0; -@@ -146,12 +175,47 @@ +@@ -135,12 +164,47 @@ if (list != null && !list.isEmpty()) { - WeightedRandomEnchant weightedrandomenchant = (WeightedRandomEnchant) list.get(this.l.nextInt(list.size())); + WeightedRandomEnchant weightedrandomenchant = (WeightedRandomEnchant) list.get(this.h.nextInt(list.size())); -- this.h[j] = IRegistry.ENCHANTMENT.a((Object) weightedrandomenchant.enchantment); -+ this.h[j] = IRegistry.ENCHANTMENT.a(weightedrandomenchant.enchantment); // CraftBukkit - decompile error - this.i[j] = weightedrandomenchant.level; +- this.enchantments[j] = IRegistry.ENCHANTMENT.a((Object) weightedrandomenchant.enchantment); ++ this.enchantments[j] = IRegistry.ENCHANTMENT.a(weightedrandomenchant.enchantment); // CraftBukkit - decompile error + this.levels[j] = weightedrandomenchant.level; } } } @@ -81,19 +81,19 @@ + CraftItemStack item = CraftItemStack.asCraftMirror(itemstack); + org.bukkit.enchantments.EnchantmentOffer[] offers = new EnchantmentOffer[3]; + for (j = 0; j < 3; ++j) { -+ org.bukkit.enchantments.Enchantment enchantment = (this.h[j] >= 0) ? org.bukkit.enchantments.Enchantment.getByKey(CraftNamespacedKey.fromMinecraft(IRegistry.ENCHANTMENT.getKey(IRegistry.ENCHANTMENT.fromId(this.h[j])))) : null; -+ offers[j] = (enchantment != null) ? new EnchantmentOffer(enchantment, this.i[j], this.costs[j]) : null; ++ org.bukkit.enchantments.Enchantment enchantment = (this.enchantments[j] >= 0) ? org.bukkit.enchantments.Enchantment.getByKey(CraftNamespacedKey.fromMinecraft(IRegistry.ENCHANTMENT.getKey(IRegistry.ENCHANTMENT.fromId(this.enchantments[j])))) : null; ++ offers[j] = (enchantment != null) ? new EnchantmentOffer(enchantment, this.levels[j], this.costs[j]) : null; + } + -+ PrepareItemEnchantEvent event = new PrepareItemEnchantEvent(player, this.getBukkitView(), this.world.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ()), item, offers, i); ++ PrepareItemEnchantEvent event = new PrepareItemEnchantEvent(player, this.getBukkitView(), containerAccess.getLocation().getBlock(), item, offers, i); + event.setCancelled(!itemstack.canEnchant()); -+ this.world.getServer().getPluginManager().callEvent(event); ++ world.getServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { + for (j = 0; j < 3; ++j) { + this.costs[j] = 0; -+ this.h[j] = -1; -+ this.i[j] = -1; ++ this.enchantments[j] = -1; ++ this.levels[j] = -1; + } + return; + } @@ -102,21 +102,21 @@ + EnchantmentOffer offer = event.getOffers()[j]; + if (offer != null) { + this.costs[j] = offer.getCost(); -+ this.h[j] = IRegistry.ENCHANTMENT.a(IRegistry.ENCHANTMENT.get(CraftNamespacedKey.toMinecraft(offer.getEnchantment().getKey()))); -+ this.i[j] = offer.getEnchantmentLevel(); ++ this.enchantments[j] = IRegistry.ENCHANTMENT.a(IRegistry.ENCHANTMENT.get(CraftNamespacedKey.toMinecraft(offer.getEnchantment().getKey()))); ++ this.levels[j] = offer.getEnchantmentLevel(); + } else { + this.costs[j] = 0; -+ this.h[j] = -1; -+ this.i[j] = -1; ++ this.enchantments[j] = -1; ++ this.levels[j] = -1; + } + } + // CraftBukkit end + - this.b(); - } + this.c(); + }); } else { -@@ -176,25 +240,53 @@ - if (!this.world.isClientSide) { +@@ -167,25 +231,53 @@ + ItemStack itemstack2 = itemstack; List list = this.a(itemstack, i, this.costs[i]); - if (!list.isEmpty()) { @@ -130,19 +130,19 @@ + WeightedRandomEnchant instance = (WeightedRandomEnchant) obj; + enchants.put(org.bukkit.enchantments.Enchantment.getByKey(CraftNamespacedKey.fromMinecraft(IRegistry.ENCHANTMENT.getKey(instance.enchantment))), instance.level); + } -+ CraftItemStack item = CraftItemStack.asCraftMirror(itemstack); ++ CraftItemStack item = CraftItemStack.asCraftMirror(itemstack2); + -+ EnchantItemEvent event = new EnchantItemEvent((Player) entityhuman.getBukkitEntity(), this.getBukkitView(), this.world.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ()), item, this.costs[i], enchants, i); -+ this.world.getServer().getPluginManager().callEvent(event); ++ EnchantItemEvent event = new EnchantItemEvent((Player) entityhuman.getBukkitEntity(), this.getBukkitView(), containerAccess.getLocation().getBlock(), item, this.costs[i], enchants, i); ++ world.getServer().getPluginManager().callEvent(event); + + int level = event.getExpLevelCost(); + if (event.isCancelled() || (level > entityhuman.expLevel && !entityhuman.abilities.canInstantlyBuild) || event.getEnchantsToAdd().isEmpty()) { -+ return false; ++ return; + } if (flag) { - itemstack = new ItemStack(Items.ENCHANTED_BOOK); - this.enchantSlots.setItem(0, itemstack); + itemstack2 = new ItemStack(Items.ENCHANTED_BOOK); + this.enchantSlots.setItem(0, itemstack2); } - for (int k = 0; k < list.size(); ++k) { @@ -157,11 +157,11 @@ + } - if (flag) { -- ItemEnchantedBook.a(itemstack, weightedrandomenchant); +- ItemEnchantedBook.a(itemstack2, weightedrandomenchant); - } else { -- itemstack.addEnchantment(weightedrandomenchant.enchantment, weightedrandomenchant.level); +- itemstack2.addEnchantment(weightedrandomenchant.enchantment, weightedrandomenchant.level); + WeightedRandomEnchant weightedrandomenchant = new WeightedRandomEnchant(nms, entry.getValue()); -+ ItemEnchantedBook.a(itemstack, weightedrandomenchant); ++ ItemEnchantedBook.a(itemstack2, weightedrandomenchant); + } else { + item.addUnsafeEnchantment(entry.getKey(), entry.getValue()); + } @@ -177,26 +177,15 @@ if (!entityhuman.abilities.canInstantlyBuild) { itemstack1.subtract(j); if (itemstack1.isEmpty()) { -@@ -233,12 +325,18 @@ - - public void b(EntityHuman entityhuman) { - super.b(entityhuman); -+ // CraftBukkit Start - If an enchantable was opened from a null location, set the world to the player's world, preventing a crash -+ if (this.world == null) { -+ this.world = entityhuman.getWorld(); -+ } -+ // CraftBukkit end - if (!this.world.isClientSide) { - this.a(entityhuman, entityhuman.world, this.enchantSlots); - } - } +@@ -232,6 +324,7 @@ + @Override public boolean canUse(EntityHuman entityhuman) { + if (!this.checkReachable) return true; // CraftBukkit - return this.world.getType(this.position).getBlock() != Blocks.ENCHANTING_TABLE ? false : entityhuman.d((double) this.position.getX() + 0.5D, (double) this.position.getY() + 0.5D, (double) this.position.getZ() + 0.5D) <= 64.0D; + return a(this.containerAccess, entityhuman, Blocks.ENCHANTING_TABLE); } -@@ -291,4 +389,17 @@ +@@ -285,4 +378,17 @@ return itemstack; } diff --git a/nms-patches/ContainerFurnace.patch b/nms-patches/ContainerFurnace.patch index 320e3f3da5..5df55973a6 100644 --- a/nms-patches/ContainerFurnace.patch +++ b/nms-patches/ContainerFurnace.patch @@ -1,19 +1,19 @@ --- a/net/minecraft/server/ContainerFurnace.java +++ b/net/minecraft/server/ContainerFurnace.java -@@ -1,6 +1,10 @@ +@@ -1,5 +1,10 @@ package net.minecraft.server; - import java.util.Iterator; +// CraftBukkit start +import org.bukkit.craftbukkit.inventory.CraftInventoryFurnace; +import org.bukkit.craftbukkit.inventory.CraftInventoryView; +// CraftBukkit end ++ + public abstract class ContainerFurnace extends ContainerRecipeBook { - public class ContainerFurnace extends ContainerRecipeBook { - -@@ -11,12 +15,29 @@ - private int i; - private int j; + private final IInventory furnace; +@@ -7,6 +12,22 @@ + protected final World c; + private final Recipes f; + // CraftBukkit start + private CraftInventoryView bukkitEntity = null; @@ -31,21 +31,40 @@ + } + // CraftBukkit end + - public ContainerFurnace(PlayerInventory playerinventory, IInventory iinventory) { - this.furnace = iinventory; - this.f = playerinventory.player.world; + protected ContainerFurnace(Containers containers, Recipes recipes, int i, PlayerInventory playerinventory) { + this(containers, recipes, i, playerinventory, new InventorySubcontainer(3), new ContainerProperties(4)); + } +@@ -22,6 +43,7 @@ this.a(new Slot(iinventory, 0, 56, 17)); - this.a((Slot) (new SlotFurnaceFuel(iinventory, 1, 56, 53))); + this.a((Slot) (new SlotFurnaceFuel(this, iinventory, 1, 56, 53))); this.a((Slot) (new SlotFurnaceResult(playerinventory.player, iinventory, 2, 116, 35))); + this.player = playerinventory; // CraftBukkit - save player - int i; + int j; -@@ -95,6 +116,7 @@ +@@ -53,7 +75,7 @@ + + @Override + public void a(boolean flag, IRecipe irecipe, EntityPlayer entityplayer) { +- (new AutoRecipeFurnace<>(this)).a(entityplayer, irecipe, flag); ++ (new AutoRecipeFurnace(this)).a(entityplayer, irecipe, flag); // CraftBukkit - decompile error } + @Override +@@ -78,6 +100,7 @@ + + @Override public boolean canUse(EntityHuman entityhuman) { + if (!this.checkReachable) return true; // CraftBukkit return this.furnace.a(entityhuman); } +@@ -133,7 +156,7 @@ + } + + protected boolean a(ItemStack itemstack) { +- return this.c.getCraftingManager().craft(this.f, new InventorySubcontainer(new ItemStack[] { itemstack}), this.c).isPresent(); ++ return this.c.getCraftingManager().craft((Recipes) this.f, new InventorySubcontainer(new ItemStack[] { itemstack}), this.c).isPresent(); // Eclipse fail + } + + protected boolean b(ItemStack itemstack) { diff --git a/nms-patches/ContainerGrindstone.patch b/nms-patches/ContainerGrindstone.patch new file mode 100644 index 0000000000..92e8b7e32f --- /dev/null +++ b/nms-patches/ContainerGrindstone.patch @@ -0,0 +1,63 @@ +--- a/net/minecraft/server/ContainerGrindstone.java ++++ b/net/minecraft/server/ContainerGrindstone.java +@@ -4,9 +4,30 @@ + import java.util.Map; + import java.util.Map.Entry; + import java.util.stream.Collectors; ++// CraftBukkit start ++import org.bukkit.Location; ++import org.bukkit.craftbukkit.inventory.CraftInventoryGrindstone; ++import org.bukkit.craftbukkit.inventory.CraftInventoryView; ++import org.bukkit.entity.Player; ++// CraftBukkit end + + public class ContainerGrindstone extends Container { + ++ // CraftBukkit start ++ private CraftInventoryView bukkitEntity = null; ++ private Player player; ++ ++ @Override ++ public CraftInventoryView getBukkitView() { ++ if (bukkitEntity != null) { ++ return bukkitEntity; ++ } ++ ++ CraftInventoryGrindstone inventory = new CraftInventoryGrindstone(this.craftInventory, this.resultInventory); ++ bukkitEntity = new CraftInventoryView(this.player, inventory, this); ++ return bukkitEntity; ++ } ++ // CraftBukkit end + private final IInventory resultInventory; + private final IInventory craftInventory; + private final ContainerAccess containerAccess; +@@ -24,6 +45,13 @@ + super.update(); + ContainerGrindstone.this.a((IInventory) this); + } ++ ++ // CraftBukkit start ++ @Override ++ public Location getLocation() { ++ return containeraccess.getLocation(); ++ } ++ // CraftBukkit end + }; + this.containerAccess = containeraccess; + this.a(new Slot(this.craftInventory, 0, 49, 19) { +@@ -108,6 +136,7 @@ + this.a(new Slot(playerinventory, j, 8 + j * 18, 142)); + } + ++ player = (Player) playerinventory.player.getBukkitEntity(); // CraftBukkit + } + + @Override +@@ -233,6 +262,7 @@ + + @Override + public boolean canUse(EntityHuman entityhuman) { ++ if (!this.checkReachable) return true; // CraftBukkit + return a(this.containerAccess, entityhuman, Blocks.GRINDSTONE); + } + diff --git a/nms-patches/ContainerHopper.patch b/nms-patches/ContainerHopper.patch index 3475a2c6d4..f125e0ec56 100644 --- a/nms-patches/ContainerHopper.patch +++ b/nms-patches/ContainerHopper.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/ContainerHopper.java +++ b/net/minecraft/server/ContainerHopper.java -@@ -1,11 +1,33 @@ +@@ -1,9 +1,30 @@ package net.minecraft.server; +// CraftBukkit start @@ -28,15 +28,20 @@ + } + // CraftBukkit end + - public ContainerHopper(PlayerInventory playerinventory, IInventory iinventory, EntityHuman entityhuman) { + public ContainerHopper(int i, PlayerInventory playerinventory) { + this(i, playerinventory, new InventorySubcontainer(5)); + } +@@ -11,6 +32,7 @@ + public ContainerHopper(int i, PlayerInventory playerinventory, IInventory iinventory) { + super(Containers.HOPPER, i); this.hopper = iinventory; + this.player = playerinventory; // CraftBukkit - save player - iinventory.startOpen(entityhuman); + a(iinventory, 5); + iinventory.startOpen(playerinventory.player); boolean flag = true; +@@ -35,6 +57,7 @@ -@@ -28,6 +50,7 @@ - } - + @Override public boolean canUse(EntityHuman entityhuman) { + if (!this.checkReachable) return true; // CraftBukkit return this.hopper.a(entityhuman); diff --git a/nms-patches/ContainerHorse.patch b/nms-patches/ContainerHorse.patch index 9237f2bfb3..9294487a28 100644 --- a/nms-patches/ContainerHorse.patch +++ b/nms-patches/ContainerHorse.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/ContainerHorse.java +++ b/net/minecraft/server/ContainerHorse.java -@@ -1,11 +1,31 @@ +@@ -1,12 +1,32 @@ package net.minecraft.server; +// CraftBukkit start @@ -10,8 +10,8 @@ + public class ContainerHorse extends Container { - private final IInventory a; - private final EntityHorseAbstract f; + private final IInventory c; + private final EntityHorseAbstract d; + // CraftBukkit start + org.bukkit.craftbukkit.inventory.CraftInventoryView bukkitEntity; @@ -23,12 +23,13 @@ + return bukkitEntity; + } + -+ return bukkitEntity = new CraftInventoryView(player.player.getBukkitEntity(), a.getOwner().getInventory(), this); ++ return bukkitEntity = new CraftInventoryView(player.player.getBukkitEntity(), c.getOwner().getInventory(), this); + } + - public ContainerHorse(IInventory iinventory, IInventory iinventory1, final EntityHorseAbstract entityhorseabstract, EntityHuman entityhuman) { -+ player = (PlayerInventory) iinventory; + public ContainerHorse(int i, PlayerInventory playerinventory, IInventory iinventory, final EntityHorseAbstract entityhorseabstract) { + super((Containers) null, i); ++ player = playerinventory; + // CraftBukkit end - this.a = iinventory1; - this.f = entityhorseabstract; + this.c = iinventory; + this.d = entityhorseabstract; boolean flag = true; diff --git a/nms-patches/ContainerLectern.patch b/nms-patches/ContainerLectern.patch new file mode 100644 index 0000000000..50a32d3724 --- /dev/null +++ b/nms-patches/ContainerLectern.patch @@ -0,0 +1,60 @@ +--- a/net/minecraft/server/ContainerLectern.java ++++ b/net/minecraft/server/ContainerLectern.java +@@ -1,15 +1,38 @@ + package net.minecraft.server; + ++// CraftBukkit start ++import org.bukkit.craftbukkit.inventory.CraftInventoryLectern; ++import org.bukkit.craftbukkit.inventory.CraftInventoryView; ++import org.bukkit.entity.Player; ++// CraftBukkit end ++ + public class ContainerLectern extends Container { + ++ // CraftBukkit start ++ private CraftInventoryView bukkitEntity = null; ++ private Player player; ++ ++ @Override ++ public CraftInventoryView getBukkitView() { ++ if (bukkitEntity != null) { ++ return bukkitEntity; ++ } ++ ++ CraftInventoryLectern inventory = new CraftInventoryLectern(this.inventory); ++ bukkitEntity = new CraftInventoryView(this.player, inventory, this); ++ return bukkitEntity; ++ } ++ // CraftBukkit end + private final IInventory inventory; + private final IContainerProperties containerProperties; + +- public ContainerLectern(int i) { +- this(i, new InventorySubcontainer(1), new ContainerProperties(1)); ++ // CraftBukkit start - add player ++ public ContainerLectern(int i, PlayerInventory playerinventory) { ++ this(i, new InventorySubcontainer(1), new ContainerProperties(1), playerinventory); + } + +- public ContainerLectern(int i, IInventory iinventory, IContainerProperties icontainerproperties) { ++ public ContainerLectern(int i, IInventory iinventory, IContainerProperties icontainerproperties, PlayerInventory playerinventory) { ++ // CraftBukkit end + super(Containers.LECTERN, i); + a(iinventory, 1); + a(icontainerproperties, 1); +@@ -23,6 +46,7 @@ + } + }); + this.a(icontainerproperties); ++ player = (Player) playerinventory.player.getBukkitEntity(); // CraftBukkit + } + + @Override +@@ -70,6 +94,7 @@ + + @Override + public boolean canUse(EntityHuman entityhuman) { ++ if (!this.checkReachable) return true; // CraftBukkit + return this.inventory.a(entityhuman); + } + } diff --git a/nms-patches/ContainerLoom.patch b/nms-patches/ContainerLoom.patch new file mode 100644 index 0000000000..5042405c84 --- /dev/null +++ b/nms-patches/ContainerLoom.patch @@ -0,0 +1,85 @@ +--- a/net/minecraft/server/ContainerLoom.java ++++ b/net/minecraft/server/ContainerLoom.java +@@ -1,7 +1,29 @@ + package net.minecraft.server; + ++// CraftBukkit start ++import org.bukkit.Location; ++import org.bukkit.craftbukkit.inventory.CraftInventoryLoom; ++import org.bukkit.craftbukkit.inventory.CraftInventoryView; ++import org.bukkit.entity.Player; ++// CraftBukkit end ++ + public class ContainerLoom extends Container { + ++ // CraftBukkit start ++ private CraftInventoryView bukkitEntity = null; ++ private Player player; ++ ++ @Override ++ public CraftInventoryView getBukkitView() { ++ if (bukkitEntity != null) { ++ return bukkitEntity; ++ } ++ ++ CraftInventoryLoom inventory = new CraftInventoryLoom(this.craftInventory, this.resultInventory); ++ bukkitEntity = new CraftInventoryView(this.player, inventory, this); ++ return bukkitEntity; ++ } ++ // CraftBukkit end + private final ContainerAccess containerAccess; + private final ContainerProperty d; + private Runnable e; +@@ -28,6 +50,13 @@ + ContainerLoom.this.a((IInventory) this); + ContainerLoom.this.e.run(); + } ++ ++ // CraftBukkit start ++ @Override ++ public Location getLocation() { ++ return containeraccess.getLocation(); ++ } ++ // CraftBukkit end + }; + this.resultInventory = new InventorySubcontainer(1) { + @Override +@@ -35,6 +64,13 @@ + super.update(); + ContainerLoom.this.e.run(); + } ++ ++ // CraftBukkit start ++ @Override ++ public Location getLocation() { ++ return containeraccess.getLocation(); ++ } ++ // CraftBukkit end + }; + this.containerAccess = containeraccess; + this.f = this.a(new Slot(this.craftInventory, 0, 13, 26) { +@@ -89,10 +125,12 @@ + } + + this.a(this.d); ++ player = (Player) playerinventory.player.getBukkitEntity(); // CraftBukkit + } + + @Override + public boolean canUse(EntityHuman entityhuman) { ++ if (!this.checkReachable) return true; // CraftBukkit + return a(this.containerAccess, entityhuman, Blocks.LOOM); + } + +@@ -211,6 +249,11 @@ + + if (nbttagcompound.hasKeyOfType("Patterns", 9)) { + nbttaglist = nbttagcompound.getList("Patterns", 10); ++ // CraftBukkit start ++ while (nbttaglist.size() > 20) { ++ nbttaglist.remove(20); ++ } ++ // CraftBukkit end + } else { + nbttaglist = new NBTTagList(); + nbttagcompound.set("Patterns", nbttaglist); diff --git a/nms-patches/ContainerMerchant.patch b/nms-patches/ContainerMerchant.patch index 3610204f0f..0001f1ca5f 100644 --- a/nms-patches/ContainerMerchant.patch +++ b/nms-patches/ContainerMerchant.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/ContainerMerchant.java +++ b/net/minecraft/server/ContainerMerchant.java -@@ -1,11 +1,26 @@ +@@ -1,10 +1,25 @@ package net.minecraft.server; +import org.bukkit.craftbukkit.inventory.CraftInventoryView; // CraftBukkit @@ -8,8 +8,7 @@ public class ContainerMerchant extends Container { private final IMerchant merchant; - private final InventoryMerchant f; - private final World g; + private final InventoryMerchant inventoryMerchant; + // CraftBukkit start + private CraftInventoryView bukkitEntity = null; @@ -18,20 +17,20 @@ + @Override + public CraftInventoryView getBukkitView() { + if (bukkitEntity == null) { -+ bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), new org.bukkit.craftbukkit.inventory.CraftInventoryMerchant((InventoryMerchant) f), this); ++ bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), new org.bukkit.craftbukkit.inventory.CraftInventoryMerchant(inventoryMerchant), this); + } + return bukkitEntity; + } + // CraftBukkit end + - public ContainerMerchant(PlayerInventory playerinventory, IMerchant imerchant, World world) { - this.merchant = imerchant; - this.g = world; -@@ -13,6 +28,7 @@ - this.a(new Slot(this.f, 0, 36, 53)); - this.a(new Slot(this.f, 1, 62, 53)); - this.a((Slot) (new SlotMerchantResult(playerinventory.player, imerchant, this.f, 2, 120, 53))); + public ContainerMerchant(int i, PlayerInventory playerinventory) { + this(i, playerinventory, new MerchantWrapper(playerinventory.player)); + } +@@ -16,6 +31,7 @@ + this.a(new Slot(this.inventoryMerchant, 0, 136, 37)); + this.a(new Slot(this.inventoryMerchant, 1, 162, 37)); + this.a((Slot) (new SlotMerchantResult(playerinventory.player, imerchant, this.inventoryMerchant, 2, 220, 37))); + this.player = playerinventory; // CraftBukkit - save player - int i; + int j; diff --git a/nms-patches/ContainerPlayer.patch b/nms-patches/ContainerPlayer.patch index 1b9002dd16..fb339b0d16 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,5 +1,10 @@ +@@ -1,18 +1,35 @@ package net.minecraft.server; +// CraftBukkit start @@ -8,12 +8,17 @@ +import org.bukkit.craftbukkit.inventory.CraftInventoryView; +// CraftBukkit end + - public class ContainerPlayer extends ContainerRecipeBook { + public class ContainerPlayer extends ContainerRecipeBook { - private static final String[] h = new String[] { "item/empty_armor_slot_boots", "item/empty_armor_slot_leggings", "item/empty_armor_slot_chestplate", "item/empty_armor_slot_helmet"}; -@@ -8,10 +13,20 @@ - public InventoryCraftResult resultInventory = new InventoryCraftResult(); - public boolean g; + private static final String[] d = new String[] { "item/empty_armor_slot_boots", "item/empty_armor_slot_leggings", "item/empty_armor_slot_chestplate", "item/empty_armor_slot_helmet"}; + private static final EnumItemSlot[] e = new EnumItemSlot[] { EnumItemSlot.HEAD, EnumItemSlot.CHEST, EnumItemSlot.LEGS, EnumItemSlot.FEET}; +- private final InventoryCrafting craftInventory = new InventoryCrafting(this, 2, 2); +- private final InventoryCraftResult resultInventory = new InventoryCraftResult(); ++ // CraftBukkit start ++ private final InventoryCrafting craftInventory; ++ private final InventoryCraftResult resultInventory; ++ // CraftBukkit end + public final boolean c; private final EntityHuman owner; + // CraftBukkit start + private CraftInventoryView bukkitEntity = null; @@ -21,7 +26,8 @@ + // CraftBukkit end public ContainerPlayer(PlayerInventory playerinventory, boolean flag, EntityHuman entityhuman) { - this.g = flag; + super((Containers) null, 0); + this.c = flag; this.owner = entityhuman; + // CraftBukkit start + this.resultInventory = new InventoryCraftResult(); // CraftBukkit - moved to before InventoryCrafting construction @@ -32,9 +38,18 @@ this.a((Slot) (new SlotResult(playerinventory.player, this.craftInventory, this.resultInventory, 0, 154, 28))); int i; -@@ -167,4 +182,17 @@ - public int g() { - return this.craftInventory.n(); +@@ -79,7 +96,7 @@ + + @Override + public void a(IInventory iinventory) { +- ContainerWorkbench.a(this.windowId, this.owner.world, this.owner, this.craftInventory, this.resultInventory); ++ ContainerWorkbench.a(this.windowId, this.owner.world, this.owner, this.craftInventory, this.resultInventory, this); // CraftBukkit + } + + @Override +@@ -182,4 +199,17 @@ + public int h() { + return this.craftInventory.f(); } + + // CraftBukkit start diff --git a/nms-patches/ContainerShulkerBox.patch b/nms-patches/ContainerShulkerBox.patch index 494f7c4946..1c59f08b26 100644 --- a/nms-patches/ContainerShulkerBox.patch +++ b/nms-patches/ContainerShulkerBox.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/ContainerShulkerBox.java +++ b/net/minecraft/server/ContainerShulkerBox.java -@@ -1,11 +1,31 @@ +@@ -1,8 +1,27 @@ package net.minecraft.server; +// CraftBukkit start @@ -10,7 +10,7 @@ + public class ContainerShulkerBox extends Container { - private final IInventory a; + private final IInventory c; + // CraftBukkit start + private CraftInventoryView bukkitEntity; + private PlayerInventory player; @@ -21,14 +21,18 @@ + return bukkitEntity; + } + -+ bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), new CraftInventory(this.a), this); ++ bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), new CraftInventory(this.c), this); + return bukkitEntity; + } + // CraftBukkit end - public ContainerShulkerBox(PlayerInventory playerinventory, IInventory iinventory, EntityHuman entityhuman) { - this.a = iinventory; + public ContainerShulkerBox(int i, PlayerInventory playerinventory) { + this(i, playerinventory, new InventorySubcontainer(27)); +@@ -12,6 +31,7 @@ + super(Containers.SHULKER_BOX, i); + a(iinventory, 27); + this.c = iinventory; + this.player = playerinventory; // CraftBukkit - save player - iinventory.startOpen(entityhuman); + iinventory.startOpen(playerinventory.player); boolean flag = true; boolean flag1 = true; diff --git a/nms-patches/ContainerStonecutter.patch b/nms-patches/ContainerStonecutter.patch new file mode 100644 index 0000000000..e44f48fb83 --- /dev/null +++ b/nms-patches/ContainerStonecutter.patch @@ -0,0 +1,49 @@ +--- a/net/minecraft/server/ContainerStonecutter.java ++++ b/net/minecraft/server/ContainerStonecutter.java +@@ -3,6 +3,11 @@ + import com.google.common.collect.ImmutableList; + import com.google.common.collect.Lists; + import java.util.List; ++// CraftBukkit start ++import org.bukkit.craftbukkit.inventory.CraftInventoryStonecutter; ++import org.bukkit.craftbukkit.inventory.CraftInventoryView; ++import org.bukkit.entity.Player; ++// CraftBukkit end + + public class ContainerStonecutter extends Container { + +@@ -18,6 +23,21 @@ + private Runnable m; + public final IInventory inventory; + private final InventoryCraftResult n; ++ // CraftBukkit start ++ private CraftInventoryView bukkitEntity = null; ++ private Player player; ++ ++ @Override ++ public CraftInventoryView getBukkitView() { ++ if (bukkitEntity != null) { ++ return bukkitEntity; ++ } ++ ++ CraftInventoryStonecutter inventory = new CraftInventoryStonecutter(this.inventory); ++ bukkitEntity = new CraftInventoryView(this.player, inventory, this); ++ return bukkitEntity; ++ } ++ // CraftBukkit end + + public ContainerStonecutter(int i, PlayerInventory playerinventory) { + this(i, playerinventory, ContainerAccess.a); +@@ -83,10 +103,12 @@ + } + + this.a(this.containerProperty); ++ player = (Player) playerinventory.player.getBukkitEntity(); // CraftBukkit + } + + @Override + public boolean canUse(EntityHuman entityhuman) { ++ if (!this.checkReachable) return true; // CraftBukkit + return a(this.containerAccess, entityhuman, Blocks.STONECUTTER); + } + diff --git a/nms-patches/ContainerWorkbench.patch b/nms-patches/ContainerWorkbench.patch index f5dd0d2d0e..2134415f87 100644 --- a/nms-patches/ContainerWorkbench.patch +++ b/nms-patches/ContainerWorkbench.patch @@ -1,48 +1,78 @@ --- a/net/minecraft/server/ContainerWorkbench.java +++ b/net/minecraft/server/ContainerWorkbench.java -@@ -1,14 +1,29 @@ +@@ -1,6 +1,10 @@ package net.minecraft.server; + import java.util.Optional; +// CraftBukkit start +import org.bukkit.craftbukkit.inventory.CraftInventoryCrafting; +import org.bukkit.craftbukkit.inventory.CraftInventoryView; +// CraftBukkit end -+ - public class ContainerWorkbench extends ContainerRecipeBook { -- public InventoryCrafting craftInventory = new InventoryCrafting(this, 3, 3); -- public InventoryCraftResult resultInventory = new InventoryCraftResult(); -+ public InventoryCrafting craftInventory; // CraftBukkit - move initialization into constructor -+ public InventoryCraftResult resultInventory; // CraftBukkit - move initialization into constructor - private final World g; - private final BlockPosition h; - private final EntityHuman i; + public class ContainerWorkbench extends ContainerRecipeBook { + +@@ -8,6 +12,10 @@ + private final InventoryCraftResult resultInventory; + private final ContainerAccess e; + private final EntityHuman f; + // CraftBukkit start + private CraftInventoryView bukkitEntity = null; + private PlayerInventory player; + // CraftBukkit end - public ContainerWorkbench(PlayerInventory playerinventory, World world, BlockPosition blockposition) { + public ContainerWorkbench(int i, PlayerInventory playerinventory) { + this(i, playerinventory, ContainerAccess.a); +@@ -15,8 +23,12 @@ + + public ContainerWorkbench(int i, PlayerInventory playerinventory, ContainerAccess containeraccess) { + super(Containers.CRAFTING, i); +- this.craftInventory = new InventoryCrafting(this, 3, 3); + // CraftBukkit start - Switched order of IInventory construction and stored player -+ this.resultInventory = new InventoryCraftResult(); + this.resultInventory = new InventoryCraftResult(); + this.craftInventory = new InventoryCrafting(this, 3, 3, playerinventory.player); // CraftBukkit - pass player + this.craftInventory.resultInventory = this.resultInventory; + this.player = playerinventory; + // CraftBukkit end - this.g = world; - this.h = blockposition; - this.i = playerinventory.player; -@@ -60,6 +75,7 @@ + this.e = containeraccess; + this.f = playerinventory.player; + this.a((Slot) (new SlotResult(playerinventory.player, this.craftInventory, this.resultInventory, 0, 124, 35))); +@@ -42,7 +54,7 @@ + } +- protected static void a(int i, World world, EntityHuman entityhuman, InventoryCrafting inventorycrafting, InventoryCraftResult inventorycraftresult) { ++ protected static void a(int i, World world, EntityHuman entityhuman, InventoryCrafting inventorycrafting, InventoryCraftResult inventorycraftresult, Container container) { // CraftBukkit + if (!world.isClientSide) { + EntityPlayer entityplayer = (EntityPlayer) entityhuman; + ItemStack itemstack = ItemStack.a; +@@ -55,6 +67,7 @@ + itemstack = recipecrafting.a(inventorycrafting); + } + } ++ itemstack = org.bukkit.craftbukkit.event.CraftEventFactory.callPreCraftEvent(inventorycrafting, inventorycraftresult, itemstack, container.getBukkitView(), false); // CraftBukkit + + inventorycraftresult.setItem(0, itemstack); + entityplayer.playerConnection.sendPacket(new PacketPlayOutSetSlot(i, 0, itemstack)); +@@ -64,7 +77,7 @@ + @Override + public void a(IInventory iinventory) { + this.e.a((world, blockposition) -> { +- a(this.windowId, world, this.f, this.craftInventory, this.resultInventory); ++ a(this.windowId, world, this.f, this.craftInventory, this.resultInventory, this); // CraftBukkit + }); + } + +@@ -94,6 +107,7 @@ + + @Override public boolean canUse(EntityHuman entityhuman) { + if (!this.checkReachable) return true; // CraftBukkit - return this.g.getType(this.h).getBlock() != Blocks.CRAFTING_TABLE ? false : entityhuman.d((double) this.h.getX() + 0.5D, (double) this.h.getY() + 0.5D, (double) this.h.getZ() + 0.5D) <= 64.0D; + return a(this.e, entityhuman, Blocks.CRAFTING_TABLE); } -@@ -125,4 +141,17 @@ - public int g() { - return this.craftInventory.n(); +@@ -166,4 +180,17 @@ + public int h() { + return this.craftInventory.f(); } + + // CraftBukkit start diff --git a/nms-patches/Containers.patch b/nms-patches/Containers.patch new file mode 100644 index 0000000000..8e6a97fbe6 --- /dev/null +++ b/nms-patches/Containers.patch @@ -0,0 +1,31 @@ +--- a/net/minecraft/server/Containers.java ++++ b/net/minecraft/server/Containers.java +@@ -19,7 +19,7 @@ + public static final Containers GRINDSTONE = a("grindstone", ContainerGrindstone::new); + public static final Containers HOPPER = a("hopper", ContainerHopper::new); + public static final Containers LECTERN = a("lectern", (i, playerinventory) -> { +- return new ContainerLectern(i); ++ return new ContainerLectern(i, playerinventory); // CraftBukkit + }); + public static final Containers LOOM = a("loom", ContainerLoom::new); + public static final Containers MERCHANT = a("merchant", ContainerMerchant::new); +@@ -30,12 +30,17 @@ + private final Containers.Supplier x; + + private static Containers a(String s, Containers.Supplier containers_supplier) { +- return (Containers) IRegistry.a(IRegistry.MENU, s, (Object) (new Containers<>(containers_supplier))); ++ return (Containers) IRegistry.a(IRegistry.MENU, s, (new Containers<>(containers_supplier))); // CraftBukkit - decompile error + } + + private Containers(Containers.Supplier containers_supplier) { + this.x = containers_supplier; + } + +- interface Supplier {} ++ // CraftBukkit start ++ interface Supplier { ++ ++ T supply(int id, PlayerInventory playerinventory); ++ } ++ // CraftBukkit end + } diff --git a/nms-patches/CraftingManager.patch b/nms-patches/CraftingManager.patch index d4aa226253..ffe263dfeb 100644 --- a/nms-patches/CraftingManager.patch +++ b/nms-patches/CraftingManager.patch @@ -1,50 +1,73 @@ --- a/net/minecraft/server/CraftingManager.java +++ b/net/minecraft/server/CraftingManager.java -@@ -20,7 +20,7 @@ +@@ -26,7 +26,7 @@ private static final Logger c = LogManager.getLogger(); public static final int a = "recipes/".length(); public static final int b = ".json".length(); -- public Map recipes = Maps.newHashMap(); -+ public it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap recipes = new it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap<>(); // CraftBukkit +- public Map, Map>> recipes = (Map) SystemUtils.a((Object) Maps.newHashMap(), CraftingManager::a); ++ public Map, it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap>> recipes = SystemUtils.a(Maps.newHashMap(), CraftingManager::a); // CraftBukkit private boolean e; public CraftingManager() {} -@@ -84,7 +84,7 @@ - if (this.recipes.containsKey(irecipe.getKey())) { +@@ -88,19 +88,23 @@ + } + + public void addRecipe(IRecipe irecipe) { +- Map> map = (Map) this.recipes.get(irecipe.g()); ++ it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap> map = this.recipes.get(irecipe.g()); // CraftBukkit + + if (map.containsKey(irecipe.getKey())) { throw new IllegalStateException("Duplicate recipe ignored with ID " + irecipe.getKey()); } else { -- this.recipes.put(irecipe.getKey(), irecipe); -+ this.recipes.putAndMoveToFirst(irecipe.getKey(), irecipe); // CraftBukkit - SPIGOT-4638: last recipe gets priority +- map.put(irecipe.getKey(), irecipe); ++ map.putAndMoveToFirst(irecipe.getKey(), irecipe); // CraftBukkit - SPIGOT-4638: last recipe gets priority } } -@@ -95,12 +95,14 @@ - - do { - if (!iterator.hasNext()) { -+ iinventory.setCurrentRecipe(null); // CraftBukkit - Clear recipe when no recipe is found - return ItemStack.a; - } - - irecipe = (IRecipe) iterator.next(); - } while (!irecipe.a(iinventory, world)); - -+ iinventory.setCurrentRecipe(irecipe); // CraftBukkit - return irecipe.craftItem(iinventory); + public > Optional craft(Recipes recipes, C c0, World world) { +- return this.a(recipes).values().stream().flatMap((irecipe) -> { ++ // CraftBukkit start ++ Optional recipe = this.a(recipes).values().stream().flatMap((irecipe) -> { + return SystemUtils.a(recipes.a(irecipe, world, c0)); + }).findFirst(); ++ c0.setCurrentRecipe(recipe.orElse(null)); // CraftBukkit - Clear recipe when no recipe is found ++ // CraftBukkit end ++ return recipe; } -@@ -112,12 +114,14 @@ - - do { - if (!iterator.hasNext()) { -+ iinventory.setCurrentRecipe(null); // CraftBukkit - Clear recipe when no recipe is found - return null; - } - - irecipe = (IRecipe) iterator.next(); - } while (!irecipe.a(iinventory, world)); - -+ iinventory.setCurrentRecipe(irecipe); // CraftBukkit - return irecipe; + public > List b(Recipes recipes, C c0, World world) { +@@ -112,7 +116,7 @@ } + private > Map> a(Recipes recipes) { +- return (Map) this.recipes.getOrDefault(recipes, Maps.newHashMap()); ++ return (Map) this.recipes.getOrDefault(recipes, new it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap<>()); // CraftBukkit + } + + public > NonNullList c(Recipes recipes, C c0, World world) { +@@ -133,7 +137,7 @@ + + public Optional> a(MinecraftKey minecraftkey) { + return this.recipes.values().stream().map((map) -> { +- return (IRecipe) map.get(minecraftkey); ++ return map.get(minecraftkey); // CraftBukkit - decompile error + }).filter(Objects::nonNull).findFirst(); + } + +@@ -157,14 +161,14 @@ + })).a(minecraftkey, jsonobject); + } + +- private static void a(Map, Map>> map) { ++ private static void a(Map, it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap>> map) { // CraftBukkit + map.clear(); + Iterator iterator = IRegistry.RECIPE_TYPE.iterator(); + + while (iterator.hasNext()) { + Recipes recipes = (Recipes) iterator.next(); + +- map.put(recipes, Maps.newHashMap()); ++ map.put(recipes, new it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap<>()); // CraftBukkit + } + + } diff --git a/nms-patches/CrashReport.patch b/nms-patches/CrashReport.patch index fb516d9170..c6274c49e0 100644 --- a/nms-patches/CrashReport.patch +++ b/nms-patches/CrashReport.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/CrashReport.java +++ b/net/minecraft/server/CrashReport.java -@@ -63,6 +63,7 @@ +@@ -64,6 +64,7 @@ return String.format("%d total; %s", list.size(), list.stream().collect(Collectors.joining(" "))); }); diff --git a/nms-patches/CustomFunction.patch b/nms-patches/CustomFunction.patch index 43851fe09b..7fc57d1a8b 100644 --- a/nms-patches/CustomFunction.patch +++ b/nms-patches/CustomFunction.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/CustomFunction.java +++ b/net/minecraft/server/CustomFunction.java -@@ -47,7 +47,7 @@ +@@ -48,7 +48,7 @@ } try { diff --git a/nms-patches/CustomFunctionData.patch b/nms-patches/CustomFunctionData.patch index 64cfdcc3d9..d7d1b8a1a0 100644 --- a/nms-patches/CustomFunctionData.patch +++ b/nms-patches/CustomFunctionData.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/CustomFunctionData.java +++ b/net/minecraft/server/CustomFunctionData.java -@@ -55,7 +55,7 @@ +@@ -53,7 +53,7 @@ } public com.mojang.brigadier.CommandDispatcher d() { diff --git a/nms-patches/DamageSource.patch b/nms-patches/DamageSource.patch index 9a4a324c91..b37c13656a 100644 --- a/nms-patches/DamageSource.patch +++ b/nms-patches/DamageSource.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/DamageSource.java +++ b/net/minecraft/server/DamageSource.java -@@ -35,6 +35,18 @@ - private boolean D; +@@ -36,6 +36,18 @@ private boolean E; + private boolean F; public final String translationIndex; + // CraftBukkit start + private boolean sweep; diff --git a/nms-patches/DataConverterMap.patch b/nms-patches/DataConverterMap.patch index 6ee2eecac6..a97e488994 100644 --- a/nms-patches/DataConverterMap.patch +++ b/nms-patches/DataConverterMap.patch @@ -4,8 +4,8 @@ Typed typed1 = typed.getOrCreateTyped(opticfinder1); Dynamic dynamic1 = (Dynamic) typed1.get(DSL.remainderFinder()); -- dynamic1 = dynamic1.set("map", dynamic1.createInt(dynamic.getInt("Damage"))); -+ if (!dynamic1.get("map").isPresent()) dynamic1 = dynamic1.set("map", dynamic1.createInt(dynamic.getInt("Damage"))); // CraftBukkit +- dynamic1 = dynamic1.set("map", dynamic1.createInt(dynamic.get("Damage").asInt(0))); ++ if (!dynamic1.getElement("map").isPresent()) dynamic1 = dynamic1.set("map", dynamic1.createInt(dynamic.get("Damage").asInt(0))); // CraftBukkit return typed.set(opticfinder1, typed1.set(DSL.remainderFinder(), dynamic1)); } else { return typed; diff --git a/nms-patches/DataConverterRegistry.patch b/nms-patches/DataConverterRegistry.patch index 0caa4e865a..69813c0263 100644 --- a/nms-patches/DataConverterRegistry.patch +++ b/nms-patches/DataConverterRegistry.patch @@ -1,20 +1,6 @@ --- a/net/minecraft/server/DataConverterRegistry.java +++ b/net/minecraft/server/DataConverterRegistry.java -@@ -20,7 +20,12 @@ - DataFixerBuilder datafixerbuilder = new DataFixerBuilder(1631); - - a(datafixerbuilder); -- return datafixerbuilder.build(ForkJoinPool.commonPool()); -+ // CraftBukkit start -+ ForkJoinPool pool = new ForkJoinPool(Integer.getInteger("net.minecraft.server.DataConverterRegistry.bootstrapThreads", Math.min(Runtime.getRuntime().availableProcessors(), 2))); -+ DataFixer fixer = datafixerbuilder.build(pool); -+ pool.shutdown(); -+ return fixer; -+ // CraftBukkit end - } - - public static DataFixer a() { -@@ -184,6 +189,18 @@ +@@ -183,6 +183,18 @@ datafixerbuilder.addFixer(new DataConverterItemFrame(schema46, false)); Schema schema47 = datafixerbuilder.addSchema(1458, DataConverterRegistry.b); diff --git a/nms-patches/DataWatcher.patch b/nms-patches/DataWatcher.patch index ace8a7726a..dcd9692a24 100644 --- a/nms-patches/DataWatcher.patch +++ b/nms-patches/DataWatcher.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/DataWatcher.java +++ b/net/minecraft/server/DataWatcher.java -@@ -128,6 +128,13 @@ +@@ -129,6 +129,13 @@ } diff --git a/nms-patches/DedicatedServer.patch b/nms-patches/DedicatedServer.patch index 68c4b08c2a..20fc039d45 100644 --- a/nms-patches/DedicatedServer.patch +++ b/nms-patches/DedicatedServer.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/DedicatedServer.java +++ b/net/minecraft/server/DedicatedServer.java -@@ -23,6 +23,17 @@ +@@ -25,6 +25,17 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -18,25 +18,21 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer { private static final Logger LOGGER = LogManager.getLogger(); -@@ -37,8 +48,10 @@ - private EnumGamemode p; - private boolean q; +@@ -38,8 +49,10 @@ + @Nullable + private ServerGUI q; -- public DedicatedServer(File file, DataFixer datafixer, YggdrasilAuthenticationService yggdrasilauthenticationservice, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache) { -- super(file, Proxy.NO_PROXY, datafixer, new CommandDispatcher(true), yggdrasilauthenticationservice, minecraftsessionservice, gameprofilerepository, usercache); +- public DedicatedServer(File file, DedicatedServerSettings dedicatedserversettings, DataFixer datafixer, YggdrasilAuthenticationService yggdrasilauthenticationservice, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache, WorldLoadListenerFactory worldloadlistenerfactory, String s) { +- super(file, Proxy.NO_PROXY, datafixer, new CommandDispatcher(true), yggdrasilauthenticationservice, minecraftsessionservice, gameprofilerepository, usercache, worldloadlistenerfactory, s); + // CraftBukkit start - Signature changed -+ public DedicatedServer(joptsimple.OptionSet options, DataFixer datafixer, YggdrasilAuthenticationService yggdrasilauthenticationservice, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache) { -+ super(options, Proxy.NO_PROXY, datafixer, new CommandDispatcher().init(true), yggdrasilauthenticationservice, minecraftsessionservice, gameprofilerepository, usercache); ++ public DedicatedServer(joptsimple.OptionSet options, DedicatedServerSettings dedicatedserversettings, DataFixer datafixer, YggdrasilAuthenticationService yggdrasilauthenticationservice, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache, WorldLoadListenerFactory worldloadlistenerfactory, String s) { ++ super(options, Proxy.NO_PROXY, datafixer, new CommandDispatcher().init(true), yggdrasilauthenticationservice, minecraftsessionservice, gameprofilerepository, usercache, worldloadlistenerfactory, s); + // CraftBukkit end + this.propertyManager = dedicatedserversettings; + this.remoteControlCommandListener = new RemoteControlCommandListener(this); Thread thread = new Thread("Server Infinisleeper") { - { - this.setDaemon(true); -@@ -58,16 +71,30 @@ - }; - } - -- protected boolean init() throws IOException { -+ public boolean init() throws IOException { // CraftBukkit - decompile error +@@ -65,13 +78,27 @@ + public boolean init() throws IOException { Thread thread = new Thread("Server console handler") { public void run() { - BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(System.in, StandardCharsets.UTF_8)); @@ -66,7 +62,7 @@ } } catch (IOException ioexception) { DedicatedServer.LOGGER.error("Exception handling console input", ioexception); -@@ -76,6 +103,27 @@ +@@ -80,6 +107,27 @@ } }; @@ -85,7 +81,7 @@ + } + } + -+ new Thread(new org.bukkit.craftbukkit.util.TerminalConsoleWriterThread(System.out, this.reader)).start(); ++ new org.bukkit.craftbukkit.util.TerminalConsoleWriterThread(System.out, this.reader).start(); + + System.setOut(new PrintStream(new LoggerOutputStream(logger, Level.INFO), true)); + System.setErr(new PrintStream(new LoggerOutputStream(logger, Level.WARN), true)); @@ -94,87 +90,60 @@ thread.setDaemon(true); thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(DedicatedServer.LOGGER)); thread.start(); -@@ -85,7 +133,7 @@ +@@ -133,6 +181,12 @@ + return false; } - DedicatedServer.LOGGER.info("Loading properties"); -- this.propertyManager = new PropertyManager(new File("server.properties")); -+ this.propertyManager = new PropertyManager(this.options); // CraftBukkit - CLI argument support - this.eula = new EULA(new File("eula.txt")); - if (!this.eula.a()) { - DedicatedServer.LOGGER.info("You need to agree to the EULA in order to run the server. Go to eula.txt for more info."); -@@ -143,6 +191,12 @@ - return false; - } - -+ // CraftBukkit start -+ this.a((PlayerList) (new DedicatedPlayerList(this))); -+ server.loadPlugins(); -+ server.enablePlugins(org.bukkit.plugin.PluginLoadOrder.STARTUP); -+ // CraftBukkit end ++ // CraftBukkit start ++ this.a((PlayerList) (new DedicatedPlayerList(this))); ++ server.loadPlugins(); ++ server.enablePlugins(org.bukkit.plugin.PluginLoadOrder.STARTUP); ++ // CraftBukkit end + - 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."); -@@ -157,7 +211,7 @@ - if (!NameReferencingFileConverter.a(this.propertyManager)) { - return false; - } else { -- this.a((PlayerList) (new DedicatedPlayerList(this))); -+ this.convertable = new WorldLoaderServer(server.getWorldContainer().toPath(), server.getWorldContainer().toPath().resolve("../backups"), this.dataConverterManager); // CraftBukkit - moved from MinecraftServer constructor - long j = SystemUtils.getMonotonicNanos(); - - if (this.getWorld() == null) { -@@ -204,7 +258,13 @@ - if (worldtype == WorldType.FLAT) { - jsonobject.addProperty("flat_world_options", s2); - } else if (!s2.isEmpty()) { -- jsonobject = ChatDeserializer.a(s2); -+ // CraftBukkit start -+ try { -+ jsonobject = ChatDeserializer.a(s2); -+ } catch (Exception ex) { -+ DedicatedServer.LOGGER.warn("Invalid generator-settings, ignoring", ex); -+ } -+ // CraftBukkit end - } - - this.a(this.getWorld(), this.getWorld(), k, worldtype, jsonobject); -@@ -228,8 +288,19 @@ - DedicatedServer.LOGGER.info("Starting remote control listener"); - this.l = new RemoteControlListener(this); - this.l.a(); -+ this.remoteConsole = new org.bukkit.craftbukkit.command.CraftRemoteConsoleCommandSender(this.remoteControlCommandListener); // CraftBukkit - } - + 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."); +@@ -147,7 +201,7 @@ + if (!NameReferencingFileConverter.e(this)) { + return false; + } else { +- this.a((PlayerList) (new DedicatedPlayerList(this))); ++ this.convertable = new Convertable(server.getWorldContainer().toPath(), server.getWorldContainer().toPath().resolve("../backups"), this.dataConverterManager); // CraftBukkit - moved from MinecraftServer constructor + long i = SystemUtils.getMonotonicNanos(); + String s = dedicatedserverproperties.levelSeed; + String s1 = dedicatedserverproperties.generatorSettings; +@@ -177,7 +231,13 @@ + if (worldtype == WorldType.FLAT) { + jsonobject.addProperty("flat_world_options", s1); + } else if (!s1.isEmpty()) { +- jsonobject = ChatDeserializer.a(s1); + // CraftBukkit start -+ if (this.server.getBukkitSpawnRadius() > -1) { -+ DedicatedServer.LOGGER.info("'settings.spawn-radius' in bukkit.yml has been moved to 'spawn-protection' in server.properties. I will move your config for you."); -+ this.propertyManager.properties.remove("spawn-protection"); -+ this.propertyManager.getInt("spawn-protection", this.server.getBukkitSpawnRadius()); -+ this.server.removeBukkitSpawnRadius(); -+ this.propertyManager.savePropertiesFile(); ++ try { ++ jsonobject = ChatDeserializer.a(s1); ++ } catch (Exception ex) { ++ DedicatedServer.LOGGER.warn("Invalid generator-settings, ignoring", ex); + } + // CraftBukkit end -+ - if (this.getMaxTickTime() > 0L) { - Thread thread1 = new Thread(new ThreadWatchdog(this)); + } -@@ -303,11 +374,11 @@ - return crashreport; + this.a(this.getWorld(), this.getWorld(), j, worldtype, jsonobject); +@@ -199,6 +259,7 @@ + DedicatedServer.LOGGER.info("Starting remote control listener"); + this.remoteControlListener = new RemoteControlListener(this); + this.remoteControlListener.a(); ++ this.remoteConsole = new org.bukkit.craftbukkit.command.CraftRemoteConsoleCommandSender(this.remoteControlCommandListener); // CraftBukkit + } + + if (this.getMaxTickTime() > 0L) { +@@ -301,6 +362,7 @@ + this.l.b(); + } + ++ System.exit(0); // CraftBukkit } -- protected void t() { -+ public void t() { // CraftBukkit - decompile error - System.exit(0); - } - -- protected void b(BooleanSupplier booleansupplier) { -+ public void b(BooleanSupplier booleansupplier) { // CraftBukkit - fix decompile error - super.b(booleansupplier); - this.handleCommandQueue(); - } -@@ -342,7 +413,15 @@ + @Override +@@ -334,7 +396,15 @@ while (!this.serverCommandQueue.isEmpty()) { ServerCommand servercommand = (ServerCommand) this.serverCommandQueue.remove(0); @@ -191,9 +160,9 @@ } } -@@ -549,12 +628,71 @@ - } +@@ -529,14 +599,61 @@ + @Override public String getPlugins() { - return ""; + // CraftBukkit start - Whole method @@ -220,10 +189,14 @@ + + return result.toString(); + // CraftBukkit end -+ } -+ -+ // CraftBukkit start - fire RemoteServerCommandEvent -+ public String executeRemoteCommand(final String s) { + } + + @Override + public String executeRemoteCommand(String s) { +- this.remoteControlCommandListener.clearMessages(); +- this.getCommandDispatcher().a(this.remoteControlCommandListener.f(), s); +- return this.remoteControlCommandListener.getMessages(); ++ // CraftBukkit start - fire RemoteServerCommandEvent + Waitable waitable = new Waitable() { + @Override + protected String evaluate() { @@ -250,21 +223,23 @@ + throw new RuntimeException("Interrupted processing rcon command " + s, e); + } + // CraftBukkit end -+ } + } + + public void setHasWhitelist(boolean flag) { +@@ -555,4 +672,16 @@ + public boolean b(GameProfile gameprofile) { + return false; + } + + // CraftBukkit start + @Override -+ public PropertyManager getPropertyManager() { -+ return this.propertyManager; - } - -- public String executeRemoteCommand(String s) { -- this.remoteControlCommandListener.clearMessages(); -- this.getCommandDispatcher().a(this.remoteControlCommandListener.f(), s); -- return this.remoteControlCommandListener.getMessages(); ++ public boolean isDebugging() { ++ return this.getDedicatedServerProperties().debug; ++ } ++ + @Override + public CommandSender getBukkitSender(CommandListenerWrapper wrapper) { + return console; - } ++ } + // CraftBukkit end } diff --git a/nms-patches/DedicatedServerProperties.patch b/nms-patches/DedicatedServerProperties.patch new file mode 100644 index 0000000000..f86b0fdfe3 --- /dev/null +++ b/nms-patches/DedicatedServerProperties.patch @@ -0,0 +1,46 @@ +--- a/net/minecraft/server/DedicatedServerProperties.java ++++ b/net/minecraft/server/DedicatedServerProperties.java +@@ -2,9 +2,11 @@ + + import java.util.Properties; + import java.util.concurrent.TimeUnit; ++import joptsimple.OptionSet; // CraftBukkit + + public class DedicatedServerProperties extends PropertyManager { + ++ public final boolean debug = this.getBoolean("debug", false); // CraftBukkit + public final boolean onlineMode = this.getBoolean("online-mode", true); + public final boolean preventProxyConnections = this.getBoolean("prevent-proxy-connections", false); + public final String serverIp = this.getString("server-ip", ""); +@@ -51,8 +53,10 @@ + public final PropertyManager.EditableProperty playerIdleTimeout; + public final PropertyManager.EditableProperty whiteList; + +- public DedicatedServerProperties(Properties properties) { +- super(properties); ++ // CraftBukkit start ++ public DedicatedServerProperties(Properties properties, OptionSet optionset) { ++ super(properties, optionset); ++ // CraftBukkit end + this.difficulty = (EnumDifficulty) this.a("difficulty", a(EnumDifficulty::getById, EnumDifficulty::a), EnumDifficulty::c, EnumDifficulty.EASY); + this.gamemode = (EnumGamemode) this.a("gamemode", a(EnumGamemode::getById, EnumGamemode::a), EnumGamemode::b, EnumGamemode.SURVIVAL); + this.levelName = this.getString("level-name", "world"); +@@ -96,12 +100,14 @@ + this.whiteList = this.b("white-list", false); + } + +- public static DedicatedServerProperties load(java.nio.file.Path java_nio_file_path) { +- return new DedicatedServerProperties(loadPropertiesFile(java_nio_file_path)); ++ // CraftBukkit start ++ public static DedicatedServerProperties load(java.nio.file.Path java_nio_file_path, OptionSet optionset) { ++ return new DedicatedServerProperties(loadPropertiesFile(java_nio_file_path), optionset); + } + + @Override +- protected DedicatedServerProperties reload(Properties properties) { +- return new DedicatedServerProperties(properties); ++ protected DedicatedServerProperties reload(Properties properties, OptionSet optionset) { ++ return new DedicatedServerProperties(properties, optionset); ++ // CraftBukkit end + } + } diff --git a/nms-patches/DedicatedServerSettings.patch b/nms-patches/DedicatedServerSettings.patch new file mode 100644 index 0000000000..59c00acd33 --- /dev/null +++ b/nms-patches/DedicatedServerSettings.patch @@ -0,0 +1,27 @@ +--- a/net/minecraft/server/DedicatedServerSettings.java ++++ b/net/minecraft/server/DedicatedServerSettings.java +@@ -1,15 +1,21 @@ + package net.minecraft.server; + + import java.util.function.UnaryOperator; ++// CraftBukkit start ++import java.io.File; ++import joptsimple.OptionSet; ++// CraftBukkit end + + public class DedicatedServerSettings { + + private final java.nio.file.Path path; + private DedicatedServerProperties properties; + +- public DedicatedServerSettings(java.nio.file.Path java_nio_file_path) { +- this.path = java_nio_file_path; +- this.properties = DedicatedServerProperties.load(java_nio_file_path); ++ // CraftBukkit start ++ public DedicatedServerSettings(OptionSet optionset) { ++ this.path = ((File) optionset.valueOf("config")).toPath(); ++ this.properties = DedicatedServerProperties.load(path, optionset); ++ // CraftBukkit end + } + + public DedicatedServerProperties getProperties() { diff --git a/nms-patches/DefinedStructure.patch b/nms-patches/DefinedStructure.patch new file mode 100644 index 0000000000..cbf2f7aceb --- /dev/null +++ b/nms-patches/DefinedStructure.patch @@ -0,0 +1,38 @@ +--- a/net/minecraft/server/DefinedStructure.java ++++ b/net/minecraft/server/DefinedStructure.java +@@ -84,7 +84,7 @@ + } + + private void a(World world, BlockPosition blockposition, BlockPosition blockposition1) { +- List list = world.a(Entity.class, new AxisAlignedBB(blockposition, blockposition1), (entity) -> { ++ List list = world.a(Entity.class, new AxisAlignedBB(blockposition, blockposition1), (java.util.function.Predicate) (entity) -> { // CraftBukkit - decompile error + return !(entity instanceof EntityHuman); + }); + +@@ -384,11 +384,13 @@ + } + + private static Optional a(GeneratorAccess generatoraccess, NBTTagCompound nbttagcompound) { +- try { ++ // CraftBukkit start ++ // try { + return EntityTypes.a(nbttagcompound, generatoraccess.getMinecraftWorld()); +- } catch (Exception exception) { +- return Optional.empty(); +- } ++ // } catch (Exception exception) { ++ // return Optional.empty(); ++ // } ++ // CraftBukkit end + } + + public BlockPosition a(EnumBlockRotation enumblockrotation) { +@@ -797,7 +799,7 @@ + public IBlockData a(int i) { + IBlockData iblockdata = (IBlockData) this.b.fromId(i); + +- return iblockdata == null ? DefinedStructure.a.a : iblockdata; ++ return iblockdata == null ? a : iblockdata; // CraftBukkit - decompile error + } + + public Iterator iterator() { diff --git a/nms-patches/DimensionManager.patch b/nms-patches/DimensionManager.patch new file mode 100644 index 0000000000..db3ac860a9 --- /dev/null +++ b/nms-patches/DimensionManager.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/server/DimensionManager.java ++++ b/net/minecraft/server/DimensionManager.java +@@ -54,7 +54,7 @@ + } + + public String toString() { +- return a(this).toString(); ++ return this.e + "(" + a(this) + ")"; // CraftBukkit + } + + @Nullable diff --git a/nms-patches/DispenseBehaviorBoat.patch b/nms-patches/DispenseBehaviorBoat.patch new file mode 100644 index 0000000000..41cac8cf6e --- /dev/null +++ b/nms-patches/DispenseBehaviorBoat.patch @@ -0,0 +1,57 @@ +--- a/net/minecraft/server/DispenseBehaviorBoat.java ++++ b/net/minecraft/server/DispenseBehaviorBoat.java +@@ -1,5 +1,10 @@ + package net.minecraft.server; + ++// CraftBukkit start ++import org.bukkit.craftbukkit.inventory.CraftItemStack; ++import org.bukkit.event.block.BlockDispenseEvent; ++// CraftBukkit end ++ + public class DispenseBehaviorBoat extends DispenseBehaviorItem { + + private final DispenseBehaviorItem b = new DispenseBehaviorItem(); +@@ -29,12 +34,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.add(1); ++ return itemstack; ++ } ++ ++ if (!event.getItem().equals(craftItem)) { ++ itemstack.add(1); ++ // Chain to handler for new item ++ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); ++ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); ++ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { ++ idispensebehavior.dispense(isourceblock, eventStack); ++ return itemstack; ++ } ++ } ++ ++ EntityBoat entityboat = new EntityBoat(world, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ()); ++ // CraftBukkit end + + entityboat.setType(this.c); + entityboat.yaw = enumdirection.l(); +- world.addEntity(entityboat); +- itemstack.subtract(1); ++ if (!world.addEntity(entityboat)) itemstack.add(1); // CraftBukkit ++ // itemstack.subtract(1); // CraftBukkit - handled during event processing + return itemstack; + } + diff --git a/nms-patches/DispenseBehaviorItem.patch b/nms-patches/DispenseBehaviorItem.patch index 50eb6ee9e8..cca2373dea 100644 --- a/nms-patches/DispenseBehaviorItem.patch +++ b/nms-patches/DispenseBehaviorItem.patch @@ -1,17 +1,18 @@ --- a/net/minecraft/server/DispenseBehaviorItem.java +++ b/net/minecraft/server/DispenseBehaviorItem.java -@@ -1,5 +1,10 @@ +@@ -1,5 +1,11 @@ package net.minecraft.server; +// CraftBukkit start +import org.bukkit.craftbukkit.inventory.CraftItemStack; ++import org.bukkit.craftbukkit.util.CraftVector; +import org.bukkit.event.block.BlockDispenseEvent; +// CraftBukkit end + public class DispenseBehaviorItem implements IDispenseBehavior { public DispenseBehaviorItem() {} -@@ -17,11 +22,19 @@ +@@ -18,11 +24,19 @@ IPosition iposition = BlockDispenser.a(isourceblock); ItemStack itemstack1 = itemstack.cloneAndSubtract(1); @@ -33,16 +34,16 @@ double d0 = iposition.getX(); double d1 = iposition.getY(); double d2 = iposition.getZ(); -@@ -41,7 +54,41 @@ - entityitem.motX += world.random.nextGaussian() * 0.007499999832361937D * (double) i; - entityitem.motY += world.random.nextGaussian() * 0.007499999832361937D * (double) i; - entityitem.motZ += world.random.nextGaussian() * 0.007499999832361937D * (double) i; +@@ -37,7 +51,39 @@ + double d3 = world.random.nextDouble() * 0.1D + 0.2D; + + entityitem.setMot(world.random.nextGaussian() * 0.007499999832361937D * (double) i + (double) enumdirection.getAdjacentX() * d3, world.random.nextGaussian() * 0.007499999832361937D * (double) i + 0.20000000298023224D, world.random.nextGaussian() * 0.007499999832361937D * (double) i + (double) enumdirection.getAdjacentZ() * d3); + + // CraftBukkit start + org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); + CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack); + -+ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(entityitem.motX, entityitem.motY, entityitem.motZ)); ++ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), CraftVector.toBukkit(entityitem.getMot())); + if (!BlockDispenser.eventFired) { + world.getServer().getPluginManager().callEvent(event); + } @@ -52,9 +53,7 @@ + } + + entityitem.setItemStack(CraftItemStack.asNMSCopy(event.getItem())); -+ entityitem.motX = event.getVelocity().getX(); -+ entityitem.motY = event.getVelocity().getY(); -+ entityitem.motZ = event.getVelocity().getZ(); ++ entityitem.setMot(CraftVector.toNMS(event.getVelocity())); + + if (!event.getItem().getType().equals(craftItem.getType())) { + // Chain to handler for new item diff --git a/nms-patches/DispenseBehaviorProjectile.patch b/nms-patches/DispenseBehaviorProjectile.patch index e3b3fd0569..fb73cdec30 100644 --- a/nms-patches/DispenseBehaviorProjectile.patch +++ b/nms-patches/DispenseBehaviorProjectile.patch @@ -11,7 +11,7 @@ public abstract class DispenseBehaviorProjectile extends DispenseBehaviorItem { public DispenseBehaviorProjectile() {} -@@ -10,9 +15,38 @@ +@@ -11,9 +16,38 @@ EnumDirection enumdirection = (EnumDirection) isourceblock.e().get(BlockDispenser.FACING); IProjectile iprojectile = this.a(world, iposition, itemstack); diff --git a/nms-patches/DispenseBehaviorShulkerBox.patch b/nms-patches/DispenseBehaviorShulkerBox.patch new file mode 100644 index 0000000000..b22060b2ad --- /dev/null +++ b/nms-patches/DispenseBehaviorShulkerBox.patch @@ -0,0 +1,44 @@ +--- a/net/minecraft/server/DispenseBehaviorShulkerBox.java ++++ b/net/minecraft/server/DispenseBehaviorShulkerBox.java +@@ -1,5 +1,10 @@ + package net.minecraft.server; + ++// CraftBukkit start ++import org.bukkit.craftbukkit.inventory.CraftItemStack; ++import org.bukkit.event.block.BlockDispenseEvent; ++// CraftBukkit end ++ + public class DispenseBehaviorShulkerBox extends DispenseBehaviorMaybe { + + public DispenseBehaviorShulkerBox() {} +@@ -14,6 +19,30 @@ + BlockPosition blockposition = isourceblock.getBlockPosition().shift(enumdirection); + EnumDirection enumdirection1 = isourceblock.getWorld().isEmpty(blockposition.down()) ? enumdirection : EnumDirection.UP; + ++ // CraftBukkit start ++ org.bukkit.block.Block bukkitBlock = isourceblock.getWorld().getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); ++ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack); ++ ++ BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockposition.getX(), blockposition.getY(), blockposition.getZ())); ++ if (!BlockDispenser.eventFired) { ++ isourceblock.getWorld().getServer().getPluginManager().callEvent(event); ++ } ++ ++ if (event.isCancelled()) { ++ return itemstack; ++ } ++ ++ if (!event.getItem().equals(craftItem)) { ++ // Chain to handler for new item ++ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); ++ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); ++ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { ++ idispensebehavior.dispense(isourceblock, eventStack); ++ return itemstack; ++ } ++ } ++ // CraftBukkit end ++ + this.dispensed = ((ItemBlock) item).a((BlockActionContext) (new BlockActionContextDirectional(isourceblock.getWorld(), blockposition, enumdirection, itemstack, enumdirection1))) == EnumInteractionResult.SUCCESS; + if (this.dispensed) { + itemstack.subtract(1); diff --git a/nms-patches/DispenserRegistry.patch b/nms-patches/DispenserRegistry.patch index 8e9eb2397b..f64e7ba8e9 100644 --- a/nms-patches/DispenserRegistry.patch +++ b/nms-patches/DispenserRegistry.patch @@ -17,434 +17,29 @@ public class DispenserRegistry { public static final PrintStream a = System.out; -@@ -105,11 +115,39 @@ - EnumDirection enumdirection = (EnumDirection) isourceblock.e().get(BlockDispenser.FACING); - EntityTypes entitytypes = ((ItemMonsterEgg) itemstack.getItem()).b(itemstack.getTag()); - -+ // CraftBukkit start -+ World world = isourceblock.getWorld(); -+ ItemStack itemstack1 = itemstack.cloneAndSubtract(1); -+ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); -+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); -+ -+ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0)); -+ if (!BlockDispenser.eventFired) { -+ world.getServer().getPluginManager().callEvent(event); -+ } -+ -+ if (event.isCancelled()) { -+ itemstack.add(1); -+ return itemstack; -+ } -+ -+ if (!event.getItem().equals(craftItem)) { -+ itemstack.add(1); -+ // Chain to handler for new item -+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); -+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); -+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { -+ idispensebehavior.dispense(isourceblock, eventStack); -+ return itemstack; -+ } -+ } -+ - if (entitytypes != null) { - entitytypes.a(isourceblock.getWorld(), itemstack, (EntityHuman) null, isourceblock.getBlockPosition().shift(enumdirection), enumdirection != EnumDirection.UP, false); +@@ -30,6 +40,69 @@ + ArgumentRegistry.a(); + d(); } - -- itemstack.subtract(1); -+ // itemstack.subtract(1); // Handled during event processing -+ // CraftBukkit end - return itemstack; - } - }; -@@ -127,10 +165,39 @@ - double d0 = isourceblock.getX() + (double) enumdirection.getAdjacentX(); - double d1 = (double) ((float) isourceblock.getBlockPosition().getY() + 0.2F); - double d2 = isourceblock.getZ() + (double) enumdirection.getAdjacentZ(); -- EntityFireworks entityfireworks = new EntityFireworks(isourceblock.getWorld(), d0, d1, d2, itemstack); -+ // CraftBukkit start -+ World world = isourceblock.getWorld(); -+ ItemStack itemstack1 = itemstack.cloneAndSubtract(1); -+ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); -+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); -+ -+ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(d0, d1, d2)); -+ if (!BlockDispenser.eventFired) { -+ world.getServer().getPluginManager().callEvent(event); -+ } -+ -+ if (event.isCancelled()) { -+ itemstack.add(1); -+ return itemstack; -+ } -+ -+ if (!event.getItem().equals(craftItem)) { -+ itemstack.add(1); -+ // Chain to handler for new item -+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); -+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); -+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { -+ idispensebehavior.dispense(isourceblock, eventStack); -+ return itemstack; -+ } -+ } -+ -+ itemstack1 = CraftItemStack.asNMSCopy(event.getItem()); -+ EntityFireworks entityfireworks = new EntityFireworks(isourceblock.getWorld(), event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), itemstack1); - - isourceblock.getWorld().addEntity(entityfireworks); -- itemstack.subtract(1); -+ // itemstack.subtract(1); // Handled during event processing -+ // CraftBukkit end - return itemstack; - } - -@@ -151,8 +218,38 @@ - double d4 = random.nextGaussian() * 0.05D + (double) enumdirection.getAdjacentY(); - double d5 = random.nextGaussian() * 0.05D + (double) enumdirection.getAdjacentZ(); - -- world.addEntity(new EntitySmallFireball(world, d0, d1, d2, d3, d4, d5)); -- itemstack.subtract(1); -+ // CraftBukkit start -+ ItemStack itemstack1 = itemstack.cloneAndSubtract(1); -+ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); -+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); -+ -+ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(d3, d4, d5)); -+ if (!BlockDispenser.eventFired) { -+ world.getServer().getPluginManager().callEvent(event); -+ } -+ -+ if (event.isCancelled()) { -+ itemstack.add(1); -+ return itemstack; -+ } -+ -+ if (!event.getItem().equals(craftItem)) { -+ itemstack.add(1); -+ // Chain to handler for new item -+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); -+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); -+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { -+ idispensebehavior.dispense(isourceblock, eventStack); -+ return itemstack; -+ } -+ } -+ -+ 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(fireball); -+ // itemstack.subtract(1); // Handled during event processing -+ // CraftBukkit end - return itemstack; - } - -@@ -174,9 +271,52 @@ - BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.e().get(BlockDispenser.FACING)); - World world = isourceblock.getWorld(); - -+ // CraftBukkit start -+ int x = blockposition.getX(); -+ int y = blockposition.getY(); -+ int z = blockposition.getZ(); -+ IBlockData iblockdata = world.getType(blockposition); -+ Material material = iblockdata.getMaterial(); -+ if (world.isEmpty(blockposition) || !material.isBuildable() || material.isReplaceable() || ((iblockdata.getBlock() instanceof IFluidContainer) && ((IFluidContainer) iblockdata.getBlock()).canPlace(world, blockposition, iblockdata, itembucket.fluidType))) { -+ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); -+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack); -+ -+ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(x, y, z)); -+ if (!BlockDispenser.eventFired) { -+ world.getServer().getPluginManager().callEvent(event); -+ } -+ -+ if (event.isCancelled()) { -+ return itemstack; -+ } -+ -+ if (!event.getItem().equals(craftItem)) { -+ // Chain to handler for new item -+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); -+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); -+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { -+ idispensebehavior.dispense(isourceblock, eventStack); -+ return itemstack; -+ } -+ } -+ -+ itembucket = (ItemBucket) CraftItemStack.asNMSCopy(event.getItem()).getItem(); -+ } -+ // CraftBukkit end -+ - if (itembucket.a((EntityHuman) null, world, blockposition, (MovingObjectPosition) null)) { - itembucket.a(world, itemstack, blockposition); -- return new ItemStack(Items.BUCKET); -+ // CraftBukkit start - Handle stacked buckets -+ Item item = Items.BUCKET; -+ itemstack.subtract(1); -+ if (itemstack.isEmpty()) { -+ itemstack.setItem(Items.BUCKET); -+ itemstack.setCount(1); -+ } else if (((TileEntityDispenser) isourceblock.getTileEntity()).addItem(new ItemStack(item)) < 0) { -+ this.a.dispense(isourceblock, new ItemStack(item)); -+ } -+ // CraftBukkit end -+ return itemstack; - } else { - return this.a.dispense(isourceblock, itemstack); - } -@@ -199,13 +339,39 @@ - Block block = iblockdata.getBlock(); - - if (block instanceof IFluidSource) { -- FluidType fluidtype = ((IFluidSource) block).removeFluid(world, blockposition, iblockdata); -+ FluidType fluidtype = ((IFluidSource) block).removeFluid(DummyGeneratorAccess.INSTANCE, blockposition, iblockdata); // CraftBukkit - - if (!(fluidtype instanceof FluidTypeFlowing)) { - return super.a(isourceblock, itemstack); - } else { - Item item = fluidtype.b(); - -+ // CraftBukkit start -+ org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); -+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack); -+ -+ BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockposition.getX(), blockposition.getY(), blockposition.getZ())); -+ if (!BlockDispenser.eventFired) { -+ world.getServer().getPluginManager().callEvent(event); -+ } -+ -+ if (event.isCancelled()) { -+ return itemstack; -+ } -+ -+ if (!event.getItem().equals(craftItem)) { -+ // Chain to handler for new item -+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); -+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); -+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { -+ idispensebehavior.dispense(isourceblock, eventStack); -+ return itemstack; -+ } -+ } -+ -+ fluidtype = ((IFluidSource) block).removeFluid(world, blockposition, iblockdata); // From above -+ // CraftBukkit end -+ - itemstack.subtract(1); - if (itemstack.isEmpty()) { - return new ItemStack(item); -@@ -226,11 +392,39 @@ - protected ItemStack a(ISourceBlock isourceblock, ItemStack itemstack) { - World world = isourceblock.getWorld(); - -+ // CraftBukkit start -+ org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); -+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack); -+ -+ BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0)); -+ if (!BlockDispenser.eventFired) { -+ world.getServer().getPluginManager().callEvent(event); -+ } -+ -+ if (event.isCancelled()) { -+ return itemstack; -+ } -+ -+ if (!event.getItem().equals(craftItem)) { -+ // Chain to handler for new item -+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); -+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); -+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { -+ idispensebehavior.dispense(isourceblock, eventStack); -+ return itemstack; -+ } -+ } -+ // CraftBukkit end -+ - this.a = true; - BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.e().get(BlockDispenser.FACING)); - - if (ItemFlintAndSteel.a((GeneratorAccess) world, blockposition)) { -- world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData()); -+ // CraftBukkit start - Ignition by dispensing flint and steel -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition, isourceblock.getBlockPosition()).isCancelled()) { -+ world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData()); -+ } -+ // CraftBukkit end - } else { - Block block = world.getType(blockposition).getBlock(); - -@@ -254,12 +448,57 @@ - this.a = true; - World world = isourceblock.getWorld(); - BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.e().get(BlockDispenser.FACING)); -+ // CraftBukkit start -+ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); -+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack); -+ -+ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0)); -+ if (!BlockDispenser.eventFired) { -+ world.getServer().getPluginManager().callEvent(event); -+ } -+ -+ if (event.isCancelled()) { -+ return itemstack; -+ } -+ -+ if (!event.getItem().equals(craftItem)) { -+ // Chain to handler for new item -+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); -+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); -+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { -+ idispensebehavior.dispense(isourceblock, eventStack); -+ return itemstack; -+ } -+ } -+ -+ world.captureTreeGeneration = true; -+ // CraftBukkit end - - if (!ItemBoneMeal.a(itemstack, world, blockposition) && !ItemBoneMeal.a(itemstack, world, blockposition, (EnumDirection) null)) { - this.a = false; - } else if (!world.isClientSide) { - world.triggerEffect(2005, blockposition, 0); - } -+ // CraftBukkit start -+ world.captureTreeGeneration = false; -+ if (world.capturedBlockStates.size() > 0) { -+ TreeType treeType = BlockSapling.treeType; -+ BlockSapling.treeType = null; -+ Location location = new Location(world.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ()); -+ List blocks = (List) world.capturedBlockStates.clone(); -+ world.capturedBlockStates.clear(); -+ StructureGrowEvent structureEvent = null; -+ if (treeType != null) { -+ structureEvent = new StructureGrowEvent(location, treeType, false, null, blocks); -+ org.bukkit.Bukkit.getPluginManager().callEvent(structureEvent); -+ } -+ if (structureEvent == null || !structureEvent.isCancelled()) { -+ for (org.bukkit.block.BlockState blockstate : blocks) { -+ blockstate.update(true); -+ } -+ } -+ } -+ // CraftBukkit end - - return itemstack; - } -@@ -268,11 +507,40 @@ - protected ItemStack a(ISourceBlock isourceblock, ItemStack itemstack) { - World world = isourceblock.getWorld(); - BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.e().get(BlockDispenser.FACING)); -- EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(world, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, (EntityLiving) null); -+ // EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(world, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, (EntityLiving) null); -+ -+ // 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((double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D)); -+ if (!BlockDispenser.eventFired) { -+ world.getServer().getPluginManager().callEvent(event); -+ } -+ -+ if (event.isCancelled()) { -+ itemstack.add(1); -+ return itemstack; -+ } -+ -+ if (!event.getItem().equals(craftItem)) { -+ itemstack.add(1); -+ // Chain to handler for new item -+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); -+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); -+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { -+ idispensebehavior.dispense(isourceblock, eventStack); -+ return itemstack; -+ } -+ } -+ -+ EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(world, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), (EntityLiving) null); -+ // CraftBukkit end - - world.addEntity(entitytntprimed); - world.a((EntityHuman) null, entitytntprimed.locX, entitytntprimed.locY, entitytntprimed.locZ, SoundEffects.ENTITY_TNT_PRIMED, SoundCategory.BLOCKS, 1.0F, 1.0F); -- itemstack.subtract(1); -+ // itemstack.subtract(1); // CraftBukkit - handled above - return itemstack; - } - })); -@@ -294,6 +562,30 @@ - EnumDirection enumdirection = (EnumDirection) isourceblock.e().get(BlockDispenser.FACING); - BlockPosition blockposition = isourceblock.getBlockPosition().shift(enumdirection); - -+ // CraftBukkit start -+ org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); -+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack); -+ -+ BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockposition.getX(), blockposition.getY(), blockposition.getZ())); -+ if (!BlockDispenser.eventFired) { -+ world.getServer().getPluginManager().callEvent(event); -+ } -+ -+ if (event.isCancelled()) { -+ return itemstack; -+ } -+ -+ if (!event.getItem().equals(craftItem)) { -+ // Chain to handler for new item -+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); -+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); -+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { -+ idispensebehavior.dispense(isourceblock, eventStack); -+ return itemstack; -+ } -+ } -+ // CraftBukkit end -+ - this.a = true; - if (world.isEmpty(blockposition) && BlockWitherSkull.b(world, blockposition, itemstack)) { - world.setTypeAndData(blockposition, (IBlockData) Blocks.WITHER_SKELETON_SKULL.getBlockData().set(BlockSkull.a, enumdirection.k() == EnumDirection.EnumAxis.Y ? 0 : enumdirection.opposite().get2DRotationValue() * 4), 3); -@@ -317,6 +609,30 @@ - BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.e().get(BlockDispenser.FACING)); - BlockPumpkinCarved blockpumpkincarved = (BlockPumpkinCarved) Blocks.CARVED_PUMPKIN; - -+ // CraftBukkit start -+ org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); -+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack); -+ -+ BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockposition.getX(), blockposition.getY(), blockposition.getZ())); -+ if (!BlockDispenser.eventFired) { -+ world.getServer().getPluginManager().callEvent(event); -+ } -+ -+ if (event.isCancelled()) { -+ return itemstack; -+ } -+ -+ if (!event.getItem().equals(craftItem)) { -+ // Chain to handler for new item -+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); -+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); -+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { -+ idispensebehavior.dispense(isourceblock, eventStack); -+ return itemstack; -+ } -+ } -+ // CraftBukkit end -+ - this.a = true; - if (world.isEmpty(blockposition) && blockpumpkincarved.a((IWorldReader) world, blockposition)) { - if (!world.isClientSide) { -@@ -384,6 +700,51 @@ - } - - d(); + // CraftBukkit start - easier than fixing the decompile ++ DataConverterFlattenData.a(1008, "{Name:'minecraft:oak_sign',Properties:{rotation:'0'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'0'}}"); ++ DataConverterFlattenData.a(1009, "{Name:'minecraft:oak_sign',Properties:{rotation:'1'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'1'}}"); ++ DataConverterFlattenData.a(1010, "{Name:'minecraft:oak_sign',Properties:{rotation:'2'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'2'}}"); ++ DataConverterFlattenData.a(1011, "{Name:'minecraft:oak_sign',Properties:{rotation:'3'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'3'}}"); ++ DataConverterFlattenData.a(1012, "{Name:'minecraft:oak_sign',Properties:{rotation:'4'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'4'}}"); ++ DataConverterFlattenData.a(1013, "{Name:'minecraft:oak_sign',Properties:{rotation:'5'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'5'}}"); ++ DataConverterFlattenData.a(1014, "{Name:'minecraft:oak_sign',Properties:{rotation:'6'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'6'}}"); ++ DataConverterFlattenData.a(1015, "{Name:'minecraft:oak_sign',Properties:{rotation:'7'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'7'}}"); ++ DataConverterFlattenData.a(1016, "{Name:'minecraft:oak_sign',Properties:{rotation:'8'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'8'}}"); ++ DataConverterFlattenData.a(1017, "{Name:'minecraft:oak_sign',Properties:{rotation:'9'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'9'}}"); ++ DataConverterFlattenData.a(1018, "{Name:'minecraft:oak_sign',Properties:{rotation:'10'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'10'}}"); ++ DataConverterFlattenData.a(1019, "{Name:'minecraft:oak_sign',Properties:{rotation:'11'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'11'}}"); ++ DataConverterFlattenData.a(1020, "{Name:'minecraft:oak_sign',Properties:{rotation:'12'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'12'}}"); ++ DataConverterFlattenData.a(1021, "{Name:'minecraft:oak_sign',Properties:{rotation:'13'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'13'}}"); ++ DataConverterFlattenData.a(1022, "{Name:'minecraft:oak_sign',Properties:{rotation:'14'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'14'}}"); ++ DataConverterFlattenData.a(1023, "{Name:'minecraft:oak_sign',Properties:{rotation:'15'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'15'}}"); ++ DataConverterMaterialId.ID_MAPPING.put(323, "minecraft:oak_sign"); ++ + DataConverterFlattenData.a(1440, "{Name:\'minecraft:portal\',Properties:{axis:\'x\'}}", new String[]{"{Name:\'minecraft:portal\',Properties:{axis:\'x\'}}"}); + + DataConverterMaterialId.ID_MAPPING.put(409, "minecraft:prismarine_shard"); @@ -492,78 +87,3 @@ } } } -@@ -481,6 +842,30 @@ - BlockPosition blockposition = isourceblock.getBlockPosition().shift(enumdirection); - EnumDirection enumdirection1 = isourceblock.getWorld().isEmpty(blockposition.down()) ? enumdirection : EnumDirection.UP; - -+ // CraftBukkit start -+ org.bukkit.block.Block bukkitBlock = isourceblock.getWorld().getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); -+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack); -+ -+ BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockposition.getX(), blockposition.getY(), blockposition.getZ())); -+ if (!BlockDispenser.eventFired) { -+ isourceblock.getWorld().getServer().getPluginManager().callEvent(event); -+ } -+ -+ if (event.isCancelled()) { -+ return itemstack; -+ } -+ -+ if (!event.getItem().equals(craftItem)) { -+ // Chain to handler for new item -+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); -+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); -+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { -+ idispensebehavior.dispense(isourceblock, eventStack); -+ return itemstack; -+ } -+ } -+ // CraftBukkit end -+ - this.a = ((ItemBlock) item).a((BlockActionContext) (new DispenserRegistry.b(isourceblock.getWorld(), blockposition, enumdirection, itemstack, enumdirection1))) == EnumInteractionResult.SUCCESS; - if (this.a) { - itemstack.subtract(1); -@@ -530,12 +915,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.add(1); -+ return itemstack; -+ } -+ -+ if (!event.getItem().equals(craftItem)) { -+ itemstack.add(1); -+ // Chain to handler for new item -+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); -+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); -+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { -+ idispensebehavior.dispense(isourceblock, eventStack); -+ return itemstack; -+ } -+ } -+ -+ EntityBoat entityboat = new EntityBoat(world, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ()); -+ // CraftBukkit end - - entityboat.setType(this.b); - entityboat.yaw = enumdirection.l(); -- world.addEntity(entityboat); -- itemstack.subtract(1); -+ if (!world.addEntity(entityboat)) itemstack.add(1); // CraftBukkit -+ // itemstack.subtract(1); // CraftBukkit - handled during event processing - return itemstack; - } - diff --git a/nms-patches/Enchantment.patch b/nms-patches/Enchantment.patch deleted file mode 100644 index 77c69ed6a2..0000000000 --- a/nms-patches/Enchantment.patch +++ /dev/null @@ -1,19 +0,0 @@ ---- a/net/minecraft/server/Enchantment.java -+++ b/net/minecraft/server/Enchantment.java -@@ -153,10 +153,15 @@ - a("channeling", new EnchantmentTridentChanneling(Enchantment.Rarity.VERY_RARE, new EnumItemSlot[] { EnumItemSlot.MAINHAND})); - a("mending", new EnchantmentMending(Enchantment.Rarity.RARE, EnumItemSlot.values())); - a("vanishing_curse", new EnchantmentVanishing(Enchantment.Rarity.VERY_RARE, EnumItemSlot.values())); -+ // CraftBukkit start -+ for (Object enchantment : IRegistry.ENCHANTMENT) { -+ org.bukkit.enchantments.Enchantment.registerEnchantment(new org.bukkit.craftbukkit.enchantments.CraftEnchantment((Enchantment) enchantment)); -+ } -+ // CraftBukkit end - } - - private static void a(String s, Enchantment enchantment) { -- IRegistry.ENCHANTMENT.a(new MinecraftKey(s), (Object) enchantment); -+ IRegistry.ENCHANTMENT.a(new MinecraftKey(s), enchantment); // CraftBukkit - decompile error - } - - public static enum Rarity { diff --git a/nms-patches/EnchantmentFrostWalker.patch b/nms-patches/EnchantmentFrostWalker.patch index ea98ad6a2a..3940ba3fb7 100644 --- a/nms-patches/EnchantmentFrostWalker.patch +++ b/nms-patches/EnchantmentFrostWalker.patch @@ -11,15 +11,15 @@ public class EnchantmentFrostWalker extends Enchantment { -@@ -42,8 +46,11 @@ - IBlockData iblockdata2 = world.getType(blockposition_mutableblockposition1); +@@ -41,8 +45,11 @@ + IBlockData iblockdata2 = world.getType(blockposition1); - if (iblockdata2.getMaterial() == Material.WATER && (Integer) iblockdata2.get(BlockFluids.LEVEL) == 0 && iblockdata.canPlace(world, blockposition_mutableblockposition1) && world.a(iblockdata, (BlockPosition) blockposition_mutableblockposition1)) { -- world.setTypeUpdate(blockposition_mutableblockposition1, iblockdata); -- world.getBlockTickList().a(blockposition_mutableblockposition1.h(), Blocks.FROSTED_ICE, MathHelper.nextInt(entityliving.getRandom(), 60, 120)); + if (iblockdata2.getMaterial() == Material.WATER && (Integer) iblockdata2.get(BlockFluids.LEVEL) == 0 && iblockdata.canPlace(world, blockposition1) && world.a(iblockdata, blockposition1, VoxelShapeCollision.a())) { +- world.setTypeUpdate(blockposition1, iblockdata); +- world.getBlockTickList().a(blockposition1.immutableCopy(), Blocks.FROSTED_ICE, MathHelper.nextInt(entityliving.getRandom(), 60, 120)); + // CraftBukkit Start - Call EntityBlockFormEvent for Frost Walker -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition_mutableblockposition1, iblockdata, entityliving)) { -+ world.getBlockTickList().a(blockposition_mutableblockposition1.h(), Blocks.FROSTED_ICE, MathHelper.nextInt(entityliving.getRandom(), 60, 120)); ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition1, iblockdata, entityliving)) { ++ world.getBlockTickList().a(blockposition1.immutableCopy(), Blocks.FROSTED_ICE, MathHelper.nextInt(entityliving.getRandom(), 60, 120)); + } + // CraftBukkit End } diff --git a/nms-patches/EnchantmentThorns.patch b/nms-patches/EnchantmentThorns.patch index 8f997f9e5b..258ac31a58 100644 --- a/nms-patches/EnchantmentThorns.patch +++ b/nms-patches/EnchantmentThorns.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/EnchantmentThorns.java +++ b/net/minecraft/server/EnchantmentThorns.java -@@ -28,7 +28,7 @@ +@@ -29,7 +29,7 @@ Random random = entityliving.getRandom(); - ItemStack itemstack = EnchantmentManager.b(Enchantments.THORNS, entityliving); + Entry entry = EnchantmentManager.b(Enchantments.THORNS, entityliving); - if (a(i, random)) { + if (entity != null && a(i, random)) { // CraftBukkit diff --git a/nms-patches/EnchantmentWeaponDamage.patch b/nms-patches/EnchantmentWeaponDamage.patch index c6cfb66e39..d385dd4999 100644 --- a/nms-patches/EnchantmentWeaponDamage.patch +++ b/nms-patches/EnchantmentWeaponDamage.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/EnchantmentWeaponDamage.java +++ b/net/minecraft/server/EnchantmentWeaponDamage.java -@@ -44,7 +44,7 @@ +@@ -46,7 +46,7 @@ if (this.a == 2 && entityliving1.getMonsterType() == EnumMonsterType.ARTHROPOD) { int j = 20 + entityliving.getRandom().nextInt(10 * i); diff --git a/nms-patches/Enchantments.patch b/nms-patches/Enchantments.patch new file mode 100644 index 0000000000..98d97bc9f0 --- /dev/null +++ b/nms-patches/Enchantments.patch @@ -0,0 +1,19 @@ +--- a/net/minecraft/server/Enchantments.java ++++ b/net/minecraft/server/Enchantments.java +@@ -41,7 +41,15 @@ + public static final Enchantment MENDING = a("mending", new EnchantmentMending(Enchantment.Rarity.RARE, EnumItemSlot.values())); + public static final Enchantment VANISHING_CURSE = a("vanishing_curse", new EnchantmentVanishing(Enchantment.Rarity.VERY_RARE, EnumItemSlot.values())); + ++ // CraftBukkit start ++ static { ++ for (Object enchantment : IRegistry.ENCHANTMENT) { ++ org.bukkit.enchantments.Enchantment.registerEnchantment(new org.bukkit.craftbukkit.enchantments.CraftEnchantment((Enchantment) enchantment)); ++ } ++ } ++ // CraftBukkit end ++ + private static Enchantment a(String s, Enchantment enchantment) { +- return (Enchantment) IRegistry.a(IRegistry.ENCHANTMENT, s, (Object) enchantment); ++ return (Enchantment) IRegistry.a(IRegistry.ENCHANTMENT, s, enchantment); // CraftBukkit - decompile error + } + } diff --git a/nms-patches/Entity.patch b/nms-patches/Entity.patch index 187d89b50e..04de1973c5 100644 --- a/nms-patches/Entity.patch +++ b/nms-patches/Entity.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/Entity.java +++ b/net/minecraft/server/Entity.java -@@ -17,8 +17,55 @@ +@@ -21,8 +21,54 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -8,7 +8,6 @@ +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Server; -+import org.bukkit.TravelAgent; +import org.bukkit.block.BlockFace; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Hanging; @@ -53,13 +52,13 @@ + } + // CraftBukkit end + - protected static final Logger i = LogManager.getLogger(); - private static final List a = Collections.emptyList(); - private static final AxisAlignedBB b = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D); -@@ -105,6 +152,16 @@ - private boolean aK; - private final double[] aL; - private long aM; + protected static final Logger LOGGER = LogManager.getLogger(); + private static final AtomicInteger entityCount = new AtomicInteger(); + private static final List c = Collections.emptyList(); +@@ -107,6 +153,16 @@ + private long aH; + private EntitySize size; + private float headHeight; + // CraftBukkit start + public boolean persist = true; + public boolean valid; @@ -72,8 +71,8 @@ + // CraftBukkit end public Entity(EntityTypes entitytypes, World world) { - this.id = Entity.entityCount++; -@@ -210,6 +267,33 @@ + this.id = Entity.entityCount.incrementAndGet(); +@@ -213,6 +269,33 @@ } protected void setYawPitch(float f, float f1) { @@ -107,87 +106,43 @@ this.yaw = f % 360.0F; this.pitch = f1 % 360.0F; } -@@ -222,6 +306,7 @@ - float f1 = this.length; +@@ -225,6 +308,7 @@ + float f1 = this.size.height; this.a(new AxisAlignedBB(d0 - (double) f, d1, d2 - (double) f, d0 + (double) f, d1 + (double) f1, d2 + (double) f)); -+ if (valid) world.entityJoinedWorld(this, false); // CraftBukkit ++ if (valid) ((WorldServer) world).chunkCheck(this); // CraftBukkit } public void tick() { -@@ -232,6 +317,51 @@ - this.W(); +@@ -235,6 +319,15 @@ + this.entityBaseTick(); } + // CraftBukkit start + public void postTick() { + // No clean way to break out of ticking once the entity has been copied to a new world, so instead we move the portalling later in the tick cycle -+ if (!this.world.isClientSide && this.world instanceof WorldServer) { -+ this.world.methodProfiler.enter("portal"); -+ if (this.an) { -+ MinecraftServer minecraftserver = this.world.getMinecraftServer(); -+ -+ if (true || minecraftserver.getAllowNether()) { // CraftBukkit -+ if (!this.isPassenger()) { -+ int i = this.X(); -+ -+ if (this.ao++ >= i) { -+ this.ao = i; -+ this.portalCooldown = this.aQ(); -+ DimensionManager dimensionmanager; -+ -+ if (this.world.worldProvider.getDimensionManager() == DimensionManager.NETHER) { -+ dimensionmanager = DimensionManager.OVERWORLD; -+ } else { -+ dimensionmanager = DimensionManager.NETHER; -+ } -+ -+ this.a(dimensionmanager); -+ } -+ } -+ -+ this.an = false; -+ } -+ } else { -+ if (this.ao > 0) { -+ this.ao -= 4; -+ } -+ -+ if (this.ao < 0) { -+ this.ao = 0; -+ } -+ } -+ -+ this.E(); -+ this.world.methodProfiler.exit(); ++ if (!(this instanceof EntityPlayer)) { ++ this.doPortalTick(); + } + } + // CraftBukkit end + - public void W() { - this.world.methodProfiler.enter("entityBaseTick"); + public void entityBaseTick() { + this.world.getMethodProfiler().enter("entityBaseTick"); if (this.isPassenger() && this.getVehicle().dead) { -@@ -248,6 +378,8 @@ +@@ -251,7 +344,7 @@ this.lastZ = this.locZ; this.lastPitch = this.pitch; this.lastYaw = this.yaw; -+ // Moved up to postTick -+ /* - if (!this.world.isClientSide && this.world instanceof WorldServer) { - this.world.methodProfiler.enter("portal"); - if (this.an) { -@@ -287,6 +419,7 @@ - this.E(); - this.world.methodProfiler.exit(); - } -+ */ - - this.av(); - this.r(); -@@ -337,12 +470,44 @@ +- this.doPortalTick(); ++ if (this instanceof EntityPlayer) this.doPortalTick(); // CraftBukkit - // Moved up to postTick + this.az(); + this.m(); + if (this.world.isClientSide) { +@@ -301,12 +394,44 @@ protected void burnFromLava() { - if (!this.fireProof) { + if (!this.isFireProof()) { - this.setOnFire(15); + // CraftBukkit start - Fallen in lava TODO: this event spams! + if (this instanceof EntityLiving && fireTicks <= 0) { @@ -230,25 +185,7 @@ int j = i * 20; if (this instanceof EntityLiving) { -@@ -503,7 +668,7 @@ - } - } - -- boolean flag = this.onGround || d1 != d1 && d1 < 0.0D; -+ boolean flag = this.onGround || d1 != d8 && d1 < 0.0D; // CraftBukkit - decompile error - double d11; - - if (this.Q > 0.0F && flag && (d7 != d0 || d9 != d2)) { -@@ -590,7 +755,7 @@ - this.world.methodProfiler.enter("rest"); - this.recalcPosition(); - this.positionChanged = d7 != d0 || d9 != d2; -- this.C = d1 != d1; -+ this.C = d1 != d8; // CraftBukkit - decompile error - this.onGround = this.C && d8 < 0.0D; - this.D = this.positionChanged || this.C; - int k = MathHelper.floor(this.locX); -@@ -625,6 +790,28 @@ +@@ -402,6 +527,28 @@ block1.a((IBlockAccess) this.world, this); } @@ -257,13 +194,13 @@ + Vehicle vehicle = (Vehicle) this.getBukkitEntity(); + org.bukkit.block.Block bl = this.world.getWorld().getBlockAt(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ)); + -+ if (d7 > d0) { ++ if (vec3d1.x > vec3d.x) { + bl = bl.getRelative(BlockFace.EAST); -+ } else if (d7 < d0) { ++ } else if (vec3d.x < vec3d.x) { + bl = bl.getRelative(BlockFace.WEST); -+ } else if (d9 > d2) { ++ } else if (vec3d1.z > vec3d.z) { + bl = bl.getRelative(BlockFace.SOUTH); -+ } else if (d9 < d2) { ++ } else if (vec3d1.z < vec3d.z) { + bl = bl.getRelative(BlockFace.NORTH); + } + @@ -275,10 +212,10 @@ + // CraftBukkit end + if (this.playStepSound() && (!this.onGround || !this.isSneaking() || !(this instanceof EntityHuman)) && !this.isPassenger()) { - double d22 = this.locX - d4; - double d23 = this.locY - d5; -@@ -676,7 +863,14 @@ - if (!flag1) { + double d0 = vec3d1.x; + double d1 = vec3d1.y; +@@ -455,7 +602,14 @@ + if (!flag) { ++this.fireTicks; if (this.fireTicks == 0) { - this.setOnFire(8); @@ -293,24 +230,33 @@ } } -@@ -704,6 +898,7 @@ +@@ -566,7 +720,7 @@ + VoxelShape voxelshape = this.world.getWorldBorder().a(); + Stream stream = VoxelShapes.c(voxelshape, VoxelShapes.a(axisalignedbb.shrink(1.0E-7D)), OperatorBoolean.AND) ? Stream.empty() : Stream.of(voxelshape); + AxisAlignedBB axisalignedbb1 = axisalignedbb.a(vec3d).g(1.0E-7D); +- Stream stream1 = this.world.getEntities(this, axisalignedbb1).stream().filter((entity) -> { ++ Stream stream1 = this.world.getEntities(this, axisalignedbb1).stream().filter((entity) -> { // CraftBukkit - decompile error + return !this.x(entity); + }).flatMap((entity) -> { + return Stream.of(entity.ap(), this.j(entity)); +@@ -650,6 +804,7 @@ this.locX = (axisalignedbb.minX + axisalignedbb.maxX) / 2.0D; this.locY = axisalignedbb.minY; this.locZ = (axisalignedbb.minZ + axisalignedbb.maxZ) / 2.0D; -+ if (valid) world.entityJoinedWorld(this, false); // CraftBukkit ++ if (valid) ((WorldServer) world).chunkCheck(this); // CraftBukkit } - protected SoundEffect ad() { -@@ -874,7 +1069,7 @@ + protected SoundEffect getSoundSwim() { +@@ -821,7 +976,7 @@ return null; } - protected void burn(int i) { + protected void burn(float i) { // CraftBukkit - int -> float - if (!this.fireProof) { + if (!this.isFireProof()) { this.damageEntity(DamageSource.FIRE, (float) i); } -@@ -1093,6 +1288,13 @@ +@@ -1054,6 +1209,13 @@ } public void spawnIn(World world) { @@ -324,7 +270,7 @@ this.world = world; } -@@ -1118,6 +1320,7 @@ +@@ -1079,6 +1241,7 @@ this.lastYaw -= 360.0F; } @@ -332,7 +278,7 @@ this.setPosition(this.locX, this.locY, this.locZ); this.setYawPitch(f, f1); } -@@ -1300,7 +1503,7 @@ +@@ -1247,7 +1410,7 @@ public boolean c(NBTTagCompound nbttagcompound) { String s = this.getSaveID(); @@ -341,10 +287,10 @@ nbttagcompound.setString("id", s); this.save(nbttagcompound); return true; -@@ -1317,6 +1520,18 @@ - try { - nbttagcompound.set("Pos", this.a(this.locX, this.locY, this.locZ)); - nbttagcompound.set("Motion", this.a(this.motX, this.motY, this.motZ)); +@@ -1266,6 +1429,18 @@ + Vec3D vec3d = this.getMot(); + + nbttagcompound.set("Motion", this.a(vec3d.x, vec3d.y, vec3d.z)); + + // CraftBukkit start - Checking for NaN pitch/yaw and resetting to zero + // TODO: make sure this is the best way to address this. @@ -360,40 +306,24 @@ nbttagcompound.set("Rotation", this.a(this.yaw, this.pitch)); nbttagcompound.setFloat("FallDistance", this.fallDistance); nbttagcompound.setShort("Fire", (short) this.fireTicks); -@@ -1326,6 +1541,12 @@ +@@ -1275,6 +1450,12 @@ nbttagcompound.setBoolean("Invulnerable", this.invulnerable); nbttagcompound.setInt("PortalCooldown", this.portalCooldown); 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.setLong("WorldUUIDLeast", ((WorldServer) this.world).getDataManager().getUUID().getLeastSignificantBits()); ++ nbttagcompound.setLong("WorldUUIDMost", ((WorldServer) this.world).getDataManager().getUUID().getMostSignificantBits()); + nbttagcompound.setInt("Bukkit.updateLevel", CURRENT_LEVEL); + // CraftBukkit end IChatBaseComponent ichatbasecomponent = this.getCustomName(); if (ichatbasecomponent != null) { -@@ -1402,6 +1623,8 @@ - this.motX = nbttaglist1.k(0); - this.motY = nbttaglist1.k(1); - this.motZ = nbttaglist1.k(2); +@@ -1415,6 +1596,42 @@ + } else { + throw new IllegalStateException("Entity has invalid position"); + } + -+ /* CraftBukkit start - Moved section down - if (Math.abs(this.motX) > 10.0D) { - this.motX = 0.0D; - } -@@ -1413,6 +1636,7 @@ - if (Math.abs(this.motZ) > 10.0D) { - this.motZ = 0.0D; - } -+ // CraftBukkit end */ - - this.locX = nbttaglist.k(0); - this.locY = nbttaglist.k(1); -@@ -1469,6 +1693,56 @@ - this.setPosition(this.locX, this.locY, this.locZ); - } - + // CraftBukkit start + if (this instanceof EntityLiving) { + EntityLiving entity = (EntityLiving) this; @@ -401,26 +331,11 @@ + // Reset the persistence for tamed animals + if (entity instanceof EntityTameableAnimal && !isLevelAtLeast(nbttagcompound, 2) && !nbttagcompound.getBoolean("PersistenceRequired")) { + EntityInsentient entityinsentient = (EntityInsentient) entity; -+ entityinsentient.persistent = !entityinsentient.isTypeNotPersistent(); ++ entityinsentient.persistent = !entityinsentient.isTypeNotPersistent(0); + } + } + // CraftBukkit end + -+ // CraftBukkit start -+ double limit = getBukkitEntity() instanceof Vehicle ? 100.0D : 10.0D; -+ if (Math.abs(this.motX) > limit) { -+ this.motX = 0.0D; -+ } -+ -+ if (Math.abs(this.motY) > limit) { -+ this.motY = 0.0D; -+ } -+ -+ if (Math.abs(this.motZ) > limit) { -+ this.motZ = 0.0D; -+ } -+ // CraftBukkit end -+ + // CraftBukkit start - Reset world + if (this instanceof EntityPlayer) { + Server server = Bukkit.getServer(); @@ -447,8 +362,8 @@ } catch (Throwable throwable) { CrashReport crashreport = CrashReport.a(throwable, "Loading entity NBT"); CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Entity being loaded"); -@@ -1542,9 +1816,22 @@ - if (itemstack.isEmpty()) { +@@ -1490,9 +1707,22 @@ + } else if (this.world.isClientSide) { return null; } else { + // CraftBukkit start - Capture drops for death event @@ -459,7 +374,7 @@ + // CraftBukkit end EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY + (double) f, this.locZ, itemstack); - entityitem.n(); + entityitem.defaultPickupDelay(); + // CraftBukkit start + EntityDropItemEvent event = new EntityDropItemEvent(this.getBukkitEntity(), (org.bukkit.entity.Item) entityitem.getBukkitEntity()); + Bukkit.getPluginManager().callEvent(event); @@ -470,7 +385,7 @@ this.world.addEntity(entityitem); return entityitem; } -@@ -1656,7 +1943,7 @@ +@@ -1596,7 +1826,7 @@ } this.vehicle = entity; @@ -479,7 +394,7 @@ return true; } } -@@ -1677,15 +1964,33 @@ +@@ -1621,15 +1851,36 @@ Entity entity = this.vehicle; this.vehicle = null; @@ -499,12 +414,15 @@ + + CraftEntity craft = (CraftEntity) entity.getBukkitEntity().getVehicle(); + Entity orig = craft == null ? null : craft.getHandle(); -+ if (getBukkitEntity() instanceof Vehicle && entity.getBukkitEntity() instanceof LivingEntity && entity.world.isChunkLoaded((int) entity.locX >> 4, (int) entity.locZ >> 4, false)) { // Boolean not used ++ if (getBukkitEntity() instanceof Vehicle && entity.getBukkitEntity() instanceof LivingEntity && entity.world.isChunkLoaded((int) entity.locX >> 4, (int) entity.locZ >> 4)) { + VehicleEnterEvent event = new VehicleEnterEvent( + (Vehicle) getBukkitEntity(), + entity.getBukkitEntity() + ); -+ Bukkit.getPluginManager().callEvent(event); ++ // Suppress during worldgen ++ if (this.valid) { ++ Bukkit.getPluginManager().callEvent(event); ++ } + CraftEntity craftn = (CraftEntity) entity.getBukkitEntity().getVehicle(); + Entity n = craftn == null ? null : craftn.getHandle(); + if (event.isCancelled() || n != orig) { @@ -512,10 +430,10 @@ + } + } + // CraftBukkit end - if (!this.world.isClientSide && entity instanceof EntityHuman && !(this.bO() instanceof EntityHuman)) { + if (!this.world.isClientSide && entity instanceof EntityHuman && !(this.getRidingPassenger() instanceof EntityHuman)) { this.passengers.add(0, entity); } else { -@@ -1693,15 +1998,33 @@ +@@ -1637,15 +1888,33 @@ } } @@ -544,13 +462,22 @@ + } + // CraftBukkit end this.passengers.remove(entity); - entity.k = 60; + entity.j = 60; } + return true; // CraftBukkit } protected boolean q(Entity entity) { -@@ -1798,6 +2121,13 @@ +@@ -1688,7 +1957,7 @@ + int i = this.ab(); + + if (this.ai) { +- if (this.world.getMinecraftServer().getAllowNether() && !this.isPassenger() && this.aj++ >= i) { ++ if ((true || this.world.getMinecraftServer().getAllowNether()) && !this.isPassenger() && this.aj++ >= i) { // CraftBukkit + this.world.getMethodProfiler().enter("portal"); + this.aj = i; + this.portalCooldown = this.aW(); +@@ -1772,6 +2041,13 @@ } public void setSwimming(boolean flag) { @@ -564,18 +491,21 @@ this.setFlag(4, flag); } -@@ -1858,16 +2188,53 @@ +@@ -1832,16 +2108,56 @@ } public void setAirTicks(int i) { -- this.datawatcher.set(Entity.aD, i); +- this.datawatcher.set(Entity.AIR_TICKS, i); + // CraftBukkit start + EntityAirChangeEvent event = new EntityAirChangeEvent(this.getBukkitEntity(), i); -+ event.getEntity().getServer().getPluginManager().callEvent(event); ++ // Suppress during worldgen ++ if (this.valid) { ++ event.getEntity().getServer().getPluginManager().callEvent(event); ++ } + if (event.isCancelled()) { + return; + } -+ this.datawatcher.set(Entity.aD, event.getAmount()); ++ this.datawatcher.set(Entity.AIR_TICKS, event.getAmount()); + // CraftBukkit end } @@ -596,9 +526,8 @@ + this.setOnFire(entityCombustEvent.getDuration(), false); + } + // CraftBukkit end - } - -- this.damageEntity(DamageSource.LIGHTNING, 5.0F); ++ } ++ + // CraftBukkit start + if (thisBukkitEntity instanceof Hanging) { + HangingBreakByEntityEvent hangingEvent = new HangingBreakByEntityEvent((Hanging) thisBukkitEntity, stormBukkitEntity); @@ -607,9 +536,10 @@ + if (hangingEvent.isCancelled()) { + return; + } -+ } -+ -+ if (this.fireProof) { + } + +- this.damageEntity(DamageSource.LIGHTNING, 5.0F); ++ if (this.isFireProof()) { + return; + } + CraftEventFactory.entityDamage = entitylightning; @@ -621,114 +551,73 @@ } public void j(boolean flag) { -@@ -2034,19 +2401,72 @@ - if (!this.world.isClientSide && !this.dead) { - this.world.methodProfiler.enter("changeDimension"); - MinecraftServer minecraftserver = this.bK(); -- DimensionManager dimensionmanager1 = this.dimension; -- WorldServer worldserver = minecraftserver.getWorldServer(dimensionmanager1); -- WorldServer worldserver1 = minecraftserver.getWorldServer(dimensionmanager); -+ // CraftBukkit start - Move logic into new function "teleportTo(Location,boolean)" -+ // DimensionManager dimensionmanager1 = this.dimension; -+ // WorldServer worldserver = minecraftserver.getWorldServer(dimensionmanager1); -+ // WorldServer worldserver1 = minecraftserver.getWorldServer(dimensionmanager); -+ WorldServer exitWorld = null; -+ if (this.dimension.getDimensionID() < CraftWorld.CUSTOM_DIMENSION_OFFSET) { // Plugins must specify exit from custom Bukkit worlds -+ exitWorld = minecraftserver.getWorldServer(dimensionmanager); -+ } -+ -+ BlockPosition blockposition = null; // PAIL: CHECK -+ Location enter = this.getBukkitEntity().getLocation(); -+ 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, exitWorld); -+ } -+ } -+ else { -+ exit = null; -+ } -+ boolean useTravelAgent = exitWorld != null && !(this.dimension == DimensionManager.THE_END && exitWorld.dimension == DimensionManager.THE_END); // 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 -+ boolean oldCanCreate = agent.getCanCreatePortal(); -+ agent.setCanCreatePortal(false); // General entities cannot create portals -+ -+ EntityPortalEvent event = new EntityPortalEvent(this.getBukkitEntity(), enter, exit, agent); -+ event.useTravelAgent(useTravelAgent); -+ event.getEntity().getServer().getPluginManager().callEvent(event); -+ if (event.isCancelled() || event.getTo() == null || event.getTo().getWorld() == null || !this.isAlive()) { -+ agent.setCanCreatePortal(oldCanCreate); -+ return null; -+ } -+ exit = event.useTravelAgent() ? event.getPortalTravelAgent().findOrCreate(event.getTo()) : event.getTo(); -+ agent.setCanCreatePortal(oldCanCreate); -+ -+ // Need to make sure the profiler state is reset afterwards (but we still want to time the call) -+ Entity entity = this.teleportTo(exit, true); -+ this.world.methodProfiler.exit(); -+ return entity; -+ } else { -+ return null; -+ } +@@ -1989,20 +2305,33 @@ + + @Nullable + public Entity a(DimensionManager dimensionmanager) { ++ // CraftBukkit start ++ return teleportTo(dimensionmanager, null); + } + -+ public Entity teleportTo(Location exit, boolean portal) { -+ if (true) { -+ WorldServer worldserver = ((CraftWorld) getBukkitEntity().getLocation().getWorld()).getHandle(); -+ WorldServer worldserver1 = ((CraftWorld) exit.getWorld()).getHandle(); -+ DimensionManager dimensionmanager = worldserver1.dimension; ++ @Nullable ++ public Entity teleportTo(DimensionManager dimensionmanager, BlockPosition location) { ++ // CraftBukkit end + if (!this.world.isClientSide && !this.dead) { + this.world.getMethodProfiler().enter("changeDimension"); + MinecraftServer minecraftserver = this.getMinecraftServer(); + DimensionManager dimensionmanager1 = this.dimension; + WorldServer worldserver = minecraftserver.getWorldServer(dimensionmanager1); + WorldServer worldserver1 = minecraftserver.getWorldServer(dimensionmanager); ++ // CraftBukkit start ++ if (worldserver1 == null){ ++ return null; ++ } + +- this.dimension = dimensionmanager; +- this.decouple(); ++ // this.dimension = dimensionmanager; ++ // this.decouple(); ++ // CraftBukkit end + this.world.getMethodProfiler().enter("reposition"); + Vec3D vec3d = this.getMot(); + float f = 0.0F; +- BlockPosition blockposition; ++ BlockPosition blockposition = location; // CraftBukkit + ++ if (blockposition == null) { // CraftBukkit + if (dimensionmanager1 == DimensionManager.THE_END && dimensionmanager == DimensionManager.OVERWORLD) { + blockposition = worldserver1.getHighestBlockYAt(HeightMap.Type.MOTION_BLOCKING_NO_LEAVES, worldserver1.getSpawn()); + } else if (dimensionmanager == DimensionManager.THE_END) { +@@ -2040,6 +2369,25 @@ + vec3d = (Vec3D) ((Pair) pair.getSecond()).getFirst(); + f = (float) (Integer) ((Pair) pair.getSecond()).getSecond(); + } ++ } // CraftBukkit ++ ++ // CraftBukkit start ++ Location enter = this.getBukkitEntity().getLocation(); ++ Location exit = new Location(worldserver1.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ()); ++ ++ EntityPortalEvent event = new EntityPortalEvent(this.getBukkitEntity(), enter, exit); ++ event.getEntity().getServer().getPluginManager().callEvent(event); ++ if (event.isCancelled() || event.getTo() == null || event.getTo().getWorld() == null || !this.isAlive()) { ++ return null; ++ } ++ ++ exit = event.getTo(); ++ worldserver1 = ((CraftWorld) exit.getWorld()).getHandle(); ++ blockposition = new BlockPosition(exit.getX(), exit.getY(), exit.getZ()); ++ ++ this.dimension = dimensionmanager; ++ this.decouple(); + // CraftBukkit end - this.dimension = dimensionmanager; -+ /* CraftBukkit start - TODO: Check if we need this - if (dimensionmanager1 == DimensionManager.THE_END && dimensionmanager == DimensionManager.THE_END) { - worldserver1 = minecraftserver.getWorldServer(DimensionManager.OVERWORLD); - this.dimension = DimensionManager.OVERWORLD; - } -+ // CraftBukkit end */ - - this.world.kill(this); - this.dead = false; - this.world.methodProfiler.enter("reposition"); -+ /* CraftBukkit start - Handled in calculateTarget - BlockPosition blockposition; - - if (dimensionmanager == DimensionManager.THE_END) { -@@ -2075,12 +2495,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); -+ worldserver1.getMinecraftServer().getPlayerList().repositionEntity(this, exit, portal); -+ // worldserver.entityJoinedWorld(this, false); // Handled in repositionEntity -+ // CraftBukkit end - this.world.methodProfiler.exitEnter("reloading"); - Entity entity = this.P().a((World) worldserver1); - - if (entity != null) { - entity.v(this); -+ /* CraftBukkit start - We need to do this... - if (dimensionmanager1 == DimensionManager.THE_END && dimensionmanager == DimensionManager.THE_END) { - BlockPosition blockposition1 = worldserver1.getHighestBlockYAt(HeightMap.Type.MOTION_BLOCKING_NO_LEAVES, worldserver1.getSpawn()); - -@@ -2088,6 +2514,7 @@ - } else { - entity.setPositionRotation(blockposition, entity.yaw, entity.pitch); - } -+ // CraftBukkit end */ - - boolean flag = entity.attachedToPlayer; - -@@ -2095,13 +2522,21 @@ - worldserver1.addEntity(entity); - entity.attachedToPlayer = flag; - worldserver1.entityJoinedWorld(entity, false); + this.world.getMethodProfiler().exitEnter("reloading"); + Entity entity = this.getEntityType().a((World) worldserver1); +@@ -2049,6 +2397,14 @@ + entity.setPositionRotation(blockposition, entity.yaw + f, entity.pitch); + entity.setMot(vec3d); + worldserver1.addEntityTeleport(entity); + // CraftBukkit start - Forward the CraftEntity to the new entity + this.getBukkitEntity().setHandle(entity); + entity.bukkitEntity = this.getBukkitEntity(); @@ -740,15 +629,7 @@ } this.dead = true; - this.world.methodProfiler.exit(); - worldserver.p(); - worldserver1.p(); -- this.world.methodProfiler.exit(); -+ // this.world.methodProfiler.exit(); // CraftBukkit: Moved up to keep balanced - return entity; - } else { - return null; -@@ -2241,7 +2676,26 @@ +@@ -2240,7 +2596,26 @@ } public void a(AxisAlignedBB axisalignedbb) { @@ -775,4 +656,4 @@ + // CraftBukkit end } - public float getHeadHeight() { + protected float getHeadHeight(EntityPose entitypose, EntitySize entitysize) { diff --git a/nms-patches/EntityAgeable.patch b/nms-patches/EntityAgeable.patch index 29aa1f783d..78387ae5f8 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 -@@ -10,6 +10,7 @@ +@@ -8,6 +8,7 @@ + protected int b; protected int c; - private float bD = -1.0F; - private float bE; + protected int d; + public boolean ageLocked; // CraftBukkit - protected EntityAgeable(EntityTypes entitytypes, World world) { + protected EntityAgeable(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -29,7 +30,7 @@ +@@ -30,7 +31,7 @@ if (entityageable != null) { entityageable.setAgeRaw(-24000); entityageable.setPositionRotation(this.locX, this.locY, this.locZ, 0.0F, 0.0F); @@ -17,27 +17,28 @@ if (itemstack.hasName()) { entityageable.setCustomName(itemstack.getName()); } -@@ -97,12 +98,14 @@ +@@ -103,6 +104,7 @@ super.b(nbttagcompound); nbttagcompound.setInt("Age", this.getAge()); - nbttagcompound.setInt("ForcedAge", this.b); + nbttagcompound.setInt("ForcedAge", this.c); + nbttagcompound.setBoolean("AgeLocked", this.ageLocked); // CraftBukkit } - public void a(NBTTagCompound nbttagcompound) { + @Override +@@ -110,6 +112,7 @@ super.a(nbttagcompound); this.setAgeRaw(nbttagcompound.getInt("Age")); - this.b = nbttagcompound.getInt("ForcedAge"); + this.c = nbttagcompound.getInt("ForcedAge"); + this.ageLocked = nbttagcompound.getBoolean("AgeLocked"); // CraftBukkit } - public void a(DataWatcherObject datawatcherobject) { -@@ -115,7 +118,7 @@ - + @Override +@@ -124,7 +127,7 @@ + @Override public void movementTick() { super.movementTick(); - if (this.world.isClientSide) { + if (this.world.isClientSide || ageLocked) { // CraftBukkit - if (this.c > 0) { - if (this.c % 4 == 0) { - this.world.addParticle(Particles.z, this.locX + (double) (this.random.nextFloat() * this.width * 2.0F) - (double) this.width, this.locY + 0.5D + (double) (this.random.nextFloat() * this.length), this.locZ + (double) (this.random.nextFloat() * this.width * 2.0F) - (double) this.width, 0.0D, 0.0D, 0.0D); + if (this.d > 0) { + if (this.d % 4 == 0) { + this.world.addParticle(Particles.HAPPY_VILLAGER, this.locX + (double) (this.random.nextFloat() * this.getWidth() * 2.0F) - (double) this.getWidth(), this.locY + 0.5D + (double) (this.random.nextFloat() * this.getHeight()), this.locZ + (double) (this.random.nextFloat() * this.getWidth() * 2.0F) - (double) this.getWidth(), 0.0D, 0.0D, 0.0D); diff --git a/nms-patches/EntityAnimal.patch b/nms-patches/EntityAnimal.patch index fda6865da8..d5fe468e82 100644 --- a/nms-patches/EntityAnimal.patch +++ b/nms-patches/EntityAnimal.patch @@ -1,35 +1,32 @@ --- a/net/minecraft/server/EntityAnimal.java +++ b/net/minecraft/server/EntityAnimal.java -@@ -6,8 +6,9 @@ - public abstract class EntityAnimal extends EntityAgeable implements IAnimal { - - protected Block bF; -- private int bC; -+ public int bC; // CraftBukkit - private -> public +@@ -8,6 +8,7 @@ + protected Block bC; + public int loveTicks; public UUID breedCause; + public ItemStack breedItem; // CraftBukkit - Add breedItem variable - protected EntityAnimal(EntityTypes entitytypes, World world) { + protected EntityAnimal(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -41,6 +42,9 @@ +@@ -43,6 +44,9 @@ } + /* CraftBukkit start + // Function disabled as it has no special function anymore after + // setSitting is disabled. + @Override public boolean damageEntity(DamageSource damagesource, float f) { if (this.isInvulnerable(damagesource)) { - return false; -@@ -49,6 +53,7 @@ +@@ -52,6 +56,7 @@ return super.damageEntity(damagesource, f); } } + // CraftBukkit end */ + @Override public float a(BlockPosition blockposition, IWorldReader iworldreader) { - return iworldreader.getType(blockposition.down()).getBlock() == this.bF ? 10.0F : iworldreader.A(blockposition) - 0.5F; -@@ -134,6 +139,7 @@ +@@ -146,6 +151,7 @@ if (entityhuman != null) { this.breedCause = entityhuman.getUniqueID(); } diff --git a/nms-patches/EntityAreaEffectCloud.patch b/nms-patches/EntityAreaEffectCloud.patch index 3b1d968045..6eb173d92b 100644 --- a/nms-patches/EntityAreaEffectCloud.patch +++ b/nms-patches/EntityAreaEffectCloud.patch @@ -11,14 +11,14 @@ public class EntityAreaEffectCloud extends Entity { -@@ -101,6 +105,22 @@ +@@ -105,6 +109,22 @@ } + // CraftBukkit start accessor methods + public void refreshEffects() { + if (!this.hasColor) { -+ this.getDataWatcher().set(EntityAreaEffectCloud.c, Integer.valueOf(PotionUtil.a((Collection) PotionUtil.a(this.potionRegistry, (Collection) this.effects)))); // PAIL: rename ++ this.getDataWatcher().set(EntityAreaEffectCloud.COLOR, PotionUtil.a((Collection) PotionUtil.a(this.potionRegistry, (Collection) this.effects))); // PAIL: rename + } + } + @@ -32,9 +32,9 @@ + // CraftBukkit end + public int getColor() { - return (Integer) this.getDataWatcher().get(EntityAreaEffectCloud.c); + return (Integer) this.getDataWatcher().get(EntityAreaEffectCloud.COLOR); } -@@ -244,6 +264,7 @@ +@@ -249,6 +269,7 @@ if (!list1.isEmpty()) { Iterator iterator2 = list1.iterator(); @@ -42,7 +42,7 @@ while (iterator2.hasNext()) { EntityLiving entityliving = (EntityLiving) iterator2.next(); -@@ -253,6 +274,17 @@ +@@ -258,6 +279,17 @@ double d2 = d0 * d0 + d1 * d1; if (d2 <= (double) (f * f)) { @@ -57,10 +57,10 @@ + if (entity instanceof CraftLivingEntity) { + EntityLiving entityliving = ((CraftLivingEntity) entity).getHandle(); + // CraftBukkit end - this.h.put(entityliving, this.ticksLived + this.reapplicationDelay); + this.affectedEntities.put(entityliving, this.ticksLived + this.reapplicationDelay); Iterator iterator3 = list.iterator(); -@@ -262,7 +294,7 @@ +@@ -267,7 +299,7 @@ if (mobeffect1.getMobEffect().isInstant()) { mobeffect1.getMobEffect().applyInstantEffect(this, this.getSource(), entityliving, mobeffect1.getAmplifier(), 0.5D); } else { diff --git a/nms-patches/EntityArmorStand.patch b/nms-patches/EntityArmorStand.patch index e94f1ec940..630bf070b4 100644 --- a/nms-patches/EntityArmorStand.patch +++ b/nms-patches/EntityArmorStand.patch @@ -15,8 +15,8 @@ + public class EntityArmorStand extends EntityLiving { - private static final Vector3f bx = new Vector3f(0.0F, 0.0F, 0.0F); -@@ -56,6 +65,13 @@ + private static final Vector3f bu = new Vector3f(0.0F, 0.0F, 0.0F); +@@ -53,6 +62,13 @@ this.setPosition(d0, d1, d2); } @@ -27,12 +27,12 @@ + } + // CraftBukkit end + - public final void setSize(float f, float f1) { + @Override + public void updateSize() { double d0 = this.locX; - double d1 = this.locY; -@@ -354,6 +370,21 @@ - if (itemstack1.isEmpty() || (this.bH & 1 << enumitemslot.c() + 8) == 0) { - if (!itemstack1.isEmpty() || (this.bH & 1 << enumitemslot.c() + 16) == 0) { +@@ -374,6 +390,21 @@ + if (itemstack1.isEmpty() || (this.bE & 1 << enumitemslot.c() + 8) == 0) { + if (!itemstack1.isEmpty() || (this.bE & 1 << enumitemslot.c() + 16) == 0) { ItemStack itemstack2; + // CraftBukkit start + org.bukkit.inventory.ItemStack armorStandItem = CraftItemStack.asCraftMirror(itemstack1); @@ -52,9 +52,9 @@ if (entityhuman.abilities.canInstantlyBuild && itemstack1.isEmpty() && !itemstack.isEmpty()) { itemstack2 = itemstack.cloneItemStack(); -@@ -375,14 +406,19 @@ - } +@@ -396,14 +427,19 @@ + @Override public boolean damageEntity(DamageSource damagesource, float f) { + // CraftBukkit start + if (org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f)) { @@ -66,71 +66,71 @@ - this.die(); + this.killEntity(); // CraftBukkit - this.die() -> this.killEntity() return false; - } else if (!this.isInvulnerable(damagesource) && !this.bG && !this.isMarker()) { + } else if (!this.isInvulnerable(damagesource) && !this.bD && !this.isMarker()) { if (damagesource.isExplosion()) { - this.D(); + this.g(damagesource); - this.die(); + this.killEntity(); // CraftBukkit - this.die() -> this.killEntity() return false; } else if (DamageSource.FIRE.equals(damagesource)) { if (this.isBurning()) { -@@ -406,7 +442,7 @@ +@@ -428,7 +464,7 @@ } else if (damagesource.v()) { this.F(); - this.A(); + this.D(); - this.die(); + this.killEntity(); // CraftBukkit - this.die() -> this.killEntity() - return false; + return flag1; } else { long i = this.world.getTime(); -@@ -417,7 +453,7 @@ +@@ -439,7 +475,7 @@ } else { - this.B(); - this.A(); + this.f(damagesource); + this.D(); - this.die(); + this.killEntity(); // CraftBukkit - this.die() -> this.killEntity() } return true; -@@ -444,7 +480,7 @@ +@@ -466,7 +502,7 @@ f1 -= f; if (f1 <= 0.5F) { - this.D(); + this.g(damagesource); - this.die(); + this.killEntity(); // CraftBukkit - this.die() -> this.killEntity() } else { this.setHealth(f1); } -@@ -452,7 +488,7 @@ +@@ -474,7 +510,7 @@ } - private void B() { + private void f(DamageSource damagesource) { - Block.a(this.world, new BlockPosition(this), new ItemStack(Items.ARMOR_STAND)); + drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(new ItemStack(Items.ARMOR_STAND))); // CraftBukkit - add to drops - this.D(); + this.g(damagesource); } -@@ -465,7 +501,7 @@ - for (i = 0; i < this.bE.size(); ++i) { - itemstack = (ItemStack) this.bE.get(i); +@@ -488,7 +524,7 @@ + for (i = 0; i < this.handItems.size(); ++i) { + itemstack = (ItemStack) this.handItems.get(i); if (!itemstack.isEmpty()) { - Block.a(this.world, (new BlockPosition(this)).up(), itemstack); + drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemstack)); // CraftBukkit - add to drops - this.bE.set(i, ItemStack.a); + this.handItems.set(i, ItemStack.a); } } -@@ -473,7 +509,7 @@ - for (i = 0; i < this.bF.size(); ++i) { - itemstack = (ItemStack) this.bF.get(i); +@@ -496,7 +532,7 @@ + for (i = 0; i < this.armorItems.size(); ++i) { + itemstack = (ItemStack) this.armorItems.get(i); if (!itemstack.isEmpty()) { - Block.a(this.world, (new BlockPosition(this)).up(), itemstack); + drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemstack)); // CraftBukkit - add to drops - this.bF.set(i, ItemStack.a); + this.armorItems.set(i, ItemStack.a); } } -@@ -585,6 +621,7 @@ - } +@@ -602,6 +638,7 @@ + @Override public void killEntity() { + org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDeathEvent(this, drops); // CraftBukkit - call event this.die(); diff --git a/nms-patches/EntityArrow.patch b/nms-patches/EntityArrow.patch index 4e086ab3e8..ee0bf8332c 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 -@@ -7,6 +7,12 @@ - import java.util.function.Predicate; +@@ -9,6 +9,12 @@ + import java.util.UUID; import javax.annotation.Nullable; +// CraftBukkit start @@ -12,25 +12,16 @@ + public abstract class EntityArrow extends Entity implements IProjectile { - private static final Predicate g = IEntitySelector.f.and(IEntitySelector.a.and(Entity::isInteractable)); -@@ -22,7 +28,7 @@ - public EntityArrow.PickupStatus fromPlayer; - public int shake; - public UUID shooter; -- private int despawnCounter; -+ public int despawnCounter; // PAIL - private int aB; - private double damage; - public int knockbackStrength; -@@ -250,6 +256,7 @@ + private static final DataWatcherObject ar = DataWatcher.a(EntityArrow.class, DataWatcherRegistry.a); +@@ -251,6 +257,7 @@ } protected void a(MovingObjectPosition movingobjectposition) { + org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this, movingobjectposition); // CraftBukkit - Call event - if (movingobjectposition.entity != null) { - this.b(movingobjectposition); - } else { -@@ -299,7 +306,13 @@ + MovingObjectPosition.EnumMovingObjectType movingobjectposition_enummovingobjecttype = movingobjectposition.getType(); + + if (movingobjectposition_enummovingobjecttype == MovingObjectPosition.EnumMovingObjectType.ENTITY) { +@@ -331,7 +338,13 @@ } if (this.isBurning() && !(entity instanceof EntityEnderman)) { @@ -45,18 +36,18 @@ } if (entity.damageEntity(damagesource, (float) i)) { -@@ -444,6 +457,7 @@ +@@ -467,6 +480,7 @@ public void setShooter(@Nullable Entity entity) { this.shooter = entity == null ? null : entity.getUniqueID(); + this.projectileSource = entity == null ? null : (LivingEntity) entity.getBukkitEntity(); // CraftBukkit - } - - @Nullable -@@ -453,9 +467,23 @@ - - public void d(EntityHuman entityhuman) { - if (!this.world.isClientSide && (this.inGround || this.q()) && this.shake <= 0) { + if (entity instanceof EntityHuman) { + this.fromPlayer = ((EntityHuman) entity).abilities.canInstantlyBuild ? EntityArrow.PickupStatus.CREATIVE_ONLY : EntityArrow.PickupStatus.ALLOWED; + } +@@ -481,9 +495,23 @@ + @Override + public void pickup(EntityHuman entityhuman) { + if (!this.world.isClientSide && (this.inGround || this.v()) && this.shake <= 0) { + // CraftBukkit start + ItemStack itemstack = this.getItemStack(); + if (this.fromPlayer == PickupStatus.ALLOWED && !itemstack.isEmpty() && entityhuman.inventory.canHold(itemstack) > 0) { @@ -70,7 +61,7 @@ + } + itemstack = item.getItemStack(); + } - boolean flag = this.fromPlayer == EntityArrow.PickupStatus.ALLOWED || this.fromPlayer == EntityArrow.PickupStatus.CREATIVE_ONLY && entityhuman.abilities.canInstantlyBuild || this.q() && this.getShooter().getUniqueID() == entityhuman.getUniqueID(); + boolean flag = this.fromPlayer == EntityArrow.PickupStatus.ALLOWED || this.fromPlayer == EntityArrow.PickupStatus.CREATIVE_ONLY && entityhuman.abilities.canInstantlyBuild || this.v() && this.getShooter().getUniqueID() == entityhuman.getUniqueID(); - if (this.fromPlayer == EntityArrow.PickupStatus.ALLOWED && !entityhuman.inventory.pickup(this.getItemStack())) { + if (this.fromPlayer == EntityArrow.PickupStatus.ALLOWED && !entityhuman.inventory.pickup(itemstack)) { diff --git a/nms-patches/EntityBat.patch b/nms-patches/EntityBat.patch index 44295d9e7e..20b466de49 100644 --- a/nms-patches/EntityBat.patch +++ b/nms-patches/EntityBat.patch @@ -8,10 +8,10 @@ public class EntityBat extends EntityAmbient { -@@ -94,12 +95,20 @@ +@@ -104,12 +105,20 @@ } - if (this.world.b(this, 4.0D) != null) { + if (this.world.a(EntityBat.c, (EntityLiving) this) != null) { + // CraftBukkit Start - Call BatToggleSleepEvent + if (CraftEventFactory.handleBatToggleSleepEvent(this, true)) { + this.setAsleep(false); @@ -31,11 +31,11 @@ + // CraftBukkit End - Call BatToggleSleepEvent } } else { - if (this.b != null && (!this.world.isEmpty(this.b) || this.b.getY() < 1)) { -@@ -123,7 +132,11 @@ - this.bj = 0.5F; + if (this.d != null && (!this.world.isEmpty(this.d) || this.d.getY() < 1)) { +@@ -133,7 +142,11 @@ + this.bd = 0.5F; this.yaw += f1; - if (this.random.nextInt(100) == 0 && this.world.getType(blockposition1).isOccluding()) { + if (this.random.nextInt(100) == 0 && this.world.getType(blockposition1).isOccluding(this.world, blockposition1)) { - this.setAsleep(true); + // CraftBukkit Start - Call BatToggleSleepEvent + if (CraftEventFactory.handleBatToggleSleepEvent(this, false)) { @@ -45,7 +45,7 @@ } } -@@ -146,7 +159,11 @@ +@@ -161,7 +174,11 @@ return false; } else { if (!this.world.isClientSide && this.isAsleep()) { diff --git a/nms-patches/EntityBoat.patch b/nms-patches/EntityBoat.patch index 265b19a508..dd83d1f382 100644 --- a/nms-patches/EntityBoat.patch +++ b/nms-patches/EntityBoat.patch @@ -15,10 +15,10 @@ + public class EntityBoat extends Entity { - private static final DataWatcherObject a = DataWatcher.a(EntityBoat.class, DataWatcherRegistry.b); + private static final DataWatcherObject b = DataWatcher.a(EntityBoat.class, DataWatcherRegistry.b); @@ -37,6 +46,14 @@ - private float aR; - private float aS; + private float aO; + private float aP; + // CraftBukkit start + // PAIL: Some of these haven't worked since a few updates, and since 1.9 they are less and less applicable. @@ -28,10 +28,10 @@ + public boolean landBoats = false; + // CraftBukkit end + - public EntityBoat(World world) { - super(EntityTypes.BOAT, world); - this.h = new float[2]; -@@ -94,6 +111,19 @@ + public EntityBoat(EntityTypes entitytypes, World world) { + super(entitytypes, world); + this.as = new float[2]; +@@ -98,6 +115,19 @@ if (damagesource instanceof EntityDamageSourceIndirect && damagesource.getEntity() != null && this.w(damagesource.getEntity())) { return false; } else { @@ -50,11 +50,11 @@ + this.c(-this.o()); this.b(10); - this.setDamage(this.m() + f * 10.0F); -@@ -101,6 +131,15 @@ + this.setDamage(this.getDamage() + f * 10.0F); +@@ -105,6 +135,15 @@ boolean flag = damagesource.getEntity() instanceof EntityHuman && ((EntityHuman) damagesource.getEntity()).abilities.canInstantlyBuild; - if (flag || this.m() > 40.0F) { + if (flag || this.getDamage() > 40.0F) { + // CraftBukkit start + VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, attacker); + this.world.getServer().getPluginManager().callEvent(destroyEvent); @@ -67,7 +67,7 @@ if (!flag && this.world.getGameRules().getBoolean("doEntityDrops")) { this.a((IMaterial) this.f()); } -@@ -134,9 +173,25 @@ +@@ -140,9 +179,25 @@ public void collide(Entity entity) { if (entity instanceof EntityBoat) { if (entity.getBoundingBox().minY < this.getBoundingBox().maxY) { @@ -93,16 +93,16 @@ super.collide(entity); } -@@ -168,6 +223,7 @@ +@@ -176,6 +231,7 @@ return this.getDirection().e(); } + private Location lastLocation; // CraftBukkit + @Override public void tick() { - this.aM = this.aL; - this.aL = this.s(); -@@ -212,6 +268,22 @@ - this.motZ = 0.0D; + this.aJ = this.aI; +@@ -219,6 +275,22 @@ + this.setMot(Vec3D.a); } + // CraftBukkit start @@ -124,9 +124,9 @@ this.q(); for (int i = 0; i <= 1; ++i) { -@@ -730,6 +802,11 @@ +@@ -740,6 +812,11 @@ - this.c(this.fallDistance, 1.0F); + this.b(this.fallDistance, 1.0F); if (!this.world.isClientSide && !this.dead) { + // CraftBukkit start + Vehicle vehicle = (Vehicle) this.getBukkitEntity(); @@ -136,7 +136,7 @@ this.die(); if (this.world.getGameRules().getBoolean("doEntityDrops")) { int i; -@@ -743,6 +820,7 @@ +@@ -753,6 +830,7 @@ } } } diff --git a/nms-patches/EntityCat.patch b/nms-patches/EntityCat.patch new file mode 100644 index 0000000000..813b85d870 --- /dev/null +++ b/nms-patches/EntityCat.patch @@ -0,0 +1,32 @@ +--- a/net/minecraft/server/EntityCat.java ++++ b/net/minecraft/server/EntityCat.java +@@ -16,7 +16,7 @@ + private static final DataWatcherObject bG = DataWatcher.a(EntityCat.class, DataWatcherRegistry.i); + private static final DataWatcherObject bH = DataWatcher.a(EntityCat.class, DataWatcherRegistry.i); + private static final DataWatcherObject bI = DataWatcher.a(EntityCat.class, DataWatcherRegistry.b); +- public static final Map bD = (Map) SystemUtils.a((Object) Maps.newHashMap(), (hashmap) -> { ++ public static final Map bD = (Map) SystemUtils.a(Maps.newHashMap(), (hashmap) -> { // CraftBukkit - decompile error + hashmap.put(0, new MinecraftKey("textures/entity/cat/tabby.png")); + hashmap.put(1, new MinecraftKey("textures/entity/cat/black.png")); + hashmap.put(2, new MinecraftKey("textures/entity/cat/red.png")); +@@ -518,7 +518,7 @@ + static class PathfinderGoalTemptChance extends PathfinderGoalTempt { + + @Nullable +- private EntityHuman chosenTarget; ++ private EntityLiving chosenTarget; // CraftBukkit + private final EntityCat d; + + public PathfinderGoalTemptChance(EntityCat entitycat, double d0, RecipeItemStack recipeitemstack, boolean flag) { +@@ -553,9 +553,9 @@ + private final EntityCat i; + + public a(EntityCat entitycat, Class oclass, float f, double d0, double d1) { +- Predicate predicate = IEntitySelector.e; ++ // Predicate predicate = IEntitySelector.e; // CraftBukkit - decompile error + +- super(entitycat, oclass, f, d0, d1, predicate::test); ++ super(entitycat, oclass, f, d0, d1, IEntitySelector.e::test); // CraftBukkit - decompile error + this.i = entitycat; + } + diff --git a/nms-patches/EntityCaveSpider.patch b/nms-patches/EntityCaveSpider.patch index cc15841b7b..27832f51c9 100644 --- a/nms-patches/EntityCaveSpider.patch +++ b/nms-patches/EntityCaveSpider.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/EntityCaveSpider.java +++ b/net/minecraft/server/EntityCaveSpider.java -@@ -26,7 +26,7 @@ +@@ -27,7 +27,7 @@ } if (b0 > 0) { diff --git a/nms-patches/EntityChicken.patch b/nms-patches/EntityChicken.patch index 06badbfaad..922fca961f 100644 --- a/nms-patches/EntityChicken.patch +++ b/nms-patches/EntityChicken.patch @@ -1,24 +1,24 @@ --- a/net/minecraft/server/EntityChicken.java +++ b/net/minecraft/server/EntityChicken.java -@@ -42,6 +42,11 @@ - } +@@ -43,6 +43,11 @@ + @Override public void movementTick() { + // CraftBukkit start + if (this.isChickenJockey()) { -+ this.persistent = !this.isTypeNotPersistent(); ++ this.persistent = !this.isTypeNotPersistent(0); + } + // CraftBukkit end super.movementTick(); - this.bG = this.bC; - this.bE = this.bD; -@@ -59,7 +64,9 @@ - this.bC += this.bH * 2.0F; - if (!this.world.isClientSide && !this.isBaby() && !this.isChickenJockey() && --this.bI <= 0) { + this.bD = this.bz; + this.bB = this.bA; +@@ -62,7 +67,9 @@ + this.bz += this.bE * 2.0F; + if (!this.world.isClientSide && this.isAlive() && !this.isBaby() && !this.isChickenJockey() && --this.eggLayTime <= 0) { this.a(SoundEffects.ENTITY_CHICKEN_EGG, 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); + this.forceDrops = true; // CraftBukkit this.a((IMaterial) Items.EGG); + this.forceDrops = false; // CraftBukkit - this.bI = this.random.nextInt(6000) + 6000; + this.eggLayTime = this.random.nextInt(6000) + 6000; } diff --git a/nms-patches/EntityCow.patch b/nms-patches/EntityCow.patch index fda4509eda..fa2194cccb 100644 --- a/nms-patches/EntityCow.patch +++ b/nms-patches/EntityCow.patch @@ -1,17 +1,17 @@ --- a/net/minecraft/server/EntityCow.java +++ b/net/minecraft/server/EntityCow.java -@@ -1,6 +1,10 @@ +@@ -1,5 +1,10 @@ package net.minecraft.server; - import javax.annotation.Nullable; +// CraftBukkit start +import org.bukkit.craftbukkit.event.CraftEventFactory; +import org.bukkit.craftbukkit.inventory.CraftItemStack; +// CraftBukkit end - ++ public class EntityCow extends EntityAnimal { -@@ -59,13 +63,23 @@ + public EntityCow(EntityTypes entitytypes, World world) { +@@ -55,13 +60,23 @@ ItemStack itemstack = entityhuman.b(enumhand); if (itemstack.getItem() == Items.BUCKET && !entityhuman.abilities.canInstantlyBuild && !this.isBaby()) { diff --git a/nms-patches/EntityCreature.patch b/nms-patches/EntityCreature.patch index 6580470d21..969f6a2708 100644 --- a/nms-patches/EntityCreature.patch +++ b/nms-patches/EntityCreature.patch @@ -9,8 +9,8 @@ + public abstract class EntityCreature extends EntityInsentient { - private BlockPosition a; -@@ -66,6 +70,7 @@ + protected EntityCreature(EntityTypes entitytypes, World world) { +@@ -34,6 +38,7 @@ if (this instanceof EntityTameableAnimal && ((EntityTameableAnimal) this).isSitting()) { if (f > 10.0F) { @@ -18,11 +18,11 @@ this.unleash(true, true); } -@@ -74,6 +79,7 @@ +@@ -42,6 +47,7 @@ this.u(f); if (f > 10.0F) { + this.world.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE)); // CraftBukkit this.unleash(true, true); - this.goalSelector.c(1); + this.goalSelector.a(PathfinderGoal.Type.MOVE); } else if (f > 6.0F) { diff --git a/nms-patches/EntityCreeper.patch b/nms-patches/EntityCreeper.patch index b35ba7f668..68389534d2 100644 --- a/nms-patches/EntityCreeper.patch +++ b/nms-patches/EntityCreeper.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/server/EntityCreeper.java +++ b/net/minecraft/server/EntityCreeper.java -@@ -3,6 +3,10 @@ +@@ -2,6 +2,10 @@ + import java.util.Collection; import java.util.Iterator; - import javax.annotation.Nullable; +// CraftBukkit start +import org.bukkit.craftbukkit.event.CraftEventFactory; +import org.bukkit.event.entity.ExplosionPrimeEvent; @@ -11,28 +11,11 @@ public class EntityCreeper extends EntityMonster { -@@ -121,7 +125,7 @@ - } - - public void die(DamageSource damagesource) { -- super.die(damagesource); -+ // super.die(damagesource); // CraftBukkit - Moved to end - if (this.world.getGameRules().getBoolean("doMobLoot")) { - if (damagesource.getEntity() instanceof EntitySkeleton) { - this.a((IMaterial) ItemRecord.a(this.random)); -@@ -130,6 +134,7 @@ - this.a((IMaterial) Items.CREEPER_HEAD); - } - } -+ super.die(damagesource); // CraftBukkit - Moved from above - - } - -@@ -156,9 +161,19 @@ - +@@ -165,9 +169,19 @@ + @Override public void onLightningStrike(EntityLightning entitylightning) { super.onLightningStrike(entitylightning); -- this.datawatcher.set(EntityCreeper.b, true); +- this.datawatcher.set(EntityCreeper.POWERED, true); + // CraftBukkit start + if (CraftEventFactory.callCreeperPowerEvent(this, entitylightning, org.bukkit.event.entity.CreeperPowerEvent.PowerCause.LIGHTNING).isCancelled()) { + return; @@ -42,19 +25,19 @@ } + public void setPowered(boolean powered) { -+ this.datawatcher.set(EntityCreeper.b, powered); ++ this.datawatcher.set(EntityCreeper.POWERED, powered); + } + // CraftBukkit end + + @Override protected boolean a(EntityHuman entityhuman, EnumHand enumhand) { ItemStack itemstack = entityhuman.b(enumhand); - -@@ -180,10 +195,18 @@ - boolean flag = this.world.getGameRules().getBoolean("mobGriefing"); +@@ -192,10 +206,18 @@ + Explosion.Effect explosion_effect = this.world.getGameRules().getBoolean("mobGriefing") ? Explosion.Effect.DESTROY : Explosion.Effect.NONE; float f = this.isPowered() ? 2.0F : 1.0F; - this.killed = true; -- this.world.explode(this, this.locX, this.locY, this.locZ, (float) this.explosionRadius * f, flag); +- this.world.explode(this, this.locX, this.locY, this.locZ, (float) this.explosionRadius * f, explosion_effect); - this.die(); - this.createEffectCloud(); + // CraftBukkit start @@ -62,7 +45,7 @@ + this.world.getServer().getPluginManager().callEvent(event); + if (!event.isCancelled()) { + this.killed = true; -+ this.world.createExplosion(this, this.locX, this.locY, this.locZ, event.getRadius(), event.getFire(), flag); ++ this.world.createExplosion(this, this.locX, this.locY, this.locZ, event.getRadius(), event.getFire(), explosion_effect); + this.die(); + this.createEffectCloud(); + } else { @@ -72,7 +55,7 @@ } } -@@ -194,6 +217,7 @@ +@@ -206,6 +228,7 @@ if (!collection.isEmpty()) { EntityAreaEffectCloud entityareaeffectcloud = new EntityAreaEffectCloud(this.world, this.locX, this.locY, this.locZ); diff --git a/nms-patches/EntityDamageSourceIndirect.patch b/nms-patches/EntityDamageSourceIndirect.patch index 9e9dd43db0..fd14861a2e 100644 --- a/nms-patches/EntityDamageSourceIndirect.patch +++ b/nms-patches/EntityDamageSourceIndirect.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/EntityDamageSourceIndirect.java +++ b/net/minecraft/server/EntityDamageSourceIndirect.java -@@ -29,4 +29,10 @@ +@@ -32,4 +32,10 @@ - return !itemstack.isEmpty() && itemstack.hasName() ? new ChatMessage(s1, new Object[] { entityliving.getScoreboardDisplayName(), ichatbasecomponent, itemstack.A()}) : new ChatMessage(s, new Object[] { entityliving.getScoreboardDisplayName(), ichatbasecomponent}); + return !itemstack.isEmpty() && itemstack.hasName() ? 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/EntityDolphin.patch b/nms-patches/EntityDolphin.patch index 8b681bd9bb..194202b417 100644 --- a/nms-patches/EntityDolphin.patch +++ b/nms-patches/EntityDolphin.patch @@ -1,15 +1,24 @@ --- a/net/minecraft/server/EntityDolphin.java +++ b/net/minecraft/server/EntityDolphin.java -@@ -412,7 +412,7 @@ - } +@@ -106,7 +106,7 @@ + this.goalSelector.a(8, new EntityDolphin.d()); + this.goalSelector.a(8, new PathfinderGoalFollowBoat(this)); + this.goalSelector.a(9, new PathfinderGoalAvoidTarget<>(this, EntityGuardian.class, 8.0F, 1.0D, 1.0D)); +- this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[] { EntityGuardian.class})).a()); ++ this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[] { EntityGuardian.class})).a(new Class[0])); // CraftBukkit - decompile error + } + @Override +@@ -422,7 +422,7 @@ + + @Override public void c() { - this.c.addEffect(new MobEffect(MobEffects.DOLPHINS_GRACE, 100)); + this.c.addEffect(new MobEffect(MobEffects.DOLPHINS_GRACE, 100), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.DOLPHIN); // CraftBukkit } - public void d() { -@@ -429,7 +429,7 @@ + @Override +@@ -441,7 +441,7 @@ } if (this.c.isSwimming() && this.c.world.random.nextInt(6) == 0) { diff --git a/nms-patches/EntityEgg.patch b/nms-patches/EntityEgg.patch index 3d0192eb69..5a15c5621b 100644 --- a/nms-patches/EntityEgg.patch +++ b/nms-patches/EntityEgg.patch @@ -10,10 +10,10 @@ +import org.bukkit.event.player.PlayerEggThrowEvent; +// CraftBukkit end + - public class EntityEgg extends EntityProjectile { + public class EntityEgg extends EntityProjectileThrowable { - public EntityEgg(World world) { -@@ -20,20 +27,40 @@ + public EntityEgg(EntityTypes entitytypes, World world) { +@@ -21,20 +28,40 @@ } if (!this.world.isClientSide) { @@ -27,7 +27,7 @@ } - for (int i = 0; i < b0; ++i) { -- EntityChicken entitychicken = new EntityChicken(this.world); +- EntityChicken entitychicken = (EntityChicken) EntityTypes.CHICKEN.a(this.world); + // CraftBukkit start + if (!hatching) { + b0 = 0; diff --git a/nms-patches/EntityEnderCrystal.patch b/nms-patches/EntityEnderCrystal.patch index 0f392b3dd5..f0c66cd81a 100644 --- a/nms-patches/EntityEnderCrystal.patch +++ b/nms-patches/EntityEnderCrystal.patch @@ -11,8 +11,8 @@ + public class EntityEnderCrystal extends Entity { - private static final DataWatcherObject> b = DataWatcher.a(EntityEnderCrystal.class, DataWatcherRegistry.m); -@@ -39,7 +44,11 @@ + private static final DataWatcherObject> c = DataWatcher.a(EntityEnderCrystal.class, DataWatcherRegistry.m); +@@ -41,7 +46,11 @@ BlockPosition blockposition = new BlockPosition(this); if (this.world.worldProvider instanceof WorldProviderTheEnd && this.world.getType(blockposition).isAir()) { @@ -25,7 +25,7 @@ } } -@@ -75,10 +84,23 @@ +@@ -81,10 +90,23 @@ return false; } else { if (!this.dead && !this.world.isClientSide) { @@ -37,7 +37,7 @@ this.die(); if (!this.world.isClientSide) { if (!damagesource.isExplosion()) { -- this.world.explode((Entity) null, this.locX, this.locY, this.locZ, 6.0F, true); +- this.world.explode((Entity) null, this.locX, this.locY, this.locZ, 6.0F, Explosion.Effect.DESTROY); + // CraftBukkit start + ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), 6.0F, false); + this.world.getServer().getPluginManager().callEvent(event); @@ -45,7 +45,7 @@ + this.dead = false; + return false; + } -+ this.world.createExplosion(this, this.locX, this.locY, this.locZ, event.getRadius(), event.getFire(), true); ++ this.world.createExplosion(this, this.locX, this.locY, this.locZ, event.getRadius(), event.getFire(), Explosion.Effect.DESTROY); + // CraftBukkit end } diff --git a/nms-patches/EntityEnderDragon.patch b/nms-patches/EntityEnderDragon.patch index 8f36ebfecf..ea567c81b7 100644 --- a/nms-patches/EntityEnderDragon.patch +++ b/nms-patches/EntityEnderDragon.patch @@ -1,36 +1,37 @@ --- a/net/minecraft/server/EntityEnderDragon.java +++ b/net/minecraft/server/EntityEnderDragon.java -@@ -5,7 +5,12 @@ +@@ -6,7 +6,13 @@ import javax.annotation.Nullable; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +// CraftBukkit start ++import org.bukkit.craftbukkit.block.CraftBlock; +import org.bukkit.event.entity.EntityExplodeEvent; +import org.bukkit.event.entity.EntityRegainHealthEvent; +// CraftBukkit end +// PAIL: Fixme - public class EntityEnderDragon extends EntityInsentient implements IComplex, IMonster { + public class EntityEnderDragon extends EntityInsentient implements IMonster { - private static final Logger bQ = LogManager.getLogger(); -@@ -33,6 +38,7 @@ - private final PathPoint[] bV = new PathPoint[24]; - private final int[] bW = new int[24]; - private final Path bX = new Path(); -+ private Explosion explosionSource = new Explosion(null, this, Double.NaN, Double.NaN, Double.NaN, Float.NaN, true, true); // CraftBukkit - reusable source for CraftTNTPrimed.getSource() + private static final Logger bN = LogManager.getLogger(); +@@ -35,6 +41,7 @@ + private final PathPoint[] bT = new PathPoint[24]; + private final int[] bU = new int[24]; + private final Path bV = new Path(); ++ private Explosion explosionSource = new Explosion(null, this, Double.NaN, Double.NaN, Double.NaN, Float.NaN, true, Explosion.Effect.DESTROY); // CraftBukkit - reusable source for CraftTNTPrimed.getSource() - public EntityEnderDragon(World world) { + public EntityEnderDragon(EntityTypes entitytypes, World world) { super(EntityTypes.ENDER_DRAGON, world); -@@ -170,7 +176,7 @@ +@@ -173,7 +180,7 @@ - Vec3D vec3d = idragoncontroller.g(); + Vec3D vec3d1 = idragoncontroller.g(); -- if (vec3d != null) { -+ if (vec3d != null && idragoncontroller.getControllerPhase() != DragonControllerPhase.HOVER) { // CraftBukkit - Don't move when hovering - d0 = vec3d.x - this.locX; - d1 = vec3d.y - this.locY; - d2 = vec3d.z - this.locZ; -@@ -326,7 +332,14 @@ +- if (vec3d1 != null) { ++ if (vec3d1 != null && idragoncontroller.getControllerPhase() != DragonControllerPhase.HOVER) { // CraftBukkit - Don't move when hovering + d0 = vec3d1.x - this.locX; + d1 = vec3d1.y - this.locY; + d2 = vec3d1.z - this.locZ; +@@ -315,7 +322,14 @@ if (this.currentEnderCrystal.dead) { this.currentEnderCrystal = null; } else if (this.ticksLived % 10 == 0 && this.getHealth() < this.getMaxHealth()) { @@ -46,31 +47,30 @@ } } -@@ -399,6 +412,10 @@ +@@ -388,6 +402,9 @@ int j1 = MathHelper.floor(axisalignedbb.maxZ); boolean flag = false; boolean flag1 = false; + // CraftBukkit start - Create a list to hold all the destroyed blocks + List destroyedBlocks = new java.util.ArrayList(); -+ org.bukkit.craftbukkit.CraftWorld craftWorld = this.world.getWorld(); + // CraftBukkit end for (int k1 = i; k1 <= l; ++k1) { for (int l1 = j; l1 <= i1; ++l1) { -@@ -412,7 +429,11 @@ +@@ -398,7 +415,11 @@ + + if (!iblockdata.isAir() && iblockdata.getMaterial() != Material.FIRE) { + if (this.world.getGameRules().getBoolean("mobGriefing") && !TagsBlock.DRAGON_IMMUNE.isTagged(block)) { +- flag1 = this.world.a(blockposition, false) || flag1; ++ // CraftBukkit start - Add blocks to list rather than destroying them ++ // flag1 = this.world.a(blockposition, false) || flag1; ++ flag1 = true; ++ destroyedBlocks.add(CraftBlock.at(world, blockposition)); ++ // CraftBukkit end + } else { flag = true; - } else if (block != Blocks.BARRIER && block != Blocks.OBSIDIAN && block != Blocks.END_STONE && block != Blocks.BEDROCK && block != Blocks.END_PORTAL && block != Blocks.END_PORTAL_FRAME) { - if (block != Blocks.COMMAND_BLOCK && block != Blocks.REPEATING_COMMAND_BLOCK && block != Blocks.CHAIN_COMMAND_BLOCK && block != Blocks.IRON_BARS && block != Blocks.END_GATEWAY) { -- flag1 = this.world.setAir(blockposition) || flag1; -+ // CraftBukkit start - Add blocks to list rather than destroying them -+ // flag1 = this.world.setAir(blockposition) || flag1; -+ flag1 = true; -+ destroyedBlocks.add(craftWorld.getBlockAt(k1, l1, i2)); -+ // CraftBukkit end - } else { - flag = true; - } -@@ -424,6 +445,42 @@ + } +@@ -407,6 +428,43 @@ } } @@ -85,7 +85,7 @@ + } 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())); ++ this.world.a(new BlockPosition(block.getX(), block.getY(), block.getZ()), false); + } + } else { + for (org.bukkit.block.Block block : event.blockList()) { @@ -94,22 +94,23 @@ + continue; + } + -+ int blockX = block.getX(); -+ int blockY = block.getY(); -+ int blockZ = block.getZ(); ++ CraftBlock craftBlock = ((CraftBlock) block); ++ BlockPosition blockposition = craftBlock.getPosition(); + -+ Block nmsBlock = org.bukkit.craftbukkit.util.CraftMagicNumbers.getBlock(blockId); ++ Block nmsBlock = craftBlock.getNMS().getBlock(); + if (nmsBlock.a(explosionSource)) { -+ BlockPosition pos = new BlockPosition(blockX, blockY, blockZ); -+ nmsBlock.dropNaturally(world.getType(pos), world, pos, event.getYield(), 0); -+ } -+ nmsBlock.wasExploded(world, new BlockPosition(blockX, blockY, blockZ), explosionSource); ++ TileEntity tileentity = nmsBlock.isTileEntity() ? this.world.getTileEntity(blockposition) : null; ++ LootTableInfo.Builder loottableinfo_builder = (new LootTableInfo.Builder((WorldServer) this.world)).a(this.world.random).set(LootContextParameters.POSITION, blockposition).set(LootContextParameters.TOOL, ItemStack.a).set(LootContextParameters.EXPLOSION_RADIUS, 1.0F / event.getYield()).setOptional(LootContextParameters.BLOCK_ENTITY, tileentity); + -+ this.world.setAir(new BlockPosition(blockX, blockY, blockZ)); ++ Block.b(craftBlock.getNMS(), loottableinfo_builder); ++ } ++ nmsBlock.wasExploded(world, blockposition, explosionSource); ++ ++ this.world.a(blockposition, false); + } + } + // CraftBukkit end + if (flag1) { - double d0 = axisalignedbb.minX + (axisalignedbb.maxX - axisalignedbb.minX) * (double) this.random.nextFloat(); - double d1 = axisalignedbb.minY + (axisalignedbb.maxY - axisalignedbb.minY) * (double) this.random.nextFloat(); + BlockPosition blockposition1 = new BlockPosition(i + this.random.nextInt(l - i + 1), j + this.random.nextInt(i1 - j + 1), k + this.random.nextInt(j1 - k + 1)); + diff --git a/nms-patches/EntityEnderPearl.patch b/nms-patches/EntityEnderPearl.patch index 12b25eb0a3..8c5450a257 100644 --- a/nms-patches/EntityEnderPearl.patch +++ b/nms-patches/EntityEnderPearl.patch @@ -11,14 +11,14 @@ +import org.bukkit.event.player.PlayerTeleportEvent; +// CraftBukkit end - public class EntityEnderPearl extends EntityProjectile { + public class EntityEnderPearl extends EntityProjectileThrowable { -@@ -57,21 +63,35 @@ +@@ -65,21 +71,35 @@ EntityPlayer entityplayer = (EntityPlayer) entityliving; 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); +- EntityEndermite entityendermite = (EntityEndermite) EntityTypes.ENDERMITE.a(this.world); - - entityendermite.setPlayerSpawned(true); - entityendermite.setPositionRotation(entityliving.locX, entityliving.locY, entityliving.locZ, entityliving.yaw, entityliving.pitch); @@ -38,7 +38,7 @@ + + if (!teleEvent.isCancelled() && !entityplayer.playerConnection.isDisconnected()) { + if (this.random.nextFloat() < 0.05F && this.world.getGameRules().getBoolean("doMobSpawning")) { -+ EntityEndermite entityendermite = new EntityEndermite(this.world); ++ EntityEndermite entityendermite = (EntityEndermite) EntityTypes.ENDERMITE.a(this.world); + + entityendermite.setPlayerSpawned(true); + entityendermite.setPositionRotation(entityliving.locX, entityliving.locY, entityliving.locZ, entityliving.yaw, entityliving.pitch); diff --git a/nms-patches/EntityEnderman.patch b/nms-patches/EntityEnderman.patch index 49dc4e2a08..e9390fd4fe 100644 --- a/nms-patches/EntityEnderman.patch +++ b/nms-patches/EntityEnderman.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/EntityEnderman.java +++ b/net/minecraft/server/EntityEnderman.java -@@ -44,7 +44,17 @@ - } +@@ -51,7 +51,17 @@ + @Override public void setGoalTarget(@Nullable EntityLiving entityliving) { - super.setGoalTarget(entityliving); + // CraftBukkit start - fire event @@ -19,33 +19,33 @@ AttributeInstance attributeinstance = this.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED); if (entityliving == null) { -@@ -58,6 +68,7 @@ - attributeinstance.b(EntityEnderman.b); +@@ -65,6 +75,7 @@ + attributeinstance.b(EntityEnderman.c); } } + return true; } -@@ -276,8 +287,12 @@ - boolean flag = movingobjectposition != null && movingobjectposition.getBlockPosition().equals(blockposition); +@@ -294,8 +305,12 @@ + boolean flag = movingobjectpositionblock.getType() != MovingObjectPosition.EnumMovingObjectType.MISS && movingobjectpositionblock.getBlockPosition().equals(blockposition); if (block.a(TagsBlock.ENDERMAN_HOLDABLE) && flag) { - this.enderman.setCarried(iblockdata); -- world.setAir(blockposition); +- world.a(blockposition, false); + // CraftBukkit start - Pickup event + if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.enderman, blockposition, Blocks.AIR.getBlockData()).isCancelled()) { + this.enderman.setCarried(iblockdata); -+ world.setAir(blockposition); ++ world.a(blockposition, false); + } + // CraftBukkit end } } -@@ -307,8 +322,12 @@ +@@ -328,8 +343,12 @@ IBlockData iblockdata2 = this.a.getCarried(); - if (iblockdata2 != null && this.a(world, blockposition, iblockdata2, iblockdata, iblockdata1)) { + if (iblockdata2 != null && this.a(world, blockposition, iblockdata2, iblockdata, iblockdata1, blockposition1)) { + // CraftBukkit start - Place event + if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.a, blockposition, iblockdata2).isCancelled()) { world.setTypeAndData(blockposition, iblockdata2, 3); diff --git a/nms-patches/EntityEvokerFangs.patch b/nms-patches/EntityEvokerFangs.patch index d43b77576f..30081d7296 100644 --- a/nms-patches/EntityEvokerFangs.patch +++ b/nms-patches/EntityEvokerFangs.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/EntityEvokerFangs.java +++ b/net/minecraft/server/EntityEvokerFangs.java -@@ -111,7 +111,9 @@ +@@ -114,7 +114,9 @@ - if (entityliving.isAlive() && !entityliving.bl() && entityliving != entityliving1) { + if (entityliving.isAlive() && !entityliving.isInvulnerable() && entityliving != entityliving1) { if (entityliving1 == null) { + org.bukkit.craftbukkit.event.CraftEventFactory.entityDamage = this; // CraftBukkit entityliving.damageEntity(DamageSource.MAGIC, 6.0F); diff --git a/nms-patches/EntityExperienceOrb.patch b/nms-patches/EntityExperienceOrb.patch index 050cf6e05d..56b4776368 100644 --- a/nms-patches/EntityExperienceOrb.patch +++ b/nms-patches/EntityExperienceOrb.patch @@ -1,26 +1,26 @@ --- a/net/minecraft/server/EntityExperienceOrb.java +++ b/net/minecraft/server/EntityExperienceOrb.java -@@ -1,5 +1,11 @@ +@@ -1,6 +1,11 @@ package net.minecraft.server; + import java.util.Map.Entry; +// CraftBukkit start +import org.bukkit.craftbukkit.event.CraftEventFactory; +import org.bukkit.event.entity.EntityTargetLivingEntityEvent; +import org.bukkit.event.entity.EntityTargetEvent; +// CraftBukkit end -+ + public class EntityExperienceOrb extends Entity { - public int a; -@@ -34,6 +40,7 @@ - +@@ -36,6 +41,7 @@ + @Override public void tick() { super.tick(); + EntityHuman prevTarget = this.targetPlayer;// CraftBukkit - store old target - if (this.c > 0) { - --this.c; + if (this.d > 0) { + --this.d; } -@@ -70,6 +77,16 @@ +@@ -73,6 +79,16 @@ } if (this.targetPlayer != null) { @@ -34,32 +34,42 @@ + } + + if (!cancelled && targetPlayer != null) { - double d1 = (this.targetPlayer.locX - this.locX) / 8.0D; - double d2 = (this.targetPlayer.locY + (double) this.targetPlayer.getHeadHeight() / 2.0D - this.locY) / 8.0D; - double d3 = (this.targetPlayer.locZ - this.locZ) / 8.0D; -@@ -82,6 +99,8 @@ - this.motY += d2 / d4 * d5 * 0.1D; - this.motZ += d3 / d4 * d5 * 0.1D; + Vec3D vec3d = new Vec3D(this.targetPlayer.locX - this.locX, this.targetPlayer.locY + (double) this.targetPlayer.getHeadHeight() / 2.0D - this.locY, this.targetPlayer.locZ - this.locZ); + double d1 = vec3d.g(); + +@@ -81,6 +97,8 @@ + + this.setMot(this.getMot().e(vec3d.d().a(d2 * d2 * 0.1D))); } + } + // CraftBukkit end } - this.move(EnumMoveType.SELF, this.motX, this.motY, this.motZ); -@@ -155,12 +174,18 @@ - if (!itemstack.isEmpty() && itemstack.f()) { - int i = Math.min(this.c(this.value), itemstack.getDamage()); + this.move(EnumMoveType.SELF, this.getMot()); +@@ -113,7 +131,7 @@ + protected void ay() {} -- this.value -= this.b(i); -- itemstack.setDamage(itemstack.getDamage() - i); -+ // CraftBukkit start -+ org.bukkit.event.player.PlayerItemMendEvent event = CraftEventFactory.callPlayerItemMendEvent(entityhuman, this, itemstack, i); -+ i = event.getRepairAmount(); -+ if (!event.isCancelled()) { -+ this.value -= this.b(i); -+ itemstack.setDamage(itemstack.getDamage() - i); -+ } -+ // CraftBukkit end + @Override +- protected void burn(int i) { ++ protected void burn(float i) { // CraftBukkit - int -> float + this.damageEntity(DamageSource.FIRE, (float) i); + } + +@@ -160,13 +178,19 @@ + if (!itemstack.isEmpty() && itemstack.f()) { + int i = Math.min(this.c(this.value), itemstack.getDamage()); + +- this.value -= this.b(i); +- itemstack.setDamage(itemstack.getDamage() - i); ++ // CraftBukkit start ++ org.bukkit.event.player.PlayerItemMendEvent event = CraftEventFactory.callPlayerItemMendEvent(entityhuman, this, itemstack, i); ++ i = event.getRepairAmount(); ++ if (!event.isCancelled()) { ++ this.value -= this.b(i); ++ itemstack.setDamage(itemstack.getDamage() - i); ++ } ++ // CraftBukkit end + } } if (this.value > 0) { @@ -68,7 +78,7 @@ } this.die(); -@@ -182,6 +207,24 @@ +@@ -188,6 +212,24 @@ } public static int getOrbValue(int i) { diff --git a/nms-patches/EntityFallingBlock.patch b/nms-patches/EntityFallingBlock.patch index 76feba7500..3df1448cfa 100644 --- a/nms-patches/EntityFallingBlock.patch +++ b/nms-patches/EntityFallingBlock.patch @@ -9,40 +9,28 @@ public class EntityFallingBlock extends Entity { private IBlockData block; -@@ -71,7 +73,7 @@ +@@ -73,7 +75,7 @@ if (this.ticksLived++ == 0) { blockposition = new BlockPosition(this); - if (this.world.getType(blockposition).getBlock() == block) { + if (this.world.getType(blockposition).getBlock() == block && !CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, Blocks.AIR.getBlockData()).isCancelled()) { - this.world.setAir(blockposition); + this.world.a(blockposition, false); } else if (!this.world.isClientSide) { this.die(); -@@ -112,7 +114,7 @@ +@@ -125,6 +127,11 @@ + this.block = (IBlockData) this.block.set(BlockProperties.C, true); + } - if (!flag1 && BlockFalling.canFallThrough(this.world.getType(new BlockPosition(this.locX, this.locY - 0.009999999776482582D, this.locZ)))) { - this.onGround = false; -- return; -+ // return; // CraftBukkit - } - - this.motX *= 0.699999988079071D; -@@ -121,7 +123,13 @@ - if (iblockdata.getBlock() != Blocks.MOVING_PISTON) { - this.die(); - if (!this.f) { -- if (iblockdata.getMaterial().isReplaceable() && (flag1 || !BlockFalling.canFallThrough(this.world.getType(blockposition.down()))) && this.world.setTypeAndData(blockposition, this.block, 3)) { -+ // CraftBukkit start -+ if (iblockdata.getMaterial().isReplaceable() && (flag1 || !BlockFalling.canFallThrough(this.world.getType(blockposition.down())))) { ++ // CraftBukkit start + if (CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, this.block).isCancelled()) { + return; + } -+ this.world.setTypeAndData(blockposition, this.block, 3); + // CraftBukkit end - if (block instanceof BlockFalling) { - ((BlockFalling) block).a(this.world, blockposition, this.block, iblockdata); - } -@@ -175,7 +183,9 @@ + if (this.world.setTypeAndData(blockposition, this.block, 3)) { + if (block instanceof BlockFalling) { + ((BlockFalling) block).a(this.world, blockposition, this.block, iblockdata); +@@ -179,7 +186,9 @@ while (iterator.hasNext()) { Entity entity = (Entity) iterator.next(); diff --git a/nms-patches/EntityFireball.patch b/nms-patches/EntityFireball.patch index b236dc4b6d..40721cb73b 100644 --- a/nms-patches/EntityFireball.patch +++ b/nms-patches/EntityFireball.patch @@ -15,18 +15,16 @@ + public float bukkitYield = 1; // CraftBukkit + public boolean isIncendiary = true; // CraftBukkit - protected EntityFireball(EntityTypes entitytypes, World world, float f, float f1) { + protected EntityFireball(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -28,11 +32,18 @@ - public EntityFireball(EntityTypes entitytypes, EntityLiving entityliving, double d0, double d1, double d2, World world, float f, float f1) { - this(entitytypes, world, f, f1); +@@ -27,9 +31,16 @@ + public EntityFireball(EntityTypes entitytypes, EntityLiving entityliving, double d0, double d1, double d2, World world) { + this(entitytypes, world); this.shooter = entityliving; + this.projectileSource = (org.bukkit.entity.LivingEntity) entityliving.getBukkitEntity(); // CraftBukkit this.setPositionRotation(entityliving.locX, entityliving.locY, entityliving.locZ, entityliving.yaw, entityliving.pitch); this.setPosition(this.locX, this.locY, this.locZ); - this.motX = 0.0D; - this.motY = 0.0D; - this.motZ = 0.0D; + this.setMot(Vec3D.a); + // CraftBukkit start - Added setDirection method + this.setDirection(d0, d1, d2); + } @@ -36,9 +34,9 @@ d0 += this.random.nextGaussian() * 0.4D; d1 += this.random.nextGaussian() * 0.4D; d2 += this.random.nextGaussian() * 0.4D; -@@ -59,6 +70,12 @@ +@@ -58,6 +69,12 @@ - if (movingobjectposition != null) { + if (movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.MISS) { this.a(movingobjectposition); + + // CraftBukkit start - Fire ProjectileHitEvent @@ -48,21 +46,21 @@ + // CraftBukkit end } - this.locX += this.motX; -@@ -146,6 +163,11 @@ + Vec3D vec3d = this.getMot(); +@@ -147,6 +164,11 @@ } else { - this.aA(); + this.velocityChanged(); if (damagesource.getEntity() != null) { + // CraftBukkit start + if (CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f)) { + return false; + } + // CraftBukkit end - Vec3D vec3d = damagesource.getEntity().aN(); - - if (vec3d != null) { -@@ -159,6 +181,7 @@ + Vec3D vec3d = damagesource.getEntity().getLookDirection(); + this.setMot(vec3d); +@@ -155,6 +177,7 @@ + this.dirZ = vec3d.z * 0.1D; if (damagesource.getEntity() instanceof EntityLiving) { this.shooter = (EntityLiving) damagesource.getEntity(); + this.projectileSource = (org.bukkit.projectiles.ProjectileSource) this.shooter.getBukkitEntity(); diff --git a/nms-patches/EntityFireworks.patch b/nms-patches/EntityFireworks.patch index a0176143cf..7255b84a96 100644 --- a/nms-patches/EntityFireworks.patch +++ b/nms-patches/EntityFireworks.patch @@ -1,39 +1,37 @@ --- a/net/minecraft/server/EntityFireworks.java +++ b/net/minecraft/server/EntityFireworks.java -@@ -2,6 +2,7 @@ - +@@ -3,6 +3,7 @@ import java.util.Iterator; import java.util.List; + import java.util.OptionalInt; +import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit - public class EntityFireworks extends Entity { + public class EntityFireworks extends Entity implements IProjectile { -@@ -114,8 +115,12 @@ +@@ -133,7 +134,11 @@ } if (!this.world.isClientSide && this.ticksFlown > this.expectedLifespan) { -- this.world.broadcastEntityEffect(this, (byte) 17); -- this.i(); +- this.explode(); + // CraftBukkit start + if (!org.bukkit.craftbukkit.event.CraftEventFactory.callFireworkExplodeEvent(this).isCancelled()) { -+ this.world.broadcastEntityEffect(this, (byte) 17); -+ this.i(); ++ this.explode(); + } + // CraftBukkit end - this.die(); } -@@ -133,7 +138,9 @@ + } +@@ -184,7 +189,9 @@ if (f > 0.0F) { - if (this.e != null) { + if (this.ridingEntity != null) { + CraftEventFactory.entityDamage = this; // CraftBukkit - this.e.damageEntity(DamageSource.FIREWORKS, (float) (5 + nbttaglist.size() * 2)); + this.ridingEntity.damageEntity(DamageSource.FIREWORKS, 5.0F + (float) (nbttaglist.size() * 2)); + CraftEventFactory.entityDamage = null; // CraftBukkit } double d0 = 5.0D; -@@ -159,7 +166,9 @@ +@@ -211,7 +218,9 @@ if (flag) { float f1 = f * (float) Math.sqrt((5.0D - (double) this.g(entityliving)) / 5.0D); diff --git a/nms-patches/EntityFish.patch b/nms-patches/EntityFish.patch index 303b99e056..a6dbb3cb3f 100644 --- a/nms-patches/EntityFish.patch +++ b/nms-patches/EntityFish.patch @@ -1,19 +1,19 @@ --- a/net/minecraft/server/EntityFish.java +++ b/net/minecraft/server/EntityFish.java -@@ -29,7 +29,7 @@ - } +@@ -36,7 +36,7 @@ - public boolean isTypeNotPersistent() { + @Override + public boolean isTypeNotPersistent(double d0) { - return !this.isFromBucket() && !this.hasCustomName(); + return true; // CraftBukkit } - public int dg() { -@@ -47,6 +47,7 @@ + @Override +@@ -56,6 +56,7 @@ public void setFromBucket(boolean flag) { - this.datawatcher.set(EntityFish.a, flag); + this.datawatcher.set(EntityFish.FROM_BUCKET, flag); + this.persistent = this.isPersistent(); // CraftBukkit - SPIGOT-4106 update persistence } - public void b(NBTTagCompound nbttagcompound) { + @Override diff --git a/nms-patches/EntityFishingHook.patch b/nms-patches/EntityFishingHook.patch index bc68d94241..d93a2cdb43 100644 --- a/nms-patches/EntityFishingHook.patch +++ b/nms-patches/EntityFishingHook.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/server/EntityFishingHook.java +++ b/net/minecraft/server/EntityFishingHook.java -@@ -3,6 +3,11 @@ - import java.util.Collections; +@@ -4,6 +4,11 @@ import java.util.Iterator; import java.util.List; + import javax.annotation.Nullable; +// CraftBukkit start +import org.bukkit.entity.Player; +import org.bukkit.entity.FishHook; @@ -12,27 +12,27 @@ public class EntityFishingHook extends Entity { -@@ -266,6 +271,7 @@ - } +@@ -207,6 +212,7 @@ + }, RayTrace.BlockCollisionOption.COLLIDER, true); - if (movingobjectposition != null && movingobjectposition.type != MovingObjectPosition.EnumMovingObjectType.MISS) { + if (movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.MISS) { + org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this, movingobjectposition); // Craftbukkit - Call event - if (movingobjectposition.type == MovingObjectPosition.EnumMovingObjectType.ENTITY) { - this.hooked = movingobjectposition.entity; - this.o(); -@@ -298,6 +304,10 @@ - if (this.g <= 0) { - this.h = 0; - this.aw = 0; + if (movingobjectposition.getType() == MovingObjectPosition.EnumMovingObjectType.ENTITY) { + this.hooked = ((MovingObjectPositionEntity) movingobjectposition).getEntity(); + this.n(); +@@ -239,6 +245,10 @@ + if (this.ar <= 0) { + this.as = 0; + this.at = 0; + // CraftBukkit start + PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), null, (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.FAILED_ATTEMPT); + this.world.getServer().getPluginManager().callEvent(playerFishEvent); + // CraftBukkit end } else { - this.motY -= 0.2D * (double) this.random.nextFloat() * (double) this.random.nextFloat(); + this.setMot(this.getMot().add(0.0D, -0.2D * (double) this.random.nextFloat() * (double) this.random.nextFloat(), 0.0D)); } -@@ -333,6 +343,13 @@ - worldserver.a(Particles.x, d0, d1, d2, 0, (double) (-f4), 0.01D, (double) f3, 1.0D); +@@ -274,6 +284,13 @@ + worldserver.a(Particles.FISHING, d0, d1, d2, 0, (double) (-f4), 0.01D, (double) f3, 1.0D); } } else { + // CraftBukkit start @@ -42,10 +42,10 @@ + return; + } + // CraftBukkit end - this.motY = (double) (-0.4F * MathHelper.a(this.random, 0.6F, 1.0F)); - this.a(SoundEffects.ENTITY_FISHING_BOBBER_SPLASH, 0.25F, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F); - double d3 = this.getBoundingBox().minY + 0.5D; -@@ -389,6 +406,14 @@ + Vec3D vec3d = this.getMot(); + + this.setMot(vec3d.x, (double) (-0.4F * MathHelper.a(this.random, 0.6F, 1.0F)), vec3d.z); +@@ -330,6 +347,14 @@ int i = 0; if (this.hooked != null) { @@ -57,10 +57,10 @@ + return 0; + } + // CraftBukkit end - this.f(); + this.reel(); CriterionTriggers.D.a((EntityPlayer) this.owner, itemstack, this, Collections.emptyList()); this.world.broadcastEntityEffect(this, (byte) 31); -@@ -405,6 +430,15 @@ +@@ -345,6 +370,15 @@ while (iterator.hasNext()) { ItemStack itemstack1 = (ItemStack) iterator.next(); EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY, this.locZ, itemstack1); @@ -76,9 +76,9 @@ double d0 = this.owner.locX - this.locX; double d1 = this.owner.locY - this.locY; double d2 = this.owner.locZ - this.locZ; -@@ -415,7 +449,11 @@ - entityitem.motY = d1 * 0.1D + (double) MathHelper.sqrt(d3) * 0.08D; - entityitem.motZ = d2 * 0.1D; +@@ -352,7 +386,11 @@ + + entityitem.setMot(d0 * 0.1D, d1 * 0.1D + Math.sqrt(Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2)) * 0.08D, d2 * 0.1D); 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() @@ -89,7 +89,7 @@ if (itemstack1.getItem().a(TagsItem.FISHES)) { this.owner.a(StatisticList.FISH_CAUGHT, 1); } -@@ -425,8 +463,25 @@ +@@ -362,8 +400,25 @@ } if (this.isInGround) { diff --git a/nms-patches/EntityGhast.patch b/nms-patches/EntityGhast.patch index 8e11962ab2..b5b58cf7d3 100644 --- a/nms-patches/EntityGhast.patch +++ b/nms-patches/EntityGhast.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/EntityGhast.java +++ b/net/minecraft/server/EntityGhast.java -@@ -154,7 +154,8 @@ +@@ -168,7 +168,8 @@ world.a((EntityHuman) null, 1016, new BlockPosition(this.ghast), 0); EntityLargeFireball entitylargefireball = new EntityLargeFireball(world, this.ghast, d2, d3, d4); @@ -8,5 +8,5 @@ + // CraftBukkit - set bukkitYield when setting explosionpower + entitylargefireball.bukkitYield = entitylargefireball.yield = this.ghast.getPower(); entitylargefireball.locX = this.ghast.locX + vec3d.x * 4.0D; - entitylargefireball.locY = this.ghast.locY + (double) (this.ghast.length / 2.0F) + 0.5D; + entitylargefireball.locY = this.ghast.locY + (double) (this.ghast.getHeight() / 2.0F) + 0.5D; entitylargefireball.locZ = this.ghast.locZ + vec3d.z * 4.0D; diff --git a/nms-patches/EntityGuardianElder.patch b/nms-patches/EntityGuardianElder.patch index e7977fe70a..f5f5291cac 100644 --- a/nms-patches/EntityGuardianElder.patch +++ b/nms-patches/EntityGuardianElder.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/EntityGuardianElder.java +++ b/net/minecraft/server/EntityGuardianElder.java -@@ -67,7 +67,7 @@ +@@ -69,7 +69,7 @@ if (!entityplayer.hasEffect(mobeffectlist) || entityplayer.getEffect(mobeffectlist).getAmplifier() < 2 || entityplayer.getEffect(mobeffectlist).getDuration() < 1200) { entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(10, 0.0F)); diff --git a/nms-patches/EntityHanging.patch b/nms-patches/EntityHanging.patch index 83063756c6..66e94dd2af 100644 --- a/nms-patches/EntityHanging.patch +++ b/nms-patches/EntityHanging.patch @@ -12,7 +12,7 @@ + public abstract class EntityHanging extends Entity { - protected static final Predicate a = (entity) -> { + protected static final Predicate b = (entity) -> { @@ -35,43 +41,52 @@ this.updateBoundingBox(); } @@ -23,8 +23,8 @@ - double d1 = (double) this.blockPosition.getY() + 0.5D; - double d2 = (double) this.blockPosition.getZ() + 0.5D; - double d3 = 0.46875D; -- double d4 = this.a(this.getWidth()); -- double d5 = this.a(this.getHeight()); +- double d4 = this.a(this.getHangingWidth()); +- double d5 = this.a(this.getHangingHeight()); - - d0 -= (double) this.direction.getAdjacentX() * 0.46875D; - d2 -= (double) this.direction.getAdjacentZ() * 0.46875D; @@ -60,9 +60,9 @@ - this.locX = d0; - this.locY = d1; - this.locZ = d2; -- double d6 = (double) this.getWidth(); -- double d7 = (double) this.getHeight(); -- double d8 = (double) this.getWidth(); +- double d6 = (double) this.getHangingWidth(); +- double d7 = (double) this.getHangingHeight(); +- double d8 = (double) this.getHangingWidth(); - - if (this.direction.k() == EnumDirection.EnumAxis.Z) { - d8 = 1.0D; @@ -74,21 +74,21 @@ + } else { + d6 = 1.0D; + } - -- d6 /= 32.0D; -- d7 /= 32.0D; -- d8 /= 32.0D; -- this.a(new AxisAlignedBB(d0 - d6, d1 - d7, d2 - d8, d0 + d6, d1 + d7, d2 + d8)); ++ + d6 /= 32.0D; + d7 /= 32.0D; + d8 /= 32.0D; + return new AxisAlignedBB(d0 - d6, d1 - d7, d2 - d8, d0 + d6, d1 + d7, d2 + d8); + } -+ + +- d6 /= 32.0D; +- d7 /= 32.0D; +- d8 /= 32.0D; +- this.a(new AxisAlignedBB(d0 - d6, d1 - d7, d2 - d8, d0 + d6, d1 + d7, d2 + d8)); + protected void updateBoundingBox() { + if (this.direction != null) { + // CraftBukkit start code moved in to calculateBoundingBox -+ this.a(calculateBoundingBox(this, this.blockPosition, this.direction, this.getWidth(), this.getHeight())); ++ this.a(calculateBoundingBox(this, this.blockPosition, this.direction, this.getHangingWidth(), this.getHangingHeight())); + // CraftBukkit end } } @@ -98,9 +98,9 @@ return i % 32 == 0 ? 0.5D : 0.0D; } -@@ -82,6 +97,24 @@ - if (this.d++ == 100 && !this.world.isClientSide) { - this.d = 0; +@@ -83,6 +98,24 @@ + if (this.e++ == 100 && !this.world.isClientSide) { + this.e = 0; if (!this.dead && !this.survives()) { + // CraftBukkit start - fire break events + Material material = this.world.getType(new BlockPosition(this)).getMaterial(); @@ -123,7 +123,7 @@ this.die(); this.a((Entity) null); } -@@ -134,6 +167,21 @@ +@@ -139,6 +172,21 @@ return false; } else { if (!this.dead && !this.world.isClientSide) { @@ -143,12 +143,12 @@ + // CraftBukkit end + this.die(); - this.aA(); + this.velocityChanged(); this.a(damagesource.getEntity()); -@@ -145,6 +193,18 @@ - - public void move(EnumMoveType enummovetype, double d0, double d1, double d2) { - if (!this.world.isClientSide && !this.dead && d0 * d0 + d1 * d1 + d2 * d2 > 0.0D) { +@@ -151,6 +199,18 @@ + @Override + public void move(EnumMoveType enummovetype, Vec3D vec3d) { + if (!this.world.isClientSide && !this.dead && vec3d.g() > 0.0D) { + if (this.dead) return; // CraftBukkit + + // CraftBukkit start - fire break events @@ -164,9 +164,9 @@ this.die(); this.a((Entity) null); } -@@ -152,7 +212,7 @@ - } +@@ -159,7 +219,7 @@ + @Override public void f(double d0, double d1, double d2) { - if (!this.world.isClientSide && !this.dead && d0 * d0 + d1 * d1 + d2 * d2 > 0.0D) { + if (false && !this.world.isClientSide && !this.dead && d0 * d0 + d1 * d1 + d2 * d2 > 0.0D) { // CraftBukkit - not needed diff --git a/nms-patches/EntityHorseAbstract.patch b/nms-patches/EntityHorseAbstract.patch index 8d0d0bc4ec..6ff40b1475 100644 --- a/nms-patches/EntityHorseAbstract.patch +++ b/nms-patches/EntityHorseAbstract.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/EntityHorseAbstract.java +++ b/net/minecraft/server/EntityHorseAbstract.java -@@ -6,6 +6,7 @@ +@@ -5,6 +5,7 @@ import java.util.UUID; import java.util.function.Predicate; import javax.annotation.Nullable; @@ -9,23 +9,23 @@ public abstract class EntityHorseAbstract extends EntityAnimal implements IInventoryListener, IJumpable { @@ -33,6 +34,7 @@ - private float bY; - protected boolean bK = true; - protected int bL; + private float bW; + protected boolean bH = true; + protected int bI; + public int maxDomestication = 100; // CraftBukkit - store max domestication value - protected EntityHorseAbstract(EntityTypes entitytypes, World world) { + protected EntityHorseAbstract(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -212,7 +214,7 @@ +@@ -209,7 +211,7 @@ public void loadChest() { - InventoryHorseChest inventoryhorsechest = this.inventoryChest; + InventorySubcontainer inventorysubcontainer = this.inventoryChest; -- this.inventoryChest = new InventoryHorseChest(this.getDisplayName(), this.dA()); -+ this.inventoryChest = new InventoryHorseChest(this.getDisplayName(), this.dA(), this); // CraftBukkit - this.inventoryChest.a(this.getCustomName()); - if (inventoryhorsechest != null) { - inventoryhorsechest.b(this); -@@ -348,7 +350,7 @@ +- this.inventoryChest = new InventorySubcontainer(this.getChestSlots()); ++ this.inventoryChest = new InventorySubcontainer(this.getChestSlots(), (org.bukkit.entity.AbstractHorse) this.getBukkitEntity()); // CraftBukkit + if (inventorysubcontainer != null) { + inventorysubcontainer.b(this); + int i = Math.min(inventorysubcontainer.getSize(), this.inventoryChest.getSize()); +@@ -332,7 +334,7 @@ } public int getMaxDomestication() { @@ -33,8 +33,8 @@ + return this.maxDomestication; // CraftBukkit - return stored max domestication instead of 100 } - protected float cD() { -@@ -408,7 +410,7 @@ + @Override +@@ -393,7 +395,7 @@ } if (this.getHealth() < this.getMaxHealth() && f > 0.0F) { @@ -43,33 +43,16 @@ flag = true; } -@@ -459,7 +461,7 @@ - } - - public void die(DamageSource damagesource) { -- super.die(damagesource); -+ // super.die(damagesource); // Moved down - if (!this.world.isClientSide && this.inventoryChest != null) { - for (int i = 0; i < this.inventoryChest.getSize(); ++i) { - ItemStack itemstack = this.inventoryChest.getItem(i); -@@ -470,6 +472,7 @@ - } - - } -+ super.die(damagesource); // CraftBukkit - } - - public void movementTick() { -@@ -480,7 +483,7 @@ +@@ -469,7 +471,7 @@ super.movementTick(); - if (!this.world.isClientSide) { + if (!this.world.isClientSide && this.isAlive()) { if (this.random.nextInt(900) == 0 && this.deathTicks == 0) { - this.heal(1.0F); + this.heal(1.0F, RegainReason.REGEN); // CraftBukkit } - if (this.dY()) { -@@ -716,6 +719,7 @@ + if (this.et()) { +@@ -716,6 +718,7 @@ if (this.getOwnerUUID() != null) { nbttagcompound.setString("OwnerUUID", this.getOwnerUUID().toString()); } @@ -77,7 +60,7 @@ if (!this.inventoryChest.getItem(0).isEmpty()) { nbttagcompound.set("SaddleItem", this.inventoryChest.getItem(0).save(new NBTTagCompound())); -@@ -742,6 +746,11 @@ +@@ -743,6 +746,11 @@ if (!s.isEmpty()) { this.setOwnerUUID(UUID.fromString(s)); } @@ -89,9 +72,9 @@ AttributeInstance attributeinstance = this.getAttributeMap().a("Speed"); -@@ -794,6 +803,18 @@ - } +@@ -800,6 +808,18 @@ + @Override public void b(int i) { + // CraftBukkit start + float power; @@ -106,5 +89,5 @@ + } + // CraftBukkit end this.canSlide = true; - this.dH(); + this.eB(); } diff --git a/nms-patches/EntityHorseChestedAbstract.patch b/nms-patches/EntityHorseChestedAbstract.patch deleted file mode 100644 index 0fff1fc3a7..0000000000 --- a/nms-patches/EntityHorseChestedAbstract.patch +++ /dev/null @@ -1,23 +0,0 @@ ---- a/net/minecraft/server/EntityHorseChestedAbstract.java -+++ b/net/minecraft/server/EntityHorseChestedAbstract.java -@@ -43,14 +43,18 @@ - } - - public void die(DamageSource damagesource) { -- super.die(damagesource); -+ // super.die(damagesource); // CraftBukkit - moved down - if (this.isCarryingChest()) { - if (!this.world.isClientSide) { - this.a((IMaterial) Blocks.CHEST); - } - -- this.setCarryingChest(false); -+ // this.setCarryingChest(false); // CraftBukkit - moved down - } -+ // CraftBukkit start -+ super.die(damagesource); -+ this.setCarryingChest(false); -+ // CraftBukkit end - - } - diff --git a/nms-patches/EntityHuman.patch b/nms-patches/EntityHuman.patch index 8d71d19f91..6885da8d53 100644 --- a/nms-patches/EntityHuman.patch +++ b/nms-patches/EntityHuman.patch @@ -1,11 +1,12 @@ --- a/net/minecraft/server/EntityHuman.java +++ b/net/minecraft/server/EntityHuman.java -@@ -12,6 +12,18 @@ +@@ -15,10 +15,24 @@ import java.util.function.Predicate; import javax.annotation.Nullable; +// CraftBukkit start +import org.bukkit.craftbukkit.entity.CraftHumanEntity; ++import org.bukkit.craftbukkit.util.CraftVector; +import org.bukkit.entity.Item; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.CreatureSpawnEvent; @@ -18,21 +19,27 @@ + public abstract class EntityHuman extends EntityLiving { - private static final DataWatcherObject a = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.c); -@@ -21,10 +33,10 @@ - protected static final DataWatcherObject bz = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.p); - protected static final DataWatcherObject bA = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.p); - public PlayerInventory inventory = new PlayerInventory(this); + public static final EntitySize bs = EntitySize.b(0.6F, 1.8F); +- private static final Map b = ImmutableMap.builder().put(EntityPose.STANDING, EntityHuman.bs).put(EntityPose.SLEEPING, EntityHuman.as).put(EntityPose.FALL_FLYING, EntitySize.b(0.6F, 0.6F)).put(EntityPose.SWIMMING, EntitySize.b(0.6F, 0.6F)).put(EntityPose.SPIN_ATTACK, EntitySize.b(0.6F, 0.6F)).put(EntityPose.SNEAKING, EntitySize.b(0.6F, 1.5F)).put(EntityPose.DYING, EntitySize.c(0.2F, 0.2F)).build(); ++ // CraftBukkit - decompile error ++ private static final Map b = ImmutableMap.builder().put(EntityPose.STANDING, EntityHuman.bs).put(EntityPose.SLEEPING, EntityHuman.as).put(EntityPose.FALL_FLYING, EntitySize.b(0.6F, 0.6F)).put(EntityPose.SWIMMING, EntitySize.b(0.6F, 0.6F)).put(EntityPose.SPIN_ATTACK, EntitySize.b(0.6F, 0.6F)).put(EntityPose.SNEAKING, EntitySize.b(0.6F, 1.5F)).put(EntityPose.DYING, EntitySize.c(0.2F, 0.2F)).build(); + private static final DataWatcherObject c = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.c); + private static final DataWatcherObject d = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.b); + protected static final DataWatcherObject bt = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.a); +@@ -26,10 +40,10 @@ + protected static final DataWatcherObject bv = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.p); + protected static final DataWatcherObject bw = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.p); + public final PlayerInventory inventory = new PlayerInventory(this); - protected InventoryEnderChest enderChest = new InventoryEnderChest(); + protected InventoryEnderChest enderChest = new InventoryEnderChest(this); // CraftBukkit - add "this" to constructor - public Container defaultContainer; + public final ContainerPlayer defaultContainer; public Container activeContainer; - protected FoodMetaData foodData = new FoodMetaData(); + protected FoodMetaData foodData = new FoodMetaData(this); // CraftBukkit - add "this" to constructor - protected int bG; - public float bH; - public float bI; -@@ -57,6 +69,17 @@ + protected int bC; + public float bD; + public float bE; +@@ -57,6 +71,17 @@ @Nullable public EntityFishingHook hookedFish; @@ -49,8 +56,8 @@ + public EntityHuman(World world, GameProfile gameprofile) { super(EntityTypes.PLAYER, world); - this.cd = ItemStack.a; -@@ -181,7 +204,7 @@ + this.bX = ItemStack.a; +@@ -179,7 +204,7 @@ ItemStack itemstack = this.getEquipment(EnumItemSlot.HEAD); if (itemstack.getItem() == Items.TURTLE_HELMET && !this.a(TagsFluid.WATER)) { @@ -59,7 +66,7 @@ } } -@@ -366,7 +389,8 @@ +@@ -352,7 +377,8 @@ if (this.world.getDifficulty() == EnumDifficulty.PEACEFUL && this.world.getGameRules().getBoolean("naturalRegeneration")) { if (this.getHealth() < this.getMaxHealth() && this.ticksLived % 20 == 0) { @@ -69,25 +76,16 @@ } if (this.foodData.c() && this.ticksLived % 10 == 0) { -@@ -390,7 +414,7 @@ - - this.o((float) attributeinstance.getValue()); - float f = MathHelper.sqrt(this.motX * this.motX + this.motZ * this.motZ); -- float f1 = (float) (Math.atan(-this.motY * 0.20000000298023224D) * 15.0D); -+ float f1 = (float) ( org.bukkit.craftbukkit.TrigMath.atan(-this.motY * 0.20000000298023224D) * 15.0D); // CraftBukkit - - if (f > 0.1F) { - f = 0.1F; -@@ -513,6 +537,7 @@ +@@ -497,6 +523,7 @@ @Nullable - public EntityItem a(boolean flag) { + public EntityItem n(boolean flag) { + // Called only when dropped by Q or CTRL-Q return this.a(this.inventory.splitStack(this.inventory.itemInHandIndex, flag && !this.inventory.getItemInHand().isEmpty() ? this.inventory.getItemInHand().getCount() : 1), false, true); } -@@ -555,6 +580,30 @@ - entityitem.motZ += Math.sin((double) f1) * (double) f; +@@ -537,6 +564,30 @@ + entityitem.setMot((double) (-f3 * f2 * 0.3F) + Math.cos((double) f5) * (double) f6, (double) (-f1 * 0.3F + 0.1F + (this.random.nextFloat() - this.random.nextFloat()) * 0.1F), (double) (f4 * f2 * 0.3F) + Math.sin((double) f5) * (double) f6); } + // CraftBukkit start - fire PlayerDropItemEvent @@ -114,13 +112,14 @@ + } + // CraftBukkit end + - ItemStack itemstack1 = this.a(entityitem); - - if (flag1) { -@@ -649,6 +698,13 @@ - this.a(true, true, false); + return entityitem; + } + } +@@ -611,6 +662,14 @@ } + this.setScore(nbttagcompound.getInt("Score")); ++ + // CraftBukkit start + this.spawnWorld = nbttagcompound.getString("SpawnWorld"); + if ("".equals(spawnWorld)) { @@ -129,9 +128,9 @@ + // CraftBukkit end + if (nbttagcompound.hasKeyOfType("SpawnX", 99) && nbttagcompound.hasKeyOfType("SpawnY", 99) && nbttagcompound.hasKeyOfType("SpawnZ", 99)) { - this.e = new BlockPosition(nbttagcompound.getInt("SpawnX"), nbttagcompound.getInt("SpawnY"), nbttagcompound.getInt("SpawnZ")); - this.f = nbttagcompound.getBoolean("SpawnForced"); -@@ -699,6 +755,7 @@ + this.f = new BlockPosition(nbttagcompound.getInt("SpawnX"), nbttagcompound.getInt("SpawnY"), nbttagcompound.getInt("SpawnZ")); + this.g = nbttagcompound.getBoolean("SpawnForced"); +@@ -661,6 +720,7 @@ if (!this.getShoulderEntityRight().isEmpty()) { nbttagcompound.set("ShoulderEntityRight", this.getShoulderEntityRight()); } @@ -139,10 +138,10 @@ } -@@ -716,10 +773,10 @@ - this.a(true, true, false); - } - +@@ -675,10 +735,10 @@ + if (this.getHealth() <= 0.0F) { + return false; + } else { - this.releaseShoulderEntities(); + // this.releaseShoulderEntities(); // CraftBukkit - moved down if (damagesource.s()) { @@ -152,7 +151,7 @@ } if (this.world.getDifficulty() == EnumDifficulty.EASY) { -@@ -731,7 +788,13 @@ +@@ -690,7 +750,13 @@ } } @@ -167,7 +166,7 @@ } } } -@@ -745,10 +808,29 @@ +@@ -705,10 +771,29 @@ } public boolean a(EntityHuman entityhuman) { @@ -199,13 +198,14 @@ + // CraftBukkit end } - protected void damageArmor(float f) { -@@ -791,7 +873,12 @@ - return (float) i / (float) this.inventory.armor.size(); + @Override +@@ -739,8 +824,13 @@ + } -- protected void damageEntity0(DamageSource damagesource, float f) { + // CraftBukkit start + @Override +- protected void damageEntity0(DamageSource damagesource, float f) { + protected boolean damageEntity0(DamageSource damagesource, float f) { // void -> boolean + if (true) { + return super.damageEntity0(damagesource, f); @@ -214,7 +214,7 @@ if (!this.isInvulnerable(damagesource)) { f = this.applyArmorModifier(damagesource, f); f = this.applyMagicModifier(damagesource, f); -@@ -817,6 +904,7 @@ +@@ -766,6 +856,7 @@ } } @@ -222,7 +222,7 @@ } public void openSign(TileEntitySign tileentitysign) {} -@@ -938,8 +1026,15 @@ +@@ -896,8 +987,15 @@ if (entity instanceof EntityLiving) { f3 = ((EntityLiving) entity).getHealth(); if (j > 0 && !entity.isBurning()) { @@ -240,10 +240,10 @@ } } -@@ -970,8 +1065,11 @@ +@@ -925,8 +1023,11 @@ EntityLiving entityliving = (EntityLiving) iterator.next(); - if (entityliving != this && entityliving != entity && !this.r(entityliving) && (!(entityliving instanceof EntityArmorStand) || !((EntityArmorStand) entityliving).isMarker()) && this.h(entityliving) < 9.0D) { + if (entityliving != this && entityliving != entity && !this.r(entityliving) && (!(entityliving instanceof EntityArmorStand) || !((EntityArmorStand) entityliving).isMarker()) && this.h((Entity) entityliving) < 9.0D) { + // CraftBukkit start - Only apply knockback if the damage hits + if (entityliving.damageEntity(DamageSource.playerAttack(this).sweep(), f4)) { entityliving.a(this, 0.4F, (double) MathHelper.sin(this.yaw * 0.017453292F), (double) (-MathHelper.cos(this.yaw * 0.017453292F))); @@ -253,14 +253,14 @@ } } -@@ -980,11 +1078,28 @@ +@@ -935,9 +1036,26 @@ } if (entity instanceof EntityPlayer && entity.velocityChanged) { + // CraftBukkit start - Add Velocity Event + boolean cancelled = false; + Player player = (Player) entity.getBukkitEntity(); -+ org.bukkit.util.Vector velocity = new Vector( d1, d2, d3 ); ++ org.bukkit.util.Vector velocity = CraftVector.toBukkit(vec3d); + + PlayerVelocityEvent event = new PlayerVelocityEvent(player, velocity.clone()); + world.getServer().getPluginManager().callEvent(event); @@ -274,15 +274,13 @@ + if (!cancelled) { ((EntityPlayer) entity).playerConnection.sendPacket(new PacketPlayOutEntityVelocity(entity)); entity.velocityChanged = false; - entity.motX = d1; - entity.motY = d2; - entity.motZ = d3; + entity.setMot(vec3d); + } + // CraftBukkit end } if (flag2) { -@@ -1033,7 +1148,14 @@ +@@ -982,7 +1100,14 @@ this.a(StatisticList.DAMAGE_DEALT, Math.round(f5 * 10.0F)); if (j > 0) { @@ -298,7 +296,7 @@ } if (this.world instanceof WorldServer && f5 > 2.0F) { -@@ -1049,6 +1171,11 @@ +@@ -998,6 +1123,11 @@ if (flag4) { entity.extinguish(); } @@ -310,63 +308,63 @@ } } -@@ -1110,15 +1237,15 @@ - return this.h; +@@ -1057,15 +1187,15 @@ + return this.bV; } -- public EntityHuman.EnumBedResult a(BlockPosition blockposition) { +- public Either sleep(BlockPosition blockposition) { - EnumDirection enumdirection = (EnumDirection) this.world.getType(blockposition).get(BlockFacingHorizontal.FACING); - + // CraftBukkit start - moved bed result checks from below into separate method -+ private EntityHuman.EnumBedResult getBedResult(BlockPosition blockposition, EnumDirection enumdirection) { ++ private Either getBedResult(BlockPosition blockposition, EnumDirection enumdirection) { if (!this.world.isClientSide) { if (this.isSleeping() || !this.isAlive()) { - return EntityHuman.EnumBedResult.OTHER_PROBLEM; + return Either.left(EntityHuman.EnumBedResult.OTHER_PROBLEM); } - if (!this.world.worldProvider.isOverworld()) { + // CraftBukkit - moved world and biome check from BlockBed interact handling here + if (!world.worldProvider.canRespawn() || world.getBiome(blockposition) == Biomes.NETHER || !this.world.worldProvider.isOverworld()) { - return EntityHuman.EnumBedResult.NOT_POSSIBLE_HERE; + return Either.left(EntityHuman.EnumBedResult.NOT_POSSIBLE_HERE); } -@@ -1140,6 +1267,34 @@ +@@ -1093,6 +1223,34 @@ } } } -+ return EntityHuman.EnumBedResult.OK; ++ return Either.right(Unit.INSTANCE); + } + -+ public EntityHuman.EnumBedResult a(BlockPosition blockposition) { ++ public Either sleep(BlockPosition blockposition) { + // CraftBukkit start - moved checks into separate method above, add force -+ return this.a(blockposition, false); ++ return this.sleep(blockposition, false); + } + -+ public EntityHuman.EnumBedResult a(BlockPosition blockposition, boolean force) { ++ public Either sleep(BlockPosition blockposition, boolean force) { + EnumDirection enumdirection = (EnumDirection) this.world.getType(blockposition).get(BlockFacingHorizontal.FACING); -+ EntityHuman.EnumBedResult bedResult = this.getBedResult(blockposition, enumdirection); ++ Either bedResult = this.getBedResult(blockposition, enumdirection); + -+ if (bedResult == EntityHuman.EnumBedResult.OTHER_PROBLEM) { ++ if (bedResult.left().orElse(null) == EntityHuman.EnumBedResult.OTHER_PROBLEM) { + return bedResult; // return immediately if the result is not bypassable by plugins + } + + if (force) { -+ bedResult = EnumBedResult.OK; ++ bedResult = Either.right(Unit.INSTANCE); + } + + if (this.getBukkitEntity() instanceof Player) { + bedResult = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerBedEnterEvent(this, blockposition, bedResult); + -+ if (bedResult != EntityHuman.EnumBedResult.OK) { ++ if (bedResult.left().isPresent()) { + return bedResult; + } + } + // CraftBukkit end - if (this.isPassenger()) { - this.stopRiding(); -@@ -1206,6 +1361,24 @@ - this.world.everyoneSleeping(); + this.e(blockposition); + this.sleepTicks = 0; +@@ -1134,6 +1292,24 @@ + ((WorldServer) this.world).everyoneSleeping(); } + // CraftBukkit start - fire PlayerBedLeaveEvent @@ -374,7 +372,7 @@ + Player player = (Player) this.getBukkitEntity(); + + org.bukkit.block.Block bed; -+ BlockPosition blockposition = this.bedPosition; ++ BlockPosition blockposition = this.getBed(); + if (blockposition != null) { + bed = this.world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); + } else { @@ -389,22 +387,22 @@ + this.sleepTicks = flag ? 0 : 100; if (flag2) { - this.setRespawnPosition(this.bedPosition, false); -@@ -1257,9 +1430,11 @@ + optional.ifPresent((blockposition) -> { +@@ -1188,9 +1364,11 @@ if (blockposition != null) { - this.e = blockposition; - this.f = flag; + this.f = blockposition; + this.g = flag; + this.spawnWorld = this.world.worldData.getName(); // CraftBukkit } else { - this.e = null; - this.f = false; + this.f = null; + this.g = false; + this.spawnWorld = ""; // CraftBukkit } } -@@ -1325,7 +1500,11 @@ - this.motY = d3 * 0.6D; - this.aU = f3; +@@ -1262,7 +1440,11 @@ + this.setMot(vec3d2.x, d3 * 0.6D, vec3d2.z); + this.aO = f; this.fallDistance = 0.0F; - this.setFlag(7, false); + // CraftBukkit start @@ -413,9 +411,9 @@ + } + // CraftBukkit end } else { - super.a(f, f1, f2); + super.e(vec3d); } -@@ -1625,13 +1804,17 @@ +@@ -1581,24 +1763,29 @@ } protected void releaseShoulderEntities() { @@ -436,14 +434,17 @@ - private void spawnEntityFromShoulder(@Nullable NBTTagCompound nbttagcompound) { + private boolean spawnEntityFromShoulder(@Nullable NBTTagCompound nbttagcompound) { // CraftBukkit void->boolean if (!this.world.isClientSide && !nbttagcompound.isEmpty()) { - Entity entity = EntityTypes.a(nbttagcompound, this.world); +- EntityTypes.a(nbttagcompound, this.world).ifPresent((entity) -> { ++ return EntityTypes.a(nbttagcompound, this.world).map((entity) -> { // CraftBukkit + if (entity instanceof EntityTameableAnimal) { + ((EntityTameableAnimal) entity).setOwnerUUID(this.uniqueID); + } -@@ -1640,9 +1823,10 @@ - } - - entity.setPosition(this.locX, this.locY + 0.699999988079071D, this.locZ); -- this.world.addEntity(entity); -+ return this.world.addEntity(entity, CreatureSpawnEvent.SpawnReason.SHOULDER_ENTITY); // CraftBukkit + entity.setPosition(this.locX, this.locY + 0.699999988079071D, this.locZ); +- ((WorldServer) this.world).addEntitySerialized(entity); +- }); ++ return ((WorldServer) this.world).addEntitySerialized(entity, CreatureSpawnEvent.SpawnReason.SHOULDER_ENTITY); // CraftBukkit ++ }).orElse(true); // CraftBukkit } + return true; // CraftBukkit diff --git a/nms-patches/EntityIllagerIllusioner.patch b/nms-patches/EntityIllagerIllusioner.patch index ba18ec7ced..d279307da5 100644 --- a/nms-patches/EntityIllagerIllusioner.patch +++ b/nms-patches/EntityIllagerIllusioner.patch @@ -1,17 +1,26 @@ --- a/net/minecraft/server/EntityIllagerIllusioner.java +++ b/net/minecraft/server/EntityIllagerIllusioner.java -@@ -164,7 +164,7 @@ - } +@@ -30,7 +30,7 @@ + this.goalSelector.a(8, new PathfinderGoalRandomStroll(this, 0.6D)); + this.goalSelector.a(9, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 3.0F, 1.0F)); + this.goalSelector.a(10, new PathfinderGoalLookAtPlayer(this, EntityInsentient.class, 8.0F)); +- this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[] { EntityRaider.class})).a()); ++ this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[] { EntityRaider.class})).a(new Class[0])); // CraftBukkit - decompile error + this.targetSelector.a(2, (new PathfinderGoalNearestAttackableTarget<>(this, EntityHuman.class, true)).a(300)); + this.targetSelector.a(3, (new PathfinderGoalNearestAttackableTarget<>(this, EntityVillagerAbstract.class, false)).a(300)); + this.targetSelector.a(3, (new PathfinderGoalNearestAttackableTarget<>(this, EntityIronGolem.class, false)).a(300)); +@@ -173,7 +173,7 @@ + @Override protected void j() { - EntityIllagerIllusioner.this.getGoalTarget().addEffect(new MobEffect(MobEffects.BLINDNESS, 400)); + EntityIllagerIllusioner.this.getGoalTarget().addEffect(new MobEffect(MobEffects.BLINDNESS, 400), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit } - protected SoundEffect k() { -@@ -195,7 +195,7 @@ - } + @Override +@@ -210,7 +210,7 @@ + @Override protected void j() { - EntityIllagerIllusioner.this.addEffect(new MobEffect(MobEffects.INVISIBILITY, 1200)); + EntityIllagerIllusioner.this.addEffect(new MobEffect(MobEffects.INVISIBILITY, 1200), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ILLUSION); // CraftBukkit diff --git a/nms-patches/EntityInsentient.patch b/nms-patches/EntityInsentient.patch index c9a3049485..25db0961a9 100644 --- a/nms-patches/EntityInsentient.patch +++ b/nms-patches/EntityInsentient.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/EntityInsentient.java +++ b/net/minecraft/server/EntityInsentient.java -@@ -10,6 +10,18 @@ +@@ -8,6 +8,18 @@ import java.util.UUID; import javax.annotation.Nullable; @@ -18,27 +18,27 @@ + public abstract class EntityInsentient extends EntityLiving { - private static final DataWatcherObject a = DataWatcher.a(EntityInsentient.class, DataWatcherRegistry.a); -@@ -28,7 +40,7 @@ - public float[] dropChanceHand; - private final NonNullList bE; - public float[] dropChanceArmor; -- public boolean canPickUpLoot; -+ // public boolean canPickUpLoot; // CraftBukkit - moved up to EntityLiving + private static final DataWatcherObject b = DataWatcher.a(EntityInsentient.class, DataWatcherRegistry.a); +@@ -26,7 +38,7 @@ + public final float[] dropChanceHand; + private final NonNullList bB; + public final float[] dropChanceArmor; +- private boolean canPickUpLoot; ++ // private boolean canPickUpLoot; // CraftBukkit - moved up to EntityLiving public boolean persistent; - private final Map bH; + private final Map bE; public MinecraftKey lootTableKey; -@@ -58,6 +70,9 @@ - this.n(); +@@ -62,6 +74,9 @@ + this.initPathfinder(); } + // CraftBukkit start - default persistance to type's persistance value -+ this.persistent = !isTypeNotPersistent(); ++ this.persistent = !isTypeNotPersistent(0); + // CraftBukkit end } - protected void n() {} -@@ -111,7 +126,38 @@ + protected void initPathfinder() {} +@@ -129,7 +144,38 @@ } public void setGoalTarget(@Nullable EntityLiving entityliving) { @@ -76,18 +76,18 @@ + // CraftBukkit end } - public boolean b(Class oclass) { -@@ -337,11 +383,20 @@ - + @Override +@@ -345,11 +391,20 @@ + @Override 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.p(nbttagcompound.getBoolean("CanPickUpLoot")); +- this.setCanPickupLoot(nbttagcompound.getBoolean("CanPickUpLoot")); + boolean data = nbttagcompound.getBoolean("CanPickUpLoot"); + if (isLevelAtLeast(nbttagcompound, 1) || data) { -+ this.p(data); ++ this.setCanPickupLoot(data); + } } @@ -100,9 +100,9 @@ NBTTagList nbttaglist; int i; -@@ -395,6 +450,11 @@ - protected MinecraftKey getDefaultLootTable() { - return null; +@@ -403,6 +458,11 @@ + super.a(damagesource, flag); + this.lootTableKey = null; } + // CraftBukkit - start + public MinecraftKey getLootTable() { @@ -110,15 +110,15 @@ + } + // CraftBukkit - end - protected void a(boolean flag, int i, DamageSource damagesource) { - MinecraftKey minecraftkey = this.lootTableKey; -@@ -471,11 +531,21 @@ + @Override + protected LootTableInfo.Builder a(boolean flag, DamageSource damagesource) { +@@ -462,11 +522,21 @@ ItemStack itemstack1 = this.getEquipment(enumitemslot); boolean flag = this.a(itemstack, itemstack1, enumitemslot); -- if (flag && this.d(itemstack)) { +- if (flag && this.g(itemstack)) { + // CraftBukkit start -+ boolean canPickup = flag && this.d(itemstack); ++ boolean canPickup = flag && this.g(itemstack); + + EntityPickupItemEvent entityEvent = new EntityPickupItemEvent((LivingEntity) getBukkitEntity(), (org.bukkit.entity.Item) entityitem.getBukkitEntity(), 0); + entityEvent.setCancelled(!canPickup); @@ -126,33 +126,33 @@ + canPickup = !entityEvent.isCancelled(); + if (canPickup) { + // CraftBukkit end - double d0 = (double) this.c(enumitemslot); + double d0 = (double) this.d(enumitemslot); if (!itemstack1.isEmpty() && (double) (this.random.nextFloat() - 0.1F) < d0) { + this.forceDrops = true; // CraftBukkit - this.a_(itemstack1); + this.a(itemstack1); + this.forceDrops = false; // CraftBukkit } this.setSlot(enumitemslot, itemstack); -@@ -554,11 +624,11 @@ - double d2 = entityhuman.locZ - this.locZ; - double d3 = d0 * d0 + d1 * d1 + d2 * d2; +@@ -544,11 +614,11 @@ + if (entityhuman != null) { + double d0 = entityhuman.h(this); -- if (this.isTypeNotPersistent() && d3 > 16384.0D) { -+ if (d3 > 16384.0D) { // CraftBukkit - remove isTypeNotPersistent() check +- if (d0 > 16384.0D && this.isTypeNotPersistent(d0)) { ++ if (d0 > 16384.0D) { // CraftBukkit - remove isTypeNotPersistent() check this.die(); } -- if (this.ticksFarFromPlayer > 600 && this.random.nextInt(800) == 0 && d3 > 1024.0D && this.isTypeNotPersistent()) { -+ if (this.ticksFarFromPlayer > 600 && this.random.nextInt(800) == 0 && d3 > 1024.0D) { // CraftBukkit - remove isTypeNotPersistent() check +- if (this.ticksFarFromPlayer > 600 && this.random.nextInt(800) == 0 && d0 > 1024.0D && this.isTypeNotPersistent(d0)) { ++ if (this.ticksFarFromPlayer > 600 && this.random.nextInt(800) == 0 && d0 > 1024.0D) { // CraftBukkit - remove isTypeNotPersistent() check this.die(); - } else if (d3 < 1024.0D) { + } else if (d0 < 1024.0D) { this.ticksFarFromPlayer = 0; -@@ -932,12 +1002,24 @@ - - public final boolean b(EntityHuman entityhuman, EnumHand enumhand) { - if (this.isLeashed() && this.getLeashHolder() == entityhuman) { +@@ -944,12 +1014,24 @@ + if (!this.isAlive()) { + return false; + } else if (this.getLeashHolder() == entityhuman) { + // CraftBukkit start - fire PlayerUnleashEntityEvent + if (CraftEventFactory.callPlayerUnleashEntityEvent(this, entityhuman).isCancelled()) { + ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutAttachEntity(this, this.getLeashHolder())); @@ -174,21 +174,16 @@ this.setLeashHolder(entityhuman, true); itemstack.subtract(1); return true; -@@ -958,10 +1040,12 @@ +@@ -995,6 +1077,7 @@ - if (this.bK) { - if (!this.isAlive()) { -+ this.world.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.PLAYER_UNLEASH)); // CraftBukkit + if (this.leashHolder != null) { + if (!this.isAlive() || !this.leashHolder.isAlive()) { ++ this.world.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), (!this.isAlive()) ? UnleashReason.PLAYER_UNLEASH : UnleashReason.HOLDER_GONE)); // CraftBukkit this.unleash(true, true); } - if (this.leashHolder == null || this.leashHolder.dead) { -+ this.world.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.HOLDER_GONE)); // CraftBukkit - this.unleash(true, true); - } - } -@@ -972,7 +1056,9 @@ - this.bK = false; +@@ -1010,7 +1093,9 @@ + this.leashHolder = null; if (!this.world.isClientSide && flag1) { + this.forceDrops = true; // CraftBukkit @@ -197,27 +192,27 @@ } if (!this.world.isClientSide && flag && this.world instanceof WorldServer) { -@@ -1042,6 +1128,7 @@ +@@ -1079,6 +1164,7 @@ - this.setLeashHolder(entityleash, true); + this.setLeashHolder(EntityLeash.a(this.world, blockposition), true); } else { + this.world.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.UNKNOWN)); // CraftBukkit this.unleash(false, true); } - } -@@ -1137,7 +1224,14 @@ - int j = EnchantmentManager.getFireAspectEnchantmentLevel(this); - if (j > 0) { -- entity.setOnFire(j * 4); -+ // CraftBukkit start - Call a combust event when somebody hits with a fire enchanted item -+ EntityCombustByEntityEvent combustEvent = new EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), j * 4); -+ org.bukkit.Bukkit.getPluginManager().callEvent(combustEvent); +@@ -1186,7 +1272,14 @@ + int i = EnchantmentManager.getFireAspectEnchantmentLevel(this); + + if (i > 0) { +- entity.setOnFire(i * 4); ++ // CraftBukkit start - Call a combust event when somebody hits with a fire enchanted item ++ EntityCombustByEntityEvent combustEvent = new EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), i * 4); ++ org.bukkit.Bukkit.getPluginManager().callEvent(combustEvent); + -+ if (!combustEvent.isCancelled()) { -+ entity.setOnFire(combustEvent.getDuration(), false); -+ } -+ // CraftBukkit end - } ++ if (!combustEvent.isCancelled()) { ++ entity.setOnFire(combustEvent.getDuration(), false); ++ } ++ // CraftBukkit end + } - if (entity instanceof EntityHuman) { + boolean flag = entity.damageEntity(DamageSource.mobAttack(this), f); diff --git a/nms-patches/EntityIronGolem.patch b/nms-patches/EntityIronGolem.patch index 650792d9a4..39baa19157 100644 --- a/nms-patches/EntityIronGolem.patch +++ b/nms-patches/EntityIronGolem.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/server/EntityIronGolem.java +++ b/net/minecraft/server/EntityIronGolem.java -@@ -66,7 +66,7 @@ - - protected void C(Entity entity) { +@@ -52,7 +52,7 @@ + @Override + protected void D(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.C(entity); + super.D(entity); diff --git a/nms-patches/EntityItem.patch b/nms-patches/EntityItem.patch index 6dd07c3d4f..026ebd5c00 100644 --- a/nms-patches/EntityItem.patch +++ b/nms-patches/EntityItem.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/server/EntityItem.java +++ b/net/minecraft/server/EntityItem.java -@@ -3,16 +3,21 @@ - import java.util.Iterator; +@@ -4,6 +4,10 @@ + import java.util.List; import java.util.UUID; import javax.annotation.Nullable; +// CraftBukkit start @@ -11,19 +11,15 @@ public class EntityItem extends Entity { - private static final DataWatcherObject b = DataWatcher.a(EntityItem.class, DataWatcherRegistry.g); -- private int age; -+ public int age; // PAIL - public int pickupDelay; - private int e; - private UUID f; - private UUID g; - public float a; +@@ -14,6 +18,7 @@ + private UUID thrower; + private UUID owner; + public final float b; + private int lastTick = MinecraftServer.currentTick - 1; // CraftBukkit - public EntityItem(World world) { - super(EntityTypes.ITEM, world); -@@ -48,9 +53,12 @@ + public EntityItem(EntityTypes entitytypes, World world) { + super(entitytypes, world); +@@ -49,9 +54,12 @@ this.die(); } else { super.tick(); @@ -39,8 +35,8 @@ this.lastX = this.locX; this.lastY = this.locY; -@@ -100,9 +108,11 @@ - this.motY *= -0.5D; +@@ -99,9 +107,11 @@ + this.setMot(this.getMot().d(1.0D, -0.5D, 1.0D)); } + /* Craftbukkit start - moved up @@ -49,9 +45,9 @@ } + // Craftbukkit end */ - this.impulse |= this.at(); + this.impulse |= this.ax(); if (!this.world.isClientSide) { -@@ -117,6 +127,12 @@ +@@ -113,6 +123,12 @@ } if (!this.world.isClientSide && this.age >= 6000) { @@ -64,15 +60,32 @@ this.die(); } -@@ -165,6 +181,7 @@ - } else if (itemstack1.getCount() + itemstack.getCount() > itemstack1.getMaxStackSize()) { - return false; - } else { -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callItemMergeEvent(this, entityitem).isCancelled()) return false; // CraftBukkit - itemstack1.add(itemstack.getCount()); - entityitem.pickupDelay = Math.max(entityitem.pickupDelay, this.pickupDelay); - entityitem.age = Math.min(entityitem.age, this.age); -@@ -197,6 +214,11 @@ +@@ -173,13 +189,14 @@ + } + + private static void a(EntityItem entityitem, ItemStack itemstack, EntityItem entityitem1, ItemStack itemstack1) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callItemMergeEvent(entityitem1, entityitem).isCancelled()) return; // CraftBukkit + int i = Math.min(itemstack.getMaxStackSize() - itemstack.getCount(), itemstack1.getCount()); + ItemStack itemstack2 = itemstack.cloneItemStack(); + + itemstack2.add(i); + entityitem.setItemStack(itemstack2); + itemstack1.subtract(i); +- entityitem1.setItemStack(itemstack1); ++ if (!itemstack1.isEmpty()) entityitem1.setItemStack(itemstack1); // CraftBukkit - don't set empty stacks + entityitem.pickupDelay = Math.max(entityitem.pickupDelay, entityitem1.pickupDelay); + entityitem.age = Math.min(entityitem.age, entityitem1.age); + if (itemstack1.isEmpty()) { +@@ -193,7 +210,7 @@ + } + + @Override +- protected void burn(int i) { ++ protected void burn(float i) { // CraftBukkit - int -> float + this.damageEntity(DamageSource.FIRE, (float) i); + } + +@@ -204,6 +221,11 @@ } else if (!this.getItemStack().isEmpty() && this.getItemStack().getItem() == Items.NETHER_STAR && damagesource.isExplosion()) { return false; } else { @@ -81,10 +94,10 @@ + return false; + } + // CraftBukkit end - this.aA(); - this.e = (int) ((float) this.e - f); - if (this.e <= 0) { -@@ -255,6 +277,35 @@ + this.velocityChanged(); + this.f = (int) ((float) this.f - f); + if (this.f <= 0) { +@@ -265,6 +287,35 @@ Item item = itemstack.getItem(); int i = itemstack.getCount(); @@ -117,16 +130,16 @@ + } + // CraftBukkit end + - if (this.pickupDelay == 0 && (this.g == null || 6000 - this.age <= 200 || this.g.equals(entityhuman.getUniqueID())) && entityhuman.inventory.pickup(itemstack)) { + if (this.pickupDelay == 0 && (this.owner == null || 6000 - this.age <= 200 || this.owner.equals(entityhuman.getUniqueID())) && entityhuman.inventory.pickup(itemstack)) { entityhuman.receive(this, i); if (itemstack.isEmpty()) { -@@ -294,7 +345,9 @@ +@@ -307,7 +358,9 @@ } public void setItemStack(ItemStack itemstack) { + com.google.common.base.Preconditions.checkArgument(!itemstack.isEmpty(), "Cannot drop air"); // CraftBukkit - this.getDataWatcher().set(EntityItem.b, itemstack); -+ this.getDataWatcher().markDirty(EntityItem.b); // CraftBukkit - SPIGOT-4591, must mark dirty + this.getDataWatcher().set(EntityItem.ITEM, itemstack); ++ this.getDataWatcher().markDirty(EntityItem.ITEM); // CraftBukkit - SPIGOT-4591, must mark dirty } @Nullable diff --git a/nms-patches/EntityItemFrame.patch b/nms-patches/EntityItemFrame.patch index 19d5445138..527897abbe 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 -@@ -95,6 +95,11 @@ +@@ -108,6 +108,11 @@ return false; } else if (!damagesource.isExplosion() && !this.getItem().isEmpty()) { if (!this.world.isClientSide) { @@ -12,7 +12,7 @@ this.b(damagesource.getEntity(), false); this.a(SoundEffects.ENTITY_ITEM_FRAME_REMOVE_ITEM, 1.0F, 1.0F); } -@@ -168,6 +173,12 @@ +@@ -193,6 +198,12 @@ } public void setItem(ItemStack itemstack, boolean flag) { @@ -25,10 +25,10 @@ if (!itemstack.isEmpty()) { itemstack = itemstack.cloneItemStack(); itemstack.setCount(1); -@@ -175,7 +186,7 @@ +@@ -200,7 +211,7 @@ } - this.getDataWatcher().set(EntityItemFrame.e, itemstack); + this.getDataWatcher().set(EntityItemFrame.ITEM, itemstack); - if (!itemstack.isEmpty()) { + if (!itemstack.isEmpty() && playSound) { // CraftBukkit this.a(SoundEffects.ENTITY_ITEM_FRAME_ADD_ITEM, 1.0F, 1.0F); diff --git a/nms-patches/EntityLargeFireball.patch b/nms-patches/EntityLargeFireball.patch index 78ddeaa072..8a94be7253 100644 --- a/nms-patches/EntityLargeFireball.patch +++ b/nms-patches/EntityLargeFireball.patch @@ -5,39 +5,39 @@ +import org.bukkit.event.entity.ExplosionPrimeEvent; // CraftBukkit + - public class EntityLargeFireball extends EntityFireball { + public class EntityLargeFireball extends EntityFireballFireball { public int yield = 1; - public EntityLargeFireball(World world) { - super(EntityTypes.FIREBALL, world, 1.0F, 1.0F); + public EntityLargeFireball(EntityTypes entitytypes, World world) { + super(entitytypes, world); + isIncendiary = this.world.getGameRules().getBoolean("mobGriefing"); // CraftBukkit } public EntityLargeFireball(World world, EntityLiving entityliving, double d0, double d1, double d2) { - super(EntityTypes.FIREBALL, entityliving, d0, d1, d2, world, 1.0F, 1.0F); + super(EntityTypes.FIREBALL, entityliving, d0, d1, d2, world); + isIncendiary = this.world.getGameRules().getBoolean("mobGriefing"); // CraftBukkit } - protected void a(MovingObjectPosition movingobjectposition) { -@@ -21,7 +25,15 @@ + @Override +@@ -24,7 +28,15 @@ boolean flag = this.world.getGameRules().getBoolean("mobGriefing"); -- this.world.createExplosion((Entity) null, this.locX, this.locY, this.locZ, (float) this.yield, flag, flag); +- this.world.createExplosion((Entity) null, this.locX, this.locY, this.locZ, (float) this.yield, flag, flag ? Explosion.Effect.DESTROY : Explosion.Effect.NONE); + // CraftBukkit start - fire ExplosionPrimeEvent + ExplosionPrimeEvent event = new ExplosionPrimeEvent((org.bukkit.entity.Explosive) this.getBukkitEntity()); + this.world.getServer().getPluginManager().callEvent(event); + + if (!event.isCancelled()) { + // give 'this' instead of (Entity) null so we know what causes the damage -+ this.world.createExplosion(this, this.locX, this.locY, this.locZ, event.getRadius(), event.getFire(), isIncendiary); ++ this.world.createExplosion(this, this.locX, this.locY, this.locZ, event.getRadius(), event.getFire(), flag ? Explosion.Effect.DESTROY : Explosion.Effect.NONE); + } + // CraftBukkit end this.die(); } -@@ -35,7 +47,8 @@ +@@ -40,7 +52,8 @@ public void a(NBTTagCompound nbttagcompound) { super.a(nbttagcompound); if (nbttagcompound.hasKeyOfType("ExplosionPower", 99)) { diff --git a/nms-patches/EntityLeash.patch b/nms-patches/EntityLeash.patch index 75bc78be75..6f40b261fb 100644 --- a/nms-patches/EntityLeash.patch +++ b/nms-patches/EntityLeash.patch @@ -8,18 +8,18 @@ import java.util.Iterator; import java.util.List; import javax.annotation.Nullable; -@@ -29,6 +31,7 @@ +@@ -31,6 +33,7 @@ this.locX = (double) this.blockPosition.getX() + 0.5D; this.locY = (double) this.blockPosition.getY() + 0.5D; this.locZ = (double) this.blockPosition.getZ() + 0.5D; -+ if (valid) world.entityJoinedWorld(this, false); // CraftBukkit ++ if (valid) ((WorldServer) world).chunkCheck(this); // CraftBukkit } - public void setDirection(EnumDirection enumdirection) {} -@@ -67,22 +70,42 @@ + @Override +@@ -77,22 +80,42 @@ while (iterator.hasNext()) { entityinsentient = (EntityInsentient) iterator.next(); - if (entityinsentient.isLeashed() && entityinsentient.getLeashHolder() == entityhuman) { + if (entityinsentient.getLeashHolder() == entityhuman) { + // CraftBukkit start + if (CraftEventFactory.callPlayerLeashEntityEvent(entityinsentient, this, entityhuman).isCancelled()) { + ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutAttachEntity(entityinsentient, entityinsentient.getLeashHolder())); diff --git a/nms-patches/EntityLightning.patch b/nms-patches/EntityLightning.patch index d57c0b1a97..042c0c2a3d 100644 --- a/nms-patches/EntityLightning.patch +++ b/nms-patches/EntityLightning.patch @@ -1,27 +1,27 @@ --- a/net/minecraft/server/EntityLightning.java +++ b/net/minecraft/server/EntityLightning.java -@@ -4,6 +4,8 @@ +@@ -5,6 +5,8 @@ import java.util.List; import javax.annotation.Nullable; +import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit + - public class EntityLightning extends EntityWeather { + public class EntityLightning extends Entity { private int lifeTicks; -@@ -12,9 +14,11 @@ - private final boolean d; +@@ -13,9 +15,11 @@ + private final boolean e; @Nullable - private EntityPlayer e; + private EntityPlayer f; + public boolean isEffect; // CraftBukkit public EntityLightning(World world, double d0, double d1, double d2, boolean flag) { super(EntityTypes.LIGHTNING_BOLT, world); + this.isEffect = flag; // CraftBukkit + this.af = true; this.setPositionRotation(d0, d1, d2, 0.0F, 0.0F); this.lifeTicks = 2; - this.a = this.random.nextLong(); -@@ -39,7 +43,24 @@ +@@ -43,7 +47,24 @@ public void tick() { super.tick(); if (this.lifeTicks == 2) { @@ -30,7 +30,7 @@ + // this.world.a((EntityHuman) null, this.locX, this.locY, this.locZ, SoundEffects.ENTITY_LIGHTNING_BOLT_THUNDER, SoundCategory.WEATHER, 10000.0F, 0.8F + this.random.nextFloat() * 0.2F); + float pitch = 0.8F + this.random.nextFloat() * 0.2F; + int viewDistance = ((WorldServer) this.world).getServer().getViewDistance() * 16; -+ for (EntityPlayer player : (List) (List) this.world.players) { ++ for (EntityPlayer player : (List) (List) this.world.getPlayers()) { + double deltaX = this.locX - player.locX; + double deltaZ = this.locZ - player.locZ; + double distanceSquared = deltaX * deltaX + deltaZ * deltaZ; @@ -47,19 +47,19 @@ this.world.a((EntityHuman) null, this.locX, this.locY, this.locZ, SoundEffects.ENTITY_LIGHTNING_BOLT_IMPACT, SoundCategory.WEATHER, 2.0F, 0.5F + this.random.nextFloat() * 0.2F); } -@@ -55,7 +76,7 @@ +@@ -59,7 +80,7 @@ } } - if (this.lifeTicks >= 0) { + if (this.lifeTicks >= 0 && !this.isEffect) { // CraftBukkit - add !this.isEffect if (this.world.isClientSide) { - this.world.d(2); - } else if (!this.d) { -@@ -82,14 +103,22 @@ + this.world.c(2); + } else if (!this.e) { +@@ -87,14 +108,22 @@ BlockPosition blockposition = new BlockPosition(this); - if (this.world.areChunksLoaded(blockposition, 10) && this.world.getType(blockposition).isAir() && iblockdata.canPlace(this.world, blockposition)) { + if (this.world.getType(blockposition).isAir() && iblockdata.canPlace(this.world, blockposition)) { - this.world.setTypeUpdate(blockposition, iblockdata); + // CraftBukkit start - add "!isEffect" + if (!isEffect && !CraftEventFactory.callBlockIgniteEvent(world, blockposition, this).isCancelled()) { @@ -69,7 +69,7 @@ } for (int j = 0; j < i; ++j) { - BlockPosition blockposition1 = blockposition.a(this.random.nextInt(3) - 1, this.random.nextInt(3) - 1, this.random.nextInt(3) - 1); + BlockPosition blockposition1 = blockposition.b(this.random.nextInt(3) - 1, this.random.nextInt(3) - 1, this.random.nextInt(3) - 1); if (this.world.getType(blockposition1).isAir() && iblockdata.canPlace(this.world, blockposition1)) { - this.world.setTypeUpdate(blockposition1, iblockdata); diff --git a/nms-patches/EntityLiving.patch b/nms-patches/EntityLiving.patch index 2e7147d37b..e26829193e 100644 --- a/nms-patches/EntityLiving.patch +++ b/nms-patches/EntityLiving.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/EntityLiving.java +++ b/net/minecraft/server/EntityLiving.java -@@ -13,6 +13,25 @@ - import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; +@@ -16,6 +16,25 @@ + import javax.annotation.Nullable; + import org.apache.commons.lang3.tuple.Pair; +// CraftBukkit start +import java.util.ArrayList; @@ -25,11 +25,11 @@ + public abstract class EntityLiving extends Entity { - private static final Logger a = LogManager.getLogger(); -@@ -93,6 +112,20 @@ - protected int bw; - private float bO; - private float bP; + private static final UUID b = UUID.fromString("662A6B8D-DA3E-4C1C-8813-96EA6097278D"); +@@ -97,6 +116,20 @@ + private float bJ; + private float bK; + protected BehaviorController br; + // CraftBukkit start + public int expToDrop; + public int maxAirTicks = 300; @@ -45,35 +45,35 @@ + } + // CraftBukkit end - protected EntityLiving(EntityTypes entitytypes, World world) { + protected EntityLiving(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -103,7 +136,8 @@ +@@ -107,7 +140,8 @@ this.updateEffects = true; this.activeItem = ItemStack.a; this.initAttributes(); - this.setHealth(this.getMaxHealth()); + // CraftBukkit - setHealth(getMaxHealth()) inlined and simplified to skip the instanceof check for EntityPlayer, as getBukkitEntity() is not initialized in constructor -+ this.datawatcher.set(EntityLiving.HEALTH, (float) this.getAttributeInstance(GenericAttributes.maxHealth).getValue()); - this.j = true; - this.aP = (float) ((Math.random() + 1.0D) * 0.009999999776482582D); ++ this.datawatcher.set(EntityLiving.HEALTH, (float) this.getAttributeInstance(GenericAttributes.MAX_HEALTH).getValue()); + this.i = true; + this.aJ = (float) ((Math.random() + 1.0D) * 0.009999999776482582D); this.setPosition(this.locX, this.locY, this.locZ); -@@ -145,7 +179,13 @@ +@@ -166,7 +200,13 @@ double d1 = Math.min((double) (0.2F + f / 15.0F), 2.5D); int i = (int) (150.0D * d1); -- ((WorldServer) this.world).a(new ParticleParamBlock(Particles.d, iblockdata), this.locX, this.locY, this.locZ, i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D); +- ((WorldServer) this.world).a(new ParticleParamBlock(Particles.BLOCK, iblockdata), this.locX, this.locY, this.locZ, i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D); + // CraftBukkit start - visiblity api + if (this instanceof EntityPlayer) { -+ ((WorldServer) this.world).sendParticles((EntityPlayer) this, new ParticleParamBlock(Particles.d, iblockdata), this.locX, this.locY, this.locZ, i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D, false); ++ ((WorldServer) this.world).sendParticles((EntityPlayer) this, new ParticleParamBlock(Particles.BLOCK, iblockdata), this.locX, this.locY, this.locZ, i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D, false); + } else { -+ ((WorldServer) this.world).a(new ParticleParamBlock(Particles.d, iblockdata), this.locX, this.locY, this.locZ, i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D); ++ ((WorldServer) this.world).a(new ParticleParamBlock(Particles.BLOCK, iblockdata), this.locX, this.locY, this.locZ, i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D); + } + // CraftBukkit end } } -@@ -264,6 +304,18 @@ - this.world.methodProfiler.exit(); +@@ -286,6 +326,18 @@ + this.world.getMethodProfiler().exit(); } + // CraftBukkit start @@ -91,9 +91,9 @@ protected void b(BlockPosition blockposition) { int i = EnchantmentManager.a(Enchantments.FROST_WALKER, this); -@@ -283,19 +335,19 @@ +@@ -310,19 +362,19 @@ - protected void cb() { + protected void cn() { ++this.deathTicks; - if (this.deathTicks == 20) { + if (this.deathTicks >= 20 && !this.dead) { // CraftBukkit - (this.deathTicks == 20) -> (this.deathTicks >= 20 && !this.dead) @@ -101,14 +101,14 @@ - if (!this.world.isClientSide && (this.alwaysGivesExp() || this.lastDamageByPlayerTime > 0 && this.isDropExperience() && this.world.getGameRules().getBoolean("doMobLoot"))) { - i = this.getExpValue(this.killer); +- +- while (i > 0) { +- int j = EntityExperienceOrb.getOrbValue(i); + // CraftBukkit start - Update getExpReward() above if the removed if() changes! + i = this.expToDrop; + while (i > 0) { + int j = EntityExperienceOrb.getOrbValue(i); -- while (i > 0) { -- int j = EntityExperienceOrb.getOrbValue(i); -- - i -= j; - this.world.addEntity(new EntityExperienceOrb(this.world, this.locX, this.locY, this.locZ, j)); - } @@ -120,7 +120,7 @@ this.die(); -@@ -455,6 +507,17 @@ +@@ -495,6 +547,17 @@ } } @@ -128,9 +128,9 @@ + if (nbttagcompound.hasKey("Bukkit.MaxHealth")) { + NBTBase nbtbase = nbttagcompound.get("Bukkit.MaxHealth"); + if (nbtbase.getTypeId() == 5) { -+ this.getAttributeInstance(GenericAttributes.maxHealth).setValue(((NBTTagFloat) nbtbase).asDouble()); ++ this.getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(((NBTTagFloat) nbtbase).asDouble()); + } else if (nbtbase.getTypeId() == 3) { -+ this.getAttributeInstance(GenericAttributes.maxHealth).setValue(((NBTTagInt) nbtbase).asDouble()); ++ this.getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(((NBTTagInt) nbtbase).asDouble()); + } + } + // CraftBukkit end @@ -138,7 +138,7 @@ if (nbttagcompound.hasKeyOfType("Health", 99)) { this.setHealth(nbttagcompound.getFloat("Health")); } -@@ -478,9 +541,32 @@ +@@ -530,9 +593,32 @@ } @@ -171,7 +171,7 @@ try { while (iterator.hasNext()) { MobEffectList mobeffectlist = (MobEffectList) iterator.next(); -@@ -488,6 +574,12 @@ +@@ -540,6 +626,12 @@ if (!mobeffect.tick(this)) { if (!this.world.isClientSide) { @@ -184,7 +184,7 @@ iterator.remove(); this.b(mobeffect); } -@@ -498,6 +590,17 @@ +@@ -550,6 +642,17 @@ } catch (ConcurrentModificationException concurrentmodificationexception) { ; } @@ -202,8 +202,8 @@ if (this.updateEffects) { if (!this.world.isClientSide) { -@@ -569,7 +672,13 @@ - this.datawatcher.set(EntityLiving.g, 0); +@@ -659,7 +762,13 @@ + this.datawatcher.set(EntityLiving.e, 0); } + // CraftBukkit start @@ -216,7 +216,7 @@ if (this.world.isClientSide) { return false; } else { -@@ -578,7 +687,14 @@ +@@ -668,7 +777,14 @@ boolean flag; for (flag = false; iterator.hasNext(); flag = true) { @@ -232,7 +232,7 @@ iterator.remove(); } -@@ -603,18 +719,44 @@ +@@ -693,18 +809,44 @@ return (MobEffect) this.effects.get(mobeffectlist); } @@ -278,8 +278,8 @@ return true; } else { return false; -@@ -637,14 +779,40 @@ - public boolean cp() { +@@ -727,14 +869,40 @@ + public boolean cB() { return this.getMonsterType() == EnumMonsterType.UNDEAD; } - @@ -321,7 +321,7 @@ if (mobeffect != null) { this.b(mobeffect); -@@ -681,20 +849,52 @@ +@@ -771,20 +939,55 @@ } @@ -336,7 +336,10 @@ if (f1 > 0.0F) { - this.setHealth(f1 + f); + EntityRegainHealthEvent event = new EntityRegainHealthEvent(this.getBukkitEntity(), f, regainReason); -+ this.world.getServer().getPluginManager().callEvent(event); ++ // Suppress during worldgen ++ if (this.valid) { ++ this.world.getServer().getPluginManager().callEvent(event); ++ } + + if (!event.isCancelled()) { + this.setHealth((float) (this.getHealth() + event.getAmount())); @@ -375,7 +378,7 @@ this.datawatcher.set(EntityLiving.HEALTH, MathHelper.a(f, 0.0F, this.getMaxHealth())); } -@@ -703,7 +903,7 @@ +@@ -794,7 +997,7 @@ return false; } else if (this.world.isClientSide) { return false; @@ -384,14 +387,16 @@ return false; } else if (damagesource.p() && this.hasEffect(MobEffects.FIRE_RESISTANCE)) { return false; -@@ -711,15 +911,17 @@ +@@ -806,17 +1009,19 @@ this.ticksFarFromPlayer = 0; float f1 = f; - if ((damagesource == DamageSource.ANVIL || damagesource == DamageSource.FALLING_BLOCK) && !this.getEquipment(EnumItemSlot.HEAD).isEmpty()) { + // CraftBukkit - Moved into damageEntity0(DamageSource, float) + if (false && (damagesource == DamageSource.ANVIL || damagesource == DamageSource.FALLING_BLOCK) && !this.getEquipment(EnumItemSlot.HEAD).isEmpty()) { - this.getEquipment(EnumItemSlot.HEAD).damage((int) (f * 4.0F + this.random.nextFloat() * f * 2.0F), this); + this.getEquipment(EnumItemSlot.HEAD).damage((int) (f * 4.0F + this.random.nextFloat() * f * 2.0F), this, (entityliving) -> { + entityliving.c(EnumItemSlot.HEAD); + }); f *= 0.75F; } @@ -405,9 +410,9 @@ this.damageShield(f); f2 = f; f = 0.0F; -@@ -739,20 +941,39 @@ +@@ -836,20 +1041,39 @@ - if ((float) this.noDamageTicks > (float) this.maxNoDamageTicks / 2.0F) { + if ((float) this.noDamageTicks > 10.0F) { if (f <= this.lastDamage) { + this.forceExplosionKnockback = true; // CraftBukkit - SPIGOT-949 - for vanilla consistency, cooldown does not prevent explosion knockback return false; @@ -427,12 +432,12 @@ + return false; + } this.lastDamage = f; - this.noDamageTicks = this.maxNoDamageTicks; + this.noDamageTicks = 20; - this.damageEntity0(damagesource, f); + // this.damageEntity0(damagesource, f); + // CraftBukkit end - this.aC = 10; - this.hurtTicks = this.aC; + this.hurtDuration = 10; + this.hurtTicks = this.hurtDuration; } + // CraftBukkit start @@ -444,10 +449,10 @@ + } + // CraftBukkit end + - this.aD = 0.0F; + this.az = 0.0F; Entity entity1 = damagesource.getEntity(); -@@ -861,19 +1082,29 @@ +@@ -970,19 +1194,29 @@ EnumHand[] aenumhand = EnumHand.values(); int i = aenumhand.length; @@ -481,7 +486,7 @@ EntityPlayer entityplayer = (EntityPlayer) this; entityplayer.b(StatisticList.ITEM_USED.b(Items.TOTEM_OF_UNDYING)); -@@ -881,13 +1112,15 @@ +@@ -990,13 +1224,15 @@ } this.setHealth(1.0F); @@ -501,20 +506,20 @@ } } -@@ -958,6 +1191,12 @@ - boolean flag = this.lastDamageByPlayerTime > 0; +@@ -1109,6 +1345,12 @@ + if (this.isDropExperience() && this.world.getGameRules().getBoolean("doMobLoot")) { + this.a(damagesource, flag); + this.dropDeathLoot(damagesource, i, flag); ++ // CraftBukkit start - Call death event ++ CraftEventFactory.callEntityDeathEvent(this, this.drops); ++ this.drops = new ArrayList(); ++ } else { ++ CraftEventFactory.callEntityDeathEvent(this); ++ // CraftBukkit end + } - this.a(flag, i, damagesource); -+ // CraftBukkit start - Call death event -+ CraftEventFactory.callEntityDeathEvent(this, this.drops); -+ this.drops = new ArrayList(); -+ } else { -+ CraftEventFactory.callEntityDeathEvent(this); -+ // CraftBukkit end - } - } - -@@ -1047,8 +1286,13 @@ + this.cE(); +@@ -1212,8 +1454,13 @@ int i = MathHelper.f((f - 3.0F - f2) * f1); if (i > 0) { @@ -523,22 +528,22 @@ + return; + } + // CraftBukkit end - this.a(this.m(i), 1.0F, 1.0F); + this.a(this.getSoundFall(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); -@@ -1075,7 +1319,7 @@ +@@ -1240,7 +1487,7 @@ protected float applyArmorModifier(DamageSource damagesource, float f) { if (!damagesource.ignoresArmor()) { - this.damageArmor(f); + // this.damageArmor(f); // CraftBukkit - Moved into damageEntity0(DamageSource, float) - f = CombatMath.a(f, (float) this.getArmorStrength(), (float) this.getAttributeInstance(GenericAttributes.i).getValue()); + f = CombatMath.a(f, (float) this.getArmorStrength(), (float) this.getAttributeInstance(GenericAttributes.ARMOR_TOUGHNESS).getValue()); } -@@ -1088,7 +1332,8 @@ +@@ -1253,7 +1500,8 @@ } else { int i; @@ -548,7 +553,7 @@ i = (this.getEffect(MobEffects.RESISTANCE).getAmplifier() + 1) * 5; int j = 25 - i; float f1 = f * (float) j; -@@ -1119,28 +1364,168 @@ +@@ -1284,28 +1532,170 @@ } } @@ -629,10 +634,7 @@ + if (event.isCancelled()) { + return false; + } - -- f = Math.max(f - this.getAbsorptionHearts(), 0.0F); -- this.setAbsorptionHearts(this.getAbsorptionHearts() - (f1 - f)); -- float f2 = f1 - f; ++ + f = (float) event.getFinalDamage(); + + // Resistance @@ -646,10 +648,12 @@ + } + } + } - ++ + // Apply damage to helmet + 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); ++ this.getEquipment(EnumItemSlot.HEAD).damage((int) (event.getDamage() * 4.0F + this.random.nextFloat() * event.getDamage() * 2.0F), this, (entityliving) -> { ++ entityliving.c(EnumItemSlot.HEAD); ++ }); + } + + // Apply damage to armor @@ -657,7 +661,10 @@ + 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)); +- float f2 = f1 - f; + // Apply blocking code // PAIL: steal from above + if (event.getDamage(DamageModifier.BLOCKING) < 0) { + this.world.broadcastEntityEffect(this, (byte) 29); // SPIGOT-4635 - shield damage sound @@ -668,7 +675,7 @@ + this.c((EntityLiving) entity); + } + } -+ + + absorptionModifier = (float) -event.getDamage(DamageModifier.ABSORPTION); + this.setAbsorptionHearts(Math.max(this.getAbsorptionHearts() - absorptionModifier, 0.0F)); + float f2 = absorptionModifier; @@ -727,7 +734,7 @@ } public CombatTracker getCombatTracker() { -@@ -1207,6 +1592,7 @@ +@@ -1373,6 +1763,7 @@ public AttributeMapBase getAttributeMap() { if (this.attributeMap == null) { this.attributeMap = new AttributeMapServer(); @@ -735,7 +742,7 @@ } return this.attributeMap; -@@ -1509,6 +1895,7 @@ +@@ -1719,6 +2110,7 @@ } if (this.onGround && !this.world.isClientSide) { @@ -743,7 +750,7 @@ this.setFlag(7, false); } } else { -@@ -1907,6 +2294,7 @@ +@@ -2100,6 +2492,7 @@ } if (!this.world.isClientSide) { @@ -751,25 +758,26 @@ this.setFlag(7, flag); } -@@ -2034,11 +2422,11 @@ - } +@@ -2228,12 +2621,12 @@ + @Override public boolean isInteractable() { - return !this.dead; + return !this.dead && this.collides; // CraftBukkit } + @Override public boolean isCollidable() { -- return this.isAlive() && !this.z_(); -+ return this.isAlive() && !this.z_() && this.collides; // CraftBukkit +- return this.isAlive() && !this.isClimbing(); ++ return this.isAlive() && !this.isClimbing() && this.collides; // CraftBukkit } - protected void aA() { -@@ -2198,7 +2586,27 @@ + @Override +@@ -2404,7 +2797,27 @@ protected void q() { if (!this.activeItem.isEmpty() && this.isHandRaised()) { this.b(this.activeItem, 16); -- this.a(this.cU(), this.activeItem.a(this.world, this)); +- this.a(this.getRaisedHand(), this.activeItem.a(this.world, this)); + // CraftBukkit start - fire PlayerItemConsumeEvent + ItemStack itemstack; + if (this instanceof EntityPlayer) { @@ -789,18 +797,18 @@ + itemstack = this.activeItem.a(this.world, this); + } + -+ this.a(this.cU(), itemstack); ++ this.a(this.getRaisedHand(), itemstack); + // CraftBukkit end - this.da(); + this.dp(); } -@@ -2277,10 +2685,18 @@ +@@ -2489,10 +2902,18 @@ } - if (flag1) { + if (flag2) { - this.enderTeleportTo(this.locX, this.locY, this.locZ); -- if (world.getCubes(this, this.getBoundingBox()) && !world.containsLiquid(this.getBoundingBox())) { -- flag = true; +- if (world.getCubes(this) && !world.containsLiquid(this.getBoundingBox())) { +- flag1 = true; + // CraftBukkit start - Teleport event + // this.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)); @@ -808,11 +816,29 @@ + if (!teleport.isCancelled()) { + Location to = teleport.getTo(); + this.enderTeleportTo(to.getX(), to.getY(), to.getZ()); -+ if (world.getCubes((Entity) this, this.getBoundingBox()) && !world.containsLiquid(this.getBoundingBox())) { -+ flag = true; ++ if (world.getCubes(this) && !world.containsLiquid(this.getBoundingBox())) { ++ flag1 = true; + } } + // CraftBukkit end } } +@@ -2579,7 +3000,7 @@ + } + + public void dy() { +- Optional optional = this.getBedPosition(); ++ Optional optional = this.getBedPosition(); // CraftBukkit - decompile error + World world = this.world; + + this.world.getClass(); +@@ -2641,7 +3062,7 @@ + Pair pair = (Pair) iterator.next(); + + if (!world.isClientSide && pair.getLeft() != null && world.random.nextFloat() < (Float) pair.getRight()) { +- entityliving.addEffect(new MobEffect((MobEffect) pair.getLeft())); ++ entityliving.addEffect(new MobEffect((MobEffect) pair.getLeft()), EntityPotionEffectEvent.Cause.FOOD); // CraftBukkit + } + } + } diff --git a/nms-patches/EntityLlamaSpit.patch b/nms-patches/EntityLlamaSpit.patch index 02f5ea83ff..f46b68adbd 100644 --- a/nms-patches/EntityLlamaSpit.patch +++ b/nms-patches/EntityLlamaSpit.patch @@ -1,19 +1,19 @@ --- a/net/minecraft/server/EntityLlamaSpit.java +++ b/net/minecraft/server/EntityLlamaSpit.java -@@ -7,7 +7,7 @@ +@@ -6,7 +6,7 @@ public class EntityLlamaSpit extends Entity implements IProjectile { - public EntityLlama shooter; + public EntityLiving shooter; // CraftBukkit - type - private NBTTagCompound b; + private NBTTagCompound c; - public EntityLlamaSpit(World world) { -@@ -143,6 +143,7 @@ + public EntityLlamaSpit(EntityTypes entitytypes, World world) { +@@ -91,6 +91,7 @@ } public void a(MovingObjectPosition movingobjectposition) { + org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this, movingobjectposition); // Craftbukkit - Call event - if (movingobjectposition.entity != null && this.shooter != null) { - movingobjectposition.entity.damageEntity(DamageSource.a(this, (EntityLiving) this.shooter).c(), 1.0F); - } + MovingObjectPosition.EnumMovingObjectType movingobjectposition_enummovingobjecttype = movingobjectposition.getType(); + + if (movingobjectposition_enummovingobjecttype == MovingObjectPosition.EnumMovingObjectType.ENTITY && this.shooter != null) { diff --git a/nms-patches/EntityMinecartAbstract.patch b/nms-patches/EntityMinecartAbstract.patch index f875c49676..9736885282 100644 --- a/nms-patches/EntityMinecartAbstract.patch +++ b/nms-patches/EntityMinecartAbstract.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/EntityMinecartAbstract.java +++ b/net/minecraft/server/EntityMinecartAbstract.java -@@ -6,6 +6,15 @@ +@@ -4,6 +4,15 @@ import java.util.List; import javax.annotation.Nullable; @@ -13,12 +13,12 @@ +import org.bukkit.util.Vector; +// CraftBukkit end + - public abstract class EntityMinecartAbstract extends Entity implements INamableTileEntity { + public abstract class EntityMinecartAbstract extends Entity { - private static final DataWatcherObject a = DataWatcher.a(EntityMinecartAbstract.class, DataWatcherRegistry.b); -@@ -23,6 +32,17 @@ - private double aA; - private double aB; + private static final DataWatcherObject b = DataWatcher.a(EntityMinecartAbstract.class, DataWatcherRegistry.b); +@@ -21,6 +30,17 @@ + private double ax; + private double ay; + // CraftBukkit start + public boolean slowWhenEmpty = true; @@ -33,8 +33,8 @@ + protected EntityMinecartAbstract(EntityTypes entitytypes, World world) { super(entitytypes, world); - this.j = true; -@@ -90,6 +110,19 @@ + this.i = true; +@@ -76,6 +96,19 @@ if (this.isInvulnerable(damagesource)) { return false; } else { @@ -51,10 +51,10 @@ + + f = (float) event.getDamage(); + // CraftBukkit end - this.k(-this.u()); - this.d(10); - this.aA(); -@@ -97,6 +130,15 @@ + this.d(-this.n()); + this.c(10); + this.velocityChanged(); +@@ -83,6 +116,15 @@ boolean flag = damagesource.getEntity() instanceof EntityHuman && ((EntityHuman) damagesource.getEntity()).abilities.canInstantlyBuild; if (flag || this.getDamage() > 40.0F) { @@ -70,9 +70,9 @@ this.ejectPassengers(); if (flag && !this.hasCustomName()) { this.die(); -@@ -135,6 +177,14 @@ - } +@@ -124,6 +166,14 @@ + @Override public void tick() { + // CraftBukkit start + double prevX = this.locX; @@ -83,26 +83,18 @@ + // CraftBukkit end + if (this.getType() > 0) { - this.d(this.getType() - 1); + this.c(this.getType() - 1); } -@@ -149,6 +199,8 @@ - - int i; - -+ // CraftBukkit - handled in postTick -+ /* - if (!this.world.isClientSide && this.world instanceof WorldServer) { - this.world.methodProfiler.enter("portal"); - MinecraftServer minecraftserver = this.world.getMinecraftServer(); -@@ -188,6 +240,7 @@ - - this.world.methodProfiler.exit(); +@@ -136,7 +186,7 @@ + this.ae(); } -+ */ +- this.doPortalTick(); ++ // this.doPortalTick(); // CraftBukkit - handled in postTick if (this.world.isClientSide) { - if (this.aw > 0) { -@@ -255,6 +308,18 @@ + if (this.at > 0) { + double d0 = this.locX + (this.au - this.locX) / (double) this.at; +@@ -202,6 +252,18 @@ } this.setYawPitch(this.yaw, this.pitch); @@ -118,10 +110,10 @@ + this.world.getServer().getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleMoveEvent(vehicle, from, to)); + } + // CraftBukkit end - if (this.v() == EntityMinecartAbstract.EnumMinecartType.RIDEABLE && this.motX * this.motX + this.motZ * this.motZ > 0.01D) { + if (this.getMinecartType() == EntityMinecartAbstract.EnumMinecartType.RIDEABLE && b(this.getMot()) > 0.01D) { List list = this.world.getEntities(this, this.getBoundingBox().grow(0.20000000298023224D, 0.0D, 0.20000000298023224D), IEntitySelector.a(this)); -@@ -263,8 +328,24 @@ +@@ -210,8 +272,24 @@ Entity entity = (Entity) list.get(l); if (!(entity instanceof EntityHuman) && !(entity instanceof EntityIronGolem) && !(entity instanceof EntityMinecartAbstract) && !this.isVehicle() && !entity.isPassenger()) { @@ -146,7 +138,7 @@ entity.collide(this); } } -@@ -276,6 +357,14 @@ +@@ -223,6 +301,14 @@ Entity entity1 = (Entity) iterator.next(); if (!this.w(entity1) && entity1.isCollidable() && entity1 instanceof EntityMinecartAbstract) { @@ -161,52 +153,44 @@ entity1.collide(this); } } -@@ -286,7 +375,7 @@ +@@ -233,7 +319,7 @@ } - protected double p() { + protected double getMaxSpeed() { - return 0.4D; + return this.maxSpeed; // CraftBukkit } public void a(int i, int j, int k, boolean flag) {} -@@ -297,16 +386,20 @@ - this.motX = MathHelper.a(this.motX, -d0, d0); - this.motZ = MathHelper.a(this.motZ, -d0, d0); +@@ -244,12 +330,16 @@ + + this.setMot(MathHelper.a(vec3d.x, -d0, d0), vec3d.y, MathHelper.a(vec3d.z, -d0, d0)); if (this.onGround) { -- this.motX *= 0.5D; -- this.motY *= 0.5D; -- this.motZ *= 0.5D; +- this.setMot(this.getMot().a(0.5D)); + // CraftBukkit start - replace magic numbers with our variables -+ this.motX *= this.derailedX; -+ this.motY *= this.derailedY; -+ this.motZ *= this.derailedZ; ++ this.setMot(new Vec3D(this.getMot().x * this.derailedX, this.getMot().y * this.derailedY, this.getMot().z * this.derailedZ)); + // CraftBukkit end } - this.move(EnumMoveType.SELF, this.motX, this.motY, this.motZ); + this.move(EnumMoveType.SELF, this.getMot()); if (!this.onGround) { -- this.motX *= 0.949999988079071D; -- this.motY *= 0.949999988079071D; -- this.motZ *= 0.949999988079071D; +- this.setMot(this.getMot().a(0.95D)); + // CraftBukkit start - replace magic numbers with our variables -+ this.motX *= this.flyingX; -+ this.motY *= this.flyingY; -+ this.motZ *= this.flyingZ; ++ this.setMot(new Vec3D(this.getMot().x * this.flyingX, this.getMot().y * this.flyingY, this.getMot().z * this.flyingZ)); + // CraftBukkit end } } -@@ -491,7 +584,7 @@ +@@ -433,7 +523,7 @@ } - 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; -@@ -588,6 +681,14 @@ + protected void decelerate() { +- double d0 = this.isVehicle() ? 0.997D : 0.96D; ++ double d0 = this.isVehicle() || !this.slowWhenEmpty ? 0.997D : 0.96D; // CraftBukkit - add !this.slowWhenEmpty + + this.setMot(this.getMot().d(d0, 0.0D, d0)); + } +@@ -516,6 +606,14 @@ if (!this.world.isClientSide) { if (!entity.noclip && !this.noclip) { if (!this.w(entity)) { @@ -221,9 +205,9 @@ double d0 = entity.locX - this.locX; double d1 = entity.locZ - this.locZ; double d2 = d0 * d0 + d1 * d1; -@@ -734,4 +835,26 @@ - return this.i; - } +@@ -651,4 +749,26 @@ + + private EnumMinecartType() {} } + + // CraftBukkit start - Methods for getting and setting flying and derailed velocity modifiers diff --git a/nms-patches/EntityMinecartCommandBlock.patch b/nms-patches/EntityMinecartCommandBlock.patch index e6ac3a1cfb..a8abf0371f 100644 --- a/nms-patches/EntityMinecartCommandBlock.patch +++ b/nms-patches/EntityMinecartCommandBlock.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/EntityMinecartCommandBlock.java +++ b/net/minecraft/server/EntityMinecartCommandBlock.java -@@ -92,5 +92,12 @@ +@@ -104,5 +104,12 @@ public CommandListenerWrapper getWrapper() { - return new CommandListenerWrapper(this, new Vec3D(EntityMinecartCommandBlock.this.locX, EntityMinecartCommandBlock.this.locY, EntityMinecartCommandBlock.this.locZ), EntityMinecartCommandBlock.this.aO(), this.d(), 2, this.getName().getString(), EntityMinecartCommandBlock.this.getScoreboardDisplayName(), this.d().getMinecraftServer(), EntityMinecartCommandBlock.this); + return new CommandListenerWrapper(this, new Vec3D(EntityMinecartCommandBlock.this.locX, EntityMinecartCommandBlock.this.locY, EntityMinecartCommandBlock.this.locZ), EntityMinecartCommandBlock.this.aT(), this.d(), 2, this.getName().getString(), EntityMinecartCommandBlock.this.getScoreboardDisplayName(), this.d().getMinecraftServer(), EntityMinecartCommandBlock.this); } + + // CraftBukkit start diff --git a/nms-patches/EntityMinecartContainer.patch b/nms-patches/EntityMinecartContainer.patch index 404bb8d9a8..b0dd7268c6 100644 --- a/nms-patches/EntityMinecartContainer.patch +++ b/nms-patches/EntityMinecartContainer.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/EntityMinecartContainer.java +++ b/net/minecraft/server/EntityMinecartContainer.java -@@ -3,6 +3,13 @@ +@@ -2,6 +2,13 @@ + import java.util.Iterator; - import java.util.Random; import javax.annotation.Nullable; +// CraftBukkit start +import java.util.List; @@ -12,10 +12,10 @@ +import org.bukkit.inventory.InventoryHolder; +// CraftBukkit end - public abstract class EntityMinecartContainer extends EntityMinecartAbstract implements ITileInventory, ILootable { + public abstract class EntityMinecartContainer extends EntityMinecartAbstract implements IInventory, ITileInventory { -@@ -11,15 +18,51 @@ - private MinecraftKey c; +@@ -11,15 +18,56 @@ + public MinecraftKey lootTable; public long lootTableSeed; + // CraftBukkit start @@ -44,6 +44,11 @@ + return null; + } + ++ @Override ++ public int getMaxStackSize() { ++ return maxStack; ++ } ++ + public void setMaxStackSize(int size) { + maxStack = size; + } @@ -58,22 +63,13 @@ super(entitytypes, world); - this.items = NonNullList.a(36, ItemStack.a); + this.items = NonNullList.a(this.getSize(), ItemStack.a); // CraftBukkit - SPIGOT-3513 - this.b = true; + this.c = true; } protected EntityMinecartContainer(EntityTypes entitytypes, double d0, double d1, double d2, World world) { super(entitytypes, world, d0, d1, d2); - this.items = NonNullList.a(36, ItemStack.a); + this.items = NonNullList.a(this.getSize(), ItemStack.a); // CraftBukkit - SPIGOT-3513 - this.b = true; + this.c = true; } -@@ -102,7 +145,7 @@ - } - - public int getMaxStackSize() { -- return 64; -+ return maxStack; // CraftBukkit - } - - @Nullable diff --git a/nms-patches/EntityMushroomCow.patch b/nms-patches/EntityMushroomCow.patch index 9997688a37..00ee0bd481 100644 --- a/nms-patches/EntityMushroomCow.patch +++ b/nms-patches/EntityMushroomCow.patch @@ -1,50 +1,49 @@ --- a/net/minecraft/server/EntityMushroomCow.java +++ b/net/minecraft/server/EntityMushroomCow.java -@@ -2,6 +2,12 @@ - - import javax.annotation.Nullable; +@@ -2,6 +2,11 @@ + import java.util.UUID; + import org.apache.commons.lang3.tuple.Pair; +// CraftBukkit start +import org.bukkit.craftbukkit.event.CraftEventFactory; +import org.bukkit.event.entity.EntityTransformEvent; +import org.bukkit.event.player.PlayerShearEntityEvent; +// CraftBukkit end -+ + public class EntityMushroomCow extends EntityCow { - public EntityMushroomCow(World world) { -@@ -23,9 +29,17 @@ +@@ -72,9 +77,17 @@ + int i; - return true; - } else if (itemstack.getItem() == Items.SHEARS && this.getAge() >= 0) { -+ // CraftBukkit start -+ PlayerShearEntityEvent event = new PlayerShearEntityEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), this.getBukkitEntity()); -+ this.world.getServer().getPluginManager().callEvent(event); -+ -+ if (event.isCancelled()) { -+ return false; -+ } -+ // CraftBukkit end - this.world.addParticle(Particles.u, this.locX, this.locY + (double) (this.length / 2.0F), this.locZ, 0.0D, 0.0D, 0.0D); - if (!this.world.isClientSide) { -- this.die(); -+ // this.die(); // CraftBukkit - moved down - EntityCow entitycow = new EntityCow(this.world); - - entitycow.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, this.pitch); -@@ -35,7 +49,14 @@ - entitycow.setCustomName(this.getCustomName()); - } - -- this.world.addEntity(entitycow); + if (itemstack.getItem() == Items.SHEARS && this.getAge() >= 0) { + // CraftBukkit start -+ if (CraftEventFactory.callEntityTransformEvent(this, entitycow, EntityTransformEvent.TransformReason.SHEARED).isCancelled()) { ++ PlayerShearEntityEvent event = new PlayerShearEntityEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), this.getBukkitEntity()); ++ this.world.getServer().getPluginManager().callEvent(event); ++ ++ if (event.isCancelled()) { + return false; + } -+ this.world.addEntity(entitycow, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SHEARED); -+ -+ this.die(); // CraftBukkit - from above + // CraftBukkit end + this.world.addParticle(Particles.EXPLOSION, this.locX, this.locY + (double) (this.getHeight() / 2.0F), this.locZ, 0.0D, 0.0D, 0.0D); + if (!this.world.isClientSide) { +- this.die(); ++ // this.die(); // CraftBukkit - moved down + EntityCow entitycow = (EntityCow) EntityTypes.COW.a(this.world); - for (int i = 0; i < 5; ++i) { - this.world.addEntity(new EntityItem(this.world, this.locX, this.locY + (double) this.length, this.locZ, new ItemStack(Blocks.RED_MUSHROOM))); + entitycow.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, this.pitch); +@@ -84,7 +97,14 @@ + entitycow.setCustomName(this.getCustomName()); + } + +- this.world.addEntity(entitycow); ++ // CraftBukkit start ++ if (CraftEventFactory.callEntityTransformEvent(this, entitycow, EntityTransformEvent.TransformReason.SHEARED).isCancelled()) { ++ return false; ++ } ++ this.world.addEntity(entitycow, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SHEARED); ++ ++ this.die(); // CraftBukkit - from above ++ // CraftBukkit end + + for (i = 0; i < 5; ++i) { + this.world.addEntity(new EntityItem(this.world, this.locX, this.locY + (double) this.getHeight(), this.locZ, new ItemStack(this.dV().d.getBlock()))); diff --git a/nms-patches/EntityOcelot.patch b/nms-patches/EntityOcelot.patch index 84ab0f737d..9434b61df5 100644 --- a/nms-patches/EntityOcelot.patch +++ b/nms-patches/EntityOcelot.patch @@ -1,40 +1,42 @@ --- a/net/minecraft/server/EntityOcelot.java +++ b/net/minecraft/server/EntityOcelot.java -@@ -60,7 +60,7 @@ +@@ -80,7 +80,7 @@ + + @Override + public boolean isTypeNotPersistent(double d0) { +- return !this.isTrusting() && this.ticksLived > 2400; ++ return !this.isTrusting() /*&& this.ticksLived > 2400*/; // CraftBukkit } - public boolean isTypeNotPersistent() { -- return !this.isTamed() && this.ticksLived > 2400; -+ return !this.isTamed() /*&& this.ticksLived > 2400*/; // CraftBukkit - } - - protected void initAttributes() { -@@ -107,7 +107,8 @@ - return false; - } else { - if (this.goalSit != null) { -- this.goalSit.setSitting(false); -+ // CraftBukkit - moved into EntityLiving.d(DamageSource, float) -+ // this.goalSit.setSitting(false); - } - - return super.damageEntity(damagesource, f); -@@ -132,7 +133,8 @@ - } - + @Override +@@ -131,7 +131,8 @@ + if ((this.bD == null || this.bD.h()) && !this.isTrusting() && this.i(itemstack) && entityhuman.h((Entity) this) < 9.0D) { + this.a(entityhuman, itemstack); if (!this.world.isClientSide) { - if (this.random.nextInt(3) == 0) { + // CraftBukkit - added event call and isCancelled check + if (this.random.nextInt(3) == 0 && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this, entityhuman).isCancelled()) { - this.c(entityhuman); - this.setCatType(1 + this.world.random.nextInt(3)); + this.setTrusting(true); this.s(true); -@@ -238,7 +240,7 @@ + this.world.broadcastEntityEffect(this, (byte) 41); +@@ -217,7 +218,7 @@ - entityocelot.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, 0.0F); - entityocelot.setAgeRaw(-24000); -- this.world.addEntity(entityocelot); -+ this.world.addEntity(entityocelot, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.OCELOT_BABY); // CraftBukkit - add SpawnReason - } + entityocelot.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, 0.0F); + entityocelot.setAgeRaw(-24000); +- this.world.addEntity(entityocelot); ++ this.world.addEntity(entityocelot, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.OCELOT_BABY); // CraftBukkit - add SpawnReason + } + + } +@@ -253,9 +254,9 @@ + private final EntityOcelot i; + + public a(EntityOcelot entityocelot, Class oclass, float f, double d0, double d1) { +- Predicate predicate = IEntitySelector.e; ++ // Predicate predicate = IEntitySelector.e; // CraftBukkit - decompile error + +- super(entityocelot, oclass, f, d0, d1, predicate::test); ++ super(entityocelot, oclass, f, d0, d1, IEntitySelector.e::test); // CraftBukkit - decompile error + this.i = entityocelot; } diff --git a/nms-patches/EntityPainting.patch b/nms-patches/EntityPainting.patch index 7b034ea7e2..db5b520bef 100644 --- a/nms-patches/EntityPainting.patch +++ b/nms-patches/EntityPainting.patch @@ -2,8 +2,8 @@ +++ b/net/minecraft/server/EntityPainting.java @@ -11,6 +11,10 @@ - public EntityPainting(World world) { - super(EntityTypes.PAINTING, world); + public EntityPainting(EntityTypes entitytypes, World world) { + super(entitytypes, world); + // CraftBukkit start - generate a non-null painting + List list = Lists.newArrayList(Paintings.a); + this.art = (Paintings) list.get(this.random.nextInt(list.size())); diff --git a/nms-patches/EntityParrot.patch b/nms-patches/EntityParrot.patch index c16d42cd68..7a9c02c078 100644 --- a/nms-patches/EntityParrot.patch +++ b/nms-patches/EntityParrot.patch @@ -2,32 +2,32 @@ +++ b/net/minecraft/server/EntityParrot.java @@ -21,7 +21,7 @@ }; - private static final Item bN = Items.COOKIE; - private static final Set bO = Sets.newHashSet(new Item[] { Items.WHEAT_SEEDS, Items.MELON_SEEDS, Items.PUMPKIN_SEEDS, Items.BEETROOT_SEEDS}); -- private static final Map, SoundEffect> bP = (Map) SystemUtils.a((Object) Maps.newHashMap(), (hashmap) -> { -+ private static final Map, SoundEffect> bP = (Map) SystemUtils.a(Maps.newHashMap(), (hashmap) -> { // CraftBukkit - decompile error + private static final Item bK = Items.COOKIE; + private static final Set bL = Sets.newHashSet(new Item[] { Items.WHEAT_SEEDS, Items.MELON_SEEDS, Items.PUMPKIN_SEEDS, Items.BEETROOT_SEEDS}); +- private static final Map, SoundEffect> bM = (Map) SystemUtils.a((Object) Maps.newHashMap(), (hashmap) -> { ++ private static final Map, SoundEffect> bM = (Map) SystemUtils.a(Maps.newHashMap(), (hashmap) -> { // CraftBukkit - decompile error hashmap.put(EntityTypes.BLAZE, SoundEffects.ENTITY_PARROT_IMITATE_BLAZE); hashmap.put(EntityTypes.CAVE_SPIDER, SoundEffects.ENTITY_PARROT_IMITATE_SPIDER); hashmap.put(EntityTypes.CREEPER, SoundEffects.ENTITY_PARROT_IMITATE_CREEPER); -@@ -168,7 +168,7 @@ +@@ -180,7 +180,7 @@ } if (!this.world.isClientSide) { - if (this.random.nextInt(10) == 0) { + if (this.random.nextInt(10) == 0 && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this, entityhuman).isCancelled()) { // CraftBukkit - this.c(entityhuman); - this.s(true); + this.tame(entityhuman); + this.r(true); this.world.broadcastEntityEffect(this, (byte) 7); -@@ -184,7 +184,7 @@ +@@ -196,7 +196,7 @@ itemstack.subtract(1); } - this.addEffect(new MobEffect(MobEffects.POISON, 900)); + this.addEffect(new MobEffect(MobEffects.POISON, 900), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.FOOD); // CraftBukkit - if (entityhuman.u() || !this.bl()) { + if (entityhuman.isCreative() || !this.isInvulnerable()) { this.damageEntity(DamageSource.playerAttack(entityhuman), Float.MAX_VALUE); } -@@ -304,7 +304,8 @@ +@@ -334,7 +334,8 @@ return false; } else { if (this.goalSit != null) { diff --git a/nms-patches/EntityPhantom.patch b/nms-patches/EntityPhantom.patch index 9ec8a7bb74..35390e1301 100644 --- a/nms-patches/EntityPhantom.patch +++ b/nms-patches/EntityPhantom.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/server/EntityPhantom.java +++ b/net/minecraft/server/EntityPhantom.java -@@ -197,7 +197,7 @@ +@@ -213,7 +213,7 @@ EntityHuman entityhuman = (EntityHuman) iterator.next(); - if (PathfinderGoalTarget.a(EntityPhantom.this, entityhuman, false, false)) { + if (EntityPhantom.this.a((EntityLiving) entityhuman, PathfinderTargetCondition.a)) { - EntityPhantom.this.setGoalTarget(entityhuman); + EntityPhantom.this.setGoalTarget(entityhuman, org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_PLAYER, true); // CraftBukkit - reason return true; diff --git a/nms-patches/EntityPig.patch b/nms-patches/EntityPig.patch index 7a01790cf3..8d307eec3e 100644 --- a/nms-patches/EntityPig.patch +++ b/nms-patches/EntityPig.patch @@ -11,35 +11,19 @@ + public class EntityPig extends EntityAnimal { - private static final DataWatcherObject bC = DataWatcher.a(EntityPig.class, DataWatcherRegistry.i); -@@ -118,13 +123,14 @@ - } - - public void die(DamageSource damagesource) { -- super.die(damagesource); -+ // super.die(damagesource); // CraftBukkit - Moved to end - if (!this.world.isClientSide) { - if (this.hasSaddle()) { - this.a((IMaterial) Items.SADDLE); - } - + private static final DataWatcherObject bz = DataWatcher.a(EntityPig.class, DataWatcherRegistry.i); +@@ -163,7 +168,13 @@ + entitypigzombie.setCustomNameVisible(this.getCustomNameVisible()); } -+ super.die(damagesource); // CraftBukkit - Moved from above + +- this.world.addEntity(entitypigzombie); ++ // CraftBukkit start ++ if (CraftEventFactory.callPigZapEvent(this, entitylightning, entitypigzombie).isCancelled()) { ++ return; ++ } ++ // CraftBukkit - added a reason for spawning this creature ++ this.world.addEntity(entitypigzombie, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING); ++ // CraftBukkit end + this.die(); } - @Nullable -@@ -157,7 +163,13 @@ - entitypigzombie.setCustomNameVisible(this.getCustomNameVisible()); - } - -- this.world.addEntity(entitypigzombie); -+ // CraftBukkit start -+ if (CraftEventFactory.callPigZapEvent(this, entitylightning, entitypigzombie).isCancelled()) { -+ return; -+ } -+ // CraftBukkit - added a reason for spawning this creature -+ this.world.addEntity(entitypigzombie, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING); -+ // CraftBukkit end - this.die(); - } - } diff --git a/nms-patches/EntityPigZombie.patch b/nms-patches/EntityPigZombie.patch index 5420df19ce..d4500c32e0 100644 --- a/nms-patches/EntityPigZombie.patch +++ b/nms-patches/EntityPigZombie.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/server/EntityPigZombie.java +++ b/net/minecraft/server/EntityPigZombie.java -@@ -113,16 +113,27 @@ +@@ -123,16 +123,27 @@ } else { Entity entity = damagesource.getEntity(); -- if (entity instanceof EntityHuman && !((EntityHuman) entity).u()) { +- if (entity instanceof EntityHuman && !((EntityHuman) entity).isCreative()) { + // CraftBukkit start + boolean result = super.damageEntity(damagesource, f); + -+ if (result && entity instanceof EntityHuman && !((EntityHuman) entity).u()) { ++ if (result && entity instanceof EntityHuman && !((EntityHuman) entity).isCreative()) { this.a(entity); } diff --git a/nms-patches/EntityPillager.patch b/nms-patches/EntityPillager.patch new file mode 100644 index 0000000000..cd82166783 --- /dev/null +++ b/nms-patches/EntityPillager.patch @@ -0,0 +1,19 @@ +--- a/net/minecraft/server/EntityPillager.java ++++ b/net/minecraft/server/EntityPillager.java +@@ -22,7 +22,7 @@ + this.goalSelector.a(8, new PathfinderGoalRandomStroll(this, 0.6D)); + this.goalSelector.a(9, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 15.0F, 1.0F)); + this.goalSelector.a(10, new PathfinderGoalLookAtPlayer(this, EntityInsentient.class, 15.0F)); +- this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[] { EntityRaider.class})).a()); ++ this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[] { EntityRaider.class})).a(new Class[0])); // CraftBukkit - decompile error + this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget<>(this, EntityHuman.class, true)); + this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget<>(this, EntityVillagerAbstract.class, false)); + this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget<>(this, EntityIronGolem.class, true)); +@@ -268,6 +268,6 @@ + + @Override + public boolean isTypeNotPersistent(double d0) { +- return super.isTypeNotPersistent(d0) && this.getInventory().isNotEmpty(); ++ return super.isTypeNotPersistent(d0) && this.getInventory() != null && this.getInventory().isNotEmpty(); // CraftBukkit - null in constructor + } + } diff --git a/nms-patches/EntityPlayer.patch b/nms-patches/EntityPlayer.patch index d2d01a9aa4..def82375fc 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 -@@ -12,10 +12,28 @@ +@@ -13,10 +13,30 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -18,19 +18,21 @@ +import org.bukkit.event.player.PlayerChangedMainHandEvent; +import org.bukkit.event.player.PlayerGameModeChangeEvent; +import org.bukkit.event.player.PlayerLocaleChangeEvent; ++import org.bukkit.event.player.PlayerPortalEvent; ++import org.bukkit.event.player.PlayerTeleportEvent; +import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; +import org.bukkit.inventory.MainHand; +// CraftBukkit end + public class EntityPlayer extends EntityHuman implements ICrafting { - private static final Logger cc = LogManager.getLogger(); + private static final Logger LOGGER = LogManager.getLogger(); - public String locale = "en_US"; + public String locale = "en_us"; // CraftBukkit - lowercase public PlayerConnection playerConnection; public final MinecraftServer server; public final PlayerInteractManager playerInteractManager; -@@ -51,6 +69,20 @@ +@@ -52,6 +72,20 @@ public int ping; public boolean viewingCredits; @@ -51,9 +53,9 @@ public EntityPlayer(MinecraftServer minecraftserver, WorldServer worldserver, GameProfile gameprofile, PlayerInteractManager playerinteractmanager) { super((World) worldserver, gameprofile); playerinteractmanager.player = this; -@@ -61,8 +93,50 @@ - this.cf = minecraftserver.getPlayerList().h(this); - this.Q = 1.0F; +@@ -62,8 +96,50 @@ + this.advancementDataPlayer = minecraftserver.getPlayerList().f(this); + this.K = 1.0F; this.a(worldserver); + + // CraftBukkit start @@ -80,14 +82,14 @@ + } + + int k = (i * 2 + 1) * (i * 2 + 1); -+ int l = this.r(k); ++ int l = this.s(k); + int i1 = (new Random()).nextInt(k); + + for (int j1 = 0; j1 < k; ++j1) { + int k1 = (i1 + l * j1) % k; + int l1 = k1 % (i * 2 + 1); + int i2 = k1 / (i * 2 + 1); -+ BlockPosition blockposition1 = worldserver.o().a(blockposition.getX() + l1 - i, blockposition.getZ() + i2 - i, false); ++ BlockPosition blockposition1 = worldserver.getWorldProvider().a(blockposition.getX() + l1 - i, blockposition.getZ() + i2 - i, false); + + if (blockposition1 != null) { + return blockposition1; @@ -102,19 +104,19 @@ private void a(WorldServer worldserver) { BlockPosition blockposition = worldserver.getSpawn(); -@@ -129,6 +203,7 @@ +@@ -131,6 +207,7 @@ if (nbttagcompound.hasKeyOfType("recipeBook", 10)) { this.recipeBook.a(nbttagcompound.getCompound("recipeBook")); } + this.getBukkitEntity().readExtraData(nbttagcompound); // CraftBukkit - } - -@@ -148,7 +223,20 @@ + if (this.isSleeping()) { + this.dy(); +@@ -155,7 +232,20 @@ Entity entity = this.getRootVehicle(); Entity entity1 = this.getVehicle(); -- if (entity1 != null && entity != this && entity.bR()) { +- if (entity1 != null && entity != this && entity.hasSinglePlayerPassenger()) { + // CraftBukkit start - handle non-persistent vehicles + boolean persistVehicle = true; + if (entity1 != null) { @@ -127,18 +129,18 @@ + } + } + -+ if (persistVehicle && entity1 != null && entity != this && entity.bR()) { ++ if (persistVehicle && entity1 != null && entity != this && entity.hasSinglePlayerPassenger()) { + // CraftBukkit end NBTTagCompound nbttagcompound2 = new NBTTagCompound(); NBTTagCompound nbttagcompound3 = new NBTTagCompound(); -@@ -159,7 +247,33 @@ +@@ -166,8 +256,34 @@ } - nbttagcompound.set("recipeBook", this.recipeBook.e()); + nbttagcompound.set("recipeBook", this.recipeBook.save()); + this.getBukkitEntity().setExtraData(nbttagcompound); // CraftBukkit -+ } -+ + } + + // CraftBukkit start - World fallback code, either respawn location or global spawn + public void spawnIn(World world) { + super.spawnIn(world); @@ -161,14 +163,15 @@ + } + this.dimension = ((WorldServer) this.world).dimension; + this.playerInteractManager.a((WorldServer) world); - } ++ } + // CraftBukkit end - ++ public void a(int i) { float f = (float) this.getExpToLevel(); -@@ -207,6 +321,11 @@ - } + float f1 = (f - 1.0F) / f; +@@ -221,6 +337,11 @@ + @Override public void tick() { + // CraftBukkit start + if (this.joining) { @@ -178,17 +181,17 @@ this.playerInteractManager.a(); --this.invulnerableTicks; if (this.noDamageTicks > 0) { -@@ -272,7 +391,7 @@ +@@ -288,7 +409,7 @@ } - if (this.getHealth() != this.lastHealthSent || this.lastFoodSent != this.foodData.getFoodLevel() || this.foodData.getSaturationLevel() == 0.0F != this.cp) { + if (this.getHealth() != this.lastHealthSent || this.lastFoodSent != this.foodData.getFoodLevel() || this.foodData.getSaturationLevel() == 0.0F != this.lastSentSaturationZero) { - this.playerConnection.sendPacket(new PacketPlayOutUpdateHealth(this.getHealth(), this.foodData.getFoodLevel(), this.foodData.getSaturationLevel())); + this.playerConnection.sendPacket(new PacketPlayOutUpdateHealth(this.getBukkitEntity().getScaledHealth(), this.foodData.getFoodLevel(), this.foodData.getSaturationLevel())); // CraftBukkit this.lastHealthSent = this.getHealth(); this.lastFoodSent = this.foodData.getFoodLevel(); - this.cp = this.foodData.getSaturationLevel() == 0.0F; -@@ -303,6 +422,12 @@ - this.a(IScoreboardCriteria.XP, MathHelper.f((float) this.cm)); + this.lastSentSaturationZero = this.foodData.getSaturationLevel() == 0.0F; +@@ -319,6 +440,12 @@ + this.a(IScoreboardCriteria.XP, MathHelper.f((float) this.lastExpTotalScored)); } + // CraftBukkit start - Force max health updates @@ -197,10 +200,10 @@ + } + // CraftBukkit end + - if (this.expLevel != this.cl) { - this.cl = this.expLevel; - this.a(IScoreboardCriteria.LEVEL, MathHelper.f((float) this.cl)); -@@ -317,6 +442,16 @@ + if (this.expLevel != this.lastExpLevelScored) { + this.lastExpLevelScored = this.expLevel; + this.a(IScoreboardCriteria.LEVEL, MathHelper.f((float) this.lastExpLevelScored)); +@@ -333,6 +460,16 @@ CriterionTriggers.p.a(this); } @@ -217,7 +220,7 @@ } catch (Throwable throwable) { CrashReport crashreport = CrashReport.a(throwable, "Ticking player"); CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Player being ticked"); -@@ -327,16 +462,48 @@ +@@ -343,7 +480,8 @@ } private void a(IScoreboardCriteria iscoreboardcriteria, int i) { @@ -227,7 +230,8 @@ scoreboardscore.setScore(i); }); } - +@@ -351,9 +489,40 @@ + @Override public void die(DamageSource damagesource) { boolean flag = this.world.getGameRules().getBoolean("showDeathMessages"); + // CraftBukkit start - fire PlayerDeathEvent @@ -269,13 +273,12 @@ this.playerConnection.a((Packet) (new PacketPlayOutCombatEvent(this.getCombatTracker(), PacketPlayOutCombatEvent.EnumCombatEventType.ENTITY_DIED, ichatbasecomponent)), (future) -> { if (!future.isSuccess()) { -@@ -367,12 +534,16 @@ +@@ -384,11 +553,16 @@ } this.releaseShoulderEntities(); -- if (!this.world.getGameRules().getBoolean("keepInventory") && !this.isSpectator()) { -- this.removeCursedItems(); -- this.inventory.dropContents(); +- if (!this.isSpectator()) { +- this.d(damagesource); - } + // we clean the player's inventory after the EntityDeathEvent is called so plugins can get the exact state of the inventory. + if (!event.getKeepInventory()) { @@ -288,10 +291,10 @@ - this.getScoreboard().getObjectivesForCriteria(IScoreboardCriteria.DEATH_COUNT, this.getName(), ScoreboardScore::incrementScore); + // CraftBukkit - Get our scores instead + this.world.getServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.DEATH_COUNT, this.getName(), ScoreboardScore::incrementScore); - EntityLiving entityliving = this.cv(); + EntityLiving entityliving = this.getKillingEntity(); if (entityliving != null) { -@@ -395,10 +566,12 @@ +@@ -431,10 +605,12 @@ String s = this.getName(); String s1 = entity.getName(); @@ -306,7 +309,7 @@ } else { this.a(StatisticList.MOB_KILLS); } -@@ -416,7 +589,8 @@ +@@ -452,7 +628,8 @@ int i = scoreboardteam.getColor().b(); if (i >= 0 && i < aiscoreboardcriteria.length) { @@ -316,7 +319,7 @@ } } -@@ -458,12 +632,14 @@ +@@ -496,16 +673,26 @@ } private boolean canPvP() { @@ -326,57 +329,142 @@ } @Nullable + @Override public Entity a(DimensionManager dimensionmanager) { - this.worldChangeInvuln = true; -+ if (this.isSleeping()) return this; // CraftBukkit - SPIGOT-3154 -+ // this.worldChangeInvuln = true; // CraftBukkit - Moved down and into PlayerList#changeDimension - if (this.dimension == DimensionManager.OVERWORLD && dimensionmanager == DimensionManager.NETHER) { - this.cC = new Vec3D(this.locX, this.locY, this.locZ); - } else if (this.dimension != DimensionManager.NETHER && dimensionmanager != DimensionManager.OVERWORLD) { -@@ -471,6 +647,7 @@ - } - - if (this.dimension == DimensionManager.THE_END && dimensionmanager == DimensionManager.THE_END) { -+ this.worldChangeInvuln = true; // CraftBukkit - Moved down from above - this.world.kill(this); - if (!this.viewingCredits) { - this.viewingCredits = true; -@@ -484,7 +661,10 @@ - dimensionmanager = DimensionManager.THE_END; - } - -- this.server.getPlayerList().a(this, dimensionmanager); -+ // CraftBukkit start -+ TeleportCause cause = (this.dimension == DimensionManager.THE_END || dimensionmanager == DimensionManager.THE_END) ? TeleportCause.END_PORTAL : TeleportCause.NETHER_PORTAL; -+ this.server.getPlayerList().changeDimension(this, dimensionmanager, cause); // PAIL: check all this -+ // CraftBukkit end - this.playerConnection.sendPacket(new PacketPlayOutWorldEvent(1032, BlockPosition.ZERO, 0, false)); - this.lastSentExp = -1; - this.lastHealthSent = -1.0F; -@@ -514,7 +694,13 @@ - } - - public EntityHuman.EnumBedResult a(BlockPosition blockposition) { -- EntityHuman.EnumBedResult entityhuman_enumbedresult = super.a(blockposition); -+ // CraftBukkit start - add force parameter -+ return this.a(blockposition, false); ++ // CraftBukkit start ++ return a(dimensionmanager, TeleportCause.UNKNOWN); + } + -+ public EntityHuman.EnumBedResult a(BlockPosition blockposition, boolean force) { -+ EntityHuman.EnumBedResult entityhuman_enumbedresult = super.a(blockposition, force); ++ @Nullable ++ public Entity a(DimensionManager dimensionmanager, PlayerTeleportEvent.TeleportCause cause) { + // CraftBukkit end ++ if (this.isSleeping()) return this; // CraftBukkit - SPIGOT-3154 ++ // this.worldChangeInvuln = true; // CraftBukkit - Moved down and into PlayerList#changeDimension + DimensionManager dimensionmanager1 = this.dimension; - if (entityhuman_enumbedresult == EntityHuman.EnumBedResult.OK) { - this.a(StatisticList.SLEEP_IN_BED); -@@ -530,6 +716,7 @@ + if (dimensionmanager1 == DimensionManager.THE_END && dimensionmanager == DimensionManager.OVERWORLD) { ++ this.worldChangeInvuln = true; // CraftBukkit - Moved down from above + this.decouple(); + this.getWorldServer().removePlayer(this); + if (!this.viewingCredits) { +@@ -518,10 +705,16 @@ + } else { + WorldServer worldserver = this.server.getWorldServer(dimensionmanager1); + +- this.dimension = dimensionmanager; ++ // this.dimension = dimensionmanager; // CraftBukkit + WorldServer worldserver1 = this.server.getWorldServer(dimensionmanager); + WorldData worlddata = this.world.getWorldData(); + ++ // CraftBukkit start ++ if (worldserver1 == null) { ++ return null; ++ } ++ ++ /* + this.playerConnection.sendPacket(new PacketPlayOutRespawn(dimensionmanager, worlddata.getType(), this.playerInteractManager.getGameMode())); + this.playerConnection.sendPacket(new PacketPlayOutServerDifficulty(worlddata.getDifficulty(), worlddata.isDifficultyLocked())); + PlayerList playerlist = this.server.getPlayerList(); +@@ -529,6 +722,8 @@ + playerlist.d(this); + worldserver.removePlayer(this); + this.dead = false; ++ */ ++ // CraftBukkit end + double d0 = this.locX; + double d1 = this.locY; + double d2 = this.locZ; +@@ -555,6 +750,52 @@ + f = 0.0F; + } + ++ // CraftBukkit start ++ Location enter = this.getBukkitEntity().getLocation(); ++ Location exit = new Location(worldserver1.getWorld(), d0, d1, d2, f1, f); ++ PlayerPortalEvent event = new PlayerPortalEvent(this.getBukkitEntity(), enter, exit, cause); ++ Bukkit.getServer().getPluginManager().callEvent(event); ++ if (event.isCancelled() || event.getTo() == null) { ++ return null; ++ } ++ ++ exit = event.getTo(); ++ if (exit == null) { ++ return null; ++ } ++ ++ PlayerTeleportEvent tpEvent = new PlayerTeleportEvent(this.getBukkitEntity(), enter, exit, cause); ++ Bukkit.getServer().getPluginManager().callEvent(tpEvent); ++ if (tpEvent.isCancelled() || tpEvent.getTo() == null) { ++ return null; ++ } ++ ++ exit = event.getTo(); ++ if (exit == null) { ++ return null; ++ } ++ worldserver1 = ((CraftWorld) exit.getWorld()).getHandle(); ++ d0 = exit.getX(); ++ d1 = exit.getY(); ++ d2 = exit.getZ(); ++ f1 = exit.getYaw(); ++ f = exit.getPitch(); ++ this.worldChangeInvuln = true; // CraftBukkit - Set teleport invulnerability only if player changing worlds ++ dimensionmanager = worldserver1.dimension; ++ // CraftBukkit end ++ ++ // CraftBukkit start ++ this.dimension = dimensionmanager; ++ ++ this.playerConnection.sendPacket(new PacketPlayOutRespawn(dimensionmanager, this.world.getWorldData().getType(), this.playerInteractManager.getGameMode())); ++ this.playerConnection.sendPacket(new PacketPlayOutServerDifficulty(this.world.getDifficulty(), this.world.getWorldData().isDifficultyLocked())); ++ PlayerList playerlist = this.server.getPlayerList(); ++ ++ playerlist.d(this); ++ worldserver.removePlayer(this); ++ this.dead = false; ++ // CraftBukkit end ++ + this.setPositionRotation(d0, d1, d2, f1, f); + worldserver.getMethodProfiler().exit(); + worldserver.getMethodProfiler().enter("placing"); +@@ -618,7 +859,7 @@ + } } - public void a(boolean flag, boolean flag1, boolean flag2) { -+ if (!this.sleeping) return; // CraftBukkit - Can't leave bed if not in one! +- private void b(WorldServer worldserver) { ++ public void b(WorldServer worldserver) { // PAIL + DimensionManager dimensionmanager = worldserver.worldProvider.getDimensionManager(); + DimensionManager dimensionmanager1 = this.world.worldProvider.getDimensionManager(); + +@@ -655,9 +896,16 @@ + this.activeContainer.c(); + } + +- @Override ++ @Override + public Either sleep(BlockPosition blockposition) { +- return super.sleep(blockposition).ifRight((unit) -> { ++ // CraftBukkit start - add force parameter ++ return this.sleep(blockposition, false); ++ } ++ ++ @Override ++ public Either sleep(BlockPosition blockposition, boolean force) { ++ // CraftBukkit end ++ return super.sleep(blockposition, force).ifRight((unit) -> { + this.a(StatisticList.SLEEP_IN_BED); + CriterionTriggers.q.a(this); + }); +@@ -665,6 +913,7 @@ + + @Override + public void wakeup(boolean flag, boolean flag1, boolean flag2) { ++ if (!this.isSleeping()) return; // CraftBukkit - Can't leave bed if not in one! if (this.isSleeping()) { - this.getWorldServer().getTracker().sendPacketToEntity(this, new PacketPlayOutAnimation(this, 2)); + this.getWorldServer().getChunkProvider().broadcastIncludingSelf(this, new PacketPlayOutAnimation(this, 2)); } -@@ -608,23 +795,55 @@ +@@ -752,8 +1001,9 @@ this.playerConnection.sendPacket(new PacketPlayOutOpenSignEditor(tileentitysign.getPosition())); } @@ -386,116 +474,46 @@ + return containerCounter; // CraftBukkit } - public void openTileEntity(ITileEntityContainer itileentitycontainer) { -- if (itileentitycontainer instanceof ILootable && ((ILootable) itileentitycontainer).getLootTable() != null && this.isSpectator()) { -+ // CraftBukkit start - Inventory open hook -+ if (false && itileentitycontainer instanceof ILootable && ((ILootable) itileentitycontainer).getLootTable() != null && this.isSpectator()) { - this.a((new ChatMessage("container.spectatorCantOpen", new Object[0])).a(EnumChatFormat.RED), true); - } else { -+ boolean cancelled = itileentitycontainer instanceof ILootable && ((ILootable) itileentitycontainer).getLootTable()!= null && this.isSpectator(); -+ Container container = CraftEventFactory.callInventoryOpenEvent(this, itileentitycontainer.createContainer(this.inventory, this), cancelled); -+ if (container == null) { -+ return; -+ } + @Override +@@ -768,6 +1018,17 @@ this.nextContainerCounter(); -+ this.activeContainer = container; - this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.containerCounter, itileentitycontainer.getContainerName(), itileentitycontainer.getScoreboardDisplayName())); -- this.activeContainer = itileentitycontainer.createContainer(this.inventory, this); + Container container = itileinventory.createMenu(this.containerCounter, this.inventory, this); + ++ // CraftBukkit start - Inventory open hook ++ if (container != null) { ++ container.setTitle(itileinventory.getScoreboardDisplayName()); ++ ++ boolean cancelled = false; ++ container = CraftEventFactory.callInventoryOpenEvent(this, container, cancelled); ++ if (container == null && !cancelled) { // Let pre-cancelled events fall through ++ return OptionalInt.empty(); ++ } ++ } + // CraftBukkit end - this.activeContainer.windowId = this.containerCounter; - this.activeContainer.addSlotListener(this); - } - } + if (container == null) { + if (this.isSpectator()) { + this.a((new ChatMessage("container.spectatorCantOpen", new Object[0])).a(EnumChatFormat.RED), true); +@@ -775,9 +1036,11 @@ - public void openContainer(IInventory iinventory) { -+ // CraftBukkit start - Inventory open hook -+ // Copied from below -+ boolean cancelled = false; -+ if (iinventory instanceof ITileInventory) { -+ ITileInventory itileinventory = (ITileInventory) iinventory; -+ cancelled = itileinventory.isLocked() && !this.a(itileinventory.getLock()) && !this.isSpectator(); -+ } -+ -+ Container container; -+ if (iinventory instanceof ITileEntityContainer) { -+ if (iinventory instanceof TileEntity) { -+ Preconditions.checkArgument(((TileEntity) iinventory).getWorld() != null, "Container must have world to be opened"); -+ } -+ container = ((ITileEntityContainer) iinventory).createContainer(this.inventory, this); -+ } else { -+ container = new ContainerChest(this.inventory, iinventory, this); -+ } -+ container = CraftEventFactory.callInventoryOpenEvent(this, container, cancelled); -+ if (container == null && !cancelled) { // Let pre-cancelled events fall through -+ iinventory.closeContainer(this); -+ return; -+ } -+ // CraftBukkit end -+ - if (iinventory instanceof ILootable && ((ILootable) iinventory).getLootTable() != null && this.isSpectator()) { - this.a((new ChatMessage("container.spectatorCantOpen", new Object[0])).a(EnumChatFormat.RED), true); - } else { -@@ -638,18 +857,21 @@ - if (itileinventory.isLocked() && !this.a(itileinventory.getLock()) && !this.isSpectator()) { - this.playerConnection.sendPacket(new PacketPlayOutChat(new ChatMessage("container.isLocked", new Object[] { iinventory.getScoreboardDisplayName()}), ChatMessageType.GAME_INFO)); - this.playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect(SoundEffects.BLOCK_CHEST_LOCKED, SoundCategory.BLOCKS, this.locX, this.locY, this.locZ, 1.0F, 1.0F)); -+ iinventory.closeContainer(this); // CraftBukkit - return; - } - } - - 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); + return OptionalInt.empty(); } 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); +- this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, container.getType(), itileinventory.getScoreboardDisplayName())); +- container.addSlotListener(this); ++ // CraftBukkit start + this.activeContainer = container; ++ this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, container.getType(), container.getTitle())); ++ // CraftBukkit end ++ container.addSlotListener(this); + return OptionalInt.of(this.containerCounter); } -+ // CraftBukkit end - - this.activeContainer.windowId = this.containerCounter; - this.activeContainer.addSlotListener(this); -@@ -657,14 +879,27 @@ - } - - public void openTrade(IMerchant imerchant) { -+ // CraftBukkit start - Inventory open hook -+ Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerMerchant(this.inventory, imerchant, this.world)); -+ if (container == null) { -+ return; -+ } -+ // CraftBukkit end - this.nextContainerCounter(); -- this.activeContainer = new ContainerMerchant(this.inventory, imerchant, this.world); -- this.activeContainer.windowId = this.containerCounter; -- this.activeContainer.addSlotListener(this); -+ this.activeContainer = container; // CraftBukkit -+ // CraftBukkit start - moved down (SPIGOT-4619) -+ // this.activeContainer.windowId = this.containerCounter; -+ // this.activeContainer.addSlotListener(this); -+ // CraftBukkit end -+ - InventoryMerchant inventorymerchant = ((ContainerMerchant) this.activeContainer).d(); - IChatBaseComponent ichatbasecomponent = imerchant.getScoreboardDisplayName(); - - this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.containerCounter, "minecraft:villager", ichatbasecomponent, inventorymerchant.getSize())); -+ // CraftBukkit start -+ this.activeContainer.windowId = this.containerCounter; -+ this.activeContainer.addSlotListener(this); -+ // CraftBukkit end - MerchantRecipeList merchantrecipelist = imerchant.getOffers(this); - - if (merchantrecipelist != null) { -@@ -678,13 +913,20 @@ - } + } +@@ -790,13 +1053,21 @@ + @Override public void openHorseInventory(EntityHorseAbstract entityhorseabstract, IInventory iinventory) { + // CraftBukkit start - Inventory open hook -+ Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerHorse(this.inventory, iinventory, entityhorseabstract, this)); ++ this.nextContainerCounter(); ++ Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerHorse(this.containerCounter, this.inventory, iinventory, entityhorseabstract)); + if (container == null) { + iinventory.closeContainer(this); + return; @@ -505,14 +523,15 @@ this.closeInventory(); } - this.nextContainerCounter(); - this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.containerCounter, "EntityHorse", iinventory.getScoreboardDisplayName(), iinventory.getSize(), entityhorseabstract.getId())); -- this.activeContainer = new ContainerHorse(this.inventory, iinventory, entityhorseabstract, this); +- this.nextContainerCounter(); ++ // this.nextContainerCounter(); // CraftBukkit - moved up + this.playerConnection.sendPacket(new PacketPlayOutOpenWindowHorse(this.containerCounter, iinventory.getSize(), entityhorseabstract.getId())); +- this.activeContainer = new ContainerHorse(this.containerCounter, this.inventory, iinventory, entityhorseabstract); + this.activeContainer = container; // CraftBukkit - this.activeContainer.windowId = this.containerCounter; this.activeContainer.addSlotListener(this); } -@@ -725,6 +967,11 @@ + +@@ -841,6 +1112,11 @@ public void a(Container container, NonNullList nonnulllist) { this.playerConnection.sendPacket(new PacketPlayOutWindowItems(container.windowId, nonnulllist)); this.playerConnection.sendPacket(new PacketPlayOutSetSlot(-1, -1, this.inventory.getCarried())); @@ -523,62 +542,62 @@ + // CraftBukkit end } - public void setContainerData(Container container, int i, int j) { -@@ -739,6 +986,7 @@ - } + @Override +@@ -850,6 +1126,7 @@ + @Override public void closeInventory() { + CraftEventFactory.handleInventoryCloseEvent(this); // CraftBukkit this.playerConnection.sendPacket(new PacketPlayOutCloseWindow(this.activeContainer.windowId)); this.m(); } -@@ -772,14 +1020,14 @@ - +@@ -884,7 +1161,7 @@ + @Override public void a(Statistic statistic, int i) { - this.cg.b(this, statistic, i); + this.serverStatisticManager.b(this, statistic, i); - this.getScoreboard().getObjectivesForCriteria(statistic, this.getName(), (scoreboardscore) -> { + this.world.getServer().getScoreboardManager().getScoreboardScores(statistic, this.getName(), (scoreboardscore) -> { // CraftBukkit - Get our scores instead scoreboardscore.addScore(i); }); } - +@@ -892,7 +1169,7 @@ + @Override public void a(Statistic statistic) { - this.cg.setStatistic(this, statistic, 0); + this.serverStatisticManager.setStatistic(this, statistic, 0); - this.getScoreboard().getObjectivesForCriteria(statistic, this.getName(), ScoreboardScore::c); + this.world.getServer().getScoreboardManager().getScoreboardScores(statistic, this.getName(), ScoreboardScore::c); // CraftBukkit - Get our scores instead } - public int discoverRecipes(Collection collection) { -@@ -827,8 +1075,17 @@ + @Override +@@ -941,7 +1218,16 @@ public void triggerHealthUpdate() { this.lastHealthSent = -1.0E8F; + this.lastSentExp = -1; // CraftBukkit - Added to reset - } - ++ } ++ + // CraftBukkit start - Support multi-line messages + public void sendMessage(IChatBaseComponent[] ichatbasecomponent) { + for (IChatBaseComponent component : ichatbasecomponent) { + this.sendMessage(component); + } -+ } -+ // CraftBukkit end -+ - public void a(IChatBaseComponent ichatbasecomponent, boolean flag) { - this.playerConnection.sendPacket(new PacketPlayOutChat(ichatbasecomponent, flag ? ChatMessageType.GAME_INFO : ChatMessageType.CHAT)); } -@@ -879,7 +1136,7 @@ ++ // CraftBukkit end + + @Override + public void a(IChatBaseComponent ichatbasecomponent, boolean flag) { +@@ -996,7 +1282,7 @@ this.lastSentExp = -1; this.lastHealthSent = -1.0F; this.lastFoodSent = -1; - this.recipeBook.a((RecipeBook) entityplayer.recipeBook); + // this.recipeBook.a((RecipeBook) entityplayer.recipeBook); // CraftBukkit this.removeQueue.addAll(entityplayer.removeQueue); - this.cx = entityplayer.cx; - this.cC = entityplayer.cC; -@@ -938,6 +1195,18 @@ - } + this.cp = entityplayer.cp; + this.cu = entityplayer.cu; +@@ -1063,6 +1349,18 @@ + @Override public void a(EnumGamemode enumgamemode) { + // CraftBukkit start + if (enumgamemode == this.playerInteractManager.getGameMode()) { @@ -595,7 +614,7 @@ this.playerInteractManager.setGameMode(enumgamemode); this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(3, (float) enumgamemode.getId())); if (enumgamemode == EnumGamemode.SPECTATOR) { -@@ -985,6 +1254,17 @@ +@@ -1113,6 +1411,17 @@ } public void a(PacketPlayInSettings packetplayinsettings) { @@ -611,9 +630,9 @@ + this.clientViewDistance = packetplayinsettings.viewDistance; + // CraftBukkit end this.locale = packetplayinsettings.b(); - this.cs = packetplayinsettings.d(); - this.ct = packetplayinsettings.e(); -@@ -1020,13 +1300,13 @@ + this.ck = packetplayinsettings.d(); + this.cl = packetplayinsettings.e(); +@@ -1149,13 +1458,13 @@ if (entity instanceof EntityHuman) { this.playerConnection.sendPacket(new PacketPlayOutEntityDestroy(new int[] { entity.getId()})); } else { @@ -628,8 +647,8 @@ + this.removeQueue.remove((Integer) entity.getId()); // CraftBukkit - decompile error } - protected void C() { -@@ -1050,7 +1330,7 @@ + @Override +@@ -1179,7 +1488,7 @@ this.spectatedEntity = (Entity) (entity == null ? this : entity); if (entity1 != this.spectatedEntity) { this.playerConnection.sendPacket(new PacketPlayOutCamera(this.spectatedEntity)); @@ -638,7 +657,7 @@ } } -@@ -1077,7 +1357,7 @@ +@@ -1208,7 +1517,7 @@ @Nullable public IChatBaseComponent getPlayerListName() { @@ -646,8 +665,8 @@ + return listName; // CraftBukkit } - public void a(EnumHand enumhand) { -@@ -1094,12 +1374,17 @@ + @Override +@@ -1226,21 +1535,33 @@ } public void J() { @@ -665,8 +684,7 @@ } public AdvancementDataPlayer getAdvancementData() { -@@ -1111,9 +1396,16 @@ - return this.cC; + return this.advancementDataPlayer; } + // CraftBukkit start @@ -682,15 +700,20 @@ if (worldserver == this.world) { this.playerConnection.a(d0, d1, d2, f, f1); } else { -@@ -1138,6 +1430,149 @@ - this.server.getPlayerList().b(this, worldserver); +@@ -1263,6 +1584,9 @@ + this.server.getPlayerList().a(this, worldserver); this.server.getPlayerList().updateClient(this); } + */ + this.getBukkitEntity().teleport(new Location(worldserver.getWorld(), d0, d1, d2, f, f1), cause); + // CraftBukkit end -+ -+ } + + } + +@@ -1314,4 +1638,144 @@ + return entityitem; + } + } + + // CraftBukkit start - Add per-player time and weather. + public long timeOffset = 0; @@ -825,10 +848,10 @@ + } + this.keepLevel = false; + } - ++ + @Override + public CraftPlayer getBukkitEntity() { + return (CraftPlayer) super.getBukkitEntity(); - } ++ } + // CraftBukkit end } diff --git a/nms-patches/EntityPotion.patch b/nms-patches/EntityPotion.patch index df5fea07cb..0161f90dee 100644 --- a/nms-patches/EntityPotion.patch +++ b/nms-patches/EntityPotion.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/server/EntityPotion.java +++ b/net/minecraft/server/EntityPotion.java -@@ -5,6 +5,12 @@ - import java.util.function.Predicate; +@@ -6,6 +6,12 @@ + import javax.annotation.Nullable; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +// CraftBukkit start @@ -13,24 +13,24 @@ public class EntityPotion extends EntityProjectile { -@@ -77,7 +83,7 @@ +@@ -79,7 +85,7 @@ if (flag) { - this.l(); + this.splash(); - } else if (!list.isEmpty()) { + } else if (true || !list.isEmpty()) { // CraftBukkit - Call event even if no effects to apply if (this.isLingering()) { this.a(itemstack, potionregistry); } else { -@@ -114,6 +120,7 @@ - private void a(MovingObjectPosition movingobjectposition, List list) { +@@ -116,6 +122,7 @@ + private void a(List list, @Nullable Entity entity) { AxisAlignedBB axisalignedbb = this.getBoundingBox().grow(4.0D, 2.0D, 4.0D); List list1 = this.world.a(EntityLiving.class, axisalignedbb); + Map affected = new HashMap(); // CraftBukkit if (!list1.isEmpty()) { Iterator iterator = list1.iterator(); -@@ -131,21 +138,46 @@ +@@ -133,21 +140,46 @@ d1 = 1.0D; } @@ -91,7 +91,7 @@ } } } -@@ -177,7 +209,14 @@ +@@ -179,7 +211,14 @@ entityareaeffectcloud.setColor(nbttagcompound.getInt("CustomPotionColor")); } diff --git a/nms-patches/EntityProjectile.patch b/nms-patches/EntityProjectile.patch index 176dade188..c45df4f023 100644 --- a/nms-patches/EntityProjectile.patch +++ b/nms-patches/EntityProjectile.patch @@ -1,24 +1,24 @@ --- a/net/minecraft/server/EntityProjectile.java +++ b/net/minecraft/server/EntityProjectile.java -@@ -33,6 +33,7 @@ +@@ -32,6 +32,7 @@ this(entitytypes, entityliving.locX, entityliving.locY + (double) entityliving.getHeadHeight() - 0.10000000149011612D, entityliving.locZ, world); this.shooter = entityliving; this.shooterId = entityliving.getUniqueID(); + this.projectileSource = (org.bukkit.entity.LivingEntity) entityliving.getBukkitEntity(); // CraftBukkit } - protected void x_() {} -@@ -111,7 +112,7 @@ - if (entity1.isInteractable()) { - if (entity1 == this.d) { - flag = true; -- } else if (this.shooter != null && this.ticksLived < 2 && this.d == null) { -+ } else if (this.shooter != null && this.ticksLived < 2 && this.d == null && this.shooter == entity1) { // CraftBukkit - MC-88491 - this.d = entity1; - flag = true; - } else { -@@ -148,6 +149,11 @@ - this.e(movingobjectposition.getBlockPosition()); + public void a(Entity entity, float f, float f1, float f2, float f3, float f4) { +@@ -86,7 +87,7 @@ + break; + } + +- if (this.shooter != null && this.ticksLived < 2 && this.as == null) { ++ if (this.shooter != null && this.ticksLived < 2 && this.as == null && this.shooter == entity) { // CraftBukkit - MC-88491 + this.as = entity; + this.at = 3; + break; +@@ -106,6 +107,11 @@ + this.c(((MovingObjectPositionBlock) movingobjectposition).getBlockPosition()); } else { this.a(movingobjectposition); + // CraftBukkit start diff --git a/nms-patches/EntityPufferFish.patch b/nms-patches/EntityPufferFish.patch index 05b2a7cc72..4cf6c70394 100644 --- a/nms-patches/EntityPufferFish.patch +++ b/nms-patches/EntityPufferFish.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/EntityPufferFish.java +++ b/net/minecraft/server/EntityPufferFish.java -@@ -140,7 +140,7 @@ +@@ -114,7 +114,7 @@ int i = this.getPuffState(); if (entityinsentient.damageEntity(DamageSource.mobAttack(this), (float) (1 + i))) { @@ -9,7 +9,7 @@ this.a(SoundEffects.ENTITY_PUFFER_FISH_STING, 1.0F, 1.0F); } -@@ -151,7 +151,7 @@ +@@ -126,7 +126,7 @@ if (entityhuman instanceof EntityPlayer && i > 0 && entityhuman.damageEntity(DamageSource.mobAttack(this), (float) (1 + i))) { ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutGameStateChange(9, 0.0F)); diff --git a/nms-patches/EntityRabbit.patch b/nms-patches/EntityRabbit.patch index 0d08e2b01c..04ff0db7b3 100644 --- a/nms-patches/EntityRabbit.patch +++ b/nms-patches/EntityRabbit.patch @@ -1,21 +1,30 @@ --- a/net/minecraft/server/EntityRabbit.java +++ b/net/minecraft/server/EntityRabbit.java -@@ -17,8 +17,14 @@ - this.setSize(0.4F, 0.5F); - this.h = new EntityRabbit.ControllerJumpRabbit(this); +@@ -16,8 +16,14 @@ + super(entitytypes, world); + this.bt = new EntityRabbit.ControllerJumpRabbit(this); this.moveController = new EntityRabbit.ControllerMoveRabbit(this); + this.initializePathFinderGoals(); // CraftBukkit - moved code + } + + // CraftBukkit start - code from constructor + public void initializePathFinderGoals(){ - this.c(0.0D); + this.d(0.0D); } + // CraftBukkit end - protected void n() { - this.goalSelector.a(1, new PathfinderGoalFloat(this)); -@@ -393,9 +399,23 @@ + @Override + protected void initPathfinder() { +@@ -285,7 +291,7 @@ + if (i == 99) { + this.getAttributeInstance(GenericAttributes.ARMOR).setValue(8.0D); + this.goalSelector.a(4, new EntityRabbit.PathfinderGoalKillerRabbitMeleeAttack(this)); +- this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[0])).a()); ++ this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[0])).a(new Class[0])); // CraftBukkit - decompile error + this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget<>(this, EntityHuman.class, true)); + this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget<>(this, EntityWolf.class, true)); + if (!this.hasCustomName()) { +@@ -413,9 +419,23 @@ Integer integer = (Integer) iblockdata.get(BlockCarrots.AGE); if (integer == 0) { @@ -25,7 +34,7 @@ + } + // CraftBukkit end world.setTypeAndData(blockposition, Blocks.AIR.getBlockData(), 2); - world.setAir(blockposition, true); + world.b(blockposition, true); } else { + // CraftBukkit start + if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent( diff --git a/nms-patches/EntityRaider.patch b/nms-patches/EntityRaider.patch new file mode 100644 index 0000000000..fa5280639f --- /dev/null +++ b/nms-patches/EntityRaider.patch @@ -0,0 +1,29 @@ +--- a/net/minecraft/server/EntityRaider.java ++++ b/net/minecraft/server/EntityRaider.java +@@ -396,7 +396,7 @@ + while (iterator.hasNext()) { + EntityRaider entityraider = (EntityRaider) iterator.next(); + +- entityraider.setGoalTarget(this.c.getGoalTarget()); ++ entityraider.setGoalTarget(this.c.getGoalTarget(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.FOLLOW_LEADER, true); // CraftBukkit + } + + } +@@ -413,7 +413,7 @@ + while (iterator.hasNext()) { + EntityRaider entityraider = (EntityRaider) iterator.next(); + +- entityraider.setGoalTarget(entityliving); ++ entityraider.setGoalTarget(this.c.getGoalTarget(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.FOLLOW_LEADER, true); // CraftBukkit + entityraider.q(true); + } + +@@ -487,7 +487,7 @@ + + private final T b; + +- public b(EntityRaider entityraider) { ++ public b(T entityraider) { // CraftBukkit - decompile error + this.b = entityraider; + this.a(EnumSet.of(PathfinderGoal.Type.MOVE)); + } diff --git a/nms-patches/EntitySelector.patch b/nms-patches/EntitySelector.patch index df6578f3a1..19c2c2c476 100644 --- a/nms-patches/EntitySelector.patch +++ b/nms-patches/EntitySelector.patch @@ -1,20 +1,11 @@ --- a/net/minecraft/server/EntitySelector.java +++ b/net/minecraft/server/EntitySelector.java -@@ -63,7 +63,7 @@ +@@ -64,7 +64,7 @@ } private void e(CommandListenerWrapper commandlistenerwrapper) throws CommandSyntaxException { -- if (this.m && !commandlistenerwrapper.hasPermission(2)) { -+ if (this.m && !commandlistenerwrapper.hasPermission(2, "minecraft.command.selector")) { // CraftBukkit +- if (this.checkPermissions && !commandlistenerwrapper.hasPermission(2)) { ++ if (this.checkPermissions && !commandlistenerwrapper.hasPermission(2, "minecraft.command.selector")) { // CraftBukkit throw ArgumentEntity.f.create(); } } -@@ -139,7 +139,7 @@ - AxisAlignedBB axisalignedbb = this.g.a(vec3d); - - predicate.getClass(); -- list.addAll(worldserver.a(oclass, axisalignedbb, predicate::test)); -+ list.addAll(worldserver.a(oclass, axisalignedbb, (java.util.function.Predicate) predicate::test)); // CraftBukkit - decompile error - } else { - oclass = this.l; - predicate.getClass(); diff --git a/nms-patches/EntitySheep.patch b/nms-patches/EntitySheep.patch index 1e2eb064dd..94e8f28de9 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 -@@ -8,6 +8,12 @@ +@@ -9,10 +9,16 @@ import java.util.stream.Collectors; import javax.annotation.Nullable; @@ -12,51 +12,42 @@ + public class EntitySheep extends EntityAnimal { - private static final DataWatcherObject bC = DataWatcher.a(EntitySheep.class, DataWatcherRegistry.a); -@@ -15,8 +21,15 @@ - public boolean canUse(EntityHuman entityhuman) { - return false; - } -+ -+ // CraftBukkit start -+ @Override -+ public InventoryView getBukkitView() { -+ return null; // TODO: O.O -+ } -+ // CraftBukkit end - }, 2, 1); -- private static final Map bE = (Map) SystemUtils.a((Object) Maps.newEnumMap(EnumColor.class), (enummap) -> { -+ private static final Map bE = (Map) SystemUtils.a(Maps.newEnumMap(EnumColor.class), (enummap) -> { // CraftBukkit - decompile error + private static final DataWatcherObject bz = DataWatcher.a(EntitySheep.class, DataWatcherRegistry.a); +- private static final Map bA = (Map) SystemUtils.a((Object) Maps.newEnumMap(EnumColor.class), (enummap) -> { ++ private static final Map bA = (Map) SystemUtils.a(Maps.newEnumMap(EnumColor.class), (enummap) -> { // CraftBukkit - decompile error enummap.put(EnumColor.WHITE, Blocks.WHITE_WOOL); enummap.put(EnumColor.ORANGE, Blocks.ORANGE_WOOL); enummap.put(EnumColor.MAGENTA, Blocks.MAGENTA_WOOL); -@@ -141,11 +154,22 @@ +@@ -141,6 +147,15 @@ + ItemStack itemstack = entityhuman.b(enumhand); if (itemstack.getItem() == Items.SHEARS && !this.isSheared() && !this.isBaby()) { ++ // CraftBukkit start ++ PlayerShearEntityEvent event = new PlayerShearEntityEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), this.getBukkitEntity()); ++ this.world.getServer().getPluginManager().callEvent(event); ++ ++ if (event.isCancelled()) { ++ return false; ++ } ++ // CraftBukkit end ++ + this.shear(); if (!this.world.isClientSide) { -+ // CraftBukkit start -+ PlayerShearEntityEvent event = new PlayerShearEntityEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), this.getBukkitEntity()); -+ this.world.getServer().getPluginManager().callEvent(event); -+ -+ if (event.isCancelled()) { -+ return false; -+ } -+ // CraftBukkit end -+ - this.setSheared(true); - int i = 1 + this.random.nextInt(3); + itemstack.damage(1, entityhuman, (entityhuman1) -> { +@@ -158,7 +173,9 @@ + int i = 1 + this.random.nextInt(3); - for (int j = 0; j < i; ++j) { -+ this.forceDrops = true; // CraftBukkit - EntityItem entityitem = this.a((IMaterial) EntitySheep.bE.get(this.getColor()), 1); -+ this.forceDrops = false; // CraftBukkit + for (int j = 0; j < i; ++j) { ++ this.forceDrops = true; // CraftBukkit + EntityItem entityitem = this.a((IMaterial) EntitySheep.bA.get(this.getColor()), 1); ++ this.forceDrops = false; // CraftBukkit - if (entityitem != null) { - entityitem.motY += (double) (this.random.nextFloat() * 0.05F); -@@ -230,6 +254,12 @@ - } + if (entityitem != null) { + entityitem.setMot(entityitem.getMot().add((double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F), (double) (this.random.nextFloat() * 0.05F), (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F))); +@@ -245,6 +262,12 @@ - public void x() { + @Override + public void blockEaten() { + // CraftBukkit start + SheepRegrowWoolEvent event = new SheepRegrowWoolEvent((org.bukkit.entity.Sheep) this.getBukkitEntity()); + this.world.getServer().getPluginManager().callEvent(event); @@ -66,11 +57,31 @@ this.setSheared(false); if (this.isBaby()) { this.setAge(60); -@@ -250,6 +280,7 @@ +@@ -264,7 +287,7 @@ + EnumColor enumcolor = ((EntitySheep) entityanimal).getColor(); + EnumColor enumcolor1 = ((EntitySheep) entityanimal1).getColor(); + InventoryCrafting inventorycrafting = a(enumcolor, enumcolor1); +- Optional optional = this.world.getCraftingManager().craft(Recipes.CRAFTING, inventorycrafting, this.world).map((recipecrafting) -> { ++ Optional optional = this.world.getCraftingManager().craft(Recipes.CRAFTING, inventorycrafting, this.world).map((recipecrafting) -> { // Eclipse fail + return recipecrafting.a(inventorycrafting); + }).map(ItemStack::getItem); + +@@ -282,10 +305,18 @@ + public boolean canUse(EntityHuman entityhuman) { + return false; + } ++ ++ // CraftBukkit start ++ @Override ++ public InventoryView getBukkitView() { ++ return null; // TODO: O.O ++ } ++ // CraftBukkit end + }, 2, 1); + + inventorycrafting.setItem(0, new ItemStack(ItemDye.a(enumcolor))); + inventorycrafting.setItem(1, new ItemStack(ItemDye.a(enumcolor1))); ++ inventorycrafting.resultInventory = new InventoryCraftResult(); // CraftBukkit - add result slot for event + return inventorycrafting; + } - this.container.setItem(0, new ItemStack(ItemDye.a(enumcolor))); - this.container.setItem(1, new ItemStack(ItemDye.a(enumcolor1))); -+ this.container.resultInventory = new InventoryCraftResult(); // CraftBukkit - add result slot for event - ItemStack itemstack = entityanimal.world.getCraftingManager().craft(this.container, ((EntitySheep) entityanimal).world); - Item item = itemstack.getItem(); - EnumColor enumcolor2; diff --git a/nms-patches/EntityShulker.patch b/nms-patches/EntityShulker.patch index 934eda32e2..651ddae97a 100644 --- a/nms-patches/EntityShulker.patch +++ b/nms-patches/EntityShulker.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/EntityShulker.java +++ b/net/minecraft/server/EntityShulker.java -@@ -5,6 +5,10 @@ +@@ -6,6 +6,10 @@ import java.util.Optional; import java.util.UUID; import javax.annotation.Nullable; @@ -11,11 +11,20 @@ public class EntityShulker extends EntityGolem implements IMonster { -@@ -320,8 +324,17 @@ +@@ -46,7 +50,7 @@ + this.goalSelector.a(4, new EntityShulker.a()); + this.goalSelector.a(7, new EntityShulker.e()); + this.goalSelector.a(8, new PathfinderGoalRandomLookaround(this)); +- this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[0])).a()); ++ this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[0])).a(new Class[0])); // CraftBukkit - decompile error + this.targetSelector.a(2, new EntityShulker.d(this)); + this.targetSelector.a(3, new EntityShulker.c(this)); + } +@@ -308,8 +312,17 @@ EnumDirection enumdirection = aenumdirection[k]; - if (this.world.q(blockposition1.shift(enumdirection))) { -- this.datawatcher.set(EntityShulker.a, enumdirection); + if (this.world.a(blockposition1.shift(enumdirection), (Entity) this)) { +- this.datawatcher.set(EntityShulker.b, enumdirection); - flag = true; + // CraftBukkit start + EntityTeleportEvent teleport = new EntityTeleportEvent(this.getBukkitEntity(), this.getBukkitEntity().getLocation(), new Location(this.world.getWorld(), blockposition1.getX(), blockposition1.getY(), blockposition1.getZ())); @@ -24,18 +33,18 @@ + Location to = teleport.getTo(); + blockposition1 = new BlockPosition(to.getX(), to.getY(), to.getZ()); + -+ this.datawatcher.set(EntityShulker.a, enumdirection); ++ this.datawatcher.set(EntityShulker.b, enumdirection); + flag = true; + } + // CraftBukkit end break; } } -@@ -366,6 +379,7 @@ +@@ -354,6 +367,7 @@ this.locX = (double) blockposition.getX() + 0.5D; this.locY = (double) blockposition.getY(); this.locZ = (double) blockposition.getZ() + 0.5D; -+ if (valid) world.entityJoinedWorld(this, false); // CraftBukkit ++ if (valid) ((WorldServer) world).chunkCheck(this); // CraftBukkit this.lastX = this.locX; this.lastY = this.locY; this.lastZ = this.locZ; diff --git a/nms-patches/EntityShulkerBullet.patch b/nms-patches/EntityShulkerBullet.patch index 732a33793e..7d2d50ba91 100644 --- a/nms-patches/EntityShulkerBullet.patch +++ b/nms-patches/EntityShulkerBullet.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/EntityShulkerBullet.java +++ b/net/minecraft/server/EntityShulkerBullet.java -@@ -41,8 +41,29 @@ +@@ -40,8 +40,29 @@ this.target = entity; - this.c = EnumDirection.UP; + this.dir = EnumDirection.UP; this.a(enumdirection_enumaxis); + projectileSource = (org.bukkit.entity.LivingEntity) entityliving.getBukkitEntity(); // CraftBukkit } @@ -22,28 +22,28 @@ + + public void setTarget(Entity e) { + this.target = e; -+ this.c = EnumDirection.UP; ++ this.dir = EnumDirection.UP; + this.a(EnumDirection.EnumAxis.X); + } + // CraftBukkit end + - public SoundCategory bV() { + @Override + public SoundCategory getSoundCategory() { return SoundCategory.HOSTILE; - } -@@ -286,6 +307,7 @@ +@@ -294,6 +315,7 @@ } protected void a(MovingObjectPosition movingobjectposition) { + org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this, movingobjectposition); // Craftbukkit - Call event - if (movingobjectposition.entity == null) { - ((WorldServer) this.world).a(Particles.u, this.locX, this.locY, this.locZ, 2, 0.2D, 0.2D, 0.2D, 0.0D); - this.a(SoundEffects.ENTITY_SHULKER_BULLET_HIT, 1.0F, 1.0F); -@@ -295,7 +317,7 @@ + if (movingobjectposition.getType() == MovingObjectPosition.EnumMovingObjectType.ENTITY) { + Entity entity = ((MovingObjectPositionEntity) movingobjectposition).getEntity(); + boolean flag = entity.damageEntity(DamageSource.a(this, this.shooter).c(), 4.0F); +@@ -301,7 +323,7 @@ if (flag) { - this.a(this.shooter, movingobjectposition.entity); - if (movingobjectposition.entity instanceof EntityLiving) { -- ((EntityLiving) movingobjectposition.entity).addEffect(new MobEffect(MobEffects.LEVITATION, 200)); -+ ((EntityLiving) movingobjectposition.entity).addEffect(new MobEffect(MobEffects.LEVITATION, 200), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit + this.a(this.shooter, entity); + if (entity instanceof EntityLiving) { +- ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.LEVITATION, 200)); ++ ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.LEVITATION, 200), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit } } - } + } else { diff --git a/nms-patches/EntitySilverfish.patch b/nms-patches/EntitySilverfish.patch index ef17cbf6d1..83e99013dd 100644 --- a/nms-patches/EntitySilverfish.patch +++ b/nms-patches/EntitySilverfish.patch @@ -1,18 +1,27 @@ --- a/net/minecraft/server/EntitySilverfish.java +++ b/net/minecraft/server/EntitySilverfish.java -@@ -153,6 +153,11 @@ +@@ -19,7 +19,7 @@ + this.goalSelector.a(3, this.c); + this.goalSelector.a(4, new PathfinderGoalMeleeAttack(this, 1.0D, false)); + this.goalSelector.a(5, new EntitySilverfish.PathfinderGoalSilverfishHideInBlock(this)); +- this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[0])).a()); ++ this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[0])).a(new Class[0])); // CraftBukkit - decompile error + this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget<>(this, EntityHuman.class, true)); + } + +@@ -167,6 +167,11 @@ IBlockData iblockdata = world.getType(blockposition); - if (BlockMonsterEggs.k(iblockdata)) { + if (BlockMonsterEggs.j(iblockdata)) { + // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.a, blockposition, BlockMonsterEggs.f(iblockdata.getBlock())).isCancelled()) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.a, blockposition, BlockMonsterEggs.e(iblockdata.getBlock())).isCancelled()) { + return; + } + // CraftBukkit end - world.setTypeAndData(blockposition, BlockMonsterEggs.f(iblockdata.getBlock()), 3); + world.setTypeAndData(blockposition, BlockMonsterEggs.e(iblockdata.getBlock()), 3); this.a.doSpawnEffect(); this.a.die(); -@@ -197,6 +202,11 @@ +@@ -213,6 +218,11 @@ Block block = iblockdata.getBlock(); if (block instanceof BlockMonsterEggs) { @@ -22,5 +31,5 @@ + } + // CraftBukkit end if (world.getGameRules().getBoolean("mobGriefing")) { - world.setAir(blockposition1, true); + world.b(blockposition1, true); } else { diff --git a/nms-patches/EntitySkeleton.patch b/nms-patches/EntitySkeleton.patch deleted file mode 100644 index c763f72117..0000000000 --- a/nms-patches/EntitySkeleton.patch +++ /dev/null @@ -1,19 +0,0 @@ ---- a/net/minecraft/server/EntitySkeleton.java -+++ b/net/minecraft/server/EntitySkeleton.java -@@ -30,7 +30,7 @@ - } - - public void die(DamageSource damagesource) { -- super.die(damagesource); -+ // super.die(damagesource); // CraftBukkit - if (damagesource.getEntity() instanceof EntityCreeper) { - EntityCreeper entitycreeper = (EntityCreeper) damagesource.getEntity(); - -@@ -39,6 +39,7 @@ - this.a((IMaterial) Items.SKELETON_SKULL); - } - } -+ super.die(damagesource); // CraftBukkit - moved from above - - } - diff --git a/nms-patches/EntitySkeletonAbstract.patch b/nms-patches/EntitySkeletonAbstract.patch index 90b1c7a4e7..11a5d0c0be 100644 --- a/nms-patches/EntitySkeletonAbstract.patch +++ b/nms-patches/EntitySkeletonAbstract.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/EntitySkeletonAbstract.java +++ b/net/minecraft/server/EntitySkeletonAbstract.java -@@ -151,8 +151,19 @@ +@@ -156,8 +156,19 @@ double d3 = (double) MathHelper.sqrt(d0 * d0 + d2 * d2); entityarrow.shoot(d0, d1 + d3 * 0.20000000298023224D, d2, 1.6F, (float) (14 - this.world.getDifficulty().a() * 4)); @@ -20,4 +20,4 @@ + // this.world.addEntity(entityarrow); // CraftBukkit - moved up } - protected EntityArrow a(float f) { + protected EntityArrow b(ItemStack itemstack, float f) { diff --git a/nms-patches/EntitySkeletonWither.patch b/nms-patches/EntitySkeletonWither.patch index 089956eefa..0080cae398 100644 --- a/nms-patches/EntitySkeletonWither.patch +++ b/nms-patches/EntitySkeletonWither.patch @@ -1,23 +1,6 @@ --- a/net/minecraft/server/EntitySkeletonWither.java +++ b/net/minecraft/server/EntitySkeletonWither.java -@@ -32,7 +32,7 @@ - } - - public void die(DamageSource damagesource) { -- super.die(damagesource); -+ // super.die(damagesource); // CraftBukkit - if (damagesource.getEntity() instanceof EntityCreeper) { - EntityCreeper entitycreeper = (EntityCreeper) damagesource.getEntity(); - -@@ -41,6 +41,7 @@ - this.a((IMaterial) Items.WITHER_SKELETON_SKULL); - } - } -+ super.die(damagesource); // CraftBukkit - moved from above - - } - -@@ -68,7 +69,7 @@ +@@ -74,7 +74,7 @@ return false; } else { if (entity instanceof EntityLiving) { diff --git a/nms-patches/EntitySlice.patch b/nms-patches/EntitySlice.patch deleted file mode 100644 index c2e001f321..0000000000 --- a/nms-patches/EntitySlice.patch +++ /dev/null @@ -1,38 +0,0 @@ ---- a/net/minecraft/server/EntitySlice.java -+++ b/net/minecraft/server/EntitySlice.java -@@ -13,7 +13,7 @@ - - public class EntitySlice extends AbstractSet { - -- private static final Set> a = Sets.newHashSet(); -+ private static final Set> a = Sets.newConcurrentHashSet(); // CraftBukkit - private final Map, List> b = Maps.newHashMap(); - private final Set> c = Sets.newIdentityHashSet(); - private final Class d; -@@ -35,7 +35,7 @@ - - protected void a(Class oclass) { - EntitySlice.a.add(oclass); -- Iterator iterator = this.e.iterator(); -+ Iterator iterator = this.e.iterator(); // CraftBukkit - decompile error - - while (iterator.hasNext()) { - T t0 = iterator.next(); -@@ -78,7 +78,7 @@ - List list = (List) this.b.get(oclass); - - if (list == null) { -- this.b.put(oclass, Lists.newArrayList(new Object[] { t0})); -+ this.b.put(oclass, Lists.newArrayList(t0)); - } else { - list.add(t0); - } -@@ -86,7 +86,7 @@ - } - - public boolean remove(Object object) { -- T t0 = object; -+ T t0 = (T) object; // CraftBukkit - decompile error - boolean flag = false; - Iterator iterator = this.c.iterator(); - diff --git a/nms-patches/EntitySlime.patch b/nms-patches/EntitySlime.patch index 50032f3b03..717f68aadf 100644 --- a/nms-patches/EntitySlime.patch +++ b/nms-patches/EntitySlime.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/EntitySlime.java +++ b/net/minecraft/server/EntitySlime.java -@@ -1,6 +1,13 @@ - package net.minecraft.server; +@@ -2,6 +2,13 @@ + import java.util.EnumSet; import javax.annotation.Nullable; +// CraftBukkit start +import java.util.ArrayList; @@ -14,16 +14,16 @@ public class EntitySlime extends EntityInsentient implements IMonster { -@@ -134,7 +141,7 @@ +@@ -138,7 +145,7 @@ + + @Override + public EntityTypes getEntityType() { +- return super.getEntityType(); ++ return (EntityTypes) super.getEntityType(); // CraftBukkit - decompile error } - public EntityTypes P() { -- return super.P(); -+ return (EntityTypes) super.P(); // CraftBukkit - decompile error - } - - public void die() { -@@ -143,6 +150,19 @@ + @Override +@@ -148,6 +155,19 @@ if (!this.world.isClientSide && i > 1 && this.getHealth() <= 0.0F) { int j = 2 + this.random.nextInt(3); @@ -43,7 +43,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; -@@ -158,8 +178,18 @@ +@@ -163,8 +183,18 @@ entityslime.setSize(i / 2, true); entityslime.setPositionRotation(this.locX + (double) f, this.locY + 0.5D, this.locZ + (double) f1, this.random.nextFloat() * 360.0F, 0.0F); diff --git a/nms-patches/EntitySmallFireball.patch b/nms-patches/EntitySmallFireball.patch index 0a8bf08b13..a745084735 100644 --- a/nms-patches/EntitySmallFireball.patch +++ b/nms-patches/EntitySmallFireball.patch @@ -5,13 +5,13 @@ +import org.bukkit.event.entity.EntityCombustByEntityEvent; // CraftBukkit + - public class EntitySmallFireball extends EntityFireball { + public class EntitySmallFireball extends EntityFireballFireball { - public EntitySmallFireball(World world) { + public EntitySmallFireball(EntityTypes entitytypes, World world) { @@ -8,6 +10,11 @@ public EntitySmallFireball(World world, EntityLiving entityliving, double d0, double d1, double d2) { - super(EntityTypes.SMALL_FIREBALL, entityliving, d0, d1, d2, world, 0.3125F, 0.3125F); + super(EntityTypes.SMALL_FIREBALL, entityliving, d0, d1, d2, world); + // CraftBukkit start + if (this.shooter != null && this.shooter instanceof EntityInsentient) { + isIncendiary = this.world.getGameRules().getBoolean("mobGriefing"); @@ -20,39 +20,34 @@ } public EntitySmallFireball(World world, double d0, double d1, double d2, double d3, double d4, double d5) { -@@ -20,7 +27,16 @@ +@@ -21,18 +28,27 @@ + Entity entity = ((MovingObjectPositionEntity) movingobjectposition).getEntity(); - if (movingobjectposition.entity != null) { - if (!movingobjectposition.entity.isFireProof()) { -- movingobjectposition.entity.setOnFire(5); + if (!entity.isFireProof()) { +- entity.setOnFire(5); + // CraftBukkit start - Entity damage by entity event + combust event + if (isIncendiary) { -+ EntityCombustByEntityEvent event = new EntityCombustByEntityEvent((org.bukkit.entity.Projectile) this.getBukkitEntity(), movingobjectposition.entity.getBukkitEntity(), 5); -+ movingobjectposition.entity.world.getServer().getPluginManager().callEvent(event); ++ EntityCombustByEntityEvent event = new EntityCombustByEntityEvent((org.bukkit.entity.Projectile) this.getBukkitEntity(), entity.getBukkitEntity(), 5); ++ entity.world.getServer().getPluginManager().callEvent(event); + + if (!event.isCancelled()) { -+ movingobjectposition.entity.setOnFire(event.getDuration(), false); ++ entity.setOnFire(event.getDuration(), false); + } + } + // CraftBukkit end - flag = movingobjectposition.entity.damageEntity(DamageSource.fireball(this, this.shooter), 5.0F); + boolean flag = entity.damageEntity(DamageSource.fireball(this, this.shooter), 5.0F); + if (flag) { - this.a(this.shooter, movingobjectposition.entity); -@@ -32,11 +48,15 @@ - flag = this.world.getGameRules().getBoolean("mobGriefing"); - } - -- if (flag) { -+ // CraftBukkit start -+ if (isIncendiary) { - BlockPosition blockposition = movingobjectposition.getBlockPosition().shift(movingobjectposition.direction); - - if (this.world.isEmpty(blockposition)) { -- this.world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData()); -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition, this).isCancelled()) { -+ this.world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData()); -+ } -+ // CraftBukkit end + this.a(this.shooter, entity); } } +- } else if (this.shooter == null || !(this.shooter instanceof EntityInsentient) || this.world.getGameRules().getBoolean("mobGriefing")) { ++ } else if (isIncendiary) { // CraftBukkit + MovingObjectPositionBlock movingobjectpositionblock = (MovingObjectPositionBlock) movingobjectposition; + BlockPosition blockposition = movingobjectpositionblock.getBlockPosition().shift(movingobjectpositionblock.getDirection()); + +- if (this.world.isEmpty(blockposition)) { ++ if (this.world.isEmpty(blockposition) && !org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition, this).isCancelled()) { // CraftBukkit + this.world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData()); + } } diff --git a/nms-patches/EntitySnowman.patch b/nms-patches/EntitySnowman.patch index abee1fd42d..5920a846ff 100644 --- a/nms-patches/EntitySnowman.patch +++ b/nms-patches/EntitySnowman.patch @@ -11,7 +11,7 @@ public class EntitySnowman extends EntityGolem implements IRangedEntity { -@@ -55,7 +59,7 @@ +@@ -62,7 +66,7 @@ } if (this.world.getBiome(new BlockPosition(i, 0, k)).getAdjustedTemperature(new BlockPosition(i, j, k)) > 1.0F) { @@ -20,7 +20,7 @@ } if (!this.world.getGameRules().getBoolean("mobGriefing")) { -@@ -71,7 +75,7 @@ +@@ -78,7 +82,7 @@ BlockPosition blockposition = new BlockPosition(i, j, k); if (this.world.getType(blockposition).isAir() && this.world.getBiome(blockposition).getAdjustedTemperature(blockposition) < 0.8F && iblockdata.canPlace(this.world, blockposition)) { @@ -29,7 +29,7 @@ } } } -@@ -104,6 +108,15 @@ +@@ -109,6 +113,15 @@ ItemStack itemstack = entityhuman.b(enumhand); if (itemstack.getItem() == Items.SHEARS && this.hasPumpkin() && !this.world.isClientSide) { @@ -43,5 +43,5 @@ + // CraftBukkit end + this.setHasPumpkin(false); - itemstack.damage(1, entityhuman); - } + itemstack.damage(1, entityhuman, (entityhuman1) -> { + entityhuman1.d(enumhand); diff --git a/nms-patches/EntitySpectralArrow.patch b/nms-patches/EntitySpectralArrow.patch index be4dcc85b1..1e7688aff9 100644 --- a/nms-patches/EntitySpectralArrow.patch +++ b/nms-patches/EntitySpectralArrow.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/EntitySpectralArrow.java +++ b/net/minecraft/server/EntitySpectralArrow.java -@@ -32,7 +32,7 @@ +@@ -35,7 +35,7 @@ super.a(entityliving); MobEffect mobeffect = new MobEffect(MobEffects.GLOWING, this.duration, 0); @@ -8,4 +8,4 @@ + entityliving.addEffect(mobeffect, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ARROW); // CraftBukkit } - public void a(NBTTagCompound nbttagcompound) { + @Override diff --git a/nms-patches/EntitySpider.patch b/nms-patches/EntitySpider.patch index 1820e8dfd8..6c1420aa5b 100644 --- a/nms-patches/EntitySpider.patch +++ b/nms-patches/EntitySpider.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/server/EntitySpider.java +++ b/net/minecraft/server/EntitySpider.java -@@ -115,7 +115,7 @@ +@@ -125,7 +125,7 @@ entityskeleton.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, 0.0F); - entityskeleton.prepare(difficultydamagescaler, (GroupDataEntity) null, (NBTTagCompound) null); -- this.world.addEntity(entityskeleton); -+ this.world.addEntity(entityskeleton, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.JOCKEY); // CraftBukkit - add SpawnReason + entityskeleton.prepare(generatoraccess, difficultydamagescaler, enummobspawn, (GroupDataEntity) null, (NBTTagCompound) null); +- generatoraccess.addEntity(entityskeleton); ++ generatoraccess.addEntity(entityskeleton, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.JOCKEY); // CraftBukkit - add SpawnReason entityskeleton.startRiding(this); } -@@ -130,7 +130,7 @@ +@@ -140,7 +140,7 @@ MobEffectList mobeffectlist = ((EntitySpider.GroupDataSpider) object).a; if (mobeffectlist != null) { diff --git a/nms-patches/EntityTNTPrimed.patch b/nms-patches/EntityTNTPrimed.patch index 0b84575023..2ed847ee3d 100644 --- a/nms-patches/EntityTNTPrimed.patch +++ b/nms-patches/EntityTNTPrimed.patch @@ -11,16 +11,16 @@ @@ -8,6 +9,8 @@ @Nullable private EntityLiving source; - private int c; + private int fuseTicks; + public float yield = 4; // CraftBukkit - add field + public boolean isIncendiary = false; // CraftBukkit - add field - public EntityTNTPrimed(World world) { - super(EntityTypes.TNT, world); -@@ -64,10 +67,13 @@ + public EntityTNTPrimed(EntityTypes entitytypes, World world) { + super(entitytypes, world); +@@ -60,10 +63,13 @@ - --this.c; - if (this.c <= 0) { + --this.fuseTicks; + if (this.fuseTicks <= 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(); @@ -30,9 +30,9 @@ + this.die(); + // CraftBukkit end } else { - this.at(); - this.world.addParticle(Particles.M, this.locX, this.locY + 0.5D, this.locZ, 0.0D, 0.0D, 0.0D); -@@ -76,9 +82,16 @@ + this.ax(); + this.world.addParticle(Particles.SMOKE, this.locX, this.locY + 0.5D, this.locZ, 0.0D, 0.0D, 0.0D); +@@ -72,9 +78,16 @@ } private void explode() { @@ -40,14 +40,14 @@ + // CraftBukkit start + // float f = 4.0F; -- this.world.explode(this, this.locX, this.locY + (double) (this.length / 16.0F), this.locZ, 4.0F, true); +- this.world.explode(this, this.locX, this.locY + (double) (this.getHeight() / 16.0F), this.locZ, 4.0F, Explosion.Effect.BREAK); + ExplosionPrimeEvent event = new ExplosionPrimeEvent((org.bukkit.entity.Explosive) this.getBukkitEntity()); + this.world.getServer().getPluginManager().callEvent(event); + + if (!event.isCancelled()) { -+ this.world.createExplosion(this, this.locX, this.locY + (double) (this.length / 16.0F), this.locZ, event.getRadius(), event.getFire(), true); ++ this.world.createExplosion(this, this.locX, this.locY + (double) (this.getHeight() / 16.0F), this.locZ, event.getRadius(), event.getFire(), Explosion.Effect.BREAK); + } + // CraftBukkit end } - protected void b(NBTTagCompound nbttagcompound) { + @Override diff --git a/nms-patches/EntityThrownExpBottle.patch b/nms-patches/EntityThrownExpBottle.patch index 6f2cee21e6..761ec125ac 100644 --- a/nms-patches/EntityThrownExpBottle.patch +++ b/nms-patches/EntityThrownExpBottle.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/server/EntityThrownExpBottle.java +++ b/net/minecraft/server/EntityThrownExpBottle.java -@@ -20,9 +20,18 @@ - +@@ -27,9 +27,18 @@ + @Override protected void a(MovingObjectPosition movingobjectposition) { if (!this.world.isClientSide) { - this.world.triggerEffect(2002, new BlockPosition(this), PotionUtil.a(Potions.b)); diff --git a/nms-patches/EntityThrownTrident.patch b/nms-patches/EntityThrownTrident.patch index 8e2d44150b..de5f702466 100644 --- a/nms-patches/EntityThrownTrident.patch +++ b/nms-patches/EntityThrownTrident.patch @@ -4,7 +4,7 @@ EntityLightning entitylightning = new EntityLightning(this.world, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, false); entitylightning.d(entity1 instanceof EntityPlayer ? (EntityPlayer) entity1 : null); -- this.world.strikeLightning(entitylightning); +- ((WorldServer) this.world).strikeLightning(entitylightning); + ((WorldServer) this.world).strikeLightning(entitylightning, org.bukkit.event.weather.LightningStrikeEvent.Cause.TRIDENT); // CraftBukkit soundeffect = SoundEffects.ITEM_TRIDENT_THUNDER; f1 = 5.0F; diff --git a/nms-patches/EntityTippedArrow.patch b/nms-patches/EntityTippedArrow.patch index 7b60939903..95c24b1325 100644 --- a/nms-patches/EntityTippedArrow.patch +++ b/nms-patches/EntityTippedArrow.patch @@ -1,12 +1,12 @@ --- a/net/minecraft/server/EntityTippedArrow.java +++ b/net/minecraft/server/EntityTippedArrow.java -@@ -115,6 +115,25 @@ +@@ -117,6 +117,25 @@ } } + // CraftBukkit start accessor methods + public void refreshEffects() { -+ this.getDataWatcher().set(EntityTippedArrow.g, Integer.valueOf(PotionUtil.a((Collection) PotionUtil.a(this.potionRegistry, (Collection) this.effects)))); ++ this.getDataWatcher().set(EntityTippedArrow.COLOR, PotionUtil.a((Collection) PotionUtil.a(this.potionRegistry, (Collection) this.effects))); + } + + public String getType() { @@ -15,7 +15,7 @@ + + public void setType(String string) { + this.potionRegistry = IRegistry.POTION.get(new MinecraftKey(string)); -+ this.datawatcher.set(EntityTippedArrow.g, Integer.valueOf(PotionUtil.a((Collection) PotionUtil.a(this.potionRegistry, (Collection) this.effects)))); ++ this.getDataWatcher().set(EntityTippedArrow.COLOR, PotionUtil.a((Collection) PotionUtil.a(this.potionRegistry, (Collection) this.effects))); + } + + public boolean isTipped() { @@ -24,9 +24,9 @@ + // CraftBukkit end + public int getColor() { - return (Integer) this.datawatcher.get(EntityTippedArrow.g); + return (Integer) this.datawatcher.get(EntityTippedArrow.COLOR); } -@@ -179,7 +198,7 @@ +@@ -184,7 +203,7 @@ while (iterator.hasNext()) { mobeffect = (MobEffect) iterator.next(); @@ -35,7 +35,7 @@ } if (!this.effects.isEmpty()) { -@@ -187,7 +206,7 @@ +@@ -192,7 +211,7 @@ while (iterator.hasNext()) { mobeffect = (MobEffect) iterator.next(); diff --git a/nms-patches/EntityTracker.patch b/nms-patches/EntityTracker.patch deleted file mode 100644 index 795c5f2281..0000000000 --- a/nms-patches/EntityTracker.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/server/EntityTracker.java -+++ b/net/minecraft/server/EntityTracker.java -@@ -91,7 +91,7 @@ - } else if (entity instanceof EntityExperienceOrb) { - this.addEntity(entity, 160, 20, true); - } else if (entity instanceof EntityAreaEffectCloud) { -- this.addEntity(entity, 160, Integer.MAX_VALUE, true); -+ this.addEntity(entity, 160, 10, true); // CraftBukkit - } else if (entity instanceof EntityEnderCrystal) { - this.addEntity(entity, 256, Integer.MAX_VALUE, false); - } else if (entity instanceof EntityEvokerFangs) { diff --git a/nms-patches/EntityTrackerEntry.patch b/nms-patches/EntityTrackerEntry.patch index b81ebfac27..11aa3109be 100644 --- a/nms-patches/EntityTrackerEntry.patch +++ b/nms-patches/EntityTrackerEntry.patch @@ -1,90 +1,90 @@ --- a/net/minecraft/server/EntityTrackerEntry.java +++ b/net/minecraft/server/EntityTrackerEntry.java -@@ -9,6 +9,11 @@ +@@ -8,6 +8,11 @@ + import java.util.function.Consumer; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; - ++ +// CraftBukkit start +import org.bukkit.entity.Player; +import org.bukkit.event.player.PlayerVelocityEvent; +// CraftBukkit end -+ + public class EntityTrackerEntry { - private static final Logger c = LogManager.getLogger(); -@@ -76,16 +81,17 @@ +@@ -29,8 +34,12 @@ + private List p; + private boolean q; + private boolean r; ++ // CraftBukkit start ++ private final Set trackedPlayers; - if (!list1.equals(this.w)) { - this.w = list1; -- this.broadcast(new PacketPlayOutMount(this.tracker)); +- public EntityTrackerEntry(WorldServer worldserver, Entity entity, int i, boolean flag, Consumer> consumer) { ++ public EntityTrackerEntry(WorldServer worldserver, Entity entity, int i, boolean flag, Consumer> consumer, Set trackedPlayers) { ++ this.trackedPlayers = trackedPlayers; ++ // CraftBukkit end + this.m = Vec3D.a; + this.p = Collections.emptyList(); + this.b = worldserver; +@@ -50,16 +59,17 @@ + + if (!list.equals(this.p)) { + this.p = list; +- this.f.accept(new PacketPlayOutMount(this.tracker)); + this.broadcastIncludingSelf(new PacketPlayOutMount(this.tracker)); // CraftBukkit } -- if (this.tracker instanceof EntityItemFrame && this.a % 10 == 0) { +- if (this.tracker instanceof EntityItemFrame && this.n % 10 == 0) { + // PAIL : rename -+ if (this.tracker instanceof EntityItemFrame /*&& this.a % 10 == 0*/) { // CraftBukkit - Moved below, should always enter this block ++ if (this.tracker instanceof EntityItemFrame /*&& this.n % 10 == 0*/) { // CraftBukkit - Moved below, should always enter this block EntityItemFrame entityitemframe = (EntityItemFrame) this.tracker; ItemStack itemstack = entityitemframe.getItem(); - if (itemstack.getItem() instanceof ItemWorldMap) { -+ if (this.a % 10 == 0 && itemstack.getItem() instanceof ItemWorldMap) { // CraftBukkit - Moved this.a % 10 logic here so item frames do not enter the other blocks - WorldMap worldmap = ItemWorldMap.getSavedMap(itemstack, this.tracker.world); -- Iterator iterator = list.iterator(); ++ if (this.n % 10 == 0 && itemstack.getItem() instanceof ItemWorldMap) { // CraftBukkit - Moved this.n % 10 logic here so item frames do not enter the other blocks + WorldMap worldmap = ItemWorldMap.getSavedMap(itemstack, this.b); +- Iterator iterator = this.b.getPlayers().iterator(); + Iterator iterator = this.trackedPlayers.iterator(); // CraftBukkit while (iterator.hasNext()) { - EntityHuman entityhuman = (EntityHuman) iterator.next(); -@@ -136,6 +142,19 @@ - boolean flag1 = l1 * l1 + i2 * i2 + j2 * j2 >= 128L || this.a % 60 == 0; - boolean flag2 = Math.abs(j1 - this.yRot) >= 1 || Math.abs(k1 - this.xRot) >= 1; + EntityPlayer entityplayer = (EntityPlayer) iterator.next(); +@@ -104,6 +114,17 @@ + boolean flag2 = flag1 || this.n % 60 == 0; + boolean flag3 = Math.abs(i - this.yRot) >= 1 || Math.abs(j - this.xRot) >= 1; + // CraftBukkit start - Code moved from below -+ if (flag1) { -+ this.xLoc = k; -+ this.yLoc = l; -+ this.zLoc = i1; ++ if (flag2) { ++ this.d(); + } + -+ if (flag2) { -+ this.yRot = j1; -+ this.xRot = k1; ++ if (flag3) { ++ this.yRot = i; ++ this.xRot = j; + } + // CraftBukkit end + - if (this.a > 0 || this.tracker instanceof EntityArrow) { - if (l1 >= -32768L && l1 < 32768L && i2 >= -32768L && i2 < 32768L && j2 >= -32768L && j2 < 32768L && this.v <= 400 && !this.x && this.y == this.tracker.onGround) { - if ((!flag1 || !flag2) && !(this.tracker instanceof EntityArrow)) { -@@ -150,6 +169,11 @@ - } else { - this.y = this.tracker.onGround; - this.v = 0; -+ // CraftBukkit start - Refresh list of who can see a player before sending teleport packet -+ if (this.tracker instanceof EntityPlayer) { -+ this.scanPlayers(new java.util.ArrayList(this.trackedPlayers)); -+ } -+ // CraftBukkit end - this.c(); - packet1 = new PacketPlayOutEntityTeleport(this.tracker); - } -@@ -181,6 +205,7 @@ + if (this.n > 0 || this.tracker instanceof EntityArrow) { + long k = PacketPlayOutEntity.a(vec3d.x); + long l = PacketPlayOutEntity.a(vec3d.y); +@@ -142,6 +163,7 @@ } - this.d(); + this.c(); + /* CraftBukkit start - Code moved up - if (flag1) { - this.xLoc = k; - this.yLoc = l; -@@ -191,6 +216,7 @@ - this.yRot = j1; - this.xRot = k1; + if (flag2) { + this.d(); + } +@@ -150,6 +172,7 @@ + this.yRot = i; + this.xRot = j; } + // CraftBukkit end */ - this.x = false; + this.q = false; } -@@ -206,7 +232,27 @@ +@@ -165,7 +188,27 @@ - ++this.a; + ++this.n; if (this.tracker.velocityChanged) { - this.broadcastIncludingSelf(new PacketPlayOutEntityVelocity(this.tracker)); + // CraftBukkit start - Create PlayerVelocity event @@ -111,7 +111,53 @@ this.tracker.velocityChanged = false; } -@@ -224,6 +270,11 @@ +@@ -180,14 +223,17 @@ + PlayerConnection playerconnection = entityplayer.playerConnection; + + entityplayer.playerConnection.getClass(); +- this.a(playerconnection::sendPacket); ++ this.a(playerconnection::sendPacket, entityplayer); // CraftBukkit - add player + this.tracker.b(entityplayer); + entityplayer.d(this.tracker); + } + +- public void a(Consumer> consumer) { ++ public void a(Consumer> consumer, EntityPlayer entityplayer) { // CraftBukkit - add player + if (this.tracker.dead) { +- EntityTrackerEntry.a.warn("Fetching addPacket for removed entity"); ++ // CraftBukkit start - Remove useless error spam, just return ++ // EntityTrackerEntry.a.warn("Fetching addPacket for removed entity") ++ return; ++ // CraftBukkit end + } + + Packet packet = this.tracker.N(); +@@ -204,6 +250,12 @@ + AttributeMapServer attributemapserver = (AttributeMapServer) ((EntityLiving) this.tracker).getAttributeMap(); + Collection collection = attributemapserver.c(); + ++ // CraftBukkit start - If sending own attributes send scaled health instead of current maximum health ++ if (this.tracker.getId() == entityplayer.getId()) { ++ ((EntityPlayer) this.tracker).getBukkitEntity().injectScaledMaxHealth(collection, false); ++ } ++ // CraftBukkit end ++ + if (!collection.isEmpty()) { + consumer.accept(new PacketPlayOutUpdateAttributes(this.tracker.getId(), collection)); + } +@@ -232,6 +284,11 @@ + } + } + ++ // CraftBukkit start - Fix for nonsensical head yaw ++ this.headYaw = MathHelper.d(this.tracker.getHeadRotation() * 256.0F / 360.0F); ++ consumer.accept(new PacketPlayOutEntityHeadRotation(this.tracker, (byte) headYaw)); ++ // CraftBukkit end ++ + if (this.tracker instanceof EntityLiving) { + EntityLiving entityliving = (EntityLiving) this.tracker; + Iterator iterator = entityliving.getEffects().iterator(); +@@ -265,6 +322,11 @@ Set set = attributemapserver.getAttributes(); if (!set.isEmpty()) { @@ -123,57 +169,3 @@ this.broadcastIncludingSelf(new PacketPlayOutUpdateAttributes(this.tracker.getId(), set)); } -@@ -276,6 +327,16 @@ - if (entityplayer != this.tracker) { - if (this.c(entityplayer)) { - if (!this.trackedPlayers.contains(entityplayer) && (this.e(entityplayer) || this.tracker.attachedToPlayer)) { -+ // CraftBukkit start - respect vanish API -+ if (this.tracker instanceof EntityPlayer) { -+ Player player = ((EntityPlayer) this.tracker).getBukkitEntity(); -+ if (!entityplayer.getBukkitEntity().canSee(player)) { -+ return; -+ } -+ } -+ -+ entityplayer.removeQueue.remove(Integer.valueOf(this.tracker.getId())); -+ // CraftBukkit end - this.trackedPlayers.add(entityplayer); - Packet packet = this.e(); - -@@ -290,6 +351,12 @@ - AttributeMapServer attributemapserver = (AttributeMapServer) ((EntityLiving) this.tracker).getAttributeMap(); - Collection collection = attributemapserver.c(); - -+ // CraftBukkit start - If sending own attributes send scaled health instead of current maximum health -+ if (this.tracker.getId() == entityplayer.getId()) { -+ ((EntityPlayer) this.tracker).getBukkitEntity().injectScaledMaxHealth(collection, false); -+ } -+ // CraftBukkit end -+ - if (!collection.isEmpty()) { - entityplayer.playerConnection.sendPacket(new PacketPlayOutUpdateAttributes(this.tracker.getId(), collection)); - } -@@ -328,6 +395,11 @@ - } - } - -+ // CraftBukkit start - Fix for nonsensical head yaw -+ 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(); -@@ -380,7 +452,10 @@ - - private Packet e() { - if (this.tracker.dead) { -- EntityTrackerEntry.c.warn("Fetching addPacket for removed entity"); -+ // CraftBukkit start - Remove useless error spam, just return -+ // EntityTrackerEntry.d.warn("Fetching addPacket for removed entity"); -+ return null; -+ // CraftBukkit end - } - - if (this.tracker instanceof EntityPlayer) { diff --git a/nms-patches/EntityTurtle.patch b/nms-patches/EntityTurtle.patch index 3adf710dba..ecdc21bd89 100644 --- a/nms-patches/EntityTurtle.patch +++ b/nms-patches/EntityTurtle.patch @@ -1,35 +1,44 @@ --- a/net/minecraft/server/EntityTurtle.java +++ b/net/minecraft/server/EntityTurtle.java -@@ -232,7 +232,9 @@ +@@ -258,7 +258,9 @@ protected void l() { super.l(); - if (this.world.getGameRules().getBoolean("doMobLoot")) { + if (!this.isBaby() && this.world.getGameRules().getBoolean("doMobLoot")) { + this.forceDrops = true; // CraftBukkit this.a((IMaterial) Items.SCUTE, 1); + this.forceDrops = false; // CraftBukkit } } -@@ -263,7 +265,9 @@ - } +@@ -285,7 +287,9 @@ + @Override public void onLightningStrike(EntityLightning entitylightning) { + org.bukkit.craftbukkit.event.CraftEventFactory.entityDamage = entitylightning; // CraftBukkit this.damageEntity(DamageSource.LIGHTNING, Float.MAX_VALUE); + org.bukkit.craftbukkit.event.CraftEventFactory.entityDamage = null; // CraftBukkit } - public void die(DamageSource damagesource) { -@@ -423,8 +427,12 @@ - } else if (this.f.bK > 200) { - World world = this.f.world; + static class g extends NavigationGuardian { +@@ -445,8 +449,12 @@ + } else if (this.g.bH > 200) { + World world = this.g.world; + // CraftBukkit start -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.f, this.d.up(), Blocks.TURTLE_EGG.getBlockData().set(BlockTurtleEgg.b, Integer.valueOf(this.f.random.nextInt(4) + 1))).isCancelled()) { ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.g, this.e.up(), (IBlockData) Blocks.TURTLE_EGG.getBlockData().set(BlockTurtleEgg.b, this.g.random.nextInt(4) + 1)).isCancelled()) { world.a((EntityHuman) null, blockposition, SoundEffects.ENTITY_TURTLE_LAY_EGG, SoundCategory.BLOCKS, 0.3F, 0.9F + world.random.nextFloat() * 0.2F); - world.setTypeAndData(this.d.up(), (IBlockData) Blocks.TURTLE_EGG.getBlockData().set(BlockTurtleEgg.b, this.f.random.nextInt(4) + 1), 3); + world.setTypeAndData(this.e.up(), (IBlockData) Blocks.TURTLE_EGG.getBlockData().set(BlockTurtleEgg.b, this.g.random.nextInt(4) + 1), 3); + } + // CraftBukkit end - this.f.s(false); - this.f.t(false); - this.f.d(600); + this.g.r(false); + this.g.s(false); + this.g.setLoveTicks(600); +@@ -532,7 +540,7 @@ + --this.e; + return false; + } else { +- this.d = this.b.world.a(EntityTurtle.i.a, (EntityLiving) this.b); ++ this.d = this.b.world.a(this.a, (EntityLiving) this.b); // CraftBukkit - decompile error + return this.d == null ? false : this.a(this.d.getItemInMainHand()) || this.a(this.d.getItemInOffHand()); + } + } diff --git a/nms-patches/EntityTypes.patch b/nms-patches/EntityTypes.patch index bc3e3d1b93..f1e63be46b 100644 --- a/nms-patches/EntityTypes.patch +++ b/nms-patches/EntityTypes.patch @@ -1,25 +1,25 @@ --- a/net/minecraft/server/EntityTypes.java +++ b/net/minecraft/server/EntityTypes.java -@@ -121,7 +121,7 @@ - public static EntityTypes a(String s, EntityTypes.a entitytypes_a) { - EntityTypes entitytypes = entitytypes_a.a(s); +@@ -131,7 +131,7 @@ + private final Type bh; + private final EntitySize bi; -- IRegistry.ENTITY_TYPE.a(new MinecraftKey(s), (Object) entitytypes); -+ IRegistry.ENTITY_TYPE.a(new MinecraftKey(s), entitytypes); // CraftBukkit - decompile error - return entitytypes; +- private static EntityTypes a(String s, EntityTypes.a entitytypes_a) { ++ private static EntityTypes a(String s, EntityTypes.a entitytypes_a) { // CraftBukkit - decompile error + return (EntityTypes) IRegistry.a((IRegistry) IRegistry.ENTITY_TYPE, s, (Object) entitytypes_a.a(s)); } -@@ -150,10 +150,16 @@ +@@ -160,10 +160,16 @@ @Nullable - public T a(World world, @Nullable NBTTagCompound nbttagcompound, @Nullable IChatBaseComponent ichatbasecomponent, @Nullable EntityHuman entityhuman, BlockPosition blockposition, boolean flag, boolean flag1) { + public T spawnCreature(World world, @Nullable NBTTagCompound nbttagcompound, @Nullable IChatBaseComponent ichatbasecomponent, @Nullable EntityHuman entityhuman, BlockPosition blockposition, EnumMobSpawn enummobspawn, boolean flag, boolean flag1) { + // CraftBukkit start -+ return spawnCreature(world, nbttagcompound, ichatbasecomponent, entityhuman, blockposition, flag, flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG); ++ return this.spawnCreature(world, nbttagcompound, ichatbasecomponent, entityhuman, blockposition, enummobspawn, flag, flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG); + } + + @Nullable -+ public T spawnCreature(World world, @Nullable NBTTagCompound nbttagcompound, @Nullable IChatBaseComponent ichatbasecomponent, @Nullable EntityHuman entityhuman, BlockPosition blockposition, boolean flag, boolean flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) { - T t0 = this.b(world, nbttagcompound, ichatbasecomponent, entityhuman, blockposition, flag, flag1); ++ public T spawnCreature(World world, @Nullable NBTTagCompound nbttagcompound, @Nullable IChatBaseComponent ichatbasecomponent, @Nullable EntityHuman entityhuman, BlockPosition blockposition, EnumMobSpawn enummobspawn, boolean flag, boolean flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) { + T t0 = this.b(world, nbttagcompound, ichatbasecomponent, entityhuman, blockposition, enummobspawn, flag, flag1); - world.addEntity(t0); - return t0; @@ -28,12 +28,31 @@ } @Nullable -@@ -250,7 +256,7 @@ +@@ -325,7 +331,7 @@ + } - @Nullable - public T a(World world) { -- return (Entity) this.aT.apply(world); -+ return this.aT.apply(world); // CraftBukkit - decompile error + return entity; +- }).orElse((Object) null); ++ }).orElse(null); // CraftBukkit - decompile error } - @Nullable + private static Optional b(NBTTagCompound nbttagcompound, World world) { +@@ -342,7 +348,8 @@ + } + + public int getUpdateInterval() { +- return this != EntityTypes.PLAYER && this != EntityTypes.EVOKER_FANGS ? (this == EntityTypes.EYE_OF_ENDER ? 4 : (this == EntityTypes.FISHING_BOBBER ? 5 : (this != EntityTypes.SMALL_FIREBALL && this != EntityTypes.DRAGON_FIREBALL && this != EntityTypes.FIREBALL && this != EntityTypes.WITHER_SKULL && this != EntityTypes.SNOWBALL && this != EntityTypes.LLAMA_SPIT && this != EntityTypes.ENDER_PEARL && this != EntityTypes.EGG && this != EntityTypes.POTION && this != EntityTypes.EXPERIENCE_BOTTLE && this != EntityTypes.FIREWORK_ROCKET && this != EntityTypes.TNT ? (this != EntityTypes.ARROW && this != EntityTypes.SPECTRAL_ARROW && this != EntityTypes.TRIDENT && this != EntityTypes.ITEM && this != EntityTypes.FALLING_BLOCK && this != EntityTypes.EXPERIENCE_ORB ? (this != EntityTypes.ITEM_FRAME && this != EntityTypes.LEASH_KNOT && this != EntityTypes.PAINTING && this != EntityTypes.AREA_EFFECT_CLOUD && this != EntityTypes.END_CRYSTAL ? 3 : Integer.MAX_VALUE) : 20) : 10))) : 2; ++ // CraftBukkit - SPIGOT-3729: track area effect clouds ++ return this != EntityTypes.PLAYER && this != EntityTypes.EVOKER_FANGS ? (this == EntityTypes.EYE_OF_ENDER ? 4 : (this == EntityTypes.FISHING_BOBBER ? 5 : (this != EntityTypes.SMALL_FIREBALL && this != EntityTypes.DRAGON_FIREBALL && this != EntityTypes.FIREBALL && this != EntityTypes.WITHER_SKULL && this != EntityTypes.SNOWBALL && this != EntityTypes.LLAMA_SPIT && this != EntityTypes.ENDER_PEARL && this != EntityTypes.EGG && this != EntityTypes.POTION && this != EntityTypes.EXPERIENCE_BOTTLE && this != EntityTypes.FIREWORK_ROCKET && this != EntityTypes.TNT ? (this != EntityTypes.ARROW && this != EntityTypes.SPECTRAL_ARROW && this != EntityTypes.TRIDENT && this != EntityTypes.ITEM && this != EntityTypes.FALLING_BLOCK && this != EntityTypes.EXPERIENCE_ORB ? (this != EntityTypes.ITEM_FRAME && this != EntityTypes.LEASH_KNOT && this != EntityTypes.PAINTING && this != EntityTypes.END_CRYSTAL ? 3 : Integer.MAX_VALUE) : 20) : 10))) : 2; + } + + public boolean isDeltaTracking() { +@@ -372,7 +379,7 @@ + this.b = enumcreaturetype; + } + +- public static EntityTypes.a a(EntityTypes.b entitytypes_b, EnumCreatureType enumcreaturetype) { ++ public static EntityTypes.a a(EntityTypes.b entitytypes_b, EnumCreatureType enumcreaturetype) { // CraftBukkit - decompile error + return new EntityTypes.a<>(entitytypes_b, enumcreaturetype); + } + diff --git a/nms-patches/EntityVex.patch b/nms-patches/EntityVex.patch index 08fc317e61..861e7329bb 100644 --- a/nms-patches/EntityVex.patch +++ b/nms-patches/EntityVex.patch @@ -1,19 +1,28 @@ --- a/net/minecraft/server/EntityVex.java +++ b/net/minecraft/server/EntityVex.java -@@ -1,6 +1,7 @@ - package net.minecraft.server; +@@ -2,6 +2,7 @@ + import java.util.EnumSet; import javax.annotation.Nullable; +import org.bukkit.event.entity.EntityTargetEvent; public class EntityVex extends EntityMonster { -@@ -178,7 +179,7 @@ - } +@@ -45,7 +46,7 @@ + this.goalSelector.a(8, new EntityVex.d()); + this.goalSelector.a(9, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 3.0F, 1.0F)); + this.goalSelector.a(10, new PathfinderGoalLookAtPlayer(this, EntityInsentient.class, 8.0F)); +- this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[] { EntityRaider.class})).a()); ++ this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[] { EntityRaider.class})).a(new Class[0])); // CraftBukkit - decompile error + this.targetSelector.a(2, new EntityVex.b(this)); + this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget<>(this, EntityHuman.class, true)); + } +@@ -189,7 +190,7 @@ + @Override public void c() { -- EntityVex.this.setGoalTarget(EntityVex.this.b.getGoalTarget()); -+ EntityVex.this.setGoalTarget(EntityVex.this.b.getGoalTarget(), EntityTargetEvent.TargetReason.OWNER_ATTACKED_TARGET, true); // CraftBukkit +- EntityVex.this.setGoalTarget(EntityVex.this.c.getGoalTarget()); ++ EntityVex.this.setGoalTarget(EntityVex.this.c.getGoalTarget(), EntityTargetEvent.TargetReason.OWNER_ATTACKED_TARGET, true); // CraftBukkit super.c(); } } diff --git a/nms-patches/EntityVillager.patch b/nms-patches/EntityVillager.patch index ef6f4d5dc3..9d8ce62a92 100644 --- a/nms-patches/EntityVillager.patch +++ b/nms-patches/EntityVillager.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/server/EntityVillager.java +++ b/net/minecraft/server/EntityVillager.java -@@ -6,6 +6,16 @@ +@@ -17,6 +17,16 @@ + import java.util.function.BiPredicate; + import java.util.stream.Collectors; import javax.annotation.Nullable; - import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; +// CraftBukkit start +import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.entity.CraftVillager; @@ -15,35 +15,28 @@ +import org.bukkit.event.entity.VillagerReplenishTradeEvent; +// CraftBukkit end - public class EntityVillager extends EntityAgeable implements NPC, IMerchant { + public class EntityVillager extends EntityVillagerAbstract implements ReputationHandler, VillagerDataHolder { -@@ -37,7 +47,7 @@ +@@ -62,7 +72,7 @@ - public EntityVillager(World world, int i) { - super(EntityTypes.VILLAGER, world); -- this.inventory = new InventorySubcontainer(new ChatComponentText("Items"), 8); -+ this.inventory = new InventorySubcontainer(new ChatComponentText("Items"), 8, (CraftVillager) this.getBukkitEntity()); // CraftBukkit add argument - this.setProfession(i); - this.setSize(0.6F, 1.95F); - ((Navigation) this.getNavigation()).a(true); -@@ -119,7 +129,14 @@ - MerchantRecipe merchantrecipe = (MerchantRecipe) iterator.next(); + @Override + public BehaviorController getBehaviorController() { +- return super.getBehaviorController(); ++ return (BehaviorController) super.getBehaviorController(); // CraftBukkit - decompile error + } - 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 - } - } - -@@ -131,7 +148,7 @@ - } + @Override +@@ -126,7 +136,7 @@ + @Override + protected void mobTick() { + this.world.getMethodProfiler().enter("brain"); +- this.getBehaviorController().a((WorldServer) this.world, (EntityLiving) this); ++ this.getBehaviorController().a((WorldServer) this.world, this); // CraftBukkit - decompile error + this.world.getMethodProfiler().exit(); + if (!this.dX() && this.bE > 0) { + --this.bE; +@@ -136,7 +146,7 @@ + this.bF = false; } - this.addEffect(new MobEffect(MobEffects.REGENERATION, 200, 0)); @@ -51,39 +44,51 @@ } } -@@ -433,7 +450,20 @@ - for (int l = 0; l < k; ++l) { - EntityVillager.IMerchantRecipeOption entityvillager_imerchantrecipeoption = aentityvillager_imerchantrecipeoption3[l]; +@@ -247,7 +257,14 @@ + while (iterator.hasNext()) { + MerchantRecipe merchantrecipe = (MerchantRecipe) iterator.next(); -- entityvillager_imerchantrecipeoption.a(this, this.trades, this.random); -+ // CraftBukkit start -+ // this is a hack. this must be done because otherwise, if -+ // mojang adds a new type of villager merchant option, it will need to -+ // have event handling added manually. this is better than having to do that. -+ MerchantRecipeList list = new MerchantRecipeList(); -+ entityvillager_imerchantrecipeoption.a(this, list, this.random); -+ for (MerchantRecipe recipe : list) { -+ VillagerAcquireTradeEvent event = new VillagerAcquireTradeEvent((Villager) getBukkitEntity(), recipe.asBukkit()); -+ Bukkit.getPluginManager().callEvent(event); -+ if (!event.isCancelled()) { -+ this.trades.add(CraftMerchantRecipe.fromBukkit(event.getRecipe()).toMinecraft()); -+ } -+ } -+ // CraftBukkit end - } +- merchantrecipe.increaseUses(-MathHelper.d((float) i * merchantrecipe.m())); ++ // CraftBukkit start ++ int bonus = -MathHelper.d((float) i * merchantrecipe.m()); ++ VillagerReplenishTradeEvent event = new VillagerReplenishTradeEvent((Villager) this.getBukkitEntity(), merchantrecipe.asBukkit(), bonus); ++ Bukkit.getPluginManager().callEvent(event); ++ if (!event.isCancelled()) { ++ merchantrecipe.increaseUses(event.getBonus()); ++ } ++ // CraftBukkit end } - -@@ -568,7 +598,12 @@ - entitywitch.setCustomNameVisible(this.getCustomNameVisible()); - } - -- this.world.addEntity(entitywitch); -+ // CraftBukkit start -+ if (CraftEventFactory.callEntityTransformEvent(this, entitywitch, EntityTransformEvent.TransformReason.LIGHTNING).isCancelled()) { -+ return; -+ } -+ this.world.addEntity(entitywitch, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING); -+ // CraftBukkit end - this.die(); } + +@@ -553,7 +570,12 @@ + entitywitch.setCustomNameVisible(this.getCustomNameVisible()); + } + +- this.world.addEntity(entitywitch); ++ // CraftBukkit start ++ if (CraftEventFactory.callEntityTransformEvent(this, entitywitch, EntityTransformEvent.TransformReason.LIGHTNING).isCancelled()) { ++ return; ++ } ++ this.world.addEntity(entitywitch, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING); ++ // CraftBukkit end + this.die(); } + +@@ -725,7 +747,7 @@ + + if (entityirongolem != null) { + if (entityirongolem.a((GeneratorAccess) this.world, EnumMobSpawn.MOB_SUMMONED) && entityirongolem.a((IWorldReader) this.world)) { +- this.world.addEntity(entityirongolem); ++ this.world.addEntity(entityirongolem, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.VILLAGE_DEFENSE); // CraftBukkit + return entityirongolem; + } + +@@ -775,7 +797,7 @@ + EntityVillager.a entityvillager_a = (EntityVillager.a) this.getBehaviorController().c(MemoryModuleType.GOLEM_SPAWN_CONDITIONS).orElseGet(EntityVillager.a::new); + + entityvillager_a.b(this.world.getTime()); +- this.br.a(MemoryModuleType.GOLEM_SPAWN_CONDITIONS, (Object) entityvillager_a); ++ this.br.a(MemoryModuleType.GOLEM_SPAWN_CONDITIONS, entityvillager_a); // CraftBukkit - decompile error + } + + public static final class a { diff --git a/nms-patches/EntityVillagerAbstract.patch b/nms-patches/EntityVillagerAbstract.patch new file mode 100644 index 0000000000..0fa972fbe0 --- /dev/null +++ b/nms-patches/EntityVillagerAbstract.patch @@ -0,0 +1,42 @@ +--- a/net/minecraft/server/EntityVillagerAbstract.java ++++ b/net/minecraft/server/EntityVillagerAbstract.java +@@ -4,6 +4,12 @@ + import java.util.Iterator; + import java.util.Set; + import javax.annotation.Nullable; ++// CraftBukkit start ++import org.bukkit.Bukkit; ++import org.bukkit.craftbukkit.inventory.CraftMerchantRecipe; ++import org.bukkit.entity.AbstractVillager; ++import org.bukkit.event.entity.VillagerAcquireTradeEvent; ++// CraftBukkit end + + public abstract class EntityVillagerAbstract extends EntityAgeable implements NPC, IMerchant { + +@@ -11,7 +17,7 @@ + private EntityHuman tradingPlayer; + @Nullable + protected MerchantRecipeList trades; +- private final InventorySubcontainer inventory = new InventorySubcontainer(8); ++ private final InventorySubcontainer inventory = new InventorySubcontainer(8, (org.bukkit.craftbukkit.entity.CraftAbstractVillager) this.getBukkitEntity()); // CraftBukkit add argument + private int bC; + + public EntityVillagerAbstract(EntityTypes entitytypes, World world) { +@@ -198,7 +204,16 @@ + MerchantRecipe merchantrecipe = villagertrades_imerchantrecipeoption.a(this, this.random); + + if (merchantrecipe != null) { +- merchantrecipelist.add(merchantrecipe); ++ // CraftBukkit start ++ VillagerAcquireTradeEvent event = new VillagerAcquireTradeEvent((AbstractVillager) getBukkitEntity(), merchantrecipe.asBukkit()); ++ // Suppress during worldgen ++ if (this.valid) { ++ Bukkit.getPluginManager().callEvent(event); ++ } ++ if (!event.isCancelled()) { ++ merchantrecipelist.add(CraftMerchantRecipe.fromBukkit(event.getRecipe()).toMinecraft()); ++ } ++ // CraftBukkit end + } + } + diff --git a/nms-patches/EntityVillagerTrader.patch b/nms-patches/EntityVillagerTrader.patch new file mode 100644 index 0000000000..8950133f16 --- /dev/null +++ b/nms-patches/EntityVillagerTrader.patch @@ -0,0 +1,33 @@ +--- a/net/minecraft/server/EntityVillagerTrader.java ++++ b/net/minecraft/server/EntityVillagerTrader.java +@@ -2,6 +2,12 @@ + + import java.util.EnumSet; + import javax.annotation.Nullable; ++// CraftBukkit start ++import org.bukkit.Bukkit; ++import org.bukkit.craftbukkit.inventory.CraftMerchantRecipe; ++import org.bukkit.entity.AbstractVillager; ++import org.bukkit.event.entity.VillagerAcquireTradeEvent; ++// CraftBukkit end + + public class EntityVillagerTrader extends EntityVillagerAbstract { + +@@ -92,7 +98,16 @@ + MerchantRecipe merchantrecipe = villagertrades_imerchantrecipeoption.a(this, this.random); + + if (merchantrecipe != null) { +- merchantrecipelist.add(merchantrecipe); ++ // CraftBukkit start ++ VillagerAcquireTradeEvent event = new VillagerAcquireTradeEvent((AbstractVillager) getBukkitEntity(), merchantrecipe.asBukkit()); ++ // Suppress during worldgen ++ if (this.valid) { ++ Bukkit.getPluginManager().callEvent(event); ++ } ++ if (!event.isCancelled()) { ++ merchantrecipelist.add(CraftMerchantRecipe.fromBukkit(event.getRecipe()).toMinecraft()); ++ } ++ // CraftBukkit end + } + + } diff --git a/nms-patches/EntityWitch.patch b/nms-patches/EntityWitch.patch index 11dbf2fd0a..b98cdca05e 100644 --- a/nms-patches/EntityWitch.patch +++ b/nms-patches/EntityWitch.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/EntityWitch.java +++ b/net/minecraft/server/EntityWitch.java -@@ -75,7 +75,7 @@ +@@ -96,7 +96,7 @@ while (iterator.hasNext()) { MobEffect mobeffect = (MobEffect) iterator.next(); diff --git a/nms-patches/EntityWither.patch b/nms-patches/EntityWither.patch index 50b2b974e3..6592f3b40e 100644 --- a/nms-patches/EntityWither.patch +++ b/nms-patches/EntityWither.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/EntityWither.java +++ b/net/minecraft/server/EntityWither.java -@@ -5,6 +5,13 @@ +@@ -6,6 +6,13 @@ import java.util.function.Predicate; import javax.annotation.Nullable; @@ -13,25 +13,25 @@ + public class EntityWither extends EntityMonster implements IRangedEntity { - private static final DataWatcherObject a = DataWatcher.a(EntityWither.class, DataWatcherRegistry.b); -@@ -181,13 +188,38 @@ - if (this.dz() > 0) { - i = this.dz() - 1; + private static final DataWatcherObject b = DataWatcher.a(EntityWither.class, DataWatcherRegistry.b); +@@ -188,14 +195,38 @@ + i = this.dV() - 1; if (i <= 0) { -- this.world.createExplosion(this, this.locX, this.locY + (double) this.getHeadHeight(), this.locZ, 7.0F, false, this.world.getGameRules().getBoolean("mobGriefing")); -- this.world.a(1023, new BlockPosition(this), 0); + Explosion.Effect explosion_effect = this.world.getGameRules().getBoolean("mobGriefing") ? Explosion.Effect.DESTROY : Explosion.Effect.NONE; + // CraftBukkit start -+ // this.world.createExplosion(this, this.locX, this.locY + (double) this.getHeadHeight(), this.locZ, 7.0F, false, this.world.getGameRules().getBoolean("mobGriefing")); ++ // this.world.createExplosion(this, this.locX, this.locY + (double) this.getHeadHeight(), this.locZ, 7.0F, false, explosion_effect); + ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), 7.0F, false); + this.world.getServer().getPluginManager().callEvent(event); + + if (!event.isCancelled()) { -+ this.world.createExplosion(this, this.locX, this.locY + (double) this.getHeadHeight(), this.locZ, event.getRadius(), event.getFire(), this.world.getGameRules().getBoolean("mobGriefing")); ++ this.world.createExplosion(this, this.locX, this.locY + (double) this.getHeadHeight(), this.locZ, event.getRadius(), event.getFire(), explosion_effect); + } + // CraftBukkit end -+ + +- this.world.createExplosion(this, this.locX, this.locY + (double) this.getHeadHeight(), this.locZ, 7.0F, false, explosion_effect); +- this.world.b(1023, new BlockPosition(this), 0); + // CraftBukkit start - Use relative location for far away sounds -+ // this.world.a(1023, new BlockPosition(this), 0); ++ // this.world.b(1023, new BlockPosition(this), 0); + int viewDistance = ((WorldServer) this.world).getServer().getViewDistance() * 16; + for (EntityPlayer player : (List) MinecraftServer.getServer().getPlayerList().players) { + double deltaX = this.locX - player.locX; @@ -49,38 +49,38 @@ + // CraftBukkit end } - this.d(i); + this.q(i); if (this.ticksLived % 10 == 0) { - this.heal(10.0F); + this.heal(10.0F, EntityRegainHealthEvent.RegainReason.WITHER_SPAWN); // CraftBukkit } } else { -@@ -239,9 +271,11 @@ +@@ -247,9 +278,11 @@ if (entityliving != this && entityliving.isAlive() && this.hasLineOfSight(entityliving)) { if (entityliving instanceof EntityHuman) { if (!((EntityHuman) entityliving).abilities.isInvulnerable) { + if (CraftEventFactory.callEntityTargetLivingEvent(this, entityliving, EntityTargetEvent.TargetReason.CLOSEST_PLAYER).isCancelled()) continue; // CraftBukkit - this.a(i, entityliving.getId()); + this.setHeadTarget(i, entityliving.getId()); } } else { + if (CraftEventFactory.callEntityTargetLivingEvent(this, entityliving, EntityTargetEvent.TargetReason.CLOSEST_ENTITY).isCancelled()) continue; // CraftBukkit - this.a(i, entityliving.getId()); + this.setHeadTarget(i, entityliving.getId()); } break; -@@ -278,6 +312,11 @@ - Block block = iblockdata.getBlock(); +@@ -285,6 +318,11 @@ + IBlockData iblockdata = this.world.getType(blockposition); - if (!iblockdata.isAir() && a(block)) { + if (b(iblockdata)) { + // CraftBukkit start + if (CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, Blocks.AIR.getBlockData()).isCancelled()) { + continue; + } + // CraftBukkit end - flag = this.world.setAir(blockposition, true) || flag; + flag = this.world.b(blockposition, true) || flag; } } -@@ -291,7 +330,7 @@ +@@ -298,7 +336,7 @@ } if (this.ticksLived % 20 == 0) { diff --git a/nms-patches/EntityWitherSkull.patch b/nms-patches/EntityWitherSkull.patch index 8e3e63f799..a98022df9b 100644 --- a/nms-patches/EntityWitherSkull.patch +++ b/nms-patches/EntityWitherSkull.patch @@ -7,39 +7,41 @@ + public class EntityWitherSkull extends EntityFireball { - private static final DataWatcherObject e = DataWatcher.a(EntityWitherSkull.class, DataWatcherRegistry.i); -@@ -28,11 +30,11 @@ - if (!this.world.isClientSide) { - if (movingobjectposition.entity != null) { + private static final DataWatcherObject f = DataWatcher.a(EntityWitherSkull.class, DataWatcherRegistry.i); +@@ -34,11 +36,11 @@ + Entity entity = ((MovingObjectPositionEntity) movingobjectposition).getEntity(); + if (this.shooter != null) { -- if (movingobjectposition.entity.damageEntity(DamageSource.mobAttack(this.shooter), 8.0F)) { -+ if (movingobjectposition.entity.damageEntity(DamageSource.projectile(this, shooter), 8.0F)) { // CraftBukkit - if (movingobjectposition.entity.isAlive()) { - this.a(this.shooter, movingobjectposition.entity); +- if (entity.damageEntity(DamageSource.mobAttack(this.shooter), 8.0F)) { ++ if (entity.damageEntity(DamageSource.projectile(this, shooter), 8.0F)) { // CraftBukkit + if (entity.isAlive()) { + this.a(this.shooter, entity); } else { - this.shooter.heal(5.0F); + this.shooter.heal(5.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.WITHER); // CraftBukkit } } } else { -@@ -49,12 +51,20 @@ +@@ -55,14 +57,22 @@ } if (b0 > 0) { -- ((EntityLiving) movingobjectposition.entity).addEffect(new MobEffect(MobEffects.WITHER, 20 * b0, 1)); -+ ((EntityLiving) movingobjectposition.entity).addEffect(new MobEffect(MobEffects.WITHER, 20 * b0, 1), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit +- ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.WITHER, 20 * b0, 1)); ++ ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.WITHER, 20 * b0, 1), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit } } } -- this.world.createExplosion(this, this.locX, this.locY, this.locZ, 1.0F, false, this.world.getGameRules().getBoolean("mobGriefing")); + Explosion.Effect explosion_effect = this.world.getGameRules().getBoolean("mobGriefing") ? Explosion.Effect.DESTROY : Explosion.Effect.NONE; + +- this.world.createExplosion(this, this.locX, this.locY, this.locZ, 1.0F, false, explosion_effect); + // CraftBukkit start -+ // this.world.createExplosion(this, this.locX, this.locY, this.locZ, 1.0F, false, this.world.getGameRules().getBoolean("mobGriefing")); ++ // this.world.createExplosion(this, this.locX, this.locY, this.locZ, 1.0F, false, explosion_effect); + ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), 1.0F, false); + this.world.getServer().getPluginManager().callEvent(event); + + if (!event.isCancelled()) { -+ this.world.createExplosion(this, this.locX, this.locY, this.locZ, event.getRadius(), event.getFire(), this.world.getGameRules().getBoolean("mobGriefing")); ++ this.world.createExplosion(this, this.locX, this.locY, this.locZ, event.getRadius(), event.getFire(), explosion_effect); + } + // CraftBukkit end this.die(); diff --git a/nms-patches/EntityWolf.patch b/nms-patches/EntityWolf.patch index 4fff0cce42..7c47443391 100644 --- a/nms-patches/EntityWolf.patch +++ b/nms-patches/EntityWolf.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/server/EntityWolf.java +++ b/net/minecraft/server/EntityWolf.java -@@ -3,6 +3,11 @@ - import java.util.UUID; +@@ -4,6 +4,11 @@ + import java.util.function.Predicate; import javax.annotation.Nullable; +// CraftBukkit start @@ -12,7 +12,16 @@ public class EntityWolf extends EntityTameableAnimal { private static final DataWatcherObject DATA_HEALTH = DataWatcher.a(EntityWolf.class, DataWatcherRegistry.c); -@@ -56,6 +61,22 @@ +@@ -42,7 +47,7 @@ + this.goalSelector.a(10, new PathfinderGoalRandomLookaround(this)); + this.targetSelector.a(1, new PathfinderGoalOwnerHurtByTarget(this)); + this.targetSelector.a(2, new PathfinderGoalOwnerHurtTarget(this)); +- this.targetSelector.a(3, (new PathfinderGoalHurtByTarget(this, new Class[0])).a()); ++ this.targetSelector.a(3, (new PathfinderGoalHurtByTarget(this, new Class[0])).a(new Class[0])); // CraftBukkit - decompile error + this.targetSelector.a(4, new PathfinderGoalRandomTargetNonTamed<>(this, EntityAnimal.class, false, EntityWolf.bD)); + this.targetSelector.a(4, new PathfinderGoalRandomTargetNonTamed<>(this, EntityTurtle.class, false, EntityTurtle.bz)); + this.targetSelector.a(5, new PathfinderGoalNearestAttackableTarget<>(this, EntitySkeletonAbstract.class, false)); +@@ -61,6 +66,22 @@ this.getAttributeMap().b(GenericAttributes.ATTACK_DAMAGE).setValue(2.0D); } @@ -32,10 +41,10 @@ + } + // CraftBukkit end + + @Override public void setGoalTarget(@Nullable EntityLiving entityliving) { super.setGoalTarget(entityliving); - if (entityliving == null) { -@@ -190,7 +211,8 @@ +@@ -217,7 +238,8 @@ Entity entity = damagesource.getEntity(); if (this.goalSit != null) { @@ -45,37 +54,37 @@ } if (entity != null && !(entity instanceof EntityHuman) && !(entity instanceof EntityArrow)) { -@@ -236,7 +258,7 @@ +@@ -264,7 +286,7 @@ itemstack.subtract(1); } -- this.heal((float) itemfood.getNutrition(itemstack)); -+ this.heal((float) itemfood.getNutrition(itemstack), org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.EATING); // CraftBukkit +- this.heal((float) item.getFoodInfo().getNutrition()); ++ this.heal((float) item.getFoodInfo().getNutrition(), org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.EATING); // CraftBukkit return true; } } else if (item instanceof ItemDye) { -@@ -257,7 +279,7 @@ +@@ -285,7 +307,7 @@ this.goalSit.setSitting(!this.isSitting()); - this.bg = false; - this.navigation.q(); + this.jumping = false; + this.navigation.o(); - this.setGoalTarget((EntityLiving) null); + this.setGoalTarget((EntityLiving) null, TargetReason.FORGOT_TARGET, true); // CraftBukkit - reason } } else if (item == Items.BONE && !this.isAngry()) { if (!entityhuman.abilities.canInstantlyBuild) { -@@ -265,12 +287,13 @@ +@@ -293,12 +315,13 @@ } if (!this.world.isClientSide) { - if (this.random.nextInt(3) == 0) { + // CraftBukkit - added event call and isCancelled check. + if (this.random.nextInt(3) == 0 && !CraftEventFactory.callEntityTameEvent(this, entityhuman).isCancelled()) { - this.c(entityhuman); - this.navigation.q(); + this.tame(entityhuman); + this.navigation.o(); this.setGoalTarget((EntityLiving) null); this.goalSit.setSitting(true); - this.setHealth(20.0F); + this.setHealth(this.getMaxHealth()); // CraftBukkit - 20.0 -> getMaxHealth() - this.s(true); + this.r(true); this.world.broadcastEntityEffect(this, (byte) 7); } else { diff --git a/nms-patches/EntityZombie.patch b/nms-patches/EntityZombie.patch index ee2790dbad..0e046eedd5 100644 --- a/nms-patches/EntityZombie.patch +++ b/nms-patches/EntityZombie.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/server/EntityZombie.java +++ b/net/minecraft/server/EntityZombie.java -@@ -6,6 +6,14 @@ - import java.util.UUID; +@@ -7,6 +7,14 @@ + import java.util.function.Predicate; import javax.annotation.Nullable; +// CraftBukkit start @@ -14,31 +14,29 @@ + public class EntityZombie extends EntityMonster { - protected static final IAttribute c = (new AttributeRanged((IAttribute) null, "zombie.spawnReinforcements", 0.0D, 0.0D, 1.0D)).a("Spawn Reinforcements Chance"); -@@ -21,6 +29,7 @@ + protected static final IAttribute d = (new AttributeRanged((IAttribute) null, "zombie.spawnReinforcements", 0.0D, 0.0D, 1.0D)).a("Spawn Reinforcements Chance"); +@@ -22,6 +30,7 @@ + private boolean bE; + private int bF; public int drownedConversionTime; - private float bK; - private float bL; + private int lastTick = MinecraftServer.currentTick; // CraftBukkit - add field - public EntityZombie(EntityTypes entitytypes, World world) { + public EntityZombie(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -143,8 +152,12 @@ - +@@ -143,7 +152,11 @@ public void tick() { - if (!this.world.isClientSide) { -- if (this.isDrownConverting()) { + if (!this.world.isClientSide && this.isAlive()) { + if (this.isDrownConverting()) { - --this.drownedConversionTime; -+ // CraftBukkit start - Use wall time instead of ticks for conversion -+ if (this.isDrownConverting() && this.isAlive()) { ++ // CraftBukkit start - Use wall time instead of ticks for conversion + int elapsedTicks = MinecraftServer.currentTick - this.lastTick; + this.lastTick = MinecraftServer.currentTick; + this.drownedConversionTime -= elapsedTicks; + // CraftBukkit end if (this.drownedConversionTime < 0) { - this.dE(); + this.eb(); } -@@ -221,7 +234,12 @@ +@@ -229,7 +242,12 @@ entityzombie.setCustomNameVisible(this.getCustomNameVisible()); } @@ -52,18 +50,18 @@ this.die(); } } -@@ -252,8 +270,8 @@ - if (this.world.getType(new BlockPosition(i1, j1 - 1, k1)).q() && this.world.getLightLevel(new BlockPosition(i1, j1, k1)) < 10) { +@@ -262,8 +280,8 @@ + if (this.world.getType(blockposition).a((IBlockAccess) this.world, blockposition, (Entity) entityzombie) && 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, entityzombie.getBoundingBox()) && this.world.getCubes(entityzombie, entityzombie.getBoundingBox()) && !this.world.containsLiquid(entityzombie.getBoundingBox())) { + if (!this.world.isPlayerNearby((double) i1, (double) j1, (double) k1, 7.0D) && this.world.i((Entity) entityzombie) && this.world.getCubes(entityzombie) && !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); // CraftBukkit - entityzombie.prepare(this.world.getDamageScaler(new BlockPosition(entityzombie)), (GroupDataEntity) null, (NBTTagCompound) null); - this.getAttributeInstance(EntityZombie.c).b(new AttributeModifier("Zombie reinforcement caller charge", -0.05000000074505806D, 0)); - entityzombie.getAttributeInstance(EntityZombie.c).b(new AttributeModifier("Zombie reinforcement callee charge", -0.05000000074505806D, 0)); -@@ -276,7 +294,14 @@ + entityzombie.prepare(this.world, this.world.getDamageScaler(new BlockPosition(entityzombie)), EnumMobSpawn.REINFORCEMENT, (GroupDataEntity) null, (NBTTagCompound) null); + this.getAttributeInstance(EntityZombie.d).b(new AttributeModifier("Zombie reinforcement caller charge", -0.05000000074505806D, AttributeModifier.Operation.ADDITION)); + entityzombie.getAttributeInstance(EntityZombie.d).b(new AttributeModifier("Zombie reinforcement callee charge", -0.05000000074505806D, AttributeModifier.Operation.ADDITION)); +@@ -287,7 +305,14 @@ float f = this.world.getDamageScaler(new BlockPosition(this)).b(); if (this.getItemInMainHand().isEmpty() && this.isBurning() && this.random.nextFloat() < f * 0.3F) { @@ -79,16 +77,16 @@ } } -@@ -362,7 +387,7 @@ - EntityZombieVillager entityzombievillager = new EntityZombieVillager(this.world); +@@ -377,7 +402,7 @@ + EntityZombieVillager entityzombievillager = (EntityZombieVillager) EntityTypes.ZOMBIE_VILLAGER.a(this.world); entityzombievillager.u(entityvillager); -- this.world.kill(entityvillager); -+ // this.world.kill(entityvillager); // CraftBukkit - moved down - entityzombievillager.prepare(this.world.getDamageScaler(new BlockPosition(entityzombievillager)), new EntityZombie.GroupDataZombie(false), (NBTTagCompound) null); - entityzombievillager.setProfession(entityvillager.getProfession()); - entityzombievillager.setBaby(entityvillager.isBaby()); -@@ -372,7 +397,13 @@ +- entityvillager.die(); ++ // entityvillager.die(); // CraftBukkit - moved down + entityzombievillager.prepare(this.world, this.world.getDamageScaler(new BlockPosition(entityzombievillager)), EnumMobSpawn.CONVERSION, new EntityZombie.GroupDataZombie(false), (NBTTagCompound) null); + entityzombievillager.setVillagerData(entityvillager.getVillagerData()); + entityzombievillager.setOffers(entityvillager.getOffers().a()); +@@ -389,7 +414,13 @@ entityzombievillager.setCustomNameVisible(entityvillager.getCustomNameVisible()); } @@ -97,35 +95,18 @@ + if (CraftEventFactory.callEntityTransformEvent(this, entityzombievillager, EntityTransformEvent.TransformReason.INFECTION).isCancelled()) { + return; + } -+ this.world.kill(entityvillager); // CraftBukkit - from above ++ entityvillager.die(); // CraftBukkit - from above + this.world.addEntity(entityzombievillager, CreatureSpawnEvent.SpawnReason.INFECTION); // CraftBukkit - add SpawnReason + // CraftBukkit end this.world.a((EntityHuman) null, 1026, new BlockPosition(this), 0); } -@@ -422,7 +453,7 @@ +@@ -436,7 +467,7 @@ entitychicken1.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, 0.0F); - entitychicken1.prepare(difficultydamagescaler, (GroupDataEntity) null, (NBTTagCompound) null); - entitychicken1.s(true); -- this.world.addEntity(entitychicken1); -+ this.world.addEntity(entitychicken1, CreatureSpawnEvent.SpawnReason.MOUNT); // CraftBukkit + entitychicken1.prepare(generatoraccess, difficultydamagescaler, EnumMobSpawn.JOCKEY, (GroupDataEntity) null, (NBTTagCompound) null); + entitychicken1.r(true); +- generatoraccess.addEntity(entitychicken1); ++ generatoraccess.addEntity(entitychicken1, CreatureSpawnEvent.SpawnReason.MOUNT); // CraftBukkit this.startRiding(entitychicken1); } } -@@ -495,7 +526,7 @@ - } - - public void die(DamageSource damagesource) { -- super.die(damagesource); -+ // super.die(damagesource); // CraftBukkit - if (damagesource.getEntity() instanceof EntityCreeper) { - EntityCreeper entitycreeper = (EntityCreeper) damagesource.getEntity(); - -@@ -508,6 +539,7 @@ - } - } - } -+ super.die(damagesource); // CraftBukkit - moved from above - - } - diff --git a/nms-patches/EntityZombieVillager.patch b/nms-patches/EntityZombieVillager.patch index f4fc67f10a..2bdeb7ec6a 100644 --- a/nms-patches/EntityZombieVillager.patch +++ b/nms-patches/EntityZombieVillager.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/server/EntityZombieVillager.java +++ b/net/minecraft/server/EntityZombieVillager.java -@@ -2,6 +2,10 @@ - +@@ -3,6 +3,10 @@ + import com.mojang.datafixers.Dynamic; import java.util.UUID; import javax.annotation.Nullable; +// CraftBukkit start @@ -9,23 +9,20 @@ +import org.bukkit.event.entity.EntityTransformEvent; +// CraftBukkit end - public class EntityZombieVillager extends EntityZombie { + public class EntityZombieVillager extends EntityZombie implements VillagerDataHolder { -@@ -9,6 +13,7 @@ - private static final DataWatcherObject b = DataWatcher.a(EntityZombieVillager.class, DataWatcherRegistry.b); - public int conversionTime; - private UUID bD; +@@ -12,6 +16,7 @@ + private UUID conversionPlayer; + private NBTTagCompound bB; + private int bC; + private int lastTick = MinecraftServer.currentTick; // CraftBukkit - add field - public EntityZombieVillager(World world) { - super(EntityTypes.ZOMBIE_VILLAGER, world); -@@ -54,8 +59,13 @@ - } - + public EntityZombieVillager(EntityTypes entitytypes, World world) { + super(entitytypes, world); +@@ -68,6 +73,11 @@ public void tick() { -- if (!this.world.isClientSide && this.isConverting()) { -+ if (!this.world.isClientSide && this.isConverting() && this.isAlive()) { // CraftBukkit - int i = this.dK(); + if (!this.world.isClientSide && this.isAlive() && this.isConverting()) { + int i = this.getConversionProgress(); + // CraftBukkit start - Use wall time instead of ticks for villager conversion + int elapsedTicks = MinecraftServer.currentTick - this.lastTick; + this.lastTick = MinecraftServer.currentTick; @@ -34,8 +31,8 @@ this.conversionTime -= i; if (this.conversionTime <= 0) { -@@ -100,8 +110,11 @@ - this.bD = uuid; +@@ -115,8 +125,11 @@ + this.conversionPlayer = uuid; this.conversionTime = i; this.getDataWatcher().set(EntityZombieVillager.CONVERTING, true); - this.removeEffect(MobEffects.WEAKNESS); @@ -48,35 +45,35 @@ this.world.broadcastEntityEffect(this, (byte) 16); } -@@ -116,14 +129,20 @@ +@@ -135,14 +148,20 @@ entityvillager.setAgeRaw(-24000); } -- this.world.kill(this); -+ // this.world.kill(this); // CraftBukkit - moved down +- this.die(); ++ // this.die(); // CraftBukkit - moved down entityvillager.setNoAI(this.isNoAI()); if (this.hasCustomName()) { entityvillager.setCustomName(this.getCustomName()); entityvillager.setCustomNameVisible(this.getCustomNameVisible()); } -- this.world.addEntity(entityvillager); +- worldserver.addEntity(entityvillager); + // CraftBukkit start + if (CraftEventFactory.callEntityTransformEvent(this, entityvillager, EntityTransformEvent.TransformReason.CURED).isCancelled()) { + return; + } -+ this.world.kill(this); // CraftBukkit - from above -+ this.world.addEntity(entityvillager, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CURED); // CraftBukkit - add SpawnReason ++ this.die(); // CraftBukkit - from above ++ worldserver.addEntity(entityvillager, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CURED); // CraftBukkit - add SpawnReason + // CraftBukkit end - if (this.bD != null) { - EntityHuman entityhuman = this.world.b(this.bD); + if (this.conversionPlayer != null) { + EntityHuman entityhuman = worldserver.b(this.conversionPlayer); -@@ -132,7 +151,7 @@ +@@ -152,7 +171,7 @@ } } - entityvillager.addEffect(new MobEffect(MobEffects.CONFUSION, 200, 0)); + entityvillager.addEffect(new MobEffect(MobEffects.CONFUSION, 200, 0), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION); // CraftBukkit - this.world.a((EntityHuman) null, 1027, new BlockPosition((int) this.locX, (int) this.locY, (int) this.locZ), 0); + worldserver.a((EntityHuman) null, 1027, new BlockPosition((int) this.locX, (int) this.locY, (int) this.locZ), 0); } diff --git a/nms-patches/ExpirableListEntry.patch b/nms-patches/ExpirableListEntry.patch index 533982ef72..fdc0dde3b1 100644 --- a/nms-patches/ExpirableListEntry.patch +++ b/nms-patches/ExpirableListEntry.patch @@ -9,7 +9,7 @@ Date date; -@@ -72,4 +72,26 @@ +@@ -74,4 +74,26 @@ jsonobject.addProperty("expires", this.d == null ? "forever" : ExpirableListEntry.a.format(this.d)); jsonobject.addProperty("reason", this.e); } diff --git a/nms-patches/ExpiringMap.patch b/nms-patches/ExpiringMap.patch deleted file mode 100644 index 0852538759..0000000000 --- a/nms-patches/ExpiringMap.patch +++ /dev/null @@ -1,51 +0,0 @@ ---- a/net/minecraft/server/ExpiringMap.java -+++ b/net/minecraft/server/ExpiringMap.java -@@ -4,8 +4,10 @@ - import it.unimi.dsi.fastutil.longs.Long2LongMap; - import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; - import it.unimi.dsi.fastutil.longs.Long2LongMap.Entry; -+import it.unimi.dsi.fastutil.objects.ObjectCollection; - import it.unimi.dsi.fastutil.objects.ObjectIterator; - import java.util.Map; -+import java.util.function.LongFunction; - - public class ExpiringMap extends Long2ObjectOpenHashMap { - -@@ -21,10 +23,17 @@ - long j = SystemUtils.getMonotonicMillis(); - - this.b.put(i, j); -+ // CraftBukkit start -+ cleanup(); -+ } -+ -+ public void cleanup() { -+ long j = SystemUtils.getMonotonicMillis(); -+ // CraftBukkit end - ObjectIterator objectiterator = this.b.long2LongEntrySet().iterator(); - - while (objectiterator.hasNext()) { -- Entry entry = (Entry) objectiterator.next(); -+ Long2LongMap.Entry entry = (Long2LongMap.Entry) objectiterator.next(); // CraftBukkit - decompile error - T t0 = super.get(entry.getLongKey()); - - if (j - entry.getLongValue() <= (long) this.a) { -@@ -69,4 +78,18 @@ - public T remove(Object object) { - throw new RuntimeException("Not implemented"); - } -+ -+ // CraftBukkit start -+ @Override -+ public T computeIfAbsent(long l, LongFunction lf) { -+ this.b.put(l, SystemUtils.getMonotonicMillis()); -+ return super.computeIfAbsent(l, lf); -+ } -+ -+ @Override -+ public ObjectCollection values() { -+ cleanup(); -+ return super.values(); -+ } -+ // CraftBukkit end - } diff --git a/nms-patches/Explosion.patch b/nms-patches/Explosion.patch index 5605823456..b166c928cb 100644 --- a/nms-patches/Explosion.patch +++ b/nms-patches/Explosion.patch @@ -20,7 +20,7 @@ private final Map l = Maps.newHashMap(); + public boolean wasCanceled = false; // CraftBukkit - add field - public Explosion(World world, @Nullable Entity entity, double d0, double d1, double d2, float f, boolean flag, boolean flag1) { + public Explosion(World world, @Nullable Entity entity, double d0, double d1, double d2, float f, boolean flag, Explosion.Effect explosion_effect) { this.world = world; this.source = entity; - this.size = f; @@ -28,7 +28,7 @@ this.posX = d0; this.posY = d1; this.posZ = d2; -@@ -38,6 +46,11 @@ +@@ -73,6 +81,11 @@ } public void a() { @@ -40,7 +40,7 @@ Set set = Sets.newHashSet(); boolean flag = true; -@@ -76,7 +89,7 @@ +@@ -111,7 +124,7 @@ f -= (f2 + 0.3F) * 0.3F; } @@ -49,8 +49,8 @@ set.add(blockposition); } -@@ -120,7 +133,16 @@ - double d12 = (double) this.world.a(vec3d, entity.getBoundingBox()); +@@ -155,7 +168,16 @@ + double d12 = (double) a(vec3d, entity); double d13 = (1.0D - d7) * d12; - entity.damageEntity(this.b(), (float) ((int) ((d13 * d13 + d13) / 2.0D * 7.0D * (double) f3 + 1.0D))); @@ -67,10 +67,10 @@ double d14 = d13; if (entity instanceof EntityLiving) { -@@ -156,6 +178,50 @@ +@@ -191,6 +213,50 @@ BlockPosition blockposition; - if (this.b) { + if (flag1) { + // CraftBukkit start + org.bukkit.World bworld = this.world.getWorld(); + org.bukkit.entity.Entity explode = this.source == null ? null : this.source.getBukkitEntity(); @@ -118,20 +118,19 @@ iterator = this.blocks.iterator(); while (iterator.hasNext()) { -@@ -187,7 +253,8 @@ +@@ -226,7 +292,7 @@ + LootTableInfo.Builder loottableinfo_builder = (new LootTableInfo.Builder((WorldServer) this.world)).a(this.world.random).set(LootContextParameters.POSITION, blockposition).set(LootContextParameters.TOOL, ItemStack.a).setOptional(LootContextParameters.BLOCK_ENTITY, tileentity); - if (!iblockdata.isAir()) { - if (block.a(this)) { -- iblockdata.dropNaturally(this.world, blockposition, 1.0F / this.size, 0); -+ // CraftBukkit - add yield -+ iblockdata.dropNaturally(this.world, blockposition, yield, 0); - } + if (this.b == Explosion.Effect.DESTROY) { +- loottableinfo_builder.set(LootContextParameters.EXPLOSION_RADIUS, this.size); ++ loottableinfo_builder.set(LootContextParameters.EXPLOSION_RADIUS, 1.0F / yield); // CraftBukkit - add yield + } - this.world.setTypeAndData(blockposition, Blocks.AIR.getBlockData(), 3); -@@ -202,7 +269,11 @@ + Block.b(iblockdata, loottableinfo_builder); +@@ -244,7 +310,11 @@ while (iterator.hasNext()) { blockposition = (BlockPosition) iterator.next(); - if (this.world.getType(blockposition).isAir() && this.world.getType(blockposition.down()).f(this.world, blockposition.down()) && this.c.nextInt(3) == 0) { + if (this.world.getType(blockposition).isAir() && this.world.getType(blockposition.down()).g(this.world, blockposition.down()) && this.c.nextInt(3) == 0) { - this.world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData()); + // CraftBukkit start - Ignition by explosion + if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(this.world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this).isCancelled()) { @@ -141,7 +140,7 @@ } } } -@@ -223,7 +294,9 @@ +@@ -265,7 +335,9 @@ @Nullable public EntityLiving getSource() { diff --git a/nms-patches/FluidTypeFlowing.patch b/nms-patches/FluidTypeFlowing.patch index cc26ce33f9..8858905981 100644 --- a/nms-patches/FluidTypeFlowing.patch +++ b/nms-patches/FluidTypeFlowing.patch @@ -15,10 +15,10 @@ public abstract class FluidTypeFlowing extends FluidType { -@@ -141,6 +149,15 @@ +@@ -134,6 +142,15 @@ Fluid fluid1 = this.a((IWorldReader) generatoraccess, blockposition1, iblockdata1); - if (this.a(generatoraccess, blockposition, iblockdata, EnumDirection.DOWN, blockposition1, iblockdata1, generatoraccess.getFluid(blockposition1), fluid1.c())) { + if (this.a(generatoraccess, blockposition, iblockdata, EnumDirection.DOWN, blockposition1, iblockdata1, generatoraccess.getFluid(blockposition1), fluid1.getType())) { + // CraftBukkit start + org.bukkit.block.Block source = CraftBlock.at(generatoraccess, blockposition); + BlockFromToEvent event = new BlockFromToEvent(source, BlockFace.DOWN); @@ -31,10 +31,10 @@ this.a(generatoraccess, blockposition1, iblockdata1, EnumDirection.DOWN, fluid1); if (this.a((IWorldReader) generatoraccess, blockposition) >= 3) { this.a(generatoraccess, blockposition, fluid, iblockdata); -@@ -171,6 +188,15 @@ +@@ -164,6 +181,15 @@ IBlockData iblockdata1 = generatoraccess.getType(blockposition1); - if (this.a(generatoraccess, blockposition, iblockdata, enumdirection, blockposition1, iblockdata1, generatoraccess.getFluid(blockposition1), fluid1.c())) { + if (this.a(generatoraccess, blockposition, iblockdata, enumdirection, blockposition1, iblockdata1, generatoraccess.getFluid(blockposition1), fluid1.getType())) { + // CraftBukkit start + org.bukkit.block.Block source = CraftBlock.at(generatoraccess, blockposition); + BlockFromToEvent event = new BlockFromToEvent(source, org.bukkit.craftbukkit.block.CraftBlock.notchToBlockFace(enumdirection)); @@ -47,9 +47,9 @@ this.a(generatoraccess, blockposition1, iblockdata1, enumdirection, fluid1); } } -@@ -448,12 +474,23 @@ +@@ -442,12 +468,23 @@ - if (fluid1.e()) { + if (fluid1.isEmpty()) { fluid = fluid1; - world.setTypeAndData(blockposition, Blocks.AIR.getBlockData(), 3); + // CraftBukkit start @@ -61,7 +61,7 @@ + // CraftBukkit end } else if (!fluid1.equals(fluid)) { fluid = fluid1; - IBlockData iblockdata = fluid1.i(); + IBlockData iblockdata = fluid1.getBlockData(); - - world.setTypeAndData(blockposition, iblockdata, 2); + // CraftBukkit start @@ -71,6 +71,6 @@ + } + world.setTypeAndData(blockposition, ((CraftBlockData) event.getNewData()).getState(), 2); + // CraftBukkit end - world.getFluidTickList().a(blockposition, fluid1.c(), i); + world.getFluidTickList().a(blockposition, fluid1.getType(), i); world.applyPhysics(blockposition, iblockdata.getBlock()); } diff --git a/nms-patches/FluidTypeLava.patch b/nms-patches/FluidTypeLava.patch index 32cbc489fe..ec7bce2e94 100644 --- a/nms-patches/FluidTypeLava.patch +++ b/nms-patches/FluidTypeLava.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/server/FluidTypeLava.java +++ b/net/minecraft/server/FluidTypeLava.java -@@ -35,6 +35,13 @@ +@@ -39,6 +39,13 @@ if (iblockdata.isAir()) { if (this.a((IWorldReader) world, blockposition1)) { + // CraftBukkit start - Prevent lava putting something on fire -+ if (world.getType(blockposition1) != Blocks.FIRE) { ++ if (world.getType(blockposition1).getBlock() != Blocks.FIRE) { + if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition1, blockposition).isCancelled()) { + continue; + } @@ -14,13 +14,13 @@ world.setTypeUpdate(blockposition1, Blocks.FIRE.getBlockData()); return; } -@@ -51,6 +58,14 @@ +@@ -55,6 +62,14 @@ } if (world.isEmpty(blockposition2.up()) && this.b(world, blockposition2)) { + // CraftBukkit start - Prevent lava putting something on fire + BlockPosition up = blockposition2.up(); -+ if (world.getType(up) != Blocks.FIRE) { ++ if (world.getType(up).getBlock() != Blocks.FIRE) { + if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, up, blockposition).isCancelled()) { + continue; + } @@ -29,7 +29,7 @@ world.setTypeUpdate(blockposition2.up(), Blocks.FIRE.getBlockData()); } } -@@ -139,7 +154,11 @@ +@@ -144,7 +159,11 @@ if (this.a(TagsFluid.LAVA) && fluid1.a(TagsFluid.WATER)) { if (iblockdata.getBlock() instanceof BlockFluids) { diff --git a/nms-patches/FoodMetaData.patch b/nms-patches/FoodMetaData.patch index 9aff748f34..53d872776f 100644 --- a/nms-patches/FoodMetaData.patch +++ b/nms-patches/FoodMetaData.patch @@ -19,26 +19,26 @@ public void eat(int i, float f) { this.foodLevel = Math.min(i + this.foodLevel, 20); -@@ -16,7 +24,17 @@ - } +@@ -18,8 +26,17 @@ + public void a(Item item, ItemStack itemstack) { + if (item.isFood()) { + FoodInfo foodinfo = item.getFoodInfo(); ++ // CraftBukkit start ++ int oldFoodLevel = foodLevel; - public void a(ItemFood itemfood, ItemStack itemstack) { -- this.eat(itemfood.getNutrition(itemstack), itemfood.getSaturationModifier(itemstack)); -+ // CraftBukkit start -+ int oldFoodLevel = foodLevel; +- this.eat(foodinfo.getNutrition(), foodinfo.getSaturationModifier()); ++ org.bukkit.event.entity.FoodLevelChangeEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callFoodLevelChangeEvent(entityhuman, foodinfo.getNutrition() + oldFoodLevel); + -+ org.bukkit.event.entity.FoodLevelChangeEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callFoodLevelChangeEvent(entityhuman, itemfood.getNutrition(itemstack) + oldFoodLevel); ++ if (!event.isCancelled()) { ++ this.eat(event.getFoodLevel() - oldFoodLevel, foodinfo.getSaturationModifier()); ++ } + -+ if (!event.isCancelled()) { -+ this.eat(event.getFoodLevel() - oldFoodLevel, itemfood.getSaturationModifier(itemstack)); -+ } -+ -+ ((EntityPlayer) entityhuman).getBukkitEntity().sendHealthUpdate(); -+ // CraftBukkit end - } ++ ((EntityPlayer) entityhuman).getBukkitEntity().sendHealthUpdate(); ++ // CraftBukkit end + } - public void a(EntityHuman entityhuman) { -@@ -28,7 +46,15 @@ + } +@@ -33,7 +50,15 @@ if (this.saturationLevel > 0.0F) { this.saturationLevel = Math.max(this.saturationLevel - 1.0F, 0.0F); } else if (enumdifficulty != EnumDifficulty.PEACEFUL) { @@ -55,7 +55,7 @@ } } -@@ -39,14 +65,14 @@ +@@ -44,14 +69,14 @@ if (this.foodTickTimer >= 10) { float f = Math.min(this.saturationLevel, 6.0F); @@ -64,7 +64,7 @@ this.a(f); this.foodTickTimer = 0; } - } else if (flag && this.foodLevel >= 18 && entityhuman.dx()) { + } else if (flag && this.foodLevel >= 18 && entityhuman.dP()) { ++this.foodTickTimer; if (this.foodTickTimer >= 80) { - entityhuman.heal(1.0F); diff --git a/nms-patches/FurnaceRecipe.patch b/nms-patches/FurnaceRecipe.patch index e9b367f873..8d6ae7e2f4 100644 --- a/nms-patches/FurnaceRecipe.patch +++ b/nms-patches/FurnaceRecipe.patch @@ -1,9 +1,8 @@ --- a/net/minecraft/server/FurnaceRecipe.java +++ b/net/minecraft/server/FurnaceRecipe.java -@@ -2,6 +2,16 @@ +@@ -1,5 +1,16 @@ + package net.minecraft.server; - import com.google.gson.JsonElement; - import com.google.gson.JsonObject; +// CraftBukkit start +import java.util.ArrayList; +import java.util.List; @@ -14,13 +13,15 @@ +import org.bukkit.craftbukkit.util.CraftNamespacedKey; +import org.bukkit.inventory.Recipe; +// CraftBukkit end ++ + public class FurnaceRecipe extends RecipeCooking { - public class FurnaceRecipe implements IRecipe { - -@@ -56,6 +66,16 @@ - return this.key; + public FurnaceRecipe(MinecraftKey minecraftkey, String s, RecipeItemStack recipeitemstack, ItemStack itemstack, float f, int i) { +@@ -10,4 +21,14 @@ + public RecipeSerializer getRecipeSerializer() { + return RecipeSerializer.o; } - ++ + @Override + public Recipe toBukkitRecipe() { + CraftItemStack result = CraftItemStack.asCraftMirror(this.result); @@ -30,7 +31,4 @@ + + return recipe; + } -+ - public static class a implements RecipeSerializer { - - public a() {} + } diff --git a/nms-patches/HandshakeListener.patch b/nms-patches/HandshakeListener.patch index 1a5a7dcd0d..c9446a0cc0 100644 --- a/nms-patches/HandshakeListener.patch +++ b/nms-patches/HandshakeListener.patch @@ -18,7 +18,7 @@ private final MinecraftServer a; private final NetworkManager b; -@@ -16,6 +26,41 @@ +@@ -17,6 +27,41 @@ this.b.setProtocol(EnumProtocol.LOGIN); ChatMessage chatmessage; @@ -57,10 +57,10 @@ + } + // CraftBukkit end + - if (packethandshakinginsetprotocol.c() > 404) { - chatmessage = new ChatMessage("multiplayer.disconnect.outdated_server", new Object[] { "1.13.2"}); + if (packethandshakinginsetprotocol.c() > SharedConstants.a().getProtocolVersion()) { + chatmessage = new ChatMessage("multiplayer.disconnect.outdated_server", new Object[] { SharedConstants.a().getName()}); this.b.sendPacket(new PacketLoginOutDisconnect(chatmessage)); -@@ -26,6 +71,7 @@ +@@ -27,6 +72,7 @@ this.b.close(chatmessage); } else { this.b.setPacketListener(new LoginListener(this.a, this.b)); diff --git a/nms-patches/IChunkLoader.patch b/nms-patches/IChunkLoader.patch new file mode 100644 index 0000000000..27666cca0c --- /dev/null +++ b/nms-patches/IChunkLoader.patch @@ -0,0 +1,55 @@ +--- a/net/minecraft/server/IChunkLoader.java ++++ b/net/minecraft/server/IChunkLoader.java +@@ -17,10 +17,51 @@ + this.b = datafixer; + } + +- public NBTTagCompound getChunkData(DimensionManager dimensionmanager, Supplier supplier, NBTTagCompound nbttagcompound) { ++ // CraftBukkit start ++ private boolean check(ChunkProviderServer cps, int x, int z) throws IOException { ++ ChunkCoordIntPair pos = new ChunkCoordIntPair(x, z); ++ if (cps != null) { ++ com.google.common.base.Preconditions.checkState(org.bukkit.Bukkit.isPrimaryThread(), "primary thread"); ++ if (cps.isLoaded(x, z)) { ++ return true; ++ } ++ } ++ ++ if (this.chunkExists(pos)) { ++ NBTTagCompound nbt = read(pos); ++ if (nbt != null) { ++ NBTTagCompound level = nbt.getCompound("Level"); ++ if (level.getBoolean("TerrainPopulated")) { ++ return true; ++ } ++ ++ ChunkStatus status = ChunkStatus.a(level.getString("Status")); ++ if (status != null && status.b(ChunkStatus.FEATURES)) { ++ return true; ++ } ++ } ++ } ++ ++ return false; ++ } ++ // CraftBukkit end ++ ++ public NBTTagCompound getChunkData(DimensionManager dimensionmanager, Supplier supplier, NBTTagCompound nbttagcompound, ChunkCoordIntPair pos, @Nullable GeneratorAccess generatoraccess) throws IOException { + int i = a(nbttagcompound); + boolean flag = true; + ++ // CraftBukkit start ++ if (i < 1466) { ++ NBTTagCompound level = nbttagcompound.getCompound("Level"); ++ if (level.getBoolean("TerrainPopulated") && !level.getBoolean("LightPopulated")) { ++ ChunkProviderServer cps = (generatoraccess == null) ? null : ((WorldServer) generatoraccess).getChunkProvider(); ++ if (check(cps, pos.x - 1, pos.z) && check(cps, pos.x - 1, pos.z - 1) && check(cps, pos.x, pos.z - 1)) { ++ level.setBoolean("LightPopulated", true); ++ } ++ } ++ } ++ // CraftBukkit end ++ + if (i < 1493) { + nbttagcompound = GameProfileSerializer.a(this.b, DataFixTypes.CHUNK, nbttagcompound, i, 1493); + if (nbttagcompound.getCompound("Level").getBoolean("hasLegacyStructureData")) { diff --git a/nms-patches/ICommandListener.patch b/nms-patches/ICommandListener.patch index d1efb9cd4b..e9d99ff130 100644 --- a/nms-patches/ICommandListener.patch +++ b/nms-patches/ICommandListener.patch @@ -1,9 +1,23 @@ --- a/net/minecraft/server/ICommandListener.java +++ b/net/minecraft/server/ICommandListener.java -@@ -9,4 +9,6 @@ - boolean b(); +@@ -20,6 +20,13 @@ + public boolean shouldBroadcastCommands() { + return false; + } ++ ++ // CraftBukkit start ++ @Override ++ public org.bukkit.command.CommandSender getBukkitSender(CommandListenerWrapper wrapper) { ++ throw new UnsupportedOperationException("Not supported yet."); ++ } ++ // CraftBukkit end + }; - boolean B_(); + void sendMessage(IChatBaseComponent ichatbasecomponent); +@@ -29,4 +36,6 @@ + boolean shouldSendFailure(); + + boolean shouldBroadcastCommands(); + + org.bukkit.command.CommandSender getBukkitSender(CommandListenerWrapper wrapper); // CraftBukkit } diff --git a/nms-patches/IDataManager.patch b/nms-patches/IDataManager.patch deleted file mode 100644 index a02e77ba6e..0000000000 --- a/nms-patches/IDataManager.patch +++ /dev/null @@ -1,9 +0,0 @@ ---- a/net/minecraft/server/IDataManager.java -+++ b/net/minecraft/server/IDataManager.java -@@ -29,4 +29,6 @@ - DefinedStructureManager h(); - - DataFixer i(); -+ -+ java.util.UUID getUUID(); // CraftBukkit - } diff --git a/nms-patches/IDispenseBehavior.patch b/nms-patches/IDispenseBehavior.patch new file mode 100644 index 0000000000..fa63b50665 --- /dev/null +++ b/nms-patches/IDispenseBehavior.patch @@ -0,0 +1,484 @@ +--- a/net/minecraft/server/IDispenseBehavior.java ++++ b/net/minecraft/server/IDispenseBehavior.java +@@ -3,6 +3,14 @@ + import java.util.Iterator; + import java.util.List; + import java.util.Random; ++// CraftBukkit start ++import org.bukkit.Location; ++import org.bukkit.TreeType; ++import org.bukkit.craftbukkit.inventory.CraftItemStack; ++import org.bukkit.craftbukkit.util.DummyGeneratorAccess; ++import org.bukkit.event.block.BlockDispenseEvent; ++import org.bukkit.event.world.StructureGrowEvent; ++// CraftBukkit end + + public interface IDispenseBehavior { + +@@ -44,7 +52,7 @@ + BlockDispenser.a((IMaterial) Items.EGG, (IDispenseBehavior) (new DispenseBehaviorProjectile() { + @Override + protected IProjectile a(World world, IPosition iposition, ItemStack itemstack) { +- return (IProjectile) SystemUtils.a((Object) (new EntityEgg(world, iposition.getX(), iposition.getY(), iposition.getZ())), (entityegg) -> { ++ return (IProjectile) SystemUtils.a((new EntityEgg(world, iposition.getX(), iposition.getY(), iposition.getZ())), (entityegg) -> { // CraftBukkit - decompile error + entityegg.setItem(itemstack); + }); + } +@@ -52,7 +60,7 @@ + BlockDispenser.a((IMaterial) Items.SNOWBALL, (IDispenseBehavior) (new DispenseBehaviorProjectile() { + @Override + protected IProjectile a(World world, IPosition iposition, ItemStack itemstack) { +- return (IProjectile) SystemUtils.a((Object) (new EntitySnowball(world, iposition.getX(), iposition.getY(), iposition.getZ())), (entitysnowball) -> { ++ return (IProjectile) SystemUtils.a((new EntitySnowball(world, iposition.getX(), iposition.getY(), iposition.getZ())), (entitysnowball) -> { // CraftBukkit - decompile error + entitysnowball.setItem(itemstack); + }); + } +@@ -60,7 +68,7 @@ + BlockDispenser.a((IMaterial) Items.EXPERIENCE_BOTTLE, (IDispenseBehavior) (new DispenseBehaviorProjectile() { + @Override + protected IProjectile a(World world, IPosition iposition, ItemStack itemstack) { +- return (IProjectile) SystemUtils.a((Object) (new EntityThrownExpBottle(world, iposition.getX(), iposition.getY(), iposition.getZ())), (entitythrownexpbottle) -> { ++ return (IProjectile) SystemUtils.a((new EntityThrownExpBottle(world, iposition.getX(), iposition.getY(), iposition.getZ())), (entitythrownexpbottle) -> { // CraftBukkit - decompile error + entitythrownexpbottle.setItem(itemstack); + }); + } +@@ -81,7 +89,7 @@ + return (new DispenseBehaviorProjectile() { + @Override + protected IProjectile a(World world, IPosition iposition, ItemStack itemstack1) { +- return (IProjectile) SystemUtils.a((Object) (new EntityPotion(world, iposition.getX(), iposition.getY(), iposition.getZ())), (entitypotion) -> { ++ return (IProjectile) SystemUtils.a((new EntityPotion(world, iposition.getX(), iposition.getY(), iposition.getZ())), (entitypotion) -> { // CraftBukkit - decompile error + entitypotion.setItem(itemstack1); + }); + } +@@ -104,7 +112,7 @@ + return (new DispenseBehaviorProjectile() { + @Override + protected IProjectile a(World world, IPosition iposition, ItemStack itemstack1) { +- return (IProjectile) SystemUtils.a((Object) (new EntityPotion(world, iposition.getX(), iposition.getY(), iposition.getZ())), (entitypotion) -> { ++ return (IProjectile) SystemUtils.a((new EntityPotion(world, iposition.getX(), iposition.getY(), iposition.getZ())), (entitypotion) -> { // CraftBukkit - decompile error + entitypotion.setItem(itemstack1); + }); + } +@@ -127,8 +135,36 @@ + EnumDirection enumdirection = (EnumDirection) isourceblock.e().get(BlockDispenser.FACING); + EntityTypes entitytypes = ((ItemMonsterEgg) itemstack.getItem()).b(itemstack.getTag()); + ++ // CraftBukkit start ++ World world = isourceblock.getWorld(); ++ ItemStack itemstack1 = itemstack.cloneAndSubtract(1); ++ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); ++ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); ++ ++ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0)); ++ if (!BlockDispenser.eventFired) { ++ world.getServer().getPluginManager().callEvent(event); ++ } ++ ++ if (event.isCancelled()) { ++ itemstack.add(1); ++ return itemstack; ++ } ++ ++ if (!event.getItem().equals(craftItem)) { ++ itemstack.add(1); ++ // Chain to handler for new item ++ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); ++ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); ++ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { ++ idispensebehavior.dispense(isourceblock, eventStack); ++ return itemstack; ++ } ++ } ++ + entitytypes.spawnCreature(isourceblock.getWorld(), itemstack, (EntityHuman) null, isourceblock.getBlockPosition().shift(enumdirection), EnumMobSpawn.DISPENSER, enumdirection != EnumDirection.UP, false); +- itemstack.subtract(1); ++ // itemstack.subtract(1); // Handled during event processing ++ // CraftBukkit end + return itemstack; + } + }; +@@ -147,9 +183,37 @@ + double d0 = isourceblock.getX() + (double) enumdirection.getAdjacentX(); + double d1 = (double) ((float) isourceblock.getBlockPosition().getY() + 0.2F); + double d2 = isourceblock.getZ() + (double) enumdirection.getAdjacentZ(); ++ // CraftBukkit start ++ World world = isourceblock.getWorld(); ++ ItemStack itemstack1 = itemstack.cloneAndSubtract(1); ++ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); ++ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); ++ ++ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(d0, d1, d2)); ++ if (!BlockDispenser.eventFired) { ++ world.getServer().getPluginManager().callEvent(event); ++ } ++ ++ if (event.isCancelled()) { ++ itemstack.add(1); ++ return itemstack; ++ } ++ ++ if (!event.getItem().equals(craftItem)) { ++ itemstack.add(1); ++ // Chain to handler for new item ++ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); ++ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); ++ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { ++ idispensebehavior.dispense(isourceblock, eventStack); ++ return itemstack; ++ } ++ } + +- isourceblock.getWorld().addEntity(new EntityFireworks(isourceblock.getWorld(), d0, d1, d2, itemstack)); +- itemstack.subtract(1); ++ itemstack1 = CraftItemStack.asNMSCopy(event.getItem()); ++ isourceblock.getWorld().addEntity(new EntityFireworks(isourceblock.getWorld(), event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), itemstack1)); ++ // itemstack.subtract(1); // Handled during event processing ++ // CraftBukkit end + return itemstack; + } + +@@ -172,10 +236,39 @@ + double d4 = random.nextGaussian() * 0.05D + (double) enumdirection.getAdjacentY(); + double d5 = random.nextGaussian() * 0.05D + (double) enumdirection.getAdjacentZ(); + +- world.addEntity((Entity) SystemUtils.a((Object) (new EntitySmallFireball(world, d0, d1, d2, d3, d4, d5)), (entitysmallfireball) -> { +- entitysmallfireball.b(itemstack); +- })); +- itemstack.subtract(1); ++ // CraftBukkit start ++ ItemStack itemstack1 = itemstack.cloneAndSubtract(1); ++ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); ++ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); ++ ++ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(d3, d4, d5)); ++ if (!BlockDispenser.eventFired) { ++ world.getServer().getPluginManager().callEvent(event); ++ } ++ ++ if (event.isCancelled()) { ++ itemstack.add(1); ++ return itemstack; ++ } ++ ++ if (!event.getItem().equals(craftItem)) { ++ itemstack.add(1); ++ // Chain to handler for new item ++ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); ++ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); ++ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { ++ idispensebehavior.dispense(isourceblock, eventStack); ++ return itemstack; ++ } ++ } ++ ++ EntitySmallFireball entitysmallfireball = new EntitySmallFireball(world, d0, d1, d2, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ()); ++ entitysmallfireball.b(itemstack); ++ entitysmallfireball.projectileSource = new org.bukkit.craftbukkit.projectiles.CraftBlockProjectileSource((TileEntityDispenser) isourceblock.getTileEntity()); ++ ++ world.addEntity(entitysmallfireball); ++ // itemstack.subtract(1); // Handled during event processing ++ // CraftBukkit end + return itemstack; + } + +@@ -199,9 +292,52 @@ + BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.e().get(BlockDispenser.FACING)); + World world = isourceblock.getWorld(); + ++ // CraftBukkit start ++ int x = blockposition.getX(); ++ int y = blockposition.getY(); ++ int z = blockposition.getZ(); ++ IBlockData iblockdata = world.getType(blockposition); ++ Material material = iblockdata.getMaterial(); ++ if (world.isEmpty(blockposition) || !material.isBuildable() || material.isReplaceable() || ((iblockdata.getBlock() instanceof IFluidContainer) && ((IFluidContainer) iblockdata.getBlock()).canPlace(world, blockposition, iblockdata, itembucket.fluidType))) { ++ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); ++ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack); ++ ++ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(x, y, z)); ++ if (!BlockDispenser.eventFired) { ++ world.getServer().getPluginManager().callEvent(event); ++ } ++ ++ if (event.isCancelled()) { ++ return itemstack; ++ } ++ ++ if (!event.getItem().equals(craftItem)) { ++ // Chain to handler for new item ++ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); ++ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); ++ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { ++ idispensebehavior.dispense(isourceblock, eventStack); ++ return itemstack; ++ } ++ } ++ ++ itembucket = (ItemBucket) CraftItemStack.asNMSCopy(event.getItem()).getItem(); ++ } ++ // CraftBukkit end ++ + if (itembucket.a((EntityHuman) null, world, blockposition, (MovingObjectPositionBlock) null)) { + itembucket.a(world, itemstack, blockposition); +- return new ItemStack(Items.BUCKET); ++ // CraftBukkit start - Handle stacked buckets ++ Item item = Items.BUCKET; ++ itemstack.subtract(1); ++ if (itemstack.isEmpty()) { ++ itemstack.setItem(Items.BUCKET); ++ itemstack.setCount(1); ++ } else if (((TileEntityDispenser) isourceblock.getTileEntity()).addItem(new ItemStack(item)) < 0) { ++ this.b.dispense(isourceblock, new ItemStack(item)); ++ } ++ // CraftBukkit end ++ return itemstack; + } else { + return this.b.dispense(isourceblock, itemstack); + } +@@ -225,13 +361,39 @@ + Block block = iblockdata.getBlock(); + + if (block instanceof IFluidSource) { +- FluidType fluidtype = ((IFluidSource) block).removeFluid(world, blockposition, iblockdata); ++ FluidType fluidtype = ((IFluidSource) block).removeFluid(DummyGeneratorAccess.INSTANCE, blockposition, iblockdata); // CraftBukkit + + if (!(fluidtype instanceof FluidTypeFlowing)) { + return super.a(isourceblock, itemstack); + } else { + Item item = fluidtype.b(); + ++ // CraftBukkit start ++ org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); ++ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack); ++ ++ BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockposition.getX(), blockposition.getY(), blockposition.getZ())); ++ if (!BlockDispenser.eventFired) { ++ world.getServer().getPluginManager().callEvent(event); ++ } ++ ++ if (event.isCancelled()) { ++ return itemstack; ++ } ++ ++ if (!event.getItem().equals(craftItem)) { ++ // Chain to handler for new item ++ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); ++ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); ++ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { ++ idispensebehavior.dispense(isourceblock, eventStack); ++ return itemstack; ++ } ++ } ++ ++ fluidtype = ((IFluidSource) block).removeFluid(world, blockposition, iblockdata); // From above ++ // CraftBukkit end ++ + itemstack.subtract(1); + if (itemstack.isEmpty()) { + return new ItemStack(item); +@@ -253,12 +415,40 @@ + protected ItemStack a(ISourceBlock isourceblock, ItemStack itemstack) { + World world = isourceblock.getWorld(); + ++ // CraftBukkit start ++ org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); ++ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack); ++ ++ BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0)); ++ if (!BlockDispenser.eventFired) { ++ world.getServer().getPluginManager().callEvent(event); ++ } ++ ++ if (event.isCancelled()) { ++ return itemstack; ++ } ++ ++ if (!event.getItem().equals(craftItem)) { ++ // Chain to handler for new item ++ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); ++ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); ++ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { ++ idispensebehavior.dispense(isourceblock, eventStack); ++ return itemstack; ++ } ++ } ++ // CraftBukkit end ++ + this.dispensed = true; + BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.e().get(BlockDispenser.FACING)); + IBlockData iblockdata = world.getType(blockposition); + + if (ItemFlintAndSteel.a(iblockdata, (GeneratorAccess) world, blockposition)) { +- world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData()); ++ // CraftBukkit start - Ignition by dispensing flint and steel ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition, isourceblock.getBlockPosition()).isCancelled()) { ++ world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData()); ++ } ++ // CraftBukkit end + } else if (ItemFlintAndSteel.a(iblockdata)) { + world.setTypeUpdate(blockposition, (IBlockData) iblockdata.set(BlockProperties.r, true)); + } else if (iblockdata.getBlock() instanceof BlockTNT) { +@@ -281,12 +471,57 @@ + this.dispensed = true; + World world = isourceblock.getWorld(); + BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.e().get(BlockDispenser.FACING)); ++ // CraftBukkit start ++ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); ++ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack); ++ ++ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0)); ++ if (!BlockDispenser.eventFired) { ++ world.getServer().getPluginManager().callEvent(event); ++ } ++ ++ if (event.isCancelled()) { ++ return itemstack; ++ } ++ ++ if (!event.getItem().equals(craftItem)) { ++ // Chain to handler for new item ++ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); ++ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); ++ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { ++ idispensebehavior.dispense(isourceblock, eventStack); ++ return itemstack; ++ } ++ } ++ ++ world.captureTreeGeneration = true; ++ // CraftBukkit end + + if (!ItemBoneMeal.a(itemstack, world, blockposition) && !ItemBoneMeal.a(itemstack, world, blockposition, (EnumDirection) null)) { + this.dispensed = false; + } else if (!world.isClientSide) { + world.triggerEffect(2005, blockposition, 0); + } ++ // CraftBukkit start ++ world.captureTreeGeneration = false; ++ if (world.capturedBlockStates.size() > 0) { ++ TreeType treeType = BlockSapling.treeType; ++ BlockSapling.treeType = null; ++ Location location = new Location(world.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ()); ++ List blocks = (List) world.capturedBlockStates.clone(); ++ world.capturedBlockStates.clear(); ++ StructureGrowEvent structureEvent = null; ++ if (treeType != null) { ++ structureEvent = new StructureGrowEvent(location, treeType, false, null, blocks); ++ org.bukkit.Bukkit.getPluginManager().callEvent(structureEvent); ++ } ++ if (structureEvent == null || !structureEvent.isCancelled()) { ++ for (org.bukkit.block.BlockState blockstate : blocks) { ++ blockstate.update(true); ++ } ++ } ++ } ++ // CraftBukkit end + + return itemstack; + } +@@ -296,11 +531,40 @@ + protected ItemStack a(ISourceBlock isourceblock, ItemStack itemstack) { + World world = isourceblock.getWorld(); + BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.e().get(BlockDispenser.FACING)); +- EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(world, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, (EntityLiving) null); ++ // EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(world, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, (EntityLiving) null); ++ ++ // 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((double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D)); ++ if (!BlockDispenser.eventFired) { ++ world.getServer().getPluginManager().callEvent(event); ++ } ++ ++ if (event.isCancelled()) { ++ itemstack.add(1); ++ return itemstack; ++ } ++ ++ if (!event.getItem().equals(craftItem)) { ++ itemstack.add(1); ++ // Chain to handler for new item ++ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); ++ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); ++ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { ++ idispensebehavior.dispense(isourceblock, eventStack); ++ return itemstack; ++ } ++ } ++ ++ EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(world, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), (EntityLiving) null); ++ // CraftBukkit end + + world.addEntity(entitytntprimed); + world.a((EntityHuman) null, entitytntprimed.locX, entitytntprimed.locY, entitytntprimed.locZ, SoundEffects.ENTITY_TNT_PRIMED, SoundCategory.BLOCKS, 1.0F, 1.0F); +- itemstack.subtract(1); ++ // itemstack.subtract(1); // CraftBukkit - handled above + return itemstack; + } + })); +@@ -324,6 +588,30 @@ + EnumDirection enumdirection = (EnumDirection) isourceblock.e().get(BlockDispenser.FACING); + BlockPosition blockposition = isourceblock.getBlockPosition().shift(enumdirection); + ++ // CraftBukkit start ++ org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); ++ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack); ++ ++ BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockposition.getX(), blockposition.getY(), blockposition.getZ())); ++ if (!BlockDispenser.eventFired) { ++ world.getServer().getPluginManager().callEvent(event); ++ } ++ ++ if (event.isCancelled()) { ++ return itemstack; ++ } ++ ++ if (!event.getItem().equals(craftItem)) { ++ // Chain to handler for new item ++ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); ++ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); ++ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { ++ idispensebehavior.dispense(isourceblock, eventStack); ++ return itemstack; ++ } ++ } ++ // CraftBukkit end ++ + this.dispensed = true; + if (world.isEmpty(blockposition) && BlockWitherSkull.b(world, blockposition, itemstack)) { + world.setTypeAndData(blockposition, (IBlockData) Blocks.WITHER_SKELETON_SKULL.getBlockData().set(BlockSkull.a, enumdirection.k() == EnumDirection.EnumAxis.Y ? 0 : enumdirection.opposite().get2DRotationValue() * 4), 3); +@@ -348,6 +636,30 @@ + BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.e().get(BlockDispenser.FACING)); + BlockPumpkinCarved blockpumpkincarved = (BlockPumpkinCarved) Blocks.CARVED_PUMPKIN; + ++ // CraftBukkit start ++ org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); ++ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack); ++ ++ BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockposition.getX(), blockposition.getY(), blockposition.getZ())); ++ if (!BlockDispenser.eventFired) { ++ world.getServer().getPluginManager().callEvent(event); ++ } ++ ++ if (event.isCancelled()) { ++ return itemstack; ++ } ++ ++ if (!event.getItem().equals(craftItem)) { ++ // Chain to handler for new item ++ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); ++ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); ++ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { ++ idispensebehavior.dispense(isourceblock, eventStack); ++ return itemstack; ++ } ++ } ++ // CraftBukkit end ++ + this.dispensed = true; + if (world.isEmpty(blockposition) && blockpumpkincarved.a((IWorldReader) world, blockposition)) { + if (!world.isClientSide) { diff --git a/nms-patches/IInventory.patch b/nms-patches/IInventory.patch index 4dd0f897ee..d5f8168d96 100644 --- a/nms-patches/IInventory.patch +++ b/nms-patches/IInventory.patch @@ -1,16 +1,27 @@ --- a/net/minecraft/server/IInventory.java +++ b/net/minecraft/server/IInventory.java -@@ -1,5 +1,7 @@ +@@ -1,6 +1,7 @@ package net.minecraft.server; + import java.util.Set; +import org.bukkit.craftbukkit.entity.CraftHumanEntity; // CraftBukkit -+ - public interface IInventory extends INamableTileEntity { - int getSize(); -@@ -41,4 +43,29 @@ - default int U_() { - return 0; + public interface IInventory extends Clearable { + +@@ -16,9 +17,7 @@ + + void setItem(int i, ItemStack itemstack); + +- default int getMaxStackSize() { +- return 64; +- } ++ int getMaxStackSize(); // CraftBukkit + + void update(); + +@@ -57,4 +56,29 @@ + + return false; } + + // CraftBukkit start diff --git a/nms-patches/IRecipe.patch b/nms-patches/IRecipe.patch index c6b8888258..7dc7ba4bd8 100644 --- a/nms-patches/IRecipe.patch +++ b/nms-patches/IRecipe.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/server/IRecipe.java +++ b/net/minecraft/server/IRecipe.java -@@ -33,4 +33,6 @@ - MinecraftKey getKey(); +@@ -35,4 +35,6 @@ + RecipeSerializer getRecipeSerializer(); - RecipeSerializer a(); + Recipes g(); + + org.bukkit.inventory.Recipe toBukkitRecipe(); // CraftBukkit } diff --git a/nms-patches/IWorldWriter.patch b/nms-patches/IWorldWriter.patch index 2315ab9ba8..5a7b809ac8 100644 --- a/nms-patches/IWorldWriter.patch +++ b/nms-patches/IWorldWriter.patch @@ -1,11 +1,13 @@ --- a/net/minecraft/server/IWorldWriter.java +++ b/net/minecraft/server/IWorldWriter.java -@@ -6,6 +6,8 @@ - - boolean addEntity(Entity entity); - -+ boolean addEntity(Entity entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason); // CraftBukkit +@@ -11,4 +11,10 @@ + default boolean addEntity(Entity entity) { + return false; + } + - boolean setAir(BlockPosition blockposition); - - void a(EnumSkyBlock enumskyblock, BlockPosition blockposition, int i); ++ // CraftBukkit start ++ default boolean addEntity(Entity entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) { ++ return false; ++ } ++ // CraftBukkit end + } diff --git a/nms-patches/InventoryCraftResult.patch b/nms-patches/InventoryCraftResult.patch index 4f275b25b3..949e9c0d7d 100644 --- a/nms-patches/InventoryCraftResult.patch +++ b/nms-patches/InventoryCraftResult.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/InventoryCraftResult.java +++ b/net/minecraft/server/InventoryCraftResult.java -@@ -2,12 +2,45 @@ +@@ -2,12 +2,50 @@ import java.util.Iterator; import javax.annotation.Nullable; @@ -13,7 +13,7 @@ public class InventoryCraftResult implements IInventory, RecipeHolder { private final NonNullList items; - private IRecipe b; + private IRecipe b; + // CraftBukkit start + private int maxStack = MAX_STACK; @@ -33,6 +33,11 @@ + return new java.util.ArrayList(); + } + ++ @Override ++ public int getMaxStackSize() { ++ return maxStack; ++ } ++ + public void setMaxStackSize(int size) { + maxStack = size; + } @@ -46,12 +51,3 @@ public InventoryCraftResult() { this.items = NonNullList.a(1, ItemStack.a); } -@@ -62,7 +95,7 @@ - } - - public int getMaxStackSize() { -- return 64; -+ return maxStack; // CraftBukkit - } - - public void update() {} diff --git a/nms-patches/InventoryCrafting.patch b/nms-patches/InventoryCrafting.patch index 336fdb19bf..74d658695e 100644 --- a/nms-patches/InventoryCrafting.patch +++ b/nms-patches/InventoryCrafting.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/server/InventoryCrafting.java +++ b/net/minecraft/server/InventoryCrafting.java -@@ -2,6 +2,14 @@ +@@ -1,6 +1,14 @@ + package net.minecraft.server; import java.util.Iterator; - import javax.annotation.Nullable; +// CraftBukkit start +import java.util.List; +import org.bukkit.Location; @@ -15,7 +15,7 @@ public class InventoryCrafting implements IInventory, AutoRecipeOutput { -@@ -10,6 +18,63 @@ +@@ -9,6 +17,68 @@ private final int c; public final Container container; @@ -50,6 +50,11 @@ + return (owner == null) ? null : owner.getBukkitEntity(); + } + ++ @Override ++ public int getMaxStackSize() { ++ return maxStack; ++ } ++ + public void setMaxStackSize(int size) { + maxStack = size; + resultInventory.setMaxStackSize(size); diff --git a/nms-patches/InventoryEnderChest.patch b/nms-patches/InventoryEnderChest.patch index c31016ff61..9e6816be1d 100644 --- a/nms-patches/InventoryEnderChest.patch +++ b/nms-patches/InventoryEnderChest.patch @@ -23,7 +23,7 @@ - public InventoryEnderChest() { + public InventoryEnderChest(EntityHuman owner) { - super(new ChatMessage("container.enderchest", new Object[0]), 27); + super(27); + this.owner = owner; + // CraftBukkit end } diff --git a/nms-patches/InventoryHorseChest.patch b/nms-patches/InventoryHorseChest.patch deleted file mode 100644 index 05e5572c22..0000000000 --- a/nms-patches/InventoryHorseChest.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- a/net/minecraft/server/InventoryHorseChest.java -+++ b/net/minecraft/server/InventoryHorseChest.java -@@ -2,7 +2,9 @@ - - public class InventoryHorseChest extends InventorySubcontainer { - -- public InventoryHorseChest(IChatBaseComponent ichatbasecomponent, int i) { -- super(ichatbasecomponent, i); -+ // CraftBukkit start -+ public InventoryHorseChest(IChatBaseComponent ichatbasecomponent, int i, EntityHorseAbstract owner) { -+ super(ichatbasecomponent, i, (org.bukkit.entity.AbstractHorse) owner.getBukkitEntity()); -+ // CraftBukkit end - } - } diff --git a/nms-patches/InventoryLargeChest.patch b/nms-patches/InventoryLargeChest.patch index f4fdba28bc..4422854d3d 100644 --- a/nms-patches/InventoryLargeChest.patch +++ b/nms-patches/InventoryLargeChest.patch @@ -1,9 +1,8 @@ --- a/net/minecraft/server/InventoryLargeChest.java +++ b/net/minecraft/server/InventoryLargeChest.java -@@ -1,6 +1,14 @@ +@@ -1,10 +1,61 @@ package net.minecraft.server; - import javax.annotation.Nullable; +// CraftBukkit start +import java.util.ArrayList; +import java.util.List; @@ -12,12 +11,11 @@ +import org.bukkit.craftbukkit.entity.CraftHumanEntity; +import org.bukkit.entity.HumanEntity; +// CraftBukkit end ++ + public class InventoryLargeChest implements IInventory { - public class InventoryLargeChest implements ITileInventory { - -@@ -8,6 +16,48 @@ - public final ITileInventory left; - public final ITileInventory right; + public final IInventory left; + public final IInventory right; + // CraftBukkit start - add fields and methods + public List transaction = new java.util.ArrayList(); @@ -61,15 +59,15 @@ + } + // CraftBukkit end + - public InventoryLargeChest(IChatBaseComponent ichatbasecomponent, ITileInventory itileinventory, ITileInventory itileinventory1) { - this.a = ichatbasecomponent; - if (itileinventory == null) { -@@ -75,7 +125,7 @@ - } + public InventoryLargeChest(IInventory iinventory, IInventory iinventory1) { + if (iinventory == null) { + iinventory = iinventory1; +@@ -59,7 +110,7 @@ + @Override public int getMaxStackSize() { - return this.left.getMaxStackSize(); + return Math.min(this.left.getMaxStackSize(), this.right.getMaxStackSize()); // CraftBukkit - check both sides } - public void update() { + @Override diff --git a/nms-patches/InventoryMerchant.patch b/nms-patches/InventoryMerchant.patch index f46377c3b1..0d6e606108 100644 --- a/nms-patches/InventoryMerchant.patch +++ b/nms-patches/InventoryMerchant.patch @@ -8,15 +8,15 @@ +import java.util.List; +import org.bukkit.Location; +import org.bukkit.craftbukkit.entity.CraftHumanEntity; -+import org.bukkit.craftbukkit.entity.CraftVillager; ++import org.bukkit.craftbukkit.entity.CraftAbstractVillager; +import org.bukkit.entity.HumanEntity; +// CraftBukkit end public class InventoryMerchant implements IInventory { -@@ -11,6 +18,40 @@ - private MerchantRecipe recipe; +@@ -12,6 +19,45 @@ public int selectedIndex; + private int e; + // CraftBukkit start - add fields and methods + public List transaction = new java.util.ArrayList(); @@ -38,12 +38,17 @@ + return transaction; + } + ++ @Override ++ public int getMaxStackSize() { ++ return maxStack; ++ } ++ + public void setMaxStackSize(int i) { + maxStack = i; + } + + public org.bukkit.inventory.InventoryHolder getOwner() { -+ return (merchant instanceof EntityVillager) ? (CraftVillager) ((EntityVillager) this.merchant).getBukkitEntity() : null; ++ return (merchant instanceof EntityVillager) ? (CraftAbstractVillager) ((EntityVillager) this.merchant).getBukkitEntity() : null; + } + + @Override @@ -52,24 +57,6 @@ + } + // CraftBukkit end + - public InventoryMerchant(EntityHuman entityhuman, IMerchant imerchant) { + public InventoryMerchant(IMerchant imerchant) { this.itemsInSlots = NonNullList.a(3, ItemStack.a); - this.player = entityhuman; -@@ -78,7 +119,7 @@ - } - - public IChatBaseComponent getDisplayName() { -- return new ChatMessage("mob.villager", new Object[0]); -+ return merchant.getScoreboardDisplayName(); // CraftBukkit - } - - public boolean hasCustomName() { -@@ -91,7 +132,7 @@ - } - - public int getMaxStackSize() { -- return 64; -+ return maxStack; // CraftBukkit - } - - public boolean a(EntityHuman entityhuman) { + this.merchant = imerchant; diff --git a/nms-patches/InventorySubcontainer.patch b/nms-patches/InventorySubcontainer.patch index 237b30c70c..961e76a30b 100644 --- a/nms-patches/InventorySubcontainer.patch +++ b/nms-patches/InventorySubcontainer.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/InventorySubcontainer.java +++ b/net/minecraft/server/InventorySubcontainer.java -@@ -5,6 +5,13 @@ +@@ -4,13 +4,65 @@ + import java.util.Iterator; import java.util.List; - import javax.annotation.Nullable; +// CraftBukkit start +import java.util.List; @@ -13,10 +13,9 @@ + public class InventorySubcontainer implements IInventory, AutoRecipeOutput { - private final IChatBaseComponent a; -@@ -13,7 +20,47 @@ - private List d; - private IChatBaseComponent e; + private final int a; + public final NonNullList items; + private List c; + // CraftBukkit start - add fields and methods + public List transaction = new java.util.ArrayList(); @@ -39,6 +38,11 @@ + return transaction; + } + ++ @Override ++ public int getMaxStackSize() { ++ return maxStack; ++ } ++ + public void setMaxStackSize(int i) { + maxStack = i; + } @@ -52,13 +56,13 @@ + return null; + } + - public InventorySubcontainer(IChatBaseComponent ichatbasecomponent, int i) { -+ this(ichatbasecomponent, i, null); + public InventorySubcontainer(int i) { ++ this(i, null); + } + -+ public InventorySubcontainer(IChatBaseComponent ichatbasecomponent, int i, org.bukkit.inventory.InventoryHolder owner) { ++ public InventorySubcontainer(int i, org.bukkit.inventory.InventoryHolder owner) { + this.bukkitOwner = owner; + // CraftBukkit end - this.a = ichatbasecomponent; - this.b = i; + this.a = i; this.items = NonNullList.a(i, ItemStack.a); + } diff --git a/nms-patches/ItemArmor.patch b/nms-patches/ItemArmor.patch index c9babe4301..29cae8763b 100644 --- a/nms-patches/ItemArmor.patch +++ b/nms-patches/ItemArmor.patch @@ -12,9 +12,9 @@ public class ItemArmor extends Item { private static final UUID[] k = new UUID[] { UUID.fromString("845DB27C-C624-495F-8C9F-6020A9A58B6B"), UUID.fromString("D8499B04-0E66-4726-AB29-64469D734E0D"), UUID.fromString("9F3D476D-C118-4544-8365-64846904B48E"), UUID.fromString("2AD3F246-FEE1-4E67-B886-69FD380BB150")}; -@@ -29,6 +34,32 @@ +@@ -30,6 +35,32 @@ EntityLiving entityliving = (EntityLiving) list.get(0); - EnumItemSlot enumitemslot = EntityInsentient.e(itemstack); + EnumItemSlot enumitemslot = EntityInsentient.h(itemstack); ItemStack itemstack1 = itemstack.cloneAndSubtract(1); + // CraftBukkit start + World world = isourceblock.getWorld(); diff --git a/nms-patches/ItemArmorStand.patch b/nms-patches/ItemArmorStand.patch index 08587855cb..9ede4eab9c 100644 --- a/nms-patches/ItemArmorStand.patch +++ b/nms-patches/ItemArmorStand.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/server/ItemArmorStand.java +++ b/net/minecraft/server/ItemArmorStand.java -@@ -40,6 +40,11 @@ +@@ -41,6 +41,11 @@ entityarmorstand.setPositionRotation(d0 + 0.5D, d1, d2 + 0.5D, f, 0.0F); this.a(entityarmorstand, world.random); - EntityTypes.a(world, itemactioncontext.getEntity(), entityarmorstand, itemstack.getTag()); + EntityTypes.a(world, itemactioncontext.getEntity(), (Entity) entityarmorstand, itemstack.getTag()); + // CraftBukkit start + if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPlaceEvent(itemactioncontext, entityarmorstand).isCancelled()) { + return EnumInteractionResult.FAIL; diff --git a/nms-patches/ItemBlock.patch b/nms-patches/ItemBlock.patch index ac90114c2a..e5a3fcf6f2 100644 --- a/nms-patches/ItemBlock.patch +++ b/nms-patches/ItemBlock.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/server/ItemBlock.java +++ b/net/minecraft/server/ItemBlock.java -@@ -2,6 +2,11 @@ - +@@ -3,6 +3,11 @@ + import java.util.Iterator; import java.util.Map; import javax.annotation.Nullable; +// CraftBukkit start @@ -12,24 +12,24 @@ public class ItemBlock extends Item { -@@ -45,7 +50,7 @@ +@@ -55,7 +60,7 @@ - SoundEffectType soundeffecttype = block.getStepSound(); - -- world.a(entityhuman, blockposition, soundeffecttype.e(), SoundCategory.BLOCKS, (soundeffecttype.a() + 1.0F) / 2.0F, soundeffecttype.b() * 0.8F); -+ // world.a(entityhuman, blockposition, soundeffecttype.e(), SoundCategory.BLOCKS, (soundeffecttype.a() + 1.0F) / 2.0F, soundeffecttype.b() * 0.8F); // CraftBukkit - SPIGOT-1288 - itemstack.subtract(1); - return EnumInteractionResult.SUCCESS; - } -@@ -64,7 +69,15 @@ - } + SoundEffectType soundeffecttype = iblockdata1.r(); +- world.a(entityhuman, blockposition, this.a(iblockdata1), SoundCategory.BLOCKS, (soundeffecttype.a() + 1.0F) / 2.0F, soundeffecttype.b() * 0.8F); ++ // world.a(entityhuman, blockposition, this.a(iblockdata1), SoundCategory.BLOCKS, (soundeffecttype.a() + 1.0F) / 2.0F, soundeffecttype.b() * 0.8F); + itemstack.subtract(1); + return EnumInteractionResult.SUCCESS; + } +@@ -120,8 +125,15 @@ protected boolean b(BlockActionContext blockactioncontext, IBlockData iblockdata) { -- return iblockdata.canPlace(blockactioncontext.getWorld(), blockactioncontext.getClickPosition()) && blockactioncontext.getWorld().a(iblockdata, blockactioncontext.getClickPosition()); + EntityHuman entityhuman = blockactioncontext.getEntity(); + VoxelShapeCollision voxelshapecollision = entityhuman == null ? VoxelShapeCollision.a() : VoxelShapeCollision.a((Entity) entityhuman); + // CraftBukkit start - store default return -+ boolean defaultReturn = iblockdata.canPlace(blockactioncontext.getWorld(), blockactioncontext.getClickPosition()) && blockactioncontext.getWorld().a(iblockdata, blockactioncontext.getClickPosition()); ++ boolean defaultReturn = (!this.d() || iblockdata.canPlace(blockactioncontext.getWorld(), blockactioncontext.getClickPosition())) && blockactioncontext.getWorld().a(iblockdata, blockactioncontext.getClickPosition(), voxelshapecollision); + org.bukkit.entity.Player player = (blockactioncontext.getEntity() instanceof EntityPlayer) ? (org.bukkit.entity.Player) blockactioncontext.getEntity().getBukkitEntity() : null; -+ + +- return (!this.d() || iblockdata.canPlace(blockactioncontext.getWorld(), blockactioncontext.getClickPosition())) && blockactioncontext.getWorld().a(iblockdata, blockactioncontext.getClickPosition(), voxelshapecollision); + BlockCanBuildEvent event = new BlockCanBuildEvent(CraftBlock.at(blockactioncontext.getWorld(), blockactioncontext.getClickPosition()), player, CraftBlockData.fromData(iblockdata), defaultReturn); + blockactioncontext.getWorld().getServer().getPluginManager().callEvent(event); + @@ -37,4 +37,4 @@ + // CraftBukkit end } - protected boolean a(BlockActionContext blockactioncontext, IBlockData iblockdata) { + protected boolean d() { diff --git a/nms-patches/ItemBoat.patch b/nms-patches/ItemBoat.patch index e9510c67fe..f8539e2eb3 100644 --- a/nms-patches/ItemBoat.patch +++ b/nms-patches/ItemBoat.patch @@ -1,20 +1,21 @@ --- a/net/minecraft/server/ItemBoat.java +++ b/net/minecraft/server/ItemBoat.java -@@ -52,6 +52,13 @@ - if (flag) { - return new InteractionResultWrapper<>(EnumInteractionResult.PASS, itemstack); - } else if (movingobjectposition.type == MovingObjectPosition.EnumMovingObjectType.BLOCK) { +@@ -41,6 +41,14 @@ + } + + if (movingobjectposition.getType() == MovingObjectPosition.EnumMovingObjectType.BLOCK) { + // CraftBukkit start - Boat placement -+ org.bukkit.event.player.PlayerInteractEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent(entityhuman, org.bukkit.event.block.Action.RIGHT_CLICK_BLOCK, movingobjectposition.getBlockPosition(), movingobjectposition.direction, itemstack, enumhand); ++ MovingObjectPositionBlock movingobjectpositionblock = (MovingObjectPositionBlock) movingobjectposition; ++ org.bukkit.event.player.PlayerInteractEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent(entityhuman, org.bukkit.event.block.Action.RIGHT_CLICK_BLOCK, movingobjectpositionblock.getBlockPosition(), movingobjectpositionblock.getDirection(), itemstack, enumhand); + + if (event.isCancelled()) { + return new InteractionResultWrapper(EnumInteractionResult.PASS, itemstack); + } + // CraftBukkit end - BlockPosition blockposition = movingobjectposition.getBlockPosition(); - Block block = world.getType(blockposition).getBlock(); - EntityBoat entityboat = new EntityBoat(world, movingobjectposition.pos.x, movingobjectposition.pos.y, movingobjectposition.pos.z); -@@ -62,7 +69,7 @@ + EntityBoat entityboat = new EntityBoat(world, movingobjectposition.getPos().x, movingobjectposition.getPos().y, movingobjectposition.getPos().z); + + entityboat.setType(this.b); +@@ -49,7 +57,7 @@ return new InteractionResultWrapper<>(EnumInteractionResult.FAIL, itemstack); } else { if (!world.isClientSide) { diff --git a/nms-patches/ItemBow.patch b/nms-patches/ItemBow.patch index 77a93494bd..bad2f67dc1 100644 --- a/nms-patches/ItemBow.patch +++ b/nms-patches/ItemBow.patch @@ -1,23 +1,23 @@ --- a/net/minecraft/server/ItemBow.java +++ b/net/minecraft/server/ItemBow.java -@@ -4,12 +4,16 @@ +@@ -6,12 +6,16 @@ public ItemBow(Item.Info item_info) { super(item_info); + // CraftBukkit start - obfuscator went a little crazy + /* this.a(new MinecraftKey("pull"), (itemstack, world, entityliving) -> { - return entityliving == null ? 0.0F : (entityliving.cW().getItem() != Items.BOW ? 0.0F : (float) (itemstack.k() - entityliving.cX()) / 20.0F); + return entityliving == null ? 0.0F : (entityliving.dl().getItem() != Items.BOW ? 0.0F : (float) (itemstack.k() - entityliving.dm()) / 20.0F); }); this.a(new MinecraftKey("pulling"), (itemstack, world, entityliving) -> { - return entityliving != null && entityliving.isHandRaised() && entityliving.cW() == itemstack ? 1.0F : 0.0F; + return entityliving != null && entityliving.isHandRaised() && entityliving.dl() == itemstack ? 1.0F : 0.0F; }); + */ + // CraftBukkit end } - private ItemStack a(EntityHuman entityhuman) { -@@ -75,13 +79,29 @@ + @Override +@@ -56,6 +60,13 @@ if (EnchantmentManager.getEnchantmentLevel(Enchantments.ARROW_FIRE, itemstack) > 0) { entityarrow.setOnFire(100); } @@ -29,8 +29,9 @@ + } + // CraftBukkit end - itemstack.damage(1, entityhuman); - if (flag1 || entityhuman.abilities.canInstantlyBuild && (itemstack1.getItem() == Items.SPECTRAL_ARROW || itemstack1.getItem() == Items.TIPPED_ARROW)) { + itemstack.damage(1, entityhuman, (entityhuman1) -> { + entityhuman1.d(entityhuman.getRaisedHand()); +@@ -64,7 +75,16 @@ entityarrow.fromPlayer = EntityArrow.PickupStatus.CREATIVE_ONLY; } diff --git a/nms-patches/ItemBucket.patch b/nms-patches/ItemBucket.patch index a234fb6bf4..0e1a0aef3e 100644 --- a/nms-patches/ItemBucket.patch +++ b/nms-patches/ItemBucket.patch @@ -14,7 +14,7 @@ public class ItemBucket extends Item { -@@ -26,12 +33,21 @@ +@@ -30,12 +37,21 @@ if (this.fluidType == FluidTypes.EMPTY) { iblockdata = world.getType(blockposition); if (iblockdata.getBlock() instanceof IFluidSource) { @@ -37,16 +37,16 @@ if (!world.isClientSide) { CriterionTriggers.j.a((EntityPlayer) entityhuman, new ItemStack(fluidtype.b())); -@@ -46,7 +62,7 @@ +@@ -50,7 +66,7 @@ iblockdata = world.getType(blockposition); - BlockPosition blockposition1 = this.a(iblockdata, blockposition, movingobjectposition); + BlockPosition blockposition1 = iblockdata.getBlock() instanceof IFluidContainer && this.fluidType == FluidTypes.WATER ? blockposition : movingobjectpositionblock.getBlockPosition().shift(movingobjectpositionblock.getDirection()); -- if (this.a(entityhuman, world, blockposition1, movingobjectposition)) { -+ if (this.a(entityhuman, world, blockposition1, movingobjectposition, movingobjectposition.direction, blockposition, itemstack)) { // CraftBukkit +- if (this.a(entityhuman, world, blockposition1, movingobjectpositionblock)) { ++ if (this.a(entityhuman, world, blockposition1, movingobjectpositionblock, movingobjectpositionblock.getDirection(), blockposition, itemstack)) { // CraftBukkit this.a(world, itemstack, blockposition1); if (entityhuman instanceof EntityPlayer) { CriterionTriggers.y.a((EntityPlayer) entityhuman, blockposition1, itemstack); -@@ -76,16 +92,19 @@ +@@ -74,16 +90,19 @@ public void a(World world, ItemStack itemstack, BlockPosition blockposition) {} @@ -70,26 +70,26 @@ } return itemstack; -@@ -93,7 +112,13 @@ +@@ -91,7 +110,13 @@ } } + // CraftBukkit start - public boolean a(@Nullable EntityHuman entityhuman, World world, BlockPosition blockposition, @Nullable MovingObjectPosition movingobjectposition) { -+ return a(entityhuman, world, blockposition, movingobjectposition, null, null, null); + public boolean a(@Nullable EntityHuman entityhuman, World world, BlockPosition blockposition, @Nullable MovingObjectPositionBlock movingobjectpositionblock) { ++ return a(entityhuman, world, blockposition, movingobjectpositionblock, null, null, null); + } + -+ public boolean a(EntityHuman entityhuman, World world, BlockPosition blockposition, @Nullable MovingObjectPosition movingobjectposition, EnumDirection enumdirection, BlockPosition clicked, ItemStack itemstack) { ++ public boolean a(EntityHuman entityhuman, World world, BlockPosition blockposition, @Nullable MovingObjectPositionBlock movingobjectpositionblock, EnumDirection enumdirection, BlockPosition clicked, ItemStack itemstack) { + // CraftBukkit end if (!(this.fluidType instanceof FluidTypeFlowing)) { return false; } else { -@@ -103,8 +128,18 @@ +@@ -101,8 +126,18 @@ boolean flag1 = material.isReplaceable(); if (!world.isEmpty(blockposition) && !flag && !flag1 && (!(iblockdata.getBlock() instanceof IFluidContainer) || !((IFluidContainer) iblockdata.getBlock()).canPlace(world, blockposition, iblockdata, this.fluidType))) { -- return movingobjectposition == null ? false : this.a(entityhuman, world, movingobjectposition.getBlockPosition().shift(movingobjectposition.direction), (MovingObjectPosition) null); -+ return movingobjectposition == null ? false : this.a(entityhuman, world, movingobjectposition.getBlockPosition().shift(movingobjectposition.direction), (MovingObjectPosition) null, enumdirection, clicked, itemstack); // CraftBukkit +- return movingobjectpositionblock == null ? false : this.a(entityhuman, world, movingobjectpositionblock.getBlockPosition().shift(movingobjectpositionblock.getDirection()), (MovingObjectPositionBlock) null); ++ return movingobjectpositionblock == null ? false : this.a(entityhuman, world, movingobjectpositionblock.getBlockPosition().shift(movingobjectpositionblock.getDirection()), (MovingObjectPositionBlock) null, enumdirection, clicked, itemstack); // CraftBukkit } else { + // CraftBukkit start + if (entityhuman != null) { diff --git a/nms-patches/ItemChorusFruit.patch b/nms-patches/ItemChorusFruit.patch index f316754503..c8ea31302c 100644 --- a/nms-patches/ItemChorusFruit.patch +++ b/nms-patches/ItemChorusFruit.patch @@ -9,11 +9,11 @@ +import org.bukkit.event.player.PlayerTeleportEvent; +// CraftBukkit end + - public class ItemChorusFruit extends ItemFood { + public class ItemChorusFruit extends Item { - public ItemChorusFruit(int i, float f, Item.Info item_info) { -@@ -19,6 +25,20 @@ - double d4 = MathHelper.a(entityliving.locY + (double) (entityliving.getRandom().nextInt(16) - 8), 0.0D, (double) (world.ab() - 1)); + public ItemChorusFruit(Item.Info item_info) { +@@ -20,6 +26,20 @@ + double d4 = MathHelper.a(entityliving.locY + (double) (entityliving.getRandom().nextInt(16) - 8), 0.0D, (double) (world.getHeight() - 1)); double d5 = entityliving.locZ + (entityliving.getRandom().nextDouble() - 0.5D) * 16.0D; + // CraftBukkit start diff --git a/nms-patches/ItemCrossbow.patch b/nms-patches/ItemCrossbow.patch new file mode 100644 index 0000000000..d69f560cce --- /dev/null +++ b/nms-patches/ItemCrossbow.patch @@ -0,0 +1,49 @@ +--- a/net/minecraft/server/ItemCrossbow.java ++++ b/net/minecraft/server/ItemCrossbow.java +@@ -12,6 +12,8 @@ + + public ItemCrossbow(Item.Info item_info) { + super(item_info); ++ // CraftBukkit start - obfuscator went a little crazy ++ /* + this.a(new MinecraftKey("pull"), (itemstack, world, entityliving) -> { + return entityliving != null && itemstack.getItem() == this ? (d(itemstack) ? 0.0F : (float) (itemstack.k() - entityliving.dm()) / (float) e(itemstack)) : 0.0F; + }); +@@ -24,6 +26,8 @@ + this.a(new MinecraftKey("firework"), (itemstack, world, entityliving) -> { + return entityliving != null && d(itemstack) && a(itemstack, Items.FIREWORK_ROCKET) ? 1.0F : 0.0F; + }); ++ */ ++ // CraftBukkit end + } + + @Override +@@ -203,11 +207,27 @@ + vector3fa.a(quaternion); + ((IProjectile) object).shoot((double) vector3fa.a(), (double) vector3fa.b(), (double) vector3fa.c(), f1, f2); + } ++ // CraftBukkit start ++ org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(entityliving, itemstack, (Entity) object, f); ++ if (event.isCancelled()) { ++ event.getProjectile().remove(); ++ return; ++ } ++ // CraftBukkit end + + itemstack.damage(flag1 ? 3 : 1, entityliving, (entityliving1) -> { + entityliving1.d(enumhand); + }); +- world.addEntity((Entity) object); ++ // CraftBukkit start ++ if (event.getProjectile() == ((Entity) object).getBukkitEntity()) { ++ if (!world.addEntity((Entity) object)) { ++ if (entityliving instanceof EntityPlayer) { ++ ((EntityPlayer) entityliving).getBukkitEntity().updateInventory(); ++ } ++ return; ++ } ++ } ++ // CraftBukkit end + world.a((EntityHuman) null, entityliving.locX, entityliving.locY, entityliving.locZ, SoundEffects.ITEM_CROSSBOW_SHOOT, SoundCategory.PLAYERS, 1.0F, f); + } + } diff --git a/nms-patches/ItemDye.patch b/nms-patches/ItemDye.patch index ab3d4cd2d1..8a51051561 100644 --- a/nms-patches/ItemDye.patch +++ b/nms-patches/ItemDye.patch @@ -9,10 +9,10 @@ public class ItemDye extends Item { private static final Map a = Maps.newEnumMap(EnumColor.class); -@@ -19,7 +21,17 @@ +@@ -20,7 +22,17 @@ EntitySheep entitysheep = (EntitySheep) entityliving; - if (!entitysheep.isSheared() && entitysheep.getColor() != this.b) { + if (entitysheep.isAlive() && !entitysheep.isSheared() && entitysheep.getColor() != this.b) { - entitysheep.setColor(this.b); + // CraftBukkit start + byte bColor = (byte) this.b.getColorIndex(); diff --git a/nms-patches/ItemEndCrystal.patch b/nms-patches/ItemEndCrystal.patch index 6173162a83..174120bb2e 100644 --- a/nms-patches/ItemEndCrystal.patch +++ b/nms-patches/ItemEndCrystal.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/ItemEndCrystal.java +++ b/net/minecraft/server/ItemEndCrystal.java -@@ -33,6 +33,11 @@ +@@ -34,6 +34,11 @@ EntityEnderCrystal entityendercrystal = new EntityEnderCrystal(world, d0 + 0.5D, d1, d2 + 0.5D); entityendercrystal.setShowingBottom(false); @@ -11,4 +11,4 @@ + // CraftBukkit end world.addEntity(entityendercrystal); if (world.worldProvider instanceof WorldProviderTheEnd) { - EnderDragonBattle enderdragonbattle = ((WorldProviderTheEnd) world.worldProvider).r(); + EnderDragonBattle enderdragonbattle = ((WorldProviderTheEnd) world.worldProvider).q(); diff --git a/nms-patches/ItemEnderPearl.patch b/nms-patches/ItemEnderPearl.patch index 8dafd4fa1f..46ac954367 100644 --- a/nms-patches/ItemEnderPearl.patch +++ b/nms-patches/ItemEnderPearl.patch @@ -1,35 +1,38 @@ --- a/net/minecraft/server/ItemEnderPearl.java +++ b/net/minecraft/server/ItemEnderPearl.java -@@ -9,18 +9,26 @@ +@@ -10,20 +10,28 @@ public InteractionResultWrapper a(World world, EntityHuman entityhuman, EnumHand enumhand) { ItemStack itemstack = entityhuman.b(enumhand); +- if (!entityhuman.abilities.canInstantlyBuild) { +- itemstack.subtract(1); +- } +- +- world.a((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.ENTITY_ENDER_PEARL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemEnderPearl.i.nextFloat() * 0.4F + 0.8F)); +- entityhuman.getCooldownTracker().a(this, 20); + // CraftBukkit start - change order -+ if (!world.isClientSide) { -+ EntityEnderPearl entityenderpearl = new EntityEnderPearl(world, entityhuman); -+ -+ entityenderpearl.a(entityhuman, entityhuman.pitch, entityhuman.yaw, 0.0F, 1.5F, 1.0F); + if (!world.isClientSide) { + EntityEnderPearl entityenderpearl = new EntityEnderPearl(world, entityhuman); + + entityenderpearl.setItem(itemstack); + entityenderpearl.a(entityhuman, entityhuman.pitch, entityhuman.yaw, 0.0F, 1.5F, 1.0F); +- world.addEntity(entityenderpearl); + if (!world.addEntity(entityenderpearl)) { + if (entityhuman instanceof EntityPlayer) { + ((EntityPlayer) entityhuman).getBukkitEntity().updateInventory(); + } + return new InteractionResultWrapper(EnumInteractionResult.FAIL, itemstack); + } -+ } -+ - if (!entityhuman.abilities.canInstantlyBuild) { - itemstack.subtract(1); } - world.a((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.ENTITY_ENDER_PEARL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemEnderPearl.i.nextFloat() * 0.4F + 0.8F)); - entityhuman.getCooldownTracker().a(this, 20); -- if (!world.isClientSide) { -- EntityEnderPearl entityenderpearl = new EntityEnderPearl(world, entityhuman); -- -- entityenderpearl.a(entityhuman, entityhuman.pitch, entityhuman.yaw, 0.0F, 1.5F, 1.0F); -- world.addEntity(entityenderpearl); -- } ++ if (!entityhuman.abilities.canInstantlyBuild) { ++ itemstack.subtract(1); ++ } ++ ++ world.a((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.ENTITY_ENDER_PEARL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemEnderPearl.i.nextFloat() * 0.4F + 0.8F)); ++ entityhuman.getCooldownTracker().a(this, 20); + // CraftBukkit end - ++ entityhuman.b(StatisticList.ITEM_USED.b(this)); return new InteractionResultWrapper<>(EnumInteractionResult.SUCCESS, itemstack); + } diff --git a/nms-patches/ItemFireball.patch b/nms-patches/ItemFireball.patch index b102662b8b..c2cd1e497d 100644 --- a/nms-patches/ItemFireball.patch +++ b/nms-patches/ItemFireball.patch @@ -1,17 +1,31 @@ --- a/net/minecraft/server/ItemFireball.java +++ b/net/minecraft/server/ItemFireball.java -@@ -15,6 +15,14 @@ - BlockPosition blockposition = itemactioncontext.getClickPosition().shift(itemactioncontext.getClickedFace()); +@@ -18,12 +18,28 @@ - if (world.getType(blockposition).isAir()) { -+ // CraftBukkit start - fire BlockIgniteEvent -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition, org.bukkit.event.block.BlockIgniteEvent.IgniteCause.FIREBALL, itemactioncontext.getEntity()).isCancelled()) { -+ if (!itemactioncontext.getEntity().abilities.canInstantlyBuild) { -+ itemactioncontext.getItemStack().subtract(1); + if (iblockdata.getBlock() == Blocks.CAMPFIRE) { + if (!(Boolean) iblockdata.get(BlockCampfire.b) && !(Boolean) iblockdata.get(BlockCampfire.d)) { ++ // CraftBukkit start - fire BlockIgniteEvent ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition, org.bukkit.event.block.BlockIgniteEvent.IgniteCause.FIREBALL, itemactioncontext.getEntity()).isCancelled()) { ++ if (!itemactioncontext.getEntity().abilities.canInstantlyBuild) { ++ itemactioncontext.getItemStack().subtract(1); ++ } ++ return EnumInteractionResult.PASS; + } -+ return EnumInteractionResult.PASS; -+ } -+ // CraftBukkit end - world.a((EntityHuman) null, blockposition, SoundEffects.ITEM_FIRECHARGE_USE, SoundCategory.BLOCKS, 1.0F, (ItemFireball.i.nextFloat() - ItemFireball.i.nextFloat()) * 0.2F + 1.0F); - world.setTypeUpdate(blockposition, ((BlockFire) Blocks.FIRE).a((IBlockAccess) world, blockposition)); - } ++ // CraftBukkit end + this.a(world, blockposition); + world.setTypeUpdate(blockposition, (IBlockData) iblockdata.set(BlockCampfire.b, true)); + } + } else { + blockposition = blockposition.shift(itemactioncontext.getClickedFace()); + if (world.getType(blockposition).isAir()) { ++ // CraftBukkit start - fire BlockIgniteEvent ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition, org.bukkit.event.block.BlockIgniteEvent.IgniteCause.FIREBALL, itemactioncontext.getEntity()).isCancelled()) { ++ if (!itemactioncontext.getEntity().abilities.canInstantlyBuild) { ++ itemactioncontext.getItemStack().subtract(1); ++ } ++ return EnumInteractionResult.PASS; ++ } ++ // CraftBukkit end + this.a(world, blockposition); + world.setTypeUpdate(blockposition, ((BlockFire) Blocks.FIRE).a((IBlockAccess) world, blockposition)); + } diff --git a/nms-patches/ItemFish.patch b/nms-patches/ItemFish.patch deleted file mode 100644 index 8b52880fd0..0000000000 --- a/nms-patches/ItemFish.patch +++ /dev/null @@ -1,17 +0,0 @@ ---- a/net/minecraft/server/ItemFish.java -+++ b/net/minecraft/server/ItemFish.java -@@ -25,9 +25,11 @@ - ItemFish.EnumFish itemfish_enumfish = ItemFish.EnumFish.a(itemstack); - - if (itemfish_enumfish == ItemFish.EnumFish.PUFFERFISH) { -- entityhuman.addEffect(new MobEffect(MobEffects.POISON, 1200, 3)); -- entityhuman.addEffect(new MobEffect(MobEffects.HUNGER, 300, 2)); -- entityhuman.addEffect(new MobEffect(MobEffects.CONFUSION, 300, 1)); -+ // CraftBukkit start -+ entityhuman.addEffect(new MobEffect(MobEffects.POISON, 1200, 3), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.FOOD); -+ entityhuman.addEffect(new MobEffect(MobEffects.HUNGER, 300, 2), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.FOOD); -+ entityhuman.addEffect(new MobEffect(MobEffects.CONFUSION, 300, 1), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.FOOD); -+ // CraftBukkit end - } - - super.a(itemstack, world, entityhuman); diff --git a/nms-patches/ItemFishingRod.patch b/nms-patches/ItemFishingRod.patch index f8d1d9d818..908677f5aa 100644 --- a/nms-patches/ItemFishingRod.patch +++ b/nms-patches/ItemFishingRod.patch @@ -22,21 +22,20 @@ + // CraftBukkit end } - public InteractionResultWrapper a(World world, EntityHuman entityhuman, EnumHand enumhand) { -@@ -30,7 +36,7 @@ + @Override +@@ -36,12 +42,23 @@ entityhuman.a(enumhand); world.a((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.ENTITY_FISHING_BOBBER_RETRIEVE, SoundCategory.NEUTRAL, 1.0F, 0.4F / (ItemFishingRod.i.nextFloat() * 0.4F + 0.8F)); } else { - world.a((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.ENTITY_FISHING_BOBBER_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemFishingRod.i.nextFloat() * 0.4F + 0.8F)); + // world.a((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.ENTITY_FISHING_BOBBER_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemFishingRod.i.nextFloat() * 0.4F + 0.8F)); if (!world.isClientSide) { - EntityFishingHook entityfishinghook = new EntityFishingHook(world, entityhuman); - int j = EnchantmentManager.c(itemstack); -@@ -45,6 +51,17 @@ - entityfishinghook.b(k); - } + i = EnchantmentManager.c(itemstack); + int j = EnchantmentManager.b(itemstack); +- world.addEntity(new EntityFishingHook(entityhuman, world, j, i)); + // CraftBukkit start ++ EntityFishingHook entityfishinghook = new EntityFishingHook(entityhuman, world, j, i); + PlayerFishEvent playerFishEvent = new PlayerFishEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), null, (org.bukkit.entity.FishHook) entityfishinghook.getBukkitEntity(), PlayerFishEvent.State.FISHING); + world.getServer().getPluginManager().callEvent(playerFishEvent); + @@ -45,8 +44,8 @@ + return new InteractionResultWrapper(EnumInteractionResult.PASS, itemstack); + } + world.a((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.ENTITY_FISHING_BOBBER_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemFishingRod.i.nextFloat() * 0.4F + 0.8F)); ++ world.addEntity(entityfishinghook); + // CraftBukkit end -+ - world.addEntity(entityfishinghook); } + entityhuman.a(enumhand); diff --git a/nms-patches/ItemFlintAndSteel.patch b/nms-patches/ItemFlintAndSteel.patch index 5c63e8fab3..a872da3f58 100644 --- a/nms-patches/ItemFlintAndSteel.patch +++ b/nms-patches/ItemFlintAndSteel.patch @@ -1,15 +1,17 @@ --- a/net/minecraft/server/ItemFlintAndSteel.java +++ b/net/minecraft/server/ItemFlintAndSteel.java -@@ -14,6 +14,12 @@ - BlockPosition blockposition = itemactioncontext.getClickPosition().shift(itemactioncontext.getClickedFace()); +@@ -17,6 +17,14 @@ + IBlockData iblockdata; - if (a((GeneratorAccess) world, blockposition)) { + if (a(world.getType(blockposition1), (GeneratorAccess) world, blockposition1)) { + // CraftBukkit start - Store the clicked block -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition, org.bukkit.event.block.BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL, entityhuman).isCancelled()) { -+ itemactioncontext.getItemStack().damage(1, entityhuman); ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition1, org.bukkit.event.block.BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL, entityhuman).isCancelled()) { ++ itemactioncontext.getItemStack().damage(1, entityhuman, (entityhuman1) -> { ++ entityhuman1.d(itemactioncontext.n()); ++ }); + return EnumInteractionResult.PASS; + } + // CraftBukkit end - world.a(entityhuman, blockposition, SoundEffects.ITEM_FLINTANDSTEEL_USE, SoundCategory.BLOCKS, 1.0F, ItemFlintAndSteel.i.nextFloat() * 0.4F + 0.8F); - IBlockData iblockdata = ((BlockFire) Blocks.FIRE).a((IBlockAccess) world, blockposition); - + world.a(entityhuman, blockposition1, SoundEffects.ITEM_FLINTANDSTEEL_USE, SoundCategory.BLOCKS, 1.0F, ItemFlintAndSteel.i.nextFloat() * 0.4F + 0.8F); + iblockdata = ((BlockFire) Blocks.FIRE).a((IBlockAccess) world, blockposition1); + world.setTypeAndData(blockposition1, iblockdata, 11); diff --git a/nms-patches/ItemFood.patch b/nms-patches/ItemFood.patch deleted file mode 100644 index 1cc8d57869..0000000000 --- a/nms-patches/ItemFood.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/server/ItemFood.java -+++ b/net/minecraft/server/ItemFood.java -@@ -36,7 +36,7 @@ - - protected void a(ItemStack itemstack, World world, EntityHuman entityhuman) { - if (!world.isClientSide && this.k != null && world.random.nextFloat() < this.l) { -- entityhuman.addEffect(new MobEffect(this.k)); -+ entityhuman.addEffect(new MobEffect(this.k), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.FOOD); // CraftBukkit - } - - } diff --git a/nms-patches/ItemGoldenApple.patch b/nms-patches/ItemGoldenApple.patch deleted file mode 100644 index 31b2c07661..0000000000 --- a/nms-patches/ItemGoldenApple.patch +++ /dev/null @@ -1,15 +0,0 @@ ---- a/net/minecraft/server/ItemGoldenApple.java -+++ b/net/minecraft/server/ItemGoldenApple.java -@@ -8,8 +8,10 @@ - - protected void a(ItemStack itemstack, World world, EntityHuman entityhuman) { - if (!world.isClientSide) { -- entityhuman.addEffect(new MobEffect(MobEffects.REGENERATION, 100, 1)); -- entityhuman.addEffect(new MobEffect(MobEffects.ABSORBTION, 2400, 0)); -+ // CraftBukkit start -+ entityhuman.addEffect(new MobEffect(MobEffects.REGENERATION, 100, 1), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.FOOD); -+ entityhuman.addEffect(new MobEffect(MobEffects.ABSORBTION, 2400, 0), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.FOOD); -+ // CraftBukkit end - } - - } diff --git a/nms-patches/ItemGoldenAppleEnchanted.patch b/nms-patches/ItemGoldenAppleEnchanted.patch deleted file mode 100644 index a24e9bc63c..0000000000 --- a/nms-patches/ItemGoldenAppleEnchanted.patch +++ /dev/null @@ -1,19 +0,0 @@ ---- a/net/minecraft/server/ItemGoldenAppleEnchanted.java -+++ b/net/minecraft/server/ItemGoldenAppleEnchanted.java -@@ -8,10 +8,12 @@ - - protected void a(ItemStack itemstack, World world, EntityHuman entityhuman) { - if (!world.isClientSide) { -- entityhuman.addEffect(new MobEffect(MobEffects.REGENERATION, 400, 1)); -- entityhuman.addEffect(new MobEffect(MobEffects.RESISTANCE, 6000, 0)); -- entityhuman.addEffect(new MobEffect(MobEffects.FIRE_RESISTANCE, 6000, 0)); -- entityhuman.addEffect(new MobEffect(MobEffects.ABSORBTION, 2400, 3)); -+ // CraftBukkit start -+ entityhuman.addEffect(new MobEffect(MobEffects.REGENERATION, 400, 1), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.FOOD); -+ entityhuman.addEffect(new MobEffect(MobEffects.RESISTANCE, 6000, 0), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.FOOD); -+ entityhuman.addEffect(new MobEffect(MobEffects.FIRE_RESISTANCE, 6000, 0), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.FOOD); -+ entityhuman.addEffect(new MobEffect(MobEffects.ABSORBTION, 2400, 3), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.FOOD); -+ // CraftBukkit end - } - - } diff --git a/nms-patches/ItemHanging.patch b/nms-patches/ItemHanging.patch index 2991d715f3..82cc9e7586 100644 --- a/nms-patches/ItemHanging.patch +++ b/nms-patches/ItemHanging.patch @@ -1,32 +1,32 @@ --- a/net/minecraft/server/ItemHanging.java +++ b/net/minecraft/server/ItemHanging.java -@@ -1,6 +1,10 @@ +@@ -1,5 +1,10 @@ package net.minecraft.server; - import javax.annotation.Nullable; +// CraftBukkit start +import org.bukkit.entity.Player; +import org.bukkit.event.hanging.HangingPlaceEvent; +// CraftBukkit end - ++ public class ItemHanging extends Item { -@@ -25,6 +29,18 @@ + private final EntityTypes a; +@@ -41,6 +46,18 @@ - if (entityhanging != null && entityhanging.survives()) { + if (((EntityHanging) object).survives()) { if (!world.isClientSide) { + // CraftBukkit start - fire HangingPlaceEvent + Player who = (itemactioncontext.getEntity() == null) ? null : (Player) itemactioncontext.getEntity().getBukkitEntity(); + org.bukkit.block.Block blockClicked = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); + org.bukkit.block.BlockFace blockFace = org.bukkit.craftbukkit.block.CraftBlock.notchToBlockFace(enumdirection); + -+ HangingPlaceEvent event = new HangingPlaceEvent((org.bukkit.entity.Hanging) entityhanging.getBukkitEntity(), who, blockClicked, blockFace); ++ HangingPlaceEvent event = new HangingPlaceEvent((org.bukkit.entity.Hanging) ((EntityHanging) object).getBukkitEntity(), who, blockClicked, blockFace); + world.getServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { + return EnumInteractionResult.FAIL; + } + // CraftBukkit end - entityhanging.m(); - world.addEntity(entityhanging); + ((EntityHanging) object).playPlaceSound(); + world.addEntity((Entity) object); } diff --git a/nms-patches/ItemLeash.patch b/nms-patches/ItemLeash.patch index 6a695213f3..bd27c40df0 100644 --- a/nms-patches/ItemLeash.patch +++ b/nms-patches/ItemLeash.patch @@ -9,8 +9,8 @@ public class ItemLeash extends Item { public ItemLeash(Item.Info item_info) { -@@ -43,7 +45,23 @@ - if (entityinsentient.isLeashed() && entityinsentient.getLeashHolder() == entityhuman) { +@@ -44,7 +46,23 @@ + if (entityinsentient.getLeashHolder() == entityhuman) { if (entityleash == null) { entityleash = EntityLeash.a(world, blockposition); + diff --git a/nms-patches/ItemMilkBucket.patch b/nms-patches/ItemMilkBucket.patch index f147e504e4..ee96e15bce 100644 --- a/nms-patches/ItemMilkBucket.patch +++ b/nms-patches/ItemMilkBucket.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/ItemMilkBucket.java +++ b/net/minecraft/server/ItemMilkBucket.java -@@ -19,7 +19,7 @@ +@@ -20,7 +20,7 @@ } if (!world.isClientSide) { diff --git a/nms-patches/ItemMinecart.patch b/nms-patches/ItemMinecart.patch index 9890f44fd2..2859151776 100644 --- a/nms-patches/ItemMinecart.patch +++ b/nms-patches/ItemMinecart.patch @@ -11,7 +11,7 @@ public class ItemMinecart extends Item { private static final IDispenseBehavior a = new DispenseBehaviorItem() { -@@ -37,14 +42,43 @@ +@@ -38,14 +43,43 @@ } } @@ -58,7 +58,7 @@ return itemstack; } -@@ -84,7 +118,12 @@ +@@ -87,7 +121,12 @@ entityminecartabstract.setCustomName(itemstack.getName()); } diff --git a/nms-patches/ItemPotion.patch b/nms-patches/ItemPotion.patch index c1277da325..348ff484ce 100644 --- a/nms-patches/ItemPotion.patch +++ b/nms-patches/ItemPotion.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/ItemPotion.java +++ b/net/minecraft/server/ItemPotion.java -@@ -30,7 +30,7 @@ +@@ -31,7 +31,7 @@ if (mobeffect.getMobEffect().isInstant()) { mobeffect.getMobEffect().applyInstantEffect(entityhuman, entityhuman, entityliving, mobeffect.getAmplifier(), 1.0D); } else { diff --git a/nms-patches/ItemRecord.patch b/nms-patches/ItemRecord.patch index ab2b7647de..692fdf0eb9 100644 --- a/nms-patches/ItemRecord.patch +++ b/nms-patches/ItemRecord.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/ItemRecord.java +++ b/net/minecraft/server/ItemRecord.java -@@ -34,6 +34,7 @@ +@@ -26,6 +26,7 @@ ItemStack itemstack = itemactioncontext.getItemStack(); if (!world.isClientSide) { diff --git a/nms-patches/ItemSign.patch b/nms-patches/ItemSign.patch index b06db8d79d..d538a04c07 100644 --- a/nms-patches/ItemSign.patch +++ b/nms-patches/ItemSign.patch @@ -6,10 +6,10 @@ + public static boolean openSign; // CraftBukkit + - public ItemSign(Item.Info item_info) { - super(Blocks.SIGN, Blocks.WALL_SIGN, item_info); + public ItemSign(Item.Info item_info, Block block, Block block1) { + super(block, block1, item_info); } -@@ -12,7 +14,10 @@ +@@ -13,7 +15,10 @@ boolean flag = super.a(blockposition, world, entityhuman, itemstack, iblockdata); if (!world.isClientSide && !flag && entityhuman != null) { diff --git a/nms-patches/ItemSkullPlayer.patch b/nms-patches/ItemSkullPlayer.patch index 0679f50303..292509cbe0 100644 --- a/nms-patches/ItemSkullPlayer.patch +++ b/nms-patches/ItemSkullPlayer.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/ItemSkullPlayer.java +++ b/net/minecraft/server/ItemSkullPlayer.java -@@ -42,6 +42,15 @@ +@@ -44,6 +44,15 @@ nbttagcompound.set("SkullOwner", GameProfileSerializer.serialize(new NBTTagCompound(), gameprofile)); return true; } else { diff --git a/nms-patches/ItemSnowball.patch b/nms-patches/ItemSnowball.patch index 7f5eae73ba..6190a807e5 100644 --- a/nms-patches/ItemSnowball.patch +++ b/nms-patches/ItemSnowball.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/ItemSnowball.java +++ b/net/minecraft/server/ItemSnowball.java -@@ -9,17 +9,29 @@ +@@ -10,18 +10,30 @@ public InteractionResultWrapper a(World world, EntityHuman entityhuman, EnumHand enumhand) { ItemStack itemstack = entityhuman.b(enumhand); @@ -15,6 +15,7 @@ if (!world.isClientSide) { EntitySnowball entitysnowball = new EntitySnowball(world, entityhuman); + entitysnowball.setItem(itemstack); entitysnowball.a(entityhuman, entityhuman.pitch, entityhuman.yaw, 0.0F, 1.5F, 1.0F); - world.addEntity(entitysnowball); + if (world.addEntity(entitysnowball)) { diff --git a/nms-patches/ItemStack.patch b/nms-patches/ItemStack.patch index d82038e8d0..1b298803c9 100644 --- a/nms-patches/ItemStack.patch +++ b/nms-patches/ItemStack.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/ItemStack.java +++ b/net/minecraft/server/ItemStack.java -@@ -15,6 +15,24 @@ +@@ -16,6 +16,24 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -25,27 +25,21 @@ public final class ItemStack { private static final Logger c = LogManager.getLogger(); -@@ -49,25 +67,49 @@ - this.E(); +@@ -50,23 +68,42 @@ + this.checkEmpty(); } + // Called to run this stack through the data converter to handle older storage methods and serialized items -+ public void convertStack() { -+ if (false && MinecraftServer.getServer() != null) { // Skip for now, causes more issues than it solves -+ // Don't convert some things - both the old and new data values are valid -+ // Conversion would make getting then impossible -+ if (this.item == Blocks.PUMPKIN.getItem() || this.item == Blocks.GRASS.getItem() || this.item == Blocks.SNOW.getItem()) { -+ return; -+ } -+ ++ public void convertStack(int version) { ++ if (0 < version && version < CraftMagicNumbers.INSTANCE.getDataVersion()) { + NBTTagCompound savedStack = new NBTTagCompound(); + this.save(savedStack); -+ savedStack = (NBTTagCompound) MinecraftServer.getServer().dataConverterManager.update(DataConverterTypes.ITEM_STACK, new Dynamic(DynamicOpsNBT.a, savedStack), -1, CraftMagicNumbers.INSTANCE.getDataVersion()).getValue(); ++ savedStack = (NBTTagCompound) MinecraftServer.getServer().dataConverterManager.update(DataConverterTypes.ITEM_STACK, new Dynamic(DynamicOpsNBT.a, savedStack), version, CraftMagicNumbers.INSTANCE.getDataVersion()).getValue(); + this.load(savedStack); + } + } + - private void E() { + private void checkEmpty() { + if (this.h && this == ItemStack.a) throw new AssertionError("TRAP"); // CraftBukkit this.h = false; this.h = this.isEmpty(); @@ -54,9 +48,7 @@ - private ItemStack(NBTTagCompound nbttagcompound) { + // CraftBukkit - break into own method + private void load(NBTTagCompound nbttagcompound) { - Item item = (Item) IRegistry.ITEM.get(new MinecraftKey(nbttagcompound.getString("id"))); - - this.item = item == null ? Items.AIR : item; + this.item = (Item) IRegistry.ITEM.get(new MinecraftKey(nbttagcompound.getString("id"))); this.count = nbttagcompound.getByte("Count"); if (nbttagcompound.hasKeyOfType("tag", 10)) { - this.tag = nbttagcompound.getCompound("tag"); @@ -70,15 +62,16 @@ if (this.getItem().usesDurability()) { this.setDamage(this.getDamage()); } -+ } ++ } ++ + private ItemStack(NBTTagCompound nbttagcompound) { + this.load(nbttagcompound); + // CraftBukkit end - this.E(); + this.checkEmpty(); } -@@ -97,7 +139,7 @@ +@@ -96,7 +133,7 @@ return this.h ? Items.AIR : this.item; } @@ -87,8 +80,8 @@ EntityHuman entityhuman = itemactioncontext.getEntity(); BlockPosition blockposition = itemactioncontext.getClickPosition(); ShapeDetectorBlock shapedetectorblock = new ShapeDetectorBlock(itemactioncontext.getWorld(), blockposition, false); -@@ -105,12 +147,150 @@ - if (entityhuman != null && !entityhuman.abilities.mayBuild && !this.b(itemactioncontext.getWorld().F(), shapedetectorblock)) { +@@ -104,12 +141,150 @@ + if (entityhuman != null && !entityhuman.abilities.mayBuild && !this.b(itemactioncontext.getWorld().t(), shapedetectorblock)) { return EnumInteractionResult.PASS; } else { + // CraftBukkit start - handle all block place event logic here @@ -186,7 +179,7 @@ + IBlockData block = world.getType(newblockposition); + + if (!(block.getBlock() instanceof BlockTileEntity)) { // Containers get placed automatically -+ block.getBlock().onPlace(block, world, newblockposition, oldBlock); ++ block.getBlock().onPlace(block, world, newblockposition, oldBlock, true); + } + + world.notifyAndUpdatePhysics(newblockposition, null, oldBlock, block, world.getType(newblockposition), updateFlag); // send null chunk as chunk.k() returns false by this point @@ -226,7 +219,7 @@ + + // SPIGOT-1288 - play sound stripped from ItemBlock + if (this.item instanceof ItemBlock) { -+ SoundEffectType soundeffecttype = ((ItemBlock) this.item).getBlock().getStepSound(); ++ SoundEffectType soundeffecttype = ((ItemBlock) this.item).getBlock().stepSound; + world.a(entityhuman, blockposition, soundeffecttype.e(), SoundCategory.BLOCKS, (soundeffecttype.a() + 1.0F) / 2.0F, soundeffecttype.b() * 0.8F); + } + @@ -239,7 +232,7 @@ return enuminteractionresult; } -@@ -134,7 +314,7 @@ +@@ -133,7 +308,7 @@ nbttagcompound.setString("id", minecraftkey == null ? "minecraft:air" : minecraftkey.toString()); nbttagcompound.setByte("Count", (byte) this.count); if (this.tag != null) { @@ -248,20 +241,20 @@ } return nbttagcompound; -@@ -167,6 +347,12 @@ +@@ -166,6 +341,12 @@ } public void setDamage(int i) { + // CraftBukkit start - remove Damage tag if 0 + if (i <= 0) { -+ this.c("Damage"); // PAIL removeTag ++ this.removeTag("Damage"); + return; + } + // CraftBukkit end this.getOrCreateTag().setInt("Damage", Math.max(0, i)); } -@@ -191,6 +377,21 @@ +@@ -190,6 +371,21 @@ } i -= k; @@ -283,19 +276,19 @@ if (i <= 0) { return false; } -@@ -212,6 +413,11 @@ - if (this.isDamaged(i, entityliving.getRandom(), entityliving instanceof EntityPlayer ? (EntityPlayer) entityliving : null)) { - entityliving.c(this); +@@ -211,6 +407,11 @@ + if (this.isDamaged(i, t0.getRandom(), t0 instanceof EntityPlayer ? (EntityPlayer) t0 : null)) { + consumer.accept(t0); Item item = this.getItem(); + // CraftBukkit start - Check for item breaking -+ if (this.count == 1 && entityliving instanceof EntityHuman) { -+ org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerItemBreakEvent((EntityHuman) entityliving, this); ++ if (this.count == 1 && t0 instanceof EntityHuman) { ++ org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerItemBreakEvent((EntityHuman) t0, this); + } + // CraftBukkit end this.subtract(1); - if (entityliving instanceof EntityHuman) { -@@ -335,6 +541,17 @@ + if (t0 instanceof EntityHuman) { +@@ -338,6 +539,17 @@ return this.tag; } @@ -313,21 +306,21 @@ public NBTTagCompound getOrCreateTag() { if (this.tag == null) { this.setTag(new NBTTagCompound()); -@@ -479,6 +696,12 @@ +@@ -482,6 +694,12 @@ } public void setRepairCost(int i) { + // CraftBukkit start - remove RepairCost tag when 0 (SPIGOT-3945) + if (i == 0) { -+ this.c("RepairCost"); // PAIL removeTag ++ this.removeTag("RepairCost"); + return; + } + // CraftBukkit end this.getOrCreateTag().setInt("RepairCost", i); } -@@ -521,6 +744,13 @@ - nbttaglist.add((NBTBase) nbttagcompound); +@@ -524,6 +742,13 @@ + nbttaglist.add(nbttagcompound); } + // CraftBukkit start @@ -337,6 +330,6 @@ + } + // CraftBukkit end + - public IChatBaseComponent A() { + public IChatBaseComponent B() { IChatBaseComponent ichatbasecomponent = (new ChatComponentText("")).addSibling(this.getName()); diff --git a/nms-patches/ItemTrident.patch b/nms-patches/ItemTrident.patch index dff9467090..7c9d375cc2 100644 --- a/nms-patches/ItemTrident.patch +++ b/nms-patches/ItemTrident.patch @@ -7,23 +7,27 @@ + // CraftBukkit start - obfuscator went a little crazy + /* this.a(new MinecraftKey("throwing"), (itemstack, world, entityliving) -> { - return entityliving != null && entityliving.isHandRaised() && entityliving.cW() == itemstack ? 1.0F : 0.0F; + return entityliving != null && entityliving.isHandRaised() && entityliving.dl() == itemstack ? 1.0F : 0.0F; }); + */ + // CraftBukkit end } - public boolean a(IBlockData iblockdata, World world, BlockPosition blockposition, EntityHuman entityhuman) { -@@ -33,7 +37,7 @@ + @Override +@@ -37,9 +41,12 @@ - if (k <= 0 || entityhuman.ao()) { + if (k <= 0 || entityhuman.isInWaterOrRain()) { if (!world.isClientSide) { -- itemstack.damage(1, entityhuman); -+ // itemstack.damage(1, entityhuman); // CraftBukkit - moved down ++ // CraftBukkit - moved down ++ /* + itemstack.damage(1, entityhuman, (entityhuman1) -> { + entityhuman1.d(entityliving.getRaisedHand()); + }); ++ */ if (k == 0) { EntityThrownTrident entitythrowntrident = new EntityThrownTrident(world, entityhuman, itemstack); -@@ -42,7 +46,18 @@ +@@ -48,7 +55,20 @@ entitythrowntrident.fromPlayer = EntityArrow.PickupStatus.CREATIVE_ONLY; } @@ -36,16 +40,18 @@ + return; + } + -+ itemstack.damage(1, entityhuman); ++ itemstack.damage(1, entityhuman, (entityhuman1) -> { ++ entityhuman1.d(entityliving.getRaisedHand()); ++ }); + entitythrowntrident.trident = itemstack.cloneItemStack(); // SPIGOT-4511 update since damage call moved + // CraftBukkit end + + world.a((EntityHuman) null, (Entity) entitythrowntrident, SoundEffects.ITEM_TRIDENT_THROW, SoundCategory.PLAYERS, 1.0F, 1.0F); if (!entityhuman.abilities.canInstantlyBuild) { entityhuman.inventory.f(itemstack); - } -@@ -53,6 +68,10 @@ - SoundEffect soundeffect = SoundEffects.ITEM_TRIDENT_THROW; +@@ -58,6 +78,10 @@ + entityhuman.b(StatisticList.ITEM_USED.b(this)); if (k > 0) { + // CraftBukkit start + org.bukkit.event.player.PlayerRiptideEvent event = new org.bukkit.event.player.PlayerRiptideEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack)); diff --git a/nms-patches/ItemWaterLily.patch b/nms-patches/ItemWaterLily.patch index 0429408fcb..91004eca18 100644 --- a/nms-patches/ItemWaterLily.patch +++ b/nms-patches/ItemWaterLily.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/server/ItemWaterLily.java +++ b/net/minecraft/server/ItemWaterLily.java -@@ -30,7 +30,15 @@ +@@ -34,7 +34,15 @@ Fluid fluid = world.getFluid(blockposition); - if ((fluid.c() == FluidTypes.WATER || material == Material.ICE) && world.isEmpty(blockposition1)) { + if ((fluid.getType() == FluidTypes.WATER || material == Material.ICE) && world.isEmpty(blockposition1)) { + // CraftBukkit start - special case for handling block placement with water lilies + org.bukkit.block.BlockState blockstate = org.bukkit.craftbukkit.block.CraftBlockState.getBlockState(world, blockposition1); world.setTypeAndData(blockposition1, Blocks.LILY_PAD.getBlockData(), 11); diff --git a/nms-patches/ItemWorldMap.patch b/nms-patches/ItemWorldMap.patch index 6584e852a0..93eb72407f 100644 --- a/nms-patches/ItemWorldMap.patch +++ b/nms-patches/ItemWorldMap.patch @@ -21,8 +21,8 @@ return itemstack; } -@@ -24,7 +29,7 @@ - WorldMap worldmap = a((GeneratorAccess) world, "map_" + e(itemstack)); +@@ -29,7 +34,7 @@ + WorldMap worldmap = a(itemstack, world); if (worldmap == null && !world.isClientSide) { - worldmap = a(itemstack, world, world.getWorldData().b(), world.getWorldData().d(), 3, false, false, world.worldProvider.getDimensionManager()); @@ -30,7 +30,7 @@ } return worldmap; -@@ -33,26 +38,42 @@ +@@ -38,7 +43,7 @@ public static int e(ItemStack itemstack) { NBTTagCompound nbttagcompound = itemstack.getTag(); @@ -39,14 +39,9 @@ } private static WorldMap a(ItemStack itemstack, World world, int i, int j, int k, boolean flag, boolean flag1, DimensionManager dimensionmanager) { -- int l = world.a(DimensionManager.OVERWORLD, "map"); -+ World worldMain = world.getServer().getServer().getWorldServer(DimensionManager.OVERWORLD); // CraftBukkit - store reference to primary world -+ int l = worldMain.a(DimensionManager.OVERWORLD, "map"); // CraftBukkit - use primary world for maps - WorldMap worldmap = new WorldMap("map_" + l); - +@@ -48,6 +53,11 @@ worldmap.a(i, j, k, flag, flag1, dimensionmanager); -- world.a(DimensionManager.OVERWORLD, worldmap.getId(), (PersistentBase) worldmap); -+ worldMain.a(DimensionManager.OVERWORLD, worldmap.getId(), (PersistentBase) worldmap); // CraftBukkit - use primary world for maps + world.a(worldmap); itemstack.getOrCreateTag().setInt("map", l); + + // CraftBukkit start @@ -56,19 +51,7 @@ return worldmap; } - @Nullable - public static WorldMap a(GeneratorAccess generatoraccess, String s) { -- return (WorldMap) generatoraccess.a(DimensionManager.OVERWORLD, WorldMap::new, s); -+ // CraftBukkit start - use primary world for maps and call event -+ WorldMap worldmap = (WorldMap) MinecraftServer.getServer().getWorldServer(DimensionManager.OVERWORLD).a(DimensionManager.OVERWORLD, (id) -> { -+ // We only get here when the data file exists, but is not a valid map -+ WorldMap newMap = new WorldMap(id); -+ MapInitializeEvent event = new MapInitializeEvent(newMap.mapView); -+ Bukkit.getServer().getPluginManager().callEvent(event); -+ return newMap; -+ }, s); -+ return worldmap; -+ // CraftBukkit end +@@ -56,7 +66,8 @@ } public void a(World world, Entity entity, WorldMap worldmap) { @@ -78,7 +61,7 @@ int i = 1 << worldmap.scale; int j = worldmap.centerX; int k = worldmap.centerZ; -@@ -199,7 +220,8 @@ +@@ -208,7 +219,8 @@ WorldMap worldmap = getSavedMap(itemstack, world); if (worldmap != null) { diff --git a/nms-patches/LoginListener.patch b/nms-patches/LoginListener.patch index a9a4def4ac..403d39a6be 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, ITickable { + public class LoginListener implements PacketLoginInListener { private static final AtomicInteger b = new AtomicInteger(0); @@ -32,6 +38,7 @@ @@ -30,7 +30,7 @@ + public void disconnect(String s) { + try { + IChatBaseComponent ichatbasecomponent = new ChatComponentText(s); -+ LoginListener.c.info("Disconnecting {}: {}", this.c(), s); ++ LoginListener.c.info("Disconnecting {}: {}", this.d(), s); + this.networkManager.sendPacket(new PacketLoginOutDisconnect(ichatbasecomponent)); + this.networkManager.close(ichatbasecomponent); + } catch (Exception exception) { @@ -41,7 +41,7 @@ + public void disconnect(IChatBaseComponent ichatbasecomponent) { try { - LoginListener.c.info("Disconnecting {}: {}", this.c(), ichatbasecomponent.getString()); + LoginListener.c.info("Disconnecting {}: {}", this.d(), ichatbasecomponent.getString()); @@ -76,10 +97,12 @@ this.i = this.a(this.i); } @@ -57,7 +57,7 @@ + // CraftBukkit end } else { this.g = LoginListener.EnumProtocolState.ACCEPTED; - if (this.server.aw() >= 0 && !this.networkManager.isLocal()) { + if (this.server.ay() >= 0 && !this.networkManager.isLocal()) { @@ -93,9 +116,9 @@ if (entityplayer != null) { @@ -70,9 +70,9 @@ } } -@@ -140,6 +163,43 @@ +@@ -143,6 +166,43 @@ - LoginListener.this.i = LoginListener.this.server.ap().hasJoinedServer(new GameProfile((UUID) null, gameprofile.getName()), s, this.a()); + LoginListener.this.i = LoginListener.this.server.getMinecraftSessionService().hasJoinedServer(new GameProfile((UUID) null, gameprofile.getName()), s, this.a()); if (LoginListener.this.i != null) { + // CraftBukkit start - fire PlayerPreLoginEvent + if (!networkManager.isConnected()) { @@ -113,8 +113,8 @@ + // CraftBukkit end LoginListener.c.info("UUID of player {} is {}", LoginListener.this.i.getName(), LoginListener.this.i.getId()); LoginListener.this.g = LoginListener.EnumProtocolState.READY_TO_ACCEPT; - } else if (LoginListener.this.server.H()) { -@@ -159,6 +219,11 @@ + } else if (LoginListener.this.server.isEmbeddedServer()) { +@@ -162,6 +222,11 @@ LoginListener.this.disconnect(new ChatMessage("multiplayer.disconnect.authservers_down", new Object[0])); LoginListener.c.error("Couldn't verify username because servers are unavailable"); } diff --git a/nms-patches/LootContextParameters.patch b/nms-patches/LootContextParameters.patch new file mode 100644 index 0000000000..d2993800f8 --- /dev/null +++ b/nms-patches/LootContextParameters.patch @@ -0,0 +1,10 @@ +--- a/net/minecraft/server/LootContextParameters.java ++++ b/net/minecraft/server/LootContextParameters.java +@@ -12,6 +12,7 @@ + public static final LootContextParameter BLOCK_ENTITY = a("block_entity"); + public static final LootContextParameter TOOL = a("tool"); + public static final LootContextParameter EXPLOSION_RADIUS = a("explosion_radius"); ++ public static final LootContextParameter LOOTING_MOD = new LootContextParameter<>(new MinecraftKey("bukkit:looting_mod")); // CraftBukkit + + private static LootContextParameter a(String s) { + return new LootContextParameter<>(new MinecraftKey(s)); diff --git a/nms-patches/LootEnchantFunction.patch b/nms-patches/LootEnchantFunction.patch index 24cf4e94bd..46134313dc 100644 --- a/nms-patches/LootEnchantFunction.patch +++ b/nms-patches/LootEnchantFunction.patch @@ -1,12 +1,12 @@ --- a/net/minecraft/server/LootEnchantFunction.java +++ b/net/minecraft/server/LootEnchantFunction.java -@@ -21,8 +21,13 @@ +@@ -32,8 +32,13 @@ if (entity instanceof EntityLiving) { int i = EnchantmentManager.g((EntityLiving) entity); + // CraftBukkit start - use lootingModifier if set by plugin -+ if (loottableinfo.lootingMod > org.bukkit.loot.LootContext.DEFAULT_LOOT_MODIFIER) { -+ i = loottableinfo.lootingMod; ++ if (loottableinfo.hasContextParameter(LootContextParameters.LOOTING_MOD)) { ++ i = loottableinfo.getContextParameter(LootContextParameters.LOOTING_MOD); + } + // CraftBukkit end @@ -15,3 +15,12 @@ return itemstack; } +@@ -59,7 +64,7 @@ + } + + public void a(JsonObject jsonobject, LootEnchantFunction lootenchantfunction, JsonSerializationContext jsonserializationcontext) { +- super.a(jsonobject, (LootItemFunctionConditional) lootenchantfunction, jsonserializationcontext); ++ super.a(jsonobject, lootenchantfunction, jsonserializationcontext); // CraftBukkit - decompile error + jsonobject.add("count", jsonserializationcontext.serialize(lootenchantfunction.a)); + if (lootenchantfunction.b()) { + jsonobject.add("limit", jsonserializationcontext.serialize(lootenchantfunction.c)); diff --git a/nms-patches/LootItemConditionRandomChanceWithLooting.patch b/nms-patches/LootItemConditionRandomChanceWithLooting.patch index 111d6a0b42..0809262ca9 100644 --- a/nms-patches/LootItemConditionRandomChanceWithLooting.patch +++ b/nms-patches/LootItemConditionRandomChanceWithLooting.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/server/LootItemConditionRandomChanceWithLooting.java +++ b/net/minecraft/server/LootItemConditionRandomChanceWithLooting.java -@@ -21,6 +21,11 @@ - if (loottableinfo.c() instanceof EntityLiving) { - i = EnchantmentManager.g((EntityLiving) loottableinfo.c()); +@@ -28,6 +28,11 @@ + if (entity instanceof EntityLiving) { + i = EnchantmentManager.g((EntityLiving) entity); } + // CraftBukkit start - only use lootingModifier if set by Bukkit -+ if (loottableinfo.lootingMod > org.bukkit.loot.LootContext.DEFAULT_LOOT_MODIFIER) { -+ i = loottableinfo.lootingMod; ++ if (loottableinfo.hasContextParameter(LootContextParameters.LOOTING_MOD)) { ++ i = loottableinfo.getContextParameter(LootContextParameters.LOOTING_MOD); + } + // CraftBukkit end - return random.nextFloat() < this.a + (float) i * this.b; + return loottableinfo.b().nextFloat() < this.a + (float) i * this.b; } diff --git a/nms-patches/LootItemConditionSurvivesExplosion.patch b/nms-patches/LootItemConditionSurvivesExplosion.patch new file mode 100644 index 0000000000..d485ef357f --- /dev/null +++ b/nms-patches/LootItemConditionSurvivesExplosion.patch @@ -0,0 +1,12 @@ +--- a/net/minecraft/server/LootItemConditionSurvivesExplosion.java ++++ b/net/minecraft/server/LootItemConditionSurvivesExplosion.java +@@ -25,7 +25,8 @@ + Random random = loottableinfo.b(); + float f = 1.0F / ofloat; + +- return random.nextFloat() <= f; ++ // CraftBukkit - <= to < to allow for plugins to completely disable block drops from explosions ++ return random.nextFloat() < f; + } else { + return true; + } diff --git a/nms-patches/LootTableInfo.patch b/nms-patches/LootTableInfo.patch deleted file mode 100644 index cb701f451d..0000000000 --- a/nms-patches/LootTableInfo.patch +++ /dev/null @@ -1,53 +0,0 @@ ---- a/net/minecraft/server/LootTableInfo.java -+++ b/net/minecraft/server/LootTableInfo.java -@@ -11,6 +11,7 @@ - public class LootTableInfo { - - private final float a; -+ public final int lootingMod; // CraftBukkit - add field - private final WorldServer b; - private final LootTableRegistry c; - @Nullable -@@ -23,7 +24,8 @@ - private final BlockPosition g; - private final Set h = Sets.newLinkedHashSet(); - -- public LootTableInfo(float f, WorldServer worldserver, LootTableRegistry loottableregistry, @Nullable Entity entity, @Nullable EntityHuman entityhuman, @Nullable DamageSource damagesource, @Nullable BlockPosition blockposition) { -+ // CraftBukkit - add looting modifier to constructor -+ public LootTableInfo(float f, WorldServer worldserver, LootTableRegistry loottableregistry, @Nullable Entity entity, @Nullable EntityHuman entityhuman, @Nullable DamageSource damagesource, @Nullable BlockPosition blockposition, int lootingModifier) { - this.a = f; - this.b = worldserver; - this.c = loottableregistry; -@@ -31,6 +33,7 @@ - this.e = entityhuman; - this.f = damagesource; - this.g = blockposition; -+ this.lootingMod = lootingModifier; // CraftBukkit - } - - @Nullable -@@ -130,6 +133,7 @@ - - private final WorldServer a; - private float b; -+ private int lootingMod = org.bukkit.loot.LootContext.DEFAULT_LOOT_MODIFIER; // CraftBukkit - private Entity c; - private EntityHuman d; - private DamageSource e; -@@ -164,8 +168,15 @@ - return this; - } - -+ // CraftBukkit start - add looting modifier -+ public LootTableInfo.Builder lootingModifier(int modifier) { -+ this.lootingMod = modifier; -+ return this; -+ } -+ // CraftBukkit end -+ - public LootTableInfo build() { -- return new LootTableInfo(this.b, this.a, this.a.getMinecraftServer().getLootTableRegistry(), this.c, this.d, this.e, this.f); -+ return new LootTableInfo(this.b, this.a, this.a.getMinecraftServer().getLootTableRegistry(), this.c, this.d, this.e, this.f, this.lootingMod); // CraftBukkit add looting modifier - } - } - } diff --git a/nms-patches/MerchantRecipe.patch b/nms-patches/MerchantRecipe.patch index 176a59b24e..4279e0008c 100644 --- a/nms-patches/MerchantRecipe.patch +++ b/nms-patches/MerchantRecipe.patch @@ -8,10 +8,10 @@ public class MerchantRecipe { public ItemStack buyingItem1; -@@ -8,6 +10,18 @@ - public int uses; - public int maxUses; - public boolean rewardExp; +@@ -12,6 +14,18 @@ + private int h; + public float priceMultiplier; + public int xp; + // CraftBukkit start + private CraftMerchantRecipe bukkitHandle; + @@ -19,11 +19,11 @@ + 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); ++ public MerchantRecipe(ItemStack itemstack, ItemStack itemstack1, ItemStack itemstack2, int uses, int maxUses, int experience, float priceMultiplier, CraftMerchantRecipe bukkit) { ++ this(itemstack, itemstack1, itemstack2, uses, maxUses, experience, priceMultiplier); + this.bukkitHandle = bukkit; + } + // CraftBukkit end public MerchantRecipe(NBTTagCompound nbttagcompound) { - this.buyingItem1 = ItemStack.a; + this.rewardExp = true; diff --git a/nms-patches/MethodProfiler.patch b/nms-patches/MethodProfiler.patch deleted file mode 100644 index 203522a2cb..0000000000 --- a/nms-patches/MethodProfiler.patch +++ /dev/null @@ -1,63 +0,0 @@ ---- a/net/minecraft/server/MethodProfiler.java -+++ b/net/minecraft/server/MethodProfiler.java -@@ -12,6 +12,7 @@ - - public class MethodProfiler { - -+ public static final boolean ENABLED = Boolean.getBoolean("enableDebugMethodProfiler"); // CraftBukkit - disable unless specified in JVM arguments - private static final Logger a = LogManager.getLogger(); - private final List b = Lists.newArrayList(); - private final List c = Lists.newArrayList(); -@@ -40,6 +41,7 @@ - } - - public void a(int i) { -+ if (!ENABLED) return; // CraftBukkit - if (!this.d) { - this.d = true; - this.f.clear(); -@@ -51,6 +53,7 @@ - } - - public void enter(String s) { -+ if (!ENABLED) return; // CraftBukkit - if (this.d) { - if (!this.e.isEmpty()) { - this.e = this.e + "."; -@@ -63,12 +66,14 @@ - } - - public void a(Supplier supplier) { -+ if (!ENABLED) return; // CraftBukkit - if (this.d) { - this.enter((String) supplier.get()); - } - } - - public void exit() { -+ if (!ENABLED) return; // CraftBukkit - if (this.d && !this.c.isEmpty()) { - long i = SystemUtils.getMonotonicNanos(); - long j = (Long) this.c.remove(this.c.size() - 1); -@@ -91,6 +96,7 @@ - } - - public List b(String s) { -+ if (!ENABLED) return Collections.emptyList(); // CraftBukkit - long i = this.f.containsKey("root") ? (Long) this.f.get("root") : 0L; - long j = this.f.containsKey(s) ? (Long) this.f.get(s) : -1L; - List list = Lists.newArrayList(); -@@ -153,11 +159,13 @@ - } - - public void exitEnter(String s) { -+ if (!ENABLED) return; // CraftBukkit - this.exit(); - this.enter(s); - } - - public String f() { -+ if (!ENABLED) return "[DISABLED]"; // CraftBukkit - return this.b.isEmpty() ? "[UNKNOWN]" : (String) this.b.get(this.b.size() - 1); - } - diff --git a/nms-patches/MinecraftServer.patch b/nms-patches/MinecraftServer.patch index 411fdad525..377c389870 100644 --- a/nms-patches/MinecraftServer.patch +++ b/nms-patches/MinecraftServer.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -54,6 +54,14 @@ +@@ -47,6 +47,14 @@ import org.apache.commons.lang3.Validate; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -13,22 +13,31 @@ +import org.bukkit.event.server.ServerLoadEvent; +// CraftBukkit end - public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStatistics, ICommandListener, Runnable { + public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant implements IMojangStatistics, ICommandListener, AutoCloseable, Runnable { -@@ -70,7 +78,7 @@ +@@ -65,7 +73,7 @@ public final DataFixer dataConverterManager; private String serverIp; - private int q = -1; + private int serverPort = -1; - public final Map worldServer = Maps.newIdentityHashMap(); + public final Map worldServer = Maps.newLinkedHashMap(); // CraftBukkit - keep order, k+v already use identity methods private PlayerList playerList; - private boolean isRunning = true; + private volatile boolean isRunning = true; private boolean isStopped; -@@ -124,7 +132,21 @@ - private boolean forceUpgrade; - private float ap; +@@ -104,7 +112,7 @@ + private final GameProfileRepository gameProfileRepository; + private final UserCache userCache; + private long Z; +- public final Thread serverThread = (Thread) SystemUtils.a((Object) (new Thread(this, "Server thread")), (thread) -> { ++ public final Thread serverThread = (Thread) SystemUtils.a((new Thread(this, "Server thread")), (thread) -> { // CraftBukkit - decompile error + thread.setUncaughtExceptionHandler((thread1, throwable) -> { + MinecraftServer.LOGGER.error(throwable); + }); +@@ -133,7 +141,20 @@ + @Nullable + private String av; -- public MinecraftServer(@Nullable File file, Proxy proxy, DataFixer datafixer, CommandDispatcher commanddispatcher, YggdrasilAuthenticationService yggdrasilauthenticationservice, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache) { +- public MinecraftServer(File file, Proxy proxy, DataFixer datafixer, CommandDispatcher commanddispatcher, YggdrasilAuthenticationService yggdrasilauthenticationservice, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache, WorldLoadListenerFactory worldloadlistenerfactory, String s) { + // CraftBukkit start + public org.bukkit.craftbukkit.CraftServer server; + public OptionSet options; @@ -36,39 +45,40 @@ + public org.bukkit.command.RemoteConsoleCommandSender remoteConsole; + public ConsoleReader reader; + public static int currentTick = (int) (System.currentTimeMillis() / 50); -+ public final Thread primaryThread; + public java.util.Queue processQueue = new java.util.concurrent.ConcurrentLinkedQueue(); + public int autosavePeriod; + public File bukkitDataPackFolder; + public CommandDispatcher vanillaCommandDispatcher; + // CraftBukkit end + -+ public MinecraftServer(OptionSet options, Proxy proxy, DataFixer datafixer, CommandDispatcher commanddispatcher, YggdrasilAuthenticationService yggdrasilauthenticationservice, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache) { - this.ac = new ResourceManager(EnumResourcePackType.SERVER_DATA); ++ public MinecraftServer(OptionSet options, Proxy proxy, DataFixer datafixer, CommandDispatcher commanddispatcher, YggdrasilAuthenticationService yggdrasilauthenticationservice, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache, WorldLoadListenerFactory worldloadlistenerfactory, String s) { + super("Server"); + this.ae = new ResourceManager(EnumResourcePackType.SERVER_DATA, this.serverThread); this.resourcePackRepository = new ResourcePackRepository<>(ResourcePackLoader::new); - this.ag = new CraftingManager(); -@@ -135,22 +157,51 @@ - this.al = new AdvancementDataWorld(); - this.am = new CustomFunctionData(this); - this.c = proxy; +@@ -146,15 +167,15 @@ + this.ao = new CustomFunctionData(this); + this.ap = new CircularTimer(); + this.proxy = proxy; - this.commandDispatcher = commanddispatcher; + this.commandDispatcher = this.vanillaCommandDispatcher = commanddispatcher; // CraftBukkit - this.U = yggdrasilauthenticationservice; - this.V = minecraftsessionservice; - this.W = gameprofilerepository; - this.X = usercache; + this.yggdrasilAuthenticationService = yggdrasilauthenticationservice; + this.minecraftSessionService = minecraftsessionservice; + this.gameProfileRepository = gameprofilerepository; + this.userCache = usercache; - this.universe = file; -- this.serverConnection = file == null ? null : new ServerConnection(this); -- this.convertable = file == null ? null : new WorldLoaderServer(file.toPath(), file.toPath().resolve("../backups"), datafixer); +- this.serverConnection = new ServerConnection(this); + // this.universe = file; // CraftBukkit + this.serverConnection = new ServerConnection(this); // CraftBukkit -+ // this.convertable = file == null ? null : new WorldLoaderServer(file.toPath(), file.toPath().resolve("../backups"), datafixer); // CraftBukkit - moved to DedicatedServer.init + this.worldLoadListenerFactory = worldloadlistenerfactory; +- this.convertable = new Convertable(file.toPath(), file.toPath().resolve("../backups"), datafixer); ++ // this.convertable = new Convertable(file.toPath(), file.toPath().resolve("../backups"), datafixer); // CraftBukkit - moved to DedicatedServer.init this.dataConverterManager = datafixer; - this.ac.a((IResourcePackListener) this.ah); - this.ac.a((IResourcePackListener) this.ag); - this.ac.a((IResourcePackListener) this.ak); - this.ac.a((IResourcePackListener) this.am); - this.ac.a((IResourcePackListener) this.al); + this.ae.a((IReloadListener) this.aj); + this.ae.a((IReloadListener) this.ai); +@@ -163,7 +184,32 @@ + this.ae.a((IReloadListener) this.an); + this.executorService = SystemUtils.e(); + this.K = s; + // CraftBukkit start + this.options = options; + // Try to see if we're actually running in a terminal, disable jline if not @@ -93,53 +103,48 @@ + } + } + Runtime.getRuntime().addShutdownHook(new org.bukkit.craftbukkit.util.ServerShutdownThread(this)); -+ -+ this.serverThread = primaryThread = new Thread(this, "Server thread"); // Moved from main } - -+ public abstract PropertyManager getPropertyManager(); + // CraftBukkit end -+ - public abstract boolean init() throws IOException; - public void convertWorld(String s) { -@@ -175,11 +226,11 @@ + private void initializeScoreboards(WorldPersistentData worldpersistentdata) { + PersistentScoreboard persistentscoreboard = (PersistentScoreboard) worldpersistentdata.a(PersistentScoreboard::new, "scoreboard"); +@@ -199,11 +245,11 @@ } if (this.forceUpgrade) { - MinecraftServer.LOGGER.info("Forcing world upgrade!"); -- WorldData worlddata = this.getConvertable().c(this.getWorld()); +- WorldData worlddata = this.getConvertable().b(this.getWorld()); + MinecraftServer.LOGGER.info("Forcing world upgrade! {}", s); // CraftBukkit -+ WorldData worlddata = this.getConvertable().c(s); // CraftBukkit ++ WorldData worlddata = this.getConvertable().b(s); // CraftBukkit if (worlddata != null) { -- WorldUpgrader worldupgrader = new WorldUpgrader(this.getWorld(), this.getConvertable(), worlddata); -+ WorldUpgrader worldupgrader = new WorldUpgrader(s, this.getConvertable(), worlddata); // CraftBukkit +- WorldUpgrader worldupgrader = new WorldUpgrader(this.getWorld(), this.getConvertable(), worlddata, this.as); ++ WorldUpgrader worldupgrader = new WorldUpgrader(s, this.getConvertable(), worlddata, this.as); // CraftBukkit IChatBaseComponent ichatbasecomponent = null; while (!worldupgrader.b()) { -@@ -218,8 +269,9 @@ +@@ -242,8 +288,9 @@ } - public void a(String s, String s1, long i, WorldType worldtype, JsonElement jsonelement) { + protected void a(String s, String s1, long i, WorldType worldtype, JsonElement jsonelement) { - this.convertWorld(s); + // this.convertWorld(s); // CraftBukkit - moved down this.b((IChatBaseComponent) (new ChatMessage("menu.loadingLevel", new Object[0]))); + /* CraftBukkit start - Remove ticktime arrays and worldsettings - IDataManager idatamanager = this.getConvertable().a(s, this); + WorldNBTStorage worldnbtstorage = this.getConvertable().a(s, this); - this.a(this.getWorld(), idatamanager); -@@ -244,54 +296,145 @@ + this.a(this.getWorld(), worldnbtstorage); +@@ -268,24 +315,134 @@ } - this.a(idatamanager.getDirectory(), worlddata); -- PersistentCollection persistentcollection = new PersistentCollection(idatamanager); + this.a(worldnbtstorage.getDirectory(), worlddata); +- WorldLoadListener worldloadlistener = this.worldLoadListenerFactory.create(11); + */ + int worldCount = 3; -- this.a(idatamanager, persistentcollection, worlddata, worldsettings); -- this.a(this.getDifficulty()); -- this.a(persistentcollection); +- this.a(worldnbtstorage, worlddata, worldsettings, worldloadlistener); +- this.a(this.getDifficulty(), true); +- this.loadSpawn(worldloadlistener); - } + for (int j = 0; j < worldCount; ++j) { + WorldServer world; @@ -153,13 +158,7 @@ + continue; + } + } - -- protected void a(IDataManager idatamanager, PersistentCollection persistentcollection, WorldData worlddata, WorldSettings worldsettings) { -- if (this.L()) { -- this.worldServer.put(DimensionManager.OVERWORLD, (new DemoWorldServer(this, idatamanager, persistentcollection, worlddata, DimensionManager.OVERWORLD, this.methodProfiler)).i_()); -- } else { -- this.worldServer.put(DimensionManager.OVERWORLD, (new WorldServer(this, idatamanager, persistentcollection, worlddata, DimensionManager.OVERWORLD, this.methodProfiler)).i_()); -- } ++ + if (j == 2) { + if (server.getAllowEnd()) { + dimension = 1; @@ -167,7 +166,10 @@ + continue; + } + } -+ + +- protected void a(WorldNBTStorage worldnbtstorage, WorldData worlddata, WorldSettings worldsettings, WorldLoadListener worldloadlistener) { +- if (this.isDemoMode()) { +- worlddata.a(MinecraftServer.c); + String worldType = org.bukkit.World.Environment.getEnvironment(dimension).toString().toLowerCase(); + String name = (dimension == 0) ? s : s + "_" + worldType; + this.convertWorld(name); // Run conversion now @@ -177,33 +179,27 @@ + worldsettings.setGeneratorSettings(jsonelement); + + if (j == 0) { -+ IDataManager idatamanager = new ServerNBTManager(server.getWorldContainer(), s1, this, this.dataConverterManager); -+ worlddata = idatamanager.getWorldData(); ++ WorldNBTStorage worldnbtstorage = new WorldNBTStorage(server.getWorldContainer(), s1, this, this.dataConverterManager); ++ worlddata = worldnbtstorage.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) -+ this.a(idatamanager.getDirectory(), worlddata); -+ PersistentCollection persistentcollection = new PersistentCollection(idatamanager); - -- WorldServer worldserver = this.getWorldServer(DimensionManager.OVERWORLD); -+ if (this.L()) { -+ world = (WorldServer) (new DemoWorldServer(this, idatamanager, persistentcollection, worlddata, DimensionManager.OVERWORLD, this.methodProfiler)).i_(); -+ } else { -+ world = (WorldServer) (new WorldServer(this, idatamanager, persistentcollection, worlddata, DimensionManager.OVERWORLD, this.methodProfiler, org.bukkit.World.Environment.getEnvironment(dimension), gen)).i_(); ++ this.a(worldnbtstorage.getDirectory(), worlddata); ++ WorldLoadListener worldloadlistener = this.worldLoadListenerFactory.create(11); ++ ++ if (this.isDemoMode()) { ++ worlddata.a(MinecraftServer.c); + } - -- worldserver.a(worldsettings); -- worldserver.addIWorldAccess(new WorldManager(this, worldserver)); -- if (!this.H()) { -- worldserver.getWorldData().setGameType(this.getGamemode()); -- } -+ world.a(worldsettings); ++ world = new WorldServer(this, this.executorService, worldnbtstorage, worlddata, DimensionManager.OVERWORLD, this.methodProfiler, worldloadlistener, org.bukkit.World.Environment.getEnvironment(dimension), gen); ++ ++ this.initializeScoreboards(world.getWorldPersistentData()); + this.server.scoreboardManager = new org.bukkit.craftbukkit.scoreboard.CraftScoreboardManager(this, world.getScoreboard()); ++ ++ this.initWorld(world, worlddata, worldsettings); + } else { + String dim = "DIM" + dimension; - -- SecondaryWorldServer secondaryworldserver = (new SecondaryWorldServer(this, idatamanager, DimensionManager.NETHER, worldserver, this.methodProfiler)).i_(); ++ + File newWorld = new File(new File(name), dim); + File oldWorld = new File(new File(s), dim); + File oldLevelDat = new File(new File(s), "level.dat"); // The data folders exist on first run as they are created in the PersistentCollection constructor above, but the level.dat won't @@ -237,51 +233,81 @@ + MinecraftServer.LOGGER.info("---- Migration of old " + worldType + " folder failed ----"); + } + } - -- this.worldServer.put(DimensionManager.NETHER, secondaryworldserver); -- secondaryworldserver.addIWorldAccess(new WorldManager(this, secondaryworldserver)); -- if (!this.H()) { -- secondaryworldserver.getWorldData().setGameType(this.getGamemode()); -- } -+ IDataManager idatamanager = new ServerNBTManager(server.getWorldContainer(), name, this, this.dataConverterManager); ++ ++ WorldNBTStorage worldnbtstorage = new WorldNBTStorage(server.getWorldContainer(), name, this, this.dataConverterManager); + // world =, b0 to dimension, s1 to name, added Environment and gen -+ worlddata = idatamanager.getWorldData(); ++ worlddata = worldnbtstorage.getWorldData(); + if (worlddata == null) { + worlddata = new WorldData(worldsettings, name); + } + worlddata.checkName(name); // 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) -+ world = (WorldServer) new SecondaryWorldServer(this, idatamanager, DimensionManager.a(dimension), this.getWorldServer(DimensionManager.OVERWORLD), this.methodProfiler, worlddata, org.bukkit.World.Environment.getEnvironment(dimension), gen).i_(); ++ WorldLoadListener worldloadlistener = this.worldLoadListenerFactory.create(11); ++ world = new SecondaryWorldServer(this.getWorldServer(DimensionManager.OVERWORLD), this, this.executorService, worldnbtstorage, DimensionManager.a(dimension), this.methodProfiler, worldloadlistener, worlddata, org.bukkit.World.Environment.getEnvironment(dimension), gen); + } - -- SecondaryWorldServer secondaryworldserver1 = (new SecondaryWorldServer(this, idatamanager, DimensionManager.THE_END, worldserver, this.methodProfiler)).i_(); ++ + this.server.getPluginManager().callEvent(new org.bukkit.event.world.WorldInitEvent(world.getWorld())); - -- this.worldServer.put(DimensionManager.THE_END, secondaryworldserver1); -- secondaryworldserver1.addIWorldAccess(new WorldManager(this, secondaryworldserver1)); -- if (!this.H()) { -- secondaryworldserver1.getWorldData().setGameType(this.getGamemode()); -- } -+ world.addIWorldAccess(new WorldManager(this, world)); -+ if (!this.H()) { -+ world.getWorldData().setGameType(this.getGamemode()); -+ } + + this.worldServer.put(world.dimension, world); + this.getPlayerList().setPlayerFileData(world); - -- this.getPlayerList().setPlayerFileData(worldserver); -- if (worlddata.P() != null) { -- this.getBossBattleCustomData().a(worlddata.P()); -+ if (worlddata.P() != null) { -+ this.getBossBattleCustomData().a(worlddata.P()); ++ ++ if (worlddata.getCustomBossEvents() != null) { ++ this.getBossBattleCustomData().a(worlddata.getCustomBossEvents()); + } ++ } ++ this.a(this.getDifficulty(), true); ++ for (WorldServer worldserver : this.getWorlds()) { ++ this.loadSpawn(worldserver.getChunkProvider().playerChunkMap.worldLoadListener, worldserver); } -+ this.a(this.getDifficulty()); -+ this.a(this.getWorldServer(DimensionManager.OVERWORLD).worldMaps); + +- WorldServer worldserver = new WorldServer(this, this.executorService, worldnbtstorage, worlddata, DimensionManager.OVERWORLD, this.methodProfiler, worldloadlistener); ++ this.server.enablePlugins(org.bukkit.plugin.PluginLoadOrder.POSTWORLD); ++ this.server.getPluginManager().callEvent(new ServerLoadEvent(ServerLoadEvent.LoadType.STARTUP)); + // CraftBukkit end - } +- this.worldServer.put(DimensionManager.OVERWORLD, worldserver); +- this.initializeScoreboards(worldserver.getWorldPersistentData()); +- worldserver.getWorldBorder().b(worlddata); +- WorldServer worldserver1 = this.getWorldServer(DimensionManager.OVERWORLD); ++ } ++ ++ // CraftBukkit start ++ public void initWorld(WorldServer worldserver1, WorldData worlddata, WorldSettings worldsettings) { ++ worldserver1.getWorldBorder().b(worlddata); ++ ++ // CraftBukkit start ++ if (worldserver1.generator != null) { ++ worldserver1.getWorld().getPopulators().addAll(worldserver1.generator.getDefaultPopulators(worldserver1.getWorld())); ++ } ++ // CraftBukkit end + if (!worlddata.v()) { + try { +@@ -309,23 +466,8 @@ + + worlddata.d(true); + } +- +- this.getPlayerList().setPlayerFileData(worldserver1); +- if (worlddata.getCustomBossEvents() != null) { +- this.getBossBattleCustomData().a(worlddata.getCustomBossEvents()); +- } +- +- Iterator iterator = DimensionManager.a().iterator(); +- +- while (iterator.hasNext()) { +- DimensionManager dimensionmanager = (DimensionManager) iterator.next(); +- +- if (dimensionmanager != DimensionManager.OVERWORLD) { +- this.worldServer.put(dimensionmanager, new SecondaryWorldServer(worldserver1, this, this.executorService, worldnbtstorage, dimensionmanager, this.methodProfiler, worldloadlistener)); +- } +- } +- + } ++ // CraftBukkit end + + private void a(WorldData worlddata) { + worlddata.f(false); +@@ -344,6 +486,25 @@ protected void a(File file, WorldData worlddata) { this.resourcePackRepository.a((ResourcePackSource) (new ResourcePackSourceVanilla())); this.resourcePackFolder = new ResourcePackSourceFolder(new File(file, "datapacks")); @@ -307,107 +333,65 @@ this.resourcePackRepository.a((ResourcePackSource) this.resourcePackFolder); this.resourcePackRepository.a(); List list = Lists.newArrayList(); -@@ -320,42 +463,52 @@ - boolean flag4 = true; +@@ -364,11 +525,13 @@ + this.b(worlddata); + } +- public void loadSpawn(WorldLoadListener worldloadlistener) { ++ // CraftBukkit start ++ public void loadSpawn(WorldLoadListener worldloadlistener, WorldServer worldserver) { this.b((IChatBaseComponent) (new ChatMessage("menu.generatingTerrain", new Object[0]))); - WorldServer worldserver = this.getWorldServer(DimensionManager.OVERWORLD); ++ // WorldServer worldserver = this.getWorldServer(DimensionManager.OVERWORLD); ++ // CraftBukkit end - MinecraftServer.LOGGER.info("Preparing start region for dimension " + DimensionManager.a(worldserver.worldProvider.getDimensionManager())); -- BlockPosition blockposition = worldserver.getSpawn(); -- List list = Lists.newArrayList(); -- Set set = Sets.newConcurrentHashSet(); -+ // CraftBukkit start - fire WorldLoadEvent and handle whether or not to keep the spawn in memory - Stopwatch stopwatch = Stopwatch.createStarted(); -- -- for (int i = -192; i <= 192 && this.isRunning(); i += 16) { -- for (int j = -192; j <= 192 && this.isRunning(); j += 16) { -- list.add(new ChunkCoordIntPair(blockposition.getX() + i >> 4, blockposition.getZ() + j >> 4)); -+ for (WorldServer worldserver : this.getWorlds()) { -+ MinecraftServer.LOGGER.info("Preparing start region for level " + worldserver.dimension + " (Seed: " + worldserver.getSeed() + ")"); -+ if (!worldserver.getWorld().getKeepSpawnInMemory()) { -+ continue; - } ++ MinecraftServer.LOGGER.info("Preparing start region for dimension '{}'/{}", worldserver.getWorldData().getName(), DimensionManager.a(worldserver.worldProvider.getDimensionManager())); // CraftBukkit + BlockPosition blockposition = worldserver.getSpawn(); -- CompletableFuture completablefuture = worldserver.getChunkProvider().a((Iterable) list, (chunk) -> { -- set.add(chunk.getPos()); -- }); -+ BlockPosition blockposition = worldserver.getSpawn(); -+ List list = Lists.newArrayList(); -+ Set set = Sets.newConcurrentHashSet(); + worldloadlistener.a(new ChunkCoordIntPair(blockposition)); +@@ -385,11 +548,13 @@ + + this.nextTick += 100L; + this.sleepForTick(); +- Iterator iterator = DimensionManager.a().iterator(); ++ // CraftBukkit start ++ // Iterator iterator = DimensionManager.a().iterator(); + +- while (iterator.hasNext()) { +- DimensionManager dimensionmanager = (DimensionManager) iterator.next(); +- ForcedChunk forcedchunk = (ForcedChunk) this.getWorldServer(dimensionmanager).getWorldPersistentData().b(ForcedChunk::new, "chunks"); ++ if (true) { ++ DimensionManager dimensionmanager = worldserver.worldProvider.getDimensionManager(); ++ // CraftBukkit end ++ ForcedChunk forcedchunk = (ForcedChunk) worldserver.getWorldPersistentData().b(ForcedChunk::new, "chunks"); + + if (forcedchunk != null) { + WorldServer worldserver1 = this.getWorldServer(dimensionmanager); +@@ -408,6 +573,8 @@ + this.sleepForTick(); + worldloadlistener.b(); + chunkproviderserver.getLightEngine().a(5); + -+ for (int i = -192; i <= 192 && this.isRunning(); i += 16) { -+ for (int j = -192; j <= 192 && this.isRunning(); j += 16) { -+ list.add(new ChunkCoordIntPair(blockposition.getX() + i >> 4, blockposition.getZ() + j >> 4)); -+ } - -- while (!completablefuture.isDone()) { -- try { -- completablefuture.get(1L, TimeUnit.SECONDS); -- } catch (InterruptedException interruptedexception) { -- throw new RuntimeException(interruptedexception); -- } catch (ExecutionException executionexception) { -- if (executionexception.getCause() instanceof RuntimeException) { -- throw (RuntimeException) executionexception.getCause(); -- } -+ CompletableFuture completablefuture = worldserver.getChunkProvider().a((Iterable) list, (chunk) -> { -+ set.add(chunk.getPos()); -+ }); - -- throw new RuntimeException(executionexception.getCause()); -- } catch (TimeoutException timeoutexception) { -- this.a(new ChatMessage("menu.preparingSpawn", new Object[0]), set.size() * 100 / 625); -+ while (!completablefuture.isDone()) { -+ try { -+ completablefuture.get(1L, TimeUnit.SECONDS); -+ } catch (InterruptedException interruptedexception) { -+ throw new RuntimeException(interruptedexception); -+ } catch (ExecutionException executionexception) { -+ if (executionexception.getCause() instanceof RuntimeException) { -+ throw (RuntimeException) executionexception.getCause(); -+ } -+ -+ throw new RuntimeException(executionexception.getCause()); -+ } catch (TimeoutException timeoutexception) { -+ this.a(new ChatMessage("menu.preparingSpawn", new Object[0]), set.size() * 100 / 625); -+ } - } -- } - -- this.a(new ChatMessage("menu.preparingSpawn", new Object[0]), set.size() * 100 / 625); -+ this.a(new ChatMessage("menu.preparingSpawn", new Object[0]), set.size() * 100 / 625); -+ } - } - -+ for (WorldServer world : this.getWorlds()) { -+ this.server.getPluginManager().callEvent(new org.bukkit.event.world.WorldLoadEvent(world.getWorld())); -+ } -+ // CraftBukkit end - MinecraftServer.LOGGER.info("Time elapsed: {} ms", stopwatch.elapsed(TimeUnit.MILLISECONDS)); - Iterator iterator = DimensionManager.b().iterator(); - -@@ -414,6 +567,10 @@ - protected void l() { - this.w = null; - this.x = 0; -+ // CraftBukkit Start -+ this.server.enablePlugins(org.bukkit.plugin.PluginLoadOrder.POSTWORLD); -+ this.server.getPluginManager().callEvent(new ServerLoadEvent(ServerLoadEvent.LoadType.STARTUP)); -+ // CraftBukkit end ++ this.server.getPluginManager().callEvent(new org.bukkit.event.world.WorldLoadEvent(worldserver.getWorld())); // CraftBukkit } - protected void saveChunks(boolean flag) { -@@ -437,8 +594,24 @@ - + protected void a(String s, WorldNBTStorage worldnbtstorage) { +@@ -466,8 +633,29 @@ + this.stop(); } -- protected void stop() { + // CraftBukkit start + private boolean hasStopped = false; + private final Object stopLock = new Object(); ++ public final boolean hasStopped() { ++ synchronized (stopLock) { ++ return hasStopped; ++ } ++ } + // CraftBukkit end + -+ public void stop() throws ExceptionWorldConflict { // CraftBukkit - added throws + protected void stop() { + // CraftBukkit start - prevent double stopping on multiple threads + synchronized(stopLock) { + if (hasStopped) return; @@ -423,15 +407,15 @@ if (this.getServerConnection() != null) { this.getServerConnection().b(); } -@@ -447,6 +620,7 @@ +@@ -476,6 +664,7 @@ MinecraftServer.LOGGER.info("Saving players"); this.playerList.savePlayers(); - this.playerList.u(); + this.playerList.shutdown(); + try { Thread.sleep(100); } catch (InterruptedException ex) {} // CraftBukkit - SPIGOT-625 - give server at least a chance to send packets } MinecraftServer.LOGGER.info("Saving worlds"); -@@ -511,11 +685,13 @@ +@@ -548,11 +737,13 @@ if (i > 2000L && this.nextTick - this.lastOverloadTime >= 15000L) { long j = i / 50L; @@ -442,10 +426,10 @@ } + MinecraftServer.currentTick = (int) (System.currentTimeMillis() / 50); // CraftBukkit - this.a(this::canSleepForTick); this.nextTick += 50L; - -@@ -554,6 +730,12 @@ + if (this.T) { + this.T = false; +@@ -599,6 +790,12 @@ } catch (Throwable throwable1) { MinecraftServer.LOGGER.error("Exception stopping the server", throwable1); } finally { @@ -455,27 +439,24 @@ + } catch (Exception ignored) { + } + // CraftBukkit end - this.t(); + this.exit(); } -@@ -622,7 +804,7 @@ - this.m.b().a(agameprofile); +@@ -709,7 +906,7 @@ + this.serverPing.b().a(agameprofile); } -- if (this.ticks % 900 == 0) { +- if (this.ticks % 6000 == 0) { + if (autosavePeriod > 0 && this.ticks % autosavePeriod == 0) { // CraftBukkit + MinecraftServer.LOGGER.debug("Autosave started"); this.methodProfiler.enter("save"); this.playerList.savePlayers(); - this.saveChunks(true); -@@ -648,6 +830,7 @@ +@@ -739,27 +936,43 @@ } - public void b(BooleanSupplier booleansupplier) { + protected void b(BooleanSupplier booleansupplier) { + this.server.getScheduler().mainThreadHeartbeat(this.ticks); // CraftBukkit - this.methodProfiler.enter("jobs"); - - FutureTask futuretask; -@@ -660,23 +843,40 @@ + this.methodProfiler.enter("commandFunctions"); this.getFunctionData().tick(); this.methodProfiler.exitEnter("levels"); @@ -486,8 +467,6 @@ + processQueue.remove().run(); + } + -+ org.bukkit.craftbukkit.chunkio.ChunkIOExecutor.tick(); -+ + // Send time updates to everyone, it will get the right time from the world the player is in. + if (this.ticks % 20 == 0) { + for (int i = 0; i < this.getPlayerList().players.size(); ++i) { @@ -499,18 +478,18 @@ + // WorldServer worldserver; // CraftBukkit - dropped down long i; -- for (Iterator iterator = this.getWorlds().iterator(); iterator.hasNext();((long[]) this.e.computeIfAbsent(worldserver.worldProvider.getDimensionManager(), (dimensionmanager) -> { +- for (Iterator iterator = this.getWorlds().iterator(); iterator.hasNext();((long[]) this.g.computeIfAbsent(worldserver.worldProvider.getDimensionManager(), (dimensionmanager) -> { - return new long[100]; - }))[this.ticks % 100] = SystemUtils.getMonotonicNanos() - i) { - worldserver = (WorldServer) iterator.next(); + // CraftBukkit - dropTickTime + for (Iterator iterator = this.getWorlds().iterator(); iterator.hasNext();) { -+ WorldServer worldserver = (WorldServer) iterator.next(); ++ WorldServer worldserver = (WorldServer) iterator.next(); i = SystemUtils.getMonotonicNanos(); - if (worldserver.worldProvider.getDimensionManager() == DimensionManager.OVERWORLD || this.getAllowNether()) { + if (true || worldserver.worldProvider.getDimensionManager() == DimensionManager.OVERWORLD || this.getAllowNether()) { // CraftBukkit this.methodProfiler.a(() -> { - return "dim-" + worldserver.worldProvider.getDimensionManager().getDimensionID(); + return worldserver.getWorldData().getName() + " " + IRegistry.DIMENSION_TYPE.getKey(worldserver.worldProvider.getDimensionManager()); }); + /* Drop global time updates if (this.ticks % 20 == 0) { @@ -522,91 +501,92 @@ this.methodProfiler.enter("tick"); -@@ -727,10 +927,11 @@ - this.k.add(itickable); +@@ -798,7 +1011,8 @@ + this.tickables.add(runnable); } - public static void main(String[] astring) { -+ public static void main(final OptionSet options) { // CraftBukkit - replaces main(String[] astring) - DispenserRegistry.c(); - - try { -+ /* CraftBukkit start - Replace everything - boolean flag = true; - String s = null; - String s1 = "."; -@@ -778,13 +979,16 @@ - ++j; - } ++ public static void main(final OptionSet optionset) { // CraftBukkit - replaces main(String[] astring) ++ /* CraftBukkit start - Replace everything + OptionParser optionparser = new OptionParser(); + OptionSpec optionspec = optionparser.accepts("nogui"); + OptionSpec optionspec1 = optionparser.accepts("initSettings", "Initializes 'server.properties' and 'eula.txt', then quits"); +@@ -821,15 +1035,17 @@ + optionparser.printHelpOn(System.err); + return; } + */ // CraftBukkit end -+ String s1 = "."; // PAIL? ++ try { + java.nio.file.Path java_nio_file_path = Paths.get("server.properties"); +- DedicatedServerSettings dedicatedserversettings = new DedicatedServerSettings(java_nio_file_path); ++ DedicatedServerSettings dedicatedserversettings = new DedicatedServerSettings(optionset); // CraftBukkit - CLI argument support + + dedicatedserversettings.save(); + java.nio.file.Path java_nio_file_path1 = Paths.get("eula.txt"); + EULA eula = new EULA(java_nio_file_path1); + +- if (optionset.has(optionspec1)) { ++ if (optionset.has("initSettings")) { // CraftBukkit + MinecraftServer.LOGGER.info("Initialized '" + java_nio_file_path.toAbsolutePath().toString() + "' and '" + java_nio_file_path1.toAbsolutePath().toString() + "'"); + return; + } +@@ -841,14 +1057,15 @@ + + DispenserRegistry.init(); + DispenserRegistry.c(); +- String s = (String) optionset.valueOf(optionspec8); ++ String s = "."; // 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); + UserCache usercache = new UserCache(gameprofilerepository, new File(s, MinecraftServer.b.getName())); +- String s1 = (String) Optional.ofNullable(optionset.valueOf(optionspec9)).orElse(dedicatedserversettings.getProperties().levelName); +- final DedicatedServer dedicatedserver = new DedicatedServer(new File(s), dedicatedserversettings, DataConverterRegistry.a(), yggdrasilauthenticationservice, minecraftsessionservice, gameprofilerepository, usercache, WorldLoadListenerLogger::new, s1); ++ String s1 = (String) Optional.ofNullable(optionset.valueOf("world")).orElse(dedicatedserversettings.getProperties().levelName); ++ final DedicatedServer dedicatedserver = new DedicatedServer(optionset, dedicatedserversettings, DataConverterRegistry.a(), yggdrasilauthenticationservice, minecraftsessionservice, gameprofilerepository, usercache, WorldLoadListenerLogger::new, s1); + /* CraftBukkit start - if (s != null) { - dedicatedserver.h(s); - } -@@ -822,6 +1026,29 @@ + dedicatedserver.i((String) optionset.valueOf(optionspec7)); + dedicatedserver.setPort((Integer) optionset.valueOf(optionspec10)); + dedicatedserver.e(optionset.has(optionspec2)); +@@ -871,6 +1088,25 @@ thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(MinecraftServer.LOGGER)); Runtime.getRuntime().addShutdownHook(thread); + */ + -+ if (options.has("port")) { -+ int port = (Integer) options.valueOf("port"); ++ if (optionset.has("port")) { ++ int port = (Integer) optionset.valueOf("port"); + if (port > 0) { + dedicatedserver.setPort(port); + } + } + -+ if (options.has("universe")) { -+ dedicatedserver.universe = (File) options.valueOf("universe"); ++ if (optionset.has("universe")) { ++ dedicatedserver.universe = (File) optionset.valueOf("universe"); + } + -+ if (options.has("world")) { -+ dedicatedserver.setWorld((String) options.valueOf("world")); -+ } -+ -+ if (options.has("forceUpgrade")) { ++ if (optionset.has("forceUpgrade")) { + dedicatedserver.setForceUpgrade(true); + } + -+ dedicatedserver.primaryThread.start(); ++ dedicatedserver.serverThread.start(); + // CraftBukkit end } catch (Exception exception) { MinecraftServer.LOGGER.fatal("Failed to start the minecraft server", exception); } -@@ -833,11 +1060,13 @@ +@@ -890,7 +1126,9 @@ } - public void v() { + public void startServerThread() { + /* CraftBukkit start - prevent abuse - this.serverThread = new Thread(this, "Server thread"); - this.serverThread.setUncaughtExceptionHandler((thread, throwable) -> { - MinecraftServer.LOGGER.error(throwable); - }); this.serverThread.start(); + // CraftBukkit end */ } - public File c(String s) { -@@ -877,7 +1106,7 @@ - } - - public boolean isDebugging() { -- return false; -+ return this.getPropertyManager().getBoolean("debug", false); // CraftBukkit - don't hardcode - } - - public void f(String s) { -@@ -892,7 +1121,7 @@ + public File d(String s) { +@@ -945,7 +1183,7 @@ } public String getServerModName() { @@ -615,39 +595,26 @@ } public CrashReport b(CrashReport crashreport) { -@@ -928,7 +1157,7 @@ +@@ -984,7 +1222,7 @@ } - public boolean D() { + public boolean E() { - return this.universe != null; + return true; // CraftBukkit } - public void sendMessage(IChatBaseComponent ichatbasecomponent) { -@@ -1068,7 +1297,7 @@ - public abstract boolean Q(); - - public boolean getOnlineMode() { -- return this.onlineMode; -+ return server.getOnlineMode(); // CraftBukkit + @Override +@@ -1480,4 +1718,16 @@ } - public void setOnlineMode(boolean flag) { -@@ -1228,7 +1457,7 @@ - - public ListenableFuture a(Callable callable) { - Validate.notNull(callable); -- if (!this.isMainThread() && !this.isStopped()) { -+ if (!this.isMainThread()) { // CraftBukkit && !this.isStopped()) { - ListenableFutureTask listenablefuturetask = ListenableFutureTask.create(callable); - - this.f.add(listenablefuturetask); -@@ -1411,4 +1640,11 @@ - return 0; - } - } + public abstract boolean b(GameProfile gameprofile); + + // CraftBukkit start ++ @Override ++ public boolean isMainThread() { ++ return super.isMainThread() || this.isStopped(); // CraftBukkit - MC-142590 ++ } ++ + @Deprecated + public static MinecraftServer getServer() { + return (Bukkit.getServer() instanceof CraftServer) ? ((CraftServer) Bukkit.getServer()).getServer() : null; diff --git a/nms-patches/MobEffectList.patch b/nms-patches/MobEffectList.patch index ff95cf402e..b06d95ac84 100644 --- a/nms-patches/MobEffectList.patch +++ b/nms-patches/MobEffectList.patch @@ -12,7 +12,7 @@ public class MobEffectList { private final Map a = Maps.newHashMap(); -@@ -24,7 +29,7 @@ +@@ -21,7 +26,7 @@ } public static int getId(MobEffectList mobeffectlist) { @@ -20,8 +20,8 @@ + return IRegistry.MOB_EFFECT.a(mobeffectlist); // CraftBukkit - decompile error } - protected MobEffectList(boolean flag, int i) { -@@ -46,11 +51,11 @@ + protected MobEffectList(MobEffectInfo mobeffectinfo, int i) { +@@ -32,11 +37,11 @@ public void tick(EntityLiving entityliving, int i) { if (this == MobEffects.REGENERATION) { if (entityliving.getHealth() < entityliving.getMaxHealth()) { @@ -35,7 +35,7 @@ } } else if (this == MobEffects.WITHER) { entityliving.damageEntity(DamageSource.WITHER, 1.0F); -@@ -58,14 +63,25 @@ +@@ -44,14 +49,25 @@ ((EntityHuman) entityliving).applyExhaustion(0.005F * (float) (i + 1)); } else if (this == MobEffects.SATURATION && entityliving instanceof EntityHuman) { if (!entityliving.world.isClientSide) { @@ -53,8 +53,8 @@ + ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutUpdateHealth(((EntityPlayer) entityhuman).getBukkitEntity().getScaledHealth(), entityhuman.getFoodData().foodLevel, entityhuman.getFoodData().saturationLevel)); + // CraftBukkit end } - } else if ((this != MobEffects.HEAL || entityliving.cp()) && (this != MobEffects.HARM || !entityliving.cp())) { - if (this == MobEffects.HARM && !entityliving.cp() || this == MobEffects.HEAL && entityliving.cp()) { + } else if ((this != MobEffects.HEAL || entityliving.cB()) && (this != MobEffects.HARM || !entityliving.cB())) { + if (this == MobEffects.HARM && !entityliving.cB() || this == MobEffects.HEAL && entityliving.cB()) { entityliving.damageEntity(DamageSource.MAGIC, (float) (6 << i)); } } else { @@ -63,7 +63,7 @@ } } -@@ -86,7 +102,7 @@ +@@ -72,7 +88,7 @@ } } else { j = (int) (d0 * (double) (4 << i) + 0.5D); @@ -72,15 +72,3 @@ } } -@@ -215,6 +231,11 @@ - a(28, "slow_falling", (new MobEffectList(false, 16773073)).b(8, 0).l()); - a(29, "conduit_power", (new MobEffectList(false, 1950417)).b(9, 0).l()); - a(30, "dolphins_grace", (new MobEffectList(false, 8954814)).b(10, 0).l()); -+ // CraftBukkit start -+ for (Object effect : IRegistry.MOB_EFFECT) { -+ org.bukkit.potion.PotionEffectType.registerPotionEffectType(new org.bukkit.craftbukkit.potion.CraftPotionEffectType((MobEffectList) effect)); -+ } -+ // CraftBukkit end - } - - private static void a(int i, String s, MobEffectList mobeffectlist) { diff --git a/nms-patches/MobEffects.patch b/nms-patches/MobEffects.patch new file mode 100644 index 0000000000..07c74ad015 --- /dev/null +++ b/nms-patches/MobEffects.patch @@ -0,0 +1,17 @@ +--- a/net/minecraft/server/MobEffects.java ++++ b/net/minecraft/server/MobEffects.java +@@ -57,6 +57,14 @@ + }); + public static final MobEffectList HERO_OF_THE_VILLAGE = a(32, "hero_of_the_village", new MobEffectList(MobEffectInfo.BENEFICIAL, 4521796)); + ++ // CraftBukkit start ++ static { ++ for (Object effect : IRegistry.MOB_EFFECT) { ++ org.bukkit.potion.PotionEffectType.registerPotionEffectType(new org.bukkit.craftbukkit.potion.CraftPotionEffectType((MobEffectList) effect)); ++ } ++ } ++ // CraftBukkit end ++ + private static MobEffectList a(int i, String s, MobEffectList mobeffectlist) { + return (MobEffectList) IRegistry.a(IRegistry.MOB_EFFECT, i, s, mobeffectlist); + } diff --git a/nms-patches/MobSpawnerAbstract.patch b/nms-patches/MobSpawnerAbstract.patch index e9c46ee505..a9d5124e5e 100644 --- a/nms-patches/MobSpawnerAbstract.patch +++ b/nms-patches/MobSpawnerAbstract.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/MobSpawnerAbstract.java +++ b/net/minecraft/server/MobSpawnerAbstract.java -@@ -41,6 +41,7 @@ +@@ -42,6 +42,7 @@ public void setMobName(EntityTypes entitytypes) { this.spawnData.b().setString("id", IRegistry.ENTITY_TYPE.getKey(entitytypes).toString()); @@ -8,12 +8,12 @@ } private boolean h() { -@@ -110,7 +111,7 @@ - ((EntityInsentient) entity).prepare(world.getDamageScaler(new BlockPosition(entity)), (GroupDataEntity) null, (NBTTagCompound) null); - } +@@ -147,7 +148,7 @@ + } -- ChunkRegionLoader.a(entity, (GeneratorAccess) world); -+ ChunkRegionLoader.a(entity, (GeneratorAccess) world, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER); // CraftBukkit - world.triggerEffect(2004, blockposition, 0); - if (entityinsentient != null) { - entityinsentient.doSpawnEffect(); + private void a(Entity entity) { +- if (this.a().addEntity(entity)) { ++ if (this.a().addEntity(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER)) { // CraftBukkit + Iterator iterator = entity.getPassengers().iterator(); + + while (iterator.hasNext()) { diff --git a/nms-patches/MobSpawnerPhantom.patch b/nms-patches/MobSpawnerPhantom.patch index 4325b4580f..fc91a324c3 100644 --- a/nms-patches/MobSpawnerPhantom.patch +++ b/nms-patches/MobSpawnerPhantom.patch @@ -3,9 +3,9 @@ @@ -54,7 +54,7 @@ entityphantom.setPositionRotation(blockposition1, 0.0F, 0.0F); - groupdataentity = entityphantom.prepare(difficultydamagescaler, groupdataentity, (NBTTagCompound) null); -- world.addEntity(entityphantom); -+ world.addEntity(entityphantom, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); // CraftBukkit + groupdataentity = entityphantom.prepare(worldserver, difficultydamagescaler, EnumMobSpawn.NATURAL, groupdataentity, (NBTTagCompound) null); +- worldserver.addEntity(entityphantom); ++ worldserver.addEntity(entityphantom, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); // CraftBukkit } i += k; diff --git a/nms-patches/NameReferencingFileConverter.patch b/nms-patches/NameReferencingFileConverter.patch index a7b62dab86..3e39582fb2 100644 --- a/nms-patches/NameReferencingFileConverter.patch +++ b/nms-patches/NameReferencingFileConverter.patch @@ -81,8 +81,8 @@ throw new NameReferencingFileConverter.FileConversionException("Could not convert file for " + s2); @@ -464,7 +492,7 @@ - private static File d(PropertyManager propertymanager) { - String s = propertymanager.getString("level-name", "world"); + private static File getPlayersFolder(MinecraftServer minecraftserver) { + String s = minecraftserver.getWorld(); - File file = new File(s); + File file = new File(MinecraftServer.getServer().server.getWorldContainer(), s); // CraftBukkit - Respect container setting diff --git a/nms-patches/NetworkManager.patch b/nms-patches/NetworkManager.patch index 96d80e408a..d65400b9d8 100644 --- a/nms-patches/NetworkManager.patch +++ b/nms-patches/NetworkManager.patch @@ -9,7 +9,7 @@ } public void setPacketListener(PacketListener packetlistener) { -@@ -240,7 +240,7 @@ +@@ -244,7 +244,7 @@ public void close(IChatBaseComponent ichatbasecomponent) { if (this.channel.isOpen()) { diff --git a/nms-patches/PacketDataSerializer.patch b/nms-patches/PacketDataSerializer.patch index 7d514052b2..d6e6bcc1ca 100644 --- a/nms-patches/PacketDataSerializer.patch +++ b/nms-patches/PacketDataSerializer.patch @@ -13,8 +13,8 @@ } public > T a(Class oclass) { -- return ((Enum[]) oclass.getEnumConstants())[this.g()]; -+ return ((T[]) oclass.getEnumConstants())[this.g()]; // CraftBukkit - fix decompile error +- return ((Enum[]) oclass.getEnumConstants())[this.i()]; ++ return ((T[]) oclass.getEnumConstants())[this.i()]; // CraftBukkit - fix decompile error } public PacketDataSerializer a(Enum oenum) { @@ -39,7 +39,7 @@ @@ -263,6 +265,11 @@ ItemStack itemstack = new ItemStack(Item.getById(i), b0); - itemstack.setTag(this.j()); + itemstack.setTag(this.l()); + // CraftBukkit start + if (itemstack.getTag() != null) { + CraftItemStack.setItemMeta(itemstack, CraftItemStack.getItemMeta(itemstack)); diff --git a/nms-patches/PacketPlayOutWorldBorder.patch b/nms-patches/PacketPlayOutWorldBorder.patch index d37e4ec3ee..f9c9ef82d6 100644 --- a/nms-patches/PacketPlayOutWorldBorder.patch +++ b/nms-patches/PacketPlayOutWorldBorder.patch @@ -11,5 +11,5 @@ + this.d = worldborder.getCenterZ() * (worldborder.world.worldProvider instanceof WorldProviderHell ? 8 : 1); + // CraftBukkit end this.f = worldborder.getSize(); - this.e = worldborder.j(); - this.g = worldborder.i(); + this.e = worldborder.k(); + this.g = worldborder.j(); diff --git a/nms-patches/PacketStatusListener.patch b/nms-patches/PacketStatusListener.patch index 4d53d1464e..5eec59eb19 100644 --- a/nms-patches/PacketStatusListener.patch +++ b/nms-patches/PacketStatusListener.patch @@ -17,7 +17,7 @@ public class PacketStatusListener implements PacketStatusInListener { private static final IChatBaseComponent a = new ChatMessage("multiplayer.status.request_handled", new Object[0]); -@@ -19,8 +30,96 @@ +@@ -21,8 +32,96 @@ this.networkManager.close(PacketStatusListener.a); } else { this.d = true; @@ -106,7 +106,7 @@ + ping.setFavicon(event.icon.value); + ping.setMOTD(new ChatComponentText(event.getMotd())); + ping.setPlayerSample(playerSample); -+ int version = minecraftServer.getServerPing().getServerData().getProtocolVersion(); ++ int version = SharedConstants.a().getProtocolVersion(); + ping.setServerInfo(new ServerPing.ServerData(minecraftServer.getServerModName() + " " + minecraftServer.getVersion(), version)); + + this.networkManager.sendPacket(new PacketStatusOutServerInfo(ping)); @@ -114,4 +114,4 @@ + // CraftBukkit end } - public void a(PacketStatusInPing packetstatusinping) { + @Override diff --git a/nms-patches/PathfinderGoalBreakDoor.patch b/nms-patches/PathfinderGoalBreakDoor.patch index 9f16c309a6..062e703faa 100644 --- a/nms-patches/PathfinderGoalBreakDoor.patch +++ b/nms-patches/PathfinderGoalBreakDoor.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/server/PathfinderGoalBreakDoor.java +++ b/net/minecraft/server/PathfinderGoalBreakDoor.java -@@ -44,6 +44,12 @@ +@@ -66,6 +66,12 @@ } - if (this.d == 240 && this.a.world.getDifficulty() == EnumDifficulty.HARD) { + if (this.a == this.f() && this.a(this.entity.world.getDifficulty())) { + // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityBreakDoorEvent(this.a, this.b.getX(), this.b.getY(), this.b.getZ()).isCancelled()) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityBreakDoorEvent(this.entity, this.door).isCancelled()) { + this.c(); + return; + } + // CraftBukkit end - this.a.world.setAir(this.b); - this.a.world.triggerEffect(1021, this.b, 0); - this.a.world.triggerEffect(2001, this.b, Block.getCombinedId(this.a.world.getType(this.b))); + this.entity.world.a(this.door, false); + this.entity.world.triggerEffect(1021, this.door, 0); + this.entity.world.triggerEffect(2001, this.door, Block.getCombinedId(this.entity.world.getType(this.door))); diff --git a/nms-patches/PathfinderGoalBreed.patch b/nms-patches/PathfinderGoalBreed.patch index 1504f5e3f3..9ec21c11b1 100644 --- a/nms-patches/PathfinderGoalBreed.patch +++ b/nms-patches/PathfinderGoalBreed.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/PathfinderGoalBreed.java +++ b/net/minecraft/server/PathfinderGoalBreed.java -@@ -75,11 +75,24 @@ +@@ -82,11 +82,24 @@ EntityAgeable entityageable = this.animal.createChild(this.partner); if (entityageable != null) { @@ -25,20 +25,15 @@ if (entityplayer != null) { entityplayer.a(StatisticList.ANIMALS_BRED); -@@ -92,7 +105,7 @@ +@@ -99,10 +112,14 @@ this.partner.resetLove(); entityageable.setAgeRaw(-24000); entityageable.setPositionRotation(this.animal.locX, this.animal.locY, this.animal.locZ, 0.0F, 0.0F); - this.b.addEntity(entityageable); + this.b.addEntity(entityageable, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - added SpawnReason - Random random = this.animal.getRandom(); - - for (int i = 0; i < 7; ++i) { -@@ -107,7 +120,11 @@ - } - + this.b.broadcastEntityEffect(this.animal, (byte) 18); if (this.b.getGameRules().getBoolean("doMobLoot")) { -- this.b.addEntity(new EntityExperienceOrb(this.b, this.animal.locX, this.animal.locY, this.animal.locZ, random.nextInt(7) + 1)); +- this.b.addEntity(new EntityExperienceOrb(this.b, this.animal.locX, this.animal.locY, this.animal.locZ, this.animal.getRandom().nextInt(7) + 1)); + // CraftBukkit start - use event experience + if (experience > 0) { + this.b.addEntity(new EntityExperienceOrb(this.b, this.animal.locX, this.animal.locY, this.animal.locZ, experience)); diff --git a/nms-patches/PathfinderGoalDefendVillage.patch b/nms-patches/PathfinderGoalDefendVillage.patch index aa468d3474..19cab7c2a6 100644 --- a/nms-patches/PathfinderGoalDefendVillage.patch +++ b/nms-patches/PathfinderGoalDefendVillage.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/PathfinderGoalDefendVillage.java +++ b/net/minecraft/server/PathfinderGoalDefendVillage.java -@@ -32,7 +32,7 @@ - } +@@ -20,7 +20,7 @@ + @Override public void c() { - this.a.setGoalTarget(this.b); + this.a.setGoalTarget(this.b, org.bukkit.event.entity.EntityTargetEvent.TargetReason.DEFEND_VILLAGE, true); // CraftBukkit - reason diff --git a/nms-patches/PathfinderGoalDoorInteract.patch b/nms-patches/PathfinderGoalDoorInteract.patch deleted file mode 100644 index 61ce33240f..0000000000 --- a/nms-patches/PathfinderGoalDoorInteract.patch +++ /dev/null @@ -1,17 +0,0 @@ ---- a/net/minecraft/server/PathfinderGoalDoorInteract.java -+++ b/net/minecraft/server/PathfinderGoalDoorInteract.java -@@ -37,6 +37,14 @@ - IBlockData iblockdata = this.a.world.getType(this.b); - - if (iblockdata.getBlock() instanceof BlockDoor) { -+ // CraftBukkit start - entities opening doors -+ org.bukkit.event.entity.EntityInteractEvent event = new org.bukkit.event.entity.EntityInteractEvent(this.a.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(this.a.world, this.b)); -+ this.a.world.getServer().getPluginManager().callEvent(event); -+ if (event.isCancelled()) { -+ return; -+ } -+ // CaftBukkit end -+ - ((BlockDoor) iblockdata.getBlock()).setDoor(this.a.world, this.b, flag); - } - } diff --git a/nms-patches/PathfinderGoalEatTile.patch b/nms-patches/PathfinderGoalEatTile.patch index ecefdb1899..20990ffd9c 100644 --- a/nms-patches/PathfinderGoalEatTile.patch +++ b/nms-patches/PathfinderGoalEatTile.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/server/PathfinderGoalEatTile.java +++ b/net/minecraft/server/PathfinderGoalEatTile.java -@@ -2,6 +2,10 @@ - +@@ -3,6 +3,10 @@ + import java.util.EnumSet; import java.util.function.Predicate; +// CraftBukkit start @@ -11,17 +11,17 @@ public class PathfinderGoalEatTile extends PathfinderGoal { private static final Predicate a = BlockStatePredicate.a(Blocks.GRASS); -@@ -49,7 +53,8 @@ +@@ -55,7 +59,8 @@ BlockPosition blockposition = new BlockPosition(this.b.locX, this.b.locY, this.b.locZ); if (PathfinderGoalEatTile.a.test(this.c.getType(blockposition))) { - if (this.c.getGameRules().getBoolean("mobGriefing")) { + // CraftBukkit + if (!CraftEventFactory.callEntityChangeBlockEvent(this.b, blockposition, Blocks.AIR.getBlockData(), !this.c.getGameRules().getBoolean("mobGriefing")).isCancelled()) { - this.c.setAir(blockposition, false); + this.c.b(blockposition, false); } -@@ -58,7 +63,8 @@ +@@ -64,7 +69,8 @@ BlockPosition blockposition1 = blockposition.down(); if (this.c.getType(blockposition1).getBlock() == Blocks.GRASS_BLOCK) { diff --git a/nms-patches/PathfinderGoalFollowOwner.patch b/nms-patches/PathfinderGoalFollowOwner.patch index 0abaf53d4f..9b59024045 100644 --- a/nms-patches/PathfinderGoalFollowOwner.patch +++ b/nms-patches/PathfinderGoalFollowOwner.patch @@ -1,34 +1,34 @@ --- a/net/minecraft/server/PathfinderGoalFollowOwner.java +++ b/net/minecraft/server/PathfinderGoalFollowOwner.java -@@ -1,5 +1,11 @@ +@@ -1,6 +1,11 @@ package net.minecraft.server; + import java.util.EnumSet; +// CraftBukkit start +import org.bukkit.Location; +import org.bukkit.craftbukkit.entity.CraftEntity; +import org.bukkit.event.entity.EntityTeleportEvent; +// CraftBukkit end -+ + public class PathfinderGoalFollowOwner extends PathfinderGoal { - private final EntityTameableAnimal b; -@@ -73,7 +79,18 @@ +@@ -80,7 +85,18 @@ for (int l = 0; l <= 4; ++l) { for (int i1 = 0; i1 <= 4; ++i1) { - if ((l < 1 || i1 < 1 || l > 3 || i1 > 3) && this.a(i, j, k, l, i1)) { -- this.b.setPositionRotation((double) ((float) (i + l) + 0.5F), (double) k, (double) ((float) (j + i1) + 0.5F), this.b.yaw, this.b.pitch); + if ((l < 1 || i1 < 1 || l > 3 || i1 > 3) && this.a(new BlockPosition(i + l, k - 1, j + i1))) { +- this.a.setPositionRotation((double) ((float) (i + l) + 0.5F), (double) k, (double) ((float) (j + i1) + 0.5F), this.a.yaw, this.a.pitch); + // CraftBukkit start -+ CraftEntity entity = this.b.getBukkitEntity(); -+ Location to = new Location(entity.getWorld(), (double) ((float) (i + l) + 0.5F), (double) k, (double) ((float) (j + i1) + 0.5F), this.b.yaw, this.b.pitch); ++ CraftEntity entity = this.a.getBukkitEntity(); ++ Location to = new Location(entity.getWorld(), (double) ((float) (i + l) + 0.5F), (double) k, (double) ((float) (j + i1) + 0.5F), this.a.yaw, this.a.pitch); + EntityTeleportEvent event = new EntityTeleportEvent(entity, entity.getLocation(), to); -+ this.b.world.getServer().getPluginManager().callEvent(event); ++ this.a.world.getServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { + return; + } + to = event.getTo(); + -+ this.b.setPositionRotation(to.getX(), to.getY(), to.getZ(), to.getYaw(), to.getPitch()); ++ this.a.setPositionRotation(to.getX(), to.getY(), to.getZ(), to.getYaw(), to.getPitch()); + // CraftBukkit end - this.e.q(); + this.e.o(); return; } diff --git a/nms-patches/PathfinderGoalHorseTrap.patch b/nms-patches/PathfinderGoalHorseTrap.patch index 35e41e6a10..0a910162ac 100644 --- a/nms-patches/PathfinderGoalHorseTrap.patch +++ b/nms-patches/PathfinderGoalHorseTrap.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/server/PathfinderGoalHorseTrap.java +++ b/net/minecraft/server/PathfinderGoalHorseTrap.java -@@ -18,16 +18,17 @@ - this.a.s(false); +@@ -20,16 +20,17 @@ + this.a.r(false); this.a.setTamed(true); this.a.setAgeRaw(0); -- this.a.world.strikeLightning(new EntityLightning(this.a.world, this.a.locX, this.a.locY, this.a.locZ, true)); +- ((WorldServer) this.a.world).strikeLightning(new EntityLightning(this.a.world, this.a.locX, this.a.locY, this.a.locZ, true)); + ((WorldServer) this.a.world).strikeLightning(new EntityLightning(this.a.world, this.a.locX, this.a.locY, this.a.locZ, true), org.bukkit.event.weather.LightningStrikeEvent.Cause.TRAP); // CraftBukkit EntitySkeleton entityskeleton = this.a(difficultydamagescaler, this.a); @@ -21,8 +21,8 @@ entityhorseabstract.f(this.a.getRandom().nextGaussian() * 0.5D, 0.0D, this.a.getRandom().nextGaussian() * 0.5D); } -@@ -42,7 +43,7 @@ - entityhorseskeleton.di(); +@@ -44,7 +45,7 @@ + entityhorseskeleton.setPersistent(); entityhorseskeleton.setTamed(true); entityhorseskeleton.setAgeRaw(0); - entityhorseskeleton.world.addEntity(entityhorseskeleton); @@ -30,7 +30,7 @@ return entityhorseskeleton; } -@@ -59,7 +60,7 @@ +@@ -61,7 +62,7 @@ entityskeleton.setSlot(EnumItemSlot.MAINHAND, EnchantmentManager.a(entityskeleton.getRandom(), entityskeleton.getItemInMainHand(), (int) (5.0F + difficultydamagescaler.d() * (float) entityskeleton.getRandom().nextInt(18)), false)); entityskeleton.setSlot(EnumItemSlot.HEAD, EnchantmentManager.a(entityskeleton.getRandom(), entityskeleton.getEquipment(EnumItemSlot.HEAD), (int) (5.0F + difficultydamagescaler.d() * (float) entityskeleton.getRandom().nextInt(18)), false)); diff --git a/nms-patches/PathfinderGoalHurtByTarget.patch b/nms-patches/PathfinderGoalHurtByTarget.patch index 1e4a1a137e..5c84e4bac2 100644 --- a/nms-patches/PathfinderGoalHurtByTarget.patch +++ b/nms-patches/PathfinderGoalHurtByTarget.patch @@ -1,19 +1,19 @@ --- a/net/minecraft/server/PathfinderGoalHurtByTarget.java +++ b/net/minecraft/server/PathfinderGoalHurtByTarget.java -@@ -24,7 +24,7 @@ - } +@@ -49,7 +49,7 @@ + @Override 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.g = this.e.getGoalTarget(); - this.b = this.e.cg(); + this.c = this.e.cs(); this.h = 300; -@@ -66,6 +66,6 @@ +@@ -95,6 +95,6 @@ } - protected void a(EntityCreature entitycreature, EntityLiving entityliving) { -- entitycreature.setGoalTarget(entityliving); -+ entitycreature.setGoalTarget(entityliving, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_NEARBY_ENTITY, true); // CraftBukkit - reason + protected void a(EntityInsentient entityinsentient, EntityLiving entityliving) { +- entityinsentient.setGoalTarget(entityliving); ++ entityinsentient.setGoalTarget(entityliving, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_NEARBY_ENTITY, true); // CraftBukkit - reason } } diff --git a/nms-patches/PathfinderGoalMakeLove.patch b/nms-patches/PathfinderGoalMakeLove.patch deleted file mode 100644 index 58d75f1913..0000000000 --- a/nms-patches/PathfinderGoalMakeLove.patch +++ /dev/null @@ -1,23 +0,0 @@ ---- a/net/minecraft/server/PathfinderGoalMakeLove.java -+++ b/net/minecraft/server/PathfinderGoalMakeLove.java -@@ -80,6 +80,11 @@ - - private void i() { - EntityVillager entityvillager = this.a.createChild(this.b); -+ // CraftBukkit start - call EntityBreedEvent -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityBreedEvent(entityvillager, this.a, this.b, null, null, 0).isCancelled()) { -+ return; -+ } -+ // CraftBukkit end - - this.b.setAgeRaw(6000); - this.a.setAgeRaw(6000); -@@ -87,7 +92,7 @@ - this.a.v(false); - entityvillager.setAgeRaw(-24000); - entityvillager.setPositionRotation(this.a.locX, this.a.locY, this.a.locZ, 0.0F, 0.0F); -- this.c.addEntity(entityvillager); -+ this.c.addEntity(entityvillager, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - added SpawnReason - this.c.broadcastEntityEffect(entityvillager, (byte) 12); - } - } diff --git a/nms-patches/PathfinderGoalNearestAttackableTarget.patch b/nms-patches/PathfinderGoalNearestAttackableTarget.patch index 19fe64ae47..7cd7f16e48 100644 --- a/nms-patches/PathfinderGoalNearestAttackableTarget.patch +++ b/nms-patches/PathfinderGoalNearestAttackableTarget.patch @@ -1,33 +1,11 @@ --- a/net/minecraft/server/PathfinderGoalNearestAttackableTarget.java +++ b/net/minecraft/server/PathfinderGoalNearestAttackableTarget.java -@@ -44,18 +44,18 @@ - 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.i(), this.i(), new Function() { -+ this.d = (T) this.e.world.a(this.e.locX, this.e.locY + (double) this.e.getHeadHeight(), this.e.locZ, this.i(), this.i(), new Function() { // CraftBukkit - fix decompile error - @Nullable - public Double apply(@Nullable EntityHuman entityhuman) { - ItemStack itemstack = entityhuman.getEquipment(EnumItemSlot.HEAD); - - return (!(PathfinderGoalNearestAttackableTarget.this.e instanceof EntitySkeleton) || itemstack.getItem() != Items.SKELETON_SKULL) && (!(PathfinderGoalNearestAttackableTarget.this.e instanceof EntityZombie) || itemstack.getItem() != Items.ZOMBIE_HEAD) && (!(PathfinderGoalNearestAttackableTarget.this.e instanceof EntityCreeper) || itemstack.getItem() != Items.CREEPER_HEAD) ? 1.0D : 0.5D; - } -- }, this.c); -+ }, (Predicate) this.c); // CraftBukkit - fix decompile error - return this.d != null; - } - } -@@ -65,7 +65,7 @@ - } +@@ -52,7 +52,7 @@ + @Override public void c() { -- this.e.setGoalTarget(this.d); -+ this.e.setGoalTarget(this.d, d instanceof EntityPlayer ? org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_PLAYER : org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_ENTITY, true); // Craftbukkit - reason +- this.e.setGoalTarget(this.c); ++ this.e.setGoalTarget(this.c, c instanceof EntityPlayer ? org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_PLAYER : org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_ENTITY, true); // Craftbukkit - reason super.c(); } - + } diff --git a/nms-patches/PathfinderGoalNearestAttackableTargetInsentient.patch b/nms-patches/PathfinderGoalNearestAttackableTargetInsentient.patch deleted file mode 100644 index dcb68d54ad..0000000000 --- a/nms-patches/PathfinderGoalNearestAttackableTargetInsentient.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/server/PathfinderGoalNearestAttackableTargetInsentient.java -+++ b/net/minecraft/server/PathfinderGoalNearestAttackableTargetInsentient.java -@@ -62,7 +62,7 @@ - } - - public void c() { -- this.b.setGoalTarget(this.e); -+ this.b.setGoalTarget(this.e, org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_ENTITY, true); // CraftBukkit - reason - super.c(); - } - diff --git a/nms-patches/PathfinderGoalOwnerHurtByTarget.patch b/nms-patches/PathfinderGoalOwnerHurtByTarget.patch index 5d62045581..3190ada960 100644 --- a/nms-patches/PathfinderGoalOwnerHurtByTarget.patch +++ b/nms-patches/PathfinderGoalOwnerHurtByTarget.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/PathfinderGoalOwnerHurtByTarget.java +++ b/net/minecraft/server/PathfinderGoalOwnerHurtByTarget.java -@@ -30,7 +30,7 @@ - } +@@ -34,7 +34,7 @@ + @Override public void c() { - this.e.setGoalTarget(this.b); + this.e.setGoalTarget(this.b, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_OWNER, true); // CraftBukkit - reason diff --git a/nms-patches/PathfinderGoalOwnerHurtTarget.patch b/nms-patches/PathfinderGoalOwnerHurtTarget.patch index a837933fc5..8da1a8c20f 100644 --- a/nms-patches/PathfinderGoalOwnerHurtTarget.patch +++ b/nms-patches/PathfinderGoalOwnerHurtTarget.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/PathfinderGoalOwnerHurtTarget.java +++ b/net/minecraft/server/PathfinderGoalOwnerHurtTarget.java -@@ -30,7 +30,7 @@ - } +@@ -34,7 +34,7 @@ + @Override public void c() { - this.e.setGoalTarget(this.b); + this.e.setGoalTarget(this.b, org.bukkit.event.entity.EntityTargetEvent.TargetReason.OWNER_ATTACKED_TARGET, true); // CraftBukkit - reason diff --git a/nms-patches/PathfinderGoalPanic.patch b/nms-patches/PathfinderGoalPanic.patch index 9b0e4a6b4b..d74ec5644a 100644 --- a/nms-patches/PathfinderGoalPanic.patch +++ b/nms-patches/PathfinderGoalPanic.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/PathfinderGoalPanic.java +++ b/net/minecraft/server/PathfinderGoalPanic.java -@@ -53,6 +53,12 @@ - } +@@ -57,6 +57,12 @@ + @Override public boolean b() { + // CraftBukkit start - introduce a temporary timeout hack until this is fixed properly + if ((this.a.ticksLived - this.a.hurtTimestamp) > 100) { @@ -10,6 +10,6 @@ + return false; + } + // CraftBukkit end - return !this.a.getNavigation().p(); + return !this.a.getNavigation().n(); } diff --git a/nms-patches/PathfinderGoalRemoveBlock.patch b/nms-patches/PathfinderGoalRemoveBlock.patch index 7da7e60e5d..1f040cb330 100644 --- a/nms-patches/PathfinderGoalRemoveBlock.patch +++ b/nms-patches/PathfinderGoalRemoveBlock.patch @@ -11,10 +11,10 @@ public class PathfinderGoalRemoveBlock extends PathfinderGoalGotoTarget { -@@ -66,6 +70,14 @@ +@@ -81,6 +85,14 @@ } - if (this.h > 60) { + if (this.i > 60) { + // CraftBukkit start - Step on eggs + EntityInteractEvent event = new EntityInteractEvent(this.entity.getBukkitEntity(), CraftBlock.at(world, blockposition1)); + world.getServer().getPluginManager().callEvent((EntityInteractEvent) event); @@ -23,6 +23,6 @@ + return; + } + // CraftBukkit end - world.setAir(blockposition1); + world.a(blockposition1, false); if (!world.isClientSide) { for (int i = 0; i < 20; ++i) { diff --git a/nms-patches/PathfinderGoalSit.patch b/nms-patches/PathfinderGoalSit.patch index 403a27af7e..ed7625c291 100644 --- a/nms-patches/PathfinderGoalSit.patch +++ b/nms-patches/PathfinderGoalSit.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/server/PathfinderGoalSit.java +++ b/net/minecraft/server/PathfinderGoalSit.java -@@ -12,7 +12,7 @@ - +@@ -15,7 +15,7 @@ + @Override public boolean a() { if (!this.entity.isTamed()) { - return false; + return this.willSit && this.entity.getGoalTarget() == null; // CraftBukkit - Allow sitting for wild animals - } else if (this.entity.aq()) { + } else if (this.entity.au()) { return false; } else if (!this.entity.onGround) { diff --git a/nms-patches/PathfinderGoalTame.patch b/nms-patches/PathfinderGoalTame.patch index 8026e5b2b8..0b2e3018d1 100644 --- a/nms-patches/PathfinderGoalTame.patch +++ b/nms-patches/PathfinderGoalTame.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/PathfinderGoalTame.java +++ b/net/minecraft/server/PathfinderGoalTame.java -@@ -51,7 +51,8 @@ +@@ -57,7 +57,8 @@ int i = this.entity.getTemper(); int j = this.entity.getMaxDomestication(); diff --git a/nms-patches/PathfinderGoalTarget.patch b/nms-patches/PathfinderGoalTarget.patch index acab1523a3..397bb0da35 100644 --- a/nms-patches/PathfinderGoalTarget.patch +++ b/nms-patches/PathfinderGoalTarget.patch @@ -8,7 +8,7 @@ public abstract class PathfinderGoalTarget extends PathfinderGoal { -@@ -58,7 +59,7 @@ +@@ -59,7 +60,7 @@ if (entityliving instanceof EntityHuman && ((EntityHuman) entityliving).abilities.isInvulnerable) { return false; } else { @@ -17,9 +17,9 @@ return true; } } -@@ -79,7 +80,7 @@ - } +@@ -82,7 +83,7 @@ + @Override public void d() { - this.e.setGoalTarget((EntityLiving) null); + this.e.setGoalTarget((EntityLiving) null, EntityTargetEvent.TargetReason.FORGOT_TARGET, true); // CraftBukkit diff --git a/nms-patches/PathfinderGoalTargetNearestPlayer.patch b/nms-patches/PathfinderGoalTargetNearestPlayer.patch deleted file mode 100644 index 560d9330b9..0000000000 --- a/nms-patches/PathfinderGoalTargetNearestPlayer.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/server/PathfinderGoalTargetNearestPlayer.java -+++ b/net/minecraft/server/PathfinderGoalTargetNearestPlayer.java -@@ -85,7 +85,7 @@ - } - - public void c() { -- this.b.setGoalTarget(this.e); -+ this.b.setGoalTarget(this.e, org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_PLAYER, true); // CraftBukkit - added reason - super.c(); - } - diff --git a/nms-patches/PathfinderGoalTempt.patch b/nms-patches/PathfinderGoalTempt.patch index 06dfabbc61..307810a564 100644 --- a/nms-patches/PathfinderGoalTempt.patch +++ b/nms-patches/PathfinderGoalTempt.patch @@ -1,31 +1,31 @@ --- a/net/minecraft/server/PathfinderGoalTempt.java +++ b/net/minecraft/server/PathfinderGoalTempt.java -@@ -1,5 +1,12 @@ +@@ -1,6 +1,12 @@ package net.minecraft.server; + import java.util.EnumSet; +// CraftBukkit start +import org.bukkit.craftbukkit.entity.CraftLivingEntity; +import org.bukkit.craftbukkit.event.CraftEventFactory; +import org.bukkit.event.entity.EntityTargetEvent; +import org.bukkit.event.entity.EntityTargetLivingEntityEvent; +// CraftBukkit end -+ + public class PathfinderGoalTempt extends PathfinderGoal { - private final EntityCreature a; -@@ -9,7 +16,7 @@ - private double e; - private double f; +@@ -12,7 +18,7 @@ private double g; -- private EntityHuman target; -+ private EntityLiving target; // CraftBukkit - private int i; - private boolean j; - private final RecipeItemStack k; -@@ -36,7 +43,17 @@ + private double h; + private double i; +- protected EntityHuman target; ++ protected EntityLiving target; // CraftBukkit + private int j; + private boolean k; + private final RecipeItemStack l; +@@ -40,7 +46,17 @@ return false; } else { - this.target = this.a.world.findNearbyPlayer(this.a, 10.0D); + this.target = this.a.world.a(PathfinderGoalTempt.c, (EntityLiving) this.a); - return this.target == null ? false : this.a(this.target.getItemInMainHand()) || this.a(this.target.getItemInOffHand()); + // CraftBukkit start + boolean tempt = this.target == null ? false : this.a(this.target.getItemInMainHand()) || this.a(this.target.getItemInOffHand()); diff --git a/nms-patches/PathfinderGoalVillagerFarm.patch b/nms-patches/PathfinderGoalVillagerFarm.patch deleted file mode 100644 index 19116f1ad1..0000000000 --- a/nms-patches/PathfinderGoalVillagerFarm.patch +++ /dev/null @@ -1,48 +0,0 @@ ---- a/net/minecraft/server/PathfinderGoalVillagerFarm.java -+++ b/net/minecraft/server/PathfinderGoalVillagerFarm.java -@@ -40,7 +40,11 @@ - Block block = iblockdata.getBlock(); - - if (this.i == 0 && block instanceof BlockCrops && ((BlockCrops) block).w(iblockdata)) { -- world.setAir(blockposition, true); -+ // CraftBukkit start -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.f, blockposition, Blocks.AIR.getBlockData()).isCancelled()) { -+ world.setAir(blockposition, true); -+ } -+ // CraftBukkit end - } else if (this.i == 1 && iblockdata.isAir()) { - InventorySubcontainer inventorysubcontainer = this.f.dD(); - -@@ -49,19 +53,28 @@ - boolean flag = false; - - if (!itemstack.isEmpty()) { -+ // CraftBukkit start -+ Block planted = null; - if (itemstack.getItem() == Items.WHEAT_SEEDS) { -- world.setTypeAndData(blockposition, Blocks.WHEAT.getBlockData(), 3); -+ planted = Blocks.WHEAT; - flag = true; - } else if (itemstack.getItem() == Items.POTATO) { -- world.setTypeAndData(blockposition, Blocks.POTATOES.getBlockData(), 3); -+ planted = Blocks.POTATOES; - flag = true; - } else if (itemstack.getItem() == Items.CARROT) { -- world.setTypeAndData(blockposition, Blocks.CARROTS.getBlockData(), 3); -+ planted = Blocks.CARROTS; - flag = true; - } else if (itemstack.getItem() == Items.BEETROOT_SEEDS) { -- world.setTypeAndData(blockposition, Blocks.BEETROOTS.getBlockData(), 3); -+ planted = Blocks.BEETROOTS; - flag = true; - } -+ -+ if (planted != null && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.f, blockposition, planted.getBlockData()).isCancelled()) { -+ world.setTypeAndData(blockposition, planted.getBlockData(), 3); -+ } else { -+ flag = false; -+ } -+ // CraftBukkit end - } - - if (flag) { diff --git a/nms-patches/PlayerChunk.patch b/nms-patches/PlayerChunk.patch new file mode 100644 index 0000000000..47ab734500 --- /dev/null +++ b/nms-patches/PlayerChunk.patch @@ -0,0 +1,48 @@ +--- a/net/minecraft/server/PlayerChunk.java ++++ b/net/minecraft/server/PlayerChunk.java +@@ -41,7 +41,7 @@ + this.statusFutures = new AtomicReferenceArray(PlayerChunk.CHUNK_STATUSES.size()); + this.tickingFuture = PlayerChunk.UNLOADED_CHUNK_FUTURE; + this.entityTickingFuture = PlayerChunk.UNLOADED_CHUNK_FUTURE; +- this.chunkSave = CompletableFuture.completedFuture((Object) null); ++ this.chunkSave = CompletableFuture.completedFuture(null); // CraftBukkit - decompile error + this.dirtyBlocks = new short[64]; + this.location = chunkcoordintpair; + this.lightEngine = lightengine; +@@ -74,9 +74,9 @@ + @Nullable + public Chunk getChunk() { + CompletableFuture> completablefuture = this.a(); +- Either either = (Either) completablefuture.getNow((Object) null); ++ Either either = (Either) completablefuture.getNow(null); // CraftBukkit - decompile error + +- return either == null ? null : (Chunk) either.left().orElse((Object) null); ++ return either == null ? null : (Chunk) either.left().orElse(null); // CraftBukkit - decompile error + } + + public CompletableFuture getChunkSave() { +@@ -199,7 +199,7 @@ + CompletableFuture> completablefuture = (CompletableFuture) this.statusFutures.get(i); + + if (completablefuture != null) { +- Either either = (Either) completablefuture.getNow((Object) null); ++ Either either = (Either) completablefuture.getNow(null); // CraftBukkit - decompile error + + if (either == null || either.left().isPresent()) { + return completablefuture; +@@ -211,6 +211,15 @@ + + this.a(completablefuture1); + this.statusFutures.set(i, completablefuture1); ++ // CraftBukkit start ++ if (chunkstatus == ChunkStatus.FULL) { ++ completablefuture1.thenAccept((either) -> { ++ Chunk chunk = (Chunk) either.left().get(); ++ ++ chunk.loadCallback(); ++ }); ++ } ++ // CraftBukkit end + return completablefuture1; + } else { + return completablefuture == null ? PlayerChunk.UNLOADED_CHUNK_ACCESS_FUTURE : completablefuture; diff --git a/nms-patches/PlayerChunkMap.patch b/nms-patches/PlayerChunkMap.patch index 526eae71e8..9af0b90a53 100644 --- a/nms-patches/PlayerChunkMap.patch +++ b/nms-patches/PlayerChunkMap.patch @@ -1,152 +1,222 @@ --- a/net/minecraft/server/PlayerChunkMap.java +++ b/net/minecraft/server/PlayerChunkMap.java -@@ -13,6 +13,10 @@ - import java.util.function.Predicate; +@@ -33,6 +33,16 @@ import javax.annotation.Nullable; - + import org.apache.logging.log4j.LogManager; + import org.apache.logging.log4j.Logger; +// CraftBukkit start -+import java.util.LinkedList; ++import java.util.concurrent.CompletionException; ++import java.util.concurrent.ExecutionException; ++import java.util.concurrent.TimeUnit; ++import java.util.concurrent.TimeoutException; ++import org.bukkit.craftbukkit.event.CraftEventFactory; ++import org.bukkit.entity.Player; ++import org.bukkit.event.entity.CreatureSpawnEvent; ++import org.bukkit.event.world.ChunkUnloadEvent; +// CraftBukkit end + + public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { + +@@ -179,9 +189,12 @@ + + return completablefuture1.thenApply((list1) -> { + List list2 = Lists.newArrayList(); +- final int l1 = 0; ++ // CraftBukkit start - decompile error ++ int cnt = 0; + +- for (Iterator iterator = list1.iterator(); iterator.hasNext(); ++l1) { ++ for (Iterator iterator = list1.iterator(); iterator.hasNext(); ++cnt) { ++ final int l1 = cnt; ++ // CraftBukkit end + final Either either = (Either) iterator.next(); + Optional optional = either.left(); + +@@ -257,9 +270,9 @@ + }).forEach((completablefuture) -> { + if (flag) { + this.executor.c(completablefuture::isDone); +- ((Either) completablefuture.join()).ifLeft(this::saveChunk); ++ (completablefuture.join()).ifLeft(this::saveChunk); // CraftBukkit - decompile error + } else { +- ((Either) completablefuture.getNow(PlayerChunk.UNLOADED_CHUNK_ACCESS)).ifLeft(this::saveChunk); ++ (completablefuture.getNow(PlayerChunk.UNLOADED_CHUNK_ACCESS)).ifLeft(this::saveChunk); // CraftBukkit - decompile error + } + + }); +@@ -280,13 +293,34 @@ + + for (int i = 0; longiterator.hasNext() && (booleansupplier.getAsBoolean() || i < 200 || this.unloadQueue.size() > 2000); longiterator.remove()) { + long j = longiterator.nextLong(); +- PlayerChunk playerchunk = (PlayerChunk) this.updatingChunks.remove(j); ++ PlayerChunk playerchunk = (PlayerChunk) this.updatingChunks.get(j); // CraftBukkit + + if (playerchunk != null) { ++ // CraftBukkit start ++ ChunkUnloadEvent event = null; ++ IChunkAccess access = null; ++ try { ++ access = playerchunk.getChunkSave().get(5, TimeUnit.SECONDS); ++ } catch (ExecutionException ex) { ++ throw new CompletionException(ex); ++ } catch (InterruptedException | TimeoutException ex) { ++ System.err.println("Failed to save chunk " + playerchunk + " " + playerchunk.getChunkSave()); ++ } + - public class PlayerChunkMap { ++ if (access instanceof Chunk) { ++ event = new ChunkUnloadEvent(((Chunk) access).bukkitChunk, access.isNeedsSaving()); ++ this.world.getServer().getPluginManager().callEvent(event); ++ ++ if (event.isCancelled()) { ++ continue; ++ } ++ } ++ this.updatingChunks.remove(j); ++ // CraftBukkit end + this.g.put(j, playerchunk); + this.updatingChunksModified = true; + ++i; +- this.a(j, playerchunk); ++ this.a(j, playerchunk, event); // CraftBukkit + } + } + } +@@ -294,17 +328,23 @@ + gameprofilerfiller.exit(); + } - private static final Predicate a = (entityplayer) -> { -@@ -32,6 +36,7 @@ - private long k; - private boolean l = true; - private boolean m = true; -+ private boolean wasNotEmpty; // CraftBukkit - add field +- private void a(long i, PlayerChunk playerchunk) { ++ private void a(long i, PlayerChunk playerchunk, ChunkUnloadEvent event) { // CraftBukkit - add event + CompletableFuture completablefuture = playerchunk.getChunkSave(); - public PlayerChunkMap(WorldServer worldserver) { - this.world = worldserver; -@@ -135,7 +140,11 @@ - break; + completablefuture.thenAcceptAsync((ichunkaccess) -> { + CompletableFuture completablefuture1 = playerchunk.getChunkSave(); + + if (completablefuture1 != completablefuture) { +- this.a(i, playerchunk); ++ this.a(i, playerchunk, event); // CraftBukkit + } else { + if (this.g.remove(i, playerchunk) && ichunkaccess != null) { +- this.saveChunk(ichunkaccess); ++ // CraftBukkit start ++ if (event == null) { ++ this.saveChunk(ichunkaccess); ++ } else { ++ this.saveChunk(ichunkaccess, event.isSaveChunk()); ++ } ++ // CraftBukkit end + if (this.h.remove(i) && ichunkaccess instanceof Chunk) { + Chunk chunk = (Chunk) ichunkaccess; + +@@ -388,7 +428,7 @@ + return CompletableFuture.completedFuture(Either.right(playerchunk_failure)); + }); + }, (runnable) -> { +- this.mailboxWorldGen.a((Object) ChunkTaskQueueSorter.a(playerchunk, runnable)); ++ this.mailboxWorldGen.a(ChunkTaskQueueSorter.a(playerchunk, runnable)); // CraftBukkit - decompile error + }); + } + } +@@ -448,7 +488,10 @@ + while (iterator.hasNext()) { + Entity entity = (Entity) iterator.next(); + +- if (!(entity instanceof EntityHuman) && !this.world.addEntityChunk(entity)) { ++ // CraftBukkit start ++ boolean addEntity = !chunk.needsDecoration || CraftEventFactory.doEntityAddEventCalling(this.world, entity, CreatureSpawnEvent.SpawnReason.CHUNK_GEN); // Only call for new chunks ++ if (addEntity && !(entity instanceof EntityHuman) && !this.world.addEntityChunk(entity)) { ++ // CraftBukkit end + if (list == null) { + list = Lists.newArrayList(new Entity[] { entity}); + } else { +@@ -470,7 +513,7 @@ + long i = playerchunk.h().pair(); + + playerchunk.getClass(); +- mailbox.a((Object) ChunkTaskQueueSorter.a(runnable, i, playerchunk::i)); ++ mailbox.a(ChunkTaskQueueSorter.a(runnable, i, playerchunk::i)); // CraftBukkit - decompile error + }); + } + +@@ -487,7 +530,7 @@ + return Either.left(chunk); + }); + }, (runnable) -> { +- this.mailboxMain.a((Object) ChunkTaskQueueSorter.a(playerchunk, runnable)); ++ this.mailboxMain.a(ChunkTaskQueueSorter.a(playerchunk, runnable)); // CraftBukkit - decompile error + }); + + completablefuture1.thenAcceptAsync((either) -> { +@@ -501,7 +544,7 @@ + return Either.left(chunk); + }); + }, (runnable) -> { +- this.mailboxMain.a((Object) ChunkTaskQueueSorter.a(playerchunk, runnable)); ++ this.mailboxMain.a(ChunkTaskQueueSorter.a(playerchunk, runnable)); // CraftBukkit - decompile error + }); + return completablefuture1; + } +@@ -511,8 +554,14 @@ + } + + public void saveChunk(IChunkAccess ichunkaccess) { ++ // CraftBukkit start ++ this.saveChunk(ichunkaccess, ichunkaccess.isNeedsSaving()); ++ } ++ ++ public void saveChunk(IChunkAccess ichunkaccess, boolean save) { ++ // CraftBukkit end + this.n.a(ichunkaccess.getPos()); +- if (ichunkaccess.isNeedsSaving()) { ++ if (save) { // CraftBukkit + try { + this.world.checkSession(); + } catch (ExceptionWorldConflict exceptionworldconflict) { +@@ -563,9 +612,10 @@ + ChunkCoordIntPair chunkcoordintpair = playerchunk.h(); + Packet[] apacket = new Packet[2]; + ++ int finall = l; // CraftBukkit - decompile error + this.a(chunkcoordintpair, false).forEach((entityplayer) -> { + int i1 = b(chunkcoordintpair, entityplayer, true); +- boolean flag = i1 <= l; ++ boolean flag = i1 <= finall; // CraftBukkit - decompile error + boolean flag1 = i1 <= this.A; + + this.sendChunk(entityplayer, chunkcoordintpair, apacket, flag, flag1); +@@ -620,7 +670,7 @@ + private NBTTagCompound f(ChunkCoordIntPair chunkcoordintpair) throws IOException { + NBTTagCompound nbttagcompound = this.read(chunkcoordintpair); + +- return nbttagcompound == null ? null : this.getChunkData(this.world.getWorldProvider().getDimensionManager(), this.m, nbttagcompound); ++ return nbttagcompound == null ? null : this.getChunkData(this.world.getWorldProvider().getDimensionManager(), this.m, nbttagcompound, chunkcoordintpair, world); // CraftBukkit + } + + boolean d(ChunkCoordIntPair chunkcoordintpair) { +@@ -940,7 +990,7 @@ + public final Set trackedPlayers = Sets.newHashSet(); + + public EntityTracker(Entity entity, int i, int j, boolean flag) { +- this.trackerEntry = new EntityTrackerEntry(PlayerChunkMap.this.world, entity, j, flag, this::broadcast); ++ this.trackerEntry = new EntityTrackerEntry(PlayerChunkMap.this.world, entity, j, flag, this::broadcast, trackedPlayers); // CraftBukkit + this.tracker = entity; + this.trackingDistance = i; + this.e = SectionPosition.a(entity); +@@ -1009,6 +1059,17 @@ } } -+ // CraftBukkit start - SPIGOT-2891: remove once chunk has been provided -+ } else { -+ iterator1.remove(); - } -+ // CraftBukkit end - } - } -@@ -197,6 +206,16 @@ - return playerchunk; - } - -+ // CraftBukkit start - add method -+ public final boolean isChunkInUse(int x, int z) { -+ PlayerChunk pi = getChunk(x, z); -+ if (pi != null) { -+ return (pi.players.size() > 0); -+ } -+ return false; -+ } -+ // CraftBukkit end ++ // CraftBukkit start - respect vanish API ++ if (this.tracker instanceof EntityPlayer) { ++ Player player = ((EntityPlayer) this.tracker).getBukkitEntity(); ++ if (!entityplayer.getBukkitEntity().canSee(player)) { ++ flag1 = false; ++ } ++ } + - public void flagDirty(BlockPosition blockposition) { - int i = blockposition.getX() >> 4; - int j = blockposition.getZ() >> 4; -@@ -215,12 +234,22 @@ - entityplayer.d = entityplayer.locX; - entityplayer.e = entityplayer.locZ; - ++ entityplayer.removeQueue.remove(Integer.valueOf(this.tracker.getId())); ++ // CraftBukkit end + -+ // CraftBukkit start - Load nearby chunks first -+ List chunkList = new LinkedList(); -+ - 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.c(pair.x, pair.z).a(entityplayer); -+ } -+ // CraftBukkit end -+ - this.managedPlayers.add(entityplayer); - this.e(); - } -@@ -264,11 +293,14 @@ - int j1 = i - k; - int k1 = j - l; - -+ List chunksToLoad = new LinkedList(); // 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.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)) { -@@ -284,6 +316,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.c(pair.x, pair.z).a(entityplayer); -+ } -+ // CraftBukkit end - } - } - } -@@ -368,4 +407,47 @@ - } - - } -+ -+ // CraftBukkit start - Sorter to load nearby chunks first -+ private static class ChunkCoordComparator implements java.util.Comparator { -+ private int x; -+ private int z; -+ -+ public ChunkCoordComparator (EntityPlayer entityplayer) { -+ x = (int) entityplayer.locX >> 4; -+ z = (int) entityplayer.locZ >> 4; -+ } -+ -+ public int compare(ChunkCoordIntPair a, ChunkCoordIntPair b) { -+ if (a.equals(b)) { -+ return 0; -+ } -+ -+ // Subtract current position to set center point -+ int ax = a.x - this.x; -+ int az = a.z - this.z; -+ int bx = b.x - this.x; -+ int bz = b.z - this.z; -+ -+ int result = ((ax - bx) * (ax + bx)) + ((az - bz) * (az + bz)); -+ if (result != 0) { -+ return result; -+ } -+ -+ if (ax < 0) { -+ if (bx < 0) { -+ return bz - az; -+ } else { -+ return -1; -+ } -+ } else { -+ if (bx < 0) { -+ return 1; -+ } else { -+ return az - bz; -+ } -+ } -+ } -+ } -+ // CraftBukkit end - } + if (flag1 && this.trackedPlayers.add(entityplayer)) { + this.trackerEntry.b(entityplayer); + } diff --git a/nms-patches/PlayerConnection.patch b/nms-patches/PlayerConnection.patch index 91ed78b8d1..033c8a3a39 100644 --- a/nms-patches/PlayerConnection.patch +++ b/nms-patches/PlayerConnection.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/PlayerConnection.java +++ b/net/minecraft/server/PlayerConnection.java -@@ -16,6 +16,50 @@ +@@ -18,6 +18,50 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -48,10 +48,10 @@ +import org.bukkit.util.NumberConversions; +// CraftBukkit end + - public class PlayerConnection implements PacketListenerPlayIn, ITickable { + public class PlayerConnection implements PacketListenerPlayIn { private static final Logger LOGGER = LogManager.getLogger(); -@@ -26,7 +70,10 @@ +@@ -28,7 +72,10 @@ private long lastKeepAlive; private boolean awaitingKeepAlive; private long h; @@ -61,9 +61,9 @@ + private static final AtomicIntegerFieldUpdater chatSpamField = AtomicIntegerFieldUpdater.newUpdater(PlayerConnection.class, "chatThrottle"); + // CraftBukkit end private int j; - private final IntHashMap k = new IntHashMap<>(); + private final Int2ShortMap k = new Int2ShortOpenHashMap(); private double l; -@@ -58,7 +105,33 @@ +@@ -60,7 +107,33 @@ networkmanager.setPacketListener(this); this.player = entityplayer; entityplayer.playerConnection = this; @@ -97,8 +97,8 @@ public void tick() { this.syncPosition(); -@@ -104,7 +177,7 @@ - this.minecraftServer.methodProfiler.enter("keepAlive"); +@@ -106,7 +179,7 @@ + this.minecraftServer.getMethodProfiler().enter("keepAlive"); long i = SystemUtils.getMonotonicMillis(); - if (i - this.lastKeepAlive >= 15000L) { @@ -106,10 +106,10 @@ if (this.awaitingKeepAlive) { this.disconnect(new ChatMessage("disconnect.timeout", new Object[0])); } else { -@@ -116,15 +189,21 @@ +@@ -118,15 +191,21 @@ } - this.minecraftServer.methodProfiler.exit(); + this.minecraftServer.getMethodProfiler().exit(); + // CraftBukkit start + for (int spam; (spam = this.chatThrottle) > 0 && !chatSpamField.compareAndSet(this, spam, spam - 1); ) ; + /* Use thread-safe field access instead @@ -128,8 +128,8 @@ this.disconnect(new ChatMessage("multiplayer.disconnect.idling", new Object[0])); } -@@ -143,16 +222,46 @@ - return this.networkManager; +@@ -149,16 +228,46 @@ + return this.minecraftServer.b(this.player.getProfile()); } + // CraftBukkit start @@ -170,17 +170,17 @@ NetworkManager networkmanager = this.networkManager; this.networkManager.getClass(); -- Futures.getUnchecked(minecraftserver.postToMainThread(networkmanager::handleDisconnection)); +- minecraftserver.f(networkmanager::handleDisconnection); + // CraftBukkit - Don't wait + minecraftserver.postToMainThread(networkmanager::handleDisconnection); } - public void a(PacketPlayInSteerVehicle packetplayinsteervehicle) { -@@ -191,7 +300,34 @@ - double d9 = entity.motX * entity.motX + entity.motY * entity.motY + entity.motZ * entity.motZ; + @Override +@@ -199,7 +308,34 @@ + double d9 = entity.getMot().g(); double d10 = d6 * d6 + d7 * d7 + d8 * d8; -- if (d10 - d9 > 100.0D && (!this.minecraftServer.H() || !this.minecraftServer.G().equals(entity.getDisplayName().getString()))) { +- if (d10 - d9 > 100.0D && !this.isExemptPlayer()) { + + // CraftBukkit start - handle custom speeds and skipped ticks + this.allowedPlayerTicks += (System.currentTimeMillis() / 50) - this.lastTick; @@ -207,12 +207,12 @@ + } + speed *= 2f; // TODO: Get the speed of the vehicle instead of the player + -+ if (d10 - d9 > Math.max(100.0D, Math.pow((double) (10.0F * (float) i * speed), 2)) && (!this.minecraftServer.H() || !this.minecraftServer.G().equals(entity.getDisplayName().getString()))) { ++ if (d10 - d9 > Math.max(100.0D, Math.pow((double) (10.0F * (float) i * speed), 2)) && !this.isExemptPlayer()) { + // CraftBukkit end PlayerConnection.LOGGER.warn("{} (vehicle of {}) moved too quickly! {},{},{}", entity.getDisplayName().getString(), this.player.getDisplayName().getString(), d6, d7, d8); this.networkManager.sendPacket(new PacketPlayOutVehicleMove(entity)); return; -@@ -221,14 +357,72 @@ +@@ -229,14 +365,72 @@ } entity.setLocation(d3, d4, d5, f, f1); @@ -282,11 +282,11 @@ + } + // CraftBukkit end + - this.minecraftServer.getPlayerList().updateChunks(this.player); + this.player.getWorldServer().getChunkProvider().movePlayer(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.a(entity.getBoundingBox().g(0.0625D).b(0.0D, -0.55D, 0.0D)); -@@ -242,7 +436,7 @@ - +@@ -251,7 +445,7 @@ + @Override public void a(PacketPlayInTeleportAccept packetplayinteleportaccept) { PlayerConnectionUtils.ensureMainThread(packetplayinteleportaccept, this, this.player.getWorldServer()); - if (packetplayinteleportaccept.b() == this.teleportAwait) { @@ -294,16 +294,25 @@ this.player.setLocation(this.teleportPos.x, this.teleportPos.y, this.teleportPos.z, this.player.yaw, this.player.pitch); this.o = this.teleportPos.x; this.p = this.teleportPos.y; -@@ -252,6 +446,7 @@ +@@ -261,6 +455,7 @@ } this.teleportPos = null; -+ this.minecraftServer.getPlayerList().updateChunks(this.player); // CraftBukkit ++ this.player.getWorldServer().getChunkProvider().movePlayer(this.player); // CraftBukkit } } -@@ -288,6 +483,12 @@ +@@ -269,7 +464,7 @@ + public void a(PacketPlayInRecipeDisplayed packetplayinrecipedisplayed) { + PlayerConnectionUtils.ensureMainThread(packetplayinrecipedisplayed, this, this.player.getWorldServer()); + if (packetplayinrecipedisplayed.b() == PacketPlayInRecipeDisplayed.Status.SHOWN) { +- Optional optional = this.minecraftServer.getCraftingManager().a(packetplayinrecipedisplayed.c()); ++ Optional> optional = this.minecraftServer.getCraftingManager().a(packetplayinrecipedisplayed.c()); // CraftBukkit - decompile error + RecipeBookServer recipebookserver = this.player.B(); + optional.ifPresent(recipebookserver::e); +@@ -303,6 +498,12 @@ + @Override public void a(PacketPlayInTabComplete packetplayintabcomplete) { PlayerConnectionUtils.ensureMainThread(packetplayintabcomplete, this, this.player.getWorldServer()); + // CraftBukkit start @@ -315,7 +324,7 @@ StringReader stringreader = new StringReader(packetplayintabcomplete.c()); if (stringreader.canRead() && stringreader.peek() == '/') { -@@ -297,7 +498,8 @@ +@@ -312,7 +513,8 @@ ParseResults parseresults = this.minecraftServer.getCommandDispatcher().a().parse(stringreader, this.player.getCommandListener()); this.minecraftServer.getCommandDispatcher().a().getCompletionSuggestions(parseresults).thenAccept((suggestions) -> { @@ -325,9 +334,9 @@ }); } -@@ -489,6 +691,15 @@ - } +@@ -526,6 +728,15 @@ + @Override public void a(PacketPlayInBEdit packetplayinbedit) { + // CraftBukkit start + PlayerConnectionUtils.ensureMainThread(packetplayinbedit, this, this.player.getWorldServer()); @@ -341,23 +350,20 @@ ItemStack itemstack = packetplayinbedit.b(); if (!itemstack.isEmpty()) { -@@ -513,11 +724,13 @@ - } - - itemstack2.a("pages", (NBTBase) nbttaglist); -- EnumItemSlot enumitemslot = packetplayinbedit.d() == EnumHand.MAIN_HAND ? EnumItemSlot.MAINHAND : EnumItemSlot.OFFHAND; -+ // EnumItemSlot enumitemslot = packetplayinbedit.d() == EnumHand.MAIN_HAND ? EnumItemSlot.MAINHAND : EnumItemSlot.OFFHAND; // CraftBukkit - Moved up - -- this.player.setSlot(enumitemslot, itemstack2); -+ this.player.setSlot(enumitemslot, CraftEventFactory.handleEditBookEvent(player, enumitemslot, itemstack1, itemstack2)); // CraftBukkit - } else { -+ ItemStack old = itemstack1.cloneItemStack(); // CraftBukkit - itemstack1.a("pages", (NBTBase) itemstack.getTag().getList("pages", 8)); -+ CraftEventFactory.handleEditBookEvent(player, enumitemslot, old, itemstack1); // CraftBukkit +@@ -554,9 +765,11 @@ } - } -@@ -557,7 +770,7 @@ + itemstack2.a("pages", (NBTBase) nbttaglist); +- this.player.a(packetplayinbedit.d(), itemstack2); ++ this.player.a(packetplayinbedit.d(), CraftEventFactory.handleEditBookEvent(player, enumitemslot, itemstack1, itemstack2)); // CraftBukkit + } else { ++ ItemStack old = itemstack1.cloneItemStack(); // CraftBukkit + itemstack1.a("pages", (NBTBase) itemstack.getTag().getList("pages", 8)); ++ CraftEventFactory.handleEditBookEvent(player, enumitemslot, old, itemstack1); // CraftBukkit + } + } + +@@ -598,7 +811,7 @@ } else { WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); @@ -366,7 +372,7 @@ if (this.e == 0) { this.syncPosition(); } -@@ -567,13 +780,21 @@ +@@ -608,13 +821,21 @@ this.A = this.e; this.a(this.teleportPos.x, this.teleportPos.y, this.teleportPos.z, this.player.yaw, this.player.pitch); } @@ -376,7 +382,7 @@ 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().updateChunks(this.player); + this.player.getWorldServer().getChunkProvider().movePlayer(this.player); + this.allowedPlayerTicks = 20; // CraftBukkit } else { + // CraftBukkit - Make sure the move is valid but then reset it for plugins to modify @@ -389,7 +395,7 @@ double d0 = this.player.locX; double d1 = this.player.locY; double d2 = this.player.locZ; -@@ -598,15 +819,33 @@ +@@ -639,15 +860,33 @@ ++this.receivedMovePackets; int i = this.receivedMovePackets - this.processedMovePackets; @@ -416,16 +422,16 @@ + speed = player.abilities.walkSpeed * 10f; + } + - if (!this.player.H() && (!this.player.getWorldServer().getGameRules().getBoolean("disableElytraMovementCheck") || !this.player.dc())) { - float f2 = this.player.dc() ? 300.0F : 100.0F; + if (!this.player.H() && (!this.player.getWorldServer().getGameRules().getBoolean("disableElytraMovementCheck") || !this.player.isGliding())) { + float f2 = this.player.isGliding() ? 300.0F : 100.0F; -- if (d11 - d10 > (double) (f2 * (float) i) && (!this.minecraftServer.H() || !this.minecraftServer.G().equals(this.player.getProfile().getName()))) { -+ if (d11 - d10 > Math.max(f2, Math.pow((double) (10.0F * (float) i * speed), 2)) && (!this.minecraftServer.H() || !this.minecraftServer.G().equals(this.player.getProfile().getName()))) { +- if (d11 - d10 > (double) (f2 * (float) i) && !this.isExemptPlayer()) { ++ if (d11 - d10 > Math.max(f2, Math.pow((double) (10.0F * (float) i * speed), 2)) && !this.isExemptPlayer()) { + // CraftBukkit end PlayerConnection.LOGGER.warn("{} moved too quickly! {},{},{}", this.player.getDisplayName().getString(), d7, d8, d9); this.a(this.player.locX, this.player.locY, this.player.locZ, this.player.yaw, this.player.pitch); return; -@@ -652,6 +891,69 @@ +@@ -693,6 +932,69 @@ } } @@ -492,10 +498,10 @@ + this.player.setLocation(d4, d5, d6, f, f1); // Copied from above + // 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.dc() && !worldserver.a(this.player.getBoundingBox().g(0.0625D).b(0.0D, -0.55D, 0.0D)); -@@ -669,10 +971,60 @@ + this.B = d12 >= -0.03125D && this.player.playerInteractManager.getGameMode() != EnumGamemode.SPECTATOR && !this.minecraftServer.getAllowFlight() && !this.player.abilities.canFly && !this.player.hasEffect(MobEffects.LEVITATION) && !this.player.isGliding() && !worldserver.a(this.player.getBoundingBox().g(0.0625D).b(0.0D, -0.55D, 0.0D)); + this.player.onGround = packetplayinflying.b(); + this.player.getWorldServer().getChunkProvider().movePlayer(this.player); +@@ -708,10 +1010,60 @@ } public void a(double d0, double d1, double d2, float f, float f1) { @@ -557,7 +563,7 @@ 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; -@@ -684,6 +1036,14 @@ +@@ -723,6 +1075,14 @@ this.teleportAwait = 0; } @@ -572,15 +578,15 @@ this.A = this.e; this.player.setLocation(d0, d1, d2, f, f1); this.player.playerConnection.sendPacket(new PacketPlayOutPosition(d0 - d3, d1 - d4, d2 - d5, f - f2, f1 - f3, set, this.teleportAwait)); -@@ -691,6 +1051,7 @@ - +@@ -731,6 +1091,7 @@ + @Override public void a(PacketPlayInBlockDig packetplayinblockdig) { PlayerConnectionUtils.ensureMainThread(packetplayinblockdig, this, this.player.getWorldServer()); + if (this.player.isFrozen()) return; // CraftBukkit WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); BlockPosition blockposition = packetplayinblockdig.b(); -@@ -700,13 +1061,45 @@ +@@ -740,13 +1101,45 @@ if (!this.player.isSpectator()) { ItemStack itemstack = this.player.b(EnumHand.OFF_HAND); @@ -625,10 +631,10 @@ + } + } + // CraftBukkit end - this.player.a(false); + this.player.n(false); } -@@ -737,7 +1130,15 @@ +@@ -777,7 +1170,15 @@ if (!this.minecraftServer.a(worldserver, blockposition, this.player) && worldserver.getWorldBorder().a(blockposition)) { this.player.playerInteractManager.a(blockposition, packetplayinblockdig.c()); } else { @@ -644,23 +650,24 @@ } } else { if (packetplayinblockdig.d() == PacketPlayInBlockDig.EnumPlayerDigType.STOP_DESTROY_BLOCK) { -@@ -756,10 +1157,12 @@ +@@ -796,11 +1197,13 @@ default: throw new IllegalArgumentException("Invalid player action"); } + // CraftBukkit end } + @Override public void a(PacketPlayInUseItem packetplayinuseitem) { PlayerConnectionUtils.ensureMainThread(packetplayinuseitem, this, this.player.getWorldServer()); + if (this.player.isFrozen()) return; // CraftBukkit WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); - EnumHand enumhand = packetplayinuseitem.d(); + EnumHand enumhand = packetplayinuseitem.b(); ItemStack itemstack = this.player.b(enumhand); -@@ -772,6 +1175,14 @@ +@@ -814,6 +1217,14 @@ this.player.playerConnection.sendPacket(new PacketPlayOutChat(ichatbasecomponent, ChatMessageType.GAME_INFO)); - } else if (this.teleportPos == null && this.player.d((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) < 64.0D && !this.minecraftServer.a(worldserver, blockposition, this.player) && worldserver.getWorldBorder().a(blockposition)) { + } 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()); @@ -669,11 +676,11 @@ + } + this.player.clearActiveItem(); // SPIGOT-4706 + // CraftBukkit end - this.player.playerInteractManager.a(this.player, worldserver, itemstack, enumhand, blockposition, enumdirection, packetplayinuseitem.e(), packetplayinuseitem.f(), packetplayinuseitem.g()); + this.player.playerInteractManager.a(this.player, worldserver, itemstack, enumhand, movingobjectpositionblock); } -@@ -781,13 +1192,52 @@ - +@@ -824,13 +1235,53 @@ + @Override public void a(PacketPlayInBlockPlace packetplayinblockplace) { PlayerConnectionUtils.ensureMainThread(packetplayinblockplace, this, this.player.getWorldServer()); + if (this.player.isFrozen()) return; // CraftBukkit @@ -701,10 +708,10 @@ + float f8 = f3 * f5; + double d3 = player.playerInteractManager.getGameMode()== EnumGamemode.CREATIVE ? 5.0D : 4.5D; + Vec3D vec3d1 = vec3d.add((double) f7 * d3, (double) f6 * d3, (double) f8 * d3); -+ MovingObjectPosition movingobjectposition = this.player.world.rayTrace(vec3d, vec3d1); ++ MovingObjectPosition movingobjectposition = this.player.world.rayTrace(new RayTrace(vec3d, vec3d1, RayTrace.BlockCollisionOption.OUTLINE, RayTrace.FluidCollisionOption.NONE, player)); + + boolean cancelled; -+ if (movingobjectposition == null || movingobjectposition.type != MovingObjectPosition.EnumMovingObjectType.BLOCK) { ++ if (movingobjectposition == null || movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.BLOCK) { + org.bukkit.event.player.PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.RIGHT_CLICK_AIR, itemstack, enumhand); + cancelled = event.useItemInHand() == Event.Result.DENY; + } else { @@ -712,7 +719,8 @@ + player.playerInteractManager.firedInteract = false; + cancelled = player.playerInteractManager.interactResult; + } else { -+ org.bukkit.event.player.PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(player, Action.RIGHT_CLICK_BLOCK, movingobjectposition.getBlockPosition(), movingobjectposition.direction, itemstack, true, enumhand); ++ MovingObjectPositionBlock movingobjectpositionblock = (MovingObjectPositionBlock) movingobjectposition; ++ org.bukkit.event.player.PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(player, Action.RIGHT_CLICK_BLOCK, movingobjectpositionblock.getBlockPosition(), movingobjectpositionblock.getDirection(), itemstack, true, enumhand); + cancelled = event.useItemInHand() == Event.Result.DENY; + } + } @@ -726,17 +734,19 @@ } } -@@ -807,13 +1257,18 @@ - } +@@ -845,7 +1296,7 @@ + Entity entity = packetplayinspectate.a(worldserver); - if (entity != null) { -- this.player.a((WorldServer) entity.world, entity.locX, entity.locY, entity.locZ, entity.yaw, entity.pitch); -+ this.player.a((WorldServer) entity.world, entity.locX, entity.locY, entity.locZ, entity.yaw, entity.pitch, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.SPECTATE); // CraftBukkit + if (entity != null) { +- this.player.a(worldserver, entity.locX, entity.locY, entity.locZ, entity.yaw, entity.pitch); ++ this.player.a(worldserver, entity.locX, entity.locY, entity.locZ, entity.yaw, entity.pitch, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.SPECTATE); // CraftBukkit + return; + } } - } - +@@ -854,7 +1305,12 @@ } + @Override - public void a(PacketPlayInResourcePackStatus packetplayinresourcepackstatus) {} + // CraftBukkit start + public void a(PacketPlayInResourcePackStatus packetplayinresourcepackstatus) { @@ -745,11 +755,11 @@ + } + // CraftBukkit end + @Override public void a(PacketPlayInBoatMove packetplayinboatmove) { - PlayerConnectionUtils.ensureMainThread(packetplayinboatmove, this, this.player.getWorldServer()); -@@ -826,11 +1281,26 @@ - } +@@ -869,11 +1325,26 @@ + @Override public void a(IChatBaseComponent ichatbasecomponent) { + // CraftBukkit start - Rarely it would send a disconnect line twice + if (this.processedDisconnect) { @@ -761,7 +771,7 @@ PlayerConnection.LOGGER.info("{} lost connection: {}", this.player.getDisplayName().getString(), ichatbasecomponent.getString()); + // CraftBukkit start - Replace vanilla quit message handling with our own. + /* - this.minecraftServer.at(); + this.minecraftServer.invalidatePingSample(); this.minecraftServer.getPlayerList().sendMessage((new ChatMessage("multiplayer.player.left", new Object[] { this.player.getScoreboardDisplayName()})).a(EnumChatFormat.YELLOW)); + */ + @@ -772,10 +782,10 @@ + this.minecraftServer.getPlayerList().sendMessage(CraftChatMessage.fromString(quitMessage)); + } + // CraftBukkit end - if (this.minecraftServer.H() && this.player.getDisplayName().getString().equals(this.minecraftServer.G())) { + if (this.isExemptPlayer()) { PlayerConnection.LOGGER.info("Stopping singleplayer server as player logged out"); - this.minecraftServer.safeShutdown(); -@@ -856,6 +1326,15 @@ + this.minecraftServer.safeShutdown(false); +@@ -899,6 +1370,15 @@ } } @@ -791,8 +801,8 @@ try { this.networkManager.sendPacket(packet, genericfuturelistener); } catch (Throwable throwable) { -@@ -871,17 +1350,37 @@ - +@@ -915,18 +1395,38 @@ + @Override public void a(PacketPlayInHeldItemSlot packetplayinhelditemslot) { PlayerConnectionUtils.ensureMainThread(packetplayinhelditemslot, this, this.player.getWorldServer()); + if (this.player.isFrozen()) return; // CraftBukkit @@ -813,9 +823,10 @@ } } + @Override public void a(PacketPlayInChat packetplayinchat) { - PlayerConnectionUtils.ensureMainThread(packetplayinchat, this, this.player.getWorldServer()); -- if (this.player.getChatFlags() == EntityHuman.EnumChatVisibility.HIDDEN) { +- if (this.player.getChatFlags() == EnumChatVisibility.HIDDEN) { + // CraftBukkit start - async chat + // SPIGOT-3638 + if (this.minecraftServer.isStopped()) { @@ -827,11 +838,11 @@ + PlayerConnectionUtils.ensureMainThread(packetplayinchat, this, this.player.getWorldServer()); + } + // CraftBukkit end -+ if (this.player.dead || this.player.getChatFlags() == EntityHuman.EnumChatVisibility.HIDDEN) { // CraftBukkit - dead men tell no tales ++ if (this.player.dead || this.player.getChatFlags() == EnumChatVisibility.HIDDEN) { // CraftBukkit - dead men tell no tales this.sendPacket(new PacketPlayOutChat((new ChatMessage("chat.cannotSend", new Object[0])).a(EnumChatFormat.RED))); } else { this.player.resetIdleTimer(); -@@ -891,39 +1390,255 @@ +@@ -936,41 +1436,257 @@ for (int i = 0; i < s.length(); ++i) { if (!SharedConstants.isAllowedChatCharacter(s.charAt(i))) { @@ -883,7 +894,7 @@ + getPlayer().acceptConversationInput(conversationInput); + } + }); -+ } else if (this.player.getChatFlags() == EntityHuman.EnumChatVisibility.SYSTEM) { // Re-add "Command Only" flag check ++ } else if (this.player.getChatFlags() == EnumChatVisibility.SYSTEM) { // Re-add "Command Only" flag check + ChatMessage chatmessage = new ChatMessage("chat.cannotSend", new Object[0]); + + chatmessage.getChatModifier().setColor(EnumChatFormat.RED); @@ -932,13 +943,13 @@ + // CraftBukkit start - add method + public void chat(String s, boolean async) { -+ if (s.isEmpty() || this.player.getChatFlags() == EntityHuman.EnumChatVisibility.HIDDEN) { ++ if (s.isEmpty() || this.player.getChatFlags() == EnumChatVisibility.HIDDEN) { + return; + } + + if (!async && s.startsWith("/")) { + this.handleCommand(s); -+ } else if (this.player.getChatFlags() == EntityHuman.EnumChatVisibility.SYSTEM) { ++ } else if (this.player.getChatFlags() == EnumChatVisibility.SYSTEM) { + // Do nothing, this is coming from a plugin + } else { + Player player = this.getPlayer(); @@ -1031,6 +1042,7 @@ + // CraftBukkit end } + @Override public void a(PacketPlayInArmAnimation packetplayinarmanimation) { PlayerConnectionUtils.ensureMainThread(packetplayinarmanimation, this, this.player.getWorldServer()); + if (this.player.isFrozen()) return; // CraftBukkit @@ -1051,9 +1063,9 @@ + float f8 = f3 * f5; + double d3 = player.playerInteractManager.getGameMode()== EnumGamemode.CREATIVE ? 5.0D : 4.5D; + Vec3D vec3d1 = vec3d.add((double) f7 * d3, (double) f6 * d3, (double) f8 * d3); -+ MovingObjectPosition movingobjectposition = this.player.world.rayTrace(vec3d, vec3d1); ++ MovingObjectPosition movingobjectposition = this.player.world.rayTrace(new RayTrace(vec3d, vec3d1, RayTrace.BlockCollisionOption.OUTLINE, RayTrace.FluidCollisionOption.NONE, player)); + -+ if (movingobjectposition == null || movingobjectposition.type != MovingObjectPosition.EnumMovingObjectType.BLOCK) { ++ if (movingobjectposition == null || movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.BLOCK) { + CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_AIR, this.player.inventory.getItemInHand(), EnumHand.MAIN_HAND); + } + @@ -1066,6 +1078,7 @@ this.player.a(packetplayinarmanimation.b()); } + @Override public void a(PacketPlayInEntityAction packetplayinentityaction) { PlayerConnectionUtils.ensureMainThread(packetplayinentityaction, this, this.player.getWorldServer()); + // CraftBukkit start @@ -1094,15 +1107,15 @@ this.player.resetIdleTimer(); IJumpable ijumpable; -@@ -986,6 +1701,7 @@ - +@@ -1034,6 +1750,7 @@ + @Override public void a(PacketPlayInUseEntity packetplayinuseentity) { PlayerConnectionUtils.ensureMainThread(packetplayinuseentity, this, this.player.getWorldServer()); + if (this.player.isFrozen()) return; // CraftBukkit WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); Entity entity = packetplayinuseentity.a((World) worldserver); -@@ -1001,20 +1717,74 @@ +@@ -1049,20 +1766,74 @@ if (this.player.h(entity) < d0) { EnumHand enumhand; @@ -1178,18 +1191,8 @@ } } } -@@ -1030,7 +1800,8 @@ - case PERFORM_RESPAWN: - if (this.player.viewingCredits) { - this.player.viewingCredits = false; -- this.player = this.minecraftServer.getPlayerList().moveToWorld(this.player, DimensionManager.OVERWORLD, true); -+ // this.player = this.minecraftServer.getPlayerList().moveToWorld(this.player, DimensionManager.OVERWORLD, true); -+ this.minecraftServer.getPlayerList().changeDimension(this.player, DimensionManager.OVERWORLD, PlayerTeleportEvent.TeleportCause.END_PORTAL); // CraftBukkit - reroute logic through custom portal management - CriterionTriggers.v.a(this.player, DimensionManager.THE_END, DimensionManager.OVERWORLD); - } else { - if (this.player.getHealth() > 0.0F) { -@@ -1052,14 +1823,20 @@ - +@@ -1102,15 +1873,21 @@ + @Override public void a(PacketPlayInCloseWindow packetplayinclosewindow) { PlayerConnectionUtils.ensureMainThread(packetplayinclosewindow, this, this.player.getWorldServer()); + @@ -1199,6 +1202,7 @@ this.player.m(); } + @Override public void a(PacketPlayInWindowClick packetplayinwindowclick) { PlayerConnectionUtils.ensureMainThread(packetplayinwindowclick, this, this.player.getWorldServer()); + if (this.player.isFrozen()) return; // CraftBukkit @@ -1211,7 +1215,7 @@ NonNullList nonnulllist = NonNullList.a(); for (int i = 0; i < this.player.activeContainer.slots.size(); ++i) { -@@ -1068,8 +1845,274 @@ +@@ -1119,8 +1896,274 @@ this.player.a(this.player.activeContainer, nonnulllist); } else { @@ -1220,7 +1224,7 @@ + if (packetplayinwindowclick.c() < -1 && packetplayinwindowclick.c() != -999) { + return; + } -+ + + InventoryView inventory = this.player.activeContainer.getBukkitView(); + SlotType type = inventory.getSlotType(packetplayinwindowclick.c()); + @@ -1420,7 +1424,7 @@ + if (this.player.activeContainer != oldContainer) { + return; + } - ++ + switch (event.getResult()) { + case ALLOW: + case DEFAULT: @@ -1486,16 +1490,16 @@ + // CraftBukkit end if (ItemStack.matches(packetplayinwindowclick.f(), itemstack)) { this.player.playerConnection.sendPacket(new PacketPlayOutTransaction(packetplayinwindowclick.b(), packetplayinwindowclick.e(), true)); - this.player.f = true; -@@ -1112,6 +2155,7 @@ - + this.player.e = true; +@@ -1160,6 +2203,7 @@ + @Override public void a(PacketPlayInEnchantItem packetplayinenchantitem) { PlayerConnectionUtils.ensureMainThread(packetplayinenchantitem, this, this.player.getWorldServer()); + if (this.player.isFrozen()) return; // CraftBukkit this.player.resetIdleTimer(); if (this.player.activeContainer.windowId == packetplayinenchantitem.b() && this.player.activeContainer.c(this.player) && !this.player.isSpectator()) { - this.player.activeContainer.a(this.player, packetplayinenchantitem.c()); -@@ -1143,6 +2187,43 @@ + this.player.activeContainer.a((EntityHuman) this.player, packetplayinenchantitem.c()); +@@ -1192,6 +2236,43 @@ boolean flag1 = packetplayinsetcreativeslot.b() >= 1 && packetplayinsetcreativeslot.b() <= 45; boolean flag2 = itemstack.isEmpty() || itemstack.getDamage() >= 0 && itemstack.getCount() <= 64 && !itemstack.isEmpty(); @@ -1539,25 +1543,25 @@ if (flag1 && flag2) { if (itemstack.isEmpty()) { -@@ -1166,6 +2247,7 @@ - +@@ -1217,6 +2298,7 @@ + @Override public void a(PacketPlayInTransaction packetplayintransaction) { PlayerConnectionUtils.ensureMainThread(packetplayintransaction, this, this.player.getWorldServer()); + if (this.player.isFrozen()) return; // CraftBukkit - Short oshort = (Short) this.k.get(this.player.activeContainer.windowId); - - if (oshort != null && packetplayintransaction.c() == oshort && this.player.activeContainer.windowId == packetplayintransaction.b() && !this.player.activeContainer.c(this.player) && !this.player.isSpectator()) { -@@ -1176,6 +2258,7 @@ + int i = this.player.activeContainer.windowId; + if (i == packetplayintransaction.b() && this.k.getOrDefault(i, (short) (packetplayintransaction.c() + 1)) == packetplayintransaction.c() && !this.player.activeContainer.c(this.player) && !this.player.isSpectator()) { +@@ -1228,6 +2310,7 @@ + @Override public void a(PacketPlayInUpdateSign packetplayinupdatesign) { PlayerConnectionUtils.ensureMainThread(packetplayinupdatesign, this, this.player.getWorldServer()); + if (this.player.isFrozen()) return; // CraftBukkit this.player.resetIdleTimer(); WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); BlockPosition blockposition = packetplayinupdatesign.b(); -@@ -1192,14 +2275,30 @@ +@@ -1244,14 +2327,30 @@ - if (!tileentitysign.d() || tileentitysign.e() != this.player) { + if (!tileentitysign.c() || tileentitysign.d() != this.player) { this.minecraftServer.warning("Player " + this.player.getDisplayName().getString() + " just tried to change non-editable sign"); + this.sendPacket(tileentity.getUpdatePacket()); // CraftBukkit return; @@ -1587,16 +1591,16 @@ tileentitysign.update(); worldserver.notify(blockposition, iblockdata, iblockdata, 3); -@@ -1208,6 +2307,7 @@ - } +@@ -1261,6 +2360,7 @@ + @Override public void a(PacketPlayInKeepAlive packetplayinkeepalive) { + PlayerConnectionUtils.ensureMainThread(packetplayinkeepalive, this, this.player.getWorldServer()); // CraftBukkit if (this.awaitingKeepAlive && packetplayinkeepalive.b() == this.h) { int i = (int) (SystemUtils.getMonotonicMillis() - this.lastKeepAlive); -@@ -1221,7 +2321,17 @@ - +@@ -1275,7 +2375,17 @@ + @Override public void a(PacketPlayInAbilities packetplayinabilities) { PlayerConnectionUtils.ensureMainThread(packetplayinabilities, this, this.player.getWorldServer()); - this.player.abilities.isFlying = packetplayinabilities.isFlying() && this.player.abilities.canFly; @@ -1613,16 +1617,18 @@ + // CraftBukkit end } - public void a(PacketPlayInSettings packetplayinsettings) { -@@ -1229,5 +2339,47 @@ + @Override +@@ -1284,8 +2394,50 @@ this.player.a(packetplayinsettings); } +- @Override - public void a(PacketPlayInCustomPayload packetplayincustompayload) {} + // CraftBukkit start + private static final MinecraftKey CUSTOM_REGISTER = new MinecraftKey("register"); + private static final MinecraftKey CUSTOM_UNREGISTER = new MinecraftKey("unregister"); + ++ @Override + public void a(PacketPlayInCustomPayload packetplayincustompayload) { + PlayerConnectionUtils.ensureMainThread(packetplayincustompayload, this, this.player.getWorldServer()); + if (packetplayincustompayload.tag.equals(CUSTOM_REGISTER)) { @@ -1662,4 +1668,6 @@ + return !this.player.joining && !this.networkManager.isConnected(); + } + // CraftBukkit end - } + + @Override + public void a(PacketPlayInDifficultyChange packetplayindifficultychange) { diff --git a/nms-patches/PlayerConnectionUtils.patch b/nms-patches/PlayerConnectionUtils.patch index 2fc062eb3a..87aa731f40 100644 --- a/nms-patches/PlayerConnectionUtils.patch +++ b/nms-patches/PlayerConnectionUtils.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/server/PlayerConnectionUtils.java +++ b/net/minecraft/server/PlayerConnectionUtils.java -@@ -5,6 +5,7 @@ - public static void ensureMainThread(Packet packet, T t0, IAsyncTaskHandler iasynctaskhandler) throws CancelledPacketHandleException { +@@ -9,6 +9,7 @@ + public static void ensureMainThread(Packet packet, T t0, IAsyncTaskHandler iasynctaskhandler) throws CancelledPacketHandleException { if (!iasynctaskhandler.isMainThread()) { - iasynctaskhandler.postToMainThread(() -> { + iasynctaskhandler.execute(() -> { + if (t0 instanceof PlayerConnection && ((PlayerConnection) t0).processedDisconnect) return; // CraftBukkit packet.a(t0); }); diff --git a/nms-patches/PlayerInteractManager.patch b/nms-patches/PlayerInteractManager.patch index 19e847fd21..bd75f83fe1 100644 --- a/nms-patches/PlayerInteractManager.patch +++ b/nms-patches/PlayerInteractManager.patch @@ -15,7 +15,7 @@ + public class PlayerInteractManager { - public World world; + public WorldServer world; @@ -26,7 +36,7 @@ this.gamemode = enumgamemode; enumgamemode.a(this.player.abilities); @@ -54,7 +54,7 @@ if (this.isCreative()) { if (!this.world.douseFire((EntityHuman) null, blockposition, enumdirection)) { this.breakBlock(blockposition); -@@ -122,16 +145,50 @@ +@@ -122,15 +145,49 @@ } } @@ -97,16 +97,15 @@ + // Let the client know the block still exists + ((EntityPlayer) this.player).playerConnection.sendPacket(new PacketPlayOutBlockChange(this.world, blockposition)); + return; - } - ++ } ++ + if (blockEvent.getInstaBreak()) { + f = 2.0f; -+ } + } + // CraftBukkit end -+ + if (!iblockdata.isAir() && f >= 1.0F) { this.breakBlock(blockposition); - } else { @@ -149,6 +206,7 @@ public void a(BlockPosition blockposition) { @@ -126,7 +125,7 @@ } } -@@ -190,13 +252,93 @@ +@@ -190,10 +252,66 @@ public boolean breakBlock(BlockPosition blockposition) { IBlockData iblockdata = this.world.getType(blockposition); @@ -158,25 +157,19 @@ + 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, @Nullable TileEntity tileentity, ItemStack itemstack) -+ // PAIL: checkme each update -+ if (!(nmsBlock.X_() && EnchantmentManager.getEnchantmentLevel(Enchantments.SILK_TOUCH, itemstack) > 0)) { -+ int bonusLevel = EnchantmentManager.getEnchantmentLevel(Enchantments.LOOT_BONUS_BLOCKS, itemstack); -+ -+ event.setExpToDrop(nmsBlock.getExpDrop(nmsData, this.world, blockposition, bonusLevel)); -+ } ++ event.setExpToDrop(nmsBlock.getExpDrop(nmsData, this.world, blockposition, itemstack)); + } + + this.world.getServer().getPluginManager().callEvent(event); -+ + +- if (!this.player.getItemInMainHand().getItem().a(iblockdata, (World) this.world, blockposition, (EntityHuman) this.player)) { + if (event.isCancelled()) { + if (isSwordNoBreak) { + return false; + } + // Let the client know the block still exists + ((EntityPlayer) this.player).playerConnection.sendPacket(new PacketPlayOutBlockChange(this.world, blockposition)); - -- if (!this.player.getItemInMainHand().getItem().a(iblockdata, this.world, blockposition, (EntityHuman) this.player)) { ++ + // Brute force all possible updates + for (EnumDirection dir : EnumDirection.values()) { + ((EntityPlayer) this.player).playerConnection.sendPacket(new PacketPlayOutBlockChange(world, blockposition.shift(dir))); @@ -192,7 +185,7 @@ + } + // CraftBukkit end + -+ if (false && !this.player.getItemInMainHand().getItem().a(iblockdata, this.world, blockposition, (EntityHuman) this.player)) { // CraftBukkit - false ++ if (false && !this.player.getItemInMainHand().getItem().a(iblockdata, (World) this.world, blockposition, (EntityHuman) this.player)) { // CraftBukkit - false return false; } else { + iblockdata = this.world.getType(blockposition); // CraftBukkit - update state from plugins @@ -200,28 +193,7 @@ TileEntity tileentity = this.world.getTileEntity(blockposition); Block block = iblockdata.getBlock(); -+ // CraftBukkit start - Special case skulls, their item data comes from a tile entity (Also check if block should drop items) -+ // And shulker boxes too for duplication on BlockPlaceEvent cancel reasons (Also check if block should drop items) -+ if (((iblockdata.getBlock() instanceof BlockSkullAbstract && !this.isCreative()) || iblockdata.getBlock() instanceof BlockShulkerBox) && event.isDropItems()) { -+ org.bukkit.block.BlockState state = bblock.getState(); -+ world.captureDrops = new ArrayList<>(); -+ -+ iblockdata.getBlock().dropNaturally(iblockdata, world, blockposition, 1.0F, 0); -+ boolean flag = this.c(blockposition); -+ -+ if (event.isDropItems()) { -+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockDropItemEvent(bblock, state, this.player, world.captureDrops); -+ } -+ -+ world.captureDrops = null; -+ return flag; -+ } -+ // CraftBukkit end -+ - if ((block instanceof BlockCommand || block instanceof BlockStructure) && !this.player.isCreativeAndOp()) { - this.world.notify(blockposition, iblockdata, iblockdata, 3); - return false; -@@ -221,6 +363,10 @@ +@@ -221,6 +339,10 @@ } } @@ -232,7 +204,7 @@ boolean flag = this.c(blockposition); if (!this.isCreative()) { -@@ -228,12 +374,26 @@ +@@ -228,13 +350,27 @@ boolean flag1 = this.player.hasBlock(iblockdata); itemstack1.a(this.world, iblockdata, blockposition, this.player); @@ -244,11 +216,11 @@ iblockdata.getBlock().a(this.world, this.player, blockposition, iblockdata, tileentity, itemstack2); } + // CraftBukkit end -+ } -+ + } + + if (event.isDropItems()) { + org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockDropItemEvent(bblock, state, this.player, world.captureDrops); - } ++ } + world.captureDrops = null; + // CraftBukkit end + @@ -257,32 +229,34 @@ + iblockdata.getBlock().dropExperience(this.world, blockposition, event.getExpToDrop()); + } + // CraftBukkit end - ++ return flag; } -@@ -277,11 +437,40 @@ + } +@@ -277,12 +413,41 @@ } } + // CraftBukkit start - whole method + public boolean interactResult = false; + public boolean firedInteract = false; - public EnumInteractionResult a(EntityHuman entityhuman, World world, ItemStack itemstack, EnumHand enumhand, BlockPosition blockposition, EnumDirection enumdirection, float f, float f1, float f2) { + public EnumInteractionResult a(EntityHuman entityhuman, World world, ItemStack itemstack, EnumHand enumhand, MovingObjectPositionBlock movingobjectpositionblock) { + BlockPosition blockposition = movingobjectpositionblock.getBlockPosition(); IBlockData iblockdata = world.getType(blockposition); + EnumInteractionResult enuminteractionresult = EnumInteractionResult.PASS; + if (iblockdata.isAir()) return enuminteractionresult; + boolean cancelledBlock = false; if (this.gamemode == EnumGamemode.SPECTATOR) { - TileEntity tileentity = world.getTileEntity(blockposition); -+ cancelledBlock = !(tileentity instanceof ITileInventory || tileentity instanceof IInventory); + ITileInventory itileinventory = iblockdata.b(world, blockposition); ++ cancelledBlock = !(itileinventory instanceof ITileInventory); + } + + if (entityhuman.getCooldownTracker().a(itemstack.getItem())) { + cancelledBlock = true; + } + -+ PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(entityhuman, Action.RIGHT_CLICK_BLOCK, blockposition, enumdirection, itemstack, cancelledBlock, enumhand); ++ PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(entityhuman, Action.RIGHT_CLICK_BLOCK, blockposition, movingobjectpositionblock.getDirection(), itemstack, cancelledBlock, enumhand); + firedInteract = true; + interactResult = event.useItemInHand() == Event.Result.DENY; + @@ -297,23 +271,23 @@ + ((EntityPlayer) entityhuman).getBukkitEntity().updateInventory(); // SPIGOT-2867 + enuminteractionresult = (event.useItemInHand() != Event.Result.ALLOW) ? EnumInteractionResult.SUCCESS : EnumInteractionResult.PASS; + } else if (this.gamemode == EnumGamemode.SPECTATOR) { -+ TileEntity tileentity = world.getTileEntity(blockposition); ++ ITileInventory itileinventory = iblockdata.b(world, blockposition); - if (tileentity instanceof ITileInventory) { - Block block = iblockdata.getBlock(); -@@ -305,24 +494,26 @@ + if (itileinventory != null) { + entityhuman.openContainer(itileinventory); +@@ -294,24 +459,26 @@ boolean flag = !entityhuman.getItemInMainHand().isEmpty() || !entityhuman.getItemInOffHand().isEmpty(); boolean flag1 = entityhuman.isSneaking() && flag; -- if (!flag1 && iblockdata.interact(world, blockposition, entityhuman, enumhand, enumdirection, f, f1, f2)) { +- if (!flag1 && iblockdata.interact(world, entityhuman, enumhand, movingobjectpositionblock)) { - return EnumInteractionResult.SUCCESS; - } else if (!itemstack.isEmpty() && !entityhuman.getCooldownTracker().a(itemstack.getItem())) { + if (!flag1) { -+ enuminteractionresult = iblockdata.interact(world, blockposition, entityhuman, enumhand, enumdirection, f, f1, f2) ? EnumInteractionResult.SUCCESS : EnumInteractionResult.FAIL; ++ enuminteractionresult = iblockdata.interact(world, entityhuman, enumhand, movingobjectpositionblock) ? EnumInteractionResult.SUCCESS : EnumInteractionResult.FAIL; + } + + if (!itemstack.isEmpty() && enuminteractionresult != EnumInteractionResult.SUCCESS && !interactResult) { // add !interactResult SPIGOT-764 - ItemActionContext itemactioncontext = new ItemActionContext(entityhuman, entityhuman.b(enumhand), blockposition, enumdirection, f, f1, f2); + ItemActionContext itemactioncontext = new ItemActionContext(entityhuman, enumhand, movingobjectpositionblock); if (this.isCreative()) { int i = itemstack.getCount(); diff --git a/nms-patches/PlayerInventory.patch b/nms-patches/PlayerInventory.patch index 46a288b35b..ab3a3893c1 100644 --- a/nms-patches/PlayerInventory.patch +++ b/nms-patches/PlayerInventory.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/PlayerInventory.java +++ b/net/minecraft/server/PlayerInventory.java -@@ -6,6 +6,15 @@ +@@ -5,6 +5,15 @@ + import java.util.List; import java.util.function.Predicate; - import javax.annotation.Nullable; +// CraftBukkit start +import java.util.ArrayList; @@ -13,10 +13,10 @@ +import org.bukkit.entity.HumanEntity; +// CraftBukkit end + - public class PlayerInventory implements IInventory { + public class PlayerInventory implements IInventory, INamableTileEntity { public final NonNullList items; -@@ -17,6 +26,49 @@ +@@ -16,6 +25,54 @@ private ItemStack carried; private int h; @@ -53,6 +53,11 @@ + return this.player.getBukkitEntity(); + } + ++ @Override ++ public int getMaxStackSize() { ++ return maxStack; ++ } ++ + public void setMaxStackSize(int size) { + maxStack = size; + } @@ -66,7 +71,7 @@ public PlayerInventory(EntityHuman entityhuman) { this.items = NonNullList.a(36, ItemStack.a); this.armor = NonNullList.a(4, ItemStack.a); -@@ -42,6 +94,22 @@ +@@ -41,6 +98,22 @@ return itemstack.getItem() == itemstack1.getItem() && ItemStack.equals(itemstack, itemstack1); } @@ -89,16 +94,18 @@ public int getFirstEmptySlotIndex() { for (int i = 0; i < this.items.size(); ++i) { if (((ItemStack) this.items.get(i)).isEmpty()) { -@@ -502,7 +570,7 @@ - } +@@ -513,8 +586,9 @@ + ItemStack itemstack = (ItemStack) this.armor.get(i); - public int getMaxStackSize() { -- return 64; -+ return maxStack; // CraftBukkit - } - - public boolean b(IBlockData iblockdata) { -@@ -554,6 +622,11 @@ + if (itemstack.getItem() instanceof ItemArmor) { ++ int finalI = i; // CraftBukkit - decompile error + itemstack.damage((int) f, this.player, (entityhuman) -> { +- entityhuman.c(EnumItemSlot.a(EnumItemSlot.Function.ARMOR, i)); ++ entityhuman.c(EnumItemSlot.a(EnumItemSlot.Function.ARMOR, finalI)); // CraftBukkit - decompile error + }); + } + } +@@ -550,6 +624,11 @@ } public ItemStack getCarried() { diff --git a/nms-patches/PlayerList.patch b/nms-patches/PlayerList.patch index 2414ac370c..a51dcb021c 100644 --- a/nms-patches/PlayerList.patch +++ b/nms-patches/PlayerList.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/PlayerList.java +++ b/net/minecraft/server/PlayerList.java -@@ -18,6 +18,29 @@ +@@ -18,6 +18,27 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -10,11 +10,9 @@ + +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.craftbukkit.CraftWorld; -+import org.bukkit.craftbukkit.chunkio.ChunkIOExecutor; + +import org.bukkit.Bukkit; +import org.bukkit.Location; -+import org.bukkit.TravelAgent; +import org.bukkit.craftbukkit.util.CraftChatMessage; +import org.bukkit.entity.Player; +import org.bukkit.event.player.PlayerChangedWorldEvent; @@ -30,7 +28,7 @@ public abstract class PlayerList { public static final File a = new File("banned-players.json"); -@@ -27,14 +50,16 @@ +@@ -27,14 +48,16 @@ private static final Logger f = LogManager.getLogger(); private static final SimpleDateFormat g = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z"); private final MinecraftServer server; @@ -49,16 +47,16 @@ + // CraftBukkit end public IPlayerFileData playerFileData; private boolean hasWhitelist; - protected int maxPlayers; -@@ -43,13 +68,23 @@ + protected final int maxPlayers; +@@ -43,13 +66,23 @@ private boolean u; private int v; + // CraftBukkit start + private CraftServer cserver; + - public PlayerList(MinecraftServer minecraftserver) { -+ this.cserver = minecraftserver.server = new CraftServer(minecraftserver, this); + public PlayerList(MinecraftServer minecraftserver, int i) { ++ this.cserver = minecraftserver.server = new CraftServer((DedicatedServer) minecraftserver, this); + minecraftserver.console = org.bukkit.craftbukkit.command.ColouredConsoleSender.getInstance(); + minecraftserver.reader.addCompleter(new org.bukkit.craftbukkit.command.ConsoleCommandCompleter(minecraftserver.server)); + // CraftBukkit end @@ -74,12 +72,12 @@ + // this.p = Maps.newHashMap(); + // CraftBukkit end this.server = minecraftserver; + this.maxPlayers = i; this.getProfileBans().a(true); - this.getIPBans().a(true); -@@ -64,6 +99,12 @@ - +@@ -65,6 +98,12 @@ usercache.a(gameprofile); NBTTagCompound nbttagcompound = this.a(entityplayer); + WorldServer worldserver = this.server.getWorldServer(entityplayer.dimension); + // CraftBukkit start - Better rename detection + if (nbttagcompound != null && nbttagcompound.hasKey("bukkit")) { + NBTTagCompound bukkit = nbttagcompound.getCompound("bukkit"); @@ -87,40 +85,107 @@ + } + // CraftBukkit end - entityplayer.spawnIn(this.server.getWorldServer(entityplayer.dimension)); + entityplayer.spawnIn(worldserver); entityplayer.playerInteractManager.a((WorldServer) entityplayer.world); -@@ -73,7 +114,8 @@ +@@ -74,13 +113,15 @@ s1 = networkmanager.getSocketAddress().toString(); } - PlayerList.f.info("{}[{}] logged in with entity id {} at ({}, {}, {})", entityplayer.getDisplayName().getString(), s1, entityplayer.getId(), entityplayer.locX, entityplayer.locY, entityplayer.locZ); + // CraftBukkit - Moved message to after join + // PlayerList.f.info("{}[{}] logged in with entity id {} at ({}, {}, {})", entityplayer.getDisplayName().getString(), s1, entityplayer.getId(), entityplayer.locX, entityplayer.locY, entityplayer.locZ); - WorldServer worldserver = this.server.getWorldServer(entityplayer.dimension); WorldData worlddata = worldserver.getWorldData(); -@@ -81,6 +123,7 @@ + this.a(entityplayer, (EntityPlayer) null, worldserver); PlayerConnection playerconnection = new PlayerConnection(this.server, networkmanager, entityplayer); - playerconnection.sendPacket(new PacketPlayOutLogin(entityplayer.getId(), entityplayer.playerInteractManager.getGameMode(), worlddata.isHardcore(), worldserver.worldProvider.getDimensionManager(), worldserver.getDifficulty(), this.getMaxPlayers(), worlddata.getType(), worldserver.getGameRules().getBoolean("reducedDebugInfo"))); + playerconnection.sendPacket(new PacketPlayOutLogin(entityplayer.getId(), entityplayer.playerInteractManager.getGameMode(), worlddata.isHardcore(), worldserver.worldProvider.getDimensionManager(), this.getMaxPlayers(), worlddata.getType(), this.s, worldserver.getGameRules().getBoolean("reducedDebugInfo"))); + entityplayer.getBukkitEntity().sendSupportedChannels(); // CraftBukkit - playerconnection.sendPacket(new PacketPlayOutCustomPayload(PacketPlayOutCustomPayload.b, (new PacketDataSerializer(Unpooled.buffer())).a(this.getServer().getServerModName()))); + playerconnection.sendPacket(new PacketPlayOutCustomPayload(PacketPlayOutCustomPayload.a, (new PacketDataSerializer(Unpooled.buffer())).a(this.getServer().getServerModName()))); playerconnection.sendPacket(new PacketPlayOutServerDifficulty(worlddata.getDifficulty(), worlddata.isDifficultyLocked())); playerconnection.sendPacket(new PacketPlayOutAbilities(entityplayer.abilities)); -@@ -100,8 +143,10 @@ +@@ -99,19 +140,61 @@ + } else { chatmessage = new ChatMessage("multiplayer.player.joined.renamed", new Object[] { entityplayer.getScoreboardDisplayName(), s}); } ++ // CraftBukkit start ++ chatmessage.a(EnumChatFormat.YELLOW); ++ String joinMessage = CraftChatMessage.fromComponent(chatmessage); - this.sendMessage(chatmessage.a(EnumChatFormat.YELLOW)); -- this.onPlayerJoin(entityplayer); -+ chatmessage.a(EnumChatFormat.YELLOW); -+ this.onPlayerJoin(entityplayer, CraftChatMessage.fromComponent(chatmessage)); -+ // CraftBukkit end -+ worldserver = server.getWorldServer(entityplayer.dimension); // CraftBukkit - Update in case join event changed it playerconnection.a(entityplayer.locX, entityplayer.locY, entityplayer.locZ, entityplayer.yaw, entityplayer.pitch); - this.b(entityplayer, worldserver); + this.players.add(entityplayer); + this.j.put(entityplayer.getUniqueID(), entityplayer); +- this.sendAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, new EntityPlayer[] { entityplayer})); ++ // this.sendAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, new EntityPlayer[] { entityplayer})); // CraftBukkit - replaced with loop below ++ ++ // CraftBukkit start ++ PlayerJoinEvent playerJoinEvent = new PlayerJoinEvent(cserver.getPlayer(entityplayer), joinMessage); ++ cserver.getPluginManager().callEvent(playerJoinEvent); ++ ++ if (!entityplayer.playerConnection.networkManager.isConnected()) { ++ return; ++ } ++ ++ joinMessage = playerJoinEvent.getJoinMessage(); ++ ++ if (joinMessage != null && joinMessage.length() > 0) { ++ for (IChatBaseComponent line : org.bukkit.craftbukkit.util.CraftChatMessage.fromString(joinMessage)) { ++ server.getPlayerList().sendAll(new PacketPlayOutChat(line)); ++ } ++ } ++ // CraftBukkit end ++ ++ // 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.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); ++ } ++ ++ if (!entityplayer.getBukkitEntity().canSee(entityplayer1.getBukkitEntity())) { ++ continue; ++ } ++ ++ entityplayer.playerConnection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, new EntityPlayer[] { entityplayer1})); ++ } ++ entityplayer.sentListPacket = true; ++ // CraftBukkit end ++ ++ entityplayer.playerConnection.sendPacket(new PacketPlayOutEntityMetadata(entityplayer.getId(), entityplayer.datawatcher, true)); // CraftBukkit - BungeeCord#2321, send complete data to self on spawn ++ ++ // CraftBukkit start - Only add if the player wasn't moved in the event ++ if (entityplayer.world == worldserver && !worldserver.getPlayers().contains(entityplayer)) { ++ worldserver.addPlayerJoin(entityplayer); ++ this.server.getBossBattleCustomData().a(entityplayer); + } + +- worldserver.addPlayerJoin(entityplayer); +- this.server.getBossBattleCustomData().a(entityplayer); ++ worldserver = server.getWorldServer(entityplayer.dimension); // CraftBukkit - Update in case join event changed it ++ // CraftBukkit end + this.a(entityplayer, worldserver); if (!this.server.getResourcePack().isEmpty()) { -@@ -153,6 +198,8 @@ + entityplayer.setResourcePack(this.server.getResourcePack(), this.server.getResourcePackHash()); +@@ -127,8 +210,11 @@ + + if (nbttagcompound != null && nbttagcompound.hasKeyOfType("RootVehicle", 10)) { + NBTTagCompound nbttagcompound1 = nbttagcompound.getCompound("RootVehicle"); +- Entity entity = EntityTypes.a(nbttagcompound1.getCompound("Entity"), worldserver, (entity1) -> { +- return !worldserver.addEntitySerialized(entity1) ? null : entity1; ++ // CraftBukkit start ++ WorldServer finalWorldServer = worldserver; ++ Entity entity = EntityTypes.a(nbttagcompound1.getCompound("Entity"), finalWorldServer, (entity1) -> { ++ return !finalWorldServer.addEntitySerialized(entity1) ? null : entity1; ++ // CraftBukkit end + }); + + if (entity != null) { +@@ -164,6 +250,8 @@ } entityplayer.syncInventory(); @@ -129,40 +194,45 @@ } public void sendScoreboard(ScoreboardServer scoreboardserver, EntityPlayer entityplayer) { -@@ -185,26 +232,27 @@ +@@ -196,31 +284,32 @@ } public void setPlayerFileData(WorldServer worldserver) { + if (playerFileData != null) return; // CraftBukkit - this.playerFileData = worldserver.getDataManager().getPlayerFileData(); + this.playerFileData = worldserver.getDataManager(); worldserver.getWorldBorder().a(new IWorldBorderListener() { + @Override public void a(WorldBorder worldborder, double d0) { - PlayerList.this.sendAll(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.SET_SIZE)); + PlayerList.this.sendAll(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.SET_SIZE), worldborder.world); } + @Override 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); } + @Override 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); } + @Override 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); } + @Override 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) {} -@@ -252,14 +300,15 @@ + @Override +@@ -248,14 +337,15 @@ } protected void savePlayerFile(EntityPlayer entityplayer) { @@ -180,75 +250,10 @@ if (advancementdataplayer != null) { advancementdataplayer.c(); -@@ -267,29 +316,80 @@ +@@ -263,10 +353,21 @@ } -- public void onPlayerJoin(EntityPlayer entityplayer) { -+ public void onPlayerJoin(EntityPlayer entityplayer, String joinMessage) { // CraftBukkit added param - this.players.add(entityplayer); - this.j.put(entityplayer.getUniqueID(), entityplayer); -- this.sendAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, new EntityPlayer[] { entityplayer})); -+ // this.sendAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, new EntityPlayer[] { entityplayer})); // CraftBukkit - replaced with loop below - WorldServer worldserver = this.server.getWorldServer(entityplayer.dimension); - -+ // CraftBukkit start -+ PlayerJoinEvent playerJoinEvent = new PlayerJoinEvent(cserver.getPlayer(entityplayer), joinMessage); -+ cserver.getPluginManager().callEvent(playerJoinEvent); -+ -+ if (!entityplayer.playerConnection.networkManager.isConnected()) { -+ return; -+ } -+ -+ joinMessage = playerJoinEvent.getJoinMessage(); -+ -+ if (joinMessage != null && joinMessage.length() > 0) { -+ for (IChatBaseComponent line : org.bukkit.craftbukkit.util.CraftChatMessage.fromString(joinMessage)) { -+ server.getPlayerList().sendAll(new PacketPlayOutChat(line)); -+ } -+ } -+ -+ ChunkIOExecutor.adjustPoolSize(getPlayerCount()); -+ // CraftBukkit end -+ -+ // 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.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); -+ } -+ -+ if (!entityplayer.getBukkitEntity().canSee(entityplayer1.getBukkitEntity())) { -+ continue; -+ } -+ -+ entityplayer.playerConnection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, new EntityPlayer[] { entityplayer1})); - } -+ entityplayer.sentListPacket = true; -+ // CraftBukkit end -+ -+ entityplayer.playerConnection.sendPacket(new PacketPlayOutEntityMetadata(entityplayer.getId(), entityplayer.datawatcher, true)); // CraftBukkit - BungeeCord#2321, send complete data to self on spawn - -- worldserver.addEntity(entityplayer); -- this.a(entityplayer, (WorldServer) null); -- this.server.getBossBattleCustomData().a(entityplayer); -+ // CraftBukkit start - Only add if the player wasn't moved in the event -+ if (entityplayer.world == worldserver && !worldserver.players.contains(entityplayer)) { -+ worldserver.addEntity(entityplayer); -+ this.a(entityplayer, (WorldServer) null); -+ this.server.getBossBattleCustomData().a(entityplayer); -+ } -+ // CraftBukkit end - } - - public void updateChunks(EntityPlayer entityplayer) { - entityplayer.getWorldServer().getPlayerChunkMap().movePlayer(entityplayer); - } - - public void disconnect(EntityPlayer entityplayer) { + public String disconnect(EntityPlayer entityplayer) { // CraftBukkit - return string WorldServer worldserver = entityplayer.getWorldServer(); @@ -268,7 +273,7 @@ this.savePlayerFile(entityplayer); if (entityplayer.isPassenger()) { Entity entity = entityplayer.getRootVehicle(); -@@ -320,18 +420,68 @@ +@@ -297,18 +398,66 @@ if (entityplayer1 == entityplayer) { this.j.remove(uuid); @@ -297,8 +302,6 @@ + cserver.getScoreboardManager().removePlayer(entityplayer.getBukkitEntity()); + // CraftBukkit end + -+ ChunkIOExecutor.adjustPoolSize(this.getPlayerCount()); // CraftBukkit -+ + return playerQuitEvent.getQuitMessage(); // CraftBukkit } @@ -343,7 +346,7 @@ GameProfileBanEntry gameprofilebanentry = (GameProfileBanEntry) this.k.get(gameprofile); chatmessage = new ChatMessage("multiplayer.disconnect.banned.reason", new Object[] { gameprofilebanentry.getReason()}); -@@ -339,10 +489,12 @@ +@@ -316,10 +465,12 @@ chatmessage.addSibling(new ChatMessage("multiplayer.disconnect.banned.expiration", new Object[] { PlayerList.g.format(gameprofilebanentry.getExpires())})); } @@ -359,7 +362,7 @@ IpBanEntry ipbanentry = this.l.get(socketaddress); chatmessage = new ChatMessage("multiplayer.disconnect.banned_ip.reason", new Object[] { ipbanentry.getReason()}); -@@ -350,13 +502,25 @@ +@@ -327,13 +478,25 @@ chatmessage.addSibling(new ChatMessage("multiplayer.disconnect.banned_ip.expiration", new Object[] { PlayerList.g.format(ipbanentry.getExpires())})); } @@ -388,7 +391,7 @@ UUID uuid = EntityHuman.a(gameprofile); List list = Lists.newArrayList(); -@@ -391,17 +555,27 @@ +@@ -368,14 +531,24 @@ } return new EntityPlayer(this.server, this.server.getWorldServer(DimensionManager.OVERWORLD), gameprofile, (PlayerInteractManager) object); @@ -404,12 +407,8 @@ + + public EntityPlayer moveToWorld(EntityPlayer entityplayer, DimensionManager dimensionmanager, boolean flag, Location location, boolean avoidSuffocation) { + entityplayer.stopRiding(); // CraftBukkit - entityplayer.getWorldServer().getTracker().untrackPlayer(entityplayer); -- entityplayer.getWorldServer().getTracker().untrackEntity(entityplayer); -+ // entityplayer.getWorldServer().getTracker().untrackEntity(entityplayer); // CraftBukkit - entityplayer.getWorldServer().getPlayerChunkMap().removePlayer(entityplayer); this.players.remove(entityplayer); - this.server.getWorldServer(entityplayer.dimension).removeEntity(entityplayer); + entityplayer.getWorldServer().removePlayer(entityplayer); BlockPosition blockposition = entityplayer.getBed(); boolean flag1 = entityplayer.isRespawnForced(); @@ -417,7 +416,7 @@ entityplayer.dimension = dimensionmanager; Object object; -@@ -412,6 +586,11 @@ +@@ -386,6 +559,11 @@ } EntityPlayer entityplayer1 = new EntityPlayer(this.server, this.server.getWorldServer(entityplayer.dimension), entityplayer.getProfile(), (PlayerInteractManager) object); @@ -429,7 +428,7 @@ entityplayer1.playerConnection = entityplayer.playerConnection; entityplayer1.copyFrom(entityplayer, flag); -@@ -425,43 +604,160 @@ +@@ -399,40 +577,97 @@ entityplayer1.addScoreboardTag(s); } @@ -437,22 +436,22 @@ + // WorldServer worldserver = this.server.getWorldServer(entityplayer.dimension); // CraftBukkit - handled later - this.a(entityplayer1, entityplayer, worldserver); -+ // this.a(entityplayer1, entityplayer, worldserver); // CraftBukkit - removed - BlockPosition blockposition1; - - if (blockposition != null) { -- blockposition1 = EntityHuman.getBed(this.server.getWorldServer(entityplayer.dimension), blockposition, flag1); +- BlockPosition blockposition1 = EntityHuman.getBed(this.server.getWorldServer(entityplayer.dimension), blockposition, flag1); +- - if (blockposition1 != null) { - entityplayer1.setPositionRotation((double) ((float) blockposition1.getX() + 0.5F), (double) ((float) blockposition1.getY() + 0.1F), (double) ((float) blockposition1.getZ() + 0.5F), 0.0F, 0.0F); - entityplayer1.setRespawnPosition(blockposition, flag1); - } else { - entityplayer1.playerConnection.sendPacket(new PacketPlayOutGameStateChange(0, 0.0F)); ++ // this.a(entityplayer1, entityplayer, worldserver); // CraftBukkit - removed ++ + // CraftBukkit start - fire PlayerRespawnEvent + if (location == null) { + boolean isBedSpawn = false; + CraftWorld cworld = (CraftWorld) this.server.server.getWorld(entityplayer.spawnWorld); + if (cworld != null && blockposition != null) { -+ blockposition1 = EntityHuman.getBed(cworld.getHandle(), blockposition, flag1); ++ BlockPosition blockposition1 = EntityHuman.getBed(cworld.getHandle(), blockposition, flag1); + if (blockposition1 != null) { + isBedSpawn = true; + location = new Location(cworld, (double) ((float) blockposition1.getX() + 0.5F), (double) ((float) blockposition1.getY() + 0.1F), (double) ((float) blockposition1.getZ() + 0.5F)); @@ -481,39 +480,40 @@ + entityplayer1.forceSetPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); + // CraftBukkit end - worldserver.getChunkProvider().getChunkAt((int) entityplayer1.locX >> 4, (int) entityplayer1.locZ >> 4, true, true); - -- while (!worldserver.getCubes(entityplayer1, entityplayer1.getBoundingBox()) && entityplayer1.locY < 256.0D) { -+ while (avoidSuffocation && !worldserver.getCubes(entityplayer1, entityplayer1.getBoundingBox()) && entityplayer1.locY < 256.0D) { +- while (!worldserver.getCubes(entityplayer1) && entityplayer1.locY < 256.0D) { ++ while (avoidSuffocation && !worldserver.getCubes(entityplayer1) && entityplayer1.locY < 256.0D) { entityplayer1.setPosition(entityplayer1.locX, entityplayer1.locY + 1.0D, entityplayer1.locZ); } + // CraftBukkit start + // Force the client to refresh their chunk cache + if (fromWorld.getEnvironment() == worldserver.getWorld().getEnvironment()) { -+ entityplayer1.playerConnection.sendPacket(new PacketPlayOutRespawn(worldserver.worldProvider.getDimensionManager().getDimensionID() >= 0 ? DimensionManager.NETHER : DimensionManager.OVERWORLD, worldserver.getDifficulty(), worldserver.getWorldData().getType(), entityplayer.playerInteractManager.getGameMode())); ++ entityplayer1.playerConnection.sendPacket(new PacketPlayOutRespawn(worldserver.worldProvider.getDimensionManager().getDimensionID() >= 0 ? DimensionManager.NETHER : DimensionManager.OVERWORLD, worldserver.getWorldData().getType(), entityplayer.playerInteractManager.getGameMode())); + } -- entityplayer1.playerConnection.sendPacket(new PacketPlayOutRespawn(entityplayer1.dimension, entityplayer1.world.getDifficulty(), entityplayer1.world.getWorldData().getType(), entityplayer1.playerInteractManager.getGameMode())); -+ entityplayer1.playerConnection.sendPacket(new PacketPlayOutRespawn(worldserver.worldProvider.getDimensionManager(), worldserver.getDifficulty(), worldserver.getWorldData().getType(), entityplayer1.playerInteractManager.getGameMode())); +- WorldData worlddata = entityplayer1.world.getWorldData(); ++ WorldData worlddata = worldserver.getWorldData(); + +- entityplayer1.playerConnection.sendPacket(new PacketPlayOutRespawn(entityplayer1.dimension, worlddata.getType(), entityplayer1.playerInteractManager.getGameMode())); ++ entityplayer1.playerConnection.sendPacket(new PacketPlayOutRespawn(worldserver.worldProvider.getDimensionManager(), worldserver.getWorldData().getType(), entityplayer1.playerInteractManager.getGameMode())); + entityplayer1.spawnIn(worldserver); + entityplayer1.dead = false; + entityplayer1.playerConnection.teleport(new Location(worldserver.getWorld(), entityplayer1.locX, entityplayer1.locY, entityplayer1.locZ, entityplayer1.yaw, entityplayer1.pitch)); + entityplayer1.setSneaking(false); - blockposition1 = worldserver.getSpawn(); + BlockPosition blockposition2 = worldserver.getSpawn(); + - entityplayer1.playerConnection.a(entityplayer1.locX, entityplayer1.locY, entityplayer1.locZ, entityplayer1.yaw, entityplayer1.pitch); + // entityplayer1.playerConnection.a(entityplayer1.locX, entityplayer1.locY, entityplayer1.locZ, entityplayer1.yaw, entityplayer1.pitch); - entityplayer1.playerConnection.sendPacket(new PacketPlayOutSpawnPosition(blockposition1)); + entityplayer1.playerConnection.sendPacket(new PacketPlayOutSpawnPosition(blockposition2)); + entityplayer1.playerConnection.sendPacket(new PacketPlayOutServerDifficulty(worlddata.getDifficulty(), worlddata.isDifficultyLocked())); 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.a(entityplayer1, worldserver); + this.d(entityplayer1); +- worldserver.addPlayerRespawn(entityplayer1); - this.players.add(entityplayer1); - this.j.put(entityplayer1.getUniqueID(), entityplayer1); - entityplayer1.syncInventory(); + if (!entityplayer.playerConnection.isDisconnected()) { -+ worldserver.getPlayerChunkMap().addPlayer(entityplayer1); -+ worldserver.addEntity(entityplayer1); ++ worldserver.addPlayerRespawn(entityplayer1); + this.players.add(entityplayer1); + this.j.put(entityplayer1.getUniqueID(), entityplayer1); + } @@ -528,10 +528,7 @@ + } + + // Fire advancement trigger -+ CriterionTriggers.v.a(entityplayer, ((CraftWorld) fromWorld).getHandle().worldProvider.getDimensionManager(), worldserver.worldProvider.getDimensionManager()); -+ if (((CraftWorld) fromWorld).getHandle().worldProvider.getDimensionManager() == DimensionManager.NETHER && worldserver.worldProvider.getDimensionManager() == DimensionManager.OVERWORLD && entityplayer.M() != null) { -+ CriterionTriggers.C.a(entityplayer, entityplayer.M()); -+ } ++ entityplayer.b(((CraftWorld) fromWorld).getHandle()); + + // Don't fire on respawn + if (fromWorld != location.getWorld()) { @@ -547,241 +544,7 @@ return entityplayer1; } -+ // CraftBukkit start - Replaced the standard handling of portals with a more customised method. -+ public void changeDimension(EntityPlayer entityplayer, DimensionManager dimensionManager, TeleportCause cause) { -+ WorldServer exitWorld = null; -+ if (entityplayer.dimension.getDimensionID() < CraftWorld.CUSTOM_DIMENSION_OFFSET) { // plugins must specify exit from custom Bukkit worlds -+ exitWorld = server.getWorldServer(dimensionManager); -+ } -+ -+ Location enter = entityplayer.getBukkitEntity().getLocation(); -+ Location exit = null; -+ boolean useTravelAgent = false; // don't use agent for custom worlds or return from THE_END -+ if (exitWorld != null) { -+ if ((cause == TeleportCause.END_PORTAL) && (dimensionManager == DimensionManager.OVERWORLD)) { -+ // THE_END -> NORMAL; use bed if available, otherwise default spawn -+ exit = ((org.bukkit.craftbukkit.entity.CraftPlayer) entityplayer.getBukkitEntity()).getBedSpawnLocation(); -+ if (exit == null || ((CraftWorld) exit.getWorld()).getHandle().dimension != DimensionManager.OVERWORLD) { -+ BlockPosition randomSpawn = entityplayer.getSpawnPoint(exitWorld); -+ exit = new Location(exitWorld.getWorld(), randomSpawn.getX(), randomSpawn.getY(), randomSpawn.getZ()); -+ } else { -+ exit = exit.add(0.5F, 0.1F, 0.5F); // SPIGOT-3879 -+ } -+ } else { -+ // NORMAL <-> NETHER or NORMAL -> THE_END -+ exit = this.calculateTarget(enter, exitWorld); -+ useTravelAgent = true; -+ } -+ } -+ -+ 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); -+ Bukkit.getServer().getPluginManager().callEvent(event); -+ if (event.isCancelled() || event.getTo() == null) { -+ return; -+ } -+ -+ exit = event.useTravelAgent() ? event.getPortalTravelAgent().findOrCreate(event.getTo()) : event.getTo(); -+ if (exit == null) { -+ return; -+ } -+ exitWorld = ((CraftWorld) exit.getWorld()).getHandle(); -+ -+ 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(); -+ exitWorld.getTravelAgent().adjustExit(entityplayer, exit, velocity); -+ -+ entityplayer.worldChangeInvuln = true; // CraftBukkit - Set teleport invulnerability only if player changing worlds -+ 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.server.a(gameprofile); -@@ -498,42 +794,69 @@ - } - - public void changeWorld(Entity entity, DimensionManager dimensionmanager, WorldServer worldserver, WorldServer worldserver1) { -+ // CraftBukkit start - Split into modular functions -+ Location exit = calculateTarget(entity.getBukkitEntity().getLocation(), worldserver1); -+ repositionEntity(entity, exit, true); -+ } -+ -+ // Copy of original changeWorld(Entity, int, WorldServer, WorldServer) method with only location calculation logic -+ public Location calculateTarget(Location enter, World target) { -+ WorldServer worldserver = ((CraftWorld) enter.getWorld()).getHandle(); -+ WorldServer worldserver1 = ((CraftWorld) target.getWorld()).getHandle(); -+ DimensionManager dimensionmanager = worldserver.dimension; -+ -+ double y = enter.getY(); -+ float yaw = enter.getYaw(); -+ float pitch = enter.getPitch(); -+ double d0 = enter.getX(); -+ 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.enter("moving"); -- if (entity.dimension == DimensionManager.NETHER) { -+ if (worldserver1.dimension == DimensionManager.NETHER) { - d0 = MathHelper.a(d0 / 8.0D, worldserver1.getWorldBorder().b() + 16.0D, worldserver1.getWorldBorder().d() - 16.0D); - d1 = MathHelper.a(d1 / 8.0D, worldserver1.getWorldBorder().c() + 16.0D, worldserver1.getWorldBorder().e() - 16.0D); -+ /* - entity.setPositionRotation(d0, entity.locY, d1, entity.yaw, entity.pitch); - if (entity.isAlive()) { - worldserver.entityJoinedWorld(entity, false); - } -- } else if (entity.dimension == DimensionManager.OVERWORLD) { -+ */ -+ } else if (worldserver1.dimension == DimensionManager.OVERWORLD) { - d0 = MathHelper.a(d0 * 8.0D, worldserver1.getWorldBorder().b() + 16.0D, worldserver1.getWorldBorder().d() - 16.0D); - d1 = MathHelper.a(d1 * 8.0D, worldserver1.getWorldBorder().c() + 16.0D, worldserver1.getWorldBorder().e() - 16.0D); -+ /* - entity.setPositionRotation(d0, entity.locY, d1, entity.yaw, entity.pitch); - if (entity.isAlive()) { - worldserver.entityJoinedWorld(entity, false); - } -+ */ - } else { - BlockPosition blockposition; - - if (dimensionmanager == DimensionManager.THE_END) { -+ // use default NORMAL world spawn instead of target -+ worldserver1 = this.server.getWorldServer(DimensionManager.OVERWORLD); - blockposition = worldserver1.getSpawn(); - } else { - blockposition = worldserver1.getDimensionSpawn(); - } - - d0 = (double) blockposition.getX(); -- entity.locY = (double) blockposition.getY(); -+ y = (double) blockposition.getY(); - d1 = (double) blockposition.getZ(); -+ /* - entity.setPositionRotation(d0, entity.locY, d1, 90.0F, 0.0F); - if (entity.isAlive()) { - worldserver.entityJoinedWorld(entity, false); - } -+ */ - } - - worldserver.methodProfiler.exit(); -@@ -541,22 +864,119 @@ - worldserver.methodProfiler.enter("placing"); - d0 = (double) MathHelper.clamp((int) d0, -29999872, 29999872); - d1 = (double) MathHelper.clamp((int) d1, -29999872, 29999872); -+ /* - if (entity.isAlive()) { - entity.setPositionRotation(d0, entity.locY, d1, entity.yaw, entity.pitch); - worldserver1.getTravelAgent().a(entity, f); - worldserver1.addEntity(entity); - worldserver1.entityJoinedWorld(entity, false); - } -+ */ -+ -+ worldserver.methodProfiler.exit(); -+ } -+ -+ // entity.spawnIn(worldserver1); -+ return new Location(worldserver1.getWorld(), d0, y, d1, yaw, pitch); -+ } -+ -+ // copy of original a(Entity, int, WorldServer, WorldServer) method with only entity repositioning logic -+ public void repositionEntity(Entity entity, Location exit, boolean portal) { -+ WorldServer worldserver = (WorldServer) entity.world; -+ WorldServer worldserver1 = ((CraftWorld) exit.getWorld()).getHandle(); -+ DimensionManager dimensionmanager = worldserver.dimension; -+ -+ /* -+ double d0 = entity.locX; -+ double d1 = entity.locZ; -+ double d2 = 8.0D; -+ float f = entity.yaw; -+ */ -+ -+ worldserver.methodProfiler.enter("moving"); -+ entity.setPositionRotation(exit.getX(), exit.getY(), exit.getZ(), exit.getYaw(), exit.getPitch()); -+ if (entity.isAlive()) { -+ worldserver.entityJoinedWorld(entity, false); -+ } -+ /* -+ if (entity.dimension == DimensionManager.NETHER) { -+ d0 = MathHelper.a(d0 / 8.0D, worldserver1.getWorldBorder().b() + 16.0D, worldserver1.getWorldBorder().d() - 16.0D); -+ d1 = MathHelper.a(d1 / 8.0D, worldserver1.getWorldBorder().c() + 16.0D, worldserver1.getWorldBorder().e() - 16.0D); -+ entity.setPositionRotation(d0, entity.locY, d1, entity.yaw, entity.pitch); -+ if (entity.isAlive()) { -+ worldserver.entityJoinedWorld(entity, false); -+ } -+ } else if (entity.dimension == DimensionManager.OVERWORLD) { -+ d0 = MathHelper.a(d0 * 8.0D, worldserver1.getWorldBorder().b() + 16.0D, worldserver1.getWorldBorder().d() - 16.0D); -+ d1 = MathHelper.a(d1 * 8.0D, worldserver1.getWorldBorder().c() + 16.0D, worldserver1.getWorldBorder().e() - 16.0D); -+ entity.setPositionRotation(d0, entity.locY, d1, entity.yaw, entity.pitch); -+ if (entity.isAlive()) { -+ worldserver.entityJoinedWorld(entity, false); -+ } -+ } else { -+ BlockPosition blockposition; -+ -+ if (dimensionmanager == DimensionManager.THE_END) { -+ // use default NORMAL world spawn instead of target -+ worldserver1 = this.server.worlds.get(0); -+ blockposition = worldserver1.getSpawn(); -+ } else { -+ blockposition = worldserver1.getDimensionSpawn(); -+ } -+ -+ d0 = (double) blockposition.getX(); -+ entity.locY = (double) blockposition.getY(); -+ d1 = (double) blockposition.getZ(); -+ entity.setPositionRotation(d0, entity.locY, d1, 90.0F, 0.0F); -+ if (entity.isAlive()) { -+ worldserver.entityJoinedWorld(entity, false); -+ } -+ } -+ */ -+ -+ worldserver.methodProfiler.exit(); -+ if (dimensionmanager != DimensionManager.THE_END) { -+ worldserver.methodProfiler.enter("placing"); -+ /* -+ d0 = (double) MathHelper.clamp((int) d0, -29999872, 29999872); -+ d1 = (double) MathHelper.clamp((int) d1, -29999872, 29999872); -+ */ -+ if (entity.isAlive()) { -+ // entity.setPositionRotation(d0, entity.locY, d1, entity.yaw, entity.pitch); -+ // worldserver1.getTravelAgent().a(entity, f); -+ if (portal) { -+ Vector velocity = entity.getBukkitEntity().getVelocity(); -+ worldserver1.getTravelAgent().adjustExit(entity, exit, velocity); -+ entity.setPositionRotation(exit.getX(), exit.getY(), exit.getZ(), exit.getYaw(), exit.getPitch()); -+ if (entity.motX != velocity.getX() || entity.motY != velocity.getY() || entity.motZ != velocity.getZ()) { -+ entity.getBukkitEntity().setVelocity(velocity); -+ } -+ } -+ // worldserver1.addEntity(entity); -+ worldserver1.entityJoinedWorld(entity, false); -+ } - - worldserver.methodProfiler.exit(); - } - - entity.spawnIn(worldserver1); -+ // CraftBukkit end - } +@@ -445,7 +680,18 @@ public void tick() { if (++this.v > 600) { @@ -801,7 +564,7 @@ this.v = 0; } -@@ -569,6 +989,25 @@ +@@ -458,6 +704,25 @@ } @@ -817,8 +580,8 @@ + } + + public void sendAll(Packet packet, World world) { -+ for (int i = 0; i < world.players.size(); ++i) { -+ ((EntityPlayer) world.players.get(i)).playerConnection.sendPacket(packet); ++ for (int i = 0; i < world.getPlayers().size(); ++i) { ++ ((EntityPlayer) world.getPlayers().get(i)).playerConnection.sendPacket(packet); + } + + } @@ -827,7 +590,7 @@ public void a(Packet packet, DimensionManager dimensionmanager) { for (int i = 0; i < this.players.size(); ++i) { EntityPlayer entityplayer = (EntityPlayer) this.players.get(i); -@@ -669,6 +1108,7 @@ +@@ -558,6 +823,7 @@ entityplayer.playerConnection.sendPacket(new PacketPlayOutEntityStatus(entityplayer, b0)); } @@ -835,7 +598,7 @@ this.server.getCommandDispatcher().a(entityplayer); } -@@ -701,6 +1141,12 @@ +@@ -590,6 +856,12 @@ for (int i = 0; i < this.players.size(); ++i) { EntityPlayer entityplayer = (EntityPlayer) this.players.get(i); @@ -848,28 +611,28 @@ if (entityplayer != entityhuman && entityplayer.dimension == dimensionmanager) { double d4 = d0 - entityplayer.locX; double d5 = d1 - entityplayer.locY; -@@ -740,7 +1186,7 @@ +@@ -629,7 +901,7 @@ public void reloadWhitelist() {} - public void b(EntityPlayer entityplayer, WorldServer worldserver) { + public void a(EntityPlayer entityplayer, WorldServer worldserver) { - WorldBorder worldborder = this.server.getWorldServer(DimensionManager.OVERWORLD).getWorldBorder(); + WorldBorder worldborder = entityplayer.world.getWorldBorder(); // CraftBukkit entityplayer.playerConnection.sendPacket(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.INITIALIZE)); entityplayer.playerConnection.sendPacket(new PacketPlayOutUpdateTime(worldserver.getTime(), worldserver.getDayTime(), worldserver.getGameRules().getBoolean("doDaylightCycle"))); -@@ -748,17 +1194,26 @@ +@@ -637,17 +909,26 @@ entityplayer.playerConnection.sendPacket(new PacketPlayOutSpawnPosition(blockposition)); if (worldserver.isRaining()) { - entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(1, 0.0F)); -- entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(7, worldserver.i(1.0F))); -- entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(8, worldserver.g(1.0F))); +- entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(7, worldserver.h(1.0F))); +- entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(8, worldserver.f(1.0F))); + // CraftBukkit start - handle player weather + // entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(1, 0.0F)); -+ // entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(7, worldserver.i(1.0F))); -+ // entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(8, worldserver.g(1.0F))); ++ // entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(7, worldserver.h(1.0F))); ++ // entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(8, worldserver.f(1.0F))); + entityplayer.setPlayerWeather(org.bukkit.WeatherType.DOWNFALL, false); -+ entityplayer.updateWeather(-worldserver.o, worldserver.o, -worldserver.q, worldserver.q); ++ entityplayer.updateWeather(-worldserver.j, worldserver.j, -worldserver.l, worldserver.l); + // CraftBukkit end } @@ -882,16 +645,16 @@ + entityplayer.getBukkitEntity().updateScaledHealth(); // CraftBukkit - Update scaled health on respawn and worldchange entityplayer.playerConnection.sendPacket(new PacketPlayOutHeldItemSlot(entityplayer.inventory.itemInHandIndex)); + // CraftBukkit start - from GameRules -+ int i = entityplayer.world.getGameRules().get("reducedDebugInfo").b() ? 22 : 23; ++ int i = entityplayer.world.getGameRules().get("reducedDebugInfo").getBooleanValue() ? 22 : 23; + entityplayer.playerConnection.sendPacket(new PacketPlayOutEntityStatus(entityplayer, (byte) i)); + // CraftBukkit end } public int getPlayerCount() { -@@ -819,26 +1274,39 @@ +@@ -704,26 +985,39 @@ } - public void u() { + public void shutdown() { - for (int i = 0; i < this.players.size(); ++i) { - ((EntityPlayer) this.players.get(i)).playerConnection.disconnect(new ChatMessage("multiplayer.disconnect.server_shutdown", new Object[0])); + // CraftBukkit start - disconnect safely @@ -933,7 +696,7 @@ if (serverstatisticmanager == null) { File file = new File(this.server.getWorldServer(DimensionManager.OVERWORLD).getDataManager().getDirectory(), "stats"); -@@ -853,7 +1321,7 @@ +@@ -738,7 +1032,7 @@ } serverstatisticmanager = new ServerStatisticManager(this.server, file1); @@ -942,9 +705,9 @@ } return serverstatisticmanager; -@@ -861,14 +1329,14 @@ +@@ -746,14 +1040,14 @@ - public AdvancementDataPlayer h(EntityPlayer entityplayer) { + public AdvancementDataPlayer f(EntityPlayer entityplayer) { UUID uuid = entityplayer.getUniqueID(); - AdvancementDataPlayer advancementdataplayer = (AdvancementDataPlayer) this.p.get(uuid); + AdvancementDataPlayer advancementdataplayer = (AdvancementDataPlayer) entityplayer.getAdvancementData(); // CraftBukkit @@ -959,7 +722,7 @@ } advancementdataplayer.a(entityplayer); -@@ -904,13 +1372,20 @@ +@@ -789,13 +1083,20 @@ } public void reload() { diff --git a/nms-patches/PortalTravelAgent.patch b/nms-patches/PortalTravelAgent.patch deleted file mode 100644 index f7ab8e66bf..0000000000 --- a/nms-patches/PortalTravelAgent.patch +++ /dev/null @@ -1,278 +0,0 @@ ---- a/net/minecraft/server/PortalTravelAgent.java -+++ b/net/minecraft/server/PortalTravelAgent.java -@@ -4,6 +4,11 @@ - import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; - import it.unimi.dsi.fastutil.objects.ObjectIterator; - import java.util.Random; -+// CraftBukkit start -+import org.bukkit.Location; -+import org.bukkit.event.entity.EntityPortalExitEvent; -+import org.bukkit.util.Vector; -+// CraftBukkit end - - public class PortalTravelAgent { - -@@ -27,8 +32,21 @@ - int i = MathHelper.floor(entity.locX); - int j = MathHelper.floor(entity.locY) - 1; - int k = MathHelper.floor(entity.locZ); -- boolean flag = true; -- boolean flag1 = false; -+ // CraftBukkit start - Modularize end portal creation -+ BlockPosition created = this.createEndPortal(entity.locX, entity.locY, entity.locZ); -+ entity.setPositionRotation((double) created.getX(), (double) created.getY(), (double) created.getZ(), entity.yaw, 0.0F); -+ entity.motX = entity.motY = entity.motZ = 0.0D; -+ } -+ } -+ -+ // Split out from original a(Entity, double, double, double, float) method in order to enable being called from createPortal -+ private BlockPosition createEndPortal(double x, double y, double z) { -+ int i = MathHelper.floor(x); -+ int j = MathHelper.floor(y) - 1; -+ int k = MathHelper.floor(z); -+ // CraftBukkit end -+ byte b0 = 1; -+ byte b1 = 0; - - for (int l = -2; l <= 2; ++l) { - for (int i1 = -2; i1 <= 2; ++i1) { -@@ -43,18 +61,63 @@ - } - } - -- entity.setPositionRotation((double) i, (double) j, (double) k, entity.yaw, 0.0F); -- entity.motX = 0.0D; -- entity.motY = 0.0D; -- entity.motZ = 0.0D; -+ // CraftBukkit start -+ return new BlockPosition(i, k, k); -+ } -+ -+ // use logic based on creation to verify end portal -+ private BlockPosition findEndPortal(BlockPosition portal) { -+ int i = portal.getX(); -+ int j = portal.getY() - 1; -+ int k = portal.getZ(); -+ byte b0 = 1; -+ byte b1 = 0; -+ -+ for (int l = -2; l <= 2; ++l) { -+ for (int i1 = -2; i1 <= 2; ++i1) { -+ for (int j1 = -1; j1 < 3; ++j1) { -+ int k1 = i + i1 * b0 + l * b1; -+ int l1 = j + j1; -+ int i2 = k + i1 * b1 - l * b0; -+ boolean flag = j1 < 0; -+ -+ if (this.world.getType(new BlockPosition(k1, l1, i2)).getBlock() != (flag ? Blocks.OBSIDIAN : Blocks.AIR)) { -+ return null; -+ } -+ } -+ } - } -+ return new BlockPosition(i, j, k); - } -+ // CraftBukkit end - - public boolean b(Entity entity, float f) { -- boolean flag = true; -+ // CraftBukkit start - Modularize portal search process and entity teleportation -+ BlockPosition found = this.findPortal(entity.locX, entity.locY, entity.locZ, 128); -+ if (found == null) { -+ return false; -+ } -+ -+ 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()); -+ if (entity.motX != velocity.getX() || entity.motY != velocity.getY() || entity.motZ != velocity.getZ()) { -+ entity.getBukkitEntity().setVelocity(velocity); -+ } -+ return true; -+ } -+ -+ public BlockPosition findPortal(double x, double y, double z, int radius) { -+ if (this.world.getWorld().getEnvironment() == org.bukkit.World.Environment.THE_END) { -+ return this.findEndPortal(this.world.worldProvider.d()); -+ } -+ // CraftBukkit end - double d0 = -1.0D; -- int i = MathHelper.floor(entity.locX); -- int j = MathHelper.floor(entity.locZ); -+ // CraftBukkit start -+ int i = MathHelper.floor(x); -+ int j = MathHelper.floor(z); -+ // CraftBukkit end - boolean flag1 = true; - Object object = BlockPosition.ZERO; - long k = ChunkCoordIntPair.a(i, j); -@@ -67,12 +130,12 @@ - portaltravelagent_chunkcoordinatesportal.b = this.world.getTime(); - flag1 = false; - } else { -- BlockPosition blockposition = new BlockPosition(entity); -+ BlockPosition blockposition = new BlockPosition(x, y, z); // CraftBukkit - -- for (int l = -128; l <= 128; ++l) { -+ for (int l = -radius; l <= radius; ++l) { - BlockPosition blockposition1; - -- for (int i1 = -128; i1 <= 128; ++i1) { -+ for (int i1 = -radius; i1 <= radius; ++i1) { - for (BlockPosition blockposition2 = blockposition.a(l, this.world.ab() - 1 - blockposition.getY(), i1); blockposition2.getY() >= 0; blockposition2 = blockposition1) { - blockposition1 = blockposition2.down(); - if (this.world.getType(blockposition2).getBlock() == PortalTravelAgent.a) { -@@ -96,6 +159,29 @@ - if (flag1) { - this.d.put(k, new PortalTravelAgent.ChunkCoordinatesPortal((BlockPosition) object, this.world.getTime())); - } -+ // CraftBukkit start - Move entity teleportation logic into exit -+ return (BlockPosition) object; -+ } else { -+ return null; -+ } -+ } -+ -+ // Entity repositioning logic split out from original b method and combined with repositioning logic for The End from original a method -+ public void adjustExit(Entity entity, Location position, Vector velocity) { -+ Location from = position.clone(); -+ Vector before = velocity.clone(); -+ BlockPosition object = new BlockPosition(position.getBlockX(), position.getBlockY(), position.getBlockZ()); -+ float f = position.getYaw(); -+ -+ 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); -+ velocity.setX(0); -+ velocity.setY(0); -+ velocity.setZ(0); -+ } else { -+ // CraftBukkit end - - double d2 = (double) ((BlockPosition) object).getX() + 0.5D; - double d3 = (double) ((BlockPosition) object).getZ() + 0.5D; -@@ -133,31 +219,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.getPortalDirection().opposite().get2DRotationValue() * 90) + (float) (shapedetector_shapedetectorcollection.getFacing().get2DRotationValue() * 90); -- if (entity instanceof EntityPlayer) { -- ((EntityPlayer) entity).playerConnection.a(d2, d5, d3, entity.yaw, entity.pitch); -- ((EntityPlayer) entity).playerConnection.syncPosition(); -- } else { -- entity.setPositionRotation(d2, d5, d3, entity.yaw, entity.pitch); -- } -- -- return true; -+ // CraftBukkit start -+ double d6 = velocity.getX(); -+ double d7 = velocity.getZ(); -+ // CraftBukkit end -+ -+ // 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.getPortalDirection().opposite().get2DRotationValue() * 90) + (float) (shapedetector_shapedetectorcollection.getFacing().get2DRotationValue() * 90); -+ // entity.setPositionRotation(d2, d5, d3, entity.yaw, entity.pitch); -+ position.setX(d2); -+ position.setY(d5); -+ position.setZ(d3); -+ position.setYaw(f); -+ } -+ EntityPortalExitEvent event = new EntityPortalExitEvent(entity.getBukkitEntity(), from, position, before, velocity); -+ this.world.getServer().getPluginManager().callEvent(event); -+ Location to = event.getTo(); -+ if (event.isCancelled() || to == null || !entity.isAlive()) { -+ position.setX(from.getX()); -+ position.setY(from.getY()); -+ position.setZ(from.getZ()); -+ position.setYaw(from.getYaw()); -+ position.setPitch(from.getPitch()); -+ velocity.copy(before); - } else { -- return false; -+ position.setX(to.getX()); -+ position.setY(to.getY()); -+ position.setZ(to.getZ()); -+ position.setYaw(to.getYaw()); -+ position.setPitch(to.getPitch()); -+ velocity.copy(event.getAfter()); // event.getAfter() will never be null, as setAfter() will cause an NPE if null is passed in - } -+ // CraftBukkit end - } - - public boolean a(Entity entity) { -- boolean flag = true; -+ // CraftBukkit start - Allow for portal creation to be based on coordinates instead of entity -+ return this.createPortal(entity.locX, entity.locY, entity.locZ, 16); -+ } -+ -+ public boolean createPortal(double x, double y, double z, int b0) { -+ if (this.world.getWorld().getEnvironment() == org.bukkit.World.Environment.THE_END) { -+ createEndPortal(x, y, z); -+ return true; -+ } -+ // CraftBukkit end - double d0 = -1.0D; -- int i = MathHelper.floor(entity.locX); -- int j = MathHelper.floor(entity.locY); -- int k = MathHelper.floor(entity.locZ); -+ // CraftBukkit start -+ int i = MathHelper.floor(x); -+ int j = MathHelper.floor(y); -+ int k = MathHelper.floor(z); -+ // CraftBukkit end - int l = i; - int i1 = j; - int j1 = k; -@@ -182,10 +296,10 @@ - double d4; - - for (i2 = i - 16; i2 <= i + 16; ++i2) { -- d1 = (double) i2 + 0.5D - entity.locX; -+ d1 = (double) i2 + 0.5D - x; // CraftBukkit - - for (j2 = k - 16; j2 <= k + 16; ++j2) { -- d2 = (double) j2 + 0.5D - entity.locZ; -+ d2 = (double) j2 + 0.5D - z; // CraftBukkit - - label257: - for (k2 = this.world.ab() - 1; k2 >= 0; --k2) { -@@ -217,7 +331,7 @@ - } - } - -- d3 = (double) k2 + 0.5D - entity.locY; -+ d3 = (double) k2 + 0.5D - y; // CraftBukkit - d4 = d1 * d1 + d3 * d3 + d2 * d2; - if (d0 < 0.0D || d4 < d0) { - d0 = d4; -@@ -234,10 +348,10 @@ - - if (d0 < 0.0D) { - for (i2 = i - 16; i2 <= i + 16; ++i2) { -- d1 = (double) i2 + 0.5D - entity.locX; -+ d1 = (double) i2 + 0.5D - x; // CraftBukkit - - for (j2 = k - 16; j2 <= k + 16; ++j2) { -- d2 = (double) j2 + 0.5D - entity.locZ; -+ d2 = (double) j2 + 0.5D - z; // CraftBukkit - - label205: - for (k2 = this.world.ab() - 1; k2 >= 0; --k2) { -@@ -262,7 +376,7 @@ - } - } - -- d3 = (double) k2 + 0.5D - entity.locY; -+ d3 = (double) k2 + 0.5D - y; // CraftBukkit - d4 = d1 * d1 + d3 * d3 + d2 * d2; - if (d0 < 0.0D || d4 < d0) { - d0 = d4; diff --git a/nms-patches/PropertyManager.patch b/nms-patches/PropertyManager.patch index c312cda9f9..066695224b 100644 --- a/nms-patches/PropertyManager.patch +++ b/nms-patches/PropertyManager.patch @@ -1,27 +1,25 @@ --- a/net/minecraft/server/PropertyManager.java +++ b/net/minecraft/server/PropertyManager.java -@@ -8,6 +8,8 @@ +@@ -15,15 +15,30 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import joptsimple.OptionSet; // CraftBukkit + - public class PropertyManager { + public abstract class PropertyManager> { private static final Logger a = LogManager.getLogger(); -@@ -42,6 +44,24 @@ - - } - + public final Properties properties; + // CraftBukkit start + private OptionSet options = null; -+ -+ public PropertyManager(final OptionSet options) { -+ this((File) options.valueOf("config")); + +- public PropertyManager(Properties properties) { ++ public PropertyManager(Properties properties, final OptionSet options) { + this.properties = properties; + + this.options = options; -+ } -+ + } + + private T getOverride(String name, T value) { + if ((this.options != null) && (this.options.has(name))) { + return (T) this.options.valueOf(name); @@ -31,63 +29,90 @@ + } + // CraftBukkit end + - public void a() { - PropertyManager.a.info("Generating new properties file"); - this.savePropertiesFile(); -@@ -51,6 +71,12 @@ - FileOutputStream fileoutputstream = null; + public static Properties loadPropertiesFile(java.nio.file.Path java_nio_file_path) { + Properties properties = new Properties(); +@@ -59,6 +74,11 @@ + + public void savePropertiesFile(java.nio.file.Path java_nio_file_path) { try { + // CraftBukkit start - Don't attempt writing to file if it's read only -+ if (this.file.exists() && !this.file.canWrite()) { ++ if (java_nio_file_path.toFile().exists() && !java_nio_file_path.toFile().canWrite()) { + return; + } + // CraftBukkit end -+ - fileoutputstream = new FileOutputStream(this.file); - this.properties.store(fileoutputstream, "Minecraft server properties"); - } catch (Exception exception) { -@@ -80,36 +106,36 @@ - this.savePropertiesFile(); - } + OutputStream outputstream = Files.newOutputStream(java_nio_file_path); + Throwable throwable = null; -- return this.properties.getProperty(s, s1); -+ return getOverride(s, this.properties.getProperty(s, s1)); // CraftBukkit +@@ -90,7 +110,7 @@ + private static Function a(Function function) { + return (s) -> { + try { +- return (Number) function.apply(s); ++ return (V) function.apply(s); // CraftBukkit - decompile error + } catch (NumberFormatException numberformatexception) { + return null; + } +@@ -109,7 +129,7 @@ + + @Nullable + private String c(String s) { +- return (String) this.properties.get(s); ++ return (String) getOverride(s, this.properties.getProperty(s)); // CraftBukkit } - public int getInt(String s, int i) { - try { -- return Integer.parseInt(this.getString(s, "" + i)); -+ return getOverride(s, Integer.parseInt(this.getString(s, "" + i))); // CraftBukkit - } catch (Exception exception) { - this.properties.setProperty(s, "" + i); - this.savePropertiesFile(); -- return i; -+ return getOverride(s, i); // CraftBukkit - } + @Nullable +@@ -137,7 +157,7 @@ + V v1 = MoreObjects.firstNonNull(s1 != null ? function.apply(s1) : null, v0); + + this.properties.put(s, function1.apply(v1)); +- return new PropertyManager.EditableProperty<>(s, v1, function1); ++ return new PropertyManager.EditableProperty(s, v1, function1); // CraftBukkit - decompile error } - public long getLong(String s, long i) { - try { -- return Long.parseLong(this.getString(s, "" + i)); -+ return getOverride(s, Long.parseLong(this.getString(s, "" + i))); // CraftBukkit - } catch (Exception exception) { - this.properties.setProperty(s, "" + i); - this.savePropertiesFile(); -- return i; -+ return getOverride(s, i); // CraftBukkit - } + protected V a(String s, Function function, UnaryOperator unaryoperator, Function function1, V v0) { +@@ -166,7 +186,7 @@ } - public boolean getBoolean(String s, boolean flag) { - try { -- return Boolean.parseBoolean(this.getString(s, "" + flag)); -+ return getOverride(s, Boolean.parseBoolean(this.getString(s, "" + flag))); //CraftBukkit - } catch (Exception exception) { - this.properties.setProperty(s, "" + flag); - this.savePropertiesFile(); -- return flag; -+ return getOverride(s, flag); // CraftBukkit - } + protected int getInt(String s, int i) { +- return (Integer) this.a(s, a(Integer::parseInt), (Object) i); ++ return (Integer) this.a(s, a(Integer::parseInt), i); // CraftBukkit - decompile error } + protected PropertyManager.EditableProperty b(String s, int i) { +@@ -178,7 +198,7 @@ + } + + protected long getLong(String s, long i) { +- return (Long) this.a(s, a(Long::parseLong), (Object) i); ++ return (Long) this.a(s, a(Long::parseLong), i); // CraftBukkit - decompile error + } + + protected boolean getBoolean(String s, boolean flag) { +@@ -201,7 +221,7 @@ + return properties; + } + +- protected abstract T reload(Properties properties); ++ protected abstract T reload(Properties properties, OptionSet optionset); // CraftBukkit + + public class EditableProperty implements Supplier { + +@@ -209,7 +229,7 @@ + private final V c; + private final Function d; + +- private EditableProperty(String s, Object object, Function function) { ++ private EditableProperty(String s, V object, Function function) { // CraftBukkit - decompile error + this.b = s; + this.c = object; + this.d = function; +@@ -223,7 +243,7 @@ + Properties properties = PropertyManager.this.a(); + + properties.put(this.b, this.d.apply(v0)); +- return PropertyManager.this.reload(properties); ++ return PropertyManager.this.reload(properties, PropertyManager.this.options); // CraftBukkit + } + } + } diff --git a/nms-patches/RayTrace.patch b/nms-patches/RayTrace.patch new file mode 100644 index 0000000000..3afeb800c8 --- /dev/null +++ b/nms-patches/RayTrace.patch @@ -0,0 +1,20 @@ +--- a/net/minecraft/server/RayTrace.java ++++ b/net/minecraft/server/RayTrace.java +@@ -15,7 +15,7 @@ + this.b = vec3d1; + this.c = raytrace_blockcollisionoption; + this.d = raytrace_fluidcollisionoption; +- this.e = VoxelShapeCollision.a(entity); ++ this.e = (entity == null) ? VoxelShapeCollision.a() : VoxelShapeCollision.a(entity); // CraftBukkit + } + + public Vec3D a() { +@@ -44,7 +44,7 @@ + + private final Predicate predicate; + +- private FluidCollisionOption(Predicate predicate) { ++ private FluidCollisionOption(Predicate predicate) { // CraftBukkit - decompile error + this.predicate = predicate; + } + diff --git a/nms-patches/RecipeArmorDye.patch b/nms-patches/RecipeArmorDye.patch index a91746b12c..e0a7924c9f 100644 --- a/nms-patches/RecipeArmorDye.patch +++ b/nms-patches/RecipeArmorDye.patch @@ -5,7 +5,7 @@ import java.util.List; -public class RecipeArmorDye extends IRecipeComplex { -+public class RecipeArmorDye extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends ++public class RecipeArmorDye extends ShapelessRecipes { // CraftBukkit - added extends + // CraftBukkit start - Delegate to new parent class with bogus info public RecipeArmorDye(MinecraftKey minecraftkey) { @@ -14,5 +14,5 @@ } + // CraftBukkit end - public boolean a(IInventory iinventory, World world) { - if (!(iinventory instanceof InventoryCrafting)) { + public boolean a(InventoryCrafting inventorycrafting, World world) { + ItemStack itemstack = ItemStack.a; diff --git a/nms-patches/RecipeBannerAdd.patch b/nms-patches/RecipeBannerAdd.patch deleted file mode 100644 index 372051982b..0000000000 --- a/nms-patches/RecipeBannerAdd.patch +++ /dev/null @@ -1,18 +0,0 @@ ---- a/net/minecraft/server/RecipeBannerAdd.java -+++ b/net/minecraft/server/RecipeBannerAdd.java -@@ -2,11 +2,13 @@ - - import javax.annotation.Nullable; - --public class RecipeBannerAdd extends IRecipeComplex { -+public class RecipeBannerAdd extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends - -+ // CraftBukkit start - Delegate to new parent class with bogus info - public RecipeBannerAdd(MinecraftKey minecraftkey) { -- super(minecraftkey); -+ super(minecraftkey, "", new ItemStack(Items.WHITE_BANNER, 0), NonNullList.a(RecipeItemStack.a, RecipeItemStack.a(Items.WHITE_BANNER))); - } -+ // CraftBukkit end - - public boolean a(IInventory iinventory, World world) { - if (!(iinventory instanceof InventoryCrafting)) { diff --git a/nms-patches/RecipeBannerDuplicate.patch b/nms-patches/RecipeBannerDuplicate.patch index f4020aca74..2a75b9ae59 100644 --- a/nms-patches/RecipeBannerDuplicate.patch +++ b/nms-patches/RecipeBannerDuplicate.patch @@ -4,7 +4,7 @@ package net.minecraft.server; -public class RecipeBannerDuplicate extends IRecipeComplex { -+public class RecipeBannerDuplicate extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends ++public class RecipeBannerDuplicate extends ShapelessRecipes { // CraftBukkit - added extends + // CraftBukkit start - Delegate to new parent class with bogus info public RecipeBannerDuplicate(MinecraftKey minecraftkey) { @@ -13,5 +13,5 @@ } + // CraftBukkit end - public boolean a(IInventory iinventory, World world) { - if (!(iinventory instanceof InventoryCrafting)) { + public boolean a(InventoryCrafting inventorycrafting, World world) { + EnumColor enumcolor = null; diff --git a/nms-patches/RecipeBlasting.patch b/nms-patches/RecipeBlasting.patch new file mode 100644 index 0000000000..333e2c0f75 --- /dev/null +++ b/nms-patches/RecipeBlasting.patch @@ -0,0 +1,33 @@ +--- a/net/minecraft/server/RecipeBlasting.java ++++ b/net/minecraft/server/RecipeBlasting.java +@@ -1,5 +1,13 @@ + package net.minecraft.server; + ++// CraftBukkit start ++import org.bukkit.craftbukkit.inventory.CraftBlastingRecipe; ++import org.bukkit.craftbukkit.inventory.CraftItemStack; ++import org.bukkit.craftbukkit.inventory.CraftRecipe; ++import org.bukkit.craftbukkit.util.CraftNamespacedKey; ++import org.bukkit.inventory.Recipe; ++// CraftBukkit end ++ + public class RecipeBlasting extends RecipeCooking { + + public RecipeBlasting(MinecraftKey minecraftkey, String s, RecipeItemStack recipeitemstack, ItemStack itemstack, float f, int i) { +@@ -10,4 +18,16 @@ + public RecipeSerializer getRecipeSerializer() { + return RecipeSerializer.p; + } ++ ++ // CraftBukkit start ++ @Override ++ public Recipe toBukkitRecipe() { ++ CraftItemStack result = CraftItemStack.asCraftMirror(this.result); ++ ++ CraftBlastingRecipe recipe = new CraftBlastingRecipe(CraftNamespacedKey.fromMinecraft(this.key), result, CraftRecipe.toBukkit(this.ingredient), this.experience, this.cookingTime); ++ recipe.setGroup(this.group); ++ ++ return recipe; ++ } ++ // CraftBukkit end + } diff --git a/nms-patches/RecipeBookClone.patch b/nms-patches/RecipeBookClone.patch index 3db8854686..5633cd671e 100644 --- a/nms-patches/RecipeBookClone.patch +++ b/nms-patches/RecipeBookClone.patch @@ -4,7 +4,7 @@ package net.minecraft.server; -public class RecipeBookClone extends IRecipeComplex { -+public class RecipeBookClone extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends ++public class RecipeBookClone extends ShapelessRecipes { // CraftBukkit - added extends + // CraftBukkit start - Delegate to new parent class with bogus info public RecipeBookClone(MinecraftKey minecraftkey) { @@ -13,5 +13,5 @@ } + // CraftBukkit end - public boolean a(IInventory iinventory, World world) { - if (!(iinventory instanceof InventoryCrafting)) { + public boolean a(InventoryCrafting inventorycrafting, World world) { + int i = 0; diff --git a/nms-patches/RecipeBookServer.patch b/nms-patches/RecipeBookServer.patch index 5175a692d8..c4ca374394 100644 --- a/nms-patches/RecipeBookServer.patch +++ b/nms-patches/RecipeBookServer.patch @@ -1,23 +1,23 @@ --- a/net/minecraft/server/RecipeBookServer.java +++ b/net/minecraft/server/RecipeBookServer.java -@@ -7,6 +7,7 @@ - import java.util.List; +@@ -8,6 +8,7 @@ + import java.util.Optional; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit public class RecipeBookServer extends RecipeBook { -@@ -26,7 +27,7 @@ - IRecipe irecipe = (IRecipe) iterator.next(); +@@ -27,7 +28,7 @@ + IRecipe irecipe = (IRecipe) iterator.next(); MinecraftKey minecraftkey = irecipe.getKey(); -- if (!this.a.contains(minecraftkey) && !irecipe.c()) { -+ if (!this.a.contains(minecraftkey) && !irecipe.c() && CraftEventFactory.handlePlayerRecipeListUpdateEvent(entityplayer, minecraftkey)) { // CraftBukkit +- if (!this.a.contains(minecraftkey) && !irecipe.isComplex()) { ++ if (!this.a.contains(minecraftkey) && !irecipe.isComplex() && CraftEventFactory.handlePlayerRecipeListUpdateEvent(entityplayer, minecraftkey)) { // CraftBukkit this.a(minecraftkey); this.c(minecraftkey); list.add(minecraftkey); -@@ -60,6 +61,7 @@ +@@ -61,6 +62,7 @@ } private void a(PacketPlayOutRecipes.Action packetplayoutrecipes_action, EntityPlayer entityplayer, List list) { diff --git a/nms-patches/RecipeCampfire.patch b/nms-patches/RecipeCampfire.patch new file mode 100644 index 0000000000..c467cfaeb9 --- /dev/null +++ b/nms-patches/RecipeCampfire.patch @@ -0,0 +1,33 @@ +--- a/net/minecraft/server/RecipeCampfire.java ++++ b/net/minecraft/server/RecipeCampfire.java +@@ -1,5 +1,13 @@ + package net.minecraft.server; + ++// CraftBukkit start ++import org.bukkit.craftbukkit.inventory.CraftCampfireRecipe; ++import org.bukkit.craftbukkit.inventory.CraftItemStack; ++import org.bukkit.craftbukkit.inventory.CraftRecipe; ++import org.bukkit.craftbukkit.util.CraftNamespacedKey; ++import org.bukkit.inventory.Recipe; ++// CraftBukkit end ++ + public class RecipeCampfire extends RecipeCooking { + + public RecipeCampfire(MinecraftKey minecraftkey, String s, RecipeItemStack recipeitemstack, ItemStack itemstack, float f, int i) { +@@ -10,4 +18,16 @@ + public RecipeSerializer getRecipeSerializer() { + return RecipeSerializer.r; + } ++ ++ // CraftBukkit start ++ @Override ++ public Recipe toBukkitRecipe() { ++ CraftItemStack result = CraftItemStack.asCraftMirror(this.result); ++ ++ CraftCampfireRecipe recipe = new CraftCampfireRecipe(CraftNamespacedKey.fromMinecraft(this.key), result, CraftRecipe.toBukkit(this.ingredient), this.experience, this.cookingTime); ++ recipe.setGroup(this.group); ++ ++ return recipe; ++ } ++ // CraftBukkit end + } diff --git a/nms-patches/RecipeFireworks.patch b/nms-patches/RecipeFireworks.patch index 5ce9b621dc..c5568e1f99 100644 --- a/nms-patches/RecipeFireworks.patch +++ b/nms-patches/RecipeFireworks.patch @@ -4,7 +4,7 @@ package net.minecraft.server; -public class RecipeFireworks extends IRecipeComplex { -+public class RecipeFireworks extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends ++public class RecipeFireworks extends ShapelessRecipes { // CraftBukkit - added extends private static final RecipeItemStack a = RecipeItemStack.a(Items.PAPER); private static final RecipeItemStack b = RecipeItemStack.a(Items.GUNPOWDER); @@ -17,5 +17,5 @@ } + // CraftBukkit end - public boolean a(IInventory iinventory, World world) { - if (!(iinventory instanceof InventoryCrafting)) { + public boolean a(InventoryCrafting inventorycrafting, World world) { + boolean flag = false; diff --git a/nms-patches/RecipeFireworksFade.patch b/nms-patches/RecipeFireworksFade.patch index eb4be83667..023df96ff8 100644 --- a/nms-patches/RecipeFireworksFade.patch +++ b/nms-patches/RecipeFireworksFade.patch @@ -5,7 +5,7 @@ import java.util.List; -public class RecipeFireworksFade extends IRecipeComplex { -+public class RecipeFireworksFade extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends ++public class RecipeFireworksFade extends ShapelessRecipes { // CraftBukkit - added extends private static final RecipeItemStack a = RecipeItemStack.a(Items.FIREWORK_STAR); @@ -16,5 +16,5 @@ } + // CraftBukkit end - public boolean a(IInventory iinventory, World world) { - if (!(iinventory instanceof InventoryCrafting)) { + public boolean a(InventoryCrafting inventorycrafting, World world) { + boolean flag = false; diff --git a/nms-patches/RecipeFireworksStar.patch b/nms-patches/RecipeFireworksStar.patch index 5cd299d718..e0a8859838 100644 --- a/nms-patches/RecipeFireworksStar.patch +++ b/nms-patches/RecipeFireworksStar.patch @@ -5,7 +5,7 @@ import java.util.Map; -public class RecipeFireworksStar extends IRecipeComplex { -+public class RecipeFireworksStar extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends ++public class RecipeFireworksStar extends ShapelessRecipes { // CraftBukkit - added extends private static final RecipeItemStack a = RecipeItemStack.a(Items.FIRE_CHARGE, Items.FEATHER, Items.GOLD_NUGGET, Items.SKELETON_SKULL, Items.WITHER_SKELETON_SKULL, Items.CREEPER_HEAD, Items.PLAYER_HEAD, Items.DRAGON_HEAD, Items.ZOMBIE_HEAD); private static final RecipeItemStack b = RecipeItemStack.a(Items.DIAMOND); @@ -26,5 +26,5 @@ } + // CraftBukkit end - public boolean a(IInventory iinventory, World world) { - if (!(iinventory instanceof InventoryCrafting)) { + public boolean a(InventoryCrafting inventorycrafting, World world) { + boolean flag = false; diff --git a/nms-patches/RecipeMapClone.patch b/nms-patches/RecipeMapClone.patch index b801676511..86c933cff9 100644 --- a/nms-patches/RecipeMapClone.patch +++ b/nms-patches/RecipeMapClone.patch @@ -4,7 +4,7 @@ package net.minecraft.server; -public class RecipeMapClone extends IRecipeComplex { -+public class RecipeMapClone extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends ++public class RecipeMapClone extends ShapelessRecipes { // CraftBukkit - added extends + // CraftBukkit start - Delegate to new parent class public RecipeMapClone(MinecraftKey minecraftkey) { @@ -13,5 +13,5 @@ } + // CraftBukkit end - public boolean a(IInventory iinventory, World world) { - if (!(iinventory instanceof InventoryCrafting)) { + public boolean a(InventoryCrafting inventorycrafting, World world) { + int i = 0; diff --git a/nms-patches/RecipeRepair.patch b/nms-patches/RecipeRepair.patch deleted file mode 100644 index e179af7f25..0000000000 --- a/nms-patches/RecipeRepair.patch +++ /dev/null @@ -1,38 +0,0 @@ ---- a/net/minecraft/server/RecipeRepair.java -+++ b/net/minecraft/server/RecipeRepair.java -@@ -2,12 +2,15 @@ - - import com.google.common.collect.Lists; - import java.util.List; -+import java.util.stream.Stream; - --public class RecipeRepair extends IRecipeComplex { -+public class RecipeRepair extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends - -+ // CraftBukkit start - Delegate to new parent class - public RecipeRepair(MinecraftKey minecraftkey) { -- super(minecraftkey); -+ super(minecraftkey, "", new ItemStack(Items.LEATHER_HELMET), NonNullList.a(RecipeItemStack.a, RecipeItemStack.a(Items.LEATHER_HELMET))); - } -+ // CraftBukkit end - - public boolean a(IInventory iinventory, World world) { - if (!(iinventory instanceof InventoryCrafting)) { -@@ -71,6 +74,17 @@ - ItemStack itemstack3 = new ItemStack(itemstack2.getItem()); - - itemstack3.setDamage(i1); -+ // CraftBukkit start - Construct a dummy repair recipe -+ if (iinventory instanceof InventoryCrafting) { -+ InventoryCrafting inventorycrafting = (InventoryCrafting) iinventory; -+ NonNullList ingredients = NonNullList.a(); -+ ingredients.add(new RecipeItemStack(Stream.of(new RecipeItemStack.StackProvider(itemstack2.cloneItemStack())))); -+ ingredients.add(new RecipeItemStack(Stream.of(new RecipeItemStack.StackProvider(itemstack.cloneItemStack())))); -+ ShapelessRecipes recipe = new ShapelessRecipes(new MinecraftKey("repairitem"), "", itemstack3.cloneItemStack(), ingredients); -+ inventorycrafting.setCurrentRecipe(recipe); -+ itemstack3 = org.bukkit.craftbukkit.event.CraftEventFactory.callPreCraftEvent(inventorycrafting, inventorycrafting.resultInventory, itemstack3, inventorycrafting.container.getBukkitView(), true); -+ } -+ // CraftBukkit end - return itemstack3; - } - } diff --git a/nms-patches/RecipeShulkerBox.patch b/nms-patches/RecipeShulkerBox.patch index 65eefa1ee3..ba447c46a5 100644 --- a/nms-patches/RecipeShulkerBox.patch +++ b/nms-patches/RecipeShulkerBox.patch @@ -4,7 +4,7 @@ package net.minecraft.server; -public class RecipeShulkerBox extends IRecipeComplex { -+public class RecipeShulkerBox extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends ++public class RecipeShulkerBox extends ShapelessRecipes { // CraftBukkit - added extends + // CraftBukkit start - Delegate to new parent class with bogus info public RecipeShulkerBox(MinecraftKey minecraftkey) { @@ -13,5 +13,5 @@ } + // CraftBukkit end - public boolean a(IInventory iinventory, World world) { - if (!(iinventory instanceof InventoryCrafting)) { + public boolean a(InventoryCrafting inventorycrafting, World world) { + int i = 0; diff --git a/nms-patches/RecipeSmoking.patch b/nms-patches/RecipeSmoking.patch new file mode 100644 index 0000000000..8699f526b8 --- /dev/null +++ b/nms-patches/RecipeSmoking.patch @@ -0,0 +1,33 @@ +--- a/net/minecraft/server/RecipeSmoking.java ++++ b/net/minecraft/server/RecipeSmoking.java +@@ -1,5 +1,13 @@ + package net.minecraft.server; + ++// CraftBukkit start ++import org.bukkit.craftbukkit.inventory.CraftItemStack; ++import org.bukkit.craftbukkit.inventory.CraftRecipe; ++import org.bukkit.craftbukkit.inventory.CraftSmokingRecipe; ++import org.bukkit.craftbukkit.util.CraftNamespacedKey; ++import org.bukkit.inventory.Recipe; ++// CraftBukkit end ++ + public class RecipeSmoking extends RecipeCooking { + + public RecipeSmoking(MinecraftKey minecraftkey, String s, RecipeItemStack recipeitemstack, ItemStack itemstack, float f, int i) { +@@ -10,4 +18,16 @@ + public RecipeSerializer getRecipeSerializer() { + return RecipeSerializer.q; + } ++ ++ // CraftBukkit start ++ @Override ++ public Recipe toBukkitRecipe() { ++ CraftItemStack result = CraftItemStack.asCraftMirror(this.result); ++ ++ CraftSmokingRecipe recipe = new CraftSmokingRecipe(CraftNamespacedKey.fromMinecraft(this.key), result, CraftRecipe.toBukkit(this.ingredient), this.experience, this.cookingTime); ++ recipe.setGroup(this.group); ++ ++ return recipe; ++ } ++ // CraftBukkit end + } diff --git a/nms-patches/RecipeStonecutting.patch b/nms-patches/RecipeStonecutting.patch new file mode 100644 index 0000000000..02bbcb1574 --- /dev/null +++ b/nms-patches/RecipeStonecutting.patch @@ -0,0 +1,33 @@ +--- a/net/minecraft/server/RecipeStonecutting.java ++++ b/net/minecraft/server/RecipeStonecutting.java +@@ -1,5 +1,13 @@ + package net.minecraft.server; + ++// CraftBukkit start ++import org.bukkit.craftbukkit.inventory.CraftItemStack; ++import org.bukkit.craftbukkit.inventory.CraftRecipe; ++import org.bukkit.craftbukkit.inventory.CraftStonecuttingRecipe; ++import org.bukkit.craftbukkit.util.CraftNamespacedKey; ++import org.bukkit.inventory.Recipe; ++// CraftBukkit end ++ + public class RecipeStonecutting extends RecipeSingleItem { + + public RecipeStonecutting(MinecraftKey minecraftkey, String s, RecipeItemStack recipeitemstack, ItemStack itemstack) { +@@ -10,4 +18,16 @@ + public boolean a(IInventory iinventory, World world) { + return this.ingredient.test(iinventory.getItem(0)); + } ++ ++ // CraftBukkit start ++ @Override ++ public Recipe toBukkitRecipe() { ++ CraftItemStack result = CraftItemStack.asCraftMirror(this.result); ++ ++ CraftStonecuttingRecipe recipe = new CraftStonecuttingRecipe(CraftNamespacedKey.fromMinecraft(this.key), result, CraftRecipe.toBukkit(this.ingredient)); ++ recipe.setGroup(this.group); ++ ++ return recipe; ++ } ++ // CraftBukkit end + } diff --git a/nms-patches/RecipeSuspiciousStew.patch b/nms-patches/RecipeSuspiciousStew.patch new file mode 100644 index 0000000000..2041241135 --- /dev/null +++ b/nms-patches/RecipeSuspiciousStew.patch @@ -0,0 +1,17 @@ +--- a/net/minecraft/server/RecipeSuspiciousStew.java ++++ b/net/minecraft/server/RecipeSuspiciousStew.java +@@ -1,10 +1,12 @@ + package net.minecraft.server; + +-public class RecipeSuspiciousStew extends IRecipeComplex { ++public class RecipeSuspiciousStew extends ShapelessRecipes { // CraftBukkit - added extends + ++ // CraftBukkit start - Delegate to new parent class with bogus info + public RecipeSuspiciousStew(MinecraftKey minecraftkey) { +- super(minecraftkey); ++ super(minecraftkey, "", new ItemStack(Items.SUSPICIOUS_STEW, 0), NonNullList.a(RecipeItemStack.a, RecipeItemStack.a(Items.BOWL))); + } ++ // CraftBukkit end + + public boolean a(InventoryCrafting inventorycrafting, World world) { + boolean flag = false; diff --git a/nms-patches/RecipeTippedArrow.patch b/nms-patches/RecipeTippedArrow.patch index 2e2e84caa0..1050c0ca35 100644 --- a/nms-patches/RecipeTippedArrow.patch +++ b/nms-patches/RecipeTippedArrow.patch @@ -5,7 +5,7 @@ import java.util.Collection; -public class RecipeTippedArrow extends IRecipeComplex { -+public class RecipeTippedArrow extends ShapedRecipes implements IRecipe { // CraftBukkit ++public class RecipeTippedArrow extends ShapedRecipes { // CraftBukkit + // CraftBukkit start public RecipeTippedArrow(MinecraftKey minecraftkey) { @@ -18,5 +18,5 @@ } + // CraftBukkit end - public boolean a(IInventory iinventory, World world) { - if (iinventory.U_() == 3 && iinventory.n() == 3) { + public boolean a(InventoryCrafting inventorycrafting, World world) { + if (inventorycrafting.g() == 3 && inventorycrafting.f() == 3) { diff --git a/nms-patches/RecipiesShield.patch b/nms-patches/RecipiesShield.patch index 39ab5d66c5..69c9c9bdc0 100644 --- a/nms-patches/RecipiesShield.patch +++ b/nms-patches/RecipiesShield.patch @@ -4,7 +4,7 @@ package net.minecraft.server; -public class RecipiesShield extends IRecipeComplex { -+public class RecipiesShield extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends ++public class RecipiesShield extends ShapelessRecipes { // CraftBukkit - added extends + // CraftBukkit start - Delegate to new parent class with bogus info public RecipiesShield(MinecraftKey minecraftkey) { @@ -13,5 +13,5 @@ } + // CraftBukkit end - public boolean a(IInventory iinventory, World world) { - if (!(iinventory instanceof InventoryCrafting)) { + public boolean a(InventoryCrafting inventorycrafting, World world) { + ItemStack itemstack = ItemStack.a; diff --git a/nms-patches/RegionFileCache.patch b/nms-patches/RegionFileCache.patch index 9258d3e110..47dc254ccb 100644 --- a/nms-patches/RegionFileCache.patch +++ b/nms-patches/RegionFileCache.patch @@ -1,69 +1,50 @@ --- a/net/minecraft/server/RegionFileCache.java +++ b/net/minecraft/server/RegionFileCache.java -@@ -36,6 +36,29 @@ +@@ -18,7 +18,7 @@ + this.a = file; + } + +- private RegionFile a(ChunkCoordIntPair chunkcoordintpair) throws IOException { ++ private RegionFile a(ChunkCoordIntPair chunkcoordintpair, boolean existingOnly) throws IOException { // CraftBukkit + long i = ChunkCoordIntPair.pair(chunkcoordintpair.getRegionX(), chunkcoordintpair.getRegionZ()); + RegionFile regionfile = (RegionFile) this.cache.getAndMoveToFirst(i); + +@@ -34,6 +34,7 @@ + } + + File file = new File(this.a, "r." + chunkcoordintpair.getRegionX() + "." + chunkcoordintpair.getRegionZ() + ".mca"); ++ if (existingOnly && !file.exists()) return null; // CraftBukkit + RegionFile regionfile1 = new RegionFile(file); + + this.cache.putAndMoveToFirst(i, regionfile1); +@@ -43,7 +44,7 @@ + + @Nullable + public NBTTagCompound read(ChunkCoordIntPair chunkcoordintpair) throws IOException { +- RegionFile regionfile = this.a(chunkcoordintpair); ++ RegionFile regionfile = this.a(chunkcoordintpair, false); // CraftBukkit + DataInputStream datainputstream = regionfile.a(chunkcoordintpair); + Throwable throwable = null; + +@@ -78,7 +79,7 @@ + } + + protected void write(ChunkCoordIntPair chunkcoordintpair, NBTTagCompound nbttagcompound) throws IOException { +- RegionFile regionfile = this.a(chunkcoordintpair); ++ RegionFile regionfile = this.a(chunkcoordintpair, false); // CraftBukkit + DataOutputStream dataoutputstream = regionfile.c(chunkcoordintpair); + Throwable throwable = null; + +@@ -114,4 +115,12 @@ } - } + } ++ + // CraftBukkit start -+ public static synchronized RegionFile b(File file, int i, int j) { -+ File file1 = new File(file, "region"); -+ File file2 = new File(file1, "r." + (i >> 5) + "." + (j >> 5) + ".mca"); -+ RegionFile regionfile = (RegionFile) RegionFileCache.cache.get(file2); ++ public boolean chunkExists(ChunkCoordIntPair pos) throws IOException { ++ RegionFile regionfile = a(pos, true); + -+ if (regionfile != null) { -+ return regionfile; -+ } else if (file1.exists() && file2.exists()) { -+ if (RegionFileCache.cache.size() >= 256) { -+ a(); -+ } -+ -+ RegionFile regionfile1 = new RegionFile(file2); -+ -+ RegionFileCache.cache.put(file2, regionfile1); -+ return regionfile1; -+ } else { -+ return null; -+ } ++ return regionfile != null ? regionfile.d(pos) : false; + } -+ // CraftBukkit end -+ - public static synchronized void a() { - Iterator iterator = RegionFileCache.cache.values().iterator(); - -@@ -55,16 +78,32 @@ - } - - @Nullable -- public static DataInputStream read(File file, int i, int j) { -+ // CraftBukkit start - call sites hoisted for synchronization -+ public static synchronized NBTTagCompound read(File file, int i, int j) throws IOException { - RegionFile regionfile = a(file, i, j); - -- return regionfile.a(i & 31, j & 31); -+ DataInputStream datainputstream = regionfile.a(i & 31, j & 31); -+ -+ if (datainputstream == null) { -+ return null; -+ } -+ -+ return NBTCompressedStreamTools.a(datainputstream); - } - - @Nullable -- public static DataOutputStream write(File file, int i, int j) { -+ public static synchronized void write(File file, int i, int j, NBTTagCompound nbttagcompound) throws IOException { - RegionFile regionfile = a(file, i, j); - -- return regionfile.c(i & 31, j & 31); -+ DataOutputStream dataoutputstream = regionfile.c(i & 31, j & 31); -+ NBTCompressedStreamTools.a(nbttagcompound, (java.io.DataOutput) dataoutputstream); -+ dataoutputstream.close(); -+ } -+ -+ public static synchronized boolean chunkExists(File file, int i, int j) { -+ RegionFile regionfile = b(file, i, j); -+ -+ return regionfile != null ? regionfile.d(i & 31, j & 31) : false; - } + // CraftBukkit end } diff --git a/nms-patches/RegionLimitedWorldAccess.patch b/nms-patches/RegionLimitedWorldAccess.patch index 94225582ff..054707cb15 100644 --- a/nms-patches/RegionLimitedWorldAccess.patch +++ b/nms-patches/RegionLimitedWorldAccess.patch @@ -1,11 +1,10 @@ --- a/net/minecraft/server/RegionLimitedWorldAccess.java +++ b/net/minecraft/server/RegionLimitedWorldAccess.java -@@ -200,7 +200,14 @@ - this.y(blockposition).e(blockposition); - } +@@ -243,6 +243,13 @@ -+ // CraftBukkit start + @Override public boolean addEntity(Entity entity) { ++ // CraftBukkit start + return addEntity(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT); + } + diff --git a/nms-patches/RemoteControlCommandListener.patch b/nms-patches/RemoteControlCommandListener.patch index def02f17e1..931fcb89ab 100644 --- a/nms-patches/RemoteControlCommandListener.patch +++ b/nms-patches/RemoteControlCommandListener.patch @@ -1,20 +1,20 @@ --- a/net/minecraft/server/RemoteControlCommandListener.java +++ b/net/minecraft/server/RemoteControlCommandListener.java @@ -23,6 +23,17 @@ - return new CommandListenerWrapper(this, new Vec3D(worldserver.getSpawn()), Vec2F.a, worldserver, 4, "Recon", new ChatComponentText("Rcon"), this.b, (Entity) null); + return new CommandListenerWrapper(this, new Vec3D(worldserver.getSpawn()), Vec2F.a, worldserver, 4, "Recon", new ChatComponentText("Rcon"), this.server, (Entity) null); } + // CraftBukkit start - Send a String + public void sendMessage(String message) { -+ this.a.append(message); ++ this.buffer.append(message); + } + + @Override + public org.bukkit.command.CommandSender getBukkitSender(CommandListenerWrapper wrapper) { -+ return b.remoteConsole; ++ return server.remoteConsole; + } + // CraftBukkit end + + @Override public void sendMessage(IChatBaseComponent ichatbasecomponent) { - this.a.append(ichatbasecomponent.getString()); - } + this.buffer.append(ichatbasecomponent.getString()); diff --git a/nms-patches/ScoreboardServer.patch b/nms-patches/ScoreboardServer.patch index f4313c34bc..aa58fe766e 100644 --- a/nms-patches/ScoreboardServer.patch +++ b/nms-patches/ScoreboardServer.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/ScoreboardServer.java +++ b/net/minecraft/server/ScoreboardServer.java -@@ -21,7 +21,7 @@ +@@ -22,7 +22,7 @@ public void handleScoreChanged(ScoreboardScore scoreboardscore) { super.handleScoreChanged(scoreboardscore); if (this.b.contains(scoreboardscore.getObjective())) { @@ -9,8 +9,8 @@ } this.b(); -@@ -29,14 +29,14 @@ - +@@ -31,7 +31,7 @@ + @Override public void handlePlayerRemoved(String s) { super.handlePlayerRemoved(s); - this.a.getPlayerList().sendAll(new PacketPlayOutScoreboardScore(ScoreboardServer.Action.REMOVE, (String) null, s, 0)); @@ -18,6 +18,7 @@ this.b(); } +@@ -39,7 +39,7 @@ public void a(String s, ScoreboardObjective scoreboardobjective) { super.a(s, scoreboardobjective); if (this.b.contains(scoreboardobjective)) { @@ -26,7 +27,7 @@ } this.b(); -@@ -48,7 +48,7 @@ +@@ -52,7 +52,7 @@ super.setDisplaySlot(i, scoreboardobjective); if (scoreboardobjective1 != scoreboardobjective && scoreboardobjective1 != null) { if (this.h(scoreboardobjective1) > 0) { @@ -35,7 +36,7 @@ } else { this.g(scoreboardobjective1); } -@@ -56,7 +56,7 @@ +@@ -60,7 +60,7 @@ if (scoreboardobjective != null) { if (this.b.contains(scoreboardobjective)) { @@ -44,8 +45,8 @@ } else { this.e(scoreboardobjective); } -@@ -67,7 +67,7 @@ - +@@ -72,7 +72,7 @@ + @Override public boolean addPlayerToTeam(String s, ScoreboardTeam scoreboardteam) { if (super.addPlayerToTeam(s, scoreboardteam)) { - this.a.getPlayerList().sendAll(new PacketPlayOutScoreboardTeam(scoreboardteam, Arrays.asList(s), 3)); @@ -53,8 +54,8 @@ this.b(); return true; } else { -@@ -77,7 +77,7 @@ - +@@ -83,7 +83,7 @@ + @Override public void removePlayerFromTeam(String s, ScoreboardTeam scoreboardteam) { super.removePlayerFromTeam(s, scoreboardteam); - this.a.getPlayerList().sendAll(new PacketPlayOutScoreboardTeam(scoreboardteam, Arrays.asList(s), 4)); @@ -62,7 +63,7 @@ this.b(); } -@@ -89,7 +89,7 @@ +@@ -97,7 +97,7 @@ public void handleObjectiveChanged(ScoreboardObjective scoreboardobjective) { super.handleObjectiveChanged(scoreboardobjective); if (this.b.contains(scoreboardobjective)) { @@ -71,8 +72,8 @@ } this.b(); -@@ -106,19 +106,19 @@ - +@@ -116,21 +116,21 @@ + @Override public void handleTeamAdded(ScoreboardTeam scoreboardteam) { super.handleTeamAdded(scoreboardteam); - this.a.getPlayerList().sendAll(new PacketPlayOutScoreboardTeam(scoreboardteam, 0)); @@ -80,6 +81,7 @@ this.b(); } + @Override public void handleTeamChanged(ScoreboardTeam scoreboardteam) { super.handleTeamChanged(scoreboardteam); - this.a.getPlayerList().sendAll(new PacketPlayOutScoreboardTeam(scoreboardteam, 2)); @@ -87,6 +89,7 @@ this.b(); } + @Override public void handleTeamRemoved(ScoreboardTeam scoreboardteam) { super.handleTeamRemoved(scoreboardteam); - this.a.getPlayerList().sendAll(new PacketPlayOutScoreboardTeam(scoreboardteam, 1)); @@ -94,7 +97,7 @@ this.b(); } -@@ -167,6 +167,7 @@ +@@ -179,6 +179,7 @@ while (iterator.hasNext()) { EntityPlayer entityplayer = (EntityPlayer) iterator.next(); @@ -102,7 +105,7 @@ Iterator iterator1 = list.iterator(); while (iterator1.hasNext()) { -@@ -199,6 +200,7 @@ +@@ -211,6 +212,7 @@ while (iterator.hasNext()) { EntityPlayer entityplayer = (EntityPlayer) iterator.next(); @@ -110,7 +113,7 @@ Iterator iterator1 = list.iterator(); while (iterator1.hasNext()) { -@@ -223,6 +225,16 @@ +@@ -235,6 +237,16 @@ return i; } diff --git a/nms-patches/SecondaryWorldServer.patch b/nms-patches/SecondaryWorldServer.patch index 22624e4dc5..980773d9c9 100644 --- a/nms-patches/SecondaryWorldServer.patch +++ b/nms-patches/SecondaryWorldServer.patch @@ -1,37 +1,21 @@ --- a/net/minecraft/server/SecondaryWorldServer.java +++ b/net/minecraft/server/SecondaryWorldServer.java -@@ -2,8 +2,11 @@ +@@ -4,11 +4,13 @@ public class SecondaryWorldServer extends WorldServer { -- public SecondaryWorldServer(MinecraftServer minecraftserver, IDataManager idatamanager, DimensionManager dimensionmanager, WorldServer worldserver, MethodProfiler methodprofiler) { -- super(minecraftserver, idatamanager, worldserver.h(), new SecondaryWorldData(worldserver.getWorldData()), dimensionmanager, methodprofiler); +- public SecondaryWorldServer(WorldServer worldserver, MinecraftServer minecraftserver, Executor executor, WorldNBTStorage worldnbtstorage, DimensionManager dimensionmanager, GameProfilerFiller gameprofilerfiller, WorldLoadListener worldloadlistener) { +- super(minecraftserver, executor, worldnbtstorage, new SecondaryWorldData(worldserver.getWorldData()), dimensionmanager, gameprofilerfiller, worldloadlistener); +- worldserver.getWorldBorder().a((IWorldBorderListener) (new IWorldBorderListener.a(this.getWorldBorder()))); + // CraftBukkit start - Add WorldData, Environment and ChunkGenerator arguments -+ public SecondaryWorldServer(MinecraftServer minecraftserver, IDataManager idatamanager, DimensionManager dimensionmanager, WorldServer worldserver, MethodProfiler methodprofiler, WorldData worldData, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen) { -+ super(minecraftserver, idatamanager, worldserver.h(), worldData, dimensionmanager, methodprofiler, env, gen); ++ public SecondaryWorldServer(WorldServer worldserver, MinecraftServer minecraftserver, Executor executor, WorldNBTStorage worldnbtstorage, DimensionManager dimensionmanager, GameProfilerFiller gameprofilerfiller, WorldLoadListener worldloadlistener, WorldData worldData, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen) { ++ super(minecraftserver, executor, worldnbtstorage, worldData, dimensionmanager, gameprofilerfiller, worldloadlistener, env, gen); ++ // worldserver.getWorldBorder().a((IWorldBorderListener) (new IWorldBorderListener.a(this.getWorldBorder()))); + // CraftBukkit end -+ /* CraftBukkit start - worldserver.getWorldBorder().a(new IWorldBorderListener() { - public void a(WorldBorder worldborder, double d0) { - SecondaryWorldServer.this.getWorldBorder().setSize(d0); -@@ -33,9 +36,10 @@ - SecondaryWorldServer.this.getWorldBorder().setDamageBuffer(d0); - } - }); -+ // CraftBukkit end */ } +- @Override - protected void a() {} ++ // @Override // CraftBukkit + // protected void a() {} // CraftBukkit - - public SecondaryWorldServer i_() { - String s = PersistentVillage.a(this.worldProvider); -@@ -49,7 +53,7 @@ - this.villages.a((World) this); - } - -- return this; -+ return (SecondaryWorldServer) super.i_(); // CraftBukkit - } - - public void t_() { + } diff --git a/nms-patches/ShapedRecipes.patch b/nms-patches/ShapedRecipes.patch index 1ec2b7d366..d19f28678d 100644 --- a/nms-patches/ShapedRecipes.patch +++ b/nms-patches/ShapedRecipes.patch @@ -14,7 +14,7 @@ +import org.bukkit.inventory.RecipeChoice; +// CraftBukkit end - public class ShapedRecipes implements IRecipe { + public class ShapedRecipes implements RecipeCrafting { @@ -31,6 +40,66 @@ this.result = itemstack; @@ -80,6 +80,6 @@ + } + // CraftBukkit end + + @Override public MinecraftKey getKey() { return this.key; - } diff --git a/nms-patches/ShapelessRecipes.patch b/nms-patches/ShapelessRecipes.patch index dfc03324a7..640ab8ed88 100644 --- a/nms-patches/ShapelessRecipes.patch +++ b/nms-patches/ShapelessRecipes.patch @@ -10,7 +10,7 @@ +import org.bukkit.craftbukkit.inventory.CraftShapelessRecipe; +// CraftBukkit end - public class ShapelessRecipes implements IRecipe { + public class ShapelessRecipes implements RecipeCrafting { @@ -20,6 +25,20 @@ this.ingredients = nonnulllist; @@ -30,6 +30,6 @@ + } + // CraftBukkit end + + @Override public MinecraftKey getKey() { return this.key; - } diff --git a/nms-patches/SlotFurnaceResult.patch b/nms-patches/SlotFurnaceResult.patch index eee722f9aa..59777958ce 100644 --- a/nms-patches/SlotFurnaceResult.patch +++ b/nms-patches/SlotFurnaceResult.patch @@ -1,32 +1,11 @@ --- a/net/minecraft/server/SlotFurnaceResult.java +++ b/net/minecraft/server/SlotFurnaceResult.java -@@ -2,6 +2,10 @@ +@@ -41,7 +41,7 @@ + protected void c(ItemStack itemstack) { + itemstack.a(this.a.world, this.a, this.b); + if (!this.a.world.isClientSide && this.inventory instanceof TileEntityFurnace) { +- ((TileEntityFurnace) this.inventory).d(this.a); ++ ((TileEntityFurnace) this.inventory).d(this.a, itemstack, this.b); // CraftBukkit + } - import java.util.Iterator; - import java.util.Map.Entry; -+// CraftBukkit start -+import org.bukkit.entity.Player; -+import org.bukkit.event.inventory.FurnaceExtractEvent; -+// CraftBukkit end - - public class SlotFurnaceResult extends Slot { - -@@ -66,6 +70,18 @@ - i = j; - } - -+ // CraftBukkit start - fire FurnaceExtractEvent -+ Player player = (Player) a.getBukkitEntity(); -+ TileEntityFurnace furnace = ((TileEntityFurnace) this.inventory); -+ org.bukkit.block.Block block = a.world.getWorld().getBlockAt(furnace.position.getX(), furnace.position.getY(), furnace.position.getZ()); -+ -+ if (b != 0) { -+ FurnaceExtractEvent event = new FurnaceExtractEvent(player, block, org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(itemstack.getItem()), b, i); -+ a.world.getServer().getPluginManager().callEvent(event); -+ i = event.getExpToDrop(); -+ } -+ // CraftBukkit end -+ - while (i > 0) { - j = EntityExperienceOrb.getOrbValue(i); - i -= j; + this.b = 0; diff --git a/nms-patches/SpawnerCreature.patch b/nms-patches/SpawnerCreature.patch index 02863545c9..8cd236f1dc 100644 --- a/nms-patches/SpawnerCreature.patch +++ b/nms-patches/SpawnerCreature.patch @@ -1,110 +1,38 @@ --- a/net/minecraft/server/SpawnerCreature.java +++ b/net/minecraft/server/SpawnerCreature.java -@@ -9,11 +9,17 @@ +@@ -7,6 +7,10 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +// 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 Logger a = LogManager.getLogger(); - private static final int b = (int) Math.pow(17.0D, 2.0D); -- private final Set c = Sets.newHashSet(); -+ private final LongHashSet c = new LongHashSet(); // CraftBukkit +@@ -85,9 +89,12 @@ + entityinsentient.setPositionRotation((double) f, (double) k, (double) f1, world.random.nextFloat() * 360.0F, 0.0F); + if ((entityhuman.e((double) f, (double) k, (double) f1) <= 16384.0D || !entityinsentient.isTypeNotPersistent(entityhuman.e((double) f, (double) k, (double) f1))) && entityinsentient.a((GeneratorAccess) world, EnumMobSpawn.NATURAL) && entityinsentient.a((IWorldReader) world)) { + groupdataentity = entityinsentient.prepare(world, world.getDamageScaler(new BlockPosition(entityinsentient)), EnumMobSpawn.NATURAL, groupdataentity, (NBTTagCompound) null); +- ++i; +- ++i2; +- world.addEntity(entityinsentient); ++ // CraftBukkit start ++ if (world.addEntity(entityinsentient, SpawnReason.NATURAL)) { ++ ++i; ++ ++i2; ++ } ++ // CraftBukkit end + if (i >= entityinsentient.dC()) { + return; + } +@@ -210,7 +217,7 @@ - public SpawnerCreature() {} - -@@ -42,13 +48,16 @@ - boolean flag4 = i1 == -8 || i1 == 8 || k == -8 || k == 8; - ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(i1 + l, k + j); - -- if (!this.c.contains(chunkcoordintpair)) { -+ // CraftBukkit start - use LongHash and LongHashSet -+ long chunkCoords = LongHash.toLong(chunkcoordintpair.x, chunkcoordintpair.z); -+ if (!this.c.contains(chunkCoords)) { - ++i; - if (!flag4 && worldserver.getWorldBorder().isInBounds(chunkcoordintpair)) { - PlayerChunk playerchunk = worldserver.getPlayerChunkMap().getChunk(chunkcoordintpair.x, chunkcoordintpair.z); - - if (playerchunk != null && playerchunk.e()) { -- this.c.add(chunkcoordintpair); -+ this.c.add(chunkCoords); -+ // CraftBukkit end - } + if (entityinsentient.a(generatoraccess, EnumMobSpawn.CHUNK_GENERATION) && entityinsentient.a((IWorldReader) generatoraccess)) { + groupdataentity = entityinsentient.prepare(generatoraccess, generatoraccess.getDamageScaler(new BlockPosition(entityinsentient)), EnumMobSpawn.CHUNK_GENERATION, groupdataentity, (NBTTagCompound) null); +- generatoraccess.addEntity(entityinsentient); ++ generatoraccess.addEntity(entityinsentient, SpawnReason.CHUNK_GEN); // CraftBukkit + flag = true; } } -@@ -66,8 +75,30 @@ - for (int k1 = 0; k1 < j; ++k1) { - EnumCreatureType enumcreaturetype = aenumcreaturetype[k1]; - -+ // CraftBukkit start - Use per-world spawn limits -+ int limit = enumcreaturetype.b(); -+ switch (enumcreaturetype) { -+ case MONSTER: -+ limit = worldserver.getWorld().getMonsterSpawnLimit(); -+ break; -+ case CREATURE: -+ limit = worldserver.getWorld().getAnimalSpawnLimit(); -+ break; -+ case WATER_CREATURE: -+ limit = worldserver.getWorld().getWaterAnimalSpawnLimit(); -+ break; -+ case AMBIENT: -+ limit = worldserver.getWorld().getAmbientSpawnLimit(); -+ break; -+ } -+ -+ if (limit == 0) { -+ continue; -+ } -+ // CraftBukkit end -+ - if ((!enumcreaturetype.c() || flag1) && (enumcreaturetype.c() || flag) && (!enumcreaturetype.d() || flag2)) { -- k = enumcreaturetype.b() * i / SpawnerCreature.b; -+ k = limit * i / SpawnerCreature.b; // CraftBukkit - use per-world limits - int l1 = worldserver.a(enumcreaturetype.a(), k); - - if (l1 <= k) { -@@ -76,8 +107,10 @@ - - label137: - while (iterator1.hasNext()) { -- ChunkCoordIntPair chunkcoordintpair1 = (ChunkCoordIntPair) iterator1.next(); -- BlockPosition blockposition1 = getRandomPosition(worldserver, chunkcoordintpair1.x, chunkcoordintpair1.z); -+ // CraftBukkit start = use LongHash and LongObjectHashMap -+ long key = ((Long) iterator1.next()).longValue(); -+ BlockPosition blockposition1 = getRandomPosition(worldserver, LongHash.msw(key), LongHash.lsw(key)); -+ // CraftBukkit - int i2 = blockposition1.getX(); - int j2 = blockposition1.getY(); - int k2 = blockposition1.getZ(); -@@ -140,9 +173,12 @@ - if ((d0 <= 16384.0D || !entityinsentient.isTypeNotPersistent()) && entityinsentient.a((GeneratorAccess) worldserver, false) && entityinsentient.a((IWorldReader) worldserver)) { - groupdataentity = entityinsentient.prepare(worldserver.getDamageScaler(new BlockPosition(entityinsentient)), groupdataentity, (NBTTagCompound) null); - if (entityinsentient.a((IWorldReader) worldserver)) { -- ++l2; -- ++j4; -- worldserver.addEntity(entityinsentient); -+ // CraftBukkit start -+ if (worldserver.addEntity(entityinsentient, SpawnReason.NATURAL)) { -+ ++l2; -+ ++j4; -+ } -+ // CraftBukkit end - } else { - entityinsentient.die(); - } -@@ -259,7 +295,7 @@ - entityinsentient.setPositionRotation(d0, (double) blockposition.getY(), d1, random.nextFloat() * 360.0F, 0.0F); - if (entityinsentient.a(generatoraccess, false) && entityinsentient.a((IWorldReader) generatoraccess)) { - groupdataentity = entityinsentient.prepare(generatoraccess.getDamageScaler(new BlockPosition(entityinsentient)), groupdataentity, (NBTTagCompound) null); -- generatoraccess.addEntity(entityinsentient); -+ generatoraccess.addEntity(entityinsentient, SpawnReason.CHUNK_GEN); // CraftBukkit - flag = true; - } - } diff --git a/nms-patches/StructureGenerator.patch b/nms-patches/StructureGenerator.patch index b65057baa9..505cddd3ea 100644 --- a/nms-patches/StructureGenerator.patch +++ b/nms-patches/StructureGenerator.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/server/StructureGenerator.java +++ b/net/minecraft/server/StructureGenerator.java -@@ -202,7 +202,7 @@ - return structurestart; - } else { - ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(i); -- IChunkAccess ichunkaccess = generatoraccess.getChunkProvider().a(chunkcoordintpair.x, chunkcoordintpair.z, false); -+ IChunkAccess ichunkaccess = generatoraccess.getChunkProvider().getChunkAt(chunkcoordintpair.x, chunkcoordintpair.z, false, false); // CraftBukkit - don't load chunks +@@ -144,7 +144,7 @@ - if (ichunkaccess != null) { - structurestart = ichunkaccess.a(this.a()); + while (longiterator.hasNext()) { + long k = longiterator.nextLong(); +- IChunkAccess ichunkaccess1 = generatoraccess.getChunkAt(ChunkCoordIntPair.getX(k), ChunkCoordIntPair.getZ(k), ChunkStatus.STRUCTURE_STARTS); ++ IChunkAccess ichunkaccess1 = generatoraccess.getChunkAt(ChunkCoordIntPair.getX(k), ChunkCoordIntPair.getZ(k), ChunkStatus.STRUCTURE_STARTS, false); // CraftBukkit - don't load chunks + StructureStart structurestart = ichunkaccess1.a(this.b()); + + if (structurestart != null) { diff --git a/nms-patches/TagRegistry.patch b/nms-patches/TagRegistry.patch index e4dafa6a59..9aeaaf8fe8 100644 --- a/nms-patches/TagRegistry.patch +++ b/nms-patches/TagRegistry.patch @@ -1,14 +1,24 @@ --- a/net/minecraft/server/TagRegistry.java +++ b/net/minecraft/server/TagRegistry.java -@@ -38,6 +38,11 @@ - TagsBlock.a((Tags) this.a); - TagsItem.a((Tags) this.b); - TagsFluid.a((Tags) this.c); -+ // CraftBukkit start -+ this.a.version++; -+ this.b.version++; -+ this.c.version++; -+ // CraftBukkit end +@@ -65,7 +65,7 @@ + CompletableFuture>> completablefuture1 = this.b.a(iresourcemanager, executor); + CompletableFuture>> completablefuture2 = this.c.a(iresourcemanager, executor); + CompletableFuture>>> completablefuture3 = this.d.a(iresourcemanager, executor); +- CompletableFuture completablefuture4 = completablefuture.thenCombine(completablefuture1, Pair::of).thenCombine(completablefuture2.thenCombine(completablefuture3, Pair::of), (pair, pair1) -> { ++ CompletableFuture completablefuture4 = completablefuture.thenCombine(completablefuture1, Pair::of).thenCombine(completablefuture2.thenCombine(completablefuture3, Pair::of), (pair, pair1) -> { // CraftBukkit - decompile error + return new TagRegistry.a((Map) pair.getFirst(), (Map) pair.getSecond(), (Map) pair1.getFirst(), (Map) pair1.getSecond()); + }); + +@@ -80,6 +80,12 @@ + TagsItem.a((Tags) this.b); + TagsFluid.a((Tags) this.c); + TagsEntity.a((Tags) this.d); ++ // CraftBukkit start ++ this.a.version++; ++ this.b.version++; ++ this.c.version++; ++ this.d.version++; ++ // CraftBukkit end + }, executor1); } - public void a(PacketDataSerializer packetdataserializer) { diff --git a/nms-patches/TagsServer.patch b/nms-patches/TagsServer.patch index ec49e57c9c..2727eb7d2e 100644 --- a/nms-patches/TagsServer.patch +++ b/nms-patches/TagsServer.patch @@ -7,7 +7,7 @@ + public int version; // CraftBukkit public TagsServer(IRegistry iregistry, String s, String s1) { - super(iregistry::c, iregistry::get, s, false, s1); + super(iregistry::getOptional, s, false, s1); @@ -27,7 +28,7 @@ Iterator iterator1 = ((Tag) entry.getValue()).a().iterator(); @@ -18,7 +18,7 @@ packetdataserializer.d(this.a.a(t0)); } @@ -47,7 +48,7 @@ - list.add(this.a.fromId(packetdataserializer.g())); + list.add(this.a.fromId(packetdataserializer.i())); } - this.c().put(minecraftkey, Tag.a.a().a((Collection) list).b(minecraftkey)); diff --git a/nms-patches/TickListServer.patch b/nms-patches/TickListServer.patch index 0e3b6e3cbc..7923be79e9 100644 --- a/nms-patches/TickListServer.patch +++ b/nms-patches/TickListServer.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/server/TickListServer.java +++ b/net/minecraft/server/TickListServer.java -@@ -11,14 +11,15 @@ - import java.util.function.Consumer; +@@ -12,14 +12,15 @@ import java.util.function.Function; import java.util.function.Predicate; + import java.util.stream.Stream; +import org.bukkit.craftbukkit.util.HashTreeSet; // CraftBukkit public class TickListServer implements TickList { @@ -18,7 +18,7 @@ private final WorldServer f; private final List> g = Lists.newArrayList(); private final Consumer> h; -@@ -34,16 +35,22 @@ +@@ -35,16 +36,22 @@ public void a() { int i = this.nextTickList.size(); @@ -37,14 +37,14 @@ + // CraftBukkit end } - this.f.methodProfiler.enter("cleaning"); + this.f.getMethodProfiler().enter("cleaning"); - NextTickListEntry nextticklistentry; + NextTickListEntry nextticklistentry; // CraftBukkit - decompile error for (int j = 0; j < i; ++j) { nextticklistentry = (NextTickListEntry) this.nextTickList.first(); -@@ -52,7 +59,7 @@ +@@ -53,7 +60,7 @@ } this.nextTickList.remove(nextticklistentry); @@ -53,7 +53,7 @@ this.g.add(nextticklistentry); } -@@ -118,7 +125,7 @@ +@@ -122,7 +129,7 @@ if (blockposition.getX() >= structureboundingbox.a && blockposition.getX() < structureboundingbox.d && blockposition.getZ() >= structureboundingbox.c && blockposition.getZ() < structureboundingbox.f) { if (flag) { if (i == 0) { @@ -62,19 +62,19 @@ } iterator.remove(); -@@ -187,7 +194,7 @@ - } +@@ -196,7 +203,7 @@ + @Override public boolean a(BlockPosition blockposition, T t0) { - return this.nextTickListHash.contains(new NextTickListEntry<>(blockposition, t0)); + return this.nextTickList.contains(new NextTickListEntry<>(blockposition, t0)); // CraftBukkit } - public void a(BlockPosition blockposition, T t0, int i, TickListPriority ticklistpriority) { -@@ -209,8 +216,8 @@ - private void c(BlockPosition blockposition, T t0, int i, TickListPriority ticklistpriority) { - NextTickListEntry nextticklistentry = new NextTickListEntry<>(blockposition, t0, (long) i + this.f.getTime(), ticklistpriority); + @Override +@@ -220,8 +227,8 @@ + } + private void a(NextTickListEntry nextticklistentry) { - if (!this.nextTickListHash.contains(nextticklistentry)) { - this.nextTickListHash.add(nextticklistentry); + // CraftBukkit - use nextTickList diff --git a/nms-patches/TicketType.patch b/nms-patches/TicketType.patch new file mode 100644 index 0000000000..af9e80dca7 --- /dev/null +++ b/nms-patches/TicketType.patch @@ -0,0 +1,10 @@ +--- a/net/minecraft/server/TicketType.java ++++ b/net/minecraft/server/TicketType.java +@@ -17,6 +17,7 @@ + public static final TicketType LIGHT = a("light", Comparator.comparingLong(ChunkCoordIntPair::pair)); + public static final TicketType PORTAL = a("portal", Comparator.comparingLong(BlockPosition2D::b)); + public static final TicketType UNKNOWN = a("unknown", Comparator.comparingLong(ChunkCoordIntPair::pair)); ++ public static final TicketType PLUGIN = a("plugin", (a, b) -> 0); // CraftBukkit + + public static TicketType a(String s, Comparator comparator) { + return new TicketType<>(s, comparator); diff --git a/nms-patches/TileEntity.patch b/nms-patches/TileEntity.patch index b0dbdfbc61..cf8676b007 100644 --- a/nms-patches/TileEntity.patch +++ b/nms-patches/TileEntity.patch @@ -9,7 +9,7 @@ public abstract class TileEntity { private static final Logger a = LogManager.getLogger(); -@@ -54,8 +56,15 @@ +@@ -55,8 +57,15 @@ } } @@ -22,20 +22,20 @@ + @Nullable + public static TileEntity create(NBTTagCompound nbttagcompound, @Nullable World world) { + // CraftBukkit end - TileEntity tileentity = null; String s = nbttagcompound.getString("id"); -@@ -67,6 +76,7 @@ - - if (tileentity != null) { + return (TileEntity) IRegistry.BLOCK_ENTITY_TYPE.getOptional(new MinecraftKey(s)).map((tileentitytypes) -> { +@@ -68,6 +77,7 @@ + } + }).map((tileentity) -> { try { + tileentity.setWorld(world); // CraftBukkit tileentity.load(nbttagcompound); - } catch (Throwable throwable1) { - TileEntity.a.error("Failed to load data for block entity {}", s, throwable1); -@@ -156,4 +166,13 @@ - public TileEntityTypes C() { - return this.e; + return tileentity; + } catch (Throwable throwable) { +@@ -157,4 +167,13 @@ + public TileEntityTypes q() { + return this.b; } + + // CraftBukkit start - add method diff --git a/nms-patches/TileEntityBanner.patch b/nms-patches/TileEntityBanner.patch index 1c10a36a1f..0be4abf7ca 100644 --- a/nms-patches/TileEntityBanner.patch +++ b/nms-patches/TileEntityBanner.patch @@ -1,18 +1,6 @@ --- a/net/minecraft/server/TileEntityBanner.java +++ b/net/minecraft/server/TileEntityBanner.java -@@ -30,6 +30,11 @@ - - if (nbttagcompound != null && nbttagcompound.hasKeyOfType("Patterns", 9)) { - this.patterns = nbttagcompound.getList("Patterns", 10).clone(); -+ // CraftBukkit start -+ while (this.patterns.size() > 20) { -+ this.patterns.remove(20); -+ } -+ // CraftBukkit end - } - - this.color = enumcolor; -@@ -79,6 +84,11 @@ +@@ -67,6 +67,11 @@ } this.patterns = nbttagcompound.getList("Patterns", 10); diff --git a/nms-patches/TileEntityBarrel.patch b/nms-patches/TileEntityBarrel.patch new file mode 100644 index 0000000000..2a7391905a --- /dev/null +++ b/nms-patches/TileEntityBarrel.patch @@ -0,0 +1,58 @@ +--- a/net/minecraft/server/TileEntityBarrel.java ++++ b/net/minecraft/server/TileEntityBarrel.java +@@ -2,8 +2,55 @@ + + import java.util.Iterator; + ++// CraftBukkit start ++import java.util.ArrayList; ++import java.util.Arrays; ++import java.util.List; ++import org.bukkit.Location; ++import org.bukkit.block.Barrel; ++import org.bukkit.block.Lectern; ++import org.bukkit.craftbukkit.block.CraftBlock; ++import org.bukkit.craftbukkit.entity.CraftHumanEntity; ++import org.bukkit.entity.HumanEntity; ++import org.bukkit.inventory.InventoryHolder; ++// CraftBukkit end ++ + public class TileEntityBarrel extends TileEntityLootable { + ++ // CraftBukkit start - add fields and methods ++ public List transaction = new ArrayList<>(); ++ private int maxStack = MAX_STACK; ++ ++ @Override ++ public List getContents() { ++ return this.items; ++ } ++ ++ @Override ++ public void onOpen(CraftHumanEntity who) { ++ transaction.add(who); ++ } ++ ++ @Override ++ public void onClose(CraftHumanEntity who) { ++ transaction.remove(who); ++ } ++ ++ @Override ++ public List getViewers() { ++ return transaction; ++ } ++ ++ @Override ++ public int getMaxStackSize() { ++ return maxStack; ++ } ++ ++ @Override ++ public void setMaxStackSize(int i) { ++ maxStack = i; ++ } ++ // CraftBukkit end + private NonNullList items; + private int b; + diff --git a/nms-patches/TileEntityBeacon.patch b/nms-patches/TileEntityBeacon.patch index f1827af33c..dcc2caf992 100644 --- a/nms-patches/TileEntityBeacon.patch +++ b/nms-patches/TileEntityBeacon.patch @@ -11,37 +11,14 @@ +import org.bukkit.potion.PotionEffect; +// CraftBukkit end + - public class TileEntityBeacon extends TileEntityContainer implements IWorldInventory, ITickable { + public class TileEntityBeacon extends TileEntity implements ITileInventory, ITickable { public static final MobEffectList[][] a = new MobEffectList[][] { { MobEffects.FASTER_MOVEMENT, MobEffects.FASTER_DIG}, { MobEffects.RESISTANCE, MobEffects.JUMP}, { MobEffects.INCREASE_DAMAGE}, { MobEffects.REGENERATION}}; -@@ -22,6 +29,38 @@ - public MobEffectList secondaryEffect; - private ItemStack inventorySlot; - private IChatBaseComponent o; +@@ -24,6 +31,15 @@ + public IChatBaseComponent customName; + public ChestLock chestLock; + private final IContainerProperties containerProperties; + // CraftBukkit start - add fields and methods -+ public List transaction = new java.util.ArrayList(); -+ private int maxStack = MAX_STACK; -+ -+ public List getContents() { -+ return Arrays.asList(this.inventorySlot); -+ } -+ -+ public void onOpen(CraftHumanEntity who) { -+ transaction.add(who); -+ } -+ -+ public void onClose(CraftHumanEntity who) { -+ transaction.remove(who); -+ } -+ -+ public List getViewers() { -+ return transaction; -+ } -+ -+ public void setMaxStackSize(int size) { -+ maxStack = size; -+ } -+ + public PotionEffect getPrimaryEffect() { + return (this.primaryEffect != null) ? CraftPotionUtil.toBukkit(new MobEffect(this.primaryEffect, getLevel(), getAmplification(), true, true)) : null; + } @@ -53,12 +30,12 @@ public TileEntityBeacon() { super(TileEntityTypes.BEACON); -@@ -55,41 +94,79 @@ - this.world.a((EntityHuman) null, this.position, soundeffect, SoundCategory.BLOCKS, 1.0F, 1.0F); +@@ -185,39 +201,78 @@ + } - private void applyEffects() { -- if (this.i && this.levels > 0 && !this.world.isClientSide && this.primaryEffect != null) { +- if (!this.world.isClientSide && this.primaryEffect != null) { - double d0 = (double) (this.levels * 10 + 10); + // CraftBukkit start - split into components + private byte getAmplification() { @@ -84,10 +61,7 @@ + { + double d0 = (double) (this.levels * 10 + 10); + - int j = this.position.getX(); - int k = this.position.getY(); - int l = this.position.getZ(); - AxisAlignedBB axisalignedbb = (new AxisAlignedBB((double) j, (double) k, (double) l, (double) (j + 1), (double) (k + 1), (double) (l + 1))).g(d0).b(0.0D, (double) this.world.getHeight(), 0.0D); + AxisAlignedBB axisalignedbb = (new AxisAlignedBB(this.position)).g(d0).b(0.0D, (double) this.world.getHeight(), 0.0D); List list = this.world.a(EntityHuman.class, axisalignedbb); + + return list; @@ -112,19 +86,21 @@ + { if (this.levels >= 4 && this.primaryEffect != this.secondaryEffect && this.secondaryEffect != null) { - iterator = list.iterator(); -+ return true; -+ } - +- - while (iterator.hasNext()) { - entityhuman = (EntityHuman) iterator.next(); - entityhuman.addEffect(new MobEffect(this.secondaryEffect, i, 0, true, true)); - } ++ return true; + } + + return false; -+ } -+ } -+ + } + } + + private void applyEffects() { -+ if (this.i && this.levels > 0 && !this.world.isClientSide && this.primaryEffect != null) { ++ if (!this.world.isClientSide && this.primaryEffect != null) { ++ double d0 = (double) (this.levels * 10 + 10); + byte b0 = getAmplification(); + + int i = getLevel(); @@ -134,24 +110,25 @@ + + if (hasSecondaryEffect()) { + applyEffect(list, this.secondaryEffect, i, 0); - } - } - - } ++ } ++ } ++ ++ } + // CraftBukkit end - - private void E() { - int i = this.position.getX(); -@@ -209,8 +286,10 @@ - ++ + public void a(SoundEffect soundeffect) { + this.world.a((EntityHuman) null, this.position, soundeffect, SoundCategory.BLOCKS, 1.0F, 1.0F); + } +@@ -247,8 +302,10 @@ + @Override public void load(NBTTagCompound nbttagcompound) { super.load(nbttagcompound); -- this.primaryEffect = e(nbttagcompound.getInt("Primary")); -- this.secondaryEffect = e(nbttagcompound.getInt("Secondary")); +- this.primaryEffect = b(nbttagcompound.getInt("Primary")); +- this.secondaryEffect = b(nbttagcompound.getInt("Secondary")); + // Craftbukkit start - persist manually set non-default beacon effects (SPIGOT-3598) + this.primaryEffect = MobEffectList.fromId(nbttagcompound.getInt("Primary")); + this.secondaryEffect = MobEffectList.fromId(nbttagcompound.getInt("Secondary")); + // Craftbukkit end - this.levels = nbttagcompound.getInt("Levels"); - } - + if (nbttagcompound.hasKeyOfType("CustomName", 8)) { + this.customName = IChatBaseComponent.ChatSerializer.a(nbttagcompound.getString("CustomName")); + } diff --git a/nms-patches/TileEntityBrewingStand.patch b/nms-patches/TileEntityBrewingStand.patch index 07d875a46b..3cccd28592 100644 --- a/nms-patches/TileEntityBrewingStand.patch +++ b/nms-patches/TileEntityBrewingStand.patch @@ -16,11 +16,11 @@ + public class TileEntityBrewingStand extends TileEntityContainer implements IWorldInventory, ITickable { - private static final int[] a = new int[] { 3}; -@@ -15,6 +25,31 @@ - private Item j; - private IChatBaseComponent k; - private int fuelLevel; + private static final int[] b = new int[] { 3}; +@@ -15,6 +25,36 @@ + private Item k; + public int fuelLevel; + protected final IContainerProperties a; + // CraftBukkit start - add fields and methods + private int lastTick = MinecraftServer.currentTick; + public List transaction = new java.util.ArrayList(); @@ -42,6 +42,11 @@ + return this.items; + } + ++ @Override ++ public int getMaxStackSize() { ++ return maxStack; ++ } ++ + public void setMaxStackSize(int size) { + maxStack = size; + } @@ -49,7 +54,7 @@ public TileEntityBrewingStand() { super(TileEntityTypes.BREWING_STAND); -@@ -62,8 +97,19 @@ +@@ -83,8 +123,19 @@ ItemStack itemstack = (ItemStack) this.items.get(4); if (this.fuelLevel <= 0 && itemstack.getItem() == Items.BLAZE_POWDER) { @@ -71,7 +76,7 @@ this.update(); } -@@ -71,9 +117,14 @@ +@@ -92,9 +143,14 @@ boolean flag1 = this.brewTime > 0; ItemStack itemstack1 = (ItemStack) this.items.get(3); @@ -87,10 +92,10 @@ + // CraftBukkit end if (flag2 && flag) { - this.r(); -@@ -147,6 +198,16 @@ + this.s(); +@@ -168,6 +224,16 @@ - private void r() { + private void s() { ItemStack itemstack = (ItemStack) this.items.get(3); + // CraftBukkit start + InventoryHolder owner = this.getOwner(); @@ -105,12 +110,3 @@ for (int i = 0; i < 3; ++i) { this.items.set(i, PotionBrewer.d(itemstack, (ItemStack) this.items.get(i))); -@@ -213,7 +274,7 @@ - } - - public int getMaxStackSize() { -- return 64; -+ return this.maxStack; // CraftBukkit - } - - public boolean a(EntityHuman entityhuman) { diff --git a/nms-patches/TileEntityCampfire.patch b/nms-patches/TileEntityCampfire.patch new file mode 100644 index 0000000000..4667a3ef2e --- /dev/null +++ b/nms-patches/TileEntityCampfire.patch @@ -0,0 +1,35 @@ +--- a/net/minecraft/server/TileEntityCampfire.java ++++ b/net/minecraft/server/TileEntityCampfire.java +@@ -3,6 +3,11 @@ + import java.util.Optional; + import java.util.Random; + import javax.annotation.Nullable; ++// CraftBukkit start ++import org.bukkit.craftbukkit.block.CraftBlock; ++import org.bukkit.craftbukkit.inventory.CraftItemStack; ++import org.bukkit.event.block.BlockCookEvent; ++// CraftBukkit end + + public class TileEntityCampfire extends TileEntity implements Clearable, ITickable { + +@@ -55,6 +60,20 @@ + }).orElse(itemstack); + BlockPosition blockposition = this.getPosition(); + ++ // CraftBukkit start - fire BlockCookEvent ++ CraftItemStack source = CraftItemStack.asCraftMirror(itemstack); ++ org.bukkit.inventory.ItemStack result = CraftItemStack.asBukkitCopy(itemstack1); ++ ++ BlockCookEvent blockCookEvent = new BlockCookEvent(CraftBlock.at(this.world, this.position), source, result); ++ this.world.getServer().getPluginManager().callEvent(blockCookEvent); ++ ++ if (blockCookEvent.isCancelled()) { ++ return; ++ } ++ ++ result = blockCookEvent.getResult(); ++ itemstack1 = CraftItemStack.asNMSCopy(result); ++ // CraftBukkit end + InventoryUtils.dropItem(this.world, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), itemstack1); + this.items.set(i, ItemStack.a); + this.s(); diff --git a/nms-patches/TileEntityChest.patch b/nms-patches/TileEntityChest.patch index c4e28bbb1a..e71a22ceef 100644 --- a/nms-patches/TileEntityChest.patch +++ b/nms-patches/TileEntityChest.patch @@ -11,9 +11,9 @@ public class TileEntityChest extends TileEntityLootable implements ITickable { -@@ -11,6 +15,31 @@ - protected int f; - private int k; +@@ -11,6 +15,36 @@ + protected int viewingCount; + private int j; + // CraftBukkit start - add fields and methods + public List transaction = new java.util.ArrayList(); @@ -35,6 +35,11 @@ + return transaction; + } + ++ @Override ++ public int getMaxStackSize() { ++ return maxStack; ++ } ++ + public void setMaxStackSize(int size) { + maxStack = size; + } @@ -43,58 +48,49 @@ protected TileEntityChest(TileEntityTypes tileentitytypes) { super(tileentitytypes); this.items = NonNullList.a(27, ItemStack.a); -@@ -75,7 +104,7 @@ - } - - public int getMaxStackSize() { -- return 64; -+ return maxStack; // CraftBukkit - } - - public void tick() { -@@ -170,8 +199,20 @@ - if (this.f < 0) { - this.f = 0; +@@ -172,8 +206,20 @@ + if (this.viewingCount < 0) { + this.viewingCount = 0; } -+ int oldPower = Math.max(0, Math.min(15, this.f)); // CraftBukkit - Get power before new viewer is added ++ int oldPower = Math.max(0, Math.min(15, this.viewingCount)); // CraftBukkit - Get power before new viewer is added - ++this.f; + ++this.viewingCount; + if (this.world == null) return; // CraftBukkit + + // CraftBukkit start - Call redstone event -+ if (this.getBlock() == Blocks.TRAPPED_CHEST) { -+ int newPower = Math.max(0, Math.min(15, this.f)); ++ if (this.getBlock().getBlock() == Blocks.TRAPPED_CHEST) { ++ int newPower = Math.max(0, Math.min(15, this.viewingCount)); + + if (oldPower != newPower) { + org.bukkit.craftbukkit.event.CraftEventFactory.callRedstoneChange(world, position, oldPower, newPower); + } + } + // CraftBukkit end - this.p(); + this.onOpen(); } -@@ -179,7 +220,18 @@ - +@@ -182,7 +228,18 @@ + @Override public void closeContainer(EntityHuman entityhuman) { if (!entityhuman.isSpectator()) { -+ int oldPower = Math.max(0, Math.min(15, this.f)); // CraftBukkit - Get power before new viewer is added - --this.f; ++ int oldPower = Math.max(0, Math.min(15, this.viewingCount)); // CraftBukkit - Get power before new viewer is added + --this.viewingCount; + + // CraftBukkit start - Call redstone event -+ if (this.getBlock() == Blocks.TRAPPED_CHEST) { -+ int newPower = Math.max(0, Math.min(15, this.f)); ++ if (this.getBlock().getBlock() == Blocks.TRAPPED_CHEST) { ++ int newPower = Math.max(0, Math.min(15, this.viewingCount)); + + if (oldPower != newPower) { + org.bukkit.craftbukkit.event.CraftEventFactory.callRedstoneChange(world, position, oldPower, newPower); + } + } + // CraftBukkit end - this.p(); + this.onOpen(); } -@@ -232,4 +284,11 @@ - tileentitychest.a(tileentitychest1.q()); - tileentitychest1.a(nonnulllist); +@@ -233,4 +290,11 @@ + protected Container createContainer(int i, PlayerInventory playerinventory) { + return ContainerChest.a(i, playerinventory, this); } + + // CraftBukkit start diff --git a/nms-patches/TileEntityCommand.patch b/nms-patches/TileEntityCommand.patch index a33d896945..ab30886d30 100644 --- a/nms-patches/TileEntityCommand.patch +++ b/nms-patches/TileEntityCommand.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/server/TileEntityCommand.java +++ b/net/minecraft/server/TileEntityCommand.java @@ -9,6 +9,13 @@ - private boolean f; + private boolean c; private boolean g; private final CommandBlockListenerAbstract h = new CommandBlockListenerAbstract() { + // CraftBukkit start @@ -11,6 +11,6 @@ + } + // CraftBukkit end + + @Override public void setCommand(String s) { super.setCommand(s); - TileEntityCommand.this.update(); diff --git a/nms-patches/TileEntityConduit.patch b/nms-patches/TileEntityConduit.patch index 71ab439510..74ef7d6de7 100644 --- a/nms-patches/TileEntityConduit.patch +++ b/nms-patches/TileEntityConduit.patch @@ -11,25 +11,25 @@ public class TileEntityConduit extends TileEntity implements ITickable { -@@ -151,7 +155,7 @@ +@@ -158,7 +162,7 @@ EntityHuman entityhuman = (EntityHuman) iterator.next(); - if (this.position.m(new BlockPosition(entityhuman)) <= (double) j && entityhuman.ao()) { + if (this.position.a((BaseBlockPosition) (new BlockPosition(entityhuman)), (double) j) && entityhuman.isInWaterOrRain()) { - entityhuman.addEffect(new MobEffect(MobEffects.CONDUIT_POWER, 260, 0, true, true)); + entityhuman.addEffect(new MobEffect(MobEffects.CONDUIT_POWER, 260, 0, true, true), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONDUIT); // CraftBukkit } } -@@ -168,7 +172,7 @@ - this.target = this.l(); +@@ -175,7 +179,7 @@ + this.target = this.v(); this.k = null; } else if (this.target == null) { -- List list = this.world.a(EntityLiving.class, this.k(), (entityliving1) -> { -+ List list = this.world.a(EntityLiving.class, this.k(), (java.util.function.Predicate) (entityliving1) -> { // CraftBukkit - decompile error - return entityliving1 instanceof IMonster && entityliving1.ao(); +- List list = this.world.a(EntityLiving.class, this.u(), (entityliving1) -> { ++ List list = this.world.a(EntityLiving.class, this.u(), (java.util.function.Predicate) (entityliving1) -> { // CraftBukkit - decompile error + return entityliving1 instanceof IMonster && entityliving1.isInWaterOrRain(); }); -@@ -180,8 +184,13 @@ +@@ -187,8 +191,13 @@ } if (this.target != null) { @@ -45,12 +45,12 @@ } if (entityliving != this.target) { -@@ -214,7 +223,7 @@ +@@ -221,7 +230,7 @@ @Nullable - private EntityLiving l() { -- List list = this.world.a(EntityLiving.class, this.k(), (entityliving) -> { -+ List list = this.world.a(EntityLiving.class, this.k(), (java.util.function.Predicate) (entityliving) -> { // CraftBukkit - decompile error + private EntityLiving v() { +- List list = this.world.a(EntityLiving.class, this.u(), (entityliving) -> { ++ List list = this.world.a(EntityLiving.class, this.u(), (java.util.function.Predicate) (entityliving) -> { // CraftBukkit - decompile error return entityliving.getUniqueID().equals(this.k); }); diff --git a/nms-patches/TileEntityContainer.patch b/nms-patches/TileEntityContainer.patch index b01f802589..f9473c325f 100644 --- a/nms-patches/TileEntityContainer.patch +++ b/nms-patches/TileEntityContainer.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/server/TileEntityContainer.java +++ b/net/minecraft/server/TileEntityContainer.java -@@ -34,4 +34,12 @@ - public void setLock(ChestLock chestlock) { - this.a = chestlock; +@@ -76,4 +76,12 @@ } + + protected abstract Container createContainer(int i, PlayerInventory playerinventory); + + // CraftBukkit start + @Override diff --git a/nms-patches/TileEntityDispenser.patch b/nms-patches/TileEntityDispenser.patch index 54a1325409..3eabd2c2a1 100644 --- a/nms-patches/TileEntityDispenser.patch +++ b/nms-patches/TileEntityDispenser.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/TileEntityDispenser.java +++ b/net/minecraft/server/TileEntityDispenser.java -@@ -2,12 +2,43 @@ +@@ -2,12 +2,48 @@ import java.util.Iterator; import java.util.Random; @@ -36,6 +36,11 @@ + return transaction; + } + ++ @Override ++ public int getMaxStackSize() { ++ return maxStack; ++ } ++ + public void setMaxStackSize(int size) { + maxStack = size; + } @@ -44,12 +49,3 @@ protected TileEntityDispenser(TileEntityTypes tileentitytypes) { super(tileentitytypes); this.items = NonNullList.a(9, ItemStack.a); -@@ -97,7 +128,7 @@ - } - - public int getMaxStackSize() { -- return 64; -+ return maxStack; // CraftBukkit - } - - public String getContainerName() { diff --git a/nms-patches/TileEntityEndGateway.patch b/nms-patches/TileEntityEndGateway.patch index 585f0f16e9..f224628ac4 100644 --- a/nms-patches/TileEntityEndGateway.patch +++ b/nms-patches/TileEntityEndGateway.patch @@ -13,9 +13,9 @@ public class TileEntityEndGateway extends TileEntityEnderPortal implements ITickable { -@@ -113,6 +119,26 @@ +@@ -119,6 +125,26 @@ if (this.exitPortal != null) { - BlockPosition blockposition = this.exactTeleport ? this.exitPortal : this.i(); + BlockPosition blockposition = this.exactTeleport ? this.exitPortal : this.s(); + // CraftBukkit start - Fire PlayerTeleportEvent + if (entity instanceof EntityPlayer) { diff --git a/nms-patches/TileEntityFurnace.patch b/nms-patches/TileEntityFurnace.patch index 3485bd63ad..32af3869ef 100644 --- a/nms-patches/TileEntityFurnace.patch +++ b/nms-patches/TileEntityFurnace.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/TileEntityFurnace.java +++ b/net/minecraft/server/TileEntityFurnace.java -@@ -7,6 +7,15 @@ +@@ -7,6 +7,17 @@ import java.util.Map; import java.util.Map.Entry; import javax.annotation.Nullable; @@ -10,13 +10,15 @@ +import org.bukkit.craftbukkit.entity.CraftHumanEntity; +import org.bukkit.craftbukkit.inventory.CraftItemStack; +import org.bukkit.entity.HumanEntity; ++import org.bukkit.entity.Player; +import org.bukkit.event.inventory.FurnaceBurnEvent; ++import org.bukkit.event.inventory.FurnaceExtractEvent; +import org.bukkit.event.inventory.FurnaceSmeltEvent; +// CraftBukkit end - public class TileEntityFurnace extends TileEntityContainer implements IWorldInventory, RecipeHolder, AutoRecipeOutput, ITickable { + public abstract class TileEntityFurnace extends TileEntityContainer implements IWorldInventory, RecipeHolder, AutoRecipeOutput, ITickable { -@@ -91,6 +100,31 @@ +@@ -135,6 +146,36 @@ return map; } @@ -40,19 +42,28 @@ + return transaction; + } + ++ @Override ++ public int getMaxStackSize() { ++ return maxStack; ++ } ++ + public void setMaxStackSize(int size) { + maxStack = size; + } + // CraftBukkit end + - public TileEntityFurnace() { - super(TileEntityTypes.FURNACE); - this.items = NonNullList.a(3, ItemStack.a); -@@ -236,9 +270,20 @@ - IRecipe irecipe = this.world.getCraftingManager().b(this, this.world); + private static void a(Map map, Tag tag, int i) { + Iterator iterator = tag.a().iterator(); + +@@ -211,12 +252,23 @@ + this.cookTime = MathHelper.clamp(this.cookTime - 2, 0, this.cookTimeTotal); + } + } else { +- IRecipe irecipe = (IRecipe) this.world.getCraftingManager().craft(this.c, this, this.world).orElse((Object) null); ++ IRecipe irecipe = this.world.getCraftingManager().craft((Recipes) this.c, this, this.world).orElse(null); // Eclipse fail if (!this.isBurning() && this.canBurn(irecipe)) { -- this.burnTime = fuelTime(itemstack); +- this.burnTime = this.fuelTime(itemstack); + // CraftBukkit start + CraftItemStack fuel = CraftItemStack.asCraftMirror(itemstack); + @@ -71,17 +82,8 @@ flag1 = true; if (!itemstack.isEmpty()) { Item item = itemstack.getItem(); -@@ -279,7 +324,7 @@ - } - - private int s() { -- FurnaceRecipe furnacerecipe = (FurnaceRecipe) this.world.getCraftingManager().b(this, this.world); -+ FurnaceRecipe furnacerecipe = (this.hasWorld()) ? (FurnaceRecipe) this.world.getCraftingManager().b(this, this.world) : null; // CraftBukkit - SPIGOT-4302 - - return furnacerecipe != null ? furnacerecipe.h() : 200; - } -@@ -306,11 +351,38 @@ - ItemStack itemstack1 = irecipe.d(); +@@ -278,11 +330,38 @@ + ItemStack itemstack1 = irecipe.c(); ItemStack itemstack2 = (ItemStack) this.items.get(2); + // CraftBukkit start - fire FurnaceSmeltEvent @@ -118,4 +120,55 @@ + // CraftBukkit end if (!this.world.isClientSide) { - this.a(this.world, (EntityPlayer) null, irecipe); + this.a(irecipe); +@@ -307,7 +386,7 @@ + } + + protected int getRecipeCookingTime() { +- return (Integer) this.world.getCraftingManager().craft(this.c, this, this.world).map(RecipeCooking::e).orElse(200); ++ return (this.hasWorld()) ? (Integer) this.world.getCraftingManager().craft((Recipes) this.c, this, this.world).map(RecipeCooking::e).orElse(200) : 200; // CraftBukkit - SPIGOT-4302 // Eclipse fail + } + + public static boolean isFuel(ItemStack itemstack) { +@@ -434,7 +513,7 @@ + @Override + public void b(EntityHuman entityhuman) {} + +- public void d(EntityHuman entityhuman) { ++ public void d(EntityHuman entityhuman, ItemStack itemstack, int amount) { // CraftBukkit + List> list = Lists.newArrayList(); + Iterator iterator = this.n.entrySet().iterator(); + +@@ -443,7 +522,7 @@ + + entityhuman.world.getCraftingManager().a((MinecraftKey) entry.getKey()).ifPresent((irecipe) -> { + list.add(irecipe); +- a(entityhuman, (Integer) entry.getValue(), ((RecipeCooking) irecipe).b()); ++ a(entityhuman, (Integer) entry.getValue(), ((RecipeCooking) irecipe).b(), itemstack, amount); // CraftBukkit + }); + } + +@@ -451,7 +530,7 @@ + this.n.clear(); + } + +- private static void a(EntityHuman entityhuman, int i, float f) { ++ private void a(EntityHuman entityhuman, int i, float f, ItemStack itemstack, int amount) { // CraftBukkit + int j; + + if (f == 0.0F) { +@@ -465,6 +544,14 @@ + i = j; + } + ++ // CraftBukkit start - fire FurnaceExtractEvent ++ if (amount != 0) { ++ FurnaceExtractEvent event = new FurnaceExtractEvent((Player) entityhuman.getBukkitEntity(), CraftBlock.at(world, position), org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(itemstack.getItem()), amount, i); ++ world.getServer().getPluginManager().callEvent(event); ++ i = event.getExpToDrop(); ++ } ++ // CraftBukkit end ++ + while (i > 0) { + j = EntityExperienceOrb.getOrbValue(i); + i -= j; diff --git a/nms-patches/TileEntityHopper.patch b/nms-patches/TileEntityHopper.patch index 4fbcc8d049..43e629004c 100644 --- a/nms-patches/TileEntityHopper.patch +++ b/nms-patches/TileEntityHopper.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/server/TileEntityHopper.java +++ b/net/minecraft/server/TileEntityHopper.java -@@ -6,12 +6,46 @@ - import java.util.stream.Collectors; +@@ -7,12 +7,51 @@ + import java.util.stream.IntStream; import javax.annotation.Nullable; +// CraftBukkit start @@ -16,8 +16,8 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITickable { private NonNullList items; - private int f; - private long j; + private int j; + private long k; + // CraftBukkit start - add fields and methods + public List transaction = new java.util.ArrayList(); @@ -39,6 +39,11 @@ + return transaction; + } + ++ @Override ++ public int getMaxStackSize() { ++ return maxStack; ++ } ++ + public void setMaxStackSize(int size) { + maxStack = size; + } @@ -47,16 +52,7 @@ public TileEntityHopper() { super(TileEntityTypes.HOPPER); this.items = NonNullList.a(5, ItemStack.a); -@@ -71,7 +105,7 @@ - } - - public int getMaxStackSize() { -- return 64; -+ return maxStack; // CraftBukkit - } - - public void tick() { -@@ -164,7 +198,28 @@ +@@ -159,7 +198,28 @@ for (int i = 0; i < this.getSize(); ++i) { if (!this.getItem(i).isEmpty()) { ItemStack itemstack = this.getItem(i).cloneItemStack(); @@ -86,7 +82,7 @@ if (itemstack1.isEmpty()) { iinventory.update(); -@@ -289,7 +344,34 @@ +@@ -224,7 +284,34 @@ if (!itemstack.isEmpty() && b(iinventory, itemstack, i, enumdirection)) { ItemStack itemstack1 = itemstack.cloneItemStack(); @@ -122,7 +118,7 @@ if (itemstack2.isEmpty()) { iinventory.update(); -@@ -304,6 +386,13 @@ +@@ -239,6 +326,13 @@ public static boolean a(IInventory iinventory, EntityItem entityitem) { boolean flag = false; diff --git a/nms-patches/TileEntityLectern.patch b/nms-patches/TileEntityLectern.patch new file mode 100644 index 0000000000..163f42c0c4 --- /dev/null +++ b/nms-patches/TileEntityLectern.patch @@ -0,0 +1,126 @@ +--- a/net/minecraft/server/TileEntityLectern.java ++++ b/net/minecraft/server/TileEntityLectern.java +@@ -1,10 +1,61 @@ + package net.minecraft.server; + + import javax.annotation.Nullable; ++// CraftBukkit start ++import java.util.ArrayList; ++import java.util.Arrays; ++import java.util.List; ++import org.bukkit.Location; ++import org.bukkit.block.Lectern; ++import org.bukkit.craftbukkit.block.CraftBlock; ++import org.bukkit.craftbukkit.entity.CraftHumanEntity; ++import org.bukkit.entity.HumanEntity; ++import org.bukkit.inventory.InventoryHolder; ++// CraftBukkit end + +-public class TileEntityLectern extends TileEntity implements Clearable, ITileInventory { ++public class TileEntityLectern extends TileEntity implements Clearable, ITileInventory, ICommandListener { // CraftBukkit - ICommandListener + + public final IInventory inventory = new IInventory() { ++ // CraftBukkit start - add fields and methods ++ public List transaction = new ArrayList<>(); ++ private int maxStack = 1; ++ ++ @Override ++ public List getContents() { ++ return Arrays.asList(book); ++ } ++ ++ @Override ++ public void onOpen(CraftHumanEntity who) { ++ transaction.add(who); ++ } ++ ++ @Override ++ public void onClose(CraftHumanEntity who) { ++ transaction.remove(who); ++ } ++ ++ @Override ++ public List getViewers() { ++ return transaction; ++ } ++ ++ @Override ++ public void setMaxStackSize(int i) { ++ maxStack = i; ++ } ++ ++ @Override ++ public Location getLocation() { ++ return new Location(world.getWorld(), position.getX(), position.getY(), position.getZ()); ++ } ++ ++ @Override ++ public InventoryHolder getOwner() { ++ return (Lectern) CraftBlock.at(world, position).getState(); ++ } ++ // CraftBukkit end ++ + @Override + public int getSize() { + return 1; +@@ -53,7 +104,7 @@ + + @Override + public int getMaxStackSize() { +- return 1; ++ return maxStack; // CraftBukkit + } + + @Override +@@ -158,6 +209,32 @@ + return itemstack; + } + ++ // CraftBukkit start ++ @Override ++ public void sendMessage(IChatBaseComponent ichatbasecomponent) { ++ } ++ ++ @Override ++ public org.bukkit.command.CommandSender getBukkitSender(CommandListenerWrapper wrapper) { ++ return wrapper.getEntity() != null ? wrapper.getEntity().getBukkitSender(wrapper) : new org.bukkit.craftbukkit.command.CraftBlockCommandSender(wrapper, this); ++ } ++ ++ @Override ++ public boolean shouldSendSuccess() { ++ return false; ++ } ++ ++ @Override ++ public boolean shouldSendFailure() { ++ return false; ++ } ++ ++ @Override ++ public boolean shouldBroadcastCommands() { ++ return false; ++ } ++ ++ // CraftBukkit end + private CommandListenerWrapper a(@Nullable EntityHuman entityhuman) { + String s; + Object object; +@@ -172,7 +249,8 @@ + + Vec3D vec3d = new Vec3D((double) this.position.getX() + 0.5D, (double) this.position.getY() + 0.5D, (double) this.position.getZ() + 0.5D); + +- return new CommandListenerWrapper(ICommandListener.DUMMY, vec3d, Vec2F.a, (WorldServer) this.world, 2, s, (IChatBaseComponent) object, this.world.getMinecraftServer(), entityhuman); ++ // CraftBukkit - this ++ return new CommandListenerWrapper(this, vec3d, Vec2F.a, (WorldServer) this.world, 2, s, (IChatBaseComponent) object, this.world.getMinecraftServer(), entityhuman); + } + + @Override +@@ -206,7 +284,7 @@ + + @Override + public Container createMenu(int i, PlayerInventory playerinventory, EntityHuman entityhuman) { +- return new ContainerLectern(i, this.inventory, this.containerProperties); ++ return new ContainerLectern(i, this.inventory, this.containerProperties, playerinventory); // CraftBukkit + } + + @Override diff --git a/nms-patches/TileEntityShulkerBox.patch b/nms-patches/TileEntityShulkerBox.patch index 435fe1e24d..15e79d57ef 100644 --- a/nms-patches/TileEntityShulkerBox.patch +++ b/nms-patches/TileEntityShulkerBox.patch @@ -11,16 +11,16 @@ public class TileEntityShulkerBox extends TileEntityLootable implements IWorldInventory, ITickable { -@@ -18,6 +22,31 @@ - private boolean o; - private boolean p; +@@ -16,6 +20,36 @@ + private EnumColor l; + private boolean m; + // CraftBukkit start - add fields and methods + public List transaction = new java.util.ArrayList(); + private int maxStack = MAX_STACK; + + public List getContents() { -+ return this.e; ++ return this.contents; + } + + public void onOpen(CraftHumanEntity who) { @@ -35,6 +35,11 @@ + return transaction; + } + ++ @Override ++ public int getMaxStackSize() { ++ return maxStack; ++ } ++ + public void setMaxStackSize(int size) { + maxStack = size; + } @@ -42,13 +47,4 @@ + public TileEntityShulkerBox(@Nullable EnumColor enumcolor) { super(TileEntityTypes.SHULKER_BOX); - this.e = NonNullList.a(27, ItemStack.a); -@@ -143,7 +172,7 @@ - } - - public int getMaxStackSize() { -- return 64; -+ return maxStack; // CraftBukkit - } - - public boolean c(int i, int j) { + this.contents = NonNullList.a(27, ItemStack.a); diff --git a/nms-patches/TileEntitySign.patch b/nms-patches/TileEntitySign.patch index 9362d3fc88..9bde15700c 100644 --- a/nms-patches/TileEntitySign.patch +++ b/nms-patches/TileEntitySign.patch @@ -1,6 +1,15 @@ --- a/net/minecraft/server/TileEntitySign.java +++ b/net/minecraft/server/TileEntitySign.java -@@ -24,6 +24,12 @@ +@@ -3,7 +3,7 @@ + import com.mojang.brigadier.exceptions.CommandSyntaxException; + import javax.annotation.Nullable; + +-public class TileEntitySign extends TileEntity { ++public class TileEntitySign extends TileEntity implements ICommandListener { // CraftBukkit - implements + + public final IChatBaseComponent[] lines = new IChatBaseComponent[] { new ChatComponentText(""), new ChatComponentText(""), new ChatComponentText(""), new ChatComponentText("")}; + private int c = -1; +@@ -29,6 +29,12 @@ nbttagcompound.setString("Text" + (i + 1), s); } @@ -10,12 +19,12 @@ + } + // CraftBukkit end + + nbttagcompound.setString("Color", this.l.b()); return nbttagcompound; } - -@@ -31,18 +37,38 @@ - this.isEditable = false; +@@ -39,18 +45,38 @@ super.load(nbttagcompound); + this.l = EnumColor.a(nbttagcompound.getString("Color"), EnumColor.BLACK); + // CraftBukkit start - Add an option to convert signs correctly + // This is done with a flag instead of all the time because @@ -29,14 +38,14 @@ + if (s != null && s.length() > 2048) { + s = "\"\""; + } ++ ++ try { ++ IChatBaseComponent ichatbasecomponent = IChatBaseComponent.ChatSerializer.a(s); - if (this.world instanceof WorldServer) { - try { - this.lines[i] = ChatComponentUtils.filterForDisplay(this.a((EntityPlayer) null), ichatbasecomponent, (Entity) null); - } catch (CommandSyntaxException commandsyntaxexception) { -+ try { -+ IChatBaseComponent ichatbasecomponent = IChatBaseComponent.ChatSerializer.a(s); -+ + if (oldSign) { + lines[i] = org.bukkit.craftbukkit.util.CraftChatMessage.fromString(s)[0]; + continue; @@ -58,18 +67,43 @@ + this.lines[i] = new ChatComponentText(s); } - this.h[i] = null; -@@ -102,6 +128,13 @@ - - public void sendMessage(IChatBaseComponent ichatbasecomponent) {} + this.k[i] = null; +@@ -111,11 +137,37 @@ + return true; + } + // CraftBukkit start + @Override ++ public void sendMessage(IChatBaseComponent ichatbasecomponent) {} ++ ++ @Override + public org.bukkit.command.CommandSender getBukkitSender(CommandListenerWrapper wrapper) { + return wrapper.getEntity() != null ? wrapper.getEntity().getBukkitSender(wrapper) : new org.bukkit.craftbukkit.command.CraftBlockCommandSender(wrapper, this); + } ++ ++ @Override ++ public boolean shouldSendSuccess() { ++ return false; ++ } ++ ++ @Override ++ public boolean shouldSendFailure() { ++ return false; ++ } ++ ++ @Override ++ public boolean shouldBroadcastCommands() { ++ return false; ++ } + // CraftBukkit end + public CommandListenerWrapper a(@Nullable EntityPlayer entityplayer) { String s = entityplayer == null ? "Sign" : entityplayer.getDisplayName().getString(); Object object = entityplayer == null ? new ChatComponentText("Sign") : entityplayer.getScoreboardDisplayName(); + +- return new CommandListenerWrapper(ICommandListener.DUMMY, new Vec3D((double) this.position.getX() + 0.5D, (double) this.position.getY() + 0.5D, (double) this.position.getZ() + 0.5D), Vec2F.a, (WorldServer) this.world, 2, s, (IChatBaseComponent) object, this.world.getMinecraftServer(), entityplayer); ++ // CraftBukkit - this ++ return new CommandListenerWrapper(this, new Vec3D((double) this.position.getX() + 0.5D, (double) this.position.getY() + 0.5D, (double) this.position.getZ() + 0.5D), Vec2F.a, (WorldServer) this.world, 2, s, (IChatBaseComponent) object, this.world.getMinecraftServer(), entityplayer); + } + + public EnumColor f() { diff --git a/nms-patches/TileEntitySkull.patch b/nms-patches/TileEntitySkull.patch deleted file mode 100644 index 7b4bcc5c0d..0000000000 --- a/nms-patches/TileEntitySkull.patch +++ /dev/null @@ -1,23 +0,0 @@ ---- a/net/minecraft/server/TileEntitySkull.java -+++ b/net/minecraft/server/TileEntitySkull.java -@@ -118,13 +118,19 @@ - } - } - -+ // CraftBukkit start - public static void a(IBlockAccess iblockaccess, BlockPosition blockposition) { -+ setShouldDrop(iblockaccess, blockposition, false); -+ } -+ -+ public static void setShouldDrop(IBlockAccess iblockaccess, BlockPosition blockposition, boolean flag) { -+ // CraftBukkit end - TileEntity tileentity = iblockaccess.getTileEntity(blockposition); - - if (tileentity instanceof TileEntitySkull) { - TileEntitySkull tileentityskull = (TileEntitySkull) tileentity; - -- tileentityskull.drop = false; -+ tileentityskull.drop = flag; // CraftBukkit - } - - } diff --git a/nms-patches/Village.patch b/nms-patches/Village.patch deleted file mode 100644 index d11b37828a..0000000000 --- a/nms-patches/Village.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/server/Village.java -+++ b/net/minecraft/server/Village.java -@@ -77,7 +77,7 @@ - - if (entityirongolem != null) { - if (entityirongolem.a((GeneratorAccess) this.a, false) && entityirongolem.a((IWorldReader) this.a)) { -- this.a.addEntity(entityirongolem); -+ this.a.addEntity(entityirongolem, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.VILLAGE_DEFENSE); // CraftBukkit - return entityirongolem; - } - diff --git a/nms-patches/VillageSiege.patch b/nms-patches/VillageSiege.patch index 626a008aa0..510cdf86b6 100644 --- a/nms-patches/VillageSiege.patch +++ b/nms-patches/VillageSiege.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/server/VillageSiege.java +++ b/net/minecraft/server/VillageSiege.java -@@ -140,7 +140,7 @@ +@@ -102,7 +102,7 @@ } 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(); + } + } - entityzombie.a(blockposition, this.f.b()); diff --git a/nms-patches/World.patch b/nms-patches/World.patch index b5aca0a6b7..077b81b991 100644 --- a/nms-patches/World.patch +++ b/nms-patches/World.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/World.java +++ b/net/minecraft/server/World.java -@@ -18,6 +18,22 @@ - import org.apache.logging.log4j.LogManager; +@@ -14,6 +14,22 @@ import org.apache.logging.log4j.Logger; + import org.apache.logging.log4j.util.Supplier; +// CraftBukkit start +import com.google.common.collect.Maps; @@ -17,22 +17,22 @@ +import org.bukkit.craftbukkit.event.CraftEventFactory; +import org.bukkit.event.block.BlockPhysicsEvent; +import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; -+import org.bukkit.generator.ChunkGenerator; ++import org.bukkit.event.weather.LightningStrikeEvent; +// CraftBukkit end + - public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAccess, AutoCloseable { + public abstract class World implements IIBlockAccess, GeneratorAccess, AutoCloseable { protected static final Logger e = LogManager.getLogger(); -@@ -59,7 +75,52 @@ - private final WorldBorder K; - int[] E; +@@ -41,14 +57,87 @@ + protected boolean tickingTileEntities; + private final WorldBorder worldBorder; -- protected World(IDataManager idatamanager, @Nullable PersistentCollection persistentcollection, WorldData worlddata, WorldProvider worldprovider, MethodProfiler methodprofiler, boolean flag) { +- protected World(WorldData worlddata, DimensionManager dimensionmanager, BiFunction bifunction, GameProfilerFiller gameprofilerfiller, boolean flag) { + // CraftBukkit start Added the following + private final CraftWorld world; + public boolean pvpMode; + public boolean keepSpawnInMemory = true; -+ public ChunkGenerator generator; ++ public org.bukkit.generator.ChunkGenerator generator; + + public boolean captureBlockStates = false; + public boolean captureTreeGeneration = false; @@ -54,7 +54,6 @@ + public long ticksPerAnimalSpawns; + public long ticksPerMonsterSpawns; + public boolean populating; -+ private int tickPosition; + + public CraftWorld getWorld() { + return this.world; @@ -65,22 +64,23 @@ + } + + public Chunk getChunkIfLoaded(int x, int z) { -+ return ((ChunkProviderServer) this.chunkProvider).getChunkAt(x, z, false, false); ++ return ((ChunkProviderServer) this.chunkProvider).getChunkAt(x, z, false); + } + -+ protected World(IDataManager idatamanager, @Nullable PersistentCollection persistentcollection, WorldData worlddata, WorldProvider worldprovider, MethodProfiler methodprofiler, boolean flag, ChunkGenerator gen, org.bukkit.World.Environment env) { ++ protected World(WorldData worlddata, DimensionManager dimensionmanager, BiFunction bifunction, GameProfilerFiller gameprofilerfiller, boolean flag, org.bukkit.generator.ChunkGenerator gen, org.bukkit.World.Environment env) { + this.generator = gen; + this.world = new CraftWorld((WorldServer) this, gen, env); + this.ticksPerAnimalSpawns = this.getServer().getTicksPerAnimalSpawns(); // CraftBukkit + this.ticksPerMonsterSpawns = this.getServer().getTicksPerMonsterSpawns(); // CraftBukkit + // CraftBukkit end - this.v = Lists.newArrayList(new IWorldAccess[] { this.u}); - this.allowMonsters = true; - this.allowAnimals = true; -@@ -71,6 +132,36 @@ - this.worldProvider = worldprovider; + this.methodProfiler = gameprofilerfiller; + this.worldData = worlddata; +- this.worldProvider = dimensionmanager.getWorldProvider(this); ++ this.worldProvider = DimensionManager.a(env.getId()).getWorldProvider(this); // CraftBukkit + this.chunkProvider = (IChunkProvider) bifunction.apply(this, this.worldProvider); this.isClientSide = flag; - this.K = worldprovider.getWorldBorder(); + this.worldBorder = this.worldProvider.getWorldBorder(); + this.c = Thread.currentThread(); + // CraftBukkit start + getWorldBorder().world = (WorldServer) this; + // From PlayerList.setPlayerFileData @@ -109,14 +109,13 @@ + + public void c(WorldBorder worldborder, double d0) {} + }); -+ this.getServer().addWorld(this.world); + // CraftBukkit end } - public BiomeBase getBiome(BlockPosition blockposition) { -@@ -145,6 +236,26 @@ - } + @Override +@@ -119,6 +208,26 @@ + @Override public boolean setTypeAndData(BlockPosition blockposition, IBlockData iblockdata, int i) { + // CraftBukkit start - tree generation + if (this.captureTreeGeneration) { @@ -138,10 +137,10 @@ + return true; + } + // CraftBukkit end - if (k(blockposition)) { + if (isInsideWorld(blockposition)) { return false; } else if (!this.isClientSide && this.worldData.getType() == WorldType.DEBUG_ALL_BLOCK_STATES) { -@@ -152,9 +263,23 @@ +@@ -126,9 +235,23 @@ } else { Chunk chunk = this.getChunkAtWorldCoords(blockposition); Block block = iblockdata.getBlock(); @@ -166,17 +165,17 @@ return false; } else { IBlockData iblockdata2 = this.getType(blockposition); -@@ -165,6 +290,7 @@ +@@ -139,6 +262,7 @@ this.methodProfiler.exit(); } + /* if (iblockdata2 == iblockdata) { if (iblockdata1 != iblockdata2) { - this.a(blockposition, blockposition); -@@ -189,12 +315,63 @@ - iblockdata.b(this, blockposition, j); - } + this.m(blockposition); +@@ -165,12 +289,65 @@ + + this.a(blockposition, iblockdata1, iblockdata2); } + */ + @@ -199,10 +198,10 @@ + IBlockData iblockdata2 = actualBlock; + if (iblockdata2 == iblockdata) { + if (iblockdata1 != iblockdata2) { -+ this.a(blockposition, blockposition); ++ this.m(blockposition); + } + -+ if ((i & 2) != 0 && (!this.isClientSide || (i & 4) == 0) && (chunk == null || chunk.isReady())) { // allow chunk to be null here as chunk.isReady() is false when we send our notification during block placement ++ if ((i & 2) != 0 && (!this.isClientSide || (i & 4) == 0) && (this.isClientSide || chunk == null || (chunk.getState() != null && chunk.getState().a(PlayerChunk.State.TICKING)))) { // allow chunk to be null here as chunk.isReady() is false when we send our notification during block placement + this.notify(blockposition, iblockdata1, iblockdata, i); + } + @@ -228,18 +227,20 @@ + } + } + // CraftBukkit end -+ iblockdata.a((GeneratorAccess) this, blockposition, j); ++ iblockdata.a(this, blockposition, j); + iblockdata.b(this, blockposition, j); + } ++ ++ this.a(blockposition, iblockdata1, iblockdata2); + } + } + // CraftBukkit end + - public boolean setAir(BlockPosition blockposition) { - Fluid fluid = this.getFluid(blockposition); - -@@ -231,6 +408,11 @@ + public void a(BlockPosition blockposition, IBlockData iblockdata, IBlockData iblockdata1) {} + @Override +@@ -209,6 +386,11 @@ + @Override public void update(BlockPosition blockposition, Block block) { if (this.worldData.getType() != WorldType.DEBUG_ALL_BLOCK_STATES) { + // CraftBukkit start @@ -250,7 +251,7 @@ this.applyPhysics(blockposition, block); } -@@ -306,6 +488,17 @@ +@@ -257,6 +439,17 @@ IBlockData iblockdata = this.getType(blockposition); try { @@ -265,12 +266,12 @@ + } + } + // CraftBukkit end - iblockdata.doPhysics(this, blockposition, block, blockposition1); + iblockdata.doPhysics(this, blockposition, block, blockposition1, false); } catch (Throwable throwable) { CrashReport crashreport = CrashReport.a(throwable, "Exception while updating neighbours"); -@@ -400,6 +593,17 @@ - } +@@ -316,6 +509,17 @@ + @Override public IBlockData getType(BlockPosition blockposition) { + // CraftBukkit start - tree generation + if (captureTreeGeneration) { @@ -283,97 +284,13 @@ + } + } + // CraftBukkit end - if (k(blockposition)) { + if (isInsideWorld(blockposition)) { return Blocks.VOID_AIR.getBlockData(); } else { -@@ -646,6 +850,16 @@ - } +@@ -454,9 +658,11 @@ + TileEntity tileentity1 = (TileEntity) this.tileEntityListPending.get(i); - public boolean addEntity(Entity entity) { -+ // CraftBukkit start - Used for entities other than creatures -+ return addEntity(entity, SpawnReason.DEFAULT); -+ } -+ -+ public boolean addEntity(Entity entity, SpawnReason spawnReason) { // Changed signature, added SpawnReason -+ if (!CraftEventFactory.doEntityAddEventCalling(this, entity, spawnReason)) { -+ return false; -+ } -+ // CraftBukkit end -+ - int i = MathHelper.floor(entity.locX / 16.0D); - int j = MathHelper.floor(entity.locZ / 16.0D); - boolean flag = entity.attachedToPlayer; -@@ -676,6 +890,7 @@ - ((IWorldAccess) this.v.get(i)).a(entity); - } - -+ entity.valid = true; // CraftBukkit - } - - protected void c(Entity entity) { -@@ -683,6 +898,7 @@ - ((IWorldAccess) this.v.get(i)).b(entity); - } - -+ entity.valid = false; // CraftBukkit - } - - public void kill(Entity entity) { -@@ -718,7 +934,15 @@ - this.getChunkAt(i, j).b(entity); - } - -- this.entityList.remove(entity); -+ // CraftBukkit start - Decrement loop variable field if we've already ticked this entity -+ int index = this.entityList.indexOf(entity); -+ if (index != -1) { -+ if (index <= this.tickPosition) { -+ this.tickPosition--; -+ } -+ this.entityList.remove(index); -+ } -+ // CraftBukkit end - this.c(entity); - } - -@@ -753,6 +977,11 @@ - - for (i = 0; i < this.k.size(); ++i) { - entity = (Entity) this.k.get(i); -+ // CraftBukkit start - Fixed an NPE -+ if (entity == null) { -+ continue; -+ } -+ // CraftBukkit end - - try { - ++entity.ticksLived; -@@ -801,8 +1030,10 @@ - CrashReport crashreport1; - CrashReportSystemDetails crashreportsystemdetails1; - -- for (i = 0; i < this.entityList.size(); ++i) { -- entity = (Entity) this.entityList.get(i); -+ // CraftBukkit start - Use field for loop variable -+ for (this.tickPosition = 0; this.tickPosition < this.entityList.size(); ++this.tickPosition) { -+ entity = (Entity) this.entityList.get(this.tickPosition); -+ // CraftBukkit end - Entity entity1 = entity.getVehicle(); - - if (entity1 != null) { -@@ -835,7 +1066,7 @@ - this.getChunkAt(j, l).b(entity); - } - -- this.entityList.remove(i--); -+ this.entityList.remove(this.tickPosition--); // CraftBukkit - Use field for loop variable - this.c(entity); - } - -@@ -890,9 +1121,11 @@ - TileEntity tileentity1 = (TileEntity) this.c.get(i1); - - if (!tileentity1.x()) { + if (!tileentity1.isRemoved()) { + /* CraftBukkit start - Order matters, moved down if (!this.tileEntityList.contains(tileentity1)) { this.a(tileentity1); @@ -382,9 +299,9 @@ if (this.isLoaded(tileentity1.getPosition())) { Chunk chunk = this.getChunkAtWorldCoords(tileentity1.getPosition()); -@@ -900,6 +1133,12 @@ +@@ -464,6 +670,12 @@ - chunk.a(tileentity1.getPosition(), tileentity1); + chunk.setTileEntity(tileentity1.getPosition(), tileentity1); this.notify(tileentity1.getPosition(), iblockdata, iblockdata, 3); + // CraftBukkit start + // From above, don't screw this up - SPIGOT-1746 @@ -395,44 +312,16 @@ } } } -@@ -953,15 +1192,13 @@ - int i; - int j; - -- if (!(entity instanceof EntityHuman)) { -- i = MathHelper.floor(entity.locX); -- j = MathHelper.floor(entity.locZ); -- boolean flag1 = true; -- -- if (flag && !this.isAreaLoaded(i - 32, 0, j - 32, i + 32, 0, j + 32, true)) { -- return; -- } -+ // CraftBukkit start - check if chunks are loaded as done in previous versions -+ // TODO: Go back to Vanilla behaviour when comfortable -+ Chunk startingChunk = this.getChunkIfLoaded(MathHelper.floor(entity.locX) >> 4, MathHelper.floor(entity.locZ) >> 4); -+ if (flag && !(startingChunk != null && startingChunk.areNeighborsLoaded(2))) { -+ return; - } -+ // CraftBukkit end - - entity.N = entity.locX; - entity.O = entity.locY; -@@ -977,6 +1214,7 @@ - return IRegistry.ENTITY_TYPE.getKey(entity.P()).toString(); - }); - entity.tick(); -+ entity.postTick(); // CraftBukkit - this.methodProfiler.exit(); - } - } -@@ -1307,11 +1545,18 @@ +@@ -626,6 +838,7 @@ } } + public Map capturedTileEntities = Maps.newHashMap(); @Nullable + @Override public TileEntity getTileEntity(BlockPosition blockposition) { - if (k(blockposition)) { +@@ -634,6 +847,12 @@ + } else if (!this.isClientSide && Thread.currentThread() != this.c) { return null; } else { + // CraftBukkit start @@ -443,11 +332,11 @@ + TileEntity tileentity = null; - if (this.J) { -@@ -1346,6 +1591,14 @@ + if (this.tickingTileEntities) { +@@ -668,6 +887,14 @@ public void setTileEntity(BlockPosition blockposition, @Nullable TileEntity tileentity) { - if (!k(blockposition)) { - if (tileentity != null && !tileentity.x()) { + if (!isInsideWorld(blockposition)) { + if (tileentity != null && !tileentity.isRemoved()) { + // CraftBukkit start + if (captureBlockStates) { + tileentity.setWorld(this); @@ -456,129 +345,6 @@ + return; + } + // CraftBukkit end - if (this.J) { + if (this.tickingTileEntities) { tileentity.setPosition(blockposition); - Iterator iterator = this.c.iterator(); -@@ -1506,6 +1759,14 @@ - } - - this.p = MathHelper.a(this.p, 0.0F, 1.0F); -+ -+ // CraftBukkit start -+ for (int idx = 0; idx < this.players.size(); ++idx) { -+ if (((EntityPlayer) this.players.get(idx)).world == this) { -+ ((EntityPlayer) this.players.get(idx)).tickWeather(); -+ } -+ } -+ // CraftBukkit end - } - } - } -@@ -1591,7 +1852,10 @@ - } - - public boolean c(EnumSkyBlock enumskyblock, BlockPosition blockposition) { -- if (!this.areChunksLoaded(blockposition, 17, false)) { -+ // CraftBukkit start - Use neighbor cache instead of looking up -+ Chunk chunk = this.getChunkIfLoaded(blockposition.getX() >> 4, blockposition.getZ() >> 4); -+ if (chunk == null || !chunk.areNeighborsLoaded(1) /*!this.areChunksLoaded(blockposition, 17, false)*/) { -+ // CraftBukkit end - return false; - } else { - int i = 0; -@@ -1734,7 +1998,7 @@ - } - - public Stream a(@Nullable Entity entity, VoxelShape voxelshape, VoxelShape voxelshape1, Set set) { -- Stream stream = GeneratorAccess.super.a(entity, voxelshape, voxelshape1, set); -+ Stream stream = IIBlockAccess.super.a(entity, voxelshape, voxelshape1, set); // CraftBukkit - decompile error - - return entity == null ? stream : Stream.concat(stream, this.a(entity, voxelshape, set)); - } -@@ -1764,8 +2028,8 @@ - while (iterator.hasNext()) { - Entity entity = (Entity) iterator.next(); - -- if (oclass.isAssignableFrom(entity.getClass()) && predicate.test(entity)) { -- list.add(entity); -+ if (oclass.isAssignableFrom(entity.getClass()) && predicate.test((T) entity)) { // CraftBukkit - decompile error -+ list.add((T) entity); // CraftBukkit - decompile error - } - } - -@@ -1779,8 +2043,8 @@ - while (iterator.hasNext()) { - Entity entity = (Entity) iterator.next(); - -- if (oclass.isAssignableFrom(entity.getClass()) && predicate.test(entity)) { -- list.add(entity); -+ if (oclass.isAssignableFrom(entity.getClass()) && predicate.test((T) entity)) { // CraftBukkit - decompile error -+ list.add((T) entity); // CraftBukkit - decompile error - } - } - -@@ -1816,7 +2080,7 @@ - double d0 = Double.MAX_VALUE; - - for (int i = 0; i < list.size(); ++i) { -- T t2 = (Entity) list.get(i); -+ T t2 = (T) list.get(i); // CraftBukkit - decompile error - - if (t2 != t0 && IEntitySelector.f.test(t2)) { - double d1 = t0.h(t2); -@@ -1849,8 +2113,16 @@ - - while (iterator.hasNext()) { - Entity entity = (Entity) iterator.next(); -+ // CraftBukkit start - Split out persistent check, don't apply it to special persistent mobs -+ if (entity instanceof EntityInsentient) { -+ EntityInsentient entityinsentient = (EntityInsentient) entity; -+ if (entityinsentient.isTypeNotPersistent() && entityinsentient.isPersistent()) { -+ continue; -+ } -+ } - -- if (!(entity instanceof EntityInsentient) || !((EntityInsentient) entity).isPersistent()) { -+ if (true || !(entity instanceof EntityInsentient) || !((EntityInsentient) entity).isPersistent()) { -+ // CraftBukkit end - if (oclass.isAssignableFrom(entity.getClass())) { - ++j; - } -@@ -1969,6 +2241,11 @@ - - for (int i = 0; i < this.players.size(); ++i) { - EntityHuman entityhuman1 = (EntityHuman) this.players.get(i); -+ // CraftBukkit start - Fixed an NPE -+ if (entityhuman1 == null || entityhuman1.dead) { -+ continue; -+ } -+ // CraftBukkit end - - if (predicate.test(entityhuman1)) { - double d5 = entityhuman1.d(d0, d1, d2); -@@ -2182,6 +2459,16 @@ - - public void everyoneSleeping() {} - -+ // CraftBukkit start -+ // Calls the method that checks to see if players are sleeping -+ // Called by CraftPlayer.setPermanentSleeping() -+ public void checkSleepStatus() { -+ if (!this.isClientSide) { -+ this.everyoneSleeping(); -+ } -+ } -+ // CraftBukkit end -+ - public float g(float f) { - return (this.q + (this.r - this.q) * f) * this.i(f); - } -@@ -2343,7 +2630,7 @@ - int l = j * 16 + 8 - blockposition.getZ(); - boolean flag = true; - -- return k >= -128 && k <= 128 && l >= -128 && l <= 128; -+ return k >= -128 && k <= 128 && l >= -128 && l <= 128 && this.keepSpawnInMemory; // CraftBukkit - Added 'this.keepSpawnInMemory' - } - - public LongSet ag() { + Iterator iterator = this.tileEntityListPending.iterator(); diff --git a/nms-patches/WorldBorder.patch b/nms-patches/WorldBorder.patch index f28a690f40..57d8864f30 100644 --- a/nms-patches/WorldBorder.patch +++ b/nms-patches/WorldBorder.patch @@ -8,7 +8,7 @@ public WorldBorder() {} -@@ -124,6 +125,7 @@ +@@ -128,6 +129,7 @@ } public void a(IWorldBorderListener iworldborderlistener) { diff --git a/nms-patches/WorldData.patch b/nms-patches/WorldData.patch index 2a60109879..7519982eb3 100644 --- a/nms-patches/WorldData.patch +++ b/nms-patches/WorldData.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/server/WorldData.java +++ b/net/minecraft/server/WorldData.java @@ -11,6 +11,11 @@ - import java.util.Set; + import java.util.UUID; import java.util.Map.Entry; import javax.annotation.Nullable; +// CraftBukkit start @@ -12,31 +12,23 @@ public class WorldData { -@@ -64,6 +69,7 @@ - private final Map T; - private NBTTagCompound U; - private final GameRules V; +@@ -68,6 +73,7 @@ + private UUID X; + private final GameRules Y; + private final CustomFunctionCallbackTimerQueue Z; + public WorldServer world; // CraftBukkit protected WorldData() { this.f = WorldType.NORMAL; -@@ -304,6 +310,7 @@ - nbttagcompound2.setBoolean("Snapshot", false); - nbttagcompound.set("Version", nbttagcompound2); - nbttagcompound.setInt("DataVersion", 1631); -+ if (org.bukkit.craftbukkit.util.CraftMagicNumbers.INSTANCE.getDataVersion() != 1631) throw new AssertionError(); // CraftBukkit - sentinel - nbttagcompound.setLong("RandomSeed", this.e); - nbttagcompound.setString("generatorName", this.f.b()); - nbttagcompound.setInt("generatorVersion", this.f.getVersion()); -@@ -389,6 +396,7 @@ - nbttagcompound.set("CustomBossEvents", this.U); +@@ -419,6 +425,7 @@ + nbttagcompound.setString("WanderingTraderId", this.X.toString()); } + nbttagcompound.setString("Bukkit.Version", Bukkit.getName() + "/" + Bukkit.getVersion() + "/" + Bukkit.getBukkitVersion()); // CraftBukkit } public long getSeed() { -@@ -478,6 +486,16 @@ +@@ -508,6 +515,16 @@ } public void setThundering(boolean flag) { @@ -53,7 +45,7 @@ this.z = flag; } -@@ -494,6 +512,16 @@ +@@ -524,6 +541,16 @@ } public void setStorm(boolean flag) { @@ -70,22 +62,22 @@ this.x = flag; } -@@ -643,6 +671,12 @@ +@@ -673,6 +700,12 @@ public void setDifficulty(EnumDifficulty enumdifficulty) { this.G = enumdifficulty; + // CraftBukkit start + PacketPlayOutServerDifficulty packet = new PacketPlayOutServerDifficulty(this.getDifficulty(), this.isDifficultyLocked()); -+ for (EntityPlayer player : (java.util.List) (java.util.List) world.players) { ++ for (EntityPlayer player : (java.util.List) (java.util.List) world.getPlayers()) { + player.playerConnection.sendPacket(packet); + } + // CraftBukkit end } public boolean isDifficultyLocked() { -@@ -723,4 +757,12 @@ - public void c(@Nullable NBTTagCompound nbttagcompound) { - this.U = nbttagcompound; +@@ -777,4 +810,12 @@ + public void a(UUID uuid) { + this.X = uuid; } + + // CraftBukkit start - Check if the name stored in NBT is the correct one diff --git a/nms-patches/WorldGenGroundBush.patch b/nms-patches/WorldGenGroundBush.patch index 4afb31ce10..30ce0ce6fe 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 @@ +@@ -43,7 +43,12 @@ } } } diff --git a/nms-patches/WorldGenMegaTreeProvider.patch b/nms-patches/WorldGenMegaTreeProvider.patch index 74037fdd08..e632efeccd 100644 --- a/nms-patches/WorldGenMegaTreeProvider.patch +++ b/nms-patches/WorldGenMegaTreeProvider.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/server/WorldGenMegaTreeProvider.java +++ b/net/minecraft/server/WorldGenMegaTreeProvider.java -@@ -28,6 +28,7 @@ +@@ -29,6 +29,7 @@ if (worldgentreeabstract == null) { return false; } else { + setTreeType(worldgentreeabstract); // CraftBukkit IBlockData iblockdata1 = Blocks.AIR.getBlockData(); - generatoraccess.setTypeAndData(blockposition.a(i, 0, j), iblockdata1, 4); + generatoraccess.setTypeAndData(blockposition.b(i, 0, j), iblockdata1, 4); diff --git a/nms-patches/WorldGenVillagePieces.patch b/nms-patches/WorldGenVillagePieces.patch deleted file mode 100644 index fb1f1e8d76..0000000000 --- a/nms-patches/WorldGenVillagePieces.patch +++ /dev/null @@ -1,19 +0,0 @@ ---- a/net/minecraft/server/WorldGenVillagePieces.java -+++ b/net/minecraft/server/WorldGenVillagePieces.java -@@ -1646,14 +1646,14 @@ - entityzombievillager.prepare(generatoraccess.getDamageScaler(new BlockPosition(entityzombievillager)), (GroupDataEntity) null, (NBTTagCompound) null); - entityzombievillager.setProfession(this.c(i1, 0)); - entityzombievillager.di(); -- generatoraccess.addEntity(entityzombievillager); -+ generatoraccess.addEntity(entityzombievillager, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CHUNK_GEN); // CraftBukkit - add SpawnReason - } else { - EntityVillager entityvillager = new EntityVillager(generatoraccess.getMinecraftWorld()); - - entityvillager.setPositionRotation((double) j1 + 0.5D, (double) k1, (double) l1 + 0.5D, 0.0F, 0.0F); - entityvillager.setProfession(this.c(i1, generatoraccess.m().nextInt(6))); - entityvillager.a(generatoraccess.getDamageScaler(new BlockPosition(entityvillager)), (GroupDataEntity) null, (NBTTagCompound) null, false); -- generatoraccess.addEntity(entityvillager); -+ generatoraccess.addEntity(entityvillager, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CHUNK_GEN); // CraftBukkit - add SpawnReason - } - } - diff --git a/nms-patches/WorldGenWitchHut.patch b/nms-patches/WorldGenWitchHut.patch index e3b94d8727..81d592ebce 100644 --- a/nms-patches/WorldGenWitchHut.patch +++ b/nms-patches/WorldGenWitchHut.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/server/WorldGenWitchHut.java +++ b/net/minecraft/server/WorldGenWitchHut.java -@@ -86,7 +86,7 @@ - entitywitch.di(); +@@ -85,7 +85,7 @@ + entitywitch.setPersistent(); entitywitch.setPositionRotation((double) j + 0.5D, (double) i, (double) k + 0.5D, 0.0F, 0.0F); - entitywitch.prepare(generatoraccess.getDamageScaler(new BlockPosition(j, i, k)), (GroupDataEntity) null, (NBTTagCompound) null); + entitywitch.prepare(generatoraccess, generatoraccess.getDamageScaler(new BlockPosition(j, i, k)), EnumMobSpawn.STRUCTURE, (GroupDataEntity) null, (NBTTagCompound) null); - generatoraccess.addEntity(entitywitch); + generatoraccess.addEntity(entitywitch, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CHUNK_GEN); // CraftBukkit - add SpawnReason } diff --git a/nms-patches/WorldManager.patch b/nms-patches/WorldManager.patch deleted file mode 100644 index 5adb0d9b27..0000000000 --- a/nms-patches/WorldManager.patch +++ /dev/null @@ -1,48 +0,0 @@ ---- a/net/minecraft/server/WorldManager.java -+++ b/net/minecraft/server/WorldManager.java -@@ -35,7 +35,8 @@ - } - - public void a(@Nullable 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(), new PacketPlayOutNamedSoundEffect(soundeffect, soundcategory, 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(soundeffect, soundcategory, d0, d1, d2, f, f1)); - } - - public void a(int i, int j, int k, int l, int i1, int j1) {} -@@ -49,7 +50,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.getDimensionManager(), 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) { -@@ -59,6 +61,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.getEntity(i); -+ if (entity instanceof EntityHuman) entityhuman = (EntityHuman) entity; -+ // CraftBukkit end -+ - while (iterator.hasNext()) { - EntityPlayer entityplayer = (EntityPlayer) iterator.next(); - -@@ -67,6 +75,12 @@ - double d1 = (double) blockposition.getY() - entityplayer.locY; - double d2 = (double) blockposition.getZ() - entityplayer.locZ; - -+ // CraftBukkit start -+ if (entityhuman != null && entityhuman instanceof EntityPlayer && !entityplayer.getBukkitEntity().canSee(((EntityPlayer) entityhuman).getBukkitEntity())) { -+ continue; -+ } -+ // CraftBukkit end -+ - if (d0 * d0 + d1 * d1 + d2 * d2 < 1024.0D) { - entityplayer.playerConnection.sendPacket(new PacketPlayOutBlockBreakAnimation(i, blockposition, j)); - } diff --git a/nms-patches/WorldMap.patch b/nms-patches/WorldMap.patch index 755cb7c40b..03f26f2f03 100644 --- a/nms-patches/WorldMap.patch +++ b/nms-patches/WorldMap.patch @@ -16,9 +16,9 @@ public class WorldMap extends PersistentBase { public int centerX; -@@ -22,8 +31,18 @@ - public Map decorations = Maps.newLinkedHashMap(); - private final Map l = Maps.newHashMap(); +@@ -23,8 +32,18 @@ + public final Map decorations = Maps.newLinkedHashMap(); + private final Map m = Maps.newHashMap(); + // CraftBukkit start + public final CraftMapView mapView; @@ -35,9 +35,9 @@ } public void a(int i, int j, int k, boolean flag, boolean flag1, DimensionManager dimensionmanager) { -@@ -45,7 +64,31 @@ - } +@@ -47,7 +66,31 @@ + @Override public void a(NBTTagCompound nbttagcompound) { - this.map = DimensionManager.a(nbttagcompound.getInt("dimension")); + // CraftBukkit start @@ -55,7 +55,7 @@ + if (world == null) { + /* All Maps which do not have their valid world loaded are set to a dimension which hopefully won't be reached. + This is to prevent them being corrupted with the wrong map data. */ -+ this.map = new DimensionManager(127, null, null, null); ++ this.map = new DimensionManager(127, null, null, null, false); + } else { + this.map = world.getHandle().dimension; + } @@ -68,9 +68,9 @@ this.centerX = nbttagcompound.getInt("xCenter"); this.centerZ = nbttagcompound.getInt("zCenter"); this.scale = (byte) MathHelper.clamp(nbttagcompound.getByte("scale"), 0, 4); -@@ -77,6 +120,25 @@ - } +@@ -81,6 +124,25 @@ + @Override public NBTTagCompound b(NBTTagCompound nbttagcompound) { + // CraftBukkit start + if (this.map.getDimensionID() >= CraftWorld.CUSTOM_DIMENSION_OFFSET) { @@ -94,7 +94,7 @@ nbttagcompound.setInt("dimension", this.map.getDimensionID()); nbttagcompound.setInt("xCenter", this.centerX); nbttagcompound.setInt("zCenter", this.centerZ); -@@ -357,12 +419,25 @@ +@@ -372,12 +434,25 @@ @Nullable public Packet a(ItemStack itemstack) { @@ -112,11 +112,11 @@ + if (this.d) { this.d = false; -- return new PacketPlayOutMap(ItemWorldMap.e(itemstack), WorldMap.this.scale, WorldMap.this.track, WorldMap.this.decorations.values(), WorldMap.this.colors, this.e, this.f, this.g + 1 - this.e, this.h + 1 - this.f); -+ return new PacketPlayOutMap(ItemWorldMap.e(itemstack), WorldMap.this.scale, WorldMap.this.track, icons, render.buffer, this.e, this.f, this.g + 1 - this.e, this.h + 1 - this.f); +- return new PacketPlayOutMap(ItemWorldMap.e(itemstack), WorldMap.this.scale, WorldMap.this.track, WorldMap.this.locked, WorldMap.this.decorations.values(), WorldMap.this.colors, this.e, this.f, this.g + 1 - this.e, this.h + 1 - this.f); ++ return new PacketPlayOutMap(ItemWorldMap.e(itemstack), WorldMap.this.scale, WorldMap.this.track, WorldMap.this.locked, 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(ItemWorldMap.e(itemstack), WorldMap.this.scale, WorldMap.this.track, WorldMap.this.decorations.values(), WorldMap.this.colors, 0, 0, 0, 0) : null; -+ return this.i++ % 5 == 0 ? new PacketPlayOutMap(ItemWorldMap.e(itemstack), WorldMap.this.scale, WorldMap.this.track, icons, render.buffer, 0, 0, 0, 0) : null; +- return this.i++ % 5 == 0 ? new PacketPlayOutMap(ItemWorldMap.e(itemstack), WorldMap.this.scale, WorldMap.this.track, WorldMap.this.locked, WorldMap.this.decorations.values(), WorldMap.this.colors, 0, 0, 0, 0) : null; ++ return this.i++ % 5 == 0 ? new PacketPlayOutMap(ItemWorldMap.e(itemstack), WorldMap.this.scale, WorldMap.this.track, WorldMap.this.locked, icons, render.buffer, 0, 0, 0, 0) : null; } + // CraftBukkit end } diff --git a/nms-patches/WorldNBTStorage.patch b/nms-patches/WorldNBTStorage.patch index 6854bdc883..79dfb00c97 100644 --- a/nms-patches/WorldNBTStorage.patch +++ b/nms-patches/WorldNBTStorage.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/WorldNBTStorage.java +++ b/net/minecraft/server/WorldNBTStorage.java -@@ -14,6 +14,11 @@ +@@ -13,6 +13,11 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -9,10 +9,10 @@ +import org.bukkit.craftbukkit.entity.CraftPlayer; +// CraftBukkit end + - public class WorldNBTStorage implements IDataManager, IPlayerFileData { + public class WorldNBTStorage implements IPlayerFileData { private static final Logger b = LogManager.getLogger(); -@@ -23,6 +28,7 @@ +@@ -22,6 +27,7 @@ private final String f; private final DefinedStructureManager g; protected final DataFixer a; @@ -20,7 +20,7 @@ public WorldNBTStorage(File file, String s, @Nullable MinecraftServer minecraftserver, DataFixer datafixer) { this.a = datafixer; -@@ -167,6 +173,16 @@ +@@ -165,6 +171,16 @@ } if (nbttagcompound != null) { @@ -37,7 +37,7 @@ int i = nbttagcompound.hasKeyOfType("DataVersion", 3) ? nbttagcompound.getInt("DataVersion") : -1; entityhuman.f(GameProfileSerializer.a(this.a, DataFixTypes.PLAYER, nbttagcompound, i)); -@@ -175,6 +191,22 @@ +@@ -173,6 +189,22 @@ return nbttagcompound; } @@ -57,11 +57,11 @@ + } + // CraftBukkit end + - public IPlayerFileData getPlayerFileData() { - return this; - } -@@ -211,4 +243,50 @@ - public DataFixer i() { + public String[] getSeenPlayers() { + String[] astring = this.playerDir.list(); + +@@ -196,4 +228,50 @@ + public DataFixer getDataFixer() { return this.a; } + diff --git a/nms-patches/WorldProviderHell.patch b/nms-patches/WorldProviderHell.patch index f3660cd7f0..5be0a8903c 100644 --- a/nms-patches/WorldProviderHell.patch +++ b/nms-patches/WorldProviderHell.patch @@ -1,13 +1,14 @@ --- a/net/minecraft/server/WorldProviderHell.java +++ b/net/minecraft/server/WorldProviderHell.java -@@ -56,11 +56,11 @@ - public WorldBorder getWorldBorder() { +@@ -63,12 +63,12 @@ return new WorldBorder() { + @Override public double getCenterX() { - return super.getCenterX() / 8.0D; + return super.getCenterX(); // CraftBukkit } + @Override public double getCenterZ() { - return super.getCenterZ() / 8.0D; + return super.getCenterZ(); // CraftBukkit diff --git a/nms-patches/WorldServer.patch b/nms-patches/WorldServer.patch index 7ab5f93c49..5876f285e2 100644 --- a/nms-patches/WorldServer.patch +++ b/nms-patches/WorldServer.patch @@ -1,81 +1,69 @@ --- a/net/minecraft/server/WorldServer.java +++ b/net/minecraft/server/WorldServer.java -@@ -17,6 +17,18 @@ +@@ -31,6 +31,21 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +// CraftBukkit start +import java.util.logging.Level; ++import org.bukkit.Bukkit; + +import org.bukkit.WeatherType; +import org.bukkit.block.BlockState; ++import org.bukkit.craftbukkit.event.CraftEventFactory; +import org.bukkit.craftbukkit.util.HashTreeSet; + +import org.bukkit.event.block.BlockFormEvent; -+import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; ++import org.bukkit.event.entity.CreatureSpawnEvent; ++import org.bukkit.event.server.MapInitializeEvent; +import org.bukkit.event.weather.LightningStrikeEvent; +// CraftBukkit end + - public class WorldServer extends World implements IAsyncTaskHandler { + public class WorldServer extends World { - private static final Logger a = LogManager.getLogger(); -@@ -35,8 +47,16 @@ - ObjectLinkedOpenHashSet d; - private boolean P; + private static final Logger v = LogManager.getLogger(); +@@ -56,12 +71,31 @@ + @Nullable + private final MobSpawnerTrader mobSpawnerTrader; -- public WorldServer(MinecraftServer minecraftserver, IDataManager idatamanager, PersistentCollection persistentcollection, WorldData worlddata, DimensionManager dimensionmanager, MethodProfiler methodprofiler) { -- super(idatamanager, persistentcollection, worlddata, dimensionmanager.e(), methodprofiler, false); +- public WorldServer(MinecraftServer minecraftserver, Executor executor, WorldNBTStorage worldnbtstorage, WorldData worlddata, DimensionManager dimensionmanager, GameProfilerFiller gameprofilerfiller, WorldLoadListener worldloadlistener) { + // CraftBukkit start + public final DimensionManager dimension; ++ private int tickPosition; + + // Add env and gen to constructor -+ public WorldServer(MinecraftServer minecraftserver, IDataManager idatamanager, PersistentCollection persistentcollection, WorldData worlddata, DimensionManager dimensionmanager, MethodProfiler methodprofiler, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen) { -+ super(idatamanager, persistentcollection, worlddata, DimensionManager.a(env.getId()).e(), methodprofiler, false, gen, env); ++ public WorldServer(MinecraftServer minecraftserver, Executor executor, WorldNBTStorage worldnbtstorage, WorldData worlddata, DimensionManager dimensionmanager, GameProfilerFiller gameprofilerfiller, WorldLoadListener worldloadlistener, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen) { + super(worlddata, dimensionmanager, (world, worldprovider) -> { +- return new ChunkProviderServer((WorldServer) world, worldnbtstorage.getDirectory(), worldnbtstorage.getDataFixer(), worldnbtstorage.f(), executor, worldprovider.getChunkGenerator(), minecraftserver.getPlayerList().getViewDistance(), minecraftserver.getPlayerList().getViewDistance() - 2, worldloadlistener, () -> { ++ // CraftBukkit start ++ ChunkGenerator chunkGenerator; ++ ++ if (gen != null) { ++ chunkGenerator = new org.bukkit.craftbukkit.generator.CustomChunkGenerator(world, world.getSeed(), gen); ++ } else { ++ chunkGenerator = worldprovider.getChunkGenerator(); ++ } ++ ++ return new ChunkProviderServer((WorldServer) world, worldnbtstorage.getDirectory(), worldnbtstorage.getDataFixer(), worldnbtstorage.f(), executor, chunkGenerator, minecraftserver.getPlayerList().getViewDistance(), minecraftserver.getPlayerList().getViewDistance() - 2, worldloadlistener, () -> { + return minecraftserver.getWorldServer(DimensionManager.OVERWORLD).getWorldPersistentData(); + }); +- }, gameprofilerfiller, false); ++ // CraftBukkit end ++ }, gameprofilerfiller, false, gen, env); + this.dimension = dimensionmanager; + this.pvpMode = minecraftserver.getPVP(); + worlddata.world = this; + // CraftBukkit end this.nextTickListBlock = new TickListServer<>(this, (block) -> { return block == null || block.getBlockData().isAir(); - }, IRegistry.BLOCK::getKey, IRegistry.BLOCK::getOrDefault, this::b); -@@ -50,7 +70,7 @@ - this.manager = new PlayerChunkMap(this); - this.worldProvider.a((World) this); - this.chunkProvider = this.r(); -- this.portalTravelAgent = new PortalTravelAgent(this); -+ this.portalTravelAgent = new org.bukkit.craftbukkit.CraftTravelAgent(this); // CraftBukkit - this.P(); - this.Q(); - this.getWorldBorder().a(minecraftserver.au()); -@@ -68,6 +88,7 @@ - this.villages.a((World) this); + }, IRegistry.BLOCK::getKey, IRegistry.BLOCK::get, this::b); +@@ -85,7 +119,123 @@ } -+ if (getServer().getScoreboardManager() == null) { // CraftBukkit - PersistentScoreboard persistentscoreboard = (PersistentScoreboard) this.a(DimensionManager.OVERWORLD, PersistentScoreboard::new, "scoreboard"); - - if (persistentscoreboard == null) { -@@ -77,6 +98,7 @@ - - persistentscoreboard.a((Scoreboard) this.server.getScoreboard()); - this.server.getScoreboard().a((Runnable) (new RunnableSaveScoreboard(persistentscoreboard))); -+ } // CraftBukkit - this.getWorldBorder().setCenter(this.worldData.B(), this.worldData.C()); - this.getWorldBorder().setDamageAmount(this.worldData.H()); - this.getWorldBorder().setDamageBuffer(this.worldData.G()); -@@ -88,9 +110,130 @@ - this.getWorldBorder().setSize(this.worldData.D()); - } - -+ // CraftBukkit start -+ if (generator != null) { -+ getWorld().getPopulators().addAll(generator.getDefaultPopulators(getWorld())); -+ } -+ // CraftBukkit end + this.mobSpawnerTrader = this.worldProvider.getDimensionManager() == DimensionManager.OVERWORLD ? new MobSpawnerTrader(this) : null; ++ this.getServer().addWorld(this.getWorld()); // CraftBukkit ++ } + - return this; - } - + // CraftBukkit start + @Override + public TileEntity getTileEntity(BlockPosition pos) { @@ -106,7 +94,7 @@ + if (!(result instanceof TileEntityMobSpawner)) { + result = fixTileEntity(pos, type, result); + } -+ } else if ((type == Blocks.SIGN) || (type == Blocks.WALL_SIGN)) { ++ } else if (TagsBlock.SIGNS.isTagged(type)) { + if (!(result instanceof TileEntitySign)) { + result = fixTileEntity(pos, type, result); + } @@ -180,7 +168,7 @@ + + "Bukkit will attempt to fix this, but there may be additional damage that we cannot recover.", new Object[]{pos.getX(), pos.getY(), pos.getZ(), type, found}); + + if (type instanceof ITileEntity) { -+ TileEntity replacement = ((ITileEntity) type).a(this); ++ TileEntity replacement = ((ITileEntity) type).createTile(this); + replacement.world = this; + this.setTileEntity(pos, replacement); + return replacement; @@ -188,50 +176,141 @@ + this.getServer().getLogger().severe("Don't know how to fix for this type... Can't do anything! :("); + return found; + } -+ } -+ // CraftBukkit end -+ - public void doTick(BooleanSupplier booleansupplier) { - this.P = true; - super.doTick(booleansupplier); -@@ -110,9 +253,12 @@ - } - - this.methodProfiler.enter("spawner"); -- if (this.getGameRules().getBoolean("doMobSpawning") && this.worldData.getType() != WorldType.DEBUG_ALL_BLOCK_STATES) { -- this.spawnerCreature.a(this, this.allowMonsters, this.allowAnimals, this.worldData.getTime() % 400L == 0L); -- this.getChunkProvider().a(this, this.allowMonsters, this.allowAnimals); -+ // CraftBukkit start - Only call spawner if we have players online and the world allows for mobs or animals -+ long time = this.worldData.getTime(); -+ if (this.getGameRules().getBoolean("doMobSpawning") && this.worldData.getType() != WorldType.DEBUG_ALL_BLOCK_STATES && (this.allowMonsters || this.allowAnimals) && (this instanceof WorldServer && this.players.size() > 0)) { -+ this.spawnerCreature.a(this, this.allowMonsters && (this.ticksPerMonsterSpawns != 0 && time % this.ticksPerMonsterSpawns == 0L), this.allowAnimals && (this.ticksPerAnimalSpawns != 0 && time % this.ticksPerAnimalSpawns == 0L), this.worldData.getTime() % 400L == 0L); -+ this.getChunkProvider().a(this, this.allowMonsters && (this.ticksPerMonsterSpawns != 0 && time % this.ticksPerMonsterSpawns == 0L), this.allowAnimals && (this.ticksPerAnimalSpawns != 0 && time % this.ticksPerAnimalSpawns == 0L)); -+ // CraftBukkit end - } - - this.methodProfiler.exitEnter("chunkSource"); -@@ -142,6 +288,8 @@ - this.methodProfiler.exit(); - this.an(); - this.P = false; -+ -+ this.getWorld().processChunkGC(); // CraftBukkit } ++ // CraftBukkit end - public boolean j_() { -@@ -173,7 +321,7 @@ + public void doTick(BooleanSupplier booleansupplier) { + GameProfilerFiller gameprofilerfiller = this.getMethodProfiler(); +@@ -161,6 +311,7 @@ + this.m = MathHelper.a(this.m, 0.0F, 1.0F); + } - if (entityhuman.isSpectator()) { ++ /* CraftBukkit start + if (this.l != this.m) { + this.server.getPlayerList().a((Packet) (new PacketPlayOutGameStateChange(7, this.m)), this.worldProvider.getDimensionManager()); + } +@@ -179,13 +330,34 @@ + this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(7, this.m)); + this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(8, this.o)); + } ++ // */ ++ for (int idx = 0; idx < this.players.size(); ++idx) { ++ if (((EntityPlayer) this.players.get(idx)).world == this) { ++ ((EntityPlayer) this.players.get(idx)).tickWeather(); ++ } ++ } ++ ++ if (flag != this.isRaining()) { ++ // Only send weather packets to those affected ++ for (int idx = 0; idx < this.players.size(); ++idx) { ++ if (((EntityPlayer) this.players.get(idx)).world == this) { ++ ((EntityPlayer) this.players.get(idx)).setPlayerWeather((!flag ? WeatherType.DOWNFALL : WeatherType.CLEAR), false); ++ } ++ } ++ } ++ for (int idx = 0; idx < this.players.size(); ++idx) { ++ if (((EntityPlayer) this.players.get(idx)).world == this) { ++ ((EntityPlayer) this.players.get(idx)).updateWeather(this.l, this.m, this.n, this.o); ++ } ++ } ++ // CraftBukkit end + + if (this.getWorldData().isHardcore() && this.getDifficulty() != EnumDifficulty.HARD) { + this.getWorldData().setDifficulty(EnumDifficulty.HARD); + } + + if (this.D && this.players.stream().noneMatch((entityplayer) -> { +- return !entityplayer.isSpectator() && !entityplayer.isDeeplySleeping(); ++ return !entityplayer.isSpectator() && !entityplayer.isDeeplySleeping() && !entityplayer.fauxSleeping; // CraftBukkit + })) { + this.D = false; + if (this.getGameRules().getBoolean("doDaylightCycle")) { +@@ -226,7 +398,7 @@ + this.ae(); + this.ticking = false; + gameprofilerfiller.exitEnter("entities"); +- boolean flag3 = !this.players.isEmpty() || !this.getForceLoadedChunks().isEmpty(); ++ boolean flag3 = true || !this.players.isEmpty() || !this.getForceLoadedChunks().isEmpty(); // CraftBukkit - this prevents entity cleanup, other issues on servers with no players + + if (flag3) { + this.resetEmptyTime(); +@@ -240,6 +412,11 @@ + + for (i = 0; i < this.globalEntityList.size(); ++i) { + entity = (Entity) this.globalEntityList.get(i); ++ // CraftBukkit start - Fixed an NPE ++ if (entity == null) { ++ continue; ++ } ++ // CraftBukkit end + this.a((entity1) -> { + ++entity1.ticksLived; + entity1.tick(); +@@ -258,6 +435,7 @@ + Entity entity1 = (Entity) entry.getValue(); + Entity entity2 = entity1.getVehicle(); + ++ /* CraftBukkit start - We prevent spawning in general, so this butchering is not needed + if (!this.server.getSpawnAnimals() && (entity1 instanceof EntityAnimal || entity1 instanceof EntityWaterAnimal)) { + entity1.die(); + } +@@ -265,6 +443,7 @@ + if (!this.server.getSpawnNPCs() && entity1 instanceof NPC) { + entity1.die(); + } ++ // CraftBukkit end */ + + if (entity2 != null) { + if (!entity2.dead && entity2.w(entity1)) { +@@ -325,10 +504,10 @@ + entityhorseskeleton.r(true); + entityhorseskeleton.setAgeRaw(0); + entityhorseskeleton.setPosition((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ()); +- this.addEntity(entityhorseskeleton); ++ this.addEntity(entityhorseskeleton, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING); // CraftBukkit + } + +- this.strikeLightning(new EntityLightning(this, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, flag1)); ++ this.strikeLightning(new EntityLightning(this, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, flag1), org.bukkit.event.weather.LightningStrikeEvent.Cause.WEATHER); // CraftBukkit + } + } + +@@ -339,11 +518,11 @@ + BiomeBase biomebase = this.getBiome(blockposition); + + if (biomebase.a((IWorldReader) this, blockposition1)) { +- this.setTypeUpdate(blockposition1, Blocks.ICE.getBlockData()); ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this, blockposition1, Blocks.ICE.getBlockData(), null); // CraftBukkit + } + + if (flag && biomebase.b(this, blockposition)) { +- this.setTypeUpdate(blockposition, Blocks.SNOW.getBlockData()); ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this, blockposition, Blocks.SNOW.getBlockData(), null); // CraftBukkit + } + + if (flag && this.getBiome(blockposition1).b() == BiomeBase.Precipitation.RAIN) { +@@ -390,7 +569,7 @@ + protected BlockPosition a(BlockPosition blockposition) { + BlockPosition blockposition1 = this.getHighestBlockYAt(HeightMap.Type.MOTION_BLOCKING, blockposition); + AxisAlignedBB axisalignedbb = (new AxisAlignedBB(blockposition1, new BlockPosition(blockposition1.getX(), this.getHeight(), blockposition1.getZ()))).g(3.0D); +- List list = this.a(EntityLiving.class, axisalignedbb, (entityliving) -> { ++ List list = this.a(EntityLiving.class, axisalignedbb, (java.util.function.Predicate) (entityliving) -> { // CraftBukkit - decompile error + return entityliving != null && entityliving.isAlive() && this.f(entityliving.getChunkCoordinates()); + }); + +@@ -421,7 +600,7 @@ + + if (entityplayer.isSpectator()) { ++i; -- } else if (entityhuman.isSleeping()) { -+ } else if (entityhuman.isSleeping() || entityhuman.fauxSleeping) { +- } else if (entityplayer.isSleeping()) { ++ } else if (entityplayer.isSleeping() || entityplayer.fauxSleeping) { // CraftBukkit ++j; } } -@@ -205,25 +353,46 @@ +@@ -437,10 +616,22 @@ } - private void b() { + private void clearWeather() { - this.worldData.setWeatherDuration(0); + // CraftBukkit start this.worldData.setStorm(false); @@ -252,118 +331,16 @@ + // CraftBukkit end } - public boolean everyoneDeeplySleeping() { - if (this.J && !this.isClientSide) { - Iterator iterator = this.players.iterator(); - -+ // CraftBukkit - This allows us to assume that some people are in bed but not really, allowing time to pass in spite of AFKers -+ boolean foundActualSleepers = false; -+ - EntityHuman entityhuman; - - do { - if (!iterator.hasNext()) { -- return true; -+ return foundActualSleepers; - } - - entityhuman = (EntityHuman) iterator.next(); -- } while (entityhuman.isSpectator() || entityhuman.isDeeplySleeping()); -+ -+ // CraftBukkit start -+ if (entityhuman.isDeeplySleeping()) { -+ foundActualSleepers = true; -+ } -+ } while (!entityhuman.isSpectator() || entityhuman.isDeeplySleeping() || entityhuman.fauxSleeping); -+ // CraftBukkit end - - return false; - } else { -@@ -298,10 +467,10 @@ - entityhorseskeleton.s(true); - entityhorseskeleton.setAgeRaw(0); - entityhorseskeleton.setPosition((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ()); -- this.addEntity(entityhorseskeleton); -+ this.addEntity(entityhorseskeleton, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING); // CraftBukkit - } - -- this.strikeLightning(new EntityLightning(this, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, flag2)); -+ this.strikeLightning(new EntityLightning(this, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, flag2), org.bukkit.event.weather.LightningStrikeEvent.Cause.WEATHER); // CraftBukkit - } - } - -@@ -314,11 +483,11 @@ - BiomeBase biomebase = this.getBiome(blockposition); - - if (biomebase.a((IWorldReader) this, blockposition1)) { -- this.setTypeUpdate(blockposition1, Blocks.ICE.getBlockData()); -+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this, blockposition1, Blocks.ICE.getBlockData(), null); // CraftBukkit - } - - if (flag && biomebase.b(this, blockposition)) { -- this.setTypeUpdate(blockposition, Blocks.SNOW.getBlockData()); -+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this, blockposition, Blocks.SNOW.getBlockData(), null); // CraftBukkit - } - - if (flag && this.getBiome(blockposition1).c() == BiomeBase.Precipitation.RAIN) { -@@ -367,7 +536,7 @@ - protected BlockPosition a(BlockPosition blockposition) { - BlockPosition blockposition1 = this.getHighestBlockYAt(HeightMap.Type.MOTION_BLOCKING, blockposition); - AxisAlignedBB axisalignedbb = (new AxisAlignedBB(blockposition1, new BlockPosition(blockposition1.getX(), this.getHeight(), blockposition1.getZ()))).g(3.0D); -- List list = this.a(EntityLiving.class, axisalignedbb, (entityliving) -> { -+ List list = this.a(EntityLiving.class, axisalignedbb, (java.util.function.Predicate) (entityliving) -> { // CraftBukkit - decompile error - return entityliving != null && entityliving.isAlive() && this.e(entityliving.getChunkCoordinates()); - }); - -@@ -383,7 +552,7 @@ - } - - 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++ >= 300) { - return; + public void resetEmptyTime() { +@@ -478,6 +669,7 @@ + return IRegistry.ENTITY_TYPE.getKey(entity.getEntityType()).toString(); + }); + entity.tick(); ++ entity.postTick(); // CraftBukkit + this.getMethodProfiler().exit(); } -@@ -472,6 +641,7 @@ - } - -+ /* CraftBukkit start - We prevent spawning in general, so this butchering is not needed - public void entityJoinedWorld(Entity entity, boolean flag) { - if (!this.getSpawnAnimals() && (entity instanceof EntityAnimal || entity instanceof EntityWaterAnimal)) { - entity.die(); -@@ -483,6 +653,7 @@ - - super.entityJoinedWorld(entity, flag); - } -+ // CraftBukkit end */ - - private boolean getSpawnNPCs() { - return this.server.getSpawnNPCs(); -@@ -495,7 +666,21 @@ - protected IChunkProvider r() { - IChunkLoader ichunkloader = this.dataManager.createChunkLoader(this.worldProvider); - -- return new ChunkProviderServer(this, ichunkloader, this.worldProvider.getChunkGenerator(), this.server); -+ // CraftBukkit start -+ org.bukkit.craftbukkit.generator.InternalChunkGenerator gen; -+ -+ if (this.generator != null) { -+ gen = new org.bukkit.craftbukkit.generator.CustomChunkGenerator(this, this.getSeed(), this.generator); -+ } else if (this.worldProvider instanceof WorldProviderHell) { -+ gen = new org.bukkit.craftbukkit.generator.NetherChunkGenerator(this, this.getSeed()); -+ } else if (this.worldProvider instanceof WorldProviderTheEnd) { -+ gen = new org.bukkit.craftbukkit.generator.SkyLandsChunkGenerator(this, this.getSeed()); -+ } else { -+ gen = new org.bukkit.craftbukkit.generator.NormalChunkGenerator(this, this.getSeed()); -+ } -+ -+ return new ChunkProviderServer(this, ichunkloader, gen, this.server); -+ // CraftBukkit end - } - - public boolean a(EntityHuman entityhuman, BlockPosition blockposition) { -@@ -554,6 +739,22 @@ +@@ -563,6 +755,22 @@ BlockPosition blockposition = worldchunkmanager.a(0, 0, 256, list, random); ChunkCoordIntPair chunkcoordintpair = blockposition == null ? new ChunkCoordIntPair(0, 0) : new ChunkCoordIntPair(blockposition); @@ -384,109 +361,197 @@ + // CraftBukkit end + if (blockposition == null) { - WorldServer.a.warn("Unable to find spawn biome"); + WorldServer.v.warn("Unable to find spawn biome"); } -@@ -629,6 +830,7 @@ +@@ -638,6 +846,7 @@ ChunkProviderServer chunkproviderserver = this.getChunkProvider(); - if (chunkproviderserver.d()) { + if (!flag1) { + org.bukkit.Bukkit.getPluginManager().callEvent(new org.bukkit.event.world.WorldSaveEvent(getWorld())); // CraftBukkit if (iprogressupdate != null) { iprogressupdate.a(new ChatMessage("menu.savingLevel", new Object[0])); } -@@ -639,7 +841,8 @@ - } +@@ -716,8 +925,16 @@ - chunkproviderserver.a(flag); -- List list = Lists.newArrayList(chunkproviderserver.a()); -+ // CraftBukkit - ArrayList -> Collection -+ java.util.Collection list = chunkproviderserver.a(); - Iterator iterator = list.iterator(); + while (objectiterator.hasNext()) { + Entity entity = (Entity) objectiterator.next(); ++ // CraftBukkit start - Split out persistent check, don't apply it to special persistent mobs ++ if (entity instanceof EntityInsentient) { ++ EntityInsentient entityinsentient = (EntityInsentient) entity; ++ if (entityinsentient.isTypeNotPersistent(0) && entityinsentient.isPersistent()) { ++ continue; ++ } ++ } - while (iterator.hasNext()) { -@@ -687,9 +890,13 @@ - this.h().a(); - } +- if (!(entity instanceof EntityInsentient) || !((EntityInsentient) entity).isPersistent()) { ++ if (true || !(entity instanceof EntityInsentient) || !((EntityInsentient) entity).isPersistent()) { ++ // CraftBukkit end + EnumCreatureType enumcreaturetype = entity.getEntityType().d(); -- public boolean addEntity(Entity entity) { -- return this.j(entity) ? super.addEntity(entity) : false; -+ // CraftBukkit start -+ public boolean addEntity(Entity entity, SpawnReason spawnReason) { // Changed signature, added SpawnReason -+ // World.addEntity(Entity) will call this, and we still want to perform -+ // existing entity checking when it's called with a SpawnReason -+ return this.j(entity) ? super.addEntity(entity, spawnReason) : false; - } -+ // CraftBukkit end + if (enumcreaturetype != EnumCreatureType.MISC) { +@@ -733,11 +950,24 @@ - public void a(Stream stream) { - stream.forEach((entity) -> { -@@ -703,7 +910,7 @@ - - private boolean j(Entity entity) { - if (entity.dead) { -- WorldServer.a.warn("Tried to add entity {} but it was marked as removed already", EntityTypes.getName(entity.P())); -+ // WorldServer.a.warn("Tried to add entity {} but it was marked as removed already", EntityTypes.getName(entity.P())); // CraftBukkit - return false; - } else { - UUID uuid = entity.getUniqueID(); -@@ -715,7 +922,7 @@ - this.g.remove(entity1); - } else { - if (!(entity instanceof EntityHuman)) { -- WorldServer.a.warn("Keeping entity {} that already exists with UUID {}", EntityTypes.getName(entity1.P()), uuid.toString()); -+ // WorldServer.a.warn("Keeping entity {} that already exists with UUID {}", EntityTypes.getName(entity1.P()), uuid.toString()); // CraftBukkit - return false; - } - -@@ -767,9 +974,21 @@ - - } - -+ // CraftBukkit start - public boolean strikeLightning(Entity entity) { -+ return this.strikeLightning(entity, LightningStrikeEvent.Cause.UNKNOWN); + @Override + public boolean addEntity(Entity entity) { +- return this.addEntity0(entity); ++ // CraftBukkit start ++ return this.addEntity0(entity, CreatureSpawnEvent.SpawnReason.DEFAULT); + } + -+ public boolean strikeLightning(Entity entity, LightningStrikeEvent.Cause cause) { -+ LightningStrikeEvent lightning = new LightningStrikeEvent(this.getWorld(), (org.bukkit.entity.LightningStrike) entity.getBukkitEntity(), cause); ++ @Override ++ public boolean addEntity(Entity entity, CreatureSpawnEvent.SpawnReason reason) { ++ return this.addEntity0(entity, reason); ++ // CraftBukkit end + } + + public boolean addEntitySerialized(Entity entity) { +- return this.addEntity0(entity); ++ // CraftBukkit start ++ return this.addEntitySerialized(entity, CreatureSpawnEvent.SpawnReason.DEFAULT); ++ } ++ ++ public boolean addEntitySerialized(Entity entity, CreatureSpawnEvent.SpawnReason reason) { ++ return this.addEntity0(entity, reason); ++ // CraftBukkit end + } + + public void addEntityTeleport(Entity entity) { +@@ -787,13 +1017,18 @@ + this.registerEntity(entityplayer); + } + +- private boolean addEntity0(Entity entity) { ++ // CraftBukkit start ++ private boolean addEntity0(Entity entity, CreatureSpawnEvent.SpawnReason spawnReason) { + if (entity.dead) { +- WorldServer.v.warn("Tried to add entity {} but it was marked as removed already", EntityTypes.getName(entity.getEntityType())); ++ // WorldServer.v.warn("Tried to add entity {} but it was marked as removed already", EntityTypes.getName(entity.getEntityType())); // CraftBukkit + return false; + } else if (this.isUUIDTaken(entity)) { + return false; + } else { ++ if (!CraftEventFactory.doEntityAddEventCalling(this, entity, spawnReason)) { ++ return false; ++ } ++ // CraftBukkit end + IChunkAccess ichunkaccess = this.getChunkAt(MathHelper.floor(entity.locX / 16.0D), MathHelper.floor(entity.locZ / 16.0D), ChunkStatus.FULL, entity.attachedToPlayer); + + if (!(ichunkaccess instanceof Chunk)) { +@@ -821,7 +1056,7 @@ + if (entity1 == null) { + return false; + } else { +- WorldServer.v.warn("Keeping entity {} that already exists with UUID {}", EntityTypes.getName(entity1.getEntityType()), entity.getUniqueID().toString()); ++ // WorldServer.v.warn("Keeping entity {} that already exists with UUID {}", EntityTypes.getName(entity1.getEntityType()), entity.getUniqueID().toString()); // CraftBukkit + return true; + } + } +@@ -899,6 +1134,7 @@ + if (entity instanceof EntityInsentient) { + this.I.add(((EntityInsentient) entity).getNavigation()); + } ++ entity.valid = true; // CraftBukkit + } + + } +@@ -929,6 +1165,18 @@ + } + + public void strikeLightning(EntityLightning entitylightning) { ++ // CraftBukkit start ++ this.strikeLightning(entitylightning, LightningStrikeEvent.Cause.UNKNOWN); ++ } ++ ++ public void strikeLightning(EntityLightning entitylightning, LightningStrikeEvent.Cause cause) { ++ LightningStrikeEvent lightning = new LightningStrikeEvent(this.getWorld(), (org.bukkit.entity.LightningStrike) entitylightning.getBukkitEntity(), cause); + this.getServer().getPluginManager().callEvent(lightning); + + if (lightning.isCancelled()) { -+ return false; ++ return; + } + // CraftBukkit end - if (super.strikeLightning(entity)) { -- this.server.getPlayerList().sendPacketNearby((EntityHuman) null, entity.locX, entity.locY, entity.locZ, 512.0D, this.worldProvider.getDimensionManager(), new PacketPlayOutSpawnEntityWeather(entity)); -+ this.server.getPlayerList().sendPacketNearby((EntityHuman) null, entity.locX, entity.locY, entity.locZ, 512.0D, dimension, new PacketPlayOutSpawnEntityWeather(entity)); // CraftBukkit - Use dimension - return true; - } else { - return false; -@@ -785,6 +1004,14 @@ + this.globalEntityList.add(entitylightning); + this.server.getPlayerList().sendPacketNearby((EntityHuman) null, entitylightning.locX, entitylightning.locY, entitylightning.locZ, 512.0D, this.worldProvider.getDimensionManager(), new PacketPlayOutSpawnEntityWeather(entitylightning)); + } +@@ -937,6 +1185,12 @@ + public void a(int i, BlockPosition blockposition, int j) { + Iterator iterator = this.server.getPlayerList().getPlayers().iterator(); + ++ // CraftBukkit start ++ EntityHuman entityhuman = null; ++ Entity entity = this.getEntity(i); ++ if (entity instanceof EntityHuman) entityhuman = (EntityHuman) entity; ++ // CraftBukkit end ++ + while (iterator.hasNext()) { + EntityPlayer entityplayer = (EntityPlayer) iterator.next(); + +@@ -945,6 +1199,12 @@ + double d1 = (double) blockposition.getY() - entityplayer.locY; + double d2 = (double) blockposition.getZ() - entityplayer.locZ; + ++ // CraftBukkit start ++ if (entityhuman != null && entityhuman instanceof EntityPlayer && !entityplayer.getBukkitEntity().canSee(((EntityPlayer) entityhuman).getBukkitEntity())) { ++ continue; ++ } ++ // CraftBukkit end ++ + if (d0 * d0 + d1 * d1 + d2 * d2 < 1024.0D) { + entityplayer.playerConnection.sendPacket(new PacketPlayOutBlockBreakAnimation(i, blockposition, j)); + } +@@ -955,12 +1215,14 @@ + + @Override + public void a(@Nullable EntityHuman entityhuman, double d0, double d1, double d2, SoundEffect soundeffect, SoundCategory soundcategory, float f, float f1) { +- this.server.getPlayerList().sendPacketNearby(entityhuman, d0, d1, d2, f > 1.0F ? (double) (16.0F * f) : 16.0D, this.worldProvider.getDimensionManager(), new PacketPlayOutNamedSoundEffect(soundeffect, soundcategory, d0, d1, d2, f, f1)); ++ // CraftBukkit - this.dimension ++ this.server.getPlayerList().sendPacketNearby(entityhuman, d0, d1, d2, f > 1.0F ? (double) (16.0F * f) : 16.0D, this.dimension, new PacketPlayOutNamedSoundEffect(soundeffect, soundcategory, d0, d1, d2, f, f1)); } - public Explosion createExplosion(@Nullable Entity entity, DamageSource damagesource, double d0, double d1, double d2, float f, boolean flag, boolean flag1) { + @Override + public void a(@Nullable EntityHuman entityhuman, Entity entity, SoundEffect soundeffect, SoundCategory soundcategory, float f, float f1) { +- this.server.getPlayerList().sendPacketNearby(entityhuman, entity.locX, entity.locY, entity.locZ, f > 1.0F ? (double) (16.0F * f) : 16.0D, this.worldProvider.getDimensionManager(), new PacketPlayOutEntitySound(soundeffect, soundcategory, entity, f, f1)); ++ // CraftBukkit - this.dimension ++ this.server.getPlayerList().sendPacketNearby(entityhuman, entity.locX, entity.locY, entity.locZ, f > 1.0F ? (double) (16.0F * f) : 16.0D, this.dimension, new PacketPlayOutEntitySound(soundeffect, soundcategory, entity, f, f1)); + } + + @Override +@@ -970,7 +1232,8 @@ + + @Override + public void a(@Nullable EntityHuman entityhuman, int i, BlockPosition blockposition, int j) { +- this.server.getPlayerList().sendPacketNearby(entityhuman, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), 64.0D, this.worldProvider.getDimensionManager(), new PacketPlayOutWorldEvent(i, blockposition, j, false)); ++ // CraftBukkit - this.dimension ++ this.server.getPlayerList().sendPacketNearby(entityhuman, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), 64.0D, this.dimension, new PacketPlayOutWorldEvent(i, blockposition, j, false)); + } + + @Override +@@ -1005,6 +1268,14 @@ + + @Override + public Explosion createExplosion(@Nullable Entity entity, DamageSource damagesource, double d0, double d1, double d2, float f, boolean flag, Explosion.Effect explosion_effect) { + // CraftBukkit start -+ Explosion explosion = super.createExplosion(entity, damagesource, d0, d1, d2, f, flag, flag1); ++ Explosion explosion = super.createExplosion(entity, damagesource, d0, d1, d2, f, flag, explosion_effect); + + if (explosion.wasCanceled) { + return explosion; + } + + /* Remove - Explosion explosion = new Explosion(this, entity, d0, d1, d2, f, flag, flag1); + Explosion explosion = new Explosion(this, entity, d0, d1, d2, f, flag, explosion_effect); if (damagesource != null) { -@@ -793,6 +1020,8 @@ +@@ -1013,6 +1284,8 @@ explosion.a(); explosion.a(false); + */ + // CraftBukkit end - TODO: Check if explosions are still properly implemented - if (!flag1) { + if (explosion_effect == Explosion.Effect.NONE) { explosion.clearBlocks(); } -@@ -819,7 +1048,8 @@ - BlockActionData blockactiondata = (BlockActionData) this.d.removeFirst(); +@@ -1040,7 +1313,8 @@ + BlockActionData blockactiondata = (BlockActionData) this.J.removeFirst(); if (this.a(blockactiondata)) { - this.server.getPlayerList().sendPacketNearby((EntityHuman) null, (double) blockactiondata.a().getX(), (double) blockactiondata.a().getY(), (double) blockactiondata.a().getZ(), 64.0D, this.worldProvider.getDimensionManager(), new PacketPlayOutBlockAction(blockactiondata.a(), blockactiondata.b(), blockactiondata.c(), blockactiondata.d())); @@ -495,37 +560,7 @@ } } -@@ -840,6 +1070,7 @@ - boolean flag = this.isRaining(); - - super.w(); -+ /* CraftBukkit start - if (this.o != this.p) { - this.server.getPlayerList().a((Packet) (new PacketPlayOutGameStateChange(7, this.p)), this.worldProvider.getDimensionManager()); - } -@@ -858,6 +1089,21 @@ - this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(7, this.p)); - this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(8, this.r)); - } -+ // */ -+ if (flag != this.isRaining()) { -+ // Only send weather packets to those affected -+ for (int i = 0; i < this.players.size(); ++i) { -+ if (((EntityPlayer) this.players.get(i)).world == this) { -+ ((EntityPlayer) this.players.get(i)).setPlayerWeather((!flag ? WeatherType.DOWNFALL : WeatherType.CLEAR), false); -+ } -+ } -+ } -+ 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); -+ } -+ } -+ // CraftBukkit end - - } - -@@ -891,13 +1137,20 @@ +@@ -1083,13 +1357,20 @@ } public int a(T t0, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6) { @@ -548,3 +583,18 @@ ++j; } } +@@ -1172,7 +1453,13 @@ + @Override + public WorldMap a(String s) { + return (WorldMap) this.getMinecraftServer().getWorldServer(DimensionManager.OVERWORLD).getWorldPersistentData().b(() -> { +- return new WorldMap(s); ++ // CraftBukkit start ++ // We only get here when the data file exists, but is not a valid map ++ WorldMap newMap = new WorldMap(s); ++ MapInitializeEvent event = new MapInitializeEvent(newMap.mapView); ++ Bukkit.getServer().getPluginManager().callEvent(event); ++ return newMap; ++ // CraftBukkit end + }, s); + } + diff --git a/nms-patches/WorldUpgrader.patch b/nms-patches/WorldUpgrader.patch new file mode 100644 index 0000000000..a6d80b3113 --- /dev/null +++ b/nms-patches/WorldUpgrader.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/server/WorldUpgrader.java ++++ b/net/minecraft/server/WorldUpgrader.java +@@ -123,7 +123,7 @@ + int j = IChunkLoader.a(nbttagcompound); + NBTTagCompound nbttagcompound1 = ichunkloader.getChunkData(dimensionmanager2, () -> { + return this.q; +- }, nbttagcompound); ++ }, nbttagcompound, chunkcoordintpair, null); // CraftBukkit + boolean flag2 = j < SharedConstants.a().getWorldVersion(); + + if (this.d) { diff --git a/pom.xml b/pom.xml index 9ce16c8297..9f99446b98 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.bukkit craftbukkit jar - 1.13.2-R0.1-SNAPSHOT + 1.14-pre5-SNAPSHOT CraftBukkit http://www.bukkit.org @@ -12,8 +12,8 @@ true UTF-8 unknown - 1.13.2 - 1_13_R2 + 1.14-pre5 + 1_14_R1 git-Bukkit- yyyyMMdd-HHmm @@ -46,10 +46,17 @@ 7.1 compile + + + com.googlecode.json-simple + json-simple + 1.1.1 + compile + org.xerial sqlite-jdbc - 3.25.2 + 3.27.2.1 runtime @@ -178,6 +185,22 @@ it.unimi org.bukkit.craftbukkit.libs.it.unimi + + org.apache.commons.codec + org.bukkit.craftbukkit.libs.org.apache.commons.codec + + + org.apache.commons.io + org.bukkit.craftbukkit.libs.org.apache.commons.io + + + org.apache.commons.lang3 + org.bukkit.craftbukkit.libs.org.apache.commons.lang3 + + + org.objectweb.asm + org.bukkit.craftbukkit.libs.org.objectweb.asm + org.bukkit.craftbukkit org.bukkit.craftbukkit.v${minecraft_version} diff --git a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java index 84028e18c0..dd03441acc 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java @@ -14,22 +14,22 @@ import org.bukkit.block.BlockState; import org.bukkit.craftbukkit.block.CraftBlock; import org.bukkit.entity.Entity; import org.bukkit.ChunkSnapshot; +import org.bukkit.craftbukkit.util.CraftMagicNumbers; public class CraftChunk implements Chunk { private WeakReference weakChunk; private final WorldServer worldServer; private final int x; private final int z; - private static final byte[] emptyData = new byte[2048]; - private static final DataPaletteBlock emptyBlockIDs = new ChunkSection(0, false).getBlocks(); - private static final byte[] emptySkyLight = new byte[2048]; + private static final DataPaletteBlock emptyBlockIDs = new ChunkSection(0).getBlocks(); + private static final byte[] emptyLight = new byte[2048]; public CraftChunk(net.minecraft.server.Chunk chunk) { this.weakChunk = new WeakReference(chunk); worldServer = (WorldServer) getHandle().world; - x = getHandle().locX; - z = getHandle().locZ; + x = getHandle().getPos().x; + z = getHandle().getPos().z; } public World getWorld() { @@ -143,10 +143,6 @@ public class CraftChunk implements Chunk { return getWorld().unloadChunk(getX(), getZ(), save); } - public boolean unload(boolean save, boolean safe) { - return getWorld().unloadChunk(getX(), getZ(), save, safe); - } - @Override public boolean isForceLoaded() { return getWorld().isChunkForceLoaded(getX(), getZ()); @@ -173,34 +169,41 @@ public class CraftChunk implements Chunk { for (int i = 0; i < cs.length; i++) { if (cs[i] == null) { // Section is empty? sectionBlockIDs[i] = emptyBlockIDs; - sectionSkyLights[i] = emptySkyLight; - sectionEmitLights[i] = emptyData; + sectionSkyLights[i] = emptyLight; + sectionEmitLights[i] = emptyLight; sectionEmpty[i] = true; } else { // Not empty NBTTagCompound data = new NBTTagCompound(); - cs[i].getBlocks().b(data, "Spigot", "Magic"); + cs[i].getBlocks().a(data, "Palette", "BlockStates"); DataPaletteBlock blockids = new DataPaletteBlock<>(ChunkSection.GLOBAL_PALETTE, net.minecraft.server.Block.REGISTRY_ID, GameProfileSerializer::d, GameProfileSerializer::a, Blocks.AIR.getBlockData()); // TODO: snapshot whole ChunkSection - blockids.a(data, "Spigot", "Magic"); + blockids.a(data.getList("Palette", CraftMagicNumbers.NBT.TAG_COMPOUND), data.getLongArray("BlockStates")); sectionBlockIDs[i] = blockids; - if (cs[i].getSkyLightArray() == null) { - sectionSkyLights[i] = emptySkyLight; + LightEngine lightengine = chunk.world.getChunkProvider().getLightEngine(); + NibbleArray skyLightArray = lightengine.a(EnumSkyBlock.SKY).a(SectionPosition.a(x, i, z)); + if (skyLightArray == null) { + sectionSkyLights[i] = emptyLight; } else { sectionSkyLights[i] = new byte[2048]; - System.arraycopy(cs[i].getSkyLightArray().asBytes(), 0, sectionSkyLights[i], 0, 2048); + System.arraycopy(skyLightArray.asBytes(), 0, sectionSkyLights[i], 0, 2048); + } + NibbleArray emitLightArray = lightengine.a(EnumSkyBlock.BLOCK).a(SectionPosition.a(x, i, z)); + if (emitLightArray == null) { + sectionEmitLights[i] = emptyLight; + } else { + sectionEmitLights[i] = new byte[2048]; + System.arraycopy(emitLightArray.asBytes(), 0, sectionEmitLights[i], 0, 2048); } - sectionEmitLights[i] = new byte[2048]; - System.arraycopy(cs[i].getEmittedLightArray().asBytes(), 0, sectionEmitLights[i], 0, 2048); } } HeightMap hmap = null; if (includeMaxBlockY) { - hmap = new HeightMap(null, HeightMap.Type.LIGHT_BLOCKING); - hmap.a(chunk.heightMap.get(HeightMap.Type.LIGHT_BLOCKING).b()); + hmap = new HeightMap(null, HeightMap.Type.MOTION_BLOCKING); + hmap.a(chunk.heightMap.get(HeightMap.Type.MOTION_BLOCKING).a()); } BiomeBase[] biome = null; @@ -263,16 +266,16 @@ public class CraftChunk implements Chunk { for (int i = 0; i < hSection; i++) { blockIDs[i] = emptyBlockIDs; - skyLight[i] = emptySkyLight; - emitLight[i] = emptyData; + skyLight[i] = emptyLight; + emitLight[i] = emptyLight; empty[i] = true; } - return new CraftChunkSnapshot(x, z, world.getName(), world.getFullTime(), blockIDs, skyLight, emitLight, empty, new HeightMap(null, HeightMap.Type.LIGHT_BLOCKING), biome, biomeTemp); + return new CraftChunkSnapshot(x, z, world.getName(), world.getFullTime(), blockIDs, skyLight, emitLight, empty, new HeightMap(null, HeightMap.Type.MOTION_BLOCKING), biome, biomeTemp); } private static float[] getTemperatures(WorldChunkManager chunkmanager, int chunkX, int chunkZ) { - BiomeBase[] biomes = chunkmanager.getBiomes(chunkX, chunkZ, 16, 16); + BiomeBase[] biomes = chunkmanager.getBiomeBlock(chunkX, chunkZ, 16, 16); float[] temps = new float[biomes.length]; for (int i = 0; i < biomes.length; i++) { @@ -295,6 +298,6 @@ public class CraftChunk implements Chunk { } static { - Arrays.fill(emptySkyLight, (byte) 0xFF); + Arrays.fill(emptyLight, (byte) 0xFF); } } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftFluidCollisionMode.java b/src/main/java/org/bukkit/craftbukkit/CraftFluidCollisionMode.java index faf2fd4ecd..4cbc492f3d 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftFluidCollisionMode.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftFluidCollisionMode.java @@ -1,7 +1,7 @@ package org.bukkit.craftbukkit; import org.bukkit.FluidCollisionMode; -import net.minecraft.server.FluidCollisionOption; +import net.minecraft.server.RayTrace.FluidCollisionOption; public class CraftFluidCollisionMode { @@ -12,11 +12,11 @@ public class CraftFluidCollisionMode { switch (fluidCollisionMode) { case ALWAYS: - return FluidCollisionOption.ALWAYS; + return FluidCollisionOption.ANY; case SOURCE_ONLY: return FluidCollisionOption.SOURCE_ONLY; case NEVER: - return FluidCollisionOption.NEVER; + return FluidCollisionOption.NONE; default: return null; } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftLootTable.java b/src/main/java/org/bukkit/craftbukkit/CraftLootTable.java index d76fe60fbb..8e23289091 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftLootTable.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftLootTable.java @@ -9,6 +9,8 @@ import net.minecraft.server.DamageSource; import net.minecraft.server.Entity; import net.minecraft.server.EntityHuman; import net.minecraft.server.IInventory; +import net.minecraft.server.LootContextParameterSets; +import net.minecraft.server.LootContextParameters; import net.minecraft.server.LootTable; import net.minecraft.server.LootTableInfo; import net.minecraft.server.WorldServer; @@ -39,7 +41,7 @@ public class CraftLootTable implements org.bukkit.loot.LootTable { @Override public Collection populateLoot(Random random, LootContext context) { LootTableInfo nmsContext = convertContext(context); - List nmsItems = handle.populateLoot(random, nmsContext); + List nmsItems = handle.populateLoot(nmsContext); Collection bukkit = new ArrayList<>(nmsItems.size()); for (net.minecraft.server.ItemStack item : nmsItems) { @@ -59,7 +61,7 @@ public class CraftLootTable implements org.bukkit.loot.LootTable { IInventory handle = craftInventory.getInventory(); // TODO: When events are added, call event here w/ custom reason? - getHandle().fillInventory(handle, random, nmsContext); + getHandle().fillInventory(handle, nmsContext); } @Override @@ -72,23 +74,23 @@ public class CraftLootTable implements org.bukkit.loot.LootTable { WorldServer handle = ((CraftWorld) loc.getWorld()).getHandle(); LootTableInfo.Builder builder = new LootTableInfo.Builder(handle); - builder.luck(context.getLuck()); + // builder.luck(context.getLuck()); if (context.getLootedEntity() != null) { Entity nmsLootedEntity = ((CraftEntity) context.getLootedEntity()).getHandle(); - builder.entity(nmsLootedEntity); - builder.damageSource(DamageSource.GENERIC); - builder.position(new BlockPosition(nmsLootedEntity)); + builder.set(LootContextParameters.THIS_ENTITY, nmsLootedEntity); + builder.set(LootContextParameters.DAMAGE_SOURCE, DamageSource.GENERIC); + builder.set(LootContextParameters.POSITION, new BlockPosition(nmsLootedEntity)); } if (context.getKiller() != null) { EntityHuman nmsKiller = ((CraftHumanEntity) context.getKiller()).getHandle(); - builder.killer(nmsKiller); + builder.set(LootContextParameters.KILLER_ENTITY, nmsKiller); // If there is a player killer, damage source should reflect that in case loot tables use that information - builder.damageSource(DamageSource.playerAttack(nmsKiller)); + builder.set(LootContextParameters.DAMAGE_SOURCE, DamageSource.playerAttack(nmsKiller)); } - return builder.build(); + return builder.build(LootContextParameterSets.GENERIC); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/CraftParticle.java b/src/main/java/org/bukkit/craftbukkit/CraftParticle.java index f4c52bf656..179b267dc2 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftParticle.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftParticle.java @@ -76,6 +76,14 @@ public enum CraftParticle { BUBBLE_COLUMN_UP("bubble_column_up"), NAUTILUS("nautilus"), DOLPHIN("dolphin"), + SNEEZE("sneeze"), + CAMPFIRE_COSY_SMOKE("campfire_cosy_smoke"), + CAMPFIRE_SIGNAL_SMOKE("campfire_signal_smoke"), + COMPOSTER("composter"), + FLASH("flash"), + FALLING_LAVA("falling_lava"), + LANDING_LAVA("landing_lava"), + FALLING_WATER("falling_water"), // ----- Legacy Separator ----- LEGACY_BLOCK_CRACK("block"), LEGACY_BLOCK_DUST("block"), @@ -147,6 +155,6 @@ public enum CraftParticle { } public static Particle toBukkit(net.minecraft.server.Particle nms) { - return particles.inverse().get(nms.d()); + return particles.inverse().get(IRegistry.PARTICLE_TYPE.getKey(nms)); } } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java index 6cc730b1ba..ae7d413e84 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -154,6 +154,10 @@ import org.bukkit.craftbukkit.block.data.CraftBlockData; import org.bukkit.craftbukkit.command.BukkitCommandWrapper; import org.bukkit.craftbukkit.command.CraftCommandMap; import org.bukkit.craftbukkit.command.VanillaCommandWrapper; +import org.bukkit.craftbukkit.inventory.CraftBlastingRecipe; +import org.bukkit.craftbukkit.inventory.CraftCampfireRecipe; +import org.bukkit.craftbukkit.inventory.CraftSmokingRecipe; +import org.bukkit.craftbukkit.inventory.CraftStonecuttingRecipe; import org.bukkit.craftbukkit.inventory.util.CraftInventoryCreator; import org.bukkit.craftbukkit.tag.CraftBlockTag; import org.bukkit.craftbukkit.tag.CraftItemTag; @@ -161,6 +165,10 @@ import org.bukkit.craftbukkit.util.CraftChatMessage; import org.bukkit.craftbukkit.util.CraftNamespacedKey; import org.bukkit.event.server.ServerLoadEvent; import org.bukkit.event.server.TabCompleteEvent; +import org.bukkit.inventory.BlastingRecipe; +import org.bukkit.inventory.CampfireRecipe; +import org.bukkit.inventory.SmokingRecipe; +import org.bukkit.inventory.StonecuttingRecipe; public final class CraftServer implements Server { private final String serverName = "CraftBukkit"; @@ -173,7 +181,7 @@ public final class CraftServer implements Server { private final SimpleHelpMap helpMap = new SimpleHelpMap(this); private final StandardMessenger messenger = new StandardMessenger(); private final SimplePluginManager pluginManager = new SimplePluginManager(this, commandMap); - protected final MinecraftServer console; + protected final DedicatedServer console; protected final DedicatedPlayerList playerList; private final Map worlds = new LinkedHashMap(); private YamlConfiguration configuration; @@ -187,11 +195,8 @@ public final class CraftServer implements Server { private int animalSpawn = -1; private int waterAnimalSpawn = -1; private int ambientSpawn = -1; - public int chunkGCPeriod = -1; - public int chunkGCLoadThresh = 0; private File container; private WarningState warningState = WarningState.DEFAULT; - private final BooleanWrapper online = new BooleanWrapper(); public CraftScoreboardManager scoreboardManager; public boolean playerCommandState; private boolean printSaveWarning; @@ -201,16 +206,12 @@ public final class CraftServer implements Server { private final List playerView; public int reloadCount; - private final class BooleanWrapper { - private boolean value = true; - } - static { ConfigurationSerialization.registerClass(CraftOfflinePlayer.class); CraftItemFactory.instance(); } - public CraftServer(MinecraftServer console, PlayerList playerList) { + public CraftServer(DedicatedServer console, PlayerList playerList) { this.console = console; this.playerList = (DedicatedPlayerList) playerList; this.playerView = Collections.unmodifiableList(Lists.transform(playerList.players, new Function() { @@ -220,7 +221,6 @@ public final class CraftServer implements Server { } })); this.serverVersion = CraftServer.class.getPackage().getImplementationVersion(); - online.value = console.getPropertyManager().getBoolean("online-mode", true); Bukkit.setServer(this); @@ -282,8 +282,6 @@ public final class CraftServer implements Server { ambientSpawn = configuration.getInt("spawn-limits.ambient"); console.autosavePeriod = configuration.getInt("ticks-per.autosave"); warningState = WarningState.value(configuration.getString("settings.deprecated-verbose")); - chunkGCPeriod = configuration.getInt("chunk-gc.period-in-ticks"); - chunkGCLoadThresh = configuration.getInt("chunk-gc.load-threshold"); loadIcon(); } @@ -535,37 +533,27 @@ public final class CraftServer implements Server { // so if that changes this will need to as well @Override public int getPort() { - return this.getConfigInt("server-port", 25565); + return this.getServer().getPort(); } @Override public int getViewDistance() { - return this.getConfigInt("view-distance", 10); + return this.getProperties().viewDistance; } @Override public String getIp() { - return this.getConfigString("server-ip", ""); - } - - @Override - public String getServerName() { - return this.getConfigString("server-name", "Unknown Server"); - } - - @Override - public String getServerId() { - return this.getConfigString("server-id", "unnamed"); + return this.getServer().getServerIp(); } @Override public String getWorldType() { - return this.getConfigString("level-type", "DEFAULT"); + return this.getProperties().levelType.name(); } @Override public boolean getGenerateStructures() { - return this.getConfigBoolean("generate-structures", true); + return this.getServer().getGenerateStructures(); } @Override @@ -575,7 +563,7 @@ public final class CraftServer implements Server { @Override public boolean getAllowNether() { - return this.getConfigBoolean("allow-nether", true); + return this.getServer().getAllowNether(); } public boolean getWarnOnOverload() { @@ -588,22 +576,13 @@ public final class CraftServer implements Server { @Override public boolean hasWhitelist() { - return this.getConfigBoolean("white-list", false); + return this.getProperties().whiteList.get(); } // NOTE: Temporary calls through to server.properies until its replaced - private String getConfigString(String variable, String defaultValue) { - return this.console.getPropertyManager().getString(variable, defaultValue); + private DedicatedServerProperties getProperties() { + return this.console.getDedicatedServerProperties(); } - - private int getConfigInt(String variable, int defaultValue) { - return this.console.getPropertyManager().getInt(variable, defaultValue); - } - - private boolean getConfigBoolean(String variable, boolean defaultValue) { - return this.console.getPropertyManager().getBoolean(variable, defaultValue); - } - // End Temporary calls @Override @@ -699,19 +678,14 @@ public final class CraftServer implements Server { reloadCount++; configuration = YamlConfiguration.loadConfiguration(getConfigFile()); commandsConfiguration = YamlConfiguration.loadConfiguration(getCommandsConfigFile()); - PropertyManager config = new PropertyManager(console.options); - ((DedicatedServer) console).propertyManager = config; + console.propertyManager = new DedicatedServerSettings(console.options); + DedicatedServerProperties config = console.propertyManager.getProperties(); - boolean animals = config.getBoolean("spawn-animals", console.getSpawnAnimals()); - boolean monsters = config.getBoolean("spawn-monsters", console.getWorldServer(DimensionManager.OVERWORLD).getDifficulty() != EnumDifficulty.PEACEFUL); - EnumDifficulty difficulty = EnumDifficulty.getById(config.getInt("difficulty", console.getWorldServer(DimensionManager.OVERWORLD).getDifficulty().ordinal())); - - online.value = config.getBoolean("online-mode", console.getOnlineMode()); - console.setSpawnAnimals(config.getBoolean("spawn-animals", console.getSpawnAnimals())); - console.setPVP(config.getBoolean("pvp", console.getPVP())); - console.setAllowFlight(config.getBoolean("allow-flight", console.getAllowFlight())); - console.setMotd(config.getString("motd", console.getMotd())); + console.setSpawnAnimals(config.spawnAnimals); + console.setPVP(config.pvp); + console.setAllowFlight(config.allowFlight); + console.setMotd(config.motd); monsterSpawn = configuration.getInt("spawn-limits.monsters"); animalSpawn = configuration.getInt("spawn-limits.animals"); waterAnimalSpawn = configuration.getInt("spawn-limits.water-animals"); @@ -719,8 +693,6 @@ public final class CraftServer implements Server { warningState = WarningState.value(configuration.getString("settings.deprecated-verbose")); printSaveWarning = false; console.autosavePeriod = configuration.getInt("ticks-per.autosave"); - chunkGCPeriod = configuration.getInt("chunk-gc.period-in-ticks"); - chunkGCLoadThresh = configuration.getInt("chunk-gc.load-threshold"); loadIcon(); try { @@ -735,8 +707,8 @@ public final class CraftServer implements Server { } for (WorldServer world : console.getWorlds()) { - world.worldData.setDifficulty(difficulty); - world.setSpawnFlags(monsters, animals); + world.worldData.setDifficulty(config.difficulty); + world.setSpawnFlags(config.spawnMonsters, config.spawnAnimals); if (this.getTicksPerAnimalSpawns() < 0) { world.ticksPerAnimalSpawns = 400; } else { @@ -911,8 +883,7 @@ public final class CraftServer implements Server { } while(used); boolean hardcore = false; - IDataManager sdm = new ServerNBTManager(getWorldContainer(), name, getServer(), getHandle().getServer().dataConverterManager); - PersistentCollection persistentcollection = new PersistentCollection(sdm); + WorldNBTStorage sdm = new WorldNBTStorage(getWorldContainer(), name, getServer(), getHandle().getServer().dataConverterManager); WorldData worlddata = sdm.getWorldData(); WorldSettings worldSettings = null; if (worlddata == null) { @@ -925,65 +896,23 @@ public final class CraftServer implements Server { } worlddata.checkName(name); // 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) - DimensionManager internalDimension = new DimensionManager(dimension, name, name, () -> DimensionManager.a(creator.environment().getId()).e()); - WorldServer internal = (WorldServer) new WorldServer(console, sdm, persistentcollection, worlddata, internalDimension, console.methodProfiler, creator.environment(), generator).i_(); + DimensionManager actualDimension = DimensionManager.a(creator.environment().getId()); + DimensionManager internalDimension = new DimensionManager(dimension, name, name, (w, manager) -> actualDimension.getWorldProvider(w), actualDimension.hasSkyLight()); + WorldServer internal = (WorldServer) new WorldServer(console, console.executorService, sdm, worlddata, internalDimension, console.getMethodProfiler(), getServer().worldLoadListenerFactory.create(11), creator.environment(), generator); if (!(worlds.containsKey(name.toLowerCase(java.util.Locale.ENGLISH)))) { return null; } - if (worldSettings != null) { - internal.a(worldSettings); - } + console.initWorld(internal, worlddata, worldSettings); - internal.tracker = new EntityTracker(internal); - internal.addIWorldAccess(new WorldManager(console, internal)); internal.worldData.setDifficulty(EnumDifficulty.EASY); internal.setSpawnFlags(true, true); console.worldServer.put(internal.dimension, internal); pluginManager.callEvent(new WorldInitEvent(internal.getWorld())); - System.out.println("Preparing start region for level " + (console.worldServer.size() - 1) + " (Seed: " + internal.getSeed() + ")"); - if (internal.getWorld().getKeepSpawnInMemory()) { - short short1 = 196; - long i = System.currentTimeMillis(); - for (int j = -short1; j <= short1; j += 16) { - for (int k = -short1; k <= short1; k += 16) { - long l = System.currentTimeMillis(); - - if (l < i) { - i = l; - } - - if (l > i + 1000L) { - int i1 = (short1 * 2 + 1) * (short1 * 2 + 1); - int j1 = (j + short1) * (short1 * 2 + 1) + k + 1; - - System.out.println("Preparing spawn area for " + name + ", " + (j1 * 100 / i1) + "%"); - i = l; - } - - BlockPosition chunkcoordinates = internal.getSpawn(); - internal.getChunkProvider().getChunkAt(chunkcoordinates.getX() + j >> 4, chunkcoordinates.getZ() + k >> 4, true, true); - } - } - } - - DimensionManager dimensionmanager = internalDimension.e().getDimensionManager(); - ForcedChunk forcedchunk = (ForcedChunk) persistentcollection.get(dimensionmanager, ForcedChunk::new, "chunks"); - - if (forcedchunk != null) { - LongIterator longiterator = forcedchunk.a().iterator(); - - while (longiterator.hasNext()) { - System.out.println("Loading forced chunks for dimension " + dimension + ", " + forcedchunk.a().size() * 100 / 625 + "%"); - long k = longiterator.nextLong(); - ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(k); - - internal.getChunkProvider().getChunkAt(chunkcoordintpair.x, chunkcoordintpair.z, true, true); - } - } + getServer().loadSpawn(internal.getChunkProvider().playerChunkMap.worldLoadListener, internal); pluginManager.callEvent(new WorldLoadEvent(internal.getWorld())); return internal.getWorld(); @@ -1010,7 +939,7 @@ public final class CraftServer implements Server { return false; } - if (handle.players.size() > 0) { + if (handle.getPlayers().size() > 0) { return false; } @@ -1023,9 +952,9 @@ public final class CraftServer implements Server { if (save) { try { - handle.save(true, null); + handle.save(null, true, true); handle.close(); - } catch (ExceptionWorldConflict ex) { + } catch (Exception ex) { getLogger().log(Level.SEVERE, null, ex); } } @@ -1035,7 +964,7 @@ public final class CraftServer implements Server { return true; } - public MinecraftServer getServer() { + public DedicatedServer getServer() { return console; } @@ -1103,6 +1032,14 @@ public final class CraftServer implements Server { toAdd = CraftShapelessRecipe.fromBukkitRecipe((ShapelessRecipe) recipe); } else if (recipe instanceof FurnaceRecipe) { toAdd = CraftFurnaceRecipe.fromBukkitRecipe((FurnaceRecipe) recipe); + } else if (recipe instanceof BlastingRecipe) { + toAdd = CraftBlastingRecipe.fromBukkitRecipe((BlastingRecipe) recipe); + } else if (recipe instanceof CampfireRecipe) { + toAdd = CraftCampfireRecipe.fromBukkitRecipe((CampfireRecipe) recipe); + } else if (recipe instanceof SmokingRecipe) { + toAdd = CraftSmokingRecipe.fromBukkitRecipe((SmokingRecipe) recipe); + } else if (recipe instanceof StonecuttingRecipe) { + toAdd = CraftStonecuttingRecipe.fromBukkitRecipe((StonecuttingRecipe) recipe); } else { return false; } @@ -1183,7 +1120,7 @@ public final class CraftServer implements Server { @Override public int getSpawnRadius() { - return ((DedicatedServer) console).propertyManager.getInt("spawn-protection", 16); + return this.getServer().getSpawnProtection(); } @Override @@ -1194,7 +1131,7 @@ public final class CraftServer implements Server { @Override public boolean getOnlineMode() { - return online.value; + return console.getOnlineMode(); } @Override @@ -1246,8 +1183,7 @@ public final class CraftServer implements Server { @Override @Deprecated public CraftMapView getMap(int id) { - PersistentCollection collection = console.getWorldServer(DimensionManager.OVERWORLD).worldMaps; - WorldMap worldmap = (WorldMap) collection.get(DimensionManager.OVERWORLD, WorldMap::new, "map_" + id); + WorldMap worldmap = console.getWorldServer(DimensionManager.OVERWORLD).a("map_" + id); if (worldmap == null) { return null; } @@ -1289,7 +1225,7 @@ public final class CraftServer implements Server { @Override public void shutdown() { - console.safeShutdown(); + console.safeShutdown(false); } @Override @@ -1412,7 +1348,7 @@ public final class CraftServer implements Server { @Override public void setWhitelist(boolean value) { playerList.setHasWhitelist(value); - console.getPropertyManager().setProperty("white-list", value); + console.setHasWhitelist(value); } @Override @@ -1590,7 +1526,7 @@ public final class CraftServer implements Server { @Override public boolean isPrimaryThread() { - return Thread.currentThread().equals(console.primaryThread); + return Thread.currentThread().equals(console.serverThread) || console.hasStopped(); // All bets are off if we have shut down (e.g. due to watchdog) } @Override @@ -1900,12 +1836,12 @@ public final class CraftServer implements Server { Preconditions.checkArgument(selector != null, "Selector cannot be null"); Preconditions.checkArgument(sender != null, "Sender cannot be null"); - ArgumentEntity arg = ArgumentEntity.b(); + ArgumentEntity arg = ArgumentEntity.multipleEntities(); List nms; try { StringReader reader = new StringReader(selector); - nms = arg.parse(reader, true).b(VanillaCommandWrapper.getListener(sender)); + nms = arg.parse(reader, true).getEntities(VanillaCommandWrapper.getListener(sender)); Preconditions.checkArgument(!reader.canRead(), "Spurious trailing data in selector: " + selector); } catch (CommandSyntaxException ex) { throw new IllegalArgumentException("Could not parse selector: " + selector, ex); diff --git a/src/main/java/org/bukkit/craftbukkit/CraftSound.java b/src/main/java/org/bukkit/craftbukkit/CraftSound.java index 17fab031b4..b43201cfdb 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftSound.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftSound.java @@ -25,22 +25,40 @@ public enum CraftSound { BLOCK_ANVIL_PLACE("block.anvil.place"), BLOCK_ANVIL_STEP("block.anvil.step"), BLOCK_ANVIL_USE("block.anvil.use"), + BLOCK_BAMBOO_BREAK("block.bamboo.break"), + BLOCK_BAMBOO_FALL("block.bamboo.fall"), + BLOCK_BAMBOO_HIT("block.bamboo.hit"), + BLOCK_BAMBOO_PLACE("block.bamboo.place"), + BLOCK_BAMBOO_SAPLING_BREAK("block.bamboo_sapling.break"), + BLOCK_BAMBOO_SAPLING_HIT("block.bamboo_sapling.hit"), + BLOCK_BAMBOO_SAPLING_PLACE("block.bamboo_sapling.place"), + BLOCK_BAMBOO_STEP("block.bamboo.step"), + BLOCK_BARREL_CLOSE("block.barrel.close"), + BLOCK_BARREL_OPEN("block.barrel.open"), BLOCK_BEACON_ACTIVATE("block.beacon.activate"), BLOCK_BEACON_AMBIENT("block.beacon.ambient"), BLOCK_BEACON_DEACTIVATE("block.beacon.deactivate"), BLOCK_BEACON_POWER_SELECT("block.beacon.power_select"), + BLOCK_BELL_RESONATE("block.bell.resonate"), + BLOCK_BELL_USE("block.bell.use"), + BLOCK_BLASTFURNACE_FIRE_CRACKLE("block.blastfurnace.fire_crackle"), BLOCK_BREWING_STAND_BREW("block.brewing_stand.brew"), BLOCK_BUBBLE_COLUMN_BUBBLE_POP("block.bubble_column.bubble_pop"), BLOCK_BUBBLE_COLUMN_UPWARDS_AMBIENT("block.bubble_column.upwards_ambient"), BLOCK_BUBBLE_COLUMN_UPWARDS_INSIDE("block.bubble_column.upwards_inside"), BLOCK_BUBBLE_COLUMN_WHIRLPOOL_AMBIENT("block.bubble_column.whirlpool_ambient"), BLOCK_BUBBLE_COLUMN_WHIRLPOOL_INSIDE("block.bubble_column.whirlpool_inside"), + BLOCK_CAMPFIRE_CRACKLE("block.campfire.crackle"), BLOCK_CHEST_CLOSE("block.chest.close"), BLOCK_CHEST_LOCKED("block.chest.locked"), BLOCK_CHEST_OPEN("block.chest.open"), BLOCK_CHORUS_FLOWER_DEATH("block.chorus_flower.death"), BLOCK_CHORUS_FLOWER_GROW("block.chorus_flower.grow"), BLOCK_COMPARATOR_CLICK("block.comparator.click"), + BLOCK_COMPOSTER_EMPTY("block.composter.empty"), + BLOCK_COMPOSTER_FILL("block.composter.fill"), + BLOCK_COMPOSTER_FILL_SUCCESS("block.composter.fill_success"), + BLOCK_COMPOSTER_READY("block.composter.ready"), BLOCK_CONDUIT_ACTIVATE("block.conduit.activate"), BLOCK_CONDUIT_AMBIENT("block.conduit.ambient"), BLOCK_CONDUIT_AMBIENT_SHORT("block.conduit.ambient.short"), @@ -51,6 +69,7 @@ public enum CraftSound { BLOCK_CORAL_BLOCK_HIT("block.coral_block.hit"), BLOCK_CORAL_BLOCK_PLACE("block.coral_block.place"), BLOCK_CORAL_BLOCK_STEP("block.coral_block.step"), + BLOCK_CROP_BREAK("block.crop.break"), BLOCK_DISPENSER_DISPENSE("block.dispenser.dispense"), BLOCK_DISPENSER_FAIL("block.dispenser.fail"), BLOCK_DISPENSER_LAUNCH("block.dispenser.launch"), @@ -80,6 +99,7 @@ public enum CraftSound { BLOCK_GRAVEL_HIT("block.gravel.hit"), BLOCK_GRAVEL_PLACE("block.gravel.place"), BLOCK_GRAVEL_STEP("block.gravel.step"), + BLOCK_GRINDSTONE_USE("block.grindstone.use"), BLOCK_IRON_DOOR_CLOSE("block.iron_door.close"), BLOCK_IRON_DOOR_OPEN("block.iron_door.open"), BLOCK_IRON_TRAPDOOR_CLOSE("block.iron_trapdoor.close"), @@ -89,6 +109,11 @@ public enum CraftSound { BLOCK_LADDER_HIT("block.ladder.hit"), BLOCK_LADDER_PLACE("block.ladder.place"), BLOCK_LADDER_STEP("block.ladder.step"), + BLOCK_LANTERN_BREAK("block.lantern.break"), + BLOCK_LANTERN_FALL("block.lantern.fall"), + BLOCK_LANTERN_HIT("block.lantern.hit"), + BLOCK_LANTERN_PLACE("block.lantern.place"), + BLOCK_LANTERN_STEP("block.lantern.step"), BLOCK_LAVA_AMBIENT("block.lava.ambient"), BLOCK_LAVA_EXTINGUISH("block.lava.extinguish"), BLOCK_LAVA_POP("block.lava.pop"), @@ -101,14 +126,20 @@ public enum CraftSound { BLOCK_METAL_PRESSURE_PLATE_CLICK_OFF("block.metal_pressure_plate.click_off"), BLOCK_METAL_PRESSURE_PLATE_CLICK_ON("block.metal_pressure_plate.click_on"), BLOCK_METAL_STEP("block.metal.step"), + BLOCK_NETHER_WART_BREAK("block.nether_wart.break"), + BLOCK_NOTE_BLOCK_BANJO("block.note_block.banjo"), BLOCK_NOTE_BLOCK_BASEDRUM("block.note_block.basedrum"), BLOCK_NOTE_BLOCK_BASS("block.note_block.bass"), BLOCK_NOTE_BLOCK_BELL("block.note_block.bell"), + BLOCK_NOTE_BLOCK_BIT("block.note_block.bit"), BLOCK_NOTE_BLOCK_CHIME("block.note_block.chime"), + BLOCK_NOTE_BLOCK_COW_BELL("block.note_block.cow_bell"), + BLOCK_NOTE_BLOCK_DIDGERIDOO("block.note_block.didgeridoo"), BLOCK_NOTE_BLOCK_FLUTE("block.note_block.flute"), BLOCK_NOTE_BLOCK_GUITAR("block.note_block.guitar"), BLOCK_NOTE_BLOCK_HARP("block.note_block.harp"), BLOCK_NOTE_BLOCK_HAT("block.note_block.hat"), + BLOCK_NOTE_BLOCK_IRON_XYLOPHONE("block.note_block.iron_xylophone"), BLOCK_NOTE_BLOCK_PLING("block.note_block.pling"), BLOCK_NOTE_BLOCK_SNARE("block.note_block.snare"), BLOCK_NOTE_BLOCK_XYLOPHONE("block.note_block.xylophone"), @@ -124,6 +155,11 @@ public enum CraftSound { BLOCK_SAND_HIT("block.sand.hit"), BLOCK_SAND_PLACE("block.sand.place"), BLOCK_SAND_STEP("block.sand.step"), + BLOCK_SCAFFOLDING_BREAK("block.scaffolding.break"), + BLOCK_SCAFFOLDING_FALL("block.scaffolding.fall"), + BLOCK_SCAFFOLDING_HIT("block.scaffolding.hit"), + BLOCK_SCAFFOLDING_PLACE("block.scaffolding.place"), + BLOCK_SCAFFOLDING_STEP("block.scaffolding.step"), BLOCK_SHULKER_BOX_CLOSE("block.shulker_box.close"), BLOCK_SHULKER_BOX_OPEN("block.shulker_box.open"), BLOCK_SLIME_BLOCK_BREAK("block.slime_block.break"), @@ -131,6 +167,7 @@ public enum CraftSound { BLOCK_SLIME_BLOCK_HIT("block.slime_block.hit"), BLOCK_SLIME_BLOCK_PLACE("block.slime_block.place"), BLOCK_SLIME_BLOCK_STEP("block.slime_block.step"), + BLOCK_SMOKER_SMOKE("block.smoker.smoke"), BLOCK_SNOW_BREAK("block.snow.break"), BLOCK_SNOW_FALL("block.snow.fall"), BLOCK_SNOW_HIT("block.snow.hit"), @@ -145,6 +182,8 @@ public enum CraftSound { BLOCK_STONE_PRESSURE_PLATE_CLICK_OFF("block.stone_pressure_plate.click_off"), BLOCK_STONE_PRESSURE_PLATE_CLICK_ON("block.stone_pressure_plate.click_on"), BLOCK_STONE_STEP("block.stone.step"), + BLOCK_SWEET_BERRY_BUSH_BREAK("block.sweet_berry_bush.break"), + BLOCK_SWEET_BERRY_BUSH_PLACE("block.sweet_berry_bush.place"), BLOCK_TRIPWIRE_ATTACH("block.tripwire.attach"), BLOCK_TRIPWIRE_CLICK_OFF("block.tripwire.click_off"), BLOCK_TRIPWIRE_CLICK_ON("block.tripwire.click_on"), @@ -194,11 +233,14 @@ public enum CraftSound { ENTITY_BOAT_PADDLE_LAND("entity.boat.paddle_land"), ENTITY_BOAT_PADDLE_WATER("entity.boat.paddle_water"), ENTITY_CAT_AMBIENT("entity.cat.ambient"), + ENTITY_CAT_BEG_FOR_FOOD("entity.cat.beg_for_food"), ENTITY_CAT_DEATH("entity.cat.death"), + ENTITY_CAT_EAT("entity.cat.eat"), ENTITY_CAT_HISS("entity.cat.hiss"), ENTITY_CAT_HURT("entity.cat.hurt"), ENTITY_CAT_PURR("entity.cat.purr"), ENTITY_CAT_PURREOW("entity.cat.purreow"), + ENTITY_CAT_STRAY_AMBIENT("entity.cat.stray_ambient"), ENTITY_CHICKEN_AMBIENT("entity.chicken.ambient"), ENTITY_CHICKEN_DEATH("entity.chicken.death"), ENTITY_CHICKEN_EGG("entity.chicken.egg"), @@ -271,6 +313,7 @@ public enum CraftSound { ENTITY_ENDER_PEARL_THROW("entity.ender_pearl.throw"), ENTITY_EVOKER_AMBIENT("entity.evoker.ambient"), ENTITY_EVOKER_CAST_SPELL("entity.evoker.cast_spell"), + ENTITY_EVOKER_CELEBRATE("entity.evoker.celebrate"), ENTITY_EVOKER_DEATH("entity.evoker.death"), ENTITY_EVOKER_FANGS_ATTACK("entity.evoker_fangs.attack"), ENTITY_EVOKER_HURT("entity.evoker.hurt"), @@ -291,6 +334,16 @@ public enum CraftSound { ENTITY_FISHING_BOBBER_SPLASH("entity.fishing_bobber.splash"), ENTITY_FISHING_BOBBER_THROW("entity.fishing_bobber.throw"), ENTITY_FISH_SWIM("entity.fish.swim"), + ENTITY_FOX_AGGRO("entity.fox.aggro"), + ENTITY_FOX_AMBIENT("entity.fox.ambient"), + ENTITY_FOX_BITE("entity.fox.bite"), + ENTITY_FOX_DEATH("entity.fox.death"), + ENTITY_FOX_EAT("entity.fox.eat"), + ENTITY_FOX_HURT("entity.fox.hurt"), + ENTITY_FOX_SCREECH("entity.fox.screech"), + ENTITY_FOX_SLEEP("entity.fox.sleep"), + ENTITY_FOX_SNIFF("entity.fox.sniff"), + ENTITY_FOX_SPIT("entity.fox.spit"), ENTITY_GENERIC_BIG_FALL("entity.generic.big_fall"), ENTITY_GENERIC_BURN("entity.generic.burn"), ENTITY_GENERIC_DEATH("entity.generic.death"), @@ -381,13 +434,31 @@ public enum CraftSound { ENTITY_MAGMA_CUBE_SQUISH_SMALL("entity.magma_cube.squish_small"), ENTITY_MINECART_INSIDE("entity.minecart.inside"), ENTITY_MINECART_RIDING("entity.minecart.riding"), + ENTITY_MOOSHROOM_CONVERT("entity.mooshroom.convert"), + ENTITY_MOOSHROOM_EAT("entity.mooshroom.eat"), + ENTITY_MOOSHROOM_MILK("entity.mooshroom.milk"), ENTITY_MOOSHROOM_SHEAR("entity.mooshroom.shear"), + ENTITY_MOOSHROOM_SUSPICIOUS_MILK("entity.mooshroom.suspicious_milk"), ENTITY_MULE_AMBIENT("entity.mule.ambient"), ENTITY_MULE_CHEST("entity.mule.chest"), ENTITY_MULE_DEATH("entity.mule.death"), ENTITY_MULE_HURT("entity.mule.hurt"), + ENTITY_OCELOT_AMBIENT("entity.ocelot.ambient"), + ENTITY_OCELOT_DEATH("entity.ocelot.death"), + ENTITY_OCELOT_HURT("entity.ocelot.hurt"), ENTITY_PAINTING_BREAK("entity.painting.break"), ENTITY_PAINTING_PLACE("entity.painting.place"), + ENTITY_PANDA_AGGRESSIVE_AMBIENT("entity.panda.aggressive_ambient"), + ENTITY_PANDA_AMBIENT("entity.panda.ambient"), + ENTITY_PANDA_BITE("entity.panda.bite"), + ENTITY_PANDA_CANT_BREED("entity.panda.cant_breed"), + ENTITY_PANDA_DEATH("entity.panda.death"), + ENTITY_PANDA_EAT("entity.panda.eat"), + ENTITY_PANDA_HURT("entity.panda.hurt"), + ENTITY_PANDA_PRE_SNEEZE("entity.panda.pre_sneeze"), + ENTITY_PANDA_SNEEZE("entity.panda.sneeze"), + ENTITY_PANDA_STEP("entity.panda.step"), + ENTITY_PANDA_WORRIED_AMBIENT("entity.panda.worried_ambient"), ENTITY_PARROT_AMBIENT("entity.parrot.ambient"), ENTITY_PARROT_DEATH("entity.parrot.death"), ENTITY_PARROT_EAT("entity.parrot.eat"), @@ -402,11 +473,15 @@ public enum CraftSound { ENTITY_PARROT_IMITATE_ENDER_DRAGON("entity.parrot.imitate.ender_dragon"), ENTITY_PARROT_IMITATE_EVOKER("entity.parrot.imitate.evoker"), ENTITY_PARROT_IMITATE_GHAST("entity.parrot.imitate.ghast"), + ENTITY_PARROT_IMITATE_GUARDIAN("entity.parrot.imitate.guardian"), ENTITY_PARROT_IMITATE_HUSK("entity.parrot.imitate.husk"), ENTITY_PARROT_IMITATE_ILLUSIONER("entity.parrot.imitate.illusioner"), ENTITY_PARROT_IMITATE_MAGMA_CUBE("entity.parrot.imitate.magma_cube"), + ENTITY_PARROT_IMITATE_PANDA("entity.parrot.imitate.panda"), ENTITY_PARROT_IMITATE_PHANTOM("entity.parrot.imitate.phantom"), + ENTITY_PARROT_IMITATE_PILLAGER("entity.parrot.imitate.pillager"), ENTITY_PARROT_IMITATE_POLAR_BEAR("entity.parrot.imitate.polar_bear"), + ENTITY_PARROT_IMITATE_RAVAGER("entity.parrot.imitate.ravager"), ENTITY_PARROT_IMITATE_SHULKER("entity.parrot.imitate.shulker"), ENTITY_PARROT_IMITATE_SILVERFISH("entity.parrot.imitate.silverfish"), ENTITY_PARROT_IMITATE_SKELETON("entity.parrot.imitate.skeleton"), @@ -434,6 +509,10 @@ public enum CraftSound { ENTITY_PIG_HURT("entity.pig.hurt"), ENTITY_PIG_SADDLE("entity.pig.saddle"), ENTITY_PIG_STEP("entity.pig.step"), + ENTITY_PILLAGER_AMBIENT("entity.pillager.ambient"), + ENTITY_PILLAGER_CELEBRATE("entity.pillager.celebrate"), + ENTITY_PILLAGER_DEATH("entity.pillager.death"), + ENTITY_PILLAGER_HURT("entity.pillager.hurt"), ENTITY_PLAYER_ATTACK_CRIT("entity.player.attack.crit"), ENTITY_PLAYER_ATTACK_KNOCKBACK("entity.player.attack.knockback"), ENTITY_PLAYER_ATTACK_NODAMAGE("entity.player.attack.nodamage"), @@ -447,6 +526,7 @@ public enum CraftSound { ENTITY_PLAYER_HURT("entity.player.hurt"), ENTITY_PLAYER_HURT_DROWN("entity.player.hurt_drown"), ENTITY_PLAYER_HURT_ON_FIRE("entity.player.hurt_on_fire"), + ENTITY_PLAYER_HURT_SWEET_BERRY_BUSH("entity.player.hurt_sweet_berry_bush"), ENTITY_PLAYER_LEVELUP("entity.player.levelup"), ENTITY_PLAYER_SMALL_FALL("entity.player.small_fall"), ENTITY_PLAYER_SPLASH("entity.player.splash"), @@ -470,6 +550,14 @@ public enum CraftSound { ENTITY_RABBIT_DEATH("entity.rabbit.death"), ENTITY_RABBIT_HURT("entity.rabbit.hurt"), ENTITY_RABBIT_JUMP("entity.rabbit.jump"), + ENTITY_RAVAGER_AMBIENT("entity.ravager.ambient"), + ENTITY_RAVAGER_ATTACK("entity.ravager.attack"), + ENTITY_RAVAGER_CELEBRATE("entity.ravager.celebrate"), + ENTITY_RAVAGER_DEATH("entity.ravager.death"), + ENTITY_RAVAGER_HURT("entity.ravager.hurt"), + ENTITY_RAVAGER_ROAR("entity.ravager.roar"), + ENTITY_RAVAGER_STEP("entity.ravager.step"), + ENTITY_RAVAGER_STUNNED("entity.ravager.stunned"), ENTITY_SALMON_AMBIENT("entity.salmon.ambient"), ENTITY_SALMON_DEATH("entity.salmon.death"), ENTITY_SALMON_FLOP("entity.salmon.flop"), @@ -556,15 +644,41 @@ public enum CraftSound { ENTITY_VEX_DEATH("entity.vex.death"), ENTITY_VEX_HURT("entity.vex.hurt"), ENTITY_VILLAGER_AMBIENT("entity.villager.ambient"), + ENTITY_VILLAGER_CELEBRATE("entity.villager.celebrate"), ENTITY_VILLAGER_DEATH("entity.villager.death"), ENTITY_VILLAGER_HURT("entity.villager.hurt"), ENTITY_VILLAGER_NO("entity.villager.no"), ENTITY_VILLAGER_TRADE("entity.villager.trade"), + ENTITY_VILLAGER_WORK_ARMORER("entity.villager.work_armorer"), + ENTITY_VILLAGER_WORK_BUTCHER("entity.villager.work_butcher"), + ENTITY_VILLAGER_WORK_CARTOGRAPHER("entity.villager.work_cartographer"), + ENTITY_VILLAGER_WORK_CLERIC("entity.villager.work_cleric"), + ENTITY_VILLAGER_WORK_FARMER("entity.villager.work_farmer"), + ENTITY_VILLAGER_WORK_FISHERMAN("entity.villager.work_fisherman"), + ENTITY_VILLAGER_WORK_FLETCHER("entity.villager.work_fletcher"), + ENTITY_VILLAGER_WORK_LEATHERWORKER("entity.villager.work_leatherworker"), + ENTITY_VILLAGER_WORK_LIBRARIAN("entity.villager.work_librarian"), + ENTITY_VILLAGER_WORK_MASON("entity.villager.work_mason"), + ENTITY_VILLAGER_WORK_SHEPHERD("entity.villager.work_shepherd"), + ENTITY_VILLAGER_WORK_TOOLSMITH("entity.villager.work_toolsmith"), + ENTITY_VILLAGER_WORK_WEAPONSMITH("entity.villager.work_weaponsmith"), ENTITY_VILLAGER_YES("entity.villager.yes"), ENTITY_VINDICATOR_AMBIENT("entity.vindicator.ambient"), + ENTITY_VINDICATOR_CELEBRATE("entity.vindicator.celebrate"), ENTITY_VINDICATOR_DEATH("entity.vindicator.death"), ENTITY_VINDICATOR_HURT("entity.vindicator.hurt"), + ENTITY_WANDERING_TRADER_AMBIENT("entity.wandering_trader.ambient"), + ENTITY_WANDERING_TRADER_DEATH("entity.wandering_trader.death"), + ENTITY_WANDERING_TRADER_DISAPPEARED("entity.wandering_trader.disappeared"), + ENTITY_WANDERING_TRADER_DRINK_MILK("entity.wandering_trader.drink_milk"), + ENTITY_WANDERING_TRADER_DRINK_POTION("entity.wandering_trader.drink_potion"), + ENTITY_WANDERING_TRADER_HURT("entity.wandering_trader.hurt"), + ENTITY_WANDERING_TRADER_NO("entity.wandering_trader.no"), + ENTITY_WANDERING_TRADER_REAPPEARED("entity.wandering_trader.reappeared"), + ENTITY_WANDERING_TRADER_TRADE("entity.wandering_trader.trade"), + ENTITY_WANDERING_TRADER_YES("entity.wandering_trader.yes"), ENTITY_WITCH_AMBIENT("entity.witch.ambient"), + ENTITY_WITCH_CELEBRATE("entity.witch.celebrate"), ENTITY_WITCH_DEATH("entity.witch.death"), ENTITY_WITCH_DRINK("entity.witch.drink"), ENTITY_WITCH_HURT("entity.witch.hurt"), @@ -611,6 +725,7 @@ public enum CraftSound { ENTITY_ZOMBIE_VILLAGER_DEATH("entity.zombie_villager.death"), ENTITY_ZOMBIE_VILLAGER_HURT("entity.zombie_villager.hurt"), ENTITY_ZOMBIE_VILLAGER_STEP("entity.zombie_villager.step"), + EVENT_RAID_HORN("event.raid.horn"), ITEM_ARMOR_EQUIP_CHAIN("item.armor.equip_chain"), ITEM_ARMOR_EQUIP_DIAMOND("item.armor.equip_diamond"), ITEM_ARMOR_EQUIP_ELYTRA("item.armor.equip_elytra"), @@ -620,6 +735,8 @@ public enum CraftSound { ITEM_ARMOR_EQUIP_LEATHER("item.armor.equip_leather"), ITEM_ARMOR_EQUIP_TURTLE("item.armor.equip_turtle"), ITEM_AXE_STRIP("item.axe.strip"), + ITEM_BOOK_PAGE_TURN("item.book.page_turn"), + ITEM_BOOK_PUT("item.book.put"), ITEM_BOTTLE_EMPTY("item.bottle.empty"), ITEM_BOTTLE_FILL("item.bottle.fill"), ITEM_BOTTLE_FILL_DRAGONBREATH("item.bottle.fill_dragonbreath"), @@ -630,13 +747,24 @@ public enum CraftSound { ITEM_BUCKET_FILL_FISH("item.bucket.fill_fish"), ITEM_BUCKET_FILL_LAVA("item.bucket.fill_lava"), ITEM_CHORUS_FRUIT_TELEPORT("item.chorus_fruit.teleport"), + ITEM_CROP_PLANT("item.crop.plant"), + ITEM_CROSSBOW_HIT("item.crossbow.hit"), + ITEM_CROSSBOW_LOADING_END("item.crossbow.loading_end"), + ITEM_CROSSBOW_LOADING_MIDDLE("item.crossbow.loading_middle"), + ITEM_CROSSBOW_LOADING_START("item.crossbow.loading_start"), + ITEM_CROSSBOW_QUICK_CHARGE_1("item.crossbow.quick_charge_1"), + ITEM_CROSSBOW_QUICK_CHARGE_2("item.crossbow.quick_charge_2"), + ITEM_CROSSBOW_QUICK_CHARGE_3("item.crossbow.quick_charge_3"), + ITEM_CROSSBOW_SHOOT("item.crossbow.shoot"), ITEM_ELYTRA_FLYING("item.elytra.flying"), ITEM_FIRECHARGE_USE("item.firecharge.use"), ITEM_FLINTANDSTEEL_USE("item.flintandsteel.use"), ITEM_HOE_TILL("item.hoe.till"), + ITEM_NETHER_WART_PLANT("item.nether_wart.plant"), ITEM_SHIELD_BLOCK("item.shield.block"), ITEM_SHIELD_BREAK("item.shield.break"), ITEM_SHOVEL_FLATTEN("item.shovel.flatten"), + ITEM_SWEET_BERRIES_PICK_FROM_BUSH("item.sweet_berries.pick_from_bush"), ITEM_TOTEM_USE("item.totem.use"), ITEM_TRIDENT_HIT("item.trident.hit"), ITEM_TRIDENT_HIT_GROUND("item.trident.hit_ground"), @@ -667,6 +795,11 @@ public enum CraftSound { MUSIC_NETHER("music.nether"), MUSIC_UNDER_WATER("music.under_water"), UI_BUTTON_CLICK("ui.button.click"), + UI_CARTOGRAPHY_TABLE_TAKE_RESULT("ui.cartography_table.take_result"), + UI_LOOM_SELECT_PATTERN("ui.loom.select_pattern"), + UI_LOOM_TAKE_RESULT("ui.loom.take_result"), + UI_STONECUTTER_SELECT_RECIPE("ui.stonecutter.select_recipe"), + UI_STONECUTTER_TAKE_RESULT("ui.stonecutter.take_result"), UI_TOAST_CHALLENGE_COMPLETE("ui.toast.challenge_complete"), UI_TOAST_IN("ui.toast.in"), UI_TOAST_OUT("ui.toast.out"), diff --git a/src/main/java/org/bukkit/craftbukkit/CraftStatistic.java b/src/main/java/org/bukkit/craftbukkit/CraftStatistic.java index 31252df5be..a34e05e9a0 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftStatistic.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftStatistic.java @@ -82,7 +82,18 @@ public enum CraftStatistic { DAMAGE_BLOCKED_BY_SHIELD(StatisticList.DAMAGE_BLOCKED_BY_SHIELD), DAMAGE_ABSORBED(StatisticList.DAMAGE_ABSORBED), DAMAGE_RESISTED(StatisticList.DAMAGE_RESISTED), - CLEAN_SHULKER_BOX(StatisticList.CLEAN_SHULKER_BOX); + CLEAN_SHULKER_BOX(StatisticList.CLEAN_SHULKER_BOX), + OPEN_BARREL(StatisticList.OPEN_BARREL), + INTERACT_WITH_BLAST_FURNACE(StatisticList.INTERACT_WITH_BLAST_FURNACE), + INTERACT_WITH_SMOKER(StatisticList.INTERACT_WITH_SMOKER), + INTERACT_WITH_LECTERN(StatisticList.INTERACT_WITH_LECTERN), + INTERACT_WITH_CAMPFIRE(StatisticList.INTERACT_WITH_CAMPFIRE), + INTERACT_WITH_CARTOGRAPHY_TABLE(StatisticList.INTERACT_WITH_CARTOGRAPHY_TABLE), + INTERACT_WITH_LOOM(StatisticList.INTERACT_WITH_LOOM), + INTERACT_WITH_STONECUTTER(StatisticList.INTERACT_WITH_STONECUTTER), + BELL_RING(StatisticList.BELL_RING), + RAID_TRIGGER(StatisticList.RAID_TRIGGER), + RAID_WIN(StatisticList.RAID_WIN); private final MinecraftKey minecraftKey; private final org.bukkit.Statistic bukkit; private static final BiMap statistics; diff --git a/src/main/java/org/bukkit/craftbukkit/CraftTravelAgent.java b/src/main/java/org/bukkit/craftbukkit/CraftTravelAgent.java deleted file mode 100644 index d4639c8221..0000000000 --- a/src/main/java/org/bukkit/craftbukkit/CraftTravelAgent.java +++ /dev/null @@ -1,86 +0,0 @@ -package org.bukkit.craftbukkit; - -import net.minecraft.server.BlockPosition; -import net.minecraft.server.DimensionManager; -import net.minecraft.server.PortalTravelAgent; -import net.minecraft.server.WorldServer; - -import org.bukkit.Location; -import org.bukkit.TravelAgent; - -public class CraftTravelAgent extends PortalTravelAgent implements TravelAgent { - - public static TravelAgent DEFAULT = null; - - private int searchRadius = 128; - private int creationRadius = 16; - private boolean canCreatePortal = true; - - public CraftTravelAgent(WorldServer worldserver) { - super(worldserver); - if (DEFAULT == null && worldserver.dimension == DimensionManager.OVERWORLD) { - DEFAULT = this; - } - } - - @Override - public Location findOrCreate(Location target) { - WorldServer worldServer = ((CraftWorld) target.getWorld()).getHandle(); - - Location found = this.findPortal(target); - if (found == null) { - if (this.getCanCreatePortal() && this.createPortal(target)) { - found = this.findPortal(target); - } else { - found = target; // fallback to original if unable to find or create - } - } - - return found; - } - - @Override - public Location findPortal(Location location) { - PortalTravelAgent pta = ((CraftWorld) location.getWorld()).getHandle().getTravelAgent(); - BlockPosition found = pta.findPortal(location.getX(), location.getY(), location.getZ(), this.getSearchRadius()); - return found != null ? new Location(location.getWorld(), found.getX(), found.getY(), found.getZ(), location.getYaw(), location.getPitch()) : null; - } - - @Override - public boolean createPortal(Location location) { - PortalTravelAgent pta = ((CraftWorld) location.getWorld()).getHandle().getTravelAgent(); - return pta.createPortal(location.getX(), location.getY(), location.getZ(), this.getCreationRadius()); - } - - @Override - public TravelAgent setSearchRadius(int radius) { - this.searchRadius = radius; - return this; - } - - @Override - public int getSearchRadius() { - return this.searchRadius; - } - - @Override - public TravelAgent setCreationRadius(int radius) { - this.creationRadius = radius < 2 ? 0 : radius; - return this; - } - - @Override - public int getCreationRadius() { - return this.creationRadius; - } - - @Override - public boolean getCanCreatePortal() { - return this.canCreatePortal; - } - - @Override - public void setCanCreatePortal(boolean create) { - this.canCreatePortal = create; - } -} diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index 4d20ce9927..6ee5dbefbd 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -1,15 +1,16 @@ package org.bukkit.craftbukkit; import com.google.common.base.Preconditions; -import com.google.common.util.concurrent.Futures; -import it.unimi.dsi.fastutil.longs.LongSet; +import it.unimi.dsi.fastutil.longs.Long2ObjectLinkedOpenHashMap; import java.io.File; +import java.io.IOException; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Iterator; +import java.util.Objects; import java.util.Random; import java.util.Set; import java.util.UUID; @@ -85,8 +86,6 @@ public class CraftWorld implements World { private int animalSpawn = -1; private int waterAnimalSpawn = -1; private int ambientSpawn = -1; - private int chunkLoadCount = 0; - private int chunkGCTickCount; private static final Random rand = new Random(); @@ -95,10 +94,6 @@ public class CraftWorld implements World { this.generator = gen; environment = env; - - if (server.chunkGCPeriod > 0) { - chunkGCTickCount = rand.nextInt(server.chunkGCPeriod); - } } public Block getBlockAt(int x, int y, int z) { @@ -107,10 +102,10 @@ public class CraftWorld implements World { public int getHighestBlockYAt(int x, int z) { if (!isChunkLoaded(x >> 4, z >> 4)) { - loadChunk(x >> 4, z >> 4); + getChunkAt(x >> 4, z >> 4); // Transient load for this tick } - return world.getHighestBlockYAt(HeightMap.Type.LIGHT_BLOCKING, new BlockPosition(x, 0, z)).getY(); + return world.getHighestBlockYAt(HeightMap.Type.MOTION_BLOCKING, new BlockPosition(x, 0, z)).getY(); } public Location getSpawnLocation() { @@ -141,7 +136,7 @@ public class CraftWorld implements World { } public Chunk getChunkAt(int x, int z) { - return this.world.getChunkProvider().getChunkAt(x, z, true, true).bukkitChunk; + return this.world.getChunkProvider().getChunkAt(x, z, true).bukkitChunk; } public Chunk getChunkAt(Block block) { @@ -149,24 +144,23 @@ public class CraftWorld implements World { } public boolean isChunkLoaded(int x, int z) { - return world.getChunkProvider().isLoaded(x, z); + net.minecraft.server.Chunk chunk = world.getChunkProvider().getChunkAt(x, z, false); + return chunk != null && chunk.loaded; } @Override public boolean isChunkGenerated(int x, int z) { - return isChunkLoaded(x, z) || ((ChunkRegionLoader) world.getChunkProvider().chunkLoader).chunkExists(x, z); + try { + return isChunkLoaded(x, z) || world.getChunkProvider().playerChunkMap.chunkExists(new ChunkCoordIntPair(x, z)); + } catch (IOException ex) { + throw new RuntimeException(ex); + } } public Chunk[] getLoadedChunks() { - Object[] chunks = world.getChunkProvider().chunks.values().toArray(); - org.bukkit.Chunk[] craftChunks = new CraftChunk[chunks.length]; + Long2ObjectLinkedOpenHashMap chunks = world.getChunkProvider().playerChunkMap.visibleChunks; - for (int i = 0; i < chunks.length; i++) { - net.minecraft.server.Chunk chunk = (net.minecraft.server.Chunk) chunks[i]; - craftChunks[i] = chunk.bukkitChunk; - } - - return craftChunks; + return chunks.values().stream().map(PlayerChunk::getChunk).filter(Objects::nonNull).filter((chunk) -> chunk.loaded).map(net.minecraft.server.Chunk::getBukkitChunk).toArray(Chunk[]::new); } public void loadChunk(int x, int z) { @@ -182,50 +176,39 @@ public class CraftWorld implements World { } public boolean unloadChunk(int x, int z, boolean save) { - return unloadChunk(x, z, save, false); + return unloadChunk0(x, z, save); } public boolean unloadChunkRequest(int x, int z) { - return unloadChunkRequest(x, z, true); - } - - public boolean unloadChunkRequest(int x, int z, boolean safe) { - if (safe && isChunkInUse(x, z)) { - return false; - } - - net.minecraft.server.Chunk chunk = world.getChunkProvider().getChunkAt(x, z, false, false); + net.minecraft.server.IChunkAccess chunk = world.getChunkProvider().getChunkAt(x, z, ChunkStatus.FULL, false); if (chunk != null) { - world.getChunkProvider().unload(chunk); + world.getChunkProvider().removeTicket(TicketType.PLUGIN, chunk.getPos(), 1, Unit.INSTANCE); } return true; } - public boolean unloadChunk(int x, int z, boolean save, boolean safe) { - if (isChunkInUse(x, z)) { - return false; - } - - return unloadChunk0(x, z, save); - } - private boolean unloadChunk0(int x, int z, boolean save) { - net.minecraft.server.Chunk chunk = world.getChunkProvider().getChunkAt(x, z, false, false); + net.minecraft.server.Chunk chunk = (net.minecraft.server.Chunk) world.getChunkProvider().getChunkAt(x, z, ChunkStatus.FULL, false); if (chunk == null) { return true; } - // If chunk had previously been queued to save, must do save to avoid loss of that data - return world.getChunkProvider().unloadChunk(chunk, chunk.mustSave || save); + chunk.mustNotSave = !save; + unloadChunkRequest(x, z); + + world.getChunkProvider().purgeUnload(); + return !isChunkLoaded(x, z); } public boolean regenerateChunk(int x, int z) { + throw new UnsupportedOperationException("Not supported in this Minecraft version! Unless you can fix it, this is not a bug :)"); + /* if (!unloadChunk0(x, z, false)) { return false; } - final long chunkKey = ChunkCoordIntPair.a(x, z); + final long chunkKey = ChunkCoordIntPair.pair(x, z); world.getChunkProvider().unloadQueue.remove(chunkKey); net.minecraft.server.Chunk chunk = world.getChunkProvider().generateChunk(x, z); @@ -239,6 +222,7 @@ public class CraftWorld implements World { } return chunk != null; + */ } public boolean refreshChunk(int x, int z) { @@ -262,12 +246,24 @@ public class CraftWorld implements World { } public boolean isChunkInUse(int x, int z) { - return world.getPlayerChunkMap().isChunkInUse(x, z) || world.isForceLoaded(x, z); + return isChunkLoaded(x, z); } public boolean loadChunk(int x, int z, boolean generate) { - chunkLoadCount++; - return world.getChunkProvider().getChunkAt(x, z, true, generate) != null; + IChunkAccess chunk = world.getChunkProvider().getChunkAt(x, z, generate ? ChunkStatus.FULL : ChunkStatus.EMPTY, true); + + // If generate = false, but the chunk already exists, we will get this back. + if (chunk instanceof ProtoChunkExtension) { + // We then cycle through again to get the full chunk immediately, rather than after the ticket addition + chunk = world.getChunkProvider().getChunkAt(x, z, ChunkStatus.FULL, true); + } + + if (chunk instanceof net.minecraft.server.Chunk) { + world.getChunkProvider().addTicket(TicketType.PLUGIN, new ChunkCoordIntPair(x, z), 1, Unit.INSTANCE); + return true; + } + + return false; } public boolean isChunkLoaded(Chunk chunk) { @@ -281,7 +277,7 @@ public class CraftWorld implements World { @Override public boolean isChunkForceLoaded(int x, int z) { - return getHandle().isForceLoaded(x, z); + return getHandle().getForceLoadedChunks().contains(ChunkCoordIntPair.pair(x, z)); } @Override @@ -293,8 +289,8 @@ public class CraftWorld implements World { public Collection getForceLoadedChunks() { Set chunks = new HashSet<>(); - for (long coord : getHandle().ag()) { // PAIL - chunks.add(getChunkAt(ChunkCoordIntPair.a(coord), ChunkCoordIntPair.b(coord))); + for (long coord : getHandle().getForceLoadedChunks()) { + chunks.add(getChunkAt(ChunkCoordIntPair.getX(coord), ChunkCoordIntPair.getZ(coord))); } return Collections.unmodifiableCollection(chunks); @@ -336,14 +332,14 @@ public class CraftWorld implements World { EntityArrow arrow; if (TippedArrow.class.isAssignableFrom(clazz)) { - arrow = new EntityTippedArrow(world); + arrow = EntityTypes.ARROW.a(world); ((EntityTippedArrow) arrow).setType(CraftPotionUtil.fromBukkit(new PotionData(PotionType.WATER, false, false))); } else if (SpectralArrow.class.isAssignableFrom(clazz)) { - arrow = new EntitySpectralArrow(world); + arrow = EntityTypes.SPECTRAL_ARROW.a(world); } else if (Trident.class.isAssignableFrom(clazz)){ - arrow = new EntityThrownTrident(world); + arrow = EntityTypes.TRIDENT.a(world); } else { - arrow = new EntityTippedArrow(world); + arrow = EntityTypes.ARROW.a(world); } arrow.setPositionRotation(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch()); @@ -374,56 +370,56 @@ public class CraftWorld implements World { net.minecraft.server.WorldGenerator gen; switch (type) { case BIG_TREE: - gen = new WorldGenBigTree(true); + gen = WorldGenerator.FANCY_TREE; break; case BIRCH: - gen = new WorldGenForest(true, false); + gen = WorldGenerator.BIRCH_TREE; break; case REDWOOD: - gen = new WorldGenTaiga2(true); + gen = WorldGenerator.SPRUCE_TREE; break; case TALL_REDWOOD: - gen = new WorldGenTaiga1(); + gen = WorldGenerator.PINE_TREE; break; case JUNGLE: - gen = new WorldGenJungleTree(true, 10, 20, Blocks.JUNGLE_LOG.getBlockData(), Blocks.JUNGLE_LEAVES.getBlockData()); + gen = WorldGenerator.MEGA_JUNGLE_TREE; break; case SMALL_JUNGLE: - gen = new WorldGenTrees(true, 4 + rand.nextInt(7), Blocks.JUNGLE_LOG.getBlockData(), Blocks.JUNGLE_LEAVES.getBlockData(), false); + gen = WorldGenerator.JUNGLE_TREE; break; case COCOA_TREE: - gen = new WorldGenJungleTree(true, 10, 20, Blocks.JUNGLE_LOG.getBlockData(), Blocks.JUNGLE_LEAVES.getBlockData()); + gen = WorldGenerator.MEGA_JUNGLE_TREE; break; case JUNGLE_BUSH: - gen = new WorldGenGroundBush(Blocks.JUNGLE_LOG.getBlockData(), Blocks.OAK_LEAVES.getBlockData()); + gen = WorldGenerator.JUNGLE_GROUND_BUSH; break; case RED_MUSHROOM: - gen = new WorldGenHugeMushroomRed(); + gen = WorldGenerator.HUGE_RED_MUSHROOM; break; case BROWN_MUSHROOM: - gen = new WorldGenHugeMushroomBrown(); + gen = WorldGenerator.HUGE_BROWN_MUSHROOM; break; case SWAMP: - gen = new WorldGenSwampTree(); + gen = WorldGenerator.SWAMP_TREE; break; case ACACIA: - gen = new WorldGenAcaciaTree(true); + gen = WorldGenerator.SAVANNA_TREE; break; case DARK_OAK: - gen = new WorldGenForestTree(true); + gen = WorldGenerator.DARK_OAK_TREE; break; case MEGA_REDWOOD: - gen = new WorldGenMegaTree(false, rand.nextBoolean()); + gen = WorldGenerator.MEGA_PINE_TREE; break; case TALL_BIRCH: - gen = new WorldGenForest(true, true); + gen = WorldGenerator.SUPER_BIRCH_TREE; break; case CHORUS_PLANT: ((BlockChorusFlower) Blocks.CHORUS_FLOWER).a(world, pos, rand, 8); return true; case TREE: default: - gen = new WorldGenTrees(true); + gen = WorldGenerator.NORMAL_TREE; break; } @@ -508,7 +504,7 @@ public class CraftWorld implements World { } public boolean createExplosion(double x, double y, double z, float power, boolean setFire, boolean breakBlocks) { - return !world.createExplosion(null, x, y, z, power, setFire, breakBlocks).wasCanceled; + return !world.createExplosion(null, x, y, z, power, setFire, breakBlocks ? Explosion.Effect.BREAK : Explosion.Effect.NONE).wasCanceled; } public boolean createExplosion(Location loc, float power) { @@ -528,13 +524,13 @@ public class CraftWorld implements World { environment = env; switch (env) { case NORMAL: - world.worldProvider = new WorldProviderNormal(); + world.worldProvider = new WorldProviderNormal(world, world.dimension); break; case NETHER: - world.worldProvider = new WorldProviderHell(); + world.worldProvider = new WorldProviderHell(world, world.dimension); break; case THE_END: - world.worldProvider = new WorldProviderTheEnd(); + world.worldProvider = new WorldProviderTheEnd(world, world.dimension); break; } } @@ -597,7 +593,7 @@ public class CraftWorld implements World { public List getEntities() { List list = new ArrayList(); - for (Object o : world.entityList) { + for (Object o : world.entitiesById.values()) { if (o instanceof net.minecraft.server.Entity) { net.minecraft.server.Entity mcEnt = (net.minecraft.server.Entity) o; Entity bukkitEntity = mcEnt.getBukkitEntity(); @@ -615,7 +611,7 @@ public class CraftWorld implements World { public List getLivingEntities() { List list = new ArrayList(); - for (Object o : world.entityList) { + for (Object o : world.entitiesById.values()) { if (o instanceof net.minecraft.server.Entity) { net.minecraft.server.Entity mcEnt = (net.minecraft.server.Entity) o; Entity bukkitEntity = mcEnt.getBukkitEntity(); @@ -640,7 +636,7 @@ public class CraftWorld implements World { public Collection getEntitiesByClass(Class clazz) { Collection list = new ArrayList(); - for (Object entity: world.entityList) { + for (Object entity: world.entitiesById.values()) { if (entity instanceof net.minecraft.server.Entity) { Entity bukkitEntity = ((net.minecraft.server.Entity) entity).getBukkitEntity(); @@ -662,7 +658,7 @@ public class CraftWorld implements World { public Collection getEntitiesByClasses(Class... classes) { Collection list = new ArrayList(); - for (Object entity: world.entityList) { + for (Object entity: world.entitiesById.values()) { if (entity instanceof net.minecraft.server.Entity) { Entity bukkitEntity = ((net.minecraft.server.Entity) entity).getBukkitEntity(); @@ -807,7 +803,7 @@ public class CraftWorld implements World { Vector dir = direction.clone().normalize().multiply(maxDistance); Vec3D startPos = new Vec3D(start.getX(), start.getY(), start.getZ()); Vec3D endPos = new Vec3D(start.getX() + dir.getX(), start.getY() + dir.getY(), start.getZ() + dir.getZ()); - MovingObjectPosition nmsHitResult = this.getHandle().rayTrace(startPos, endPos, CraftFluidCollisionMode.toNMS(fluidCollisionMode), ignorePassableBlocks, false); + MovingObjectPosition nmsHitResult = this.getHandle().rayTrace(new RayTrace(startPos, endPos, ignorePassableBlocks ? RayTrace.BlockCollisionOption.COLLIDER : RayTrace.BlockCollisionOption.OUTLINE, CraftFluidCollisionMode.toNMS(fluidCollisionMode), null)); return CraftRayTraceResult.fromNMS(this, nmsHitResult); } @@ -843,9 +839,9 @@ public class CraftWorld implements World { } public List getPlayers() { - List list = new ArrayList(world.players.size()); + List list = new ArrayList(world.getPlayers().size()); - for (EntityHuman human : world.players) { + for (EntityHuman human : world.getPlayers()) { HumanEntity bukkitEntity = human.getBukkitEntity(); if ((bukkitEntity != null) && (bukkitEntity instanceof Player)) { @@ -862,7 +858,7 @@ public class CraftWorld implements World { boolean oldSave = world.savingDisabled; world.savingDisabled = false; - world.save(true, null); + world.save(null, false, false); world.savingDisabled = oldSave; } catch (ExceptionWorldConflict ex) { @@ -1045,46 +1041,48 @@ public class CraftWorld implements World { entity = new EntityEgg(world, x, y, z); } else if (Arrow.class.isAssignableFrom(clazz)) { if (TippedArrow.class.isAssignableFrom(clazz)) { - entity = new EntityTippedArrow(world); + entity = EntityTypes.ARROW.a(world); ((EntityTippedArrow) entity).setType(CraftPotionUtil.fromBukkit(new PotionData(PotionType.WATER, false, false))); } else if (SpectralArrow.class.isAssignableFrom(clazz)) { - entity = new EntitySpectralArrow(world); + entity = EntityTypes.SPECTRAL_ARROW.a(world); } else if (Trident.class.isAssignableFrom(clazz)) { - entity = new EntityThrownTrident(world); + entity = EntityTypes.TRIDENT.a(world); } else { - entity = new EntityTippedArrow(world); + entity = EntityTypes.ARROW.a(world); } entity.setPositionRotation(x, y, z, 0, 0); } else if (ThrownExpBottle.class.isAssignableFrom(clazz)) { - entity = new EntityThrownExpBottle(world); + entity = EntityTypes.EXPERIENCE_BOTTLE.a(world); entity.setPositionRotation(x, y, z, 0, 0); } else if (EnderPearl.class.isAssignableFrom(clazz)) { - entity = new EntityEnderPearl(world); + entity = EntityTypes.ENDER_PEARL.a(world); entity.setPositionRotation(x, y, z, 0, 0); } else if (ThrownPotion.class.isAssignableFrom(clazz)) { if (LingeringPotion.class.isAssignableFrom(clazz)) { - entity = new EntityPotion(world, x, y, z, CraftItemStack.asNMSCopy(new ItemStack(org.bukkit.Material.LINGERING_POTION, 1))); + entity = new EntityPotion(world, x, y, z); + ((EntityPotion) entity).setItem(CraftItemStack.asNMSCopy(new ItemStack(org.bukkit.Material.LINGERING_POTION, 1))); } else { - entity = new EntityPotion(world, x, y, z, CraftItemStack.asNMSCopy(new ItemStack(org.bukkit.Material.SPLASH_POTION, 1))); + entity = new EntityPotion(world, x, y, z); + ((EntityPotion) entity).setItem(CraftItemStack.asNMSCopy(new ItemStack(org.bukkit.Material.SPLASH_POTION, 1))); } } else if (Fireball.class.isAssignableFrom(clazz)) { if (SmallFireball.class.isAssignableFrom(clazz)) { - entity = new EntitySmallFireball(world); + entity = EntityTypes.SMALL_FIREBALL.a(world); } else if (WitherSkull.class.isAssignableFrom(clazz)) { - entity = new EntityWitherSkull(world); + entity = EntityTypes.WITHER_SKULL.a(world); } else if (DragonFireball.class.isAssignableFrom(clazz)) { - entity = new EntityDragonFireball(world); + entity = EntityTypes.DRAGON_FIREBALL.a(world); } else { - entity = new EntityLargeFireball(world); + entity = EntityTypes.FIREBALL.a(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 = EntityTypes.SHULKER_BULLET.a(world); entity.setPositionRotation(x, y, z, yaw, pitch); } else if (LlamaSpit.class.isAssignableFrom(clazz)) { - entity = new EntityLlamaSpit(world); + entity = EntityTypes.LLAMA_SPIT.a(world); entity.setPositionRotation(x, y, z, yaw, pitch); } } else if (Minecart.class.isAssignableFrom(clazz)) { @@ -1106,157 +1104,175 @@ public class CraftWorld implements World { } else if (EnderSignal.class.isAssignableFrom(clazz)) { entity = new EntityEnderSignal(world, x, y, z); } else if (EnderCrystal.class.isAssignableFrom(clazz)) { - entity = new EntityEnderCrystal(world); + entity = EntityTypes.END_CRYSTAL.a(world); entity.setPositionRotation(x, y, z, 0, 0); } else if (LivingEntity.class.isAssignableFrom(clazz)) { if (Chicken.class.isAssignableFrom(clazz)) { - entity = new EntityChicken(world); + entity = EntityTypes.CHICKEN.a(world); } else if (Cow.class.isAssignableFrom(clazz)) { if (MushroomCow.class.isAssignableFrom(clazz)) { - entity = new EntityMushroomCow(world); + entity = EntityTypes.MOOSHROOM.a(world); } else { - entity = new EntityCow(world); + entity = EntityTypes.COW.a(world); } } else if (Golem.class.isAssignableFrom(clazz)) { if (Snowman.class.isAssignableFrom(clazz)) { - entity = new EntitySnowman(world); + entity = EntityTypes.SNOW_GOLEM.a(world); } else if (IronGolem.class.isAssignableFrom(clazz)) { - entity = new EntityIronGolem(world); + entity = EntityTypes.IRON_GOLEM.a(world); } else if (Shulker.class.isAssignableFrom(clazz)) { - entity = new EntityShulker(world); + entity = EntityTypes.SHULKER.a(world); } } else if (Creeper.class.isAssignableFrom(clazz)) { - entity = new EntityCreeper(world); + entity = EntityTypes.CREEPER.a(world); } else if (Ghast.class.isAssignableFrom(clazz)) { - entity = new EntityGhast(world); + entity = EntityTypes.GHAST.a(world); } else if (Pig.class.isAssignableFrom(clazz)) { - entity = new EntityPig(world); + entity = EntityTypes.PIG.a(world); } else if (Player.class.isAssignableFrom(clazz)) { // need a net server handler for this one } else if (Sheep.class.isAssignableFrom(clazz)) { - entity = new EntitySheep(world); + entity = EntityTypes.SHEEP.a(world); } else if (AbstractHorse.class.isAssignableFrom(clazz)) { if (ChestedHorse.class.isAssignableFrom(clazz)) { if (Donkey.class.isAssignableFrom(clazz)) { - entity = new EntityHorseDonkey(world); + entity = EntityTypes.DONKEY.a(world); } else if (Mule.class.isAssignableFrom(clazz)) { - entity = new EntityHorseMule(world); + entity = EntityTypes.MULE.a(world); } else if (Llama.class.isAssignableFrom(clazz)) { - entity = new EntityLlama(world); + if (TraderLlama.class.isAssignableFrom(clazz)) { + entity = EntityTypes.TRADER_LLAMA.a(world); + } else { + entity = EntityTypes.LLAMA.a(world); + } } } else if (SkeletonHorse.class.isAssignableFrom(clazz)) { - entity = new EntityHorseSkeleton(world); + entity = EntityTypes.SKELETON_HORSE.a(world); } else if (ZombieHorse.class.isAssignableFrom(clazz)) { - entity = new EntityHorseZombie(world); + entity = EntityTypes.ZOMBIE_HORSE.a(world); } else { - entity = new EntityHorse(world); + entity = EntityTypes.HORSE.a(world); } } else if (Skeleton.class.isAssignableFrom(clazz)) { if (Stray.class.isAssignableFrom(clazz)){ - entity = new EntitySkeletonStray(world); + entity = EntityTypes.STRAY.a(world); } else if (WitherSkeleton.class.isAssignableFrom(clazz)) { - entity = new EntitySkeletonWither(world); + entity = EntityTypes.WITHER_SKELETON.a(world); } else { - entity = new EntitySkeleton(world); + entity = EntityTypes.SKELETON.a(world); } } else if (Slime.class.isAssignableFrom(clazz)) { if (MagmaCube.class.isAssignableFrom(clazz)) { - entity = new EntityMagmaCube(world); + entity = EntityTypes.MAGMA_CUBE.a(world); } else { - entity = new EntitySlime(world); + entity = EntityTypes.SLIME.a(world); } } else if (Spider.class.isAssignableFrom(clazz)) { if (CaveSpider.class.isAssignableFrom(clazz)) { - entity = new EntityCaveSpider(world); + entity = EntityTypes.CAVE_SPIDER.a(world); } else { - entity = new EntitySpider(world); + entity = EntityTypes.SPIDER.a(world); } } else if (Squid.class.isAssignableFrom(clazz)) { - entity = new EntitySquid(world); + entity = EntityTypes.SQUID.a(world); } else if (Tameable.class.isAssignableFrom(clazz)) { if (Wolf.class.isAssignableFrom(clazz)) { - entity = new EntityWolf(world); - } else if (Ocelot.class.isAssignableFrom(clazz)) { - entity = new EntityOcelot(world); + entity = EntityTypes.WOLF.a(world); } else if (Parrot.class.isAssignableFrom(clazz)) { - entity = new EntityParrot(world); + entity = EntityTypes.PARROT.a(world); } } else if (PigZombie.class.isAssignableFrom(clazz)) { - entity = new EntityPigZombie(world); + entity = EntityTypes.ZOMBIE_PIGMAN.a(world); } else if (Zombie.class.isAssignableFrom(clazz)) { if (Husk.class.isAssignableFrom(clazz)) { - entity = new EntityZombieHusk(world); + entity = EntityTypes.HUSK.a(world); } else if (ZombieVillager.class.isAssignableFrom(clazz)) { - entity = new EntityZombieVillager(world); + entity = EntityTypes.ZOMBIE_VILLAGER.a(world); } else if (Drowned.class.isAssignableFrom(clazz)) { - entity = new EntityDrowned(world); + entity = EntityTypes.DROWNED.a(world); } else { entity = new EntityZombie(world); } } else if (Giant.class.isAssignableFrom(clazz)) { - entity = new EntityGiantZombie(world); + entity = EntityTypes.GIANT.a(world); } else if (Silverfish.class.isAssignableFrom(clazz)) { - entity = new EntitySilverfish(world); + entity = EntityTypes.SILVERFISH.a(world); } else if (Enderman.class.isAssignableFrom(clazz)) { - entity = new EntityEnderman(world); + entity = EntityTypes.ENDERMAN.a(world); } else if (Blaze.class.isAssignableFrom(clazz)) { - entity = new EntityBlaze(world); - } else if (Villager.class.isAssignableFrom(clazz)) { - entity = new EntityVillager(world); + entity = EntityTypes.BLAZE.a(world); + } else if (AbstractVillager.class.isAssignableFrom(clazz)) { + if (Villager.class.isAssignableFrom(clazz)) { + entity = EntityTypes.VILLAGER.a(world); + } else if (WanderingTrader.class.isAssignableFrom(clazz)) { + entity = EntityTypes.WANDERING_TRADER.a(world); + } } else if (Witch.class.isAssignableFrom(clazz)) { - entity = new EntityWitch(world); + entity = EntityTypes.WITCH.a(world); } else if (Wither.class.isAssignableFrom(clazz)) { - entity = new EntityWither(world); + entity = EntityTypes.WITHER.a(world); } else if (ComplexLivingEntity.class.isAssignableFrom(clazz)) { if (EnderDragon.class.isAssignableFrom(clazz)) { - entity = new EntityEnderDragon(world); + entity = EntityTypes.ENDER_DRAGON.a(world); } } else if (Ambient.class.isAssignableFrom(clazz)) { if (Bat.class.isAssignableFrom(clazz)) { - entity = new EntityBat(world); + entity = EntityTypes.BAT.a(world); } } else if (Rabbit.class.isAssignableFrom(clazz)) { - entity = new EntityRabbit(world); + entity = EntityTypes.RABBIT.a(world); } else if (Endermite.class.isAssignableFrom(clazz)) { - entity = new EntityEndermite(world); + entity = EntityTypes.ENDERMITE.a(world); } else if (Guardian.class.isAssignableFrom(clazz)) { if (ElderGuardian.class.isAssignableFrom(clazz)){ - entity = new EntityGuardianElder(world); + entity = EntityTypes.ELDER_GUARDIAN.a(world); } else { - entity = new EntityGuardian(world); + entity = EntityTypes.GUARDIAN.a(world); } } else if (ArmorStand.class.isAssignableFrom(clazz)) { entity = new EntityArmorStand(world, x, y, z); } else if (PolarBear.class.isAssignableFrom(clazz)) { - entity = new EntityPolarBear(world); + entity = EntityTypes.POLAR_BEAR.a(world); } else if (Vex.class.isAssignableFrom(clazz)) { - entity = new EntityVex(world); + entity = EntityTypes.VEX.a(world); } else if (Illager.class.isAssignableFrom(clazz)) { if (Spellcaster.class.isAssignableFrom(clazz)) { if (Evoker.class.isAssignableFrom(clazz)) { - entity = new EntityEvoker(world); + entity = EntityTypes.EVOKER.a(world); } else if (Illusioner.class.isAssignableFrom(clazz)) { - entity = new EntityIllagerIllusioner(world); + entity = EntityTypes.ILLUSIONER.a(world); } } else if (Vindicator.class.isAssignableFrom(clazz)) { - entity = new EntityVindicator(world); + entity = EntityTypes.VINDICATOR.a(world); + } else if (Pillager.class.isAssignableFrom(clazz)) { + entity = EntityTypes.PILLAGER.a(world); } } else if (Turtle.class.isAssignableFrom(clazz)) { - entity = new EntityTurtle(world); + entity = EntityTypes.TURTLE.a(world); } else if (Phantom.class.isAssignableFrom(clazz)) { - entity = new EntityPhantom(world); + entity = EntityTypes.PHANTOM.a(world); } else if (Fish.class.isAssignableFrom(clazz)) { if (Cod.class.isAssignableFrom(clazz)) { - entity = new EntityCod(world); + entity = EntityTypes.COD.a(world); } else if (PufferFish.class.isAssignableFrom(clazz)) { - entity = new EntityPufferFish(world); + entity = EntityTypes.PUFFERFISH.a(world); } else if (Salmon.class.isAssignableFrom(clazz)) { - entity = new EntitySalmon(world); + entity = EntityTypes.SALMON.a(world); } else if (TropicalFish.class.isAssignableFrom(clazz)) { - entity = new EntityTropicalFish(world); + entity = EntityTypes.TROPICAL_FISH.a(world); } } else if (Dolphin.class.isAssignableFrom(clazz)) { - entity = new EntityDolphin(world); + entity = EntityTypes.DOLPHIN.a(world); + } else if (Ocelot.class.isAssignableFrom(clazz)) { + entity = EntityTypes.OCELOT.a(world); + } else if (Cat.class.isAssignableFrom(clazz)) { + entity = EntityTypes.CAT.a(world); + } else if (Ravager.class.isAssignableFrom(clazz)) { + entity = EntityTypes.RAVAGER.a(world); + } else if (Panda.class.isAssignableFrom(clazz)) { + entity = EntityTypes.PANDA.a(world); + } else if (Fox.class.isAssignableFrom(clazz)) { + entity = EntityTypes.FOX.a(world); } if (entity != null) { @@ -1321,12 +1337,8 @@ public class CraftWorld implements World { entity = new EntityTNTPrimed(world, x, y, z, null); } else if (ExperienceOrb.class.isAssignableFrom(clazz)) { entity = new EntityExperienceOrb(world, x, y, z, 0); - } else if (Weather.class.isAssignableFrom(clazz)) { - // not sure what this can do - if (LightningStrike.class.isAssignableFrom(clazz)) { - entity = new EntityLightning(world, x, y, z, false); - // what is this, I don't even - } + } else if (LightningStrike.class.isAssignableFrom(clazz)) { + entity = new EntityLightning(world, x, y, z, false); } else if (Firework.class.isAssignableFrom(clazz)) { entity = new EntityFireworks(world, x, y, z, net.minecraft.server.ItemStack.a); } else if (AreaEffectCloud.class.isAssignableFrom(clazz)) { @@ -1352,7 +1364,7 @@ public class CraftWorld implements World { Preconditions.checkArgument(entity != null, "Cannot spawn null entity"); if (entity instanceof EntityInsentient) { - ((EntityInsentient) entity).prepare(getHandle().getDamageScaler(new BlockPosition(entity)), (GroupDataEntity) null, null); + ((EntityInsentient) entity).prepare(getHandle(), getHandle().getDamageScaler(new BlockPosition(entity)), EnumMobSpawn.COMMAND, (GroupDataEntity) null, null); } if (function != null) { @@ -1378,11 +1390,11 @@ public class CraftWorld implements World { } public boolean getAllowAnimals() { - return world.allowAnimals; + return world.getChunkProvider().allowAnimals; } public boolean getAllowMonsters() { - return world.allowMonsters; + return world.getChunkProvider().allowMonsters; } public int getMaxHeight() { @@ -1584,7 +1596,7 @@ public class CraftWorld implements World { } GameRules.GameRuleValue value = getHandle().getGameRules().get(rule); - return value != null ? value.a() : ""; + return value != null ? value.getValue() : ""; } public boolean setGameRuleValue(String rule, String value) { @@ -1636,9 +1648,9 @@ public class CraftWorld implements World { switch (value.getType()) { case BOOLEAN_VALUE: - return rule.getType().cast(value.b()); + return rule.getType().cast(value.getBooleanValue()); case NUMERICAL_VALUE: - return rule.getType().cast(value.c()); + return rule.getType().cast(value.getIntValue()); default: throw new IllegalArgumentException("Invalid GameRule type (" + value.getType() + ") for GameRule " + rule.getName()); } @@ -1741,32 +1753,4 @@ public class CraftWorld implements World { BlockPosition nearest = getHandle().getChunkProvider().getChunkGenerator().findNearestMapFeature(getHandle(), structureType.getName(), originPos, radius, findUnexplored); return (nearest == null) ? null : new Location(this, nearest.getX(), nearest.getY(), nearest.getZ()); } - - public void processChunkGC() { - chunkGCTickCount++; - - if (chunkLoadCount >= server.chunkGCLoadThresh && server.chunkGCLoadThresh > 0) { - chunkLoadCount = 0; - } else if (chunkGCTickCount >= server.chunkGCPeriod && server.chunkGCPeriod > 0) { - chunkGCTickCount = 0; - } else { - return; - } - - ChunkProviderServer cps = world.getChunkProvider(); - for (net.minecraft.server.Chunk chunk : cps.chunks.values()) { - // If in use, skip it - if (isChunkInUse(chunk.locX, chunk.locZ)) { - continue; - } - - // Already unloading? - if (cps.unloadQueue.contains(ChunkCoordIntPair.a(chunk.locX, chunk.locZ))) { - continue; - } - - // Add unload request - cps.unload(chunk); - } - } } diff --git a/src/main/java/org/bukkit/craftbukkit/TrigMath.java b/src/main/java/org/bukkit/craftbukkit/TrigMath.java deleted file mode 100644 index 6d613c53c6..0000000000 --- a/src/main/java/org/bukkit/craftbukkit/TrigMath.java +++ /dev/null @@ -1,47 +0,0 @@ -package org.bukkit.craftbukkit; - -/** - * Credits for this class goes to user aioobe on stackoverflow.com - * Source: http://stackoverflow.com/questions/4454630/j2me-calculate-the-the-distance-between-2-latitude-and-longitude - */ -public class TrigMath { - - static final double sq2p1 = 2.414213562373095048802e0; - static final double sq2m1 = .414213562373095048802e0; - static final double p4 = .161536412982230228262e2; - static final double p3 = .26842548195503973794141e3; - static final double p2 = .11530293515404850115428136e4; - static final double p1 = .178040631643319697105464587e4; - static final double p0 = .89678597403663861959987488e3; - static final double q4 = .5895697050844462222791e2; - static final double q3 = .536265374031215315104235e3; - static final double q2 = .16667838148816337184521798e4; - static final double q1 = .207933497444540981287275926e4; - static final double q0 = .89678597403663861962481162e3; - static final double PIO2 = 1.5707963267948966135E0; - - private static double mxatan(double arg) { - double argsq = arg * arg, value; - - value = ((((p4 * argsq + p3) * argsq + p2) * argsq + p1) * argsq + p0); - value = value / (((((argsq + q4) * argsq + q3) * argsq + q2) * argsq + q1) * argsq + q0); - return value * arg; - } - - private static double msatan(double arg) { - return arg < sq2m1 ? mxatan(arg) - : arg > sq2p1 ? PIO2 - mxatan(1 / arg) - : PIO2 / 2 + mxatan((arg - 1) / (arg + 1)); - } - - public static double atan(double arg) { - return arg > 0 ? msatan(arg) : -msatan(-arg); - } - - public static double atan2(double arg1, double arg2) { - if (arg1 + arg2 == arg1) - return arg1 >= 0 ? PIO2 : -PIO2; - arg1 = atan(arg1 / arg2); - return arg2 < 0 ? arg1 <= 0 ? arg1 + Math.PI : arg1 - Math.PI : arg1; - } -} \ No newline at end of file diff --git a/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeInstance.java b/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeInstance.java index 07b457e8a3..49852d971e 100644 --- a/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeInstance.java +++ b/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeInstance.java @@ -66,10 +66,10 @@ public class CraftAttributeInstance implements AttributeInstance { } public static net.minecraft.server.AttributeModifier convert(AttributeModifier bukkit) { - return new net.minecraft.server.AttributeModifier(bukkit.getUniqueId(), bukkit.getName(), bukkit.getAmount(), bukkit.getOperation().ordinal()); + return new net.minecraft.server.AttributeModifier(bukkit.getUniqueId(), bukkit.getName(), bukkit.getAmount(), net.minecraft.server.AttributeModifier.Operation.values()[bukkit.getOperation().ordinal()]); } public static AttributeModifier convert(net.minecraft.server.AttributeModifier nms) { - return new AttributeModifier(nms.a(), nms.b(), nms.d(), AttributeModifier.Operation.values()[nms.c()]); + return new AttributeModifier(nms.a(), nms.b(), nms.d(), AttributeModifier.Operation.values()[nms.c().ordinal()]); } } diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBarrel.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBarrel.java new file mode 100644 index 0000000000..cb5ac0f098 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBarrel.java @@ -0,0 +1,33 @@ +package org.bukkit.craftbukkit.block; + +import net.minecraft.server.TileEntityBarrel; +import org.bukkit.Material; +import org.bukkit.block.Barrel; +import org.bukkit.block.Block; +import org.bukkit.craftbukkit.inventory.CraftInventory; +import org.bukkit.inventory.Inventory; + +public class CraftBarrel extends CraftLootable implements Barrel { + + public CraftBarrel(Block block) { + super(block, TileEntityBarrel.class); + } + + public CraftBarrel(Material material, TileEntityBarrel te) { + super(material, te); + } + + @Override + public Inventory getSnapshotInventory() { + return new CraftInventory(this.getSnapshot()); + } + + @Override + public Inventory getInventory() { + if (!this.isPlaced()) { + return this.getSnapshotInventory(); + } + + return new CraftInventory(this.getTileEntity()); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java index 5b908d3bf5..21ebceafbf 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java @@ -2,6 +2,7 @@ package org.bukkit.craftbukkit.block; import java.util.ArrayList; import java.util.Collection; +import net.minecraft.server.ChestLock; import net.minecraft.server.EntityHuman; import net.minecraft.server.MobEffectList; import net.minecraft.server.TileEntity; @@ -9,14 +10,12 @@ import net.minecraft.server.TileEntityBeacon; import org.bukkit.Material; import org.bukkit.block.Beacon; import org.bukkit.block.Block; -import org.bukkit.craftbukkit.inventory.CraftInventoryBeacon; import org.bukkit.craftbukkit.util.CraftChatMessage; import org.bukkit.entity.LivingEntity; -import org.bukkit.inventory.BeaconInventory; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; -public class CraftBeacon extends CraftContainer implements Beacon { +public class CraftBeacon extends CraftBlockEntityState implements Beacon { public CraftBeacon(final Block block) { super(block, TileEntityBeacon.class); @@ -26,20 +25,6 @@ public class CraftBeacon extends CraftContainer implements Bea super(material, te); } - @Override - public BeaconInventory getSnapshotInventory() { - return new CraftInventoryBeacon(this.getSnapshot()); - } - - @Override - public BeaconInventory getInventory() { - if (!this.isPlaced()) { - return this.getSnapshotInventory(); - } - - return new CraftInventoryBeacon(this.getTileEntity()); - } - @Override public Collection getEntitiesInRange() { TileEntity tileEntity = this.getTileEntityFromWorld(); @@ -88,11 +73,26 @@ public class CraftBeacon extends CraftContainer implements Bea @Override public String getCustomName() { TileEntityBeacon beacon = this.getSnapshot(); - return beacon.hasCustomName() ? CraftChatMessage.fromComponent(beacon.getCustomName()) : null; + return beacon.customName != null ? CraftChatMessage.fromComponent(beacon.customName) : null; } @Override public void setCustomName(String name) { this.getSnapshot().setCustomName(CraftChatMessage.fromStringOrNull(name)); } + + @Override + public boolean isLocked() { + return !this.getSnapshot().chestLock.key.isEmpty(); + } + + @Override + public String getLock() { + return this.getSnapshot().chestLock.key; + } + + @Override + public void setLock(String key) { + this.getSnapshot().chestLock = (key == null) ? ChestLock.a : new ChestLock(key); + } } diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBell.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBell.java new file mode 100644 index 0000000000..bf5d0c3a15 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBell.java @@ -0,0 +1,16 @@ +package org.bukkit.craftbukkit.block; + +import net.minecraft.server.TileEntityBell; +import org.bukkit.Material; +import org.bukkit.block.Block; + +public class CraftBell extends CraftBlockEntityState { + + public CraftBell(Block block) { + super(block, TileEntityBell.class); + } + + public CraftBell(Material material, TileEntityBell te) { + super(material, te); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlastFurnace.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlastFurnace.java new file mode 100644 index 0000000000..8ed4d99fee --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlastFurnace.java @@ -0,0 +1,17 @@ +package org.bukkit.craftbukkit.block; + +import net.minecraft.server.TileEntityBlastFurnace; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlastFurnace; + +public class CraftBlastFurnace extends CraftFurnace implements BlastFurnace { + + public CraftBlastFurnace(Block block) { + super(block, TileEntityBlastFurnace.class); + } + + public CraftBlastFurnace(Material material, TileEntityBlastFurnace te) { + super(material, te); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java index 4b4fdf93f6..afef6a11ca 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java @@ -5,6 +5,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; +import java.util.stream.Collectors; import net.minecraft.server.*; @@ -40,7 +41,7 @@ public class CraftBlock implements Block { public CraftBlock(GeneratorAccess world, BlockPosition position) { this.world = world; - this.position = position.h(); + this.position = position.immutableCopy(); } public static CraftBlock at(GeneratorAccess world, BlockPosition position) { @@ -158,7 +159,12 @@ public class CraftBlock implements Block { public boolean setTypeAndData(final IBlockData blockData, final boolean applyPhysics) { // SPIGOT-611: need to do this to prevent glitchiness. Easier to handle this here (like /setblock) than to fix weirdness in tile entity cleanup if (!blockData.isAir() && blockData.getBlock() instanceof BlockTileEntity && blockData.getBlock() != getNMSBlock()) { - world.setTypeAndData(position, Blocks.AIR.getBlockData(), 0); + // SPIGOT-4612: faster - just clear tile + if (world instanceof net.minecraft.server.World) { + ((net.minecraft.server.World) world).removeTileEntity(position); + } else { + world.setTypeAndData(position, Blocks.AIR.getBlockData(), 0); + } } if (applyPhysics) { @@ -278,14 +284,24 @@ public class CraftBlock implements Block { Material material = getType(); switch (material) { - case SIGN: - case WALL_SIGN: + case ACACIA_SIGN: + case ACACIA_WALL_SIGN: + case BIRCH_SIGN: + case BIRCH_WALL_SIGN: + case DARK_OAK_SIGN: + case DARK_OAK_WALL_SIGN: + case JUNGLE_SIGN: + case JUNGLE_WALL_SIGN: + case OAK_SIGN: + case OAK_WALL_SIGN: + case SPRUCE_SIGN: + case SPRUCE_WALL_SIGN: return new CraftSign(this); case CHEST: case TRAPPED_CHEST: return new CraftChest(this); case FURNACE: - return new CraftFurnace(this); + return new CraftFurnaceFurnace(this); case DISPENSER: return new CraftDispenser(this); case DROPPER: @@ -399,6 +415,22 @@ public class CraftBlock implements Block { return new CraftBed(this); case CONDUIT: return new CraftConduit(this); + case BARRIER: + return new CraftBarrel(this); + case BARREL: + return new CraftBarrel(this); + case BELL: + return new CraftBell(this); + case BLAST_FURNACE: + return new CraftBlastFurnace(this); + case CAMPFIRE: + return new CraftCampfire(this); + case JIGSAW: + return new CraftJigsaw(this); + case LECTERN: + return new CraftLectern(this); + case SMOKER: + return new CraftSmoker(this); default: TileEntity tileEntity = world.getTileEntity(position); if (tileEntity != null) { @@ -512,80 +544,30 @@ public class CraftBlock implements Block { return PistonMoveReaction.getById(getNMS().getPushReaction().ordinal()); } - private boolean itemCausesDrops(ItemStack item) { - net.minecraft.server.Block block = this.getNMSBlock(); - net.minecraft.server.Item itemType = CraftMagicNumbers.getItem(item.getType()); - return block != null && (block.getBlockData().getMaterial().isAlwaysDestroyable() || (itemType != null && itemType.canDestroySpecialBlock(block.getBlockData()))); + public boolean breakNaturally() { + return breakNaturally(new ItemStack(Material.AIR)); } - public boolean breakNaturally() { + public boolean breakNaturally(ItemStack item) { // Order matters here, need to drop before setting to air so skulls can get their data net.minecraft.server.Block block = this.getNMSBlock(); boolean result = false; if (block != null && block != Blocks.AIR) { - block.dropNaturally(getNMS(), world.getMinecraftWorld(), position, 1.0F, 0); + net.minecraft.server.Block.dropItems(getNMS(), world.getMinecraftWorld(), position, world.getTileEntity(position), null, CraftItemStack.asNMSCopy(item)); result = true; } - setType(Material.AIR); - return result; - } - - public boolean breakNaturally(ItemStack item) { - if (itemCausesDrops(item)) { - return breakNaturally(); - } else { - return setTypeAndData(Blocks.AIR.getBlockData(), true); - } + return setTypeAndData(Blocks.AIR.getBlockData(), true) && result; } public Collection getDrops() { - List drops = new ArrayList(); - - net.minecraft.server.Block block = this.getNMSBlock(); - if (block != Blocks.AIR) { - IBlockData data = getData0(); - // based on nms.Block.dropNaturally - int count = block.getDropCount(data, 0, world.getMinecraftWorld(), position, world.getMinecraftWorld().random); - for (int i = 0; i < count; ++i) { - Item item = block.getDropType(data, world.getMinecraftWorld(), position, 0).getItem(); - if (item != Items.AIR) { - // Skulls are special, their data is based on the tile entity - if (block instanceof BlockSkullAbstract) { - net.minecraft.server.ItemStack nmsStack = block.a((IBlockAccess) world, position, data); - TileEntitySkull tileentityskull = (TileEntitySkull) world.getTileEntity(position); - - if ((block == Blocks.PLAYER_HEAD || block == Blocks.PLAYER_WALL_HEAD) && tileentityskull.getGameProfile() != null) { - NBTTagCompound nbttagcompound = new NBTTagCompound(); - - GameProfileSerializer.serialize(nbttagcompound, tileentityskull.getGameProfile()); - nmsStack.getOrCreateTag().set("SkullOwner", nbttagcompound); - } - - 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) data.get(BlockCocoa.AGE); - int dropAmount = (age >= 2 ? 3 : 1); - for (int j = 0; j < dropAmount; ++j) { - drops.add(new ItemStack(Material.COCOA_BEANS, 1)); - } - } else { - drops.add(new ItemStack(org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(item), 1)); - } - } - } - } - return drops; + return getDrops(new ItemStack(Material.AIR)); } public Collection getDrops(ItemStack item) { - if (itemCausesDrops(item)) { - return getDrops(); - } else { - return Collections.emptyList(); - } + return net.minecraft.server.Block.getDrops(getNMS(), (WorldServer) world.getMinecraftWorld(), position, world.getTileEntity(position), null, CraftItemStack.asNMSCopy(item)) + .stream().map(CraftItemStack::asBukkitCopy).collect(Collectors.toList()); } public void setMetadata(String metadataKey, MetadataValue newMetadataValue) { @@ -628,25 +610,7 @@ public class CraftBlock implements Block { Vec3D startPos = new Vec3D(start.getX(), start.getY(), start.getZ()); Vec3D endPos = new Vec3D(start.getX() + dir.getX(), start.getY() + dir.getY(), start.getZ() + dir.getZ()); - // Similar to to nms.World#rayTrace: - IBlockData blockData = world.getType(position); - Fluid fluid = world.getFluid(position); - boolean collidableBlock = blockData.getBlock().isCollidable(blockData); - boolean collideWithFluid = CraftFluidCollisionMode.toNMS(fluidCollisionMode).predicate.test(fluid); - - if (!collidableBlock && !collideWithFluid) { - return null; - } - - MovingObjectPosition nmsHitResult = null; - if (collidableBlock) { - nmsHitResult = net.minecraft.server.Block.rayTrace(blockData, world.getMinecraftWorld(), position, startPos, endPos); - } - - if (nmsHitResult == null && collideWithFluid) { - nmsHitResult = VoxelShapes.create(0.0D, 0.0D, 0.0D, 1.0D, (double) fluid.getHeight(), 1.0D).rayTrace(startPos, endPos, position); - } - + MovingObjectPosition nmsHitResult = world.rayTrace(new RayTrace(startPos, endPos, RayTrace.BlockCollisionOption.OUTLINE, CraftFluidCollisionMode.toNMS(fluidCollisionMode), null)); return CraftRayTraceResult.fromNMS(this.getWorld(), nmsHitResult); } diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBrewingStand.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBrewingStand.java index dafaa6fb3c..89038ffc45 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBrewingStand.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBrewingStand.java @@ -34,41 +34,21 @@ public class CraftBrewingStand extends CraftContainer im @Override public int getBrewingTime() { - return this.getSnapshot().getProperty(0); + return this.getSnapshot().brewTime; } @Override public void setBrewingTime(int brewTime) { - this.getSnapshot().setProperty(0, brewTime); + this.getSnapshot().brewTime = brewTime; } @Override public int getFuelLevel() { - return this.getSnapshot().getProperty(1); + return this.getSnapshot().fuelLevel; } @Override public void setFuelLevel(int level) { - this.getSnapshot().setProperty(1, level); - } - - @Override - public String getCustomName() { - TileEntityBrewingStand brewingStand = this.getSnapshot(); - return brewingStand.hasCustomName() ? CraftChatMessage.fromComponent(brewingStand.getCustomName()) : null; - } - - @Override - public void setCustomName(String name) { - this.getSnapshot().setCustomName(CraftChatMessage.fromStringOrNull(name)); - } - - @Override - public void applyTo(TileEntityBrewingStand brewingStand) { - super.applyTo(brewingStand); - - if (!this.getSnapshot().hasCustomName()) { - brewingStand.setCustomName(null); - } + this.getSnapshot().fuelLevel = level; } } diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftCampfire.java b/src/main/java/org/bukkit/craftbukkit/block/CraftCampfire.java new file mode 100644 index 0000000000..95d10dd9f2 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftCampfire.java @@ -0,0 +1,55 @@ +package org.bukkit.craftbukkit.block; + +import net.minecraft.server.TileEntityCampfire; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.Campfire; +import org.bukkit.craftbukkit.inventory.CraftItemStack; +import org.bukkit.inventory.ItemStack; + +public class CraftCampfire extends CraftBlockEntityState implements Campfire { + + public CraftCampfire(Block block) { + super(block, TileEntityCampfire.class); + } + + public CraftCampfire(Material material, TileEntityCampfire te) { + super(material, te); + } + + @Override + public int getSize() { + return getSnapshot().getItems().size(); + } + + @Override + public ItemStack getItem(int index) { + net.minecraft.server.ItemStack item = getSnapshot().getItems().get(index); + return item.isEmpty() ? null : CraftItemStack.asCraftMirror(item); + } + + @Override + public void setItem(int index, ItemStack item) { + getSnapshot().getItems().set(index, CraftItemStack.asNMSCopy(item)); + } + + @Override + public int getCookTime(int index) { + return getSnapshot().cookingTimes[index]; + } + + @Override + public void setCookTime(int index, int cookTime) { + getSnapshot().cookingTimes[index] = cookTime; + } + + @Override + public int getCookTimeTotal(int index) { + return getSnapshot().cookingTotalTimes[index]; + } + + @Override + public void setCookTimeTotal(int index, int cookTimeTotal) { + getSnapshot().cookingTotalTimes[index] = cookTimeTotal; + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java b/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java index fa03d17a4c..f881a6be7e 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java @@ -49,7 +49,7 @@ public class CraftChest extends CraftLootable implements Chest CraftWorld world = (CraftWorld) this.getWorld(); BlockChest blockChest = (BlockChest) (this.getType() == Material.CHEST ? Blocks.CHEST : Blocks.TRAPPED_CHEST); - ITileInventory nms = blockChest.getInventory(data, world.getHandle(), this.getPosition(), true); + ITileInventory nms = blockChest.getInventory(data, world.getHandle(), this.getPosition()); if (nms instanceof InventoryLargeChest) { inventory = new CraftInventoryDoubleChest((InventoryLargeChest) nms); diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftContainer.java b/src/main/java/org/bukkit/craftbukkit/block/CraftContainer.java index 06a1d4473a..36ba813e56 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftContainer.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftContainer.java @@ -5,6 +5,7 @@ import net.minecraft.server.TileEntityContainer; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.Container; +import org.bukkit.craftbukkit.util.CraftChatMessage; public abstract class CraftContainer extends CraftBlockEntityState implements Container { @@ -18,16 +19,36 @@ public abstract class CraftContainer extends Craf @Override public boolean isLocked() { - return this.getSnapshot().isLocked(); + return !this.getSnapshot().chestLock.key.isEmpty(); } @Override public String getLock() { - return this.getSnapshot().getLock().getKey(); + return this.getSnapshot().chestLock.key; } @Override public void setLock(String key) { - this.getSnapshot().setLock(key == null ? ChestLock.a : new ChestLock(key)); + this.getSnapshot().chestLock = (key == null) ? ChestLock.a : new ChestLock(key); + } + + @Override + public String getCustomName() { + T container = this.getSnapshot(); + return container.customName != null ? CraftChatMessage.fromComponent(container.getCustomName()) : null; + } + + @Override + public void setCustomName(String name) { + this.getSnapshot().setCustomName(CraftChatMessage.fromStringOrNull(name)); + } + + @Override + public void applyTo(T container) { + super.applyTo(container); + + if (this.getSnapshot().customName == null) { + container.setCustomName(null); + } } } diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java b/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java index aa63b854d1..835d394df3 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java @@ -32,7 +32,7 @@ public class CraftCreatureSpawner extends CraftBlockEntityState implements Furnace { +public class CraftFurnace extends CraftContainer implements Furnace { - public CraftFurnace(final Block block) { - super(block, TileEntityFurnace.class); + public CraftFurnace(Block block, Class tileEntityClass) { + super(block, tileEntityClass); } - public CraftFurnace(final Material material, final TileEntityFurnace te) { + public CraftFurnace(final Material material, final T te) { super(material, te); } @@ -35,53 +34,33 @@ public class CraftFurnace extends CraftContainer implements F @Override public short getBurnTime() { - return (short) this.getSnapshot().getProperty(0); + return (short) this.getSnapshot().burnTime; } @Override public void setBurnTime(short burnTime) { - this.getSnapshot().setProperty(0, burnTime); + this.getSnapshot().burnTime = burnTime; // SPIGOT-844: Allow lighting and relighting using this API this.data = this.data.set(BlockFurnace.LIT, burnTime > 0); } @Override public short getCookTime() { - return (short) this.getSnapshot().getProperty(2); + return (short) this.getSnapshot().cookTime; } @Override public void setCookTime(short cookTime) { - this.getSnapshot().setProperty(2, cookTime); + this.getSnapshot().cookTime = cookTime; } @Override public int getCookTimeTotal() { - return this.getSnapshot().getProperty(3); + return this.getSnapshot().cookTimeTotal; } @Override public void setCookTimeTotal(int cookTimeTotal) { - this.getSnapshot().setProperty(3, cookTimeTotal); - } - - @Override - public String getCustomName() { - TileEntityFurnace furnace = this.getSnapshot(); - return furnace.hasCustomName() ? CraftChatMessage.fromComponent(furnace.getCustomName()) : null; - } - - @Override - public void setCustomName(String name) { - this.getSnapshot().setCustomName(CraftChatMessage.fromStringOrNull(name)); - } - - @Override - public void applyTo(TileEntityFurnace furnace) { - super.applyTo(furnace); - - if (!this.getSnapshot().hasCustomName()) { - furnace.setCustomName(null); - } + this.getSnapshot().cookTimeTotal = cookTimeTotal; } } diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftFurnaceFurnace.java b/src/main/java/org/bukkit/craftbukkit/block/CraftFurnaceFurnace.java new file mode 100644 index 0000000000..fd8b91c1b4 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftFurnaceFurnace.java @@ -0,0 +1,16 @@ +package org.bukkit.craftbukkit.block; + +import net.minecraft.server.TileEntityFurnaceFurnace; +import org.bukkit.Material; +import org.bukkit.block.Block; + +public class CraftFurnaceFurnace extends CraftFurnace { + + public CraftFurnaceFurnace(Block block) { + super(block, TileEntityFurnaceFurnace.class); + } + + public CraftFurnaceFurnace(Material material, TileEntityFurnaceFurnace te) { + super(material, te); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftJigsaw.java b/src/main/java/org/bukkit/craftbukkit/block/CraftJigsaw.java new file mode 100644 index 0000000000..bbce44c487 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftJigsaw.java @@ -0,0 +1,17 @@ +package org.bukkit.craftbukkit.block; + +import net.minecraft.server.TileEntityJigsaw; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.Jigsaw; + +public class CraftJigsaw extends CraftBlockEntityState implements Jigsaw { + + public CraftJigsaw(Block block) { + super(block, TileEntityJigsaw.class); + } + + public CraftJigsaw(Material material, TileEntityJigsaw te) { + super(material, te); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftLectern.java b/src/main/java/org/bukkit/craftbukkit/block/CraftLectern.java new file mode 100644 index 0000000000..63db8fd92e --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftLectern.java @@ -0,0 +1,43 @@ +package org.bukkit.craftbukkit.block; + +import net.minecraft.server.TileEntityLectern; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.Lectern; +import org.bukkit.craftbukkit.inventory.CraftInventory; +import org.bukkit.inventory.Inventory; + +public class CraftLectern extends CraftBlockEntityState implements Lectern { + + public CraftLectern(Block block) { + super(block, TileEntityLectern.class); + } + + public CraftLectern(Material material, TileEntityLectern te) { + super(material, te); + } + + @Override + public int getPage() { + return getSnapshot().getPage(); + } + + @Override + public void setPage(int page) { + getSnapshot().setPage(page); + } + + @Override + public Inventory getSnapshotInventory() { + return new CraftInventory(this.getSnapshot().inventory); + } + + @Override + public Inventory getInventory() { + if (!this.isPlaced()) { + return this.getSnapshotInventory(); + } + + return new CraftInventory(this.getTileEntity().inventory); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftLootable.java b/src/main/java/org/bukkit/craftbukkit/block/CraftLootable.java index 7ef68bb626..e1ad26a242 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftLootable.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftLootable.java @@ -6,7 +6,6 @@ import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.Nameable; import org.bukkit.block.Block; -import org.bukkit.craftbukkit.util.CraftChatMessage; import org.bukkit.craftbukkit.util.CraftNamespacedKey; import org.bukkit.loot.LootTable; import org.bukkit.loot.Lootable; @@ -21,36 +20,22 @@ public abstract class CraftLootable extends CraftC super(material, tileEntity); } - @Override - public String getCustomName() { - T lootable = this.getSnapshot(); - return lootable.hasCustomName() ? CraftChatMessage.fromComponent(lootable.getCustomName()) : null; - } - - @Override - public void setCustomName(String name) { - this.getSnapshot().setCustomName(CraftChatMessage.fromStringOrNull(name)); - } - @Override public void applyTo(T lootable) { super.applyTo(lootable); - if (!this.getSnapshot().hasCustomName()) { - lootable.setCustomName(null); - } - if (this.getSnapshot().getLootTable() == null) { + if (this.getSnapshot().lootTable == null) { lootable.setLootTable((MinecraftKey) null, 0L); } } @Override public LootTable getLootTable() { - if (getSnapshot().getLootTable() == null) { + if (getSnapshot().lootTable == null) { return null; } - MinecraftKey key = getSnapshot().getLootTable(); + MinecraftKey key = getSnapshot().lootTable; return Bukkit.getLootTable(CraftNamespacedKey.fromMinecraft(key)); } @@ -61,7 +46,7 @@ public abstract class CraftLootable extends CraftC @Override public long getSeed() { - return getSnapshotNBT().getLong("LootTableSeed"); // returns OL if an error occurred + return getSnapshot().lootTableSeed; } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftSkull.java b/src/main/java/org/bukkit/craftbukkit/block/CraftSkull.java index 110e04597b..9d563e538c 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftSkull.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftSkull.java @@ -34,7 +34,7 @@ public class CraftSkull extends CraftBlockEntityState implement public void load(TileEntitySkull skull) { super.load(skull); - profile = skull.getGameProfile(); + profile = skull.gameProfile; } static int getSkullType(SkullType type) { diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftSmoker.java b/src/main/java/org/bukkit/craftbukkit/block/CraftSmoker.java new file mode 100644 index 0000000000..40bfcad469 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftSmoker.java @@ -0,0 +1,17 @@ +package org.bukkit.craftbukkit.block; + +import net.minecraft.server.TileEntitySmoker; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.Smoker; + +public class CraftSmoker extends CraftFurnace implements Smoker { + + public CraftSmoker(Block block) { + super(block, TileEntitySmoker.class); + } + + public CraftSmoker(Material material, TileEntitySmoker te) { + super(material, te); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java b/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java index 7755e4f7a6..ab049ed52c 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java +++ b/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java @@ -275,6 +275,10 @@ public class CraftBlockData implements BlockData { return stateString.toString(); } + public String toStates() { + return ((BlockDataAbstract) state).getStateMap().entrySet().stream().map(BlockDataAbstract.STATE_TO_VALUE).collect(Collectors.joining(",")).toString(); + } + @Override public boolean equals(Object obj) { return obj instanceof CraftBlockData && state.equals(((CraftBlockData) obj).state); @@ -331,7 +335,7 @@ public class CraftBlockData implements BlockData { private static IBlockState getState(Class block, String name, boolean optional) { IBlockState state = null; - for (Block instance : (Iterable) IRegistry.BLOCK) { // Eclipse fail + for (Block instance : IRegistry.BLOCK) { if (instance.getClass() == block) { if (state == null) { state = instance.getStates().a(name); @@ -374,14 +378,19 @@ public class CraftBlockData implements BlockData { static { // register(net.minecraft.server.BlockAnvil.class, org.bukkit.craftbukkit.block.impl.CraftAnvil::new); + register(net.minecraft.server.BlockBamboo.class, org.bukkit.craftbukkit.block.impl.CraftBamboo::new); register(net.minecraft.server.BlockBanner.class, org.bukkit.craftbukkit.block.impl.CraftBanner::new); register(net.minecraft.server.BlockBannerWall.class, org.bukkit.craftbukkit.block.impl.CraftBannerWall::new); + register(net.minecraft.server.BlockBarrel.class, org.bukkit.craftbukkit.block.impl.CraftBarrel::new); register(net.minecraft.server.BlockBed.class, org.bukkit.craftbukkit.block.impl.CraftBed::new); register(net.minecraft.server.BlockBeetroot.class, org.bukkit.craftbukkit.block.impl.CraftBeetroot::new); + register(net.minecraft.server.BlockBell.class, org.bukkit.craftbukkit.block.impl.CraftBell::new); + register(net.minecraft.server.BlockBlastFurnace.class, org.bukkit.craftbukkit.block.impl.CraftBlastFurnace::new); register(net.minecraft.server.BlockBrewingStand.class, org.bukkit.craftbukkit.block.impl.CraftBrewingStand::new); register(net.minecraft.server.BlockBubbleColumn.class, org.bukkit.craftbukkit.block.impl.CraftBubbleColumn::new); register(net.minecraft.server.BlockCactus.class, org.bukkit.craftbukkit.block.impl.CraftCactus::new); register(net.minecraft.server.BlockCake.class, org.bukkit.craftbukkit.block.impl.CraftCake::new); + register(net.minecraft.server.BlockCampfire.class, org.bukkit.craftbukkit.block.impl.CraftCampfire::new); register(net.minecraft.server.BlockCarrots.class, org.bukkit.craftbukkit.block.impl.CraftCarrots::new); register(net.minecraft.server.BlockCauldron.class, org.bukkit.craftbukkit.block.impl.CraftCauldron::new); register(net.minecraft.server.BlockChest.class, org.bukkit.craftbukkit.block.impl.CraftChest::new); @@ -391,6 +400,7 @@ public class CraftBlockData implements BlockData { register(net.minecraft.server.BlockCobbleWall.class, org.bukkit.craftbukkit.block.impl.CraftCobbleWall::new); register(net.minecraft.server.BlockCocoa.class, org.bukkit.craftbukkit.block.impl.CraftCocoa::new); register(net.minecraft.server.BlockCommand.class, org.bukkit.craftbukkit.block.impl.CraftCommand::new); + register(net.minecraft.server.BlockComposter.class, org.bukkit.craftbukkit.block.impl.CraftComposter::new); register(net.minecraft.server.BlockConduit.class, org.bukkit.craftbukkit.block.impl.CraftConduit::new); register(net.minecraft.server.BlockCoralDead.class, org.bukkit.craftbukkit.block.impl.CraftCoralDead::new); register(net.minecraft.server.BlockCoralFan.class, org.bukkit.craftbukkit.block.impl.CraftCoralFan::new); @@ -412,21 +422,25 @@ public class CraftBlockData implements BlockData { register(net.minecraft.server.BlockFire.class, org.bukkit.craftbukkit.block.impl.CraftFire::new); register(net.minecraft.server.BlockFloorSign.class, org.bukkit.craftbukkit.block.impl.CraftFloorSign::new); register(net.minecraft.server.BlockFluids.class, org.bukkit.craftbukkit.block.impl.CraftFluids::new); - register(net.minecraft.server.BlockFurnace.class, org.bukkit.craftbukkit.block.impl.CraftFurnace::new); - register(net.minecraft.server.BlockGlassPane.class, org.bukkit.craftbukkit.block.impl.CraftGlassPane::new); + register(net.minecraft.server.BlockFurnaceFurace.class, org.bukkit.craftbukkit.block.impl.CraftFurnaceFurace::new); register(net.minecraft.server.BlockGlazedTerracotta.class, org.bukkit.craftbukkit.block.impl.CraftGlazedTerracotta::new); register(net.minecraft.server.BlockGrass.class, org.bukkit.craftbukkit.block.impl.CraftGrass::new); + register(net.minecraft.server.BlockGrindstone.class, org.bukkit.craftbukkit.block.impl.CraftGrindstone::new); register(net.minecraft.server.BlockHay.class, org.bukkit.craftbukkit.block.impl.CraftHay::new); register(net.minecraft.server.BlockHopper.class, org.bukkit.craftbukkit.block.impl.CraftHopper::new); register(net.minecraft.server.BlockHugeMushroom.class, org.bukkit.craftbukkit.block.impl.CraftHugeMushroom::new); register(net.minecraft.server.BlockIceFrost.class, org.bukkit.craftbukkit.block.impl.CraftIceFrost::new); register(net.minecraft.server.BlockIronBars.class, org.bukkit.craftbukkit.block.impl.CraftIronBars::new); + register(net.minecraft.server.BlockJigsaw.class, org.bukkit.craftbukkit.block.impl.CraftJigsaw::new); register(net.minecraft.server.BlockJukeBox.class, org.bukkit.craftbukkit.block.impl.CraftJukeBox::new); register(net.minecraft.server.BlockKelp.class, org.bukkit.craftbukkit.block.impl.CraftKelp::new); register(net.minecraft.server.BlockLadder.class, org.bukkit.craftbukkit.block.impl.CraftLadder::new); + register(net.minecraft.server.BlockLantern.class, org.bukkit.craftbukkit.block.impl.CraftLantern::new); register(net.minecraft.server.BlockLeaves.class, org.bukkit.craftbukkit.block.impl.CraftLeaves::new); + register(net.minecraft.server.BlockLectern.class, org.bukkit.craftbukkit.block.impl.CraftLectern::new); register(net.minecraft.server.BlockLever.class, org.bukkit.craftbukkit.block.impl.CraftLever::new); register(net.minecraft.server.BlockLogAbstract.class, org.bukkit.craftbukkit.block.impl.CraftLogAbstract::new); + register(net.minecraft.server.BlockLoom.class, org.bukkit.craftbukkit.block.impl.CraftLoom::new); register(net.minecraft.server.BlockMinecartDetector.class, org.bukkit.craftbukkit.block.impl.CraftMinecartDetector::new); register(net.minecraft.server.BlockMinecartTrack.class, org.bukkit.craftbukkit.block.impl.CraftMinecartTrack::new); register(net.minecraft.server.BlockMycel.class, org.bukkit.craftbukkit.block.impl.CraftMycel::new); @@ -452,12 +466,14 @@ public class CraftBlockData implements BlockData { register(net.minecraft.server.BlockRepeater.class, org.bukkit.craftbukkit.block.impl.CraftRepeater::new); register(net.minecraft.server.BlockRotatable.class, org.bukkit.craftbukkit.block.impl.CraftRotatable::new); register(net.minecraft.server.BlockSapling.class, org.bukkit.craftbukkit.block.impl.CraftSapling::new); + register(net.minecraft.server.BlockScaffolding.class, org.bukkit.craftbukkit.block.impl.CraftScaffolding::new); register(net.minecraft.server.BlockSeaPickle.class, org.bukkit.craftbukkit.block.impl.CraftSeaPickle::new); register(net.minecraft.server.BlockShulkerBox.class, org.bukkit.craftbukkit.block.impl.CraftShulkerBox::new); register(net.minecraft.server.BlockSkull.class, org.bukkit.craftbukkit.block.impl.CraftSkull::new); register(net.minecraft.server.BlockSkullPlayer.class, org.bukkit.craftbukkit.block.impl.CraftSkullPlayer::new); register(net.minecraft.server.BlockSkullPlayerWall.class, org.bukkit.craftbukkit.block.impl.CraftSkullPlayerWall::new); register(net.minecraft.server.BlockSkullWall.class, org.bukkit.craftbukkit.block.impl.CraftSkullWall::new); + register(net.minecraft.server.BlockSmoker.class, org.bukkit.craftbukkit.block.impl.CraftSmoker::new); register(net.minecraft.server.BlockSnow.class, org.bukkit.craftbukkit.block.impl.CraftSnow::new); register(net.minecraft.server.BlockSoil.class, org.bukkit.craftbukkit.block.impl.CraftSoil::new); register(net.minecraft.server.BlockStainedGlassPane.class, org.bukkit.craftbukkit.block.impl.CraftStainedGlassPane::new); @@ -466,10 +482,12 @@ public class CraftBlockData implements BlockData { register(net.minecraft.server.BlockStemAttached.class, org.bukkit.craftbukkit.block.impl.CraftStemAttached::new); register(net.minecraft.server.BlockStepAbstract.class, org.bukkit.craftbukkit.block.impl.CraftStepAbstract::new); register(net.minecraft.server.BlockStoneButton.class, org.bukkit.craftbukkit.block.impl.CraftStoneButton::new); + register(net.minecraft.server.BlockStonecutter.class, org.bukkit.craftbukkit.block.impl.CraftStonecutter::new); register(net.minecraft.server.BlockStructure.class, org.bukkit.craftbukkit.block.impl.CraftStructure::new); + register(net.minecraft.server.BlockSweetBerryBush.class, org.bukkit.craftbukkit.block.impl.CraftSweetBerryBush::new); register(net.minecraft.server.BlockTNT.class, org.bukkit.craftbukkit.block.impl.CraftTNT::new); + register(net.minecraft.server.BlockTallPlant.class, org.bukkit.craftbukkit.block.impl.CraftTallPlant::new); register(net.minecraft.server.BlockTallPlantFlower.class, org.bukkit.craftbukkit.block.impl.CraftTallPlantFlower::new); - register(net.minecraft.server.BlockTallPlantShearable.class, org.bukkit.craftbukkit.block.impl.CraftTallPlantShearable::new); register(net.minecraft.server.BlockTallSeaGrass.class, org.bukkit.craftbukkit.block.impl.CraftTallSeaGrass::new); register(net.minecraft.server.BlockTorchWall.class, org.bukkit.craftbukkit.block.impl.CraftTorchWall::new); register(net.minecraft.server.BlockTrapdoor.class, org.bukkit.craftbukkit.block.impl.CraftTrapdoor::new); diff --git a/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftBamboo.java b/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftBamboo.java new file mode 100644 index 0000000000..65485a9ed6 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftBamboo.java @@ -0,0 +1,19 @@ +package org.bukkit.craftbukkit.block.data.type; + +import org.bukkit.block.data.type.Bamboo; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +public abstract class CraftBamboo extends CraftBlockData implements Bamboo { + + private static final net.minecraft.server.BlockStateEnum LEAVES = getEnum("leaves"); + + @Override + public Leaves getLeaves() { + return get(LEAVES, Leaves.class); + } + + @Override + public void setLeaves(Leaves leaves) { + set(LEAVES, leaves); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftCampfire.java b/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftCampfire.java new file mode 100644 index 0000000000..99250172b7 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftCampfire.java @@ -0,0 +1,19 @@ +package org.bukkit.craftbukkit.block.data.type; + +import org.bukkit.block.data.type.Campfire; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +public abstract class CraftCampfire extends CraftBlockData implements Campfire { + + private static final net.minecraft.server.BlockStateBoolean SIGNAL_FIRE = getBoolean("signal_fire"); + + @Override + public boolean isSignalFire() { + return get(SIGNAL_FIRE); + } + + @Override + public void setSignalFire(boolean signalFire) { + set(SIGNAL_FIRE, signalFire); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftLantern.java b/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftLantern.java new file mode 100644 index 0000000000..01bdf9d80d --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftLantern.java @@ -0,0 +1,19 @@ +package org.bukkit.craftbukkit.block.data.type; + +import org.bukkit.block.data.type.Lantern; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +public abstract class CraftLantern extends CraftBlockData implements Lantern { + + private static final net.minecraft.server.BlockStateBoolean HANGING = getBoolean("hanging"); + + @Override + public boolean isHanging() { + return get(HANGING); + } + + @Override + public void setHanging(boolean hanging) { + set(HANGING, hanging); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftLectern.java b/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftLectern.java new file mode 100644 index 0000000000..1ecdf4718f --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftLectern.java @@ -0,0 +1,14 @@ +package org.bukkit.craftbukkit.block.data.type; + +import org.bukkit.block.data.type.Lectern; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +public abstract class CraftLectern extends CraftBlockData implements Lectern { + + private static final net.minecraft.server.BlockStateBoolean HAS_BOOK = getBoolean("has_book"); + + @Override + public boolean hasBook() { + return get(HAS_BOOK); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftScaffolding.java b/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftScaffolding.java new file mode 100644 index 0000000000..fe896908c2 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftScaffolding.java @@ -0,0 +1,35 @@ +package org.bukkit.craftbukkit.block.data.type; + +import org.bukkit.block.data.type.Scaffolding; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +public abstract class CraftScaffolding extends CraftBlockData implements Scaffolding { + + private static final net.minecraft.server.BlockStateBoolean BOTTOM = getBoolean("bottom"); + private static final net.minecraft.server.BlockStateInteger DISTANCE = getInteger("distance"); + + @Override + public boolean isBottom() { + return get(BOTTOM); + } + + @Override + public void setBottom(boolean bottom) { + set(BOTTOM, bottom); + } + + @Override + public int getDistance() { + return get(DISTANCE); + } + + @Override + public void setDistance(int distance) { + set(DISTANCE, distance); + } + + @Override + public int getMaximumDistance() { + return getMax(DISTANCE); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftBamboo.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftBamboo.java new file mode 100644 index 0000000000..3c650d4f89 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftBamboo.java @@ -0,0 +1,67 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftBamboo extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Bamboo, org.bukkit.block.data.Ageable, org.bukkit.block.data.type.Sapling { + + public CraftBamboo() { + super(); + } + + public CraftBamboo(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.type.CraftBamboo + + private static final net.minecraft.server.BlockStateEnum LEAVES = getEnum(net.minecraft.server.BlockBamboo.class, "leaves"); + + @Override + public Leaves getLeaves() { + return get(LEAVES, Leaves.class); + } + + @Override + public void setLeaves(Leaves leaves) { + set(LEAVES, leaves); + } + + // org.bukkit.craftbukkit.block.data.CraftAgeable + + private static final net.minecraft.server.BlockStateInteger AGE = getInteger(net.minecraft.server.BlockBamboo.class, "age"); + + @Override + public int getAge() { + return get(AGE); + } + + @Override + public void setAge(int age) { + set(AGE, age); + } + + @Override + public int getMaximumAge() { + return getMax(AGE); + } + + // org.bukkit.craftbukkit.block.data.type.CraftSapling + + private static final net.minecraft.server.BlockStateInteger STAGE = getInteger(net.minecraft.server.BlockBamboo.class, "stage"); + + @Override + public int getStage() { + return get(STAGE); + } + + @Override + public void setStage(int stage) { + set(STAGE, stage); + } + + @Override + public int getMaximumStage() { + return getMax(STAGE); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftBarrel.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftBarrel.java new file mode 100644 index 0000000000..81919c9412 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftBarrel.java @@ -0,0 +1,34 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftBarrel extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Directional { + + public CraftBarrel() { + super(); + } + + public CraftBarrel(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.CraftDirectional + + private static final net.minecraft.server.BlockStateEnum FACING = getEnum(net.minecraft.server.BlockBarrel.class, "facing"); + + @Override + public org.bukkit.block.BlockFace getFacing() { + return get(FACING, org.bukkit.block.BlockFace.class); + } + + @Override + public void setFacing(org.bukkit.block.BlockFace facing) { + set(FACING, facing); + } + + @Override + public java.util.Set getFaces() { + return getValues(FACING, org.bukkit.block.BlockFace.class); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftBell.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftBell.java new file mode 100644 index 0000000000..12c4c46330 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftBell.java @@ -0,0 +1,34 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftBell extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Bell, org.bukkit.block.data.Directional { + + public CraftBell() { + super(); + } + + public CraftBell(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.CraftDirectional + + private static final net.minecraft.server.BlockStateEnum FACING = getEnum(net.minecraft.server.BlockBell.class, "facing"); + + @Override + public org.bukkit.block.BlockFace getFacing() { + return get(FACING, org.bukkit.block.BlockFace.class); + } + + @Override + public void setFacing(org.bukkit.block.BlockFace facing) { + set(FACING, facing); + } + + @Override + public java.util.Set getFaces() { + return getValues(FACING, org.bukkit.block.BlockFace.class); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftBlastFurnace.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftBlastFurnace.java new file mode 100644 index 0000000000..8e223604fb --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftBlastFurnace.java @@ -0,0 +1,48 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftBlastFurnace extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Furnace, org.bukkit.block.data.Directional, org.bukkit.block.data.Lightable { + + public CraftBlastFurnace() { + super(); + } + + public CraftBlastFurnace(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.CraftDirectional + + private static final net.minecraft.server.BlockStateEnum FACING = getEnum(net.minecraft.server.BlockBlastFurnace.class, "facing"); + + @Override + public org.bukkit.block.BlockFace getFacing() { + return get(FACING, org.bukkit.block.BlockFace.class); + } + + @Override + public void setFacing(org.bukkit.block.BlockFace facing) { + set(FACING, facing); + } + + @Override + public java.util.Set getFaces() { + return getValues(FACING, org.bukkit.block.BlockFace.class); + } + + // org.bukkit.craftbukkit.block.data.CraftLightable + + private static final net.minecraft.server.BlockStateBoolean LIT = getBoolean(net.minecraft.server.BlockBlastFurnace.class, "lit"); + + @Override + public boolean isLit() { + return get(LIT); + } + + @Override + public void setLit(boolean lit) { + set(LIT, lit); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCampfire.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCampfire.java new file mode 100644 index 0000000000..a9fcc7ab9d --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCampfire.java @@ -0,0 +1,57 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftCampfire extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Campfire, org.bukkit.block.data.Lightable, org.bukkit.block.data.Waterlogged { + + public CraftCampfire() { + super(); + } + + public CraftCampfire(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.type.CraftCampfire + + private static final net.minecraft.server.BlockStateBoolean SIGNAL_FIRE = getBoolean(net.minecraft.server.BlockCampfire.class, "signal_fire"); + + @Override + public boolean isSignalFire() { + return get(SIGNAL_FIRE); + } + + @Override + public void setSignalFire(boolean signalFire) { + set(SIGNAL_FIRE, signalFire); + } + + // org.bukkit.craftbukkit.block.data.CraftLightable + + private static final net.minecraft.server.BlockStateBoolean LIT = getBoolean(net.minecraft.server.BlockCampfire.class, "lit"); + + @Override + public boolean isLit() { + return get(LIT); + } + + @Override + public void setLit(boolean lit) { + set(LIT, lit); + } + + // org.bukkit.craftbukkit.block.data.CraftWaterlogged + + private static final net.minecraft.server.BlockStateBoolean WATERLOGGED = getBoolean(net.minecraft.server.BlockCampfire.class, "waterlogged"); + + @Override + public boolean isWaterlogged() { + return get(WATERLOGGED); + } + + @Override + public void setWaterlogged(boolean waterlogged) { + set(WATERLOGGED, waterlogged); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftComposter.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftComposter.java new file mode 100644 index 0000000000..536628624f --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftComposter.java @@ -0,0 +1,34 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftComposter extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Levelled { + + public CraftComposter() { + super(); + } + + public CraftComposter(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.CraftLevelled + + private static final net.minecraft.server.BlockStateInteger LEVEL = getInteger(net.minecraft.server.BlockComposter.class, "level"); + + @Override + public int getLevel() { + return get(LEVEL); + } + + @Override + public void setLevel(int level) { + set(LEVEL, level); + } + + @Override + public int getMaximumLevel() { + return getMax(LEVEL); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftFurnaceFurace.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftFurnaceFurace.java new file mode 100644 index 0000000000..49d4b885eb --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftFurnaceFurace.java @@ -0,0 +1,48 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftFurnaceFurace extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Furnace, org.bukkit.block.data.Directional, org.bukkit.block.data.Lightable { + + public CraftFurnaceFurace() { + super(); + } + + public CraftFurnaceFurace(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.CraftDirectional + + private static final net.minecraft.server.BlockStateEnum FACING = getEnum(net.minecraft.server.BlockFurnaceFurace.class, "facing"); + + @Override + public org.bukkit.block.BlockFace getFacing() { + return get(FACING, org.bukkit.block.BlockFace.class); + } + + @Override + public void setFacing(org.bukkit.block.BlockFace facing) { + set(FACING, facing); + } + + @Override + public java.util.Set getFaces() { + return getValues(FACING, org.bukkit.block.BlockFace.class); + } + + // org.bukkit.craftbukkit.block.data.CraftLightable + + private static final net.minecraft.server.BlockStateBoolean LIT = getBoolean(net.minecraft.server.BlockFurnaceFurace.class, "lit"); + + @Override + public boolean isLit() { + return get(LIT); + } + + @Override + public void setLit(boolean lit) { + set(LIT, lit); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftGlassPane.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftGlassPane.java deleted file mode 100644 index 4c8bfcb733..0000000000 --- a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftGlassPane.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * Automatically generated file, changes will be lost. - */ -package org.bukkit.craftbukkit.block.impl; - -public final class CraftGlassPane extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.GlassPane, org.bukkit.block.data.MultipleFacing, org.bukkit.block.data.Waterlogged { - - public CraftGlassPane() { - super(); - } - - public CraftGlassPane(net.minecraft.server.IBlockData state) { - super(state); - } - - // org.bukkit.craftbukkit.block.data.CraftMultipleFacing - - private static final net.minecraft.server.BlockStateBoolean[] FACES = new net.minecraft.server.BlockStateBoolean[]{ - getBoolean(net.minecraft.server.BlockGlassPane.class, "north", true), getBoolean(net.minecraft.server.BlockGlassPane.class, "east", true), getBoolean(net.minecraft.server.BlockGlassPane.class, "south", true), getBoolean(net.minecraft.server.BlockGlassPane.class, "west", true), getBoolean(net.minecraft.server.BlockGlassPane.class, "up", true), getBoolean(net.minecraft.server.BlockGlassPane.class, "down", true) - }; - - @Override - public boolean hasFace(org.bukkit.block.BlockFace face) { - return get(FACES[face.ordinal()]); - } - - @Override - public void setFace(org.bukkit.block.BlockFace face, boolean has) { - set(FACES[face.ordinal()], has); - } - - @Override - public java.util.Set getFaces() { - com.google.common.collect.ImmutableSet.Builder faces = com.google.common.collect.ImmutableSet.builder(); - - for (int i = 0; i < FACES.length; i++) { - if (FACES[i] != null && get(FACES[i])) { - faces.add(org.bukkit.block.BlockFace.values()[i]); - } - } - - return faces.build(); - } - - @Override - public java.util.Set getAllowedFaces() { - com.google.common.collect.ImmutableSet.Builder faces = com.google.common.collect.ImmutableSet.builder(); - - for (int i = 0; i < FACES.length; i++) { - if (FACES[i] != null) { - faces.add(org.bukkit.block.BlockFace.values()[i]); - } - } - - return faces.build(); - } - - // org.bukkit.craftbukkit.block.data.CraftWaterlogged - - private static final net.minecraft.server.BlockStateBoolean WATERLOGGED = getBoolean(net.minecraft.server.BlockGlassPane.class, "waterlogged"); - - @Override - public boolean isWaterlogged() { - return get(WATERLOGGED); - } - - @Override - public void setWaterlogged(boolean waterlogged) { - set(WATERLOGGED, waterlogged); - } -} diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftGrindstone.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftGrindstone.java new file mode 100644 index 0000000000..f4c08558e9 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftGrindstone.java @@ -0,0 +1,34 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftGrindstone extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Directional { + + public CraftGrindstone() { + super(); + } + + public CraftGrindstone(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.CraftDirectional + + private static final net.minecraft.server.BlockStateEnum FACING = getEnum(net.minecraft.server.BlockGrindstone.class, "facing"); + + @Override + public org.bukkit.block.BlockFace getFacing() { + return get(FACING, org.bukkit.block.BlockFace.class); + } + + @Override + public void setFacing(org.bukkit.block.BlockFace facing) { + set(FACING, facing); + } + + @Override + public java.util.Set getFaces() { + return getValues(FACING, org.bukkit.block.BlockFace.class); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftJigsaw.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftJigsaw.java new file mode 100644 index 0000000000..10f0094b7f --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftJigsaw.java @@ -0,0 +1,34 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftJigsaw extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Directional { + + public CraftJigsaw() { + super(); + } + + public CraftJigsaw(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.CraftDirectional + + private static final net.minecraft.server.BlockStateEnum FACING = getEnum(net.minecraft.server.BlockJigsaw.class, "facing"); + + @Override + public org.bukkit.block.BlockFace getFacing() { + return get(FACING, org.bukkit.block.BlockFace.class); + } + + @Override + public void setFacing(org.bukkit.block.BlockFace facing) { + set(FACING, facing); + } + + @Override + public java.util.Set getFaces() { + return getValues(FACING, org.bukkit.block.BlockFace.class); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftLantern.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftLantern.java new file mode 100644 index 0000000000..8e279de3e0 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftLantern.java @@ -0,0 +1,29 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftLantern extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Lantern { + + public CraftLantern() { + super(); + } + + public CraftLantern(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.type.CraftLantern + + private static final net.minecraft.server.BlockStateBoolean HANGING = getBoolean(net.minecraft.server.BlockLantern.class, "hanging"); + + @Override + public boolean isHanging() { + return get(HANGING); + } + + @Override + public void setHanging(boolean hanging) { + set(HANGING, hanging); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftLectern.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftLectern.java new file mode 100644 index 0000000000..f7fa832ed3 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftLectern.java @@ -0,0 +1,57 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftLectern extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Lectern, org.bukkit.block.data.Directional, org.bukkit.block.data.Powerable { + + public CraftLectern() { + super(); + } + + public CraftLectern(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.type.CraftLectern + + private static final net.minecraft.server.BlockStateBoolean HAS_BOOK = getBoolean(net.minecraft.server.BlockLectern.class, "has_book"); + + @Override + public boolean hasBook() { + return get(HAS_BOOK); + } + + // org.bukkit.craftbukkit.block.data.CraftDirectional + + private static final net.minecraft.server.BlockStateEnum FACING = getEnum(net.minecraft.server.BlockLectern.class, "facing"); + + @Override + public org.bukkit.block.BlockFace getFacing() { + return get(FACING, org.bukkit.block.BlockFace.class); + } + + @Override + public void setFacing(org.bukkit.block.BlockFace facing) { + set(FACING, facing); + } + + @Override + public java.util.Set getFaces() { + return getValues(FACING, org.bukkit.block.BlockFace.class); + } + + // org.bukkit.craftbukkit.block.data.CraftPowerable + + private static final net.minecraft.server.BlockStateBoolean POWERED = getBoolean(net.minecraft.server.BlockLectern.class, "powered"); + + @Override + public boolean isPowered() { + return get(POWERED); + } + + @Override + public void setPowered(boolean powered) { + set(POWERED, powered); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftLoom.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftLoom.java new file mode 100644 index 0000000000..e0e56dc957 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftLoom.java @@ -0,0 +1,34 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftLoom extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Directional { + + public CraftLoom() { + super(); + } + + public CraftLoom(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.CraftDirectional + + private static final net.minecraft.server.BlockStateEnum FACING = getEnum(net.minecraft.server.BlockLoom.class, "facing"); + + @Override + public org.bukkit.block.BlockFace getFacing() { + return get(FACING, org.bukkit.block.BlockFace.class); + } + + @Override + public void setFacing(org.bukkit.block.BlockFace facing) { + set(FACING, facing); + } + + @Override + public java.util.Set getFaces() { + return getValues(FACING, org.bukkit.block.BlockFace.class); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftScaffolding.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftScaffolding.java new file mode 100644 index 0000000000..857e4d1fca --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftScaffolding.java @@ -0,0 +1,59 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftScaffolding extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Scaffolding, org.bukkit.block.data.Waterlogged { + + public CraftScaffolding() { + super(); + } + + public CraftScaffolding(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.type.CraftScaffolding + + private static final net.minecraft.server.BlockStateBoolean BOTTOM = getBoolean(net.minecraft.server.BlockScaffolding.class, "bottom"); + private static final net.minecraft.server.BlockStateInteger DISTANCE = getInteger(net.minecraft.server.BlockScaffolding.class, "distance"); + + @Override + public boolean isBottom() { + return get(BOTTOM); + } + + @Override + public void setBottom(boolean bottom) { + set(BOTTOM, bottom); + } + + @Override + public int getDistance() { + return get(DISTANCE); + } + + @Override + public void setDistance(int distance) { + set(DISTANCE, distance); + } + + @Override + public int getMaximumDistance() { + return getMax(DISTANCE); + } + + // org.bukkit.craftbukkit.block.data.CraftWaterlogged + + private static final net.minecraft.server.BlockStateBoolean WATERLOGGED = getBoolean(net.minecraft.server.BlockScaffolding.class, "waterlogged"); + + @Override + public boolean isWaterlogged() { + return get(WATERLOGGED); + } + + @Override + public void setWaterlogged(boolean waterlogged) { + set(WATERLOGGED, waterlogged); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftFurnace.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftSmoker.java similarity index 69% rename from src/main/java/org/bukkit/craftbukkit/block/impl/CraftFurnace.java rename to src/main/java/org/bukkit/craftbukkit/block/impl/CraftSmoker.java index 1ca1a9c796..c14aed35cb 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftFurnace.java +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftSmoker.java @@ -3,19 +3,19 @@ */ package org.bukkit.craftbukkit.block.impl; -public final class CraftFurnace extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Furnace, org.bukkit.block.data.Directional, org.bukkit.block.data.Lightable { +public final class CraftSmoker extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Furnace, org.bukkit.block.data.Directional, org.bukkit.block.data.Lightable { - public CraftFurnace() { + public CraftSmoker() { super(); } - public CraftFurnace(net.minecraft.server.IBlockData state) { + public CraftSmoker(net.minecraft.server.IBlockData state) { super(state); } // org.bukkit.craftbukkit.block.data.CraftDirectional - private static final net.minecraft.server.BlockStateEnum FACING = getEnum(net.minecraft.server.BlockFurnace.class, "facing"); + private static final net.minecraft.server.BlockStateEnum FACING = getEnum(net.minecraft.server.BlockSmoker.class, "facing"); @Override public org.bukkit.block.BlockFace getFacing() { @@ -34,7 +34,7 @@ public final class CraftFurnace extends org.bukkit.craftbukkit.block.data.CraftB // org.bukkit.craftbukkit.block.data.CraftLightable - private static final net.minecraft.server.BlockStateBoolean LIT = getBoolean(net.minecraft.server.BlockFurnace.class, "lit"); + private static final net.minecraft.server.BlockStateBoolean LIT = getBoolean(net.minecraft.server.BlockSmoker.class, "lit"); @Override public boolean isLit() { diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftStonecutter.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftStonecutter.java new file mode 100644 index 0000000000..7a2789eb7b --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftStonecutter.java @@ -0,0 +1,34 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftStonecutter extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Directional { + + public CraftStonecutter() { + super(); + } + + public CraftStonecutter(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.CraftDirectional + + private static final net.minecraft.server.BlockStateEnum FACING = getEnum(net.minecraft.server.BlockStonecutter.class, "facing"); + + @Override + public org.bukkit.block.BlockFace getFacing() { + return get(FACING, org.bukkit.block.BlockFace.class); + } + + @Override + public void setFacing(org.bukkit.block.BlockFace facing) { + set(FACING, facing); + } + + @Override + public java.util.Set getFaces() { + return getValues(FACING, org.bukkit.block.BlockFace.class); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftSweetBerryBush.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftSweetBerryBush.java new file mode 100644 index 0000000000..2733a067e7 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftSweetBerryBush.java @@ -0,0 +1,34 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftSweetBerryBush extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Ageable { + + public CraftSweetBerryBush() { + super(); + } + + public CraftSweetBerryBush(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.CraftAgeable + + private static final net.minecraft.server.BlockStateInteger AGE = getInteger(net.minecraft.server.BlockSweetBerryBush.class, "age"); + + @Override + public int getAge() { + return get(AGE); + } + + @Override + public void setAge(int age) { + set(AGE, age); + } + + @Override + public int getMaximumAge() { + return getMax(AGE); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTallPlantShearable.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTallPlant.java similarity index 57% rename from src/main/java/org/bukkit/craftbukkit/block/impl/CraftTallPlantShearable.java rename to src/main/java/org/bukkit/craftbukkit/block/impl/CraftTallPlant.java index c98414b3bc..0ed0ad0cff 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTallPlantShearable.java +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTallPlant.java @@ -3,19 +3,19 @@ */ package org.bukkit.craftbukkit.block.impl; -public final class CraftTallPlantShearable extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Bisected { +public final class CraftTallPlant extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Bisected { - public CraftTallPlantShearable() { + public CraftTallPlant() { super(); } - public CraftTallPlantShearable(net.minecraft.server.IBlockData state) { + public CraftTallPlant(net.minecraft.server.IBlockData state) { super(state); } // org.bukkit.craftbukkit.block.data.CraftBisected - private static final net.minecraft.server.BlockStateEnum HALF = getEnum(net.minecraft.server.BlockTallPlantShearable.class, "half"); + private static final net.minecraft.server.BlockStateEnum HALF = getEnum(net.minecraft.server.BlockTallPlant.class, "half"); @Override public Half getHalf() { diff --git a/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOExecutor.java b/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOExecutor.java deleted file mode 100644 index e4fd9bc604..0000000000 --- a/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOExecutor.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.bukkit.craftbukkit.chunkio; - -import net.minecraft.server.Chunk; -import net.minecraft.server.ChunkProviderServer; -import net.minecraft.server.ChunkRegionLoader; -import net.minecraft.server.World; -import org.bukkit.craftbukkit.util.AsynchronousExecutor; - -public class ChunkIOExecutor { - static final int BASE_THREADS = 1; - static final int PLAYERS_PER_THREAD = 50; - - private static final AsynchronousExecutor instance = new AsynchronousExecutor(new ChunkIOProvider(), BASE_THREADS); - - public static Chunk syncChunkLoad(World world, ChunkRegionLoader loader, ChunkProviderServer provider, int x, int z) { - return instance.getSkipQueue(new QueuedChunk(x, z, loader, world, provider)); - } - - public static void queueChunkLoad(World world, ChunkRegionLoader loader, ChunkProviderServer provider, int x, int z, Runnable runnable) { - instance.add(new QueuedChunk(x, z, loader, world, provider), runnable); - } - - // Abuses the fact that hashCode and equals for QueuedChunk only use world and coords - public static void dropQueuedChunkLoad(World world, int x, int z, Runnable runnable) { - instance.drop(new QueuedChunk(x, z, null, world, null), runnable); - } - - public static void adjustPoolSize(int players) { - int size = Math.max(BASE_THREADS, (int) Math.ceil(players / PLAYERS_PER_THREAD)); - instance.setActiveThreads(size); - } - - public static void tick() { - instance.finishActive(); - } -} diff --git a/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOProvider.java b/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOProvider.java deleted file mode 100644 index 413dd35f06..0000000000 --- a/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOProvider.java +++ /dev/null @@ -1,57 +0,0 @@ -package org.bukkit.craftbukkit.chunkio; - -import java.io.IOException; -import net.minecraft.server.Chunk; -import net.minecraft.server.ChunkCoordIntPair; -import net.minecraft.server.ChunkRegionLoader; -import net.minecraft.server.NBTTagCompound; - -import org.bukkit.Server; -import org.bukkit.craftbukkit.util.AsynchronousExecutor; - -import java.util.concurrent.atomic.AtomicInteger; - -class ChunkIOProvider implements AsynchronousExecutor.CallBackProvider { - private final AtomicInteger threadNumber = new AtomicInteger(1); - - // async stuff - public Chunk callStage1(QueuedChunk queuedChunk) throws RuntimeException { - try { - ChunkRegionLoader loader = queuedChunk.loader; - Object[] data = loader.loadChunk(queuedChunk.world, queuedChunk.x, queuedChunk.z, (chunk) -> {}); - - if (data != null) { - queuedChunk.compound = (NBTTagCompound) data[1]; - return (Chunk) data[0]; - } - - return null; - } catch (IOException ex) { - throw new RuntimeException(ex); - } - } - - // sync stuff - public void callStage2(QueuedChunk queuedChunk, Chunk chunk) throws RuntimeException { - if (chunk == null) { - // If the chunk loading failed just do it synchronously (may generate) - // queuedChunk.provider.originalGetChunkAt(queuedChunk.x, queuedChunk.z); - return; - } - - queuedChunk.loader.loadEntities(queuedChunk.compound.getCompound("Level"), chunk); - chunk.setLastSaved(queuedChunk.provider.world.getTime()); - queuedChunk.provider.chunks.put(ChunkCoordIntPair.a(queuedChunk.x, queuedChunk.z), chunk); - chunk.addEntities(); - } - - public void callStage3(QueuedChunk queuedChunk, Chunk chunk, Runnable runnable) throws RuntimeException { - runnable.run(); - } - - public Thread newThread(Runnable runnable) { - Thread thread = new Thread(runnable, "Chunk I/O Executor Thread-" + threadNumber.getAndIncrement()); - thread.setDaemon(true); - return thread; - } -} diff --git a/src/main/java/org/bukkit/craftbukkit/chunkio/QueuedChunk.java b/src/main/java/org/bukkit/craftbukkit/chunkio/QueuedChunk.java deleted file mode 100644 index 842d424f6a..0000000000 --- a/src/main/java/org/bukkit/craftbukkit/chunkio/QueuedChunk.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.bukkit.craftbukkit.chunkio; - -import net.minecraft.server.ChunkProviderServer; -import net.minecraft.server.ChunkRegionLoader; -import net.minecraft.server.NBTTagCompound; -import net.minecraft.server.World; - -class QueuedChunk { - final int x; - final int z; - final ChunkRegionLoader loader; - final World world; - final ChunkProviderServer provider; - NBTTagCompound compound; - - public QueuedChunk(int x, int z, ChunkRegionLoader loader, World world, ChunkProviderServer provider) { - this.x = x; - this.z = z; - this.loader = loader; - this.world = world; - this.provider = provider; - } - - @Override - public int hashCode() { - return (x * 31 + z * 29) ^ world.hashCode(); - } - - @Override - public boolean equals(Object object) { - if (object instanceof QueuedChunk) { - QueuedChunk other = (QueuedChunk) object; - return x == other.x && z == other.z && world == other.world; - } - - return false; - } -} diff --git a/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java b/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java index 2897713add..6818e1adc3 100644 --- a/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java +++ b/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java @@ -57,6 +57,8 @@ public class CraftEnchantment extends Enchantment { return EnchantmentTarget.WEARABLE; case TRIDENT: return EnchantmentTarget.TRIDENT; + case CROSSBOW: + return EnchantmentTarget.CROSSBOW; default: return null; } @@ -146,11 +148,17 @@ public class CraftEnchantment extends Enchantment { case 31: return "CHANNELING"; case 32: - return "MENDING"; + return "MULTSHOT"; case 33: + return "QUICK_CHARGE"; + case 34: + return "PIERCING"; + case 35: + return "MENDING"; + case 36: return "VANISHING_CURSE"; default: - return "UNKNOWN_ENCHANT_" + getName(); + return "UNKNOWN_ENCHANT_" + IRegistry.ENCHANTMENT.a(target); } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractVillager.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractVillager.java new file mode 100644 index 0000000000..ca36bfc308 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractVillager.java @@ -0,0 +1,76 @@ +package org.bukkit.craftbukkit.entity; + +import java.util.List; +import net.minecraft.server.EntityVillager; +import net.minecraft.server.EntityVillagerAbstract; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.craftbukkit.inventory.CraftInventory; +import org.bukkit.craftbukkit.inventory.CraftMerchant; +import org.bukkit.entity.HumanEntity; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.InventoryHolder; +import org.bukkit.inventory.MerchantRecipe; +import org.bukkit.entity.AbstractVillager; + +public class CraftAbstractVillager extends CraftAgeable implements AbstractVillager, InventoryHolder { + + private CraftMerchant merchant; + + public CraftAbstractVillager(CraftServer server, EntityVillagerAbstract entity) { + super(server, entity); + } + + @Override + public EntityVillagerAbstract getHandle() { + return (EntityVillager) entity; + } + + @Override + public String toString() { + return "CraftAbstractVillager"; + } + + @Override + public Inventory getInventory() { + return new CraftInventory(getHandle().getInventory()); + } + + private CraftMerchant getMerchant() { + return (merchant == null) ? merchant = new CraftMerchant(getHandle()) : merchant; + } + + @Override + public List getRecipes() { + return getMerchant().getRecipes(); + } + + @Override + public void setRecipes(List recipes) { + this.getMerchant().setRecipes(recipes); + } + + @Override + public MerchantRecipe getRecipe(int i) { + return getMerchant().getRecipe(i); + } + + @Override + public void setRecipe(int i, MerchantRecipe merchantRecipe) { + getMerchant().setRecipe(i, merchantRecipe); + } + + @Override + public int getRecipeCount() { + return getMerchant().getRecipeCount(); + } + + @Override + public boolean isTrading() { + return getTrader() != null; + } + + @Override + public HumanEntity getTrader() { + return getMerchant().getTrader(); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftAnimals.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftAnimals.java index b06909c3e9..56e5d9d99c 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftAnimals.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftAnimals.java @@ -40,11 +40,11 @@ public class CraftAnimals extends CraftAgeable implements Animals { @Override public void setLoveModeTicks(int ticks) { Preconditions.checkArgument(ticks >= 0, "Love mode ticks must be positive or 0"); - getHandle().d(ticks); // PAIL rename setLoveModeTicks + getHandle().setLoveTicks(ticks); } @Override public int getLoveModeTicks() { - return getHandle().bC; // PAIL rename loveTicks + return getHandle().loveTicks; } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java index 75dad21cd4..f5b9d47b43 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java @@ -1,6 +1,7 @@ package org.bukkit.craftbukkit.entity; import com.google.common.base.Preconditions; +import net.minecraft.server.BlockPosition; import net.minecraft.server.EntityArrow; import org.apache.commons.lang.Validate; @@ -69,8 +70,8 @@ public class CraftArrow extends AbstractProjectile implements Arrow { return null; } - EntityArrow handle = getHandle(); - return getWorld().getBlockAt(handle.tileX, handle.tileY, handle.tileZ); + BlockPosition pos = getHandle().getChunkCoordinates(); + return getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()); } @Override @@ -103,6 +104,6 @@ public class CraftArrow extends AbstractProjectile implements Arrow { } public EntityType getType() { - return EntityType.ARROW; + return EntityType.UNKNOWN; } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftCat.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftCat.java new file mode 100644 index 0000000000..989a8aa218 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftCat.java @@ -0,0 +1,41 @@ +package org.bukkit.craftbukkit.entity; + +import com.google.common.base.Preconditions; +import net.minecraft.server.EntityCat; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.entity.Cat; +import org.bukkit.entity.EntityType; + +public class CraftCat extends CraftTameableAnimal implements Cat { + + public CraftCat(CraftServer server, EntityCat entity) { + super(server, entity); + } + + @Override + public EntityCat getHandle() { + return (EntityCat) super.getHandle(); + } + + @Override + public EntityType getType() { + return EntityType.CAT; + } + + @Override + public String toString() { + return "CraftCat"; + } + + @Override + public Type getCatType() { + return Type.values()[getHandle().getCatType()]; + } + + @Override + public void setCatType(Type type) { + Preconditions.checkArgument(type != null, "Cannot have null Type"); + + getHandle().setCatType(type.ordinal()); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftComplexPart.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftComplexPart.java index 02fd230a34..0c26048223 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftComplexPart.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftComplexPart.java @@ -43,6 +43,6 @@ public class CraftComplexPart extends CraftEntity implements ComplexEntityPart { } public EntityType getType() { - return EntityType.COMPLEX_PART; + return EntityType.UNKNOWN; } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java index aca4532863..dc98c464c1 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java @@ -19,6 +19,7 @@ import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftWorld; import org.bukkit.craftbukkit.block.CraftBlock; import org.bukkit.craftbukkit.util.CraftChatMessage; +import org.bukkit.craftbukkit.util.CraftVector; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; import org.bukkit.metadata.MetadataValue; @@ -78,7 +79,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { else if (entity instanceof EntityPig) { return new CraftPig(server, (EntityPig) entity); } else if (entity instanceof EntityTameableAnimal) { if (entity instanceof EntityWolf) { return new CraftWolf(server, (EntityWolf) entity); } - else if (entity instanceof EntityOcelot) { return new CraftOcelot(server, (EntityOcelot) entity); } + else if (entity instanceof EntityCat) { return new CraftCat(server, (EntityCat) entity); } else if (entity instanceof EntityParrot) { return new CraftParrot(server, (EntityParrot) entity); } } else if (entity instanceof EntitySheep) { return new CraftSheep(server, (EntitySheep) entity); } @@ -86,6 +87,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { if (entity instanceof EntityHorseChestedAbstract){ if (entity instanceof EntityHorseDonkey) { return new CraftDonkey(server, (EntityHorseDonkey) entity); } else if (entity instanceof EntityHorseMule) { return new CraftMule(server, (EntityHorseMule) entity); } + else if (entity instanceof EntityLLamaTrader) { return new CraftTraderLlama(server, (EntityLLamaTrader) entity); } else if (entity instanceof EntityLlama) { return new CraftLlama(server, (EntityLlama) entity); } } else if (entity instanceof EntityHorse) { return new CraftHorse(server, (EntityHorse) entity); } else if (entity instanceof EntityHorseSkeleton) { return new CraftSkeletonHorse(server, (EntityHorseSkeleton) entity); } @@ -94,6 +96,9 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { else if (entity instanceof EntityRabbit) { return new CraftRabbit(server, (EntityRabbit) entity); } else if (entity instanceof EntityPolarBear) { return new CraftPolarBear(server, (EntityPolarBear) entity); } else if (entity instanceof EntityTurtle) { return new CraftTurtle(server, (EntityTurtle) entity); } + else if (entity instanceof EntityOcelot) { return new CraftOcelot(server, (EntityOcelot) entity); } + else if (entity instanceof EntityPanda) { return new CraftPanda(server, (EntityPanda) entity); } + else if (entity instanceof EntityFox) { return new CraftFox(server, (EntityFox) entity); } else { return new CraftAnimals(server, (EntityAnimal) entity); } } // Monsters @@ -134,8 +139,10 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { else { return new CraftSpellcaster(server, (EntityIllagerWizard) entity); } } else if (entity instanceof EntityVindicator) { return new CraftVindicator(server, (EntityVindicator) entity); } + else if (entity instanceof EntityPillager) { return new CraftPillager(server, (EntityPillager) entity); } else { return new CraftIllager(server, (EntityIllagerAbstract) entity); } } + else if (entity instanceof EntityRavager) { return new CraftRavager(server, (EntityRavager) entity); } else { return new CraftMonster(server, (EntityMonster) entity); } } @@ -144,7 +151,11 @@ public abstract class CraftEntity implements org.bukkit.entity.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 if (entity instanceof EntityVillagerAbstract) { + if (entity instanceof EntityVillager) { return new CraftVillager(server, (EntityVillager) entity); } + else if (entity instanceof EntityVillagerTrader) { return new CraftWanderingTrader(server, (EntityVillagerTrader) entity); } + else { return new CraftAbstractVillager(server, (EntityVillagerAbstract) entity); } + } else { return new CraftCreature(server, (EntityCreature) entity); } } // Slimes are a special (and broken) case @@ -175,10 +186,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { else { return new CraftComplexPart(server, (EntityComplexPart) entity); } } else if (entity instanceof EntityExperienceOrb) { return new CraftExperienceOrb(server, (EntityExperienceOrb) entity); } - else if (entity instanceof EntityTippedArrow) { - if (((EntityTippedArrow) entity).isTipped()) { return new CraftTippedArrow(server, (EntityTippedArrow) entity); } - else { return new CraftArrow(server, (EntityArrow) entity); } - } + else if (entity instanceof EntityTippedArrow) { return new CraftTippedArrow(server, (EntityTippedArrow) entity); } else if (entity instanceof EntitySpectralArrow) { return new CraftSpectralArrow(server, (EntitySpectralArrow) entity); } else if (entity instanceof EntityArrow) { if (entity instanceof EntityThrownTrident) { return new CraftTrident(server, (EntityThrownTrident) entity); } @@ -188,10 +196,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { else if (entity instanceof EntityProjectile) { if (entity instanceof EntityEgg) { return new CraftEgg(server, (EntityEgg) entity); } else if (entity instanceof EntitySnowball) { return new CraftSnowball(server, (EntitySnowball) entity); } - else if (entity instanceof EntityPotion) { - if (!((EntityPotion) entity).isLingering()) { return new CraftSplashPotion(server, (EntityPotion) entity); } - else { return new CraftLingeringPotion(server, (EntityPotion) entity); } - } + else if (entity instanceof EntityPotion) { return new CraftThrownPotion(server, (EntityPotion) entity); } else if (entity instanceof EntityEnderPearl) { return new CraftEnderPearl(server, (EntityEnderPearl) entity); } else if (entity instanceof EntityThrownExpBottle) { return new CraftThrownExpBottle(server, (EntityThrownExpBottle) entity); } } @@ -207,10 +212,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { else if (entity instanceof EntityEnderCrystal) { return new CraftEnderCrystal(server, (EntityEnderCrystal) entity); } else if (entity instanceof EntityFishingHook) { return new CraftFishHook(server, (EntityFishingHook) entity); } else if (entity instanceof EntityItem) { return new CraftItem(server, (EntityItem) entity); } - else if (entity instanceof EntityWeather) { - if (entity instanceof EntityLightning) { return new CraftLightningStrike(server, (EntityLightning) entity); } - else { return new CraftWeather(server, (EntityWeather) entity); } - } + else if (entity instanceof EntityLightning) { return new CraftLightningStrike(server, (EntityLightning) entity); } else if (entity instanceof EntityMinecartAbstract) { if (entity instanceof EntityMinecartFurnace) { return new CraftMinecartFurnace(server, (EntityMinecartFurnace) entity); } else if (entity instanceof EntityMinecartChest) { return new CraftMinecartChest(server, (EntityMinecartChest) entity); } @@ -253,26 +255,24 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { } public Vector getVelocity() { - return new Vector(entity.motX, entity.motY, entity.motZ); + return CraftVector.toBukkit(entity.getMot()); } public void setVelocity(Vector velocity) { Preconditions.checkArgument(velocity != null, "velocity"); velocity.checkFinite(); - entity.motX = velocity.getX(); - entity.motY = velocity.getY(); - entity.motZ = velocity.getZ(); + entity.setMot(CraftVector.toNMS(velocity)); entity.velocityChanged = true; } @Override public double getHeight() { - return getHandle().length; + return getHandle().getHeight(); } @Override public double getWidth() { - return getHandle().width; + return getHandle().getWidth(); } @Override @@ -324,7 +324,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { // Let the server handle cross world teleports if (!location.getWorld().equals(getWorld())) { - entity.teleportTo(location, false); + entity.teleportTo(((CraftWorld) location.getWorld()).getHandle().dimension, new BlockPosition(location.getX(), location.getY(), location.getZ())); return true; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFox.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFox.java new file mode 100644 index 0000000000..770b1111de --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFox.java @@ -0,0 +1,28 @@ +package org.bukkit.craftbukkit.entity; + +import net.minecraft.server.EntityFox; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Fox; + +public class CraftFox extends CraftAnimals implements Fox { + + public CraftFox(CraftServer server, EntityFox entity) { + super(server, entity); + } + + @Override + public EntityFox getHandle() { + return (EntityFox) super.getHandle(); + } + + @Override + public EntityType getType() { + return EntityType.FOX; + } + + @Override + public String toString() { + return "CraftFox"; + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java index 79d1255676..af6b52324a 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java @@ -4,13 +4,17 @@ import com.google.common.base.Preconditions; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; +import java.util.Optional; import java.util.Set; import net.minecraft.server.BlockAnvil; import net.minecraft.server.BlockBed; +import net.minecraft.server.BlockEnchantmentTable; import net.minecraft.server.BlockPosition; import net.minecraft.server.BlockWorkbench; +import net.minecraft.server.Blocks; import net.minecraft.server.ChatComponentText; import net.minecraft.server.Container; +import net.minecraft.server.Containers; import net.minecraft.server.CraftingManager; import net.minecraft.server.Entity; import net.minecraft.server.EntityHuman; @@ -19,6 +23,7 @@ import net.minecraft.server.EntityPlayer; import net.minecraft.server.EntityTypes; import net.minecraft.server.EnumMainHand; import net.minecraft.server.IBlockData; +import net.minecraft.server.IChatBaseComponent; import net.minecraft.server.IInventory; import net.minecraft.server.IMerchant; import net.minecraft.server.IRecipe; @@ -29,14 +34,19 @@ import net.minecraft.server.NBTTagCompound; import net.minecraft.server.PacketPlayInCloseWindow; import net.minecraft.server.PacketPlayOutOpenWindow; import net.minecraft.server.TileEntity; +import net.minecraft.server.TileEntityBarrel; import net.minecraft.server.TileEntityBeacon; +import net.minecraft.server.TileEntityBlastFurnace; import net.minecraft.server.TileEntityBrewingStand; import net.minecraft.server.TileEntityDispenser; import net.minecraft.server.TileEntityDropper; import net.minecraft.server.TileEntityEnchantTable; import net.minecraft.server.TileEntityFurnace; +import net.minecraft.server.TileEntityFurnaceFurnace; import net.minecraft.server.TileEntityHopper; +import net.minecraft.server.TileEntityLectern; import net.minecraft.server.TileEntityShulkerBox; +import net.minecraft.server.TileEntitySmoker; import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Material; @@ -52,6 +62,7 @@ import org.bukkit.craftbukkit.inventory.CraftInventoryPlayer; import org.bukkit.craftbukkit.inventory.CraftInventoryView; import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.craftbukkit.inventory.CraftMerchant; +import org.bukkit.craftbukkit.inventory.CraftMerchantCustom; import org.bukkit.craftbukkit.util.CraftMagicNumbers; import org.bukkit.craftbukkit.util.CraftNamespacedKey; import org.bukkit.entity.HumanEntity; @@ -121,7 +132,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { } public boolean isSleeping() { - return getHandle().sleeping; + return getHandle().isSleeping(); } public int getSleepTicks() { @@ -168,7 +179,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { return false; } - if (getHandle().a(blockposition, force) != EntityHuman.EnumBedResult.OK) { + if (getHandle().sleep(blockposition, force).left().isPresent()) { return false; } @@ -183,14 +194,15 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { public void wakeup(boolean setSpawnLocation) { Preconditions.checkState(isSleeping(), "Cannot wakeup if not sleeping"); - getHandle().a(true, true, setSpawnLocation); + getHandle().wakeup(true, true, setSpawnLocation); } @Override public Location getBedLocation() { Preconditions.checkState(isSleeping(), "Not sleeping"); - return new Location(getWorld(), getHandle().bedPosition.getX(), getHandle().bedPosition.getY(), getHandle().bedPosition.getZ()); + BlockPosition bed = getHandle().getBed(); + return new Location(getWorld(), bed.getX(), bed.getY(), bed.getZ()); } @Override @@ -303,41 +315,64 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { case PLAYER: case CHEST: case ENDER_CHEST: - getHandle().openContainer(iinventory); + Containers customSize; + switch (inventory.getSize()) { + case 9: + customSize = Containers.GENERIC_9X1; + break; + case 18: + customSize = Containers.GENERIC_9X2; + break; + case 27: + customSize = Containers.GENERIC_9X3; + break; + case 36: + customSize = Containers.GENERIC_9X4; + break; + case 45: + customSize = Containers.GENERIC_9X5; + break; + case 54: + customSize = Containers.GENERIC_9X6; + break; + default: + throw new IllegalArgumentException("Unsupported custom size " + inventory.getSize()); + } + openCustomInventory(inventory, player, customSize); break; case DISPENSER: if (iinventory instanceof TileEntityDispenser) { getHandle().openContainer((TileEntityDispenser) iinventory); } else { - openCustomInventory(inventory, player, "minecraft:dispenser"); + openCustomInventory(inventory, player, Containers.GENERIC_3X3); } break; case DROPPER: if (iinventory instanceof TileEntityDropper) { getHandle().openContainer((TileEntityDropper) iinventory); } else { - openCustomInventory(inventory, player, "minecraft:dropper"); + openCustomInventory(inventory, player, Containers.GENERIC_3X3); } break; case FURNACE: - if (iinventory instanceof TileEntityFurnace) { - getHandle().openContainer((TileEntityFurnace) iinventory); + if (iinventory instanceof TileEntityFurnaceFurnace) { + getHandle().openContainer((TileEntityFurnaceFurnace) iinventory); } else { - openCustomInventory(inventory, player, "minecraft:furnace"); + openCustomInventory(inventory, player, Containers.FURNACE); } break; case WORKBENCH: - openCustomInventory(inventory, player, "minecraft:crafting_table"); + openCustomInventory(inventory, player, Containers.CRAFTING); break; case BREWING: if (iinventory instanceof TileEntityBrewingStand) { getHandle().openContainer((TileEntityBrewingStand) iinventory); } else { - openCustomInventory(inventory, player, "minecraft:brewing_stand"); + openCustomInventory(inventory, player, Containers.BREWING_STAND); } break; case ENCHANTING: - openCustomInventory(inventory, player, "minecraft:enchanting_table"); + openCustomInventory(inventory, player, Containers.ENCHANTMENT); break; case HOPPER: if (iinventory instanceof TileEntityHopper) { @@ -345,33 +380,67 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { } else if (iinventory instanceof EntityMinecartHopper) { getHandle().openContainer((EntityMinecartHopper) iinventory); } else { - openCustomInventory(inventory, player, "minecraft:hopper"); + openCustomInventory(inventory, player, Containers.HOPPER); } break; case BEACON: if (iinventory instanceof TileEntityBeacon) { getHandle().openContainer((TileEntityBeacon) iinventory); } else { - openCustomInventory(inventory, player, "minecraft:beacon"); + openCustomInventory(inventory, player, Containers.BEACON); } break; case ANVIL: - if (iinventory instanceof BlockAnvil.TileEntityContainerAnvil) { - getHandle().openTileEntity((BlockAnvil.TileEntityContainerAnvil) iinventory); + if (iinventory instanceof ITileInventory) { + getHandle().openContainer((ITileInventory) iinventory); } else { - openCustomInventory(inventory, player, "minecraft:anvil"); + openCustomInventory(inventory, player, Containers.ANVIL); } break; case SHULKER_BOX: if (iinventory instanceof TileEntityShulkerBox) { getHandle().openContainer((TileEntityShulkerBox) iinventory); } else { - openCustomInventory(inventory, player, "minecraft:shulker_box"); + openCustomInventory(inventory, player, Containers.SHULKER_BOX); } break; + case BARREL: + if (iinventory instanceof TileEntityBarrel) { + getHandle().openContainer((TileEntityBarrel) iinventory); + } else { + openCustomInventory(inventory, player, Containers.GENERIC_9X3); + } + break; + case BLAST_FURNACE: + if (iinventory instanceof TileEntityBlastFurnace) { + getHandle().openContainer((TileEntityBlastFurnace) iinventory); + } else { + openCustomInventory(inventory, player, Containers.BLAST_FURNACE); + } + break; + case LECTERN: + if (iinventory instanceof TileEntityLectern) { + getHandle().openContainer((TileEntityLectern) iinventory); + } else { + openCustomInventory(inventory, player, Containers.LECTERN); + } + break; + case SMOKER: + if (iinventory instanceof TileEntitySmoker) { + getHandle().openContainer((TileEntitySmoker) iinventory); + } else { + openCustomInventory(inventory, player, Containers.SMOKER); + } + break; + case STONECUTTER: + openCustomInventory(inventory, player, Containers.STONECUTTER); + break; case CREATIVE: case CRAFTING: case MERCHANT: + case LOOM: + case CARTOGRAPHY: + case GRINDSTONE: throw new IllegalArgumentException("Can't open a " + type + " inventory!"); } if (getHandle().activeContainer == formerContainer) { @@ -381,25 +450,17 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { return getHandle().activeContainer.getBukkitView(); } - private void openCustomInventory(Inventory inventory, EntityPlayer player, String windowType) { + private void openCustomInventory(Inventory inventory, EntityPlayer player, Containers windowType) { if (player.playerConnection == null) return; + Preconditions.checkArgument(windowType != null, "Unknown windowType"); Container container = new CraftContainer(inventory, this.getHandle(), player.nextContainerCounter()); container = CraftEventFactory.callInventoryOpenEvent(player, container); if(container == null) return; String title = container.getBukkitView().getTitle(); - int size = container.getBukkitView().getTopInventory().getSize(); - // Special cases - if (windowType.equals("minecraft:crafting_table") - || windowType.equals("minecraft:anvil") - || windowType.equals("minecraft:enchanting_table") - ) { - size = 0; - } - - player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, windowType, new ChatComponentText(title), size)); + player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, windowType, new ChatComponentText(title))); getHandle().activeContainer = container; getHandle().activeContainer.addSlotListener(player); } @@ -414,7 +475,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { if (location == null) { location = getLocation(); } - getHandle().openTileEntity(new BlockWorkbench.TileEntityContainerWorkbench(getHandle().world, new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ()))); + getHandle().openContainer(((BlockWorkbench) Blocks.CRAFTING_TABLE).getInventory(null, getHandle().world, new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ()))); if (force) { getHandle().activeContainer.checkReachable = false; } @@ -434,13 +495,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { // If there isn't an enchant table we can force create one, won't be very useful though. BlockPosition pos = new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ()); - TileEntity container = getHandle().world.getTileEntity(pos); - if (container == null && force) { - container = new TileEntityEnchantTable(); - container.setWorld(getHandle().world); - container.setPosition(pos); - } - getHandle().openTileEntity((ITileEntityContainer) container); + getHandle().openContainer(((BlockEnchantmentTable) Blocks.ENCHANTING_TABLE).getInventory(null, getHandle().world, pos)); if (force) { getHandle().activeContainer.checkReachable = false; @@ -471,10 +526,9 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { // Now open the window InventoryType type = inventory.getType(); - String windowType = CraftContainer.getNotchInventoryType(type); + Containers windowType = CraftContainer.getNotchInventoryType(type); String title = inventory.getTitle(); - int size = inventory.getTopInventory().getSize(); - player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, windowType, new ChatComponentText(title), size)); + player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, windowType, new ChatComponentText(title))); player.activeContainer = container; player.activeContainer.addSlotListener(player); } @@ -498,16 +552,19 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { } IMerchant mcMerchant; + IChatBaseComponent name; if (merchant instanceof CraftVillager) { mcMerchant = ((CraftVillager) merchant).getHandle(); - } else if (merchant instanceof CraftMerchant) { - mcMerchant = ((CraftMerchant) merchant).getMerchant(); + name = ((CraftVillager) merchant).getHandle().getScoreboardDisplayName(); + } else if (merchant instanceof CraftMerchantCustom) { + mcMerchant = ((CraftMerchantCustom) merchant).getMerchant(); + name = ((CraftMerchantCustom) merchant).getMerchant().getScoreboardDisplayName(); } else { throw new IllegalArgumentException("Can't open merchant " + merchant.toString()); } mcMerchant.setTradingPlayer(this.getHandle()); - this.getHandle().openTrade(mcMerchant); + mcMerchant.openTrade(this.getHandle(), name, 0); return this.getHandle().activeContainer.getBukkitView(); } @@ -576,17 +633,17 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { return getHandle().undiscoverRecipes(bukkitKeysToMinecraftRecipes(recipes)); } - private Collection bukkitKeysToMinecraftRecipes(Collection recipeKeys) { - Collection recipes = new ArrayList<>(); + private Collection> bukkitKeysToMinecraftRecipes(Collection recipeKeys) { + Collection> recipes = new ArrayList<>(); CraftingManager manager = getHandle().world.getMinecraftServer().getCraftingManager(); for (NamespacedKey recipeKey : recipeKeys) { - IRecipe recipe = manager.a(CraftNamespacedKey.toMinecraft(recipeKey)); - if (recipe == null) { + Optional> recipe = manager.a(CraftNamespacedKey.toMinecraft(recipeKey)); + if (!recipe.isPresent()) { continue; } - recipes.add(recipe); + recipes.add(recipe.get()); } return recipes; @@ -595,9 +652,9 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { @Override public org.bukkit.entity.Entity getShoulderEntityLeft() { if (!getHandle().getShoulderEntityLeft().isEmpty()) { - Entity shoulder = EntityTypes.a(getHandle().getShoulderEntityLeft(), getHandle().world); + Optional shoulder = EntityTypes.a(getHandle().getShoulderEntityLeft(), getHandle().world); - return (shoulder == null) ? null : shoulder.getBukkitEntity(); + return (!shoulder.isPresent()) ? null : shoulder.get().getBukkitEntity(); } return null; @@ -614,9 +671,9 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { @Override public org.bukkit.entity.Entity getShoulderEntityRight() { if (!getHandle().getShoulderEntityRight().isEmpty()) { - Entity shoulder = EntityTypes.a(getHandle().getShoulderEntityRight(), getHandle().world); + Optional shoulder = EntityTypes.a(getHandle().getShoulderEntityRight(), getHandle().world); - return (shoulder == null) ? null : shoulder.getBukkitEntity(); + return (!shoulder.isPresent()) ? null : shoulder.get().getBukkitEntity(); } return null; diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftIllager.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftIllager.java index 824af57808..9bdd1f1d4d 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftIllager.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftIllager.java @@ -4,7 +4,7 @@ import net.minecraft.server.EntityIllagerAbstract; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.Illager; -public class CraftIllager extends CraftMonster implements Illager { +public class CraftIllager extends CraftRaider implements Illager { public CraftIllager(CraftServer server, EntityIllagerAbstract entity) { super(server, entity); diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLingeringPotion.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLingeringPotion.java deleted file mode 100644 index 2a5482ff89..0000000000 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLingeringPotion.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.bukkit.craftbukkit.entity; - -import net.minecraft.server.EntityPotion; -import org.apache.commons.lang.Validate; -import org.bukkit.Material; -import org.bukkit.craftbukkit.CraftServer; -import org.bukkit.craftbukkit.inventory.CraftItemStack; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.LingeringPotion; -import org.bukkit.inventory.ItemStack; - -public class CraftLingeringPotion extends CraftThrownPotion implements LingeringPotion { - - public CraftLingeringPotion(CraftServer server, EntityPotion entity) { - super(server, entity); - } - - public void setItem(ItemStack item) { - // The ItemStack must not be null. - Validate.notNull(item, "ItemStack cannot be null."); - - // The ItemStack must be a potion. - Validate.isTrue(item.getType() == Material.LINGERING_POTION, "ItemStack must be a lingering potion. This item stack was " + item.getType() + "."); - - getHandle().setItem(CraftItemStack.asNMSCopy(item)); - } - - @Override - public EntityPotion getHandle() { - return (EntityPotion) entity; - } - - @Override - public String toString() { - return "CraftLingeringPotion"; - } - - @Override - public EntityType getType() { - return EntityType.LINGERING_POTION; - } -} diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java index 3a15b47dd6..db7d292e8a 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java @@ -29,6 +29,7 @@ import net.minecraft.server.EntityThrownExpBottle; import net.minecraft.server.EntityTippedArrow; import net.minecraft.server.EntitySpectralArrow; import net.minecraft.server.EntityThrownTrident; +import net.minecraft.server.EntityTypes; import net.minecraft.server.EntityWither; import net.minecraft.server.EntityWitherSkull; import net.minecraft.server.GenericAttributes; @@ -117,7 +118,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { public void setMaxHealth(double amount) { Validate.isTrue(amount > 0, "Max health must be greater than 0"); - getHandle().getAttributeInstance(GenericAttributes.maxHealth).setValue(amount); + getHandle().getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(amount); if (getHealth() > amount) { setHealth(amount); @@ -125,7 +126,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { } public void resetMaxHealth() { - setMaxHealth(getHandle().getAttributeInstance(GenericAttributes.maxHealth).getAttribute().getDefault()); + setMaxHealth(getHandle().getAttributeInstance(GenericAttributes.MAX_HEALTH).getAttribute().getDefault()); } public double getEyeHeight() { @@ -352,16 +353,18 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { ((EntityArrow) launch).a(getHandle(), getHandle().pitch, getHandle().yaw, 0.0F, 3.0F, 1.0F); // ItemBow } else if (ThrownPotion.class.isAssignableFrom(projectile)) { if (LingeringPotion.class.isAssignableFrom(projectile)) { - launch = new EntityPotion(world, getHandle(), CraftItemStack.asNMSCopy(new ItemStack(org.bukkit.Material.LINGERING_POTION, 1))); + launch = new EntityPotion(world, getHandle()); + ((EntityPotion) launch).setItem(CraftItemStack.asNMSCopy(new ItemStack(org.bukkit.Material.LINGERING_POTION, 1))); } else { - launch = new EntityPotion(world, getHandle(), CraftItemStack.asNMSCopy(new ItemStack(org.bukkit.Material.SPLASH_POTION, 1))); + launch = new EntityPotion(world, getHandle()); + ((EntityPotion) launch).setItem(CraftItemStack.asNMSCopy(new ItemStack(org.bukkit.Material.SPLASH_POTION, 1))); } ((EntityProjectile) launch).a(getHandle(), getHandle().pitch, getHandle().yaw, -20.0F, 0.5F, 1.0F); // ItemSplashPotion } else if (ThrownExpBottle.class.isAssignableFrom(projectile)) { launch = new EntityThrownExpBottle(world, getHandle()); ((EntityProjectile) launch).a(getHandle(), getHandle().pitch, getHandle().yaw, -20.0F, 0.7F, 1.0F); // ItemExpBottle } else if (FishHook.class.isAssignableFrom(projectile) && getHandle() instanceof EntityHuman) { - launch = new EntityFishingHook(world, (EntityHuman) getHandle()); + launch = new EntityFishingHook((EntityHuman) getHandle(), world, 0, 0); } else if (Fireball.class.isAssignableFrom(projectile)) { Location location = getEyeLocation(); Vector direction = location.getDirection().multiply(10); @@ -382,7 +385,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { Location location = getEyeLocation(); Vector direction = location.getDirection(); - launch = new EntityLlamaSpit(world); + launch = EntityTypes.LLAMA_SPIT.a(world); ((EntityLlamaSpit) launch).shooter = getHandle(); ((EntityLlamaSpit) launch).shoot(direction.getX(), direction.getY(), direction.getZ(), 1.5F, 10.0F); // EntityLlama diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartContainer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartContainer.java index 87303ecd13..2d776b520b 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartContainer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartContainer.java @@ -28,7 +28,7 @@ public abstract class CraftMinecartContainer extends CraftMinecart implements Lo @Override public LootTable getLootTable() { - MinecraftKey nmsTable = getHandle().getLootTable(); + MinecraftKey nmsTable = getHandle().lootTable; if (nmsTable == null) { return null; // return empty loot table? } @@ -49,6 +49,6 @@ public abstract class CraftMinecartContainer extends CraftMinecart implements Lo private void setLootTable(LootTable table, long seed) { MinecraftKey newKey = (table == null) ? null : CraftNamespacedKey.toMinecraft(table.getKey()); - getHandle().a(newKey, seed); + getHandle().setLootTable(newKey, seed); } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftOcelot.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftOcelot.java index e73c2c9f18..00de05bb3c 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftOcelot.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftOcelot.java @@ -1,12 +1,11 @@ package org.bukkit.craftbukkit.entity; import net.minecraft.server.EntityOcelot; -import org.apache.commons.lang.Validate; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.EntityType; import org.bukkit.entity.Ocelot; -public class CraftOcelot extends CraftTameableAnimal implements Ocelot { +public class CraftOcelot extends CraftAnimals implements Ocelot { public CraftOcelot(CraftServer server, EntityOcelot ocelot) { super(server, ocelot); } @@ -17,12 +16,11 @@ public class CraftOcelot extends CraftTameableAnimal implements Ocelot { } public Type getCatType() { - return Type.getType(getHandle().getCatType()); + return Type.WILD_OCELOT; } public void setCatType(Type type) { - Validate.notNull(type, "Cat type cannot be null"); - getHandle().setCatType(type.getId()); + throw new UnsupportedOperationException("Cats are now a different entity!"); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java index 9c29a56da6..05c36ed885 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java @@ -1,6 +1,7 @@ package org.bukkit.craftbukkit.entity; import net.minecraft.server.EntityPainting; +import net.minecraft.server.EntityTypes; import net.minecraft.server.Paintings; import net.minecraft.server.WorldServer; @@ -53,7 +54,7 @@ public class CraftPainting extends CraftHanging implements Painting { private void update() { WorldServer world = ((CraftWorld) getWorld()).getHandle(); - EntityPainting painting = new EntityPainting(world); + EntityPainting painting = EntityTypes.PAINTING.a(world); painting.blockPosition = getHandle().blockPosition; painting.art = getHandle().art; painting.setDirection(getHandle().direction); diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPanda.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPanda.java new file mode 100644 index 0000000000..60520ca37f --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPanda.java @@ -0,0 +1,61 @@ +package org.bukkit.craftbukkit.entity; + +import com.google.common.base.Preconditions; +import net.minecraft.server.EntityPanda; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.entity.Panda; +import org.bukkit.entity.EntityType; + +public class CraftPanda extends CraftAnimals implements Panda { + + public CraftPanda(CraftServer server, EntityPanda entity) { + super(server, entity); + } + + @Override + public EntityPanda getHandle() { + return (EntityPanda) super.getHandle(); + } + + @Override + public EntityType getType() { + return EntityType.PANDA; + } + + @Override + public String toString() { + return "CraftPanda"; + } + + @Override + public Gene getMainGene() { + return fromNms(getHandle().getMainGene()); + } + + @Override + public void setMainGene(Gene gene) { + getHandle().setMainGene(toNms(gene)); + } + + @Override + public Gene getHiddenGene() { + return fromNms(getHandle().getHiddenGene()); + } + + @Override + public void setHiddenGene(Gene gene) { + getHandle().setHiddenGene(toNms(gene)); + } + + public static Gene fromNms(EntityPanda.Gene gene) { + Preconditions.checkArgument(gene != null, "Gene may not be null"); + + return Gene.values()[gene.ordinal()]; + } + + public static EntityPanda.Gene toNms(Gene gene) { + Preconditions.checkArgument(gene != null, "Gene may not be null"); + + return EntityPanda.Gene.values()[gene.ordinal()]; + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPillager.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPillager.java new file mode 100644 index 0000000000..4c39520df7 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPillager.java @@ -0,0 +1,35 @@ +package org.bukkit.craftbukkit.entity; + +import net.minecraft.server.EntityPillager; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.craftbukkit.inventory.CraftInventory; +import org.bukkit.entity.Pillager; +import org.bukkit.entity.EntityType; +import org.bukkit.inventory.Inventory; + +public class CraftPillager extends CraftIllager implements Pillager { + + public CraftPillager(CraftServer server, EntityPillager entity) { + super(server, entity); + } + + @Override + public EntityPillager getHandle() { + return (EntityPillager) super.getHandle(); + } + + @Override + public EntityType getType() { + return EntityType.PILLAGER; + } + + @Override + public String toString() { + return "CraftPillager"; + } + + @Override + public Inventory getInventory() { + return new CraftInventory(getHandle().getInventory()); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index 23277f404f..57383feb26 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -36,8 +36,6 @@ import net.minecraft.server.Container; import net.minecraft.server.Entity; import net.minecraft.server.EntityLiving; import net.minecraft.server.EntityPlayer; -import net.minecraft.server.EntityTracker; -import net.minecraft.server.EntityTrackerEntry; import net.minecraft.server.EnumChatFormat; import net.minecraft.server.EnumGamemode; import net.minecraft.server.IChatBaseComponent; @@ -60,6 +58,7 @@ import net.minecraft.server.PacketPlayOutUpdateAttributes; import net.minecraft.server.PacketPlayOutUpdateHealth; import net.minecraft.server.PacketPlayOutWorldEvent; import net.minecraft.server.PacketPlayOutWorldParticles; +import net.minecraft.server.PlayerChunkMap; import net.minecraft.server.PlayerConnection; import net.minecraft.server.TileEntitySign; import net.minecraft.server.Vec3D; @@ -399,6 +398,27 @@ public class CraftPlayer extends CraftHumanEntity implements Player { case 9: instrumentName = "xylophone"; break; + case 10: + instrumentName = "iron_xylophone"; + break; + case 11: + instrumentName = "cow_bell"; + break; + case 12: + instrumentName = "didgeridoo"; + break; + case 13: + instrumentName = "bit"; + break; + case 14: + instrumentName = "banjo"; + break; + case 15: + instrumentName = "pling"; + break; + case 16: + instrumentName = "xylophone"; + break; } float f = (float) Math.pow(2.0D, (note.getId() - 12.0D) / 12.0D); getHandle().playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect(CraftSound.getSoundEffect("block.note_block." + instrumentName), net.minecraft.server.SoundCategory.RECORDS, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), 3.0f, f)); @@ -562,7 +582,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { } } - PacketPlayOutMap packet = new PacketPlayOutMap(map.getId(), map.getScale().getValue(), true, icons, data.buffer, 0, 0, 128, 128); + PacketPlayOutMap packet = new PacketPlayOutMap(map.getId(), map.getScale().getValue(), true, map.isLocked(), icons, data.buffer, 0, 0, 128, 128); getHandle().playerConnection.sendPacket(packet); } @@ -668,7 +688,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @Override public void setSleepingIgnored(boolean isSleeping) { getHandle().fauxSleeping = isSleeping; - ((CraftWorld) getWorld()).getHandle().checkSleepStatus(); + ((CraftWorld) getWorld()).getHandle().everyoneSleeping(); } @Override @@ -1000,9 +1020,9 @@ public class CraftPlayer extends CraftHumanEntity implements Player { hiddenPlayers.put(player.getUniqueId(), hidingPlugins); // Remove this player from the hidden player's EntityTrackerEntry - EntityTracker tracker = ((WorldServer) entity.world).tracker; + PlayerChunkMap tracker = ((WorldServer) entity.world).getChunkProvider().playerChunkMap; EntityPlayer other = ((CraftPlayer) player).getHandle(); - EntityTrackerEntry entry = tracker.trackedEntities.get(other.getId()); + PlayerChunkMap.EntityTracker entry = tracker.trackedEntities.get(other.getId()); if (entry != null) { entry.clear(getHandle()); } @@ -1042,12 +1062,12 @@ public class CraftPlayer extends CraftHumanEntity implements Player { } hiddenPlayers.remove(player.getUniqueId()); - EntityTracker tracker = ((WorldServer) entity.world).tracker; + PlayerChunkMap tracker = ((WorldServer) entity.world).getChunkProvider().playerChunkMap; EntityPlayer other = ((CraftPlayer) player).getHandle(); getHandle().playerConnection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, other)); - EntityTrackerEntry entry = tracker.trackedEntities.get(other.getId()); + PlayerChunkMap.EntityTracker entry = tracker.trackedEntities.get(other.getId()); if (entry != null && !entry.trackedPlayers.contains(getHandle())) { entry.updatePlayer(getHandle()); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftRabbit.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftRabbit.java index 61330d2436..bfb8f07abd 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftRabbit.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftRabbit.java @@ -41,8 +41,8 @@ public class CraftRabbit extends CraftAnimals implements Rabbit { if (getRabbitType() == Type.THE_KILLER_BUNNY) { // Reset goals and target finders. World world = ((CraftWorld) this.getWorld()).getHandle(); - entity.goalSelector = new PathfinderGoalSelector(world != null && world.methodProfiler != null ? world.methodProfiler : null); - entity.targetSelector = new PathfinderGoalSelector(world != null && world.methodProfiler != null ? world.methodProfiler : null); + entity.goalSelector = new PathfinderGoalSelector(world != null && world.getMethodProfiler() != null ? world.getMethodProfiler() : null); + entity.targetSelector = new PathfinderGoalSelector(world != null && world.getMethodProfiler() != null ? world.getMethodProfiler() : null); entity.initializePathFinderGoals(); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftRaider.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftRaider.java new file mode 100644 index 0000000000..f8b92b425c --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftRaider.java @@ -0,0 +1,52 @@ +package org.bukkit.craftbukkit.entity; + +import com.google.common.base.Preconditions; +import net.minecraft.server.BlockPosition; +import net.minecraft.server.EntityRaider; +import org.bukkit.block.Block; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.craftbukkit.block.CraftBlock; +import org.bukkit.entity.Raider; + +public abstract class CraftRaider extends CraftMonster implements Raider { + + public CraftRaider(CraftServer server, EntityRaider entity) { + super(server, entity); + } + + @Override + public EntityRaider getHandle() { + return (EntityRaider) super.getHandle(); + } + + @Override + public String toString() { + return "CraftRaider"; + } + + @Override + public Block getPatrolTarget() { + return getHandle().getPatrolTarget() == null ? null : CraftBlock.at(getHandle().world, getHandle().getPatrolTarget()); + } + + @Override + public void setPatrolTarget(Block block) { + if (block == null) { + getHandle().setPatrolTarget((BlockPosition) null); + } else { + Preconditions.checkArgument(block.getWorld().equals(this.getWorld()), "Block must be in same world"); + + getHandle().setPatrolTarget(new BlockPosition(block.getX(), block.getY(), block.getZ())); + } + } + + @Override + public boolean isPatrolLeader() { + return getHandle().isPatrolLeader(); + } + + @Override + public void setPatrolLeader(boolean leader) { + getHandle().setPatrolLeader(leader); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftRavager.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftRavager.java new file mode 100644 index 0000000000..3cb2e6cc5e --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftRavager.java @@ -0,0 +1,28 @@ +package org.bukkit.craftbukkit.entity; + +import net.minecraft.server.EntityRavager; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Ravager; + +public class CraftRavager extends CraftRaider implements Ravager { + + public CraftRavager(CraftServer server, EntityRavager entity) { + super(server, entity); + } + + @Override + public EntityRavager getHandle() { + return (EntityRavager) super.getHandle(); + } + + @Override + public EntityType getType() { + return EntityType.RAVAGER; + } + + @Override + public String toString() { + return "CraftRavager"; + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSplashPotion.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSplashPotion.java deleted file mode 100644 index 1ef057b86f..0000000000 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSplashPotion.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.bukkit.craftbukkit.entity; - -import net.minecraft.server.EntityPotion; -import org.apache.commons.lang.Validate; -import org.bukkit.Material; -import org.bukkit.craftbukkit.CraftServer; -import org.bukkit.craftbukkit.inventory.CraftItemStack; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.SplashPotion; -import org.bukkit.inventory.ItemStack; - -public class CraftSplashPotion extends CraftThrownPotion implements SplashPotion { - - public CraftSplashPotion(CraftServer server, EntityPotion entity) { - super(server, entity); - } - - @Override - public void setItem(ItemStack item) { - // The ItemStack must not be null. - Validate.notNull(item, "ItemStack cannot be null."); - - // The ItemStack must be a potion. - Validate.isTrue(item.getType() == Material.SPLASH_POTION, "ItemStack must be a splash potion. This item stack was " + item.getType() + "."); - - getHandle().setItem(CraftItemStack.asNMSCopy(item)); - } - - @Override - public EntityPotion getHandle() { - return (EntityPotion) entity; - } - - @Override - public String toString() { - return "CraftSplashPotion"; - } - - @Override - public EntityType getType() { - return EntityType.SPLASH_POTION; - } -} diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownPotion.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownPotion.java index b19539935d..1af23a0def 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownPotion.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownPotion.java @@ -17,7 +17,7 @@ import org.bukkit.potion.PotionEffect; import com.google.common.collect.ImmutableList; -public abstract class CraftThrownPotion extends CraftProjectile implements ThrownPotion { +public class CraftThrownPotion extends CraftProjectile implements ThrownPotion { public CraftThrownPotion(CraftServer server, EntityPotion entity) { super(server, entity); } @@ -34,8 +34,24 @@ public abstract class CraftThrownPotion extends CraftProjectile implements Throw return CraftItemStack.asBukkitCopy(getHandle().getItem()); } + @Override + public void setItem(ItemStack item) { + // The ItemStack must not be null. + Validate.notNull(item, "ItemStack cannot be null."); + + // The ItemStack must be a potion. + Validate.isTrue(item.getType() == Material.LINGERING_POTION || item.getType() == Material.SPLASH_POTION, "ItemStack must be a lingering or splash potion. This item stack was " + item.getType() + "."); + + getHandle().setItem(CraftItemStack.asNMSCopy(item)); + } + @Override public EntityPotion getHandle() { return (EntityPotion) entity; } + + @Override + public EntityType getType() { + return EntityType.SPLASH_POTION; + } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftTippedArrow.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftTippedArrow.java index 435203b881..b71b5d8658 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftTippedArrow.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftTippedArrow.java @@ -37,7 +37,7 @@ public class CraftTippedArrow extends CraftArrow implements TippedArrow { @Override public EntityType getType() { - return EntityType.TIPPED_ARROW; + return EntityType.ARROW; } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftTraderLlama.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftTraderLlama.java new file mode 100644 index 0000000000..a8ecddf78e --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftTraderLlama.java @@ -0,0 +1,28 @@ +package org.bukkit.craftbukkit.entity; + +import net.minecraft.server.EntityLLamaTrader; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.TraderLlama; + +public class CraftTraderLlama extends CraftLlama implements TraderLlama { + + public CraftTraderLlama(CraftServer server, EntityLLamaTrader entity) { + super(server, entity); + } + + @Override + public EntityLLamaTrader getHandle() { + return (EntityLLamaTrader) super.getHandle(); + } + + @Override + public String toString() { + return "CraftTraderLlama"; + } + + @Override + public EntityType getType() { + return EntityType.TRADER_LLAMA; + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftVex.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftVex.java index 0f01fc591d..737a37b6fe 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftVex.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftVex.java @@ -28,11 +28,11 @@ public class CraftVex extends CraftMonster implements Vex { @Override public boolean isCharging() { - return getHandle().dA(); + return getHandle().isCharging(); } @Override public void setCharging(boolean charging) { - getHandle().a(charging); + getHandle().setCharging(charging); } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java index e21fe51a06..16eba14f73 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java @@ -1,25 +1,15 @@ package org.bukkit.craftbukkit.entity; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import javax.annotation.Nullable; +import java.util.Locale; import net.minecraft.server.EntityVillager; +import net.minecraft.server.IRegistry; +import net.minecraft.server.MinecraftKey; import org.apache.commons.lang.Validate; import org.bukkit.craftbukkit.CraftServer; -import org.bukkit.craftbukkit.inventory.CraftInventory; -import org.bukkit.craftbukkit.inventory.CraftMerchant; 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 { - - private static final Map careerIDMap = new HashMap<>(); - private CraftMerchant merchant; +public class CraftVillager extends CraftAbstractVillager implements Villager { public CraftVillager(CraftServer server, EntityVillager entity) { super(server, entity); @@ -40,126 +30,11 @@ public class CraftVillager extends CraftAgeable implements Villager, InventoryHo } public Profession getProfession() { - return Profession.values()[getHandle().getProfession() + 1]; // Offset by 1 from the zombie types + return Profession.valueOf(IRegistry.VILLAGER_PROFESSION.getKey(getHandle().getVillagerData().getProfession()).getKey().toUpperCase(Locale.ROOT)); } public void setProfession(Profession profession) { Validate.notNull(profession); - Validate.isTrue(!profession.isZombie(), "Profession is reserved for Zombies: ", profession); - getHandle().setProfession(profession.ordinal() - 1); - } - - @Override - public Career getCareer() { - return getCareer(getProfession(), getHandle().careerId); - } - - @Override - public void setCareer(Career career) { - setCareer(career, true); - } - - @Override - public void setCareer(Career career, boolean resetTrades) { - if (career == null) { - getHandle().careerId = 0; // reset career - } else { - Validate.isTrue(career.getProfession() == getProfession(), "Career assignment mismatch. Found (" + getProfession() + ") Required (" + career.getProfession() + ")"); - getHandle().careerId = getCareerID(career); - } - - if (resetTrades) { - getHandle().trades = null; - getHandle().careerLevel = 0; // SPIGOT-4310 - getHandle().populateTrades(); - } - } - - @Override - public Inventory getInventory() { - return new CraftInventory(getHandle().inventory); - } - - private CraftMerchant getMerchant() { - return (merchant == null) ? merchant = new CraftMerchant(getHandle()) : merchant; - } - - @Override - public List getRecipes() { - return getMerchant().getRecipes(); - } - - @Override - public void setRecipes(List recipes) { - this.getMerchant().setRecipes(recipes); - } - - @Override - public MerchantRecipe getRecipe(int i) { - return getMerchant().getRecipe(i); - } - - @Override - public void setRecipe(int i, MerchantRecipe merchantRecipe) { - getMerchant().setRecipe(i, merchantRecipe); - } - - @Override - public int getRecipeCount() { - return getMerchant().getRecipeCount(); - } - - @Override - public boolean isTrading() { - return getTrader() != null; - } - - @Override - public HumanEntity getTrader() { - return getMerchant().getTrader(); - } - - @Override - public int getRiches() { - return getHandle().riches; - } - - @Override - public void setRiches(int riches) { - getHandle().riches = riches; - } - - @Nullable - private static Career getCareer(Profession profession, int id) { - Validate.isTrue(id > 0, "Career id must be greater than 0"); - - List careers = profession.getCareers(); - for (Career c : careers) { - if (careerIDMap.containsKey(c) && careerIDMap.get(c) == id) { - return c; - } - } - - return null; - } - - private static int getCareerID(Career career) { - return careerIDMap.getOrDefault(career, 0); - } - - static { - // build Career -> ID map - int id = 0; - for (Profession prof : Profession.values()) { - List careers = prof.getCareers(); - if (!careers.isEmpty()) { - for (Career c : careers) { - careerIDMap.put(c, ++id); - } - } - - Validate.isTrue(id == careers.size(), "Career id registration mismatch"); - id = 0; - } + getHandle().setVillagerData(getHandle().getVillagerData().withProfession(IRegistry.VILLAGER_PROFESSION.get(new MinecraftKey(profession.name().toLowerCase(Locale.ROOT))))); } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftVillagerZombie.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftVillagerZombie.java index 5117da245f..df9d1069ee 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftVillagerZombie.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftVillagerZombie.java @@ -1,8 +1,12 @@ package org.bukkit.craftbukkit.entity; import com.google.common.base.Preconditions; +import java.util.Locale; import java.util.UUID; import net.minecraft.server.EntityZombieVillager; +import net.minecraft.server.IRegistry; +import net.minecraft.server.MinecraftKey; +import org.apache.commons.lang.Validate; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.EntityType; import org.bukkit.entity.Villager; @@ -31,12 +35,13 @@ public class CraftVillagerZombie extends CraftZombie implements ZombieVillager { @Override public Villager.Profession getVillagerProfession() { - return Villager.Profession.values()[getHandle().getProfession() + Villager.Profession.FARMER.ordinal()]; + return Villager.Profession.valueOf(IRegistry.VILLAGER_PROFESSION.getKey(getHandle().getVillagerData().getProfession()).getKey().toUpperCase(Locale.ROOT)); } @Override public void setVillagerProfession(Villager.Profession profession) { - getHandle().setProfession(profession == null ? 0 : profession.ordinal() - Villager.Profession.FARMER.ordinal()); + Validate.notNull(profession); + getHandle().setVillagerData(getHandle().getVillagerData().withProfession(IRegistry.VILLAGER_PROFESSION.get(new MinecraftKey(profession.name().toLowerCase(Locale.ROOT))))); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftWanderingTrader.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftWanderingTrader.java new file mode 100644 index 0000000000..795e6afd81 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftWanderingTrader.java @@ -0,0 +1,28 @@ +package org.bukkit.craftbukkit.entity; + +import net.minecraft.server.EntityVillagerTrader; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.WanderingTrader; + +public class CraftWanderingTrader extends CraftAbstractVillager implements WanderingTrader { + + public CraftWanderingTrader(CraftServer server, EntityVillagerTrader entity) { + super(server, entity); + } + + @Override + public EntityVillagerTrader getHandle() { + return (EntityVillagerTrader) entity; + } + + @Override + public String toString() { + return "CraftWanderingTrader"; + } + + @Override + public EntityType getType() { + return EntityType.WANDERING_TRADER; + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftWeather.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftWeather.java deleted file mode 100644 index 91a749334a..0000000000 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftWeather.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.bukkit.craftbukkit.entity; - -import net.minecraft.server.EntityWeather; -import org.bukkit.craftbukkit.CraftServer; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Weather; - -public class CraftWeather extends CraftEntity implements Weather { - public CraftWeather(final CraftServer server, final EntityWeather entity) { - super(server, entity); - } - - @Override - public EntityWeather getHandle() { - return (EntityWeather) entity; - } - - @Override - public String toString() { - return "CraftWeather"; - } - - public EntityType getType() { - return EntityType.WEATHER; - } -} diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftWitch.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftWitch.java index c08833cb7a..a3a8455a30 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftWitch.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftWitch.java @@ -5,7 +5,7 @@ import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.Witch; import org.bukkit.entity.EntityType; -public class CraftWitch extends CraftMonster implements Witch { +public class CraftWitch extends CraftRaider implements Witch { public CraftWitch(CraftServer server, EntityWitch entity) { super(server, entity); } diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index b4f66ceaaf..d191b065a6 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -11,6 +11,7 @@ import javax.annotation.Nullable; import com.google.common.base.Function; import com.google.common.base.Functions; import com.google.common.collect.Lists; +import com.mojang.datafixers.util.Either; import net.minecraft.server.*; @@ -106,36 +107,33 @@ public class CraftEventFactory { /** * PlayerBedEnterEvent */ - public static EntityHuman.EnumBedResult callPlayerBedEnterEvent(EntityHuman player, BlockPosition bed, EntityHuman.EnumBedResult nmsBedResult) { - BedEnterResult bedEnterResult; - switch (nmsBedResult) { - case OK: - bedEnterResult = BedEnterResult.OK; - break; - case NOT_POSSIBLE_HERE: - bedEnterResult = BedEnterResult.NOT_POSSIBLE_HERE; - break; - case NOT_POSSIBLE_NOW: - bedEnterResult = BedEnterResult.NOT_POSSIBLE_NOW; - break; - case TOO_FAR_AWAY: - bedEnterResult = BedEnterResult.TOO_FAR_AWAY; - break; - case NOT_SAFE: - bedEnterResult = BedEnterResult.NOT_SAFE; - break; - default: - bedEnterResult = BedEnterResult.OTHER_PROBLEM; - } + public static Either callPlayerBedEnterEvent(EntityHuman player, BlockPosition bed, Either nmsBedResult) { + BedEnterResult bedEnterResult = nmsBedResult.mapBoth(new Function() { + @Override + public BedEnterResult apply(EntityHuman.EnumBedResult t) { + switch (t) { + case NOT_POSSIBLE_HERE: + return BedEnterResult.NOT_POSSIBLE_HERE; + case NOT_POSSIBLE_NOW: + return BedEnterResult.NOT_POSSIBLE_NOW; + case TOO_FAR_AWAY: + return BedEnterResult.TOO_FAR_AWAY; + case NOT_SAFE: + return BedEnterResult.NOT_SAFE; + default: + return BedEnterResult.OTHER_PROBLEM; + } + } + }, t -> BedEnterResult.OK).map(java.util.function.Function.identity(), java.util.function.Function.identity()); PlayerBedEnterEvent event = new PlayerBedEnterEvent((Player) player.getBukkitEntity(), CraftBlock.at(player.world, bed), bedEnterResult); Bukkit.getServer().getPluginManager().callEvent(event); Result result = event.useBed(); if (result == Result.ALLOW) { - return EntityHuman.EnumBedResult.OK; + return Either.right(Unit.INSTANCE); } else if (result == Result.DENY) { - return EntityHuman.EnumBedResult.OTHER_PROBLEM; + return Either.left(EntityHuman.EnumBedResult.OTHER_PROBLEM); } return nmsBedResult; @@ -331,10 +329,10 @@ public class CraftEventFactory { /** * EntityShootBowEvent */ - public static EntityShootBowEvent callEntityShootBowEvent(EntityLiving who, ItemStack itemstack, EntityArrow entityArrow, float force) { + public static EntityShootBowEvent callEntityShootBowEvent(EntityLiving who, ItemStack itemstack, Entity entityArrow, float force) { LivingEntity shooter = (LivingEntity) who.getBukkitEntity(); CraftItemStack itemInHand = CraftItemStack.asCraftMirror(itemstack); - Arrow arrow = (Arrow) entityArrow.getBukkitEntity(); + org.bukkit.entity.Entity arrow = entityArrow.getBukkitEntity(); if (itemInHand != null && (itemInHand.getType() == Material.AIR || itemInHand.getAmount() == 0)) { itemInHand = null; @@ -374,7 +372,7 @@ public class CraftEventFactory { boolean isNpc = entity instanceof NPC; if (spawnReason != SpawnReason.CUSTOM) { - if (isAnimal && !world.allowAnimals || isMonster && !world.allowMonsters || isNpc && !world.getServer().getServer().getSpawnNPCs()) { + if (isAnimal && !world.getWorld().getAllowAnimals() || isMonster && !world.getWorld().getAllowMonsters() || isNpc && !world.getServer().getServer().getSpawnNPCs()) { entity.dead = true; return false; } @@ -658,7 +656,7 @@ public class CraftEventFactory { DamageCause cause = null; Block damager = blockDamage; blockDamage = null; - if (source == DamageSource.CACTUS) { + if (source == DamageSource.CACTUS || source == DamageSource.SWEET_BERRY_BUSH) { cause = DamageCause.CONTACT; } else if (source == DamageSource.HOT_FLOOR) { cause = DamageCause.HOT_FLOOR; @@ -895,9 +893,9 @@ public class CraftEventFactory { return event; } - public static EntityBreakDoorEvent callEntityBreakDoorEvent(Entity entity, int x, int y, int z) { + public static EntityBreakDoorEvent callEntityBreakDoorEvent(Entity entity, BlockPosition pos) { org.bukkit.entity.Entity entity1 = entity.getBukkitEntity(); - Block block = entity1.getWorld().getBlockAt(x, y, z); + Block block = CraftBlock.at(entity.world, pos); EntityBreakDoorEvent event = new EntityBreakDoorEvent((LivingEntity) entity1, block); entity1.getServer().getPluginManager().callEvent(event); @@ -952,12 +950,18 @@ public class CraftEventFactory { public static ProjectileHitEvent callProjectileHitEvent(Entity entity, MovingObjectPosition position) { Block hitBlock = null; BlockFace hitFace = null; - if (position.type == MovingObjectPosition.EnumMovingObjectType.BLOCK) { - hitBlock = CraftBlock.at(entity.world, position.getBlockPosition()); - hitFace = CraftBlock.notchToBlockFace(position.direction); + if (position.getType() == MovingObjectPosition.EnumMovingObjectType.BLOCK) { + MovingObjectPositionBlock positionBlock = (MovingObjectPositionBlock) position; + hitBlock = CraftBlock.at(entity.world, positionBlock.getBlockPosition()); + hitFace = CraftBlock.notchToBlockFace(positionBlock.getDirection()); } - ProjectileHitEvent event = new ProjectileHitEvent((Projectile) entity.getBukkitEntity(), position.entity == null ? null : position.entity.getBukkitEntity(), hitBlock, hitFace); + org.bukkit.entity.Entity hitEntity = null; + if (position.getType() == MovingObjectPosition.EnumMovingObjectType.ENTITY) { + hitEntity = ((MovingObjectPositionEntity) position).getEntity().getBukkitEntity(); + } + + ProjectileHitEvent event = new ProjectileHitEvent((Projectile) entity.getBukkitEntity(), hitEntity, hitBlock, hitFace); entity.world.getServer().getPluginManager().callEvent(event); return event; } @@ -1209,7 +1213,10 @@ public class CraftEventFactory { public static BlockPhysicsEvent callBlockPhysicsEvent(GeneratorAccess world, BlockPosition blockposition) { org.bukkit.block.Block block = CraftBlock.at(world, blockposition); BlockPhysicsEvent event = new BlockPhysicsEvent(block, block.getBlockData()); - world.getMinecraftWorld().getMinecraftServer().server.getPluginManager().callEvent(event); + // Suppress during worldgen + if (world instanceof World) { + world.getMinecraftWorld().getMinecraftServer().server.getPluginManager().callEvent(event); + } return event; } diff --git a/src/main/java/org/bukkit/craftbukkit/generator/CraftChunkData.java b/src/main/java/org/bukkit/craftbukkit/generator/CraftChunkData.java index 791017258a..7772d59005 100644 --- a/src/main/java/org/bukkit/craftbukkit/generator/CraftChunkData.java +++ b/src/main/java/org/bukkit/craftbukkit/generator/CraftChunkData.java @@ -157,7 +157,7 @@ public final class CraftChunkData implements ChunkGenerator.ChunkData { private ChunkSection getChunkSection(int y, boolean create) { ChunkSection section = sections[y >> 4]; if (create && section == null) { - sections[y >> 4] = section = new ChunkSection(y, create); + sections[y >> 4] = section = new ChunkSection(y); } return section; } diff --git a/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java b/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java index 91d528fb39..bc1ca5ce21 100644 --- a/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java +++ b/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java @@ -1,29 +1,23 @@ package org.bukkit.craftbukkit.generator; import com.google.common.base.Preconditions; -import com.google.common.collect.Maps; -import it.unimi.dsi.fastutil.longs.Long2ObjectMap; -import it.unimi.dsi.fastutil.longs.Long2ObjectMaps; -import it.unimi.dsi.fastutil.longs.LongSet; import java.util.List; -import java.util.Map; import java.util.Random; import net.minecraft.server.*; import org.bukkit.block.Biome; -import org.bukkit.generator.BlockPopulator; import org.bukkit.generator.ChunkGenerator; import org.bukkit.craftbukkit.block.CraftBlock; +import org.bukkit.generator.ChunkGenerator.BiomeGrid; +import org.bukkit.generator.ChunkGenerator.ChunkData; public class CustomChunkGenerator extends InternalChunkGenerator { private final ChunkGenerator generator; private final WorldServer world; private final long seed; private final Random random; - private final WorldChunkManager chunkManager; - private final WorldGenStronghold strongholdGen = new WorldGenStronghold(); - private final GeneratorSettingsDefault settings = new GeneratorSettingsDefault(); + private final StructureGenerator strongholdGen = WorldGenerator.STRONGHOLD; private static class CustomBiomeGrid implements BiomeGrid { BiomeBase[] biome; @@ -40,23 +34,23 @@ public class CustomChunkGenerator extends InternalChunkGenerator getDefaultPopulators(org.bukkit.World world) { - return generator.getDefaultPopulators(world); + public int getBaseHeight(int i, int j, HeightMap.Type heightmap_type) { + return 0; } @Override @@ -116,10 +108,6 @@ public class CustomChunkGenerator extends InternalChunkGenerator structuregenerator) { - return biomebase.b(structuregenerator); - } - - // Taken from ChunkGeneratorAbstract - private final Map, Long2ObjectMap> structureStartCache = Maps.newHashMap(); - - @Override - public Long2ObjectMap getStructureStartCache(StructureGenerator structuregenerator) { - return (Long2ObjectMap) this.structureStartCache.computeIfAbsent(structuregenerator, (s) -> { - return Long2ObjectMaps.synchronize(new ExpiringMap(8192, 10000)); - }); - } - - // Taken from ChunkGeneratorAbstract - private final Map, Long2ObjectMap> structureCache = Maps.newHashMap(); - - @Override - public Long2ObjectMap getStructureCache(StructureGenerator structuregenerator) { - return (Long2ObjectMap) this.structureCache.computeIfAbsent(structuregenerator, (s) -> { - return Long2ObjectMaps.synchronize(new ExpiringMap(8192, 10000)); - }); - } - - @Override - public WorldChunkManager getWorldChunkManager() { - return chunkManager; - } - @Override public long getSeed() { return seed; diff --git a/src/main/java/org/bukkit/craftbukkit/generator/InternalChunkGenerator.java b/src/main/java/org/bukkit/craftbukkit/generator/InternalChunkGenerator.java index b0710cd825..d98b1be39e 100644 --- a/src/main/java/org/bukkit/craftbukkit/generator/InternalChunkGenerator.java +++ b/src/main/java/org/bukkit/craftbukkit/generator/InternalChunkGenerator.java @@ -1,8 +1,13 @@ package org.bukkit.craftbukkit.generator; -import net.minecraft.server.GeneratorSettings; -import org.bukkit.generator.ChunkGenerator; +import net.minecraft.server.GeneratorAccess; +import net.minecraft.server.GeneratorSettingsDefault; +import net.minecraft.server.WorldChunkManager; // Do not implement functions to this class, add to NormalChunkGenerator -public abstract class InternalChunkGenerator extends ChunkGenerator implements net.minecraft.server.ChunkGenerator { +public abstract class InternalChunkGenerator extends net.minecraft.server.ChunkGenerator { + + public InternalChunkGenerator(GeneratorAccess generatorAccess, WorldChunkManager worldChunkManager, C c0) { + super(generatorAccess, worldChunkManager, c0); + } } diff --git a/src/main/java/org/bukkit/craftbukkit/generator/NetherChunkGenerator.java b/src/main/java/org/bukkit/craftbukkit/generator/NetherChunkGenerator.java deleted file mode 100644 index 59d7bbec55..0000000000 --- a/src/main/java/org/bukkit/craftbukkit/generator/NetherChunkGenerator.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.bukkit.craftbukkit.generator; - -import net.minecraft.server.World; - -/** - * This class is useless. Just fyi. - */ -public class NetherChunkGenerator extends NormalChunkGenerator { - public NetherChunkGenerator(World world, long seed) { - super(world, seed); - } -} diff --git a/src/main/java/org/bukkit/craftbukkit/generator/NormalChunkGenerator.java b/src/main/java/org/bukkit/craftbukkit/generator/NormalChunkGenerator.java deleted file mode 100644 index fd5280e003..0000000000 --- a/src/main/java/org/bukkit/craftbukkit/generator/NormalChunkGenerator.java +++ /dev/null @@ -1,114 +0,0 @@ -package org.bukkit.craftbukkit.generator; - -import it.unimi.dsi.fastutil.longs.Long2ObjectMap; -import it.unimi.dsi.fastutil.longs.LongSet; -import java.util.ArrayList; -import java.util.List; -import java.util.Random; - -import net.minecraft.server.*; - -import org.bukkit.generator.BlockPopulator; - -public class NormalChunkGenerator extends InternalChunkGenerator { - private final ChunkGenerator generator; - - public NormalChunkGenerator(World world, long seed) { - generator = world.worldProvider.getChunkGenerator(); - } - - @Override - public ChunkData generateChunkData(org.bukkit.World world, Random random, int x, int z, BiomeGrid biome) { - throw new UnsupportedOperationException("Not supported."); - } - - @Override - public boolean canSpawn(org.bukkit.World world, int x, int z) { - return true; // PAIL - } - - @Override - public List getDefaultPopulators(org.bukkit.World world) { - return new ArrayList(); - } - - @Override - public List getMobsFor(EnumCreatureType enumCreatureType, BlockPosition blockPosition) { - return generator.getMobsFor(enumCreatureType, blockPosition); - } - - @Override - public BlockPosition findNearestMapFeature(World world, String s, BlockPosition blockPosition, int i, boolean flag) { - return generator.findNearestMapFeature(world, s, blockPosition, i, flag); - } - - @Override - public void createChunk(IChunkAccess ichunkaccess) { - generator.createChunk(ichunkaccess); - } - - @Override - public void addFeatures(RegionLimitedWorldAccess regionlimitedworldaccess, WorldGenStage.Features worldgenstage_features) { - generator.addFeatures(regionlimitedworldaccess, worldgenstage_features); - } - - @Override - public void addDecorations(RegionLimitedWorldAccess regionlimitedworldaccess) { - generator.addDecorations(regionlimitedworldaccess); - } - - @Override - public void addMobs(RegionLimitedWorldAccess regionlimitedworldaccess) { - generator.addMobs(regionlimitedworldaccess); - } - - @Override - public C getSettings() { - return (C) generator.getSettings(); - } - - @Override - public int a(World world, boolean flag, boolean flag1) { - return generator.a(world, flag, flag1); - } - - @Override - public boolean canSpawnStructure(BiomeBase biomebase, StructureGenerator structuregenerator) { - return generator.canSpawnStructure(biomebase, structuregenerator); - } - - @Override - public WorldGenFeatureConfiguration getFeatureConfiguration(BiomeBase biomebase, StructureGenerator structuregenerator) { - return generator.getFeatureConfiguration(biomebase, structuregenerator); - } - - @Override - public Long2ObjectMap getStructureStartCache(StructureGenerator structuregenerator) { - return generator.getStructureStartCache(structuregenerator); - } - - @Override - public Long2ObjectMap getStructureCache(StructureGenerator structuregenerator) { - return generator.getStructureCache(structuregenerator); - } - - @Override - public WorldChunkManager getWorldChunkManager() { - return generator.getWorldChunkManager(); - } - - @Override - public long getSeed() { - return generator.getSeed(); - } - - @Override - public int getSpawnHeight() { - return generator.getSpawnHeight(); - } - - @Override - public int getGenerationDepth() { - return generator.getGenerationDepth(); - } -} diff --git a/src/main/java/org/bukkit/craftbukkit/generator/SkyLandsChunkGenerator.java b/src/main/java/org/bukkit/craftbukkit/generator/SkyLandsChunkGenerator.java deleted file mode 100644 index e327996943..0000000000 --- a/src/main/java/org/bukkit/craftbukkit/generator/SkyLandsChunkGenerator.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.bukkit.craftbukkit.generator; - -import net.minecraft.server.World; - -/** - * This class is useless. Just fyi. - */ -public class SkyLandsChunkGenerator extends NormalChunkGenerator { - public SkyLandsChunkGenerator(World world, long seed) { - super(world, seed); - } -} diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftBlastingRecipe.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftBlastingRecipe.java new file mode 100644 index 0000000000..f6e32ca099 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftBlastingRecipe.java @@ -0,0 +1,30 @@ +package org.bukkit.craftbukkit.inventory; + +import net.minecraft.server.MinecraftServer; +import org.bukkit.NamespacedKey; +import org.bukkit.craftbukkit.util.CraftNamespacedKey; +import org.bukkit.inventory.BlastingRecipe; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.RecipeChoice; + +public class CraftBlastingRecipe extends BlastingRecipe implements CraftRecipe { + public CraftBlastingRecipe(NamespacedKey key, ItemStack result, RecipeChoice source, float experience, int cookingTime) { + super(key, result, source, experience, cookingTime); + } + + public static CraftBlastingRecipe fromBukkitRecipe(BlastingRecipe recipe) { + if (recipe instanceof CraftBlastingRecipe) { + return (CraftBlastingRecipe) recipe; + } + CraftBlastingRecipe ret = new CraftBlastingRecipe(recipe.getKey(), recipe.getResult(), recipe.getInputChoice(), recipe.getExperience(), recipe.getCookingTime()); + ret.setGroup(recipe.getGroup()); + return ret; + } + + @Override + public void addToCraftingManager() { + ItemStack result = this.getResult(); + + MinecraftServer.getServer().getCraftingManager().addRecipe(new net.minecraft.server.RecipeBlasting(CraftNamespacedKey.toMinecraft(this.getKey()), this.getGroup(), toNMS(this.getInputChoice(), true), CraftItemStack.asNMSCopy(result), getExperience(), getCookingTime())); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftBlockInventoryHolder.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftBlockInventoryHolder.java new file mode 100644 index 0000000000..d5149c2462 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftBlockInventoryHolder.java @@ -0,0 +1,30 @@ +package org.bukkit.craftbukkit.inventory; + +import net.minecraft.server.BlockPosition; +import net.minecraft.server.GeneratorAccess; +import net.minecraft.server.IInventory; +import org.bukkit.block.Block; +import org.bukkit.craftbukkit.block.CraftBlock; +import org.bukkit.inventory.BlockInventoryHolder; +import org.bukkit.inventory.Inventory; + +public class CraftBlockInventoryHolder implements BlockInventoryHolder { + + private final Block block; + private final Inventory inventory; + + public CraftBlockInventoryHolder(GeneratorAccess world, BlockPosition pos, IInventory inv) { + this.block = CraftBlock.at(world, pos); + this.inventory = new CraftInventory(inv); + } + + @Override + public Block getBlock() { + return block; + } + + @Override + public Inventory getInventory() { + return inventory; + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftCampfireRecipe.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftCampfireRecipe.java new file mode 100644 index 0000000000..5c61cf9650 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftCampfireRecipe.java @@ -0,0 +1,30 @@ +package org.bukkit.craftbukkit.inventory; + +import net.minecraft.server.MinecraftServer; +import org.bukkit.NamespacedKey; +import org.bukkit.craftbukkit.util.CraftNamespacedKey; +import org.bukkit.inventory.CampfireRecipe; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.RecipeChoice; + +public class CraftCampfireRecipe extends CampfireRecipe implements CraftRecipe { + public CraftCampfireRecipe(NamespacedKey key, ItemStack result, RecipeChoice source, float experience, int cookingTime) { + super(key, result, source, experience, cookingTime); + } + + public static CraftCampfireRecipe fromBukkitRecipe(CampfireRecipe recipe) { + if (recipe instanceof CraftCampfireRecipe) { + return (CraftCampfireRecipe) recipe; + } + CraftCampfireRecipe ret = new CraftCampfireRecipe(recipe.getKey(), recipe.getResult(), recipe.getInputChoice(), recipe.getExperience(), recipe.getCookingTime()); + ret.setGroup(recipe.getGroup()); + return ret; + } + + @Override + public void addToCraftingManager() { + ItemStack result = this.getResult(); + + MinecraftServer.getServer().getCraftingManager().addRecipe(new net.minecraft.server.RecipeCampfire(CraftNamespacedKey.toMinecraft(this.getKey()), this.getGroup(), toNMS(this.getInputChoice(), true), CraftItemStack.asNMSCopy(result), getExperience(), getCookingTime())); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java index 4c71d9fea1..1724b9b9e0 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java @@ -10,14 +10,23 @@ import org.bukkit.inventory.InventoryView; import net.minecraft.server.Container; import net.minecraft.server.ContainerAnvil; import net.minecraft.server.ContainerBeacon; +import net.minecraft.server.ContainerBlastFurnace; import net.minecraft.server.ContainerBrewingStand; +import net.minecraft.server.ContainerCartography; import net.minecraft.server.ContainerChest; import net.minecraft.server.ContainerDispenser; import net.minecraft.server.ContainerEnchantTable; -import net.minecraft.server.ContainerFurnace; +import net.minecraft.server.ContainerFurnaceFurnace; +import net.minecraft.server.ContainerGrindstone; import net.minecraft.server.ContainerHopper; +import net.minecraft.server.ContainerLectern; +import net.minecraft.server.ContainerLoom; +import net.minecraft.server.ContainerProperties; import net.minecraft.server.ContainerShulkerBox; +import net.minecraft.server.ContainerSmoker; +import net.minecraft.server.ContainerStonecutter; import net.minecraft.server.ContainerWorkbench; +import net.minecraft.server.Containers; import net.minecraft.server.EntityHuman; import net.minecraft.server.IInventory; import net.minecraft.server.ItemStack; @@ -34,8 +43,8 @@ public class CraftContainer extends Container { private final int cachedSize; public CraftContainer(InventoryView view, EntityHuman player, int id) { + super(getNotchInventoryType(view.getType()), id); this.view = view; - this.windowId = id; // TODO: Do we need to check that it really is a CraftInventory? IInventory top = ((CraftInventory) view.getTopInventory()).getInventory(); PlayerInventory bottom = (PlayerInventory) ((CraftInventory) view.getBottomInventory()).getInventory(); @@ -66,6 +75,11 @@ public class CraftContainer extends Container { public InventoryType getType() { return inventory.getType(); } + + @Override + public String getTitle() { + return inventory instanceof CraftInventoryCustom ? ((CraftInventoryCustom.MinecraftInventory) ((CraftInventory) inventory).getInventory()).getTitle() : inventory.getType().getDefaultTitle(); + } }, player, id); } @@ -91,7 +105,7 @@ public class CraftContainer extends Container { cachedTitle = view.getTitle(); if (view.getPlayer() instanceof CraftPlayer) { CraftPlayer player = (CraftPlayer) view.getPlayer(); - String type = getNotchInventoryType(cachedType); + Containers type = getNotchInventoryType(cachedType); IInventory top = ((CraftInventory) view.getTopInventory()).getInventory(); PlayerInventory bottom = (PlayerInventory) ((CraftInventory) view.getBottomInventory()).getInventory(); this.items.clear(); @@ -100,75 +114,112 @@ public class CraftContainer extends Container { setupSlots(top, bottom, player.getHandle()); } int size = getSize(); - player.getHandle().playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.windowId, type, new ChatComponentText(cachedTitle), size)); + player.getHandle().playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.windowId, type, new ChatComponentText(cachedTitle))); player.updateInventory(); } return true; } - public static String getNotchInventoryType(InventoryType type) { + public static Containers getNotchInventoryType(InventoryType type) { switch (type) { case WORKBENCH: - return "minecraft:crafting_table"; + return Containers.CRAFTING; case FURNACE: - return "minecraft:furnace"; + return Containers.FURNACE; case DISPENSER: - return "minecraft:dispenser"; + return Containers.GENERIC_3X3; case ENCHANTING: - return "minecraft:enchanting_table"; + return Containers.ENCHANTMENT; case BREWING: - return "minecraft:brewing_stand"; + return Containers.BREWING_STAND; case BEACON: - return "minecraft:beacon"; + return Containers.BEACON; case ANVIL: - return "minecraft:anvil"; + return Containers.ANVIL; case HOPPER: - return "minecraft:hopper"; + return Containers.HOPPER; case DROPPER: - return "minecraft:dropper"; + return Containers.GENERIC_3X3; case SHULKER_BOX: - return "minecraft:shulker_box"; + return Containers.SHULKER_BOX; + case BLAST_FURNACE: + return Containers.BLAST_FURNACE; + case LECTERN: + return Containers.LECTERN; + case SMOKER: + return Containers.SMOKER; + case LOOM: + return Containers.LOOM; + case CARTOGRAPHY: + return Containers.CARTOGRAPHY; + case GRINDSTONE: + return Containers.GRINDSTONE; + case STONECUTTER: + return Containers.STONECUTTER; default: - return "minecraft:chest"; + return Containers.GENERIC_9X3; } } private void setupSlots(IInventory top, PlayerInventory bottom, EntityHuman entityhuman) { + int windowId = -1; switch (cachedType) { case CREATIVE: break; // TODO: This should be an error? case PLAYER: case CHEST: - delegate = new ContainerChest(bottom, top, entityhuman); + case BARREL: + delegate = new ContainerChest(Containers.GENERIC_9X3, windowId, bottom, top, 3); break; case DISPENSER: case DROPPER: - delegate = new ContainerDispenser(bottom, top); + delegate = new ContainerDispenser(windowId, bottom, top); break; case FURNACE: - delegate = new ContainerFurnace(bottom, top); + delegate = new ContainerFurnaceFurnace(windowId, bottom, top, new ContainerProperties(4)); break; case CRAFTING: // TODO: This should be an error? case WORKBENCH: setupWorkbench(top, bottom); // SPIGOT-3812 - manually set up slots so we can use the delegated inventory and not the automatically created one break; case ENCHANTING: - delegate = new ContainerEnchantTable(bottom, entityhuman.world, entityhuman.getChunkCoordinates()); + delegate = new ContainerEnchantTable(windowId, bottom); break; case BREWING: - delegate = new ContainerBrewingStand(bottom, top); + delegate = new ContainerBrewingStand(windowId, bottom, top, new ContainerProperties(2)); break; case HOPPER: - delegate = new ContainerHopper(bottom, top, entityhuman); + delegate = new ContainerHopper(windowId, bottom, top); break; case ANVIL: - delegate = new ContainerAnvil(bottom, entityhuman.world, entityhuman.getChunkCoordinates(), entityhuman); + delegate = new ContainerAnvil(windowId, bottom); break; case BEACON: - delegate = new ContainerBeacon(bottom, top); + delegate = new ContainerBeacon(windowId, bottom); break; case SHULKER_BOX: - delegate = new ContainerShulkerBox(bottom, top, entityhuman); + delegate = new ContainerShulkerBox(windowId, bottom, top); + break; + case BLAST_FURNACE: + delegate = new ContainerBlastFurnace(windowId, bottom, top, new ContainerProperties(4)); + break; + case LECTERN: + delegate = new ContainerLectern(windowId, top, new ContainerProperties(1), bottom); + break; + case SMOKER: + delegate = new ContainerSmoker(windowId, bottom, top, new ContainerProperties(4)); + break; + case LOOM: + delegate = new ContainerLoom(windowId, bottom); + break; + case CARTOGRAPHY: + delegate = new ContainerCartography(windowId, bottom); + break; + case GRINDSTONE: + delegate = new ContainerGrindstone(windowId, bottom); + break; + case STONECUTTER: + delegate = new ContainerStonecutter(windowId, bottom); break; } @@ -179,7 +230,7 @@ public class CraftContainer extends Container { // SPIGOT-4598 - we should still delegate the shift click handler if (cachedType == InventoryType.WORKBENCH) { - delegate = new ContainerWorkbench(bottom, entityhuman.world, entityhuman.getChunkCoordinates()); + delegate = new ContainerWorkbench(windowId, bottom); } } @@ -217,4 +268,9 @@ public class CraftContainer extends Container { public boolean canUse(EntityHuman entity) { return true; } + + @Override + public Containers getType() { + return getNotchInventoryType(cachedType); + } } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftCustomTagTypeRegistry.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftCustomTagTypeRegistry.java index 47ff875b93..cd9aa66e31 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftCustomTagTypeRegistry.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftCustomTagTypeRegistry.java @@ -133,13 +133,13 @@ public final class CraftCustomTagTypeRegistry { Primitive Arrays */ if (Objects.equals(byte[].class, type)) { - return createAdapter(byte[].class, NBTTagByteArray.class, array -> new NBTTagByteArray(Arrays.copyOf(array, array.length)), n -> Arrays.copyOf(n.c(), n.size())); + return createAdapter(byte[].class, NBTTagByteArray.class, array -> new NBTTagByteArray(Arrays.copyOf(array, array.length)), n -> Arrays.copyOf(n.getBytes(), n.size())); } if (Objects.equals(int[].class, type)) { - return createAdapter(int[].class, NBTTagIntArray.class, array -> new NBTTagIntArray(Arrays.copyOf(array, array.length)), n -> Arrays.copyOf(n.d(), n.size())); + return createAdapter(int[].class, NBTTagIntArray.class, array -> new NBTTagIntArray(Arrays.copyOf(array, array.length)), n -> Arrays.copyOf(n.getInts(), n.size())); } if (Objects.equals(long[].class, type)) { - return createAdapter(long[].class, NBTTagLongArray.class, array -> new NBTTagLongArray(Arrays.copyOf(array, array.length)), n -> Arrays.copyOf(n.d(), n.size())); + return createAdapter(long[].class, NBTTagLongArray.class, array -> new NBTTagLongArray(Arrays.copyOf(array, array.length)), n -> Arrays.copyOf(n.getLongs(), n.size())); } /* diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftFurnaceRecipe.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftFurnaceRecipe.java index a38d08a153..fddae1a789 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftFurnaceRecipe.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftFurnaceRecipe.java @@ -25,6 +25,6 @@ public class CraftFurnaceRecipe extends FurnaceRecipe implements CraftRecipe { public void addToCraftingManager() { ItemStack result = this.getResult(); - MinecraftServer.getServer().getCraftingManager().a(new net.minecraft.server.FurnaceRecipe(CraftNamespacedKey.toMinecraft(this.getKey()), this.getGroup(), toNMS(this.getInputChoice(), true), CraftItemStack.asNMSCopy(result), getExperience(), getCookingTime())); + MinecraftServer.getServer().getCraftingManager().addRecipe(new net.minecraft.server.FurnaceRecipe(CraftNamespacedKey.toMinecraft(this.getKey()), this.getGroup(), toNMS(this.getInputChoice(), true), CraftItemStack.asNMSCopy(result), getExperience(), getCookingTime())); } } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java index dd7b3d766f..8c5e0d8977 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java @@ -10,12 +10,16 @@ import net.minecraft.server.InventoryCrafting; import net.minecraft.server.InventoryEnderChest; import net.minecraft.server.InventoryMerchant; import net.minecraft.server.PlayerInventory; +import net.minecraft.server.TileEntityBarrel; import net.minecraft.server.TileEntityBeacon; +import net.minecraft.server.TileEntityBlastFurnace; import net.minecraft.server.TileEntityBrewingStand; import net.minecraft.server.TileEntityDispenser; import net.minecraft.server.TileEntityDropper; import net.minecraft.server.TileEntityFurnace; +import net.minecraft.server.TileEntityLectern; import net.minecraft.server.TileEntityShulkerBox; +import net.minecraft.server.TileEntitySmoker; import org.apache.commons.lang.Validate; import org.bukkit.Location; @@ -43,10 +47,6 @@ public class CraftInventory implements Inventory { return getInventory().getSize(); } - public String getName() { - return CraftChatMessage.fromComponent(getInventory().getDisplayName()); - } - public ItemStack getItem(int index) { net.minecraft.server.ItemStack item = getInventory().getItem(index); return item.isEmpty() ? null : CraftItemStack.asCraftMirror(item); @@ -422,12 +422,8 @@ public class CraftInventory implements Inventory { return this.inventory.getViewers(); } - public String getTitle() { - return getName(); - } - public InventoryType getType() { - // Thanks to Droppers extending Dispensers, order is important. + // Thanks to Droppers extending Dispensers, Blast Furnaces & Smokers extending Furnace, order is important. if (inventory instanceof InventoryCrafting) { return inventory.getSize() >= 9 ? InventoryType.WORKBENCH : InventoryType.CRAFTING; } else if (inventory instanceof PlayerInventory) { @@ -436,6 +432,10 @@ public class CraftInventory implements Inventory { return InventoryType.DROPPER; } else if (inventory instanceof TileEntityDispenser) { return InventoryType.DISPENSER; + } else if (inventory instanceof TileEntityBlastFurnace) { + return InventoryType.BLAST_FURNACE; + } else if (inventory instanceof TileEntitySmoker) { + return InventoryType.SMOKER; } else if (inventory instanceof TileEntityFurnace) { return InventoryType.FURNACE; } else if (this instanceof CraftInventoryEnchanting) { @@ -456,6 +456,18 @@ public class CraftInventory implements Inventory { return InventoryType.HOPPER; } else if (inventory instanceof TileEntityShulkerBox) { return InventoryType.SHULKER_BOX; + } else if (inventory instanceof TileEntityBarrel) { + return InventoryType.BARREL; + } else if (inventory instanceof TileEntityLectern) { + return InventoryType.LECTERN; + } else if (this instanceof CraftInventoryLoom) { + return InventoryType.LOOM; + } else if (this instanceof CraftInventoryCartography) { + return InventoryType.CARTOGRAPHY; + } else if (this instanceof CraftInventoryGrindstone) { + return InventoryType.GRINDSTONE; + } else if (this instanceof CraftInventoryStonecutter) { + return InventoryType.STONECUTTER; } else { return InventoryType.CHEST; } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryAnvil.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryAnvil.java index ca19600da5..70c9605c3b 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryAnvil.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryAnvil.java @@ -65,12 +65,12 @@ public class CraftInventoryAnvil extends CraftInventory implements AnvilInventor @Override public int getRepairCost() { - return container.levelCost; + return container.levelCost.b(); } @Override public void setRepairCost(int i) { - container.levelCost = i; + container.levelCost.a(i); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryBeacon.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryBeacon.java index 43c4107c65..fa15ff5222 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryBeacon.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryBeacon.java @@ -1,11 +1,11 @@ package org.bukkit.craftbukkit.inventory; -import net.minecraft.server.TileEntityBeacon; +import net.minecraft.server.IInventory; import org.bukkit.inventory.BeaconInventory; import org.bukkit.inventory.ItemStack; public class CraftInventoryBeacon extends CraftInventory implements BeaconInventory { - public CraftInventoryBeacon(TileEntityBeacon beacon) { + public CraftInventoryBeacon(IInventory beacon) { super(beacon); } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCartography.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCartography.java new file mode 100644 index 0000000000..6cfa3d3e0a --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCartography.java @@ -0,0 +1,11 @@ +package org.bukkit.craftbukkit.inventory; + +import net.minecraft.server.IInventory; +import org.bukkit.inventory.CartographyInventory; + +public class CraftInventoryCartography extends CraftInventory implements CartographyInventory { + + public CraftInventoryCartography(IInventory inventory) { + super(inventory); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java index 6e17b4fd90..0e98e14011 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java @@ -40,7 +40,7 @@ public class CraftInventoryCustom extends CraftInventory { private final NonNullList items; private int maxStack = MAX_STACK; private final List viewers; - private final IChatBaseComponent title; + private final String title; private InventoryType type; private final InventoryHolder owner; @@ -60,8 +60,9 @@ public class CraftInventoryCustom extends CraftInventory { public MinecraftInventory(InventoryHolder owner, int size, String title) { Validate.notNull(title, "Title cannot be null"); + Validate.isTrue(9 <= size && size <= 54 && size % 9 == 0, "Size for custom inventory must be a multiple of 9 between 9 and 54 slots"); this.items = NonNullList.a(size, ItemStack.a); - this.title = CraftChatMessage.fromString(title)[0]; + this.title = title; this.viewers = new ArrayList(); this.owner = owner; this.type = InventoryType.CHEST; @@ -163,52 +164,22 @@ public class CraftInventoryCustom extends CraftInventory { } - @Override - public int getProperty(int i) { - return 0; - } - - @Override - public void setProperty(int i, int j) { - } - - @Override - public int h() { - return 0; - } - @Override public void clear() { items.clear(); } - @Override - public IChatBaseComponent getDisplayName() { - return title; - } - - @Override - public IChatBaseComponent getCustomName() { - return title; - } - - @Override - public boolean hasCustomName() { - return title != null; - } - - @Override - public IChatBaseComponent getScoreboardDisplayName() { - return title; - } - @Override public Location getLocation() { return null; } + public String getTitle() { + return title; + } + @Override - public boolean P_() { + public boolean isNotEmpty() { Iterator iterator = this.items.iterator(); ItemStack itemstack; diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryDoubleChest.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryDoubleChest.java index 799f8ea5d2..eb7b8fdde7 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryDoubleChest.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryDoubleChest.java @@ -1,7 +1,5 @@ package org.bukkit.craftbukkit.inventory; -import net.minecraft.server.ChatMessage; -import net.minecraft.server.ITileInventory; import org.bukkit.block.DoubleChest; import org.bukkit.inventory.DoubleChestInventory; import org.bukkit.inventory.Inventory; @@ -15,7 +13,7 @@ public class CraftInventoryDoubleChest extends CraftInventory implements DoubleC private final CraftInventory right; public CraftInventoryDoubleChest(CraftInventory left, CraftInventory right) { - super(new InventoryLargeChest(new ChatMessage("container.chestDouble"), (ITileInventory) left.getInventory(), (ITileInventory) right.getInventory())); + super(new InventoryLargeChest(left.getInventory(), right.getInventory())); this.left = left; this.right = right; } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryGrindstone.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryGrindstone.java new file mode 100644 index 0000000000..704d65041e --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryGrindstone.java @@ -0,0 +1,14 @@ +package org.bukkit.craftbukkit.inventory; + +import net.minecraft.server.IInventory; +import org.bukkit.inventory.GrindstoneInventory; + +public class CraftInventoryGrindstone extends CraftInventory implements GrindstoneInventory { + + private final IInventory resultInventory; + + public CraftInventoryGrindstone(IInventory inventory, IInventory resultInventory) { + super(inventory); + this.resultInventory = resultInventory; + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryLectern.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryLectern.java new file mode 100644 index 0000000000..f60ed85ef7 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryLectern.java @@ -0,0 +1,17 @@ +package org.bukkit.craftbukkit.inventory; + +import net.minecraft.server.IInventory; +import org.bukkit.block.Lectern; +import org.bukkit.inventory.LecternInventory; + +public class CraftInventoryLectern extends CraftInventory implements LecternInventory { + + public CraftInventoryLectern(IInventory inventory) { + super(inventory); + } + + @Override + public Lectern getHolder() { + return (Lectern) inventory.getOwner(); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryLoom.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryLoom.java new file mode 100644 index 0000000000..341d831a47 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryLoom.java @@ -0,0 +1,14 @@ +package org.bukkit.craftbukkit.inventory; + +import net.minecraft.server.IInventory; +import org.bukkit.inventory.LoomInventory; + +public class CraftInventoryLoom extends CraftInventory implements LoomInventory { + + private final IInventory resultInventory; + + public CraftInventoryLoom(IInventory inventory, IInventory resultInventory) { + super(inventory); + this.resultInventory = resultInventory; + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryStonecutter.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryStonecutter.java new file mode 100644 index 0000000000..880df2a19f --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryStonecutter.java @@ -0,0 +1,11 @@ +package org.bukkit.craftbukkit.inventory; + +import net.minecraft.server.IInventory; +import org.bukkit.inventory.StonecutterInventory; + +public class CraftInventoryStonecutter extends CraftInventory implements StonecutterInventory { + + public CraftInventoryStonecutter(IInventory inventory) { + super(inventory); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryView.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryView.java index ac23350917..16ec59ef37 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryView.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryView.java @@ -2,6 +2,7 @@ package org.bukkit.craftbukkit.inventory; import org.bukkit.GameMode; import org.bukkit.craftbukkit.entity.CraftHumanEntity; +import org.bukkit.craftbukkit.util.CraftChatMessage; import org.bukkit.entity.HumanEntity; import org.bukkit.event.inventory.InventoryType; import org.bukkit.event.inventory.InventoryType.SlotType; @@ -65,6 +66,11 @@ public class CraftInventoryView extends InventoryView { return CraftItemStack.asCraftMirror(container.getSlot(slot).getItem()); } + @Override + public String getTitle() { + return CraftChatMessage.fromComponent(container.getTitle()); + } + public boolean isInTop(int rawSlot) { return rawSlot < viewing.getSize(); } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java index 52041caedc..56dcd8aeec 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java @@ -34,6 +34,7 @@ public final class CraftItemFactory implements ItemFactory { .add("generic.luck") .add("horse.jumpStrength") .add("zombie.spawnReinforcements") + .add("generic.attackKnockback") .build(); } @@ -87,6 +88,7 @@ public final class CraftItemFactory implements ItemFactory { case ZOMBIE_WALL_HEAD: return meta instanceof CraftMetaSkull ? meta : new CraftMetaSkull(meta); case LEATHER_HELMET: + case LEATHER_HORSE_ARMOR: case LEATHER_CHESTPLATE: case LEATHER_LEGGINGS: case LEATHER_BOOTS: @@ -197,7 +199,18 @@ public final class CraftItemFactory implements ItemFactory { case JUKEBOX: case DISPENSER: case DROPPER: - case SIGN: + case ACACIA_SIGN: + case ACACIA_WALL_SIGN: + case BIRCH_SIGN: + case BIRCH_WALL_SIGN: + case DARK_OAK_SIGN: + case DARK_OAK_WALL_SIGN: + case JUNGLE_SIGN: + case JUNGLE_WALL_SIGN: + case OAK_SIGN: + case OAK_WALL_SIGN: + case SPRUCE_SIGN: + case SPRUCE_WALL_SIGN: case SPAWNER: case BREWING_STAND: case ENCHANTING_TABLE: @@ -228,7 +241,14 @@ public final class CraftItemFactory implements ItemFactory { case RED_SHULKER_BOX: case BLACK_SHULKER_BOX: case ENDER_CHEST: - return new CraftMetaBlockState(meta, material); + case BARREL: + case BELL: + case BLAST_FURNACE: + case CAMPFIRE: + case JIGSAW: + case LECTERN: + case SMOKER: + return new CraftMetaBlockState(meta, material); case TROPICAL_FISH_BUCKET: return meta instanceof CraftMetaTropicalFishBucket ? meta : new CraftMetaTropicalFishBucket(meta); default: diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java index 2ef4ac64b2..c4aa0152c8 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java @@ -46,9 +46,6 @@ public final class CraftItemStack extends ItemStack { net.minecraft.server.ItemStack stack = new net.minecraft.server.ItemStack(item, original.getAmount()); if (original.hasItemMeta()) { setItemMeta(stack, original.getItemMeta()); - } else { - // Converted after setItemMeta - stack.convertStack(); } return stack; } @@ -349,6 +346,7 @@ public final class CraftItemStack extends ItemStack { case ZOMBIE_WALL_HEAD: return new CraftMetaSkull(item.getTag()); case LEATHER_HELMET: + case LEATHER_HORSE_ARMOR: case LEATHER_CHESTPLATE: case LEATHER_LEGGINGS: case LEATHER_BOOTS: @@ -459,7 +457,18 @@ public final class CraftItemStack extends ItemStack { case JUKEBOX: case DISPENSER: case DROPPER: - case SIGN: + case ACACIA_SIGN: + case ACACIA_WALL_SIGN: + case BIRCH_SIGN: + case BIRCH_WALL_SIGN: + case DARK_OAK_SIGN: + case DARK_OAK_WALL_SIGN: + case JUNGLE_SIGN: + case JUNGLE_WALL_SIGN: + case OAK_SIGN: + case OAK_WALL_SIGN: + case SPRUCE_SIGN: + case SPRUCE_WALL_SIGN: case SPAWNER: case BREWING_STAND: case ENCHANTING_TABLE: @@ -490,6 +499,13 @@ public final class CraftItemStack extends ItemStack { case RED_SHULKER_BOX: case BLACK_SHULKER_BOX: case ENDER_CHEST: + case BARREL: + case BELL: + case BLAST_FURNACE: + case CAMPFIRE: + case JIGSAW: + case LECTERN: + case SMOKER: return new CraftMetaBlockState(item.getTag(), CraftMagicNumbers.getMaterial(item.getItem())); case TROPICAL_FISH_BUCKET: return new CraftMetaTropicalFishBucket(item.getTag()); @@ -532,7 +548,7 @@ public final class CraftItemStack extends ItemStack { item.setTag(tag); ((CraftMetaItem) itemMeta).applyToItem(tag); - item.convertStack(); + item.convertStack(((CraftMetaItem) itemMeta).getVersion()); return true; } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchant.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchant.java index 7569b29dc7..50bc720d42 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchant.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchant.java @@ -25,7 +25,7 @@ public class CraftMerchant implements Merchant { @Override public List getRecipes() { - return Collections.unmodifiableList(Lists.transform(merchant.getOffers(null), new Function() { + return Collections.unmodifiableList(Lists.transform(merchant.getOffers(), new Function() { @Override public MerchantRecipe apply(net.minecraft.server.MerchantRecipe recipe) { return recipe.asBukkit(); @@ -35,7 +35,7 @@ public class CraftMerchant implements Merchant { @Override public void setRecipes(List recipes) { - MerchantRecipeList recipesList = merchant.getOffers(null); + MerchantRecipeList recipesList = merchant.getOffers(); recipesList.clear(); for (MerchantRecipe recipe : recipes) { recipesList.add(CraftMerchantRecipe.fromBukkit(recipe).toMinecraft()); @@ -44,17 +44,17 @@ public class CraftMerchant implements Merchant { @Override public MerchantRecipe getRecipe(int i) { - return merchant.getOffers(null).get(i).asBukkit(); + return merchant.getOffers().get(i).asBukkit(); } @Override public void setRecipe(int i, MerchantRecipe merchantRecipe) { - merchant.getOffers(null).set(i, CraftMerchantRecipe.fromBukkit(merchantRecipe).toMinecraft()); + merchant.getOffers().set(i, CraftMerchantRecipe.fromBukkit(merchantRecipe).toMinecraft()); } @Override public int getRecipeCount() { - return merchant.getOffers(null).size(); + return merchant.getOffers().size(); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java index 4f8edbe3ba..92d496d0f3 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java @@ -22,7 +22,12 @@ public class CraftMerchantCustom extends CraftMerchant { return "CraftMerchantCustom"; } - private static class MinecraftMerchant implements IMerchant { + @Override + public MinecraftMerchant getMerchant() { + return (MinecraftMerchant) super.getMerchant(); + } + + public static class MinecraftMerchant implements IMerchant { private final IChatBaseComponent title; private final MerchantRecipeList trades = new MerchantRecipeList(); @@ -44,7 +49,7 @@ public class CraftMerchantCustom extends CraftMerchant { } @Override - public MerchantRecipeList getOffers(EntityHuman entityhuman) { + public MerchantRecipeList getOffers() { return this.trades; } @@ -55,10 +60,9 @@ public class CraftMerchantCustom extends CraftMerchant { } @Override - public void a(ItemStack itemstack) { + public void i(ItemStack itemstack) { } - @Override public IChatBaseComponent getScoreboardDisplayName() { return title; } @@ -69,8 +73,17 @@ public class CraftMerchantCustom extends CraftMerchant { } @Override - public BlockPosition getPosition() { - return null; + public int dV() { + return 0; // xp + } + + @Override + public void q(int i) { + } + + @Override + public boolean dZ() { + return true; } } } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantRecipe.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantRecipe.java index 1730cc93b5..ff7c656348 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantRecipe.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantRecipe.java @@ -16,14 +16,16 @@ public class CraftMerchantRecipe extends MerchantRecipe { addIngredient(CraftItemStack.asBukkitCopy(merchantRecipe.buyingItem2)); } - public CraftMerchantRecipe(ItemStack result, int uses, int maxUses, boolean experienceReward) { - super(result, uses, maxUses, experienceReward); + public CraftMerchantRecipe(ItemStack result, int uses, int maxUses, boolean experienceReward, int experience, float priceMultiplier) { + super(result, uses, maxUses, experienceReward, experience, priceMultiplier); this.handle = new net.minecraft.server.MerchantRecipe( net.minecraft.server.ItemStack.a, net.minecraft.server.ItemStack.a, CraftItemStack.asNMSCopy(result), uses, maxUses, + experience, + priceMultiplier, this ); this.setExperienceReward(experienceReward); @@ -59,6 +61,26 @@ public class CraftMerchantRecipe extends MerchantRecipe { handle.rewardExp = flag; } + @Override + public int getVillagerExperience() { + return handle.xp; + } + + @Override + public void setVillagerExperience(int villagerExperience) { + handle.xp = villagerExperience; + } + + @Override + public float getPriceMultiplier() { + return handle.priceMultiplier; + } + + @Override + public void setPriceMultiplier(float priceMultiplier) { + handle.priceMultiplier = priceMultiplier; + } + public net.minecraft.server.MerchantRecipe toMinecraft() { List ingredients = getIngredients(); Preconditions.checkState(!ingredients.isEmpty(), "No offered ingredients"); @@ -73,7 +95,7 @@ public class CraftMerchantRecipe extends MerchantRecipe { if (recipe instanceof CraftMerchantRecipe) { return (CraftMerchantRecipe) recipe; } else { - CraftMerchantRecipe craft = new CraftMerchantRecipe(recipe.getResult(), recipe.getUses(), recipe.getMaxUses(), recipe.hasExperienceReward()); + CraftMerchantRecipe craft = new CraftMerchantRecipe(recipe.getResult(), recipe.getUses(), recipe.getMaxUses(), recipe.hasExperienceReward(), recipe.getVillagerExperience(), recipe.getPriceMultiplier()); 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 f96f6af038..1529f30f7b 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java @@ -8,8 +8,12 @@ import net.minecraft.server.NBTBase; import net.minecraft.server.NBTTagCompound; import net.minecraft.server.TileEntity; import net.minecraft.server.TileEntityBanner; +import net.minecraft.server.TileEntityBarrel; import net.minecraft.server.TileEntityBeacon; +import net.minecraft.server.TileEntityBell; +import net.minecraft.server.TileEntityBlastFurnace; import net.minecraft.server.TileEntityBrewingStand; +import net.minecraft.server.TileEntityCampfire; import net.minecraft.server.TileEntityChest; import net.minecraft.server.TileEntityCommand; import net.minecraft.server.TileEntityComparator; @@ -19,22 +23,30 @@ import net.minecraft.server.TileEntityEnchantTable; import net.minecraft.server.TileEntityEndGateway; import net.minecraft.server.TileEntityEnderChest; import net.minecraft.server.TileEntityFurnace; +import net.minecraft.server.TileEntityFurnaceFurnace; import net.minecraft.server.TileEntityHopper; +import net.minecraft.server.TileEntityJigsaw; import net.minecraft.server.TileEntityJukeBox; +import net.minecraft.server.TileEntityLectern; import net.minecraft.server.TileEntityLightDetector; import net.minecraft.server.TileEntityMobSpawner; import net.minecraft.server.TileEntityShulkerBox; import net.minecraft.server.TileEntitySign; import net.minecraft.server.TileEntitySkull; +import net.minecraft.server.TileEntitySmoker; import net.minecraft.server.TileEntityStructure; import org.apache.commons.lang.Validate; import org.bukkit.Material; import org.bukkit.block.BlockState; import org.bukkit.configuration.serialization.DelegateDeserialization; import org.bukkit.craftbukkit.block.CraftBanner; +import org.bukkit.craftbukkit.block.CraftBarrel; import org.bukkit.craftbukkit.block.CraftBeacon; +import org.bukkit.craftbukkit.block.CraftBell; +import org.bukkit.craftbukkit.block.CraftBlastFurnace; import org.bukkit.craftbukkit.block.CraftBlockEntityState; import org.bukkit.craftbukkit.block.CraftBrewingStand; +import org.bukkit.craftbukkit.block.CraftCampfire; import org.bukkit.craftbukkit.block.CraftChest; import org.bukkit.craftbukkit.block.CraftCommandBlock; import org.bukkit.craftbukkit.block.CraftComparator; @@ -47,10 +59,13 @@ import org.bukkit.craftbukkit.block.CraftEndGateway; import org.bukkit.craftbukkit.block.CraftEnderChest; import org.bukkit.craftbukkit.block.CraftFurnace; import org.bukkit.craftbukkit.block.CraftHopper; +import org.bukkit.craftbukkit.block.CraftJigsaw; import org.bukkit.craftbukkit.block.CraftJukebox; +import org.bukkit.craftbukkit.block.CraftLectern; import org.bukkit.craftbukkit.block.CraftShulkerBox; import org.bukkit.craftbukkit.block.CraftSign; import org.bukkit.craftbukkit.block.CraftSkull; +import org.bukkit.craftbukkit.block.CraftSmoker; import org.bukkit.craftbukkit.block.CraftStructureBlock; import org.bukkit.craftbukkit.util.CraftMagicNumbers; import org.bukkit.inventory.meta.BlockStateMeta; @@ -174,7 +189,18 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta case JUKEBOX: case DISPENSER: case DROPPER: - case SIGN: + case ACACIA_SIGN: + case ACACIA_WALL_SIGN: + case BIRCH_SIGN: + case BIRCH_WALL_SIGN: + case DARK_OAK_SIGN: + case DARK_OAK_WALL_SIGN: + case JUNGLE_SIGN: + case JUNGLE_WALL_SIGN: + case OAK_SIGN: + case OAK_WALL_SIGN: + case SPRUCE_SIGN: + case SPRUCE_WALL_SIGN: case SPAWNER: case BREWING_STAND: case ENCHANTING_TABLE: @@ -205,6 +231,13 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta case RED_SHULKER_BOX: case BLACK_SHULKER_BOX: case ENDER_CHEST: + case BARREL: + case BELL: + case BLAST_FURNACE: + case CAMPFIRE: + case JIGSAW: + case LECTERN: + case SMOKER: return true; } return false; @@ -255,8 +288,18 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta TileEntity te = (blockEntityTag == null) ? null : TileEntity.create(blockEntityTag); switch (material) { - case SIGN: - case WALL_SIGN: + case ACACIA_SIGN: + case ACACIA_WALL_SIGN: + case BIRCH_SIGN: + case BIRCH_WALL_SIGN: + case DARK_OAK_SIGN: + case DARK_OAK_WALL_SIGN: + case JUNGLE_SIGN: + case JUNGLE_WALL_SIGN: + case OAK_SIGN: + case OAK_WALL_SIGN: + case SPRUCE_SIGN: + case SPRUCE_WALL_SIGN: if (te == null) { te = new TileEntitySign(); } @@ -269,7 +312,7 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta return new CraftChest(material, (TileEntityChest) te); case FURNACE: if (te == null) { - te = new TileEntityFurnace(); + te = new TileEntityFurnaceFurnace(); } return new CraftFurnace(material, (TileEntityFurnace) te); case DISPENSER: @@ -422,6 +465,41 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta te = new TileEntityComparator(); } return new CraftComparator(material, (TileEntityComparator) te); + case BARREL: + if (te == null){ + te = new TileEntityBarrel(); + } + return new CraftBarrel(material, (TileEntityBarrel) te); + case BELL: + if (te == null){ + te = new TileEntityBell(); + } + return new CraftBell(material, (TileEntityBell) te); + case BLAST_FURNACE: + if (te == null){ + te = new TileEntityBlastFurnace(); + } + return new CraftBlastFurnace(material, (TileEntityBlastFurnace) te); + case CAMPFIRE: + if (te == null){ + te = new TileEntityCampfire(); + } + return new CraftCampfire(material, (TileEntityCampfire) te); + case JIGSAW: + if (te == null){ + te = new TileEntityJigsaw(); + } + return new CraftJigsaw(material, (TileEntityJigsaw) te); + case LECTERN: + if (te == null){ + te = new TileEntityLectern(); + } + return new CraftLectern(material, (TileEntityLectern) te); + case SMOKER: + if (te == null){ + te = new TileEntitySmoker(); + } + return new CraftSmoker(material, (TileEntitySmoker) te); default: throw new IllegalStateException("Missing blockState for " + material); } @@ -433,8 +511,18 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta boolean valid; switch (material) { - case SIGN: - case WALL_SIGN: + case ACACIA_SIGN: + case ACACIA_WALL_SIGN: + case BIRCH_SIGN: + case BIRCH_WALL_SIGN: + case DARK_OAK_SIGN: + case DARK_OAK_WALL_SIGN: + case JUNGLE_SIGN: + case JUNGLE_WALL_SIGN: + case OAK_SIGN: + case OAK_WALL_SIGN: + case SPRUCE_SIGN: + case SPRUCE_WALL_SIGN: valid = blockState instanceof CraftSign; break; case CHEST: @@ -556,6 +644,27 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta case COMPARATOR: valid = blockState instanceof CraftComparator; break; + case BARREL: + valid = blockState instanceof CraftBarrel; + break; + case BELL: + valid = blockState instanceof CraftBell; + break; + case BLAST_FURNACE: + valid = blockState instanceof CraftBlastFurnace; + break; + case CAMPFIRE: + valid = blockState instanceof CraftCampfire; + break; + case JIGSAW: + valid = blockState instanceof CraftJigsaw; + break; + case LECTERN: + valid = blockState instanceof CraftLectern; + break; + case SMOKER: + valid = blockState instanceof CraftSmoker; + break; default: valid = false; break; diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java index df1eb143ee..6fb4dec06f 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java @@ -34,6 +34,7 @@ import org.apache.commons.lang3.EnumUtils; import org.bukkit.Material; import org.bukkit.attribute.Attribute; import org.bukkit.attribute.AttributeModifier; +import org.bukkit.block.data.BlockData; import org.bukkit.configuration.serialization.ConfigurationSerializable; import org.bukkit.configuration.serialization.DelegateDeserialization; import org.bukkit.configuration.serialization.SerializableAs; @@ -41,6 +42,7 @@ import org.bukkit.craftbukkit.CraftEquipmentSlot; import org.bukkit.craftbukkit.Overridden; import org.bukkit.craftbukkit.attribute.CraftAttributeInstance; import org.bukkit.craftbukkit.attribute.CraftAttributeMap; +import org.bukkit.craftbukkit.block.data.CraftBlockData; import org.bukkit.craftbukkit.inventory.CraftMetaItem.ItemMetaKey.Specific; import org.bukkit.craftbukkit.inventory.tags.CraftCustomItemTagContainer; import org.bukkit.craftbukkit.util.CraftChatMessage; @@ -50,6 +52,7 @@ import org.bukkit.craftbukkit.util.CraftNamespacedKey; import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemFlag; +import org.bukkit.inventory.meta.BlockDataMeta; import org.bukkit.inventory.meta.Damageable; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.Repairable; @@ -98,7 +101,7 @@ import javax.annotation.Nullable; *
  • SerializableMeta.Deserializers deserializer() */ @DelegateDeserialization(CraftMetaItem.SerializableMeta.class) -class CraftMetaItem implements ItemMeta, Damageable, Repairable { +class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { static class ItemMetaKey { @@ -221,6 +224,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable { @Specific(Specific.To.NBT) static final ItemMetaKey DISPLAY = new ItemMetaKey("display"); static final ItemMetaKey LORE = new ItemMetaKey("Lore", "lore"); + static final ItemMetaKey CUSTOM_MODEL_DATA = new ItemMetaKey("CustomModelData", "custom-model-data"); static final ItemMetaKey ENCHANTMENTS = new ItemMetaKey("Enchantments", "enchants"); @Specific(Specific.To.NBT) static final ItemMetaKey ENCHANTMENTS_ID = new ItemMetaKey("id"); @@ -248,11 +252,15 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable { static final ItemMetaKey UNBREAKABLE = new ItemMetaKey("Unbreakable"); @Specific(Specific.To.NBT) static final ItemMetaKey DAMAGE = new ItemMetaKey("Damage"); + @Specific(Specific.To.NBT) + static final ItemMetaKey BLOCK_DATA = new ItemMetaKey("BlockStateTag"); static final ItemMetaKey BUKKIT_CUSTOM_TAG = new ItemMetaKey("PublicBukkitValues"); private IChatBaseComponent displayName; private IChatBaseComponent locName; private List lore; + private Integer customModelData; + private String blockData; private Map enchantments; private Multimap attributeModifiers; private int repairCost; @@ -267,6 +275,8 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable { private final Map unhandledTags = new HashMap(); private final CraftCustomItemTagContainer publicItemTagContainer = new CraftCustomItemTagContainer(TAG_TYPE_REGISTRY); + private int version = CraftMagicNumbers.INSTANCE.getDataVersion(); // Internal use only + CraftMetaItem(CraftMetaItem meta) { if (meta == null) { return; @@ -279,6 +289,9 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable { this.lore = new ArrayList(meta.lore); } + this.customModelData = meta.customModelData; + this.blockData = meta.blockData; + if (meta.hasEnchants()) { this.enchantments = new LinkedHashMap(meta.enchantments); } @@ -298,6 +311,8 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable { if (this.internalTag != null) { deserializeInternal(internalTag, meta); } + + this.version = meta.version; } CraftMetaItem(NBTTagCompound tag) { @@ -331,6 +346,13 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable { } } + if (tag.hasKeyOfType(CUSTOM_MODEL_DATA.NBT, CraftMagicNumbers.NBT.TAG_INT)) { + customModelData = tag.getInt(CUSTOM_MODEL_DATA.NBT); + } + if (tag.hasKeyOfType(BLOCK_DATA.NBT, CraftMagicNumbers.NBT.TAG_STRING)) { + blockData = tag.getString(BLOCK_DATA.NBT); + } + this.enchantments = buildEnchantments(tag, ENCHANTMENTS); this.attributeModifiers = buildModifiers(tag, ATTRIBUTES); @@ -450,6 +472,16 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable { safelyAdd(lore, this.lore = new ArrayList(), Integer.MAX_VALUE); } + Integer customModelData = SerializableMeta.getObject(Integer.class, map, CUSTOM_MODEL_DATA.BUKKIT, true); + if (customModelData != null) { + setCustomModelData(customModelData); + } + + String blockData = SerializableMeta.getObject(String.class, map, BLOCK_DATA.BUKKIT, true); + if (blockData != null) { + this.blockData = blockData; + } + enchantments = buildEnchantments(map, ENCHANTMENTS); attributeModifiers = buildModifiers(map, ATTRIBUTES); @@ -583,6 +615,14 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable { setDisplayTag(itemTag, LORE.NBT, createStringList(lore)); } + if (hasCustomModelData()) { + itemTag.setInt(CUSTOM_MODEL_DATA.NBT, customModelData); + } + + if (hasBlockData()) { + itemTag.setString(BLOCK_DATA.NBT, blockData); + } + if (hideFlag != 0) { itemTag.setInt(HIDEFLAGS.NBT, hideFlag); } @@ -699,7 +739,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable { @Overridden boolean isEmpty() { - return !(hasDisplayName() || hasLocalizedName() || hasEnchants() || hasLore() || hasRepairCost() || !unhandledTags.isEmpty() || !publicItemTagContainer.isEmpty() || hideFlag != 0 || isUnbreakable() || hasDamage() || hasAttributeModifiers()); + return !(hasDisplayName() || hasLocalizedName() || hasEnchants() || hasLore() || hasCustomModelData() || hasBlockData() || hasRepairCost() || !unhandledTags.isEmpty() || !publicItemTagContainer.isEmpty() || hideFlag != 0 || isUnbreakable() || hasDamage() || hasAttributeModifiers()); } public String getDisplayName() { @@ -835,6 +875,37 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable { } } + @Override + public boolean hasCustomModelData() { + return customModelData != null; + } + + @Override + public int getCustomModelData() { + Preconditions.checkState(hasCustomModelData(), "We don't have CustomModelData! Check hasCustomModelData first!"); + return customModelData; + } + + @Override + public void setCustomModelData(Integer data) { + this.customModelData = data; + } + + @Override + public boolean hasBlockData() { + return this.blockData != null; + } + + @Override + public BlockData getBlockData(Material material) { + return CraftBlockData.newData(material, '[' + blockData + ']'); + } + + @Override + public void setBlockData(BlockData blockData) { + this.blockData = (blockData == null) ? null : ((CraftBlockData) blockData).toStates(); + } + public int getRepairCost() { return repairCost; } @@ -1028,13 +1099,16 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable { && (this.hasLocalizedName()? that.hasLocalizedName()&& this.locName.equals(that.locName) : !that.hasLocalizedName()) && (this.hasEnchants() ? that.hasEnchants() && this.enchantments.equals(that.enchantments) : !that.hasEnchants()) && (this.hasLore() ? that.hasLore() && this.lore.equals(that.lore) : !that.hasLore()) + && (this.hasCustomModelData() ? that.hasCustomModelData() && this.customModelData.equals(that.customModelData) : !that.hasCustomModelData()) + && (this.hasBlockData() ? that.hasBlockData() && this.blockData.equals(that.blockData) : !that.hasBlockData()) && (this.hasRepairCost() ? that.hasRepairCost() && this.repairCost == that.repairCost : !that.hasRepairCost()) && (this.hasAttributeModifiers() ? that.hasAttributeModifiers() && compareModifiers(this.attributeModifiers, that.attributeModifiers) : !that.hasAttributeModifiers()) && (this.unhandledTags.equals(that.unhandledTags)) && (this.publicItemTagContainer.equals(that.publicItemTagContainer)) && (this.hideFlag == that.hideFlag) && (this.isUnbreakable() == that.isUnbreakable()) - && (this.hasDamage() ? that.hasDamage() && this.damage == that.damage : !that.hasDamage()); + && (this.hasDamage() ? that.hasDamage() && this.damage == that.damage : !that.hasDamage()) + && (this.version == that.version); } /** @@ -1058,6 +1132,8 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable { hash = 61 * hash + (hasDisplayName() ? this.displayName.hashCode() : 0); hash = 61 * hash + (hasLocalizedName()? this.locName.hashCode() : 0); hash = 61 * hash + (hasLore() ? this.lore.hashCode() : 0); + hash = 61 * hash + (hasCustomModelData() ? this.customModelData.hashCode() : 0); + hash = 61 * hash + (hasBlockData() ? this.blockData.hashCode() : 0); hash = 61 * hash + (hasEnchants() ? this.enchantments.hashCode() : 0); hash = 61 * hash + (hasRepairCost() ? this.repairCost : 0); hash = 61 * hash + unhandledTags.hashCode(); @@ -1066,6 +1142,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable { hash = 61 * hash + (isUnbreakable() ? 1231 : 1237); hash = 61 * hash + (hasDamage() ? this.damage : 0); hash = 61 * hash + (hasAttributeModifiers() ? this.attributeModifiers.hashCode() : 0); + hash = 61 * hash + version; return hash; } @@ -1077,6 +1154,8 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable { if (this.lore != null) { clone.lore = new ArrayList(this.lore); } + clone.customModelData = this.customModelData; + clone.blockData = this.blockData; if (this.enchantments != null) { clone.enchantments = new LinkedHashMap(this.enchantments); } @@ -1086,6 +1165,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable { clone.hideFlag = this.hideFlag; clone.unbreakable = this.unbreakable; clone.damage = this.damage; + clone.version = this.version; return clone; } catch (CloneNotSupportedException e) { throw new Error(e); @@ -1112,6 +1192,13 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable { builder.put(LORE.BUKKIT, ImmutableList.copyOf(lore)); } + if (hasCustomModelData()) { + builder.put(CUSTOM_MODEL_DATA.BUKKIT, customModelData); + } + if (hasBlockData()) { + builder.put(BLOCK_DATA.BUKKIT, blockData); + } + serializeEnchantments(enchantments, builder, ENCHANTMENTS); serializeModifiers(attributeModifiers, builder, ATTRIBUTES); @@ -1240,11 +1327,22 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable { return SerializableMeta.classMap.get(getClass()) + "_META:" + serialize(); // TODO: cry } + public int getVersion() { + return version; + } + + @Override + public void setVersion(int version) { + this.version = version; + } + public static Set getHandledTags() { synchronized (HANDLED_TAGS) { if (HANDLED_TAGS.isEmpty()) { HANDLED_TAGS.addAll(Arrays.asList( DISPLAY.NBT, + CUSTOM_MODEL_DATA.NBT, + BLOCK_DATA.NBT, REPAIR.NBT, ENCHANTMENTS.NBT, HIDEFLAGS.NBT, diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaLeatherArmor.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaLeatherArmor.java index f321d854d4..469855983e 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaLeatherArmor.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaLeatherArmor.java @@ -72,6 +72,7 @@ class CraftMetaLeatherArmor extends CraftMetaItem implements LeatherArmorMeta { boolean applicableTo(Material type) { switch(type) { case LEATHER_HELMET: + case LEATHER_HORSE_ARMOR: case LEATHER_CHESTPLATE: case LEATHER_LEGGINGS: case LEATHER_BOOTS: diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapedRecipe.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapedRecipe.java index 1d06a59769..1b6072213f 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapedRecipe.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapedRecipe.java @@ -57,6 +57,6 @@ public class CraftShapedRecipe extends ShapedRecipe implements CraftRecipe { } } - MinecraftServer.getServer().getCraftingManager().a(new ShapedRecipes(CraftNamespacedKey.toMinecraft(this.getKey()), this.getGroup(), width, shape.length, data, CraftItemStack.asNMSCopy(this.getResult()))); + MinecraftServer.getServer().getCraftingManager().addRecipe(new ShapedRecipes(CraftNamespacedKey.toMinecraft(this.getKey()), this.getGroup(), width, shape.length, data, CraftItemStack.asNMSCopy(this.getResult()))); } } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapelessRecipe.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapelessRecipe.java index 0773b13596..28875ec563 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapelessRecipe.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapelessRecipe.java @@ -45,6 +45,6 @@ public class CraftShapelessRecipe extends ShapelessRecipe implements CraftRecipe data.set(i, toNMS(ingred.get(i), true)); } - MinecraftServer.getServer().getCraftingManager().a(new ShapelessRecipes(CraftNamespacedKey.toMinecraft(this.getKey()), this.getGroup(), CraftItemStack.asNMSCopy(this.getResult()), data)); + MinecraftServer.getServer().getCraftingManager().addRecipe(new ShapelessRecipes(CraftNamespacedKey.toMinecraft(this.getKey()), this.getGroup(), CraftItemStack.asNMSCopy(this.getResult()), data)); } } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmokingRecipe.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmokingRecipe.java new file mode 100644 index 0000000000..400437e2cb --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmokingRecipe.java @@ -0,0 +1,30 @@ +package org.bukkit.craftbukkit.inventory; + +import net.minecraft.server.MinecraftServer; +import org.bukkit.NamespacedKey; +import org.bukkit.craftbukkit.util.CraftNamespacedKey; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.RecipeChoice; +import org.bukkit.inventory.SmokingRecipe; + +public class CraftSmokingRecipe extends SmokingRecipe implements CraftRecipe { + public CraftSmokingRecipe(NamespacedKey key, ItemStack result, RecipeChoice source, float experience, int cookingTime) { + super(key, result, source, experience, cookingTime); + } + + public static CraftSmokingRecipe fromBukkitRecipe(SmokingRecipe recipe) { + if (recipe instanceof CraftSmokingRecipe) { + return (CraftSmokingRecipe) recipe; + } + CraftSmokingRecipe ret = new CraftSmokingRecipe(recipe.getKey(), recipe.getResult(), recipe.getInputChoice(), recipe.getExperience(), recipe.getCookingTime()); + ret.setGroup(recipe.getGroup()); + return ret; + } + + @Override + public void addToCraftingManager() { + ItemStack result = this.getResult(); + + MinecraftServer.getServer().getCraftingManager().addRecipe(new net.minecraft.server.RecipeSmoking(CraftNamespacedKey.toMinecraft(this.getKey()), this.getGroup(), toNMS(this.getInputChoice(), true), CraftItemStack.asNMSCopy(result), getExperience(), getCookingTime())); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftStonecuttingRecipe.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftStonecuttingRecipe.java new file mode 100644 index 0000000000..512a0e9d33 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftStonecuttingRecipe.java @@ -0,0 +1,30 @@ +package org.bukkit.craftbukkit.inventory; + +import net.minecraft.server.MinecraftServer; +import org.bukkit.NamespacedKey; +import org.bukkit.craftbukkit.util.CraftNamespacedKey; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.RecipeChoice; +import org.bukkit.inventory.StonecuttingRecipe; + +public class CraftStonecuttingRecipe extends StonecuttingRecipe implements CraftRecipe { + public CraftStonecuttingRecipe(NamespacedKey key, ItemStack result, RecipeChoice source) { + super(key, result, source); + } + + public static CraftStonecuttingRecipe fromBukkitRecipe(StonecuttingRecipe recipe) { + if (recipe instanceof CraftStonecuttingRecipe) { + return (CraftStonecuttingRecipe) recipe; + } + CraftStonecuttingRecipe ret = new CraftStonecuttingRecipe(recipe.getKey(), recipe.getResult(), recipe.getInputChoice()); + ret.setGroup(recipe.getGroup()); + return ret; + } + + @Override + public void addToCraftingManager() { + ItemStack result = this.getResult(); + + MinecraftServer.getServer().getCraftingManager().addRecipe(new net.minecraft.server.RecipeStonecutting(CraftNamespacedKey.toMinecraft(this.getKey()), this.getGroup(), toNMS(this.getInputChoice(), true), CraftItemStack.asNMSCopy(result))); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/InventoryWrapper.java b/src/main/java/org/bukkit/craftbukkit/inventory/InventoryWrapper.java index c280dbbc82..05685f84a8 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/InventoryWrapper.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/InventoryWrapper.java @@ -103,20 +103,6 @@ public class InventoryWrapper implements IInventory { return true; } - @Override - public int getProperty(int i) { - return 0; - } - - @Override - public void setProperty(int i, int j) { - } - - @Override - public int h() { - return 0; - } - @Override public void clear() { inventory.clear(); @@ -159,33 +145,13 @@ public class InventoryWrapper implements IInventory { inventory.setMaxStackSize(size); } - @Override - public IChatBaseComponent getDisplayName() { - return CraftChatMessage.fromStringOrNull(inventory.getName()); - } - - @Override - public IChatBaseComponent getCustomName() { - return getDisplayName(); - } - - @Override - public boolean hasCustomName() { - return inventory.getName() != null; - } - - @Override - public IChatBaseComponent getScoreboardDisplayName() { - return getDisplayName(); - } - @Override public Location getLocation() { return inventory.getLocation(); } @Override - public boolean P_() { + public boolean isNotEmpty() { return Iterables.any(inventory, Predicates.notNull()); } } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/RecipeIterator.java b/src/main/java/org/bukkit/craftbukkit/inventory/RecipeIterator.java index 165225e732..297076ebf4 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/RecipeIterator.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/RecipeIterator.java @@ -8,10 +8,10 @@ import net.minecraft.server.IRecipe; import net.minecraft.server.MinecraftServer; public class RecipeIterator implements Iterator { - private final Iterator recipes; + private final Iterator> recipes; public RecipeIterator() { - this.recipes = MinecraftServer.getServer().getCraftingManager().recipes.values().iterator(); + this.recipes = MinecraftServer.getServer().getCraftingManager().b().iterator(); } public boolean hasNext() { diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftInventoryCreator.java b/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftInventoryCreator.java index 23389743d5..9957ed0402 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftInventoryCreator.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftInventoryCreator.java @@ -25,9 +25,17 @@ public final class CraftInventoryCreator { converterMap.put(InventoryType.MERCHANT, DEFAULT_CONVERTER); converterMap.put(InventoryType.ENDER_CHEST, DEFAULT_CONVERTER); converterMap.put(InventoryType.ANVIL, DEFAULT_CONVERTER); - converterMap.put(InventoryType.BEACON, new CraftTileInventoryConverter.Beacon()); + converterMap.put(InventoryType.BEACON, DEFAULT_CONVERTER); converterMap.put(InventoryType.HOPPER, new CraftTileInventoryConverter.Hopper()); converterMap.put(InventoryType.SHULKER_BOX, DEFAULT_CONVERTER); + converterMap.put(InventoryType.BARREL, DEFAULT_CONVERTER); + converterMap.put(InventoryType.BLAST_FURNACE, new CraftTileInventoryConverter.BlastFurnace()); + converterMap.put(InventoryType.LECTERN, new CraftTileInventoryConverter.Lectern()); + converterMap.put(InventoryType.SMOKER, new CraftTileInventoryConverter.Smoker()); + converterMap.put(InventoryType.LOOM, DEFAULT_CONVERTER); + converterMap.put(InventoryType.CARTOGRAPHY, DEFAULT_CONVERTER); + converterMap.put(InventoryType.GRINDSTONE, DEFAULT_CONVERTER); + converterMap.put(InventoryType.STONECUTTER, DEFAULT_CONVERTER); } public Inventory createInventory(InventoryHolder holder, InventoryType type) { diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftTileInventoryConverter.java b/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftTileInventoryConverter.java index bb09139f80..2a705913d2 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftTileInventoryConverter.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftTileInventoryConverter.java @@ -1,17 +1,21 @@ package org.bukkit.craftbukkit.inventory.util; import net.minecraft.server.DimensionManager; -import net.minecraft.server.ITileInventory; +import net.minecraft.server.IInventory; import net.minecraft.server.MinecraftServer; +import net.minecraft.server.TileEntityBarrel; import net.minecraft.server.TileEntityBeacon; +import net.minecraft.server.TileEntityBlastFurnace; import net.minecraft.server.TileEntityBrewingStand; import net.minecraft.server.TileEntityDispenser; import net.minecraft.server.TileEntityDropper; import net.minecraft.server.TileEntityFurnace; +import net.minecraft.server.TileEntityFurnaceFurnace; import net.minecraft.server.TileEntityHopper; +import net.minecraft.server.TileEntityLectern; import net.minecraft.server.TileEntityLootable; +import net.minecraft.server.TileEntitySmoker; import org.bukkit.craftbukkit.inventory.CraftInventory; -import org.bukkit.craftbukkit.inventory.CraftInventoryBeacon; import org.bukkit.craftbukkit.inventory.CraftInventoryBrewer; import org.bukkit.craftbukkit.inventory.CraftInventoryFurnace; import org.bukkit.craftbukkit.util.CraftChatMessage; @@ -21,7 +25,7 @@ import org.bukkit.inventory.InventoryHolder; public abstract class CraftTileInventoryConverter implements CraftInventoryCreator.InventoryConverter { - public abstract ITileInventory getTileEntity(); + public abstract IInventory getTileEntity(); @Override public Inventory createInventory(InventoryHolder holder, InventoryType type) { @@ -30,7 +34,7 @@ public abstract class CraftTileInventoryConverter implements CraftInventoryCreat @Override public Inventory createInventory(InventoryHolder holder, InventoryType type, String title) { - ITileInventory te = getTileEntity(); + IInventory te = getTileEntity(); if (te instanceof TileEntityLootable) { ((TileEntityLootable) te).setCustomName(CraftChatMessage.fromStringOrNull(title)); } @@ -38,28 +42,28 @@ public abstract class CraftTileInventoryConverter implements CraftInventoryCreat return getInventory(te); } - public Inventory getInventory(ITileInventory tileEntity) { + public Inventory getInventory(IInventory tileEntity) { return new CraftInventory(tileEntity); } public static class Furnace extends CraftTileInventoryConverter { @Override - public ITileInventory getTileEntity() { - TileEntityFurnace furnace = new TileEntityFurnace(); + public IInventory getTileEntity() { + TileEntityFurnace furnace = new TileEntityFurnaceFurnace(); furnace.setWorld(MinecraftServer.getServer().getWorldServer(DimensionManager.OVERWORLD)); // TODO: customize this if required return furnace; } @Override public Inventory createInventory(InventoryHolder owner, InventoryType type, String title) { - ITileInventory tileEntity = getTileEntity(); + IInventory tileEntity = getTileEntity(); ((TileEntityFurnace) tileEntity).setCustomName(CraftChatMessage.fromStringOrNull(title)); return getInventory(tileEntity); } @Override - public Inventory getInventory(ITileInventory tileEntity) { + public Inventory getInventory(IInventory tileEntity) { return new CraftInventoryFurnace((TileEntityFurnace) tileEntity); } } @@ -67,14 +71,14 @@ public abstract class CraftTileInventoryConverter implements CraftInventoryCreat public static class BrewingStand extends CraftTileInventoryConverter { @Override - public ITileInventory getTileEntity() { + public IInventory getTileEntity() { return new TileEntityBrewingStand(); } @Override public Inventory createInventory(InventoryHolder holder, InventoryType type, String title) { // BrewingStand does not extend TileEntityLootable - ITileInventory tileEntity = getTileEntity(); + IInventory tileEntity = getTileEntity(); if (tileEntity instanceof TileEntityBrewingStand) { ((TileEntityBrewingStand) tileEntity).setCustomName(CraftChatMessage.fromStringOrNull(title)); } @@ -82,28 +86,15 @@ public abstract class CraftTileInventoryConverter implements CraftInventoryCreat } @Override - public Inventory getInventory(ITileInventory tileEntity) { + public Inventory getInventory(IInventory tileEntity) { return new CraftInventoryBrewer(tileEntity); } } - public static class Beacon extends CraftTileInventoryConverter { - - @Override - public ITileInventory getTileEntity() { - return new TileEntityBeacon(); - } - - @Override - public Inventory getInventory(ITileInventory tileInventory) { - return new CraftInventoryBeacon((TileEntityBeacon) tileInventory); - } - } - public static class Dispenser extends CraftTileInventoryConverter { @Override - public ITileInventory getTileEntity() { + public IInventory getTileEntity() { return new TileEntityDispenser(); } } @@ -111,7 +102,7 @@ public abstract class CraftTileInventoryConverter implements CraftInventoryCreat public static class Dropper extends CraftTileInventoryConverter { @Override - public ITileInventory getTileEntity() { + public IInventory getTileEntity() { return new TileEntityDropper(); } } @@ -119,8 +110,32 @@ public abstract class CraftTileInventoryConverter implements CraftInventoryCreat public static class Hopper extends CraftTileInventoryConverter { @Override - public ITileInventory getTileEntity() { + public IInventory getTileEntity() { return new TileEntityHopper(); } } + + public static class BlastFurnace extends CraftTileInventoryConverter { + + @Override + public IInventory getTileEntity() { + return new TileEntityBlastFurnace(); + } + } + + public static class Lectern extends CraftTileInventoryConverter { + + @Override + public IInventory getTileEntity() { + return new TileEntityLectern().inventory; + } + } + + public static class Smoker extends CraftTileInventoryConverter { + + @Override + public IInventory getTileEntity() { + return new TileEntitySmoker(); + } + } } diff --git a/src/main/java/org/bukkit/craftbukkit/map/CraftMapView.java b/src/main/java/org/bukkit/craftbukkit/map/CraftMapView.java index d52fcde179..8fe1208cd4 100644 --- a/src/main/java/org/bukkit/craftbukkit/map/CraftMapView.java +++ b/src/main/java/org/bukkit/craftbukkit/map/CraftMapView.java @@ -175,4 +175,14 @@ public final class CraftMapView implements MapView { public void setUnlimitedTracking(boolean unlimited) { worldMap.unlimitedTracking = unlimited; } + + @Override + public boolean isLocked() { + return worldMap.locked; + } + + @Override + public void setLocked(boolean locked) { + worldMap.locked = locked; + } } diff --git a/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionEffectType.java b/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionEffectType.java index 035e4fe829..9528bff1f9 100644 --- a/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionEffectType.java +++ b/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionEffectType.java @@ -15,7 +15,7 @@ public class CraftPotionEffectType extends PotionEffectType { @Override public double getDurationModifier() { - return handle.durationModifier; + return 1.0D; } public MobEffectList getHandle() { diff --git a/src/main/java/org/bukkit/craftbukkit/projectiles/CraftBlockProjectileSource.java b/src/main/java/org/bukkit/craftbukkit/projectiles/CraftBlockProjectileSource.java index 744da023de..a791ae92f7 100644 --- a/src/main/java/org/bukkit/craftbukkit/projectiles/CraftBlockProjectileSource.java +++ b/src/main/java/org/bukkit/craftbukkit/projectiles/CraftBlockProjectileSource.java @@ -31,7 +31,6 @@ import net.minecraft.server.EntityArrow; import net.minecraft.server.EntityEgg; import net.minecraft.server.EntityEnderPearl; import net.minecraft.server.EntityFireball; -import net.minecraft.server.EntityLargeFireball; import net.minecraft.server.EntityPotion; import net.minecraft.server.EntityProjectile; import net.minecraft.server.EntitySmallFireball; @@ -39,7 +38,7 @@ import net.minecraft.server.EntitySnowball; import net.minecraft.server.EntitySpectralArrow; import net.minecraft.server.EntityThrownExpBottle; import net.minecraft.server.EntityTippedArrow; -import net.minecraft.server.EntityWitherSkull; +import net.minecraft.server.EntityTypes; import net.minecraft.server.EnumDirection; import net.minecraft.server.IPosition; import net.minecraft.server.IProjectile; @@ -86,9 +85,11 @@ public class CraftBlockProjectileSource implements BlockProjectileSource { launch = new EntityThrownExpBottle(world, iposition.getX(), iposition.getY(), iposition.getZ()); } else if (ThrownPotion.class.isAssignableFrom(projectile)) { if (LingeringPotion.class.isAssignableFrom(projectile)) { - launch = new EntityPotion(world, iposition.getX(), iposition.getY(), iposition.getZ(), CraftItemStack.asNMSCopy(new ItemStack(org.bukkit.Material.LINGERING_POTION, 1))); + launch = new EntityPotion(world, iposition.getX(), iposition.getY(), iposition.getZ()); + ((EntityPotion) launch).setItem(CraftItemStack.asNMSCopy(new ItemStack(org.bukkit.Material.LINGERING_POTION, 1))); } else { - launch = new EntityPotion(world, iposition.getX(), iposition.getY(), iposition.getZ(), CraftItemStack.asNMSCopy(new ItemStack(org.bukkit.Material.SPLASH_POTION, 1))); + launch = new EntityPotion(world, iposition.getX(), iposition.getY(), iposition.getZ()); + ((EntityPotion) launch).setItem(CraftItemStack.asNMSCopy(new ItemStack(org.bukkit.Material.SPLASH_POTION, 1))); } } else if (Arrow.class.isAssignableFrom(projectile)) { if (TippedArrow.class.isAssignableFrom(projectile)) { @@ -113,7 +114,7 @@ public class CraftBlockProjectileSource implements BlockProjectileSource { if (SmallFireball.class.isAssignableFrom(projectile)) { launch = new EntitySmallFireball(world, null, d0, d1, d2); } else if (WitherSkull.class.isAssignableFrom(projectile)) { - launch = new EntityWitherSkull(world); + launch = EntityTypes.WITHER_SKULL.a(world); launch.setPosition(d0, d1, d2); double d6 = (double) MathHelper.sqrt(d3 * d3 + d4 * d4 + d5 * d5); @@ -121,7 +122,7 @@ public class CraftBlockProjectileSource implements BlockProjectileSource { ((EntityFireball) launch).dirY = d4 / d6 * 0.1D; ((EntityFireball) launch).dirZ = d5 / d6 * 0.1D; } else { - launch = new EntityLargeFireball(world); + launch = EntityTypes.FIREBALL.a(world); launch.setPosition(d0, d1, d2); double d6 = (double) MathHelper.sqrt(d3 * d3 + d4 * d4 + d5 * d5); diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java index 61d9febbf7..670146bdda 100644 --- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java +++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java @@ -484,54 +484,54 @@ public class CraftScheduler implements BukkitScheduler { @Deprecated @Override public int scheduleSyncDelayedTask(Plugin plugin, BukkitRunnable task, long delay) { - return scheduleSyncDelayedTask(plugin, (Runnable) task, delay); + throw new UnsupportedOperationException("Use BukkitRunnable#runTaskLater(Plugin, long)"); } @Deprecated @Override public int scheduleSyncDelayedTask(Plugin plugin, BukkitRunnable task) { - return scheduleSyncDelayedTask(plugin, (Runnable) task); + throw new UnsupportedOperationException("Use BukkitRunnable#runTask(Plugin)"); } @Deprecated @Override public int scheduleSyncRepeatingTask(Plugin plugin, BukkitRunnable task, long delay, long period) { - return scheduleSyncRepeatingTask(plugin, (Runnable) task, delay, period); + throw new UnsupportedOperationException("Use BukkitRunnable#runTaskTimer(Plugin, long, long)"); } @Deprecated @Override public BukkitTask runTask(Plugin plugin, BukkitRunnable task) throws IllegalArgumentException { - return runTask(plugin, (Runnable) task); + throw new UnsupportedOperationException("Use BukkitRunnable#runTask(Plugin)"); } @Deprecated @Override public BukkitTask runTaskAsynchronously(Plugin plugin, BukkitRunnable task) throws IllegalArgumentException { - return runTaskAsynchronously(plugin, (Runnable) task); + throw new UnsupportedOperationException("Use BukkitRunnable#runTaskAsynchronously(Plugin)"); } @Deprecated @Override public BukkitTask runTaskLater(Plugin plugin, BukkitRunnable task, long delay) throws IllegalArgumentException { - return runTaskLater(plugin, (Runnable) task, delay); + throw new UnsupportedOperationException("Use BukkitRunnable#runTaskLater(Plugin, long)"); } @Deprecated @Override public BukkitTask runTaskLaterAsynchronously(Plugin plugin, BukkitRunnable task, long delay) throws IllegalArgumentException { - return runTaskLaterAsynchronously(plugin, (Runnable) task, delay); + throw new UnsupportedOperationException("Use BukkitRunnable#runTaskLaterAsynchronously(Plugin, long)"); } @Deprecated @Override public BukkitTask runTaskTimer(Plugin plugin, BukkitRunnable task, long delay, long period) throws IllegalArgumentException { - return runTaskTimer(plugin, (Runnable) task, delay, period); + throw new UnsupportedOperationException("Use BukkitRunnable#runTaskTimer(Plugin, long, long)"); } @Deprecated @Override public BukkitTask runTaskTimerAsynchronously(Plugin plugin, BukkitRunnable task, long delay, long period) throws IllegalArgumentException { - return runTaskTimerAsynchronously(plugin, (Runnable) task, delay, period); + throw new UnsupportedOperationException("Use BukkitRunnable#runTaskTimerAsynchronously(Plugin, long, long)"); } } diff --git a/src/main/java/org/bukkit/craftbukkit/util/AsynchronousExecutor.java b/src/main/java/org/bukkit/craftbukkit/util/AsynchronousExecutor.java deleted file mode 100644 index 193c3621c6..0000000000 --- a/src/main/java/org/bukkit/craftbukkit/util/AsynchronousExecutor.java +++ /dev/null @@ -1,354 +0,0 @@ -package org.bukkit.craftbukkit.util; - -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Queue; -import java.util.concurrent.ConcurrentLinkedQueue; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.ThreadFactory; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; - -import org.apache.commons.lang.Validate; - -/** - * Executes tasks using a multi-stage process executor. Synchronous executions are via {@link AsynchronousExecutor#finishActive()} or the {@link AsynchronousExecutor#get(Object)} methods. - *
  • Stage 1 creates the object from a parameter, and is usually called asynchronously. - *
  • Stage 2 takes the parameter and object from stage 1 and does any synchronous processing to prepare it. - *
  • Stage 3 takes the parameter and object from stage 1, as well as a callback that was registered, and performs any synchronous calculations. - * - * @param

    The type of parameter you provide to make the object that will be created. It should implement {@link Object#hashCode()} and {@link Object#equals(Object)} if you want to get the value early. - * @param The type of object you provide. This is created in stage 1, and passed to stage 2, 3, and returned if get() is called. - * @param The type of callback you provide. You may register many of these to be passed to the provider in stage 3, one at a time. - * @param A type of exception you may throw and expect to be handled by the main thread - * @author Wesley Wolfe (c) 2012, 2014 - */ -public final class AsynchronousExecutor { - - public static interface CallBackProvider extends ThreadFactory { - - /** - * Normally an asynchronous call, but can be synchronous - * - * @param parameter parameter object provided - * @return the created object - */ - T callStage1(P parameter) throws E; - - /** - * Synchronous call - * - * @param parameter parameter object provided - * @param object the previously created object - */ - void callStage2(P parameter, T object) throws E; - - /** - * Synchronous call, called multiple times, once per registered callback - * - * @param parameter parameter object provided - * @param object the previously created object - * @param callback the current callback to execute - */ - void callStage3(P parameter, T object, C callback) throws E; - } - - @SuppressWarnings("rawtypes") - static final AtomicIntegerFieldUpdater STATE_FIELD = AtomicIntegerFieldUpdater.newUpdater(AsynchronousExecutor.Task.class, "state"); - - @SuppressWarnings({ "unchecked", "rawtypes" }) - private static boolean set(AsynchronousExecutor.Task $this, int expected, int value) { - return STATE_FIELD.compareAndSet($this, expected, value); - } - - class Task implements Runnable { - static final int PENDING = 0x0; - static final int STAGE_1_ASYNC = PENDING + 1; - static final int STAGE_1_SYNC = STAGE_1_ASYNC + 1; - static final int STAGE_1_COMPLETE = STAGE_1_SYNC + 1; - static final int FINISHED = STAGE_1_COMPLETE + 1; - - volatile int state = PENDING; - final P parameter; - T object; - final List callbacks = new LinkedList(); - E t = null; - - Task(final P parameter) { - this.parameter = parameter; - } - - public void run() { - if (initAsync()) { - finished.add(this); - } - } - - boolean initAsync() { - if (set(this, PENDING, STAGE_1_ASYNC)) { - boolean ret = true; - - try { - init(); - } finally { - if (set(this, STAGE_1_ASYNC, STAGE_1_COMPLETE)) { - // No one is/will be waiting - } else { - // We know that the sync thread will be waiting - synchronized (this) { - if (state != STAGE_1_SYNC) { - // They beat us to the synchronized block - this.notifyAll(); - } else { - // We beat them to the synchronized block - } - state = STAGE_1_COMPLETE; // They're already synchronized, atomic locks are not needed - } - // We want to return false, because we know a synchronous task already handled the finish() - ret = false; // Don't return inside finally; VERY bad practice. - } - } - - return ret; - } else { - return false; - } - } - - void initSync() { - if (set(this, PENDING, STAGE_1_COMPLETE)) { - // If we succeed that variable switch, good as done - init(); - } else if (set(this, STAGE_1_ASYNC, STAGE_1_SYNC)) { - // Async thread is running, but this shouldn't be likely; we need to sync to wait on them because of it. - synchronized (this) { - if (set(this, STAGE_1_SYNC, PENDING)) { // They might NOT synchronized yet, atomic lock IS needed - // We are the first into the lock - while (state != STAGE_1_COMPLETE) { - try { - this.wait(); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - throw new RuntimeException("Unable to handle interruption on " + parameter, e); - } - } - } else { - // They beat us to the synchronized block - } - } - } else { - // Async thread is not pending, the more likely situation for a task not pending - } - } - - @SuppressWarnings("unchecked") - void init() { - try { - object = provider.callStage1(parameter); - } catch (final Throwable t) { - this.t = (E) t; - } - } - - @SuppressWarnings("unchecked") - T get() throws E { - initSync(); - if (callbacks.isEmpty()) { - // 'this' is a placeholder to prevent callbacks from being empty during finish call - // See get method below - callbacks.add((C) this); - } - finish(); - return object; - } - - void finish() throws E { - switch (state) { - default: - case PENDING: - case STAGE_1_ASYNC: - case STAGE_1_SYNC: - throw new IllegalStateException("Attempting to finish unprepared(" + state + ") task(" + parameter + ")"); - case STAGE_1_COMPLETE: - try { - if (t != null) { - throw t; - } - if (callbacks.isEmpty()) { - return; - } - - final CallBackProvider provider = AsynchronousExecutor.this.provider; - final P parameter = this.parameter; - final T object = this.object; - - provider.callStage2(parameter, object); - for (C callback : callbacks) { - if (callback == this) { - // 'this' is a placeholder to prevent callbacks from being empty on a get() call - // See get method above - continue; - } - provider.callStage3(parameter, object, callback); - } - } finally { - tasks.remove(parameter); - state = FINISHED; - } - case FINISHED: - } - } - - boolean drop() { - if (set(this, PENDING, FINISHED)) { - // If we succeed that variable switch, good as forgotten - tasks.remove(parameter); - return true; - } else { - // We need the async thread to finish normally to properly dispose of the task - return false; - } - } - } - - final CallBackProvider provider; - final Queue finished = new ConcurrentLinkedQueue(); - final Map tasks = new HashMap(); - final ThreadPoolExecutor pool; - - /** - * Uses a thread pool to pass executions to the provider. - * @see AsynchronousExecutor - */ - public AsynchronousExecutor(final CallBackProvider provider, final int coreSize) { - Validate.notNull(provider, "Provider cannot be null"); - this.provider = provider; - - // We have an unbound queue size so do not need a max thread size - pool = new ThreadPoolExecutor(coreSize, Integer.MAX_VALUE, 60l, TimeUnit.SECONDS, new LinkedBlockingQueue(), provider); - } - - /** - * Adds a callback to the parameter provided, adding parameter to the queue if needed. - *

    - * This should always be synchronous. - */ - public void add(P parameter, C callback) { - Task task = tasks.get(parameter); - if (task == null) { - tasks.put(parameter, task = new Task(parameter)); - pool.execute(task); - } - task.callbacks.add(callback); - } - - /** - * This removes a particular callback from the specified parameter. - *

    - * If no callbacks remain for a given parameter, then the {@link CallBackProvider CallBackProvider's} stages may be omitted from execution. - * Stage 3 will have no callbacks, stage 2 will be skipped unless a {@link #get(Object)} is used, and stage 1 will be avoided on a best-effort basis. - *

    - * Subsequent calls to {@link #getSkipQueue(Object)} will always work. - *

    - * Subsequent calls to {@link #get(Object)} might work. - *

    - * This should always be synchronous - * @return true if no further execution for the parameter is possible, such that, no exceptions will be thrown in {@link #finishActive()} for the parameter, and {@link #get(Object)} will throw an {@link IllegalStateException}, false otherwise - * @throws IllegalStateException if parameter is not in the queue anymore - * @throws IllegalStateException if the callback was not specified for given parameter - */ - public boolean drop(P parameter, C callback) throws IllegalStateException { - final Task task = tasks.get(parameter); - if (task == null) { - return true; - } - if (!task.callbacks.remove(callback)) { - throw new IllegalStateException("Unknown " + callback + " for " + parameter); - } - if (task.callbacks.isEmpty()) { - return task.drop(); - } - return false; - } - - /** - * This method attempts to skip the waiting period for said parameter. - *

    - * This should always be synchronous. - * @throws IllegalStateException if the parameter is not in the queue anymore, or sometimes if called from asynchronous thread - */ - public T get(P parameter) throws E, IllegalStateException { - final Task task = tasks.get(parameter); - if (task == null) { - throw new IllegalStateException("Unknown " + parameter); - } - return task.get(); - } - - /** - * Processes a parameter as if it was in the queue, without ever passing to another thread. - */ - public T getSkipQueue(P parameter) throws E { - return skipQueue(parameter); - } - - /** - * Processes a parameter as if it was in the queue, without ever passing to another thread. - */ - public T getSkipQueue(P parameter, C callback) throws E { - final T object = skipQueue(parameter); - provider.callStage3(parameter, object, callback); - return object; - } - - /** - * Processes a parameter as if it was in the queue, without ever passing to another thread. - */ - public T getSkipQueue(P parameter, C...callbacks) throws E { - final CallBackProvider provider = this.provider; - final T object = skipQueue(parameter); - for (C callback : callbacks) { - provider.callStage3(parameter, object, callback); - } - return object; - } - - /** - * Processes a parameter as if it was in the queue, without ever passing to another thread. - */ - public T getSkipQueue(P parameter, Iterable callbacks) throws E { - final CallBackProvider provider = this.provider; - final T object = skipQueue(parameter); - for (C callback : callbacks) { - provider.callStage3(parameter, object, callback); - } - return object; - } - - private T skipQueue(P parameter) throws E { - Task task = tasks.get(parameter); - if (task != null) { - return task.get(); - } - T object = provider.callStage1(parameter); - provider.callStage2(parameter, object); - return object; - } - - /** - * This is the 'heartbeat' that should be called synchronously to finish any pending tasks - */ - public void finishActive() throws E { - final Queue finished = this.finished; - while (!finished.isEmpty()) { - finished.poll().finish(); - } - } - - public void setActiveThreads(final int coreSize) { - pool.setCorePoolSize(coreSize); - } -} diff --git a/src/main/java/org/bukkit/craftbukkit/util/BlockStateListPopulator.java b/src/main/java/org/bukkit/craftbukkit/util/BlockStateListPopulator.java index 165843ddfe..a65c0500cd 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/BlockStateListPopulator.java +++ b/src/main/java/org/bukkit/craftbukkit/util/BlockStateListPopulator.java @@ -3,6 +3,7 @@ package org.bukkit.craftbukkit.util; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; +import java.util.Set; import net.minecraft.server.BlockPosition; import net.minecraft.server.IBlockData; @@ -38,6 +39,10 @@ public class BlockStateListPopulator extends DummyGeneratorAccess { } } + public Set getBlocks() { + return list.keySet(); + } + public List getList() { return new ArrayList<>(list.values()); } diff --git a/src/main/java/org/bukkit/craftbukkit/util/Commodore.java b/src/main/java/org/bukkit/craftbukkit/util/Commodore.java index 632df2270c..467b2d9385 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/Commodore.java +++ b/src/main/java/org/bukkit/craftbukkit/util/Commodore.java @@ -140,6 +140,28 @@ public class Commodore { if ( modern ) { + if ( owner.equals( "org/bukkit/Material" ) ) + { + switch ( name ) + { + case "CACTUS_GREEN": + name = "GREEN_DYE"; + break; + case "DANDELION_YELLOW": + name = "YELLOW_DYE"; + break; + case "ROSE_RED": + name = "RED_DYE"; + break; + case "SIGN": + name = "OAK_SIGN"; + break; + case "WALL_SIGN": + name = "OAK_WALL_SIGN"; + break; + } + } + super.visitFieldInsn( opcode, owner, name, desc ); return; } diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftLegacy.java b/src/main/java/org/bukkit/craftbukkit/util/CraftLegacy.java index c6aae80716..4539a4a773 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftLegacy.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftLegacy.java @@ -43,7 +43,7 @@ import org.bukkit.material.MaterialData; public class CraftLegacy { private static final Map SPAWN_EGGS = new HashMap<>(); - private static final Set whitelistedStates = new HashSet<>(Arrays.asList("explode", "check_decay", "decayable")); + private static final Set whitelistedStates = new HashSet<>(Arrays.asList("explode", "check_decay", "decayable", "facing")); private static final Map materialToItem = new HashMap<>(16384); private static final Map itemToMaterial = new HashMap<>(1024); private static final Map materialToData = new HashMap<>(4096); @@ -311,7 +311,7 @@ public class CraftLegacy { SPAWN_EGGS.put((byte) EntityType.PIG_ZOMBIE.getTypeId(), Material.ZOMBIE_PIGMAN_SPAWN_EGG); SPAWN_EGGS.put((byte) EntityType.ZOMBIE_VILLAGER.getTypeId(), Material.ZOMBIE_VILLAGER_SPAWN_EGG); - DispenserRegistry.c(); + DispenserRegistry.init(); for (Material material : Material.values()) { if (!material.isLegacy()) { @@ -324,11 +324,11 @@ public class CraftLegacy { MaterialData matData = new MaterialData(material, data); Dynamic blockTag = DataConverterFlattenData.b(material.getId() << 4 | data); // TODO: better skull conversion, chests - if (blockTag.getString("Name").contains("%%FILTER_ME%%")) { + if (blockTag.get("Name").asString("").contains("%%FILTER_ME%%")) { continue; } - String name = blockTag.getString("Name"); + String name = blockTag.get("Name").asString(""); // TODO: need to fix if (name.equals("minecraft:portal")) { name = "minecraft:nether_portal"; @@ -341,9 +341,9 @@ public class CraftLegacy { IBlockData blockData = block.getBlockData(); BlockStateList states = block.getStates(); - Optional propMap = blockTag.get("Properties"); + Optional propMap = blockTag.getElement("Properties"); if (propMap.isPresent()) { - NBTTagCompound properties = (NBTTagCompound) propMap.get().getValue(); + NBTTagCompound properties = propMap.get(); for (String dataKey : properties.getKeys()) { IBlockState state = states.a(dataKey); @@ -402,7 +402,7 @@ public class CraftLegacy { Dynamic converted = DataConverterRegistry.a().update(DataConverterTypes.ITEM_STACK, new Dynamic(DynamicOpsNBT.a, stack), -1, CraftMagicNumbers.INSTANCE.getDataVersion()); - String newId = converted.getString("id"); + String newId = converted.get("id").asString(""); // Recover spawn eggs with invalid data if (newId.equals("minecraft:spawn_egg")) { newId = "minecraft:pig_spawn_egg"; diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java index 72e83454fc..853dc1c003 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java @@ -1,9 +1,11 @@ package org.bukkit.craftbukkit.util; import com.google.common.base.Charsets; +import com.google.common.base.Preconditions; import com.google.common.collect.Maps; import com.google.common.io.Files; import com.mojang.brigadier.exceptions.CommandSyntaxException; +import com.mojang.datafixers.Dynamic; import java.io.File; import java.io.IOException; import java.util.Collections; @@ -16,13 +18,18 @@ import java.util.logging.Logger; import net.minecraft.server.AdvancementDataWorld; import net.minecraft.server.Block; import net.minecraft.server.ChatDeserializer; +import net.minecraft.server.DataConverterRegistry; +import net.minecraft.server.DataConverterTypes; +import net.minecraft.server.DynamicOpsNBT; import net.minecraft.server.IBlockData; import net.minecraft.server.IRegistry; import net.minecraft.server.Item; import net.minecraft.server.MinecraftKey; import net.minecraft.server.MinecraftServer; import net.minecraft.server.MojangsonParser; +import net.minecraft.server.NBTBase; import net.minecraft.server.NBTTagCompound; +import net.minecraft.server.SharedConstants; import org.bukkit.Bukkit; import org.bukkit.Material; @@ -74,19 +81,22 @@ public final class CraftMagicNumbers implements UnsafeValues { private static final Map MATERIAL_BLOCK = new HashMap<>(); static { - for (Block block : (Iterable) IRegistry.BLOCK) { // Eclipse fail + for (Block block : IRegistry.BLOCK) { BLOCK_MATERIAL.put(block, Material.getMaterial(IRegistry.BLOCK.getKey(block).getKey().toUpperCase(Locale.ROOT))); } - for (Item item : (Iterable) IRegistry.ITEM) { // Eclipse fail + for (Item item : IRegistry.ITEM) { ITEM_MATERIAL.put(item, Material.getMaterial(IRegistry.ITEM.getKey(item).getKey().toUpperCase(Locale.ROOT))); } for (Material material : Material.values()) { MinecraftKey key = key(material); - // TODO: only register if block/item? - MATERIAL_ITEM.put(material, IRegistry.ITEM.get(key)); - MATERIAL_BLOCK.put(material, IRegistry.BLOCK.get(key)); + IRegistry.ITEM.getOptional(key).ifPresent((item) -> { + MATERIAL_ITEM.put(material, item); + }); + IRegistry.BLOCK.getOptional(key).ifPresent((block) -> { + MATERIAL_BLOCK.put(material, block); + }); } } @@ -144,6 +154,24 @@ public final class CraftMagicNumbers implements UnsafeValues { return CraftBlockData.fromData(getBlock(material, data)); } + @Override + public Material getMaterial(String material, int version) { + Preconditions.checkArgument(version <= this.getDataVersion(), "Newer version! Server downgrades are not supported!"); + + // Fastpath up to date materials + if (version == this.getDataVersion()) { + return Material.getMaterial(material); + } + + NBTTagCompound stack = new NBTTagCompound(); + stack.setString("id", "minecraft:" + material.toLowerCase(Locale.ROOT)); + + Dynamic converted = DataConverterRegistry.a().update(DataConverterTypes.ITEM_STACK, new Dynamic<>(DynamicOpsNBT.a, stack), version, this.getDataVersion()); + String newId = converted.get("id").asString(""); + + return Material.matchMaterial(newId); + } + /** * This string should be changed if the NMS mappings do. * @@ -160,12 +188,12 @@ public final class CraftMagicNumbers implements UnsafeValues { * @return string */ public String getMappingsVersion() { - return "7dd4b3ec31629620c41553e5c142e454"; + return "8b7fe9012a93b36df04844a6c990de27"; } @Override public int getDataVersion() { - return 1631; + return SharedConstants.a().getWorldVersion(); } @Override @@ -222,9 +250,11 @@ public final class CraftMagicNumbers implements UnsafeValues { @Override public void checkSupported(PluginDescriptionFile pdf) throws InvalidPluginException { if (pdf.getAPIVersion() != null) { - if (!pdf.getAPIVersion().equals("1.13")) { + if (!pdf.getAPIVersion().equals("1.13") && !pdf.getAPIVersion().equals("1.14")) { throw new InvalidPluginException("Unsupported API version " + pdf.getAPIVersion()); } + } else { + Bukkit.getLogger().log(Level.WARNING, "Plugin " + pdf.getFullName() + " does not specify an api-version."); } } diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftNBTTagConfigSerializer.java b/src/main/java/org/bukkit/craftbukkit/util/CraftNBTTagConfigSerializer.java index 8b7c29403b..fd0b99b786 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftNBTTagConfigSerializer.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftNBTTagConfigSerializer.java @@ -34,7 +34,7 @@ public class CraftNBTTagConfigSerializer { } else if (base instanceof NBTTagList) { List baseList = new ArrayList<>(); for (int i = 0; i < ((NBTList) base).size(); i++) { - baseList.add(serialize(((NBTList) base).get(i))); + baseList.add(serialize((NBTBase) ((NBTList) base).get(i))); } return baseList; diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftRayTraceResult.java b/src/main/java/org/bukkit/craftbukkit/util/CraftRayTraceResult.java index 050f4d3a8e..ffd2e64aa2 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftRayTraceResult.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftRayTraceResult.java @@ -10,6 +10,8 @@ import org.bukkit.util.Vector; import net.minecraft.server.BlockPosition; import net.minecraft.server.MovingObjectPosition; import net.minecraft.server.MovingObjectPosition.EnumMovingObjectType; +import net.minecraft.server.MovingObjectPositionBlock; +import net.minecraft.server.MovingObjectPositionEntity; import net.minecraft.server.Vec3D; public class CraftRayTraceResult { @@ -17,23 +19,24 @@ public class CraftRayTraceResult { private CraftRayTraceResult() {} public static RayTraceResult fromNMS(World world, MovingObjectPosition nmsHitResult) { - if (nmsHitResult == null || nmsHitResult.type == EnumMovingObjectType.MISS) return null; + if (nmsHitResult == null || nmsHitResult.getType() == EnumMovingObjectType.MISS) return null; - Vec3D nmsHitPos = nmsHitResult.pos; + Vec3D nmsHitPos = nmsHitResult.getPos(); Vector hitPosition = new Vector(nmsHitPos.x, nmsHitPos.y, nmsHitPos.z); BlockFace hitBlockFace = null; - if (nmsHitResult.direction != null) { - hitBlockFace = CraftBlock.notchToBlockFace(nmsHitResult.direction); - } - - if (nmsHitResult.entity != null) { - Entity hitEntity = nmsHitResult.entity.getBukkitEntity(); - return new RayTraceResult(hitPosition, hitEntity, hitBlockFace); + if (nmsHitResult.getType() == EnumMovingObjectType.ENTITY) { + Entity hitEntity = ((MovingObjectPositionEntity) nmsHitResult).getEntity().getBukkitEntity(); + return new RayTraceResult(hitPosition, hitEntity, null); } Block hitBlock = null; - BlockPosition nmsBlockPos = nmsHitResult.getBlockPosition(); + BlockPosition nmsBlockPos = null; + if (nmsHitResult.getType() == EnumMovingObjectType.BLOCK) { + MovingObjectPositionBlock blockHitResult = (MovingObjectPositionBlock) nmsHitResult; + hitBlockFace = CraftBlock.notchToBlockFace(blockHitResult.getDirection()); + nmsBlockPos = blockHitResult.getBlockPosition(); + } if (nmsBlockPos != null && world != null) { hitBlock = world.getBlockAt(nmsBlockPos.getX(), nmsBlockPos.getY(), nmsBlockPos.getZ()); } diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftVector.java b/src/main/java/org/bukkit/craftbukkit/util/CraftVector.java new file mode 100644 index 0000000000..d474327398 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftVector.java @@ -0,0 +1,15 @@ +package org.bukkit.craftbukkit.util; + +public final class CraftVector { + + private CraftVector() { + } + + public static org.bukkit.util.Vector toBukkit(net.minecraft.server.Vec3D nms) { + return new org.bukkit.util.Vector(nms.x, nms.y, nms.z); + } + + public static net.minecraft.server.Vec3D toNMS(org.bukkit.util.Vector bukkit) { + return new net.minecraft.server.Vec3D(bukkit.getX(), bukkit.getY(), bukkit.getZ()); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java b/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java index b1ecf5a530..e81fc4a7f4 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java +++ b/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java @@ -1,10 +1,13 @@ package org.bukkit.craftbukkit.util; +import java.util.List; import java.util.Random; import java.util.function.Predicate; +import net.minecraft.server.AxisAlignedBB; import net.minecraft.server.BiomeBase; import net.minecraft.server.Block; import net.minecraft.server.BlockPosition; +import net.minecraft.server.ChunkStatus; import net.minecraft.server.DifficultyDamageScaler; import net.minecraft.server.Entity; import net.minecraft.server.EntityHuman; @@ -17,19 +20,15 @@ import net.minecraft.server.HeightMap; import net.minecraft.server.IBlockData; import net.minecraft.server.IChunkAccess; import net.minecraft.server.IChunkProvider; -import net.minecraft.server.IDataManager; import net.minecraft.server.ParticleParam; -import net.minecraft.server.PersistentCollection; import net.minecraft.server.SoundCategory; import net.minecraft.server.SoundEffect; import net.minecraft.server.TickList; import net.minecraft.server.TileEntity; -import net.minecraft.server.VoxelShape; import net.minecraft.server.World; import net.minecraft.server.WorldBorder; import net.minecraft.server.WorldData; import net.minecraft.server.WorldProvider; -import org.bukkit.event.entity.CreatureSpawnEvent; public class DummyGeneratorAccess implements GeneratorAccess { @@ -53,11 +52,6 @@ public class DummyGeneratorAccess implements GeneratorAccess { throw new UnsupportedOperationException("Not supported yet."); } - @Override - public IChunkAccess getChunkAt(int i, int i1) { - throw new UnsupportedOperationException("Not supported yet."); - } - @Override public World getMinecraftWorld() { throw new UnsupportedOperationException("Not supported yet."); @@ -79,12 +73,7 @@ public class DummyGeneratorAccess implements GeneratorAccess { } @Override - public IDataManager getDataManager() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public Random m() { + public Random getRandom() { throw new UnsupportedOperationException("Not supported yet."); } @@ -93,11 +82,6 @@ public class DummyGeneratorAccess implements GeneratorAccess { throw new UnsupportedOperationException("Not supported yet."); } - @Override - public BlockPosition getSpawn() { - throw new UnsupportedOperationException("Not supported yet."); - } - @Override public void a(EntityHuman eh, BlockPosition bp, SoundEffect se, SoundCategory sc, float f, float f1) { throw new UnsupportedOperationException("Not supported yet."); @@ -109,17 +93,22 @@ public class DummyGeneratorAccess implements GeneratorAccess { } @Override - public boolean isEmpty(BlockPosition bp) { + public void a(EntityHuman eh, int i, BlockPosition bp, int i1) { throw new UnsupportedOperationException("Not supported yet."); } @Override - public BiomeBase getBiome(BlockPosition bp) { + public List getEntities(Entity entity, AxisAlignedBB aabb, Predicate prdct) { throw new UnsupportedOperationException("Not supported yet."); } @Override - public int getBrightness(EnumSkyBlock esb, BlockPosition bp) { + public List a(Class type, AxisAlignedBB aabb, Predicate prdct) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public List getPlayers() { throw new UnsupportedOperationException("Not supported yet."); } @@ -129,12 +118,12 @@ public class DummyGeneratorAccess implements GeneratorAccess { } @Override - public boolean isChunkLoaded(int i, int i1, boolean bln) { + public IChunkAccess getChunkAt(int i, int i1, ChunkStatus cs, boolean bln) { throw new UnsupportedOperationException("Not supported yet."); } @Override - public boolean e(BlockPosition bp) { + public BlockPosition getHighestBlockYAt(HeightMap.Type type, BlockPosition bp) { throw new UnsupportedOperationException("Not supported yet."); } @@ -143,11 +132,6 @@ public class DummyGeneratorAccess implements GeneratorAccess { throw new UnsupportedOperationException("Not supported yet."); } - @Override - public EntityHuman a(double d, double d1, double d2, double d3, Predicate prdct) { - throw new UnsupportedOperationException("Not supported yet."); - } - @Override public int c() { throw new UnsupportedOperationException("Not supported yet."); @@ -158,11 +142,6 @@ public class DummyGeneratorAccess implements GeneratorAccess { throw new UnsupportedOperationException("Not supported yet."); } - @Override - public boolean a(Entity entity, VoxelShape vs) { - throw new UnsupportedOperationException("Not supported yet."); - } - @Override public int a(BlockPosition bp, EnumDirection ed) { throw new UnsupportedOperationException("Not supported yet."); @@ -179,7 +158,17 @@ public class DummyGeneratorAccess implements GeneratorAccess { } @Override - public WorldProvider o() { + public WorldProvider getWorldProvider() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public BiomeBase getBiome(BlockPosition bp) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getBrightness(EnumSkyBlock esb, BlockPosition bp) { throw new UnsupportedOperationException("Not supported yet."); } @@ -199,7 +188,7 @@ public class DummyGeneratorAccess implements GeneratorAccess { } @Override - public PersistentCollection h() { + public boolean a(BlockPosition bp, Predicate prdct) { throw new UnsupportedOperationException("Not supported yet."); } @@ -209,27 +198,12 @@ public class DummyGeneratorAccess implements GeneratorAccess { } @Override - public boolean addEntity(Entity entity) { + public boolean a(BlockPosition blockposition, boolean flag) { throw new UnsupportedOperationException("Not supported yet."); } @Override - public boolean addEntity(Entity entity, CreatureSpawnEvent.SpawnReason reason) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public boolean setAir(BlockPosition blockposition) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public void a(EnumSkyBlock enumskyblock, BlockPosition blockposition, int i) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public boolean setAir(BlockPosition blockposition, boolean flag) { + public boolean b(BlockPosition blockposition, boolean flag) { throw new UnsupportedOperationException("Not supported yet."); } } diff --git a/src/main/java/org/bukkit/craftbukkit/util/LongHash.java b/src/main/java/org/bukkit/craftbukkit/util/LongHash.java deleted file mode 100644 index 691cafd03d..0000000000 --- a/src/main/java/org/bukkit/craftbukkit/util/LongHash.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.bukkit.craftbukkit.util; - -public class LongHash { - public static long toLong(int msw, int lsw) { - return ((long) msw << 32) + lsw - Integer.MIN_VALUE; - } - - public static int msw(long l) { - return (int) (l >> 32); - } - - public static int lsw(long l) { - return (int) (l & 0xFFFFFFFF) + Integer.MIN_VALUE; - } -} diff --git a/src/main/java/org/bukkit/craftbukkit/util/LongHashSet.java b/src/main/java/org/bukkit/craftbukkit/util/LongHashSet.java deleted file mode 100644 index a213579220..0000000000 --- a/src/main/java/org/bukkit/craftbukkit/util/LongHashSet.java +++ /dev/null @@ -1,302 +0,0 @@ -/* - Based on CompactHashSet Copyright 2011 Ontopia Project - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package org.bukkit.craftbukkit.util; - -import java.util.Arrays; -import java.util.Iterator; -import java.util.ConcurrentModificationException; -import java.util.NoSuchElementException; - -public class LongHashSet { - private final static int INITIAL_SIZE = 3; - private final static double LOAD_FACTOR = 0.75; - - private final static long FREE = 0; - private final static long REMOVED = Long.MIN_VALUE; - - private int freeEntries; - private int elements; - private long[] values; - private int modCount; - - public LongHashSet() { - this(INITIAL_SIZE); - } - - public LongHashSet(int size) { - values = new long[(size==0 ? 1 : size)]; - elements = 0; - freeEntries = values.length; - modCount = 0; - } - - public Iterator iterator() { - return new Itr(); - } - - public int size() { - return elements; - } - - public boolean isEmpty() { - return elements == 0; - } - - public boolean contains(int msw, int lsw) { - return contains(LongHash.toLong(msw, lsw)); - } - - public boolean contains(long value) { - int hash = hash(value); - int index = (hash & 0x7FFFFFFF) % values.length; - int offset = 1; - - // search for the object (continue while !null and !this object) - while(values[index] != FREE && !(hash(values[index]) == hash && values[index] == value)) { - index = ((index + offset) & 0x7FFFFFFF) % values.length; - offset = offset * 2 + 1; - - if (offset == -1) { - offset = 2; - } - } - - return values[index] != FREE; - } - - public boolean add(int msw, int lsw) { - return add(LongHash.toLong(msw, lsw)); - } - - public boolean add(long value) { - int hash = hash(value); - int index = (hash & 0x7FFFFFFF) % values.length; - int offset = 1; - int deletedix = -1; - - // search for the object (continue while !null and !this object) - while(values[index] != FREE && !(hash(values[index]) == hash && values[index] == value)) { - // if there's a deleted object here we can put this object here, - // provided it's not in here somewhere else already - if (values[index] == REMOVED) { - deletedix = index; - } - - index = ((index + offset) & 0x7FFFFFFF) % values.length; - offset = offset * 2 + 1; - - if (offset == -1) { - offset = 2; - } - } - - if (values[index] == FREE) { - if (deletedix != -1) { // reusing a deleted cell - index = deletedix; - } else { - freeEntries--; - } - - modCount++; - elements++; - values[index] = value; - - if (1 - (freeEntries / (double) values.length) > LOAD_FACTOR) { - rehash(); - } - - return true; - } else { - return false; - } - } - - public void remove(int msw, int lsw) { - remove(LongHash.toLong(msw, lsw)); - } - - public boolean remove(long value) { - int hash = hash(value); - int index = (hash & 0x7FFFFFFF) % values.length; - int offset = 1; - - // search for the object (continue while !null and !this object) - while(values[index] != FREE && !(hash(values[index]) == hash && values[index] == value)) { - index = ((index + offset) & 0x7FFFFFFF) % values.length; - offset = offset * 2 + 1; - - if (offset == -1) { - offset = 2; - } - } - - if (values[index] != FREE) { - values[index] = REMOVED; - modCount++; - elements--; - return true; - } else { - return false; - } - } - - public void clear() { - elements = 0; - for (int ix = 0; ix < values.length; ix++) { - values[ix] = FREE; - } - - freeEntries = values.length; - modCount++; - } - - public long[] toArray() { - long[] result = new long[elements]; - long[] values = Arrays.copyOf(this.values, this.values.length); - int pos = 0; - - for (long value : values) { - if (value != FREE && value != REMOVED) { - result[pos++] = value; - } - } - - return result; - } - - public long popFirst() { - for (long value : values) { - if (value != FREE && value != REMOVED) { - remove(value); - return value; - } - } - - return 0; - } - - public long[] popAll() { - long[] ret = toArray(); - clear(); - return ret; - } - - // This method copied from Murmur3, written by Austin Appleby released under Public Domain - private int hash(long value) { - value ^= value >>> 33; - value *= 0xff51afd7ed558ccdL; - value ^= value >>> 33; - value *= 0xc4ceb9fe1a85ec53L; - value ^= value >>> 33; - return (int) value; - } - - private void rehash() { - int gargagecells = values.length - (elements + freeEntries); - if (gargagecells / (double) values.length > 0.05) { - rehash(values.length); - } else { - rehash(values.length * 2 + 1); - } - } - - private void rehash(int newCapacity) { - long[] newValues = new long[newCapacity]; - - for (long value : values) { - if (value == FREE || value == REMOVED) { - continue; - } - - int hash = hash(value); - int index = (hash & 0x7FFFFFFF) % newCapacity; - int offset = 1; - - // search for the object - while (newValues[index] != FREE) { - index = ((index + offset) & 0x7FFFFFFF) % newCapacity; - offset = offset * 2 + 1; - - if (offset == -1) { - offset = 2; - } - } - - newValues[index] = value; - } - - values = newValues; - freeEntries = values.length - elements; - } - - private class Itr implements Iterator { - private int index; - private int lastReturned = -1; - private int expectedModCount; - - public Itr() { - for (index = 0; index < values.length && (values[index] == FREE || values[index] == REMOVED); index++) { - // This is just to drive the index forward to the first valid entry - } - expectedModCount = modCount; - } - - public boolean hasNext() { - return index != values.length; - } - - public Long next() { - if (modCount != expectedModCount) { - throw new ConcurrentModificationException(); - } - - int length = values.length; - if (index >= length) { - lastReturned = -2; - throw new NoSuchElementException(); - } - - lastReturned = index; - for (index += 1; index < length && (values[index] == FREE || values[index] == REMOVED); index++) { - // This is just to drive the index forward to the next valid entry - } - - if (values[lastReturned] == FREE) { - return FREE; - } else { - return values[lastReturned]; - } - } - - public void remove() { - if (modCount != expectedModCount) { - throw new ConcurrentModificationException(); - } - - if (lastReturned == -1 || lastReturned == -2) { - throw new IllegalStateException(); - } - - if (values[lastReturned] != FREE && values[lastReturned] != REMOVED) { - values[lastReturned] = REMOVED; - elements--; - modCount++; - expectedModCount = modCount; - } - } - } -} diff --git a/src/main/java/org/bukkit/craftbukkit/util/LongObjectHashMap.java b/src/main/java/org/bukkit/craftbukkit/util/LongObjectHashMap.java deleted file mode 100644 index 0cd430a3ad..0000000000 --- a/src/main/java/org/bukkit/craftbukkit/util/LongObjectHashMap.java +++ /dev/null @@ -1,422 +0,0 @@ -package org.bukkit.craftbukkit.util; - -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.Serializable; -import java.util.AbstractCollection; -import java.util.AbstractSet; -import java.util.Arrays; -import java.util.Collection; -import java.util.ConcurrentModificationException; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Map; -import java.util.NoSuchElementException; -import java.util.Set; - -@SuppressWarnings("unchecked") -public class LongObjectHashMap implements Cloneable, Serializable { - static final long serialVersionUID = 2841537710170573815L; - - private static final long EMPTY_KEY = Long.MIN_VALUE; - private static final int BUCKET_SIZE = 4096; - - private transient long[][] keys; - private transient V[][] values; - private transient int modCount; - private transient int size; - - public LongObjectHashMap() { - initialize(); - } - - public LongObjectHashMap(Map map) { - this(); - putAll(map); - } - - public int size() { - return size; - } - - public boolean isEmpty() { - return size == 0; - } - - public boolean containsKey(long key) { - return get(key) != null; - } - - public boolean containsValue(V value) { - for (V val : values()) { - if (val == value || val.equals(value)) { - return true; - } - } - - return false; - } - - public V get(long key) { - int index = (int) (keyIndex(key) & (BUCKET_SIZE - 1)); - long[] inner = keys[index]; - if (inner == null) return null; - - for (int i = 0; i < inner.length; i++) { - long innerKey = inner[i]; - if (innerKey == EMPTY_KEY) { - return null; - } else if (innerKey == key) { - return values[index][i]; - } - } - - return null; - } - - public V put(long key, V value) { - int index = (int) (keyIndex(key) & (BUCKET_SIZE - 1)); - long[] innerKeys = keys[index]; - V[] innerValues = values[index]; - modCount++; - - if (innerKeys == null) { - // need to make a new chain - keys[index] = innerKeys = new long[8]; - Arrays.fill(innerKeys, EMPTY_KEY); - values[index] = innerValues = (V[]) new Object[8]; - innerKeys[0] = key; - innerValues[0] = value; - size++; - } else { - int i; - for (i = 0; i < innerKeys.length; i++) { - // found an empty spot in the chain to put this - if (innerKeys[i] == EMPTY_KEY) { - size++; - innerKeys[i] = key; - innerValues[i] = value; - return null; - } - - // found an existing entry in the chain with this key, replace it - if (innerKeys[i] == key) { - V oldValue = innerValues[i]; - innerKeys[i] = key; - innerValues[i] = value; - return oldValue; - } - } - - // chain is full, resize it and add our new entry - keys[index] = innerKeys = Arrays.copyOf(innerKeys, i << 1); - Arrays.fill(innerKeys, i, innerKeys.length, EMPTY_KEY); - values[index] = innerValues = Arrays.copyOf(innerValues, i << 1); - innerKeys[i] = key; - innerValues[i] = value; - size++; - } - - return null; - } - - public V remove(long key) { - int index = (int) (keyIndex(key) & (BUCKET_SIZE - 1)); - long[] inner = keys[index]; - if (inner == null) { - return null; - } - - for (int i = 0; i < inner.length; i++) { - // hit the end of the chain, didn't find this entry - if (inner[i] == EMPTY_KEY) { - break; - } - - if (inner[i] == key) { - V value = values[index][i]; - - for (i++; i < inner.length; i++) { - if (inner[i] == EMPTY_KEY) { - break; - } - - inner[i - 1] = inner[i]; - values[index][i - 1] = values[index][i]; - } - - inner[i - 1] = EMPTY_KEY; - values[index][i - 1] = null; - size--; - modCount++; - return value; - } - } - - return null; - } - - public void putAll(Map map) { - for (Map.Entry entry : map.entrySet()) { - put((Long) entry.getKey(), (V) entry.getValue()); - } - } - - public void clear() { - if (size == 0) { - return; - } - - modCount++; - size = 0; - Arrays.fill(keys, null); - Arrays.fill(values, null); - } - - public Set keySet() { - return new KeySet(); - } - - public Collection values() { - return new ValueCollection(); - } - - /** - * Returns a Set of Entry objects for the HashMap. This is not how the internal - * implementation is laid out so this constructs the entire Set when called. For - * this reason it should be avoided if at all possible. - * - * @return Set of Entry objects - * @deprecated - */ - @Deprecated - public Set> entrySet() { - HashSet> set = new HashSet>(); - for (long key : keySet()) { - set.add(new Entry(key, get(key))); - } - - return set; - } - - public Object clone() throws CloneNotSupportedException { - LongObjectHashMap clone = (LongObjectHashMap) super.clone(); - // Make sure we clear any existing information from the clone - clone.clear(); - // Make sure the clone is properly setup for new entries - clone.initialize(); - - // Iterate through the data normally to do a safe clone - for (long key : keySet()) { - final V value = get(key); - clone.put(key, value); - } - - return clone; - } - - private void initialize() { - keys = new long[BUCKET_SIZE][]; - values = (V[][]) new Object[BUCKET_SIZE][]; - } - - private long keyIndex(long key) { - key ^= key >>> 33; - key *= 0xff51afd7ed558ccdL; - key ^= key >>> 33; - key *= 0xc4ceb9fe1a85ec53L; - key ^= key >>> 33; - return key; - } - - private void writeObject(ObjectOutputStream outputStream) throws IOException { - outputStream.defaultWriteObject(); - - for (long key : keySet()) { - V value = get(key); - outputStream.writeLong(key); - outputStream.writeObject(value); - } - - outputStream.writeLong(EMPTY_KEY); - outputStream.writeObject(null); - } - - private void readObject(ObjectInputStream inputStream) throws ClassNotFoundException, IOException { - inputStream.defaultReadObject(); - initialize(); - - while (true) { - long key = inputStream.readLong(); - V value = (V) inputStream.readObject(); - if (key == EMPTY_KEY && value == null) { - break; - } - - put(key, value); - } - } - - - private class ValueIterator implements Iterator { - private int count; - private int index; - private int innerIndex; - private int expectedModCount; - private long lastReturned = EMPTY_KEY; - - long prevKey = EMPTY_KEY; - V prevValue; - - ValueIterator() { - expectedModCount = LongObjectHashMap.this.modCount; - } - - public boolean hasNext() { - return count < LongObjectHashMap.this.size; - } - - public void remove() { - if (LongObjectHashMap.this.modCount != expectedModCount) { - throw new ConcurrentModificationException(); - } - - if (lastReturned == EMPTY_KEY) { - throw new IllegalStateException(); - } - - count--; - LongObjectHashMap.this.remove(lastReturned); - lastReturned = EMPTY_KEY; - expectedModCount = LongObjectHashMap.this.modCount; - } - - public V next() { - if (LongObjectHashMap.this.modCount != expectedModCount) { - throw new ConcurrentModificationException(); - } - - if (!hasNext()) { - throw new NoSuchElementException(); - } - - long[][] keys = LongObjectHashMap.this.keys; - count++; - - if (prevKey != EMPTY_KEY) { - innerIndex++; - } - - for (; index < keys.length; index++) { - if (keys[index] != null) { - for (; innerIndex < keys[index].length; innerIndex++) { - long key = keys[index][innerIndex]; - V value = values[index][innerIndex]; - if (key == EMPTY_KEY) { - break; - } - - lastReturned = key; - prevKey = key; - prevValue = value; - return prevValue; - } - innerIndex = 0; - } - } - - throw new NoSuchElementException(); - } - } - - private class KeyIterator implements Iterator { - final ValueIterator iterator; - - public KeyIterator() { - iterator = new ValueIterator(); - } - - public void remove() { - iterator.remove(); - } - - public boolean hasNext() { - return iterator.hasNext(); - } - - public Long next() { - iterator.next(); - return iterator.prevKey; - } - } - - - private class KeySet extends AbstractSet { - public void clear() { - LongObjectHashMap.this.clear(); - } - - public int size() { - return LongObjectHashMap.this.size(); - } - - public boolean contains(Object key) { - return key instanceof Long && LongObjectHashMap.this.containsKey((Long) key); - - } - - public boolean remove(Object key) { - return LongObjectHashMap.this.remove((Long) key) != null; - } - - public Iterator iterator() { - return new KeyIterator(); - } - } - - - private class ValueCollection extends AbstractCollection { - public void clear() { - LongObjectHashMap.this.clear(); - } - - public int size() { - return LongObjectHashMap.this.size(); - } - - public boolean contains(Object value) { - return LongObjectHashMap.this.containsValue((V) value); - } - - public Iterator iterator() { - return new ValueIterator(); - } - } - - - private class Entry implements Map.Entry { - private final Long key; - private V value; - - Entry(long k, V v) { - key = k; - value = v; - } - - public Long getKey() { - return key; - } - - public V getValue() { - return value; - } - - public V setValue(V v) { - V old = value; - value = v; - put(key, v); - return old; - } - } -} diff --git a/src/main/java/org/bukkit/craftbukkit/util/MojangNameLookup.java b/src/main/java/org/bukkit/craftbukkit/util/MojangNameLookup.java deleted file mode 100644 index 93a8f0bd70..0000000000 --- a/src/main/java/org/bukkit/craftbukkit/util/MojangNameLookup.java +++ /dev/null @@ -1,63 +0,0 @@ -package org.bukkit.craftbukkit.util; - -import com.google.common.base.Charsets; -import com.google.gson.Gson; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import java.io.IOException; -import java.io.InputStream; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLConnection; -import java.util.UUID; -import org.apache.commons.io.IOUtils; - -public class MojangNameLookup { - private static final Logger logger = LogManager.getFormatterLogger(MojangNameLookup.class); - - public static String lookupName(UUID id) { - if (id == null) { - return null; - } - - InputStream inputStream = null; - try { - URL url = new URL("https://sessionserver.mojang.com/session/minecraft/profile/" + id.toString().replace("-", "")); - URLConnection connection = url.openConnection(); - connection.setConnectTimeout(15000); - connection.setReadTimeout(15000); - connection.setUseCaches(false); - inputStream = connection.getInputStream(); - String result = IOUtils.toString(inputStream, Charsets.UTF_8); - Gson gson = new Gson(); - Response response = gson.fromJson(result, Response.class); - if (response == null || response.name == null) { - logger.warn("Failed to lookup name from UUID"); - return null; - } - - if (response.cause != null && response.cause.length() > 0) { - logger.warn("Failed to lookup name from UUID: %s", response.errorMessage); - return null; - } - - return response.name; - } catch (MalformedURLException ex) { - logger.warn("Malformed URL in UUID lookup"); - return null; - } catch (IOException ex) { - IOUtils.closeQuietly(inputStream); - } finally { - IOUtils.closeQuietly(inputStream); - } - - return null; - } - - private class Response { - String errorMessage; - String cause; - String name; - } -} diff --git a/src/main/java/org/bukkit/craftbukkit/util/ServerShutdownThread.java b/src/main/java/org/bukkit/craftbukkit/util/ServerShutdownThread.java index ae3481ba88..2e057fd4c0 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/ServerShutdownThread.java +++ b/src/main/java/org/bukkit/craftbukkit/util/ServerShutdownThread.java @@ -1,6 +1,5 @@ package org.bukkit.craftbukkit.util; -import net.minecraft.server.ExceptionWorldConflict; import net.minecraft.server.MinecraftServer; public class ServerShutdownThread extends Thread { @@ -13,9 +12,7 @@ public class ServerShutdownThread extends Thread { @Override public void run() { try { - server.stop(); - } catch (ExceptionWorldConflict ex) { - ex.printStackTrace(); + server.close(); } finally { try { server.reader.getTerminal().restore(); diff --git a/src/main/java/org/bukkit/craftbukkit/util/ShortConsoleLogFormatter.java b/src/main/java/org/bukkit/craftbukkit/util/ShortConsoleLogFormatter.java deleted file mode 100644 index 2dbfef963c..0000000000 --- a/src/main/java/org/bukkit/craftbukkit/util/ShortConsoleLogFormatter.java +++ /dev/null @@ -1,61 +0,0 @@ -package org.bukkit.craftbukkit.util; - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.text.SimpleDateFormat; -import java.util.logging.Formatter; -import java.util.logging.LogRecord; -import joptsimple.OptionException; -import joptsimple.OptionSet; -import net.minecraft.server.MinecraftServer; - -public class ShortConsoleLogFormatter extends Formatter { - private final SimpleDateFormat date; - - public ShortConsoleLogFormatter(MinecraftServer server) { - OptionSet options = server.options; - SimpleDateFormat date = null; - - if (options.has("date-format")) { - try { - Object object = options.valueOf("date-format"); - - if ((object != null) && (object instanceof SimpleDateFormat)) { - date = (SimpleDateFormat) object; - } - } catch (OptionException ex) { - System.err.println("Given date format is not valid. Falling back to default."); - } - } else if (options.has("nojline")) { - date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - } - - if (date == null) { - date = new SimpleDateFormat("HH:mm:ss"); - } - - this.date = date; - } - - @Override - public String format(LogRecord record) { - StringBuilder builder = new StringBuilder(); - Throwable ex = record.getThrown(); - - builder.append(date.format(record.getMillis())); - builder.append(" ["); - builder.append(record.getLevel().getLocalizedName().toUpperCase()); - builder.append("] "); - builder.append(formatMessage(record)); - builder.append('\n'); - - if (ex != null) { - StringWriter writer = new StringWriter(); - ex.printStackTrace(new PrintWriter(writer)); - builder.append(writer); - } - - return builder.toString(); - } - -} diff --git a/src/main/java/org/bukkit/craftbukkit/util/TerminalConsoleWriterThread.java b/src/main/java/org/bukkit/craftbukkit/util/TerminalConsoleWriterThread.java index b640971130..27bfe616ab 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/TerminalConsoleWriterThread.java +++ b/src/main/java/org/bukkit/craftbukkit/util/TerminalConsoleWriterThread.java @@ -10,13 +10,15 @@ import org.bukkit.craftbukkit.Main; import org.fusesource.jansi.Ansi; import org.fusesource.jansi.Ansi.Erase; -public class TerminalConsoleWriterThread implements Runnable { +public class TerminalConsoleWriterThread extends Thread { final private ConsoleReader reader; final private OutputStream output; public TerminalConsoleWriterThread(OutputStream output, ConsoleReader reader) { this.output = output; this.reader = reader; + + this.setDaemon(true); } public void run() { diff --git a/src/main/resources/configurations/bukkit.yml b/src/main/resources/configurations/bukkit.yml index 301e28b2cf..e75ad475b7 100644 --- a/src/main/resources/configurations/bukkit.yml +++ b/src/main/resources/configurations/bukkit.yml @@ -27,9 +27,6 @@ spawn-limits: animals: 10 water-animals: 15 ambient: 15 -chunk-gc: - period-in-ticks: 600 - load-threshold: 0 ticks-per: animal-spawns: 400 monster-spawns: 1 diff --git a/src/main/resources/log4j2.xml b/src/main/resources/log4j2.xml index 4a5ca1ebd2..d997ef583f 100644 --- a/src/main/resources/log4j2.xml +++ b/src/main/resources/log4j2.xml @@ -3,7 +3,7 @@ - + diff --git a/src/test/java/org/bukkit/ArtTest.java b/src/test/java/org/bukkit/ArtTest.java index e6888dec53..1eab951037 100644 --- a/src/test/java/org/bukkit/ArtTest.java +++ b/src/test/java/org/bukkit/ArtTest.java @@ -29,8 +29,8 @@ public class ArtTest extends AbstractTestingBase { for (MinecraftKey key : IRegistry.MOTIVE.keySet()) { Paintings enumArt = IRegistry.MOTIVE.get(key); String name = key.getKey(); - int width = enumArt.b() / UNIT_MULTIPLIER; - int height = enumArt.c() / UNIT_MULTIPLIER; + int width = enumArt.getWidth() / UNIT_MULTIPLIER; + int height = enumArt.getHeight() / UNIT_MULTIPLIER; Art subject = CraftArt.NotchToBukkit(enumArt); @@ -60,7 +60,7 @@ public class ArtTest extends AbstractTestingBase { @Test public void testCraftArtToBukkit() { Map cache = new EnumMap(Art.class); - for (Paintings enumArt : (Iterable) IRegistry.MOTIVE) { // Eclipse fail + for (Paintings enumArt : IRegistry.MOTIVE) { Art art = CraftArt.NotchToBukkit(enumArt); assertNotNull("Could not CraftArt.NotchToBukkit " + enumArt, art); assertThat("Duplicate artwork " + enumArt, cache.put(art, enumArt), is(nullValue())); diff --git a/src/test/java/org/bukkit/LegacyTest.java b/src/test/java/org/bukkit/LegacyTest.java index b441d40d9d..6099364c20 100644 --- a/src/test/java/org/bukkit/LegacyTest.java +++ b/src/test/java/org/bukkit/LegacyTest.java @@ -34,6 +34,18 @@ public class LegacyTest extends AbstractTestingBase { Material.TUBE_CORAL_WALL_FAN, Material.BRAIN_CORAL_WALL_FAN, Material.BUBBLE_CORAL_WALL_FAN, Material.FIRE_CORAL_WALL_FAN, Material.HORN_CORAL_WALL_FAN, Material.DEAD_TUBE_CORAL_WALL_FAN, Material.DEAD_BRAIN_CORAL_WALL_FAN, Material.DEAD_BUBBLE_CORAL_WALL_FAN, Material.DEAD_FIRE_CORAL_WALL_FAN, Material.DEAD_HORN_CORAL_WALL_FAN, Material.DEAD_TUBE_CORAL_FAN, Material.DEAD_BRAIN_CORAL_FAN, Material.DEAD_BUBBLE_CORAL_FAN, Material.DEAD_FIRE_CORAL_FAN, Material.DEAD_HORN_CORAL_FAN, Material.DEAD_BRAIN_CORAL, Material.DEAD_BUBBLE_CORAL, Material.DEAD_FIRE_CORAL, Material.DEAD_HORN_CORAL, Material.DEAD_TUBE_CORAL, + // 1.14 + Material.ACACIA_SIGN, Material.ACACIA_WALL_SIGN, Material.ANDESITE_SLAB, Material.ANDESITE_STAIRS, Material.ANDESITE_WALL, Material.BAMBOO, Material.BAMBOO_SAPLING, Material.BARREL, Material.BELL, Material.BIRCH_SIGN, Material.BIRCH_WALL_SIGN, + Material.BLACK_DYE, Material.BLAST_FURNACE, Material.BLUE_DYE, Material.BRICK_WALL, Material.BROWN_DYE, Material.CAMPFIRE, Material.CARTOGRAPHY_TABLE, Material.CAT_SPAWN_EGG, Material.CORNFLOWER, Material.CREEPER_BANNER_PATTERN, Material.CROSSBOW, + Material.DARK_OAK_SIGN, Material.DARK_OAK_WALL_SIGN, Material.DIORITE_SLAB, Material.DIORITE_STAIRS, Material.DIORITE_WALL, Material.END_STONE_BRICK_SLAB, Material.END_STONE_BRICK_STAIRS, Material.END_STONE_BRICK_WALL, Material.FLETCHING_TABLE, + Material.FLOWER_BANNER_PATTERN, Material.GRANITE_SLAB, Material.GRANITE_STAIRS, Material.GRANITE_WALL, Material.GREEN_DYE, Material.GRINDSTONE, Material.RAVAGER_SPAWN_EGG, Material.JIGSAW, Material.JUNGLE_SIGN, Material.JUNGLE_WALL_SIGN, + Material.LANTERN, Material.LECTERN, Material.LILY_OF_THE_VALLEY, Material.LOOM, Material.MOJANG_BANNER_PATTERN, Material.MOSSY_COBBLESTONE_SLAB, Material.MOSSY_COBBLESTONE_STAIRS, Material.MOSSY_STONE_BRICK_SLAB, Material.MOSSY_STONE_BRICK_STAIRS, + Material.MOSSY_STONE_BRICK_WALL, Material.NETHER_BRICK_WALL, Material.OAK_SIGN, Material.OAK_WALL_SIGN, Material.PANDA_SPAWN_EGG, Material.PILLAGER_SPAWN_EGG, Material.POLISHED_ANDESITE_SLAB, Material.POLISHED_ANDESITE_STAIRS, Material.POLISHED_DIORITE_SLAB, + Material.POLISHED_DIORITE_STAIRS, Material.POLISHED_GRANITE_SLAB, Material.POLISHED_GRANITE_STAIRS, Material.POTTED_BAMBOO, Material.POTTED_CORNFLOWER, Material.POTTED_LILY_OF_THE_VALLEY, Material.POTTED_WITHER_ROSE, Material.PRISMARINE_WALL, Material.RED_DYE, + Material.RED_NETHER_BRICK_SLAB, Material.RED_NETHER_BRICK_STAIRS, Material.RED_NETHER_BRICK_WALL, Material.RED_SANDSTONE_WALL, Material.SANDSTONE_WALL, Material.SCAFFOLDING, Material.SKULL_BANNER_PATTERN, Material.SMITHING_TABLE, Material.SMOKER, + Material.SMOOTH_QUARTZ_SLAB, Material.SMOOTH_QUARTZ_STAIRS, Material.SMOOTH_RED_SANDSTONE_SLAB, Material.SMOOTH_RED_SANDSTONE_STAIRS, Material.SMOOTH_SANDSTONE_SLAB, Material.SMOOTH_SANDSTONE_STAIRS, Material.SMOOTH_STONE_SLAB, Material.SPRUCE_SIGN, + Material.SPRUCE_WALL_SIGN, Material.STONECUTTER, Material.STONE_BRICK_WALL, Material.STONE_STAIRS, Material.SUSPICIOUS_STEW, Material.SWEET_BERRIES, Material.SWEET_BERRY_BUSH, Material.WHITE_DYE, Material.WITHER_ROSE, Material.YELLOW_DYE, + Material.COMPOSTER, Material.TRADER_LLAMA_SPAWN_EGG, Material.WANDERING_TRADER_SPAWN_EGG, Material.FOX_SPAWN_EGG, Material.LEATHER_HORSE_ARMOR, Material.GLOBE_BANNER_PATTERN, Material.CUT_RED_SANDSTONE_SLAB, Material.CUT_SANDSTONE_SLAB, // Material.LEGACY_AIR, Material.LEGACY_DEAD_BUSH, Material.LEGACY_BURNING_FURNACE, Material.LEGACY_WALL_SIGN, Material.LEGACY_REDSTONE_TORCH_OFF, Material.LEGACY_SKULL, Material.LEGACY_REDSTONE_COMPARATOR_ON, Material.LEGACY_WALL_BANNER, Material.LEGACY_MONSTER_EGG)); diff --git a/src/test/java/org/bukkit/ParticleTest.java b/src/test/java/org/bukkit/ParticleTest.java index 829dfa112e..33701c812b 100644 --- a/src/test/java/org/bukkit/ParticleTest.java +++ b/src/test/java/org/bukkit/ParticleTest.java @@ -28,8 +28,8 @@ public class ParticleTest extends AbstractTestingBase { Assert.assertNotNull("Missing Bukkit->NMS particle mapping for " + bukkit, CraftParticle.toNMS(bukkit, data)); } - for (net.minecraft.server.Particle nms : (Iterable>) IRegistry.PARTICLE_TYPE) { // Eclipse fail - Assert.assertNotNull("Missing NMS->Bukkit particle mapping for " + nms, CraftParticle.toBukkit(nms)); + for (net.minecraft.server.Particle nms : IRegistry.PARTICLE_TYPE) { + Assert.assertNotNull("Missing NMS->Bukkit particle mapping for " + IRegistry.PARTICLE_TYPE.getKey(nms), CraftParticle.toBukkit(nms)); } } } diff --git a/src/test/java/org/bukkit/PerMaterialTest.java b/src/test/java/org/bukkit/PerMaterialTest.java index 7967c4c398..34b388b855 100644 --- a/src/test/java/org/bukkit/PerMaterialTest.java +++ b/src/test/java/org/bukkit/PerMaterialTest.java @@ -8,7 +8,6 @@ import java.util.List; import net.minecraft.server.BlockFalling; import net.minecraft.server.BlockFire; import net.minecraft.server.Item; -import net.minecraft.server.ItemFood; import net.minecraft.server.ItemRecord; import net.minecraft.server.TileEntityFurnace; @@ -26,12 +25,14 @@ import org.junit.runners.Parameterized.Parameters; import com.google.common.collect.Lists; import java.util.Map; import net.minecraft.server.Block; +import net.minecraft.server.BlockAccessAir; import net.minecraft.server.BlockPosition; import net.minecraft.server.Blocks; import net.minecraft.server.EntityHuman; import net.minecraft.server.EnumDirection; import net.minecraft.server.EnumHand; import net.minecraft.server.IBlockData; +import net.minecraft.server.MovingObjectPositionBlock; import org.bukkit.craftbukkit.util.CraftMagicNumbers; import org.bukkit.enchantments.EnchantmentTarget; @@ -77,7 +78,11 @@ public class PerMaterialTest extends AbstractTestingBase { @Test public void isEdible() { - assertThat(material.isEdible(), is(CraftMagicNumbers.getItem(material) instanceof ItemFood)); + if (material.isBlock()) { + assertFalse(material.isEdible()); + } else { + assertThat(material.isEdible(), is(CraftMagicNumbers.getItem(material).isFood())); + } } @Test @@ -153,7 +158,7 @@ public class PerMaterialTest extends AbstractTestingBase { @Test public void isOccluding() { if (material.isBlock()) { - assertThat(material.isOccluding(), is(CraftMagicNumbers.getBlock(material).isOccluding(CraftMagicNumbers.getBlock(material).getBlockData()))); + assertThat(material.isOccluding(), is(CraftMagicNumbers.getBlock(material).isOccluding(CraftMagicNumbers.getBlock(material).getBlockData(), BlockAccessAir.INSTANCE, BlockPosition.ZERO))); } else { assertFalse(material.isOccluding()); } @@ -209,7 +214,7 @@ public class PerMaterialTest extends AbstractTestingBase { if (material.isBlock()) { assertThat(material.isInteractable(), is(!CraftMagicNumbers.getBlock(material).getClass() - .getMethod("interact", IBlockData.class, net.minecraft.server.World.class, BlockPosition.class, EntityHuman.class, EnumHand.class, EnumDirection.class, float.class, float.class, float.class) + .getMethod("interact", IBlockData.class, net.minecraft.server.World.class, BlockPosition.class, EntityHuman.class, EnumHand.class, MovingObjectPositionBlock.class) .getDeclaringClass().equals(Block.class))); } else { assertFalse(material.isInteractable()); diff --git a/src/test/java/org/bukkit/StatisticsAndAchievementsTest.java b/src/test/java/org/bukkit/StatisticsAndAchievementsTest.java index 4edbc126cf..574e3b69b7 100644 --- a/src/test/java/org/bukkit/StatisticsAndAchievementsTest.java +++ b/src/test/java/org/bukkit/StatisticsAndAchievementsTest.java @@ -34,7 +34,7 @@ public class StatisticsAndAchievementsTest extends AbstractTestingBase { @SuppressWarnings("unchecked") public void verifyStatisticMapping() throws Throwable { HashMultiset statistics = HashMultiset.create(); - for (StatisticWrapper wrapper : (Iterable>) IRegistry.STATS) { // Eclipse fail + for (StatisticWrapper wrapper : IRegistry.STATS) { for (Object child : wrapper.a()) { net.minecraft.server.Statistic statistic = wrapper.b(child); String message = String.format("org.bukkit.Statistic is missing: '%s'", statistic); @@ -43,7 +43,7 @@ public class StatisticsAndAchievementsTest extends AbstractTestingBase { assertThat(message, subject, is(not(nullValue()))); if (wrapper.a() == IRegistry.BLOCK || wrapper.a() == IRegistry.ITEM) { - assertNotNull("Material type map missing for " + child, CraftStatistic.getMaterialFromStatistic(statistic)); + assertNotNull("Material type map missing for " + wrapper.a().getKey(child), CraftStatistic.getMaterialFromStatistic(statistic)); } else if (wrapper.a() == IRegistry.ENTITY_TYPE) { assertNotNull("Entity type map missing for " + EntityTypes.getName((EntityTypes) child), CraftStatistic.getEntityTypeFromStatistic((net.minecraft.server.Statistic>) statistic)); } diff --git a/src/test/java/org/bukkit/StructureTypeTest.java b/src/test/java/org/bukkit/StructureTypeTest.java index ad1c7a4d7d..f25e13c08a 100644 --- a/src/test/java/org/bukkit/StructureTypeTest.java +++ b/src/test/java/org/bukkit/StructureTypeTest.java @@ -1,7 +1,8 @@ package org.bukkit; import java.util.Map; -import net.minecraft.server.WorldGenFactory; +import net.minecraft.server.IRegistry; +import net.minecraft.server.MinecraftKey; import org.bukkit.support.AbstractTestingBase; import org.junit.Assert; import org.junit.BeforeClass; @@ -22,24 +23,24 @@ public class StructureTypeTest extends AbstractTestingBase { @Test public void testMinecraftToBukkit() { - for (String key : WorldGenFactory.structureStartMap.keySet()) { - Assert.assertNotNull(structures.get(key)); + for (MinecraftKey key : IRegistry.STRUCTURE_FEATURE.keySet()) { + Assert.assertNotNull(key.getKey(), structures.get(key.getKey())); } } @Test public void testBukkit() { for (Map.Entry entry : structures.entrySet()) { - Assert.assertNotNull(StructureType.getStructureTypes().get(entry.getKey())); - Assert.assertNotNull(StructureType.getStructureTypes().get(entry.getValue().getName())); + Assert.assertNotNull(entry.getKey(), StructureType.getStructureTypes().get(entry.getKey())); + Assert.assertNotNull(entry.getValue().getName(), StructureType.getStructureTypes().get(entry.getValue().getName())); } } @Test public void testBukkitToMinecraft() { for (Map.Entry entry : structures.entrySet()) { - Assert.assertNotNull(WorldGenFactory.structureStartMap.get(entry.getKey())); - Assert.assertNotNull(WorldGenFactory.structureStartMap.get(entry.getValue().getName())); + Assert.assertNotNull(entry.getKey(), IRegistry.STRUCTURE_FEATURE.get(new MinecraftKey(entry.getKey()))); + Assert.assertNotNull(entry.getValue().getName(), IRegistry.STRUCTURE_FEATURE.get(new MinecraftKey(entry.getValue().getName()))); } } } diff --git a/src/test/java/org/bukkit/craftbukkit/inventory/InventoryWrapperTest.java b/src/test/java/org/bukkit/craftbukkit/inventory/InventoryWrapperTest.java index 9448c18826..64c3a7fa9c 100644 --- a/src/test/java/org/bukkit/craftbukkit/inventory/InventoryWrapperTest.java +++ b/src/test/java/org/bukkit/craftbukkit/inventory/InventoryWrapperTest.java @@ -10,7 +10,7 @@ public class InventoryWrapperTest { @Test public void test() { - Inventory raw = new CraftInventoryCustom(null, 9); + Inventory raw = new CraftInventoryCustom(null, 27); raw.addItem(new ItemStack(Material.STONE)); Assert.assertTrue(raw.contains(Material.STONE)); diff --git a/src/test/java/org/bukkit/craftbukkit/inventory/ItemFactoryTest.java b/src/test/java/org/bukkit/craftbukkit/inventory/ItemFactoryTest.java index 18f3e1ff65..f91e393271 100644 --- a/src/test/java/org/bukkit/craftbukkit/inventory/ItemFactoryTest.java +++ b/src/test/java/org/bukkit/craftbukkit/inventory/ItemFactoryTest.java @@ -10,8 +10,8 @@ import java.util.HashSet; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; -import net.minecraft.server.IAnimal; import net.minecraft.server.IAttribute; +import net.minecraft.server.IDynamicTexture; import org.bukkit.support.AbstractTestingBase; import org.junit.Test; @@ -20,7 +20,7 @@ public class ItemFactoryTest extends AbstractTestingBase { @Test public void testKnownAttributes() throws Throwable { - final ZipInputStream nmsZipStream = new ZipInputStream(IAnimal.class/* Magic class that isn't imported! */.getProtectionDomain().getCodeSource().getLocation().openStream()); + final ZipInputStream nmsZipStream = new ZipInputStream(IDynamicTexture.class/* Magic class that isn't imported! */.getProtectionDomain().getCodeSource().getLocation().openStream()); final Collection names = new HashSet(); for (ZipEntry clazzEntry; (clazzEntry = nmsZipStream.getNextEntry()) != null; ) { final String entryName = clazzEntry.getName(); diff --git a/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java b/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java index 5a2de14fa5..88e8165af2 100644 --- a/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java +++ b/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java @@ -27,6 +27,7 @@ import org.bukkit.attribute.Attribute; import org.bukkit.attribute.AttributeModifier; import org.bukkit.block.banner.Pattern; import org.bukkit.block.banner.PatternType; +import org.bukkit.craftbukkit.block.data.CraftBlockData; import org.bukkit.craftbukkit.inventory.ItemStackTest.StackProvider; import org.bukkit.craftbukkit.inventory.ItemStackTest.StackWrapper; import org.bukkit.craftbukkit.inventory.ItemStackTest.BukkitWrapper; @@ -36,6 +37,7 @@ import org.bukkit.entity.EntityType; import org.bukkit.entity.TropicalFish; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.BannerMeta; +import org.bukkit.inventory.meta.BlockDataMeta; import org.bukkit.inventory.meta.BlockStateMeta; import org.bukkit.inventory.meta.BookMeta; import org.bukkit.inventory.meta.EnchantmentStorageMeta; @@ -188,7 +190,7 @@ public class ItemMetaTest extends AbstractTestingBase { public void testBlockStateMeta() { List queue = new ArrayList<>(); - for (Item item : (Iterable) IRegistry.ITEM) { // Eclipse fail + for (Item item : IRegistry.ITEM) { if (item instanceof ItemBlock) { queue.add(((ItemBlock) item).getBlock()); } @@ -370,6 +372,13 @@ public class ItemMetaTest extends AbstractTestingBase { assertThat(itemMeta2.equals(notEqualMeta2), is(false)); } + @Test + public void testBlockData() { + BlockDataMeta itemMeta = (BlockDataMeta) Bukkit.getItemFactory().getItemMeta(Material.CHEST); + itemMeta.setBlockData(CraftBlockData.newData(null, "minecraft:chest[waterlogged=true]")); + assertThat(itemMeta.getBlockData(Material.CHEST), is(CraftBlockData.newData(null, "minecraft:chest[waterlogged=true]"))); + } + private void downCastTest(final StackWrapper provider) { final String name = provider.toString(); final ItemStack blank = new ItemStack(Material.STONE); diff --git a/src/test/java/org/bukkit/entity/EntityTypesTest.java b/src/test/java/org/bukkit/entity/EntityTypesTest.java index 465bc9735e..07d978c74b 100644 --- a/src/test/java/org/bukkit/entity/EntityTypesTest.java +++ b/src/test/java/org/bukkit/entity/EntityTypesTest.java @@ -16,8 +16,7 @@ public class EntityTypesTest extends AbstractTestingBase { public void testMaps() { Set allBukkit = Arrays.stream(EntityType.values()).filter((b) -> b.getName() != null).collect(Collectors.toSet()); - for (Object o : IRegistry.ENTITY_TYPE) { - EntityTypes nms = (EntityTypes) o; // Eclipse fail + for (EntityTypes nms : IRegistry.ENTITY_TYPE) { MinecraftKey key = EntityTypes.getName(nms); EntityType bukkit = EntityType.fromName(key.getKey()); diff --git a/src/test/java/org/bukkit/entity/PandaGeneTest.java b/src/test/java/org/bukkit/entity/PandaGeneTest.java new file mode 100644 index 0000000000..5505e14905 --- /dev/null +++ b/src/test/java/org/bukkit/entity/PandaGeneTest.java @@ -0,0 +1,31 @@ +package org.bukkit.entity; + +import net.minecraft.server.EntityPanda; +import org.bukkit.craftbukkit.entity.CraftPanda; +import org.junit.Assert; +import org.junit.Test; + +public class PandaGeneTest { + + @Test + public void testBukkit() { + for (Panda.Gene gene : Panda.Gene.values()) { + EntityPanda.Gene nms = CraftPanda.toNms(gene); + + Assert.assertNotNull("NMS gene null for " + gene, nms); + Assert.assertEquals("Recessive status did not match " + gene, gene.isRecessive(), nms.isRecessive()); + Assert.assertEquals("Gene did not convert back " + gene, gene, CraftPanda.fromNms(nms)); + } + } + + @Test + public void testNMS() { + for (EntityPanda.Gene gene : EntityPanda.Gene.values()) { + Panda.Gene bukkit = CraftPanda.fromNms(gene); + + Assert.assertNotNull("Bukkit gene null for " + gene, bukkit); + Assert.assertEquals("Recessive status did not match " + gene, gene.isRecessive(), bukkit.isRecessive()); + Assert.assertEquals("Gene did not convert back " + gene, gene, CraftPanda.toNms(bukkit)); + } + } +} diff --git a/src/test/java/org/bukkit/support/AbstractTestingBase.java b/src/test/java/org/bukkit/support/AbstractTestingBase.java index 53cbb525e4..f135d88005 100644 --- a/src/test/java/org/bukkit/support/AbstractTestingBase.java +++ b/src/test/java/org/bukkit/support/AbstractTestingBase.java @@ -1,14 +1,17 @@ package org.bukkit.support; import com.google.common.collect.ImmutableList; +import com.google.common.util.concurrent.MoreExecutors; import java.util.Collections; import java.util.List; +import java.util.concurrent.CompletableFuture; import net.minecraft.server.DispenserRegistry; import net.minecraft.server.EnumResourcePackType; import net.minecraft.server.LootTableRegistry; import net.minecraft.server.ResourceManager; import net.minecraft.server.ResourcePackVanilla; import net.minecraft.server.TagRegistry; +import net.minecraft.server.Unit; import org.bukkit.Material; import org.bukkit.craftbukkit.util.CraftMagicNumbers; import org.junit.Assert; @@ -29,14 +32,14 @@ public abstract class AbstractTestingBase { public static final TagRegistry TAG_REGISTRY; static { - DispenserRegistry.c(); + DispenserRegistry.init(); // Set up resource manager - ResourceManager resourceManager = new ResourceManager(EnumResourcePackType.SERVER_DATA); + ResourceManager resourceManager = new ResourceManager(EnumResourcePackType.SERVER_DATA, Thread.currentThread()); // add tags and loot tables for unit tests resourceManager.a(TAG_REGISTRY = new TagRegistry()); resourceManager.a(LOOT_TABLE_REGISTRY = new LootTableRegistry()); // Register vanilla pack - resourceManager.a(Collections.singletonList(new ResourcePackVanilla("minecraft"))); + resourceManager.a(MoreExecutors.directExecutor(), MoreExecutors.directExecutor(), Collections.singletonList(new ResourcePackVanilla("minecraft")), CompletableFuture.completedFuture(Unit.INSTANCE)).join(); DummyServer.setup(); DummyEnchantments.setup(); @@ -48,6 +51,6 @@ public abstract class AbstractTestingBase { } } INVALIDATED_MATERIALS = builder.build(); - Assert.assertEquals("Expected 543 invalidated materials (got " + INVALIDATED_MATERIALS.size() + ")", 543, INVALIDATED_MATERIALS.size()); + Assert.assertEquals("Expected 554 invalidated materials (got " + INVALIDATED_MATERIALS.size() + ")", 554, INVALIDATED_MATERIALS.size()); } }