From 7e0a66fdd53caa2397423926a15710a7650a72a0 Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Sun, 15 Jul 2018 10:00:00 +1000 Subject: [PATCH] Update to Minecraft 1.13-pre7 By: md_5 --- paper-server/.gitignore | 1 + paper-server/nms-patches/Advancement.patch | 11 +- .../nms-patches/AdvancementDataPlayer.patch | 55 +- .../nms-patches/AdvancementRewards.patch | 52 -- paper-server/nms-patches/Advancements.patch | 6 +- paper-server/nms-patches/Block.patch | 61 +- .../nms-patches/BlockButtonAbstract.patch | 76 +- paper-server/nms-patches/BlockCactus.patch | 25 +- paper-server/nms-patches/BlockCake.patch | 4 +- paper-server/nms-patches/BlockCauldron.patch | 70 +- .../nms-patches/BlockChorusFlower.patch | 75 +- paper-server/nms-patches/BlockCocoa.patch | 26 +- paper-server/nms-patches/BlockCommand.patch | 4 +- .../nms-patches/BlockConcretePowder.patch | 48 +- paper-server/nms-patches/BlockCrops.patch | 20 +- .../nms-patches/BlockDaylightDetector.patch | 6 +- .../nms-patches/BlockDiodeAbstract.patch | 22 +- .../nms-patches/BlockDirtSnowSpreadable.patch | 23 + paper-server/nms-patches/BlockDispenser.patch | 22 +- paper-server/nms-patches/BlockDoor.patch | 47 +- paper-server/nms-patches/BlockDragonEgg.patch | 41 +- paper-server/nms-patches/BlockDropper.patch | 56 +- .../nms-patches/BlockEnderPortal.patch | 14 +- paper-server/nms-patches/BlockFire.patch | 158 ++-- paper-server/nms-patches/BlockFlowing.patch | 66 -- paper-server/nms-patches/BlockFluids.patch | 30 +- paper-server/nms-patches/BlockGrass.patch | 72 +- paper-server/nms-patches/BlockIce.patch | 8 +- paper-server/nms-patches/BlockJukeBox.patch | 14 - paper-server/nms-patches/BlockLeaves.patch | 34 +- paper-server/nms-patches/BlockLever.patch | 17 +- paper-server/nms-patches/BlockMagma.patch | 2 +- .../nms-patches/BlockMinecartDetector.patch | 8 +- .../nms-patches/BlockMobSpawner.patch | 10 +- .../nms-patches/BlockMonsterEggs.patch | 8 +- paper-server/nms-patches/BlockMushroom.patch | 38 +- paper-server/nms-patches/BlockMycel.patch | 58 -- .../nms-patches/BlockNetherWart.patch | 9 +- paper-server/nms-patches/BlockNote.patch | 46 ++ paper-server/nms-patches/BlockOre.patch | 18 +- paper-server/nms-patches/BlockPiston.patch | 51 +- paper-server/nms-patches/BlockPlant.patch | 24 +- paper-server/nms-patches/BlockPortal.patch | 80 +- .../nms-patches/BlockPoweredRail.patch | 19 +- .../BlockPressurePlateAbstract.patch | 8 +- .../BlockPressurePlateBinary.patch | 2 +- .../BlockPressurePlateWeighted.patch | 6 +- paper-server/nms-patches/BlockPumpkin.patch | 81 -- .../nms-patches/BlockPumpkinCarved.patch | 65 ++ .../nms-patches/BlockRedstoneLamp.patch | 59 +- .../nms-patches/BlockRedstoneOre.patch | 71 +- .../nms-patches/BlockRedstoneTorch.patch | 39 +- .../nms-patches/BlockRedstoneWire.patch | 8 +- paper-server/nms-patches/BlockReed.patch | 21 +- paper-server/nms-patches/BlockSapling.patch | 135 +--- .../nms-patches/BlockShulkerBox.patch | 65 +- paper-server/nms-patches/BlockSkull.patch | 123 --- .../nms-patches/BlockSkullAbstract.patch | 45 ++ paper-server/nms-patches/BlockSnow.patch | 8 +- paper-server/nms-patches/BlockSnowBlock.patch | 8 +- paper-server/nms-patches/BlockSoil.patch | 23 +- .../nms-patches/BlockStateInteger.patch | 18 + .../nms-patches/BlockStationary.patch | 40 - paper-server/nms-patches/BlockStem.patch | 44 +- paper-server/nms-patches/BlockTNT.patch | 6 +- paper-server/nms-patches/BlockTallPlant.patch | 20 +- paper-server/nms-patches/BlockTrapdoor.patch | 14 +- paper-server/nms-patches/BlockTripwire.patch | 8 +- .../nms-patches/BlockTripwireHook.patch | 6 +- paper-server/nms-patches/BlockVine.patch | 102 ++- paper-server/nms-patches/BlockWaterLily.patch | 8 +- .../nms-patches/BlockWitherSkull.patch | 66 ++ .../nms-patches/ChatBaseComponent.patch | 11 - paper-server/nms-patches/ChatModifier.patch | 45 -- paper-server/nms-patches/Chunk.patch | 167 ++-- paper-server/nms-patches/ChunkMap.patch | 88 +++ .../nms-patches/ChunkProviderGenerate.patch | 13 +- .../nms-patches/ChunkProviderServer.patch | 136 +--- .../nms-patches/ChunkRegionLoader.patch | 290 ++++--- paper-server/nms-patches/ChunkSection.patch | 36 +- .../CommandBlockListenerAbstract.patch | 214 +----- paper-server/nms-patches/CommandDebug.patch | 46 +- .../nms-patches/CommandDispatcher.patch | 189 +++++ paper-server/nms-patches/CommandExecute.patch | 58 -- .../nms-patches/CommandGamemode.patch | 43 +- .../nms-patches/CommandGamerule.patch | 23 - .../nms-patches/CommandListenerWrapper.patch | 46 ++ .../nms-patches/CommandSpreadPlayers.patch | 42 +- .../nms-patches/CommandTeleport.patch | 27 +- paper-server/nms-patches/CommandTp.patch | 45 -- paper-server/nms-patches/Container.patch | 10 +- paper-server/nms-patches/ContainerAnvil.patch | 24 +- .../nms-patches/ContainerEnchantTable.patch | 42 +- .../nms-patches/ContainerFurnace.patch | 15 +- .../nms-patches/ContainerPlayer.patch | 30 +- .../nms-patches/ContainerWorkbench.patch | 10 +- .../nms-patches/CraftingManager.patch | 43 +- paper-server/nms-patches/CrashReport.patch | 6 +- paper-server/nms-patches/CustomFunction.patch | 22 +- .../nms-patches/CustomFunctionData.patch | 65 +- paper-server/nms-patches/DamageSource.patch | 6 +- .../nms-patches/DataConverterFlatten.patch | 11 + .../nms-patches/DataConverterMap.patch | 20 + .../DataInspectorBlockEntity.patch | 12 - .../nms-patches/DataPaletteBlock.patch | 25 - paper-server/nms-patches/DataWatcher.patch | 14 + .../nms-patches/DedicatedServer.patch | 111 ++- .../nms-patches/DispenseBehaviorItem.patch | 7 +- .../DispenseBehaviorProjectile.patch | 2 +- .../nms-patches/DispenserRegistry.patch | 388 +++++----- paper-server/nms-patches/Enchantment.patch | 35 +- .../nms-patches/EnchantmentFrostWalker.patch | 12 +- .../nms-patches/EnchantmentThorns.patch | 2 +- paper-server/nms-patches/Entity.patch | 215 +++--- paper-server/nms-patches/EntityAgeable.patch | 36 +- paper-server/nms-patches/EntityAnimal.patch | 18 +- .../nms-patches/EntityAreaEffectCloud.patch | 16 +- .../nms-patches/EntityArmorStand.patch | 76 +- paper-server/nms-patches/EntityArrow.patch | 72 +- paper-server/nms-patches/EntityBoat.patch | 58 +- paper-server/nms-patches/EntityChicken.patch | 22 +- paper-server/nms-patches/EntityCow.patch | 2 +- paper-server/nms-patches/EntityCreature.patch | 13 +- paper-server/nms-patches/EntityCreeper.patch | 33 +- .../EntityDamageSourceIndirect.patch | 2 +- paper-server/nms-patches/EntityEgg.patch | 2 +- .../nms-patches/EntityEnderCrystal.patch | 8 +- .../nms-patches/EntityEnderDragon.patch | 25 +- .../nms-patches/EntityEnderPearl.patch | 2 +- .../nms-patches/EntityEnderSignal.patch | 19 - paper-server/nms-patches/EntityEnderman.patch | 43 +- .../nms-patches/EntityEvokerFangs.patch | 2 +- .../nms-patches/EntityExperienceOrb.patch | 27 +- .../nms-patches/EntityFallingBlock.patch | 22 +- paper-server/nms-patches/EntityFireball.patch | 21 +- .../nms-patches/EntityFireworks.patch | 14 +- .../nms-patches/EntityFishingHook.patch | 54 +- paper-server/nms-patches/EntityGhast.patch | 2 +- paper-server/nms-patches/EntityHanging.patch | 14 +- .../nms-patches/EntityHorseAbstract.patch | 50 +- .../EntityHorseChestedAbstract.patch | 2 +- paper-server/nms-patches/EntityHuman.patch | 100 +-- .../nms-patches/EntityInsentient.patch | 77 +- .../nms-patches/EntityIronGolem.patch | 17 +- paper-server/nms-patches/EntityItem.patch | 48 +- .../nms-patches/EntityItemFrame.patch | 6 +- .../nms-patches/EntityLargeFireball.patch | 6 +- paper-server/nms-patches/EntityLeash.patch | 2 +- .../nms-patches/EntityLightning.patch | 90 +-- paper-server/nms-patches/EntityLiving.patch | 143 ++-- .../nms-patches/EntityLlamaSpit.patch | 2 +- .../nms-patches/EntityMinecartAbstract.patch | 58 +- .../EntityMinecartCommandBlock.patch | 21 +- .../nms-patches/EntityMinecartContainer.patch | 8 +- paper-server/nms-patches/EntityMonster.patch | 26 - .../nms-patches/EntityMushroomCow.patch | 4 +- paper-server/nms-patches/EntityOcelot.patch | 10 +- paper-server/nms-patches/EntityPainting.patch | 9 +- paper-server/nms-patches/EntityParrot.patch | 97 +-- paper-server/nms-patches/EntityPhantom.patch | 20 + paper-server/nms-patches/EntityPig.patch | 14 +- paper-server/nms-patches/EntityPlayer.patch | 425 +++++----- paper-server/nms-patches/EntityPotion.patch | 14 +- .../nms-patches/EntityProjectile.patch | 12 +- paper-server/nms-patches/EntityRabbit.patch | 16 +- paper-server/nms-patches/EntitySheep.patch | 43 +- paper-server/nms-patches/EntityShulker.patch | 15 +- .../nms-patches/EntityShulkerBullet.patch | 12 +- .../nms-patches/EntitySilverfish.patch | 16 +- paper-server/nms-patches/EntitySkeleton.patch | 6 +- .../nms-patches/EntitySkeletonAbstract.patch | 38 +- .../nms-patches/EntitySkeletonWither.patch | 6 +- paper-server/nms-patches/EntitySlime.patch | 9 + .../nms-patches/EntitySmallFireball.patch | 12 +- paper-server/nms-patches/EntitySnowman.patch | 14 +- paper-server/nms-patches/EntitySpider.patch | 2 +- .../nms-patches/EntityTNTPrimed.patch | 6 +- .../nms-patches/EntityThrownExpBottle.patch | 2 +- paper-server/nms-patches/EntityTracker.patch | 15 - .../nms-patches/EntityTrackerEntry.patch | 2 +- paper-server/nms-patches/EntityTypes.patch | 39 + paper-server/nms-patches/EntityVex.patch | 2 +- paper-server/nms-patches/EntityVillager.patch | 39 +- paper-server/nms-patches/EntityWither.patch | 20 +- .../nms-patches/EntityWitherSkull.patch | 6 +- paper-server/nms-patches/EntityWolf.patch | 28 +- paper-server/nms-patches/EntityZombie.patch | 56 +- .../nms-patches/EntityZombieVillager.patch | 16 +- .../nms-patches/ExpirableListEntry.patch | 4 +- paper-server/nms-patches/Explosion.patch | 36 +- .../nms-patches/FluidTypeFlowing.patch | 46 ++ paper-server/nms-patches/FluidTypeLava.patch | 44 ++ paper-server/nms-patches/FoodMetaData.patch | 2 +- paper-server/nms-patches/FurnaceRecipe.patch | 44 ++ .../nms-patches/HandshakeListener.patch | 4 +- .../nms-patches/ICommandListener.patch | 9 + paper-server/nms-patches/IDataManager.patch | 6 +- paper-server/nms-patches/IInventory.patch | 15 +- paper-server/nms-patches/IRecipe.patch | 10 +- paper-server/nms-patches/IWorldWriter.patch | 11 + .../nms-patches/InventoryCraftResult.patch | 4 +- .../nms-patches/InventoryCrafting.patch | 20 +- .../nms-patches/InventoryEnderChest.patch | 2 +- .../nms-patches/InventoryHorseChest.patch | 8 +- .../nms-patches/InventoryLargeChest.patch | 13 +- .../nms-patches/InventoryMerchant.patch | 8 +- .../nms-patches/InventorySubcontainer.patch | 22 +- paper-server/nms-patches/ItemArmor.patch | 12 +- paper-server/nms-patches/ItemBlock.patch | 32 +- paper-server/nms-patches/ItemBoat.patch | 14 +- paper-server/nms-patches/ItemBow.patch | 24 +- paper-server/nms-patches/ItemBucket.patch | 87 +-- .../nms-patches/ItemChorusFruit.patch | 4 +- paper-server/nms-patches/ItemDye.patch | 20 +- paper-server/nms-patches/ItemEnderPearl.patch | 6 +- paper-server/nms-patches/ItemFireball.patch | 28 +- paper-server/nms-patches/ItemFishingRod.patch | 35 +- .../nms-patches/ItemFlintAndSteel.patch | 26 +- paper-server/nms-patches/ItemHanging.patch | 6 +- paper-server/nms-patches/ItemLeash.patch | 4 +- paper-server/nms-patches/ItemMinecart.patch | 4 +- paper-server/nms-patches/ItemMonsterEgg.patch | 30 - paper-server/nms-patches/ItemRecord.patch | 10 +- paper-server/nms-patches/ItemRedstone.patch | 11 - paper-server/nms-patches/ItemReed.patch | 11 - ...{ItemSkull.patch => ItemSkullPlayer.patch} | 6 +- paper-server/nms-patches/ItemSnowball.patch | 8 +- paper-server/nms-patches/ItemStack.patch | 390 ++++------ paper-server/nms-patches/ItemWaterLily.patch | 12 +- paper-server/nms-patches/ItemWorldMap.patch | 139 ++-- .../nms-patches/ItemWrittenBook.patch | 54 +- paper-server/nms-patches/JsonList.patch | 29 +- paper-server/nms-patches/LoginListener.patch | 39 +- paper-server/nms-patches/MethodProfiler.patch | 66 +- .../nms-patches/MinecraftServer.patch | 532 +++++++------ paper-server/nms-patches/MobEffectList.patch | 29 +- .../nms-patches/MobSpawnerAbstract.patch | 40 +- .../NameReferencingFileConverter.patch | 14 +- paper-server/nms-patches/NetworkManager.patch | 31 +- .../nms-patches/PacketDataSerializer.patch | 4 +- .../nms-patches/PacketStatusListener.patch | 2 +- .../nms-patches/PathfinderGoalBreakDoor.patch | 6 +- .../nms-patches/PathfinderGoalBreed.patch | 12 +- .../nms-patches/PathfinderGoalEatTile.patch | 33 +- .../PathfinderGoalFollowOwner.patch | 14 +- .../nms-patches/PathfinderGoalHorseTrap.patch | 2 +- .../PathfinderGoalHurtByTarget.patch | 2 +- .../nms-patches/PathfinderGoalMakeLove.patch | 16 +- ...athfinderGoalNearestAttackableTarget.patch | 17 +- ...oalNearestAttackableTargetInsentient.patch | 2 +- .../nms-patches/PathfinderGoalPanic.patch | 2 +- .../nms-patches/PathfinderGoalSit.patch | 2 +- .../PathfinderGoalTargetNearestPlayer.patch | 2 +- .../nms-patches/PathfinderGoalTempt.patch | 14 +- .../PathfinderGoalVillagerFarm.patch | 14 +- paper-server/nms-patches/PlayerChunk.patch | 72 +- paper-server/nms-patches/PlayerChunkMap.patch | 41 +- .../nms-patches/PlayerConnection.patch | 726 ++++++++---------- .../nms-patches/PlayerInteractManager.patch | 228 +++--- .../nms-patches/PlayerInventory.patch | 16 +- paper-server/nms-patches/PlayerList.patch | 258 +++---- .../nms-patches/PortalTravelAgent.patch | 37 +- paper-server/nms-patches/RecipeArmorDye.patch | 16 +- .../nms-patches/RecipeBannerAdd.patch | 18 + .../nms-patches/RecipeBannerDuplicate.patch | 17 + .../nms-patches/RecipeBookClone.patch | 17 +- .../nms-patches/RecipeFireworks.patch | 21 +- .../nms-patches/RecipeFireworksFade.patch | 20 + .../nms-patches/RecipeFireworksStar.patch | 30 + paper-server/nms-patches/RecipeMapClone.patch | 16 +- paper-server/nms-patches/RecipeRepair.patch | 46 +- .../nms-patches/RecipeShulkerBox.patch | 25 +- .../nms-patches/RecipeTippedArrow.patch | 16 +- paper-server/nms-patches/RecipesBanner.patch | 37 - paper-server/nms-patches/RecipesFurnace.patch | 80 -- paper-server/nms-patches/RecipiesShield.patch | 25 +- .../nms-patches/RegionFileCache.patch | 5 +- .../RegionLimitedWorldAccess.patch | 30 + .../RemoteControlCommandListener.patch | 11 +- .../nms-patches/ScoreboardServer.patch | 51 +- paper-server/nms-patches/ScoreboardTeam.patch | 47 ++ .../nms-patches/SecondaryWorldServer.patch | 12 +- paper-server/nms-patches/ShapedRecipes.patch | 44 +- .../nms-patches/ShapelessRecipes.patch | 45 +- .../nms-patches/SlotFurnaceResult.patch | 40 +- .../nms-patches/SpawnerCreature.patch | 82 +- .../nms-patches/StatisticManager.patch | 6 +- paper-server/nms-patches/TickListServer.patch | 111 +++ paper-server/nms-patches/TileEntity.patch | 30 +- .../nms-patches/TileEntityBanner.patch | 12 +- .../nms-patches/TileEntityBeacon.patch | 30 +- .../nms-patches/TileEntityBrewingStand.patch | 26 +- .../nms-patches/TileEntityChest.patch | 82 +- .../nms-patches/TileEntityCommand.patch | 20 +- .../nms-patches/TileEntityContainer.patch | 6 +- .../nms-patches/TileEntityDispenser.patch | 6 +- .../nms-patches/TileEntityEndGateway.patch | 6 +- .../nms-patches/TileEntityFurnace.patch | 70 +- .../nms-patches/TileEntityHopper.patch | 40 +- .../nms-patches/TileEntityJukeBox.patch | 14 + paper-server/nms-patches/TileEntityNote.patch | 16 - .../nms-patches/TileEntityShulkerBox.patch | 20 +- paper-server/nms-patches/TileEntitySign.patch | 63 +- .../nms-patches/TileEntitySkull.patch | 23 + .../nms-patches/TileEntityStructure.patch | 36 - paper-server/nms-patches/UserCache.patch | 2 +- paper-server/nms-patches/Village.patch | 16 +- paper-server/nms-patches/World.patch | 293 +++---- paper-server/nms-patches/WorldData.patch | 38 +- .../nms-patches/WorldGenGroundBush.patch | 2 +- .../WorldGenMegaTreeAbstract.patch | 11 - .../nms-patches/WorldGenRegistration.patch | 11 - .../nms-patches/WorldGenTreeProvider.patch | 40 + .../nms-patches/WorldGenVillagePieces.patch | 46 +- .../nms-patches/WorldGenWitchHut.patch | 11 + paper-server/nms-patches/WorldMap.patch | 28 +- .../nms-patches/WorldNBTStorage.patch | 23 +- .../nms-patches/WorldProviderHell.patch | 2 +- paper-server/nms-patches/WorldServer.patch | 406 ++++------ paper-server/pom.xml | 38 +- .../mojang/brigadier/tree/CommandNode.java | 200 +++++ .../java/org/bukkit/craftbukkit/CraftArt.java | 85 +- .../org/bukkit/craftbukkit/CraftChunk.java | 69 +- .../craftbukkit/CraftChunkSnapshot.java | 35 +- .../bukkit/craftbukkit/CraftCrashReport.java | 4 +- .../org/bukkit/craftbukkit/CraftEffect.java | 7 +- .../craftbukkit/CraftOfflinePlayer.java | 5 +- .../org/bukkit/craftbukkit/CraftParticle.java | 148 +++- .../org/bukkit/craftbukkit/CraftServer.java | 179 +++-- .../org/bukkit/craftbukkit/CraftSound.java | 383 +++++---- .../bukkit/craftbukkit/CraftStatistic.java | 177 +++-- .../org/bukkit/craftbukkit/CraftWorld.java | 121 +-- .../java/org/bukkit/craftbukkit/Main.java | 12 +- .../bukkit/craftbukkit/block/CraftBanner.java | 4 +- .../bukkit/craftbukkit/block/CraftBeacon.java | 5 +- .../bukkit/craftbukkit/block/CraftBed.java | 57 +- .../bukkit/craftbukkit/block/CraftBlock.java | 277 ++++--- .../block/CraftBlockEntityState.java | 9 +- .../craftbukkit/block/CraftBlockState.java | 92 ++- .../craftbukkit/block/CraftBrewingStand.java | 5 +- .../bukkit/craftbukkit/block/CraftChest.java | 30 +- .../craftbukkit/block/CraftCommandBlock.java | 5 +- .../craftbukkit/block/CraftConduit.java | 17 + .../block/CraftCreatureSpawner.java | 3 +- .../block/CraftEnchantingTable.java | 5 +- .../craftbukkit/block/CraftFlowerPot.java | 46 -- .../craftbukkit/block/CraftFurnace.java | 5 +- .../craftbukkit/block/CraftJukebox.java | 17 +- .../craftbukkit/block/CraftLootable.java | 5 +- .../craftbukkit/block/CraftNoteBlock.java | 83 -- .../bukkit/craftbukkit/block/CraftSkull.java | 150 +--- .../block/CraftStructureBlock.java | 55 +- .../craftbukkit/block/data/CraftAgeable.java | 23 + .../block/data/CraftAnaloguePowerable.java | 23 + .../block/data/CraftAttachable.java | 18 + .../craftbukkit/block/data/CraftBisected.java | 18 + .../block/data/CraftBlockData.java | 356 +++++++++ .../block/data/CraftDirectional.java | 23 + .../craftbukkit/block/data/CraftLevelled.java | 23 + .../block/data/CraftLightable.java | 18 + .../block/data/CraftMultipleFacing.java | 46 ++ .../craftbukkit/block/data/CraftOpenable.java | 18 + .../block/data/CraftOrientable.java | 23 + .../block/data/CraftPowerable.java | 18 + .../craftbukkit/block/data/CraftRail.java | 23 + .../block/data/CraftRotatable.java | 107 +++ .../craftbukkit/block/data/CraftSnowable.java | 18 + .../block/data/CraftWaterlogged.java | 19 + .../craftbukkit/block/data/type/CraftBed.java | 25 + .../block/data/type/CraftBrewingStand.java | 39 + .../block/data/type/CraftBubbleColumn.java | 19 + .../block/data/type/CraftCake.java | 24 + .../block/data/type/CraftChest.java | 19 + .../block/data/type/CraftCommandBlock.java | 19 + .../block/data/type/CraftComparator.java | 19 + .../data/type/CraftDaylightDetector.java | 19 + .../block/data/type/CraftDispenser.java | 19 + .../block/data/type/CraftDoor.java | 19 + .../block/data/type/CraftEndPortalFrame.java | 19 + .../block/data/type/CraftFarmland.java | 24 + .../block/data/type/CraftGate.java | 19 + .../block/data/type/CraftHopper.java | 19 + .../block/data/type/CraftJukebox.java | 14 + .../block/data/type/CraftLeaves.java | 30 + .../block/data/type/CraftNoteBlock.java | 30 + .../block/data/type/CraftPiston.java | 19 + .../block/data/type/CraftPistonHead.java | 19 + .../block/data/type/CraftRedstoneWire.java | 49 ++ .../block/data/type/CraftRepeater.java | 40 + .../block/data/type/CraftSapling.java | 24 + .../block/data/type/CraftSeaPickle.java | 29 + .../block/data/type/CraftSlab.java | 19 + .../block/data/type/CraftSnow.java | 29 + .../block/data/type/CraftStairs.java | 19 + .../block/data/type/CraftStructureBlock.java | 19 + .../block/data/type/CraftSwitch.java | 19 + .../block/data/type/CraftTechnicalPiston.java | 19 + .../block/data/type/CraftTripwire.java | 19 + .../block/data/type/CraftTurtleEgg.java | 45 ++ .../craftbukkit/block/impl/CraftAnvil.java | 34 + .../craftbukkit/block/impl/CraftBanner.java | 118 +++ .../block/impl/CraftBannerWall.java | 34 + .../craftbukkit/block/impl/CraftBed.java | 54 ++ .../craftbukkit/block/impl/CraftBeetroot.java | 34 + .../block/impl/CraftBrewingStand.java | 49 ++ .../block/impl/CraftBubbleColumn.java | 29 + .../craftbukkit/block/impl/CraftCactus.java | 34 + .../craftbukkit/block/impl/CraftCake.java | 34 + .../craftbukkit/block/impl/CraftCarrots.java | 34 + .../craftbukkit/block/impl/CraftCauldron.java | 34 + .../craftbukkit/block/impl/CraftChest.java | 62 ++ .../block/impl/CraftChestTrapped.java | 62 ++ .../block/impl/CraftChorusFlower.java | 34 + .../block/impl/CraftChorusFruit.java | 57 ++ .../block/impl/CraftCobbleWall.java | 71 ++ .../craftbukkit/block/impl/CraftCocoa.java | 53 ++ .../craftbukkit/block/impl/CraftCommand.java | 48 ++ .../craftbukkit/block/impl/CraftCoralFan.java | 34 + .../craftbukkit/block/impl/CraftCrops.java | 34 + .../block/impl/CraftDaylightDetector.java | 48 ++ .../craftbukkit/block/impl/CraftDirtSnow.java | 29 + .../block/impl/CraftDispenser.java | 48 ++ .../craftbukkit/block/impl/CraftDoor.java | 90 +++ .../craftbukkit/block/impl/CraftDropper.java | 48 ++ .../craftbukkit/block/impl/CraftEndRod.java | 34 + .../block/impl/CraftEnderChest.java | 48 ++ .../block/impl/CraftEnderPortalFrame.java | 48 ++ .../craftbukkit/block/impl/CraftFence.java | 71 ++ .../block/impl/CraftFenceGate.java | 76 ++ .../craftbukkit/block/impl/CraftFire.java | 76 ++ .../block/impl/CraftFloorSign.java | 132 ++++ .../craftbukkit/block/impl/CraftFluids.java | 34 + .../craftbukkit/block/impl/CraftFurnace.java | 48 ++ .../block/impl/CraftGlassPane.java | 71 ++ .../block/impl/CraftGlazedTerracotta.java | 34 + .../craftbukkit/block/impl/CraftGrass.java | 29 + .../craftbukkit/block/impl/CraftHay.java | 34 + .../craftbukkit/block/impl/CraftHopper.java | 48 ++ .../block/impl/CraftHugeMushroom.java | 57 ++ .../craftbukkit/block/impl/CraftIceFrost.java | 34 + .../craftbukkit/block/impl/CraftIronBars.java | 71 ++ .../craftbukkit/block/impl/CraftJukeBox.java | 24 + .../craftbukkit/block/impl/CraftKelp.java | 34 + .../craftbukkit/block/impl/CraftLadder.java | 48 ++ .../craftbukkit/block/impl/CraftLeaves.java | 40 + .../craftbukkit/block/impl/CraftLever.java | 62 ++ .../block/impl/CraftLogAbstract.java | 34 + .../block/impl/CraftMinecartDetector.java | 48 ++ .../block/impl/CraftMinecartTrack.java | 34 + .../craftbukkit/block/impl/CraftMycel.java | 29 + .../block/impl/CraftNetherWart.java | 34 + .../craftbukkit/block/impl/CraftNote.java | 54 ++ .../craftbukkit/block/impl/CraftObserver.java | 48 ++ .../craftbukkit/block/impl/CraftPiston.java | 48 ++ .../block/impl/CraftPistonExtension.java | 62 ++ .../block/impl/CraftPistonMoving.java | 48 ++ .../craftbukkit/block/impl/CraftPortal.java | 34 + .../craftbukkit/block/impl/CraftPotatoes.java | 34 + .../block/impl/CraftPoweredRail.java | 48 ++ .../block/impl/CraftPressurePlateBinary.java | 29 + .../impl/CraftPressurePlateWeighted.java | 34 + .../block/impl/CraftPumpkinCarved.java | 34 + .../block/impl/CraftRedstoneComparator.java | 62 ++ .../block/impl/CraftRedstoneLamp.java | 29 + .../block/impl/CraftRedstoneOre.java | 29 + .../block/impl/CraftRedstoneTorch.java | 29 + .../block/impl/CraftRedstoneTorchWall.java | 48 ++ .../block/impl/CraftRedstoneWire.java | 78 ++ .../craftbukkit/block/impl/CraftReed.java | 34 + .../craftbukkit/block/impl/CraftRepeater.java | 83 ++ .../block/impl/CraftRotatable.java | 34 + .../craftbukkit/block/impl/CraftSapling.java | 34 + .../block/impl/CraftSeaPickle.java | 53 ++ .../block/impl/CraftShulkerBox.java | 34 + .../craftbukkit/block/impl/CraftSkull.java | 118 +++ .../block/impl/CraftSkullPlayer.java | 118 +++ .../block/impl/CraftSkullPlayerWall.java | 34 + .../block/impl/CraftSkullWall.java | 34 + .../craftbukkit/block/impl/CraftSnow.java | 39 + .../craftbukkit/block/impl/CraftSoil.java | 34 + .../block/impl/CraftStainedGlassPane.java | 71 ++ .../craftbukkit/block/impl/CraftStairs.java | 76 ++ .../craftbukkit/block/impl/CraftStem.java | 34 + .../block/impl/CraftStemAttached.java | 34 + .../block/impl/CraftStepAbstract.java | 43 ++ .../block/impl/CraftStoneButton.java | 62 ++ .../block/impl/CraftStructure.java | 29 + .../block/impl/CraftTallPlantFlower.java | 29 + .../block/impl/CraftTallPlantShearable.java | 29 + .../block/impl/CraftTallSeaGrass.java | 29 + .../block/impl/CraftTorchWall.java | 34 + .../craftbukkit/block/impl/CraftTrapdoor.java | 90 +++ .../craftbukkit/block/impl/CraftTripwire.java | 99 +++ .../block/impl/CraftTripwireHook.java | 62 ++ .../block/impl/CraftTurtleEgg.java | 55 ++ .../craftbukkit/block/impl/CraftVine.java | 57 ++ .../craftbukkit/block/impl/CraftWallSign.java | 48 ++ .../block/impl/CraftWitherSkull.java | 118 +++ .../block/impl/CraftWitherSkullWall.java | 34 + .../block/impl/CraftWoodButton.java | 62 ++ .../bukkit/craftbukkit/boss/CraftBossBar.java | 2 +- .../craftbukkit/chunkio/ChunkIOProvider.java | 12 +- .../command/BukkitCommandWrapper.java | 56 ++ .../command/CraftBlockCommandSender.java | 14 +- .../craftbukkit/command/CraftCommandMap.java | 17 + .../command/CraftFunctionCommandSender.java | 47 -- .../command/ProxiedNativeCommandSender.java | 8 +- .../command/VanillaCommandWrapper.java | 169 +--- .../enchantments/CraftEnchantment.java | 62 +- .../bukkit/craftbukkit/entity/CraftArrow.java | 2 +- .../bukkit/craftbukkit/entity/CraftCod.java | 28 + .../craftbukkit/entity/CraftDolphin.java | 28 + .../craftbukkit/entity/CraftDrowned.java | 28 + .../craftbukkit/entity/CraftEnderSignal.java | 10 +- .../craftbukkit/entity/CraftEnderman.java | 18 +- .../craftbukkit/entity/CraftEntity.java | 34 +- .../craftbukkit/entity/CraftFallingBlock.java | 12 +- .../craftbukkit/entity/CraftFirework.java | 6 +- .../bukkit/craftbukkit/entity/CraftFish.java | 53 +- .../craftbukkit/entity/CraftFishHook.java | 65 ++ .../craftbukkit/entity/CraftHumanEntity.java | 10 +- .../craftbukkit/entity/CraftLivingEntity.java | 4 + .../craftbukkit/entity/CraftMinecart.java | 24 +- .../entity/CraftMinecartCommand.java | 5 +- .../craftbukkit/entity/CraftPainting.java | 6 +- .../craftbukkit/entity/CraftPhantom.java | 38 + .../craftbukkit/entity/CraftPlayer.java | 95 ++- .../craftbukkit/entity/CraftProjectile.java | 6 +- .../craftbukkit/entity/CraftPufferFish.java | 38 + .../craftbukkit/entity/CraftSalmon.java | 28 + .../craftbukkit/entity/CraftTrident.java | 28 + .../craftbukkit/entity/CraftTropicalFish.java | 111 +++ .../craftbukkit/entity/CraftTurtle.java | 28 + .../craftbukkit/entity/CraftVillager.java | 8 +- .../craftbukkit/event/CraftEventFactory.java | 125 +-- .../craftbukkit/generator/CraftChunkData.java | 133 ++-- .../generator/CustomChunkGenerator.java | 258 +++---- .../generator/InternalChunkGenerator.java | 4 +- .../generator/NormalChunkGenerator.java | 98 ++- .../inventory/CraftFurnaceRecipe.java | 17 +- .../craftbukkit/inventory/CraftInventory.java | 67 +- .../inventory/CraftInventoryCrafting.java | 5 +- .../inventory/CraftInventoryCustom.java | 16 +- .../inventory/CraftInventoryDoubleChest.java | 3 +- .../inventory/CraftInventoryPlayer.java | 17 - .../inventory/CraftItemFactory.java | 127 ++- .../craftbukkit/inventory/CraftItemStack.java | 178 +++-- .../inventory/CraftMerchantCustom.java | 4 +- .../inventory/CraftMetaBanner.java | 40 +- .../inventory/CraftMetaBlockState.java | 186 +++-- .../craftbukkit/inventory/CraftMetaBook.java | 2 +- .../inventory/CraftMetaBookSigned.java | 2 +- .../inventory/CraftMetaCharge.java | 2 +- .../inventory/CraftMetaFirework.java | 2 +- .../craftbukkit/inventory/CraftMetaItem.java | 97 ++- .../craftbukkit/inventory/CraftMetaMap.java | 2 +- .../inventory/CraftMetaPotion.java | 2 +- .../craftbukkit/inventory/CraftMetaSkull.java | 16 +- .../inventory/CraftMetaSpawnEgg.java | 92 ++- .../CraftMetaTropicalFishBucket.java | 168 ++++ .../inventory/CraftShapedRecipe.java | 9 +- .../inventory/CraftShapelessRecipe.java | 9 +- .../inventory/InventoryWrapper.java | 15 +- .../craftbukkit/inventory/RecipeIterator.java | 35 +- .../craftbukkit/map/CraftMapRenderer.java | 2 +- .../bukkit/craftbukkit/map/CraftMapView.java | 2 +- .../potion/CraftPotionEffectType.java | 4 + .../craftbukkit/potion/CraftPotionUtil.java | 6 + .../scoreboard/CraftObjective.java | 4 +- .../scoreboard/CraftScoreboard.java | 10 +- .../scoreboard/CraftScoreboardManager.java | 8 +- .../craftbukkit/scoreboard/CraftTeam.java | 2 +- .../bukkit/craftbukkit/tag/CraftBlockTag.java | 28 + .../bukkit/craftbukkit/tag/CraftItemTag.java | 28 + .../util/BlockStateListPopulator.java | 39 +- .../bukkit/craftbukkit/util/Commodore.java | 268 +++++++ .../craftbukkit/util/CraftChatMessage.java | 18 +- .../bukkit/craftbukkit/util/CraftEvil.java | 80 ++ .../bukkit/craftbukkit/util/CraftLegacy.java | 366 +++++++++ .../craftbukkit/util/CraftMagicNumbers.java | 206 ++--- .../util/DummyGeneratorAccess.java | 254 ++++++ .../util/StructureGrowDelegate.java | 70 -- .../util/permissions/CommandPermissions.java | 2 +- .../src/test/java/org/bukkit/ArtTest.java | 30 +- .../test/java/org/bukkit/BlockDataTest.java | 58 ++ .../test/java/org/bukkit/DyeColorsTest.java | 5 +- .../test/java/org/bukkit/EnchantmentTest.java | 24 + .../src/test/java/org/bukkit/LegacyTest.java | 89 +++ .../test/java/org/bukkit/MaterialTest.java | 8 +- .../test/java/org/bukkit/ParticleTest.java | 25 +- .../test/java/org/bukkit/PerMaterialTest.java | 22 +- .../bukkit/StatisticsAndAchievementsTest.java | 40 +- .../craftbukkit/generator/ChunkDataTest.java | 21 +- .../inventory/CompositeSerialization.java | 29 +- .../inventory/ItemFactoryTest.java | 4 +- .../craftbukkit/inventory/ItemMetaTest.java | 62 +- .../inventory/ItemStackBookTest.java | 2 +- .../ItemStackFireworkChargeTest.java | 2 +- .../inventory/ItemStackFireworkTest.java | 2 +- .../inventory/ItemStackMapTest.java | 2 +- .../inventory/ItemStackSkullTest.java | 2 +- .../inventory/NMSCraftItemStackTest.java | 1 - .../org/bukkit/entity/EntityTypesTest.java | 29 + .../org/bukkit/entity/TropicalFishTest.java | 45 ++ .../src/test/java/org/bukkit/map/MapTest.java | 2 +- .../java/org/bukkit/potion/PotionTest.java | 2 +- .../bukkit/support/AbstractTestingBase.java | 87 +-- .../java/org/bukkit/support/DummyServer.java | 20 + 608 files changed, 17788 insertions(+), 9378 deletions(-) delete mode 100644 paper-server/nms-patches/AdvancementRewards.patch create mode 100644 paper-server/nms-patches/BlockDirtSnowSpreadable.patch delete mode 100644 paper-server/nms-patches/BlockFlowing.patch delete mode 100644 paper-server/nms-patches/BlockJukeBox.patch delete mode 100644 paper-server/nms-patches/BlockMycel.patch create mode 100644 paper-server/nms-patches/BlockNote.patch delete mode 100644 paper-server/nms-patches/BlockPumpkin.patch create mode 100644 paper-server/nms-patches/BlockPumpkinCarved.patch delete mode 100644 paper-server/nms-patches/BlockSkull.patch create mode 100644 paper-server/nms-patches/BlockSkullAbstract.patch create mode 100644 paper-server/nms-patches/BlockStateInteger.patch delete mode 100644 paper-server/nms-patches/BlockStationary.patch create mode 100644 paper-server/nms-patches/BlockWitherSkull.patch delete mode 100644 paper-server/nms-patches/ChatBaseComponent.patch delete mode 100644 paper-server/nms-patches/ChatModifier.patch create mode 100644 paper-server/nms-patches/ChunkMap.patch create mode 100644 paper-server/nms-patches/CommandDispatcher.patch delete mode 100644 paper-server/nms-patches/CommandExecute.patch delete mode 100644 paper-server/nms-patches/CommandGamerule.patch create mode 100644 paper-server/nms-patches/CommandListenerWrapper.patch delete mode 100644 paper-server/nms-patches/CommandTp.patch create mode 100644 paper-server/nms-patches/DataConverterFlatten.patch create mode 100644 paper-server/nms-patches/DataConverterMap.patch delete mode 100644 paper-server/nms-patches/DataInspectorBlockEntity.patch delete mode 100644 paper-server/nms-patches/DataPaletteBlock.patch delete mode 100644 paper-server/nms-patches/EntityEnderSignal.patch delete mode 100644 paper-server/nms-patches/EntityMonster.patch create mode 100644 paper-server/nms-patches/EntityPhantom.patch create mode 100644 paper-server/nms-patches/EntityTypes.patch create mode 100644 paper-server/nms-patches/FluidTypeFlowing.patch create mode 100644 paper-server/nms-patches/FluidTypeLava.patch create mode 100644 paper-server/nms-patches/FurnaceRecipe.patch create mode 100644 paper-server/nms-patches/ICommandListener.patch create mode 100644 paper-server/nms-patches/IWorldWriter.patch delete mode 100644 paper-server/nms-patches/ItemMonsterEgg.patch delete mode 100644 paper-server/nms-patches/ItemRedstone.patch delete mode 100644 paper-server/nms-patches/ItemReed.patch rename paper-server/nms-patches/{ItemSkull.patch => ItemSkullPlayer.patch} (87%) create mode 100644 paper-server/nms-patches/RecipeBannerAdd.patch create mode 100644 paper-server/nms-patches/RecipeBannerDuplicate.patch create mode 100644 paper-server/nms-patches/RecipeFireworksFade.patch create mode 100644 paper-server/nms-patches/RecipeFireworksStar.patch delete mode 100644 paper-server/nms-patches/RecipesBanner.patch delete mode 100644 paper-server/nms-patches/RecipesFurnace.patch create mode 100644 paper-server/nms-patches/RegionLimitedWorldAccess.patch create mode 100644 paper-server/nms-patches/ScoreboardTeam.patch create mode 100644 paper-server/nms-patches/TickListServer.patch create mode 100644 paper-server/nms-patches/TileEntityJukeBox.patch delete mode 100644 paper-server/nms-patches/TileEntityNote.patch create mode 100644 paper-server/nms-patches/TileEntitySkull.patch delete mode 100644 paper-server/nms-patches/TileEntityStructure.patch delete mode 100644 paper-server/nms-patches/WorldGenMegaTreeAbstract.patch delete mode 100644 paper-server/nms-patches/WorldGenRegistration.patch create mode 100644 paper-server/nms-patches/WorldGenTreeProvider.patch create mode 100644 paper-server/nms-patches/WorldGenWitchHut.patch create mode 100644 paper-server/src/main/java/com/mojang/brigadier/tree/CommandNode.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftConduit.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftFlowerPot.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftNoteBlock.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftAgeable.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftAnaloguePowerable.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftAttachable.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftBisected.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftDirectional.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftLevelled.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftLightable.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftMultipleFacing.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftOpenable.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftOrientable.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftPowerable.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftRail.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftRotatable.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftSnowable.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftWaterlogged.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftBed.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftBrewingStand.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftBubbleColumn.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftCake.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftChest.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftCommandBlock.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftComparator.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftDaylightDetector.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftDispenser.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftDoor.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftEndPortalFrame.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftFarmland.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftGate.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftHopper.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftJukebox.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftLeaves.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftNoteBlock.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftPiston.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftPistonHead.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftRedstoneWire.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftRepeater.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftSapling.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftSeaPickle.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftSlab.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftSnow.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftStairs.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftStructureBlock.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftSwitch.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftTechnicalPiston.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftTripwire.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftTurtleEgg.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftAnvil.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftBanner.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftBannerWall.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftBed.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftBeetroot.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftBrewingStand.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftBubbleColumn.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCactus.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCake.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCarrots.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCauldron.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftChest.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftChestTrapped.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftChorusFlower.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftChorusFruit.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCobbleWall.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCocoa.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCommand.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCoralFan.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCrops.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftDaylightDetector.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftDirtSnow.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftDispenser.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftDoor.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftDropper.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftEndRod.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftEnderChest.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftEnderPortalFrame.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftFence.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftFenceGate.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftFire.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftFloorSign.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftFluids.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftFurnace.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftGlassPane.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftGlazedTerracotta.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftGrass.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftHay.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftHopper.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftHugeMushroom.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftIceFrost.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftIronBars.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftJukeBox.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftKelp.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftLadder.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftLeaves.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftLever.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftLogAbstract.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftMinecartDetector.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftMinecartTrack.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftMycel.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftNetherWart.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftNote.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftObserver.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPiston.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPistonExtension.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPistonMoving.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPortal.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPotatoes.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPoweredRail.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPressurePlateBinary.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPressurePlateWeighted.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPumpkinCarved.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftRedstoneComparator.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftRedstoneLamp.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftRedstoneOre.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftRedstoneTorch.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftRedstoneTorchWall.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftRedstoneWire.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftReed.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftRepeater.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftRotatable.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftSapling.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftSeaPickle.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftShulkerBox.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftSkull.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftSkullPlayer.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftSkullPlayerWall.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftSkullWall.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftSnow.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftSoil.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftStainedGlassPane.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftStairs.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftStem.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftStemAttached.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftStepAbstract.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftStoneButton.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftStructure.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTallPlantFlower.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTallPlantShearable.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTallSeaGrass.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTorchWall.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTrapdoor.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTripwire.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTripwireHook.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTurtleEgg.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftVine.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftWallSign.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftWitherSkull.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftWitherSkullWall.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftWoodButton.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/command/BukkitCommandWrapper.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/command/CraftCommandMap.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/command/CraftFunctionCommandSender.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCod.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftDolphin.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftDrowned.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFishHook.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPhantom.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPufferFish.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSalmon.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTrident.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTropicalFish.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTurtle.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaTropicalFishBucket.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/tag/CraftBlockTag.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/tag/CraftItemTag.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/util/Commodore.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftEvil.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftLegacy.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/util/StructureGrowDelegate.java create mode 100644 paper-server/src/test/java/org/bukkit/BlockDataTest.java create mode 100644 paper-server/src/test/java/org/bukkit/EnchantmentTest.java create mode 100644 paper-server/src/test/java/org/bukkit/LegacyTest.java create mode 100644 paper-server/src/test/java/org/bukkit/entity/EntityTypesTest.java create mode 100644 paper-server/src/test/java/org/bukkit/entity/TropicalFishTest.java diff --git a/paper-server/.gitignore b/paper-server/.gitignore index 73c16b1d53..67fb370cad 100644 --- a/paper-server/.gitignore +++ b/paper-server/.gitignore @@ -24,6 +24,7 @@ dependency-reduced-pom.xml /manifest.mf /world +/logs # Mac filesystem dust .DS_Store diff --git a/paper-server/nms-patches/Advancement.patch b/paper-server/nms-patches/Advancement.patch index ba026b62ac..348a517583 100644 --- a/paper-server/nms-patches/Advancement.patch +++ b/paper-server/nms-patches/Advancement.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/Advancement.java +++ b/net/minecraft/server/Advancement.java -@@ -24,6 +24,7 @@ +@@ -27,6 +27,7 @@ private final String[][] f; private final Set g = Sets.newLinkedHashSet(); private final IChatBaseComponent h; @@ -8,3 +8,12 @@ public Advancement(MinecraftKey minecraftkey, @Nullable Advancement advancement, @Nullable AdvancementDisplay advancementdisplay, AdvancementRewards advancementrewards, Map map, String[][] astring) { this.d = minecraftkey; +@@ -206,7 +207,7 @@ + } + + public Advancement b(MinecraftKey minecraftkey) { +- if (!this.a((minecraftkey) -> { ++ if (!this.a((Function) (minecraftkey1) -> { // CraftBukkit - decompile error + return null; + })) { + throw new IllegalStateException("Tried to build incomplete advancement!"); diff --git a/paper-server/nms-patches/AdvancementDataPlayer.patch b/paper-server/nms-patches/AdvancementDataPlayer.patch index 947510a9f7..0cadb6c8ec 100644 --- a/paper-server/nms-patches/AdvancementDataPlayer.patch +++ b/paper-server/nms-patches/AdvancementDataPlayer.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/AdvancementDataPlayer.java +++ b/net/minecraft/server/AdvancementDataPlayer.java -@@ -31,7 +31,7 @@ +@@ -38,7 +38,7 @@ private static final Logger a = LogManager.getLogger(); private static final Gson b = (new GsonBuilder()).registerTypeAdapter(AdvancementProgress.class, new AdvancementProgress.a()).registerTypeAdapter(MinecraftKey.class, new MinecraftKey.a()).setPrettyPrinting().create(); @@ -9,7 +9,7 @@ }; private final MinecraftServer d; private final File e; -@@ -93,7 +93,7 @@ +@@ -100,7 +100,7 @@ Iterator iterator = this.data.entrySet().iterator(); while (iterator.hasNext()) { @@ -18,29 +18,38 @@ if (((AdvancementProgress) entry.getValue()).isDone()) { arraylist.add(entry.getKey()); -@@ -129,7 +129,7 @@ - if (this.e.isFile()) { - try { - String s = Files.toString(this.e, StandardCharsets.UTF_8); -- Map map = (Map) ChatDeserializer.a(AdvancementDataPlayer.b, s, AdvancementDataPlayer.c.getType()); -+ Map map = (Map) ChatDeserializer.a(AdvancementDataPlayer.b, s, AdvancementDataPlayer.c.getType()); // CraftBukkit +@@ -140,7 +140,7 @@ - if (map == null) { - throw new JsonParseException("Found null for advancements"); -@@ -143,7 +143,11 @@ - Advancement advancement = this.d.getAdvancementData().a((MinecraftKey) entry.getKey()); + try { + jsonreader.setLenient(false); +- Dynamic dynamic = new Dynamic(JsonOps.INSTANCE, Streams.parse(jsonreader)); ++ Dynamic dynamic = new Dynamic(JsonOps.INSTANCE, Streams.parse(jsonreader)); // CraftBukkit - decompile error - if (advancement == null) { -- AdvancementDataPlayer.a.warn("Ignored advancement \'" + entry.getKey() + "\' in progress file " + this.e + " - it doesn\'t exist anymore?"); -+ // CraftBukkit start -+ if (((MinecraftKey) entry.getKey()).b().equals("minecraft")) { -+ AdvancementDataPlayer.a.warn("Ignored advancement \'" + entry.getKey() + "\' in progress file " + this.e + " - it doesn\'t exist anymore?"); -+ } -+ // CraftBukkit end - } else { - this.a(advancement, (AdvancementProgress) entry.getValue()); - } -@@ -195,6 +199,7 @@ + if (!dynamic.get("DataVersion").flatMap(Dynamic::getNumberValue).isPresent()) { + dynamic = dynamic.set("DataVersion", dynamic.createInt(1343)); +@@ -148,7 +148,7 @@ + + dynamic = this.d.aB().update(DataFixTypes.ADVANCEMENTS, dynamic, dynamic.getInt("DataVersion"), 1513); + dynamic = dynamic.remove("DataVersion"); +- Map map = (Map) AdvancementDataPlayer.b.getAdapter(AdvancementDataPlayer.c).fromJsonTree((JsonElement) dynamic.getValue()); ++ Map map = (Map) AdvancementDataPlayer.b.getAdapter(AdvancementDataPlayer.c).fromJsonTree((JsonElement) dynamic.getValue()); // CraftBukkit - decompile error + + if (map == null) { + throw new JsonParseException("Found null for advancements"); +@@ -162,7 +162,11 @@ + Advancement advancement = this.d.getAdvancementData().a((MinecraftKey) entry.getKey()); + + if (advancement == null) { +- AdvancementDataPlayer.a.warn("Ignored advancement \'{}\' in progress file {} - it doesn\'t exist anymore?", entry.getKey(), this.e); ++ // CraftBukkit start ++ if (((MinecraftKey) entry.getKey()).b().equals("minecraft")) { ++ AdvancementDataPlayer.a.warn("Ignored advancement \'{}\' in progress file {} - it doesn\'t exist anymore?", entry.getKey(), this.e); ++ } ++ // CraftBukkit end + } else { + this.a(advancement, (AdvancementProgress) entry.getValue()); + } +@@ -231,6 +235,7 @@ this.i.add(advancement); flag = true; if (!flag1 && advancementprogress.isDone()) { diff --git a/paper-server/nms-patches/AdvancementRewards.patch b/paper-server/nms-patches/AdvancementRewards.patch deleted file mode 100644 index 8f0ea2c330..0000000000 --- a/paper-server/nms-patches/AdvancementRewards.patch +++ /dev/null @@ -1,52 +0,0 @@ ---- a/net/minecraft/server/AdvancementRewards.java -+++ b/net/minecraft/server/AdvancementRewards.java -@@ -66,7 +66,24 @@ - CustomFunction customfunction = this.e.a(minecraftserver.aL()); - - if (customfunction != null) { -- ICommandListener icommandlistener = new ICommandListener() { -+ // CraftBukkit start -+ ICommandListener icommandlistener = new AdvancementCommandListener(entityplayer, minecraftserver); -+ -+ minecraftserver.aL().a(customfunction, icommandlistener); -+ } -+ -+ } -+ -+ public static class AdvancementCommandListener implements ICommandListener { -+ -+ private final EntityPlayer entityplayer; -+ private final MinecraftServer minecraftserver; -+ -+ public AdvancementCommandListener(EntityPlayer entityplayer, MinecraftServer minecraftserver) { -+ this.entityplayer = entityplayer; -+ this.minecraftserver = minecraftserver; -+ } -+ - public String getName() { - return entityplayer.getName(); - } -@@ -108,12 +125,8 @@ - public MinecraftServer C_() { - return entityplayer.C_(); - } -- }; -- -- minecraftserver.aL().a(customfunction, icommandlistener); -- } -- -- } -+ } -+ // CraftBukkit end - - public String toString() { - return "AdvancementRewards{experience=" + this.b + ", loot=" + Arrays.toString(this.c) + ", recipes=" + Arrays.toString(this.d) + ", function=" + this.e + '}'; -@@ -156,7 +169,7 @@ - return new AdvancementRewards(i, aminecraftkey, aminecraftkey1, customfunction_a); - } - -- public Object deserialize(JsonElement jsonelement, Type type, JsonDeserializationContext jsondeserializationcontext) throws JsonParseException { -+ public AdvancementRewards deserialize(JsonElement jsonelement, Type type, JsonDeserializationContext jsondeserializationcontext) throws JsonParseException { // CraftBukkit - decompile error - return this.a(jsonelement, type, jsondeserializationcontext); - } - } diff --git a/paper-server/nms-patches/Advancements.patch b/paper-server/nms-patches/Advancements.patch index c6fb5b4cdb..9871ffc707 100644 --- a/paper-server/nms-patches/Advancements.patch +++ b/paper-server/nms-patches/Advancements.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/server/Advancements.java +++ b/net/minecraft/server/Advancements.java -@@ -71,7 +71,7 @@ +@@ -72,7 +72,7 @@ } } -- Advancements.a.info("Loaded " + this.advancements.size() + " advancements"); -+ // Advancements.a.info("Loaded " + this.b.size() + " advancements"); // CraftBukkit - moved to AdvancementDataWorld#reload +- Advancements.a.info("Loaded {} advancements", Integer.valueOf(this.advancements.size())); ++ // Advancements.a.info("Loaded {} advancements", Integer.valueOf(this.advancements.size())); // CraftBukkit - moved to AdvancementDataWorld#reload } public void a() { diff --git a/paper-server/nms-patches/Block.patch b/paper-server/nms-patches/Block.patch index 8060e69d3d..abff3dcd73 100644 --- a/paper-server/nms-patches/Block.patch +++ b/paper-server/nms-patches/Block.patch @@ -1,28 +1,28 @@ --- a/net/minecraft/server/Block.java +++ b/net/minecraft/server/Block.java -@@ -37,7 +37,7 @@ - private String name; - - public static int getId(Block block) { -- return Block.REGISTRY.a((Object) block); -+ return Block.REGISTRY.a(block); // CraftBukkit - decompile error +@@ -213,7 +213,7 @@ } - public static int getCombinedId(IBlockData iblockdata) { -@@ -343,7 +343,8 @@ - int j = this.getDropCount(i, world.random); + public Block(Block.Info block_info) { +- BlockStateList.a blockstatelist_a = new BlockStateList.a(this); ++ BlockStateList.a blockstatelist_a = new BlockStateList.a(this); // CraftBukkit - decompile error + + this.a(blockstatelist_a); + this.blockStateList = blockstatelist_a.a(BlockData::new); +@@ -428,7 +428,8 @@ + int j = this.getDropCount(iblockdata, i, world, blockposition, world.random); for (int k = 0; k < j; ++k) { -- if (world.random.nextFloat() <= f) { +- if (f >= 1.0F || world.random.nextFloat() <= f) { + // CraftBukkit - <= to < to allow for plugins to completely disable block drops from explosions -+ if (world.random.nextFloat() < f) { - Item item = this.getDropType(iblockdata, world.random, i); ++ if (f >= 1.0F || world.random.nextFloat() < f) { + Item item = this.getDropType(iblockdata, world, blockposition, i).getItem(); - if (item != Items.a) { -@@ -364,7 +365,13 @@ + if (item != Items.AIR) { +@@ -449,7 +450,13 @@ EntityItem entityitem = new EntityItem(world, (double) blockposition.getX() + d0, (double) blockposition.getY() + d1, (double) blockposition.getZ() + d2, itemstack); - entityitem.q(); + entityitem.n(); - world.addEntity(entityitem); + // CraftBukkit start + if (world.captureDrops != null) { @@ -34,34 +34,25 @@ } } -@@ -931,7 +938,7 @@ +@@ -668,7 +675,7 @@ + } - if (hashset.contains(block16)) { - for (int i = 0; i < 15; ++i) { -- int j = Block.REGISTRY.a((Object) block16) << 4 | i; -+ int j = Block.REGISTRY.a(block16) << 4 | i; // CraftBukkit - decompile error + public String toString() { +- return "Block{" + Block.REGISTRY.b(this) + "}"; ++ return Block.REGISTRY.b(this).toString(); // CraftBukkit - cheap hack + } - Block.REGISTRY_ID.a(block16.fromLegacyData(i), j); - } -@@ -940,7 +947,7 @@ - - while (unmodifiableiterator.hasNext()) { - IBlockData iblockdata = (IBlockData) unmodifiableiterator.next(); -- int k = Block.REGISTRY.a((Object) block16) << 4 | block16.toLegacyData(iblockdata); -+ int k = Block.REGISTRY.a(block16) << 4 | block16.toLegacyData(iblockdata); // CraftBukkit - decompile error - - Block.REGISTRY_ID.a(iblockdata, k); - } -@@ -949,6 +956,12 @@ + public static boolean c(Block block) { +@@ -1380,6 +1387,12 @@ } + // CraftBukkit start -+ public int getExpDrop(World world, IBlockData data, int enchantmentLevel) { ++ public int getExpDrop(IBlockData iblockdata, World world, BlockPosition blockposition, int enchantmentLevel) { + return 0; + } + // CraftBukkit end + - private static void a(int i, MinecraftKey minecraftkey, Block block) { - Block.REGISTRY.a(i, minecraftkey, block); + private static void a(MinecraftKey minecraftkey, Block block) { + Block.REGISTRY.a(minecraftkey, block); } diff --git a/paper-server/nms-patches/BlockButtonAbstract.patch b/paper-server/nms-patches/BlockButtonAbstract.patch index bf32c8f250..028d1dd1c1 100644 --- a/paper-server/nms-patches/BlockButtonAbstract.patch +++ b/paper-server/nms-patches/BlockButtonAbstract.patch @@ -9,10 +9,10 @@ +import org.bukkit.event.entity.EntityInteractEvent; +// CraftBukkit end + - public abstract class BlockButtonAbstract extends BlockDirectional { + public abstract class BlockButtonAbstract extends BlockAttachable { - public static final BlockStateBoolean POWERED = BlockStateBoolean.of("powered"); -@@ -126,6 +131,19 @@ + public static final BlockStateBoolean POWERED = BlockProperties.t; +@@ -77,6 +82,19 @@ if (((Boolean) iblockdata.get(BlockButtonAbstract.POWERED)).booleanValue()) { return true; } else { @@ -29,27 +29,27 @@ + return true; + } + // CraftBukkit end - world.setTypeAndData(blockposition, iblockdata.set(BlockButtonAbstract.POWERED, Boolean.valueOf(true)), 3); - world.b(blockposition, blockposition); - this.a(entityhuman, world, blockposition); -@@ -167,6 +185,16 @@ - if (this.I) { - this.d(iblockdata, world, blockposition); - } else { -+ // CraftBukkit start -+ org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); + world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockButtonAbstract.POWERED, Boolean.valueOf(true)), 3); + this.a(entityhuman, world, blockposition, true); + this.c(iblockdata, world, blockposition); +@@ -118,6 +136,16 @@ + if (this.F) { + this.b(iblockdata, world, blockposition); + } else { ++ // CraftBukkit start ++ org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); + -+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, 15, 0); -+ world.getServer().getPluginManager().callEvent(eventRedstone); ++ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, 15, 0); ++ world.getServer().getPluginManager().callEvent(eventRedstone); + -+ if (eventRedstone.getNewCurrent() > 0) { -+ return; -+ } -+ // CraftBukkit end - world.setTypeUpdate(blockposition, iblockdata.set(BlockButtonAbstract.POWERED, Boolean.valueOf(false))); - this.c(world, blockposition, (EnumDirection) iblockdata.get(BlockButtonAbstract.FACING)); - this.b(world, blockposition); -@@ -192,7 +220,41 @@ ++ if (eventRedstone.getNewCurrent() > 0) { ++ return; ++ } ++ // CraftBukkit end + world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockButtonAbstract.POWERED, Boolean.valueOf(false)), 3); + this.c(iblockdata, world, blockposition); + this.a((EntityHuman) null, world, blockposition, false); +@@ -137,7 +165,44 @@ boolean flag = !list.isEmpty(); boolean flag1 = ((Boolean) iblockdata.get(BlockButtonAbstract.POWERED)).booleanValue(); @@ -77,34 +77,20 @@ + } + // CraftBukkit end + - if (flag && !flag1) { + if (flag != flag1) { + // CraftBukkit start ++ boolean powered = flag1; + org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); ++ int old = (powered) ? 15 : 0; ++ int current = (!powered) ? 15 : 0; + -+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, 0, 15); ++ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, old, current); + world.getServer().getPluginManager().callEvent(eventRedstone); + -+ if (eventRedstone.getNewCurrent() <= 0) { ++ if ((flag && eventRedstone.getNewCurrent() <= 0) || (!flag && eventRedstone.getNewCurrent() > 0)) { + return; + } + // CraftBukkit end - world.setTypeUpdate(blockposition, iblockdata.set(BlockButtonAbstract.POWERED, Boolean.valueOf(true))); - this.c(world, blockposition, (EnumDirection) iblockdata.get(BlockButtonAbstract.FACING)); - world.b(blockposition, blockposition); -@@ -200,6 +262,16 @@ - } - - if (!flag && flag1) { -+ // CraftBukkit start -+ org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); -+ -+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, 15, 0); -+ world.getServer().getPluginManager().callEvent(eventRedstone); -+ -+ if (eventRedstone.getNewCurrent() > 0) { -+ return; -+ } -+ // CraftBukkit end - world.setTypeUpdate(blockposition, iblockdata.set(BlockButtonAbstract.POWERED, Boolean.valueOf(false))); - this.c(world, blockposition, (EnumDirection) iblockdata.get(BlockButtonAbstract.FACING)); - world.b(blockposition, blockposition); + world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockButtonAbstract.POWERED, Boolean.valueOf(flag)), 3); + this.c(iblockdata, world, blockposition); + this.a((EntityHuman) null, world, blockposition, flag); diff --git a/paper-server/nms-patches/BlockCactus.patch b/paper-server/nms-patches/BlockCactus.patch index 282dcd80f8..9be8a4956b 100644 --- a/paper-server/nms-patches/BlockCactus.patch +++ b/paper-server/nms-patches/BlockCactus.patch @@ -8,26 +8,23 @@ + public class BlockCactus extends Block { - public static final BlockStateInteger AGE = BlockStateInteger.of("age", 0, 15); -@@ -30,9 +32,10 @@ - int j = ((Integer) iblockdata.get(BlockCactus.AGE)).intValue(); + public static final BlockStateInteger AGE = BlockProperties.W; +@@ -31,7 +33,7 @@ + int j = ((Integer) iblockdata.get(BlockCactus.AGE)).intValue(); - if (j == 15) { -- world.setTypeUpdate(blockposition1, this.getBlockData()); -+ // world.setTypeUpdate(blockposition1, this.getBlockData()); // CraftBukkit - IBlockData iblockdata1 = iblockdata.set(BlockCactus.AGE, Integer.valueOf(0)); + if (j == 15) { +- world.setTypeUpdate(blockposition1, this.getBlockData()); ++ CraftEventFactory.handleBlockGrowEvent(world, blockposition1, this.getBlockData()); // CraftBukkit + IBlockData iblockdata1 = (IBlockData) iblockdata.set(BlockCactus.AGE, Integer.valueOf(0)); -+ CraftEventFactory.handleBlockGrowEvent(world, blockposition1.getX(), blockposition1.getY(), blockposition1.getZ(), this, 0); // CraftBukkit - world.setTypeAndData(blockposition, iblockdata1, 4); - iblockdata1.doPhysics(world, blockposition1, this, blockposition); - } else { -@@ -87,7 +90,9 @@ + world.setTypeAndData(blockposition, iblockdata1, 4); +@@ -92,7 +94,9 @@ } - public void a(World world, BlockPosition blockposition, IBlockData iblockdata, Entity entity) { + public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { + CraftEventFactory.blockDamage = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); // CraftBukkit entity.damageEntity(DamageSource.CACTUS, 1.0F); + CraftEventFactory.blockDamage = null; // CraftBukkit } - public IBlockData fromLegacyData(int i) { + public TextureType c() { diff --git a/paper-server/nms-patches/BlockCake.patch b/paper-server/nms-patches/BlockCake.patch index 80b0801d1f..4830491d8b 100644 --- a/paper-server/nms-patches/BlockCake.patch +++ b/paper-server/nms-patches/BlockCake.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/server/BlockCake.java +++ b/net/minecraft/server/BlockCake.java -@@ -40,7 +40,18 @@ +@@ -33,7 +33,18 @@ return false; } else { - entityhuman.b(StatisticList.H); + entityhuman.a(StatisticList.EAT_CAKE_SLICE); - entityhuman.getFoodData().eat(2, 0.1F); + // CraftBukkit start + // entityhuman.getFoodData().eat(2, 0.1F); diff --git a/paper-server/nms-patches/BlockCauldron.patch b/paper-server/nms-patches/BlockCauldron.patch index 4ba652e41c..9b862840ff 100644 --- a/paper-server/nms-patches/BlockCauldron.patch +++ b/paper-server/nms-patches/BlockCauldron.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/server/BlockCauldron.java +++ b/net/minecraft/server/BlockCauldron.java -@@ -3,6 +3,7 @@ - import java.util.List; - import java.util.Random; - import javax.annotation.Nullable; -+import org.bukkit.event.block.CauldronLevelChangeEvent; // CraftBukkit +@@ -1,5 +1,7 @@ + package net.minecraft.server; ++import org.bukkit.event.block.CauldronLevelChangeEvent; // CraftBukkit ++ public class BlockCauldron extends Block { -@@ -43,8 +44,13 @@ + public static final BlockStateInteger LEVEL = BlockProperties.ae; +@@ -32,8 +34,13 @@ float f = (float) blockposition.getY() + (6.0F + (float) (3 * i)) / 16.0F; if (!world.isClientSide && entity.isBurning() && i > 0 && entity.getBoundingBox().b <= (double) f) { @@ -23,7 +23,7 @@ } } -@@ -60,18 +66,27 @@ +@@ -49,18 +56,27 @@ if (item == Items.WATER_BUCKET) { if (i < 3 && !world.isClientSide) { @@ -35,11 +35,11 @@ entityhuman.a(enumhand, new ItemStack(Items.BUCKET)); } - entityhuman.b(StatisticList.I); + entityhuman.a(StatisticList.FILL_CAULDRON); - this.a(world, blockposition, iblockdata, 3); + // this.a(world, blockposition, iblockdata, 3); + // CraftBukkit end - world.a((EntityHuman) null, blockposition, SoundEffects.Q, SoundCategory.BLOCKS, 1.0F, 1.0F); + world.a((EntityHuman) null, blockposition, SoundEffects.ITEM_BUCKET_EMPTY, SoundCategory.BLOCKS, 1.0F, 1.0F); } return true; @@ -52,17 +52,17 @@ if (!entityhuman.abilities.canInstantlyBuild) { itemstack.subtract(1); if (itemstack.isEmpty()) { -@@ -82,7 +97,8 @@ +@@ -71,7 +87,8 @@ } - entityhuman.b(StatisticList.J); + entityhuman.a(StatisticList.USE_CAULDRON); - this.a(world, blockposition, iblockdata, 0); + // this.a(world, blockposition, iblockdata, 0); + // CraftBukkit end - world.a((EntityHuman) null, blockposition, SoundEffects.S, SoundCategory.BLOCKS, 1.0F, 1.0F); + world.a((EntityHuman) null, blockposition, SoundEffects.ITEM_BUCKET_FILL, SoundCategory.BLOCKS, 1.0F, 1.0F); } -@@ -92,6 +108,10 @@ +@@ -81,6 +98,10 @@ if (item == Items.GLASS_BOTTLE) { if (i > 0 && !world.isClientSide) { @@ -72,11 +72,11 @@ + } if (!entityhuman.abilities.canInstantlyBuild) { itemstack1 = PotionUtil.a(new ItemStack(Items.POTION), Potions.b); - entityhuman.b(StatisticList.J); -@@ -106,12 +126,17 @@ + entityhuman.a(StatisticList.USE_CAULDRON); +@@ -95,12 +116,17 @@ } - world.a((EntityHuman) null, blockposition, SoundEffects.N, SoundCategory.BLOCKS, 1.0F, 1.0F); + world.a((EntityHuman) null, blockposition, SoundEffects.ITEM_BOTTLE_FILL, SoundCategory.BLOCKS, 1.0F, 1.0F); - this.a(world, blockposition, iblockdata, i - 1); + // this.a(world, blockposition, iblockdata, i - 1); + // CraftBukkit end @@ -91,44 +91,44 @@ + } if (!entityhuman.abilities.canInstantlyBuild) { itemstack1 = new ItemStack(Items.GLASS_BOTTLE); - entityhuman.b(StatisticList.J); -@@ -122,7 +147,8 @@ + entityhuman.a(StatisticList.USE_CAULDRON); +@@ -111,7 +137,8 @@ } - world.a((EntityHuman) null, blockposition, SoundEffects.M, SoundCategory.BLOCKS, 1.0F, 1.0F); + world.a((EntityHuman) null, blockposition, SoundEffects.ITEM_BOTTLE_EMPTY, SoundCategory.BLOCKS, 1.0F, 1.0F); - this.a(world, blockposition, iblockdata, i + 1); + // this.a(world, blockposition, iblockdata, i + 1); + // CraftBukkit end } return true; -@@ -131,8 +157,13 @@ - ItemArmor itemarmor = (ItemArmor) item; +@@ -120,8 +147,13 @@ + ItemArmorColorable itemarmorcolorable = (ItemArmorColorable) item; - if (itemarmor.d() == ItemArmor.EnumArmorMaterial.LEATHER && itemarmor.e_(itemstack) && !world.isClientSide) { + if (itemarmorcolorable.e(itemstack) && !world.isClientSide) { + // CraftBukkit start + if (!this.changeLevel(world, blockposition, iblockdata, i - 1, entityhuman, CauldronLevelChangeEvent.ChangeReason.ARMOR_WASH)) { + return true; + } - itemarmor.d(itemstack); + itemarmorcolorable.g(itemstack); - this.a(world, blockposition, iblockdata, i - 1); + // this.a(world, blockposition, iblockdata, i - 1); + // CraftBukkit end - entityhuman.b(StatisticList.K); + entityhuman.a(StatisticList.CLEAN_ARMOR); return true; } -@@ -140,13 +171,18 @@ +@@ -129,13 +161,18 @@ if (i > 0 && item instanceof ItemBanner) { - if (TileEntityBanner.b(itemstack) > 0 && !world.isClientSide) { + if (TileEntityBanner.a(itemstack) > 0 && !world.isClientSide) { + // CraftBukkit start + if (!this.changeLevel(world, blockposition, iblockdata, i - 1, entityhuman, CauldronLevelChangeEvent.ChangeReason.BANNER_WASH)) { + return true; + } itemstack1 = itemstack.cloneItemStack(); itemstack1.setCount(1); - TileEntityBanner.c(itemstack1); - entityhuman.b(StatisticList.L); + TileEntityBanner.b(itemstack1); + entityhuman.a(StatisticList.CLEAN_BANNER); if (!entityhuman.abilities.canInstantlyBuild) { itemstack.subtract(1); - this.a(world, blockposition, iblockdata, i - 1); @@ -137,13 +137,13 @@ } if (itemstack.isEmpty()) { -@@ -167,9 +203,25 @@ +@@ -171,9 +208,25 @@ } } + // CraftBukkit start public void a(World world, BlockPosition blockposition, IBlockData iblockdata, int i) { -- world.setTypeAndData(blockposition, iblockdata.set(BlockCauldron.LEVEL, Integer.valueOf(MathHelper.clamp(i, 0, 3))), 2); +- world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockCauldron.LEVEL, Integer.valueOf(MathHelper.clamp(i, 0, 3))), 2); + this.changeLevel(world, blockposition, iblockdata, i, null, CauldronLevelChangeEvent.ChangeReason.UNKNOWN); + } + @@ -157,19 +157,19 @@ + if (event.isCancelled()) { + return false; + } -+ world.setTypeAndData(blockposition, iblockdata.set(BlockCauldron.LEVEL, event.getNewLevel()), 2); ++ world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockCauldron.LEVEL, event.getNewLevel()), 2); world.updateAdjacentComparators(blockposition, this); + return true; + // CraftBukkit end } - public void h(World world, BlockPosition blockposition) { -@@ -180,7 +232,7 @@ + public void c(World world, BlockPosition blockposition) { +@@ -184,7 +237,7 @@ IBlockData iblockdata = world.getType(blockposition); if (((Integer) iblockdata.get(BlockCauldron.LEVEL)).intValue() < 3) { -- world.setTypeAndData(blockposition, iblockdata.a((IBlockState) BlockCauldron.LEVEL), 2); -+ this.a(world, blockposition, iblockdata.a((IBlockState) BlockCauldron.LEVEL), 2); // CraftBukkit +- world.setTypeAndData(blockposition, (IBlockData) iblockdata.a((IBlockState) BlockCauldron.LEVEL), 2); ++ this.a(world, blockposition, (IBlockData) iblockdata.a((IBlockState) BlockCauldron.LEVEL), 2); // CraftBukkit } } diff --git a/paper-server/nms-patches/BlockChorusFlower.patch b/paper-server/nms-patches/BlockChorusFlower.patch index e5482d55b5..2e24180c3f 100644 --- a/paper-server/nms-patches/BlockChorusFlower.patch +++ b/paper-server/nms-patches/BlockChorusFlower.patch @@ -8,46 +8,31 @@ + public class BlockChorusFlower extends Block { - public static final BlockStateInteger AGE = BlockStateInteger.of("age", 0, 5); -@@ -68,8 +70,20 @@ + public static final BlockStateInteger AGE = BlockProperties.U; +@@ -61,8 +63,12 @@ } - if (flag && a(world, blockposition1, (EnumDirection) null) && world.isEmpty(blockposition.up(2))) { -- world.setTypeAndData(blockposition, Blocks.CHORUS_PLANT.getBlockData(), 2); -- this.a(world, blockposition1, i); -+ // world.setTypeAndData(blockposition, Blocks.CHORUS_PLANT.getBlockData(), 2); -+ // this.a(world, blockposition1, i); + if (flag && a((IWorldReader) world, blockposition1, (EnumDirection) null) && world.isEmpty(blockposition.up(2))) { +- world.setTypeAndData(blockposition, this.b.a((IBlockAccess) world, blockposition), 2); +- this.b(world, blockposition1, i); + // CraftBukkit start - add event -+ BlockPosition target = blockposition1; -+ if (CraftEventFactory.handleBlockSpreadEvent( -+ world.getWorld().getBlockAt(target.getX(), target.getY(), target.getZ()), -+ world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), -+ this, -+ toLegacyData(this.getBlockData().set(BlockChorusFlower.AGE, Integer.valueOf(i))) -+ )) { -+ world.setTypeAndData(blockposition, Blocks.CHORUS_PLANT.getBlockData(), 2); -+ world.triggerEffect(1033, blockposition, 0); ++ if (CraftEventFactory.handleBlockSpreadEvent(world, blockposition, blockposition1, this.getBlockData().set(BlockChorusFlower.AGE, Integer.valueOf(i)), 2)) { ++ world.setTypeAndData(blockposition, this.b.a((IBlockAccess) world, blockposition), 2); ++ this.b(world, blockposition1, i); + } + // CraftBukkit end } else if (i < 4) { j = random.nextInt(4); - boolean flag2 = false; -@@ -83,18 +97,53 @@ + if (flag1) { +@@ -76,18 +82,30 @@ BlockPosition blockposition2 = blockposition.shift(enumdirection); - if (world.isEmpty(blockposition2) && world.isEmpty(blockposition2.down()) && a(world, blockposition2, enumdirection.opposite())) { -- this.a(world, blockposition2, i + 1); + if (world.isEmpty(blockposition2) && world.isEmpty(blockposition2.down()) && a((IWorldReader) world, blockposition2, enumdirection.opposite())) { +- this.b(world, blockposition2, i + 1); - flag2 = true; + // CraftBukkit start - add event -+ // this.a(world, blockposition2, i + 1); -+ BlockPosition target = blockposition2; -+ if (CraftEventFactory.handleBlockSpreadEvent( -+ world.getWorld().getBlockAt(target.getX(), target.getY(), target.getZ()), -+ world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), -+ this, -+ toLegacyData(this.getBlockData().set(BlockChorusFlower.AGE, Integer.valueOf(i + 1))) -+ )) { -+ world.triggerEffect(1033, blockposition, 0); ++ if (CraftEventFactory.handleBlockSpreadEvent(world, blockposition, blockposition2, this.getBlockData().set(BlockChorusFlower.AGE, Integer.valueOf(i + 1)), 2)) { ++ this.b(world, blockposition2, i + 1); + flag2 = true; + } + // CraftBukkit end @@ -55,37 +40,21 @@ } if (flag2) { - world.setTypeAndData(blockposition, Blocks.CHORUS_PLANT.getBlockData(), 2); + world.setTypeAndData(blockposition, this.b.a((IBlockAccess) world, blockposition), 2); } else { -- this.c(world, blockposition); +- this.a(world, blockposition); + // CraftBukkit - add event -+ if (CraftEventFactory.handleBlockGrowEvent( -+ world, -+ blockposition.getX(), -+ blockposition.getY(), -+ blockposition.getZ(), -+ this, -+ toLegacyData(iblockdata.set(BlockChorusFlower.AGE, Integer.valueOf(5))) -+ )) { -+ world.triggerEffect(1034, blockposition, 0); ++ if (CraftEventFactory.handleBlockGrowEvent(world, blockposition, this.getBlockData().set(BlockChorusFlower.AGE, Integer.valueOf(5)), 2)) { ++ this.a(world, blockposition); + } -+ // this.c(world, blockposition); + // CraftBukkit end } - } else if (i == 4) { -- this.c(world, blockposition); + } else { +- this.a(world, blockposition); + // CraftBukkit - add event -+ if (CraftEventFactory.handleBlockGrowEvent( -+ world, -+ blockposition.getX(), -+ blockposition.getY(), -+ blockposition.getZ(), -+ this, -+ toLegacyData(iblockdata.set(BlockChorusFlower.AGE, Integer.valueOf(5))) -+ )) { -+ world.triggerEffect(1034, blockposition, 0); ++ if (CraftEventFactory.handleBlockGrowEvent(world, blockposition, this.getBlockData().set(BlockChorusFlower.AGE, Integer.valueOf(5)), 2)) { ++ this.a(world, blockposition); + } -+ // this.c(world, blockposition); + // CraftBukkit end } diff --git a/paper-server/nms-patches/BlockCocoa.patch b/paper-server/nms-patches/BlockCocoa.patch index 470a26f63f..3affcb742a 100644 --- a/paper-server/nms-patches/BlockCocoa.patch +++ b/paper-server/nms-patches/BlockCocoa.patch @@ -1,35 +1,29 @@ --- a/net/minecraft/server/BlockCocoa.java +++ b/net/minecraft/server/BlockCocoa.java -@@ -2,6 +2,8 @@ - +@@ -3,6 +3,8 @@ import java.util.Random; + import javax.annotation.Nullable; +import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit + public class BlockCocoa extends BlockFacingHorizontal implements IBlockFragilePlantElement { - public static final BlockStateInteger AGE = BlockStateInteger.of("age", 0, 2); -@@ -23,7 +25,10 @@ + public static final BlockStateInteger AGE = BlockProperties.S; +@@ -21,7 +23,7 @@ int i = ((Integer) iblockdata.get(BlockCocoa.AGE)).intValue(); if (i < 2) { -- world.setTypeAndData(blockposition, iblockdata.set(BlockCocoa.AGE, Integer.valueOf(i + 1)), 2); -+ // CraftBukkit start -+ IBlockData data = iblockdata.set(AGE, Integer.valueOf(i + 1)); -+ CraftEventFactory.handleBlockGrowEvent(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this, toLegacyData(data)); -+ // CraftBukkit end +- world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockCocoa.AGE, Integer.valueOf(i + 1)), 2); ++ CraftEventFactory.handleBlockGrowEvent(world, blockposition, (IBlockData) iblockdata.set(BlockCocoa.AGE, Integer.valueOf(i + 1)), 2); // CraftBukkkit } } -@@ -124,7 +129,10 @@ +@@ -109,7 +111,7 @@ } public void b(World world, Random random, BlockPosition blockposition, IBlockData iblockdata) { -- world.setTypeAndData(blockposition, iblockdata.set(BlockCocoa.AGE, Integer.valueOf(((Integer) iblockdata.get(BlockCocoa.AGE)).intValue() + 1)), 2); -+ // CraftBukkit start -+ IBlockData data = iblockdata.set(AGE, Integer.valueOf(((Integer) iblockdata.get(AGE)).intValue() + 1)); -+ CraftEventFactory.handleBlockGrowEvent(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this, toLegacyData(data)); -+ // CraftBukkit end +- world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockCocoa.AGE, Integer.valueOf(((Integer) iblockdata.get(BlockCocoa.AGE)).intValue() + 1)), 2); ++ CraftEventFactory.handleBlockGrowEvent(world, blockposition, (IBlockData) iblockdata.set(BlockCocoa.AGE, Integer.valueOf(((Integer) iblockdata.get(BlockCocoa.AGE)).intValue() + 1)), 2); // CraftBukkit } - public IBlockData fromLegacyData(int i) { + public TextureType c() { diff --git a/paper-server/nms-patches/BlockCommand.patch b/paper-server/nms-patches/BlockCommand.patch index 12a88a41ad..4f0974f244 100644 --- a/paper-server/nms-patches/BlockCommand.patch +++ b/paper-server/nms-patches/BlockCommand.patch @@ -12,7 +12,7 @@ @@ -30,6 +32,15 @@ TileEntityCommand tileentitycommand = (TileEntityCommand) tileentity; boolean flag = world.isBlockIndirectlyPowered(blockposition); - boolean flag1 = tileentitycommand.f(); + boolean flag1 = tileentitycommand.d(); + // CraftBukkit start + org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); + int old = flag1 ? 15 : 0; @@ -24,4 +24,4 @@ + // CraftBukkit end tileentitycommand.a(flag); - if (!flag1 && !tileentitycommand.h() && tileentitycommand.l() != TileEntityCommand.Type.SEQUENCE) { + if (!flag1 && !tileentitycommand.e() && tileentitycommand.j() != TileEntityCommand.Type.SEQUENCE) { diff --git a/paper-server/nms-patches/BlockConcretePowder.patch b/paper-server/nms-patches/BlockConcretePowder.patch index dd2708f7a3..83e1128088 100644 --- a/paper-server/nms-patches/BlockConcretePowder.patch +++ b/paper-server/nms-patches/BlockConcretePowder.patch @@ -1,22 +1,46 @@ --- a/net/minecraft/server/BlockConcretePowder.java +++ b/net/minecraft/server/BlockConcretePowder.java -@@ -11,8 +11,8 @@ +@@ -1,5 +1,10 @@ + package net.minecraft.server; + ++// CraftBukkit start ++import org.bukkit.craftbukkit.block.CraftBlockState; ++import org.bukkit.event.block.BlockFormEvent; ++// CraftBukkit end ++ + public class BlockConcretePowder extends BlockFalling { + + private final IBlockData a; +@@ -10,8 +15,8 @@ } public void a(World world, BlockPosition blockposition, IBlockData iblockdata, IBlockData iblockdata1) { - if (iblockdata1.getMaterial().isLiquid()) { -- world.setTypeAndData(blockposition, Blocks.dR.getBlockData().set(BlockCloth.COLOR, iblockdata.get(BlockConcretePowder.a)), 3); -+ if (iblockdata1.getMaterial().isLiquid() && world.getType(blockposition).getBlock() != Blocks.dR) { // CraftBukkit - don't double concrete -+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition, Blocks.dR.getBlockData().set(BlockCloth.COLOR, iblockdata.get(BlockConcretePowder.a)), null); // CraftBukkit +- world.setTypeAndData(blockposition, this.a, 3); ++ if (iblockdata1.getMaterial().isLiquid() && !(world.getType(blockposition).getBlock() instanceof BlockConcretePowder)) { // CraftBukkit - don't double concrete ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition, this.a, 3); } } -@@ -36,7 +36,7 @@ - } +@@ -45,6 +50,20 @@ + } - if (flag) { -- world.setTypeAndData(blockposition, Blocks.dR.getBlockData().set(BlockCloth.COLOR, iblockdata.get(BlockConcretePowder.a)), 3); -+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition, Blocks.dR.getBlockData().set(BlockCloth.COLOR, iblockdata.get(BlockConcretePowder.a)), null); // CraftBukkit - } - - return flag; + public IBlockData updateState(IBlockData iblockdata, EnumDirection enumdirection, IBlockData iblockdata1, GeneratorAccess generatoraccess, BlockPosition blockposition, BlockPosition blockposition1) { +- return a((IBlockAccess) generatoraccess, blockposition) ? this.a : super.updateState(iblockdata, enumdirection, iblockdata1, generatoraccess, blockposition, blockposition1); ++ // CraftBukkit start ++ if (a((IBlockAccess) generatoraccess, blockposition)) { ++ CraftBlockState blockState = CraftBlockState.getBlockState(generatoraccess, blockposition); ++ blockState.setData(this.a); ++ ++ BlockFormEvent event = new BlockFormEvent(blockState.getBlock(), blockState); ++ generatoraccess.getMinecraftWorld().getMinecraftServer().server.getPluginManager().callEvent(event); ++ ++ if (!event.isCancelled()) { ++ return blockState.getHandle(); ++ } ++ } ++ ++ return super.updateState(iblockdata, enumdirection, iblockdata1, generatoraccess, blockposition, blockposition1); ++ // CraftBukkit end + } + } diff --git a/paper-server/nms-patches/BlockCrops.patch b/paper-server/nms-patches/BlockCrops.patch index 385751dafb..f5169e7944 100644 --- a/paper-server/nms-patches/BlockCrops.patch +++ b/paper-server/nms-patches/BlockCrops.patch @@ -8,28 +8,22 @@ + public class BlockCrops extends BlockPlant implements IBlockFragilePlantElement { - public static final BlockStateInteger AGE = BlockStateInteger.of("age", 0, 7); -@@ -53,7 +55,10 @@ - float f = a((Block) this, world, blockposition); + public static final BlockStateInteger AGE = BlockProperties.V; +@@ -49,7 +51,7 @@ + float f = a((Block) this, (IBlockAccess) world, blockposition); if (random.nextInt((int) (25.0F / f) + 1) == 0) { - world.setTypeAndData(blockposition, this.setAge(i + 1), 2); -+ // CraftBukkit start -+ IBlockData data = this.setAge(i + 1); -+ CraftEventFactory.handleBlockGrowEvent(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this, toLegacyData(data)); -+ // CraftBukkit end ++ CraftEventFactory.handleBlockGrowEvent(world, blockposition, this.setAge(i + 1), 2); // CraftBukkit } } } -@@ -68,7 +73,10 @@ +@@ -64,7 +66,7 @@ i = j; } - world.setTypeAndData(blockposition, this.setAge(i), 2); -+ // CraftBukkit start -+ IBlockData data = this.setAge(i); -+ CraftEventFactory.handleBlockGrowEvent(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this, toLegacyData(data)); -+ // CraftBukkit end ++ CraftEventFactory.handleBlockGrowEvent(world, blockposition, this.setAge(i), 2); // CraftBukkit } - protected int b(World world) { + protected int a(World world) { diff --git a/paper-server/nms-patches/BlockDaylightDetector.patch b/paper-server/nms-patches/BlockDaylightDetector.patch index a9525a88cc..b62dbbf641 100644 --- a/paper-server/nms-patches/BlockDaylightDetector.patch +++ b/paper-server/nms-patches/BlockDaylightDetector.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/server/BlockDaylightDetector.java +++ b/net/minecraft/server/BlockDaylightDetector.java -@@ -45,6 +45,7 @@ +@@ -36,6 +36,7 @@ i = MathHelper.clamp(i, 0, 15); if (((Integer) iblockdata.get(BlockDaylightDetector.POWER)).intValue() != i) { -+ i = org.bukkit.craftbukkit.event.CraftEventFactory.callRedstoneChange(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), ((Integer) iblockdata.get(POWER)), i).getNewCurrent(); // CraftBukkit - Call BlockRedstoneEvent - world.setTypeAndData(blockposition, iblockdata.set(BlockDaylightDetector.POWER, Integer.valueOf(i)), 3); ++ i = org.bukkit.craftbukkit.event.CraftEventFactory.callRedstoneChange(world, blockposition, ((Integer) iblockdata.get(POWER)), i).getNewCurrent(); // CraftBukkit - Call BlockRedstoneEvent + world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockDaylightDetector.POWER, Integer.valueOf(i)), 3); } diff --git a/paper-server/nms-patches/BlockDiodeAbstract.patch b/paper-server/nms-patches/BlockDiodeAbstract.patch index f7f4522e14..b870476b88 100644 --- a/paper-server/nms-patches/BlockDiodeAbstract.patch +++ b/paper-server/nms-patches/BlockDiodeAbstract.patch @@ -8,23 +8,23 @@ + public abstract class BlockDiodeAbstract extends BlockFacingHorizontal { - protected static final AxisAlignedBB c = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 0.125D, 1.0D); -@@ -35,8 +37,18 @@ - boolean flag = this.e(world, blockposition, iblockdata); + protected static final VoxelShape b = Block.a(0.0D, 0.0D, 0.0D, 16.0D, 2.0D, 16.0D); +@@ -29,8 +31,18 @@ + boolean flag1 = this.a(world, blockposition, iblockdata); - if (this.d && !flag) { + if (flag && !flag1) { + // CraftBukkit start -+ if (CraftEventFactory.callRedstoneChange(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), 15, 0).getNewCurrent() != 0) { ++ if (CraftEventFactory.callRedstoneChange(world, blockposition, 15, 0).getNewCurrent() != 0) { + return; + } + // CraftBukkit end - world.setTypeAndData(blockposition, this.z(iblockdata), 2); - } else if (!this.d) { + world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockDiodeAbstract.c, Boolean.valueOf(false)), 2); + } else if (!flag) { + // CraftBukkit start -+ if (CraftEventFactory.callRedstoneChange(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), 0, 15).getNewCurrent() != 15) { ++ if (CraftEventFactory.callRedstoneChange(world, blockposition, 0, 15).getNewCurrent() != 15) { + return; + } + // CraftBukkit end - world.setTypeAndData(blockposition, this.y(iblockdata), 2); - if (!flag) { - world.a(blockposition, this.y(iblockdata).getBlock(), this.E(iblockdata), -1); + world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockDiodeAbstract.c, Boolean.valueOf(true)), 2); + if (!flag1) { + world.I().a(blockposition, this, this.j(iblockdata), TickListPriority.HIGH); diff --git a/paper-server/nms-patches/BlockDirtSnowSpreadable.patch b/paper-server/nms-patches/BlockDirtSnowSpreadable.patch new file mode 100644 index 0000000000..af18d01d07 --- /dev/null +++ b/paper-server/nms-patches/BlockDirtSnowSpreadable.patch @@ -0,0 +1,23 @@ +--- a/net/minecraft/server/BlockDirtSnowSpreadable.java ++++ b/net/minecraft/server/BlockDirtSnowSpreadable.java +@@ -23,6 +23,11 @@ + public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) { + if (!world.isClientSide) { + if (!a((IWorldReader) world, blockposition)) { ++ // CraftBukkit start ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(world, blockposition, Blocks.DIRT.getBlockData()).isCancelled()) { ++ return; ++ } ++ // CraftBukkit end + world.setTypeUpdate(blockposition, Blocks.DIRT.getBlockData()); + } else { + if (world.getLightLevel(blockposition.up()) >= 9) { +@@ -34,7 +39,7 @@ + } + + if (world.getType(blockposition1).getBlock() == Blocks.DIRT && b(world, blockposition1)) { +- world.setTypeUpdate(blockposition1, this.getBlockData()); ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(world, blockposition, blockposition1, this.getBlockData()); // CraftBukkit + } + } + } diff --git a/paper-server/nms-patches/BlockDispenser.patch b/paper-server/nms-patches/BlockDispenser.patch index a46b1eef71..45431d4bd8 100644 --- a/paper-server/nms-patches/BlockDispenser.patch +++ b/paper-server/nms-patches/BlockDispenser.patch @@ -1,18 +1,18 @@ --- a/net/minecraft/server/BlockDispenser.java +++ b/net/minecraft/server/BlockDispenser.java -@@ -8,6 +8,7 @@ - public static final BlockStateBoolean TRIGGERED = BlockStateBoolean.of("triggered"); +@@ -7,6 +7,7 @@ + public static final BlockStateDirection FACING = BlockDirectional.FACING; + public static final BlockStateBoolean TRIGGERED = BlockProperties.w; public static final RegistryDefault REGISTRY = new RegistryDefault(new DispenseBehaviorItem()); - protected Random d = new Random(); + public static boolean eventFired = false; // CraftBukkit - protected BlockDispenser() { - super(Material.STONE); -@@ -82,6 +83,7 @@ - IDispenseBehavior idispensebehavior = this.a(itemstack); + public static void a(IMaterial imaterial, IDispenseBehavior idispensebehavior) { + BlockDispenser.REGISTRY.a(imaterial.getItem(), idispensebehavior); +@@ -52,6 +53,7 @@ + IDispenseBehavior idispensebehavior = this.a(itemstack); - if (idispensebehavior != IDispenseBehavior.NONE) { -+ eventFired = false; // CraftBukkit - reset event status - tileentitydispenser.setItem(i, idispensebehavior.a(sourceblock, itemstack)); - } + if (idispensebehavior != IDispenseBehavior.NONE) { ++ eventFired = false; // CraftBukkit - reset event status + tileentitydispenser.setItem(i, idispensebehavior.dispense(sourceblock, itemstack)); + } diff --git a/paper-server/nms-patches/BlockDoor.patch b/paper-server/nms-patches/BlockDoor.patch index 063d2ea12e..e47addb1d5 100644 --- a/paper-server/nms-patches/BlockDoor.patch +++ b/paper-server/nms-patches/BlockDoor.patch @@ -2,36 +2,37 @@ +++ b/net/minecraft/server/BlockDoor.java @@ -2,6 +2,8 @@ - import java.util.Random; + import javax.annotation.Nullable; +import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit + public class BlockDoor extends Block { public static final BlockStateDirection FACING = BlockFacingHorizontal.FACING; -@@ -137,9 +139,23 @@ - this.b(world, blockposition, iblockdata, 0); - } - } else { -- boolean flag1 = world.isBlockIndirectlyPowered(blockposition) || world.isBlockIndirectlyPowered(blockposition3); +@@ -169,9 +171,24 @@ + } -- if (block != this && (flag1 || block.getBlockData().m()) && flag1 != ((Boolean) iblockdata2.get(BlockDoor.POWERED)).booleanValue()) { -+ // CraftBukkit start -+ org.bukkit.World bworld = world.getWorld(); -+ org.bukkit.block.Block bukkitBlock = bworld.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); -+ org.bukkit.block.Block blockTop = bworld.getBlockAt(blockposition3.getX(), blockposition3.getY(), blockposition3.getZ()); + public void doPhysics(IBlockData iblockdata, World world, BlockPosition blockposition, Block block, BlockPosition blockposition1) { +- boolean flag = world.isBlockIndirectlyPowered(blockposition) || world.isBlockIndirectlyPowered(blockposition.shift(iblockdata.get(BlockDoor.HALF) == BlockPropertyDoubleBlockHalf.LOWER ? EnumDirection.UP : EnumDirection.DOWN)); ++ // CraftBukkit start ++ BlockPosition otherHalf = blockposition.shift(iblockdata.get(BlockDoor.HALF) == BlockPropertyDoubleBlockHalf.LOWER ? EnumDirection.UP : EnumDirection.DOWN); + -+ int power = bukkitBlock.getBlockPower(); -+ int powerTop = blockTop.getBlockPower(); -+ if (powerTop > power) power = powerTop; -+ int oldPower = (Boolean) iblockdata2.get(BlockDoor.POWERED) ? 15 : 0; ++ org.bukkit.World bworld = world.getWorld(); ++ org.bukkit.block.Block bukkitBlock = bworld.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); ++ org.bukkit.block.Block blockTop = bworld.getBlockAt(otherHalf.getX(), otherHalf.getY(), otherHalf.getZ()); + -+ if (oldPower == 0 ^ power == 0) { -+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bukkitBlock, oldPower, power); -+ world.getServer().getPluginManager().callEvent(eventRedstone); ++ int power = bukkitBlock.getBlockPower(); ++ int powerTop = blockTop.getBlockPower(); ++ if (powerTop > power) power = powerTop; ++ int oldPower = ((Boolean) iblockdata.get(BlockDoor.POWERED)).booleanValue() ? 15 : 0; + -+ boolean flag1 = eventRedstone.getNewCurrent() > 0; -+ // CraftBukkit end - world.setTypeAndData(blockposition3, iblockdata2.set(BlockDoor.POWERED, Boolean.valueOf(flag1)), 2); - if (flag1 != ((Boolean) iblockdata.get(BlockDoor.OPEN)).booleanValue()) { - world.setTypeAndData(blockposition, iblockdata.set(BlockDoor.OPEN, Boolean.valueOf(flag1)), 2); ++ if (oldPower == 0 ^ power == 0) { ++ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bukkitBlock, oldPower, power); ++ world.getServer().getPluginManager().callEvent(eventRedstone); + +- if (block != this && flag != ((Boolean) iblockdata.get(BlockDoor.POWERED)).booleanValue()) { ++ boolean flag = eventRedstone.getNewCurrent() > 0; ++ // CraftBukkit end + if (flag != ((Boolean) iblockdata.get(BlockDoor.OPEN)).booleanValue()) { + this.b(world, blockposition, flag); + } diff --git a/paper-server/nms-patches/BlockDragonEgg.patch b/paper-server/nms-patches/BlockDragonEgg.patch index af397c6782..1533b9bd76 100644 --- a/paper-server/nms-patches/BlockDragonEgg.patch +++ b/paper-server/nms-patches/BlockDragonEgg.patch @@ -1,30 +1,29 @@ --- a/net/minecraft/server/BlockDragonEgg.java +++ b/net/minecraft/server/BlockDragonEgg.java -@@ -2,6 +2,8 @@ - - import java.util.Random; +@@ -1,5 +1,7 @@ + package net.minecraft.server; +import org.bukkit.event.block.BlockFromToEvent; // CraftBukkit + - public class BlockDragonEgg extends Block { + public class BlockDragonEgg extends BlockFalling { - protected static final AxisAlignedBB a = new AxisAlignedBB(0.0625D, 0.0D, 0.0625D, 0.9375D, 1.0D, 0.9375D); -@@ -66,6 +68,18 @@ - BlockPosition blockposition1 = blockposition.a(world.random.nextInt(16) - world.random.nextInt(16), world.random.nextInt(8) - world.random.nextInt(8), world.random.nextInt(16) - world.random.nextInt(16)); + protected static final VoxelShape a = Block.a(1.0D, 0.0D, 1.0D, 15.0D, 16.0D, 15.0D); +@@ -26,6 +28,18 @@ + BlockPosition blockposition1 = blockposition.a(world.random.nextInt(16) - world.random.nextInt(16), world.random.nextInt(8) - world.random.nextInt(8), world.random.nextInt(16) - world.random.nextInt(16)); - if (world.getType(blockposition1).getBlock().material == Material.AIR) { -+ // CraftBukkit start -+ org.bukkit.block.Block from = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); -+ org.bukkit.block.Block to = world.getWorld().getBlockAt(blockposition1.getX(), blockposition1.getY(), blockposition1.getZ()); -+ BlockFromToEvent event = new BlockFromToEvent(from, to); -+ org.bukkit.Bukkit.getPluginManager().callEvent(event); + if (world.getType(blockposition1).isAir()) { ++ // CraftBukkit start ++ org.bukkit.block.Block from = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); ++ org.bukkit.block.Block to = world.getWorld().getBlockAt(blockposition1.getX(), blockposition1.getY(), blockposition1.getZ()); ++ BlockFromToEvent event = new BlockFromToEvent(from, to); ++ org.bukkit.Bukkit.getPluginManager().callEvent(event); + -+ if (event.isCancelled()) { -+ return; -+ } ++ if (event.isCancelled()) { ++ return; ++ } + -+ blockposition1 = new BlockPosition(event.getToBlock().getX(), event.getToBlock().getY(), event.getToBlock().getZ()); -+ // CraftBukkit end - if (world.isClientSide) { - for (int j = 0; j < 128; ++j) { - double d0 = world.random.nextDouble(); ++ blockposition1 = new BlockPosition(event.getToBlock().getX(), event.getToBlock().getY(), event.getToBlock().getZ()); ++ // CraftBukkit end + if (world.isClientSide) { + for (int j = 0; j < 128; ++j) { + double d0 = world.random.nextDouble(); diff --git a/paper-server/nms-patches/BlockDropper.patch b/paper-server/nms-patches/BlockDropper.patch index 07c21cb4dd..ba4ddc9b16 100644 --- a/paper-server/nms-patches/BlockDropper.patch +++ b/paper-server/nms-patches/BlockDropper.patch @@ -10,32 +10,32 @@ + public class BlockDropper extends BlockDispenser { - private final IDispenseBehavior e = new DispenseBehaviorItem(); -@@ -35,8 +40,25 @@ - if (iinventory == null) { - itemstack1 = this.e.a(sourceblock, itemstack); + private static final IDispenseBehavior c = new DispenseBehaviorItem(); +@@ -34,8 +39,25 @@ + if (iinventory == null) { + itemstack1 = BlockDropper.c.dispense(sourceblock, itemstack); + } else { +- itemstack1 = TileEntityHopper.addItem(tileentitydispenser, iinventory, itemstack.cloneItemStack().cloneAndSubtract(1), enumdirection.opposite()); +- if (itemstack1.isEmpty()) { ++ // CraftBukkit start - Fire event when pushing items into other inventories ++ CraftItemStack oitemstack = CraftItemStack.asCraftMirror(itemstack.cloneItemStack().cloneAndSubtract(1)); ++ ++ org.bukkit.inventory.Inventory destinationInventory; ++ // Have to special case large chests as they work oddly ++ if (iinventory instanceof InventoryLargeChest) { ++ destinationInventory = new org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest((InventoryLargeChest) iinventory); ++ } else { ++ destinationInventory = iinventory.getOwner().getInventory(); ++ } ++ ++ InventoryMoveItemEvent event = new InventoryMoveItemEvent(tileentitydispenser.getOwner().getInventory(), oitemstack.clone(), destinationInventory, true); ++ world.getServer().getPluginManager().callEvent(event); ++ if (event.isCancelled()) { ++ return; ++ } ++ itemstack1 = TileEntityHopper.addItem(tileentitydispenser, iinventory, CraftItemStack.asNMSCopy(event.getItem()), enumdirection.opposite()); ++ if (event.getItem().equals(oitemstack) && itemstack1.isEmpty()) { ++ // CraftBukkit end + itemstack1 = itemstack.cloneItemStack(); + itemstack1.subtract(1); } else { -- itemstack1 = TileEntityHopper.addItem(tileentitydispenser, iinventory, itemstack.cloneItemStack().cloneAndSubtract(1), enumdirection.opposite()); -- if (itemstack1.isEmpty()) { -+ // CraftBukkit start - Fire event when pushing items into other inventories -+ CraftItemStack oitemstack = CraftItemStack.asCraftMirror(itemstack.cloneItemStack().cloneAndSubtract(1)); -+ -+ org.bukkit.inventory.Inventory destinationInventory; -+ // Have to special case large chests as they work oddly -+ if (iinventory instanceof InventoryLargeChest) { -+ destinationInventory = new org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest((InventoryLargeChest) iinventory); -+ } else { -+ destinationInventory = iinventory.getOwner().getInventory(); -+ } -+ -+ InventoryMoveItemEvent event = new InventoryMoveItemEvent(tileentitydispenser.getOwner().getInventory(), oitemstack.clone(), destinationInventory, true); -+ world.getServer().getPluginManager().callEvent(event); -+ if (event.isCancelled()) { -+ return; -+ } -+ itemstack1 = TileEntityHopper.addItem(tileentitydispenser, iinventory, CraftItemStack.asNMSCopy(event.getItem()), enumdirection.opposite()); -+ if (event.getItem().equals(oitemstack) && itemstack1.isEmpty()) { -+ // CraftBukkit end - itemstack1 = itemstack.cloneItemStack(); - itemstack1.subtract(1); - } else { diff --git a/paper-server/nms-patches/BlockEnderPortal.patch b/paper-server/nms-patches/BlockEnderPortal.patch index 52f8b812b0..9f871fba8e 100644 --- a/paper-server/nms-patches/BlockEnderPortal.patch +++ b/paper-server/nms-patches/BlockEnderPortal.patch @@ -1,22 +1,22 @@ --- a/net/minecraft/server/BlockEnderPortal.java +++ b/net/minecraft/server/BlockEnderPortal.java -@@ -4,6 +4,8 @@ +@@ -2,6 +2,8 @@ + import java.util.Random; - import javax.annotation.Nullable; +import org.bukkit.event.entity.EntityPortalEnterEvent; // CraftBukkit + public class BlockEnderPortal extends BlockTileEntity { - protected static final AxisAlignedBB a = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 0.75D, 1.0D); -@@ -37,6 +39,10 @@ + protected static final VoxelShape a = Block.a(0.0D, 0.0D, 0.0D, 16.0D, 12.0D, 16.0D); +@@ -28,6 +30,10 @@ - public void a(World world, BlockPosition blockposition, IBlockData iblockdata, Entity entity) { - if (!world.isClientSide && !entity.isPassenger() && !entity.isVehicle() && entity.bf() && entity.getBoundingBox().c(iblockdata.e(world, blockposition).a(blockposition))) { + public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { + if (!world.isClientSide && !entity.isPassenger() && !entity.isVehicle() && entity.bm() && VoxelShapes.c(VoxelShapes.a(entity.getBoundingBox().d((double) (-blockposition.getX()), (double) (-blockposition.getY()), (double) (-blockposition.getZ()))), iblockdata.g(world, blockposition), OperatorBoolean.AND)) { + // CraftBukkit start - Entity in portal + EntityPortalEnterEvent event = new EntityPortalEnterEvent(entity.getBukkitEntity(), new org.bukkit.Location(world.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ())); + world.getServer().getPluginManager().callEvent(event); + // CraftBukkit end - entity.b(1); + entity.d(1); } diff --git a/paper-server/nms-patches/BlockFire.patch b/paper-server/nms-patches/BlockFire.patch index f5ce1cd85f..9f26ccf38f 100644 --- a/paper-server/nms-patches/BlockFire.patch +++ b/paper-server/nms-patches/BlockFire.patch @@ -1,39 +1,65 @@ --- a/net/minecraft/server/BlockFire.java +++ b/net/minecraft/server/BlockFire.java -@@ -5,6 +5,12 @@ - import java.util.Random; +@@ -8,6 +8,16 @@ + import java.util.function.Predicate; import javax.annotation.Nullable; +// CraftBukkit start ++ ++import org.bukkit.Bukkit; ++import org.bukkit.craftbukkit.block.CraftBlockState; +import org.bukkit.craftbukkit.event.CraftEventFactory; +import org.bukkit.event.block.BlockBurnEvent; ++import org.bukkit.event.block.BlockFadeEvent; +import org.bukkit.event.block.BlockSpreadEvent; +// CraftBukkit end + public class BlockFire extends Block { - public static final BlockStateInteger AGE = BlockStateInteger.of("age", 0, 15); -@@ -95,7 +101,7 @@ - public void b(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) { + public static final BlockStateInteger AGE = BlockProperties.W; +@@ -32,7 +42,20 @@ + } + + public IBlockData updateState(IBlockData iblockdata, EnumDirection enumdirection, IBlockData iblockdata1, GeneratorAccess generatoraccess, BlockPosition blockposition, BlockPosition blockposition1) { +- return this.canPlace(iblockdata, generatoraccess, blockposition) ? (IBlockData) this.a((IBlockAccess) generatoraccess, blockposition).set(BlockFire.AGE, iblockdata.get(BlockFire.AGE)) : Blocks.AIR.getBlockData(); ++ // CraftBukkit start ++ if (!iblockdata.canPlace(generatoraccess, blockposition)) { ++ CraftBlockState blockState = CraftBlockState.getBlockState(generatoraccess, blockposition); ++ blockState.setData(Blocks.AIR.getBlockData()); ++ ++ BlockFadeEvent event = new BlockFadeEvent(blockState.getBlock(), blockState); ++ generatoraccess.getMinecraftWorld().getMinecraftServer().server.getPluginManager().callEvent(event); ++ ++ if (!event.isCancelled()) { ++ return blockState.getHandle(); ++ } ++ } ++ return this.a((IBlockAccess) generatoraccess, blockposition).set(BlockFire.AGE, iblockdata.get(BlockFire.AGE)); ++ // CraftBukkit end + } + + @Nullable +@@ -82,7 +105,7 @@ + public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) { if (world.getGameRules().getBoolean("doFireTick")) { - if (!this.canPlace(world, blockposition)) { + if (!iblockdata.canPlace(world, blockposition)) { - world.setAir(blockposition); + fireExtinguished(world, blockposition); // CraftBukkit - invalid place location } Block block = world.getType(blockposition.down()).getBlock(); -@@ -108,7 +114,7 @@ +@@ -90,7 +113,7 @@ int i = ((Integer) iblockdata.get(BlockFire.AGE)).intValue(); - if (!flag && world.isRaining() && this.b(world, blockposition) && random.nextFloat() < 0.2F + (float) i * 0.03F) { + if (!flag && world.isRaining() && this.a(world, blockposition) && random.nextFloat() < 0.2F + (float) i * 0.03F) { - world.setAir(blockposition); + fireExtinguished(world, blockposition); // CraftBukkit - extinguished by rain } else { - if (i < 15) { - iblockdata = iblockdata.set(BlockFire.AGE, Integer.valueOf(i + random.nextInt(3) / 2)); -@@ -119,14 +125,14 @@ - if (!flag) { - if (!this.c(world, blockposition)) { + int j = Math.min(15, i + random.nextInt(3) / 2); + +@@ -103,14 +126,14 @@ + world.I().a(blockposition, this, this.a((IWorldReader) world) + random.nextInt(10)); + if (!this.d(world, blockposition)) { if (!world.getType(blockposition.down()).q() || i > 3) { - world.setAir(blockposition); + fireExtinguished(world, blockposition); // CraftBukkit @@ -42,68 +68,57 @@ return; } - if (!this.c((IBlockAccess) world, blockposition.down()) && i == 15 && random.nextInt(4) == 0) { + if (i == 15 && random.nextInt(4) == 0 && !this.j(world.getType(blockposition.down()))) { - world.setAir(blockposition); + fireExtinguished(world, blockposition); // CraftBukkit return; } } -@@ -138,12 +144,14 @@ - b0 = -50; - } +@@ -118,12 +141,14 @@ + boolean flag1 = world.x(blockposition); + int k = flag1 ? -50 : 0; -- this.a(world, blockposition.east(), 300 + b0, random, i); -- this.a(world, blockposition.west(), 300 + b0, random, i); -- this.a(world, blockposition.down(), 250 + b0, random, i); -- this.a(world, blockposition.up(), 250 + b0, random, i); -- this.a(world, blockposition.north(), 300 + b0, random, i); -- this.a(world, blockposition.south(), 300 + b0, random, i); +- this.a(world, blockposition.east(), 300 + k, random, i); +- this.a(world, blockposition.west(), 300 + k, random, i); +- this.a(world, blockposition.down(), 250 + k, random, i); +- this.a(world, blockposition.up(), 250 + k, random, i); +- this.a(world, blockposition.north(), 300 + k, random, i); +- this.a(world, blockposition.south(), 300 + k, random, i); + // CraftBukkit start - add source blockposition to burn calls -+ this.a(world, blockposition.east(), 300 + b0, random, i, blockposition); -+ this.a(world, blockposition.west(), 300 + b0, random, i, blockposition); -+ this.a(world, blockposition.down(), 250 + b0, random, i, blockposition); -+ this.a(world, blockposition.up(), 250 + b0, random, i, blockposition); -+ this.a(world, blockposition.north(), 300 + b0, random, i, blockposition); -+ this.a(world, blockposition.south(), 300 + b0, random, i, blockposition); ++ this.a(world, blockposition.east(), 300 + k, random, i, blockposition); ++ this.a(world, blockposition.west(), 300 + k, random, i, blockposition); ++ this.a(world, blockposition.down(), 250 + k, random, i, blockposition); ++ this.a(world, blockposition.up(), 250 + k, random, i, blockposition); ++ this.a(world, blockposition.north(), 300 + k, random, i, blockposition); ++ this.a(world, blockposition.south(), 300 + k, random, i, blockposition); + // CraftBukkit end + BlockPosition.MutableBlockPosition blockposition_mutableblockposition = new BlockPosition.MutableBlockPosition(); - for (int j = -1; j <= 1; ++j) { - for (int k = -1; k <= 1; ++k) { -@@ -172,7 +180,26 @@ - l1 = 15; - } + for (int l = -1; l <= 1; ++l) { +@@ -149,7 +174,15 @@ + if (i2 > 0 && random.nextInt(k1) <= i2 && (!world.isRaining() || !this.a(world, (BlockPosition) blockposition_mutableblockposition))) { + int j2 = Math.min(15, i + random.nextInt(5) / 4); -- world.setTypeAndData(blockposition1, iblockdata.set(BlockFire.AGE, Integer.valueOf(l1)), 3); +- world.setTypeAndData(blockposition_mutableblockposition, (IBlockData) this.a((IBlockAccess) world, (BlockPosition) blockposition_mutableblockposition).set(BlockFire.AGE, Integer.valueOf(j2)), 3); + // CraftBukkit start - Call to stop spread of fire -+ if (world.getType(blockposition1) != Blocks.FIRE) { -+ if (CraftEventFactory.callBlockIgniteEvent(world, blockposition1.getX(), blockposition1.getY(), blockposition1.getZ(), blockposition.getX(), blockposition.getY(), blockposition.getZ()).isCancelled()) { ++ if (world.getType(blockposition_mutableblockposition) != Blocks.FIRE) { ++ if (CraftEventFactory.callBlockIgniteEvent(world, blockposition_mutableblockposition, blockposition).isCancelled()) { + continue; + } + -+ org.bukkit.Server server = world.getServer(); -+ org.bukkit.World bworld = world.getWorld(); -+ org.bukkit.block.BlockState blockState = bworld.getBlockAt(blockposition1.getX(), blockposition1.getY(), blockposition1.getZ()).getState(); -+ blockState.setTypeId(Block.getId(this)); -+ blockState.setData(new org.bukkit.material.MaterialData(Block.getId(this), (byte) l1)); -+ -+ BlockSpreadEvent spreadEvent = new BlockSpreadEvent(blockState.getBlock(), bworld.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), blockState); -+ server.getPluginManager().callEvent(spreadEvent); -+ -+ if (!spreadEvent.isCancelled()) { -+ blockState.update(true); -+ } ++ CraftEventFactory.handleBlockSpreadEvent(world, blockposition, blockposition_mutableblockposition, (IBlockData) this.a((IBlockAccess) world, (BlockPosition) blockposition_mutableblockposition).set(BlockFire.AGE, Integer.valueOf(j2)), 3); // CraftBukkit + } + // CraftBukkit end } } } -@@ -204,12 +231,24 @@ - return integer == null ? 0 : integer.intValue(); +@@ -173,12 +206,24 @@ + return this.flameChances.getInt(block); } - private void a(World world, BlockPosition blockposition, int i, Random random, int j) { + private void a(World world, BlockPosition blockposition, int i, Random random, int j, BlockPosition sourceposition) { // CraftBukkit add sourceposition - int k = this.e(world.getType(blockposition).getBlock()); + int k = this.f(world.getType(blockposition).getBlock()); if (random.nextInt(i) < k) { IBlockData iblockdata = world.getType(blockposition); @@ -121,34 +136,25 @@ + // CraftBukkit end + if (random.nextInt(j + 10) < 5 && !world.isRainingAt(blockposition)) { - int l = j + random.nextInt(5) / 4; + int l = Math.min(j + random.nextInt(5) / 4, 15); -@@ -276,7 +315,7 @@ - - public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Block block, BlockPosition blockposition1) { - if (!world.getType(blockposition.down()).q() && !this.c(world, blockposition)) { -- world.setAir(blockposition); -+ fireExtinguished(world, blockposition); // CraftBukkit - fuel block gone - } - - } -@@ -284,7 +323,7 @@ - public void onPlace(World world, BlockPosition blockposition, IBlockData iblockdata) { - if (world.worldProvider.getDimensionManager().getDimensionID() > 0 || !Blocks.PORTAL.b(world, blockposition)) { - if (!world.getType(blockposition.down()).q() && !this.c(world, blockposition)) { -- world.setAir(blockposition); -+ fireExtinguished(world, blockposition); // CraftBukkit - fuel block broke - } else { - world.a(blockposition, (Block) this, this.a(world) + world.random.nextInt(10)); - } -@@ -310,4 +349,12 @@ - public EnumBlockFaceShape a(IBlockAccess iblockaccess, IBlockData iblockdata, BlockPosition blockposition, EnumDirection enumdirection) { - return EnumBlockFaceShape.UNDEFINED; +@@ -241,7 +286,7 @@ + if (iblockdata1.getBlock() != iblockdata.getBlock()) { + if (world.worldProvider.getDimensionManager().getDimensionID() > 0 || !((BlockPortal) Blocks.NETHER_PORTAL).a((GeneratorAccess) world, blockposition)) { + if (!iblockdata.canPlace(world, blockposition)) { +- world.setAir(blockposition); ++ fireExtinguished(world, blockposition); // CraftBukkit - fuel block broke + } else { + world.I().a(blockposition, this, this.a((IWorldReader) world) + world.random.nextInt(10)); + } +@@ -387,4 +432,12 @@ + blockfire.a(Blocks.BLACK_CARPET, 60, 20); + blockfire.a(Blocks.DRIED_KELP_BLOCK, 30, 60); } + + // CraftBukkit start -+ private void fireExtinguished(World world, BlockPosition position) { -+ if (!CraftEventFactory.callBlockFadeEvent(world.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ()), Blocks.AIR).isCancelled()) { ++ private void fireExtinguished(GeneratorAccess world, BlockPosition position) { ++ if (!CraftEventFactory.callBlockFadeEvent(world, position, Blocks.AIR.getBlockData()).isCancelled()) { + world.setAir(position); + } + } diff --git a/paper-server/nms-patches/BlockFlowing.patch b/paper-server/nms-patches/BlockFlowing.patch deleted file mode 100644 index 55906695fe..0000000000 --- a/paper-server/nms-patches/BlockFlowing.patch +++ /dev/null @@ -1,66 +0,0 @@ ---- a/net/minecraft/server/BlockFlowing.java -+++ b/net/minecraft/server/BlockFlowing.java -@@ -5,6 +5,11 @@ - import java.util.Random; - import java.util.Set; - -+// CraftBukkit start -+import org.bukkit.block.BlockFace; -+import org.bukkit.event.block.BlockFromToEvent; -+// CraftBukkit end -+ - public class BlockFlowing extends BlockFluids { - - int a; -@@ -85,12 +90,25 @@ - this.f(world, blockposition, iblockdata); - } - -+ org.bukkit.block.Block source = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); // CraftBukkit - IBlockData iblockdata2 = world.getType(blockposition.down()); - - if (this.h(world, blockposition.down(), iblockdata2)) { -+ // CraftBukkit start -+ BlockFromToEvent event = new BlockFromToEvent(source, BlockFace.DOWN); -+ world.getServer().getPluginManager().callEvent(event); -+ -+ if (event.isCancelled()) { -+ return; -+ } -+ // CraftBukkit end -+ - if (this.material == Material.LAVA && world.getType(blockposition.down()).getMaterial() == Material.WATER) { -- world.setTypeUpdate(blockposition.down(), Blocks.STONE.getBlockData()); -- this.fizz(world, blockposition.down()); -+ // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition.down(), Blocks.STONE.getBlockData(), null)) { -+ this.fizz(world, blockposition.down()); -+ } -+ // CraftBukkit end - return; - } - -@@ -116,14 +134,21 @@ - while (iterator1.hasNext()) { - EnumDirection enumdirection1 = (EnumDirection) iterator1.next(); - -- this.flow(world, blockposition.shift(enumdirection1), world.getType(blockposition.shift(enumdirection1)), k); -+ // CraftBukkit start -+ BlockFromToEvent event = new BlockFromToEvent(source, org.bukkit.craftbukkit.block.CraftBlock.notchToBlockFace(enumdirection1)); -+ world.getServer().getPluginManager().callEvent(event); -+ -+ if (!event.isCancelled()) { -+ this.flow(world, blockposition.shift(enumdirection1), world.getType(blockposition.shift(enumdirection1)), k); -+ } -+ // CraftBukkit end - } - } - - } - - private void flow(World world, BlockPosition blockposition, IBlockData iblockdata, int i) { -- if (this.h(world, blockposition, iblockdata)) { -+ if (world.isLoaded(blockposition) && this.h(world, blockposition, iblockdata)) { // CraftBukkit - add isLoaded check - if (iblockdata.getMaterial() != Material.AIR) { - if (this.material == Material.LAVA) { - this.fizz(world, blockposition); diff --git a/paper-server/nms-patches/BlockFluids.patch b/paper-server/nms-patches/BlockFluids.patch index cccec39459..cad979d2cc 100644 --- a/paper-server/nms-patches/BlockFluids.patch +++ b/paper-server/nms-patches/BlockFluids.patch @@ -1,27 +1,41 @@ --- a/net/minecraft/server/BlockFluids.java +++ b/net/minecraft/server/BlockFluids.java -@@ -175,14 +175,20 @@ - Integer integer = (Integer) iblockdata.get(BlockFluids.LEVEL); +@@ -46,10 +46,10 @@ + public VoxelShape a(IBlockData iblockdata, IBlockAccess iblockaccess, BlockPosition blockposition) { + Fluid fluid = iblockaccess.b(blockposition.up()); - if (integer.intValue() == 0) { +- return fluid.c().a((FluidType) this.b) ? VoxelShapes.b() : (VoxelShape) this.c.computeIfAbsent(iblockdata, (iblockdata) -> { +- Fluid fluid = iblockdata.s(); ++ return fluid.c().a((FluidType) this.b) ? VoxelShapes.b() : (VoxelShape) this.c.computeIfAbsent(iblockdata, (iblockdata1) -> { // CraftBukkit - decompile errors ++ Fluid fluid1 = iblockdata1.s(); + +- return VoxelShapes.a(0.0D, 0.0D, 0.0D, 1.0D, (double) fluid.f(), 1.0D); ++ return VoxelShapes.a(0.0D, 0.0D, 0.0D, 1.0D, (double) fluid1.f(), 1.0D); + }); + } + +@@ -106,14 +106,20 @@ + Fluid fluid = world.b(blockposition); + + if (fluid.d()) { - world.setTypeUpdate(blockposition, Blocks.OBSIDIAN.getBlockData()); - this.fizz(world, blockposition); + // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition, Blocks.OBSIDIAN.getBlockData(), null)) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition, Blocks.OBSIDIAN.getBlockData())) { + this.fizz(world, blockposition); + } + // CraftBukkit end - return true; + return false; } - if (integer.intValue() <= 4) { + if (fluid.f() >= 0.44444445F) { - world.setTypeUpdate(blockposition, Blocks.COBBLESTONE.getBlockData()); - this.fizz(world, blockposition); + // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition, Blocks.COBBLESTONE.getBlockData(), null)) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition, Blocks.COBBLESTONE.getBlockData())) { + this.fizz(world, blockposition); + } + // CraftBukkit end - return true; + return false; } } diff --git a/paper-server/nms-patches/BlockGrass.patch b/paper-server/nms-patches/BlockGrass.patch index 040f26ae68..68f953a26a 100644 --- a/paper-server/nms-patches/BlockGrass.patch +++ b/paper-server/nms-patches/BlockGrass.patch @@ -1,77 +1,11 @@ --- a/net/minecraft/server/BlockGrass.java +++ b/net/minecraft/server/BlockGrass.java -@@ -2,6 +2,14 @@ - - import java.util.Random; - -+// CraftBukkit start -+import org.bukkit.block.BlockState; -+import org.bukkit.craftbukkit.event.CraftEventFactory; -+import org.bukkit.craftbukkit.util.CraftMagicNumbers; -+import org.bukkit.event.block.BlockSpreadEvent; -+import org.bukkit.event.block.BlockFadeEvent; -+// CraftBukkit end -+ - public class BlockGrass extends Block implements IBlockFragilePlantElement { - - public static final BlockStateBoolean SNOWY = BlockStateBoolean.of("snowy"); -@@ -22,7 +30,19 @@ - public void b(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) { - if (!world.isClientSide) { - if (world.getLightLevel(blockposition.up()) < 4 && world.getType(blockposition.up()).c() > 2) { -- world.setTypeUpdate(blockposition, Blocks.DIRT.getBlockData()); -+ // CraftBukkit start -+ // world.setTypeUpdate(blockposition, Blocks.DIRT.getBlockData()); -+ org.bukkit.World bworld = world.getWorld(); -+ BlockState blockState = bworld.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()).getState(); -+ blockState.setType(CraftMagicNumbers.getMaterial(Blocks.DIRT)); -+ -+ BlockFadeEvent event = new BlockFadeEvent(blockState.getBlock(), blockState); -+ world.getServer().getPluginManager().callEvent(event); -+ -+ if (!event.isCancelled()) { -+ blockState.update(true); -+ } -+ // CraftBukkit end - } else { - if (world.getLightLevel(blockposition.up()) >= 9) { - for (int i = 0; i < 4; ++i) { -@@ -36,7 +56,19 @@ - IBlockData iblockdata2 = world.getType(blockposition1); - - if (iblockdata2.getBlock() == Blocks.DIRT && iblockdata2.get(BlockDirt.VARIANT) == BlockDirt.EnumDirtVariant.DIRT && world.getLightLevel(blockposition1.up()) >= 4 && iblockdata1.c() <= 2) { -- world.setTypeUpdate(blockposition1, Blocks.GRASS.getBlockData()); -+ // CraftBukkit start -+ // world.setTypeUpdate(blockposition1, Blocks.GRASS.getBlockData()); -+ org.bukkit.World bworld = world.getWorld(); -+ BlockState blockState = bworld.getBlockAt(blockposition1.getX(), blockposition1.getY(), blockposition1.getZ()).getState(); -+ blockState.setType(CraftMagicNumbers.getMaterial(Blocks.GRASS)); -+ -+ BlockSpreadEvent event = new BlockSpreadEvent(blockState.getBlock(), bworld.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), blockState); -+ world.getServer().getPluginManager().callEvent(event); -+ -+ if (!event.isCancelled()) { -+ blockState.update(true); -+ } -+ // CraftBukkit end +@@ -51,7 +51,7 @@ } - } - } -@@ -79,13 +111,15 @@ - IBlockData iblockdata1 = blockflowers.getBlockData().set(blockflowers.g(), blockflowers_enumflowervarient); - if (blockflowers.f(world, blockposition2, iblockdata1)) { -- world.setTypeAndData(blockposition2, iblockdata1, 3); -+ // world.setTypeAndData(blockposition2, iblockdata1, 3); // CraftBukkit -+ CraftEventFactory.handleBlockGrowEvent(world, blockposition2.getX(), blockposition2.getY(), blockposition2.getZ(), iblockdata1.getBlock(), iblockdata1.getBlock().toLegacyData(iblockdata1)); // CraftBukkit - } - } else { - IBlockData iblockdata2 = Blocks.TALLGRASS.getBlockData().set(BlockLongGrass.TYPE, BlockLongGrass.EnumTallGrassType.GRASS); - - if (Blocks.TALLGRASS.f(world, blockposition2, iblockdata2)) { + if (iblockdata2.canPlace(world, blockposition2)) { - world.setTypeAndData(blockposition2, iblockdata2, 3); -+ // world.setTypeAndData(blockposition2, iblockdata2, 3); // CraftBukkit -+ CraftEventFactory.handleBlockGrowEvent(world, blockposition2.getX(), blockposition2.getY(), blockposition2.getZ(), iblockdata2.getBlock(), iblockdata2.getBlock().toLegacyData(iblockdata2)); // CraftBukkit ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(world, blockposition2, iblockdata2, 3); // CraftBukkit } } } diff --git a/paper-server/nms-patches/BlockIce.patch b/paper-server/nms-patches/BlockIce.patch index 2971d2761b..e7a337606f 100644 --- a/paper-server/nms-patches/BlockIce.patch +++ b/paper-server/nms-patches/BlockIce.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/server/BlockIce.java +++ b/net/minecraft/server/BlockIce.java -@@ -47,6 +47,11 @@ +@@ -52,6 +52,11 @@ } - protected void b(World world, BlockPosition blockposition) { + protected void b(IBlockData iblockdata, World world, BlockPosition blockposition) { + // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), world.worldProvider.l() ? Blocks.AIR : Blocks.WATER).isCancelled()) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(world, blockposition, world.worldProvider.isNether() ? Blocks.AIR.getBlockData() : Blocks.WATER.getBlockData()).isCancelled()) { + return; + } + // CraftBukkit end - if (world.worldProvider.l()) { + if (world.worldProvider.isNether()) { world.setAir(blockposition); } else { diff --git a/paper-server/nms-patches/BlockJukeBox.patch b/paper-server/nms-patches/BlockJukeBox.patch deleted file mode 100644 index 2b1a5cd654..0000000000 --- a/paper-server/nms-patches/BlockJukeBox.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- a/net/minecraft/server/BlockJukeBox.java -+++ b/net/minecraft/server/BlockJukeBox.java -@@ -141,6 +141,11 @@ - } - - public void setRecord(ItemStack itemstack) { -+ // CraftBukkit start - There can only be one -+ if (!itemstack.isEmpty()) { -+ itemstack.setCount(1); -+ } -+ // CraftBukkit end - this.record = itemstack; - this.update(); - } diff --git a/paper-server/nms-patches/BlockLeaves.patch b/paper-server/nms-patches/BlockLeaves.patch index bb3a479d13..3aad2770dd 100644 --- a/paper-server/nms-patches/BlockLeaves.patch +++ b/paper-server/nms-patches/BlockLeaves.patch @@ -1,26 +1,26 @@ --- a/net/minecraft/server/BlockLeaves.java +++ b/net/minecraft/server/BlockLeaves.java -@@ -2,6 +2,8 @@ - +@@ -3,6 +3,8 @@ import java.util.Random; + import javax.annotation.Nullable; +import org.bukkit.event.block.LeavesDecayEvent; // CraftBukkit + - public abstract class BlockLeaves extends Block { + public class BlockLeaves extends Block { - public static final BlockStateBoolean DECAYABLE = BlockStateBoolean.of("decayable"); -@@ -132,6 +134,14 @@ - } + public static final BlockStateInteger DISTANCE = BlockProperties.aa; +@@ -20,6 +22,14 @@ - private void b(World world, BlockPosition blockposition) { -+ // CraftBukkit start -+ LeavesDecayEvent event = new LeavesDecayEvent(world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ())); -+ world.getServer().getPluginManager().callEvent(event); + public void b(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) { + if (!((Boolean) iblockdata.get(BlockLeaves.PERSISTENT)).booleanValue() && ((Integer) iblockdata.get(BlockLeaves.DISTANCE)).intValue() == 7) { ++ // CraftBukkit start ++ LeavesDecayEvent event = new LeavesDecayEvent(world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ())); ++ world.getServer().getPluginManager().callEvent(event); + -+ if (event.isCancelled() || world.getType(blockposition).getBlock() != this) { -+ return; -+ } -+ // CraftBukkit end - this.b(world, blockposition, world.getType(blockposition), 0); - world.setAir(blockposition); - } ++ if (event.isCancelled() || world.getType(blockposition).getBlock() != this) { ++ return; ++ } ++ // CraftBukkit end + iblockdata.a(world, blockposition, 0); + world.setAir(blockposition); + } diff --git a/paper-server/nms-patches/BlockLever.patch b/paper-server/nms-patches/BlockLever.patch index db03cc1ff7..945ac93564 100644 --- a/paper-server/nms-patches/BlockLever.patch +++ b/paper-server/nms-patches/BlockLever.patch @@ -1,16 +1,15 @@ --- a/net/minecraft/server/BlockLever.java +++ b/net/minecraft/server/BlockLever.java -@@ -3,6 +3,8 @@ - import java.util.Iterator; - import javax.annotation.Nullable; +@@ -1,5 +1,7 @@ + package net.minecraft.server; +import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit + - public class BlockLever extends Block { + public class BlockLever extends BlockAttachable { + + public static final BlockStateBoolean POWERED = BlockProperties.t; +@@ -73,6 +75,20 @@ - public static final BlockStateEnum FACING = BlockStateEnum.of("facing", BlockLever.EnumLeverPosition.class); -@@ -129,6 +131,20 @@ - if (world.isClientSide) { return true; } else { + // CraftBukkit start - Interact Lever @@ -27,6 +26,6 @@ + } + // CraftBukkit end + - iblockdata = iblockdata.a((IBlockState) BlockLever.POWERED); world.setTypeAndData(blockposition, iblockdata, 3); - float f3 = ((Boolean) iblockdata.get(BlockLever.POWERED)).booleanValue() ? 0.6F : 0.5F; + float f3 = flag ? 0.6F : 0.5F; + diff --git a/paper-server/nms-patches/BlockMagma.patch b/paper-server/nms-patches/BlockMagma.patch index 75f5fbad9b..6e1cc11c38 100644 --- a/paper-server/nms-patches/BlockMagma.patch +++ b/paper-server/nms-patches/BlockMagma.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/BlockMagma.java +++ b/net/minecraft/server/BlockMagma.java -@@ -17,7 +17,9 @@ +@@ -10,7 +10,9 @@ public void stepOn(World world, BlockPosition blockposition, Entity entity) { if (!entity.isFireProof() && entity instanceof EntityLiving && !EnchantmentManager.i((EntityLiving) entity)) { diff --git a/paper-server/nms-patches/BlockMinecartDetector.patch b/paper-server/nms-patches/BlockMinecartDetector.patch index 014c510205..071412c986 100644 --- a/paper-server/nms-patches/BlockMinecartDetector.patch +++ b/paper-server/nms-patches/BlockMinecartDetector.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/server/BlockMinecartDetector.java +++ b/net/minecraft/server/BlockMinecartDetector.java @@ -6,6 +6,8 @@ - import java.util.Random; + import java.util.function.Predicate; import javax.annotation.Nullable; +import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit + public class BlockMinecartDetector extends BlockMinecartTrackAbstract { - public static final BlockStateEnum SHAPE = BlockStateEnum.a("shape", BlockMinecartTrackAbstract.EnumTrackPosition.class, new Predicate() { -@@ -66,6 +68,17 @@ + public static final BlockStateEnum SHAPE = BlockProperties.R; +@@ -55,6 +57,17 @@ flag1 = true; } @@ -25,5 +25,5 @@ + // CraftBukkit end + if (flag1 && !flag) { - world.setTypeAndData(blockposition, iblockdata.set(BlockMinecartDetector.POWERED, Boolean.valueOf(true)), 3); + world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockMinecartDetector.POWERED, Boolean.valueOf(true)), 3); this.b(world, blockposition, iblockdata, true); diff --git a/paper-server/nms-patches/BlockMobSpawner.patch b/paper-server/nms-patches/BlockMobSpawner.patch index 67c46a901d..2b95d6b1db 100644 --- a/paper-server/nms-patches/BlockMobSpawner.patch +++ b/paper-server/nms-patches/BlockMobSpawner.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/server/BlockMobSpawner.java +++ b/net/minecraft/server/BlockMobSpawner.java -@@ -22,9 +22,19 @@ +@@ -16,9 +16,19 @@ - public void dropNaturally(World world, BlockPosition blockposition, IBlockData iblockdata, float f, int i) { - super.dropNaturally(world, blockposition, iblockdata, f, i); + public void dropNaturally(IBlockData iblockdata, World world, BlockPosition blockposition, float f, int i) { + super.dropNaturally(iblockdata, world, blockposition, f, i); + /* CraftBukkit start - Delegate to getExpDrop int j = 15 + world.random.nextInt(15) + world.random.nextInt(15); @@ -12,11 +12,11 @@ + } + + @Override -+ public int getExpDrop(World world, IBlockData iblockdata, int enchantmentLevel) { ++ public int getExpDrop(IBlockData iblockdata, World world, BlockPosition blockposition, int enchantmentLevel) { + int j = 15 + world.random.nextInt(15) + world.random.nextInt(15); + + return j; + // CraftBukkit end } - public boolean b(IBlockData iblockdata) { + public EnumRenderType c(IBlockData iblockdata) { diff --git a/paper-server/nms-patches/BlockMonsterEggs.patch b/paper-server/nms-patches/BlockMonsterEggs.patch index ae60b27d24..7b493438b3 100644 --- a/paper-server/nms-patches/BlockMonsterEggs.patch +++ b/paper-server/nms-patches/BlockMonsterEggs.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/server/BlockMonsterEggs.java +++ b/net/minecraft/server/BlockMonsterEggs.java -@@ -2,6 +2,8 @@ - +@@ -4,6 +4,8 @@ + import java.util.Map; import java.util.Random; +import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; // CraftBukkit + public class BlockMonsterEggs extends Block { - public static final BlockStateEnum VARIANT = BlockStateEnum.of("variant", BlockMonsterEggs.EnumMonsterEggVarient.class); -@@ -50,7 +52,7 @@ + private final Block a; +@@ -36,7 +38,7 @@ EntitySilverfish entitysilverfish = new EntitySilverfish(world); entitysilverfish.setPositionRotation((double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, 0.0F, 0.0F); diff --git a/paper-server/nms-patches/BlockMushroom.patch b/paper-server/nms-patches/BlockMushroom.patch index 911f296f7c..0787a57c0f 100644 --- a/paper-server/nms-patches/BlockMushroom.patch +++ b/paper-server/nms-patches/BlockMushroom.patch @@ -1,55 +1,41 @@ --- a/net/minecraft/server/BlockMushroom.java +++ b/net/minecraft/server/BlockMushroom.java -@@ -3,6 +3,12 @@ +@@ -3,6 +3,10 @@ import java.util.Iterator; import java.util.Random; +// CraftBukkit start +import org.bukkit.TreeType; -+import org.bukkit.block.BlockState; -+import org.bukkit.event.block.BlockSpreadEvent; +// CraftBukkit end + public class BlockMushroom extends BlockPlant implements IBlockFragilePlantElement { - protected static final AxisAlignedBB a = new AxisAlignedBB(0.30000001192092896D, 0.0D, 0.30000001192092896D, 0.699999988079071D, 0.4000000059604645D, 0.699999988079071D); -@@ -16,6 +22,7 @@ + protected static final VoxelShape a = Block.a(5.0D, 0.0D, 5.0D, 11.0D, 6.0D, 11.0D); +@@ -16,6 +20,7 @@ } - public void b(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) { + public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) { + final int sourceX = blockposition.getX(), sourceY = blockposition.getY(), sourceZ = blockposition.getZ(); // CraftBukkit if (random.nextInt(25) == 0) { int i = 5; boolean flag = true; -@@ -43,7 +50,19 @@ +@@ -43,7 +48,7 @@ } - if (world.isEmpty(blockposition2) && this.f(world, blockposition2, this.getBlockData())) { -- world.setTypeAndData(blockposition2, this.getBlockData(), 2); -+ // CraftBukkit start -+ // world.setTypeAndData(blockposition2, this.getBlockData(), 2); -+ org.bukkit.World bworld = world.getWorld(); -+ BlockState blockState = bworld.getBlockAt(blockposition2.getX(), blockposition2.getY(), blockposition2.getZ()).getState(); -+ blockState.setType(org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(this)); // nms: this.id, 0, 2 -+ -+ BlockSpreadEvent event = new BlockSpreadEvent(blockState.getBlock(), bworld.getBlockAt(sourceX, sourceY, sourceZ), blockState); -+ world.getServer().getPluginManager().callEvent(event); -+ -+ if (!event.isCancelled()) { -+ blockState.update(true); -+ } -+ // CraftBukkit end + if (world.isEmpty(blockposition2) && iblockdata.canPlace(world, blockposition2)) { +- world.setTypeAndData(blockposition2, iblockdata, 2); ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(world, blockposition, blockposition2, iblockdata, 2); // CraftBukkit } } -@@ -72,8 +91,10 @@ - WorldGenHugeMushroom worldgenhugemushroom = null; +@@ -66,8 +71,10 @@ + WorldGenerator worldgenerator = null; if (this == Blocks.BROWN_MUSHROOM) { + BlockSapling.treeType = TreeType.BROWN_MUSHROOM; // CraftBukkit - worldgenhugemushroom = new WorldGenHugeMushroom(Blocks.BROWN_MUSHROOM_BLOCK); + worldgenerator = WorldGenerator.U; } else if (this == Blocks.RED_MUSHROOM) { + BlockSapling.treeType = TreeType.RED_MUSHROOM; // CraftBukkit - worldgenhugemushroom = new WorldGenHugeMushroom(Blocks.RED_MUSHROOM_BLOCK); + worldgenerator = WorldGenerator.T; } diff --git a/paper-server/nms-patches/BlockMycel.patch b/paper-server/nms-patches/BlockMycel.patch deleted file mode 100644 index 626b81bfc4..0000000000 --- a/paper-server/nms-patches/BlockMycel.patch +++ /dev/null @@ -1,58 +0,0 @@ ---- a/net/minecraft/server/BlockMycel.java -+++ b/net/minecraft/server/BlockMycel.java -@@ -2,6 +2,13 @@ - - import java.util.Random; - -+// CraftBukkit start -+import org.bukkit.block.BlockState; -+import org.bukkit.craftbukkit.util.CraftMagicNumbers; -+import org.bukkit.event.block.BlockFadeEvent; -+import org.bukkit.event.block.BlockSpreadEvent; -+// CraftBukkit end -+ - public class BlockMycel extends Block { - - public static final BlockStateBoolean SNOWY = BlockStateBoolean.of("snowy"); -@@ -22,7 +29,19 @@ - public void b(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) { - if (!world.isClientSide) { - if (world.getLightLevel(blockposition.up()) < 4 && world.getType(blockposition.up()).c() > 2) { -- world.setTypeUpdate(blockposition, Blocks.DIRT.getBlockData().set(BlockDirt.VARIANT, BlockDirt.EnumDirtVariant.DIRT)); -+ // CraftBukkit start -+ // world.setTypeUpdate(blockposition, Blocks.DIRT.getBlockData().set(BlockDirt.VARIANT, BlockDirt.EnumDirtVariant.DIRT)); -+ org.bukkit.World bworld = world.getWorld(); -+ BlockState blockState = bworld.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()).getState(); -+ blockState.setType(CraftMagicNumbers.getMaterial(Blocks.DIRT)); -+ -+ BlockFadeEvent event = new BlockFadeEvent(blockState.getBlock(), blockState); -+ world.getServer().getPluginManager().callEvent(event); -+ -+ if (!event.isCancelled()) { -+ blockState.update(true); -+ } -+ // CraftBukkit end - } else { - if (world.getLightLevel(blockposition.up()) >= 9) { - for (int i = 0; i < 4; ++i) { -@@ -31,7 +50,19 @@ - IBlockData iblockdata2 = world.getType(blockposition1.up()); - - if (iblockdata1.getBlock() == Blocks.DIRT && iblockdata1.get(BlockDirt.VARIANT) == BlockDirt.EnumDirtVariant.DIRT && world.getLightLevel(blockposition1.up()) >= 4 && iblockdata2.c() <= 2) { -- world.setTypeUpdate(blockposition1, this.getBlockData()); -+ // CraftBukkit start -+ // world.setTypeUpdate(blockposition1, this.getBlockData()); -+ org.bukkit.World bworld = world.getWorld(); -+ BlockState blockState = bworld.getBlockAt(blockposition1.getX(), blockposition1.getY(), blockposition1.getZ()).getState(); -+ blockState.setType(CraftMagicNumbers.getMaterial(this)); -+ -+ BlockSpreadEvent event = new BlockSpreadEvent(blockState.getBlock(), bworld.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), blockState); -+ world.getServer().getPluginManager().callEvent(event); -+ -+ if (!event.isCancelled()) { -+ blockState.update(true); -+ } -+ // CraftBukkit end - } - } - } diff --git a/paper-server/nms-patches/BlockNetherWart.patch b/paper-server/nms-patches/BlockNetherWart.patch index 1af3f818a2..f0aca39fdd 100644 --- a/paper-server/nms-patches/BlockNetherWart.patch +++ b/paper-server/nms-patches/BlockNetherWart.patch @@ -1,12 +1,11 @@ --- a/net/minecraft/server/BlockNetherWart.java +++ b/net/minecraft/server/BlockNetherWart.java -@@ -31,7 +31,8 @@ +@@ -25,7 +25,7 @@ if (i < 3 && random.nextInt(10) == 0) { - iblockdata = iblockdata.set(BlockNetherWart.AGE, Integer.valueOf(i + 1)); + iblockdata = (IBlockData) iblockdata.set(BlockNetherWart.AGE, Integer.valueOf(i + 1)); - world.setTypeAndData(blockposition, iblockdata, 2); -+ // world.setTypeAndData(blockposition, iblockdata, 2); // CraftBukkit -+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this, toLegacyData(iblockdata)); // CraftBukkit ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(world, blockposition, iblockdata, 2); // CraftBukkit } - super.b(world, blockposition, iblockdata, random); + super.a(iblockdata, world, blockposition, random); diff --git a/paper-server/nms-patches/BlockNote.patch b/paper-server/nms-patches/BlockNote.patch new file mode 100644 index 0000000000..246b882bc8 --- /dev/null +++ b/paper-server/nms-patches/BlockNote.patch @@ -0,0 +1,46 @@ +--- a/net/minecraft/server/BlockNote.java ++++ b/net/minecraft/server/BlockNote.java +@@ -24,7 +24,7 @@ + + if (flag != ((Boolean) iblockdata.get(BlockNote.POWERED)).booleanValue()) { + if (flag) { +- this.play(world, blockposition); ++ this.play(world, blockposition, iblockdata); // CraftBukkit + } + + world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockNote.POWERED, Boolean.valueOf(flag)), 3); +@@ -32,9 +32,14 @@ + + } + +- private void play(World world, BlockPosition blockposition) { ++ private void play(World world, BlockPosition blockposition, IBlockData data) { // CraftBukkit + if (world.getType(blockposition.up()).isAir()) { +- world.playBlockAction(blockposition, this, 0, 0); ++ // CraftBukkit start ++ org.bukkit.event.block.NotePlayEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callNotePlayEvent(world, blockposition, data.get(BlockNote.INSTRUMENT), data.get(BlockNote.NOTE)); ++ if (!event.isCancelled()) { ++ world.playBlockAction(blockposition, this, 0, 0); ++ } ++ // CraftBukkit end + } + + } +@@ -45,7 +50,7 @@ + } else { + iblockdata = (IBlockData) iblockdata.a((IBlockState) BlockNote.NOTE); + world.setTypeAndData(blockposition, iblockdata, 3); +- this.play(world, blockposition); ++ this.play(world, blockposition, iblockdata); // CraftBukkit + entityhuman.a(StatisticList.TUNE_NOTEBLOCK); + return true; + } +@@ -53,7 +58,7 @@ + + public void attack(IBlockData iblockdata, World world, BlockPosition blockposition, EntityHuman entityhuman) { + if (!world.isClientSide) { +- this.play(world, blockposition); ++ this.play(world, blockposition, iblockdata); // CraftBukkit + entityhuman.a(StatisticList.PLAY_NOTEBLOCK); + } + } diff --git a/paper-server/nms-patches/BlockOre.patch b/paper-server/nms-patches/BlockOre.patch index 236ce96e70..38a989393a 100644 --- a/paper-server/nms-patches/BlockOre.patch +++ b/paper-server/nms-patches/BlockOre.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/server/BlockOre.java +++ b/net/minecraft/server/BlockOre.java -@@ -37,6 +37,7 @@ +@@ -32,6 +32,7 @@ - public void dropNaturally(World world, BlockPosition blockposition, IBlockData iblockdata, float f, int i) { - super.dropNaturally(world, blockposition, iblockdata, f, i); + public void dropNaturally(IBlockData iblockdata, World world, BlockPosition blockposition, float f, int i) { + super.dropNaturally(iblockdata, world, blockposition, f, i); + /* CraftBukkit start - Delegated to getExpDrop - if (this.getDropType(iblockdata, world.random, i) != Item.getItemOf(this)) { + if (this.getDropType(iblockdata, world, blockposition, i) != this) { int j = 0; -@@ -54,9 +55,34 @@ +@@ -49,9 +50,34 @@ this.dropExperience(world, blockposition, j); } @@ -17,8 +17,8 @@ } + @Override -+ public int getExpDrop(World world, IBlockData iblockdata, int i) { -+ if (this.getDropType(iblockdata, world.random, i) != Item.getItemOf(this)) { ++ public int getExpDrop(IBlockData iblockdata, World world, BlockPosition blockposition, int enchantmentLevel) { ++ if (this.getDropType(iblockdata, world, blockposition, enchantmentLevel) != this) { + int j = 0; + + if (this == Blocks.COAL_ORE) { @@ -29,7 +29,7 @@ + j = MathHelper.nextInt(world.random, 3, 7); + } else if (this == Blocks.LAPIS_ORE) { + j = MathHelper.nextInt(world.random, 2, 5); -+ } else if (this == Blocks.QUARTZ_ORE) { ++ } else if (this == Blocks.NETHER_QUARTZ_ORE) { + j = MathHelper.nextInt(world.random, 2, 5); + } + @@ -40,6 +40,6 @@ + // CraftBukkit end + } + - public ItemStack a(World world, BlockPosition blockposition, IBlockData iblockdata) { + public ItemStack a(IBlockAccess iblockaccess, BlockPosition blockposition, IBlockData iblockdata) { return new ItemStack(this); } diff --git a/paper-server/nms-patches/BlockPiston.patch b/paper-server/nms-patches/BlockPiston.patch index c7e24f36f5..ae8fcc83a6 100644 --- a/paper-server/nms-patches/BlockPiston.patch +++ b/paper-server/nms-patches/BlockPiston.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/BlockPiston.java +++ b/net/minecraft/server/BlockPiston.java -@@ -5,6 +5,18 @@ +@@ -7,6 +7,18 @@ + import java.util.Iterator; import java.util.List; - import javax.annotation.Nullable; +// CraftBukkit start +import java.util.AbstractList; @@ -18,39 +18,30 @@ + public class BlockPiston extends BlockDirectional { - public static final BlockStateBoolean EXTENDED = BlockStateBoolean.of("extended"); -@@ -103,6 +115,18 @@ - world.playBlockAction(blockposition, this, 0, enumdirection.a()); - } - } else if (!flag && ((Boolean) iblockdata.get(BlockPiston.EXTENDED)).booleanValue()) { -+ // CraftBukkit start -+ if (!this.sticky) { -+ org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); -+ BlockPistonRetractEvent event = new BlockPistonRetractEvent(block, ImmutableList.of(), CraftBlock.notchToBlockFace(enumdirection)); -+ world.getServer().getPluginManager().callEvent(event); -+ -+ if (event.isCancelled()) { -+ return; -+ } -+ } -+ // PAIL: checkME - what happened to setTypeAndData? -+ // CraftBukkit end - world.playBlockAction(blockposition, this, 1, enumdirection.a()); - } - -@@ -193,7 +217,7 @@ + public static final BlockStateBoolean EXTENDED = BlockProperties.f; +@@ -109,6 +121,18 @@ + b0 = 2; } } ++ // CraftBukkit start ++ if (!this.sticky) { ++ org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); ++ BlockPistonRetractEvent event = new BlockPistonRetractEvent(block, ImmutableList.of(), CraftBlock.notchToBlockFace(enumdirection)); ++ world.getServer().getPluginManager().callEvent(event); ++ ++ if (event.isCancelled()) { ++ return; ++ } ++ } ++ // PAIL: checkME - what happened to setTypeAndData? ++ // CraftBukkit end + } -- if (!flag1 && iblockdata1.getMaterial() != Material.AIR && a(iblockdata1, world, blockposition1, enumdirection.opposite(), false, enumdirection) && (iblockdata1.o() == EnumPistonReaction.NORMAL || block == Blocks.PISTON || block == Blocks.STICKY_PISTON)) { -+ if (!flag1 && a(iblockdata1, world, blockposition1, enumdirection.opposite(), false, enumdirection) && (iblockdata1.o() == EnumPistonReaction.NORMAL || block == Blocks.PISTON || block == Blocks.STICKY_PISTON)) { // CraftBukkit - remove 'block.getMaterial() != Material.AIR' condition - this.a(world, blockposition, enumdirection, false); - } - } else { -@@ -277,6 +301,48 @@ - int j = list.size() + list1.size(); + world.playBlockAction(blockposition, this, b0, enumdirection.a()); +@@ -271,6 +295,48 @@ IBlockData[] aiblockdata = new IBlockData[j]; EnumDirection enumdirection1 = flag ? enumdirection : enumdirection.opposite(); + HashSet hashset = Sets.newHashSet(list); + // CraftBukkit start + final org.bukkit.block.Block bblock = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); + diff --git a/paper-server/nms-patches/BlockPlant.patch b/paper-server/nms-patches/BlockPlant.patch index c9ac5dc76e..d3ff331e3d 100644 --- a/paper-server/nms-patches/BlockPlant.patch +++ b/paper-server/nms-patches/BlockPlant.patch @@ -1,14 +1,18 @@ --- a/net/minecraft/server/BlockPlant.java +++ b/net/minecraft/server/BlockPlant.java -@@ -40,6 +40,11 @@ +@@ -13,7 +13,14 @@ + } - protected void e(World world, BlockPosition blockposition, IBlockData iblockdata) { - if (!this.f(world, blockposition, iblockdata)) { -+ // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPhysicsEvent(world, blockposition).isCancelled()) { -+ return; + public IBlockData updateState(IBlockData iblockdata, EnumDirection enumdirection, IBlockData iblockdata1, GeneratorAccess generatoraccess, BlockPosition blockposition, BlockPosition blockposition1) { +- return !iblockdata.canPlace(generatoraccess, blockposition) ? Blocks.AIR.getBlockData() : super.updateState(iblockdata, enumdirection, iblockdata1, generatoraccess, blockposition, blockposition1); ++ // CraftBukkit start ++ if (!iblockdata.canPlace(generatoraccess, blockposition)) { ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPhysicsEvent(generatoraccess, blockposition).isCancelled()) { ++ return Blocks.AIR.getBlockData(); + } -+ // CraftBukkit end - this.b(world, blockposition, iblockdata, 0); - world.setTypeAndData(blockposition, Blocks.AIR.getBlockData(), 3); - } ++ } ++ return super.updateState(iblockdata, enumdirection, iblockdata1, generatoraccess, blockposition, blockposition1); ++ // CraftBukkit end + } + + public boolean canPlace(IBlockData iblockdata, IWorldReader iworldreader, BlockPosition blockposition) { diff --git a/paper-server/nms-patches/BlockPortal.patch b/paper-server/nms-patches/BlockPortal.patch index f9ccf2aa03..07c4cf2018 100644 --- a/paper-server/nms-patches/BlockPortal.patch +++ b/paper-server/nms-patches/BlockPortal.patch @@ -1,50 +1,45 @@ --- a/net/minecraft/server/BlockPortal.java +++ b/net/minecraft/server/BlockPortal.java -@@ -4,6 +4,9 @@ +@@ -4,6 +4,12 @@ import java.util.Random; import javax.annotation.Nullable; -+import org.bukkit.event.entity.EntityPortalEnterEvent; // CraftBukkit -+import org.bukkit.event.world.PortalCreateEvent; // CraftBukkit ++// CraftBukkit start ++import org.bukkit.craftbukkit.block.CraftBlock; ++import org.bukkit.event.entity.EntityPortalEnterEvent; ++import org.bukkit.event.world.PortalCreateEvent; ++// CraftBukkit end + - public class BlockPortal extends BlockHalfTransparent { + public class BlockPortal extends Block { - public static final BlockStateEnum AXIS = BlockStateEnum.of("axis", EnumDirection.EnumAxis.class, new EnumDirection.EnumAxis[] { EnumDirection.EnumAxis.X, EnumDirection.EnumAxis.Z}); -@@ -43,7 +46,8 @@ + public static final BlockStateEnum AXIS = BlockProperties.y; +@@ -37,7 +43,8 @@ } - if (i > 0 && !world.getType(blockposition1.up()).l()) { -- Entity entity = ItemMonsterEgg.a(world, EntityTypes.getName(EntityPigZombie.class), (double) blockposition1.getX() + 0.5D, (double) blockposition1.getY() + 1.1D, (double) blockposition1.getZ() + 0.5D); + if (i > 0 && !world.getType(blockposition1.up()).isOccluding()) { +- Entity entity = EntityTypes.ZOMBIE_PIGMAN.a(world, (NBTTagCompound) null, (IChatBaseComponent) null, (EntityHuman) null, blockposition1.up(), false, false); + // CraftBukkit - set spawn reason to NETHER_PORTAL -+ Entity entity = ItemMonsterEgg.spawnCreature(world, EntityTypes.getName(EntityPigZombie.class), (double) blockposition1.getX() + 0.5D, (double) blockposition1.getY() + 1.1D, (double) blockposition1.getZ() + 0.5D, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NETHER_PORTAL); ++ Entity entity = EntityTypes.ZOMBIE_PIGMAN.spawnCreature(world, (NBTTagCompound) null, (IChatBaseComponent) null, (EntityHuman) null, blockposition1.up(), false, false, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NETHER_PORTAL); if (entity != null) { - entity.portalCooldown = entity.aM(); -@@ -70,14 +74,16 @@ - BlockPortal.Shape blockportal_shape = new BlockPortal.Shape(world, blockposition, EnumDirection.EnumAxis.X); + entity.portalCooldown = entity.aQ(); +@@ -55,8 +62,10 @@ + BlockPortal.Shape blockportal_shape = this.b(generatoraccess, blockposition); - if (blockportal_shape.d() && blockportal_shape.e == 0) { + if (blockportal_shape != null) { - blockportal_shape.createPortal(); - return true; + // CraftBukkit start - return portalcreator + return blockportal_shape.createPortal(); + // return true; ++ // CraftBukkit end } else { - BlockPortal.Shape blockportal_shape1 = new BlockPortal.Shape(world, blockposition, EnumDirection.EnumAxis.Z); + return false; + } +@@ -93,6 +102,10 @@ - if (blockportal_shape1.d() && blockportal_shape1.e == 0) { -- blockportal_shape1.createPortal(); -- return true; -+ return blockportal_shape1.createPortal(); -+ // return true; -+ // CraftBukkit end - } else { - return false; - } -@@ -108,6 +114,10 @@ - - public void a(World world, BlockPosition blockposition, IBlockData iblockdata, Entity entity) { - if (!entity.isPassenger() && !entity.isVehicle() && entity.bf()) { + public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { + if (!entity.isPassenger() && !entity.isVehicle() && entity.bm()) { + // CraftBukkit start - Entity in portal + EntityPortalEnterEvent event = new EntityPortalEnterEvent(entity.getBukkitEntity(), new org.bukkit.Location(world.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ())); + world.getServer().getPluginManager().callEvent(event); @@ -52,33 +47,32 @@ entity.e(blockposition); } -@@ -216,6 +226,7 @@ +@@ -193,6 +206,7 @@ private BlockPosition position; private int height; private int width; + java.util.Collection blocks = new java.util.HashSet(); // CraftBukkit - add field - public Shape(World world, BlockPosition blockposition, EnumDirection.EnumAxis enumdirection_enumaxis) { - this.a = world; -@@ -274,6 +285,10 @@ + public Shape(GeneratorAccess generatoraccess, BlockPosition blockposition, EnumDirection.EnumAxis enumdirection_enumaxis) { + this.a = generatoraccess; +@@ -251,6 +265,9 @@ } protected int c() { + // CraftBukkit start + this.blocks.clear(); -+ org.bukkit.World bworld = this.a.getWorld(); + // CraftBukkit end int i; label56: -@@ -294,11 +309,21 @@ +@@ -273,11 +290,21 @@ block = this.a.getType(blockposition.shift(this.d)).getBlock(); if (block != Blocks.OBSIDIAN) { break label56; + // CraftBukkit start - add the block to our list + } else { + BlockPosition pos = blockposition.shift(this.d); -+ blocks.add(bworld.getBlockAt(pos.getX(), pos.getY(), pos.getZ())); ++ blocks.add(CraftBlock.at(this.a, pos)); + // CraftBukkit end } } else if (i == this.width - 1) { @@ -88,31 +82,31 @@ + // CraftBukkit start - add the block to our list + } else { + BlockPosition pos = blockposition.shift(this.c); -+ blocks.add(bworld.getBlockAt(pos.getX(), pos.getY(), pos.getZ())); ++ blocks.add(CraftBlock.at(this.a, pos)); + // CraftBukkit end } } } -@@ -308,6 +333,11 @@ +@@ -287,6 +314,11 @@ if (this.a.getType(this.position.shift(this.c, i).up(this.height)).getBlock() != Blocks.OBSIDIAN) { this.height = 0; break; + // CraftBukkit start - add the block to our list + } else { + BlockPosition pos = this.position.shift(this.c, i).up(this.height); -+ blocks.add(bworld.getBlockAt(pos.getX(), pos.getY(), pos.getZ())); ++ blocks.add(CraftBlock.at(this.a, pos)); + // CraftBukkit end } } -@@ -329,7 +359,27 @@ +@@ -310,7 +342,27 @@ return this.position != null && this.width >= 2 && this.width <= 21 && this.height >= 3 && this.height <= 21; } - public void createPortal() { + // CraftBukkit start - return boolean + public boolean createPortal() { -+ org.bukkit.World bworld = this.a.getWorld(); ++ org.bukkit.World bworld = this.a.getMinecraftWorld().getWorld(); + + // Copy below for loop + for (int i = 0; i < this.width; ++i) { @@ -125,7 +119,7 @@ + } + + PortalCreateEvent event = new PortalCreateEvent(blocks, bworld, PortalCreateEvent.CreateReason.FIRE); -+ this.a.getServer().getPluginManager().callEvent(event); ++ this.a.getMinecraftWorld().getMinecraftServer().server.getPluginManager().callEvent(event); + + if (event.isCancelled()) { + return false; @@ -134,11 +128,11 @@ for (int i = 0; i < this.width; ++i) { BlockPosition blockposition = this.position.shift(this.c, i); -@@ -338,6 +388,7 @@ +@@ -319,6 +371,7 @@ } } + return true; // CraftBukkit } - } - } + + private boolean g() { diff --git a/paper-server/nms-patches/BlockPoweredRail.patch b/paper-server/nms-patches/BlockPoweredRail.patch index 973f55762c..5a9e7598dc 100644 --- a/paper-server/nms-patches/BlockPoweredRail.patch +++ b/paper-server/nms-patches/BlockPoweredRail.patch @@ -1,25 +1,24 @@ --- a/net/minecraft/server/BlockPoweredRail.java +++ b/net/minecraft/server/BlockPoweredRail.java -@@ -3,6 +3,8 @@ - import com.google.common.base.Predicate; - import javax.annotation.Nullable; +@@ -1,5 +1,7 @@ + package net.minecraft.server; +import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit + public class BlockPoweredRail extends BlockMinecartTrackAbstract { - public static final BlockStateEnum SHAPE = BlockStateEnum.a("shape", BlockMinecartTrackAbstract.EnumTrackPosition.class, new Predicate() { -@@ -117,6 +119,13 @@ + public static final BlockStateEnum SHAPE = BlockProperties.R; +@@ -106,6 +108,13 @@ boolean flag1 = world.isBlockIndirectlyPowered(blockposition) || this.a(world, blockposition, iblockdata, true, 0) || this.a(world, blockposition, iblockdata, false, 0); if (flag1 != flag) { + // CraftBukkit start -+ int power = (Boolean)iblockdata.get(POWERED) ? 15 : 0; -+ int newPower = CraftEventFactory.callRedstoneChange(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), power, 15 - power).getNewCurrent(); ++ int power = flag ? 15 : 0; ++ int newPower = CraftEventFactory.callRedstoneChange(world, blockposition, power, 15 - power).getNewCurrent(); + if (newPower == power) { + return; + } + // CraftBukkit end - world.setTypeAndData(blockposition, iblockdata.set(BlockPoweredRail.POWERED, Boolean.valueOf(flag1)), 3); - world.applyPhysics(blockposition.down(), this, false); - if (((BlockMinecartTrackAbstract.EnumTrackPosition) iblockdata.get(BlockPoweredRail.SHAPE)).c()) { + world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockPoweredRail.POWERED, Boolean.valueOf(flag1)), 3); + world.applyPhysics(blockposition.down(), this); + if (((BlockPropertyTrackPosition) iblockdata.get(BlockPoweredRail.SHAPE)).c()) { diff --git a/paper-server/nms-patches/BlockPressurePlateAbstract.patch b/paper-server/nms-patches/BlockPressurePlateAbstract.patch index 775f0989ad..08fea30f90 100644 --- a/paper-server/nms-patches/BlockPressurePlateAbstract.patch +++ b/paper-server/nms-patches/BlockPressurePlateAbstract.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/server/BlockPressurePlateAbstract.java +++ b/net/minecraft/server/BlockPressurePlateAbstract.java -@@ -3,6 +3,8 @@ +@@ -2,6 +2,8 @@ + import java.util.Random; - import javax.annotation.Nullable; +import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit + public abstract class BlockPressurePlateAbstract extends Block { - protected static final AxisAlignedBB a = new AxisAlignedBB(0.0625D, 0.0D, 0.0625D, 0.9375D, 0.03125D, 0.9375D); -@@ -95,6 +97,19 @@ + protected static final VoxelShape a = Block.a(1.0D, 0.0D, 1.0D, 15.0D, 0.5D, 15.0D); +@@ -65,6 +67,19 @@ boolean flag = i > 0; boolean flag1 = j > 0; diff --git a/paper-server/nms-patches/BlockPressurePlateBinary.patch b/paper-server/nms-patches/BlockPressurePlateBinary.patch index fea5dce1b8..6607944b26 100644 --- a/paper-server/nms-patches/BlockPressurePlateBinary.patch +++ b/paper-server/nms-patches/BlockPressurePlateBinary.patch @@ -8,7 +8,7 @@ + public class BlockPressurePlateBinary extends BlockPressurePlateAbstract { - public static final BlockStateBoolean POWERED = BlockStateBoolean.of("powered"); + public static final BlockStateBoolean POWERED = BlockProperties.t; @@ -63,6 +65,26 @@ while (iterator.hasNext()) { Entity entity = (Entity) iterator.next(); diff --git a/paper-server/nms-patches/BlockPressurePlateWeighted.patch b/paper-server/nms-patches/BlockPressurePlateWeighted.patch index d24fd748ba..6550159bd5 100644 --- a/paper-server/nms-patches/BlockPressurePlateWeighted.patch +++ b/paper-server/nms-patches/BlockPressurePlateWeighted.patch @@ -7,11 +7,11 @@ + public class BlockPressurePlateWeighted extends BlockPressurePlateAbstract { - public static final BlockStateInteger POWER = BlockStateInteger.of("power", 0, 15); -@@ -16,7 +18,31 @@ + public static final BlockStateInteger POWER = BlockProperties.ak; +@@ -12,7 +14,31 @@ } - protected int e(World world, BlockPosition blockposition) { + protected int b(World world, BlockPosition blockposition) { - int i = Math.min(world.a(Entity.class, BlockPressurePlateWeighted.c.a(blockposition)).size(), this.weight); + // CraftBukkit start + // int i = Math.min(world.a(Entity.class, BlockPressurePlateWeighted.c.a(blockposition)).size(), this.weight); diff --git a/paper-server/nms-patches/BlockPumpkin.patch b/paper-server/nms-patches/BlockPumpkin.patch deleted file mode 100644 index 04cdad4b8d..0000000000 --- a/paper-server/nms-patches/BlockPumpkin.patch +++ /dev/null @@ -1,81 +0,0 @@ ---- a/net/minecraft/server/BlockPumpkin.java -+++ b/net/minecraft/server/BlockPumpkin.java -@@ -4,6 +4,12 @@ - import java.util.Iterator; - import javax.annotation.Nullable; - -+// CraftBukkit start -+import org.bukkit.craftbukkit.util.BlockStateListPopulator; -+import org.bukkit.event.block.BlockRedstoneEvent; -+import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; -+// CraftBukkit end -+ - public class BlockPumpkin extends BlockFacingHorizontal { - - private ShapeDetector snowGolemPart; -@@ -43,18 +49,25 @@ - EntityPlayer entityplayer; - int j; - -+ BlockStateListPopulator blockList = new BlockStateListPopulator(world.getWorld()); // CraftBukkit - Use BlockStateListPopulator - if (shapedetector_shapedetectorcollection != null) { - for (i = 0; i < this.getDetectorSnowGolem().b(); ++i) { - ShapeDetectorBlock shapedetectorblock = shapedetector_shapedetectorcollection.a(0, i, 0); - -- world.setTypeAndData(shapedetectorblock.getPosition(), Blocks.AIR.getBlockData(), 2); -+ // CraftBukkit start -+ // world.setTypeAndData(shapedetectorblock.d(), Blocks.AIR.getBlockData(), 2); -+ BlockPosition pos = shapedetectorblock.getPosition(); -+ blockList.setTypeId(pos.getX(), pos.getY(), pos.getZ(), 0); -+ // CraftBukkit end - } - - EntitySnowman entitysnowman = new EntitySnowman(world); - BlockPosition blockposition1 = shapedetector_shapedetectorcollection.a(0, 2, 0).getPosition(); - - entitysnowman.setPositionRotation((double) blockposition1.getX() + 0.5D, (double) blockposition1.getY() + 0.05D, (double) blockposition1.getZ() + 0.5D, 0.0F, 0.0F); -- world.addEntity(entitysnowman); -+ // CraftBukkit start -+ if (world.addEntity(entitysnowman, SpawnReason.BUILD_SNOWMAN)) { -+ blockList.updateList(); - iterator = world.a(EntityPlayer.class, entitysnowman.getBoundingBox().g(5.0D)).iterator(); - - while (iterator.hasNext()) { -@@ -71,12 +84,17 @@ - - world.update(shapedetectorblock1.getPosition(), Blocks.AIR, false); - } -+ } // CraftBukkit end - } else { - shapedetector_shapedetectorcollection = this.getDetectorIronGolem().a(world, blockposition); - if (shapedetector_shapedetectorcollection != null) { - for (i = 0; i < this.getDetectorIronGolem().c(); ++i) { - for (int k = 0; k < this.getDetectorIronGolem().b(); ++k) { -- world.setTypeAndData(shapedetector_shapedetectorcollection.a(i, k, 0).getPosition(), Blocks.AIR.getBlockData(), 2); -+ // CraftBukkit start -+ // world.setTypeAndData(shapedetector_shapedetectorcollection.a(i, k, 0).getPosition(), Blocks.AIR.getBlockData(), 2); -+ BlockPosition pos = shapedetector_shapedetectorcollection.a(i, k, 0).getPosition(); -+ blockList.setTypeId(pos.getX(), pos.getY(), pos.getZ(), 0); -+ // CraftBukkit end - } - } - -@@ -85,7 +103,9 @@ - - entityirongolem.setPlayerCreated(true); - entityirongolem.setPositionRotation((double) blockposition2.getX() + 0.5D, (double) blockposition2.getY() + 0.05D, (double) blockposition2.getZ() + 0.5D, 0.0F, 0.0F); -- world.addEntity(entityirongolem); -+ // CraftBukkit start -+ if (world.addEntity(entityirongolem, SpawnReason.BUILD_IRONGOLEM)) { -+ blockList.updateList(); - iterator = world.a(EntityPlayer.class, entityirongolem.getBoundingBox().g(5.0D)).iterator(); - - while (iterator.hasNext()) { -@@ -105,6 +125,7 @@ - } - } - } -+ } // CraftBukkit end - } - - } diff --git a/paper-server/nms-patches/BlockPumpkinCarved.patch b/paper-server/nms-patches/BlockPumpkinCarved.patch new file mode 100644 index 0000000000..8e2dfb39f2 --- /dev/null +++ b/paper-server/nms-patches/BlockPumpkinCarved.patch @@ -0,0 +1,65 @@ +--- a/net/minecraft/server/BlockPumpkinCarved.java ++++ b/net/minecraft/server/BlockPumpkinCarved.java +@@ -3,6 +3,12 @@ + import java.util.Iterator; + import java.util.function.Predicate; + ++// CraftBukkit start ++import org.bukkit.craftbukkit.util.BlockStateListPopulator; ++import org.bukkit.event.block.BlockRedstoneEvent; ++import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; ++// CraftBukkit end ++ + public class BlockPumpkinCarved extends BlockFacingHorizontal { + + public static final BlockStateDirection a = BlockFacingHorizontal.FACING; +@@ -38,18 +44,24 @@ + int j; + int k; + ++ BlockStateListPopulator blockList = new BlockStateListPopulator(world); // CraftBukkit - Use BlockStateListPopulator + if (shapedetector_shapedetectorcollection != null) { + for (i = 0; i < this.d().b(); ++i) { + ShapeDetectorBlock shapedetectorblock1 = shapedetector_shapedetectorcollection.a(0, i, 0); + +- world.setTypeAndData(shapedetectorblock1.getPosition(), Blocks.AIR.getBlockData(), 2); ++ blockList.setTypeAndData(shapedetectorblock1.getPosition(), Blocks.AIR.getBlockData(), 2); // CraftBukkit + } + + EntitySnowman entitysnowman = new EntitySnowman(world); + BlockPosition blockposition1 = shapedetector_shapedetectorcollection.a(0, 2, 0).getPosition(); + + entitysnowman.setPositionRotation((double) blockposition1.getX() + 0.5D, (double) blockposition1.getY() + 0.05D, (double) blockposition1.getZ() + 0.5D, 0.0F, 0.0F); +- world.addEntity(entitysnowman); ++ // CraftBukkit start ++ if (!world.addEntity(entitysnowman, SpawnReason.BUILD_SNOWMAN)) { ++ return; ++ } ++ blockList.updateList(); ++ // CraftBukkit end + iterator = world.a(EntityPlayer.class, entitysnowman.getBoundingBox().g(5.0D)).iterator(); + + while (iterator.hasNext()) { +@@ -70,7 +82,7 @@ + if (shapedetector_shapedetectorcollection != null) { + for (i = 0; i < this.f().c(); ++i) { + for (int l = 0; l < this.f().b(); ++l) { +- world.setTypeAndData(shapedetector_shapedetectorcollection.a(i, l, 0).getPosition(), Blocks.AIR.getBlockData(), 2); ++ blockList.setTypeAndData(shapedetector_shapedetectorcollection.a(i, l, 0).getPosition(), Blocks.AIR.getBlockData(), 2); // CraftBukkit + } + } + +@@ -79,7 +91,12 @@ + + entityirongolem.setPlayerCreated(true); + entityirongolem.setPositionRotation((double) blockposition2.getX() + 0.5D, (double) blockposition2.getY() + 0.05D, (double) blockposition2.getZ() + 0.5D, 0.0F, 0.0F); +- world.addEntity(entityirongolem); ++ // CraftBukkit start ++ if (!world.addEntity(entityirongolem, SpawnReason.BUILD_IRONGOLEM)) { ++ return; ++ } ++ blockList.updateList(); ++ // CraftBukkit end + iterator = world.a(EntityPlayer.class, entityirongolem.getBoundingBox().g(5.0D)).iterator(); + + while (iterator.hasNext()) { diff --git a/paper-server/nms-patches/BlockRedstoneLamp.patch b/paper-server/nms-patches/BlockRedstoneLamp.patch index e349acdc44..71ed926cb0 100644 --- a/paper-server/nms-patches/BlockRedstoneLamp.patch +++ b/paper-server/nms-patches/BlockRedstoneLamp.patch @@ -1,54 +1,35 @@ --- a/net/minecraft/server/BlockRedstoneLamp.java +++ b/net/minecraft/server/BlockRedstoneLamp.java -@@ -2,6 +2,8 @@ - +@@ -3,6 +3,8 @@ import java.util.Random; + import javax.annotation.Nullable; +import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit + public class BlockRedstoneLamp extends Block { - private final boolean a; -@@ -18,8 +20,18 @@ - public void onPlace(World world, BlockPosition blockposition, IBlockData iblockdata) { + public static final BlockStateBoolean a = BlockRedstoneTorch.LIT; +@@ -33,6 +35,11 @@ + if (flag) { + world.I().a(blockposition, this, 4); + } else { ++ // CraftBukkit start ++ if (CraftEventFactory.callRedstoneChange(world, blockposition, 0, 15).getNewCurrent() != 15) { ++ return; ++ } ++ // CraftBukkit end + world.setTypeAndData(blockposition, (IBlockData) iblockdata.a((IBlockState) BlockRedstoneLamp.a), 2); + } + } +@@ -43,6 +50,11 @@ + public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) { if (!world.isClientSide) { - if (this.a && !world.isBlockIndirectlyPowered(blockposition)) { + if (((Boolean) iblockdata.get(BlockRedstoneLamp.a)).booleanValue() && !world.isBlockIndirectlyPowered(blockposition)) { + // CraftBukkit start -+ if (CraftEventFactory.callRedstoneChange(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), 15, 0).getNewCurrent() != 0) { ++ if (CraftEventFactory.callRedstoneChange(world, blockposition, 15, 0).getNewCurrent() != 0) { + return; + } + // CraftBukkit end - world.setTypeAndData(blockposition, Blocks.REDSTONE_LAMP.getBlockData(), 2); - } else if (!this.a && world.isBlockIndirectlyPowered(blockposition)) { -+ // CraftBukkit start -+ if (CraftEventFactory.callRedstoneChange(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), 0, 15).getNewCurrent() != 15) { -+ return; -+ } -+ // CraftBukkit end - world.setTypeAndData(blockposition, Blocks.LIT_REDSTONE_LAMP.getBlockData(), 2); - } - -@@ -31,6 +43,11 @@ - if (this.a && !world.isBlockIndirectlyPowered(blockposition)) { - world.a(blockposition, (Block) this, 4); - } else if (!this.a && world.isBlockIndirectlyPowered(blockposition)) { -+ // CraftBukkit start -+ if (CraftEventFactory.callRedstoneChange(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), 0, 15).getNewCurrent() != 15) { -+ return; -+ } -+ // CraftBukkit end - world.setTypeAndData(blockposition, Blocks.LIT_REDSTONE_LAMP.getBlockData(), 2); - } - -@@ -40,6 +57,11 @@ - public void b(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) { - if (!world.isClientSide) { - if (this.a && !world.isBlockIndirectlyPowered(blockposition)) { -+ // CraftBukkit start -+ if (CraftEventFactory.callRedstoneChange(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), 15, 0).getNewCurrent() != 0) { -+ return; -+ } -+ // CraftBukkit end - world.setTypeAndData(blockposition, Blocks.REDSTONE_LAMP.getBlockData(), 2); + world.setTypeAndData(blockposition, (IBlockData) iblockdata.a((IBlockState) BlockRedstoneLamp.a), 2); } diff --git a/paper-server/nms-patches/BlockRedstoneOre.patch b/paper-server/nms-patches/BlockRedstoneOre.patch index c4b08ac9a8..e9312c2cf1 100644 --- a/paper-server/nms-patches/BlockRedstoneOre.patch +++ b/paper-server/nms-patches/BlockRedstoneOre.patch @@ -11,76 +11,75 @@ + public class BlockRedstoneOre extends Block { - private final boolean a; -@@ -20,23 +25,45 @@ + public static final BlockStateBoolean a = BlockRedstoneTorch.LIT; +@@ -16,23 +21,44 @@ } - public void attack(World world, BlockPosition blockposition, EntityHuman entityhuman) { -- this.interact(world, blockposition); -+ this.interact(world, blockposition, entityhuman); // CraftBukkit - add entityhuman - super.attack(world, blockposition, entityhuman); + public void attack(IBlockData iblockdata, World world, BlockPosition blockposition, EntityHuman entityhuman) { +- interact(iblockdata, world, blockposition); ++ interact(iblockdata, world, blockposition, entityhuman); // CraftBukkit - add entityhuman + super.attack(iblockdata, world, blockposition, entityhuman); } public void stepOn(World world, BlockPosition blockposition, Entity entity) { -- this.interact(world, blockposition); +- interact(world.getType(blockposition), world, blockposition); - super.stepOn(world, blockposition, entity); + // CraftBukkit start -+ // this.interact(world, blockposition); ++ // interact(world.getType(blockposition), world, blockposition); + // super.stepOn(world, blockposition, entity); + if (entity instanceof EntityHuman) { + org.bukkit.event.player.PlayerInteractEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent((EntityHuman) entity, org.bukkit.event.block.Action.PHYSICAL, blockposition, null, null, null); + if (!event.isCancelled()) { -+ this.interact(world, blockposition, entity); // add entity ++ interact(world.getType(blockposition), world, blockposition, entity); // add entity + super.stepOn(world, blockposition, entity); + } + } else { + EntityInteractEvent event = new EntityInteractEvent(entity.getBukkitEntity(), world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ())); + world.getServer().getPluginManager().callEvent(event); + if (!event.isCancelled()) { -+ this.interact(world, blockposition, entity); // add entity ++ interact(world.getType(blockposition), world, blockposition, entity); // add entity + super.stepOn(world, blockposition, entity); + } + } + // CraftBukkit end } -+ - public boolean interact(World world, BlockPosition blockposition, IBlockData iblockdata, EntityHuman entityhuman, EnumHand enumhand, EnumDirection enumdirection, float f, float f1, float f2) { -- this.interact(world, blockposition); -+ this.interact(world, blockposition, entityhuman); // CraftBukkit - add entityhuman - return super.interact(world, blockposition, iblockdata, entityhuman, enumhand, enumdirection, f, f1, f2); + public boolean interact(IBlockData iblockdata, World world, BlockPosition blockposition, EntityHuman entityhuman, EnumHand enumhand, EnumDirection enumdirection, float f, float f1, float f2) { +- interact(iblockdata, world, blockposition); ++ interact(iblockdata, world, blockposition, entityhuman); // CraftBukkit - add entityhuman + return super.interact(iblockdata, world, blockposition, entityhuman, enumhand, enumdirection, f, f1, f2); } -- private void interact(World world, BlockPosition blockposition) { -+ private void interact(World world, BlockPosition blockposition, Entity entity) { // CraftBukkit - add Entity - this.playEffect(world, blockposition); - if (this == Blocks.REDSTONE_ORE) { +- private static void interact(IBlockData iblockdata, World world, BlockPosition blockposition) { ++ private static void interact(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { // CraftBukkit - add Entity + playEffect(world, blockposition); + if (!((Boolean) iblockdata.get(BlockRedstoneOre.a)).booleanValue()) { + // CraftBukkit start -+ if (CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, Blocks.LIT_REDSTONE_ORE, 0).isCancelled()) { ++ if (CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, iblockdata.set(BlockRedstoneOre.a, Boolean.valueOf(true))).isCancelled()) { + return; + } + // CraftBukkit end - world.setTypeUpdate(blockposition, Blocks.LIT_REDSTONE_ORE.getBlockData()); + world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockRedstoneOre.a, Boolean.valueOf(true)), 3); } -@@ -44,6 +71,11 @@ +@@ -40,6 +66,11 @@ - public void b(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) { - if (this == Blocks.LIT_REDSTONE_ORE) { + public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) { + if (((Boolean) iblockdata.get(BlockRedstoneOre.a)).booleanValue()) { + // CraftBukkit start -+ if (CraftEventFactory.callBlockFadeEvent(world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), Blocks.REDSTONE_ORE).isCancelled()) { ++ if (CraftEventFactory.callBlockFadeEvent(world, blockposition, iblockdata.set(BlockRedstoneOre.a, Boolean.valueOf(false))).isCancelled()) { + return; + } + // CraftBukkit end - world.setTypeUpdate(blockposition, Blocks.REDSTONE_ORE.getBlockData()); + world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockRedstoneOre.a, Boolean.valueOf(false)), 3); } -@@ -63,12 +95,25 @@ +@@ -59,12 +90,25 @@ - public void dropNaturally(World world, BlockPosition blockposition, IBlockData iblockdata, float f, int i) { - super.dropNaturally(world, blockposition, iblockdata, f, i); + public void dropNaturally(IBlockData iblockdata, World world, BlockPosition blockposition, float f, int i) { + super.dropNaturally(iblockdata, world, blockposition, f, i); + /* CraftBukkit start - Delegated to getExpDrop - if (this.getDropType(iblockdata, world.random, i) != Item.getItemOf(this)) { + if (this.getDropType(iblockdata, world, blockposition, i) != this) { int j = 1 + world.random.nextInt(5); this.dropExperience(world, blockposition, j); @@ -88,16 +87,16 @@ + // */ + + } -+ -+ @Override -+ public int getExpDrop(World world, IBlockData data, int i) { -+ if (this.getDropType(data, world.random, i) != Item.getItemOf(this)) { -+ int j = 1 + world.random.nextInt(5); ++ @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); ++ + return j; + } + return 0; + // CraftBukkit end } - private void playEffect(World world, BlockPosition blockposition) { + private static void playEffect(World world, BlockPosition blockposition) { diff --git a/paper-server/nms-patches/BlockRedstoneTorch.patch b/paper-server/nms-patches/BlockRedstoneTorch.patch index e35ce52720..4506c4b4a4 100644 --- a/paper-server/nms-patches/BlockRedstoneTorch.patch +++ b/paper-server/nms-patches/BlockRedstoneTorch.patch @@ -8,29 +8,19 @@ + public class BlockRedstoneTorch extends BlockTorch { - private static final Map> g = Maps.newHashMap(); -@@ -13,7 +15,7 @@ - - private boolean a(World world, BlockPosition blockposition, boolean flag) { - if (!BlockRedstoneTorch.g.containsKey(world)) { -- BlockRedstoneTorch.g.put(world, Lists.newArrayList()); -+ BlockRedstoneTorch.g.put(world, Lists.newArrayList()); // CraftBukkit - fix decompile error - } - - List list = (List) BlockRedstoneTorch.g.get(world); -@@ -96,8 +98,25 @@ + public static final BlockStateBoolean LIT = BlockProperties.o; +@@ -65,8 +67,24 @@ list.remove(0); } + // CraftBukkit start + org.bukkit.plugin.PluginManager manager = world.getServer().getPluginManager(); + org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); -+ int oldCurrent = this.isOn ? 15 : 0; ++ int oldCurrent = ((Boolean) iblockdata.get(BlockRedstoneTorch.LIT)).booleanValue() ? 15 : 0; + + BlockRedstoneEvent event = new BlockRedstoneEvent(block, oldCurrent, oldCurrent); + // CraftBukkit end -+ - if (this.isOn) { + if (((Boolean) iblockdata.get(BlockRedstoneTorch.LIT)).booleanValue()) { if (flag) { + // CraftBukkit start + if (oldCurrent != 0) { @@ -41,13 +31,13 @@ + } + } + // CraftBukkit end - world.setTypeAndData(blockposition, Blocks.UNLIT_REDSTONE_TORCH.getBlockData().set(BlockRedstoneTorch.FACING, iblockdata.get(BlockRedstoneTorch.FACING)), 3); - if (this.a(world, blockposition, true)) { - world.a((EntityHuman) null, blockposition, SoundEffects.gm, SoundCategory.BLOCKS, 0.5F, 2.6F + (world.random.nextFloat() - world.random.nextFloat()) * 0.8F); -@@ -114,6 +133,15 @@ + world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockRedstoneTorch.LIT, Boolean.valueOf(false)), 3); + if (a(world, blockposition, true)) { + world.a((EntityHuman) null, blockposition, SoundEffects.BLOCK_REDSTONE_TORCH_BURNOUT, SoundCategory.BLOCKS, 0.5F, 2.6F + (world.random.nextFloat() - world.random.nextFloat()) * 0.8F); +@@ -83,6 +101,15 @@ } } - } else if (!flag && !this.a(world, blockposition, false)) { + } else if (!flag && !a(world, blockposition, false)) { + // CraftBukkit start + if (oldCurrent != 15) { + event.setNewCurrent(15); @@ -57,6 +47,15 @@ + } + } + // CraftBukkit end - world.setTypeAndData(blockposition, Blocks.REDSTONE_TORCH.getBlockData().set(BlockRedstoneTorch.FACING, iblockdata.get(BlockRedstoneTorch.FACING)), 3); + world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockRedstoneTorch.LIT, Boolean.valueOf(true)), 3); } +@@ -112,7 +139,7 @@ + } + + private static boolean a(World world, BlockPosition blockposition, boolean flag) { +- Object object = (List) BlockRedstoneTorch.b.get(world); ++ List object = (List) BlockRedstoneTorch.b.get(world); // CraftBukkit - decompile error + + if (object == null) { + object = Lists.newArrayList(); diff --git a/paper-server/nms-patches/BlockRedstoneWire.patch b/paper-server/nms-patches/BlockRedstoneWire.patch index 0f200a3500..206d6222f3 100644 --- a/paper-server/nms-patches/BlockRedstoneWire.patch +++ b/paper-server/nms-patches/BlockRedstoneWire.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/BlockRedstoneWire.java +++ b/net/minecraft/server/BlockRedstoneWire.java -@@ -9,6 +9,8 @@ +@@ -11,6 +11,8 @@ import java.util.Set; import javax.annotation.Nullable; @@ -8,8 +8,8 @@ + public class BlockRedstoneWire extends Block { - public static final BlockStateEnum NORTH = BlockStateEnum.of("north", BlockRedstoneWire.EnumRedstoneWireConnection.class); -@@ -168,6 +170,15 @@ + public static final BlockStateEnum NORTH = BlockProperties.L; +@@ -216,6 +218,15 @@ j = k; } @@ -23,5 +23,5 @@ + // CraftBukkit end + if (i != j) { - iblockdata = iblockdata.set(BlockRedstoneWire.POWER, Integer.valueOf(j)); + iblockdata = (IBlockData) iblockdata.set(BlockRedstoneWire.POWER, Integer.valueOf(j)); if (world.getType(blockposition) == iblockdata1) { diff --git a/paper-server/nms-patches/BlockReed.patch b/paper-server/nms-patches/BlockReed.patch index 8acc843a22..4bdaf9e72b 100644 --- a/paper-server/nms-patches/BlockReed.patch +++ b/paper-server/nms-patches/BlockReed.patch @@ -1,16 +1,11 @@ --- a/net/minecraft/server/BlockReed.java +++ b/net/minecraft/server/BlockReed.java -@@ -32,8 +32,12 @@ - int j = ((Integer) iblockdata.get(BlockReed.AGE)).intValue(); +@@ -29,7 +29,7 @@ + int j = ((Integer) iblockdata.get(BlockReed.AGE)).intValue(); - if (j == 15) { -- world.setTypeUpdate(blockposition.up(), this.getBlockData()); -+ // CraftBukkit start -+ // world.setTypeUpdate(blockposition.up(), this.getBlockData()); // CraftBukkit -+ BlockPosition upPos = blockposition.up(); -+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(world, upPos.getX(), upPos.getY(), upPos.getZ(), this, 0); - world.setTypeAndData(blockposition, iblockdata.set(BlockReed.AGE, Integer.valueOf(0)), 4); -+ // CraftBukkit end - } else { - world.setTypeAndData(blockposition, iblockdata.set(BlockReed.AGE, Integer.valueOf(j + 1)), 4); - } + if (j == 15) { +- world.setTypeUpdate(blockposition.up(), this.getBlockData()); ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(world, blockposition.up(), this.getBlockData()); // CraftBukkit + world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockReed.AGE, Integer.valueOf(0)), 4); + } else { + world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockReed.AGE, Integer.valueOf(j + 1)), 4); diff --git a/paper-server/nms-patches/BlockSapling.patch b/paper-server/nms-patches/BlockSapling.patch index c5f6c374a8..3dab623201 100644 --- a/paper-server/nms-patches/BlockSapling.patch +++ b/paper-server/nms-patches/BlockSapling.patch @@ -15,112 +15,41 @@ + public class BlockSapling extends BlockPlant implements IBlockFragilePlantElement { - public static final BlockStateEnum TYPE = BlockStateEnum.of("type", BlockWood.EnumLogVariant.class); - public static final BlockStateInteger STAGE = BlockStateInteger.of("stage", 0, 1); - protected static final AxisAlignedBB d = new AxisAlignedBB(0.09999999403953552D, 0.0D, 0.09999999403953552D, 0.8999999761581421D, 0.800000011920929D, 0.8999999761581421D); + public static final BlockStateInteger STAGE = BlockProperties.al; + protected static final VoxelShape b = Block.a(2.0D, 0.0D, 2.0D, 14.0D, 12.0D, 14.0D); + private final WorldGenTreeProvider c; + public static TreeType treeType; // CraftBukkit - protected BlockSapling() { - this.w(this.blockStateList.getBlockData().set(BlockSapling.TYPE, BlockWood.EnumLogVariant.OAK).set(BlockSapling.STAGE, Integer.valueOf(0))); -@@ -25,7 +35,30 @@ - if (!world.isClientSide) { - super.b(world, blockposition, iblockdata, random); - if (world.getLightLevel(blockposition.up()) >= 9 && random.nextInt(7) == 0) { -+ // CraftBukkit start -+ world.captureTreeGeneration = true; -+ // CraftBukkit end - this.grow(world, blockposition, iblockdata, random); -+ // CraftBukkit start -+ world.captureTreeGeneration = false; -+ if (world.capturedBlockStates.size() > 0) { -+ TreeType treeType = BlockSapling.treeType; -+ BlockSapling.treeType = null; -+ Location location = new Location(world.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ()); -+ List blocks = (List) world.capturedBlockStates.clone(); -+ world.capturedBlockStates.clear(); -+ StructureGrowEvent event = null; -+ if (treeType != null) { -+ event = new StructureGrowEvent(location, treeType, false, null, blocks); -+ org.bukkit.Bukkit.getPluginManager().callEvent(event); -+ } -+ if (event == null || !event.isCancelled()) { -+ for (BlockState blockstate : blocks) { -+ blockstate.update(true); -+ } + protected BlockSapling(WorldGenTreeProvider worldgentreeprovider, Block.Info block_info) { + super(block_info); +@@ -21,7 +31,30 @@ + public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) { + super.a(iblockdata, world, blockposition, random); + if (world.getLightLevel(blockposition.up()) >= 9 && random.nextInt(7) == 0) { ++ // CraftBukkit start ++ world.captureTreeGeneration = true; ++ // CraftBukkit end + this.grow(world, blockposition, iblockdata, random); ++ // CraftBukkit start ++ world.captureTreeGeneration = false; ++ if (world.capturedBlockStates.size() > 0) { ++ TreeType treeType = BlockSapling.treeType; ++ BlockSapling.treeType = null; ++ Location location = new Location(world.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ()); ++ List blocks = (List) world.capturedBlockStates.clone(); ++ world.capturedBlockStates.clear(); ++ StructureGrowEvent event = null; ++ if (treeType != null) { ++ event = new StructureGrowEvent(location, treeType, false, null, blocks); ++ org.bukkit.Bukkit.getPluginManager().callEvent(event); ++ } ++ if (event == null || !event.isCancelled()) { ++ for (BlockState blockstate : blocks) { ++ blockstate.update(true); + } + } -+ // CraftBukkit end - } - ++ } ++ // CraftBukkit end } -@@ -41,7 +74,17 @@ + } - - public void d(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) { -- Object object = random.nextInt(10) == 0 ? new WorldGenBigTree(true) : new WorldGenTrees(true); -+ // CraftBukkit start - Turn ternary operator into if statement to set treeType -+ // Object object = random.nextInt(10) == 0 ? new WorldGenBigTree(true) : new WorldGenTrees(true); -+ Object object; -+ if (random.nextInt(10) == 0) { -+ treeType = TreeType.BIG_TREE; -+ object = new WorldGenBigTree(true); -+ } else { -+ treeType = TreeType.TREE; -+ object = new WorldGenTrees(true); -+ } -+ // CraftBukkit end - int i = 0; - int j = 0; - boolean flag = false; -@@ -53,6 +96,7 @@ - for (i = 0; i >= -1; --i) { - for (j = 0; j >= -1; --j) { - if (this.a(world, blockposition, i, j, BlockWood.EnumLogVariant.SPRUCE)) { -+ treeType = TreeType.MEGA_REDWOOD; // CraftBukkit - object = new WorldGenMegaTree(false, random.nextBoolean()); - flag = true; - break label66; -@@ -63,11 +107,13 @@ - if (!flag) { - i = 0; - j = 0; -+ treeType = TreeType.REDWOOD; // CraftBukkit - object = new WorldGenTaiga2(true); - } - break; - - case BIRCH: -+ treeType = TreeType.BIRCH; // CraftBukkit - object = new WorldGenForest(true, false); - break; - -@@ -79,6 +125,7 @@ - for (i = 0; i >= -1; --i) { - for (j = 0; j >= -1; --j) { - if (this.a(world, blockposition, i, j, BlockWood.EnumLogVariant.JUNGLE)) { -+ treeType = TreeType.JUNGLE; // CraftBukkit - object = new WorldGenJungleTree(true, 10, 20, iblockdata1, iblockdata2); - flag = true; - break label78; -@@ -89,11 +136,13 @@ - if (!flag) { - i = 0; - j = 0; -+ treeType = TreeType.SMALL_JUNGLE; // CraftBukkit - object = new WorldGenTrees(true, 4 + random.nextInt(7), iblockdata1, iblockdata2, false); - } - break; - - case ACACIA: -+ treeType = TreeType.ACACIA; // CraftBukkit - object = new WorldGenAcaciaTree(true); - break; - -@@ -102,6 +151,7 @@ - for (i = 0; i >= -1; --i) { - for (j = 0; j >= -1; --j) { - if (this.a(world, blockposition, i, j, BlockWood.EnumLogVariant.DARK_OAK)) { -+ treeType = TreeType.DARK_OAK; // CraftBukkit - object = new WorldGenForestTree(true); - flag = true; - break label90; diff --git a/paper-server/nms-patches/BlockShulkerBox.patch b/paper-server/nms-patches/BlockShulkerBox.patch index e0a5aaa3c4..e4c24bc972 100644 --- a/paper-server/nms-patches/BlockShulkerBox.patch +++ b/paper-server/nms-patches/BlockShulkerBox.patch @@ -1,32 +1,31 @@ --- a/net/minecraft/server/BlockShulkerBox.java +++ b/net/minecraft/server/BlockShulkerBox.java -@@ -92,7 +92,32 @@ - +@@ -81,7 +81,31 @@ + super.a(world, blockposition, iblockdata, entityhuman); } -- public void dropNaturally(World world, BlockPosition blockposition, IBlockData iblockdata, float f, int i) {} +- public void dropNaturally(IBlockData iblockdata, World world, BlockPosition blockposition, float f, int i) {} + // CraftBukkit start - override to prevent duplication when dropping -+ public void dropNaturally(World world, BlockPosition blockposition, IBlockData iblockdata, float f, int i) { -+ TileEntity tileentity = world.getTileEntity(blockposition); ++ @Override ++ public void dropNaturally(IBlockData iblockdata, World world, BlockPosition blockposition, float f, int i) { ++ if (true) { ++ TileEntity tileentity = world.getTileEntity(blockposition); + -+ if (tileentity instanceof TileEntityShulkerBox) { -+ TileEntityShulkerBox tileentityshulkerbox = (TileEntityShulkerBox) tileentity; ++ if (tileentity instanceof TileEntityShulkerBox) { ++ TileEntityShulkerBox tileentityshulkerbox = (TileEntityShulkerBox) tileentity; + -+ if (!tileentityshulkerbox.r() && tileentityshulkerbox.F()) { -+ ItemStack itemstack = new ItemStack(Item.getItemOf(this)); -+ NBTTagCompound nbttagcompound = new NBTTagCompound(); -+ NBTTagCompound nbttagcompound1 = new NBTTagCompound(); ++ if (!tileentityshulkerbox.s() && tileentityshulkerbox.G()) { ++ ItemStack itemstack = new ItemStack(this); + -+ nbttagcompound.set("BlockEntityTag", ((TileEntityShulkerBox) tileentity).f(nbttagcompound1)); -+ itemstack.setTag(nbttagcompound); -+ if (tileentityshulkerbox.hasCustomName()) { -+ itemstack.g(tileentityshulkerbox.getName()); -+ tileentityshulkerbox.setCustomName(""); ++ itemstack.getOrCreateTag().set("BlockEntityTag", ((TileEntityShulkerBox) tileentity).g(new NBTTagCompound())); ++ if (tileentityshulkerbox.hasCustomName()) { ++ itemstack.a(tileentityshulkerbox.getCustomName()); ++ tileentityshulkerbox.setCustomName((IChatBaseComponent) null); ++ } ++ ++ a(world, blockposition, itemstack); + } -+ -+ a(world, blockposition, itemstack); + } -+ + world.updateAdjacentComparators(blockposition, iblockdata.getBlock()); + } + } @@ -34,22 +33,22 @@ public void postPlace(World world, BlockPosition blockposition, IBlockData iblockdata, EntityLiving entityliving, ItemStack itemstack) { if (itemstack.hasName()) { -@@ -108,7 +133,7 @@ - public void remove(World world, BlockPosition blockposition, IBlockData iblockdata) { - TileEntity tileentity = world.getTileEntity(blockposition); +@@ -98,7 +122,7 @@ + if (iblockdata.getBlock() != iblockdata1.getBlock()) { + TileEntity tileentity = world.getTileEntity(blockposition); -- if (tileentity instanceof TileEntityShulkerBox) { -+ if (false && tileentity instanceof TileEntityShulkerBox) { // CraftBukkit - moved up - TileEntityShulkerBox tileentityshulkerbox = (TileEntityShulkerBox) tileentity; +- if (tileentity instanceof TileEntityShulkerBox) { ++ if (false && tileentity instanceof TileEntityShulkerBox) { // CraftBukkit - moved up + TileEntityShulkerBox tileentityshulkerbox = (TileEntityShulkerBox) tileentity; - if (!tileentityshulkerbox.r() && tileentityshulkerbox.F()) { -@@ -126,8 +151,8 @@ - a(world, blockposition, itemstack); + if (!tileentityshulkerbox.s() && tileentityshulkerbox.G()) { +@@ -113,8 +137,8 @@ + a(world, blockposition, itemstack); + } + +- world.updateAdjacentComparators(blockposition, iblockdata.getBlock()); } ++ world.updateAdjacentComparators(blockposition, iblockdata.getBlock()); // CraftBukkit - moved down -- world.updateAdjacentComparators(blockposition, iblockdata.getBlock()); + super.remove(iblockdata, world, blockposition, iblockdata1, flag); } -+ world.updateAdjacentComparators(blockposition, iblockdata.getBlock()); // CraftBukkit - moved down - - super.remove(world, blockposition, iblockdata); - } diff --git a/paper-server/nms-patches/BlockSkull.patch b/paper-server/nms-patches/BlockSkull.patch deleted file mode 100644 index b2c8601e97..0000000000 --- a/paper-server/nms-patches/BlockSkull.patch +++ /dev/null @@ -1,123 +0,0 @@ ---- a/net/minecraft/server/BlockSkull.java -+++ b/net/minecraft/server/BlockSkull.java -@@ -5,6 +5,11 @@ - import java.util.Random; - import javax.annotation.Nullable; - -+// CraftBukkit start -+import org.bukkit.craftbukkit.util.BlockStateListPopulator; -+import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; -+// CraftBukkit end -+ - public class BlockSkull extends BlockTileEntity { - - public static final BlockStateDirection FACING = BlockDirectional.FACING; -@@ -82,7 +87,29 @@ - return new ItemStack(Items.SKULL, 1, i); - } - -- public void dropNaturally(World world, BlockPosition blockposition, IBlockData iblockdata, float f, int i) {} -+ // CraftBukkit start - Special case dropping so we can get info from the tile entity -+ @Override -+ public void dropNaturally(World world, BlockPosition blockposition, IBlockData iblockdata, float f, int i) { -+ if (world.random.nextFloat() < f) { -+ TileEntity tileentity = world.getTileEntity(blockposition); -+ -+ if (tileentity instanceof TileEntitySkull) { -+ TileEntitySkull tileentityskull = (TileEntitySkull) tileentity; -+ ItemStack itemstack = this.a(world, blockposition, iblockdata); -+ -+ if (tileentityskull.getSkullType() == 3 && tileentityskull.getGameProfile() != null) { -+ itemstack.setTag(new NBTTagCompound()); -+ NBTTagCompound nbttagcompound = new NBTTagCompound(); -+ -+ GameProfileSerializer.serialize(nbttagcompound, tileentityskull.getGameProfile()); -+ itemstack.getTag().set("SkullOwner", nbttagcompound); -+ } -+ -+ a(world, blockposition, itemstack); -+ } -+ } -+ } -+ // CraftBukkit end - - public void a(World world, BlockPosition blockposition, IBlockData iblockdata, EntityHuman entityhuman) { - if (entityhuman.abilities.canInstantlyBuild) { -@@ -95,7 +122,10 @@ - - public void remove(World world, BlockPosition blockposition, IBlockData iblockdata) { - if (!world.isClientSide) { -- if (!((Boolean) iblockdata.get(BlockSkull.NODROP)).booleanValue()) { -+ // CraftBukkit start - Drop item in code above, not here -+ // if (!((Boolean) iblockdata.get(BlockSkull.NODROP)).booleanValue()) { -+ if (false) { -+ // CraftBukkit end - TileEntity tileentity = world.getTileEntity(blockposition); - - if (tileentity instanceof TileEntitySkull) { -@@ -127,24 +157,36 @@ - } - - public void a(World world, BlockPosition blockposition, TileEntitySkull tileentityskull) { -+ if (world.captureBlockStates) return; // CraftBukkit - if (tileentityskull.getSkullType() == 1 && blockposition.getY() >= 2 && world.getDifficulty() != EnumDifficulty.PEACEFUL && !world.isClientSide) { - ShapeDetector shapedetector = this.g(); - ShapeDetector.ShapeDetectorCollection shapedetector_shapedetectorcollection = shapedetector.a(world, blockposition); - - if (shapedetector_shapedetectorcollection != null) { -+ // CraftBukkit start - Use BlockStateListPopulator -+ BlockStateListPopulator blockList = new BlockStateListPopulator(world.getWorld()); - int i; - - for (i = 0; i < 3; ++i) { - ShapeDetectorBlock shapedetectorblock = shapedetector_shapedetectorcollection.a(i, 0, 0); - -- world.setTypeAndData(shapedetectorblock.getPosition(), shapedetectorblock.a().set(BlockSkull.NODROP, Boolean.valueOf(true)), 2); -+ // CraftBukkit start -+ // world.setTypeAndData(shapedetectorblock.getPosition(), shapedetectorblock.a().set(BlockSkull.NODROP, Boolean.valueOf(true)), 2); -+ BlockPosition pos = shapedetectorblock.getPosition(); -+ IBlockData data = shapedetectorblock.a().set(BlockSkull.NODROP, Boolean.valueOf(true)); -+ blockList.setTypeAndData(pos.getX(), pos.getY(), pos.getZ(), data.getBlock(), data.getBlock().toLegacyData(data), 2); -+ // CraftBukkit end - } - - for (i = 0; i < shapedetector.c(); ++i) { - for (int j = 0; j < shapedetector.b(); ++j) { - ShapeDetectorBlock shapedetectorblock1 = shapedetector_shapedetectorcollection.a(i, j, 0); - -- world.setTypeAndData(shapedetectorblock1.getPosition(), Blocks.AIR.getBlockData(), 2); -+ // CraftBukkit start -+ // world.setTypeAndData(shapedetectorblock1.getPosition(), Blocks.AIR.getBlockData(), 2); -+ BlockPosition pos = shapedetectorblock1.getPosition(); -+ blockList.setTypeAndData(pos.getX(), pos.getY(), pos.getZ(), Blocks.AIR, 0, 2); -+ // CraftBukkit end - } - } - -@@ -157,14 +199,16 @@ - entitywither.p(); - Iterator iterator = world.a(EntityPlayer.class, entitywither.getBoundingBox().g(50.0D)).iterator(); - -+ // CraftBukkit start -+ if (world.addEntity(entitywither, SpawnReason.BUILD_WITHER)) { -+ blockList.updateList(); -+ - while (iterator.hasNext()) { - EntityPlayer entityplayer = (EntityPlayer) iterator.next(); - - CriterionTriggers.m.a(entityplayer, (Entity) entitywither); - } - -- world.addEntity(entitywither); -- - int k; - - for (k = 0; k < 120; ++k) { -@@ -178,6 +222,7 @@ - world.update(shapedetectorblock2.getPosition(), Blocks.AIR, false); - } - } -+ } // CraftBukkit end - - } - } diff --git a/paper-server/nms-patches/BlockSkullAbstract.patch b/paper-server/nms-patches/BlockSkullAbstract.patch new file mode 100644 index 0000000000..84a88f4b78 --- /dev/null +++ b/paper-server/nms-patches/BlockSkullAbstract.patch @@ -0,0 +1,45 @@ +--- a/net/minecraft/server/BlockSkullAbstract.java ++++ b/net/minecraft/server/BlockSkullAbstract.java +@@ -17,7 +17,32 @@ + return new TileEntitySkull(); + } + +- public void dropNaturally(IBlockData iblockdata, World world, BlockPosition blockposition, float f, int i) {} ++ // CraftBukkit start - Special case dropping so we can get info from the tile entity ++ @Override ++ public void dropNaturally(IBlockData iblockdata, World world, BlockPosition blockposition, float f, int i) { ++ if (world.random.nextFloat() < f) { ++ TileEntity tileentity = world.getTileEntity(blockposition); ++ ++ if (tileentity instanceof TileEntitySkull) { ++ TileEntitySkull tileentityskull = (TileEntitySkull) tileentity; ++ ++ if (tileentityskull.shouldDrop()) { ++ ItemStack itemstack = this.a((IBlockAccess) world, blockposition, iblockdata); ++ Block block = tileentityskull.getBlock().getBlock(); ++ ++ if ((block == Blocks.PLAYER_HEAD || block == Blocks.PLAYER_WALL_HEAD) && tileentityskull.getGameProfile() != null) { ++ NBTTagCompound nbttagcompound = new NBTTagCompound(); ++ ++ GameProfileSerializer.serialize(nbttagcompound, tileentityskull.getGameProfile()); ++ itemstack.getOrCreateTag().set("SkullOwner", nbttagcompound); ++ } ++ ++ a(world, blockposition, itemstack); ++ } ++ } ++ } ++ } ++ // CraftBukkit end + + public void a(World world, BlockPosition blockposition, IBlockData iblockdata, EntityHuman entityhuman) { + if (!world.isClientSide && entityhuman.abilities.canInstantlyBuild) { +@@ -35,7 +60,7 @@ + if (iblockdata.getBlock() != iblockdata1.getBlock() && !world.isClientSide) { + TileEntity tileentity = world.getTileEntity(blockposition); + +- if (tileentity instanceof TileEntitySkull) { ++ if (false && tileentity instanceof TileEntitySkull) { // CraftBukkit - Drop item in code above, not here + TileEntitySkull tileentityskull = (TileEntitySkull) tileentity; + + if (tileentityskull.shouldDrop()) { diff --git a/paper-server/nms-patches/BlockSnow.patch b/paper-server/nms-patches/BlockSnow.patch index b69c90e1b2..00bda6753e 100644 --- a/paper-server/nms-patches/BlockSnow.patch +++ b/paper-server/nms-patches/BlockSnow.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/server/BlockSnow.java +++ b/net/minecraft/server/BlockSnow.java -@@ -91,6 +91,11 @@ +@@ -88,6 +88,11 @@ - public void b(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) { + public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) { if (world.getBrightness(EnumSkyBlock.BLOCK, blockposition) > 11) { + // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), Blocks.AIR).isCancelled()) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(world, blockposition, Blocks.AIR.getBlockData()).isCancelled()) { + return; + } + // CraftBukkit end - this.b(world, blockposition, world.getType(blockposition), 0); + iblockdata.a(world, blockposition, 0); world.setAir(blockposition); } diff --git a/paper-server/nms-patches/BlockSnowBlock.patch b/paper-server/nms-patches/BlockSnowBlock.patch index 532914933e..0bd8cb6986 100644 --- a/paper-server/nms-patches/BlockSnowBlock.patch +++ b/paper-server/nms-patches/BlockSnowBlock.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/server/BlockSnowBlock.java +++ b/net/minecraft/server/BlockSnowBlock.java -@@ -20,6 +20,11 @@ +@@ -18,6 +18,11 @@ - public void b(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) { + public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) { if (world.getBrightness(EnumSkyBlock.BLOCK, blockposition) > 11) { + // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), Blocks.AIR).isCancelled()) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(world, blockposition, Blocks.AIR.getBlockData()).isCancelled()) { + return; + } + // CraftBukkit end - this.b(world, blockposition, world.getType(blockposition), 0); + iblockdata.a(world, blockposition, 0); world.setAir(blockposition); } diff --git a/paper-server/nms-patches/BlockSoil.patch b/paper-server/nms-patches/BlockSoil.patch index a7d37719a7..7c6475a055 100644 --- a/paper-server/nms-patches/BlockSoil.patch +++ b/paper-server/nms-patches/BlockSoil.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/server/BlockSoil.java +++ b/net/minecraft/server/BlockSoil.java -@@ -4,6 +4,11 @@ - import java.util.List; +@@ -3,6 +3,11 @@ + import java.util.Iterator; import java.util.Random; +// CraftBukkit start @@ -11,8 +11,8 @@ + public class BlockSoil extends Block { - public static final BlockStateInteger MOISTURE = BlockStateInteger.of("moisture", 0, 7); -@@ -45,14 +50,38 @@ + public static final BlockStateInteger MOISTURE = BlockProperties.ah; +@@ -63,14 +68,37 @@ } public void fallOn(World world, BlockPosition blockposition, Entity entity, float f) { @@ -31,24 +31,23 @@ + return; + } + -+ if (CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, Blocks.DIRT, 0).isCancelled()) { ++ if (CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, Blocks.DIRT.getBlockData()).isCancelled()) { + return; + } + // CraftBukkit end - b(world, blockposition); + b(world.getType(blockposition), world, blockposition); } - super.fallOn(world, blockposition, entity, f); + // super.fallOn(world, blockposition, entity, f); // CraftBukkit - moved up } - protected static void b(World world, BlockPosition blockposition) { + protected static void b(IBlockData iblockdata, World world, BlockPosition blockposition) { + // CraftBukkit start -+ org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); -+ if (CraftEventFactory.callBlockFadeEvent(block, Blocks.DIRT).isCancelled()) { ++ if (CraftEventFactory.callBlockFadeEvent(world, blockposition, Blocks.DIRT.getBlockData()).isCancelled()) { + return; + } + // CraftBukkit end - world.setTypeUpdate(blockposition, Blocks.DIRT.getBlockData()); - AxisAlignedBB axisalignedbb = BlockSoil.c.a(blockposition); - List list = world.getEntities((Entity) null, axisalignedbb); + world.setTypeUpdate(blockposition, a(iblockdata, Blocks.DIRT.getBlockData(), (GeneratorAccess) world, blockposition)); + } + diff --git a/paper-server/nms-patches/BlockStateInteger.patch b/paper-server/nms-patches/BlockStateInteger.patch new file mode 100644 index 0000000000..878d458dc4 --- /dev/null +++ b/paper-server/nms-patches/BlockStateInteger.patch @@ -0,0 +1,18 @@ +--- a/net/minecraft/server/BlockStateInteger.java ++++ b/net/minecraft/server/BlockStateInteger.java +@@ -9,9 +9,15 @@ + public class BlockStateInteger extends BlockState { + + private final ImmutableSet a; ++ // CraftBukkit start ++ public final int min; ++ public final int max; + + protected BlockStateInteger(String s, int i, int j) { + super(s, Integer.class); ++ this.min = i; ++ this.max = j; ++ // CraftBukkit end + if (i < 0) { + throw new IllegalArgumentException("Min value of " + s + " must be 0 or greater"); + } else if (j <= i) { diff --git a/paper-server/nms-patches/BlockStationary.patch b/paper-server/nms-patches/BlockStationary.patch deleted file mode 100644 index 02a516fdd1..0000000000 --- a/paper-server/nms-patches/BlockStationary.patch +++ /dev/null @@ -1,40 +0,0 @@ ---- a/net/minecraft/server/BlockStationary.java -+++ b/net/minecraft/server/BlockStationary.java -@@ -2,6 +2,8 @@ - - import java.util.Random; - -+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit -+ - public class BlockStationary extends BlockFluids { - - protected BlockStationary(Material material) { -@@ -45,6 +47,13 @@ - - if (block.material == Material.AIR) { - if (this.c(world, blockposition1)) { -+ // CraftBukkit start - Prevent lava putting something on fire -+ if (world.getType(blockposition1) != Blocks.FIRE) { -+ if (CraftEventFactory.callBlockIgniteEvent(world, blockposition1.getX(), blockposition1.getY(), blockposition1.getZ(), blockposition.getX(), blockposition.getY(), blockposition.getZ()).isCancelled()) { -+ continue; -+ } -+ } -+ // CraftBukkit end - world.setTypeUpdate(blockposition1, Blocks.FIRE.getBlockData()); - return; - } -@@ -61,6 +70,14 @@ - } - - if (world.isEmpty(blockposition2.up()) && this.d(world, blockposition2)) { -+ // CraftBukkit start - Prevent lava putting something on fire -+ BlockPosition up = blockposition2.up(); -+ if (world.getType(up) != Blocks.FIRE) { -+ if (CraftEventFactory.callBlockIgniteEvent(world, up.getX(), up.getY(), up.getZ(), blockposition.getX(), blockposition.getY(), blockposition.getZ()).isCancelled()) { -+ continue; -+ } -+ } -+ // CraftBukkit end - world.setTypeUpdate(blockposition2.up(), Blocks.FIRE.getBlockData()); - } - } diff --git a/paper-server/nms-patches/BlockStem.patch b/paper-server/nms-patches/BlockStem.patch index df952dca07..1159ca0aa9 100644 --- a/paper-server/nms-patches/BlockStem.patch +++ b/paper-server/nms-patches/BlockStem.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/BlockStem.java +++ b/net/minecraft/server/BlockStem.java -@@ -4,6 +4,8 @@ +@@ -3,6 +3,8 @@ import java.util.Random; import javax.annotation.Nullable; @@ -8,34 +8,30 @@ + public class BlockStem extends BlockPlant implements IBlockFragilePlantElement { - public static final BlockStateInteger AGE = BlockStateInteger.of("age", 0, 7); -@@ -54,7 +56,8 @@ + public static final BlockStateInteger AGE = BlockProperties.V; +@@ -33,14 +35,14 @@ if (i < 7) { - iblockdata = iblockdata.set(BlockStem.AGE, Integer.valueOf(i + 1)); + iblockdata = (IBlockData) iblockdata.set(BlockStem.AGE, Integer.valueOf(i + 1)); - world.setTypeAndData(blockposition, iblockdata, 2); -+ // world.setTypeAndData(blockposition, iblockdata, 2); // CraftBukkit -+ CraftEventFactory.handleBlockGrowEvent(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this, toLegacyData(iblockdata)); // CraftBukkit ++ CraftEventFactory.handleBlockGrowEvent(world, blockposition, iblockdata, 2); // CraftBukkit } else { - Iterator iterator = EnumDirection.EnumDirectionLimit.HORIZONTAL.iterator(); + EnumDirection enumdirection = EnumDirection.EnumDirectionLimit.HORIZONTAL.a(random); + BlockPosition blockposition1 = blockposition.shift(enumdirection); + Block block = world.getType(blockposition1.down()).getBlock(); -@@ -70,7 +73,8 @@ - Block block = world.getType(blockposition.down()).getBlock(); - - if (world.getType(blockposition).getBlock().material == Material.AIR && (block == Blocks.FARMLAND || block == Blocks.DIRT || block == Blocks.GRASS)) { -- world.setTypeUpdate(blockposition, this.blockFruit.getBlockData()); -+ // world.setTypeUpdate(blockposition, this.blockFruit.getBlockData()); // CraftBukkit -+ CraftEventFactory.handleBlockGrowEvent(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this.blockFruit, 0); // CraftBukkit + if (world.getType(blockposition1).isAir() && (block == Blocks.FARMLAND || block == Blocks.DIRT || block == Blocks.COARSE_DIRT || block == Blocks.PODZOL || block == Blocks.GRASS_BLOCK)) { +- world.setTypeUpdate(blockposition1, this.blockFruit.getBlockData()); ++ CraftEventFactory.handleBlockGrowEvent(world, blockposition1, this.blockFruit.getBlockData()); // CraftBukkit + world.setTypeUpdate(blockposition, (IBlockData) this.blockFruit.d().getBlockData().set(BlockFacingHorizontal.FACING, enumdirection)); } } - } -@@ -81,7 +85,8 @@ - public void g(World world, BlockPosition blockposition, IBlockData iblockdata) { - int i = ((Integer) iblockdata.get(BlockStem.AGE)).intValue() + MathHelper.nextInt(world.random, 2, 5); +@@ -94,7 +96,7 @@ + int i = Math.min(7, ((Integer) iblockdata.get(BlockStem.AGE)).intValue() + MathHelper.nextInt(world.random, 2, 5)); + IBlockData iblockdata1 = (IBlockData) iblockdata.set(BlockStem.AGE, Integer.valueOf(i)); -- world.setTypeAndData(blockposition, iblockdata.set(BlockStem.AGE, Integer.valueOf(Math.min(7, i))), 2); -+ // world.setTypeAndData(blockposition, iblockdata.set(BlockStem.AGE, Integer.valueOf(Math.min(7, i))), 2); -+ CraftEventFactory.handleBlockGrowEvent(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this, Math.min(7, i)); // CraftBukkit - } - - public void dropNaturally(World world, BlockPosition blockposition, IBlockData iblockdata, float f, int i) { +- world.setTypeAndData(blockposition, iblockdata1, 2); ++ CraftEventFactory.handleBlockGrowEvent(world, blockposition, iblockdata1, 2); // CraftBukkit + if (i == 7) { + iblockdata1.a(world, blockposition, world.random); + } diff --git a/paper-server/nms-patches/BlockTNT.patch b/paper-server/nms-patches/BlockTNT.patch index ef5838b949..1af71a5f79 100644 --- a/paper-server/nms-patches/BlockTNT.patch +++ b/paper-server/nms-patches/BlockTNT.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/server/BlockTNT.java +++ b/net/minecraft/server/BlockTNT.java -@@ -75,6 +75,11 @@ +@@ -72,6 +72,11 @@ EntityArrow entityarrow = (EntityArrow) entity; if (entityarrow.isBurning()) { + // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entityarrow, blockposition, Blocks.AIR, 0).isCancelled()) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entityarrow, blockposition, Blocks.AIR.getBlockData()).isCancelled()) { + return; + } + // CraftBukkit end - this.a(world, blockposition, world.getType(blockposition).set(BlockTNT.EXPLODE, Boolean.valueOf(true)), entityarrow.shooter instanceof EntityLiving ? (EntityLiving) entityarrow.shooter : null); + this.a(world, blockposition, entityarrow.shooter instanceof EntityLiving ? (EntityLiving) entityarrow.shooter : null); world.setAir(blockposition); } diff --git a/paper-server/nms-patches/BlockTallPlant.patch b/paper-server/nms-patches/BlockTallPlant.patch index a1127a3aed..70676d56d8 100644 --- a/paper-server/nms-patches/BlockTallPlant.patch +++ b/paper-server/nms-patches/BlockTallPlant.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/server/BlockTallPlant.java +++ b/net/minecraft/server/BlockTallPlant.java @@ -48,6 +48,11 @@ + } - protected void e(World world, BlockPosition blockposition, IBlockData iblockdata) { - if (!this.f(world, blockposition, iblockdata)) { -+ // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPhysicsEvent(world, blockposition).isCancelled()) { -+ return; -+ } -+ // CraftBukkit end - boolean flag = iblockdata.get(BlockTallPlant.HALF) == BlockTallPlant.EnumTallPlantHalf.UPPER; - BlockPosition blockposition1 = flag ? blockposition : blockposition.up(); - BlockPosition blockposition2 = flag ? blockposition.down() : blockposition; + public void a(World world, BlockPosition blockposition, IBlockData iblockdata, EntityHuman entityhuman) { ++ // CraftBukkit start ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPhysicsEvent(world, blockposition).isCancelled()) { ++ return; ++ } ++ // CraftBukkit end + BlockPropertyDoubleBlockHalf blockpropertydoubleblockhalf = (BlockPropertyDoubleBlockHalf) iblockdata.get(BlockTallPlant.HALF); + boolean flag = blockpropertydoubleblockhalf == BlockPropertyDoubleBlockHalf.LOWER; + BlockPosition blockposition1 = flag ? blockposition.up() : blockposition.down(); diff --git a/paper-server/nms-patches/BlockTrapdoor.patch b/paper-server/nms-patches/BlockTrapdoor.patch index 310070951d..c809229bc8 100644 --- a/paper-server/nms-patches/BlockTrapdoor.patch +++ b/paper-server/nms-patches/BlockTrapdoor.patch @@ -6,12 +6,12 @@ import javax.annotation.Nullable; +import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit - public class BlockTrapdoor extends Block { + public class BlockTrapdoor extends BlockFacingHorizontal implements IFluidSource, IFluidContainer { -@@ -91,6 +92,19 @@ +@@ -94,6 +95,19 @@ boolean flag = world.isBlockIndirectlyPowered(blockposition); - if (flag || block.getBlockData().m()) { + if (flag != ((Boolean) iblockdata.get(BlockTrapdoor.c)).booleanValue()) { + // CraftBukkit start + org.bukkit.World bworld = world.getWorld(); + org.bukkit.block.Block bblock = bworld.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); @@ -19,12 +19,12 @@ + int power = bblock.getBlockPower(); + int oldPower = (Boolean) iblockdata.get(OPEN) ? 15 : 0; + -+ if (oldPower == 0 ^ power == 0 || block.getBlockData().n()) { ++ if (oldPower == 0 ^ power == 0 || block.getBlockData().isPowerSource()) { + BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bblock, oldPower, power); + world.getServer().getPluginManager().callEvent(eventRedstone); + flag = eventRedstone.getNewCurrent() > 0; + } + // CraftBukkit end - boolean flag1 = ((Boolean) iblockdata.get(BlockTrapdoor.OPEN)).booleanValue(); - - if (flag1 != flag) { + if (((Boolean) iblockdata.get(BlockTrapdoor.OPEN)).booleanValue() != flag) { + iblockdata = (IBlockData) iblockdata.set(BlockTrapdoor.OPEN, Boolean.valueOf(flag)); + this.a((EntityHuman) null, world, blockposition, flag); diff --git a/paper-server/nms-patches/BlockTripwire.patch b/paper-server/nms-patches/BlockTripwire.patch index 3f955f11bf..598b9c1b82 100644 --- a/paper-server/nms-patches/BlockTripwire.patch +++ b/paper-server/nms-patches/BlockTripwire.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/server/BlockTripwire.java +++ b/net/minecraft/server/BlockTripwire.java @@ -5,6 +5,8 @@ + import java.util.Map; import java.util.Random; - import javax.annotation.Nullable; +import org.bukkit.event.entity.EntityInteractEvent; // CraftBukkit + public class BlockTripwire extends Block { - public static final BlockStateBoolean POWERED = BlockStateBoolean.of("powered"); -@@ -138,6 +140,40 @@ + public static final BlockStateBoolean POWERED = BlockProperties.t; +@@ -134,6 +136,40 @@ } } @@ -48,5 +48,5 @@ + // CraftBukkit end + if (flag1 != flag) { - iblockdata = iblockdata.set(BlockTripwire.POWERED, Boolean.valueOf(flag1)); + iblockdata = (IBlockData) iblockdata.set(BlockTripwire.POWERED, Boolean.valueOf(flag1)); world.setTypeAndData(blockposition, iblockdata, 3); diff --git a/paper-server/nms-patches/BlockTripwireHook.patch b/paper-server/nms-patches/BlockTripwireHook.patch index d3cf09471b..dcc5409e52 100644 --- a/paper-server/nms-patches/BlockTripwireHook.patch +++ b/paper-server/nms-patches/BlockTripwireHook.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/BlockTripwireHook.java +++ b/net/minecraft/server/BlockTripwireHook.java -@@ -5,6 +5,8 @@ +@@ -4,6 +4,8 @@ import java.util.Random; import javax.annotation.Nullable; @@ -9,7 +9,7 @@ public class BlockTripwireHook extends Block { public static final BlockStateDirection FACING = BlockFacingHorizontal.FACING; -@@ -160,6 +162,17 @@ +@@ -137,6 +139,17 @@ this.a(world, blockposition1, flag4, flag5, flag2, flag3); } @@ -26,4 +26,4 @@ + this.a(world, blockposition, flag4, flag5, flag2, flag3); if (!flag) { - world.setTypeAndData(blockposition, iblockdata3.set(BlockTripwireHook.FACING, enumdirection), 3); + world.setTypeAndData(blockposition, (IBlockData) iblockdata3.set(BlockTripwireHook.FACING, enumdirection), 3); diff --git a/paper-server/nms-patches/BlockVine.patch b/paper-server/nms-patches/BlockVine.patch index aa2e152b62..d7093f6f54 100644 --- a/paper-server/nms-patches/BlockVine.patch +++ b/paper-server/nms-patches/BlockVine.patch @@ -1,71 +1,59 @@ --- a/net/minecraft/server/BlockVine.java +++ b/net/minecraft/server/BlockVine.java -@@ -4,6 +4,8 @@ - import java.util.Random; +@@ -7,6 +7,8 @@ + import java.util.function.Predicate; import javax.annotation.Nullable; +import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit + public class BlockVine extends Block { - public static final BlockStateBoolean UP = BlockStateBoolean.of("up"); -@@ -177,7 +179,13 @@ - } + public static final BlockStateBoolean UP = BlockSprawling.q; +@@ -183,20 +185,24 @@ + BlockPosition blockposition3 = blockposition2.shift(enumdirection1); + BlockPosition blockposition4 = blockposition2.shift(enumdirection2); - if (((Boolean) iblockdata1.get(BlockVine.NORTH)).booleanValue() || ((Boolean) iblockdata1.get(BlockVine.EAST)).booleanValue() || ((Boolean) iblockdata1.get(BlockVine.SOUTH)).booleanValue() || ((Boolean) iblockdata1.get(BlockVine.WEST)).booleanValue()) { -- world.setTypeAndData(blockposition1, iblockdata1, 2); -+ // CraftBukkit start - Call BlockSpreadEvent -+ // world.setTypeAndData(blockposition1, iblockdata1, 2); -+ BlockPosition target = blockposition1; -+ org.bukkit.block.Block source = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); -+ org.bukkit.block.Block block = world.getWorld().getBlockAt(target.getX(), target.getY(), target.getZ()); -+ CraftEventFactory.handleBlockSpreadEvent(block, source, this, toLegacyData(iblockdata1)); -+ // CraftBukkit end - } - - } else { -@@ -198,15 +206,26 @@ - BlockPosition blockposition3 = blockposition2.shift(enumdirection2); - BlockPosition blockposition4 = blockposition2.shift(enumdirection3); - -+ // CraftBukkit start - Call BlockSpreadEvent -+ org.bukkit.block.Block source = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); -+ org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(blockposition2.getX(), blockposition2.getY(), blockposition2.getZ()); ++ // CraftBukkit start - Call BlockSpreadEvent ++ BlockPosition source = blockposition; + - if (flag2 && this.a(world, blockposition3.shift(enumdirection2), enumdirection2)) { -- world.setTypeAndData(blockposition2, this.getBlockData().set(getDirection(enumdirection2), Boolean.valueOf(true)), 2); -+ // world.setTypeAndData(blockposition2, this.getBlockData().set(getDirection(enumdirection2), Boolean.valueOf(true)), 2); -+ CraftEventFactory.handleBlockSpreadEvent(bukkitBlock, source, this, toLegacyData(this.getBlockData().set(getDirection(enumdirection2), Boolean.valueOf(true)))); - } else if (flag3 && this.a(world, blockposition4.shift(enumdirection3), enumdirection3)) { -- world.setTypeAndData(blockposition2, this.getBlockData().set(getDirection(enumdirection3), Boolean.valueOf(true)), 2); -+ // world.setTypeAndData(blockposition2, this.getBlockData().set(getDirection(enumdirection3), Boolean.valueOf(true)), 2); -+ CraftEventFactory.handleBlockSpreadEvent(bukkitBlock, source, this, toLegacyData(this.getBlockData().set(getDirection(enumdirection3), Boolean.valueOf(true)))); - } else if (flag2 && world.isEmpty(blockposition3) && this.a(world, blockposition3, enumdirection)) { -- world.setTypeAndData(blockposition3, this.getBlockData().set(getDirection(enumdirection.opposite()), Boolean.valueOf(true)), 2); -+ // world.setTypeAndData(blockposition3, this.getBlockData().set(getDirection(enumdirection.opposite()), Boolean.valueOf(true)), 2); -+ bukkitBlock = world.getWorld().getBlockAt(blockposition3.getX(), blockposition3.getY(), blockposition3.getZ()); -+ CraftEventFactory.handleBlockSpreadEvent(bukkitBlock, source, this, toLegacyData(this.getBlockData().set(getDirection(enumdirection.opposite()), Boolean.valueOf(true)))); - } else if (flag3 && world.isEmpty(blockposition4) && this.a(world, blockposition4, enumdirection)) { -- world.setTypeAndData(blockposition4, this.getBlockData().set(getDirection(enumdirection.opposite()), Boolean.valueOf(true)), 2); -+ // world.setTypeAndData(blockposition4, this.getBlockData().set(getDirection(enumdirection.opposite()), Boolean.valueOf(true)), 2); -+ bukkitBlock = world.getWorld().getBlockAt(blockposition4.getX(), blockposition4.getY(), blockposition4.getZ()); -+ CraftEventFactory.handleBlockSpreadEvent(bukkitBlock, source, this, toLegacyData(this.getBlockData().set(getDirection(enumdirection.opposite()), Boolean.valueOf(true)))); + if (flag && this.b(world, blockposition3, enumdirection1)) { +- world.setTypeAndData(blockposition2, (IBlockData) this.getBlockData().set(getDirection(enumdirection1), Boolean.valueOf(true)), 2); ++ CraftEventFactory.handleBlockSpreadEvent(world, source, blockposition2, (IBlockData) this.getBlockData().set(getDirection(enumdirection1), Boolean.valueOf(true)), 2); + } else if (flag1 && this.b(world, blockposition4, enumdirection2)) { +- world.setTypeAndData(blockposition2, (IBlockData) this.getBlockData().set(getDirection(enumdirection2), Boolean.valueOf(true)), 2); ++ CraftEventFactory.handleBlockSpreadEvent(world, source, blockposition2, (IBlockData) this.getBlockData().set(getDirection(enumdirection2), Boolean.valueOf(true)), 2); + } else { + EnumDirection enumdirection3 = enumdirection.opposite(); + + if (flag && world.isEmpty(blockposition3) && this.b(world, blockposition.shift(enumdirection1), enumdirection3)) { +- world.setTypeAndData(blockposition3, (IBlockData) this.getBlockData().set(getDirection(enumdirection3), Boolean.valueOf(true)), 2); ++ CraftEventFactory.handleBlockSpreadEvent(world, source, blockposition3, (IBlockData) this.getBlockData().set(getDirection(enumdirection3), Boolean.valueOf(true)), 2); + } else if (flag1 && world.isEmpty(blockposition4) && this.b(world, blockposition.shift(enumdirection2), enumdirection3)) { +- world.setTypeAndData(blockposition4, (IBlockData) this.getBlockData().set(getDirection(enumdirection3), Boolean.valueOf(true)), 2); ++ CraftEventFactory.handleBlockSpreadEvent(world, source, blockposition4, (IBlockData) this.getBlockData().set(getDirection(enumdirection3), Boolean.valueOf(true)), 2); + } else if ((double) world.random.nextFloat() < 0.05D && this.b(world, blockposition2.up(), EnumDirection.UP)) { +- world.setTypeAndData(blockposition2, (IBlockData) this.getBlockData().set(BlockVine.UP, Boolean.valueOf(true)), 2); ++ CraftEventFactory.handleBlockSpreadEvent(world, source, blockposition2, (IBlockData) this.getBlockData().set(BlockVine.UP, Boolean.valueOf(true)), 2); } + // CraftBukkit end - } else if (iblockdata2.d(world, blockposition2, enumdirection) == EnumBlockFaceShape.SOLID) { - world.setTypeAndData(blockposition, iblockdata.set(getDirection(enumdirection), Boolean.valueOf(true)), 2); } -@@ -233,7 +252,12 @@ - } + } else if (this.b(world, blockposition2, enumdirection)) { + world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(getDirection(enumdirection), Boolean.valueOf(true)), 2); +@@ -226,7 +232,7 @@ + } - if (((Boolean) iblockdata3.get(BlockVine.NORTH)).booleanValue() || ((Boolean) iblockdata3.get(BlockVine.EAST)).booleanValue() || ((Boolean) iblockdata3.get(BlockVine.SOUTH)).booleanValue() || ((Boolean) iblockdata3.get(BlockVine.WEST)).booleanValue()) { -- world.setTypeAndData(blockposition2, iblockdata3, 2); -+ // CraftBukkit start - Call BlockSpreadEvent -+ // world.setTypeAndData(blockposition2, iblockdata3, 2); -+ org.bukkit.block.Block source = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); -+ org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(blockposition2.getX(), blockposition2.getY(), blockposition2.getZ()); -+ CraftEventFactory.handleBlockSpreadEvent(bukkitBlock, source, this, toLegacyData(iblockdata3)); -+ // CraftBukkit end - } - } else if (block == this) { - iblockdata3 = iblockdata2; + if (this.x(iblockdata3)) { +- world.setTypeAndData(blockposition1, iblockdata3, 2); ++ CraftEventFactory.handleBlockSpreadEvent(world, blockposition, blockposition1, iblockdata3, 2); // CraftBukkit + } + + return; +@@ -241,7 +247,7 @@ + IBlockData iblockdata5 = this.a(iblockdata, iblockdata4, random); + + if (iblockdata4 != iblockdata5 && this.x(iblockdata5)) { +- world.setTypeAndData(blockposition2, iblockdata5, 2); ++ CraftEventFactory.handleBlockSpreadEvent(world, blockposition, blockposition2, iblockdata5, 2); // CraftBukkit + } + } + } diff --git a/paper-server/nms-patches/BlockWaterLily.patch b/paper-server/nms-patches/BlockWaterLily.patch index 83a6ae1d01..e055a69661 100644 --- a/paper-server/nms-patches/BlockWaterLily.patch +++ b/paper-server/nms-patches/BlockWaterLily.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/server/BlockWaterLily.java +++ b/net/minecraft/server/BlockWaterLily.java -@@ -20,7 +20,7 @@ +@@ -10,7 +10,7 @@ - public void a(World world, BlockPosition blockposition, IBlockData iblockdata, Entity entity) { - super.a(world, blockposition, iblockdata, entity); + public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { + super.a(iblockdata, world, blockposition, entity); - if (entity instanceof EntityBoat) { -+ if (entity instanceof EntityBoat && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, Blocks.AIR, 0).isCancelled()) { // CraftBukkit ++ if (entity instanceof EntityBoat && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, Blocks.AIR.getBlockData()).isCancelled()) { // CraftBukkit world.setAir(new BlockPosition(blockposition), true); } diff --git a/paper-server/nms-patches/BlockWitherSkull.patch b/paper-server/nms-patches/BlockWitherSkull.patch new file mode 100644 index 0000000000..bc921119fa --- /dev/null +++ b/paper-server/nms-patches/BlockWitherSkull.patch @@ -0,0 +1,66 @@ +--- a/net/minecraft/server/BlockWitherSkull.java ++++ b/net/minecraft/server/BlockWitherSkull.java +@@ -3,6 +3,11 @@ + import java.util.Iterator; + import javax.annotation.Nullable; + ++// CraftBukkit start ++import org.bukkit.craftbukkit.util.BlockStateListPopulator; ++import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; ++// CraftBukkit end ++ + public class BlockWitherSkull extends BlockSkull { + + private static ShapeDetector c; +@@ -23,6 +28,7 @@ + } + + public static void a(World world, BlockPosition blockposition, TileEntitySkull tileentityskull) { ++ if (world.captureBlockStates) return; // CraftBukkit + Block block = tileentityskull.getBlock().getBlock(); + boolean flag = block == Blocks.WITHER_SKELETON_SKULL || block == Blocks.WITHER_SKELETON_WALL_SKULL; + +@@ -31,6 +37,8 @@ + ShapeDetector.ShapeDetectorCollection shapedetector_shapedetectorcollection = shapedetector.a(world, blockposition); + + if (shapedetector_shapedetectorcollection != null) { ++ // CraftBukkit start - Use BlockStateListPopulator ++ BlockStateListPopulator blockList = new BlockStateListPopulator(world); + int i; + + for (i = 0; i < 3; ++i) { +@@ -39,7 +47,7 @@ + + for (i = 0; i < shapedetector.c(); ++i) { + for (int j = 0; j < shapedetector.b(); ++j) { +- world.setTypeAndData(shapedetector_shapedetectorcollection.a(i, j, 0).getPosition(), Blocks.AIR.getBlockData(), 2); ++ blockList.setTypeAndData(shapedetector_shapedetectorcollection.a(i, j, 0).getPosition(), Blocks.AIR.getBlockData(), 2); // CraftBukkit + } + } + +@@ -50,6 +58,16 @@ + entitywither.setPositionRotation((double) blockposition2.getX() + 0.5D, (double) blockposition2.getY() + 0.55D, (double) blockposition2.getZ() + 0.5D, shapedetector_shapedetectorcollection.getFacing().k() == EnumDirection.EnumAxis.X ? 0.0F : 90.0F, 0.0F); + entitywither.aQ = shapedetector_shapedetectorcollection.getFacing().k() == EnumDirection.EnumAxis.X ? 0.0F : 90.0F; + entitywither.l(); ++ // CraftBukkit start ++ if (!world.addEntity(entitywither, SpawnReason.BUILD_WITHER)) { ++ // Restore drop status from above ++ for (i = 0; i < 3; ++i) { ++ TileEntitySkull.setShouldDrop(world, shapedetector_shapedetectorcollection.a(i, 0, 0).getPosition(), true); ++ } ++ return; ++ } ++ blockList.updateList(); ++ // CraftBukkit end + Iterator iterator = world.a(EntityPlayer.class, entitywither.getBoundingBox().g(50.0D)).iterator(); + + while (iterator.hasNext()) { +@@ -58,7 +76,7 @@ + CriterionTriggers.n.a(entityplayer, (Entity) entitywither); + } + +- world.addEntity(entitywither); ++ // world.addEntity(entitywither); // CraftBukkit - moved up + + int k; + diff --git a/paper-server/nms-patches/ChatBaseComponent.patch b/paper-server/nms-patches/ChatBaseComponent.patch deleted file mode 100644 index bd82c4a175..0000000000 --- a/paper-server/nms-patches/ChatBaseComponent.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/server/ChatBaseComponent.java -+++ b/net/minecraft/server/ChatBaseComponent.java -@@ -112,7 +112,7 @@ - } - - public int hashCode() { -- return 31 * this.b.hashCode() + this.a.hashCode(); -+ return 31 * this.getChatModifier().hashCode() + this.a.hashCode(); // CraftBukkit - fix null pointer - } - - public String toString() { diff --git a/paper-server/nms-patches/ChatModifier.patch b/paper-server/nms-patches/ChatModifier.patch deleted file mode 100644 index bd72bcff2d..0000000000 --- a/paper-server/nms-patches/ChatModifier.patch +++ /dev/null @@ -1,45 +0,0 @@ ---- a/net/minecraft/server/ChatModifier.java -+++ b/net/minecraft/server/ChatModifier.java -@@ -263,16 +263,18 @@ - } - - public int hashCode() { -- int i = this.b.hashCode(); -+ // CraftBukkit start - fix npe -+ int i = b == null ? 0 : this.b.hashCode(); - -- i = 31 * i + this.c.hashCode(); -- i = 31 * i + this.d.hashCode(); -- i = 31 * i + this.e.hashCode(); -- i = 31 * i + this.f.hashCode(); -- i = 31 * i + this.g.hashCode(); -- i = 31 * i + this.h.hashCode(); -- i = 31 * i + this.i.hashCode(); -- i = 31 * i + this.j.hashCode(); -+ i = 31 * i + (c == null ? 0 : this.c.hashCode()); -+ i = 31 * i + (d == null ? 0 : this.d.hashCode()); -+ i = 31 * i + (e == null ? 0 : this.e.hashCode()); -+ i = 31 * i + (f == null ? 0 : this.f.hashCode()); -+ i = 31 * i + (g == null ? 0 : this.g.hashCode()); -+ i = 31 * i + (h == null ? 0 : this.h.hashCode()); -+ i = 31 * i + (this.i == null ? 0 : this.i.hashCode()); -+ i = 31 * i + (j == null ? 0 : this.j.hashCode()); -+ // CraftBukkit end - return i; - } - -@@ -441,12 +443,12 @@ - } - - @Nullable -- public JsonElement serialize(Object object, Type type, JsonSerializationContext jsonserializationcontext) { -+ public JsonElement serialize(ChatModifier object, Type type, JsonSerializationContext jsonserializationcontext) { // CraftBukkit - fix decompile error - return this.a((ChatModifier) object, type, jsonserializationcontext); - } - - @Nullable -- public Object deserialize(JsonElement jsonelement, Type type, JsonDeserializationContext jsondeserializationcontext) throws JsonParseException { -+ public ChatModifier deserialize(JsonElement jsonelement, Type type, JsonDeserializationContext jsondeserializationcontext) throws JsonParseException { // CraftBukkit - fix decompile error - return this.a(jsonelement, type, jsondeserializationcontext); - } - } diff --git a/paper-server/nms-patches/Chunk.patch b/paper-server/nms-patches/Chunk.patch index 92d24e2d8c..7159a34cfe 100644 --- a/paper-server/nms-patches/Chunk.patch +++ b/paper-server/nms-patches/Chunk.patch @@ -1,18 +1,17 @@ --- a/net/minecraft/server/Chunk.java +++ b/net/minecraft/server/Chunk.java -@@ -14,6 +14,9 @@ +@@ -23,6 +23,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import com.google.common.collect.Lists; // CraftBukkit -+import org.bukkit.Server; // CraftBukkit + - public class Chunk { + public class Chunk implements IChunkAccess { private static final Logger e = LogManager.getLogger(); -@@ -42,6 +45,35 @@ - private final ConcurrentLinkedQueue y; - public boolean d; +@@ -58,6 +60,35 @@ + private int E; + private final AtomicInteger F; + // CraftBukkit start - Neighbor loaded cache for chunk lighting and entity ticking + private int neighbors = 0x1 << 12; @@ -43,13 +42,13 @@ + } + // CraftBukkit end + - public Chunk(World world, int i, int j) { + public Chunk(World world, int i, int j, BiomeBase[] abiomebase, ChunkConverter chunkconverter, TickList ticklist, TickList ticklist1, long k) { this.sections = new ChunkSection[16]; - this.g = new byte[256]; -@@ -62,8 +94,15 @@ - - Arrays.fill(this.h, -999); - Arrays.fill(this.g, (byte) -1); + this.h = new boolean[256]; +@@ -95,8 +126,16 @@ + this.t = ticklist; + this.u = ticklist1; + this.A = k; + // CraftBukkit start + this.bukkitChunk = new org.bukkit.craftbukkit.CraftChunk(this); + this.chunkKey = ChunkCoordIntPair.a(this.locX, this.locZ); @@ -57,22 +56,41 @@ + public org.bukkit.Chunk bukkitChunk; + public boolean mustSave; ++ public boolean newChunk; + // CraftBukkit end + - public Chunk(World world, ChunkSnapshot chunksnapshot, int i, int j) { - this(world, i, j); - boolean flag = true; -@@ -467,7 +506,8 @@ + public Chunk(World world, ProtoChunk protochunk, int i, int j) { + this(world, i, j, protochunk.getBiomeIndex(), protochunk.v(), protochunk.n(), protochunk.o(), protochunk.m()); + +@@ -136,14 +175,15 @@ + HeightMap.Type heightmap_type = (HeightMap.Type) iterator.next(); + + if (heightmap_type.c() == HeightMap.Use.LIVE_WORLD) { +- ((HeightMap) this.heightMap.computeIfAbsent(heightmap_type, (heightmap_type) -> { +- return new HeightMap(this, heightmap_type); ++ ((HeightMap) this.heightMap.computeIfAbsent(heightmap_type, (heightmap_type1) -> { // CraftBukkit - decompile error ++ return new HeightMap(this, heightmap_type1); // CraftBukkit - decompile error + })).a(protochunk.b(heightmap_type).b()); + } + } + + this.y = true; + this.a(ChunkStatus.FULLCHUNK); ++ this.newChunk = true; // CraftBukkit + } + + public Set t() { +@@ -474,7 +514,8 @@ } } -- if (!this.world.isClientSide && block1 != block) { +- if (!this.world.isClientSide) { + // CraftBukkit - Don't place while processing the BlockPlaceEvent, unless it's a BlockContainer. Prevents blocks such as TNT from activating when cancelled. -+ if (!this.world.isClientSide && block1 != block && (!this.world.captureBlockStates || block instanceof BlockTileEntity)) { - block.onPlace(this.world, blockposition, iblockdata); ++ if (!this.world.isClientSide && (!this.world.captureBlockStates || block instanceof BlockTileEntity)) { + iblockdata.onPlace(this.world, blockposition, iblockdata1); } -@@ -604,7 +644,15 @@ +@@ -654,7 +695,15 @@ @Nullable public TileEntity a(BlockPosition blockposition, Chunk.EnumTileEntityState chunk_enumtileentitystate) { @@ -89,21 +107,21 @@ if (tileentity == null) { if (chunk_enumtileentitystate == Chunk.EnumTileEntityState.IMMEDIATE) { -@@ -639,6 +687,13 @@ +@@ -689,6 +738,13 @@ - tileentity.A(); + tileentity.z(); this.tileEntities.put(blockposition, tileentity); + // CraftBukkit start + } else { + System.out.println("Attempted to place a tile entity (" + tileentity + ") at " + tileentity.position.getX() + "," + tileentity.position.getY() + "," + tileentity.position.getZ() -+ + " (" + org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(getBlockData(blockposition).getBlock()) + ") where there was no entity tile!"); ++ + " (" + getType(blockposition) + ") where there was no entity tile!"); + System.out.println("Chunk coordinates: " + (this.locX * 16) + "," + (this.locZ * 16)); + new Exception().printStackTrace(); + // CraftBukkit end } } -@@ -681,9 +736,21 @@ +@@ -735,9 +791,21 @@ int i = aentityslice.length; for (int j = 0; j < i; ++j) { @@ -127,80 +145,49 @@ } } -@@ -745,8 +812,8 @@ +@@ -799,8 +867,8 @@ while (iterator.hasNext()) { Entity entity = (Entity) iterator.next(); -- if (entity.getBoundingBox().c(axisalignedbb) && (predicate == null || predicate.apply(entity))) { +- if (entity.getBoundingBox().c(axisalignedbb) && (predicate == null || predicate.test(entity))) { - list.add(entity); -+ if (entity.getBoundingBox().c(axisalignedbb) && (predicate == null || predicate.apply((T) entity))) { // CraftBukkit - fix decompile error ++ if (entity.getBoundingBox().c(axisalignedbb) && (predicate == null || predicate.test((T) entity))) { // CraftBukkit - fix decompile error + list.add((T) entity); // Fix decompile error } } } -@@ -773,7 +840,34 @@ - return false; +@@ -1006,13 +1074,13 @@ + + @Nullable + public LongSet b(String s) { +- return (LongSet) this.r.computeIfAbsent(s, (s) -> { ++ return (LongSet) this.r.computeIfAbsent(s, (s1) -> { // CraftBukkit - decompile error + return new LongOpenHashSet(); + }); } -- public void loadNearby(IChunkProvider ichunkprovider, ChunkGenerator chunkgenerator) { -+ // CraftBukkit start -+ public void loadNearby(IChunkProvider ichunkprovider, ChunkGenerator chunkgenerator, boolean newChunk) { -+ Server server = world.getServer(); -+ if (server != null) { -+ /* -+ * If it's a new world, the first few chunks are generated inside -+ * the World constructor. We can't reliably alter that, so we have -+ * no way of creating a CraftWorld/CraftServer at that point. -+ */ -+ server.getPluginManager().callEvent(new org.bukkit.event.world.ChunkLoadEvent(bukkitChunk, newChunk)); -+ } -+ -+ // Update neighbor counts -+ for (int x = -2; x < 3; x++) { -+ for (int z = -2; z < 3; z++) { -+ if (x == 0 && z == 0) { -+ continue; -+ } -+ -+ Chunk neighbor = getWorld().getChunkIfLoaded(locX + x, locZ + z); -+ if (neighbor != null) { -+ neighbor.setNeighborLoaded(-x, -z); -+ setNeighborLoaded(x, z); -+ } -+ } -+ } -+ // CraftBukkit end -+ - Chunk chunk = ichunkprovider.getLoadedChunkAt(this.locX, this.locZ - 1); - Chunk chunk1 = ichunkprovider.getLoadedChunkAt(this.locX + 1, this.locZ); - Chunk chunk2 = ichunkprovider.getLoadedChunkAt(this.locX, this.locZ + 1); -@@ -809,6 +903,29 @@ - } else { - this.o(); - chunkgenerator.recreateStructures(this.locX, this.locZ); -+ -+ // CraftBukkit start -+ BlockSand.instaFall = true; -+ Random random = new Random(); -+ random.setSeed(world.getSeed()); -+ long xRand = random.nextLong() / 2L * 2L + 1L; -+ long zRand = random.nextLong() / 2L * 2L + 1L; -+ random.setSeed((long) locX * xRand + (long) locZ * zRand ^ world.getSeed()); -+ -+ org.bukkit.World world = this.world.getWorld(); -+ if (world != null) { -+ this.world.populating = true; -+ try { -+ for (org.bukkit.generator.BlockPopulator populator : world.getPopulators()) { -+ populator.populate(world, random, bukkitChunk); -+ } -+ } finally { -+ this.world.populating = false; -+ } -+ } -+ BlockSand.instaFall = false; -+ this.world.getServer().getPluginManager().callEvent(new org.bukkit.event.world.ChunkPopulateEvent(bukkitChunk)); -+ // CraftBukkit end - this.markDirty(); - } + public void a(String s, long i) { +- ((LongSet) this.r.computeIfAbsent(s, (s) -> { ++ ((LongSet) this.r.computeIfAbsent(s, (s1) -> { // CraftBukkit - decompile error + return new LongOpenHashSet(); + })).add(i); + } +@@ -1061,14 +1129,14 @@ + } + + if (this.t instanceof ProtoChunkTickList) { +- ((ProtoChunkTickList) this.t).a(this.world.I(), (blockposition) -> { +- return this.world.getType(blockposition).getBlock(); ++ ((ProtoChunkTickList) this.t).a(this.world.I(), (blockposition1) -> { // CraftBukkit - decompile error ++ return this.world.getType(blockposition1).getBlock(); + }); + } + + if (this.u instanceof ProtoChunkTickList) { +- ((ProtoChunkTickList) this.u).a(this.world.H(), (blockposition) -> { +- return this.world.b(blockposition).c(); ++ ((ProtoChunkTickList) this.u).a(this.world.H(), (blockposition1) -> { // CraftBukkit - decompile error ++ return this.world.b(blockposition1).c(); + }); + } diff --git a/paper-server/nms-patches/ChunkMap.patch b/paper-server/nms-patches/ChunkMap.patch new file mode 100644 index 0000000000..8007134eff --- /dev/null +++ b/paper-server/nms-patches/ChunkMap.patch @@ -0,0 +1,88 @@ +--- a/net/minecraft/server/ChunkMap.java ++++ b/net/minecraft/server/ChunkMap.java +@@ -31,6 +31,54 @@ + } + } + ++ org.bukkit.Server server = chunk.world.getServer(); ++ if (server != null) { ++ /* ++ * If it's a new world, the first few chunks are generated inside ++ * the World constructor. We can't reliably alter that, so we have ++ * no way of creating a CraftWorld/CraftServer at that point. ++ */ ++ server.getPluginManager().callEvent(new org.bukkit.event.world.ChunkLoadEvent(chunk.bukkitChunk, chunk.newChunk)); ++ } ++ ++ // Update neighbor counts ++ for (int x = -2; x < 3; x++) { ++ for (int z = -2; z < 3; z++) { ++ if (x == 0 && z == 0) { ++ continue; ++ } ++ ++ Chunk neighbor = this.get(ChunkCoordIntPair.a(chunkcoordintpair.x + x, chunkcoordintpair.z + z)); ++ if (neighbor != null) { ++ neighbor.setNeighborLoaded(-x, -z); ++ chunk.setNeighborLoaded(x, z); ++ } ++ } ++ } ++ ++ if (chunk.newChunk) { ++ BlockSand.instaFall = true; ++ java.util.Random random = new java.util.Random(); ++ random.setSeed(chunk.world.getSeed()); ++ long xRand = random.nextLong() / 2L * 2L + 1L; ++ long zRand = random.nextLong() / 2L * 2L + 1L; ++ random.setSeed((long) chunk.locX * xRand + (long) chunk.locZ * zRand ^ chunk.world.getSeed()); ++ ++ org.bukkit.World world = chunk.world.getWorld(); ++ if (world != null) { ++ chunk.world.populating = true; ++ try { ++ for (org.bukkit.generator.BlockPopulator populator : world.getPopulators()) { ++ populator.populate(world, random, chunk.bukkitChunk); ++ } ++ } finally { ++ chunk.world.populating = false; ++ } ++ } ++ BlockSand.instaFall = false; ++ chunk.world.getServer().getPluginManager().callEvent(new org.bukkit.event.world.ChunkPopulateEvent(chunk.bukkitChunk)); ++ } ++ + return chunk1; + } + +@@ -69,23 +117,25 @@ + throw new RuntimeException("Not yet implemented"); + } + +- public Object remove(Object object) { ++ // CraftBukkit start - decompile errors ++ public Chunk remove(Object object) { + return this.a(object); + } + +- public Object remove(long i) { ++ public Chunk remove(long i) { + return this.a(i); + } + +- public Object put(Long olong, Object object) { ++ public Chunk put(Long olong, Chunk object) { + return this.a(olong, (Chunk) object); + } + +- public Object put(long i, Object object) { ++ public Chunk put(long i, Chunk object) { + return this.a(i, (Chunk) object); + } + +- public Object put(Object object, Object object1) { ++ public Object put(Object object, Chunk object1) { + return this.a((Long) object, (Chunk) object1); + } ++ // CraftBukkit end + } diff --git a/paper-server/nms-patches/ChunkProviderGenerate.patch b/paper-server/nms-patches/ChunkProviderGenerate.patch index 65c2bcd92b..f884de90ed 100644 --- a/paper-server/nms-patches/ChunkProviderGenerate.patch +++ b/paper-server/nms-patches/ChunkProviderGenerate.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/ChunkProviderGenerate.java +++ b/net/minecraft/server/ChunkProviderGenerate.java -@@ -234,6 +234,11 @@ +@@ -166,6 +166,11 @@ f5 = 1.0F + f5 * 2.0F; f6 = 1.0F + f6 * 4.0F; } @@ -10,5 +10,14 @@ + } + // CraftBukkit end - float f7 = this.r[l1 + 2 + (i2 + 2) * 5] / (f5 + 2.0F); + float f7 = this.o[l1 + 2 + (i2 + 2) * 5] / (f5 + 2.0F); +@@ -267,7 +272,7 @@ + return this.a.getSeaLevel() + 1; + } + +- public GeneratorSettings getSettings() { ++ public GeneratorSettingsOverworld getSettings() { // CraftBukkit - decompile error + return this.f(); + } + } diff --git a/paper-server/nms-patches/ChunkProviderServer.patch b/paper-server/nms-patches/ChunkProviderServer.patch index 9f92a1c33e..008a069b8a 100644 --- a/paper-server/nms-patches/ChunkProviderServer.patch +++ b/paper-server/nms-patches/ChunkProviderServer.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/ChunkProviderServer.java +++ b/net/minecraft/server/ChunkProviderServer.java -@@ -15,6 +15,11 @@ +@@ -20,6 +20,11 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -12,40 +12,31 @@ public class ChunkProviderServer implements IChunkProvider { private static final Logger a = LogManager.getLogger(); -@@ -70,19 +75,82 @@ - Chunk chunk = this.getLoadedChunkAt(i, j); +@@ -35,7 +40,7 @@ + this.world = worldserver; + this.chunkLoader = ichunkloader; + this.chunkGenerator = chunkgenerator; +- this.f = new ChunkTaskScheduler(2, worldserver, chunkgenerator, ichunkloader, iasynctaskhandler); ++ this.f = new ChunkTaskScheduler(0, worldserver, chunkgenerator, ichunkloader, iasynctaskhandler); // CraftBukkit - very buggy, broken in lots of __subtle__ ways. Same goes for async chunk loading. Also Bukkit API / plugins can't handle async events at all anyway. + this.g = new SchedulerBatch(this.f); + } + +@@ -77,9 +82,10 @@ + @Nullable + private Chunk loadChunkAt(int i, int j) { + try { +- Chunk chunk = this.chunkLoader.a(this.world, i, j, (chunk) -> { +- chunk.setLastSaved(this.world.getTime()); +- this.chunks.put(ChunkCoordIntPair.a(i, j), chunk); ++ // CraftBukkit - decompile error ++ Chunk chunk = this.chunkLoader.a(this.world, i, j, (chunk1) -> { ++ chunk1.setLastSaved(this.world.getTime()); ++ this.chunks.put(ChunkCoordIntPair.a(i, j), chunk1); + }); - if (chunk == null) { -+ // CraftBukkit start -+ ChunkRegionLoader loader = null; -+ -+ if (this.chunkLoader instanceof ChunkRegionLoader) { -+ loader = (ChunkRegionLoader) this.chunkLoader; -+ } -+ if (loader != null && loader.chunkExists(i, j)) { -+ chunk = ChunkIOExecutor.syncChunkLoad(world, loader, this, i, j); -+ } -+ } -+ -+ return chunk; -+ } -+ -+ @Nullable -+ public Chunk originalGetOrLoadChunkAt(int i, int j) { -+ // CraftBukkit end -+ Chunk chunk = this.getLoadedChunkAt(i, j); -+ -+ if (chunk == null) { - chunk = this.loadChunk(i, j); if (chunk != null) { - this.chunks.put(ChunkCoordIntPair.a(i, j), chunk); - chunk.addEntities(); -- chunk.loadNearby(this, this.chunkGenerator); -+ chunk.loadNearby(this, this.chunkGenerator, false); // CraftBukkit - } +@@ -104,6 +110,12 @@ } - - return chunk; } + // CraftBukkit start @@ -55,74 +46,27 @@ + // CraftBukkit end + public Chunk getChunkAt(int i, int j) { -- Chunk chunk = this.getOrLoadChunkAt(i, j); -+ return getChunkAt(i, j, null); -+ } -+ -+ public Chunk getChunkAt(int i, int j, Runnable runnable) { -+ return getChunkAt(i, j, runnable, true); -+ } -+ -+ public Chunk getChunkAt(int i, int j, Runnable runnable, boolean generate) { -+ Chunk chunk = getLoadedChunkAt(i, j); -+ ChunkRegionLoader loader = null; -+ -+ if (this.chunkLoader instanceof ChunkRegionLoader) { -+ loader = (ChunkRegionLoader) this.chunkLoader; -+ -+ } -+ // We can only use the queue for already generated chunks -+ if (chunk == null && loader != null && loader.chunkExists(i, j)) { -+ if (runnable != null) { -+ ChunkIOExecutor.queueChunkLoad(world, loader, this, i, j, runnable); -+ return null; -+ } else { -+ chunk = ChunkIOExecutor.syncChunkLoad(world, loader, this, i, j); -+ } -+ } else if (chunk == null && generate) { -+ chunk = originalGetChunkAt(i, j); -+ } -+ -+ // If we didn't load the chunk async and have a callback run it now -+ if (runnable != null) { -+ runnable.run(); -+ } -+ -+ return chunk; -+ } -+ -+ public Chunk originalGetChunkAt(int i, int j) { -+ Chunk chunk = this.originalGetOrLoadChunkAt(i, j); -+ // CraftBukkit end + Chunk chunk = this.getOrLoadChunkAt(i, j); - if (chunk == null) { - long k = ChunkCoordIntPair.a(i, j); -@@ -101,7 +169,7 @@ +@@ -125,7 +137,7 @@ + synchronized (this.chunks) { + IChunkAccess ichunkaccess = (IChunkAccess) this.chunks.get(ChunkCoordIntPair.a(i, j)); - this.chunks.put(k, chunk); - chunk.addEntities(); -- chunk.loadNearby(this, this.chunkGenerator); -+ chunk.loadNearby(this, this.chunkGenerator, true); // CraftBukkit +- return ichunkaccess != null ? ichunkaccess : (IChunkAccess) this.f.c((Object) (new ChunkCoordIntPair(i, j))); ++ return ichunkaccess != null ? ichunkaccess : (IChunkAccess) this.f.c((new ChunkCoordIntPair(i, j))); // CraftBukkit - decompile error } + } - return chunk; -@@ -147,10 +215,12 @@ +@@ -150,7 +162,7 @@ + public CompletableFuture generateChunk(int i, int j) { + this.g.b(); + this.g.a(new ChunkCoordIntPair(i, j)); +- CompletableFuture completablefuture = this.g.c(); ++ CompletableFuture completablefuture = this.g.c(); // CraftBukkit - decompile error - public boolean a(boolean flag) { - int i = 0; -- ArrayList arraylist = Lists.newArrayList(this.chunks.values()); - -- for (int j = 0; j < arraylist.size(); ++j) { -- Chunk chunk = (Chunk) arraylist.get(j); -+ // CraftBukkit start -+ Iterator iterator = this.chunks.values().iterator(); -+ while (iterator.hasNext()) { -+ Chunk chunk = (Chunk) iterator.next(); -+ // CraftBukkit end - - if (flag) { - this.saveChunkNOP(chunk); -@@ -183,10 +253,12 @@ + return completablefuture.thenApply(this::a); + } +@@ -268,10 +280,12 @@ Chunk chunk = (Chunk) this.chunks.get(olong); if (chunk != null && chunk.d) { @@ -139,7 +83,7 @@ ++i; } } -@@ -198,6 +270,40 @@ +@@ -284,6 +298,40 @@ return false; } diff --git a/paper-server/nms-patches/ChunkRegionLoader.patch b/paper-server/nms-patches/ChunkRegionLoader.patch index bf874a1b77..d657e19aee 100644 --- a/paper-server/nms-patches/ChunkRegionLoader.patch +++ b/paper-server/nms-patches/ChunkRegionLoader.patch @@ -1,112 +1,123 @@ --- a/net/minecraft/server/ChunkRegionLoader.java +++ b/net/minecraft/server/ChunkRegionLoader.java -@@ -19,29 +19,47 @@ - - private static final Logger a = LogManager.getLogger(); - private final Map b = Maps.newConcurrentMap(); -- private final Set c = Collections.newSetFromMap(Maps.newConcurrentMap()); -+ // CraftBukkit -+ // private final Set c = Collections.newSetFromMap(Maps.newConcurrentMap()); - private final File d; - private final DataConverterManager e; +@@ -34,7 +34,7 @@ + private final File c; + private final DataFixer d; + private PersistentStructureLegacy e; - private boolean f; -+ // private boolean f; -+ // CraftBukkit ++ // private boolean f; // CraftBukkit - public ChunkRegionLoader(File file, DataConverterManager dataconvertermanager) { - this.d = file; - this.e = dataconvertermanager; + public ChunkRegionLoader(File file, DataFixer datafixer) { + this.c = file; +@@ -50,12 +50,13 @@ + + @Nullable + private NBTTagCompound b(GeneratorAccess generatoraccess, int i, int j) throws IOException { +- DataInputStream datainputstream = RegionFileCache.d(this.c, i, j); ++ // CraftBukkit start ++ NBTTagCompound nbttagcompound = RegionFileCache.d(this.c, i, j); + +- if (datainputstream == null) { ++ if (nbttagcompound == null) { + return null; + } else { +- NBTTagCompound nbttagcompound = NBTCompressedStreamTools.a(datainputstream); ++ // CraftBukkit end + int k = nbttagcompound.hasKeyOfType("DataVersion", 99) ? nbttagcompound.getInt("DataVersion") : -1; + + if (k < 1493) { +@@ -78,13 +79,29 @@ + } } + // CraftBukkit start - Add async variant, provide compatibility @Nullable - public Chunk a(World world, int i, int j) throws IOException { -+ Object[] data = loadChunk(world, i, j); + public synchronized Chunk a(GeneratorAccess generatoraccess, int i, int j, Consumer consumer) throws IOException { ++ Object[] data = loadChunk(generatoraccess, i, j, consumer); + if (data != null) { + Chunk chunk = (Chunk) data[0]; + NBTTagCompound nbttagcompound = (NBTTagCompound) data[1]; -+ loadEntities(chunk, nbttagcompound.getCompound("Level"), world); ++ consumer.accept(chunk); ++ this.loadEntities(nbttagcompound.getCompound("Level"), chunk); + return chunk; + } + + return null; + } + -+ public Object[] loadChunk(World world, int i, int j) throws IOException { ++ public synchronized Object[] loadChunk(GeneratorAccess generatoraccess, int i, int j, Consumer consumer) throws IOException { + // CraftBukkit end - ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(i, j); - NBTTagCompound nbttagcompound = (NBTTagCompound) this.b.get(chunkcoordintpair); + NBTTagCompound nbttagcompound = this.a(generatoraccess, i, j); if (nbttagcompound == null) { -- DataInputStream datainputstream = RegionFileCache.d(this.d, i, j); -+ // CraftBukkit start -+ nbttagcompound = RegionFileCache.d(this.d, i, j); + return null; + } else { ++ /* + Chunk chunk = this.a(generatoraccess, i, j, nbttagcompound); -- if (datainputstream == null) { -+ if (nbttagcompound == null) { - return null; + if (chunk != null) { +@@ -93,6 +110,9 @@ } -- nbttagcompound = this.e.a((DataConverterType) DataConverterTypes.CHUNK, NBTCompressedStreamTools.a(datainputstream)); -+ nbttagcompound = this.e.a((DataConverterType) DataConverterTypes.CHUNK, nbttagcompound); -+ // CraftBukkit end + return chunk; ++ */ ++ ++ return this.a(generatoraccess, i, j, nbttagcompound); } + } - return this.a(world, i, j, nbttagcompound); -@@ -55,7 +73,7 @@ +@@ -121,7 +141,7 @@ } @Nullable -- protected Chunk a(World world, int i, int j, NBTTagCompound nbttagcompound) { -+ protected Object[] a(World world, int i, int j, NBTTagCompound nbttagcompound) { // CraftBukkit - return Chunk -> Object[] - if (!nbttagcompound.hasKeyOfType("Level", 10)) { - ChunkRegionLoader.a.error("Chunk file at {},{} is missing level data, skipping", Integer.valueOf(i), Integer.valueOf(j)); - return null; -@@ -72,10 +90,28 @@ - ChunkRegionLoader.a.error("Chunk file at {},{} is in the wrong location; relocating. (Expected {}, {}, got {}, {})", Integer.valueOf(i), Integer.valueOf(j), Integer.valueOf(i), Integer.valueOf(j), Integer.valueOf(chunk.locX), Integer.valueOf(chunk.locZ)); - nbttagcompound1.setInt("xPos", i); - nbttagcompound1.setInt("zPos", j); +- protected Chunk a(GeneratorAccess generatoraccess, int i, int j, NBTTagCompound nbttagcompound) { ++ protected Object[] a(GeneratorAccess generatoraccess, int i, int j, NBTTagCompound nbttagcompound) { // CraftBukkit - return Chunk -> Object[] + if (nbttagcompound.hasKeyOfType("Level", 10) && nbttagcompound.getCompound("Level").hasKeyOfType("Status", 8)) { + ChunkStatus.Type chunkstatus_type = this.a(nbttagcompound); + +@@ -140,10 +160,28 @@ + ChunkRegionLoader.a.error("Chunk file at {},{} is in the wrong location; relocating. (Expected {}, {}, got {}, {})", Integer.valueOf(i), Integer.valueOf(j), Integer.valueOf(i), Integer.valueOf(j), Integer.valueOf(chunk.locX), Integer.valueOf(chunk.locZ)); + nbttagcompound1.setInt("xPos", i); + nbttagcompound1.setInt("zPos", j); + -+ // CraftBukkit start - Have to move tile entities since we don't load them at this stage -+ NBTTagList tileEntities = nbttagcompound.getCompound("Level").getList("TileEntities", 10); -+ if (tileEntities != null) { -+ for (int te = 0; te < tileEntities.size(); te++) { -+ NBTTagCompound tileEntity = (NBTTagCompound) tileEntities.get(te); -+ int x = tileEntity.getInt("x") - chunk.locX * 16; -+ int z = tileEntity.getInt("z") - chunk.locZ * 16; -+ tileEntity.setInt("x", i * 16 + x); -+ tileEntity.setInt("z", j * 16 + z); ++ // CraftBukkit start - Have to move tile entities since we don't load them at this stage ++ NBTTagList tileEntities = nbttagcompound.getCompound("Level").getList("TileEntities", 10); ++ if (tileEntities != null) { ++ for (int te = 0; te < tileEntities.size(); te++) { ++ NBTTagCompound tileEntity = (NBTTagCompound) tileEntities.get(te); ++ int x = tileEntity.getInt("x") - chunk.locX * 16; ++ int z = tileEntity.getInt("z") - chunk.locZ * 16; ++ tileEntity.setInt("x", i * 16 + x); ++ tileEntity.setInt("z", j * 16 + z); ++ } + } -+ } ++ // CraftBukkit end + chunk = this.a(generatoraccess, nbttagcompound1); + } + +- return chunk; ++ // CraftBukkit start ++ Object[] data = new Object[2]; ++ data[0] = chunk; ++ data[1] = nbttagcompound; ++ return data; + // CraftBukkit end - chunk = this.a(world, nbttagcompound1); } - -- return chunk; -+ // CraftBukkit start -+ Object[] data = new Object[2]; -+ data[0] = chunk; -+ data[1] = nbttagcompound; -+ return data; -+ // CraftBukkit end } - } - } -@@ -98,7 +134,9 @@ + } else { +@@ -158,7 +196,7 @@ + ChunkStatus.Type chunkstatus_type = this.a(nbttagcompound); + + 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"); + +@@ -204,19 +242,30 @@ } - protected void a(ChunkCoordIntPair chunkcoordintpair, NBTTagCompound nbttagcompound) { -- if (!this.c.contains(chunkcoordintpair)) { -+ // CraftBukkit -+ // if (!this.c.contains(chunkcoordintpair)) -+ { - this.b.put(chunkcoordintpair, nbttagcompound); - } - -@@ -106,20 +144,32 @@ - } - - public boolean a() { + public synchronized boolean a() { - if (this.b.isEmpty()) { - if (this.f) { + // CraftBukkit start @@ -118,7 +129,7 @@ + if (!iter.hasNext()) { + if (logCompletion) { + // CraftBukkit end - ChunkRegionLoader.a.info("ThreadedAnvilChunkStorage ({}): All chunks are saved", this.d.getName()); + ChunkRegionLoader.a.info("ThreadedAnvilChunkStorage ({}): All chunks are saved", this.c.getName()); } return false; @@ -133,40 +144,37 @@ boolean flag; try { -- this.c.add(chunkcoordintpair); -- NBTTagCompound nbttagcompound = (NBTTagCompound) this.b.remove(chunkcoordintpair); -+ // this.c.add(chunkcoordintpair); -+ // NBTTagCompound nbttagcompound = (NBTTagCompound) this.b.remove(chunkcoordintpair); -+ // CraftBukkit +- NBTTagCompound nbttagcompound = (NBTTagCompound) this.b.get(chunkcoordintpair); ++ // NBTTagCompound nbttagcompound = (NBTTagCompound) this.b.get(chunkcoordintpair); // CraftBukkit if (nbttagcompound != null) { try { -@@ -131,7 +181,7 @@ +@@ -228,7 +277,7 @@ flag = true; } finally { -- this.c.remove(chunkcoordintpair); +- this.b.remove(chunkcoordintpair); + this.b.remove(chunkcoordintpair, nbttagcompound); // CraftBukkit } return flag; -@@ -139,10 +189,14 @@ +@@ -248,10 +297,14 @@ } private void b(ChunkCoordIntPair chunkcoordintpair, NBTTagCompound nbttagcompound) throws IOException { -- DataOutputStream dataoutputstream = RegionFileCache.e(this.d, chunkcoordintpair.x, chunkcoordintpair.z); +- DataOutputStream dataoutputstream = RegionFileCache.e(this.c, chunkcoordintpair.x, chunkcoordintpair.z); + // CraftBukkit start -+ RegionFileCache.e(this.d, chunkcoordintpair.x, chunkcoordintpair.z, nbttagcompound); ++ RegionFileCache.e(this.c, chunkcoordintpair.x, chunkcoordintpair.z, nbttagcompound); + /* NBTCompressedStreamTools.a(nbttagcompound, (DataOutput) dataoutputstream); dataoutputstream.close(); + */ + // CraftBukkit end - } - - public void b(World world, Chunk chunk) throws IOException {} -@@ -151,15 +205,16 @@ + if (this.e != null) { + this.e.a(chunkcoordintpair.a()); + } +@@ -264,15 +317,16 @@ public void c() { try { @@ -186,30 +194,52 @@ } } -@@ -334,6 +389,13 @@ - chunk.a(nbttagcompound.getByteArray("Biomes")); - } +@@ -301,7 +355,7 @@ -+ // CraftBukkit start - End this method here and split off entity loading to another method -+ return chunk; -+ } -+ -+ public void loadEntities(Chunk chunk, NBTTagCompound nbttagcompound, World world) { -+ // CraftBukkit end -+ - NBTTagList nbttaglist1 = nbttagcompound.getList("Entities", 10); - - for (int l = 0; l < nbttaglist1.size(); ++l) { -@@ -371,7 +433,7 @@ + if (abiomebase != null) { + for (int k = 0; k < abiomebase.length; ++k) { +- aint[k] = BiomeBase.REGISTRY_ID.a((Object) abiomebase[k]); ++ aint[k] = BiomeBase.REGISTRY_ID.a(abiomebase[k]); // CraftBukkit - decompile error } } -- return chunk; -+ // return chunk; // CraftBukkit - } +@@ -383,7 +437,7 @@ + int[] aint = new int[abiomebase.length]; - @Nullable -@@ -399,14 +461,20 @@ + for (int i = 0; i < abiomebase.length; ++i) { +- aint[i] = BiomeBase.REGISTRY_ID.a((Object) abiomebase[i]); ++ aint[i] = BiomeBase.REGISTRY_ID.a(abiomebase[i]); // CraftBukkit - decompile error + } + + nbttagcompound.setIntArray("Biomes", aint); +@@ -485,7 +539,7 @@ + } + + ChunkConverter chunkconverter = nbttagcompound.hasKeyOfType("UpgradeData", 10) ? new ChunkConverter(nbttagcompound.getCompound("UpgradeData")) : ChunkConverter.a; +- Predicate predicate = (block) -> { ++ Predicate predicate = (block) -> { // CraftBukkit - decompile error + return block.getBlockData().isAir(); + }; + RegistryBlocks registryblocks = Block.REGISTRY; +@@ -497,7 +551,7 @@ + Block.REGISTRY.getClass(); + ProtoChunkTickList protochunkticklist = new ProtoChunkTickList(predicate, function, registryblocks1::get, new ChunkCoordIntPair(i, j)); + +- predicate = (fluidtype) -> { ++ Predicate predicate1 = (fluidtype) -> { // CraftBukkit - decompile error + return fluidtype == FluidTypes.a; + }; + registryblocks = FluidType.c; +@@ -505,7 +559,7 @@ + function = registryblocks::b; + registryblocks1 = FluidType.c; + FluidType.c.getClass(); +- ProtoChunkTickList protochunkticklist1 = new ProtoChunkTickList(predicate, function, registryblocks1::get, new ChunkCoordIntPair(i, j)); ++ ProtoChunkTickList protochunkticklist1 = new ProtoChunkTickList(predicate1, function, registryblocks1::get, new ChunkCoordIntPair(i, j)); // CraftBukkit - decompile error + long i1 = nbttagcompound.getLong("InhabitedTime"); + Chunk chunk = new Chunk(generatoraccess.getMinecraftWorld(), i, j, abiomebase, chunkconverter, protochunkticklist, protochunkticklist1, i1); + +@@ -852,17 +906,29 @@ } @Nullable @@ -220,30 +250,40 @@ + + public static Entity spawnEntity(NBTTagCompound nbttagcompound, World world, double d0, double d1, double d2, boolean flag, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) { + // CraftBukkit end - Entity entity = a(nbttagcompound, world); - - if (entity == null) { - return null; - } else { + return a(nbttagcompound, world, (entity) -> { entity.setPositionRotation(d0, d1, d2, entity.yaw, entity.pitch); -- if (flag && !world.addEntity(entity)) { -+ if (flag && !world.addEntity(entity, spawnReason)) { // CraftBukkit - return null; - } else { - if (nbttagcompound.hasKeyOfType("Passengers", 9)) { -@@ -435,8 +503,14 @@ +- return flag && !world.addEntity(entity) ? null : entity; ++ return flag && !world.addEntity(entity, spawnReason) ? null : entity; + }); + } + + @Nullable ++ // CraftBukkit start + public static Entity a(NBTTagCompound nbttagcompound, World world, boolean flag) { ++ return spawnEntity(nbttagcompound, world, flag, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT); ++ } ++ ++ public static Entity spawnEntity(NBTTagCompound nbttagcompound, World world, boolean flag, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) { ++ // CraftBukkit end + return a(nbttagcompound, world, (entity) -> { +- return flag && !world.addEntity(entity) ? null : entity; ++ return flag && !world.addEntity(entity, spawnReason) ? null : entity; // CraftBukkit + }); + } + +@@ -876,8 +942,14 @@ } } + // CraftBukkit start - public static void a(Entity entity, World world) { -- if (world.addEntity(entity) && entity.isVehicle()) { -+ a(entity, world, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT); + public static void a(Entity entity, GeneratorAccess generatoraccess) { +- if (generatoraccess.addEntity(entity) && entity.isVehicle()) { ++ a(entity, generatoraccess, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT); + } + -+ public static void a(Entity entity, World world, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) { -+ if (world.addEntity(entity, reason) && entity.isVehicle()) { ++ public static void a(Entity entity, GeneratorAccess generatoraccess, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) { ++ if (generatoraccess.addEntity(entity, reason) && entity.isVehicle()) { + // CraftBukkit end - Iterator iterator = entity.bF().iterator(); + Iterator iterator = entity.bP().iterator(); while (iterator.hasNext()) { diff --git a/paper-server/nms-patches/ChunkSection.patch b/paper-server/nms-patches/ChunkSection.patch index 7a9ab688a0..88b6e356d3 100644 --- a/paper-server/nms-patches/ChunkSection.patch +++ b/paper-server/nms-patches/ChunkSection.patch @@ -1,31 +1,15 @@ --- a/net/minecraft/server/ChunkSection.java +++ b/net/minecraft/server/ChunkSection.java -@@ -19,6 +19,24 @@ +@@ -15,7 +15,7 @@ - } - -+ // CraftBukkit start -+ public ChunkSection(int y, boolean flag, char[] blockIds) { -+ this.yPos = y; -+ this.blockIds = new DataPaletteBlock(); -+ for (int i = 0; i < blockIds.length; i++) { -+ int xx = i & 15; -+ int yy = (i >> 8) & 15; -+ int zz = (i >> 4) & 15; -+ this.blockIds.setBlock(xx, yy, zz, Block.REGISTRY_ID.fromId(blockIds[i])); -+ } -+ this.emittedLight = new NibbleArray(); -+ if (flag) { -+ this.skyLight = new NibbleArray(); -+ } -+ recalcBlockCounts(); -+ } -+ // CraftBukkit end -+ - public IBlockData getType(int i, int j, int k) { - return this.blockIds.a(i, j, k); - } -@@ -46,7 +64,7 @@ + public ChunkSection(int i, boolean flag) { + this.yPos = i; +- this.blockIds = new DataPaletteBlock(ChunkSection.GLOBAL_PALETTE, Block.REGISTRY_ID, GameProfileSerializer::d, GameProfileSerializer::a, Blocks.AIR.getBlockData()); ++ this.blockIds = new DataPaletteBlock<>(ChunkSection.GLOBAL_PALETTE, Block.REGISTRY_ID, GameProfileSerializer::d, GameProfileSerializer::a, Blocks.AIR.getBlockData()); // CraftBukkit - decompile error + this.emittedLight = new NibbleArray(); + if (flag) { + this.skyLight = new NibbleArray(); +@@ -62,7 +62,7 @@ } public boolean a() { @@ -33,4 +17,4 @@ + return false; // CraftBukkit - MC-80966 } - public boolean shouldTick() { + public boolean b() { diff --git a/paper-server/nms-patches/CommandBlockListenerAbstract.patch b/paper-server/nms-patches/CommandBlockListenerAbstract.patch index 359289f072..84668fcc33 100644 --- a/paper-server/nms-patches/CommandBlockListenerAbstract.patch +++ b/paper-server/nms-patches/CommandBlockListenerAbstract.patch @@ -1,209 +1,37 @@ --- a/net/minecraft/server/CommandBlockListenerAbstract.java +++ b/net/minecraft/server/CommandBlockListenerAbstract.java -@@ -4,6 +4,15 @@ +@@ -5,6 +5,7 @@ + import java.text.SimpleDateFormat; import java.util.Date; import javax.annotation.Nullable; - -+// CraftBukkit start -+import java.util.ArrayList; -+import org.bukkit.craftbukkit.command.VanillaCommandWrapper; -+import com.google.common.base.Joiner; -+import java.util.logging.Level; +import org.bukkit.command.CommandSender; -+import org.bukkit.event.server.ServerCommandEvent; -+// CraftBukkit end -+ + public abstract class CommandBlockListenerAbstract implements ICommandListener { - private static final SimpleDateFormat a = new SimpleDateFormat("HH:mm:ss"); -@@ -15,6 +24,7 @@ +@@ -16,6 +17,10 @@ + private IChatBaseComponent f; private String g = ""; - private String h = "@"; - private final CommandObjectiveExecutor i = new CommandObjectiveExecutor(); -+ protected org.bukkit.command.CommandSender sender; // CraftBukkit - add sender + private IChatBaseComponent h = new ChatComponentText("@"); ++ // CraftBukkit start ++ @Override ++ public abstract CommandSender getBukkitSender(CommandListenerWrapper wrapper); ++ // CraftBukkit end public CommandBlockListenerAbstract() {} -@@ -107,7 +117,9 @@ - if (minecraftserver != null && minecraftserver.M() && minecraftserver.getEnableCommandBlock()) { +@@ -103,14 +108,7 @@ + if (minecraftserver != null && minecraftserver.F() && minecraftserver.getEnableCommandBlock() && !UtilColor.b(this.g)) { try { this.f = null; -- this.d = minecraftserver.getCommandHandler().a(this, this.g); -+ // CraftBukkit start - Handle command block commands using Bukkit dispatcher -+ this.d = executeSafely(this, sender, this.g); -+ // CraftBukkit end +- CommandListenerWrapper commandlistenerwrapper = this.getWrapper().a((commandcontext, flag, i) -> { +- if (flag) { +- ++this.d; +- } +- +- }); +- +- minecraftserver.getCommandDispatcher().a(commandlistenerwrapper, this.g); ++ this.d = minecraftserver.getCommandDispatcher().dispatchServerCommand(this.getWrapper(), this.g); // CraftBukkit } catch (Throwable throwable) { CrashReport crashreport = CrashReport.a(throwable, "Executing command block"); CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Command to be executed"); -@@ -149,6 +161,171 @@ - } - } - -+ public static int executeSafely(ICommandListener sender, org.bukkit.command.CommandSender bSender, String command) { -+ try { -+ return executeCommand(sender, bSender, command); -+ } catch (CommandException commandexception) { -+ // Taken from CommandHandler -+ ChatMessage chatmessage = new ChatMessage(commandexception.getMessage(), commandexception.getArgs()); -+ chatmessage.getChatModifier().setColor(EnumChatFormat.RED); -+ sender.sendMessage(chatmessage); -+ } -+ -+ return 0; -+ } -+ -+ // CraftBukkit start -+ public static int executeCommand(ICommandListener sender, org.bukkit.command.CommandSender bSender, String command) throws CommandException { -+ org.bukkit.command.SimpleCommandMap commandMap = sender.getWorld().getServer().getCommandMap(); -+ Joiner joiner = Joiner.on(" "); -+ if (command.startsWith("/")) { -+ command = command.substring(1); -+ } -+ -+ ServerCommandEvent event = new ServerCommandEvent(bSender, command); -+ org.bukkit.Bukkit.getPluginManager().callEvent(event); -+ if (event.isCancelled()) { -+ return 0; -+ } -+ command = event.getCommand(); -+ -+ String[] args = command.split(" "); -+ ArrayList commands = new ArrayList(); -+ -+ String cmd = args[0]; -+ if (cmd.startsWith("minecraft:")) cmd = cmd.substring("minecraft:".length()); -+ if (cmd.startsWith("bukkit:")) cmd = cmd.substring("bukkit:".length()); -+ -+ // Block disallowed commands -+ if (cmd.equalsIgnoreCase("stop") || cmd.equalsIgnoreCase("kick") || cmd.equalsIgnoreCase("op") -+ || cmd.equalsIgnoreCase("deop") || cmd.equalsIgnoreCase("ban") || cmd.equalsIgnoreCase("ban-ip") -+ || cmd.equalsIgnoreCase("pardon") || cmd.equalsIgnoreCase("pardon-ip") || cmd.equalsIgnoreCase("reload")) { -+ return 0; -+ } -+ -+ // Handle vanilla commands; -+ org.bukkit.command.Command commandBlockCommand = commandMap.getCommand(args[0]); -+ if (sender.getWorld().getServer().getCommandBlockOverride(args[0])) { -+ commandBlockCommand = commandMap.getCommand("minecraft:" + args[0]); -+ } -+ if (commandBlockCommand instanceof VanillaCommandWrapper) { -+ command = command.trim(); -+ if (command.startsWith("/")) { -+ command = command.substring(1); -+ } -+ String as[] = command.split(" "); -+ as = VanillaCommandWrapper.dropFirstArgument(as); -+ if (!sender.getWorld().getServer().getPermissionOverride(sender) && !((VanillaCommandWrapper) commandBlockCommand).testPermission(bSender)) { -+ return 0; -+ } -+ return ((VanillaCommandWrapper) commandBlockCommand).dispatchVanillaCommand(bSender, sender, as); -+ } -+ -+ // Make sure this is a valid command -+ if (commandMap.getCommand(args[0]) == null) { -+ return 0; -+ } -+ -+ commands.add(args); -+ -+ // Find positions of command block syntax, if any -+ WorldServer[] prev = MinecraftServer.getServer().worldServer; -+ MinecraftServer server = MinecraftServer.getServer(); -+ server.worldServer = new WorldServer[server.worlds.size()]; -+ server.worldServer[0] = (WorldServer) sender.getWorld(); -+ int bpos = 0; -+ for (int pos = 1; pos < server.worldServer.length; pos++) { -+ WorldServer world = server.worlds.get(bpos++); -+ if (server.worldServer[0] == world) { -+ pos--; -+ continue; -+ } -+ server.worldServer[pos] = world; -+ } -+ try { -+ ArrayList newCommands = new ArrayList(); -+ for (int i = 0; i < args.length; i++) { -+ if (PlayerSelector.isPattern(args[i])) { -+ for (int j = 0; j < commands.size(); j++) { -+ newCommands.addAll(buildCommands(sender, commands.get(j), i)); -+ } -+ ArrayList temp = commands; -+ commands = newCommands; -+ newCommands = temp; -+ newCommands.clear(); -+ } -+ } -+ } finally { -+ MinecraftServer.getServer().worldServer = prev; -+ } -+ -+ int completed = 0; -+ -+ // Now dispatch all of the commands we ended up with -+ for (int i = 0; i < commands.size(); i++) { -+ try { -+ if (commandMap.dispatch(bSender, joiner.join(java.util.Arrays.asList(commands.get(i))))) { -+ completed++; -+ } -+ } catch (Throwable exception) { -+ if (sender.f() instanceof EntityMinecartCommandBlock) { -+ MinecraftServer.getServer().server.getLogger().log(Level.WARNING, String.format("MinecartCommandBlock at (%d,%d,%d) failed to handle command", sender.getChunkCoordinates().getX(), sender.getChunkCoordinates().getY(), sender.getChunkCoordinates().getZ()), exception); -+ } else if (sender instanceof CommandBlockListenerAbstract) { -+ CommandBlockListenerAbstract listener = (CommandBlockListenerAbstract) sender; -+ MinecraftServer.getServer().server.getLogger().log(Level.WARNING, String.format("CommandBlock at (%d,%d,%d) failed to handle command", listener.getChunkCoordinates().getX(), listener.getChunkCoordinates().getY(), listener.getChunkCoordinates().getZ()), exception); -+ } else { -+ MinecraftServer.getServer().server.getLogger().log(Level.WARNING, String.format("Unknown CommandBlock failed to handle command"), exception); -+ } -+ } -+ } -+ -+ return completed; -+ } -+ -+ private static ArrayList buildCommands(ICommandListener sender, String[] args, int pos) throws CommandException { -+ ArrayList commands = new ArrayList(); -+ java.util.List players = (java.util.List)PlayerSelector.getPlayers(sender, args[pos], EntityPlayer.class); -+ -+ if (players != null) { -+ for (EntityPlayer player : players) { -+ if (player.world != sender.getWorld()) { -+ continue; -+ } -+ String[] command = args.clone(); -+ command[pos] = player.getName(); -+ commands.add(command); -+ } -+ } -+ -+ return commands; -+ } -+ -+ public static CommandSender unwrapSender(ICommandListener listener) { -+ org.bukkit.command.CommandSender sender = null; -+ while (sender == null) { -+ if (listener instanceof DedicatedServer) { -+ sender = ((DedicatedServer) listener).console; -+ } else if (listener instanceof RemoteControlCommandListener) { -+ sender = ((RemoteControlCommandListener) listener).C_().remoteConsole; -+ } else if (listener instanceof CommandBlockListenerAbstract) { -+ sender = ((CommandBlockListenerAbstract) listener).sender; -+ } else if (listener instanceof CustomFunctionData.CustomFunctionListener) { -+ sender = ((CustomFunctionData.CustomFunctionListener) listener).sender; -+ } else if (listener instanceof CommandListenerWrapper) { -+ listener = ((CommandListenerWrapper) listener).base; // Search deeper -+ } else if (VanillaCommandWrapper.lastSender != null) { -+ sender = VanillaCommandWrapper.lastSender; -+ } else if (listener.f() != null) { -+ sender = listener.f().getBukkitEntity(); -+ } else { -+ throw new RuntimeException("Unhandled executor " + listener.getClass().getSimpleName()); -+ } -+ } -+ -+ return sender; -+ } -+ // CraftBukkit end -+ - public String getName() { - return this.h; - } diff --git a/paper-server/nms-patches/CommandDebug.patch b/paper-server/nms-patches/CommandDebug.patch index 68da6b1fb3..d982a4834a 100644 --- a/paper-server/nms-patches/CommandDebug.patch +++ b/paper-server/nms-patches/CommandDebug.patch @@ -1,32 +1,32 @@ --- a/net/minecraft/server/CommandDebug.java +++ b/net/minecraft/server/CommandDebug.java -@@ -34,6 +34,14 @@ +@@ -35,6 +35,14 @@ } - public void execute(MinecraftServer minecraftserver, ICommandListener icommandlistener, String[] astring) throws CommandException { + private static int a(CommandListenerWrapper commandlistenerwrapper) throws CommandSyntaxException { + // CraftBukkit start - only allow use when enabled (so that no blank profile results occur) -+ if (!minecraftserver.methodProfiler.ENABLED) { -+ icommandlistener.sendMessage(new ChatComponentText("Vanilla debug profiling is disabled.")); -+ icommandlistener.sendMessage(new ChatComponentText("To enable, restart the server with `-DenableDebugMethodProfiler=true' before `-jar'.")); -+ icommandlistener.sendMessage(new ChatComponentText("Use `/timings' for plugin timings.")); -+ return; ++ if (!commandlistenerwrapper.getServer().methodProfiler.ENABLED) { ++ commandlistenerwrapper.sendFailureMessage(new ChatComponentText("Vanilla debug profiling is disabled.")); ++ commandlistenerwrapper.sendFailureMessage(new ChatComponentText("To enable, restart the server with `-DenableDebugMethodProfiler=true' before `-jar'.")); ++ commandlistenerwrapper.sendFailureMessage(new ChatComponentText("Use `/timings' for plugin timings.")); ++ return 0; + } + // CraftBukkit end - if (astring.length < 1) { - throw new ExceptionUsage("commands.debug.usage", new Object[0]); - } else { -@@ -142,6 +150,13 @@ + MinecraftServer minecraftserver = commandlistenerwrapper.getServer(); + MethodProfiler methodprofiler = minecraftserver.methodProfiler; + +@@ -48,6 +56,14 @@ } - public List tabComplete(MinecraftServer minecraftserver, ICommandListener icommandlistener, String[] astring, @Nullable BlockPosition blockposition) { -- return astring.length == 1 ? a(astring, new String[] { "start", "stop"}) : Collections.emptyList(); -+ return astring.length == 1 ? a(astring, new String[] { "start", "stop"}) : Collections.emptyList(); // CraftBukkit - decompile error -+ } -+ -+ // CraftBukkit start - fix decompile error -+ @Override -+ public int compareTo(ICommand o) { -+ return a((ICommand) o); - } -+ // CraftBukkit end - } + private static int b(CommandListenerWrapper commandlistenerwrapper) throws CommandSyntaxException { ++ // CraftBukkit start - only allow use when enabled (so that no blank profile results occur) ++ if (!commandlistenerwrapper.getServer().methodProfiler.ENABLED) { ++ commandlistenerwrapper.sendFailureMessage(new ChatComponentText("Vanilla debug profiling is disabled.")); ++ commandlistenerwrapper.sendFailureMessage(new ChatComponentText("To enable, restart the server with `-DenableDebugMethodProfiler=true' before `-jar'.")); ++ commandlistenerwrapper.sendFailureMessage(new ChatComponentText("Use `/timings' for plugin timings.")); ++ return 0; ++ } ++ // CraftBukkit end + MinecraftServer minecraftserver = commandlistenerwrapper.getServer(); + MethodProfiler methodprofiler = minecraftserver.methodProfiler; + diff --git a/paper-server/nms-patches/CommandDispatcher.patch b/paper-server/nms-patches/CommandDispatcher.patch new file mode 100644 index 0000000000..f9842a44d3 --- /dev/null +++ b/paper-server/nms-patches/CommandDispatcher.patch @@ -0,0 +1,189 @@ +--- a/net/minecraft/server/CommandDispatcher.java ++++ b/net/minecraft/server/CommandDispatcher.java +@@ -26,12 +26,19 @@ + import org.apache.logging.log4j.LogManager; + import org.apache.logging.log4j.Logger; + ++// CraftBukkit start ++import com.google.common.base.Joiner; ++import org.apache.logging.log4j.Level; ++import org.bukkit.event.server.ServerCommandEvent; ++// CraftBukkit end ++ + public class CommandDispatcher { + + private static final Logger a = LogManager.getLogger(); + private final com.mojang.brigadier.CommandDispatcher b = new com.mojang.brigadier.CommandDispatcher(); + +- public CommandDispatcher(boolean flag) { ++ // CraftBukkit start ++ public final CommandDispatcher init(boolean flag) { + CommandAdvancement.a(this.b); + CommandExecute.a(this.b); + CommmandBossBar.a(this.b); +@@ -100,6 +107,11 @@ + this.b.findAmbiguities((commandnode, commandnode1, commandnode2, collection) -> { + CommandDispatcher.a.warn("Ambiguity between arguments {} and {} with inputs: {}", this.b.getPath(commandnode1), this.b.getPath(commandnode2), collection); + }); ++ return this; ++ } ++ ++ public CommandDispatcher() { ++ // CraftBukkit end + this.b.setConsumer((commandcontext, flag, i) -> { + ((CommandListenerWrapper) commandcontext.getSource()).a(commandcontext, flag, i); + }); +@@ -114,7 +126,58 @@ + + } + ++ // CraftBukkit start ++ public int dispatchServerCommand(CommandListenerWrapper sender, String command) { ++ Joiner joiner = Joiner.on(" "); ++ if (command.startsWith("/")) { ++ command = command.substring(1); ++ } ++ ++ ServerCommandEvent event = new ServerCommandEvent(sender.getBukkitSender(), command); ++ org.bukkit.Bukkit.getPluginManager().callEvent(event); ++ if (event.isCancelled()) { ++ return 0; ++ } ++ command = event.getCommand(); ++ ++ String[] args = command.split(" "); ++ ++ String cmd = args[0]; ++ if (cmd.startsWith("minecraft:")) cmd = cmd.substring("minecraft:".length()); ++ if (cmd.startsWith("bukkit:")) cmd = cmd.substring("bukkit:".length()); ++ ++ // Block disallowed commands ++ if (cmd.equalsIgnoreCase("stop") || cmd.equalsIgnoreCase("kick") || cmd.equalsIgnoreCase("op") ++ || cmd.equalsIgnoreCase("deop") || cmd.equalsIgnoreCase("ban") || cmd.equalsIgnoreCase("ban-ip") ++ || cmd.equalsIgnoreCase("pardon") || cmd.equalsIgnoreCase("pardon-ip") || cmd.equalsIgnoreCase("reload")) { ++ return 0; ++ } ++ ++ // Handle vanilla commands; ++ if (sender.getWorld().getServer().getCommandBlockOverride(args[0])) { ++ args[0] = "minecraft:" + args[0]; ++ } ++ ++ return this.a(sender, joiner.join(args)); ++ } ++ + public int a(CommandListenerWrapper commandlistenerwrapper, String s) { ++ // Some commands use the worldserver variable but we leave it full of null values, ++ // so we must temporarily populate it with the world of the commandsender ++ WorldServer[] prev = MinecraftServer.getServer().worldServer; ++ MinecraftServer server = MinecraftServer.getServer(); ++ server.worldServer = new WorldServer[server.worlds.size()]; ++ server.worldServer[0] = (WorldServer) commandlistenerwrapper.getWorld(); ++ int bpos = 0; ++ for (int pos = 1; pos < server.worldServer.length; pos++) { ++ WorldServer world = server.worlds.get(bpos++); ++ if (server.worldServer[0] == world) { ++ pos--; ++ continue; ++ } ++ server.worldServer[pos] = world; ++ } ++ // CraftBukkit end + String s1 = s; + + if (s.startsWith("/")) { +@@ -126,7 +189,6 @@ + byte b0; + + try { +- byte b1; + ChatComponentText chatcomponenttext; + + try { +@@ -135,54 +197,59 @@ + return i; + } catch (CommandException commandexception) { + commandlistenerwrapper.sendFailureMessage(commandexception.a()); +- b1 = 0; +- return b1; ++ b0 = 0; ++ return b0; + } catch (CommandSyntaxException commandsyntaxexception) { + commandlistenerwrapper.sendFailureMessage(ChatComponentUtils.a(commandsyntaxexception.getRawMessage())); + if (commandsyntaxexception.getInput() != null && commandsyntaxexception.getCursor() >= 0) { + int j = Math.min(commandsyntaxexception.getInput().length(), commandsyntaxexception.getCursor()); +- IChatBaseComponent ichatbasecomponent = (new ChatComponentText("")).a(EnumChatFormat.GRAY).a((chatmodifier) -> { +- chatmodifier.setChatClickable(new ChatClickable(ChatClickable.EnumClickAction.SUGGEST_COMMAND, s)); +- }); + ++ chatcomponenttext = new ChatComponentText(""); + if (j > 10) { +- ichatbasecomponent.a("..."); ++ chatcomponenttext.a("..."); + } + +- ichatbasecomponent.a(commandsyntaxexception.getInput().substring(Math.max(0, j - 10), j)); ++ chatcomponenttext.a(commandsyntaxexception.getInput().substring(Math.max(0, j - 10), j)); + if (j < commandsyntaxexception.getInput().length()) { +- IChatBaseComponent ichatbasecomponent1 = (new ChatComponentText(commandsyntaxexception.getInput().substring(j))).a(new EnumChatFormat[] { EnumChatFormat.RED, EnumChatFormat.UNDERLINE}); ++ ChatComponentText chatcomponenttext1 = new ChatComponentText(commandsyntaxexception.getInput().substring(j)); + +- ichatbasecomponent.addSibling(ichatbasecomponent1); ++ chatcomponenttext1.getChatModifier().setColor(EnumChatFormat.RED); ++ chatcomponenttext1.getChatModifier().setUnderline(Boolean.valueOf(true)); ++ chatcomponenttext.addSibling(chatcomponenttext1); + } + +- ichatbasecomponent.addSibling((new ChatMessage("command.context.here", new Object[0])).a(new EnumChatFormat[] { EnumChatFormat.RED, EnumChatFormat.ITALIC})); +- commandlistenerwrapper.sendFailureMessage(ichatbasecomponent); ++ ChatMessage chatmessage = new ChatMessage("command.context.here", new Object[0]); ++ ++ chatmessage.getChatModifier().setItalic(Boolean.valueOf(true)); ++ chatmessage.getChatModifier().setColor(EnumChatFormat.RED); ++ chatcomponenttext.addSibling(chatmessage); ++ chatcomponenttext.getChatModifier().setColor(EnumChatFormat.GRAY); ++ chatcomponenttext.getChatModifier().setChatClickable(new ChatClickable(ChatClickable.EnumClickAction.SUGGEST_COMMAND, s1)); ++ commandlistenerwrapper.sendFailureMessage(chatcomponenttext); + } + +- b1 = 0; +- return b1; ++ b0 = 0; + } catch (Exception exception) { +- chatcomponenttext = new ChatComponentText; +- } ++ ChatMessage chatmessage1 = new ChatMessage("command.failed", new Object[0]); + +- chatcomponenttext.(exception.getMessage() == null ? exception.getClass().getName() : exception.getMessage()); +- ChatComponentText chatcomponenttext1 = chatcomponenttext; ++ chatcomponenttext = new ChatComponentText(exception.getMessage() == null ? exception.getClass().getName() : exception.getMessage()); ++ if (CommandDispatcher.a.isDebugEnabled()) { ++ StackTraceElement[] astacktraceelement = exception.getStackTrace(); + +- if (CommandDispatcher.a.isDebugEnabled()) { +- StackTraceElement[] astacktraceelement = exception.getStackTrace(); +- +- for (int k = 0; k < Math.min(astacktraceelement.length, 3); ++k) { +- chatcomponenttext1.a("\n\n").a(astacktraceelement[k].getMethodName()).a("\n ").a(astacktraceelement[k].getFileName()).a(":").a(String.valueOf(astacktraceelement[k].getLineNumber())); ++ for (int k = 0; k < Math.min(astacktraceelement.length, 3); ++k) { ++ chatcomponenttext.a("\n\n" + astacktraceelement[k].getMethodName() + "\n " + astacktraceelement[k].getFileName() + ":" + astacktraceelement[k].getLineNumber()); ++ } + } +- } + +- commandlistenerwrapper.sendFailureMessage((new ChatMessage("command.failed", new Object[0])).a((chatmodifier) -> { +- chatmodifier.setChatHoverable(new ChatHoverable(ChatHoverable.EnumHoverAction.SHOW_TEXT, ichatbasecomponent)); +- })); +- b0 = 0; ++ chatmessage1.getChatModifier().setChatHoverable(new ChatHoverable(ChatHoverable.EnumHoverAction.SHOW_TEXT, chatcomponenttext)); ++ commandlistenerwrapper.sendFailureMessage(chatmessage1); ++ byte b1 = 0; ++ ++ return b1; ++ } + } finally { + commandlistenerwrapper.getServer().methodProfiler.e(); ++ MinecraftServer.getServer().worldServer = prev; // CraftBukkit + } + + return b0; diff --git a/paper-server/nms-patches/CommandExecute.patch b/paper-server/nms-patches/CommandExecute.patch deleted file mode 100644 index eef65e5bff..0000000000 --- a/paper-server/nms-patches/CommandExecute.patch +++ /dev/null @@ -1,58 +0,0 @@ ---- a/net/minecraft/server/CommandExecute.java -+++ b/net/minecraft/server/CommandExecute.java -@@ -4,6 +4,10 @@ - import java.util.Collections; - import java.util.List; - import javax.annotation.Nullable; -+// CraftBukkit start -+import org.bukkit.craftbukkit.command.ProxiedNativeCommandSender; -+import org.bukkit.craftbukkit.command.VanillaCommandWrapper; -+// CraftBukkit end - - public class CommandExecute extends CommandAbstract { - -@@ -59,26 +63,41 @@ - } - - String s = a(astring, b0); -- CommandListenerWrapper commandlistenerwrapper = CommandListenerWrapper.a(icommandlistener).a(entity, new Vec3D(d0, d1, d2)).a(minecraftserver.worldServer[0].getGameRules().getBoolean("commandBlockOutput")); -+ CommandListenerWrapper commandlistenerwrapper = CommandListenerWrapper.a(icommandlistener).a(entity, new Vec3D(d0, d1, d2)).a(minecraftserver.worlds.get(0).getGameRules().getBoolean("commandBlockOutput")); // CraftBukkit - ICommandHandler icommandhandler = minecraftserver.getCommandHandler(); - - try { -- int i = icommandhandler.a(commandlistenerwrapper, s); -+ // CraftBukkit start -+ org.bukkit.command.CommandSender sender = CommandBlockListenerAbstract.unwrapSender(icommandlistener); -+ int i = CommandBlockListenerAbstract.executeCommand(commandlistenerwrapper, new ProxiedNativeCommandSender(commandlistenerwrapper, sender, entity.getBukkitEntity()), s); -+ // CraftBukkit end - - if (i < 1) { - throw new CommandException("commands.execute.allInvocationsFailed", new Object[] { s}); - } - } catch (Throwable throwable) { -+ // CraftBukkit start -+ if (throwable instanceof CommandException) { -+ throw (CommandException) throwable; -+ } -+ // CraftBukkit end - throw new CommandException("commands.execute.failed", new Object[] { s, entity.getName()}); - } - } - } - - public List tabComplete(MinecraftServer minecraftserver, ICommandListener icommandlistener, String[] astring, @Nullable BlockPosition blockposition) { -- return astring.length == 1 ? a(astring, minecraftserver.getPlayers()) : (astring.length > 1 && astring.length <= 4 ? a(astring, 1, blockposition) : (astring.length > 5 && astring.length <= 8 && "detect".equals(astring[4]) ? a(astring, 5, blockposition) : (astring.length == 9 && "detect".equals(astring[4]) ? a(astring, (Collection) Block.REGISTRY.keySet()) : Collections.emptyList()))); -+ return astring.length == 1 ? a(astring, minecraftserver.getPlayers()) : (astring.length > 1 && astring.length <= 4 ? a(astring, 1, blockposition) : (astring.length > 5 && astring.length <= 8 && "detect".equals(astring[4]) ? a(astring, 5, blockposition) : (astring.length == 9 && "detect".equals(astring[4]) ? a(astring, (Collection) Block.REGISTRY.keySet()) : Collections.emptyList()))); // CraftBukkit - decompile error - } - - public boolean isListStart(String[] astring, int i) { - return i == 0; - } -+ -+ // CraftBukkit start - fix decompiler error -+ @Override -+ public int compareTo(ICommand o) { -+ return a((ICommand) o); -+ } -+ // CraftBukkit end - } diff --git a/paper-server/nms-patches/CommandGamemode.patch b/paper-server/nms-patches/CommandGamemode.patch index 1c227638fa..939a80d371 100644 --- a/paper-server/nms-patches/CommandGamemode.patch +++ b/paper-server/nms-patches/CommandGamemode.patch @@ -1,34 +1,15 @@ --- a/net/minecraft/server/CommandGamemode.java +++ b/net/minecraft/server/CommandGamemode.java -@@ -28,6 +28,12 @@ - EntityPlayer entityplayer = astring.length >= 2 ? b(minecraftserver, icommandlistener, astring[1]) : a(icommandlistener); +@@ -57,6 +57,12 @@ - entityplayer.a(enumgamemode); -+ // CraftBukkit start - handle event cancelling the change -+ if (entityplayer.playerInteractManager.getGameMode() != enumgamemode) { -+ icommandlistener.sendMessage(new ChatComponentText("Failed to set the gamemode of '" + entityplayer.getName() + "'")); -+ return; -+ } -+ // CraftBukkit end - ChatMessage chatmessage = new ChatMessage("gameMode." + enumgamemode.b(), new Object[0]); - - if (icommandlistener.getWorld().getGameRules().getBoolean("sendCommandFeedback")) { -@@ -50,10 +56,17 @@ - } - - public List tabComplete(MinecraftServer minecraftserver, ICommandListener icommandlistener, String[] astring, @Nullable BlockPosition blockposition) { -- return astring.length == 1 ? a(astring, new String[] { "survival", "creative", "adventure", "spectator"}) : (astring.length == 2 ? a(astring, minecraftserver.getPlayers()) : Collections.emptyList()); -+ return astring.length == 1 ? a(astring, new String[] { "survival", "creative", "adventure", "spectator"}) : (astring.length == 2 ? a(astring, minecraftserver.getPlayers()) : Collections.emptyList()); // CraftBukkit - decompile error - } - - public boolean isListStart(String[] astring, int i) { - return i == 1; - } -+ -+ // CraftBukkit start - fix decompiler error -+ @Override -+ public int compareTo(ICommand o) { -+ return a((ICommand) o); -+ } -+ // CraftBukkit end - } + if (entityplayer.playerInteractManager.getGameMode() != enumgamemode) { + entityplayer.a(enumgamemode); ++ // CraftBukkit start - handle event cancelling the change ++ if (entityplayer.playerInteractManager.getGameMode() != enumgamemode) { ++ commandcontext.getSource().sendFailureMessage(new ChatComponentText("Failed to set the gamemode of '" + entityplayer.getName() + "'")); ++ continue; ++ } ++ // CraftBukkit end + a((CommandListenerWrapper) commandcontext.getSource(), entityplayer, enumgamemode); + ++i; + } diff --git a/paper-server/nms-patches/CommandGamerule.patch b/paper-server/nms-patches/CommandGamerule.patch deleted file mode 100644 index 6de418190f..0000000000 --- a/paper-server/nms-patches/CommandGamerule.patch +++ /dev/null @@ -1,23 +0,0 @@ ---- a/net/minecraft/server/CommandGamerule.java -+++ b/net/minecraft/server/CommandGamerule.java -@@ -23,7 +23,7 @@ - } - - public void execute(MinecraftServer minecraftserver, ICommandListener icommandlistener, String[] astring) throws CommandException { -- GameRules gamerules = this.a(minecraftserver); -+ GameRules gamerules = icommandlistener.getWorld().getGameRules(); // CraftBukkit - Use current world - String s = astring.length > 0 ? astring[0] : ""; - String s1 = astring.length > 1 ? a(astring, 1) : ""; - -@@ -92,4 +92,11 @@ - private GameRules a(MinecraftServer minecraftserver) { - return minecraftserver.getWorldServer(0).getGameRules(); - } -+ -+ // CraftBukkit start - fix decompile error -+ @Override -+ public int compareTo(ICommand o) { -+ return a((ICommand) o); -+ } -+ // CraftBukkit end - } diff --git a/paper-server/nms-patches/CommandListenerWrapper.patch b/paper-server/nms-patches/CommandListenerWrapper.patch new file mode 100644 index 0000000000..0f8d1c9d64 --- /dev/null +++ b/paper-server/nms-patches/CommandListenerWrapper.patch @@ -0,0 +1,46 @@ +--- a/net/minecraft/server/CommandListenerWrapper.java ++++ b/net/minecraft/server/CommandListenerWrapper.java +@@ -7,6 +7,7 @@ + import com.mojang.brigadier.exceptions.SimpleCommandExceptionType; + import com.mojang.brigadier.suggestion.Suggestions; + import com.mojang.brigadier.suggestion.SuggestionsBuilder; ++import com.mojang.brigadier.tree.CommandNode; + import java.util.Collection; + import java.util.Collections; + import java.util.Iterator; +@@ -31,9 +32,10 @@ + private final ResultConsumer l; + private final ArgumentAnchor.Anchor m; + private final Vec2F n; ++ public CommandNode currentCommand; // CraftBukkit + + public CommandListenerWrapper(ICommandListener icommandlistener, Vec3D vec3d, Vec2F vec2f, WorldServer worldserver, int i, String s, IChatBaseComponent ichatbasecomponent, MinecraftServer minecraftserver, @Nullable Entity entity) { +- this(icommandlistener, vec3d, vec2f, worldserver, i, s, ichatbasecomponent, minecraftserver, entity, false, (commandcontext, flag, i) -> { ++ this(icommandlistener, vec3d, vec2f, worldserver, i, s, ichatbasecomponent, minecraftserver, entity, false, (commandcontext, flag, ix) -> { // CraftBukkit - decompile error + }, ArgumentAnchor.Anchor.FEET); + } + +@@ -119,6 +121,12 @@ + } + + public boolean hasPermission(int i) { ++ // CraftBukkit start ++ if (currentCommand != null) { ++ return this.f >= i || getBukkitSender().hasPermission(org.bukkit.craftbukkit.command.VanillaCommandWrapper.getPermission(currentCommand)); ++ } ++ // CraftBukkit end ++ + return this.f >= i; + } + +@@ -232,4 +240,10 @@ + public Collection a(boolean flag) { + return Collections.singleton(ICompletionProvider.a.b); + } ++ ++ // CraftBukkit start ++ public org.bukkit.command.CommandSender getBukkitSender() { ++ return base.getBukkitSender(this); ++ } ++ // CraftBukkit end + } diff --git a/paper-server/nms-patches/CommandSpreadPlayers.patch b/paper-server/nms-patches/CommandSpreadPlayers.patch index 33279985d3..652eaa8695 100644 --- a/paper-server/nms-patches/CommandSpreadPlayers.patch +++ b/paper-server/nms-patches/CommandSpreadPlayers.patch @@ -1,50 +1,32 @@ --- a/net/minecraft/server/CommandSpreadPlayers.java +++ b/net/minecraft/server/CommandSpreadPlayers.java -@@ -240,9 +240,16 @@ - } - - public List tabComplete(MinecraftServer minecraftserver, ICommandListener icommandlistener, String[] astring, @Nullable BlockPosition blockposition) { -- return astring.length >= 1 && astring.length <= 2 ? b(astring, 0, blockposition) : Collections.emptyList(); -+ return astring.length >= 1 && astring.length <= 2 ? b(astring, 0, blockposition) : Collections.emptyList(); // CraftBukkit - decompile error - } - -+ // CraftBukkit start - fix decompile error -+ @Override -+ public int compareTo(ICommand o) { -+ return a(o); -+ } -+ // CraftBukkit end -+ - static class Location2D { - - double a; -@@ -309,7 +316,7 @@ +@@ -269,7 +269,7 @@ } blockposition = blockposition.down(); -- } while (world.getType(blockposition).getMaterial() == Material.AIR); -+ } while (getType(world, blockposition).getMaterial() == Material.AIR); // CraftBukkit +- } while (iblockaccess.getType(blockposition).isAir()); ++ } while (getType(iblockaccess, blockposition).isAir()); // CraftBukkit return blockposition.getY() + 1; } -@@ -325,7 +332,7 @@ +@@ -285,7 +285,7 @@ } blockposition = blockposition.down(); -- material = world.getType(blockposition).getMaterial(); -+ material = getType(world, blockposition).getMaterial(); // CraftBukkit - } while (material == Material.AIR); +- iblockdata = iblockaccess.getType(blockposition); ++ iblockdata = getType(iblockaccess, blockposition); // CraftBukkit + } while (iblockdata.isAir()); - return !material.isLiquid() && material != Material.FIRE; -@@ -335,5 +342,12 @@ + Material material = iblockdata.getMaterial(); +@@ -297,5 +297,12 @@ this.a = MathHelper.a(random, d0, d2); this.b = MathHelper.a(random, d1, d3); } + + // CraftBukkit start - add a version of getType which force loads chunks -+ private static IBlockData getType(World world, BlockPosition position) { -+ ((ChunkProviderServer) world.chunkProvider).getChunkAt(position.getX() >> 4, position.getZ() >> 4); -+ return world.getType(position); ++ private static IBlockData getType(IBlockAccess iblockaccess, BlockPosition position) { ++ ((ChunkProviderServer) ((World) iblockaccess).chunkProvider).getChunkAt(position.getX() >> 4, position.getZ() >> 4); ++ return iblockaccess.getType(position); + } + // CraftBukkit end } diff --git a/paper-server/nms-patches/CommandTeleport.patch b/paper-server/nms-patches/CommandTeleport.patch index 003cc6c1fd..3b5763e9f1 100644 --- a/paper-server/nms-patches/CommandTeleport.patch +++ b/paper-server/nms-patches/CommandTeleport.patch @@ -1,23 +1,14 @@ --- a/net/minecraft/server/CommandTeleport.java +++ b/net/minecraft/server/CommandTeleport.java -@@ -69,7 +69,7 @@ +@@ -116,9 +116,9 @@ + if (entity instanceof EntityPlayer) { + entity.stopRiding(); + if (worldserver == entity.world) { +- ((EntityPlayer) entity).playerConnection.a(d0, d1, d2, f, f1, set); ++ ((EntityPlayer) entity).playerConnection.a(d0, d1, d2, f, f1, set, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.COMMAND); // CraftBukkit + } else { +- ((EntityPlayer) entity).a(worldserver, d0, d1, d2, f, f1); ++ ((EntityPlayer) entity).a(worldserver, d0, d1, d2, f, f1, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.COMMAND); // CraftBukkit } - entity.stopRiding(); -- ((EntityPlayer) entity).playerConnection.a(commandabstract_commandnumber.a(), commandabstract_commandnumber1.a(), commandabstract_commandnumber2.a(), f, f1, enumset); -+ ((EntityPlayer) entity).playerConnection.a(commandabstract_commandnumber.a(), commandabstract_commandnumber1.a(), commandabstract_commandnumber2.a(), f, f1, enumset, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.COMMAND); // CraftBukkit entity.setHeadRotation(f); - } else { - float f2 = (float) MathHelper.g(commandabstract_commandnumber3.a()); -@@ -94,4 +94,11 @@ - public boolean isListStart(String[] astring, int i) { - return i == 0; - } -+ -+ // CraftBukkit start - fix decompile error -+ @Override -+ public int compareTo(ICommand o) { -+ return a((ICommand) o); -+ } -+ // CraftBukkit end - } diff --git a/paper-server/nms-patches/CommandTp.patch b/paper-server/nms-patches/CommandTp.patch deleted file mode 100644 index 603af70863..0000000000 --- a/paper-server/nms-patches/CommandTp.patch +++ /dev/null @@ -1,45 +0,0 @@ ---- a/net/minecraft/server/CommandTp.java -+++ b/net/minecraft/server/CommandTp.java -@@ -53,17 +53,11 @@ - } else { - Entity entity = c(minecraftserver, icommandlistener, astring[astring.length - 1]); - -- if (entity.world != ((Entity) object).world) { -- throw new CommandException("commands.tp.notSameDimension", new Object[0]); -- } else { -- ((Entity) object).stopRiding(); -- if (object instanceof EntityPlayer) { -- ((EntityPlayer) object).playerConnection.a(entity.locX, entity.locY, entity.locZ, entity.yaw, entity.pitch); -- } else { -- ((Entity) object).setPositionRotation(entity.locX, entity.locY, entity.locZ, entity.yaw, entity.pitch); -- } -- -+ // CraftBukkit Start -+ // Use Bukkit teleport method in all cases. It has cross dimensional handling, events -+ if (((Entity) object).getBukkitEntity().teleport(entity.getBukkitEntity(), org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.COMMAND)) { - a(icommandlistener, (ICommand) this, "commands.tp.success", new Object[] { ((Entity) object).getName(), entity.getName()}); -+ // CraftBukkit End - } - } - } -@@ -107,7 +101,7 @@ - } - - entity.stopRiding(); -- ((EntityPlayer) entity).playerConnection.a(commandabstract_commandnumber.b(), commandabstract_commandnumber1.b(), commandabstract_commandnumber2.b(), f, f1, enumset); -+ ((EntityPlayer) entity).playerConnection.a(commandabstract_commandnumber.b(), commandabstract_commandnumber1.b(), commandabstract_commandnumber2.b(), f, f1, enumset, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.COMMAND); // CraftBukkit - entity.setHeadRotation(f); - } else { - float f2 = (float) MathHelper.g(commandabstract_commandnumber3.a()); -@@ -132,4 +126,11 @@ - public boolean isListStart(String[] astring, int i) { - return i == 0; - } -+ -+ // CraftBukkit start - fix decompile error -+ @Override -+ public int compareTo(ICommand o) { -+ return a((ICommand) o); -+ } -+ // CraftBukkit end - } diff --git a/paper-server/nms-patches/Container.patch b/paper-server/nms-patches/Container.patch index 26daef6366..ef86d902f4 100644 --- a/paper-server/nms-patches/Container.patch +++ b/paper-server/nms-patches/Container.patch @@ -96,7 +96,7 @@ + // CraftBukkit end } - this.d(); + this.c(); @@ -165,8 +225,11 @@ if (i == -999) { if (!playerinventory.getCarried().isEmpty()) { @@ -126,11 +126,11 @@ } } } else if (inventoryclicktype == InventoryClickType.SWAP && j >= 0 && j < 9) { -@@ -564,6 +636,7 @@ - inventorycraftresult.a(irecipe); - itemstack = irecipe.craftItem(inventorycrafting); +@@ -567,6 +639,7 @@ + if (inventorycraftresult.a(world, entityplayer, irecipe) && irecipe != null) { + itemstack = irecipe.craftItem(iinventory); } -+ itemstack = org.bukkit.craftbukkit.event.CraftEventFactory.callPreCraftEvent(inventorycrafting, itemstack, getBukkitView(), false); // CraftBukkit ++ itemstack = org.bukkit.craftbukkit.event.CraftEventFactory.callPreCraftEvent(iinventory, inventorycraftresult, itemstack, getBukkitView(), false); // CraftBukkit inventorycraftresult.setItem(0, itemstack); entityplayer.playerConnection.sendPacket(new PacketPlayOutSetSlot(this.windowId, 0, itemstack)); diff --git a/paper-server/nms-patches/ContainerAnvil.patch b/paper-server/nms-patches/ContainerAnvil.patch index e32f857e29..0f9f7d3a62 100644 --- a/paper-server/nms-patches/ContainerAnvil.patch +++ b/paper-server/nms-patches/ContainerAnvil.patch @@ -26,7 +26,7 @@ this.j = blockposition; this.i = world; this.m = entityhuman; -@@ -110,7 +120,7 @@ +@@ -111,7 +121,7 @@ byte b1 = 0; if (itemstack.isEmpty()) { @@ -35,25 +35,25 @@ this.levelCost = 0; } else { ItemStack itemstack1 = itemstack.cloneItemStack(); -@@ -128,7 +138,7 @@ - if (itemstack1.f() && itemstack1.getItem().a(itemstack, itemstack2)) { - k = Math.min(itemstack1.i(), itemstack1.k() / 4); +@@ -129,7 +139,7 @@ + if (itemstack1.e() && itemstack1.getItem().a(itemstack, itemstack2)) { + k = Math.min(itemstack1.getDamage(), itemstack1.h() / 4); if (k <= 0) { - this.g.setItem(0, ItemStack.a); + org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.a); // CraftBukkit this.levelCost = 0; return; } -@@ -143,7 +153,7 @@ +@@ -144,7 +154,7 @@ this.k = l; } else { - if (!flag && (itemstack1.getItem() != itemstack2.getItem() || !itemstack1.f())) { + if (!flag && (itemstack1.getItem() != itemstack2.getItem() || !itemstack1.e())) { - this.g.setItem(0, ItemStack.a); + org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.a); // CraftBukkit this.levelCost = 0; return; } -@@ -236,7 +246,7 @@ +@@ -237,7 +247,7 @@ } if (flag2 && !flag1) { @@ -62,7 +62,7 @@ this.levelCost = 0; return; } -@@ -283,7 +293,7 @@ +@@ -284,7 +294,7 @@ EnchantmentManager.a(map, itemstack1); } @@ -71,17 +71,17 @@ this.b(); } } -@@ -301,6 +311,7 @@ +@@ -302,6 +312,7 @@ } public boolean canUse(EntityHuman entityhuman) { + if (!this.checkReachable) return true; // CraftBukkit - return this.i.getType(this.j).getBlock() != Blocks.ANVIL ? false : entityhuman.d((double) this.j.getX() + 0.5D, (double) this.j.getY() + 0.5D, (double) this.j.getZ() + 0.5D) <= 64.0D; + return !this.i.getType(this.j).a(TagsBlock.x) ? false : entityhuman.d((double) this.j.getX() + 0.5D, (double) this.j.getY() + 0.5D, (double) this.j.getZ() + 0.5D) <= 64.0D; } -@@ -356,4 +367,33 @@ +@@ -357,4 +368,33 @@ - this.e(); + this.d(); } + + // CraftBukkit start diff --git a/paper-server/nms-patches/ContainerEnchantTable.patch b/paper-server/nms-patches/ContainerEnchantTable.patch index 6b4c4a70f6..a6d9ffd11f 100644 --- a/paper-server/nms-patches/ContainerEnchantTable.patch +++ b/paper-server/nms-patches/ContainerEnchantTable.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/ContainerEnchantTable.java +++ b/net/minecraft/server/ContainerEnchantTable.java -@@ -3,6 +3,19 @@ +@@ -3,6 +3,21 @@ import java.util.List; import java.util.Random; @@ -8,9 +8,11 @@ +import java.util.Collections; +import java.util.Map; +import org.bukkit.Location; ++import org.bukkit.NamespacedKey; +import org.bukkit.craftbukkit.inventory.CraftInventoryEnchanting; +import org.bukkit.craftbukkit.inventory.CraftInventoryView; +import org.bukkit.craftbukkit.inventory.CraftItemStack; ++import org.bukkit.craftbukkit.util.CraftNamespacedKey; +import org.bukkit.enchantments.EnchantmentOffer; +import org.bukkit.event.enchantment.EnchantItemEvent; +import org.bukkit.event.enchantment.PrepareItemEnchantEvent; @@ -19,8 +21,8 @@ + public class ContainerEnchantTable extends Container { - public IInventory enchantSlots = new InventorySubcontainer("Enchant", true, 2) { -@@ -14,6 +27,13 @@ + public IInventory enchantSlots = new InventorySubcontainer(new ChatComponentText("Enchant"), 2) { +@@ -14,6 +29,13 @@ super.update(); ContainerEnchantTable.this.a((IInventory) this); } @@ -34,7 +36,7 @@ }; public World world; private final BlockPosition position; -@@ -22,6 +42,10 @@ +@@ -22,6 +44,10 @@ public int[] costs = new int[3]; public int[] h = new int[] { -1, -1, -1}; public int[] i = new int[] { -1, -1, -1}; @@ -45,7 +47,7 @@ public ContainerEnchantTable(PlayerInventory playerinventory, World world, BlockPosition blockposition) { this.world = world; -@@ -54,6 +78,9 @@ +@@ -54,6 +80,9 @@ this.a(new Slot(playerinventory, i, 8 + i * 18, 142)); } @@ -55,7 +57,7 @@ } protected void c(ICrafting icrafting) { -@@ -90,7 +117,7 @@ +@@ -90,7 +119,7 @@ ItemStack itemstack = iinventory.getItem(0); int i; @@ -64,7 +66,14 @@ if (!this.world.isClientSide) { i = 0; -@@ -152,6 +179,41 @@ +@@ -146,12 +175,47 @@ + if (list != null && !list.isEmpty()) { + WeightedRandomEnchant weightedrandomenchant = (WeightedRandomEnchant) list.get(this.l.nextInt(list.size())); + +- this.h[j] = Enchantment.enchantments.a((Object) weightedrandomenchant.enchantment); ++ this.h[j] = Enchantment.enchantments.a(weightedrandomenchant.enchantment); // CraftBukkit - decompile error + this.i[j] = weightedrandomenchant.level; + } } } @@ -72,7 +81,7 @@ + CraftItemStack item = CraftItemStack.asCraftMirror(itemstack); + org.bukkit.enchantments.EnchantmentOffer[] offers = new EnchantmentOffer[3]; + for (j = 0; j < 3; ++j) { -+ org.bukkit.enchantments.Enchantment enchantment = (this.h[j] >= 0) ? org.bukkit.enchantments.Enchantment.getById(this.h[j]) : null; ++ org.bukkit.enchantments.Enchantment enchantment = (this.h[j] >= 0) ? org.bukkit.enchantments.Enchantment.getByKey(CraftNamespacedKey.fromMinecraft(Enchantment.getId(Enchantment.enchantments.getId(this.h[j])))) : null; + offers[j] = (enchantment != null) ? new EnchantmentOffer(enchantment, this.i[j], this.costs[j]) : null; + } + @@ -93,7 +102,7 @@ + EnchantmentOffer offer = event.getOffers()[j]; + if (offer != null) { + this.costs[j] = offer.getCost(); -+ this.h[j] = offer.getEnchantment().getId(); ++ this.h[j] = Enchantment.enchantments.a(Enchantment.fromId(CraftNamespacedKey.toMinecraft(offer.getEnchantment().getKey()))); + this.i[j] = offer.getEnchantmentLevel(); + } else { + this.costs[j] = 0; @@ -106,7 +115,7 @@ this.b(); } } else { -@@ -176,25 +238,52 @@ +@@ -176,25 +240,53 @@ if (!this.world.isClientSide) { List list = this.a(itemstack, i, this.costs[i]); @@ -119,7 +128,7 @@ + Map enchants = new java.util.HashMap(); + for (Object obj : list) { + WeightedRandomEnchant instance = (WeightedRandomEnchant) obj; -+ enchants.put(org.bukkit.enchantments.Enchantment.getById(Enchantment.getId(instance.enchantment)), instance.level); ++ enchants.put(org.bukkit.enchantments.Enchantment.getByKey(CraftNamespacedKey.fromMinecraft(Enchantment.getId(instance.enchantment))), instance.level); + } + CraftItemStack item = CraftItemStack.asCraftMirror(itemstack); + @@ -141,8 +150,9 @@ + for (Map.Entry entry : event.getEnchantsToAdd().entrySet()) { + try { + if (flag) { -+ int enchantId = entry.getKey().getId(); -+ if (Enchantment.c(enchantId) == null) { ++ NamespacedKey enchantId = entry.getKey().getKey(); ++ Enchantment nms = Enchantment.fromId(CraftNamespacedKey.toMinecraft(enchantId)); ++ if (nms == null) { + continue; + } @@ -150,7 +160,7 @@ - ItemEnchantedBook.a(itemstack, weightedrandomenchant); - } else { - itemstack.addEnchantment(weightedrandomenchant.enchantment, weightedrandomenchant.level); -+ WeightedRandomEnchant weightedrandomenchant = new WeightedRandomEnchant(Enchantment.c(enchantId), entry.getValue()); ++ WeightedRandomEnchant weightedrandomenchant = new WeightedRandomEnchant(nms, entry.getValue()); + ItemEnchantedBook.a(itemstack, weightedrandomenchant); + } else { + item.addUnsafeEnchantment(entry.getKey(), entry.getValue()); @@ -167,7 +177,7 @@ if (!entityhuman.abilities.canInstantlyBuild) { itemstack1.subtract(j); if (itemstack1.isEmpty()) { -@@ -233,12 +322,18 @@ +@@ -233,12 +325,18 @@ public void b(EntityHuman entityhuman) { super.b(entityhuman); @@ -186,7 +196,7 @@ return this.world.getType(this.position).getBlock() != Blocks.ENCHANTING_TABLE ? false : entityhuman.d((double) this.position.getX() + 0.5D, (double) this.position.getY() + 0.5D, (double) this.position.getZ() + 0.5D) <= 64.0D; } -@@ -291,4 +386,17 @@ +@@ -291,4 +389,17 @@ return itemstack; } diff --git a/paper-server/nms-patches/ContainerFurnace.patch b/paper-server/nms-patches/ContainerFurnace.patch index 51ddf578ee..320e3f3da5 100644 --- a/paper-server/nms-patches/ContainerFurnace.patch +++ b/paper-server/nms-patches/ContainerFurnace.patch @@ -1,19 +1,19 @@ --- a/net/minecraft/server/ContainerFurnace.java +++ b/net/minecraft/server/ContainerFurnace.java -@@ -1,5 +1,10 @@ +@@ -1,6 +1,10 @@ package net.minecraft.server; + import java.util.Iterator; +// CraftBukkit start +import org.bukkit.craftbukkit.inventory.CraftInventoryFurnace; +import org.bukkit.craftbukkit.inventory.CraftInventoryView; +// CraftBukkit end -+ - public class ContainerFurnace extends Container { - private final IInventory furnace; -@@ -8,11 +13,28 @@ - private int h; + public class ContainerFurnace extends ContainerRecipeBook { + +@@ -11,12 +15,29 @@ private int i; + private int j; + // CraftBukkit start + private CraftInventoryView bukkitEntity = null; @@ -33,6 +33,7 @@ + public ContainerFurnace(PlayerInventory playerinventory, IInventory iinventory) { this.furnace = iinventory; + this.f = playerinventory.player.world; this.a(new Slot(iinventory, 0, 56, 17)); this.a((Slot) (new SlotFurnaceFuel(iinventory, 1, 56, 53))); this.a((Slot) (new SlotFurnaceResult(playerinventory.player, iinventory, 2, 116, 35))); @@ -40,7 +41,7 @@ int i; -@@ -63,6 +85,7 @@ +@@ -95,6 +116,7 @@ } public boolean canUse(EntityHuman entityhuman) { diff --git a/paper-server/nms-patches/ContainerPlayer.patch b/paper-server/nms-patches/ContainerPlayer.patch index feaa5bcd76..40595e4911 100644 --- a/paper-server/nms-patches/ContainerPlayer.patch +++ b/paper-server/nms-patches/ContainerPlayer.patch @@ -8,10 +8,10 @@ +import org.bukkit.craftbukkit.inventory.CraftInventoryView; +// CraftBukkit end + - public class ContainerPlayer extends Container { + public class ContainerPlayer extends ContainerRecipeBook { - private static final EnumItemSlot[] h = new EnumItemSlot[] { EnumItemSlot.HEAD, EnumItemSlot.CHEST, EnumItemSlot.LEGS, EnumItemSlot.FEET}; -@@ -7,10 +12,20 @@ + private static final String[] h = new String[] { "item/empty_armor_slot_boots", "item/empty_armor_slot_leggings", "item/empty_armor_slot_chestplate", "item/empty_armor_slot_helmet"}; +@@ -8,10 +13,20 @@ public InventoryCraftResult resultInventory = new InventoryCraftResult(); public boolean g; private final EntityHuman owner; @@ -32,27 +32,9 @@ this.a((Slot) (new SlotResult(playerinventory.player, this.craftInventory, this.resultInventory, 0, 154, 28))); int i; -@@ -23,7 +38,7 @@ - } - - for (i = 0; i < 4; ++i) { -- final EnumItemSlot enumitemslot = ContainerPlayer.h[i]; -+ final EnumItemSlot enumitemslot1 = ContainerPlayer.h[i]; - - this.a(new Slot(playerinventory, 36 + (3 - i), 8, 8 + i * 18) { - public int getMaxStackSize() { -@@ -31,7 +46,7 @@ - } - - public boolean isAllowed(ItemStack itemstack) { -- return enumitemslot == EntityInsentient.d(itemstack); -+ return enumitemslot1 == EntityInsentient.d(itemstack); // CraftBukkit - decompile error - } - - public boolean isAllowed(EntityHuman entityhuman) { -@@ -141,4 +156,17 @@ - public boolean a(ItemStack itemstack, Slot slot) { - return slot.inventory != this.resultInventory && super.a(itemstack, slot); +@@ -167,4 +182,17 @@ + public int g() { + return this.craftInventory.n(); } + + // CraftBukkit start diff --git a/paper-server/nms-patches/ContainerWorkbench.patch b/paper-server/nms-patches/ContainerWorkbench.patch index 153d2c6473..f5dd0d2d0e 100644 --- a/paper-server/nms-patches/ContainerWorkbench.patch +++ b/paper-server/nms-patches/ContainerWorkbench.patch @@ -8,7 +8,7 @@ +import org.bukkit.craftbukkit.inventory.CraftInventoryView; +// CraftBukkit end + - public class ContainerWorkbench extends Container { + public class ContainerWorkbench extends ContainerRecipeBook { - public InventoryCrafting craftInventory = new InventoryCrafting(this, 3, 3); - public InventoryCraftResult resultInventory = new InventoryCraftResult(); @@ -32,7 +32,7 @@ this.g = world; this.h = blockposition; this.i = playerinventory.player; -@@ -47,6 +62,7 @@ +@@ -60,6 +75,7 @@ } public boolean canUse(EntityHuman entityhuman) { @@ -40,9 +40,9 @@ return this.g.getType(this.h).getBlock() != Blocks.CRAFTING_TABLE ? false : entityhuman.d((double) this.h.getX() + 0.5D, (double) this.h.getY() + 0.5D, (double) this.h.getZ() + 0.5D) <= 64.0D; } -@@ -100,4 +116,17 @@ - public boolean a(ItemStack itemstack, Slot slot) { - return slot.inventory != this.resultInventory && super.a(itemstack, slot); +@@ -125,4 +141,17 @@ + public int g() { + return this.craftInventory.n(); } + + // CraftBukkit start diff --git a/paper-server/nms-patches/CraftingManager.patch b/paper-server/nms-patches/CraftingManager.patch index a619d68fd5..c788f89154 100644 --- a/paper-server/nms-patches/CraftingManager.patch +++ b/paper-server/nms-patches/CraftingManager.patch @@ -1,57 +1,32 @@ --- a/net/minecraft/server/CraftingManager.java +++ b/net/minecraft/server/CraftingManager.java -@@ -34,6 +34,7 @@ - - public static boolean init() { - try { -+ CraftingManager.c = 0; // Reset recipe ID count - a("armordye", new RecipeArmorDye()); - a("bookcloning", new RecipeBookClone()); - a("mapcloning", new RecipeMapClone()); -@@ -147,6 +148,7 @@ - if (CraftingManager.recipes.d(minecraftkey)) { - throw new IllegalStateException("Duplicate recipe ignored with ID " + minecraftkey); - } else { -+ irecipe.setKey(minecraftkey); // CraftBukkit - CraftingManager.recipes.a(CraftingManager.c++, minecraftkey, irecipe); - } - } -@@ -158,12 +160,14 @@ +@@ -96,12 +96,14 @@ do { if (!iterator.hasNext()) { -+ inventorycrafting.currentRecipe = null; // CraftBukkit - Clear recipe when no recipe is found ++ iinventory.setCurrentRecipe(null); // CraftBukkit - Clear recipe when no recipe is found return ItemStack.a; } irecipe = (IRecipe) iterator.next(); - } while (!irecipe.a(inventorycrafting, world)); + } while (!irecipe.a(iinventory, world)); -+ inventorycrafting.currentRecipe = irecipe; // CraftBukkit - return irecipe.craftItem(inventorycrafting); ++ iinventory.setCurrentRecipe(irecipe); // CraftBukkit + return irecipe.craftItem(iinventory); } -@@ -175,12 +179,14 @@ +@@ -113,12 +115,14 @@ do { if (!iterator.hasNext()) { -+ inventorycrafting.currentRecipe = null; // CraftBukkit - Clear recipe when no recipe is found ++ iinventory.setCurrentRecipe(null); // CraftBukkit - Clear recipe when no recipe is found return null; } irecipe = (IRecipe) iterator.next(); - } while (!irecipe.a(inventorycrafting, world)); + } while (!irecipe.a(iinventory, world)); -+ inventorycrafting.currentRecipe = irecipe; // CraftBukkit ++ iinventory.setCurrentRecipe(irecipe); // CraftBukkit return irecipe; } -@@ -210,7 +216,7 @@ - } - - public static int a(IRecipe irecipe) { -- return CraftingManager.recipes.a((Object) irecipe); -+ return CraftingManager.recipes.a(irecipe); // CraftBukkit - decompile error - } - - @Nullable diff --git a/paper-server/nms-patches/CrashReport.patch b/paper-server/nms-patches/CrashReport.patch index de74312b32..7e9cb27606 100644 --- a/paper-server/nms-patches/CrashReport.patch +++ b/paper-server/nms-patches/CrashReport.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/CrashReport.java +++ b/net/minecraft/server/CrashReport.java -@@ -125,6 +125,7 @@ - return this.a(); - } +@@ -63,6 +63,7 @@ + + return String.format("%d total; %s", new Object[] { Integer.valueOf(list.size()), list.stream().collect(Collectors.joining(" "))}); }); + this.d.a("CraftBukkit Information", (CrashReportCallable) new org.bukkit.craftbukkit.CraftCrashReport()); // CraftBukkit } diff --git a/paper-server/nms-patches/CustomFunction.patch b/paper-server/nms-patches/CustomFunction.patch index a01167d403..034c354659 100644 --- a/paper-server/nms-patches/CustomFunction.patch +++ b/paper-server/nms-patches/CustomFunction.patch @@ -1,19 +1,11 @@ --- a/net/minecraft/server/CustomFunction.java +++ b/net/minecraft/server/CustomFunction.java -@@ -122,7 +122,15 @@ - } +@@ -45,7 +45,7 @@ + } - public void a(CustomFunctionData customfunctiondata, ICommandListener icommandlistener, ArrayDeque arraydeque, int i) { -- customfunctiondata.a().a(icommandlistener, this.a); -+ // CraftBukkit start -+ org.bukkit.command.CommandSender sender; -+ if (icommandlistener instanceof CustomFunctionData.CustomFunctionListener) { -+ sender = ((CustomFunctionData.CustomFunctionListener) icommandlistener).sender; -+ } else { -+ sender = CommandBlockListenerAbstract.unwrapSender(icommandlistener); -+ } -+ CommandBlockListenerAbstract.executeSafely(icommandlistener, sender, this.a); -+ // CraftBukkit end - } + try { +- ParseResults parseresults = customfunctiondata.a().getCommandDispatcher().a().parse(s, customfunctiondata.f()); ++ ParseResults parseresults = customfunctiondata.d().parse(s, customfunctiondata.f()); // CraftBukkit - public String toString() { + if (parseresults.getReader().canRead()) { + if (parseresults.getExceptions().size() == 1) { diff --git a/paper-server/nms-patches/CustomFunctionData.patch b/paper-server/nms-patches/CustomFunctionData.patch index 821ff006ab..d478a82391 100644 --- a/paper-server/nms-patches/CustomFunctionData.patch +++ b/paper-server/nms-patches/CustomFunctionData.patch @@ -1,45 +1,38 @@ --- a/net/minecraft/server/CustomFunctionData.java +++ b/net/minecraft/server/CustomFunctionData.java -@@ -23,7 +23,14 @@ - private CustomFunction f; - private final ArrayDeque g = new ArrayDeque(); - private boolean h = false; -- private final ICommandListener i = new ICommandListener() { -+ // CraftBukkit start -+ private final ICommandListener i = new CustomFunctionListener(); -+ -+ public class CustomFunctionListener implements ICommandListener { -+ -+ protected org.bukkit.command.CommandSender sender = new org.bukkit.craftbukkit.command.CraftFunctionCommandSender(this); -+ // CraftBukkit end -+ - public String getName() { - return CustomFunctionData.this.e; - } -@@ -33,7 +40,7 @@ - } +@@ -32,14 +32,16 @@ + private final Map g = Maps.newHashMap(); + private final ArrayDeque h = new ArrayDeque(); + private boolean i; +- private final Tags j = new Tags((minecraftkey) -> { ++ private final Tags j = new Tags<>((minecraftkey) -> { // CraftBukkit - decompile error + return this.a(minecraftkey) != null; + }, this::a, "tags/functions", true, "function"); + private final List k = Lists.newArrayList(); + private boolean l; ++ private final com.mojang.brigadier.CommandDispatcher dispatcher; // CraftBukkit - public World getWorld() { -- return CustomFunctionData.this.c.worldServer[0]; -+ return CustomFunctionData.this.c.worlds.get(0); // CraftBukkit - } - - public MinecraftServer C_() { -@@ -57,7 +64,7 @@ + public CustomFunctionData(MinecraftServer minecraftserver) { + this.f = minecraftserver; ++ this.dispatcher = this.f.getCommandDispatcher().a(); // CraftBukkit } - public int c() { -- return this.c.worldServer[0].getGameRules().c("maxCommandChainLength"); -+ return this.c.worlds.get(0).getGameRules().c("maxCommandChainLength"); // CraftBukkit + @Nullable +@@ -60,7 +62,7 @@ } - public Map d() { -@@ -65,7 +72,7 @@ + public com.mojang.brigadier.CommandDispatcher d() { +- return this.f.getCommandDispatcher().a(); ++ return dispatcher; // CraftBukkit } - public void e() { -- String s = this.c.worldServer[0].getGameRules().get("gameLoopFunction"); -+ String s = this.c.worlds.get(0).getGameRules().get("gameLoopFunction"); // CraftBukkit - - if (!s.equals(this.e)) { - this.e = s; + public void X_() { +@@ -164,7 +166,7 @@ + arraylist.add(CompletableFuture.supplyAsync(() -> { + return a(iresourcemanager, minecraftkey); + }, Resource.a).thenApplyAsync((list) -> { +- return CustomFunction.a(minecraftkey, this, list); ++ return CustomFunction.a(minecraftkey1, this, list); // CraftBukkit - decompile error + }).handle((customfunction, throwable) -> { + return this.a(customfunction, throwable, minecraftkey); + })); diff --git a/paper-server/nms-patches/DamageSource.patch b/paper-server/nms-patches/DamageSource.patch index ac9ca78e7e..9a4a324c91 100644 --- a/paper-server/nms-patches/DamageSource.patch +++ b/paper-server/nms-patches/DamageSource.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/server/DamageSource.java +++ b/net/minecraft/server/DamageSource.java -@@ -34,6 +34,18 @@ - private boolean C; +@@ -35,6 +35,18 @@ private boolean D; - public String translationIndex; + private boolean E; + public final String translationIndex; + // CraftBukkit start + private boolean sweep; + diff --git a/paper-server/nms-patches/DataConverterFlatten.patch b/paper-server/nms-patches/DataConverterFlatten.patch new file mode 100644 index 0000000000..4c4a198f84 --- /dev/null +++ b/paper-server/nms-patches/DataConverterFlatten.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/server/DataConverterFlatten.java ++++ b/net/minecraft/server/DataConverterFlatten.java +@@ -378,7 +378,7 @@ + Typed typed2 = typed.getOrCreateTyped(opticfinder1); + Dynamic dynamic1 = (Dynamic) typed2.get(DSL.remainderFinder()); + +- dynamic1 = dynamic1.set("Damage", dynamic1.createInt(i)); ++ if (i != 0) dynamic1 = dynamic1.set("Damage", dynamic1.createInt(i)); // CraftBukkit + typed1 = typed1.set(opticfinder1, typed2.set(DSL.remainderFinder(), dynamic1)); + } + diff --git a/paper-server/nms-patches/DataConverterMap.patch b/paper-server/nms-patches/DataConverterMap.patch new file mode 100644 index 0000000000..190d6490c2 --- /dev/null +++ b/paper-server/nms-patches/DataConverterMap.patch @@ -0,0 +1,20 @@ +--- a/net/minecraft/server/DataConverterMap.java ++++ b/net/minecraft/server/DataConverterMap.java +@@ -22,7 +22,7 @@ + public TypeRewriteRule makeRule() { + Type type = this.getInputSchema().getType(DataConverterTypes.ITEM_STACK); + OpticFinder opticfinder = DSL.fieldFinder("id", DSL.named(DataConverterTypes.q.typeName(), DSL.namespacedString())); +- OpticFinder opticfinder1 = type.findField("tag"); ++ OpticFinder opticfinder1 = type.findField("tag"); // CraftBukkit - decompile error + + return this.fixTypeEverywhereTyped("ItemInstanceMapIdFix", type, (typed) -> { + Optional optional = typed.getOptional(opticfinder); +@@ -32,7 +32,7 @@ + Typed typed1 = typed.getOrCreateTyped(opticfinder1); + Dynamic dynamic1 = (Dynamic) typed1.get(DSL.remainderFinder()); + +- dynamic1 = dynamic1.set("map", dynamic1.createInt(dynamic.getInt("Damage"))); ++ if (!dynamic1.get("map").isPresent()) dynamic1 = dynamic1.set("map", dynamic1.createInt(dynamic.getInt("Damage"))); // CraftBukkit + return typed.set(opticfinder1, typed1.set(DSL.remainderFinder(), dynamic1)); + } else { + return typed; diff --git a/paper-server/nms-patches/DataInspectorBlockEntity.patch b/paper-server/nms-patches/DataInspectorBlockEntity.patch deleted file mode 100644 index 0ec5d7998c..0000000000 --- a/paper-server/nms-patches/DataInspectorBlockEntity.patch +++ /dev/null @@ -1,12 +0,0 @@ ---- a/net/minecraft/server/DataInspectorBlockEntity.java -+++ b/net/minecraft/server/DataInspectorBlockEntity.java -@@ -32,7 +32,8 @@ - boolean flag; - - if (s1 == null) { -- DataInspectorBlockEntity.a.warn("Unable to resolve BlockEntity for ItemInstance: {}", s); -+ // CraftBukkit - Remove unnecessary warning (occurs when deserializing a Shulker Box item) -+ // DataInspectorBlockEntity.a.warn("Unable to resolve BlockEntity for ItemInstance: {}", s); - flag = false; - } else { - flag = !nbttagcompound2.hasKey("id"); diff --git a/paper-server/nms-patches/DataPaletteBlock.patch b/paper-server/nms-patches/DataPaletteBlock.patch deleted file mode 100644 index 676b070e72..0000000000 --- a/paper-server/nms-patches/DataPaletteBlock.patch +++ /dev/null @@ -1,25 +0,0 @@ ---- a/net/minecraft/server/DataPaletteBlock.java -+++ b/net/minecraft/server/DataPaletteBlock.java -@@ -112,7 +112,21 @@ - int i1 = nibblearray1 == null ? 0 : nibblearray1.a(j, k, l); - int j1 = i1 << 12 | (abyte[i] & 255) << 4 | nibblearray.a(j, k, l); - -- this.setBlockIndex(i, (IBlockData) Block.REGISTRY_ID.fromId(j1)); -+ // CraftBukkit start - fix blocks with random data values (caused by plugins) -+ IBlockData data = Block.REGISTRY_ID.fromId(j1); -+ if (data == null) { -+ Block block = Block.getById(j1 >> 4); -+ if (block != null) { -+ try { -+ data = block.fromLegacyData(j1 & 0xF); -+ } catch (Exception ignored) { -+ data = block.getBlockData(); -+ } -+ } -+ } -+ this.setBlockIndex(i, data); -+ // this.setBlockIndex(i, (IBlockData) Block.REGISTRY_ID.fromId(j1)); -+ // CraftBukkit end - } - - } diff --git a/paper-server/nms-patches/DataWatcher.patch b/paper-server/nms-patches/DataWatcher.patch index 131d78a75f..676bc64c1a 100644 --- a/paper-server/nms-patches/DataWatcher.patch +++ b/paper-server/nms-patches/DataWatcher.patch @@ -18,3 +18,17 @@ DataWatcher.Item datawatcher_item = new DataWatcher.Item(datawatcherobject, t0); this.e.writeLock().lock(); +@@ -128,6 +128,13 @@ + + } + ++ // CraftBukkit start - add method from above ++ public void markDirty(DataWatcherObject datawatcherobject) { ++ this.b(datawatcherobject).a(true); ++ this.g = true; ++ } ++ // CraftBukkit end ++ + public boolean a() { + return this.g; + } diff --git a/paper-server/nms-patches/DedicatedServer.patch b/paper-server/nms-patches/DedicatedServer.patch index 9cd3444c51..e2d9e6ee29 100644 --- a/paper-server/nms-patches/DedicatedServer.patch +++ b/paper-server/nms-patches/DedicatedServer.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/DedicatedServer.java +++ b/net/minecraft/server/DedicatedServer.java -@@ -19,11 +19,21 @@ +@@ -23,11 +23,22 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -8,6 +8,7 @@ +import java.io.PrintStream; +import org.apache.logging.log4j.Level; + ++import org.bukkit.command.CommandSender; +import org.bukkit.craftbukkit.LoggerOutputStream; +import org.bukkit.event.server.ServerCommandEvent; +import org.bukkit.craftbukkit.util.Waitable; @@ -17,26 +18,26 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer { private static final Logger LOGGER = LogManager.getLogger(); - private static final Pattern l = Pattern.compile("^[a-fA-F0-9]{40}$"); + private static final Pattern i = Pattern.compile("^[a-fA-F0-9]{40}$"); - private final List serverCommandQueue = Collections.synchronizedList(Lists.newArrayList()); + private final List serverCommandQueue = Collections.synchronizedList(Lists.newArrayList()); // CraftBukkit - fix decompile error - private RemoteStatusListener n; + private RemoteStatusListener k; public final RemoteControlCommandListener remoteControlCommandListener = new RemoteControlCommandListener(this); - private RemoteControlListener p; -@@ -33,8 +43,10 @@ - private EnumGamemode t; - private boolean u; + private RemoteControlListener m; +@@ -37,8 +48,10 @@ + private EnumGamemode q; + private boolean r; -- public DedicatedServer(File file, DataConverterManager dataconvertermanager, YggdrasilAuthenticationService yggdrasilauthenticationservice, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache) { -- super(file, Proxy.NO_PROXY, dataconvertermanager, yggdrasilauthenticationservice, minecraftsessionservice, gameprofilerepository, usercache); +- public DedicatedServer(File file, DataFixer datafixer, YggdrasilAuthenticationService yggdrasilauthenticationservice, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache) { +- super(file, Proxy.NO_PROXY, datafixer, new CommandDispatcher(true), yggdrasilauthenticationservice, minecraftsessionservice, gameprofilerepository, usercache); + // CraftBukkit start - Signature changed -+ public DedicatedServer(joptsimple.OptionSet options, DataConverterManager dataconvertermanager, YggdrasilAuthenticationService yggdrasilauthenticationservice, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache) { -+ super(options, Proxy.NO_PROXY, dataconvertermanager, yggdrasilauthenticationservice, minecraftsessionservice, gameprofilerepository, usercache); ++ public DedicatedServer(joptsimple.OptionSet options, DataFixer datafixer, YggdrasilAuthenticationService yggdrasilauthenticationservice, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache) { ++ super(options, Proxy.NO_PROXY, datafixer, new CommandDispatcher().init(true), yggdrasilauthenticationservice, minecraftsessionservice, gameprofilerepository, usercache); + // CraftBukkit end Thread thread = new Thread("Server Infinisleeper") { { this.setDaemon(true); -@@ -53,16 +65,30 @@ +@@ -58,16 +71,30 @@ }; } @@ -56,22 +57,22 @@ try { - while (!DedicatedServer.this.isStopped() && DedicatedServer.this.isRunning() && (s = bufferedreader.readLine()) != null) { -- DedicatedServer.this.issueCommand(s, DedicatedServer.this); +- DedicatedServer.this.issueCommand(s, DedicatedServer.this.getServerCommandListener()); + // CraftBukkit start - JLine disabling compatibility -+ while (!isStopped() && isRunning()) { ++ while (!DedicatedServer.this.isStopped() && DedicatedServer.this.isRunning()) { + if (org.bukkit.craftbukkit.Main.useJline) { + s = bufferedreader.readLine(">", null); + } else { + s = bufferedreader.readLine(); + } + if (s != null && s.trim().length() > 0) { // Trim to filter lines which are just spaces -+ issueCommand(s, DedicatedServer.this); ++ DedicatedServer.this.issueCommand(s, DedicatedServer.this.getServerCommandListener()); + } + // CraftBukkit end } } catch (IOException ioexception) { DedicatedServer.LOGGER.error("Exception handling console input", ioexception); -@@ -71,6 +97,27 @@ +@@ -76,6 +103,27 @@ } }; @@ -97,18 +98,18 @@ + // CraftBukkit end + thread.setDaemon(true); + thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(DedicatedServer.LOGGER)); thread.start(); - DedicatedServer.LOGGER.info("Starting minecraft server version 1.12.2"); -@@ -79,7 +126,7 @@ +@@ -85,7 +133,7 @@ } DedicatedServer.LOGGER.info("Loading properties"); - this.propertyManager = new PropertyManager(new File("server.properties")); + this.propertyManager = new PropertyManager(this.options); // CraftBukkit - CLI argument support - this.r = new EULA(new File("eula.txt")); - if (!this.r.a()) { + this.o = new EULA(new File("eula.txt")); + if (!this.o.a()) { DedicatedServer.LOGGER.info("You need to agree to the EULA in order to run the server. Go to eula.txt for more info."); -@@ -136,6 +183,12 @@ +@@ -143,6 +191,12 @@ return false; } @@ -121,28 +122,19 @@ if (!this.getOnlineMode()) { DedicatedServer.LOGGER.warn("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!"); DedicatedServer.LOGGER.warn("The server will make no attempt to authenticate usernames. Beware."); -@@ -150,7 +203,7 @@ +@@ -157,7 +211,7 @@ if (!NameReferencingFileConverter.a(this.propertyManager)) { return false; } else { - this.a((PlayerList) (new DedicatedPlayerList(this))); -+ this.convertable = new WorldLoaderServer(server.getWorldContainer(), this.dataConverterManager); // CraftBukkit - moved from MinecraftServer constructor - long j = System.nanoTime(); ++ this.convertable = new WorldLoaderServer(server.getWorldContainer().toPath(), server.getWorldContainer().toPath().resolve("../backups"), this.dataConverterManager); // CraftBukkit - moved from MinecraftServer constructor + long j = SystemUtils.c(); - if (this.S() == null) { -@@ -198,7 +251,7 @@ - - DedicatedServer.LOGGER.info("Done ({})! For help, type \"help\" or \"?\"", s3); - if (this.propertyManager.a("announce-player-achievements")) { -- this.worldServer[0].getGameRules().set("announceAdvancements", this.propertyManager.getBoolean("announce-player-achievements", true) ? "true" : "false"); -+ this.worlds.get(0).getGameRules().set("announceAdvancements", this.propertyManager.getBoolean("announce-player-achievements", true) ? "true" : "false"); // CraftBukkit - this.propertyManager.b("announce-player-achievements"); - this.propertyManager.savePropertiesFile(); - } -@@ -213,7 +266,18 @@ + if (this.K() == null) { +@@ -228,7 +282,18 @@ DedicatedServer.LOGGER.info("Starting remote control listener"); - this.p = new RemoteControlListener(this); - this.p.a(); + this.m = new RemoteControlListener(this); + this.m.a(); + this.remoteConsole = new org.bukkit.craftbukkit.command.CraftRemoteConsoleCommandSender(this.remoteControlCommandListener); // CraftBukkit + } + @@ -156,40 +148,40 @@ } + // CraftBukkit end - if (this.aT() > 0L) { + if (this.ba() > 0L) { Thread thread1 = new Thread(new ThreadWatchdog(this)); -@@ -299,11 +363,11 @@ +@@ -303,11 +368,11 @@ return crashreport; } -- protected void B() { -+ public void B() { +- protected void u() { ++ public void u() { // CraftBukkit - decompile error System.exit(0); } -- protected void D() { -+ public void D() { // CraftBukkit - fix decompile error - super.D(); - this.aP(); +- protected void w() { ++ public void w() { // CraftBukkit - fix decompile error + super.w(); + this.aW(); } -@@ -334,7 +398,15 @@ +@@ -342,7 +407,15 @@ while (!this.serverCommandQueue.isEmpty()) { ServerCommand servercommand = (ServerCommand) this.serverCommandQueue.remove(0); -- this.getCommandHandler().a(servercommand.source, servercommand.command); +- this.getCommandDispatcher().a(servercommand.source, servercommand.command); + // CraftBukkit start - ServerCommand for preprocessing + ServerCommandEvent event = new ServerCommandEvent(console, servercommand.command); + server.getPluginManager().callEvent(event); + if (event.isCancelled()) continue; + servercommand = new ServerCommand(event.getCommand(), servercommand.source); + -+ // this.getCommandHandler().a(servercommand.source, servercommand.command); // Called in dispatchServerCommand ++ // this.getCommandDispatcher().a(servercommand.source, servercommand.command); // Called in dispatchServerCommand + server.dispatchServerCommand(console, servercommand); + // CraftBukkit end } } -@@ -537,16 +609,70 @@ +@@ -549,16 +622,75 @@ } public String getPlugins() { @@ -210,17 +202,17 @@ + if (i > 0) { + result.append("; "); + } -+ + +- public String executeRemoteCommand(String s) { +- this.remoteControlCommandListener.clearMessages(); +- this.getCommandDispatcher().a(this.remoteControlCommandListener.f(), s); +- return this.remoteControlCommandListener.getMessages(); + result.append(plugins[i].getDescription().getName()); + result.append(" "); + result.append(plugins[i].getDescription().getVersion().replaceAll(";", ",")); + } + } - -- public String executeRemoteCommand(String s) { -- this.remoteControlCommandListener.clearMessages(); -- this.b.a(this.remoteControlCommandListener, s); -- return this.remoteControlCommandListener.getMessages(); ++ + return result.toString(); + // CraftBukkit end + } @@ -238,7 +230,7 @@ + return ""; + } + // Event change end -+ ServerCommand serverCommand = new ServerCommand(event.getCommand(), remoteControlCommandListener); ++ ServerCommand serverCommand = new ServerCommand(event.getCommand(), remoteControlCommandListener.f()); + server.dispatchServerCommand(remoteConsole, serverCommand); + return remoteControlCommandListener.getMessages(); + } @@ -256,7 +248,7 @@ } public PlayerList getPlayerList() { - return this.aQ(); + return this.aX(); } + + // CraftBukkit start @@ -264,5 +256,10 @@ + public PropertyManager getPropertyManager() { + return this.propertyManager; + } ++ ++ @Override ++ public CommandSender getBukkitSender(CommandListenerWrapper wrapper) { ++ return console; ++ } + // CraftBukkit end } diff --git a/paper-server/nms-patches/DispenseBehaviorItem.patch b/paper-server/nms-patches/DispenseBehaviorItem.patch index f325425fd2..50eb6ee9e8 100644 --- a/paper-server/nms-patches/DispenseBehaviorItem.patch +++ b/paper-server/nms-patches/DispenseBehaviorItem.patch @@ -11,7 +11,7 @@ public class DispenseBehaviorItem implements IDispenseBehavior { public DispenseBehaviorItem() {} -@@ -17,11 +22,18 @@ +@@ -17,11 +22,19 @@ IPosition iposition = BlockDispenser.a(isourceblock); ItemStack itemstack1 = itemstack.cloneAndSubtract(1); @@ -27,12 +27,13 @@ - public static void a(World world, ItemStack itemstack, int i, EnumDirection enumdirection, IPosition iposition) { + // CraftBukkit start - void -> boolean return, IPosition -> ISourceBlock last argument + public static boolean a(World world, ItemStack itemstack, int i, EnumDirection enumdirection, ISourceBlock isourceblock) { ++ if (itemstack.isEmpty()) return true; + IPosition iposition = BlockDispenser.a(isourceblock); + // CraftBukkit end double d0 = iposition.getX(); double d1 = iposition.getY(); double d2 = iposition.getZ(); -@@ -41,7 +53,41 @@ +@@ -41,7 +54,41 @@ entityitem.motX += world.random.nextGaussian() * 0.007499999832361937D * (double) i; entityitem.motY += world.random.nextGaussian() * 0.007499999832361937D * (double) i; entityitem.motZ += world.random.nextGaussian() * 0.007499999832361937D * (double) i; @@ -60,7 +61,7 @@ + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); + if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior.getClass() != DispenseBehaviorItem.class) { -+ idispensebehavior.a(isourceblock, eventStack); ++ idispensebehavior.dispense(isourceblock, eventStack); + } else { + world.addEntity(entityitem); + } diff --git a/paper-server/nms-patches/DispenseBehaviorProjectile.patch b/paper-server/nms-patches/DispenseBehaviorProjectile.patch index a7f5100e76..e3b3fd0569 100644 --- a/paper-server/nms-patches/DispenseBehaviorProjectile.patch +++ b/paper-server/nms-patches/DispenseBehaviorProjectile.patch @@ -38,7 +38,7 @@ + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); + if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { -+ idispensebehavior.a(isourceblock, eventStack); ++ idispensebehavior.dispense(isourceblock, eventStack); + return itemstack; + } + } diff --git a/paper-server/nms-patches/DispenserRegistry.patch b/paper-server/nms-patches/DispenserRegistry.patch index 5d7bba4e1b..47b0478dc6 100644 --- a/paper-server/nms-patches/DispenserRegistry.patch +++ b/paper-server/nms-patches/DispenserRegistry.patch @@ -16,38 +16,35 @@ public class DispenserRegistry { public static final PrintStream a = System.out; -@@ -71,7 +80,7 @@ - BlockDispenser.REGISTRY.a(Items.SPLASH_POTION, new IDispenseBehavior() { - public ItemStack a(ISourceBlock isourceblock, final ItemStack itemstack) { +@@ -70,7 +79,7 @@ + BlockDispenser.a((IMaterial) Items.SPLASH_POTION, new IDispenseBehavior() { + public ItemStack dispense(ISourceBlock isourceblock, final ItemStack itemstack) { return (new DispenseBehaviorProjectile() { - protected IProjectile a(World world, IPosition iposition, ItemStack itemstack) { + protected IProjectile a(World world, IPosition iposition, ItemStack itemstack1) { // CraftBukkit - decompile issue return new EntityPotion(world, iposition.getX(), iposition.getY(), iposition.getZ(), itemstack1.cloneItemStack()); } -@@ -88,7 +97,7 @@ - BlockDispenser.REGISTRY.a(Items.LINGERING_POTION, new IDispenseBehavior() { - public ItemStack a(ISourceBlock isourceblock, final ItemStack itemstack) { +@@ -87,7 +96,7 @@ + BlockDispenser.a((IMaterial) Items.LINGERING_POTION, new IDispenseBehavior() { + public ItemStack dispense(ISourceBlock isourceblock, final ItemStack itemstack) { return (new DispenseBehaviorProjectile() { - protected IProjectile a(World world, IPosition iposition, ItemStack itemstack) { + protected IProjectile a(World world, IPosition iposition, ItemStack itemstack1) { // CraftBukkit - decompile issue return new EntityPotion(world, iposition.getX(), iposition.getY(), iposition.getZ(), itemstack1.cloneItemStack()); } -@@ -108,14 +117,46 @@ - double d0 = isourceblock.getX() + (double) enumdirection.getAdjacentX(); - double d1 = (double) ((float) (isourceblock.getBlockPosition().getY() + enumdirection.getAdjacentY()) + 0.2F); - double d2 = isourceblock.getZ() + (double) enumdirection.getAdjacentZ(); -- Entity entity = ItemMonsterEgg.a(isourceblock.getWorld(), ItemMonsterEgg.h(itemstack), d0, d1, d2); -+ // Entity entity = ItemMonsterEgg.a(isourceblock.getWorld(), ItemMonsterEgg.h(itemstack), d0, d1, d2); -+ +@@ -106,11 +115,39 @@ + EnumDirection enumdirection = (EnumDirection) isourceblock.e().get(BlockDispenser.FACING); + EntityTypes entitytypes = ((ItemMonsterEgg) itemstack.getItem()).b(itemstack.getTag()); + + // CraftBukkit start + World world = isourceblock.getWorld(); + ItemStack itemstack1 = itemstack.cloneAndSubtract(1); + org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); + CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); + -+ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(d0, d1, d2)); ++ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0)); + if (!BlockDispenser.eventFired) { + world.getServer().getPluginManager().callEvent(event); + } @@ -63,27 +60,22 @@ + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); + if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { -+ idispensebehavior.a(isourceblock, eventStack); ++ idispensebehavior.dispense(isourceblock, eventStack); + return itemstack; + } + } + -+ itemstack1 = CraftItemStack.asNMSCopy(event.getItem()); -+ -+ Entity entity = ItemMonsterEgg.spawnCreature(isourceblock.getWorld(), ItemMonsterEgg.h(itemstack), event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DISPENSE_EGG); - - if (entity instanceof EntityLiving && itemstack.hasName()) { - entity.setCustomName(itemstack.getName()); + if (entitytypes != null) { + entitytypes.a(isourceblock.getWorld(), itemstack, (EntityHuman) null, isourceblock.getBlockPosition().shift(enumdirection), enumdirection != EnumDirection.UP, false); } - ItemMonsterEgg.a(isourceblock.getWorld(), (EntityHuman) null, itemstack, entity); - itemstack.subtract(1); -+ // itemstack.subtract(1);// Handled during event processing ++ // itemstack.subtract(1); // Handled during event processing + // CraftBukkit end return itemstack; } - }); -@@ -125,10 +166,39 @@ + }; +@@ -128,10 +165,39 @@ double d0 = isourceblock.getX() + (double) enumdirection.getAdjacentX(); double d1 = (double) ((float) isourceblock.getBlockPosition().getY() + 0.2F); double d2 = isourceblock.getZ() + (double) enumdirection.getAdjacentZ(); @@ -110,7 +102,7 @@ + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); + if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { -+ idispensebehavior.a(isourceblock, eventStack); ++ idispensebehavior.dispense(isourceblock, eventStack); + return itemstack; + } + } @@ -125,7 +117,7 @@ return itemstack; } -@@ -149,8 +219,38 @@ +@@ -152,8 +218,38 @@ double d4 = random.nextGaussian() * 0.05D + (double) enumdirection.getAdjacentY(); double d5 = random.nextGaussian() * 0.05D + (double) enumdirection.getAdjacentZ(); @@ -152,7 +144,7 @@ + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); + if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { -+ idispensebehavior.a(isourceblock, eventStack); ++ idispensebehavior.dispense(isourceblock, eventStack); + return itemstack; + } + } @@ -166,13 +158,11 @@ return itemstack; } -@@ -171,7 +271,53 @@ - ItemBucket itembucket = (ItemBucket) itemstack.getItem(); +@@ -175,9 +271,49 @@ BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.e().get(BlockDispenser.FACING)); + World world = isourceblock.getWorld(); -- return itembucket.a((EntityHuman) null, isourceblock.getWorld(), blockposition) ? new ItemStack(Items.BUCKET) : this.b.a(isourceblock, itemstack); + // CraftBukkit start -+ World world = isourceblock.getWorld(); + int x = blockposition.getX(); + int y = blockposition.getY(); + int z = blockposition.getZ(); @@ -194,7 +184,7 @@ + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); + if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { -+ idispensebehavior.a(isourceblock, eventStack); ++ idispensebehavior.dispense(isourceblock, eventStack); + return itemstack; + } + } @@ -203,7 +193,9 @@ + } + // CraftBukkit end + -+ if (itembucket.a((EntityHuman) null, isourceblock.getWorld(), blockposition)) { + if (itembucket.a((EntityHuman) null, world, blockposition, (MovingObjectPosition) null)) { +- itembucket.a(world, itemstack, blockposition); +- return new ItemStack(Items.BUCKET); + // CraftBukkit start - Handle stacked buckets + Item item = Items.BUCKET; + itemstack.subtract(1); @@ -211,25 +203,53 @@ + itemstack.setItem(Items.BUCKET); + itemstack.setCount(1); + } else if (((TileEntityDispenser) isourceblock.getTileEntity()).addItem(new ItemStack(item)) < 0) { -+ this.b.a(isourceblock, new ItemStack(item)); ++ this.a.dispense(isourceblock, new ItemStack(item)); + } + // CraftBukkit end + return itemstack; -+ } else { -+ return this.b.a(isourceblock, itemstack); -+ } - } - }; - -@@ -198,6 +344,30 @@ - item = Items.LAVA_BUCKET; + } else { + return this.a.dispense(isourceblock, itemstack); } +@@ -207,6 +343,30 @@ + } else { + Item item = fluidtype.b(); + ++ // CraftBukkit start ++ org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); ++ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack); ++ ++ BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockposition.getX(), blockposition.getY(), blockposition.getZ())); ++ if (!BlockDispenser.eventFired) { ++ world.getServer().getPluginManager().callEvent(event); ++ } ++ ++ if (event.isCancelled()) { ++ return itemstack; ++ } ++ ++ if (!event.getItem().equals(craftItem)) { ++ // Chain to handler for new item ++ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); ++ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); ++ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { ++ idispensebehavior.dispense(isourceblock, eventStack); ++ return itemstack; ++ } ++ } ++ // CraftBukkit end ++ + itemstack.subtract(1); + if (itemstack.isEmpty()) { + return new ItemStack(item); +@@ -227,14 +387,42 @@ + protected ItemStack a(ISourceBlock isourceblock, ItemStack itemstack) { + World world = isourceblock.getWorld(); + // CraftBukkit start + org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); + CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack); + -+ BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockposition.getX(), blockposition.getY(), blockposition.getZ())); ++ BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0)); + if (!BlockDispenser.eventFired) { + world.getServer().getPluginManager().callEvent(event); + } @@ -243,19 +263,34 @@ + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); + if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { -+ idispensebehavior.a(isourceblock, eventStack); ++ idispensebehavior.dispense(isourceblock, eventStack); + return itemstack; + } + } + // CraftBukkit end + - world.setAir(blockposition); - itemstack.subtract(1); - if (itemstack.isEmpty()) { -@@ -215,14 +385,42 @@ - protected ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) { - World world = isourceblock.getWorld(); + this.a = true; + BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.e().get(BlockDispenser.FACING)); + if (ItemFlintAndSteel.a((GeneratorAccess) world, blockposition)) { +- world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData()); +- if (itemstack.isDamaged(1, world.random, (EntityPlayer) null)) { +- itemstack.setCount(0); ++ // CraftBukkit start - Ignition by dispensing flint and steel ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition, isourceblock.getBlockPosition()).isCancelled()) { ++ world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData()); ++ if (itemstack.isDamaged(1, world.random, (EntityPlayer) null)) { ++ itemstack.setCount(0); ++ } + } ++ // CraftBukkit end + } else { + Block block = world.getType(blockposition).getBlock(); + +@@ -254,12 +442,55 @@ + this.a = true; + World world = isourceblock.getWorld(); + BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.e().get(BlockDispenser.FACING)); + // CraftBukkit start + org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); + CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack); @@ -274,92 +309,42 @@ + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); + if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { -+ idispensebehavior.a(isourceblock, eventStack); ++ idispensebehavior.dispense(isourceblock, eventStack); + return itemstack; + } + } + // CraftBukkit end -+ - this.b = true; - BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.e().get(BlockDispenser.FACING)); - if (world.isEmpty(blockposition)) { -- world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData()); -- if (itemstack.isDamaged(1, world.random, (EntityPlayer) null)) { -- itemstack.setCount(0); -+ // CraftBukkit start - Ignition by dispensing flint and steel -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()).isCancelled()) { -+ world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData()); -+ if (itemstack.isDamaged(1, world.random, (EntityPlayer) null)) { -+ itemstack.setCount(0); + if (!ItemBoneMeal.a(itemstack, world, blockposition) && !ItemBoneMeal.b(itemstack, world, blockposition)) { + this.a = false; + } else if (!world.isClientSide) { + world.triggerEffect(2005, blockposition, 0); + } ++ // CraftBukkit start ++ world.captureTreeGeneration = false; ++ if (world.capturedBlockStates.size() > 0) { ++ TreeType treeType = BlockSapling.treeType; ++ BlockSapling.treeType = null; ++ Location location = new Location(world.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ()); ++ List 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 - } else if (world.getType(blockposition).getBlock() == Blocks.TNT) { - Blocks.TNT.postBreak(world, blockposition, Blocks.TNT.getBlockData().set(BlockTNT.EXPLODE, Boolean.valueOf(true))); - world.setAir(blockposition); -@@ -240,6 +438,32 @@ - World world = isourceblock.getWorld(); - BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.e().get(BlockDispenser.FACING)); ++ } ++ } ++ // CraftBukkit end -+ // 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.a(isourceblock, eventStack); -+ return itemstack; -+ } -+ } -+ -+ world.captureTreeGeneration = true; -+ // CraftBukkit end -+ - if (ItemDye.a(itemstack, world, blockposition)) { - if (!world.isClientSide) { - world.triggerEffect(2005, blockposition, 0); -@@ -247,6 +471,26 @@ - } else { - this.b = false; - } -+ // CraftBukkit start -+ world.captureTreeGeneration = false; -+ if (world.capturedBlockStates.size() > 0) { -+ TreeType treeType = BlockSapling.treeType; -+ BlockSapling.treeType = null; -+ Location location = new Location(world.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ()); -+ List 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; - } else { -@@ -258,11 +502,40 @@ - protected ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) { + return itemstack; + } +@@ -268,11 +499,40 @@ + protected ItemStack a(ISourceBlock isourceblock, ItemStack itemstack) { World world = isourceblock.getWorld(); BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.e().get(BlockDispenser.FACING)); - EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(world, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, (EntityLiving) null); @@ -386,7 +371,7 @@ + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); + if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { -+ idispensebehavior.a(isourceblock, eventStack); ++ idispensebehavior.dispense(isourceblock, eventStack); + return itemstack; + } + } @@ -395,15 +380,15 @@ + // CraftBukkit end world.addEntity(entitytntprimed); - world.a((EntityHuman) null, entitytntprimed.locX, entitytntprimed.locY, entitytntprimed.locZ, SoundEffects.hW, SoundCategory.BLOCKS, 1.0F, 1.0F); + world.a((EntityHuman) null, entitytntprimed.locX, entitytntprimed.locY, entitytntprimed.locZ, SoundEffects.ENTITY_TNT_PRIMED, SoundCategory.BLOCKS, 1.0F, 1.0F); - itemstack.subtract(1); + // itemstack.subtract(1); // CraftBukkit - handled above return itemstack; } - }); -@@ -273,6 +546,30 @@ + })); +@@ -294,6 +554,30 @@ + EnumDirection enumdirection = (EnumDirection) isourceblock.e().get(BlockDispenser.FACING); BlockPosition blockposition = isourceblock.getBlockPosition().shift(enumdirection); - BlockSkull blockskull = Blocks.SKULL; + // CraftBukkit start + org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); @@ -423,18 +408,18 @@ + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); + if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { -+ idispensebehavior.a(isourceblock, eventStack); ++ idispensebehavior.dispense(isourceblock, eventStack); + return itemstack; + } + } + // CraftBukkit end + - this.b = true; - if (world.isEmpty(blockposition) && blockskull.b(world, blockposition, itemstack)) { - if (!world.isClientSide) { -@@ -321,6 +618,30 @@ + this.a = true; + if (world.isEmpty(blockposition) && BlockWitherSkull.b(world, blockposition, itemstack)) { + world.setTypeAndData(blockposition, (IBlockData) Blocks.WITHER_SKELETON_SKULL.getBlockData().set(BlockSkull.a, Integer.valueOf(enumdirection.opposite().get2DRotationValue() * 4)), 3); +@@ -317,6 +601,30 @@ BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.e().get(BlockDispenser.FACING)); - BlockPumpkin blockpumpkin = (BlockPumpkin) Blocks.PUMPKIN; + BlockPumpkinCarved blockpumpkincarved = (BlockPumpkinCarved) Blocks.CARVED_PUMPKIN; + // CraftBukkit start + org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); @@ -454,47 +439,108 @@ + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); + if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { -+ idispensebehavior.a(isourceblock, eventStack); ++ idispensebehavior.dispense(isourceblock, eventStack); + return itemstack; + } + } + // CraftBukkit end + - this.b = true; - if (world.isEmpty(blockposition) && blockpumpkin.b(world, blockposition)) { + this.a = true; + if (world.isEmpty(blockposition) && blockpumpkincarved.a((IWorldReader) world, blockposition)) { if (!world.isClientSide) { -@@ -407,6 +728,30 @@ - EnumDirection enumdirection = (EnumDirection) isourceblock.e().get(BlockDispenser.FACING); - BlockPosition blockposition = isourceblock.getBlockPosition().shift(enumdirection); +@@ -378,6 +686,51 @@ + } -+ // CraftBukkit start -+ org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); -+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack); + d(); ++ // CraftBukkit start - easier than fixing the decompile ++ DataConverterFlattenData.a(1440, "{Name:\'minecraft:portal\',Properties:{axis:\'x\'}}", new String[]{"{Name:\'minecraft:portal\',Properties:{axis:\'x\'}}"}); + -+ 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); -+ } ++ DataConverterMaterialId.ID_MAPPING.put(409, "minecraft:prismarine_shard"); ++ DataConverterMaterialId.ID_MAPPING.put(410, "minecraft:prismarine_crystals"); ++ DataConverterMaterialId.ID_MAPPING.put(411, "minecraft:rabbit"); ++ DataConverterMaterialId.ID_MAPPING.put(412, "minecraft:cooked_rabbit"); ++ DataConverterMaterialId.ID_MAPPING.put(413, "minecraft:rabbit_stew"); ++ DataConverterMaterialId.ID_MAPPING.put(414, "minecraft:rabbit_foot"); ++ DataConverterMaterialId.ID_MAPPING.put(415, "minecraft:rabbit_hide"); ++ DataConverterMaterialId.ID_MAPPING.put(416, "minecraft:armor_stand"); + -+ if (event.isCancelled()) { -+ return itemstack; -+ } ++ DataConverterMaterialId.ID_MAPPING.put(423, "minecraft:mutton"); ++ DataConverterMaterialId.ID_MAPPING.put(424, "minecraft:cooked_mutton"); ++ DataConverterMaterialId.ID_MAPPING.put(425, "minecraft:banner"); ++ DataConverterMaterialId.ID_MAPPING.put(426, "minecraft:end_crystal"); ++ DataConverterMaterialId.ID_MAPPING.put(427, "minecraft:spruce_door"); ++ DataConverterMaterialId.ID_MAPPING.put(428, "minecraft:birch_door"); ++ DataConverterMaterialId.ID_MAPPING.put(429, "minecraft:jungle_door"); ++ DataConverterMaterialId.ID_MAPPING.put(430, "minecraft:acacia_door"); ++ DataConverterMaterialId.ID_MAPPING.put(431, "minecraft:dark_oak_door"); ++ DataConverterMaterialId.ID_MAPPING.put(432, "minecraft:chorus_fruit"); ++ DataConverterMaterialId.ID_MAPPING.put(433, "minecraft:chorus_fruit_popped"); ++ DataConverterMaterialId.ID_MAPPING.put(434, "minecraft:beetroot"); ++ DataConverterMaterialId.ID_MAPPING.put(435, "minecraft:beetroot_seeds"); ++ DataConverterMaterialId.ID_MAPPING.put(436, "minecraft:beetroot_soup"); ++ DataConverterMaterialId.ID_MAPPING.put(437, "minecraft:dragon_breath"); ++ DataConverterMaterialId.ID_MAPPING.put(438, "minecraft:splash_potion"); ++ DataConverterMaterialId.ID_MAPPING.put(439, "minecraft:spectral_arrow"); ++ DataConverterMaterialId.ID_MAPPING.put(440, "minecraft:tipped_arrow"); ++ DataConverterMaterialId.ID_MAPPING.put(441, "minecraft:lingering_potion"); ++ DataConverterMaterialId.ID_MAPPING.put(442, "minecraft:shield"); ++ DataConverterMaterialId.ID_MAPPING.put(443, "minecraft:elytra"); ++ DataConverterMaterialId.ID_MAPPING.put(444, "minecraft:spruce_boat"); ++ DataConverterMaterialId.ID_MAPPING.put(445, "minecraft:birch_boat"); ++ DataConverterMaterialId.ID_MAPPING.put(446, "minecraft:jungle_boat"); ++ DataConverterMaterialId.ID_MAPPING.put(447, "minecraft:acacia_boat"); ++ DataConverterMaterialId.ID_MAPPING.put(448, "minecraft:dark_oak_boat"); ++ DataConverterMaterialId.ID_MAPPING.put(449, "minecraft:totem_of_undying"); ++ DataConverterMaterialId.ID_MAPPING.put(450, "minecraft:shulker_shell"); ++ DataConverterMaterialId.ID_MAPPING.put(452, "minecraft:iron_nugget"); ++ DataConverterMaterialId.ID_MAPPING.put(453, "minecraft:knowledge_book"); + -+ if (!event.getItem().equals(craftItem)) { -+ // Chain to handler for new item -+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); -+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); -+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { -+ idispensebehavior.a(isourceblock, eventStack); ++ DataConverterSpawnEgg.ID_MAPPING[23] = "Arrow"; ++ // CraftBukkit end + } + } + } +@@ -386,7 +739,7 @@ + LocaleLanguage localelanguage = LocaleLanguage.a(); + + registrymaterials.iterator().forEachRemaining((object) -> { +- String s = (String) function.apply(object); ++ String s1 = (String) function.apply(object); // CraftBukkit - decompile error + + if (!localelanguage.b(s)) { + DispenserRegistry.c.warn("Missing translation for {}: {} (key: \'{}\')", s1, registrymaterials.b(object), s); +@@ -480,6 +833,30 @@ + BlockPosition blockposition = isourceblock.getBlockPosition().shift(enumdirection); + EnumDirection enumdirection1 = isourceblock.getWorld().isEmpty(blockposition.down()) ? enumdirection : EnumDirection.UP; + ++ // CraftBukkit start ++ org.bukkit.block.Block bukkitBlock = isourceblock.getWorld().getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); ++ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack); ++ ++ 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; + } -+ } -+ // CraftBukkit end + - this.b = world.a(block, blockposition, false, EnumDirection.DOWN, (Entity) null); - if (this.b) { - EnumDirection enumdirection1 = world.isEmpty(blockposition.down()) ? enumdirection : EnumDirection.UP; -@@ -475,12 +820,40 @@ ++ if (!event.getItem().equals(craftItem)) { ++ // Chain to handler for new item ++ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); ++ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); ++ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { ++ idispensebehavior.dispense(isourceblock, eventStack); ++ return itemstack; ++ } ++ } ++ // CraftBukkit end ++ + this.a = ((ItemBlock) item).a((BlockActionContext) (new DispenserRegistry.b(isourceblock.getWorld(), blockposition, enumdirection, itemstack, enumdirection1))) == EnumInteractionResult.SUCCESS; + if (this.a) { + itemstack.subtract(1); +@@ -533,12 +910,40 @@ d3 = 0.0D; } @@ -521,7 +567,7 @@ + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); + if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { -+ idispensebehavior.a(isourceblock, eventStack); ++ idispensebehavior.dispense(isourceblock, eventStack); + return itemstack; + } + } @@ -529,7 +575,7 @@ + EntityBoat entityboat = new EntityBoat(world, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ()); + // CraftBukkit end - entityboat.setType(this.c); + entityboat.setType(this.b); entityboat.yaw = enumdirection.l(); - world.addEntity(entityboat); - itemstack.subtract(1); diff --git a/paper-server/nms-patches/Enchantment.patch b/paper-server/nms-patches/Enchantment.patch index 498dc96544..259916040f 100644 --- a/paper-server/nms-patches/Enchantment.patch +++ b/paper-server/nms-patches/Enchantment.patch @@ -1,18 +1,27 @@ --- a/net/minecraft/server/Enchantment.java +++ b/net/minecraft/server/Enchantment.java -@@ -20,7 +20,7 @@ - } - - public static int getId(Enchantment enchantment) { -- return Enchantment.enchantments.a((Object) enchantment); -+ return Enchantment.enchantments.a(enchantment); // CraftBukkit - fix decompile error - } - +@@ -15,6 +15,17 @@ @Nullable -@@ -155,6 +155,11 @@ - Enchantment.enchantments.a(62, new MinecraftKey("lure"), new EnchantmentLure(Enchantment.Rarity.RARE, EnchantmentSlotType.FISHING_ROD, new EnumItemSlot[] { EnumItemSlot.MAINHAND})); - Enchantment.enchantments.a(70, new MinecraftKey("mending"), new EnchantmentMending(Enchantment.Rarity.RARE, EnumItemSlot.values())); - Enchantment.enchantments.a(71, new MinecraftKey("vanishing_curse"), new EnchantmentVanishing(Enchantment.Rarity.VERY_RARE, EnumItemSlot.values())); + protected String d; + ++ // CraftBukkit start - add back ++ @Nullable ++ public static Enchantment fromId(MinecraftKey key) { ++ return Enchantment.enchantments.get(key); ++ } ++ ++ public static MinecraftKey getId(Enchantment enchantment) { ++ return Enchantment.enchantments.b(enchantment); ++ } ++ // CraftBukkit end ++ + protected Enchantment(Enchantment.Rarity enchantment_rarity, EnchantmentSlotType enchantmentslottype, EnumItemSlot[] aenumitemslot) { + this.e = enchantment_rarity; + this.itemTarget = enchantmentslottype; +@@ -153,6 +164,11 @@ + a("channeling", new EnchantmentTridentChanneling(Enchantment.Rarity.VERY_RARE, new EnumItemSlot[] { EnumItemSlot.MAINHAND})); + a("mending", new EnchantmentMending(Enchantment.Rarity.RARE, EnumItemSlot.values())); + a("vanishing_curse", new EnchantmentVanishing(Enchantment.Rarity.VERY_RARE, EnumItemSlot.values())); + // CraftBukkit start + for (Object enchantment : Enchantment.enchantments) { + org.bukkit.enchantments.Enchantment.registerEnchantment(new org.bukkit.craftbukkit.enchantments.CraftEnchantment((Enchantment) enchantment)); @@ -20,4 +29,4 @@ + // CraftBukkit end } - public static enum Rarity { + private static void a(String s, Enchantment enchantment) { diff --git a/paper-server/nms-patches/EnchantmentFrostWalker.patch b/paper-server/nms-patches/EnchantmentFrostWalker.patch index c4f9f2b8db..5ebd39a38b 100644 --- a/paper-server/nms-patches/EnchantmentFrostWalker.patch +++ b/paper-server/nms-patches/EnchantmentFrostWalker.patch @@ -10,14 +10,14 @@ public class EnchantmentFrostWalker extends Enchantment { @@ -42,8 +45,11 @@ - IBlockData iblockdata1 = world.getType(blockposition_mutableblockposition1); + IBlockData iblockdata2 = world.getType(blockposition_mutableblockposition1); - if (iblockdata1.getMaterial() == Material.WATER && ((Integer) iblockdata1.get(BlockFluids.LEVEL)).intValue() == 0 && world.a(Blocks.FROSTED_ICE, blockposition_mutableblockposition1, false, EnumDirection.DOWN, (Entity) null)) { -- world.setTypeUpdate(blockposition_mutableblockposition1, Blocks.FROSTED_ICE.getBlockData()); -- world.a(blockposition_mutableblockposition1.h(), Blocks.FROSTED_ICE, MathHelper.nextInt(entityliving.getRandom(), 60, 120)); + if (iblockdata2.getMaterial() == Material.WATER && ((Integer) iblockdata2.get(BlockFluids.LEVEL)).intValue() == 0 && iblockdata.canPlace(world, blockposition_mutableblockposition1) && world.a(iblockdata, (BlockPosition) blockposition_mutableblockposition1)) { +- world.setTypeUpdate(blockposition_mutableblockposition1, iblockdata); +- world.I().a(blockposition_mutableblockposition1.h(), Blocks.FROSTED_ICE, MathHelper.nextInt(entityliving.getRandom(), 60, 120)); + // CraftBukkit Start - Call EntityBlockFormEvent for Frost Walker -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition_mutableblockposition1, Blocks.FROSTED_ICE.getBlockData(), entityliving)) { -+ world.a(blockposition_mutableblockposition1.h(), Blocks.FROSTED_ICE, MathHelper.nextInt(entityliving.getRandom(), 60, 120)); ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition_mutableblockposition1, iblockdata, entityliving)) { ++ world.I().a(blockposition_mutableblockposition1.h(), Blocks.FROSTED_ICE, MathHelper.nextInt(entityliving.getRandom(), 60, 120)); + } + // CraftBukkit End } diff --git a/paper-server/nms-patches/EnchantmentThorns.patch b/paper-server/nms-patches/EnchantmentThorns.patch index 82ffbcd932..8f997f9e5b 100644 --- a/paper-server/nms-patches/EnchantmentThorns.patch +++ b/paper-server/nms-patches/EnchantmentThorns.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/EnchantmentThorns.java +++ b/net/minecraft/server/EnchantmentThorns.java -@@ -29,7 +29,7 @@ +@@ -28,7 +28,7 @@ Random random = entityliving.getRandom(); ItemStack itemstack = EnchantmentManager.b(Enchantments.THORNS, entityliving); diff --git a/paper-server/nms-patches/Entity.patch b/paper-server/nms-patches/Entity.patch index 39777cd1a3..b7bc2f619f 100644 --- a/paper-server/nms-patches/Entity.patch +++ b/paper-server/nms-patches/Entity.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/Entity.java +++ b/net/minecraft/server/Entity.java -@@ -16,8 +16,48 @@ +@@ -19,8 +19,54 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -10,6 +10,7 @@ +import org.bukkit.Server; +import org.bukkit.TravelAgent; +import org.bukkit.block.BlockFace; ++import org.bukkit.command.CommandSender; +import org.bukkit.entity.Hanging; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Vehicle; @@ -28,7 +29,7 @@ +import org.bukkit.plugin.PluginManager; +// CraftBukkit end + - public abstract class Entity implements ICommandListener { + public abstract class Entity implements INamableTileEntity, ICommandListener { + // CraftBukkit start + private static final int CURRENT_LEVEL = 2; @@ -44,15 +45,20 @@ + } + return bukkitEntity; + } -+ // CraftBukikt end + - private static final Logger a = LogManager.getLogger(); - private static final List b = Collections.emptyList(); - private static final AxisAlignedBB c = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D); -@@ -102,6 +142,15 @@ - private boolean aI; - private final double[] aJ; - private long aK; ++ @Override ++ public CommandSender getBukkitSender(CommandListenerWrapper wrapper) { ++ return getBukkitEntity(); ++ } ++ // CraftBukkit end ++ + protected static final Logger i = LogManager.getLogger(); + private static final List a = Collections.emptyList(); + private static final AxisAlignedBB b = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D); +@@ -107,6 +153,15 @@ + private boolean aK; + private final double[] aL; + private long aM; + // CraftBukkit start + public boolean valid; + public org.bukkit.projectiles.ProjectileSource projectileSource; // For projectiles only @@ -63,9 +69,9 @@ + } + // CraftBukkit end - public Entity(World world) { + public Entity(EntityTypes entitytypes, World world) { this.id = Entity.entityCount++; -@@ -208,6 +257,33 @@ +@@ -212,6 +267,33 @@ } protected void setYawPitch(float f, float f1) { @@ -99,8 +105,8 @@ this.yaw = f % 360.0F; this.pitch = f1 % 360.0F; } -@@ -230,6 +306,51 @@ - this.Y(); +@@ -234,6 +316,51 @@ + this.W(); } + // CraftBukkit start @@ -108,16 +114,16 @@ + // No clean way to break out of ticking once the entity has been copied to a new world, so instead we move the portalling later in the tick cycle + if (!this.world.isClientSide && this.world instanceof WorldServer) { + this.world.methodProfiler.a("portal"); -+ if (this.ak) { ++ if (this.an) { + MinecraftServer minecraftserver = this.world.getMinecraftServer(); + + if (true || minecraftserver.getAllowNether()) { // CraftBukkit + if (!this.isPassenger()) { -+ int i = this.Z(); ++ int i = this.X(); + -+ if (this.al++ >= i) { -+ this.al = i; -+ this.portalCooldown = this.aM(); ++ if (this.ao++ >= i) { ++ this.ao = i; ++ this.portalCooldown = this.aQ(); + byte b0; + + if (this.world.worldProvider.getDimensionManager().getDimensionID() == -1) { @@ -126,32 +132,32 @@ + b0 = -1; + } + -+ this.b(b0); ++ this.d(b0); + } + } + -+ this.ak = false; ++ this.an = false; + } + } else { -+ if (this.al > 0) { -+ this.al -= 4; ++ if (this.ao > 0) { ++ this.ao -= 4; + } + -+ if (this.al < 0) { -+ this.al = 0; ++ if (this.ao < 0) { ++ this.ao = 0; + } + } + -+ this.I(); -+ this.world.methodProfiler.b(); ++ this.E(); ++ this.world.methodProfiler.e(); + } + } + // CraftBukkit end + - public void Y() { + public void W() { this.world.methodProfiler.a("entityBaseTick"); - if (this.isPassenger() && this.bJ().dead) { -@@ -246,6 +367,8 @@ + if (this.isPassenger() && this.getVehicle().dead) { +@@ -250,6 +377,8 @@ this.lastZ = this.locZ; this.lastPitch = this.pitch; this.lastYaw = this.yaw; @@ -159,16 +165,16 @@ + /* if (!this.world.isClientSide && this.world instanceof WorldServer) { this.world.methodProfiler.a("portal"); - if (this.ak) { -@@ -285,6 +408,7 @@ - this.I(); - this.world.methodProfiler.b(); + if (this.an) { +@@ -289,6 +418,7 @@ + this.E(); + this.world.methodProfiler.e(); } + */ - this.as(); - this.aq(); -@@ -336,6 +460,27 @@ + this.av(); + this.r(); +@@ -340,6 +470,27 @@ protected void burnFromLava() { if (!this.fireProof) { this.damageEntity(DamageSource.LAVA, 4.0F); @@ -196,7 +202,7 @@ this.setOnFire(15); } } -@@ -376,6 +521,22 @@ +@@ -378,6 +529,22 @@ this.a(this.getBoundingBox().d(d0, d1, d2)); this.recalcPosition(); } else { @@ -219,7 +225,7 @@ if (enummovetype == EnumMoveType.PISTON) { long i = this.world.getTime(); -@@ -517,7 +678,7 @@ +@@ -505,7 +672,7 @@ } } @@ -227,18 +233,18 @@ + boolean flag = this.onGround || d1 != d8 && d1 < 0.0D; // CraftBukkit - decompile error double d11; - if (this.P > 0.0F && flag && (d7 != d0 || d9 != d2)) { -@@ -615,7 +776,7 @@ + if (this.Q > 0.0F && flag && (d7 != d0 || d9 != d2)) { +@@ -592,7 +759,7 @@ this.world.methodProfiler.a("rest"); this.recalcPosition(); this.positionChanged = d7 != d0 || d9 != d2; -- this.B = d1 != d1; -+ this.B = d1 != d8; // CraftBukkit - decompile error - this.onGround = this.B && d8 < 0.0D; - this.C = this.positionChanged || this.B; - l = MathHelper.floor(this.locX); -@@ -650,6 +811,28 @@ - block1.a(this.world, this); +- this.C = d1 != d1; ++ this.C = d1 != d8; // CraftBukkit - decompile error + this.onGround = this.C && d8 < 0.0D; + this.D = this.positionChanged || this.C; + int k = MathHelper.floor(this.locX); +@@ -627,6 +794,28 @@ + block1.a((IBlockAccess) this.world, this); } + // CraftBukkit start @@ -266,7 +272,7 @@ if (this.playStepSound() && (!this.onGround || !this.isSneaking() || !(this instanceof EntityHuman)) && !this.isPassenger()) { double d22 = this.locX - d4; double d23 = this.locY - d5; -@@ -685,6 +868,8 @@ +@@ -662,6 +851,8 @@ } } @@ -275,16 +281,16 @@ try { this.checkBlockCollisions(); } catch (Throwable throwable) { -@@ -694,6 +879,8 @@ +@@ -671,6 +862,8 @@ this.appendEntityCrashDetails(crashreportsystemdetails); throw new ReportedException(crashreport); } + */ + // CraftBukkit end - boolean flag1 = this.an(); + boolean flag1 = this.ap(); -@@ -702,7 +889,14 @@ +@@ -679,7 +872,14 @@ if (!flag1) { ++this.fireTicks; if (this.fireTicks == 0) { @@ -300,7 +306,7 @@ } } } else if (this.fireTicks <= 0) { -@@ -834,7 +1028,7 @@ +@@ -875,7 +1075,7 @@ return null; } @@ -309,7 +315,7 @@ if (!this.fireProof) { this.damageEntity(DamageSource.FIRE, (float) i); } -@@ -1008,6 +1202,13 @@ +@@ -1094,6 +1294,13 @@ } public void spawnIn(World world) { @@ -323,7 +329,7 @@ this.world = world; } -@@ -1245,6 +1446,18 @@ +@@ -1318,6 +1525,18 @@ try { nbttagcompound.set("Pos", this.a(new double[] { this.locX, this.locY, this.locZ})); nbttagcompound.set("Motion", this.a(new double[] { this.motX, this.motY, this.motZ})); @@ -342,7 +348,7 @@ nbttagcompound.set("Rotation", this.a(new float[] { this.yaw, this.pitch})); nbttagcompound.setFloat("FallDistance", this.fallDistance); nbttagcompound.setShort("Fire", (short) this.fireTicks); -@@ -1254,6 +1467,12 @@ +@@ -1327,6 +1546,12 @@ nbttagcompound.setBoolean("Invulnerable", this.invulnerable); nbttagcompound.setInt("PortalCooldown", this.portalCooldown); nbttagcompound.a("UUID", this.getUniqueID()); @@ -352,27 +358,27 @@ + nbttagcompound.setLong("WorldUUIDMost", this.world.getDataManager().getUUID().getMostSignificantBits()); + nbttagcompound.setInt("Bukkit.updateLevel", CURRENT_LEVEL); + // CraftBukkit end - if (this.hasCustomName()) { - nbttagcompound.setString("CustomName", this.getCustomName()); - } -@@ -1329,6 +1548,8 @@ - this.motX = nbttaglist1.f(0); - this.motY = nbttaglist1.f(1); - this.motZ = nbttaglist1.f(2); + IChatBaseComponent ichatbasecomponent = this.getCustomName(); + + if (ichatbasecomponent != null) { +@@ -1403,6 +1628,8 @@ + this.motX = nbttaglist1.k(0); + this.motY = nbttaglist1.k(1); + this.motZ = nbttaglist1.k(2); + + /* CraftBukkit start - Moved section down if (Math.abs(this.motX) > 10.0D) { this.motX = 0.0D; } -@@ -1340,6 +1561,7 @@ +@@ -1414,6 +1641,7 @@ if (Math.abs(this.motZ) > 10.0D) { this.motZ = 0.0D; } + // CraftBukkit end */ - this.locX = nbttaglist.f(0); - this.locY = nbttaglist.f(1); -@@ -1397,6 +1619,57 @@ + this.locX = nbttaglist.k(0); + this.locY = nbttaglist.k(1); +@@ -1470,6 +1698,57 @@ this.setPosition(this.locX, this.locY, this.locZ); } @@ -430,7 +436,7 @@ } catch (Throwable throwable) { CrashReport crashreport = CrashReport.a(throwable, "Loading entity NBT"); CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Entity being loaded"); -@@ -1464,6 +1737,12 @@ +@@ -1543,6 +1822,12 @@ if (itemstack.isEmpty()) { return null; } else { @@ -442,9 +448,9 @@ + // CraftBukkit end EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY + (double) f, this.locZ, itemstack); - entityitem.q(); -@@ -1589,6 +1868,24 @@ - if (entity.bJ() != this) { + entityitem.n(); +@@ -1687,6 +1972,24 @@ + if (entity.getVehicle() != this) { throw new IllegalStateException("Use x.startRiding(y), not y.addPassenger(x)"); } else { + // CraftBukkit start @@ -465,11 +471,11 @@ + } + } + // CraftBukkit end - if (!this.world.isClientSide && entity instanceof EntityHuman && !(this.bE() instanceof EntityHuman)) { + if (!this.world.isClientSide && entity instanceof EntityHuman && !(this.bO() instanceof EntityHuman)) { this.passengers.add(0, entity); } else { -@@ -1602,6 +1899,22 @@ - if (entity.bJ() == this) { +@@ -1700,6 +2003,22 @@ + if (entity.getVehicle() == this) { throw new IllegalStateException("Use x.stopRiding(y), not y.removePassenger(x)"); } else { + // CraftBukkit start @@ -489,20 +495,20 @@ + } + // CraftBukkit end this.passengers.remove(entity); - entity.j = 60; + entity.k = 60; } -@@ -1741,14 +2054,49 @@ +@@ -1859,14 +2178,49 @@ } public void setAirTicks(int i) { -- this.datawatcher.set(Entity.aA, Integer.valueOf(i)); +- this.datawatcher.set(Entity.aD, Integer.valueOf(i)); + // CraftBukkit start + EntityAirChangeEvent event = new EntityAirChangeEvent(this.getBukkitEntity(), i); + event.getEntity().getServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { + return; + } -+ this.datawatcher.set(Entity.aA, Integer.valueOf(event.getAmount())); ++ this.datawatcher.set(Entity.aD, Integer.valueOf(event.getAmount())); + // CraftBukkit end } @@ -544,10 +550,10 @@ } } -@@ -1893,19 +2241,76 @@ +@@ -2035,19 +2389,76 @@ if (!this.world.isClientSide && !this.dead) { this.world.methodProfiler.a("changeDimension"); - MinecraftServer minecraftserver = this.C_(); + MinecraftServer minecraftserver = this.bK(); - int j = this.dimension; - WorldServer worldserver = minecraftserver.getWorldServer(j); - WorldServer worldserver1 = minecraftserver.getWorldServer(i); @@ -596,7 +602,7 @@ + + // Need to make sure the profiler state is reset afterwards (but we still want to time the call) + Entity entity = this.teleportTo(exit, true); -+ this.world.methodProfiler.b(); ++ this.world.methodProfiler.e(); + return entity; + } + return null; @@ -612,7 +618,7 @@ this.dimension = i; + /* CraftBukkit start - TODO: Check if we need this if (j == 1 && i == 1) { - worldserver1 = minecraftserver.getWorldServer(0); + worldserver1 = minecraftserver.a(DimensionManager.OVERWORLD); this.dimension = 0; } + // CraftBukkit end */ @@ -624,7 +630,7 @@ BlockPosition blockposition; if (i == 1) { -@@ -1934,12 +2339,18 @@ +@@ -2076,12 +2487,18 @@ blockposition = new BlockPosition(this); } @@ -636,15 +642,15 @@ + // worldserver.entityJoinedWorld(this, false); // Handled in repositionEntity + // CraftBukkit end this.world.methodProfiler.c("reloading"); - Entity entity = EntityTypes.a(this.getClass(), (World) worldserver1); + Entity entity = this.P().a((World) worldserver1); if (entity != null) { - entity.a(this); + entity.v(this); + /* CraftBukkit start - We need to do this... if (j == 1 && i == 1) { - BlockPosition blockposition1 = worldserver1.q(worldserver1.getSpawn()); + BlockPosition blockposition1 = worldserver1.getHighestBlockYAt(HeightMap.Type.MOTION_BLOCKING_NO_LEAVES, worldserver1.getSpawn()); -@@ -1947,6 +2358,7 @@ +@@ -2089,6 +2506,7 @@ } else { entity.setPositionRotation(blockposition, entity.yaw, entity.pitch); } @@ -652,7 +658,7 @@ boolean flag = entity.attachedToPlayer; -@@ -1954,13 +2366,21 @@ +@@ -2096,13 +2514,21 @@ worldserver1.addEntity(entity); entity.attachedToPlayer = flag; worldserver1.entityJoinedWorld(entity, false); @@ -667,27 +673,15 @@ } this.dead = true; - this.world.methodProfiler.b(); - worldserver.m(); - worldserver1.m(); -- this.world.methodProfiler.b(); -+ // this.world.methodProfiler.b(); // CraftBukkit: Moved up to keep balanced + this.world.methodProfiler.e(); + worldserver.q_(); + worldserver1.q_(); +- this.world.methodProfiler.e(); ++ // this.world.methodProfiler.e(); // CraftBukkit: Moved up to keep balanced return entity; } else { return null; -@@ -2064,6 +2484,11 @@ - } - - public void setCustomName(String s) { -+ // CraftBukkit start - Add a sane limit for name length -+ if (s.length() > 256) { -+ s = s.substring(0, 256); -+ } -+ // CraftBukkit end - this.datawatcher.set(Entity.aB, s); - } - -@@ -2121,7 +2546,26 @@ +@@ -2242,7 +2668,26 @@ } public void a(AxisAlignedBB axisalignedbb) { @@ -715,12 +709,3 @@ } public float getHeadHeight() { -@@ -2295,7 +2739,7 @@ - for (Iterator iterator = this.bF().iterator(); iterator.hasNext(); entity.a(oclass, set)) { - entity = (Entity) iterator.next(); - if (oclass.isAssignableFrom(entity.getClass())) { -- set.add(entity); -+ set.add((T) entity); // CraftBukkit - decompile error - } - } - diff --git a/paper-server/nms-patches/EntityAgeable.patch b/paper-server/nms-patches/EntityAgeable.patch index 5800328e0d..02e44b5424 100644 --- a/paper-server/nms-patches/EntityAgeable.patch +++ b/paper-server/nms-patches/EntityAgeable.patch @@ -2,22 +2,22 @@ +++ b/net/minecraft/server/EntityAgeable.java @@ -10,6 +10,7 @@ protected int c; - private float by = -1.0F; - private float bz; + private float bD = -1.0F; + private float bE; + public boolean ageLocked; // CraftBukkit - public EntityAgeable(World world) { - super(world); -@@ -31,7 +32,7 @@ - if (entityageable != null) { - entityageable.setAgeRaw(-24000); - entityageable.setPositionRotation(this.locX, this.locY, this.locZ, 0.0F, 0.0F); -- this.world.addEntity(entityageable); -+ this.world.addEntity(entityageable, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG); // CraftBukkit - if (itemstack.hasName()) { - entityageable.setCustomName(itemstack.getName()); - } -@@ -110,12 +111,14 @@ + protected EntityAgeable(EntityTypes entitytypes, World world) { + super(entitytypes, world); +@@ -29,7 +30,7 @@ + if (entityageable != null) { + entityageable.setAgeRaw(-24000); + entityageable.setPositionRotation(this.locX, this.locY, this.locZ, 0.0F, 0.0F); +- this.world.addEntity(entityageable); ++ this.world.addEntity(entityageable, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG); // CraftBukkit + if (itemstack.hasName()) { + entityageable.setCustomName(itemstack.getName()); + } +@@ -97,12 +98,14 @@ super.b(nbttagcompound); nbttagcompound.setInt("Age", this.getAge()); nbttagcompound.setInt("ForcedAge", this.b); @@ -32,12 +32,12 @@ } public void a(DataWatcherObject datawatcherobject) { -@@ -128,7 +131,7 @@ +@@ -115,7 +118,7 @@ - public void n() { - super.n(); + public void k() { + super.k(); - if (this.world.isClientSide) { + if (this.world.isClientSide || ageLocked) { // CraftBukkit if (this.c > 0) { if (this.c % 4 == 0) { - this.world.addParticle(EnumParticle.VILLAGER_HAPPY, this.locX + (double) (this.random.nextFloat() * this.width * 2.0F) - (double) this.width, this.locY + 0.5D + (double) (this.random.nextFloat() * this.length), this.locZ + (double) (this.random.nextFloat() * this.width * 2.0F) - (double) this.width, 0.0D, 0.0D, 0.0D, new int[0]); + this.world.addParticle(Particles.z, this.locX + (double) (this.random.nextFloat() * this.width * 2.0F) - (double) this.width, this.locY + 0.5D + (double) (this.random.nextFloat() * this.length), this.locZ + (double) (this.random.nextFloat() * this.width * 2.0F) - (double) this.width, 0.0D, 0.0D, 0.0D); diff --git a/paper-server/nms-patches/EntityAnimal.patch b/paper-server/nms-patches/EntityAnimal.patch index 80469e67d4..a095cddf81 100644 --- a/paper-server/nms-patches/EntityAnimal.patch +++ b/paper-server/nms-patches/EntityAnimal.patch @@ -1,13 +1,13 @@ --- a/net/minecraft/server/EntityAnimal.java +++ b/net/minecraft/server/EntityAnimal.java @@ -8,6 +8,7 @@ - protected Block bA; - private int bx; - private UUID by; + protected Block bF; + private int bC; + private UUID bD; + public ItemStack breedItem; // CraftBukkit - Add breedItem variable - public EntityAnimal(World world) { - super(world); + protected EntityAnimal(EntityTypes entitytypes, World world) { + super(entitytypes, world); @@ -41,6 +42,9 @@ } @@ -24,11 +24,11 @@ } + // CraftBukkit end */ - public float a(BlockPosition blockposition) { - return this.world.getType(blockposition.down()).getBlock() == this.bA ? 10.0F : this.world.n(blockposition) - 0.5F; -@@ -130,6 +135,7 @@ + public float a(BlockPosition blockposition, IWorldReader iworldreader) { + return iworldreader.getType(blockposition.down()).getBlock() == this.bF ? 10.0F : iworldreader.A(blockposition) - 0.5F; +@@ -134,6 +139,7 @@ if (entityhuman != null) { - this.by = entityhuman.getUniqueID(); + this.bD = entityhuman.getUniqueID(); } + this.breedItem = entityhuman.inventory.getItemInHand(); // CraftBukkit diff --git a/paper-server/nms-patches/EntityAreaEffectCloud.patch b/paper-server/nms-patches/EntityAreaEffectCloud.patch index c5009a553f..ab14a3ca41 100644 --- a/paper-server/nms-patches/EntityAreaEffectCloud.patch +++ b/paper-server/nms-patches/EntityAreaEffectCloud.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/EntityAreaEffectCloud.java +++ b/net/minecraft/server/EntityAreaEffectCloud.java -@@ -8,6 +8,10 @@ +@@ -10,6 +10,10 @@ import java.util.List; import java.util.Map; import java.util.UUID; @@ -10,15 +10,15 @@ + import java.util.Map.Entry; import javax.annotation.Nullable; - -@@ -101,6 +105,22 @@ + import org.apache.logging.log4j.LogManager; +@@ -102,6 +106,22 @@ } + // CraftBukkit start accessor methods + public void refreshEffects() { + if (!this.hasColor) { -+ this.getDataWatcher().set(EntityAreaEffectCloud.b, Integer.valueOf(PotionUtil.a((Collection) PotionUtil.a(this.potionRegistry, (Collection) this.effects)))); // PAIL: rename ++ this.getDataWatcher().set(EntityAreaEffectCloud.c, Integer.valueOf(PotionUtil.a((Collection) PotionUtil.a(this.potionRegistry, (Collection) this.effects)))); // PAIL: rename + } + } + @@ -32,9 +32,9 @@ + // CraftBukkit end + public int getColor() { - return ((Integer) this.getDataWatcher().get(EntityAreaEffectCloud.b)).intValue(); + return ((Integer) this.getDataWatcher().get(EntityAreaEffectCloud.c)).intValue(); } -@@ -270,6 +290,7 @@ +@@ -245,6 +265,7 @@ if (!list.isEmpty()) { Iterator iterator2 = list.iterator(); @@ -42,7 +42,7 @@ while (iterator2.hasNext()) { EntityLiving entityliving = (EntityLiving) iterator2.next(); -@@ -279,6 +300,17 @@ +@@ -254,6 +275,17 @@ double d2 = d0 * d0 + d1 * d1; if (d2 <= (double) (f * f)) { @@ -57,6 +57,6 @@ + if (entity instanceof CraftLivingEntity) { + EntityLiving entityliving = ((CraftLivingEntity) entity).getHandle(); + // CraftBukkit end - this.at.put(entityliving, Integer.valueOf(this.ticksLived + this.reapplicationDelay)); + this.h.put(entityliving, Integer.valueOf(this.ticksLived + this.reapplicationDelay)); Iterator iterator3 = arraylist.iterator(); diff --git a/paper-server/nms-patches/EntityArmorStand.patch b/paper-server/nms-patches/EntityArmorStand.patch index 496a092595..a0f06e681f 100644 --- a/paper-server/nms-patches/EntityArmorStand.patch +++ b/paper-server/nms-patches/EntityArmorStand.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/server/EntityArmorStand.java +++ b/net/minecraft/server/EntityArmorStand.java @@ -5,6 +5,15 @@ - import java.util.List; + import java.util.function.Predicate; import javax.annotation.Nullable; +// CraftBukkit start @@ -15,8 +15,8 @@ + public class EntityArmorStand extends EntityLiving { - private static final Vector3f br = new Vector3f(0.0F, 0.0F, 0.0F); -@@ -61,6 +70,13 @@ + private static final Vector3f bx = new Vector3f(0.0F, 0.0F, 0.0F); +@@ -56,6 +65,13 @@ this.setPosition(d0, d1, d2); } @@ -30,9 +30,9 @@ public final void setSize(float f, float f1) { double d0 = this.locX; double d1 = this.locY; -@@ -364,6 +380,21 @@ - if (itemstack1.isEmpty() || (this.bB & 1 << enumitemslot.c() + 8) == 0) { - if (!itemstack1.isEmpty() || (this.bB & 1 << enumitemslot.c() + 16) == 0) { +@@ -355,6 +371,21 @@ + if (itemstack1.isEmpty() || (this.bH & 1 << enumitemslot.c() + 8) == 0) { + if (!itemstack1.isEmpty() || (this.bH & 1 << enumitemslot.c() + 16) == 0) { ItemStack itemstack2; + // CraftBukkit start + org.bukkit.inventory.ItemStack armorStandItem = CraftItemStack.asCraftMirror(itemstack1); @@ -52,7 +52,7 @@ if (entityhuman.abilities.canInstantlyBuild && itemstack1.isEmpty() && !itemstack.isEmpty()) { itemstack2 = itemstack.cloneItemStack(); -@@ -385,14 +416,19 @@ +@@ -376,14 +407,19 @@ } public boolean damageEntity(DamageSource damagesource, float f) { @@ -66,69 +66,69 @@ - this.die(); + this.killEntity(); // CraftBukkit - this.die() -> this.killEntity() return false; - } else if (!this.isInvulnerable(damagesource) && !this.bA && !this.isMarker()) { + } else if (!this.isInvulnerable(damagesource) && !this.bG && !this.isMarker()) { if (damagesource.isExplosion()) { - this.F(); + this.D(); - this.die(); + this.killEntity(); // CraftBukkit - this.die() -> this.killEntity() return false; } else if (DamageSource.FIRE.equals(damagesource)) { if (this.isBurning()) { -@@ -421,7 +457,7 @@ - } else if (damagesource.u()) { - this.H(); - this.D(); +@@ -407,7 +443,7 @@ + } else if (damagesource.v()) { + this.F(); + this.A(); +- this.die(); ++ this.killEntity(); // CraftBukkit - this.die() -> this.killEntity() + return false; + } else { + long i = this.world.getTime(); +@@ -418,7 +454,7 @@ + } else { + this.B(); + this.A(); - this.die(); + this.killEntity(); // CraftBukkit - this.die() -> this.killEntity() - return false; - } else { - long i = this.world.getTime(); -@@ -432,7 +468,7 @@ - } else { - this.E(); - this.D(); -- this.die(); -+ this.killEntity(); // CraftBukkit - this.die() -> this.killEntity() - } + } - return false; -@@ -460,7 +496,7 @@ + return true; +@@ -445,7 +481,7 @@ f1 -= f; if (f1 <= 0.5F) { - this.F(); + this.D(); - this.die(); + this.killEntity(); // CraftBukkit - this.die() -> this.killEntity() } else { this.setHealth(f1); } -@@ -468,7 +504,7 @@ +@@ -453,7 +489,7 @@ } - private void E() { + private void B() { - Block.a(this.world, new BlockPosition(this), new ItemStack(Items.ARMOR_STAND)); + drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(new ItemStack(Items.ARMOR_STAND))); // CraftBukkit - add to drops - this.F(); + this.D(); } -@@ -481,7 +517,7 @@ - for (i = 0; i < this.by.size(); ++i) { - itemstack = (ItemStack) this.by.get(i); +@@ -466,7 +502,7 @@ + for (i = 0; i < this.bE.size(); ++i) { + itemstack = (ItemStack) this.bE.get(i); if (!itemstack.isEmpty()) { - Block.a(this.world, (new BlockPosition(this)).up(), itemstack); + drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemstack)); // CraftBukkit - add to drops - this.by.set(i, ItemStack.a); + this.bE.set(i, ItemStack.a); } } -@@ -489,7 +525,7 @@ - for (i = 0; i < this.bz.size(); ++i) { - itemstack = (ItemStack) this.bz.get(i); +@@ -474,7 +510,7 @@ + for (i = 0; i < this.bF.size(); ++i) { + itemstack = (ItemStack) this.bF.get(i); if (!itemstack.isEmpty()) { - Block.a(this.world, (new BlockPosition(this)).up(), itemstack); + drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemstack)); // CraftBukkit - add to drops - this.bz.set(i, ItemStack.a); + this.bF.set(i, ItemStack.a); } } -@@ -601,6 +637,7 @@ +@@ -586,6 +622,7 @@ } public void killEntity() { diff --git a/paper-server/nms-patches/EntityArrow.patch b/paper-server/nms-patches/EntityArrow.patch index 3d27615c30..91b2b41f11 100644 --- a/paper-server/nms-patches/EntityArrow.patch +++ b/paper-server/nms-patches/EntityArrow.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/server/EntityArrow.java +++ b/net/minecraft/server/EntityArrow.java @@ -5,6 +5,13 @@ - import java.util.List; + import java.util.function.Predicate; import javax.annotation.Nullable; +// CraftBukkit start @@ -13,58 +13,44 @@ + public abstract class EntityArrow extends Entity implements IProjectile { - private static final Predicate f = Predicates.and(new Predicate[] { IEntitySelector.e, IEntitySelector.a, new Predicate() { -@@ -17,9 +24,9 @@ - } - }}); - private static final DataWatcherObject g = DataWatcher.a(EntityArrow.class, DataWatcherRegistry.a); -- private int h; -- private int at; -- private int au; -+ public int h; // PAIL: private->public -+ public int at; // PAIL: private->public -+ public int au; // PAIL: private->public - private Block av; - private int aw; - public boolean inGround; -@@ -50,6 +57,7 @@ - public EntityArrow(World world, EntityLiving entityliving) { - this(world, entityliving.locX, entityliving.locY + (double) entityliving.getHeadHeight() - 0.10000000149011612D, entityliving.locZ); + private static final Predicate f = IEntitySelector.e.and(IEntitySelector.a.and(Entity::isInteractable)); +@@ -42,6 +49,7 @@ + protected EntityArrow(EntityTypes entitytypes, EntityLiving entityliving, World world) { + this(entitytypes, entityliving.locX, entityliving.locY + (double) entityliving.getHeadHeight() - 0.10000000149011612D, entityliving.locZ, world); this.shooter = entityliving; + this.projectileSource = (LivingEntity) entityliving.getBukkitEntity(); // CraftBukkit if (entityliving instanceof EntityHuman) { this.fromPlayer = EntityArrow.PickupStatus.ALLOWED; } -@@ -236,7 +244,7 @@ +@@ -245,6 +253,7 @@ + } protected void a(MovingObjectPosition movingobjectposition) { - Entity entity = movingobjectposition.entity; -- + org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this, movingobjectposition); // CraftBukkit - Call event - if (entity != null) { - float f = MathHelper.sqrt(this.motX * this.motX + this.motY * this.motY + this.motZ * this.motZ); - int i = MathHelper.f((double) f * this.damage); -@@ -254,7 +262,13 @@ - } + if (movingobjectposition.entity != null) { + this.b(movingobjectposition); + } else { +@@ -293,7 +302,13 @@ + } - if (this.isBurning() && !(entity instanceof EntityEnderman)) { -- entity.setOnFire(5); -+ // CraftBukkit start -+ EntityCombustByEntityEvent combustEvent = new EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), 5); -+ org.bukkit.Bukkit.getPluginManager().callEvent(combustEvent); -+ if (!combustEvent.isCancelled()) { -+ entity.setOnFire(combustEvent.getDuration()); -+ } -+ // CraftBukkit end - } + if (this.isBurning() && !(entity instanceof EntityEnderman)) { +- entity.setOnFire(5); ++ // CraftBukkit start ++ EntityCombustByEntityEvent combustEvent = new EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), 5); ++ org.bukkit.Bukkit.getPluginManager().callEvent(combustEvent); ++ if (!combustEvent.isCancelled()) { ++ entity.setOnFire(combustEvent.getDuration()); ++ } ++ // CraftBukkit end + } - if (entity.damageEntity(damagesource, (float) i)) { -@@ -422,9 +436,22 @@ + if (entity.damageEntity(damagesource, (float) i)) { +@@ -430,9 +445,22 @@ public void d(EntityHuman entityhuman) { - if (!this.world.isClientSide && this.inGround && this.shake <= 0) { + if (!this.world.isClientSide && (this.inGround || this.p()) && this.shake <= 0) { + // CraftBukkit start -+ ItemStack itemstack = this.j(); // PAIL: rename ++ ItemStack itemstack = this.getItemStack(); + EntityItem item = new EntityItem(this.world, this.locX, this.locY, this.locZ, itemstack); + if (this.fromPlayer == PickupStatus.ALLOWED && entityhuman.inventory.canHold(itemstack) > 0) { + PlayerPickupArrowEvent event = new PlayerPickupArrowEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), new org.bukkit.craftbukkit.entity.CraftItem(this.world.getServer(), this, item), (org.bukkit.entity.Arrow) this.getBukkitEntity()); @@ -75,15 +61,15 @@ + return; + } + } - boolean flag = this.fromPlayer == EntityArrow.PickupStatus.ALLOWED || this.fromPlayer == EntityArrow.PickupStatus.CREATIVE_ONLY && entityhuman.abilities.canInstantlyBuild; + boolean flag = this.fromPlayer == EntityArrow.PickupStatus.ALLOWED || this.fromPlayer == EntityArrow.PickupStatus.CREATIVE_ONLY && entityhuman.abilities.canInstantlyBuild || this.p() && this.shooter == entityhuman; -- if (this.fromPlayer == EntityArrow.PickupStatus.ALLOWED && !entityhuman.inventory.pickup(this.j())) { +- if (this.fromPlayer == EntityArrow.PickupStatus.ALLOWED && !entityhuman.inventory.pickup(this.getItemStack())) { + if (this.fromPlayer == EntityArrow.PickupStatus.ALLOWED && !entityhuman.inventory.pickup(item.getItemStack())) { + // CraftBukkit end flag = false; } -@@ -493,7 +520,14 @@ +@@ -505,7 +533,14 @@ } if (EnchantmentManager.a(Enchantments.ARROW_FIRE, entityliving) > 0) { diff --git a/paper-server/nms-patches/EntityBoat.patch b/paper-server/nms-patches/EntityBoat.patch index e322502aab..949598f655 100644 --- a/paper-server/nms-patches/EntityBoat.patch +++ b/paper-server/nms-patches/EntityBoat.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/EntityBoat.java +++ b/net/minecraft/server/EntityBoat.java -@@ -5,6 +5,15 @@ +@@ -3,6 +3,15 @@ import java.util.List; import javax.annotation.Nullable; @@ -16,9 +16,9 @@ public class EntityBoat extends Entity { private static final DataWatcherObject a = DataWatcher.a(EntityBoat.class, DataWatcherRegistry.b); -@@ -32,6 +41,14 @@ - private EntityBoat.EnumStatus aH; - private double aI; +@@ -37,6 +46,14 @@ + private float aR; + private float aS; + // CraftBukkit start + // PAIL: Some of these haven't worked since a few updates, and since 1.9 they are less and less applicable. @@ -29,9 +29,9 @@ + // CraftBukkit end + public EntityBoat(World world) { - super(world); - this.f = new float[2]; -@@ -95,6 +112,19 @@ + super(EntityTypes.BOAT, world); + this.h = new float[2]; +@@ -94,6 +111,19 @@ if (damagesource instanceof EntityDamageSourceIndirect && damagesource.getEntity() != null && this.w(damagesource.getEntity())) { return false; } else { @@ -48,13 +48,13 @@ + // f = event.getDamage(); // TODO Why don't we do this? + // CraftBukkit end + - this.d(-this.r()); - this.c(10); - this.setDamage(this.p() + f * 10.0F); -@@ -102,6 +132,15 @@ + this.c(-this.o()); + this.b(10); + this.setDamage(this.m() + f * 10.0F); +@@ -101,6 +131,15 @@ boolean flag = damagesource.getEntity() instanceof EntityHuman && ((EntityHuman) damagesource.getEntity()).abilities.canInstantlyBuild; - if (flag || this.p() > 40.0F) { + if (flag || this.m() > 40.0F) { + // CraftBukkit start + VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, attacker); + this.world.getServer().getPluginManager().callEvent(destroyEvent); @@ -65,9 +65,9 @@ + } + // CraftBukkit end if (!flag && this.world.getGameRules().getBoolean("doEntityDrops")) { - this.a(this.j(), 1, 0.0F); + this.a((IMaterial) this.f()); } -@@ -119,9 +158,25 @@ +@@ -134,9 +173,25 @@ public void collide(Entity entity) { if (entity instanceof EntityBoat) { if (entity.getBoundingBox().b < this.getBoundingBox().e) { @@ -93,23 +93,15 @@ super.collide(entity); } -@@ -158,6 +213,7 @@ +@@ -173,6 +228,7 @@ return this.getDirection().e(); } + private Location lastLocation; // CraftBukkit - public void B_() { - this.aH = this.aG; - this.aG = this.u(); -@@ -178,7 +234,6 @@ - if (this.p() > 0.0F) { - this.setDamage(this.p() - 1.0F); - } -- - this.lastX = this.locX; - this.lastY = this.locY; - this.lastZ = this.locZ; -@@ -202,6 +257,22 @@ + public void tick() { + this.aM = this.aL; + this.aL = this.s(); +@@ -217,6 +273,22 @@ this.motZ = 0.0D; } @@ -129,12 +121,12 @@ + lastLocation = vehicle.getLocation(); + // CraftBukkit end + - for (int i = 0; i <= 1; ++i) { - if (this.a(i)) { - if (!this.isSilent() && (double) (this.f[i] % 6.2831855F) <= 0.7853981852531433D && ((double) this.f[i] + 0.39269909262657166D) % 6.2831854820251465D >= 0.7853981852531433D) { -@@ -622,6 +693,11 @@ + this.q(); - this.e(this.fallDistance, 1.0F); + for (int i = 0; i <= 1; ++i) { +@@ -737,6 +809,11 @@ + + this.c(this.fallDistance, 1.0F); if (!this.world.isClientSide && !this.dead) { + // CraftBukkit start + Vehicle vehicle = (Vehicle) this.getBukkitEntity(); @@ -144,7 +136,7 @@ this.die(); if (this.world.getGameRules().getBoolean("doEntityDrops")) { int i; -@@ -635,6 +711,7 @@ +@@ -750,6 +827,7 @@ } } } diff --git a/paper-server/nms-patches/EntityChicken.patch b/paper-server/nms-patches/EntityChicken.patch index d98f010b08..11ec20a80f 100644 --- a/paper-server/nms-patches/EntityChicken.patch +++ b/paper-server/nms-patches/EntityChicken.patch @@ -1,24 +1,24 @@ --- a/net/minecraft/server/EntityChicken.java +++ b/net/minecraft/server/EntityChicken.java -@@ -44,6 +44,11 @@ +@@ -42,6 +42,11 @@ } - public void n() { + public void k() { + // CraftBukkit start + if (this.isChickenJockey()) { + this.persistent = !this.isTypeNotPersistent(); + } + // CraftBukkit end - super.n(); - this.bB = this.bx; - this.bz = this.by; -@@ -61,7 +66,9 @@ - this.bx += this.bC * 2.0F; - if (!this.world.isClientSide && !this.isBaby() && !this.isChickenJockey() && --this.bD <= 0) { - this.a(SoundEffects.af, 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); + super.k(); + this.bG = this.bC; + this.bE = this.bD; +@@ -59,7 +64,9 @@ + this.bC += this.bH * 2.0F; + if (!this.world.isClientSide && !this.isBaby() && !this.isChickenJockey() && --this.bI <= 0) { + this.a(SoundEffects.ENTITY_CHICKEN_EGG, 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); + this.forceDrops = true; // CraftBukkit - this.a(Items.EGG, 1); + this.a((IMaterial) Items.EGG); + this.forceDrops = false; // CraftBukkit - this.bD = this.random.nextInt(6000) + 6000; + this.bI = this.random.nextInt(6000) + 6000; } diff --git a/paper-server/nms-patches/EntityCow.patch b/paper-server/nms-patches/EntityCow.patch index a69a075052..fda4509eda 100644 --- a/paper-server/nms-patches/EntityCow.patch +++ b/paper-server/nms-patches/EntityCow.patch @@ -24,7 +24,7 @@ + } + + ItemStack result = CraftItemStack.asNMSCopy(event.getItemStack()); - entityhuman.a(SoundEffects.au, 1.0F, 1.0F); + entityhuman.a(SoundEffects.ENTITY_COW_MILK, 1.0F, 1.0F); itemstack.subtract(1); if (itemstack.isEmpty()) { - entityhuman.a(enumhand, new ItemStack(Items.MILK_BUCKET)); diff --git a/paper-server/nms-patches/EntityCreature.patch b/paper-server/nms-patches/EntityCreature.patch index 7813c99835..6580470d21 100644 --- a/paper-server/nms-patches/EntityCreature.patch +++ b/paper-server/nms-patches/EntityCreature.patch @@ -1,8 +1,7 @@ --- a/net/minecraft/server/EntityCreature.java +++ b/net/minecraft/server/EntityCreature.java -@@ -2,6 +2,10 @@ - - import java.util.UUID; +@@ -1,5 +1,9 @@ + package net.minecraft.server; +// CraftBukkit start +import org.bukkit.event.entity.EntityUnleashEvent; @@ -10,8 +9,8 @@ + public abstract class EntityCreature extends EntityInsentient { - public static final UUID bv = UUID.fromString("E199AD21-BA8A-4C53-8D13-6182D5C69D3A"); -@@ -68,6 +72,7 @@ + private BlockPosition a; +@@ -66,6 +70,7 @@ if (this instanceof EntityTameableAnimal && ((EntityTameableAnimal) this).isSitting()) { if (f > 10.0F) { @@ -19,9 +18,9 @@ this.unleash(true, true); } -@@ -76,6 +81,7 @@ +@@ -74,6 +79,7 @@ - this.q(f); + this.u(f); if (f > 10.0F) { + this.world.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE)); // CraftBukkit this.unleash(true, true); diff --git a/paper-server/nms-patches/EntityCreeper.patch b/paper-server/nms-patches/EntityCreeper.patch index 580aeb9145..4a0912c67e 100644 --- a/paper-server/nms-patches/EntityCreeper.patch +++ b/paper-server/nms-patches/EntityCreeper.patch @@ -11,18 +11,7 @@ public class EntityCreeper extends EntityMonster { -@@ -11,8 +15,8 @@ - private static final DataWatcherObject c = DataWatcher.a(EntityCreeper.class, DataWatcherRegistry.h); - private int bx; - private int fuseTicks; -- private int maxFuseTicks = 30; -- private int explosionRadius = 3; -+ public int maxFuseTicks = 30; // PAIL private -> public -+ public int explosionRadius = 3; // PAIL private -> public - private int bB; - - public EntityCreeper(World world) { -@@ -125,7 +129,7 @@ +@@ -121,7 +125,7 @@ } public void die(DamageSource damagesource) { @@ -30,16 +19,16 @@ + // super.die(damagesource); // CraftBukkit - Moved to end if (this.world.getGameRules().getBoolean("doMobLoot")) { if (damagesource.getEntity() instanceof EntitySkeleton) { - int i = Item.getId(Items.RECORD_13); -@@ -138,6 +142,7 @@ - this.a(new ItemStack(Items.SKULL, 1, 4), 0.0F); + this.a((IMaterial) ItemRecord.a(this.random)); +@@ -130,6 +134,7 @@ + this.a((IMaterial) Items.CREEPER_HEAD); } } + super.die(damagesource); // CraftBukkit - Moved from above } -@@ -164,9 +169,19 @@ +@@ -156,9 +161,19 @@ public void onLightningStrike(EntityLightning entitylightning) { super.onLightningStrike(entitylightning); @@ -60,22 +49,22 @@ protected boolean a(EntityHuman entityhuman, EnumHand enumhand) { ItemStack itemstack = entityhuman.b(enumhand); -@@ -188,10 +203,18 @@ +@@ -180,10 +195,18 @@ boolean flag = this.world.getGameRules().getBoolean("mobGriefing"); float f = this.isPowered() ? 2.0F : 1.0F; -- this.aU = true; +- this.aX = true; - this.world.explode(this, this.locX, this.locY, this.locZ, (float) this.explosionRadius * f, flag); - this.die(); -- this.ds(); +- this.dF(); + // CraftBukkit start + ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), this.explosionRadius * f, false); + this.world.getServer().getPluginManager().callEvent(event); + if (!event.isCancelled()) { -+ this.aU = true; ++ this.aX = true; + this.world.createExplosion(this, this.locX, this.locY, this.locZ, event.getRadius(), event.getFire(), flag); + this.die(); -+ this.ds(); ++ this.dF(); + } else { + fuseTicks = 0; + } @@ -83,7 +72,7 @@ } } -@@ -202,6 +225,7 @@ +@@ -194,6 +217,7 @@ if (!collection.isEmpty()) { EntityAreaEffectCloud entityareaeffectcloud = new EntityAreaEffectCloud(this.world, this.locX, this.locY, this.locZ); diff --git a/paper-server/nms-patches/EntityDamageSourceIndirect.patch b/paper-server/nms-patches/EntityDamageSourceIndirect.patch index 2bd5300b6a..9e9dd43db0 100644 --- a/paper-server/nms-patches/EntityDamageSourceIndirect.patch +++ b/paper-server/nms-patches/EntityDamageSourceIndirect.patch @@ -2,7 +2,7 @@ +++ b/net/minecraft/server/EntityDamageSourceIndirect.java @@ -29,4 +29,10 @@ - return !itemstack.isEmpty() && itemstack.hasName() && LocaleI18n.c(s1) ? new ChatMessage(s1, new Object[] { entityliving.getScoreboardDisplayName(), ichatbasecomponent, itemstack.C()}) : new ChatMessage(s, new Object[] { entityliving.getScoreboardDisplayName(), ichatbasecomponent}); + return !itemstack.isEmpty() && itemstack.hasName() ? new ChatMessage(s1, new Object[] { entityliving.getScoreboardDisplayName(), ichatbasecomponent, itemstack.A()}) : new ChatMessage(s, new Object[] { entityliving.getScoreboardDisplayName(), ichatbasecomponent}); } + + // CraftBukkit start diff --git a/paper-server/nms-patches/EntityEgg.patch b/paper-server/nms-patches/EntityEgg.patch index 314bd2fe85..3d0192eb69 100644 --- a/paper-server/nms-patches/EntityEgg.patch +++ b/paper-server/nms-patches/EntityEgg.patch @@ -13,7 +13,7 @@ public class EntityEgg extends EntityProjectile { public EntityEgg(World world) { -@@ -24,20 +31,40 @@ +@@ -20,20 +27,40 @@ } if (!this.world.isClientSide) { diff --git a/paper-server/nms-patches/EntityEnderCrystal.patch b/paper-server/nms-patches/EntityEnderCrystal.patch index e8fe828c4a..81245d8634 100644 --- a/paper-server/nms-patches/EntityEnderCrystal.patch +++ b/paper-server/nms-patches/EntityEnderCrystal.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/server/EntityEnderCrystal.java +++ b/net/minecraft/server/EntityEnderCrystal.java @@ -3,6 +3,11 @@ - import com.google.common.base.Optional; + import java.util.Optional; import javax.annotation.Nullable; +// CraftBukkit start @@ -11,14 +11,14 @@ + public class EntityEnderCrystal extends Entity { - private static final DataWatcherObject> b = DataWatcher.a(EntityEnderCrystal.class, DataWatcherRegistry.k); + private static final DataWatcherObject> b = DataWatcher.a(EntityEnderCrystal.class, DataWatcherRegistry.m); @@ -39,7 +44,11 @@ BlockPosition blockposition = new BlockPosition(this); - if (this.world.worldProvider instanceof WorldProviderTheEnd && this.world.getType(blockposition).getBlock() != Blocks.FIRE) { + if (this.world.worldProvider instanceof WorldProviderTheEnd && this.world.getType(blockposition).isAir()) { - this.world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData()); + // CraftBukkit start -+ if (!CraftEventFactory.callBlockIgniteEvent(this.world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this).isCancelled()) { ++ if (!CraftEventFactory.callBlockIgniteEvent(this.world, blockposition, this).isCancelled()) { + this.world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData()); + } + // CraftBukkit end diff --git a/paper-server/nms-patches/EntityEnderDragon.patch b/paper-server/nms-patches/EntityEnderDragon.patch index 6bfae174b0..8c1b4cdee6 100644 --- a/paper-server/nms-patches/EntityEnderDragon.patch +++ b/paper-server/nms-patches/EntityEnderDragon.patch @@ -12,16 +12,16 @@ +// PAIL: Fixme public class EntityEnderDragon extends EntityInsentient implements IComplex, IMonster { - private static final Logger bJ = LogManager.getLogger(); + private static final Logger bQ = LogManager.getLogger(); @@ -33,6 +38,7 @@ - private final PathPoint[] bO = new PathPoint[24]; - private final int[] bP = new int[24]; - private final Path bQ = new Path(); + private final PathPoint[] bV = new PathPoint[24]; + private final int[] bW = new int[24]; + private final Path bX = new Path(); + private Explosion explosionSource = new Explosion(null, this, Double.NaN, Double.NaN, Double.NaN, Float.NaN, true, true); // CraftBukkit - reusable source for CraftTNTPrimed.getSource() public EntityEnderDragon(World world) { - super(world); -@@ -171,7 +177,7 @@ + super(EntityTypes.ENDER_DRAGON, world); +@@ -170,7 +176,7 @@ Vec3D vec3d = idragoncontroller.g(); @@ -30,7 +30,7 @@ d0 = vec3d.x - this.locX; d1 = vec3d.y - this.locY; d2 = vec3d.z - this.locZ; -@@ -327,7 +333,14 @@ +@@ -326,7 +332,14 @@ if (this.currentEnderCrystal.dead) { this.currentEnderCrystal = null; } else if (this.ticksLived % 10 == 0 && this.getHealth() < this.getMaxHealth()) { @@ -46,7 +46,7 @@ } } -@@ -400,6 +413,10 @@ +@@ -399,6 +412,10 @@ int j1 = MathHelper.floor(axisalignedbb.f); boolean flag = false; boolean flag1 = false; @@ -57,10 +57,10 @@ for (int k1 = i; k1 <= l; ++k1) { for (int l1 = j; l1 <= i1; ++l1) { -@@ -413,7 +430,11 @@ +@@ -412,7 +429,11 @@ flag = true; } else if (block != Blocks.BARRIER && block != Blocks.OBSIDIAN && block != Blocks.END_STONE && block != Blocks.BEDROCK && block != Blocks.END_PORTAL && block != Blocks.END_PORTAL_FRAME) { - if (block != Blocks.COMMAND_BLOCK && block != Blocks.dc && block != Blocks.dd && block != Blocks.IRON_BARS && block != Blocks.END_GATEWAY) { + if (block != Blocks.COMMAND_BLOCK && block != Blocks.REPEATING_COMMAND_BLOCK && block != Blocks.CHAIN_COMMAND_BLOCK && block != Blocks.IRON_BARS && block != Blocks.END_GATEWAY) { - flag1 = this.world.setAir(blockposition) || flag1; + // CraftBukkit start - Add blocks to list rather than destroying them + // flag1 = this.world.setAir(blockposition) || flag1; @@ -70,7 +70,7 @@ } else { flag = true; } -@@ -425,6 +446,41 @@ +@@ -424,6 +445,42 @@ } } @@ -100,7 +100,8 @@ + + Block nmsBlock = org.bukkit.craftbukkit.util.CraftMagicNumbers.getBlock(blockId); + if (nmsBlock.a(explosionSource)) { -+ nmsBlock.dropNaturally(this.world, new BlockPosition(blockX, blockY, blockZ), nmsBlock.fromLegacyData(block.getData()), event.getYield(), 0); ++ BlockPosition pos = new BlockPosition(blockX, blockY, blockZ); ++ nmsBlock.dropNaturally(world.getType(pos), world, pos, event.getYield(), 0); + } + nmsBlock.wasExploded(world, new BlockPosition(blockX, blockY, blockZ), explosionSource); + diff --git a/paper-server/nms-patches/EntityEnderPearl.patch b/paper-server/nms-patches/EntityEnderPearl.patch index d61d7c6729..9f8b18a922 100644 --- a/paper-server/nms-patches/EntityEnderPearl.patch +++ b/paper-server/nms-patches/EntityEnderPearl.patch @@ -13,7 +13,7 @@ public class EntityEnderPearl extends EntityProjectile { -@@ -61,21 +67,35 @@ +@@ -57,21 +63,35 @@ EntityPlayer entityplayer = (EntityPlayer) entityliving; if (entityplayer.playerConnection.a().isConnected() && entityplayer.world == this.world && !entityplayer.isSleeping()) { diff --git a/paper-server/nms-patches/EntityEnderSignal.patch b/paper-server/nms-patches/EntityEnderSignal.patch deleted file mode 100644 index b611b9740b..0000000000 --- a/paper-server/nms-patches/EntityEnderSignal.patch +++ /dev/null @@ -1,19 +0,0 @@ ---- a/net/minecraft/server/EntityEnderSignal.java -+++ b/net/minecraft/server/EntityEnderSignal.java -@@ -2,11 +2,11 @@ - - public class EntityEnderSignal extends Entity { - -- private double a; -- private double b; -- private double c; -- private int d; -- private boolean e; -+ public double a; // CraftBukkit private -> public // PAIL rename targetX -+ public double b; // CraftBukkit private -> public // PAIL rename targetY -+ public double c; // CraftBukkit private -> public // PAIL rename targetZ -+ public int d; // CraftBukkit private -> public // PAIL rename despawnTimer -+ public boolean e; // CraftBukkit private -> public // PAIL rename shouldDropItem - - public EntityEnderSignal(World world) { - super(world); diff --git a/paper-server/nms-patches/EntityEnderman.patch b/paper-server/nms-patches/EntityEnderman.patch index dc6ad77876..fdfcc0f5e6 100644 --- a/paper-server/nms-patches/EntityEnderman.patch +++ b/paper-server/nms-patches/EntityEnderman.patch @@ -1,21 +1,28 @@ --- a/net/minecraft/server/EntityEnderman.java +++ b/net/minecraft/server/EntityEnderman.java -@@ -4,6 +4,8 @@ - import com.google.common.base.Optional; - import com.google.common.base.Predicate; - import com.google.common.collect.Sets; -+import org.bukkit.event.entity.EntityTargetEvent; -+ - import java.util.Random; - import java.util.Set; - import java.util.UUID; -@@ -56,7 +58,17 @@ +@@ -33,7 +33,14 @@ + this.goalSelector.a(11, new EntityEnderman.PathfinderGoalEndermanPickupBlock(this)); + this.targetSelector.a(1, new EntityEnderman.PathfinderGoalPlayerWhoLookedAtTarget(this)); + this.targetSelector.a(2, new PathfinderGoalHurtByTarget(this, false, new Class[0])); +- this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget(this, EntityEndermite.class, 10, true, false, EntityEndermite::l)); ++ // CraftBukkit - decompile error ++ this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget(this, EntityEndermite.class, 10, true, false, new Predicate() { ++ @Override ++ public boolean test(EntityEndermite entityendermite) { ++ return entityendermite.l(); ++ } ++ })); ++ // CraftBukkit end + } + + protected void initAttributes() { +@@ -45,7 +52,17 @@ } public void setGoalTarget(@Nullable EntityLiving entityliving) { - super.setGoalTarget(entityliving); + // CraftBukkit start - fire event -+ setGoalTarget(entityliving, EntityTargetEvent.TargetReason.UNKNOWN, true); ++ setGoalTarget(entityliving, org.bukkit.event.entity.EntityTargetEvent.TargetReason.UNKNOWN, true); + } + + @Override @@ -28,7 +35,7 @@ AttributeInstance attributeinstance = this.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED); if (entityliving == null) { -@@ -70,6 +82,7 @@ +@@ -59,6 +76,7 @@ attributeinstance.b(EntityEnderman.b); } } @@ -36,14 +43,14 @@ } -@@ -317,8 +330,12 @@ +@@ -277,8 +295,12 @@ boolean flag = movingobjectposition != null && movingobjectposition.a().equals(blockposition); - if (EntityEnderman.c.contains(block) && flag) { + if (block.a(TagsBlock.G) && flag) { - this.enderman.setCarried(iblockdata); - world.setAir(blockposition); + // CraftBukkit start - Pickup event -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.enderman, this.enderman.world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), org.bukkit.Material.AIR).isCancelled()) { ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.enderman, blockposition, Blocks.AIR.getBlockData()).isCancelled()) { + this.enderman.setCarried(iblockdata); + world.setAir(blockposition); + } @@ -51,12 +58,12 @@ } } -@@ -348,8 +365,12 @@ +@@ -308,8 +330,12 @@ IBlockData iblockdata2 = this.a.getCarried(); - if (iblockdata2 != null && this.a(world, blockposition, iblockdata2.getBlock(), iblockdata, iblockdata1)) { + if (iblockdata2 != null && this.a(world, blockposition, iblockdata2, iblockdata, iblockdata1)) { + // CraftBukkit start - Place event -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.a, blockposition, this.a.getCarried().getBlock(), this.a.getCarried().getBlock().toLegacyData(this.a.getCarried())).isCancelled()) { ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.a, blockposition, iblockdata2).isCancelled()) { world.setTypeAndData(blockposition, iblockdata2, 3); this.a.setCarried((IBlockData) null); + } diff --git a/paper-server/nms-patches/EntityEvokerFangs.patch b/paper-server/nms-patches/EntityEvokerFangs.patch index 0e392ed56e..b90581a8e5 100644 --- a/paper-server/nms-patches/EntityEvokerFangs.patch +++ b/paper-server/nms-patches/EntityEvokerFangs.patch @@ -2,7 +2,7 @@ +++ b/net/minecraft/server/EntityEvokerFangs.java @@ -108,7 +108,9 @@ - if (entityliving.isAlive() && !entityliving.be() && entityliving != entityliving1) { + if (entityliving.isAlive() && !entityliving.bl() && entityliving != entityliving1) { if (entityliving1 == null) { + org.bukkit.craftbukkit.event.CraftEventFactory.entityDamage = this; // CraftBukkit entityliving.damageEntity(DamageSource.MAGIC, 6.0F); diff --git a/paper-server/nms-patches/EntityExperienceOrb.patch b/paper-server/nms-patches/EntityExperienceOrb.patch index bd249662b0..050cf6e05d 100644 --- a/paper-server/nms-patches/EntityExperienceOrb.patch +++ b/paper-server/nms-patches/EntityExperienceOrb.patch @@ -14,13 +14,13 @@ public int a; @@ -34,6 +40,7 @@ - public void B_() { - super.B_(); + public void tick() { + super.tick(); + EntityHuman prevTarget = this.targetPlayer;// CraftBukkit - store old target if (this.c > 0) { --this.c; } -@@ -68,6 +75,16 @@ +@@ -70,6 +77,16 @@ } if (this.targetPlayer != null) { @@ -37,7 +37,7 @@ double d1 = (this.targetPlayer.locX - this.locX) / 8.0D; double d2 = (this.targetPlayer.locY + (double) this.targetPlayer.getHeadHeight() / 2.0D - this.locY) / 8.0D; double d3 = (this.targetPlayer.locZ - this.locZ) / 8.0D; -@@ -80,6 +97,8 @@ +@@ -82,6 +99,8 @@ this.motY += d2 / d4 * d5 * 0.1D; this.motZ += d3 / d4 * d5 * 0.1D; } @@ -46,22 +46,21 @@ } this.move(EnumMoveType.SELF, this.motX, this.motY, this.motZ); -@@ -148,12 +167,18 @@ - if (!itemstack.isEmpty() && itemstack.h()) { - int i = Math.min(this.d(this.value), itemstack.i()); +@@ -155,12 +174,18 @@ + if (!itemstack.isEmpty() && itemstack.f()) { + int i = Math.min(this.c(this.value), itemstack.getDamage()); -- this.value -= this.c(i); -- itemstack.setData(itemstack.i() - i); -- } +- this.value -= this.b(i); +- itemstack.setDamage(itemstack.getDamage() - i); + // CraftBukkit start + org.bukkit.event.player.PlayerItemMendEvent event = CraftEventFactory.callPlayerItemMendEvent(entityhuman, this, itemstack, i); + i = event.getRepairAmount(); + if (!event.isCancelled()) { -+ this.value -= this.c(i); -+ itemstack.setData(itemstack.i() - i); ++ this.value -= this.b(i); ++ itemstack.setDamage(itemstack.getDamage() - i); + } + // CraftBukkit end -+ } + } if (this.value > 0) { - entityhuman.giveExp(this.value); @@ -69,7 +68,7 @@ } this.die(); -@@ -175,6 +200,24 @@ +@@ -182,6 +207,24 @@ } public static int getOrbValue(int i) { diff --git a/paper-server/nms-patches/EntityFallingBlock.patch b/paper-server/nms-patches/EntityFallingBlock.patch index afdb8dbb07..c09b0e5fad 100644 --- a/paper-server/nms-patches/EntityFallingBlock.patch +++ b/paper-server/nms-patches/EntityFallingBlock.patch @@ -1,40 +1,40 @@ --- a/net/minecraft/server/EntityFallingBlock.java +++ b/net/minecraft/server/EntityFallingBlock.java -@@ -5,6 +5,8 @@ +@@ -4,6 +4,8 @@ + import java.util.ArrayList; import java.util.Iterator; - import javax.annotation.Nullable; +import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit + public class EntityFallingBlock extends Entity { private IBlockData block; -@@ -69,7 +71,7 @@ +@@ -71,7 +73,7 @@ if (this.ticksLived++ == 0) { blockposition = new BlockPosition(this); - if (this.world.getType(blockposition).getBlock() == block) { -+ if (this.world.getType(blockposition).getBlock() == block && !CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, Blocks.AIR, 0).isCancelled()) { ++ if (this.world.getType(blockposition).getBlock() == block && !CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, Blocks.AIR.getBlockData()).isCancelled()) { this.world.setAir(blockposition); } else if (!this.world.isClientSide) { this.die(); -@@ -110,7 +112,7 @@ +@@ -112,7 +114,7 @@ - if (!flag1 && BlockFalling.x(this.world.getType(new BlockPosition(this.locX, this.locY - 0.009999999776482582D, this.locZ)))) { + if (!flag1 && BlockFalling.j(this.world.getType(new BlockPosition(this.locX, this.locY - 0.009999999776482582D, this.locZ)))) { this.onGround = false; - return; + // return; // CraftBukkit } this.motX *= 0.699999988079071D; -@@ -119,7 +121,13 @@ - if (iblockdata.getBlock() != Blocks.PISTON_EXTENSION) { +@@ -121,7 +123,13 @@ + if (iblockdata.getBlock() != Blocks.MOVING_PISTON) { this.die(); if (!this.f) { -- if (this.world.a(block, blockposition, true, EnumDirection.UP, (Entity) null) && (flag1 || !BlockFalling.x(this.world.getType(blockposition.down()))) && this.world.setTypeAndData(blockposition, this.block, 3)) { +- if (iblockdata.getMaterial().isReplaceable() && (flag1 || !BlockFalling.j(this.world.getType(blockposition.down()))) && this.world.setTypeAndData(blockposition, this.block, 3)) { + // CraftBukkit start -+ if (this.world.a(block, blockposition, true, EnumDirection.UP, (Entity) null) && (flag1 || !BlockFalling.x(this.world.getType(blockposition.down())))) { -+ if (CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, this.block.getBlock(), this.block.getBlock().toLegacyData(this.block)).isCancelled()) { ++ if (iblockdata.getMaterial().isReplaceable() && (flag1 || !BlockFalling.j(this.world.getType(blockposition.down())))) { ++ if (CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, this.block).isCancelled()) { + return; + } + this.world.setTypeAndData(blockposition, this.block, 3); diff --git a/paper-server/nms-patches/EntityFireball.patch b/paper-server/nms-patches/EntityFireball.patch index e9e26fd1a7..b236dc4b6d 100644 --- a/paper-server/nms-patches/EntityFireball.patch +++ b/paper-server/nms-patches/EntityFireball.patch @@ -15,14 +15,13 @@ + public float bukkitYield = 1; // CraftBukkit + public boolean isIncendiary = true; // CraftBukkit - public EntityFireball(World world) { - super(world); -@@ -31,12 +35,19 @@ - public EntityFireball(World world, EntityLiving entityliving, double d0, double d1, double d2) { - super(world); + protected EntityFireball(EntityTypes entitytypes, World world, float f, float f1) { + super(entitytypes, world); +@@ -28,11 +32,18 @@ + public EntityFireball(EntityTypes entitytypes, EntityLiving entityliving, double d0, double d1, double d2, World world, float f, float f1) { + this(entitytypes, world, f, f1); this.shooter = entityliving; + this.projectileSource = (org.bukkit.entity.LivingEntity) entityliving.getBukkitEntity(); // CraftBukkit - this.setSize(1.0F, 1.0F); this.setPositionRotation(entityliving.locX, entityliving.locY, entityliving.locZ, entityliving.yaw, entityliving.pitch); this.setPosition(this.locX, this.locY, this.locZ); this.motX = 0.0D; @@ -37,7 +36,7 @@ d0 += this.random.nextGaussian() * 0.4D; d1 += this.random.nextGaussian() * 0.4D; d2 += this.random.nextGaussian() * 0.4D; -@@ -61,6 +72,12 @@ +@@ -59,6 +70,12 @@ if (movingobjectposition != null) { this.a(movingobjectposition); @@ -50,19 +49,19 @@ } this.locX += this.motX; -@@ -150,6 +167,11 @@ +@@ -146,6 +163,11 @@ } else { - this.ax(); + this.aA(); if (damagesource.getEntity() != null) { + // CraftBukkit start + if (CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f)) { + return false; + } + // CraftBukkit end - Vec3D vec3d = damagesource.getEntity().aJ(); + Vec3D vec3d = damagesource.getEntity().aN(); if (vec3d != null) { -@@ -163,6 +185,7 @@ +@@ -159,6 +181,7 @@ if (damagesource.getEntity() instanceof EntityLiving) { this.shooter = (EntityLiving) damagesource.getEntity(); diff --git a/paper-server/nms-patches/EntityFireworks.patch b/paper-server/nms-patches/EntityFireworks.patch index 99fc74ae34..a0176143cf 100644 --- a/paper-server/nms-patches/EntityFireworks.patch +++ b/paper-server/nms-patches/EntityFireworks.patch @@ -8,37 +8,37 @@ public class EntityFireworks extends Entity { -@@ -117,8 +118,12 @@ +@@ -114,8 +115,12 @@ } if (!this.world.isClientSide && this.ticksFlown > this.expectedLifespan) { - this.world.broadcastEntityEffect(this, (byte) 17); -- this.k(); +- this.i(); + // CraftBukkit start + if (!org.bukkit.craftbukkit.event.CraftEventFactory.callFireworkExplodeEvent(this).isCancelled()) { + this.world.broadcastEntityEffect(this, (byte) 17); -+ this.k(); ++ this.i(); + } + // CraftBukkit end this.die(); } -@@ -136,7 +141,9 @@ +@@ -133,7 +138,9 @@ if (f > 0.0F) { if (this.e != null) { + CraftEventFactory.entityDamage = this; // CraftBukkit - this.e.damageEntity(DamageSource.t, (float) (5 + nbttaglist.size() * 2)); + this.e.damageEntity(DamageSource.FIREWORKS, (float) (5 + nbttaglist.size() * 2)); + CraftEventFactory.entityDamage = null; // CraftBukkit } double d0 = 5.0D; -@@ -162,7 +169,9 @@ +@@ -159,7 +166,9 @@ if (flag) { float f1 = f * (float) Math.sqrt((5.0D - (double) this.g(entityliving)) / 5.0D); + CraftEventFactory.entityDamage = this; // CraftBukkit - entityliving.damageEntity(DamageSource.t, f1); + entityliving.damageEntity(DamageSource.FIREWORKS, f1); + CraftEventFactory.entityDamage = null; // CraftBukkit } } diff --git a/paper-server/nms-patches/EntityFishingHook.patch b/paper-server/nms-patches/EntityFishingHook.patch index bcad37d4b3..10a8f12107 100644 --- a/paper-server/nms-patches/EntityFishingHook.patch +++ b/paper-server/nms-patches/EntityFishingHook.patch @@ -1,71 +1,71 @@ --- a/net/minecraft/server/EntityFishingHook.java +++ b/net/minecraft/server/EntityFishingHook.java -@@ -2,6 +2,11 @@ - +@@ -3,6 +3,11 @@ + import java.util.Collections; import java.util.Iterator; import java.util.List; +// CraftBukkit start +import org.bukkit.entity.Player; -+import org.bukkit.entity.Fish; ++import org.bukkit.entity.FishHook; +import org.bukkit.event.player.PlayerFishEvent; +// CraftBukkit end public class EntityFishingHook extends Entity { -@@ -261,6 +266,7 @@ +@@ -266,6 +271,7 @@ } if (movingobjectposition != null && movingobjectposition.type != MovingObjectPosition.EnumMovingObjectType.MISS) { + org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this, movingobjectposition); // Craftbukkit - Call event if (movingobjectposition.type == MovingObjectPosition.EnumMovingObjectType.ENTITY) { this.hooked = movingobjectposition.entity; - this.s(); -@@ -293,6 +299,10 @@ + this.o(); +@@ -298,6 +304,10 @@ if (this.g <= 0) { this.h = 0; - this.at = 0; + this.aw = 0; + // CraftBukkit start -+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), null, (Fish) this.getBukkitEntity(), PlayerFishEvent.State.FAILED_ATTEMPT); ++ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), null, (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.FAILED_ATTEMPT); + this.world.getServer().getPluginManager().callEvent(playerFishEvent); + // CraftBukkit end } else { this.motY -= 0.2D * (double) this.random.nextFloat() * (double) this.random.nextFloat(); } -@@ -328,6 +338,13 @@ - worldserver.a(EnumParticle.WATER_WAKE, d0, d1, d2, 0, (double) (-f4), 0.01D, (double) f3, 1.0D, new int[0]); +@@ -333,6 +343,13 @@ + worldserver.a(Particles.x, d0, d1, d2, 0, (double) (-f4), 0.01D, (double) f3, 1.0D); } } else { + // CraftBukkit start -+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), null, (Fish) this.getBukkitEntity(), PlayerFishEvent.State.BITE); ++ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), null, (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.BITE); + this.world.getServer().getPluginManager().callEvent(playerFishEvent); + if (playerFishEvent.isCancelled()) { + return; + } + // CraftBukkit end this.motY = (double) (-0.4F * MathHelper.a(this.random, 0.6F, 1.0F)); - this.a(SoundEffects.K, 0.25F, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F); + this.a(SoundEffects.ENTITY_FISHING_BOBBER_SPLASH, 0.25F, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F); double d3 = this.getBoundingBox().b + 0.5D; -@@ -384,6 +401,14 @@ +@@ -389,6 +406,14 @@ int i = 0; if (this.hooked != null) { + // CraftBukkit start -+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), this.hooked.getBukkitEntity(), (Fish) this.getBukkitEntity(), PlayerFishEvent.State.CAUGHT_ENTITY); ++ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), this.hooked.getBukkitEntity(), (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.CAUGHT_ENTITY); + this.world.getServer().getPluginManager().callEvent(playerFishEvent); + + if (playerFishEvent.isCancelled()) { + return 0; + } + // CraftBukkit end - this.k(); + this.f(); + CriterionTriggers.D.a((EntityPlayer) this.owner, itemstack, this, Collections.emptyList()); this.world.broadcastEntityEffect(this, (byte) 31); - i = this.hooked instanceof EntityItem ? 3 : 5; -@@ -396,6 +421,15 @@ +@@ -405,6 +430,15 @@ while (iterator.hasNext()) { - ItemStack itemstack = (ItemStack) iterator.next(); - EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY, this.locZ, itemstack); + ItemStack itemstack1 = (ItemStack) iterator.next(); + EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY, this.locZ, itemstack1); + // CraftBukkit start -+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), entityitem.getBukkitEntity(), (Fish) this.getBukkitEntity(), PlayerFishEvent.State.CAUGHT_FISH); ++ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), entityitem.getBukkitEntity(), (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.CAUGHT_FISH); + playerFishEvent.setExpToDrop(this.random.nextInt(6) + 1); + this.world.getServer().getPluginManager().callEvent(playerFishEvent); + @@ -76,7 +76,7 @@ double d0 = this.owner.locX - this.locX; double d1 = this.owner.locY - this.locY; double d2 = this.owner.locZ - this.locZ; -@@ -406,7 +440,11 @@ +@@ -415,7 +449,11 @@ entityitem.motY = d1 * 0.1D + (double) MathHelper.sqrt(d3) * 0.08D; entityitem.motZ = d2 * 0.1D; this.world.addEntity(entityitem); @@ -86,15 +86,15 @@ + this.owner.world.addEntity(new EntityExperienceOrb(this.owner.world, this.owner.locX, this.owner.locY + 0.5D, this.owner.locZ + 0.5D, playerFishEvent.getExpToDrop())); + } + // CraftBukkit end - Item item = itemstack.getItem(); - - if (item == Items.FISH || item == Items.COOKED_FISH) { -@@ -418,8 +456,25 @@ + if (itemstack1.getItem().a(TagsItem.G)) { + this.owner.a(StatisticList.FISH_CAUGHT, 1); + } +@@ -425,8 +463,25 @@ } if (this.isInGround) { + // CraftBukkit start -+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), null, (Fish) this.getBukkitEntity(), PlayerFishEvent.State.IN_GROUND); ++ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), null, (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.IN_GROUND); + this.world.getServer().getPluginManager().callEvent(playerFishEvent); + + if (playerFishEvent.isCancelled()) { @@ -105,7 +105,7 @@ } + // CraftBukkit start + if (i == 0) { -+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), null, (Fish) this.getBukkitEntity(), PlayerFishEvent.State.FAILED_ATTEMPT); ++ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), null, (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.FAILED_ATTEMPT); + this.world.getServer().getPluginManager().callEvent(playerFishEvent); + if (playerFishEvent.isCancelled()) { + return 0; diff --git a/paper-server/nms-patches/EntityGhast.patch b/paper-server/nms-patches/EntityGhast.patch index e4a07c97ed..8e11962ab2 100644 --- a/paper-server/nms-patches/EntityGhast.patch +++ b/paper-server/nms-patches/EntityGhast.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/EntityGhast.java +++ b/net/minecraft/server/EntityGhast.java -@@ -158,7 +158,8 @@ +@@ -154,7 +154,8 @@ world.a((EntityHuman) null, 1016, new BlockPosition(this.ghast), 0); EntityLargeFireball entitylargefireball = new EntityLargeFireball(world, this.ghast, d2, d3, d4); diff --git a/paper-server/nms-patches/EntityHanging.patch b/paper-server/nms-patches/EntityHanging.patch index 1c6ff3029d..83063756c6 100644 --- a/paper-server/nms-patches/EntityHanging.patch +++ b/paper-server/nms-patches/EntityHanging.patch @@ -12,8 +12,8 @@ + public abstract class EntityHanging extends Entity { - private static final Predicate c = new Predicate() { -@@ -41,43 +47,52 @@ + protected static final Predicate a = (entity) -> { +@@ -35,43 +41,52 @@ this.updateBoundingBox(); } @@ -98,7 +98,7 @@ return i % 32 == 0 ? 0.5D : 0.0D; } -@@ -88,6 +103,24 @@ +@@ -82,6 +97,24 @@ if (this.d++ == 100 && !this.world.isClientSide) { this.d = 0; if (!this.dead && !this.survives()) { @@ -123,7 +123,7 @@ this.die(); this.a((Entity) null); } -@@ -140,6 +173,21 @@ +@@ -134,6 +167,21 @@ return false; } else { if (!this.dead && !this.world.isClientSide) { @@ -143,9 +143,9 @@ + // CraftBukkit end + this.die(); - this.ax(); + this.aA(); this.a(damagesource.getEntity()); -@@ -151,6 +199,18 @@ +@@ -145,6 +193,18 @@ public void move(EnumMoveType enummovetype, double d0, double d1, double d2) { if (!this.world.isClientSide && !this.dead && d0 * d0 + d1 * d1 + d2 * d2 > 0.0D) { @@ -164,7 +164,7 @@ this.die(); this.a((Entity) null); } -@@ -158,7 +218,7 @@ +@@ -152,7 +212,7 @@ } public void f(double d0, double d1, double d2) { diff --git a/paper-server/nms-patches/EntityHorseAbstract.patch b/paper-server/nms-patches/EntityHorseAbstract.patch index 58896b499b..f4b2eeda69 100644 --- a/paper-server/nms-patches/EntityHorseAbstract.patch +++ b/paper-server/nms-patches/EntityHorseAbstract.patch @@ -1,31 +1,31 @@ --- a/net/minecraft/server/EntityHorseAbstract.java +++ b/net/minecraft/server/EntityHorseAbstract.java @@ -6,6 +6,7 @@ - import java.util.List; import java.util.UUID; + import java.util.function.Predicate; import javax.annotation.Nullable; +import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; // CraftBukkit public abstract class EntityHorseAbstract extends EntityAnimal implements IInventoryListener, IJumpable { -@@ -39,6 +40,7 @@ - private float bT; - protected boolean bF = true; - protected int bG; +@@ -33,6 +34,7 @@ + private float bY; + protected boolean bK = true; + protected int bL; + public int maxDomestication = 100; // CraftBukkit - store max domestication value - public EntityHorseAbstract(World world) { - super(world); -@@ -214,7 +216,7 @@ + protected EntityHorseAbstract(EntityTypes entitytypes, World world) { + super(entitytypes, world); +@@ -212,7 +214,7 @@ public void loadChest() { InventoryHorseChest inventoryhorsechest = this.inventoryChest; -- this.inventoryChest = new InventoryHorseChest("HorseChest", this.dn()); -+ this.inventoryChest = new InventoryHorseChest("HorseChest", this.dn(), this); // CraftBukkit - this.inventoryChest.a(this.getName()); +- this.inventoryChest = new InventoryHorseChest(this.getDisplayName(), this.dA()); ++ this.inventoryChest = new InventoryHorseChest(this.getDisplayName(), this.dA(), this); // CraftBukkit + this.inventoryChest.a(this.getCustomName()); if (inventoryhorsechest != null) { inventoryhorsechest.b(this); -@@ -354,7 +356,7 @@ +@@ -348,7 +350,7 @@ } public int getMaxDomestication() { @@ -33,8 +33,8 @@ + return this.maxDomestication; // CraftBukkit - return stored max domestication instead of 100 } - protected float cq() { -@@ -414,7 +416,7 @@ + protected float cC() { +@@ -408,7 +410,7 @@ } if (this.getHealth() < this.getMaxHealth() && f > 0.0F) { @@ -43,7 +43,7 @@ flag = true; } -@@ -465,7 +467,7 @@ +@@ -459,7 +461,7 @@ } public void die(DamageSource damagesource) { @@ -52,24 +52,24 @@ if (!this.world.isClientSide && this.inventoryChest != null) { for (int i = 0; i < this.inventoryChest.getSize(); ++i) { ItemStack itemstack = this.inventoryChest.getItem(i); -@@ -476,6 +478,7 @@ +@@ -470,6 +472,7 @@ } } + super.die(damagesource); // CraftBukkit } - public void n() { -@@ -486,7 +489,7 @@ - super.n(); + public void k() { +@@ -480,7 +483,7 @@ + super.k(); if (!this.world.isClientSide) { if (this.random.nextInt(900) == 0 && this.deathTicks == 0) { - this.heal(1.0F); + this.heal(1.0F, RegainReason.REGEN); // CraftBukkit } - if (this.dJ()) { -@@ -723,6 +726,7 @@ + if (this.dY()) { +@@ -716,6 +719,7 @@ if (this.getOwnerUUID() != null) { nbttagcompound.setString("OwnerUUID", this.getOwnerUUID().toString()); } @@ -77,7 +77,7 @@ if (!this.inventoryChest.getItem(0).isEmpty()) { nbttagcompound.set("SaddleItem", this.inventoryChest.getItem(0).save(new NBTTagCompound())); -@@ -749,6 +753,11 @@ +@@ -742,6 +746,11 @@ if (!s.isEmpty()) { this.setOwnerUUID(UUID.fromString(s)); } @@ -89,10 +89,10 @@ AttributeInstance attributeinstance = this.getAttributeMap().a("Speed"); -@@ -801,6 +810,18 @@ +@@ -794,6 +803,18 @@ } - public void b_(int i) { + public void b(int i) { + // CraftBukkit start + float power; + if (i >= 90) { @@ -106,5 +106,5 @@ + } + // CraftBukkit end this.canSlide = true; - this.dt(); + this.dH(); } diff --git a/paper-server/nms-patches/EntityHorseChestedAbstract.patch b/paper-server/nms-patches/EntityHorseChestedAbstract.patch index 2e49b194b3..0fff1fc3a7 100644 --- a/paper-server/nms-patches/EntityHorseChestedAbstract.patch +++ b/paper-server/nms-patches/EntityHorseChestedAbstract.patch @@ -8,7 +8,7 @@ + // super.die(damagesource); // CraftBukkit - moved down if (this.isCarryingChest()) { if (!this.world.isClientSide) { - this.a(Item.getItemOf(Blocks.CHEST), 1); + this.a((IMaterial) Blocks.CHEST); } - this.setCarryingChest(false); diff --git a/paper-server/nms-patches/EntityHuman.patch b/paper-server/nms-patches/EntityHuman.patch index 42eff8f35a..d8a3d00c70 100644 --- a/paper-server/nms-patches/EntityHuman.patch +++ b/paper-server/nms-patches/EntityHuman.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/server/EntityHuman.java +++ b/net/minecraft/server/EntityHuman.java -@@ -9,6 +9,19 @@ - import java.util.UUID; +@@ -15,6 +15,19 @@ + import java.util.function.ToIntFunction; import javax.annotation.Nullable; +// CraftBukkit start @@ -20,9 +20,9 @@ public abstract class EntityHuman extends EntityLiving { private static final DataWatcherObject a = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.c); -@@ -18,10 +31,10 @@ - protected static final DataWatcherObject bt = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.n); - protected static final DataWatcherObject bu = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.n); +@@ -24,10 +37,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); - protected InventoryEnderChest enderChest = new InventoryEnderChest(); + protected InventoryEnderChest enderChest = new InventoryEnderChest(this); // CraftBukkit - add "this" to constructor @@ -30,10 +30,10 @@ public Container activeContainer; - protected FoodMetaData foodData = new FoodMetaData(); + protected FoodMetaData foodData = new FoodMetaData(this); // CraftBukkit - add "this" to constructor - protected int bA; - public float bB; - public float bC; -@@ -52,6 +65,17 @@ + protected int bG; + public float bH; + public float bI; +@@ -60,6 +73,17 @@ @Nullable public EntityFishingHook hookedFish; @@ -48,10 +48,10 @@ + } + // CraftBukkit end + - protected ItemCooldown l() { - return new ItemCooldown(); - } -@@ -310,7 +334,8 @@ + public EntityHuman(World world, GameProfile gameprofile) { + super(EntityTypes.PLAYER, world); + this.cd = ItemStack.a; +@@ -369,7 +393,8 @@ if (this.world.getDifficulty() == EnumDifficulty.PEACEFUL && this.world.getGameRules().getBoolean("naturalRegeneration")) { if (this.getHealth() < this.getMaxHealth() && this.ticksLived % 20 == 0) { @@ -61,16 +61,16 @@ } if (this.foodData.c() && this.ticksLived % 10 == 0) { -@@ -334,7 +359,7 @@ +@@ -393,7 +418,7 @@ - this.k((float) attributeinstance.getValue()); + this.o((float) attributeinstance.getValue()); float f = MathHelper.sqrt(this.motX * this.motX + this.motZ * this.motZ); - float f1 = (float) (Math.atan(-this.motY * 0.20000000298023224D) * 15.0D); + float f1 = (float) ( org.bukkit.craftbukkit.TrigMath.atan(-this.motY * 0.20000000298023224D) * 15.0D); // CraftBukkit if (f > 0.1F) { f = 0.1F; -@@ -456,6 +481,7 @@ +@@ -516,6 +541,7 @@ @Nullable public EntityItem a(boolean flag) { @@ -78,7 +78,7 @@ return this.a(this.inventory.splitStack(this.inventory.itemInHandIndex, flag && !this.inventory.getItemInHand().isEmpty() ? this.inventory.getItemInHand().getCount() : 1), false, true); } -@@ -498,6 +524,30 @@ +@@ -558,6 +584,30 @@ entityitem.motZ += Math.sin((double) f1) * (double) f; } @@ -109,7 +109,7 @@ ItemStack itemstack1 = this.a(entityitem); if (flag1) { -@@ -613,6 +663,13 @@ +@@ -655,6 +705,13 @@ this.a(true, true, false); } @@ -121,9 +121,9 @@ + // CraftBukkit end + if (nbttagcompound.hasKeyOfType("SpawnX", 99) && nbttagcompound.hasKeyOfType("SpawnY", 99) && nbttagcompound.hasKeyOfType("SpawnZ", 99)) { - this.d = new BlockPosition(nbttagcompound.getInt("SpawnX"), nbttagcompound.getInt("SpawnY"), nbttagcompound.getInt("SpawnZ")); - this.e = nbttagcompound.getBoolean("SpawnForced"); -@@ -665,6 +722,7 @@ + this.e = new BlockPosition(nbttagcompound.getInt("SpawnX"), nbttagcompound.getInt("SpawnY"), nbttagcompound.getInt("SpawnZ")); + this.f = nbttagcompound.getBoolean("SpawnForced"); +@@ -705,6 +762,7 @@ if (!this.getShoulderEntityRight().isEmpty()) { nbttagcompound.set("ShoulderEntityRight", this.getShoulderEntityRight()); } @@ -131,20 +131,20 @@ } -@@ -682,10 +740,10 @@ +@@ -722,10 +780,10 @@ this.a(true, true, false); } - this.releaseShoulderEntities(); + // this.releaseShoulderEntities(); // CraftBukkit - moved down - if (damagesource.r()) { + if (damagesource.s()) { if (this.world.getDifficulty() == EnumDifficulty.PEACEFUL) { - f = 0.0F; + return false; // CraftBukkit - f = 0.0f -> return false } if (this.world.getDifficulty() == EnumDifficulty.EASY) { -@@ -697,7 +755,13 @@ +@@ -737,7 +795,13 @@ } } @@ -159,12 +159,12 @@ } } } -@@ -711,10 +775,29 @@ +@@ -751,10 +815,29 @@ } public boolean a(EntityHuman entityhuman) { -- ScoreboardTeamBase scoreboardteambase = this.aY(); -- ScoreboardTeamBase scoreboardteambase1 = entityhuman.aY(); +- ScoreboardTeamBase scoreboardteambase = this.be(); +- ScoreboardTeamBase scoreboardteambase1 = entityhuman.be(); + // CraftBukkit start - Change to check OTHER player's scoreboard team according to API + // To summarize this method's logic, it's "Can parameter hurt this" + org.bukkit.scoreboard.Team team; @@ -192,7 +192,7 @@ } protected void damageArmor(float f) { -@@ -757,7 +840,12 @@ +@@ -797,7 +880,12 @@ return (float) i / (float) this.inventory.armor.size(); } @@ -206,7 +206,7 @@ if (!this.isInvulnerable(damagesource)) { f = this.applyArmorModifier(damagesource, f); f = this.applyMagicModifier(damagesource, f); -@@ -777,6 +865,7 @@ +@@ -817,6 +905,7 @@ } } @@ -214,7 +214,7 @@ } public void openSign(TileEntitySign tileentitysign) {} -@@ -898,8 +987,15 @@ +@@ -938,8 +1027,15 @@ if (entity instanceof EntityLiving) { f3 = ((EntityLiving) entity).getHealth(); if (j > 0 && !entity.isBurning()) { @@ -232,7 +232,7 @@ } } -@@ -930,8 +1026,11 @@ +@@ -970,8 +1066,11 @@ EntityLiving entityliving = (EntityLiving) iterator.next(); if (entityliving != this && entityliving != entity && !this.r(entityliving) && this.h(entityliving) < 9.0D) { @@ -245,7 +245,7 @@ } } -@@ -940,11 +1039,28 @@ +@@ -980,11 +1079,28 @@ } if (entity instanceof EntityPlayer && entity.velocityChanged) { @@ -274,9 +274,9 @@ } if (flag2) { -@@ -993,7 +1109,14 @@ +@@ -1033,7 +1149,14 @@ - this.a(StatisticList.y, Math.round(f5 * 10.0F)); + this.a(StatisticList.DAMAGE_DEALT, Math.round(f5 * 10.0F)); if (j > 0) { - entity.setOnFire(j * 4); + // CraftBukkit start - Call a combust event when somebody hits with a fire enchanted item @@ -290,7 +290,7 @@ } if (this.world instanceof WorldServer && f5 > 2.0F) { -@@ -1009,6 +1132,11 @@ +@@ -1049,6 +1172,11 @@ if (flag4) { entity.extinguish(); } @@ -302,7 +302,7 @@ } } -@@ -1099,6 +1227,20 @@ +@@ -1145,6 +1273,20 @@ this.stopRiding(); } @@ -321,9 +321,9 @@ + // CraftBukkit end + this.releaseShoulderEntities(); + this.a(StatisticList.CUSTOM.b(StatisticList.n)); this.setSize(0.2F, 0.2F); - if (this.world.isLoaded(blockposition)) { -@@ -1159,6 +1301,23 @@ +@@ -1206,6 +1348,23 @@ this.world.everyoneSleeping(); } @@ -347,21 +347,21 @@ this.sleepTicks = flag ? 0 : 100; if (flag2) { this.setRespawnPosition(this.bedPosition, false); -@@ -1210,9 +1369,11 @@ +@@ -1257,9 +1416,11 @@ if (blockposition != null) { - this.d = blockposition; - this.e = flag; + this.e = blockposition; + this.f = flag; + this.spawnWorld = this.world.worldData.getName(); // CraftBukkit } else { - this.d = null; - this.e = false; + this.e = null; + this.f = false; + this.spawnWorld = ""; // CraftBukkit } } -@@ -1256,7 +1417,11 @@ +@@ -1325,7 +1486,11 @@ this.motY = d3 * 0.6D; - this.aR = f3; + this.aU = f3; this.fallDistance = 0.0F; - this.setFlag(7, false); + // CraftBukkit start @@ -372,7 +372,7 @@ } else { super.a(f, f1, f2); } -@@ -1540,13 +1705,17 @@ +@@ -1636,13 +1801,17 @@ } protected void releaseShoulderEntities() { @@ -395,7 +395,7 @@ if (!this.world.isClientSide && !nbttagcompound.isEmpty()) { Entity entity = EntityTypes.a(nbttagcompound, this.world); -@@ -1555,9 +1724,10 @@ +@@ -1651,9 +1820,10 @@ } entity.setPosition(this.locX, this.locY + 0.699999988079071D, this.locZ); @@ -407,12 +407,12 @@ } public abstract boolean isSpectator(); -@@ -1759,7 +1929,7 @@ +@@ -1864,7 +2034,7 @@ return entitymonster.c(this.a); } -- public boolean apply(@Nullable Object object) { -+ public boolean apply(@Nullable EntityMonster object) { // CraftBukkit - decompile error +- public boolean test(@Nullable Object object) { ++ public boolean test(@Nullable EntityMonster object) { // CraftBukkit - decompile error return this.a((EntityMonster) object); } diff --git a/paper-server/nms-patches/EntityInsentient.patch b/paper-server/nms-patches/EntityInsentient.patch index ef6aadb7aa..a93da20511 100644 --- a/paper-server/nms-patches/EntityInsentient.patch +++ b/paper-server/nms-patches/EntityInsentient.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/EntityInsentient.java +++ b/net/minecraft/server/EntityInsentient.java -@@ -9,6 +9,17 @@ +@@ -9,6 +9,18 @@ import java.util.UUID; import javax.annotation.Nullable; @@ -8,6 +8,7 @@ +import org.bukkit.craftbukkit.event.CraftEventFactory; +import org.bukkit.craftbukkit.entity.CraftLivingEntity; +import org.bukkit.entity.LivingEntity; ++import org.bukkit.event.entity.EntityCombustByEntityEvent; +import org.bukkit.event.entity.EntityPickupItemEvent; +import org.bukkit.event.entity.EntityTargetLivingEntityEvent; +import org.bukkit.event.entity.EntityTargetEvent; @@ -18,17 +19,17 @@ public abstract class EntityInsentient extends EntityLiving { private static final DataWatcherObject a = DataWatcher.a(EntityInsentient.class, DataWatcherRegistry.a); -@@ -27,7 +38,7 @@ +@@ -27,7 +39,7 @@ public float[] dropChanceHand; - private final NonNullList by; + private final NonNullList bE; public float[] dropChanceArmor; - public boolean canPickUpLoot; + // public boolean canPickUpLoot; // CraftBukkit - moved up to EntityLiving public boolean persistent; - private final Map bB; - private MinecraftKey bC; -@@ -57,6 +68,9 @@ - this.r(); + private final Map bH; + private MinecraftKey bI; +@@ -57,6 +69,9 @@ + this.n(); } + // CraftBukkit start - default persistance to type's persistance value @@ -36,8 +37,8 @@ + // CraftBukkit end } - protected void r() {} -@@ -110,7 +124,38 @@ + protected void n() {} +@@ -110,7 +125,38 @@ } public void setGoalTarget(@Nullable EntityLiving entityliving) { @@ -75,18 +76,18 @@ + // CraftBukkit end } - public boolean d(Class oclass) { -@@ -340,11 +385,20 @@ + public boolean b(Class oclass) { +@@ -336,11 +382,20 @@ public void a(NBTTagCompound nbttagcompound) { super.a(nbttagcompound); + + // CraftBukkit start - If looting or persistence is false only use it if it was set after we started using it if (nbttagcompound.hasKeyOfType("CanPickUpLoot", 1)) { -- this.m(nbttagcompound.getBoolean("CanPickUpLoot")); +- this.p(nbttagcompound.getBoolean("CanPickUpLoot")); + boolean data = nbttagcompound.getBoolean("CanPickUpLoot"); + if (isLevelAtLeast(nbttagcompound, 1) || data) { -+ this.m(data); ++ this.p(data); + } } @@ -99,13 +100,13 @@ NBTTagList nbttaglist; int i; -@@ -508,7 +562,15 @@ - } - } +@@ -470,11 +525,21 @@ + ItemStack itemstack1 = this.getEquipment(enumitemslot); + boolean flag = this.a(itemstack, itemstack1, enumitemslot); -- if (flag && this.c(itemstack)) { +- if (flag && this.d(itemstack)) { + // CraftBukkit start -+ boolean canPickup = flag && this.c(itemstack); ++ boolean canPickup = flag && this.d(itemstack); + + EntityPickupItemEvent entityEvent = new EntityPickupItemEvent((LivingEntity) getBukkitEntity(), (org.bukkit.entity.Item) entityitem.getBukkitEntity(), 0); + entityEvent.setCancelled(!canPickup); @@ -113,20 +114,16 @@ + canPickup = !entityEvent.isCancelled(); + if (canPickup) { + // CraftBukkit end - double d0; - - switch (enumitemslot.a()) { -@@ -525,7 +587,9 @@ - } + double d0 = this.c(enumitemslot); if (!itemstack1.isEmpty() && (double) (this.random.nextFloat() - 0.1F) < d0) { + this.forceDrops = true; // CraftBukkit - this.a(itemstack1, 0.0F); + this.a_(itemstack1); + this.forceDrops = false; // CraftBukkit } this.setSlot(enumitemslot, itemstack); -@@ -565,11 +629,11 @@ +@@ -554,11 +619,11 @@ double d2 = entityhuman.locZ - this.locZ; double d3 = d0 * d0 + d1 * d1 + d2 * d2; @@ -140,7 +137,7 @@ this.die(); } else if (d3 < 1024.0D) { this.ticksFarFromPlayer = 0; -@@ -938,12 +1002,24 @@ +@@ -946,12 +1011,24 @@ public final boolean b(EntityHuman entityhuman, EnumHand enumhand) { if (this.isLeashed() && this.getLeashHolder() == entityhuman) { @@ -165,9 +162,9 @@ this.setLeashHolder(entityhuman, true); itemstack.subtract(1); return true; -@@ -964,10 +1040,12 @@ +@@ -972,10 +1049,12 @@ - if (this.bE) { + if (this.bK) { if (!this.isAlive()) { + this.world.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.PLAYER_UNLEASH)); // CraftBukkit this.unleash(true, true); @@ -178,17 +175,17 @@ this.unleash(true, true); } } -@@ -978,7 +1056,9 @@ - this.bE = false; +@@ -986,7 +1065,9 @@ + this.bK = false; this.leashHolder = null; if (!this.world.isClientSide && flag1) { + this.forceDrops = true; // CraftBukkit - this.a(Items.LEAD, 1); + this.a((IMaterial) Items.LEAD); + this.forceDrops = false; // CraftBukkit } if (!this.world.isClientSide && flag && this.world instanceof WorldServer) { -@@ -1048,6 +1128,7 @@ +@@ -1056,6 +1137,7 @@ this.setLeashHolder(entityleash, true); } else { @@ -196,3 +193,19 @@ this.unleash(false, true); } } +@@ -1151,7 +1233,14 @@ + int j = EnchantmentManager.getFireAspectEnchantmentLevel(this); + + if (j > 0) { +- entity.setOnFire(j * 4); ++ // CraftBukkit start - Call a combust event when somebody hits with a fire enchanted item ++ EntityCombustByEntityEvent combustEvent = new EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), j * 4); ++ org.bukkit.Bukkit.getPluginManager().callEvent(combustEvent); ++ ++ if (!combustEvent.isCancelled()) { ++ entity.setOnFire(combustEvent.getDuration()); ++ } ++ // CraftBukkit end + } + + if (entity instanceof EntityHuman) { diff --git a/paper-server/nms-patches/EntityIronGolem.patch b/paper-server/nms-patches/EntityIronGolem.patch index 45aee397dc..5b53545a63 100644 --- a/paper-server/nms-patches/EntityIronGolem.patch +++ b/paper-server/nms-patches/EntityIronGolem.patch @@ -1,6 +1,21 @@ --- a/net/minecraft/server/EntityIronGolem.java +++ b/net/minecraft/server/EntityIronGolem.java -@@ -73,7 +73,7 @@ +@@ -28,8 +28,12 @@ + this.goalSelector.a(8, new PathfinderGoalRandomLookaround(this)); + this.targetSelector.a(1, new PathfinderGoalDefendVillage(this)); + this.targetSelector.a(2, new PathfinderGoalHurtByTarget(this, false, new Class[0])); +- this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget(this, EntityInsentient.class, 10, false, true, (entityinsentient) -> { +- return entityinsentient != null && IMonster.e.test(entityinsentient) && !(entityinsentient instanceof EntityCreeper); ++ // CraftBukkit start - decompile error ++ this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget(this, EntityInsentient.class, 10, false, true, new Predicate() { ++ public boolean test(@Nullable EntityInsentient entityinsentient) { ++ return entityinsentient != null && IMonster.e.test(entityinsentient) && !(entityinsentient instanceof EntityCreeper); ++ } ++ // CraftBukkit end + })); + } + +@@ -67,7 +71,7 @@ protected void C(Entity entity) { if (entity instanceof IMonster && !(entity instanceof EntityCreeper) && this.getRandom().nextInt(20) == 0) { diff --git a/paper-server/nms-patches/EntityItem.patch b/paper-server/nms-patches/EntityItem.patch index 0cb43b4b72..f12c053cdc 100644 --- a/paper-server/nms-patches/EntityItem.patch +++ b/paper-server/nms-patches/EntityItem.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/server/EntityItem.java +++ b/net/minecraft/server/EntityItem.java -@@ -4,6 +4,10 @@ +@@ -3,6 +3,10 @@ + import java.util.Iterator; + import java.util.UUID; import javax.annotation.Nullable; - import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; +// CraftBukkit start +import org.bukkit.event.entity.EntityPickupItemEvent; +import org.bukkit.event.player.PlayerPickupItemEvent; @@ -11,18 +11,18 @@ public class EntityItem extends Entity { -@@ -15,6 +19,7 @@ - private String g; - private String h; +@@ -13,6 +17,7 @@ + private UUID f; + private UUID g; public float a; + private int lastTick = MinecraftServer.currentTick - 1; // CraftBukkit - public EntityItem(World world, double d0, double d1, double d2) { - super(world); -@@ -54,9 +59,12 @@ + public EntityItem(World world) { + super(EntityTypes.ITEM, world); +@@ -48,9 +53,12 @@ this.die(); } else { - super.B_(); + super.tick(); - if (this.pickupDelay > 0 && this.pickupDelay != 32767) { - --this.pickupDelay; - } @@ -35,7 +35,7 @@ this.lastX = this.locX; this.lastY = this.locY; -@@ -104,9 +112,11 @@ +@@ -100,9 +108,11 @@ this.motY *= -0.5D; } @@ -45,9 +45,9 @@ } + // Craftbukkit end */ - this.aq(); + this.impulse |= this.at(); if (!this.world.isClientSide) { -@@ -121,6 +131,12 @@ +@@ -117,6 +127,12 @@ } if (!this.world.isClientSide && this.age >= 6000) { @@ -60,7 +60,7 @@ this.die(); } -@@ -162,6 +178,7 @@ +@@ -165,6 +181,7 @@ } else if (itemstack1.getCount() + itemstack.getCount() > itemstack1.getMaxStackSize()) { return false; } else { @@ -68,7 +68,7 @@ itemstack1.add(itemstack.getCount()); entityitem.pickupDelay = Math.max(entityitem.pickupDelay, this.pickupDelay); entityitem.age = Math.min(entityitem.age, this.age); -@@ -208,6 +225,11 @@ +@@ -197,6 +214,11 @@ } else if (!this.getItemStack().isEmpty() && this.getItemStack().getItem() == Items.NETHER_STAR && damagesource.isExplosion()) { return false; } else { @@ -77,10 +77,10 @@ + return false; + } + // CraftBukkit end - this.ax(); - this.f = (int) ((float) this.f - f); - if (this.f <= 0) { -@@ -270,6 +292,35 @@ + this.aA(); + this.e = (int) ((float) this.e - f); + if (this.e <= 0) { +@@ -255,6 +277,35 @@ Item item = itemstack.getItem(); int i = itemstack.getCount(); @@ -113,6 +113,14 @@ + } + // CraftBukkit end + - if (this.pickupDelay == 0 && (this.h == null || 6000 - this.age <= 200 || this.h.equals(entityhuman.getName())) && entityhuman.inventory.pickup(itemstack)) { + if (this.pickupDelay == 0 && (this.g == null || 6000 - this.age <= 200 || this.g.equals(entityhuman.getUniqueID())) && entityhuman.inventory.pickup(itemstack)) { entityhuman.receive(this, i); if (itemstack.isEmpty()) { +@@ -294,6 +345,7 @@ + } + + public void setItemStack(ItemStack itemstack) { ++ com.google.common.base.Preconditions.checkArgument(!itemstack.isEmpty(), "Cannot drop air"); // CraftBukkit + this.getDataWatcher().set(EntityItem.b, itemstack); + } + diff --git a/paper-server/nms-patches/EntityItemFrame.patch b/paper-server/nms-patches/EntityItemFrame.patch index f2cd4fa0d8..e15c81e42f 100644 --- a/paper-server/nms-patches/EntityItemFrame.patch +++ b/paper-server/nms-patches/EntityItemFrame.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/EntityItemFrame.java +++ b/net/minecraft/server/EntityItemFrame.java -@@ -31,6 +31,11 @@ +@@ -97,6 +97,11 @@ return false; } else if (!damagesource.isExplosion() && !this.getItem().isEmpty()) { if (!this.world.isClientSide) { @@ -10,5 +10,5 @@ + } + // CraftBukkit end this.b(damagesource.getEntity(), false); - this.a(SoundEffects.du, 1.0F, 1.0F); - this.setItem(ItemStack.a); + this.a(SoundEffects.ENTITY_ITEM_FRAME_REMOVE_ITEM, 1.0F, 1.0F); + } diff --git a/paper-server/nms-patches/EntityLargeFireball.patch b/paper-server/nms-patches/EntityLargeFireball.patch index 3e4e73c7f0..d3072c01e9 100644 --- a/paper-server/nms-patches/EntityLargeFireball.patch +++ b/paper-server/nms-patches/EntityLargeFireball.patch @@ -10,12 +10,12 @@ public int yield = 1; public EntityLargeFireball(World world) { - super(world); + super(EntityTypes.FIREBALL, world, 1.0F, 1.0F); + isIncendiary = this.world.getGameRules().getBoolean("mobGriefing"); // CraftBukkit } public EntityLargeFireball(World world, EntityLiving entityliving, double d0, double d1, double d2) { - super(world, entityliving, d0, d1, d2); + super(EntityTypes.FIREBALL, entityliving, d0, d1, d2, world, 1.0F, 1.0F); + isIncendiary = this.world.getGameRules().getBoolean("mobGriefing"); // CraftBukkit } @@ -37,7 +37,7 @@ this.die(); } -@@ -39,7 +51,8 @@ +@@ -35,7 +47,8 @@ public void a(NBTTagCompound nbttagcompound) { super.a(nbttagcompound); if (nbttagcompound.hasKeyOfType("ExplosionPower", 99)) { diff --git a/paper-server/nms-patches/EntityLeash.patch b/paper-server/nms-patches/EntityLeash.patch index c742be1c79..78552678ea 100644 --- a/paper-server/nms-patches/EntityLeash.patch +++ b/paper-server/nms-patches/EntityLeash.patch @@ -8,7 +8,7 @@ import java.util.Iterator; import java.util.List; import javax.annotation.Nullable; -@@ -71,22 +73,42 @@ +@@ -67,22 +69,42 @@ while (iterator.hasNext()) { entityinsentient = (EntityInsentient) iterator.next(); if (entityinsentient.isLeashed() && entityinsentient.getLeashHolder() == entityhuman) { diff --git a/paper-server/nms-patches/EntityLightning.patch b/paper-server/nms-patches/EntityLightning.patch index ec1e14a87f..d57c0b1a97 100644 --- a/paper-server/nms-patches/EntityLightning.patch +++ b/paper-server/nms-patches/EntityLightning.patch @@ -1,57 +1,33 @@ --- a/net/minecraft/server/EntityLightning.java +++ b/net/minecraft/server/EntityLightning.java -@@ -2,15 +2,19 @@ - +@@ -4,6 +4,8 @@ import java.util.List; + import javax.annotation.Nullable; +import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit + public class EntityLightning extends EntityWeather { private int lifeTicks; - public long a; - private int c; +@@ -12,9 +14,11 @@ private final boolean d; + @Nullable + private EntityPlayer e; + public boolean isEffect; // CraftBukkit public EntityLightning(World world, double d0, double d1, double d2, boolean flag) { - super(world); + super(EntityTypes.LIGHTNING_BOLT, world); + this.isEffect = flag; // CraftBukkit this.setPositionRotation(d0, d1, d2, 0.0F, 0.0F); this.lifeTicks = 2; this.a = this.random.nextLong(); -@@ -20,14 +24,22 @@ - - if (!flag && !world.isClientSide && world.getGameRules().getBoolean("doFireTick") && (world.getDifficulty() == EnumDifficulty.NORMAL || world.getDifficulty() == EnumDifficulty.HARD) && world.areChunksLoaded(blockposition, 10)) { - if (world.getType(blockposition).getMaterial() == Material.AIR && Blocks.FIRE.canPlace(world, blockposition)) { -- world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData()); -+ // CraftBukkit start -+ if (!CraftEventFactory.callBlockIgniteEvent(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this).isCancelled()) { -+ world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData()); -+ } -+ // CraftBukkit end - } - - for (int i = 0; i < 4; ++i) { - BlockPosition blockposition1 = blockposition.a(this.random.nextInt(3) - 1, this.random.nextInt(3) - 1, this.random.nextInt(3) - 1); - - if (world.getType(blockposition1).getMaterial() == Material.AIR && Blocks.FIRE.canPlace(world, blockposition1)) { -- world.setTypeUpdate(blockposition1, Blocks.FIRE.getBlockData()); -+ // CraftBukkit start -+ if (!CraftEventFactory.callBlockIgniteEvent(world, blockposition1.getX(), blockposition1.getY(), blockposition1.getZ(), this).isCancelled()) { -+ world.setTypeUpdate(blockposition1, Blocks.FIRE.getBlockData()); -+ } -+ // CraftBukkit end - } - } - } -@@ -41,7 +53,24 @@ - public void B_() { - super.B_(); +@@ -39,7 +43,24 @@ + public void tick() { + super.tick(); if (this.lifeTicks == 2) { -- this.world.a((EntityHuman) null, this.locX, this.locY, this.locZ, SoundEffects.dK, SoundCategory.WEATHER, 10000.0F, 0.8F + this.random.nextFloat() * 0.2F); +- this.world.a((EntityHuman) null, this.locX, this.locY, this.locZ, SoundEffects.ENTITY_LIGHTNING_BOLT_THUNDER, SoundCategory.WEATHER, 10000.0F, 0.8F + this.random.nextFloat() * 0.2F); + // CraftBukkit start - Use relative location for far away sounds -+ // this.world.a((EntityHuman) null, this.locX, this.locY, this.locZ, SoundEffects.dG, SoundCategory.WEATHER, 10000.0F, 0.8F + this.random.nextFloat() * 0.2F); ++ // this.world.a((EntityHuman) null, this.locX, this.locY, this.locZ, SoundEffects.ENTITY_LIGHTNING_BOLT_THUNDER, SoundCategory.WEATHER, 10000.0F, 0.8F + this.random.nextFloat() * 0.2F); + float pitch = 0.8F + this.random.nextFloat() * 0.2F; + int viewDistance = ((WorldServer) this.world).getServer().getViewDistance() * 16; + for (EntityPlayer player : (List) (List) this.world.players) { @@ -62,27 +38,16 @@ + double deltaLength = Math.sqrt(distanceSquared); + double relativeX = player.locX + (deltaX / deltaLength) * viewDistance; + double relativeZ = player.locZ + (deltaZ / deltaLength) * viewDistance; -+ player.playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect(SoundEffects.dK, SoundCategory.WEATHER, relativeX, this.locY, relativeZ, 10000.0F, pitch)); ++ player.playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect(SoundEffects.ENTITY_LIGHTNING_BOLT_THUNDER, SoundCategory.WEATHER, relativeX, this.locY, relativeZ, 10000.0F, pitch)); + } else { -+ player.playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect(SoundEffects.dK, SoundCategory.WEATHER, this.locX, this.locY, this.locZ, 10000.0F, pitch)); ++ player.playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect(SoundEffects.ENTITY_LIGHTNING_BOLT_THUNDER, SoundCategory.WEATHER, this.locX, this.locY, this.locZ, 10000.0F, pitch)); + } + } + // CraftBukkit end - this.world.a((EntityHuman) null, this.locX, this.locY, this.locZ, SoundEffects.dJ, SoundCategory.WEATHER, 2.0F, 0.5F + this.random.nextFloat() * 0.2F); + this.world.a((EntityHuman) null, this.locX, this.locY, this.locZ, SoundEffects.ENTITY_LIGHTNING_BOLT_IMPACT, SoundCategory.WEATHER, 2.0F, 0.5F + this.random.nextFloat() * 0.2F); } -@@ -57,13 +86,17 @@ - BlockPosition blockposition = new BlockPosition(this); - - if (this.world.getGameRules().getBoolean("doFireTick") && this.world.areChunksLoaded(blockposition, 10) && this.world.getType(blockposition).getMaterial() == Material.AIR && Blocks.FIRE.canPlace(this.world, blockposition)) { -- this.world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData()); -+ // CraftBukkit start - add "!isEffect" -+ if (!isEffect && !CraftEventFactory.callBlockIgniteEvent(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this).isCancelled()) { -+ this.world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData()); -+ } -+ // CraftBukkit end - } - } +@@ -55,7 +76,7 @@ } } @@ -91,3 +56,28 @@ if (this.world.isClientSide) { this.world.d(2); } else if (!this.d) { +@@ -82,14 +103,22 @@ + BlockPosition blockposition = new BlockPosition(this); + + if (this.world.areChunksLoaded(blockposition, 10) && this.world.getType(blockposition).isAir() && iblockdata.canPlace(this.world, blockposition)) { +- this.world.setTypeUpdate(blockposition, iblockdata); ++ // CraftBukkit start - add "!isEffect" ++ if (!isEffect && !CraftEventFactory.callBlockIgniteEvent(world, blockposition, this).isCancelled()) { ++ this.world.setTypeUpdate(blockposition, iblockdata); ++ } ++ // CraftBukkit end + } + + for (int j = 0; j < i; ++j) { + BlockPosition blockposition1 = blockposition.a(this.random.nextInt(3) - 1, this.random.nextInt(3) - 1, this.random.nextInt(3) - 1); + + if (this.world.getType(blockposition1).isAir() && iblockdata.canPlace(this.world, blockposition1)) { +- this.world.setTypeUpdate(blockposition1, iblockdata); ++ // CraftBukkit start - add "!isEffect" ++ if (!isEffect && !CraftEventFactory.callBlockIgniteEvent(world, blockposition1, this).isCancelled()) { ++ this.world.setTypeUpdate(blockposition1, iblockdata); ++ } ++ // CraftBukkit end + } + } + diff --git a/paper-server/nms-patches/EntityLiving.patch b/paper-server/nms-patches/EntityLiving.patch index 72d5cdccba..df052af41f 100644 --- a/paper-server/nms-patches/EntityLiving.patch +++ b/paper-server/nms-patches/EntityLiving.patch @@ -25,10 +25,10 @@ public abstract class EntityLiving extends Entity { private static final Logger a = LogManager.getLogger(); -@@ -88,6 +106,20 @@ - private BlockPosition bF; - private DamageSource bG; - private long bH; +@@ -93,6 +111,20 @@ + protected int bw; + private float bO; + private float bP; + // CraftBukkit start + public int expToDrop; + public int maxAirTicks = 300; @@ -44,48 +44,35 @@ + } + // CraftBukkit end - public void killEntity() { - this.damageEntity(DamageSource.OUT_OF_WORLD, Float.MAX_VALUE); -@@ -102,7 +134,8 @@ + protected EntityLiving(EntityTypes entitytypes, World world) { + super(entitytypes, world); +@@ -103,7 +135,8 @@ this.updateEffects = true; this.activeItem = ItemStack.a; this.initAttributes(); - this.setHealth(this.getMaxHealth()); + // CraftBukkit - setHealth(getMaxHealth()) inlined and simplified to skip the instanceof check for EntityPlayer, as getBukkitEntity() is not initialized in constructor + this.datawatcher.set(EntityLiving.HEALTH, (float) this.getAttributeInstance(GenericAttributes.maxHealth).getValue()); - this.i = true; - this.aM = (float) ((Math.random() + 1.0D) * 0.009999999776482582D); + this.j = true; + this.aP = (float) ((Math.random() + 1.0D) * 0.009999999776482582D); this.setPosition(this.locX, this.locY, this.locZ); -@@ -140,7 +173,13 @@ +@@ -145,7 +178,13 @@ double d1 = Math.min((double) (0.2F + f / 15.0F), 2.5D); int i = (int) (150.0D * d1); -- ((WorldServer) this.world).a(EnumParticle.BLOCK_DUST, this.locX, this.locY, this.locZ, i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D, new int[] { Block.getCombinedId(iblockdata)}); +- ((WorldServer) this.world).a(new ParticleParamBlock(Particles.d, iblockdata), this.locX, this.locY, this.locZ, i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D); + // CraftBukkit start - visiblity api + if (this instanceof EntityPlayer) { -+ ((WorldServer) this.world).sendParticles((EntityPlayer) this, EnumParticle.BLOCK_DUST, false, this.locX, this.locY, this.locZ, i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D, new int[] { Block.getCombinedId(iblockdata)}); ++ ((WorldServer) this.world).sendParticles((EntityPlayer) this, new ParticleParamBlock(Particles.d, iblockdata), this.locX, this.locY, this.locZ, i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D); + } else { -+ ((WorldServer) this.world).a(EnumParticle.BLOCK_DUST, this.locX, this.locY, this.locZ, i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D, new int[] { Block.getCombinedId(iblockdata)}); ++ ((WorldServer) this.world).a(new ParticleParamBlock(Particles.d, iblockdata), this.locX, this.locY, this.locZ, i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D); + } + // CraftBukkit end } } -@@ -202,7 +241,11 @@ - this.stopRiding(); - } - } else { -- this.setAirTicks(300); -+ // CraftBukkit start - Only set if needed to work around a DataWatcher inefficiency -+ if (this.getAirTicks() != 300) { -+ this.setAirTicks(maxAirTicks); -+ } -+ // CraftBukkit end - } - - if (!this.world.isClientSide) { -@@ -259,6 +302,18 @@ - this.world.methodProfiler.b(); +@@ -264,6 +303,18 @@ + this.world.methodProfiler.e(); } + // CraftBukkit start @@ -103,9 +90,9 @@ protected void b(BlockPosition blockposition) { int i = EnchantmentManager.a(Enchantments.j, this); -@@ -274,19 +329,19 @@ +@@ -283,19 +334,19 @@ - protected void bO() { + protected void ca() { ++this.deathTicks; - if (this.deathTicks == 20) { + if (this.deathTicks >= 20 && !this.dead) { // CraftBukkit - (this.deathTicks == 20) -> (this.deathTicks >= 20 && !this.dead) @@ -113,14 +100,14 @@ - if (!this.world.isClientSide && (this.alwaysGivesExp() || this.lastDamageByPlayerTime > 0 && this.isDropExperience() && this.world.getGameRules().getBoolean("doMobLoot"))) { - i = this.getExpValue(this.killer); -- -- while (i > 0) { -- int j = EntityExperienceOrb.getOrbValue(i); + // CraftBukkit start - Update getExpReward() above if the removed if() changes! + i = this.expToDrop; + while (i > 0) { + int j = EntityExperienceOrb.getOrbValue(i); +- while (i > 0) { +- int j = EntityExperienceOrb.getOrbValue(i); +- - i -= j; - this.world.addEntity(new EntityExperienceOrb(this.world, this.locX, this.locY, this.locZ, j)); - } @@ -132,7 +119,7 @@ this.die(); -@@ -442,6 +497,17 @@ +@@ -455,6 +506,17 @@ } } @@ -150,7 +137,7 @@ if (nbttagcompound.hasKeyOfType("Health", 99)) { this.setHealth(nbttagcompound.getFloat("Health")); } -@@ -464,9 +530,15 @@ +@@ -478,9 +540,15 @@ } @@ -166,7 +153,7 @@ try { while (iterator.hasNext()) { MobEffectList mobeffectlist = (MobEffectList) iterator.next(); -@@ -484,6 +556,17 @@ +@@ -498,6 +566,17 @@ } catch (ConcurrentModificationException concurrentmodificationexception) { ; } @@ -184,20 +171,20 @@ if (this.updateEffects) { if (!this.world.isClientSide) { -@@ -585,6 +668,12 @@ +@@ -604,6 +683,12 @@ } - public void addEffect(MobEffect mobeffect) { + public boolean addEffect(MobEffect mobeffect) { + // CraftBukkit start + if (isTickingEffects) { + effectsToProcess.add(mobeffect); -+ return; ++ return true; + } + // CraftBukkit end - if (this.d(mobeffect)) { - MobEffect mobeffect1 = (MobEffect) this.effects.get(mobeffect.getMobEffect()); - -@@ -617,6 +706,12 @@ + if (!this.d(mobeffect)) { + return false; + } else { +@@ -640,6 +725,12 @@ @Nullable public MobEffect c(@Nullable MobEffectList mobeffectlist) { @@ -210,7 +197,7 @@ return (MobEffect) this.effects.remove(mobeffectlist); } -@@ -656,20 +751,52 @@ +@@ -681,20 +772,52 @@ } @@ -235,7 +222,7 @@ } - public final float getHealth() { + public float getHealth() { + // CraftBukkit start - Use unscaled health + if (this instanceof EntityPlayer) { + return (float) ((EntityPlayer) this).getBukkitEntity().getHealth(); @@ -264,7 +251,7 @@ this.datawatcher.set(EntityLiving.HEALTH, Float.valueOf(MathHelper.a(f, 0.0F, this.getMaxHealth()))); } -@@ -687,14 +814,16 @@ +@@ -712,14 +835,16 @@ } else { float f1 = f; @@ -283,8 +270,8 @@ + if (false && f > 0.0F && this.applyBlockingModifier(damagesource)) { this.damageShield(f); f = 0.0F; - if (!damagesource.a()) { -@@ -713,20 +842,39 @@ + if (!damagesource.b()) { +@@ -738,20 +863,39 @@ if ((float) this.noDamageTicks > (float) this.maxNoDamageTicks / 2.0F) { if (f <= this.lastDamage) { @@ -310,8 +297,8 @@ - this.damageEntity0(damagesource, f); + // this.damageEntity0(damagesource, f); + // CraftBukkit end - this.az = 10; - this.hurtTicks = this.az; + this.aC = 10; + this.hurtTicks = this.aC; } + // CraftBukkit start @@ -323,10 +310,10 @@ + } + // CraftBukkit end + - this.aA = 0.0F; + this.aD = 0.0F; Entity entity1 = damagesource.getEntity(); -@@ -833,19 +981,29 @@ +@@ -858,19 +1002,29 @@ EnumHand[] aenumhand = EnumHand.values(); int i = aenumhand.length; @@ -337,7 +324,7 @@ - ItemStack itemstack1 = this.b(enumhand); + itemstack1 = this.b(enumhand); - if (itemstack1.getItem() == Items.cY) { + if (itemstack1.getItem() == Items.TOTEM_OF_UNDYING) { itemstack = itemstack1.cloneItemStack(); - itemstack1.subtract(1); + // itemstack1.subtract(1); // CraftBukkit @@ -359,8 +346,8 @@ + // CraftBukkit end EntityPlayer entityplayer = (EntityPlayer) this; - entityplayer.b(StatisticList.b(Items.cY)); -@@ -859,7 +1017,7 @@ + entityplayer.b(StatisticList.ITEM_USED.b(Items.TOTEM_OF_UNDYING)); +@@ -884,7 +1038,7 @@ this.world.broadcastEntityEffect(this, (byte) 35); } @@ -369,7 +356,7 @@ } } -@@ -944,6 +1102,12 @@ +@@ -955,6 +1109,12 @@ boolean flag = this.lastDamageByPlayerTime > 0; this.a(flag, i, damagesource); @@ -382,7 +369,7 @@ } } -@@ -1033,8 +1197,13 @@ +@@ -1044,8 +1204,13 @@ int i = MathHelper.f((f - 3.0F - f2) * f1); if (i > 0) { @@ -391,13 +378,13 @@ + return; + } + // CraftBukkit end - this.a(this.e(i), 1.0F, 1.0F); + this.a(this.n(i), 1.0F, 1.0F); - this.damageEntity(DamageSource.FALL, (float) i); + // this.damageEntity(DamageSource.FALL, (float) i); // CraftBukkit - moved up int j = MathHelper.floor(this.locX); int k = MathHelper.floor(this.locY - 0.20000000298023224D); int l = MathHelper.floor(this.locZ); -@@ -1061,7 +1230,7 @@ +@@ -1072,7 +1237,7 @@ protected float applyArmorModifier(DamageSource damagesource, float f) { if (!damagesource.ignoresArmor()) { @@ -406,7 +393,7 @@ f = CombatMath.a(f, (float) this.getArmorStrength(), (float) this.getAttributeInstance(GenericAttributes.i).getValue()); } -@@ -1074,7 +1243,8 @@ +@@ -1085,7 +1250,8 @@ } else { int i; @@ -416,7 +403,7 @@ i = (this.getEffect(MobEffects.RESISTANCE).getAmplifier() + 1) * 5; int j = 25 - i; float f1 = f * (float) j; -@@ -1095,22 +1265,142 @@ +@@ -1106,22 +1272,142 @@ } } @@ -518,7 +505,7 @@ + // Apply blocking code // PAIL: steal from above + if (event.getDamage(DamageModifier.BLOCKING) < 0) { + this.damageShield((float) -event.getDamage(DamageModifier.BLOCKING)); -+ Entity entity = damagesource.i(); ++ Entity entity = damagesource.j(); + + if (entity instanceof EntityLiving) { + this.c((EntityLiving) entity); @@ -532,7 +519,7 @@ + // PAIL: Be sure to drag all this code from the EntityHuman subclass each update. + ((EntityHuman) this).applyExhaustion(damagesource.getExhaustionCost()); + if (f < 3.4028235E37F) { -+ ((EntityHuman) this).a(StatisticList.z, Math.round(f * 10.0F)); ++ ((EntityHuman) this).a(StatisticList.DAMAGE_TAKEN, Math.round(f * 10.0F)); + } + } + // CraftBukkit end @@ -569,7 +556,7 @@ } public CombatTracker getCombatTracker() { -@@ -1177,6 +1467,7 @@ +@@ -1188,6 +1474,7 @@ public AttributeMapBase getAttributeMap() { if (this.attributeMap == null) { this.attributeMap = new AttributeMapServer(); @@ -577,7 +564,7 @@ } return this.attributeMap; -@@ -1469,6 +1760,7 @@ +@@ -1490,6 +1777,7 @@ } if (this.onGround && !this.world.isClientSide) { @@ -585,7 +572,7 @@ this.setFlag(7, false); } } else { -@@ -1838,6 +2130,7 @@ +@@ -1891,6 +2179,7 @@ } if (!this.world.isClientSide) { @@ -593,7 +580,7 @@ this.setFlag(7, flag); } -@@ -1931,11 +2224,11 @@ +@@ -2018,11 +2307,11 @@ } public boolean isInteractable() { @@ -602,16 +589,16 @@ } public boolean isCollidable() { -- return this.isAlive() && !this.m_(); -+ return this.isAlive() && !this.m_() && this.collides; // CraftBukkit +- return this.isAlive() && !this.z_(); ++ return this.isAlive() && !this.z_() && this.collides; // CraftBukkit } - protected void ax() { -@@ -2072,7 +2365,27 @@ - protected void v() { + protected void aA() { +@@ -2182,7 +2471,27 @@ + protected void q() { if (!this.activeItem.isEmpty() && this.isHandRaised()) { this.b(this.activeItem, 16); -- this.a(this.cH(), this.activeItem.a(this.world, this)); +- this.a(this.cT(), this.activeItem.a(this.world, this)); + // CraftBukkit start - fire PlayerItemConsumeEvent + ItemStack itemstack; + if (this instanceof EntityPlayer) { @@ -631,17 +618,17 @@ + itemstack = this.activeItem.a(this.world, this); + } + -+ this.a(this.cH(), itemstack); ++ this.a(this.cT(), itemstack); + // CraftBukkit end - this.cN(); + this.cZ(); } -@@ -2151,10 +2464,18 @@ +@@ -2261,10 +2570,18 @@ } if (flag1) { - this.enderTeleportTo(this.locX, this.locY, this.locZ); -- if (world.getCubes(this, this.getBoundingBox()).isEmpty() && !world.containsLiquid(this.getBoundingBox())) { +- if (world.getCubes(this, this.getBoundingBox()) && !world.containsLiquid(this.getBoundingBox())) { - flag = true; + // CraftBukkit start - Teleport event + // this.enderTeleportTo(this.locX, this.locY, this.locZ); @@ -650,7 +637,7 @@ + if (!teleport.isCancelled()) { + Location to = teleport.getTo(); + this.enderTeleportTo(to.getX(), to.getY(), to.getZ()); -+ if (world.getCubes(this, this.getBoundingBox()).isEmpty() && !world.containsLiquid(this.getBoundingBox())) { ++ if (world.getCubes((Entity) this, this.getBoundingBox()) && !world.containsLiquid(this.getBoundingBox())) { + flag = true; + } } diff --git a/paper-server/nms-patches/EntityLlamaSpit.patch b/paper-server/nms-patches/EntityLlamaSpit.patch index 4b284248e7..02f5ea83ff 100644 --- a/paper-server/nms-patches/EntityLlamaSpit.patch +++ b/paper-server/nms-patches/EntityLlamaSpit.patch @@ -15,5 +15,5 @@ public void a(MovingObjectPosition movingobjectposition) { + org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this, movingobjectposition); // Craftbukkit - Call event if (movingobjectposition.entity != null && this.shooter != null) { - movingobjectposition.entity.damageEntity(DamageSource.a(this, this.shooter).b(), 1.0F); + movingobjectposition.entity.damageEntity(DamageSource.a(this, (EntityLiving) this.shooter).c(), 1.0F); } diff --git a/paper-server/nms-patches/EntityMinecartAbstract.patch b/paper-server/nms-patches/EntityMinecartAbstract.patch index 7e9aac01da..d3ac7cc3f2 100644 --- a/paper-server/nms-patches/EntityMinecartAbstract.patch +++ b/paper-server/nms-patches/EntityMinecartAbstract.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/server/EntityMinecartAbstract.java +++ b/net/minecraft/server/EntityMinecartAbstract.java -@@ -6,6 +6,15 @@ - import java.util.Map; +@@ -8,6 +8,15 @@ + import java.util.function.ToIntFunction; import javax.annotation.Nullable; +// CraftBukkit start @@ -16,9 +16,9 @@ public abstract class EntityMinecartAbstract extends Entity implements INamableTileEntity { private static final DataWatcherObject a = DataWatcher.a(EntityMinecartAbstract.class, DataWatcherRegistry.b); -@@ -23,6 +32,17 @@ - private double ax; - private double ay; +@@ -25,6 +34,17 @@ + private double aA; + private double aB; + // CraftBukkit start + public boolean slowWhenEmpty = true; @@ -31,10 +31,10 @@ + public double maxSpeed = 0.4D; + // CraftBukkit end + - public EntityMinecartAbstract(World world) { - super(world); - this.i = true; -@@ -101,6 +121,19 @@ + protected EntityMinecartAbstract(EntityTypes entitytypes, World world) { + super(entitytypes, world); + this.j = true; +@@ -98,6 +118,19 @@ if (this.isInvulnerable(damagesource)) { return false; } else { @@ -51,10 +51,10 @@ + + f = (float) event.getDamage(); + // CraftBukkit end - this.e(-this.u()); - this.d(10); - this.ax(); -@@ -108,6 +141,15 @@ + this.l(-this.u()); + this.e(10); + this.aA(); +@@ -105,6 +138,15 @@ boolean flag = damagesource.getEntity() instanceof EntityHuman && ((EntityHuman) damagesource.getEntity()).abilities.canInstantlyBuild; if (flag || this.getDamage() > 40.0F) { @@ -70,10 +70,10 @@ this.ejectPassengers(); if (flag && !this.hasCustomName()) { this.die(); -@@ -146,6 +188,14 @@ +@@ -143,6 +185,14 @@ } - public void B_() { + public void tick() { + // CraftBukkit start + double prevX = this.locX; + double prevY = this.locY; @@ -83,9 +83,9 @@ + // CraftBukkit end + if (this.getType() > 0) { - this.d(this.getType() - 1); + this.e(this.getType() - 1); } -@@ -160,6 +210,8 @@ +@@ -157,6 +207,8 @@ int i; @@ -94,15 +94,15 @@ if (!this.world.isClientSide && this.world instanceof WorldServer) { this.world.methodProfiler.a("portal"); MinecraftServer minecraftserver = this.world.getMinecraftServer(); -@@ -199,6 +251,7 @@ +@@ -196,6 +248,7 @@ - this.world.methodProfiler.b(); + this.world.methodProfiler.e(); } + */ if (this.world.isClientSide) { - if (this.at > 0) { -@@ -266,6 +319,18 @@ + if (this.aw > 0) { +@@ -263,6 +316,18 @@ } this.setYawPitch(this.yaw, this.pitch); @@ -121,7 +121,7 @@ if (this.v() == EntityMinecartAbstract.EnumMinecartType.RIDEABLE && this.motX * this.motX + this.motZ * this.motZ > 0.01D) { List list = this.world.getEntities(this, this.getBoundingBox().grow(0.20000000298023224D, 0.0D, 0.20000000298023224D), IEntitySelector.a(this)); -@@ -274,8 +339,24 @@ +@@ -271,8 +336,24 @@ Entity entity = (Entity) list.get(l); if (!(entity instanceof EntityHuman) && !(entity instanceof EntityIronGolem) && !(entity instanceof EntityMinecartAbstract) && !this.isVehicle() && !entity.isPassenger()) { @@ -146,7 +146,7 @@ entity.collide(this); } } -@@ -287,6 +368,14 @@ +@@ -284,6 +365,14 @@ Entity entity1 = (Entity) iterator.next(); if (!this.w(entity1) && entity1.isCollidable() && entity1 instanceof EntityMinecartAbstract) { @@ -161,7 +161,7 @@ entity1.collide(this); } } -@@ -297,7 +386,7 @@ +@@ -294,7 +383,7 @@ } protected double p() { @@ -170,7 +170,7 @@ } public void a(int i, int j, int k, boolean flag) {} -@@ -308,16 +397,20 @@ +@@ -305,16 +394,20 @@ this.motX = MathHelper.a(this.motX, -d0, d0); this.motZ = MathHelper.a(this.motZ, -d0, d0); if (this.onGround) { @@ -197,7 +197,7 @@ } } -@@ -505,7 +598,7 @@ +@@ -502,7 +595,7 @@ } protected void r() { @@ -206,7 +206,7 @@ this.motX *= 0.996999979019165D; this.motY *= 0.0D; this.motZ *= 0.996999979019165D; -@@ -618,6 +711,14 @@ +@@ -599,6 +692,14 @@ if (!this.world.isClientSide) { if (!entity.noclip && !this.noclip) { if (!this.w(entity)) { @@ -221,8 +221,8 @@ double d0 = entity.locX - this.locX; double d1 = entity.locZ - this.locZ; double d2 = d0 * d0 + d1 * d1; -@@ -780,4 +881,26 @@ - +@@ -745,4 +846,26 @@ + return this.i; } } + diff --git a/paper-server/nms-patches/EntityMinecartCommandBlock.patch b/paper-server/nms-patches/EntityMinecartCommandBlock.patch index 1f44e4afca..e6ac3a1cfb 100644 --- a/paper-server/nms-patches/EntityMinecartCommandBlock.patch +++ b/paper-server/nms-patches/EntityMinecartCommandBlock.patch @@ -1,12 +1,15 @@ --- a/net/minecraft/server/EntityMinecartCommandBlock.java +++ b/net/minecraft/server/EntityMinecartCommandBlock.java -@@ -5,6 +5,9 @@ - public static final DataWatcherObject COMMAND = DataWatcher.a(EntityMinecartCommandBlock.class, DataWatcherRegistry.d); - private static final DataWatcherObject b = DataWatcher.a(EntityMinecartCommandBlock.class, DataWatcherRegistry.e); - private final CommandBlockListenerAbstract c = new CommandBlockListenerAbstract() { -+ { -+ this.sender = (org.bukkit.craftbukkit.entity.CraftMinecartCommand) EntityMinecartCommandBlock.this.getBukkitEntity(); // CraftBukkit - Set the sender +@@ -92,5 +92,12 @@ + public CommandListenerWrapper getWrapper() { + return new CommandListenerWrapper(this, new Vec3D(EntityMinecartCommandBlock.this.locX, EntityMinecartCommandBlock.this.locY, EntityMinecartCommandBlock.this.locZ), EntityMinecartCommandBlock.this.aO(), this.d(), 2, this.getName().getString(), EntityMinecartCommandBlock.this.getScoreboardDisplayName(), this.d().getMinecraftServer(), EntityMinecartCommandBlock.this); + } ++ ++ // CraftBukkit start ++ @Override ++ public org.bukkit.command.CommandSender getBukkitSender(CommandListenerWrapper wrapper) { ++ return (org.bukkit.craftbukkit.entity.CraftMinecartCommand) EntityMinecartCommandBlock.this.getBukkitEntity(); + } - public void i() { - EntityMinecartCommandBlock.this.getDataWatcher().set(EntityMinecartCommandBlock.COMMAND, this.getCommand()); - EntityMinecartCommandBlock.this.getDataWatcher().set(EntityMinecartCommandBlock.b, this.l()); ++ // CraftBukkit end + } + } diff --git a/paper-server/nms-patches/EntityMinecartContainer.patch b/paper-server/nms-patches/EntityMinecartContainer.patch index 19c2f366cf..f204468623 100644 --- a/paper-server/nms-patches/EntityMinecartContainer.patch +++ b/paper-server/nms-patches/EntityMinecartContainer.patch @@ -54,15 +54,15 @@ + } + // CraftBukkit end + - public EntityMinecartContainer(World world) { - super(world); + protected EntityMinecartContainer(EntityTypes entitytypes, World world) { + super(entitytypes, world); - this.items = NonNullList.a(36, ItemStack.a); + this.items = NonNullList.a(this.getSize(), ItemStack.a); // CraftBukkit - SPIGOT-3513 this.b = true; } - public EntityMinecartContainer(World world, double d0, double d1, double d2) { - super(world, d0, d1, d2); + protected EntityMinecartContainer(EntityTypes entitytypes, double d0, double d1, double d2, World world) { + super(entitytypes, world, d0, d1, d2); - this.items = NonNullList.a(36, ItemStack.a); + this.items = NonNullList.a(this.getSize(), ItemStack.a); // CraftBukkit - SPIGOT-3513 this.b = true; diff --git a/paper-server/nms-patches/EntityMonster.patch b/paper-server/nms-patches/EntityMonster.patch deleted file mode 100644 index 0a19ca7d49..0000000000 --- a/paper-server/nms-patches/EntityMonster.patch +++ /dev/null @@ -1,26 +0,0 @@ ---- a/net/minecraft/server/EntityMonster.java -+++ b/net/minecraft/server/EntityMonster.java -@@ -1,5 +1,7 @@ - package net.minecraft.server; - -+import org.bukkit.event.entity.EntityCombustByEntityEvent; // CraftBukkit -+ - public abstract class EntityMonster extends EntityCreature implements IMonster { - - public EntityMonster(World world) { -@@ -75,7 +77,14 @@ - int j = EnchantmentManager.getFireAspectEnchantmentLevel(this); - - if (j > 0) { -- entity.setOnFire(j * 4); -+ // CraftBukkit start - Call a combust event when somebody hits with a fire enchanted item -+ EntityCombustByEntityEvent combustEvent = new EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), j * 4); -+ org.bukkit.Bukkit.getPluginManager().callEvent(combustEvent); -+ -+ if (!combustEvent.isCancelled()) { -+ entity.setOnFire(combustEvent.getDuration()); -+ } -+ // CraftBukkit end - } - - if (entity instanceof EntityHuman) { diff --git a/paper-server/nms-patches/EntityMushroomCow.patch b/paper-server/nms-patches/EntityMushroomCow.patch index 4fa155b34e..8888c99b95 100644 --- a/paper-server/nms-patches/EntityMushroomCow.patch +++ b/paper-server/nms-patches/EntityMushroomCow.patch @@ -8,7 +8,7 @@ public class EntityMushroomCow extends EntityCow { -@@ -27,6 +28,14 @@ +@@ -23,6 +24,14 @@ return true; } else if (itemstack.getItem() == Items.SHEARS && this.getAge() >= 0) { @@ -21,5 +21,5 @@ + } + // CraftBukkit end this.die(); - this.world.addParticle(EnumParticle.EXPLOSION_LARGE, this.locX, this.locY + (double) (this.length / 2.0F), this.locZ, 0.0D, 0.0D, 0.0D, new int[0]); + this.world.addParticle(Particles.u, this.locX, this.locY + (double) (this.length / 2.0F), this.locZ, 0.0D, 0.0D, 0.0D); if (!this.world.isClientSide) { diff --git a/paper-server/nms-patches/EntityOcelot.patch b/paper-server/nms-patches/EntityOcelot.patch index 1caea988b0..9f18245bc5 100644 --- a/paper-server/nms-patches/EntityOcelot.patch +++ b/paper-server/nms-patches/EntityOcelot.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/EntityOcelot.java +++ b/net/minecraft/server/EntityOcelot.java -@@ -57,7 +57,7 @@ +@@ -60,7 +60,7 @@ } protected boolean isTypeNotPersistent() { @@ -9,7 +9,7 @@ } protected void initAttributes() { -@@ -108,7 +108,8 @@ +@@ -107,7 +107,8 @@ return false; } else { if (this.goalSit != null) { @@ -19,7 +19,7 @@ } return super.damageEntity(damagesource, f); -@@ -133,7 +134,8 @@ +@@ -132,7 +133,8 @@ } if (!this.world.isClientSide) { @@ -28,8 +28,8 @@ + if (this.random.nextInt(3) == 0 && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this, entityhuman).isCancelled()) { this.c(entityhuman); this.setCatType(1 + this.world.random.nextInt(3)); - this.p(true); -@@ -237,7 +239,7 @@ + this.s(true); +@@ -238,7 +240,7 @@ entityocelot.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, 0.0F); entityocelot.setAgeRaw(-24000); diff --git a/paper-server/nms-patches/EntityPainting.patch b/paper-server/nms-patches/EntityPainting.patch index 06269bbb4d..cc62b6709b 100644 --- a/paper-server/nms-patches/EntityPainting.patch +++ b/paper-server/nms-patches/EntityPainting.patch @@ -1,10 +1,13 @@ --- a/net/minecraft/server/EntityPainting.java +++ b/net/minecraft/server/EntityPainting.java -@@ -11,6 +11,7 @@ +@@ -11,6 +11,10 @@ public EntityPainting(World world) { - super(world); -+ this.art = EnumArt.values()[this.random.nextInt(EnumArt.values().length)]; // CraftBukkit - generate a non-null painting + super(EntityTypes.PAINTING, world); ++ // CraftBukkit start - generate a non-null painting ++ ArrayList arraylist = Lists.newArrayList(Paintings.a); ++ this.art = (Paintings) arraylist.get(this.random.nextInt(arraylist.size())); ++ // CraftBukkit end } public EntityPainting(World world, BlockPosition blockposition, EnumDirection enumdirection) { diff --git a/paper-server/nms-patches/EntityParrot.patch b/paper-server/nms-patches/EntityParrot.patch index 432c1d9750..07a227bb2f 100644 --- a/paper-server/nms-patches/EntityParrot.patch +++ b/paper-server/nms-patches/EntityParrot.patch @@ -1,33 +1,24 @@ --- a/net/minecraft/server/EntityParrot.java +++ b/net/minecraft/server/EntityParrot.java -@@ -15,7 +15,7 @@ - private static final DataWatcherObject bG = DataWatcher.a(EntityParrot.class, DataWatcherRegistry.b); - private static final Predicate bH = new Predicate() { - public boolean a(@Nullable EntityInsentient entityinsentient) { -- return entityinsentient != null && EntityParrot.bK.containsKey(EntityTypes.b.a((Object) entityinsentient.getClass())); -+ return entityinsentient != null && EntityParrot.bK.containsKey(EntityTypes.b.a(entityinsentient.getClass())); // CraftBukkit - decompile error - } - - public boolean apply(@Nullable Object object) { -@@ -114,7 +114,7 @@ - EntityInsentient entityinsentient = (EntityInsentient) list.get(world.random.nextInt(list.size())); - - if (!entityinsentient.isSilent()) { -- SoundEffect soundeffect = g(EntityTypes.b.a((Object) entityinsentient.getClass())); -+ SoundEffect soundeffect = g(EntityTypes.b.a(entityinsentient.getClass())); // CraftBukkit - decompile error - - world.a((EntityHuman) null, entity.locX, entity.locY, entity.locZ, soundeffect, entity.bK(), 0.7F, b(world.random)); - return true; -@@ -140,7 +140,7 @@ +@@ -27,7 +27,7 @@ + }; + private static final Item bN = Items.COOKIE; + private static final Set 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 + hashmap.put(EntityTypes.BLAZE, SoundEffects.ENTITY_PARROT_IMITATE_BLAZE); + hashmap.put(EntityTypes.CAVE_SPIDER, SoundEffects.ENTITY_PARROT_IMITATE_SPIDER); + hashmap.put(EntityTypes.CREEPER, SoundEffects.ENTITY_PARROT_IMITATE_CREEPER); +@@ -174,7 +174,7 @@ } if (!this.world.isClientSide) { - if (this.random.nextInt(10) == 0) { + if (this.random.nextInt(10) == 0 && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this, entityhuman).isCancelled()) { // CraftBukkit this.c(entityhuman); - this.p(true); + this.s(true); this.world.broadcastEntityEffect(this, (byte) 7); -@@ -276,7 +276,8 @@ +@@ -310,7 +310,8 @@ return false; } else { if (this.goalSit != null) { @@ -37,67 +28,3 @@ } return super.damageEntity(damagesource, f); -@@ -316,33 +317,35 @@ - } - - static { -- EntityParrot.bK.put(EntityTypes.b.a((Object) EntityBlaze.class), SoundEffects.eM); -- EntityParrot.bK.put(EntityTypes.b.a((Object) EntityCaveSpider.class), SoundEffects.fc); -- EntityParrot.bK.put(EntityTypes.b.a((Object) EntityCreeper.class), SoundEffects.eN); -- EntityParrot.bK.put(EntityTypes.b.a((Object) EntityGuardianElder.class), SoundEffects.eO); -- EntityParrot.bK.put(EntityTypes.b.a((Object) EntityEnderDragon.class), SoundEffects.eP); -- EntityParrot.bK.put(EntityTypes.b.a((Object) EntityEnderman.class), SoundEffects.eQ); -- EntityParrot.bK.put(EntityTypes.b.a((Object) EntityEndermite.class), SoundEffects.eR); -- EntityParrot.bK.put(EntityTypes.b.a((Object) EntityEvoker.class), SoundEffects.eS); -- EntityParrot.bK.put(EntityTypes.b.a((Object) EntityGhast.class), SoundEffects.eT); -- EntityParrot.bK.put(EntityTypes.b.a((Object) EntityZombieHusk.class), SoundEffects.eU); -- EntityParrot.bK.put(EntityTypes.b.a((Object) EntityIllagerIllusioner.class), SoundEffects.eV); -- EntityParrot.bK.put(EntityTypes.b.a((Object) EntityMagmaCube.class), SoundEffects.eW); -- EntityParrot.bK.put(EntityTypes.b.a((Object) EntityPigZombie.class), SoundEffects.fl); -- EntityParrot.bK.put(EntityTypes.b.a((Object) EntityPolarBear.class), SoundEffects.eX); -- EntityParrot.bK.put(EntityTypes.b.a((Object) EntityShulker.class), SoundEffects.eY); -- EntityParrot.bK.put(EntityTypes.b.a((Object) EntitySilverfish.class), SoundEffects.eZ); -- EntityParrot.bK.put(EntityTypes.b.a((Object) EntitySkeleton.class), SoundEffects.fa); -- EntityParrot.bK.put(EntityTypes.b.a((Object) EntitySlime.class), SoundEffects.fb); -- EntityParrot.bK.put(EntityTypes.b.a((Object) EntitySpider.class), SoundEffects.fc); -- EntityParrot.bK.put(EntityTypes.b.a((Object) EntitySkeletonStray.class), SoundEffects.fd); -- EntityParrot.bK.put(EntityTypes.b.a((Object) EntityVex.class), SoundEffects.fe); -- EntityParrot.bK.put(EntityTypes.b.a((Object) EntityVindicator.class), SoundEffects.ff); -- EntityParrot.bK.put(EntityTypes.b.a((Object) EntityWitch.class), SoundEffects.fg); -- EntityParrot.bK.put(EntityTypes.b.a((Object) EntityWither.class), SoundEffects.fh); -- EntityParrot.bK.put(EntityTypes.b.a((Object) EntitySkeletonWither.class), SoundEffects.fi); -- EntityParrot.bK.put(EntityTypes.b.a((Object) EntityWolf.class), SoundEffects.fj); -- EntityParrot.bK.put(EntityTypes.b.a((Object) EntityZombie.class), SoundEffects.fk); -- EntityParrot.bK.put(EntityTypes.b.a((Object) EntityZombieVillager.class), SoundEffects.fm); -+ // CraftBukkit start -+ EntityParrot.bK.put(EntityTypes.b.a(EntityBlaze.class), SoundEffects.eM); -+ EntityParrot.bK.put(EntityTypes.b.a(EntityCaveSpider.class), SoundEffects.fc); -+ EntityParrot.bK.put(EntityTypes.b.a(EntityCreeper.class), SoundEffects.eN); -+ EntityParrot.bK.put(EntityTypes.b.a(EntityGuardianElder.class), SoundEffects.eO); -+ EntityParrot.bK.put(EntityTypes.b.a(EntityEnderDragon.class), SoundEffects.eP); -+ EntityParrot.bK.put(EntityTypes.b.a(EntityEnderman.class), SoundEffects.eQ); -+ EntityParrot.bK.put(EntityTypes.b.a(EntityEndermite.class), SoundEffects.eR); -+ EntityParrot.bK.put(EntityTypes.b.a(EntityEvoker.class), SoundEffects.eS); -+ EntityParrot.bK.put(EntityTypes.b.a(EntityGhast.class), SoundEffects.eT); -+ EntityParrot.bK.put(EntityTypes.b.a(EntityZombieHusk.class), SoundEffects.eU); -+ EntityParrot.bK.put(EntityTypes.b.a(EntityIllagerIllusioner.class), SoundEffects.eV); -+ EntityParrot.bK.put(EntityTypes.b.a(EntityMagmaCube.class), SoundEffects.eW); -+ EntityParrot.bK.put(EntityTypes.b.a(EntityPigZombie.class), SoundEffects.fl); -+ EntityParrot.bK.put(EntityTypes.b.a(EntityPolarBear.class), SoundEffects.eX); -+ EntityParrot.bK.put(EntityTypes.b.a(EntityShulker.class), SoundEffects.eY); -+ EntityParrot.bK.put(EntityTypes.b.a(EntitySilverfish.class), SoundEffects.eZ); -+ EntityParrot.bK.put(EntityTypes.b.a(EntitySkeleton.class), SoundEffects.fa); -+ EntityParrot.bK.put(EntityTypes.b.a(EntitySlime.class), SoundEffects.fb); -+ EntityParrot.bK.put(EntityTypes.b.a(EntitySpider.class), SoundEffects.fc); -+ EntityParrot.bK.put(EntityTypes.b.a(EntitySkeletonStray.class), SoundEffects.fd); -+ EntityParrot.bK.put(EntityTypes.b.a(EntityVex.class), SoundEffects.fe); -+ EntityParrot.bK.put(EntityTypes.b.a(EntityVindicator.class), SoundEffects.ff); -+ EntityParrot.bK.put(EntityTypes.b.a(EntityWitch.class), SoundEffects.fg); -+ EntityParrot.bK.put(EntityTypes.b.a(EntityWither.class), SoundEffects.fh); -+ EntityParrot.bK.put(EntityTypes.b.a(EntitySkeletonWither.class), SoundEffects.fi); -+ EntityParrot.bK.put(EntityTypes.b.a(EntityWolf.class), SoundEffects.fj); -+ EntityParrot.bK.put(EntityTypes.b.a(EntityZombie.class), SoundEffects.fk); -+ EntityParrot.bK.put(EntityTypes.b.a(EntityZombieVillager.class), SoundEffects.fm); -+ // CraftBukkit end - } - } diff --git a/paper-server/nms-patches/EntityPhantom.patch b/paper-server/nms-patches/EntityPhantom.patch new file mode 100644 index 0000000000..a6589d3985 --- /dev/null +++ b/paper-server/nms-patches/EntityPhantom.patch @@ -0,0 +1,20 @@ +--- a/net/minecraft/server/EntityPhantom.java ++++ b/net/minecraft/server/EntityPhantom.java +@@ -186,7 +186,7 @@ + } else { + this.b = 60; + AxisAlignedBB axisalignedbb = EntityPhantom.this.getBoundingBox().grow(16.0D, 64.0D, 16.0D); +- List list = EntityPhantom.this.world.a(EntityHuman.class, axisalignedbb); ++ List list = EntityPhantom.this.world.a(EntityHuman.class, axisalignedbb); // CraftBukkit - decompile error + + if (!list.isEmpty()) { + list.sort((entityhuman, entityhuman1) -> { +@@ -198,7 +198,7 @@ + EntityHuman entityhuman = (EntityHuman) iterator.next(); + + if (PathfinderGoalTarget.a(EntityPhantom.this, entityhuman, false, false)) { +- EntityPhantom.this.setGoalTarget(entityhuman); ++ EntityPhantom.this.setGoalTarget(entityhuman, org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_PLAYER, true); // CraftBukkit - reason + return true; + } + } diff --git a/paper-server/nms-patches/EntityPig.patch b/paper-server/nms-patches/EntityPig.patch index 0af22aafb3..0266917607 100644 --- a/paper-server/nms-patches/EntityPig.patch +++ b/paper-server/nms-patches/EntityPig.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/server/EntityPig.java +++ b/net/minecraft/server/EntityPig.java -@@ -4,6 +4,8 @@ - import java.util.Set; +@@ -2,6 +2,8 @@ + import javax.annotation.Nullable; +import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit + public class EntityPig extends EntityAnimal { - private static final DataWatcherObject bx = DataWatcher.a(EntityPig.class, DataWatcherRegistry.h); -@@ -124,13 +126,14 @@ + private static final DataWatcherObject bC = DataWatcher.a(EntityPig.class, DataWatcherRegistry.i); +@@ -118,13 +120,14 @@ } public void die(DamageSource damagesource) { @@ -17,7 +17,7 @@ + // super.die(damagesource); // CraftBukkit - Moved to end if (!this.world.isClientSide) { if (this.hasSaddle()) { - this.a(Items.SADDLE, 1); + this.a((IMaterial) Items.SADDLE); } } @@ -25,7 +25,7 @@ } @Nullable -@@ -155,6 +158,12 @@ +@@ -149,6 +152,12 @@ if (!this.world.isClientSide && !this.dead) { EntityPigZombie entitypigzombie = new EntityPigZombie(this.world); @@ -38,7 +38,7 @@ entitypigzombie.setSlot(EnumItemSlot.MAINHAND, new ItemStack(Items.GOLDEN_SWORD)); entitypigzombie.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, this.pitch); entitypigzombie.setNoAI(this.isNoAI()); -@@ -163,7 +172,8 @@ +@@ -157,7 +166,8 @@ entitypigzombie.setCustomNameVisible(this.getCustomNameVisible()); } diff --git a/paper-server/nms-patches/EntityPlayer.patch b/paper-server/nms-patches/EntityPlayer.patch index 364fe7e447..71ab9dcde2 100644 --- a/paper-server/nms-patches/EntityPlayer.patch +++ b/paper-server/nms-patches/EntityPlayer.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/EntityPlayer.java +++ b/net/minecraft/server/EntityPlayer.java -@@ -11,10 +11,27 @@ +@@ -15,11 +15,29 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -8,6 +8,7 @@ +import com.google.common.base.Preconditions; +import org.bukkit.Bukkit; +import org.bukkit.GameMode; ++import org.bukkit.Location; +import org.bukkit.WeatherType; +import org.bukkit.craftbukkit.CraftWorld; +import org.bukkit.craftbukkit.entity.CraftPlayer; @@ -23,13 +24,14 @@ + public class EntityPlayer extends EntityHuman implements ICrafting { - private static final Logger bV = LogManager.getLogger(); + private static final Logger cc = LogManager.getLogger(); + private static final IChatBaseComponent cd = (new ChatMessage("multiplayer.message_not_delivered", new Object[0])).a(EnumChatFormat.RED); - public String locale = "en_US"; + public String locale = "en_us"; // CraftBukkit - lowercase public PlayerConnection playerConnection; public final MinecraftServer server; public final PlayerInteractManager playerInteractManager; -@@ -50,10 +67,45 @@ +@@ -55,6 +73,19 @@ public int ping; public boolean viewingCredits; @@ -47,69 +49,73 @@ + // CraftBukkit end + public EntityPlayer(MinecraftServer minecraftserver, WorldServer worldserver, GameProfile gameprofile, PlayerInteractManager playerinteractmanager) { - super(worldserver, gameprofile); + super((World) worldserver, gameprofile); playerinteractmanager.player = this; - this.playerInteractManager = playerinteractmanager; -+ // CraftBukkit start -+ BlockPosition blockposition = getSpawnPoint(minecraftserver, worldserver); -+ -+ this.server = minecraftserver; -+ this.bZ = minecraftserver.getPlayerList().getStatisticManager(this); -+ this.bY = minecraftserver.getPlayerList().h(this); -+ this.P = 1.0F; -+ this.setPositionRotation(blockposition, 0.0F, 0.0F); -+ // CraftBukkit end -+ -+ while (!worldserver.getCubes(this, this.getBoundingBox()).isEmpty() && this.locY < 255.0D) { -+ this.setPosition(this.locX, this.locY + 1.0D, this.locZ); -+ } +@@ -65,7 +96,49 @@ + this.cg = minecraftserver.getPlayerList().h(this); + this.Q = 1.0F; + this.a(worldserver); + + // CraftBukkit start + this.displayName = this.getName(); + this.canPickUpLoot = true; + this.maxHealthCache = this.getMaxHealth(); -+ // CraftBukkit end + } + -+ public final BlockPosition getSpawnPoint(MinecraftServer minecraftserver, WorldServer worldserver) { - BlockPosition blockposition = worldserver.getSpawn(); - - if (worldserver.worldProvider.m() && worldserver.getWorldData().getGameType() != EnumGamemode.ADVENTURE) { -@@ -71,17 +123,9 @@ - blockposition = worldserver.q(blockposition.a(this.random.nextInt(i * 2 + 1) - i, 0, this.random.nextInt(i * 2 + 1) - i)); - } - -- this.server = minecraftserver; -- this.bZ = minecraftserver.getPlayerList().getStatisticManager(this); -- this.bY = minecraftserver.getPlayerList().h(this); -- this.P = 1.0F; -- this.setPositionRotation(blockposition, 0.0F, 0.0F); -- -- while (!worldserver.getCubes(this, this.getBoundingBox()).isEmpty() && this.locY < 255.0D) { -- this.setPosition(this.locX, this.locY + 1.0D, this.locZ); -- } -- ++ // Yes, this doesn't match Vanilla, but it's the best we can do for now. ++ // If this is an issue, PRs are welcome ++ public final BlockPosition getSpawnPoint(WorldServer worldserver) { ++ BlockPosition blockposition = worldserver.getSpawn(); ++ ++ if (worldserver.worldProvider.g() && worldserver.getWorldData().getGameType() != EnumGamemode.ADVENTURE) { ++ int i = Math.max(0, this.server.a(worldserver)); ++ int j = MathHelper.floor(worldserver.getWorldBorder().b((double) blockposition.getX(), (double) blockposition.getZ())); ++ ++ if (j < i) { ++ i = j; ++ } ++ ++ if (j <= 1) { ++ i = 1; ++ } ++ ++ int k = (i * 2 + 1) * (i * 2 + 1); ++ int l = this.s(k); ++ int i1 = (new Random()).nextInt(k); ++ ++ for (int j1 = 0; j1 < k; ++j1) { ++ int k1 = (i1 + l * j1) % k; ++ int l1 = k1 % (i * 2 + 1); ++ int i2 = k1 / (i * 2 + 1); ++ BlockPosition blockposition1 = worldserver.o().a(blockposition.getX() + l1 - i, blockposition.getZ() + i2 - i, false); ++ ++ if (blockposition1 != null) { ++ return blockposition1; ++ } ++ } ++ } ++ + return blockposition; } + // CraftBukkit end - public void a(NBTTagCompound nbttagcompound) { - super.a(nbttagcompound); -@@ -103,6 +147,7 @@ + private void a(WorldServer worldserver) { + BlockPosition blockposition = worldserver.getSpawn(); +@@ -133,6 +206,7 @@ if (nbttagcompound.hasKeyOfType("recipeBook", 10)) { - this.cr.a(nbttagcompound.getCompound("recipeBook")); + this.cz.a(nbttagcompound.getCompound("recipeBook")); } + this.getBukkitEntity().readExtraData(nbttagcompound); // CraftBukkit } -@@ -149,7 +194,33 @@ +@@ -163,8 +237,34 @@ } - nbttagcompound.set("recipeBook", this.cr.c()); + nbttagcompound.set("recipeBook", this.cz.e()); + this.getBukkitEntity().setExtraData(nbttagcompound); // CraftBukkit -+ } -+ + } + + // CraftBukkit start - World fallback code, either respawn location or global spawn + public void spawnIn(World world) { + super.spawnIn(world); @@ -132,15 +138,16 @@ + } + this.dimension = ((WorldServer) this.world).dimension; + this.playerInteractManager.a((WorldServer) world); - } ++ } + // CraftBukkit end - - public void levelDown(int i) { - super.levelDown(i); -@@ -184,6 +255,11 @@ ++ + public void a(int i) { + float f = (float) this.getExpToLevel(); + float f1 = (f - 1.0F) / f; +@@ -211,6 +311,11 @@ } - public void B_() { + public void tick() { + // CraftBukkit start + if (this.joining) { + this.joining = false; @@ -149,17 +156,17 @@ this.playerInteractManager.a(); --this.invulnerableTicks; if (this.noDamageTicks > 0) { -@@ -249,7 +325,7 @@ +@@ -276,7 +381,7 @@ } - if (this.getHealth() != this.lastHealthSent || this.ch != this.foodData.getFoodLevel() || this.foodData.getSaturationLevel() == 0.0F != this.ci) { + if (this.getHealth() != this.lastHealthSent || this.cp != this.foodData.getFoodLevel() || this.foodData.getSaturationLevel() == 0.0F != this.cq) { - this.playerConnection.sendPacket(new PacketPlayOutUpdateHealth(this.getHealth(), this.foodData.getFoodLevel(), this.foodData.getSaturationLevel())); + this.playerConnection.sendPacket(new PacketPlayOutUpdateHealth(this.getBukkitEntity().getScaledHealth(), this.foodData.getFoodLevel(), this.foodData.getSaturationLevel())); // CraftBukkit this.lastHealthSent = this.getHealth(); - this.ch = this.foodData.getFoodLevel(); - this.ci = this.foodData.getSaturationLevel() == 0.0F; -@@ -270,6 +346,12 @@ - this.a(IScoreboardCriteria.i, MathHelper.f((float) this.cc)); + this.cp = this.foodData.getFoodLevel(); + this.cq = this.foodData.getSaturationLevel() == 0.0F; +@@ -307,6 +412,12 @@ + this.a(IScoreboardCriteria.k, MathHelper.f((float) this.cn)); } + // CraftBukkit start - Force max health updates @@ -168,11 +175,11 @@ + } + // CraftBukkit end + - if (this.getArmorStrength() != this.cd) { - this.cd = this.getArmorStrength(); - this.a(IScoreboardCriteria.j, MathHelper.f((float) this.cd)); -@@ -294,6 +376,16 @@ - CriterionTriggers.o.a(this); + if (this.expLevel != this.cm) { + this.cm = this.expLevel; + this.a(IScoreboardCriteria.l, MathHelper.f((float) this.cm)); +@@ -321,6 +432,16 @@ + CriterionTriggers.p.a(this); } + // CraftBukkit start - initialize oldLevel and fire PlayerLevelChangeEvent @@ -188,27 +195,22 @@ } catch (Throwable throwable) { CrashReport crashreport = CrashReport.a(throwable, "Ticking player"); CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Player being ticked"); -@@ -304,12 +396,11 @@ +@@ -331,7 +452,8 @@ } private void a(IScoreboardCriteria iscoreboardcriteria, int i) { -- Collection collection = this.getScoreboard().getObjectivesForCriteria(iscoreboardcriteria); -+ Collection collection = this.world.getServer().getScoreboardManager().getScoreboardScores(iscoreboardcriteria, this.getName(), new java.util.ArrayList()); // CraftBukkit - Use our scores instead - Iterator iterator = collection.iterator(); - - while (iterator.hasNext()) { -- ScoreboardObjective scoreboardobjective = (ScoreboardObjective) iterator.next(); -- ScoreboardScore scoreboardscore = this.getScoreboard().getPlayerScoreForObjective(this.getName(), scoreboardobjective); -+ ScoreboardScore scoreboardscore = (ScoreboardScore) iterator.next(); // CraftBukkit - Use our scores instead - +- this.getScoreboard().getObjectivesForCriteria(iscoreboardcriteria, this.getName(), (scoreboardscore) -> { ++ // CraftBukkit - Use our scores instead ++ this.world.getServer().getScoreboardManager().getScoreboardScores(iscoreboardcriteria, this.getName(), (scoreboardscore) -> { scoreboardscore.setScore(i); - } -@@ -320,32 +411,62 @@ + }); + } +@@ -340,27 +462,59 @@ boolean flag = this.world.getGameRules().getBoolean("showDeathMessages"); this.playerConnection.sendPacket(new PacketPlayOutCombatEvent(this.getCombatTracker(), PacketPlayOutCombatEvent.EnumCombatEventType.ENTITY_DIED, flag)); - if (flag) { -- ScoreboardTeamBase scoreboardteambase = this.aY(); +- ScoreboardTeamBase scoreboardteambase = this.be(); + // CraftBukkit start - fire PlayerDeathEvent + if (this.dead) { + return; @@ -223,22 +225,22 @@ + } + } + } -+ -+ IChatBaseComponent chatmessage = this.getCombatTracker().getDeathMessage(); -+ -+ String deathmessage = chatmessage.toPlainText(); -+ org.bukkit.event.entity.PlayerDeathEvent event = CraftEventFactory.callPlayerDeathEvent(this, loot, deathmessage, keepInventory); - if (scoreboardteambase != null && scoreboardteambase.getDeathMessageVisibility() != ScoreboardTeamBase.EnumNameTagVisibility.ALWAYS) { - if (scoreboardteambase.getDeathMessageVisibility() == ScoreboardTeamBase.EnumNameTagVisibility.HIDE_FOR_OTHER_TEAMS) { - this.server.getPlayerList().a((EntityHuman) this, this.getCombatTracker().getDeathMessage()); - } else if (scoreboardteambase.getDeathMessageVisibility() == ScoreboardTeamBase.EnumNameTagVisibility.HIDE_FOR_OWN_TEAM) { - this.server.getPlayerList().b((EntityHuman) this, this.getCombatTracker().getDeathMessage()); ++ IChatBaseComponent chatmessage = this.getCombatTracker().getDeathMessage(); ++ ++ String deathmessage = chatmessage.getString(); ++ org.bukkit.event.entity.PlayerDeathEvent event = CraftEventFactory.callPlayerDeathEvent(this, loot, deathmessage, keepInventory); ++ + String deathMessage = event.getDeathMessage(); + + if (deathMessage != null && deathMessage.length() > 0 && flag) { // TODO: allow plugins to override? + if (deathMessage.equals(deathmessage)) { -+ ScoreboardTeamBase scoreboardteambase = this.aY(); ++ ScoreboardTeamBase scoreboardteambase = this.be(); + + if (scoreboardteambase != null && scoreboardteambase.getDeathMessageVisibility() != ScoreboardTeamBase.EnumNameTagVisibility.ALWAYS) { + if (scoreboardteambase.getDeathMessageVisibility() == ScoreboardTeamBase.EnumNameTagVisibility.HIDE_FOR_OTHER_TEAMS) { @@ -257,85 +259,50 @@ this.releaseShoulderEntities(); - if (!this.world.getGameRules().getBoolean("keepInventory") && !this.isSpectator()) { -- this.cV(); -- this.inventory.o(); +- this.di(); +- this.inventory.q(); + // we clean the player's inventory after the EntityDeathEvent is called so plugins can get the exact state of the inventory. + if (!event.getKeepInventory()) { + this.inventory.clear(); } -- Collection collection = this.world.getScoreboard().getObjectivesForCriteria(IScoreboardCriteria.d); +- this.getScoreboard().getObjectivesForCriteria(IScoreboardCriteria.d, this.getName(), ScoreboardScore::incrementScore); + this.closeInventory(); + this.setSpectatorTarget(this); // Remove spectated target + // CraftBukkit end + + // CraftBukkit - Get our scores instead -+ Collection collection = this.world.getServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.d, this.getName(), new java.util.ArrayList()); - Iterator iterator = collection.iterator(); ++ this.world.getServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.d, this.getName(), ScoreboardScore::incrementScore); ++ + EntityLiving entityliving = this.cu(); - while (iterator.hasNext()) { -- ScoreboardObjective scoreboardobjective = (ScoreboardObjective) iterator.next(); -- ScoreboardScore scoreboardscore = this.getScoreboard().getPlayerScoreForObjective(this.getName(), scoreboardobjective); -+ ScoreboardScore scoreboardscore = (ScoreboardScore) iterator.next(); // CraftBukkit - Use our scores instead + if (entityliving != null) { +@@ -383,10 +537,12 @@ + String s = this.getName(); + String s1 = entity.getName(); - scoreboardscore.incrementScore(); - } -@@ -373,29 +494,36 @@ - if (entity != this) { - super.a(entity, i, damagesource); - this.addScore(i); -- Collection collection = this.getScoreboard().getObjectivesForCriteria(IScoreboardCriteria.f); +- this.getScoreboard().getObjectivesForCriteria(IScoreboardCriteria.f, s, ScoreboardScore::incrementScore); + // CraftBukkit - Get our scores instead -+ Collection collection = this.world.getServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.f, this.getName(), new java.util.ArrayList()); - ++ this.world.getServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.f, s, ScoreboardScore::incrementScore); if (entity instanceof EntityHuman) { - this.b(StatisticList.D); -- collection.addAll(this.getScoreboard().getObjectivesForCriteria(IScoreboardCriteria.e)); + this.a(StatisticList.PLAYER_KILLS); +- this.getScoreboard().getObjectivesForCriteria(IScoreboardCriteria.e, s, ScoreboardScore::incrementScore); + // CraftBukkit - Get our scores instead -+ this.world.getServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.e, this.getName(), collection); -+ // collection.addAll(this.getScoreboard().getObjectivesForCriteria(IScoreboardCriteria.e)); -+ // CraftBukkit end ++ this.world.getServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.e, s, ScoreboardScore::incrementScore); } else { - this.b(StatisticList.B); + this.a(StatisticList.MOB_KILLS); } +@@ -404,7 +560,8 @@ + int i = scoreboardteam.getColor().b(); - collection.addAll(this.E(entity)); -- Iterator iterator = collection.iterator(); -+ Iterator iterator = collection.iterator(); // CraftBukkit - - while (iterator.hasNext()) { -- ScoreboardObjective scoreboardobjective = (ScoreboardObjective) iterator.next(); -+ // CraftBukkit start -+ // ScoreboardObjective scoreboardobjective = (ScoreboardObjective) iterator.next(); - -- this.getScoreboard().getPlayerScoreForObjective(this.getName(), scoreboardobjective).incrementScore(); -+ // this.getScoreboard().getPlayerScoreForObjective(this.getName(), scoreboardobjective).incrementScore(); -+ iterator.next().incrementScore(); -+ // CraftBukkit end - } - - CriterionTriggers.b.a(this, entity, damagesource); - } - } - -- private Collection E(Entity entity) { -+ private Collection E(Entity entity) { // CraftBukkit - String s = entity instanceof EntityHuman ? entity.getName() : entity.bn(); - ScoreboardTeam scoreboardteam = this.getScoreboard().getPlayerTeam(this.getName()); - -@@ -420,7 +548,10 @@ - int j = scoreboardteam1.getColor().b(); - - if (j >= 0 && j < IScoreboardCriteria.m.length) { -- return this.getScoreboard().getObjectivesForCriteria(IScoreboardCriteria.m[j]); + if (i >= 0 && i < aiscoreboardcriteria.length) { +- this.getScoreboard().getObjectivesForCriteria(aiscoreboardcriteria[i], s, ScoreboardScore::incrementScore); + // CraftBukkit - Get our scores instead -+ return this.world.getServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.m[j], this.getName(), new java.util.ArrayList()); -+ // return this.getScoreboard().getObjectivesForCriteria(IScoreboardCriteria.m[j]); -+ // CraftBukkit end ++ this.world.getServer().getScoreboardManager().getScoreboardScores(aiscoreboardcriteria[i], s, ScoreboardScore::incrementScore); } } -@@ -462,12 +593,14 @@ +@@ -445,12 +602,14 @@ } private boolean canPvP() { @@ -345,14 +312,14 @@ } @Nullable - public Entity b(int i) { + public Entity d(int i) { - this.worldChangeInvuln = true; + if (this.isSleeping()) return this; // CraftBukkit - SPIGOT-3154 + // this.worldChangeInvuln = true; // CraftBukkit - Moved down and into PlayerList#changeDimension if (this.dimension == 0 && i == -1) { - this.cv = new Vec3D(this.locX, this.locY, this.locZ); + this.cD = new Vec3D(this.locX, this.locY, this.locZ); } else if (this.dimension != -1 && i != 0) { -@@ -475,6 +608,7 @@ +@@ -458,6 +617,7 @@ } if (this.dimension == 1 && i == 1) { @@ -360,7 +327,7 @@ this.world.kill(this); if (!this.viewingCredits) { this.viewingCredits = true; -@@ -488,7 +622,10 @@ +@@ -471,7 +631,10 @@ i = 1; } @@ -372,15 +339,15 @@ this.playerConnection.sendPacket(new PacketPlayOutWorldEvent(1032, BlockPosition.ZERO, 0, false)); this.lastSentExp = -1; this.lastHealthSent = -1.0F; -@@ -534,6 +671,7 @@ +@@ -517,6 +680,7 @@ } public void a(boolean flag, boolean flag1, boolean flag2) { + if (!this.sleeping) return; // CraftBukkit - Can't leave bed if not in one! if (this.isSleeping()) { - this.x().getTracker().sendPacketToEntity(this, new PacketPlayOutAnimation(this, 2)); + this.getWorldServer().getTracker().sendPacketToEntity(this, new PacketPlayOutAnimation(this, 2)); } -@@ -612,23 +750,55 @@ +@@ -595,23 +759,55 @@ this.playerConnection.sendPacket(new PacketPlayOutOpenSignEditor(tileentitysign.getPosition())); } @@ -391,12 +358,12 @@ } public void openTileEntity(ITileEntityContainer itileentitycontainer) { -- if (itileentitycontainer instanceof ILootable && ((ILootable) itileentitycontainer).b() != null && this.isSpectator()) { +- if (itileentitycontainer instanceof ILootable && ((ILootable) itileentitycontainer).Q_() != null && this.isSpectator()) { + // CraftBukkit start - Inventory open hook -+ if (false && itileentitycontainer instanceof ILootable && ((ILootable) itileentitycontainer).b() != null && this.isSpectator()) { - this.a((new ChatMessage("container.spectatorCantOpen", new Object[0])).setChatModifier((new ChatModifier()).setColor(EnumChatFormat.RED)), true); ++ if (false && itileentitycontainer instanceof ILootable && ((ILootable) itileentitycontainer).Q_() != null && this.isSpectator()) { + this.a((new ChatMessage("container.spectatorCantOpen", new Object[0])).a(EnumChatFormat.RED), true); } else { -+ boolean cancelled = itileentitycontainer instanceof ILootable && ((ILootable) itileentitycontainer).b() != null && this.isSpectator(); ++ boolean cancelled = itileentitycontainer instanceof ILootable && ((ILootable) itileentitycontainer).Q_() != null && this.isSpectator(); + Container container = CraftEventFactory.callInventoryOpenEvent(this, itileentitycontainer.createContainer(this.inventory, this), cancelled); + if (container == null) { + return; @@ -436,13 +403,13 @@ + } + // CraftBukkit end + - if (iinventory instanceof ILootable && ((ILootable) iinventory).b() != null && this.isSpectator()) { - this.a((new ChatMessage("container.spectatorCantOpen", new Object[0])).setChatModifier((new ChatModifier()).setColor(EnumChatFormat.RED)), true); + if (iinventory instanceof ILootable && ((ILootable) iinventory).Q_() != null && this.isSpectator()) { + this.a((new ChatMessage("container.spectatorCantOpen", new Object[0])).a(EnumChatFormat.RED), true); } else { -@@ -642,18 +812,21 @@ +@@ -625,18 +821,21 @@ if (itileinventory.isLocked() && !this.a(itileinventory.getLock()) && !this.isSpectator()) { this.playerConnection.sendPacket(new PacketPlayOutChat(new ChatMessage("container.isLocked", new Object[] { iinventory.getScoreboardDisplayName()}), ChatMessageType.GAME_INFO)); - this.playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect(SoundEffects.ab, SoundCategory.BLOCKS, this.locX, this.locY, this.locZ, 1.0F, 1.0F)); + this.playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect(SoundEffects.BLOCK_CHEST_LOCKED, SoundCategory.BLOCKS, this.locX, this.locY, this.locZ, 1.0F, 1.0F)); + iinventory.closeContainer(this); // CraftBukkit return; } @@ -463,7 +430,7 @@ this.activeContainer.windowId = this.containerCounter; this.activeContainer.addSlotListener(this); -@@ -661,8 +834,14 @@ +@@ -644,8 +843,14 @@ } public void openTrade(IMerchant imerchant) { @@ -478,8 +445,8 @@ + this.activeContainer = container; // CraftBukkit this.activeContainer.windowId = this.containerCounter; this.activeContainer.addSlotListener(this); - InventoryMerchant inventorymerchant = ((ContainerMerchant) this.activeContainer).e(); -@@ -682,13 +861,20 @@ + InventoryMerchant inventorymerchant = ((ContainerMerchant) this.activeContainer).d(); +@@ -665,13 +870,20 @@ } public void openHorseInventory(EntityHorseAbstract entityhorseabstract, IInventory iinventory) { @@ -501,7 +468,7 @@ this.activeContainer.windowId = this.containerCounter; this.activeContainer.addSlotListener(this); } -@@ -729,6 +915,11 @@ +@@ -712,6 +924,11 @@ public void a(Container container, NonNullList nonnulllist) { this.playerConnection.sendPacket(new PacketPlayOutWindowItems(container.windowId, nonnulllist)); this.playerConnection.sendPacket(new PacketPlayOutSetSlot(-1, -1, this.inventory.getCarried())); @@ -513,59 +480,59 @@ } public void setContainerData(Container container, int i, int j) { -@@ -743,6 +934,7 @@ +@@ -726,6 +943,7 @@ } public void closeInventory() { + CraftEventFactory.handleInventoryCloseEvent(this); // CraftBukkit this.playerConnection.sendPacket(new PacketPlayOutCloseWindow(this.activeContainer.windowId)); - this.r(); + this.m(); } -@@ -814,10 +1006,16 @@ - for (int j = 0; j < i; ++j) { - MinecraftKey minecraftkey = aminecraftkey1[j]; +@@ -759,14 +977,14 @@ -+ // CraftBukkit start -+ if (CraftingManager.a(minecraftkey) == null) { -+ Bukkit.getLogger().warning("Ignoring grant of non existent recipe " + minecraftkey); -+ continue; -+ } -+ // CraftBukit end - arraylist.add(CraftingManager.a(minecraftkey)); - } - -- this.a((List) arraylist); -+ this.a((List) arraylist); // CraftBukkit - decompile error + public void a(Statistic statistic, int i) { + this.ch.b(this, statistic, i); +- this.getScoreboard().getObjectivesForCriteria(statistic, this.getName(), (scoreboardscore) -> { ++ this.world.getServer().getScoreboardManager().getScoreboardScores(statistic, this.getName(), (scoreboardscore) -> { // CraftBukkit - Get our scores instead + scoreboardscore.addScore(i); + }); } - public void b(List list) { -@@ -839,7 +1037,16 @@ + public void a(Statistic statistic) { + this.ch.setStatistic(this, statistic, 0); +- this.getScoreboard().getObjectivesForCriteria(statistic, this.getName(), ScoreboardScore::c); ++ this.world.getServer().getScoreboardManager().getScoreboardScores(statistic, this.getName(), ScoreboardScore::c); // CraftBukkit - Get our scores instead + } + + public int a(Collection collection) { +@@ -814,8 +1032,17 @@ public void triggerHealthUpdate() { this.lastHealthSent = -1.0E8F; + this.lastSentExp = -1; // CraftBukkit - Added to reset -+ } -+ + } + + // CraftBukkit start - Support multi-line messages + public void sendMessage(IChatBaseComponent[] ichatbasecomponent) { + for (IChatBaseComponent component : ichatbasecomponent) { + this.sendMessage(component); + } - } ++ } + // CraftBukkit end - ++ public void a(IChatBaseComponent ichatbasecomponent, boolean flag) { this.playerConnection.sendPacket(new PacketPlayOutChat(ichatbasecomponent, flag ? ChatMessageType.GAME_INFO : ChatMessageType.CHAT)); -@@ -879,7 +1086,7 @@ + } +@@ -866,7 +1093,7 @@ this.lastSentExp = -1; this.lastHealthSent = -1.0F; - this.ch = -1; -- this.cr.a((RecipeBook) entityplayer.cr); -+ // this.cr.a((RecipeBook) entityplayer.cr); // CraftBukkit + this.cp = -1; +- this.cz.a((RecipeBook) entityplayer.cz); ++ // this.cz.a((RecipeBook) entityplayer.cz); // CraftBukkit this.removeQueue.addAll(entityplayer.removeQueue); - this.cq = entityplayer.cq; - this.cv = entityplayer.cv; -@@ -938,6 +1145,18 @@ + this.cy = entityplayer.cy; + this.cD = entityplayer.cD; +@@ -925,6 +1152,18 @@ } public void a(EnumGamemode enumgamemode) { @@ -584,31 +551,7 @@ this.playerInteractManager.setGameMode(enumgamemode); this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(3, (float) enumgamemode.getId())); if (enumgamemode == EnumGamemode.SPECTATOR) { -@@ -964,6 +1183,7 @@ - } - - public boolean a(int i, String s) { -+ /* CraftBukkit start - if ("seed".equals(s) && !this.server.aa()) { - return true; - } else if (!"tell".equals(s) && !"help".equals(s) && !"me".equals(s) && !"trigger".equals(s)) { -@@ -977,6 +1197,15 @@ - } else { - return true; - } -+ */ -+ if ("@".equals(s)) { -+ return getBukkitEntity().hasPermission("minecraft.command.selector"); -+ } -+ if ("".equals(s)) { -+ return getBukkitEntity().isOp(); -+ } -+ return getBukkitEntity().hasPermission("minecraft.command." + s); -+ // CraftBukkit end - } - - public String A() { -@@ -988,6 +1217,16 @@ +@@ -968,6 +1207,16 @@ } public void a(PacketPlayInSettings packetplayinsettings) { @@ -618,23 +561,23 @@ + this.server.server.getPluginManager().callEvent(event); + } + if (!this.locale.equals(packetplayinsettings.a())) { -+ PlayerLocaleChangeEvent event = new PlayerLocaleChangeEvent(getBukkitEntity(), packetplayinsettings.a()); ++ PlayerLocaleChangeEvent event = new PlayerLocaleChangeEvent(getBukkitEntity(), packetplayinsettings.b()); + this.server.server.getPluginManager().callEvent(event); + } + // CraftBukkit end - this.locale = packetplayinsettings.a(); - this.cl = packetplayinsettings.c(); - this.cm = packetplayinsettings.d(); -@@ -1053,7 +1292,7 @@ - this.co = (Entity) (entity == null ? this : entity); - if (entity1 != this.co) { - this.playerConnection.sendPacket(new PacketPlayOutCamera(this.co)); -- this.enderTeleportTo(this.co.locX, this.co.locY, this.co.locZ); -+ this.playerConnection.a(this.co.locX, this.co.locY, this.co.locZ, this.yaw, this.pitch, TeleportCause.SPECTATE); // CraftBukkit + this.locale = packetplayinsettings.b(); + this.ct = packetplayinsettings.d(); + this.cu = packetplayinsettings.e(); +@@ -1039,7 +1288,7 @@ + this.cw = (Entity) (entity == null ? this : entity); + if (entity1 != this.cw) { + this.playerConnection.sendPacket(new PacketPlayOutCamera(this.cw)); +- this.enderTeleportTo(this.cw.locX, this.cw.locY, this.cw.locZ); ++ this.playerConnection.a(this.cw.locX, this.cw.locY, this.cw.locZ, this.yaw, this.pitch, TeleportCause.SPECTATE); // CraftBukkit } } -@@ -1080,7 +1319,7 @@ +@@ -1066,7 +1315,7 @@ @Nullable public IChatBaseComponent getPlayerListName() { @@ -643,15 +586,15 @@ } public void a(EnumHand enumhand) { -@@ -1097,12 +1336,17 @@ +@@ -1083,12 +1332,17 @@ } - public void N() { + public void J() { + if (!CraftEventFactory.callToggleGlideEvent(this, true).isCancelled()) // CraftBukkit this.setFlag(7, true); } - public void O() { + public void K() { + // CraftBukkit start + if (!CraftEventFactory.callToggleGlideEvent(this, false).isCancelled()) { this.setFlag(7, true); @@ -661,10 +604,32 @@ } public AdvancementDataPlayer getAdvancementData() { -@@ -1113,4 +1357,144 @@ - public Vec3D Q() { - return this.cv; +@@ -1100,9 +1354,16 @@ + return this.cD; } + ++ // CraftBukkit start + public void a(WorldServer worldserver, double d0, double d1, double d2, float f, float f1) { ++ this.a(worldserver, d0, d1, d2, f, f1, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.UNKNOWN); ++ } ++ ++ public void a(WorldServer worldserver, double d0, double d1, double d2, float f, float f1, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause cause) { ++ // CraftBukkit end + this.setSpectatorTarget(this); + this.stopRiding(); ++ /* CraftBukkit start - replace with bukkit handling for multi-world + if (worldserver == this.world) { + this.playerConnection.a(d0, d1, d2, f, f1); + } else { +@@ -1127,6 +1388,149 @@ + this.server.getPlayerList().b(this, worldserver); + this.server.getPlayerList().updateClient(this); + } ++ */ ++ this.getBukkitEntity().teleport(new Location(worldserver.getWorld(), d0, d1, d2, f, f1), cause); ++ // CraftBukkit end ++ ++ } + + // CraftBukkit start - Add per-player time and weather. + public long timeOffset = 0; @@ -799,10 +764,10 @@ + } + this.keepLevel = false; + } -+ + + @Override + public CraftPlayer getBukkitEntity() { + return (CraftPlayer) super.getBukkitEntity(); -+ } + } + // CraftBukkit end } diff --git a/paper-server/nms-patches/EntityPotion.patch b/paper-server/nms-patches/EntityPotion.patch index 117e59dc99..f39d8365e8 100644 --- a/paper-server/nms-patches/EntityPotion.patch +++ b/paper-server/nms-patches/EntityPotion.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/server/EntityPotion.java +++ b/net/minecraft/server/EntityPotion.java -@@ -6,6 +6,12 @@ - import javax.annotation.Nullable; +@@ -5,6 +5,12 @@ + import java.util.function.Predicate; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +// CraftBukkit start @@ -13,16 +13,16 @@ public class EntityPotion extends EntityProjectile { -@@ -87,7 +93,7 @@ +@@ -77,7 +83,7 @@ if (flag) { - this.n(); + this.l(); - } else if (!list.isEmpty()) { + } else if (true || !list.isEmpty()) { // CraftBukkit - Call event even if no effects to apply if (this.isLingering()) { this.a(itemstack, potionregistry); } else { -@@ -124,6 +130,7 @@ +@@ -114,6 +120,7 @@ private void a(MovingObjectPosition movingobjectposition, List list) { AxisAlignedBB axisalignedbb = this.getBoundingBox().grow(4.0D, 2.0D, 4.0D); List list1 = this.world.a(EntityLiving.class, axisalignedbb); @@ -30,7 +30,7 @@ if (!list1.isEmpty()) { Iterator iterator = list1.iterator(); -@@ -141,21 +148,46 @@ +@@ -131,21 +138,46 @@ d1 = 1.0D; } @@ -91,7 +91,7 @@ } } } -@@ -187,7 +219,14 @@ +@@ -177,7 +209,14 @@ entityareaeffectcloud.setColor(nbttagcompound.getInt("CustomPotionColor")); } diff --git a/paper-server/nms-patches/EntityProjectile.patch b/paper-server/nms-patches/EntityProjectile.patch index af70eb1b00..3e8aa8a0e0 100644 --- a/paper-server/nms-patches/EntityProjectile.patch +++ b/paper-server/nms-patches/EntityProjectile.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/server/EntityProjectile.java +++ b/net/minecraft/server/EntityProjectile.java -@@ -35,6 +35,7 @@ - public EntityProjectile(World world, EntityLiving entityliving) { - this(world, entityliving.locX, entityliving.locY + (double) entityliving.getHeadHeight() - 0.10000000149011612D, entityliving.locZ); +@@ -33,6 +33,7 @@ + this(entitytypes, entityliving.locX, entityliving.locY + (double) entityliving.getHeadHeight() - 0.10000000149011612D, entityliving.locZ, world); this.shooter = entityliving; + this.shooterId = entityliving.getUniqueID(); + this.projectileSource = (org.bukkit.entity.LivingEntity) entityliving.getBukkitEntity(); // CraftBukkit } - protected void i() {} -@@ -127,7 +128,7 @@ + protected void x_() {} +@@ -111,7 +112,7 @@ if (entity1.isInteractable()) { if (entity1 == this.d) { flag = true; @@ -17,7 +17,7 @@ this.d = entity1; flag = true; } else { -@@ -164,6 +165,11 @@ +@@ -148,6 +149,11 @@ this.e(movingobjectposition.a()); } else { this.a(movingobjectposition); diff --git a/paper-server/nms-patches/EntityRabbit.patch b/paper-server/nms-patches/EntityRabbit.patch index 890a0efdd1..91309d3b49 100644 --- a/paper-server/nms-patches/EntityRabbit.patch +++ b/paper-server/nms-patches/EntityRabbit.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/EntityRabbit.java +++ b/net/minecraft/server/EntityRabbit.java -@@ -16,8 +16,14 @@ +@@ -17,8 +17,14 @@ this.setSize(0.4F, 0.5F); - this.g = new EntityRabbit.ControllerJumpRabbit(this); + this.h = new EntityRabbit.ControllerJumpRabbit(this); this.moveController = new EntityRabbit.ControllerMoveRabbit(this); + this.initializePathFinderGoals(); // CraftBukkit - moved code + } @@ -13,14 +13,14 @@ } + // CraftBukkit end - protected void r() { + protected void n() { this.goalSelector.a(1, new PathfinderGoalFloat(this)); -@@ -400,9 +406,23 @@ +@@ -397,9 +403,23 @@ Integer integer = (Integer) iblockdata.get(BlockCarrots.AGE); if (integer.intValue() == 0) { + // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.c, blockposition, Blocks.AIR, 0).isCancelled()) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.f, blockposition, Blocks.AIR.getBlockData()).isCancelled()) { + return; + } + // CraftBukkit end @@ -29,13 +29,13 @@ } else { + // CraftBukkit start + if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent( -+ this.c, ++ this.f, + blockposition, -+ block, block.toLegacyData(iblockdata.set(BlockCarrots.AGE, Integer.valueOf(integer.intValue() - 1))) ++ iblockdata.set(BlockCarrots.AGE, Integer.valueOf(integer.intValue() - 1)) + ).isCancelled()) { + return; + } + // CraftBukkit end - world.setTypeAndData(blockposition, iblockdata.set(BlockCarrots.AGE, Integer.valueOf(integer.intValue() - 1)), 2); + world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockCarrots.AGE, Integer.valueOf(integer.intValue() - 1)), 2); world.triggerEffect(2001, blockposition, Block.getCombinedId(iblockdata)); } diff --git a/paper-server/nms-patches/EntitySheep.patch b/paper-server/nms-patches/EntitySheep.patch index 2f4845dba4..d9a10993c2 100644 --- a/paper-server/nms-patches/EntitySheep.patch +++ b/paper-server/nms-patches/EntitySheep.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/server/EntitySheep.java +++ b/net/minecraft/server/EntitySheep.java -@@ -5,6 +5,12 @@ - import java.util.Random; +@@ -10,6 +10,12 @@ + import java.util.stream.Collectors; import javax.annotation.Nullable; +// CraftBukkit start @@ -12,8 +12,8 @@ + public class EntitySheep extends EntityAnimal { - private static final DataWatcherObject bx = DataWatcher.a(EntitySheep.class, DataWatcherRegistry.a); -@@ -12,6 +18,13 @@ + private static final DataWatcherObject bC = DataWatcher.a(EntitySheep.class, DataWatcherRegistry.a); +@@ -17,8 +23,15 @@ public boolean canUse(EntityHuman entityhuman) { return false; } @@ -25,17 +25,12 @@ + } + // CraftBukkit end }, 2, 1); - private static final Map bz = Maps.newEnumMap(EnumColor.class); - private int bB; -@@ -29,6 +42,7 @@ - this.setSize(0.9F, 1.3F); - this.container.setItem(0, new ItemStack(Items.DYE)); - this.container.setItem(1, new ItemStack(Items.DYE)); -+ this.container.resultInventory = new InventoryCraftResult(); // CraftBukkit - add result slot for event - } - - protected void r() { -@@ -131,11 +145,22 @@ +- private static final Map 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 + enummap.put(EnumColor.WHITE, Blocks.WHITE_WOOL); + enummap.put(EnumColor.ORANGE, Blocks.ORANGE_WOOL); + enummap.put(EnumColor.MAGENTA, Blocks.MAGENTA_WOOL); +@@ -158,11 +171,22 @@ if (itemstack.getItem() == Items.SHEARS && !this.isSheared() && !this.isBaby()) { if (!this.world.isClientSide) { @@ -53,15 +48,15 @@ for (int j = 0; j < i; ++j) { + this.forceDrops = true; // CraftBukkit - EntityItem entityitem = this.a(new ItemStack(Item.getItemOf(Blocks.WOOL), 1, this.getColor().getColorIndex()), 1.0F); + EntityItem entityitem = this.a((IMaterial) EntitySheep.bE.get(this.getColor()), 1); + this.forceDrops = false; // CraftBukkit - entityitem.motY += (double) (this.random.nextFloat() * 0.05F); - entityitem.motX += (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F); -@@ -222,6 +247,12 @@ + if (entityitem != null) { + entityitem.motY += (double) (this.random.nextFloat() * 0.05F); +@@ -247,6 +271,12 @@ } - public void A() { + public void x() { + // CraftBukkit start + SheepRegrowWoolEvent event = new SheepRegrowWoolEvent((org.bukkit.entity.Sheep) this.getBukkitEntity()); + this.world.getServer().getPluginManager().callEvent(event); @@ -71,3 +66,11 @@ this.setSheared(false); if (this.isBaby()) { this.setAge(60); +@@ -267,6 +297,7 @@ + + this.container.setItem(0, new ItemStack(ItemDye.a(enumcolor))); + this.container.setItem(1, new ItemStack(ItemDye.a(enumcolor1))); ++ this.container.resultInventory = new InventoryCraftResult(); // CraftBukkit - add result slot for event + ItemStack itemstack = entityanimal.world.D().craft(this.container, ((EntitySheep) entityanimal).world); + Item item = itemstack.getItem(); + EnumColor enumcolor2; diff --git a/paper-server/nms-patches/EntityShulker.patch b/paper-server/nms-patches/EntityShulker.patch index 9b21b29306..80e651f4d6 100644 --- a/paper-server/nms-patches/EntityShulker.patch +++ b/paper-server/nms-patches/EntityShulker.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/EntityShulker.java +++ b/net/minecraft/server/EntityShulker.java @@ -6,6 +6,10 @@ - import java.util.List; import java.util.UUID; + import java.util.function.Predicate; import javax.annotation.Nullable; +// CraftBukkit start +import org.bukkit.Location; @@ -11,19 +11,10 @@ public class EntityShulker extends EntityGolem implements IMonster { -@@ -112,7 +116,7 @@ - - this.datawatcher.set(EntityShulker.b, Optional.of(new BlockPosition(i, j, k))); - } else { -- this.datawatcher.set(EntityShulker.b, Optional.absent()); -+ this.datawatcher.set(EntityShulker.b, Optional.absent()); - } - - } -@@ -331,8 +335,17 @@ +@@ -326,8 +330,17 @@ EnumDirection enumdirection = aenumdirection[k]; - if (this.world.d(blockposition1.shift(enumdirection), false)) { + if (this.world.q(blockposition1.shift(enumdirection))) { - this.datawatcher.set(EntityShulker.a, enumdirection); - flag = true; + // CraftBukkit start diff --git a/paper-server/nms-patches/EntityShulkerBullet.patch b/paper-server/nms-patches/EntityShulkerBullet.patch index 915d374759..a3b154008b 100644 --- a/paper-server/nms-patches/EntityShulkerBullet.patch +++ b/paper-server/nms-patches/EntityShulkerBullet.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/EntityShulkerBullet.java +++ b/net/minecraft/server/EntityShulkerBullet.java -@@ -46,8 +46,29 @@ +@@ -42,8 +42,29 @@ this.target = entity; this.c = EnumDirection.UP; this.a(enumdirection_enumaxis); @@ -27,14 +27,14 @@ + } + // CraftBukkit end + - protected void b(NBTTagCompound nbttagcompound) { - BlockPosition blockposition; - NBTTagCompound nbttagcompound1; + public SoundCategory bV() { + return SoundCategory.HOSTILE; + } @@ -287,6 +308,7 @@ } protected void a(MovingObjectPosition movingobjectposition) { + org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this, movingobjectposition); // Craftbukkit - Call event if (movingobjectposition.entity == null) { - ((WorldServer) this.world).a(EnumParticle.EXPLOSION_LARGE, this.locX, this.locY, this.locZ, 2, 0.2D, 0.2D, 0.2D, 0.0D, new int[0]); - this.a(SoundEffects.gD, 1.0F, 1.0F); + ((WorldServer) this.world).a(Particles.u, this.locX, this.locY, this.locZ, 2, 0.2D, 0.2D, 0.2D, 0.0D); + this.a(SoundEffects.ENTITY_SHULKER_BULLET_HIT, 1.0F, 1.0F); diff --git a/paper-server/nms-patches/EntitySilverfish.patch b/paper-server/nms-patches/EntitySilverfish.patch index c631fa4c03..6eeae7d5bb 100644 --- a/paper-server/nms-patches/EntitySilverfish.patch +++ b/paper-server/nms-patches/EntitySilverfish.patch @@ -1,23 +1,23 @@ --- a/net/minecraft/server/EntitySilverfish.java +++ b/net/minecraft/server/EntitySilverfish.java -@@ -157,6 +157,11 @@ +@@ -153,6 +153,11 @@ IBlockData iblockdata = world.getType(blockposition); - if (BlockMonsterEggs.x(iblockdata)) { + if (BlockMonsterEggs.j(iblockdata)) { + // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.a, blockposition, Blocks.MONSTER_EGG, Block.getId(BlockMonsterEggs.getById(iblockdata.getBlock().toLegacyData(iblockdata)))).isCancelled()) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.a, blockposition, BlockMonsterEggs.f(iblockdata.getBlock())).isCancelled()) { + return; + } + // CraftBukkit end - world.setTypeAndData(blockposition, Blocks.MONSTER_EGG.getBlockData().set(BlockMonsterEggs.VARIANT, BlockMonsterEggs.EnumMonsterEggVarient.a(iblockdata)), 3); + world.setTypeAndData(blockposition, BlockMonsterEggs.f(iblockdata.getBlock()), 3); this.a.doSpawnEffect(); this.a.die(); -@@ -200,6 +205,11 @@ - IBlockData iblockdata = world.getType(blockposition1); +@@ -197,6 +202,11 @@ + Block block = iblockdata.getBlock(); - if (iblockdata.getBlock() == Blocks.MONSTER_EGG) { + if (block instanceof BlockMonsterEggs) { + // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.silverfish, blockposition1, Blocks.AIR, 0).isCancelled()) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.silverfish, blockposition1, Blocks.AIR.getBlockData()).isCancelled()) { + continue; + } + // CraftBukkit end diff --git a/paper-server/nms-patches/EntitySkeleton.patch b/paper-server/nms-patches/EntitySkeleton.patch index 1824371042..c763f72117 100644 --- a/paper-server/nms-patches/EntitySkeleton.patch +++ b/paper-server/nms-patches/EntitySkeleton.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/EntitySkeleton.java +++ b/net/minecraft/server/EntitySkeleton.java -@@ -34,7 +34,7 @@ +@@ -30,7 +30,7 @@ } public void die(DamageSource damagesource) { @@ -9,8 +9,8 @@ if (damagesource.getEntity() instanceof EntityCreeper) { EntityCreeper entitycreeper = (EntityCreeper) damagesource.getEntity(); -@@ -43,6 +43,7 @@ - this.a(new ItemStack(Items.SKULL, 1, 0), 0.0F); +@@ -39,6 +39,7 @@ + this.a((IMaterial) Items.SKELETON_SKULL); } } + super.die(damagesource); // CraftBukkit - moved from above diff --git a/paper-server/nms-patches/EntitySkeletonAbstract.patch b/paper-server/nms-patches/EntitySkeletonAbstract.patch index 424cca7c39..9b16ed8208 100644 --- a/paper-server/nms-patches/EntitySkeletonAbstract.patch +++ b/paper-server/nms-patches/EntitySkeletonAbstract.patch @@ -1,37 +1,37 @@ --- a/net/minecraft/server/EntitySkeletonAbstract.java +++ b/net/minecraft/server/EntitySkeletonAbstract.java -@@ -2,12 +2,13 @@ - - import java.util.Calendar; +@@ -3,12 +3,13 @@ + import java.time.LocalDate; + import java.time.temporal.ChronoField; import javax.annotation.Nullable; +import org.bukkit.event.entity.EntityCombustEvent; // CraftBukkit public abstract class EntitySkeletonAbstract extends EntityMonster implements IRangedEntity { - private static final DataWatcherObject a = DataWatcher.a(EntitySkeletonAbstract.class, DataWatcherRegistry.h); + private static final DataWatcherObject a = DataWatcher.a(EntitySkeletonAbstract.class, DataWatcherRegistry.i); private final PathfinderGoalBowShoot b = new PathfinderGoalBowShoot(this, 1.0D, 20, 15.0F); - private final PathfinderGoalMeleeAttack c = new PathfinderGoalMeleeAttack(this, 1.2D, flag) { + private final PathfinderGoalMeleeAttack c = new PathfinderGoalMeleeAttack(this, 1.2D, false) { // CraftBukkit - decompile error public void d() { super.d(); - EntitySkeletonAbstract.this.p(false); -@@ -80,7 +81,14 @@ - } + EntitySkeletonAbstract.this.s(false); +@@ -78,7 +79,14 @@ + } - if (flag) { -- this.setOnFire(8); -+ // CraftBukkit start -+ EntityCombustEvent event = new EntityCombustEvent(this.getBukkitEntity(), 8); -+ this.world.getServer().getPluginManager().callEvent(event); + if (flag) { +- this.setOnFire(8); ++ // CraftBukkit start ++ EntityCombustEvent event = new EntityCombustEvent(this.getBukkitEntity(), 8); ++ this.world.getServer().getPluginManager().callEvent(event); + -+ if (!event.isCancelled()) { -+ this.setOnFire(event.getDuration()); -+ } -+ // CraftBukkit end - } ++ if (!event.isCancelled()) { ++ this.setOnFire(event.getDuration()); ++ } ++ // CraftBukkit end } } -@@ -152,8 +160,19 @@ + +@@ -151,8 +159,19 @@ double d3 = (double) MathHelper.sqrt(d0 * d0 + d2 * d2); entityarrow.shoot(d0, d1 + d3 * 0.20000000298023224D, d2, 1.6F, (float) (14 - this.world.getDifficulty().a() * 4)); @@ -46,7 +46,7 @@ + world.addEntity(entityarrow); + } + // CraftBukkit end - this.a(SoundEffects.gW, 1.0F, 1.0F / (this.getRandom().nextFloat() * 0.4F + 0.8F)); + this.a(SoundEffects.ENTITY_SKELETON_SHOOT, 1.0F, 1.0F / (this.getRandom().nextFloat() * 0.4F + 0.8F)); - this.world.addEntity(entityarrow); + // this.world.addEntity(entityarrow); // CraftBukkit - moved up } diff --git a/paper-server/nms-patches/EntitySkeletonWither.patch b/paper-server/nms-patches/EntitySkeletonWither.patch index 25d7fc871c..d66a1b59e4 100644 --- a/paper-server/nms-patches/EntitySkeletonWither.patch +++ b/paper-server/nms-patches/EntitySkeletonWither.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/EntitySkeletonWither.java +++ b/net/minecraft/server/EntitySkeletonWither.java -@@ -36,7 +36,7 @@ +@@ -32,7 +32,7 @@ } public void die(DamageSource damagesource) { @@ -9,8 +9,8 @@ if (damagesource.getEntity() instanceof EntityCreeper) { EntityCreeper entitycreeper = (EntityCreeper) damagesource.getEntity(); -@@ -45,6 +45,7 @@ - this.a(new ItemStack(Items.SKULL, 1, 1), 0.0F); +@@ -41,6 +41,7 @@ + this.a((IMaterial) Items.WITHER_SKELETON_SKULL); } } + super.die(damagesource); // CraftBukkit - moved from above diff --git a/paper-server/nms-patches/EntitySlime.patch b/paper-server/nms-patches/EntitySlime.patch index 6e55a144bb..0e817f257b 100644 --- a/paper-server/nms-patches/EntitySlime.patch +++ b/paper-server/nms-patches/EntitySlime.patch @@ -10,6 +10,15 @@ public class EntitySlime extends EntityInsentient implements IMonster { +@@ -134,7 +137,7 @@ + } + + public EntityTypes P() { +- return super.P(); ++ return (EntityTypes) super.P(); // CraftBukkit - decompile error + } + + public void die() { @@ -143,6 +146,18 @@ if (!this.world.isClientSide && i > 1 && this.getHealth() <= 0.0F) { int j = 2 + this.random.nextInt(3); diff --git a/paper-server/nms-patches/EntitySmallFireball.patch b/paper-server/nms-patches/EntitySmallFireball.patch index 0833ca94f2..0a93a44cbf 100644 --- a/paper-server/nms-patches/EntitySmallFireball.patch +++ b/paper-server/nms-patches/EntitySmallFireball.patch @@ -8,10 +8,10 @@ public class EntitySmallFireball extends EntityFireball { public EntitySmallFireball(World world) { -@@ -10,6 +12,11 @@ +@@ -8,6 +10,11 @@ + public EntitySmallFireball(World world, EntityLiving entityliving, double d0, double d1, double d2) { - super(world, entityliving, d0, d1, d2); - this.setSize(0.3125F, 0.3125F); + super(EntityTypes.SMALL_FIREBALL, entityliving, d0, d1, d2, world, 0.3125F, 0.3125F); + // CraftBukkit start + if (this.shooter != null && this.shooter instanceof EntityInsentient) { + isIncendiary = this.world.getGameRules().getBoolean("mobGriefing"); @@ -20,7 +20,7 @@ } public EntitySmallFireball(World world, double d0, double d1, double d2, double d3, double d4, double d5) { -@@ -27,10 +34,17 @@ +@@ -20,10 +27,17 @@ if (movingobjectposition.entity != null) { if (!movingobjectposition.entity.isFireProof()) { @@ -41,7 +41,7 @@ } } } else { -@@ -39,11 +53,15 @@ +@@ -32,11 +46,15 @@ flag = this.world.getGameRules().getBoolean("mobGriefing"); } @@ -52,7 +52,7 @@ if (this.world.isEmpty(blockposition)) { - this.world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData()); -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this).isCancelled()) { ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition, this).isCancelled()) { + this.world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData()); + } + // CraftBukkit end diff --git a/paper-server/nms-patches/EntitySnowman.patch b/paper-server/nms-patches/EntitySnowman.patch index bf919be5b2..d78d57264a 100644 --- a/paper-server/nms-patches/EntitySnowman.patch +++ b/paper-server/nms-patches/EntitySnowman.patch @@ -11,25 +11,25 @@ public class EntitySnowman extends EntityGolem implements IRangedEntity { -@@ -59,7 +63,7 @@ +@@ -55,7 +59,7 @@ } - if (this.world.getBiome(new BlockPosition(i, 0, k)).a(new BlockPosition(i, j, k)) > 1.0F) { + if (this.world.getBiome(new BlockPosition(i, 0, k)).c(new BlockPosition(i, j, k)) > 1.0F) { - this.damageEntity(DamageSource.BURN, 1.0F); + this.damageEntity(CraftEventFactory.MELTING, 1.0F); // CraftBukkit - DamageSource.BURN -> CraftEventFactory.MELTING } if (!this.world.getGameRules().getBoolean("mobGriefing")) { -@@ -73,7 +77,7 @@ +@@ -71,7 +75,7 @@ BlockPosition blockposition = new BlockPosition(i, j, k); - if (this.world.getType(blockposition).getMaterial() == Material.AIR && this.world.getBiome(blockposition).a(blockposition) < 0.8F && Blocks.SNOW_LAYER.canPlace(this.world, blockposition)) { -- this.world.setTypeUpdate(blockposition, Blocks.SNOW_LAYER.getBlockData()); -+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this.world, blockposition, Blocks.SNOW_LAYER.getBlockData(), this); // CraftBukkit + if (this.world.getType(blockposition).isAir() && this.world.getBiome(blockposition).c(blockposition) < 0.8F && iblockdata.canPlace(this.world, blockposition)) { +- this.world.setTypeUpdate(blockposition, iblockdata); ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this.world, blockposition, iblockdata, this); // CraftBukkit } } } -@@ -106,6 +110,15 @@ +@@ -104,6 +108,15 @@ ItemStack itemstack = entityhuman.b(enumhand); if (itemstack.getItem() == Items.SHEARS && this.hasPumpkin() && !this.world.isClientSide) { diff --git a/paper-server/nms-patches/EntitySpider.patch b/paper-server/nms-patches/EntitySpider.patch index 4c7b19b31e..ce14684d5c 100644 --- a/paper-server/nms-patches/EntitySpider.patch +++ b/paper-server/nms-patches/EntitySpider.patch @@ -3,7 +3,7 @@ @@ -115,7 +115,7 @@ entityskeleton.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, 0.0F); - entityskeleton.prepare(difficultydamagescaler, (GroupDataEntity) null); + entityskeleton.prepare(difficultydamagescaler, (GroupDataEntity) null, (NBTTagCompound) null); - this.world.addEntity(entityskeleton); + this.world.addEntity(entityskeleton, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.JOCKEY); // CraftBukkit - add SpawnReason entityskeleton.startRiding(this); diff --git a/paper-server/nms-patches/EntityTNTPrimed.patch b/paper-server/nms-patches/EntityTNTPrimed.patch index 0836702cd7..d5a2e2c3d2 100644 --- a/paper-server/nms-patches/EntityTNTPrimed.patch +++ b/paper-server/nms-patches/EntityTNTPrimed.patch @@ -16,7 +16,7 @@ + public boolean isIncendiary = false; // CraftBukkit - add field public EntityTNTPrimed(World world) { - super(world); + super(EntityTypes.TNT, world); @@ -64,10 +67,13 @@ --this.c; @@ -30,8 +30,8 @@ + this.die(); + // CraftBukkit end } else { - this.aq(); - this.world.addParticle(EnumParticle.SMOKE_NORMAL, this.locX, this.locY + 0.5D, this.locZ, 0.0D, 0.0D, 0.0D, new int[0]); + this.at(); + this.world.addParticle(Particles.M, this.locX, this.locY + 0.5D, this.locZ, 0.0D, 0.0D, 0.0D); @@ -76,9 +82,17 @@ } diff --git a/paper-server/nms-patches/EntityThrownExpBottle.patch b/paper-server/nms-patches/EntityThrownExpBottle.patch index 256bf0ad75..6f2cee21e6 100644 --- a/paper-server/nms-patches/EntityThrownExpBottle.patch +++ b/paper-server/nms-patches/EntityThrownExpBottle.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/EntityThrownExpBottle.java +++ b/net/minecraft/server/EntityThrownExpBottle.java -@@ -24,9 +24,18 @@ +@@ -20,9 +20,18 @@ protected void a(MovingObjectPosition movingobjectposition) { if (!this.world.isClientSide) { diff --git a/paper-server/nms-patches/EntityTracker.patch b/paper-server/nms-patches/EntityTracker.patch index 1e0a52a9e3..795c5f2281 100644 --- a/paper-server/nms-patches/EntityTracker.patch +++ b/paper-server/nms-patches/EntityTracker.patch @@ -9,18 +9,3 @@ } else if (entity instanceof EntityEnderCrystal) { this.addEntity(entity, 256, Integer.MAX_VALUE, false); } else if (entity instanceof EntityEvokerFangs) { -@@ -120,11 +120,12 @@ - CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Entity To Track"); - - crashreportsystemdetails.a("Tracking range", (Object) (i + " blocks")); -+ final int finalI = i; // CraftBukkit - fix decompile error - crashreportsystemdetails.a("Update interval", new CrashReportCallable() { - public String a() throws Exception { -- String s = "Once per " + i + " ticks"; -+ String s = "Once per " + finalI + " ticks"; // CraftBukkit - -- if (i == Integer.MAX_VALUE) { -+ if (finalI == Integer.MAX_VALUE) { // CraftBukkit - s = "Maximum (" + s + ")"; - } - diff --git a/paper-server/nms-patches/EntityTrackerEntry.patch b/paper-server/nms-patches/EntityTrackerEntry.patch index 88438c3521..cb8903ad68 100644 --- a/paper-server/nms-patches/EntityTrackerEntry.patch +++ b/paper-server/nms-patches/EntityTrackerEntry.patch @@ -28,7 +28,7 @@ - if (itemstack.getItem() instanceof ItemWorldMap) { + if (this.a % 10 == 0 && itemstack.getItem() instanceof ItemWorldMap) { // CraftBukkit - Moved this.a % 10 logic here so item frames do not enter the other blocks - WorldMap worldmap = Items.FILLED_MAP.getSavedMap(itemstack, this.tracker.world); + WorldMap worldmap = ItemWorldMap.getSavedMap(itemstack, this.tracker.world); - Iterator iterator = list.iterator(); + Iterator iterator = this.trackedPlayers.iterator(); // CraftBukkit diff --git a/paper-server/nms-patches/EntityTypes.patch b/paper-server/nms-patches/EntityTypes.patch new file mode 100644 index 0000000000..8b0f704128 --- /dev/null +++ b/paper-server/nms-patches/EntityTypes.patch @@ -0,0 +1,39 @@ +--- a/net/minecraft/server/EntityTypes.java ++++ b/net/minecraft/server/EntityTypes.java +@@ -148,10 +148,16 @@ + + @Nullable + public T a(World world, @Nullable NBTTagCompound nbttagcompound, @Nullable IChatBaseComponent ichatbasecomponent, @Nullable EntityHuman entityhuman, BlockPosition blockposition, boolean flag, boolean flag1) { ++ // CraftBukkit start ++ return spawnCreature(world, nbttagcompound, ichatbasecomponent, entityhuman, blockposition, flag, flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG); ++ } ++ ++ @Nullable ++ public T spawnCreature(World world, @Nullable NBTTagCompound nbttagcompound, @Nullable IChatBaseComponent ichatbasecomponent, @Nullable EntityHuman entityhuman, BlockPosition blockposition, boolean flag, boolean flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) { + Entity entity = this.b(world, nbttagcompound, ichatbasecomponent, entityhuman, blockposition, flag, flag1); + +- world.addEntity(entity); +- return entity; ++ return world.addEntity(entity, spawnReason) ? (T) entity : null; // Don't return an entity when CreatureSpawnEvent is canceled ++ // CraftBukkit end + } + + @Nullable +@@ -185,7 +191,7 @@ + } + + a(world, entityhuman, entity, nbttagcompound); +- return entity; ++ return (T) entity; // CraftBukkit - decompile error + } + } + +@@ -240,7 +246,7 @@ + + @Nullable + public T a(World world) { +- return (Entity) this.aU.apply(world); ++ return this.aU.apply(world); // CraftBukkit - decompile error + } + + @Nullable diff --git a/paper-server/nms-patches/EntityVex.patch b/paper-server/nms-patches/EntityVex.patch index 0c50e0e260..08fc317e61 100644 --- a/paper-server/nms-patches/EntityVex.patch +++ b/paper-server/nms-patches/EntityVex.patch @@ -8,7 +8,7 @@ public class EntityVex extends EntityMonster { -@@ -182,7 +183,7 @@ +@@ -178,7 +179,7 @@ } public void c() { diff --git a/paper-server/nms-patches/EntityVillager.patch b/paper-server/nms-patches/EntityVillager.patch index 8693d0ff09..201e9a2c6c 100644 --- a/paper-server/nms-patches/EntityVillager.patch +++ b/paper-server/nms-patches/EntityVillager.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/EntityVillager.java +++ b/net/minecraft/server/EntityVillager.java -@@ -6,6 +6,14 @@ +@@ -7,6 +7,14 @@ import javax.annotation.Nullable; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -15,32 +15,16 @@ public class EntityVillager extends EntityAgeable implements NPC, IMerchant { -@@ -18,13 +26,13 @@ - @Nullable - private EntityHuman tradingPlayer; - @Nullable -- private MerchantRecipeList trades; -+ public MerchantRecipeList trades; // PAIL private -> public - private int bF; - private boolean bG; - private boolean bH; - public int riches; - private String bJ; -- private int bK; -+ public int bK; // PAIL private -> public // PAIL rename careerID - private int bL; - private boolean bM; - private boolean bN; -@@ -37,7 +45,7 @@ +@@ -38,7 +46,7 @@ public EntityVillager(World world, int i) { - super(world); -- this.inventory = new InventorySubcontainer("Items", false, 8); -+ this.inventory = new InventorySubcontainer("Items", false, 8, (CraftVillager) this.getBukkitEntity()); // CraftBukkit add argument + super(EntityTypes.VILLAGER, world); +- this.inventory = new InventorySubcontainer(new ChatComponentText("Items"), 8); ++ this.inventory = new InventorySubcontainer(new ChatComponentText("Items"), 8, (CraftVillager) this.getBukkitEntity()); // CraftBukkit add argument this.setProfession(i); this.setSize(0.6F, 1.95F); ((Navigation) this.getNavigation()).a(true); -@@ -119,7 +127,14 @@ +@@ -120,7 +128,14 @@ MerchantRecipe merchantrecipe = (MerchantRecipe) iterator.next(); if (merchantrecipe.h()) { @@ -56,16 +40,7 @@ } } -@@ -432,7 +447,7 @@ - return this.trades; - } - -- private void dx() { -+ public void dx() { // CraftBukkit private -> public // PAIL rename populateTrades - EntityVillager.IMerchantRecipeOption[][][] aentityvillager_imerchantrecipeoption = EntityVillager.bP[this.getProfession()]; - - if (this.bK != 0 && this.bL != 0) { -@@ -460,7 +475,20 @@ +@@ -434,7 +449,20 @@ for (int l = 0; l < k; ++l) { EntityVillager.IMerchantRecipeOption entityvillager_imerchantrecipeoption = aentityvillager_imerchantrecipeoption3[l]; diff --git a/paper-server/nms-patches/EntityWither.patch b/paper-server/nms-patches/EntityWither.patch index c6a4a11eb6..26eb069d7d 100644 --- a/paper-server/nms-patches/EntityWither.patch +++ b/paper-server/nms-patches/EntityWither.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/server/EntityWither.java +++ b/net/minecraft/server/EntityWither.java @@ -5,6 +5,12 @@ - import java.util.List; + import java.util.function.Predicate; import javax.annotation.Nullable; +// CraftBukkit start @@ -13,9 +13,9 @@ public class EntityWither extends EntityMonster implements IRangedEntity { private static final DataWatcherObject a = DataWatcher.a(EntityWither.class, DataWatcherRegistry.b); -@@ -192,13 +198,38 @@ - if (this.dm() > 0) { - i = this.dm() - 1; +@@ -181,13 +187,38 @@ + if (this.dz() > 0) { + i = this.dz() - 1; if (i <= 0) { - this.world.createExplosion(this, this.locX, this.locY + (double) this.getHeadHeight(), this.locZ, 7.0F, false, this.world.getGameRules().getBoolean("mobGriefing")); - this.world.a(1023, new BlockPosition(this), 0); @@ -48,26 +48,26 @@ + // CraftBukkit end } - this.g(i); + this.e(i); if (this.ticksLived % 10 == 0) { - this.heal(10.0F); + this.heal(10.0F, EntityRegainHealthEvent.RegainReason.WITHER_SPAWN); // CraftBukkit } } else { -@@ -289,6 +320,11 @@ +@@ -278,6 +309,11 @@ Block block = iblockdata.getBlock(); - if (iblockdata.getMaterial() != Material.AIR && a(block)) { + if (!iblockdata.isAir() && a(block)) { + // CraftBukkit start -+ if (CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, Blocks.AIR, 0).isCancelled()) { ++ if (CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, Blocks.AIR.getBlockData()).isCancelled()) { + continue; + } + // CraftBukkit end flag = this.world.setAir(blockposition, true) || flag; } } -@@ -302,7 +338,7 @@ +@@ -291,7 +327,7 @@ } if (this.ticksLived % 20 == 0) { @@ -75,4 +75,4 @@ + this.heal(1.0F, EntityRegainHealthEvent.RegainReason.REGEN); // CraftBukkit } - this.bG.setProgress(this.getHealth() / this.getMaxHealth()); + this.bL.setProgress(this.getHealth() / this.getMaxHealth()); diff --git a/paper-server/nms-patches/EntityWitherSkull.patch b/paper-server/nms-patches/EntityWitherSkull.patch index ba9d947856..c700d1a945 100644 --- a/paper-server/nms-patches/EntityWitherSkull.patch +++ b/paper-server/nms-patches/EntityWitherSkull.patch @@ -7,8 +7,8 @@ + public class EntityWitherSkull extends EntityFireball { - private static final DataWatcherObject e = DataWatcher.a(EntityWitherSkull.class, DataWatcherRegistry.h); -@@ -41,11 +43,11 @@ + private static final DataWatcherObject e = DataWatcher.a(EntityWitherSkull.class, DataWatcherRegistry.i); +@@ -28,11 +30,11 @@ if (!this.world.isClientSide) { if (movingobjectposition.entity != null) { if (this.shooter != null) { @@ -22,7 +22,7 @@ } } } else { -@@ -67,7 +69,15 @@ +@@ -54,7 +56,15 @@ } } diff --git a/paper-server/nms-patches/EntityWolf.patch b/paper-server/nms-patches/EntityWolf.patch index 1efa3ef506..69378f11ca 100644 --- a/paper-server/nms-patches/EntityWolf.patch +++ b/paper-server/nms-patches/EntityWolf.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/server/EntityWolf.java +++ b/net/minecraft/server/EntityWolf.java @@ -4,6 +4,11 @@ - import java.util.UUID; + import java.util.function.Predicate; import javax.annotation.Nullable; +// CraftBukkit start @@ -12,7 +12,7 @@ public class EntityWolf extends EntityTameableAnimal { private static final DataWatcherObject DATA_HEALTH = DataWatcher.a(EntityWolf.class, DataWatcherRegistry.c); -@@ -62,6 +67,22 @@ +@@ -57,6 +62,22 @@ this.getAttributeMap().b(GenericAttributes.ATTACK_DAMAGE).setValue(2.0D); } @@ -35,7 +35,7 @@ public void setGoalTarget(@Nullable EntityLiving entityliving) { super.setGoalTarget(entityliving); if (entityliving == null) { -@@ -200,9 +221,9 @@ +@@ -191,7 +212,8 @@ Entity entity = damagesource.getEntity(); if (this.goalSit != null) { @@ -43,11 +43,9 @@ + // CraftBukkit - moved into EntityLiving.d(DamageSource, float) + // this.goalSit.setSitting(false); } -- + if (entity != null && !(entity instanceof EntityHuman) && !(entity instanceof EntityArrow)) { - f = (f + 1.0F) / 2.0F; - } -@@ -245,7 +266,7 @@ +@@ -237,7 +259,7 @@ itemstack.subtract(1); } @@ -55,17 +53,17 @@ + this.heal((float) itemfood.getNutrition(itemstack), org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.EATING); // CraftBukkit return true; } - } else if (itemstack.getItem() == Items.DYE) { -@@ -266,7 +287,7 @@ + } else if (item instanceof ItemDye) { +@@ -258,7 +280,7 @@ this.goalSit.setSitting(!this.isSitting()); - this.bd = false; - this.navigation.p(); + this.bg = false; + this.navigation.r(); - this.setGoalTarget((EntityLiving) null); + this.setGoalTarget((EntityLiving) null, TargetReason.FORGOT_TARGET, true); // CraftBukkit - reason } - } else if (itemstack.getItem() == Items.BONE && !this.isAngry()) { + } else if (item == Items.BONE && !this.isAngry()) { if (!entityhuman.abilities.canInstantlyBuild) { -@@ -274,12 +295,13 @@ +@@ -266,12 +288,13 @@ } if (!this.world.isClientSide) { @@ -73,11 +71,11 @@ + // CraftBukkit - added event call and isCancelled check. + if (this.random.nextInt(3) == 0 && !CraftEventFactory.callEntityTameEvent(this, entityhuman).isCancelled()) { this.c(entityhuman); - this.navigation.p(); + this.navigation.r(); this.setGoalTarget((EntityLiving) null); this.goalSit.setSitting(true); - this.setHealth(20.0F); + this.setHealth(this.getMaxHealth()); // CraftBukkit - 20.0 -> getMaxHealth() - this.p(true); + this.s(true); this.world.broadcastEntityEffect(this, (byte) 7); } else { diff --git a/paper-server/nms-patches/EntityZombie.patch b/paper-server/nms-patches/EntityZombie.patch index 60c088762f..4ae666cd50 100644 --- a/paper-server/nms-patches/EntityZombie.patch +++ b/paper-server/nms-patches/EntityZombie.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/EntityZombie.java +++ b/net/minecraft/server/EntityZombie.java -@@ -5,6 +5,13 @@ +@@ -6,6 +6,13 @@ import java.util.UUID; import javax.annotation.Nullable; @@ -13,36 +13,36 @@ + public class EntityZombie extends EntityMonster { - protected static final IAttribute a = (new AttributeRanged((IAttribute) null, "zombie.spawnReinforcements", 0.0D, 0.0D, 1.0D)).a("Spawn Reinforcements Chance"); -@@ -133,7 +140,14 @@ - } + protected static final IAttribute c = (new AttributeRanged((IAttribute) null, "zombie.spawnReinforcements", 0.0D, 0.0D, 1.0D)).a("Spawn Reinforcements Chance"); +@@ -182,7 +189,14 @@ + } - if (flag) { -- this.setOnFire(8); -+ // CraftBukkit start -+ EntityCombustEvent event = new EntityCombustEvent(this.getBukkitEntity(), 8); -+ this.world.getServer().getPluginManager().callEvent(event); + if (flag) { +- this.setOnFire(8); ++ // CraftBukkit start ++ EntityCombustEvent event = new EntityCombustEvent(this.getBukkitEntity(), 8); ++ this.world.getServer().getPluginManager().callEvent(event); + -+ if (!event.isCancelled()) { -+ this.setOnFire(event.getDuration()); -+ } -+ // CraftBukkit end - } ++ if (!event.isCancelled()) { ++ this.setOnFire(event.getDuration()); ++ } ++ // CraftBukkit end } } -@@ -167,8 +181,8 @@ + +@@ -251,8 +265,8 @@ if (this.world.getType(new BlockPosition(i1, j1 - 1, k1)).q() && this.world.getLightLevel(new BlockPosition(i1, j1, k1)) < 10) { entityzombie.setPosition((double) i1, (double) j1, (double) k1); - if (!this.world.isPlayerNearby((double) i1, (double) j1, (double) k1, 7.0D) && this.world.a(entityzombie.getBoundingBox(), (Entity) entityzombie) && this.world.getCubes(entityzombie, entityzombie.getBoundingBox()).isEmpty() && !this.world.containsLiquid(entityzombie.getBoundingBox())) { + if (!this.world.isPlayerNearby((double) i1, (double) j1, (double) k1, 7.0D) && this.world.b((Entity) entityzombie, entityzombie.getBoundingBox()) && this.world.getCubes(entityzombie, entityzombie.getBoundingBox()) && !this.world.containsLiquid(entityzombie.getBoundingBox())) { - this.world.addEntity(entityzombie); - entityzombie.setGoalTarget(entityliving); + this.world.addEntity(entityzombie, CreatureSpawnEvent.SpawnReason.REINFORCEMENTS); // CraftBukkit -+ entityzombie.setGoalTarget(entityliving, EntityTargetEvent.TargetReason.REINFORCEMENT_TARGET, true); - entityzombie.prepare(this.world.D(new BlockPosition(entityzombie)), (GroupDataEntity) null); - this.getAttributeInstance(EntityZombie.a).b(new AttributeModifier("Zombie reinforcement caller charge", -0.05000000074505806D, 0)); - entityzombie.getAttributeInstance(EntityZombie.a).b(new AttributeModifier("Zombie reinforcement callee charge", -0.05000000074505806D, 0)); -@@ -191,7 +205,14 @@ - float f = this.world.D(new BlockPosition(this)).b(); ++ entityzombie.setGoalTarget(entityliving, EntityTargetEvent.TargetReason.REINFORCEMENT_TARGET, true); // CraftBukkit + entityzombie.prepare(this.world.getDamageScaler(new BlockPosition(entityzombie)), (GroupDataEntity) null, (NBTTagCompound) null); + this.getAttributeInstance(EntityZombie.c).b(new AttributeModifier("Zombie reinforcement caller charge", -0.05000000074505806D, 0)); + entityzombie.getAttributeInstance(EntityZombie.c).b(new AttributeModifier("Zombie reinforcement callee charge", -0.05000000074505806D, 0)); +@@ -275,7 +289,14 @@ + float f = this.world.getDamageScaler(new BlockPosition(this)).b(); if (this.getItemInMainHand().isEmpty() && this.isBurning() && this.random.nextFloat() < f * 0.3F) { - entity.setOnFire(2 * (int) f); @@ -57,7 +57,7 @@ } } -@@ -284,7 +305,7 @@ +@@ -371,7 +392,7 @@ entityzombievillager.setCustomNameVisible(entityvillager.getCustomNameVisible()); } @@ -66,16 +66,16 @@ this.world.a((EntityHuman) null, 1026, new BlockPosition(this), 0); } -@@ -334,7 +355,7 @@ +@@ -421,7 +442,7 @@ entitychicken1.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, 0.0F); - entitychicken1.prepare(difficultydamagescaler, (GroupDataEntity) null); - entitychicken1.p(true); + entitychicken1.prepare(difficultydamagescaler, (GroupDataEntity) null, (NBTTagCompound) null); + entitychicken1.s(true); - this.world.addEntity(entitychicken1); + this.world.addEntity(entitychicken1, CreatureSpawnEvent.SpawnReason.MOUNT); // CraftBukkit this.startRiding(entitychicken1); } } -@@ -392,7 +413,7 @@ +@@ -494,7 +515,7 @@ } public void die(DamageSource damagesource) { @@ -84,7 +84,7 @@ if (damagesource.getEntity() instanceof EntityCreeper) { EntityCreeper entitycreeper = (EntityCreeper) damagesource.getEntity(); -@@ -405,6 +426,7 @@ +@@ -507,6 +528,7 @@ } } } diff --git a/paper-server/nms-patches/EntityZombieVillager.patch b/paper-server/nms-patches/EntityZombieVillager.patch index 247d022703..c4d767bc27 100644 --- a/paper-server/nms-patches/EntityZombieVillager.patch +++ b/paper-server/nms-patches/EntityZombieVillager.patch @@ -1,17 +1,17 @@ --- a/net/minecraft/server/EntityZombieVillager.java +++ b/net/minecraft/server/EntityZombieVillager.java @@ -9,6 +9,7 @@ - private static final DataWatcherObject c = DataWatcher.a(EntityZombieVillager.class, DataWatcherRegistry.b); + private static final DataWatcherObject b = DataWatcher.a(EntityZombieVillager.class, DataWatcherRegistry.b); private int conversionTime; - private UUID by; + private UUID bD; + private int lastTick = MinecraftServer.currentTick; // CraftBukkit - add field public EntityZombieVillager(World world) { - super(world); -@@ -60,6 +61,11 @@ - public void B_() { + super(EntityTypes.ZOMBIE_VILLAGER, world); +@@ -56,6 +57,11 @@ + public void tick() { if (!this.world.isClientSide && this.isConverting()) { - int i = this.du(); + int i = this.dK(); + // CraftBukkit start - Use wall time instead of ticks for villager conversion + int elapsedTicks = MinecraftServer.currentTick - this.lastTick; + this.lastTick = MinecraftServer.currentTick; @@ -26,6 +26,6 @@ - this.world.addEntity(entityvillager); + this.world.addEntity(entityvillager, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CURED); // CraftBukkit - add SpawnReason - if (this.by != null) { - EntityHuman entityhuman = this.world.b(this.by); + if (this.bD != null) { + EntityHuman entityhuman = this.world.b(this.bD); diff --git a/paper-server/nms-patches/ExpirableListEntry.patch b/paper-server/nms-patches/ExpirableListEntry.patch index aa81c8243d..6b07ceffd5 100644 --- a/paper-server/nms-patches/ExpirableListEntry.patch +++ b/paper-server/nms-patches/ExpirableListEntry.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/ExpirableListEntry.java +++ b/net/minecraft/server/ExpirableListEntry.java -@@ -22,7 +22,7 @@ +@@ -23,7 +23,7 @@ } protected ExpirableListEntry(T t0, JsonObject jsonobject) { @@ -9,7 +9,7 @@ Date date; -@@ -65,4 +65,30 @@ +@@ -72,4 +72,30 @@ jsonobject.addProperty("expires", this.d == null ? "forever" : ExpirableListEntry.a.format(this.d)); jsonobject.addProperty("reason", this.e); } diff --git a/paper-server/nms-patches/Explosion.patch b/paper-server/nms-patches/Explosion.patch index ccc8d40fc6..be06f65b06 100644 --- a/paper-server/nms-patches/Explosion.patch +++ b/paper-server/nms-patches/Explosion.patch @@ -14,13 +14,13 @@ public class Explosion { private final boolean a; -@@ -23,11 +30,12 @@ - private final float size; +@@ -24,11 +31,12 @@ + private DamageSource j; private final List blocks = Lists.newArrayList(); - private final Map k = Maps.newHashMap(); + private final Map l = Maps.newHashMap(); + public boolean wasCanceled = false; // CraftBukkit - add field - public Explosion(World world, Entity entity, double d0, double d1, double d2, float f, boolean flag, boolean flag1) { + public Explosion(World world, @Nullable Entity entity, double d0, double d1, double d2, float f, boolean flag, boolean flag1) { this.world = world; this.source = entity; - this.size = f; @@ -28,7 +28,7 @@ this.posX = d0; this.posY = d1; this.posZ = d2; -@@ -36,6 +44,11 @@ +@@ -38,6 +46,11 @@ } public void a() { @@ -40,7 +40,7 @@ HashSet hashset = Sets.newHashSet(); boolean flag = true; -@@ -69,7 +82,7 @@ +@@ -75,7 +88,7 @@ f -= (f2 + 0.3F) * 0.3F; } @@ -49,16 +49,16 @@ hashset.add(blockposition); } -@@ -113,7 +126,16 @@ +@@ -119,7 +132,16 @@ double d12 = (double) this.world.a(vec3d, entity.getBoundingBox()); double d13 = (1.0D - d7) * d12; -- entity.damageEntity(DamageSource.explosion(this), (float) ((int) ((d13 * d13 + d13) / 2.0D * 7.0D * (double) f3 + 1.0D))); +- entity.damageEntity(this.b(), (float) ((int) ((d13 * d13 + d13) / 2.0D * 7.0D * (double) f3 + 1.0D))); + // CraftBukkit start -+ // entity.damageEntity(DamageSource.explosion(this), (float) ((int) ((d13 * d13 + d13) / 2.0D * 7.0D * (double) f3 + 1.0D))); ++ // entity.damageEntity(this.b(), (float) ((int) ((d13 * d13 + d13) / 2.0D * 7.0D * (double) f3 + 1.0D))); + CraftEventFactory.entityDamage = source; + entity.forceExplosionKnockback = false; -+ boolean wasDamaged = entity.damageEntity(DamageSource.explosion(this), (float) ((int) ((d13 * d13 + d13) / 2.0D * 7.0D * (double) f3 + 1.0D))); ++ boolean wasDamaged = entity.damageEntity(this.b(), (float) ((int) ((d13 * d13 + d13) / 2.0D * 7.0D * (double) f3 + 1.0D))); + CraftEventFactory.entityDamage = null; + if (!wasDamaged && !(entity instanceof EntityTNTPrimed || entity instanceof EntityFallingBlock) && !entity.forceExplosionKnockback) { + continue; @@ -67,7 +67,7 @@ double d14 = d13; if (entity instanceof EntityLiving) { -@@ -149,6 +171,50 @@ +@@ -155,6 +177,50 @@ BlockPosition blockposition; if (this.b) { @@ -118,20 +118,20 @@ iterator = this.blocks.iterator(); while (iterator.hasNext()) { -@@ -180,7 +246,8 @@ +@@ -186,7 +252,8 @@ - if (iblockdata.getMaterial() != Material.AIR) { + if (!iblockdata.isAir()) { if (block.a(this)) { -- block.dropNaturally(this.world, blockposition, this.world.getType(blockposition), 1.0F / this.size, 0); +- iblockdata.dropNaturally(this.world, blockposition, 1.0F / this.size, 0); + // CraftBukkit - add yield -+ block.dropNaturally(this.world, blockposition, this.world.getType(blockposition), yield, 0); ++ iblockdata.dropNaturally(this.world, blockposition, yield, 0); } this.world.setTypeAndData(blockposition, Blocks.AIR.getBlockData(), 3); -@@ -195,7 +262,11 @@ +@@ -201,7 +268,11 @@ while (iterator.hasNext()) { blockposition = (BlockPosition) iterator.next(); - if (this.world.getType(blockposition).getMaterial() == Material.AIR && this.world.getType(blockposition.down()).b() && this.c.nextInt(3) == 0) { + if (this.world.getType(blockposition).isAir() && this.world.getType(blockposition.down()).f(this.world, blockposition.down()) && this.c.nextInt(3) == 0) { - this.world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData()); + // CraftBukkit start - Ignition by explosion + if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(this.world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this).isCancelled()) { @@ -141,7 +141,7 @@ } } } -@@ -208,7 +279,9 @@ +@@ -222,7 +293,9 @@ @Nullable public EntityLiving getSource() { diff --git a/paper-server/nms-patches/FluidTypeFlowing.patch b/paper-server/nms-patches/FluidTypeFlowing.patch new file mode 100644 index 0000000000..d1f69c0775 --- /dev/null +++ b/paper-server/nms-patches/FluidTypeFlowing.patch @@ -0,0 +1,46 @@ +--- a/net/minecraft/server/FluidTypeFlowing.java ++++ b/net/minecraft/server/FluidTypeFlowing.java +@@ -5,6 +5,11 @@ + import java.util.Iterator; + import java.util.Map; + import java.util.Map.Entry; ++// CraftBukkit start ++import org.bukkit.block.BlockFace; ++import org.bukkit.craftbukkit.block.CraftBlock; ++import org.bukkit.event.block.BlockFromToEvent; ++// CraftBukkit end + + public abstract class FluidTypeFlowing extends FluidType { + +@@ -116,6 +121,15 @@ + Fluid fluid1 = this.a((IWorldReader) generatoraccess, blockposition1, iblockdata1); + + if (this.a(generatoraccess, blockposition, iblockdata, EnumDirection.DOWN, blockposition1, iblockdata1, generatoraccess.b(blockposition1), fluid1.c())) { ++ // CraftBukkit start ++ org.bukkit.block.Block source = CraftBlock.at(generatoraccess, blockposition); ++ BlockFromToEvent event = new BlockFromToEvent(source, BlockFace.DOWN); ++ generatoraccess.getMinecraftWorld().getServer().getPluginManager().callEvent(event); ++ ++ if (event.isCancelled()) { ++ return; ++ } ++ // CraftBukkit end + this.a(generatoraccess, blockposition1, iblockdata1, EnumDirection.DOWN, fluid1); + if (this.a((IWorldReader) generatoraccess, blockposition) >= 3) { + this.a(generatoraccess, blockposition, fluid, iblockdata); +@@ -146,6 +160,15 @@ + IBlockData iblockdata1 = generatoraccess.getType(blockposition1); + + if (this.a(generatoraccess, blockposition, iblockdata, enumdirection, blockposition1, iblockdata1, generatoraccess.b(blockposition1), fluid1.c())) { ++ // CraftBukkit start ++ org.bukkit.block.Block source = CraftBlock.at(generatoraccess, blockposition); ++ BlockFromToEvent event = new BlockFromToEvent(source, org.bukkit.craftbukkit.block.CraftBlock.notchToBlockFace(enumdirection)); ++ generatoraccess.getMinecraftWorld().getServer().getPluginManager().callEvent(event); ++ ++ if (event.isCancelled()) { ++ continue; ++ } ++ // CraftBukkit end + this.a(generatoraccess, blockposition1, iblockdata1, enumdirection, fluid1); + } + } diff --git a/paper-server/nms-patches/FluidTypeLava.patch b/paper-server/nms-patches/FluidTypeLava.patch new file mode 100644 index 0000000000..ef36738d2b --- /dev/null +++ b/paper-server/nms-patches/FluidTypeLava.patch @@ -0,0 +1,44 @@ +--- a/net/minecraft/server/FluidTypeLava.java ++++ b/net/minecraft/server/FluidTypeLava.java +@@ -35,6 +35,13 @@ + + if (iblockdata.isAir()) { + if (this.a((IWorldReader) world, blockposition1)) { ++ // CraftBukkit start - Prevent lava putting something on fire ++ if (world.getType(blockposition1) != Blocks.FIRE) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition1, blockposition).isCancelled()) { ++ continue; ++ } ++ } ++ // CraftBukkit end + world.setTypeUpdate(blockposition1, Blocks.FIRE.getBlockData()); + return; + } +@@ -51,6 +58,14 @@ + } + + if (world.isEmpty(blockposition2.up()) && this.b(world, blockposition2)) { ++ // CraftBukkit start - Prevent lava putting something on fire ++ BlockPosition up = blockposition2.up(); ++ if (world.getType(up) != Blocks.FIRE) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, up, blockposition).isCancelled()) { ++ continue; ++ } ++ } ++ // CraftBukkit end + world.setTypeUpdate(blockposition2.up(), Blocks.FIRE.getBlockData()); + } + } +@@ -139,7 +154,11 @@ + + if (this.a(TagsFluid.b) && fluid1.a(TagsFluid.a)) { + if (iblockdata.getBlock() instanceof BlockFluids) { +- generatoraccess.setTypeAndData(blockposition, Blocks.STONE.getBlockData(), 3); ++ // CraftBukkit start ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(generatoraccess.getMinecraftWorld(), blockposition, Blocks.STONE.getBlockData(), 3)) { ++ return; ++ } ++ // CraftBukkit end + } + + this.a(generatoraccess, blockposition); diff --git a/paper-server/nms-patches/FoodMetaData.patch b/paper-server/nms-patches/FoodMetaData.patch index 121f388b71..3383084e87 100644 --- a/paper-server/nms-patches/FoodMetaData.patch +++ b/paper-server/nms-patches/FoodMetaData.patch @@ -64,7 +64,7 @@ this.a(f); this.foodTickTimer = 0; } - } else if (flag && this.foodLevel >= 18 && entityhuman.dj()) { + } else if (flag && this.foodLevel >= 18 && entityhuman.dw()) { ++this.foodTickTimer; if (this.foodTickTimer >= 80) { - entityhuman.heal(1.0F); diff --git a/paper-server/nms-patches/FurnaceRecipe.patch b/paper-server/nms-patches/FurnaceRecipe.patch new file mode 100644 index 0000000000..30eb77a1a4 --- /dev/null +++ b/paper-server/nms-patches/FurnaceRecipe.patch @@ -0,0 +1,44 @@ +--- a/net/minecraft/server/FurnaceRecipe.java ++++ b/net/minecraft/server/FurnaceRecipe.java +@@ -2,6 +2,10 @@ + + import com.google.gson.JsonElement; + import com.google.gson.JsonObject; ++import org.bukkit.craftbukkit.inventory.CraftFurnaceRecipe; ++import org.bukkit.craftbukkit.inventory.CraftItemStack; ++import org.bukkit.craftbukkit.util.CraftNamespacedKey; ++import org.bukkit.inventory.Recipe; + + public class FurnaceRecipe implements IRecipe { + +@@ -56,6 +60,16 @@ + return this.key; + } + ++ @Override ++ public Recipe toBukkitRecipe() { ++ CraftItemStack result = CraftItemStack.asCraftMirror(this.result); ++ RecipeItemStack list = this.ingredient; ++ list.buildChoices(); ++ net.minecraft.server.ItemStack stack = list.choices[0]; ++ ++ return new CraftFurnaceRecipe(CraftNamespacedKey.fromMinecraft(this.key), result, CraftItemStack.asCraftMirror(stack), this.experience, this.cookingTime); ++ } ++ + public static class a implements RecipeSerializer { + + public a() {} +@@ -106,11 +120,11 @@ + return "smelting"; + } + +- public IRecipe a(MinecraftKey minecraftkey, PacketDataSerializer packetdataserializer) { ++ public FurnaceRecipe a(MinecraftKey minecraftkey, PacketDataSerializer packetdataserializer) { // CraftBukkit - decompile error + return this.b(minecraftkey, packetdataserializer); + } + +- public IRecipe a(MinecraftKey minecraftkey, JsonObject jsonobject) { ++ public FurnaceRecipe a(MinecraftKey minecraftkey, JsonObject jsonobject) { // CraftBukkit - decompile error + return this.b(minecraftkey, jsonobject); + } + } diff --git a/paper-server/nms-patches/HandshakeListener.patch b/paper-server/nms-patches/HandshakeListener.patch index 8799f9f098..0b5c975ca9 100644 --- a/paper-server/nms-patches/HandshakeListener.patch +++ b/paper-server/nms-patches/HandshakeListener.patch @@ -57,8 +57,8 @@ + } + // CraftBukkit end + - if (packethandshakinginsetprotocol.b() > 340) { - chatmessage = new ChatMessage("multiplayer.disconnect.outdated_server", new Object[] { "1.12.2"}); + if (packethandshakinginsetprotocol.c() > 389) { + chatmessage = new ChatMessage("multiplayer.disconnect.outdated_server", new Object[] { "1.13-pre7"}); this.b.sendPacket(new PacketLoginOutDisconnect(chatmessage)); @@ -26,6 +71,7 @@ this.b.close(chatmessage); diff --git a/paper-server/nms-patches/ICommandListener.patch b/paper-server/nms-patches/ICommandListener.patch new file mode 100644 index 0000000000..d1efb9cd4b --- /dev/null +++ b/paper-server/nms-patches/ICommandListener.patch @@ -0,0 +1,9 @@ +--- a/net/minecraft/server/ICommandListener.java ++++ b/net/minecraft/server/ICommandListener.java +@@ -9,4 +9,6 @@ + boolean b(); + + boolean B_(); ++ ++ org.bukkit.command.CommandSender getBukkitSender(CommandListenerWrapper wrapper); // CraftBukkit + } diff --git a/paper-server/nms-patches/IDataManager.patch b/paper-server/nms-patches/IDataManager.patch index 362ecd7607..a02e77ba6e 100644 --- a/paper-server/nms-patches/IDataManager.patch +++ b/paper-server/nms-patches/IDataManager.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/server/IDataManager.java +++ b/net/minecraft/server/IDataManager.java -@@ -25,4 +25,6 @@ - File getDataFile(String s); - +@@ -29,4 +29,6 @@ DefinedStructureManager h(); + + DataFixer i(); + + java.util.UUID getUUID(); // CraftBukkit } diff --git a/paper-server/nms-patches/IInventory.patch b/paper-server/nms-patches/IInventory.patch index 0d2e884cea..4dd0f897ee 100644 --- a/paper-server/nms-patches/IInventory.patch +++ b/paper-server/nms-patches/IInventory.patch @@ -8,10 +8,10 @@ public interface IInventory extends INamableTileEntity { int getSize(); -@@ -33,4 +35,22 @@ - int h(); - - void clear(); +@@ -41,4 +43,29 @@ + default int U_() { + return 0; + } + + // CraftBukkit start + java.util.List getContents(); @@ -28,6 +28,13 @@ + + org.bukkit.Location getLocation(); + ++ default IRecipe getCurrentRecipe() { ++ return null; ++ } ++ ++ default void setCurrentRecipe(IRecipe recipe) { ++ } ++ + int MAX_STACK = 64; + // CraftBukkit end } diff --git a/paper-server/nms-patches/IRecipe.patch b/paper-server/nms-patches/IRecipe.patch index 325b5b695e..c6b8888258 100644 --- a/paper-server/nms-patches/IRecipe.patch +++ b/paper-server/nms-patches/IRecipe.patch @@ -1,11 +1,9 @@ --- a/net/minecraft/server/IRecipe.java +++ b/net/minecraft/server/IRecipe.java -@@ -17,4 +17,8 @@ - default boolean c() { - return false; - } +@@ -33,4 +33,6 @@ + MinecraftKey getKey(); + + RecipeSerializer a(); + + org.bukkit.inventory.Recipe toBukkitRecipe(); // CraftBukkit -+ -+ void setKey(MinecraftKey key); // CraftBukkit } diff --git a/paper-server/nms-patches/IWorldWriter.patch b/paper-server/nms-patches/IWorldWriter.patch new file mode 100644 index 0000000000..2315ab9ba8 --- /dev/null +++ b/paper-server/nms-patches/IWorldWriter.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/server/IWorldWriter.java ++++ b/net/minecraft/server/IWorldWriter.java +@@ -6,6 +6,8 @@ + + boolean addEntity(Entity entity); + ++ boolean addEntity(Entity entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason); // CraftBukkit ++ + boolean setAir(BlockPosition blockposition); + + void a(EnumSkyBlock enumskyblock, BlockPosition blockposition, int i); diff --git a/paper-server/nms-patches/InventoryCraftResult.patch b/paper-server/nms-patches/InventoryCraftResult.patch index 70c8e7f101..4f275b25b3 100644 --- a/paper-server/nms-patches/InventoryCraftResult.patch +++ b/paper-server/nms-patches/InventoryCraftResult.patch @@ -10,7 +10,7 @@ +import org.bukkit.entity.HumanEntity; +// CraftBukkit end - public class InventoryCraftResult implements IInventory { + public class InventoryCraftResult implements IInventory, RecipeHolder { private final NonNullList items; private IRecipe b; @@ -46,7 +46,7 @@ public InventoryCraftResult() { this.items = NonNullList.a(1, ItemStack.a); } -@@ -61,7 +94,7 @@ +@@ -62,7 +95,7 @@ } public int getMaxStackSize() { diff --git a/paper-server/nms-patches/InventoryCrafting.patch b/paper-server/nms-patches/InventoryCrafting.patch index 3ddb4a1ce8..336fdb19bf 100644 --- a/paper-server/nms-patches/InventoryCrafting.patch +++ b/paper-server/nms-patches/InventoryCrafting.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/server/InventoryCrafting.java +++ b/net/minecraft/server/InventoryCrafting.java -@@ -1,6 +1,14 @@ - package net.minecraft.server; +@@ -2,6 +2,14 @@ import java.util.Iterator; + import javax.annotation.Nullable; +// CraftBukkit start +import java.util.List; +import org.bukkit.Location; @@ -13,15 +13,15 @@ +import org.bukkit.event.inventory.InventoryType; +// CraftBukkit end - public class InventoryCrafting implements IInventory { + public class InventoryCrafting implements IInventory, AutoRecipeOutput { -@@ -9,6 +17,53 @@ +@@ -10,6 +18,63 @@ private final int c; public final Container container; + // CraftBukkit start - add fields + public List transaction = new java.util.ArrayList(); -+ public IRecipe currentRecipe; ++ private IRecipe currentRecipe; + public IInventory resultInventory; + private EntityHuman owner; + private int maxStack = MAX_STACK; @@ -60,6 +60,16 @@ + return owner.getBukkitEntity().getLocation(); + } + ++ @Override ++ public IRecipe getCurrentRecipe() { ++ return currentRecipe; ++ } ++ ++ @Override ++ public void setCurrentRecipe(IRecipe currentRecipe) { ++ this.currentRecipe = currentRecipe; ++ } ++ + public InventoryCrafting(Container container, int i, int j, EntityHuman player) { + this(container, i, j); + this.owner = player; diff --git a/paper-server/nms-patches/InventoryEnderChest.patch b/paper-server/nms-patches/InventoryEnderChest.patch index 18f4a07b85..c31016ff61 100644 --- a/paper-server/nms-patches/InventoryEnderChest.patch +++ b/paper-server/nms-patches/InventoryEnderChest.patch @@ -23,7 +23,7 @@ - public InventoryEnderChest() { + public InventoryEnderChest(EntityHuman owner) { - super("container.enderchest", false, 27); + super(new ChatMessage("container.enderchest", new Object[0]), 27); + this.owner = owner; + // CraftBukkit end } diff --git a/paper-server/nms-patches/InventoryHorseChest.patch b/paper-server/nms-patches/InventoryHorseChest.patch index 875dd670de..05e5572c22 100644 --- a/paper-server/nms-patches/InventoryHorseChest.patch +++ b/paper-server/nms-patches/InventoryHorseChest.patch @@ -4,11 +4,11 @@ public class InventoryHorseChest extends InventorySubcontainer { -- public InventoryHorseChest(String s, int i) { -- super(s, false, i); +- public InventoryHorseChest(IChatBaseComponent ichatbasecomponent, int i) { +- super(ichatbasecomponent, i); + // CraftBukkit start -+ public InventoryHorseChest(String s, int i, EntityHorseAbstract owner) { -+ super(s, false, i, (org.bukkit.entity.AbstractHorse) owner.getBukkitEntity()); ++ public InventoryHorseChest(IChatBaseComponent ichatbasecomponent, int i, EntityHorseAbstract owner) { ++ super(ichatbasecomponent, i, (org.bukkit.entity.AbstractHorse) owner.getBukkitEntity()); + // CraftBukkit end } } diff --git a/paper-server/nms-patches/InventoryLargeChest.patch b/paper-server/nms-patches/InventoryLargeChest.patch index 3ed9ccd87e..f4fdba28bc 100644 --- a/paper-server/nms-patches/InventoryLargeChest.patch +++ b/paper-server/nms-patches/InventoryLargeChest.patch @@ -1,8 +1,9 @@ --- a/net/minecraft/server/InventoryLargeChest.java +++ b/net/minecraft/server/InventoryLargeChest.java -@@ -1,11 +1,62 @@ +@@ -1,6 +1,14 @@ package net.minecraft.server; + import javax.annotation.Nullable; +// CraftBukkit start +import java.util.ArrayList; +import java.util.List; @@ -11,10 +12,10 @@ +import org.bukkit.craftbukkit.entity.CraftHumanEntity; +import org.bukkit.entity.HumanEntity; +// CraftBukkit end -+ + public class InventoryLargeChest implements ITileInventory { - private final String a; +@@ -8,6 +16,48 @@ public final ITileInventory left; public final ITileInventory right; @@ -60,10 +61,10 @@ + } + // CraftBukkit end + - public InventoryLargeChest(String s, ITileInventory itileinventory, ITileInventory itileinventory1) { - this.a = s; + public InventoryLargeChest(IChatBaseComponent ichatbasecomponent, ITileInventory itileinventory, ITileInventory itileinventory1) { + this.a = ichatbasecomponent; if (itileinventory == null) { -@@ -72,7 +123,7 @@ +@@ -75,7 +125,7 @@ } public int getMaxStackSize() { diff --git a/paper-server/nms-patches/InventoryMerchant.patch b/paper-server/nms-patches/InventoryMerchant.patch index 8c56630707..30897b1da3 100644 --- a/paper-server/nms-patches/InventoryMerchant.patch +++ b/paper-server/nms-patches/InventoryMerchant.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/server/InventoryMerchant.java +++ b/net/minecraft/server/InventoryMerchant.java -@@ -1,6 +1,13 @@ - package net.minecraft.server; +@@ -2,6 +2,13 @@ import java.util.Iterator; + import javax.annotation.Nullable; +// CraftBukkit start +import java.util.List; +import org.bukkit.Location; @@ -14,7 +14,7 @@ public class InventoryMerchant implements IInventory { -@@ -10,6 +17,40 @@ +@@ -11,6 +18,40 @@ private MerchantRecipe recipe; public int selectedIndex; @@ -55,7 +55,7 @@ public InventoryMerchant(EntityHuman entityhuman, IMerchant imerchant) { this.itemsInSlots = NonNullList.a(3, ItemStack.a); this.player = entityhuman; -@@ -89,7 +130,7 @@ +@@ -91,7 +132,7 @@ } public int getMaxStackSize() { diff --git a/paper-server/nms-patches/InventorySubcontainer.patch b/paper-server/nms-patches/InventorySubcontainer.patch index ee8e435a44..237b30c70c 100644 --- a/paper-server/nms-patches/InventorySubcontainer.patch +++ b/paper-server/nms-patches/InventorySubcontainer.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/InventorySubcontainer.java +++ b/net/minecraft/server/InventorySubcontainer.java -@@ -4,6 +4,13 @@ - import java.util.Iterator; +@@ -5,6 +5,13 @@ import java.util.List; + import javax.annotation.Nullable; +// CraftBukkit start +import java.util.List; @@ -11,12 +11,12 @@ +import org.bukkit.entity.HumanEntity; +// CraftBukkit end + - public class InventorySubcontainer implements IInventory { + public class InventorySubcontainer implements IInventory, AutoRecipeOutput { - private String a; -@@ -12,7 +19,47 @@ + private final IChatBaseComponent a; +@@ -13,7 +20,47 @@ private List d; - private boolean e; + private IChatBaseComponent e; + // CraftBukkit start - add fields and methods + public List transaction = new java.util.ArrayList(); @@ -52,13 +52,13 @@ + return null; + } + - public InventorySubcontainer(String s, boolean flag, int i) { -+ this(s, flag, i, null); + public InventorySubcontainer(IChatBaseComponent ichatbasecomponent, int i) { ++ this(ichatbasecomponent, i, null); + } + -+ public InventorySubcontainer(String s, boolean flag, int i, org.bukkit.inventory.InventoryHolder owner) { ++ public InventorySubcontainer(IChatBaseComponent ichatbasecomponent, int i, org.bukkit.inventory.InventoryHolder owner) { + this.bukkitOwner = owner; + // CraftBukkit end - this.a = s; - this.e = flag; + this.a = ichatbasecomponent; this.b = i; + this.items = NonNullList.a(i, ItemStack.a); diff --git a/paper-server/nms-patches/ItemArmor.patch b/paper-server/nms-patches/ItemArmor.patch index 61627ea6b0..082ce7881d 100644 --- a/paper-server/nms-patches/ItemArmor.patch +++ b/paper-server/nms-patches/ItemArmor.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/ItemArmor.java +++ b/net/minecraft/server/ItemArmor.java -@@ -5,6 +5,11 @@ +@@ -4,6 +4,11 @@ import java.util.List; import java.util.UUID; @@ -11,10 +11,10 @@ + public class ItemArmor extends Item { - private static final int[] n = new int[] { 13, 15, 16, 11}; -@@ -33,6 +38,32 @@ + private static final UUID[] l = new UUID[] { UUID.fromString("845DB27C-C624-495F-8C9F-6020A9A58B6B"), UUID.fromString("D8499B04-0E66-4726-AB29-64469D734E0D"), UUID.fromString("9F3D476D-C118-4544-8365-64846904B48E"), UUID.fromString("2AD3F246-FEE1-4E67-B886-69FD380BB150")}; +@@ -29,6 +34,32 @@ EntityLiving entityliving = (EntityLiving) list.get(0); - EnumItemSlot enumitemslot = EntityInsentient.d(itemstack); + EnumItemSlot enumitemslot = EntityInsentient.e(itemstack); ItemStack itemstack1 = itemstack.cloneAndSubtract(1); + // CraftBukkit start + World world = isourceblock.getWorld(); @@ -36,8 +36,8 @@ + // Chain to handler for new item + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); -+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != ItemArmor.b) { -+ idispensebehavior.a(isourceblock, eventStack); ++ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != ItemArmor.a) { ++ idispensebehavior.dispense(isourceblock, eventStack); + return itemstack; + } + } diff --git a/paper-server/nms-patches/ItemBlock.patch b/paper-server/nms-patches/ItemBlock.patch index 859afa2808..b0bf1a67a7 100644 --- a/paper-server/nms-patches/ItemBlock.patch +++ b/paper-server/nms-patches/ItemBlock.patch @@ -1,11 +1,39 @@ --- a/net/minecraft/server/ItemBlock.java +++ b/net/minecraft/server/ItemBlock.java -@@ -36,7 +36,7 @@ +@@ -2,6 +2,11 @@ - SoundEffectType soundeffecttype = this.a.getStepSound(); + import java.util.Map; + import javax.annotation.Nullable; ++// CraftBukkit start ++import org.bukkit.craftbukkit.block.CraftBlock; ++import org.bukkit.craftbukkit.block.data.CraftBlockData; ++import org.bukkit.event.block.BlockCanBuildEvent; ++// CraftBukkit end + + public class ItemBlock extends Item { + +@@ -45,7 +50,7 @@ + + SoundEffectType soundeffecttype = block.getStepSound(); - world.a(entityhuman, blockposition, soundeffecttype.e(), SoundCategory.BLOCKS, (soundeffecttype.a() + 1.0F) / 2.0F, soundeffecttype.b() * 0.8F); + // world.a(entityhuman, blockposition, soundeffecttype.e(), SoundCategory.BLOCKS, (soundeffecttype.a() + 1.0F) / 2.0F, soundeffecttype.b() * 0.8F); // CraftBukkit - SPIGOT-1288 itemstack.subtract(1); + return EnumInteractionResult.SUCCESS; } +@@ -64,7 +69,14 @@ + } + protected boolean b(BlockActionContext blockactioncontext, IBlockData iblockdata) { +- return iblockdata.canPlace(blockactioncontext.getWorld(), blockactioncontext.getClickPosition()) && blockactioncontext.getWorld().a(iblockdata, blockactioncontext.getClickPosition()); ++ // CraftBukkit start - store default return ++ boolean defaultReturn = iblockdata.canPlace(blockactioncontext.getWorld(), blockactioncontext.getClickPosition()) && blockactioncontext.getWorld().a(iblockdata, blockactioncontext.getClickPosition()); ++ ++ BlockCanBuildEvent event = new BlockCanBuildEvent(CraftBlock.at(blockactioncontext.getWorld(), blockactioncontext.getClickPosition()), CraftBlockData.fromData(iblockdata), defaultReturn); ++ blockactioncontext.getWorld().getServer().getPluginManager().callEvent(event); ++ ++ return event.isBuildable(); ++ // CraftBukkit end + } + + protected boolean a(BlockActionContext blockactioncontext, IBlockData iblockdata) { diff --git a/paper-server/nms-patches/ItemBoat.patch b/paper-server/nms-patches/ItemBoat.patch index e25ef73ffc..e51c9eb586 100644 --- a/paper-server/nms-patches/ItemBoat.patch +++ b/paper-server/nms-patches/ItemBoat.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/server/ItemBoat.java +++ b/net/minecraft/server/ItemBoat.java -@@ -56,6 +56,13 @@ - } else if (movingobjectposition.type != MovingObjectPosition.EnumMovingObjectType.BLOCK) { +@@ -52,6 +52,13 @@ + if (flag) { return new InteractionResultWrapper(EnumInteractionResult.PASS, itemstack); - } else { + } else if (movingobjectposition.type == MovingObjectPosition.EnumMovingObjectType.BLOCK) { + // CraftBukkit start - Boat placement + org.bukkit.event.player.PlayerInteractEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent(entityhuman, org.bukkit.event.block.Action.RIGHT_CLICK_BLOCK, movingobjectposition.a(), movingobjectposition.direction, itemstack, enumhand); + @@ -11,10 +11,10 @@ + return new InteractionResultWrapper(EnumInteractionResult.PASS, itemstack); + } + // CraftBukkit end - Block block = world.getType(movingobjectposition.a()).getBlock(); - boolean flag1 = block == Blocks.WATER || block == Blocks.FLOWING_WATER; - EntityBoat entityboat = new EntityBoat(world, movingobjectposition.pos.x, flag1 ? movingobjectposition.pos.y - 0.12D : movingobjectposition.pos.y, movingobjectposition.pos.z); -@@ -66,7 +73,7 @@ + BlockPosition blockposition = movingobjectposition.a(); + Block block = world.getType(blockposition).getBlock(); + EntityBoat entityboat = new EntityBoat(world, movingobjectposition.pos.x, movingobjectposition.pos.y, movingobjectposition.pos.z); +@@ -62,7 +69,7 @@ return new InteractionResultWrapper(EnumInteractionResult.FAIL, itemstack); } else { if (!world.isClientSide) { diff --git a/paper-server/nms-patches/ItemBow.patch b/paper-server/nms-patches/ItemBow.patch index d17d8d150d..4f227519ef 100644 --- a/paper-server/nms-patches/ItemBow.patch +++ b/paper-server/nms-patches/ItemBow.patch @@ -1,14 +1,28 @@ --- a/net/minecraft/server/ItemBow.java +++ b/net/minecraft/server/ItemBow.java -@@ -1,5 +1,7 @@ +@@ -1,15 +1,21 @@ package net.minecraft.server; +import org.bukkit.event.entity.EntityCombustEvent; // CraftBukkit + public class ItemBow extends Item { - public ItemBow() { -@@ -73,7 +75,20 @@ + public ItemBow(Item.Info item_info) { + super(item_info); ++ // CraftBukkit start - obfuscator went a little crazy ++ /* + this.a(new MinecraftKey("pull"), (itemstack, world, entityliving) -> { + return entityliving == null ? 0.0F : (entityliving.cV().getItem() != Items.BOW ? 0.0F : (float) (itemstack.k() - entityliving.cW()) / 20.0F); + }); + this.a(new MinecraftKey("pulling"), (itemstack, world, entityliving) -> { + return entityliving != null && entityliving.isHandRaised() && entityliving.cV() == itemstack ? 1.0F : 0.0F; + }); ++ */ ++ // CraftBukkit end + } + + private ItemStack a(EntityHuman entityhuman) { +@@ -73,7 +79,20 @@ } if (EnchantmentManager.getEnchantmentLevel(Enchantments.ARROW_FIRE, itemstack) > 0) { @@ -30,7 +44,7 @@ } itemstack.damage(1, entityhuman); -@@ -81,7 +96,15 @@ +@@ -81,7 +100,15 @@ entityarrow.fromPlayer = EntityArrow.PickupStatus.CREATIVE_ONLY; } @@ -46,4 +60,4 @@ + // CraftBukkit end } - world.a((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.w, SoundCategory.PLAYERS, 1.0F, 1.0F / (ItemBow.j.nextFloat() * 0.4F + 1.2F) + f * 0.5F); + world.a((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.ENTITY_ARROW_SHOOT, SoundCategory.PLAYERS, 1.0F, 1.0F / (ItemBow.k.nextFloat() * 0.4F + 1.2F) + f * 0.5F); diff --git a/paper-server/nms-patches/ItemBucket.patch b/paper-server/nms-patches/ItemBucket.patch index 0d6b49e120..029b20230c 100644 --- a/paper-server/nms-patches/ItemBucket.patch +++ b/paper-server/nms-patches/ItemBucket.patch @@ -1,62 +1,53 @@ --- a/net/minecraft/server/ItemBucket.java +++ b/net/minecraft/server/ItemBucket.java -@@ -1,6 +1,12 @@ +@@ -1,6 +1,13 @@ package net.minecraft.server; import javax.annotation.Nullable; +// CraftBukkit start +import org.bukkit.craftbukkit.event.CraftEventFactory; +import org.bukkit.craftbukkit.inventory.CraftItemStack; ++import org.bukkit.craftbukkit.util.DummyGeneratorAccess; +import org.bukkit.event.player.PlayerBucketEmptyEvent; +import org.bukkit.event.player.PlayerBucketFillEvent; +// CraftBukkit end public class ItemBucket extends Item { -@@ -34,15 +40,29 @@ - Material material = iblockdata.getMaterial(); - - if (material == Material.WATER && ((Integer) iblockdata.get(BlockFluids.LEVEL)).intValue() == 0) { +@@ -28,12 +35,20 @@ + if (this.a == FluidTypes.a) { + iblockdata = world.getType(blockposition); + if (iblockdata.getBlock() instanceof IFluidSource) { + // CraftBukkit start -+ PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent(entityhuman, blockposition.getX(), blockposition.getY(), blockposition.getZ(), null, itemstack, Items.WATER_BUCKET); -+ -+ if (event.isCancelled()) { -+ return new InteractionResultWrapper(EnumInteractionResult.FAIL, itemstack); -+ } -+ // CraftBukkit end - world.setTypeAndData(blockposition, Blocks.AIR.getBlockData(), 11); - entityhuman.b(StatisticList.b((Item) this)); - entityhuman.a(SoundEffects.S, 1.0F, 1.0F); -- return new InteractionResultWrapper(EnumInteractionResult.SUCCESS, this.a(itemstack, entityhuman, Items.WATER_BUCKET)); -+ return new InteractionResultWrapper(EnumInteractionResult.SUCCESS, this.a(itemstack, entityhuman, Items.WATER_BUCKET, event.getItemStack())); // CraftBukkit - } else if (material == Material.LAVA && ((Integer) iblockdata.get(BlockFluids.LEVEL)).intValue() == 0) { -+ // CraftBukkit start -+ PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent(entityhuman, blockposition.getX(), blockposition.getY(), blockposition.getZ(), null, itemstack, Items.LAVA_BUCKET); ++ FluidType dummyFluid = ((IFluidSource) iblockdata.getBlock()).b(DummyGeneratorAccess.INSTANCE, blockposition, iblockdata); ++ PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent(entityhuman, blockposition.getX(), blockposition.getY(), blockposition.getZ(), null, itemstack, dummyFluid.b()); + + if (event.isCancelled()) { + return new InteractionResultWrapper(EnumInteractionResult.FAIL, itemstack); + } + // CraftBukkit end - entityhuman.a(SoundEffects.T, 1.0F, 1.0F); - world.setTypeAndData(blockposition, Blocks.AIR.getBlockData(), 11); - entityhuman.b(StatisticList.b((Item) this)); -- return new InteractionResultWrapper(EnumInteractionResult.SUCCESS, this.a(itemstack, entityhuman, Items.LAVA_BUCKET)); -+ return new InteractionResultWrapper(EnumInteractionResult.SUCCESS, this.a(itemstack, entityhuman, Items.LAVA_BUCKET, event.getItemStack())); // CraftBukkit - } else { - return new InteractionResultWrapper(EnumInteractionResult.FAIL, itemstack); - } -@@ -53,7 +73,7 @@ + FluidType fluidtype = ((IFluidSource) iblockdata.getBlock()).b(world, blockposition, iblockdata); - if (!entityhuman.a(blockposition1, movingobjectposition.direction, itemstack)) { - return new InteractionResultWrapper(EnumInteractionResult.FAIL, itemstack); -- } else if (this.a(entityhuman, world, blockposition1)) { -+ } else if (this.a(entityhuman, world, blockposition1, movingobjectposition.direction, blockposition, itemstack)) { // CraftBukkit - if (entityhuman instanceof EntityPlayer) { - CriterionTriggers.x.a((EntityPlayer) entityhuman, blockposition1, itemstack); - } -@@ -67,16 +87,19 @@ - } - } + if (fluidtype != FluidTypes.a) { + entityhuman.b(StatisticList.ITEM_USED.b(this)); + entityhuman.a(fluidtype.a(TagsFluid.b) ? SoundEffects.ITEM_BUCKET_FILL_LAVA : SoundEffects.ITEM_BUCKET_FILL, 1.0F, 1.0F); +- ItemStack itemstack1 = this.a(itemstack, entityhuman, fluidtype.b()); ++ ItemStack itemstack1 = this.a(itemstack, entityhuman, fluidtype.b(), event.getItemStack()); // CraftBukkit + + if (!world.isClientSide) { + CriterionTriggers.j.a((EntityPlayer) entityhuman, new ItemStack(fluidtype.b())); +@@ -48,7 +63,7 @@ + iblockdata = world.getType(blockposition); + BlockPosition blockposition1 = this.a(iblockdata, blockposition, movingobjectposition); + +- if (this.a(entityhuman, world, blockposition1, movingobjectposition)) { ++ if (this.a(entityhuman, world, blockposition1, movingobjectposition, blockposition, itemstack)) { // CraftBukkit + this.a(world, itemstack, blockposition1); + if (entityhuman instanceof EntityPlayer) { + CriterionTriggers.y.a((EntityPlayer) entityhuman, blockposition1, itemstack); +@@ -76,16 +91,19 @@ + + public void a(World world, ItemStack itemstack, BlockPosition blockposition) {} - private ItemStack a(ItemStack itemstack, EntityHuman entityhuman, Item item) { + // CraftBukkit - added ob.ItemStack result - TODO: Is this... the right way to handle this? @@ -78,33 +69,33 @@ } return itemstack; -@@ -84,7 +107,13 @@ +@@ -93,7 +111,13 @@ } } + // CraftBukkit start - public boolean a(@Nullable EntityHuman entityhuman, World world, BlockPosition blockposition) { -+ return a(entityhuman, world, blockposition, null, blockposition, null); + public boolean a(@Nullable EntityHuman entityhuman, World world, BlockPosition blockposition, @Nullable MovingObjectPosition movingobjectposition) { ++ return a(entityhuman, world, blockposition, movingobjectposition, null, null); + } + -+ public boolean a(EntityHuman entityhuman, World world, BlockPosition blockposition, EnumDirection enumdirection, BlockPosition clicked, ItemStack itemstack) { ++ public boolean a(EntityHuman entityhuman, World world, BlockPosition blockposition, @Nullable MovingObjectPosition movingobjectposition, BlockPosition clicked, ItemStack itemstack) { + // CraftBukkit end - if (this.a == Blocks.AIR) { + if (!(this.a instanceof FluidTypeFlowing)) { return false; } else { -@@ -96,6 +125,15 @@ - if (!world.isEmpty(blockposition) && !flag && !flag1) { - return false; +@@ -105,6 +129,15 @@ + if (!world.isEmpty(blockposition) && !flag && !flag1 && (!(iblockdata.getBlock() instanceof IFluidContainer) || !((IFluidContainer) iblockdata.getBlock()).a((IBlockAccess) world, blockposition, iblockdata, this.a))) { + return movingobjectposition == null ? false : this.a(entityhuman, world, movingobjectposition.a().shift(movingobjectposition.direction), (MovingObjectPosition) null); } else { + // CraftBukkit start + if (entityhuman != null) { -+ PlayerBucketEmptyEvent event = CraftEventFactory.callPlayerBucketEmptyEvent(entityhuman, clicked.getX(), clicked.getY(), clicked.getZ(), enumdirection, itemstack); ++ PlayerBucketEmptyEvent event = CraftEventFactory.callPlayerBucketEmptyEvent(entityhuman, clicked.getX(), clicked.getY(), clicked.getZ(), movingobjectposition.direction, itemstack); + if (event.isCancelled()) { + // TODO: inventory not updated + return false; + } + } + // CraftBukkit end - if (world.worldProvider.l() && this.a == Blocks.FLOWING_WATER) { + if (world.worldProvider.isNether() && this.a.a(TagsFluid.a)) { int i = blockposition.getX(); int j = blockposition.getY(); diff --git a/paper-server/nms-patches/ItemChorusFruit.patch b/paper-server/nms-patches/ItemChorusFruit.patch index c05c10b56b..70f0423c4f 100644 --- a/paper-server/nms-patches/ItemChorusFruit.patch +++ b/paper-server/nms-patches/ItemChorusFruit.patch @@ -11,9 +11,9 @@ + public class ItemChorusFruit extends ItemFood { - public ItemChorusFruit(int i, float f) { + public ItemChorusFruit(int i, float f, Item.Info item_info) { @@ -19,6 +25,20 @@ - double d4 = MathHelper.a(entityliving.locY + (double) (entityliving.getRandom().nextInt(16) - 8), 0.0D, (double) (world.ab() - 1)); + double d4 = MathHelper.a(entityliving.locY + (double) (entityliving.getRandom().nextInt(16) - 8), 0.0D, (double) (world.aa() - 1)); double d5 = entityliving.locZ + (entityliving.getRandom().nextDouble() - 0.5D) * 16.0D; + // CraftBukkit start diff --git a/paper-server/nms-patches/ItemDye.patch b/paper-server/nms-patches/ItemDye.patch index e92fa1886a..ab3d4cd2d1 100644 --- a/paper-server/nms-patches/ItemDye.patch +++ b/paper-server/nms-patches/ItemDye.patch @@ -1,19 +1,21 @@ --- a/net/minecraft/server/ItemDye.java +++ b/net/minecraft/server/ItemDye.java -@@ -1,5 +1,7 @@ - package net.minecraft.server; +@@ -3,6 +3,8 @@ + import com.google.common.collect.Maps; + import java.util.Map; +import org.bukkit.event.entity.SheepDyeWoolEvent; // CraftBukkit + public class ItemDye extends Item { - public static final int[] a = new int[] { 1973019, 11743532, 3887386, 5320730, 2437522, 8073150, 2651799, 11250603, 4408131, 14188952, 4312372, 14602026, 6719955, 12801229, 15435844, 15790320}; -@@ -89,6 +91,17 @@ - EnumColor enumcolor = EnumColor.fromInvColorIndex(itemstack.getData()); + private static final Map a = Maps.newEnumMap(EnumColor.class); +@@ -19,7 +21,17 @@ + EntitySheep entitysheep = (EntitySheep) entityliving; - if (!entitysheep.isSheared() && entitysheep.getColor() != enumcolor) { + if (!entitysheep.isSheared() && entitysheep.getColor() != this.b) { +- entitysheep.setColor(this.b); + // CraftBukkit start -+ byte bColor = (byte) enumcolor.getColorIndex(); ++ byte bColor = (byte) this.b.getColorIndex(); + SheepDyeWoolEvent event = new SheepDyeWoolEvent((org.bukkit.entity.Sheep) entitysheep.getBukkitEntity(), org.bukkit.DyeColor.getByWoolData(bColor)); + entitysheep.world.getServer().getPluginManager().callEvent(event); + @@ -21,8 +23,8 @@ + return false; + } + -+ enumcolor = EnumColor.fromColorIndex((byte) event.getColor().getWoolData()); ++ entitysheep.setColor(EnumColor.fromColorIndex((byte) event.getColor().getWoolData())); + // CraftBukkit end - entitysheep.setColor(enumcolor); itemstack.subtract(1); } + diff --git a/paper-server/nms-patches/ItemEnderPearl.patch b/paper-server/nms-patches/ItemEnderPearl.patch index ea00f5729b..baec115c58 100644 --- a/paper-server/nms-patches/ItemEnderPearl.patch +++ b/paper-server/nms-patches/ItemEnderPearl.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/ItemEnderPearl.java +++ b/net/minecraft/server/ItemEnderPearl.java -@@ -10,18 +10,26 @@ +@@ -9,18 +9,26 @@ public InteractionResultWrapper a(World world, EntityHuman entityhuman, EnumHand enumhand) { ItemStack itemstack = entityhuman.b(enumhand); @@ -21,7 +21,7 @@ itemstack.subtract(1); } - world.a((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.bn, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemEnderPearl.j.nextFloat() * 0.4F + 0.8F)); + world.a((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.ENTITY_ENDER_PEARL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemEnderPearl.k.nextFloat() * 0.4F + 0.8F)); entityhuman.getCooldownTracker().a(this, 20); - if (!world.isClientSide) { - EntityEnderPearl entityenderpearl = new EntityEnderPearl(world, entityhuman); @@ -31,5 +31,5 @@ - } + // CraftBukkit end - entityhuman.b(StatisticList.b((Item) this)); + entityhuman.b(StatisticList.ITEM_USED.b(this)); return new InteractionResultWrapper(EnumInteractionResult.SUCCESS, itemstack); diff --git a/paper-server/nms-patches/ItemFireball.patch b/paper-server/nms-patches/ItemFireball.patch index aa84efa135..fdab04fae0 100644 --- a/paper-server/nms-patches/ItemFireball.patch +++ b/paper-server/nms-patches/ItemFireball.patch @@ -1,17 +1,17 @@ --- a/net/minecraft/server/ItemFireball.java +++ b/net/minecraft/server/ItemFireball.java -@@ -17,6 +17,14 @@ - return EnumInteractionResult.FAIL; - } else { - if (world.getType(blockposition).getMaterial() == Material.AIR) { -+ // CraftBukkit start - fire BlockIgniteEvent -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), org.bukkit.event.block.BlockIgniteEvent.IgniteCause.FIREBALL, entityhuman).isCancelled()) { -+ if (!entityhuman.abilities.canInstantlyBuild) { -+ itemstack.subtract(1); -+ } -+ return EnumInteractionResult.PASS; +@@ -15,6 +15,14 @@ + BlockPosition blockposition = itemactioncontext.getClickPosition().shift(itemactioncontext.getClickedFace()); + + if (world.getType(blockposition).isAir()) { ++ // CraftBukkit start - fire BlockIgniteEvent ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition, org.bukkit.event.block.BlockIgniteEvent.IgniteCause.FIREBALL, itemactioncontext.getEntity()).isCancelled()) { ++ if (!itemactioncontext.getEntity().abilities.canInstantlyBuild) { ++ itemactioncontext.getItemStack().subtract(1); + } -+ // CraftBukkit end - world.a((EntityHuman) null, blockposition, SoundEffects.bD, SoundCategory.BLOCKS, 1.0F, (ItemFireball.j.nextFloat() - ItemFireball.j.nextFloat()) * 0.2F + 1.0F); - world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData()); - } ++ return EnumInteractionResult.PASS; ++ } ++ // CraftBukkit end + world.a((EntityHuman) null, blockposition, SoundEffects.ITEM_FIRECHARGE_USE, SoundCategory.BLOCKS, 1.0F, (ItemFireball.k.nextFloat() - ItemFireball.k.nextFloat()) * 0.2F + 1.0F); + world.setTypeUpdate(blockposition, ((BlockFire) Blocks.FIRE).a((IBlockAccess) world, blockposition)); + } diff --git a/paper-server/nms-patches/ItemFishingRod.patch b/paper-server/nms-patches/ItemFishingRod.patch index ca728962de..f9fd1bdc49 100644 --- a/paper-server/nms-patches/ItemFishingRod.patch +++ b/paper-server/nms-patches/ItemFishingRod.patch @@ -1,35 +1,50 @@ --- a/net/minecraft/server/ItemFishingRod.java +++ b/net/minecraft/server/ItemFishingRod.java -@@ -1,5 +1,7 @@ +@@ -1,9 +1,13 @@ package net.minecraft.server; +import org.bukkit.event.player.PlayerFishEvent; // CraftBukkit + public class ItemFishingRod extends Item { - public ItemFishingRod() { -@@ -20,7 +22,7 @@ + public ItemFishingRod(Item.Info item_info) { + super(item_info); ++ // CraftBukkit start - obfuscator went a little crazy ++ /* + this.a(new MinecraftKey("cast"), (itemstack, world, entityliving) -> { + if (entityliving == null) { + return 0.0F; +@@ -18,6 +22,8 @@ + return (flag || flag1) && entityliving instanceof EntityHuman && ((EntityHuman) entityliving).hookedFish != null ? 1.0F : 0.0F; + } + }); ++ */ ++ // CraftBukkit end + } + + public InteractionResultWrapper a(World world, EntityHuman entityhuman, EnumHand enumhand) { +@@ -30,7 +36,7 @@ entityhuman.a(enumhand); - world.a((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.J, SoundCategory.NEUTRAL, 1.0F, 0.4F / (ItemFishingRod.j.nextFloat() * 0.4F + 0.8F)); + world.a((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.ENTITY_FISHING_BOBBER_RETRIEVE, SoundCategory.NEUTRAL, 1.0F, 0.4F / (ItemFishingRod.k.nextFloat() * 0.4F + 0.8F)); } else { -- world.a((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.L, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemFishingRod.j.nextFloat() * 0.4F + 0.8F)); -+ // world.a((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.L, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemFishingRod.j.nextFloat() * 0.4F + 0.8F)); // CraftBukkit - moved down +- world.a((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.ENTITY_FISHING_BOBBER_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemFishingRod.k.nextFloat() * 0.4F + 0.8F)); ++ // world.a((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.ENTITY_FISHING_BOBBER_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemFishingRod.k.nextFloat() * 0.4F + 0.8F)); if (!world.isClientSide) { EntityFishingHook entityfishinghook = new EntityFishingHook(world, entityhuman); int j = EnchantmentManager.c(itemstack); -@@ -35,6 +37,17 @@ - entityfishinghook.c(k); +@@ -45,6 +51,17 @@ + entityfishinghook.b(k); } + // CraftBukkit start -+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), null, (org.bukkit.entity.Fish) entityfishinghook.getBukkitEntity(), PlayerFishEvent.State.FISHING); ++ PlayerFishEvent playerFishEvent = new PlayerFishEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), null, (org.bukkit.entity.FishHook) entityfishinghook.getBukkitEntity(), PlayerFishEvent.State.FISHING); + world.getServer().getPluginManager().callEvent(playerFishEvent); + + if (playerFishEvent.isCancelled()) { + entityhuman.hookedFish = null; + return new InteractionResultWrapper(EnumInteractionResult.PASS, itemstack); + } -+ world.a((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.L, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemFishingRod.j.nextFloat() * 0.4F + 0.8F)); ++ world.a((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.ENTITY_FISHING_BOBBER_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemFishingRod.k.nextFloat() * 0.4F + 0.8F)); + // CraftBukkit end + world.addEntity(entityfishinghook); diff --git a/paper-server/nms-patches/ItemFlintAndSteel.patch b/paper-server/nms-patches/ItemFlintAndSteel.patch index 7442ab6ff0..81a7ef4836 100644 --- a/paper-server/nms-patches/ItemFlintAndSteel.patch +++ b/paper-server/nms-patches/ItemFlintAndSteel.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/server/ItemFlintAndSteel.java +++ b/net/minecraft/server/ItemFlintAndSteel.java -@@ -16,6 +16,12 @@ - return EnumInteractionResult.FAIL; - } else { - if (world.getType(blockposition).getMaterial() == Material.AIR) { -+ // CraftBukkit start - Store the clicked block -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), org.bukkit.event.block.BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL, entityhuman).isCancelled()) { -+ itemstack.damage(1, entityhuman); -+ return EnumInteractionResult.PASS; -+ } -+ // CraftBukkit end - world.a(entityhuman, blockposition, SoundEffects.bO, SoundCategory.BLOCKS, 1.0F, ItemFlintAndSteel.j.nextFloat() * 0.4F + 0.8F); - world.setTypeAndData(blockposition, Blocks.FIRE.getBlockData(), 11); - } +@@ -14,6 +14,12 @@ + BlockPosition blockposition = itemactioncontext.getClickPosition().shift(itemactioncontext.getClickedFace()); + + if (a((GeneratorAccess) world, blockposition)) { ++ // CraftBukkit start - Store the clicked block ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition, org.bukkit.event.block.BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL, entityhuman).isCancelled()) { ++ itemactioncontext.getItemStack().damage(1, entityhuman); ++ return EnumInteractionResult.PASS; ++ } ++ // CraftBukkit end + world.a(entityhuman, blockposition, SoundEffects.ITEM_FLINTANDSTEEL_USE, SoundCategory.BLOCKS, 1.0F, ItemFlintAndSteel.k.nextFloat() * 0.4F + 0.8F); + IBlockData iblockdata = ((BlockFire) Blocks.FIRE).a((IBlockAccess) world, blockposition); + diff --git a/paper-server/nms-patches/ItemHanging.patch b/paper-server/nms-patches/ItemHanging.patch index f6826f0058..2991d715f3 100644 --- a/paper-server/nms-patches/ItemHanging.patch +++ b/paper-server/nms-patches/ItemHanging.patch @@ -11,12 +11,12 @@ public class ItemHanging extends Item { -@@ -20,6 +24,18 @@ +@@ -25,6 +29,18 @@ if (entityhanging != null && entityhanging.survives()) { if (!world.isClientSide) { + // CraftBukkit start - fire HangingPlaceEvent -+ Player who = (entityhuman == null) ? null : (Player) entityhuman.getBukkitEntity(); ++ Player who = (itemactioncontext.getEntity() == null) ? null : (Player) itemactioncontext.getEntity().getBukkitEntity(); + org.bukkit.block.Block blockClicked = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); + org.bukkit.block.BlockFace blockFace = org.bukkit.craftbukkit.block.CraftBlock.notchToBlockFace(enumdirection); + @@ -27,6 +27,6 @@ + return EnumInteractionResult.FAIL; + } + // CraftBukkit end - entityhanging.p(); + entityhanging.m(); world.addEntity(entityhanging); } diff --git a/paper-server/nms-patches/ItemLeash.patch b/paper-server/nms-patches/ItemLeash.patch index d51c6786bf..6a695213f3 100644 --- a/paper-server/nms-patches/ItemLeash.patch +++ b/paper-server/nms-patches/ItemLeash.patch @@ -8,8 +8,8 @@ + public class ItemLeash extends Item { - public ItemLeash() { -@@ -39,7 +41,23 @@ + public ItemLeash(Item.Info item_info) { +@@ -43,7 +45,23 @@ if (entityinsentient.isLeashed() && entityinsentient.getLeashHolder() == entityhuman) { if (entityleash == null) { entityleash = EntityLeash.a(world, blockposition); diff --git a/paper-server/nms-patches/ItemMinecart.patch b/paper-server/nms-patches/ItemMinecart.patch index 60c5b2e5ff..ef20cdf99d 100644 --- a/paper-server/nms-patches/ItemMinecart.patch +++ b/paper-server/nms-patches/ItemMinecart.patch @@ -38,7 +38,7 @@ + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); + if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { -+ idispensebehavior.a(isourceblock, eventStack); ++ idispensebehavior.dispense(isourceblock, eventStack); + return itemstack; + } + } @@ -58,7 +58,7 @@ return itemstack; } -@@ -83,7 +117,7 @@ +@@ -84,7 +118,7 @@ entityminecartabstract.setCustomName(itemstack.getName()); } diff --git a/paper-server/nms-patches/ItemMonsterEgg.patch b/paper-server/nms-patches/ItemMonsterEgg.patch deleted file mode 100644 index 2069ea11bf..0000000000 --- a/paper-server/nms-patches/ItemMonsterEgg.patch +++ /dev/null @@ -1,30 +0,0 @@ ---- a/net/minecraft/server/ItemMonsterEgg.java -+++ b/net/minecraft/server/ItemMonsterEgg.java -@@ -152,6 +152,11 @@ - - @Nullable - public static Entity a(World world, @Nullable MinecraftKey minecraftkey, double d0, double d1, double d2) { -+ return spawnCreature(world, minecraftkey, d0, d1, d2, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG); -+ } -+ -+ @Nullable -+ public static Entity spawnCreature(World world, @Nullable MinecraftKey minecraftkey, double d0, double d1, double d2, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) { - if (minecraftkey != null && EntityTypes.eggInfo.containsKey(minecraftkey)) { - Entity entity = null; - -@@ -164,8 +169,13 @@ - entityinsentient.aP = entityinsentient.yaw; - entityinsentient.aN = entityinsentient.yaw; - entityinsentient.prepare(world.D(new BlockPosition(entityinsentient)), (GroupDataEntity) null); -- world.addEntity(entity); -- entityinsentient.D(); -+ // CraftBukkit start - don't return an entity when CreatureSpawnEvent is canceled -+ if (!world.addEntity(entity, spawnReason)) { -+ entity = null; -+ } else { -+ entityinsentient.D(); -+ } -+ // CraftBukkit end - } - } - diff --git a/paper-server/nms-patches/ItemRecord.patch b/paper-server/nms-patches/ItemRecord.patch index 0dff1125b8..ab2b7647de 100644 --- a/paper-server/nms-patches/ItemRecord.patch +++ b/paper-server/nms-patches/ItemRecord.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/server/ItemRecord.java +++ b/net/minecraft/server/ItemRecord.java -@@ -22,6 +22,7 @@ +@@ -34,6 +34,7 @@ + ItemStack itemstack = itemactioncontext.getItemStack(); - if (iblockdata.getBlock() == Blocks.JUKEBOX && !((Boolean) iblockdata.get(BlockJukeBox.HAS_RECORD)).booleanValue()) { if (!world.isClientSide) { + if (true) return EnumInteractionResult.SUCCESS; // CraftBukkit - handled in ItemStack - ItemStack itemstack = entityhuman.b(enumhand); - - ((BlockJukeBox) Blocks.JUKEBOX).a(world, blockposition, iblockdata, itemstack); + ((BlockJukeBox) Blocks.JUKEBOX).a((GeneratorAccess) world, blockposition, iblockdata, itemstack); + world.a((EntityHuman) null, 1010, blockposition, Item.getId(this)); + itemstack.subtract(1); diff --git a/paper-server/nms-patches/ItemRedstone.patch b/paper-server/nms-patches/ItemRedstone.patch deleted file mode 100644 index 62cf2e3555..0000000000 --- a/paper-server/nms-patches/ItemRedstone.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/server/ItemRedstone.java -+++ b/net/minecraft/server/ItemRedstone.java -@@ -11,7 +11,7 @@ - BlockPosition blockposition1 = flag ? blockposition : blockposition.shift(enumdirection); - ItemStack itemstack = entityhuman.b(enumhand); - -- if (entityhuman.a(blockposition1, enumdirection, itemstack) && world.a(world.getType(blockposition1).getBlock(), blockposition1, false, enumdirection, (Entity) null) && Blocks.REDSTONE_WIRE.canPlace(world, blockposition1)) { -+ if (!itemstack.isEmpty() && entityhuman.a(blockposition1, enumdirection, itemstack) && world.a(world.getType(blockposition1).getBlock(), blockposition1, false, enumdirection, (Entity) null) && Blocks.REDSTONE_WIRE.canPlace(world, blockposition1)) { // CraftBukkit - world.setTypeUpdate(blockposition1, Blocks.REDSTONE_WIRE.getBlockData()); - if (entityhuman instanceof EntityPlayer) { - CriterionTriggers.x.a((EntityPlayer) entityhuman, blockposition1, itemstack); diff --git a/paper-server/nms-patches/ItemReed.patch b/paper-server/nms-patches/ItemReed.patch deleted file mode 100644 index c3c6658456..0000000000 --- a/paper-server/nms-patches/ItemReed.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/server/ItemReed.java -+++ b/net/minecraft/server/ItemReed.java -@@ -2,7 +2,7 @@ - - public class ItemReed extends Item { - -- private final Block a; -+ public final Block a; // PAIL: private->public - - public ItemReed(Block block) { - this.a = block; diff --git a/paper-server/nms-patches/ItemSkull.patch b/paper-server/nms-patches/ItemSkullPlayer.patch similarity index 87% rename from paper-server/nms-patches/ItemSkull.patch rename to paper-server/nms-patches/ItemSkullPlayer.patch index e0f0e443b7..0679f50303 100644 --- a/paper-server/nms-patches/ItemSkull.patch +++ b/paper-server/nms-patches/ItemSkullPlayer.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/server/ItemSkull.java -+++ b/net/minecraft/server/ItemSkull.java -@@ -133,6 +133,15 @@ +--- a/net/minecraft/server/ItemSkullPlayer.java ++++ b/net/minecraft/server/ItemSkullPlayer.java +@@ -42,6 +42,15 @@ nbttagcompound.set("SkullOwner", GameProfileSerializer.serialize(new NBTTagCompound(), gameprofile)); return true; } else { diff --git a/paper-server/nms-patches/ItemSnowball.patch b/paper-server/nms-patches/ItemSnowball.patch index 77d4839594..498fa712e7 100644 --- a/paper-server/nms-patches/ItemSnowball.patch +++ b/paper-server/nms-patches/ItemSnowball.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/ItemSnowball.java +++ b/net/minecraft/server/ItemSnowball.java -@@ -10,17 +10,29 @@ +@@ -9,17 +9,29 @@ public InteractionResultWrapper a(World world, EntityHuman entityhuman, EnumHand enumhand) { ItemStack itemstack = entityhuman.b(enumhand); @@ -10,7 +10,7 @@ itemstack.subtract(1); } - world.a((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.hp, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemSnowball.j.nextFloat() * 0.4F + 0.8F)); + world.a((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.ENTITY_SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemSnowball.k.nextFloat() * 0.4F + 0.8F)); + */ if (!world.isClientSide) { EntitySnowball entitysnowball = new EntitySnowball(world, entityhuman); @@ -22,12 +22,12 @@ + itemstack.subtract(1); + } + -+ world.a((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.hp, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemSnowball.j.nextFloat() * 0.4F + 0.8F)); ++ world.a((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.ENTITY_SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemSnowball.k.nextFloat() * 0.4F + 0.8F)); + } else if (entityhuman instanceof EntityPlayer) { + ((EntityPlayer) entityhuman).getBukkitEntity().updateInventory(); + } } + // CraftBukkit end - entityhuman.b(StatisticList.b((Item) this)); + entityhuman.b(StatisticList.ITEM_USED.b(this)); return new InteractionResultWrapper(EnumInteractionResult.SUCCESS, itemstack); diff --git a/paper-server/nms-patches/ItemStack.patch b/paper-server/nms-patches/ItemStack.patch index 0e6dbd508f..672002cd40 100644 --- a/paper-server/nms-patches/ItemStack.patch +++ b/paper-server/nms-patches/ItemStack.patch @@ -1,10 +1,11 @@ --- a/net/minecraft/server/ItemStack.java +++ b/net/minecraft/server/ItemStack.java -@@ -6,6 +6,19 @@ - import java.util.Random; - import javax.annotation.Nullable; +@@ -16,6 +16,20 @@ + import org.apache.logging.log4j.LogManager; + import org.apache.logging.log4j.Logger; +// CraftBukkit start ++import com.mojang.datafixers.Dynamic; +import java.util.List; +import java.util.Map; + @@ -19,291 +20,211 @@ + public final class ItemStack { - public static final ItemStack a = new ItemStack((Item) null); -@@ -42,32 +55,74 @@ - this(item, i, 0); - } - -+ // CraftBukkit start - public ItemStack(Item item, int i, int j) { -+ this(item, i, j, true); -+ } -+ -+ public ItemStack(Item item, int i, int j, boolean convert) { -+ // CraftBukkit end - this.item = item; - this.damage = j; - this.count = i; -+ // CraftBukkit start - Pass to setData to do filtering -+ if (MinecraftServer.getServer() != null) { -+ this.setData(j); -+ } -+ if (convert) { -+ this.convertStack(); -+ } -+ // CraftBukkit end - if (this.damage < 0) { -- this.damage = 0; -+ // this.damage = 0; // CraftBukkit - remove this. - } - - this.F(); + private static final Logger c = LogManager.getLogger(); +@@ -50,25 +64,43 @@ + this.E(); } + // Called to run this stack through the data converter to handle older storage methods and serialized items + public void convertStack() { + if (MinecraftServer.getServer() != null) { -+ // Don't convert beds - both the old and new data values are valid -+ // Conversion would make getting white beds (data value 0) impossible -+ if (this.item == Items.BED) { -+ return; -+ } -+ + NBTTagCompound savedStack = new NBTTagCompound(); + this.save(savedStack); -+ MinecraftServer.getServer().dataConverterManager.a(DataConverterTypes.ITEM_INSTANCE, savedStack); // PAIL: convert ++ MinecraftServer.getServer().dataConverterManager.update(DataConverterTypes.ITEM_STACK, new Dynamic(DynamicOpsNBT.a, savedStack), -1, CraftMagicNumbers.DATA_VERSION); + this.load(savedStack); + } + } + - private void F() { -+ if (this.g && this == ItemStack.a) throw new AssertionError("TRAP"); // CraftBukkit - this.g = this.isEmpty(); + private void E() { ++ if (this.h && this == ItemStack.a) throw new AssertionError("TRAP"); // CraftBukkit + this.h = false; + this.h = this.isEmpty(); } -- public ItemStack(NBTTagCompound nbttagcompound) { +- private ItemStack(NBTTagCompound nbttagcompound) { + // CraftBukkit - break into own method -+ public void load(NBTTagCompound nbttagcompound) { - this.item = Item.b(nbttagcompound.getString("id")); ++ private void load(NBTTagCompound nbttagcompound) { + Item item = (Item) Item.REGISTRY.get(new MinecraftKey(nbttagcompound.getString("id"))); + + this.item = item == null ? Items.AIR : item; this.count = nbttagcompound.getByte("Count"); -- this.damage = Math.max(0, nbttagcompound.getShort("Damage")); -+ // CraftBukkit start - Route through setData for filtering -+ // this.damage = Math.max(0, nbttagcompound.getShort("Damage")); -+ this.setData(nbttagcompound.getShort("Damage")); -+ // CraftBukkit end -+ if (nbttagcompound.hasKeyOfType("tag", 10)) { - this.tag = nbttagcompound.getCompound("tag"); +- this.getItem().a(nbttagcompound); + // CraftBukkit start - make defensive copy as this data may be coming from the save thread + this.tag = (NBTTagCompound) nbttagcompound.getCompound("tag").clone(); - if (this.item != null) { -- this.item.a(nbttagcompound); -+ this.item.a(this.tag); -+ // CraftBukkit end - } ++ this.getItem().a(this.tag); ++ // CraftBukkit end + } + + if (this.getItem().usesDurability()) { + this.setDamage(this.getDamage()); } + } -+ public ItemStack(NBTTagCompound nbttagcompound) { ++ private ItemStack(NBTTagCompound nbttagcompound) { + this.load(nbttagcompound); + // CraftBukkit end - this.F(); + this.E(); } -@@ -94,11 +149,138 @@ +@@ -98,7 +130,7 @@ + return this.h ? Items.AIR : this.item; } - public EnumInteractionResult placeItem(EntityHuman entityhuman, World world, BlockPosition blockposition, EnumHand enumhand, EnumDirection enumdirection, float f, float f1, float f2) { -+ // CraftBukkit start - handle all block place event logic here -+ int oldData = this.getData(); -+ int oldCount = this.getCount(); +- public EnumInteractionResult placeItem(ItemActionContext itemactioncontext) { ++ public EnumInteractionResult placeItem(ItemActionContext itemactioncontext, EnumHand enumhand) { // CraftBukkit - add hand + EntityHuman entityhuman = itemactioncontext.getEntity(); + BlockPosition blockposition = itemactioncontext.getClickPosition(); + ShapeDetectorBlock shapedetectorblock = new ShapeDetectorBlock(itemactioncontext.getWorld(), blockposition, false); +@@ -106,12 +138,124 @@ + if (entityhuman != null && !entityhuman.abilities.mayBuild && !this.b(itemactioncontext.getWorld().E(), shapedetectorblock)) { + return EnumInteractionResult.PASS; + } else { ++ // CraftBukkit start - handle all block place event logic here ++ int oldCount = this.getCount(); ++ World world = itemactioncontext.getWorld(); + -+ if (!(this.getItem() instanceof ItemBucket)) { // if not bucket -+ world.captureBlockStates = true; -+ // special case bonemeal -+ if (this.getItem() instanceof ItemDye && this.getData() == 15) { -+ Block block = world.getType(blockposition).getBlock(); -+ if (block == Blocks.SAPLING || block instanceof BlockMushroom) { -+ world.captureTreeGeneration = true; ++ if (!(this.getItem() instanceof ItemBucket)) { // if not bucket ++ world.captureBlockStates = true; ++ // special case bonemeal ++ if (this.getItem() == Items.BONE_MEAL) { ++ Block block = world.getType(blockposition).getBlock(); ++ if (block instanceof BlockSapling || block instanceof BlockMushroom) { ++ world.captureTreeGeneration = true; ++ } + } + } -+ } - EnumInteractionResult enuminteractionresult = this.getItem().a(entityhuman, world, blockposition, enumhand, enumdirection, f, f1, f2); -+ int newData = this.getData(); -+ int newCount = this.getCount(); -+ this.setCount(oldCount); -+ this.setData(oldData); -+ world.captureBlockStates = false; -+ if (enuminteractionresult == EnumInteractionResult.SUCCESS && world.captureTreeGeneration && world.capturedBlockStates.size() > 0) { + Item item = this.getItem(); + EnumInteractionResult enuminteractionresult = item.a(itemactioncontext); ++ int newCount = this.getCount(); ++ this.setCount(oldCount); ++ world.captureBlockStates = false; ++ if (enuminteractionresult == EnumInteractionResult.SUCCESS && world.captureTreeGeneration && world.capturedBlockStates.size() > 0) { ++ world.captureTreeGeneration = false; ++ Location location = new Location(world.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ()); ++ TreeType treeType = BlockSapling.treeType; ++ BlockSapling.treeType = null; ++ List blocks = (List) world.capturedBlockStates.clone(); ++ world.capturedBlockStates.clear(); ++ StructureGrowEvent event = null; ++ if (treeType != null) { ++ boolean isBonemeal = getItem() == Items.BONE_MEAL; ++ event = new StructureGrowEvent(location, treeType, isBonemeal, (Player) entityhuman.getBukkitEntity(), blocks); ++ org.bukkit.Bukkit.getPluginManager().callEvent(event); ++ } ++ if (event == null || !event.isCancelled()) { ++ // Change the stack to its new contents if it hasn't been tampered with. ++ if (this.getCount() == oldCount) { ++ this.setCount(newCount); ++ } ++ for (BlockState blockstate : blocks) { ++ blockstate.update(true); ++ } ++ } ++ ++ return enuminteractionresult; ++ } + world.captureTreeGeneration = false; -+ Location location = new Location(world.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ()); -+ TreeType treeType = BlockSapling.treeType; -+ BlockSapling.treeType = null; -+ List blocks = (List) world.capturedBlockStates.clone(); -+ world.capturedBlockStates.clear(); -+ StructureGrowEvent event = null; -+ if (treeType != null) { -+ boolean isBonemeal = getItem() == Items.DYE && oldData == 15; -+ event = new StructureGrowEvent(location, treeType, isBonemeal, (Player) entityhuman.getBukkitEntity(), blocks); -+ org.bukkit.Bukkit.getPluginManager().callEvent(event); -+ } -+ if (event == null || !event.isCancelled()) { -+ // Change the stack to its new contents if it hasn't been tampered with. -+ if (this.getCount() == oldCount && this.getData() == oldData) { -+ this.setData(newData); -+ this.setCount(newCount); -+ } -+ for (BlockState blockstate : blocks) { -+ blockstate.update(true); -+ } -+ } -+ -+ return enuminteractionresult; -+ } -+ world.captureTreeGeneration = false; - if (enuminteractionresult == EnumInteractionResult.SUCCESS) { -- entityhuman.b(StatisticList.b(this.item)); -+ org.bukkit.event.block.BlockPlaceEvent placeEvent = null; -+ List blocks = (List) world.capturedBlockStates.clone(); -+ world.capturedBlockStates.clear(); -+ if (blocks.size() > 1) { -+ placeEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockMultiPlaceEvent(world, entityhuman, enumhand, blocks, blockposition.getX(), blockposition.getY(), blockposition.getZ()); -+ } else if (blocks.size() == 1) { -+ placeEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPlaceEvent(world, entityhuman, enumhand, blocks.get(0), blockposition.getX(), blockposition.getY(), blockposition.getZ()); -+ } -+ -+ if (placeEvent != null && (placeEvent.isCancelled() || !placeEvent.canBuild())) { -+ enuminteractionresult = EnumInteractionResult.FAIL; // cancel placement -+ // PAIL: Remove this when MC-99075 fixed -+ placeEvent.getPlayer().updateInventory(); -+ // revert back all captured blocks -+ for (BlockState blockstate : blocks) { -+ blockstate.update(true, false); -+ } -+ } else { -+ // Change the stack to its new contents if it hasn't been tampered with. -+ if (this.getCount() == oldCount && this.getData() == oldData) { -+ this.setData(newData); -+ this.setCount(newCount); + if (entityhuman != null && enuminteractionresult == EnumInteractionResult.SUCCESS) { +- entityhuman.b(StatisticList.ITEM_USED.b(item)); ++ org.bukkit.event.block.BlockPlaceEvent placeEvent = null; ++ List blocks = (List) world.capturedBlockStates.clone(); ++ world.capturedBlockStates.clear(); ++ if (blocks.size() > 1) { ++ placeEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockMultiPlaceEvent(world, entityhuman, enumhand, blocks, blockposition.getX(), blockposition.getY(), blockposition.getZ()); ++ } else if (blocks.size() == 1) { ++ placeEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPlaceEvent(world, entityhuman, enumhand, blocks.get(0), blockposition.getX(), blockposition.getY(), blockposition.getZ()); + } + -+ for (Map.Entry e : world.capturedTileEntities.entrySet()) { -+ world.setTileEntity(e.getKey(), e.getValue()); -+ } -+ -+ for (BlockState blockstate : blocks) { -+ int x = blockstate.getX(); -+ int y = blockstate.getY(); -+ int z = blockstate.getZ(); -+ int updateFlag = ((CraftBlockState) blockstate).getFlag(); -+ org.bukkit.Material mat = blockstate.getType(); -+ Block oldBlock = CraftMagicNumbers.getBlock(mat); -+ BlockPosition newblockposition = new BlockPosition(x, y, z); -+ IBlockData block = world.getType(newblockposition); -+ -+ if (!(block.getBlock() instanceof BlockTileEntity)) { // Containers get placed automatically -+ block.getBlock().onPlace(world, newblockposition, block); ++ if (placeEvent != null && (placeEvent.isCancelled() || !placeEvent.canBuild())) { ++ enuminteractionresult = EnumInteractionResult.FAIL; // cancel placement ++ // PAIL: Remove this when MC-99075 fixed ++ placeEvent.getPlayer().updateInventory(); ++ // revert back all captured blocks ++ for (BlockState blockstate : blocks) { ++ blockstate.update(true, false); ++ } ++ } else { ++ // Change the stack to its new contents if it hasn't been tampered with. ++ if (this.getCount() == oldCount) { ++ this.setCount(newCount); + } + -+ world.notifyAndUpdatePhysics(newblockposition, null, oldBlock.getBlockData(), block, updateFlag); // send null chunk as chunk.k() returns false by this point -+ } ++ for (Map.Entry e : world.capturedTileEntities.entrySet()) { ++ world.setTileEntity(e.getKey(), e.getValue()); ++ } + -+ // Special case juke boxes as they update their tile entity. Copied from ItemRecord. -+ // PAIL: checkme on updates. -+ if (this.item instanceof ItemRecord) { -+ ((BlockJukeBox) Blocks.JUKEBOX).a(world, blockposition, world.getType(blockposition), this); -+ world.a((EntityHuman) null, 1010, blockposition, Item.getId(this.item)); -+ this.subtract(1); -+ entityhuman.b(StatisticList.Z); -+ } ++ for (BlockState blockstate : blocks) { ++ int x = blockstate.getX(); ++ int y = blockstate.getY(); ++ int z = blockstate.getZ(); ++ int updateFlag = ((CraftBlockState) blockstate).getFlag(); ++ IBlockData oldBlock = ((CraftBlockState) blockstate).getHandle(); ++ BlockPosition newblockposition = new BlockPosition(x, y, z); ++ IBlockData block = world.getType(newblockposition); + -+ if (this.item == Items.SKULL) { // Special case skulls to allow wither spawns to be cancelled -+ BlockPosition bp = blockposition; -+ if (!world.getType(blockposition).getBlock().a(world, blockposition)) { -+ if (!world.getType(blockposition).getMaterial().isBuildable()) { -+ bp = null; -+ } else { -+ bp = bp.shift(enumdirection); ++ if (!(block.getBlock() instanceof BlockTileEntity)) { // Containers get placed automatically ++ block.getBlock().onPlace(block, world, newblockposition, oldBlock); + } ++ ++ world.notifyAndUpdatePhysics(newblockposition, null, oldBlock, block, world.getType(newblockposition), updateFlag); // send null chunk as chunk.k() returns false by this point + } -+ if (bp != null) { -+ TileEntity te = world.getTileEntity(bp); ++ ++ // Special case juke boxes as they update their tile entity. Copied from ItemRecord. ++ // PAIL: checkme on updates. ++ if (this.item instanceof ItemRecord) { ++ ((BlockJukeBox) Blocks.JUKEBOX).a(world, blockposition, world.getType(blockposition), this); ++ world.a((EntityHuman) null, 1010, blockposition, Item.getId(this.item)); ++ this.subtract(1); ++ entityhuman.a(StatisticList.PLAY_RECORD); ++ } ++ ++ if (this.item == Items.WITHER_SKELETON_SKULL) { // Special case skulls to allow wither spawns to be cancelled ++ TileEntity te = world.getTileEntity(blockposition); + if (te instanceof TileEntitySkull) { -+ Blocks.SKULL.a(world, bp, (TileEntitySkull) te); ++ BlockWitherSkull.a(world, blockposition, (TileEntitySkull) te); + } + } -+ } + -+ // SPIGOT-1288 - play sound stripped from ItemBlock -+ if (this.item instanceof ItemBlock) { -+ SoundEffectType soundeffecttype = ((ItemBlock) this.item).getBlock().getStepSound(); -+ world.a(entityhuman, blockposition, soundeffecttype.e(), SoundCategory.BLOCKS, (soundeffecttype.a() + 1.0F) / 2.0F, soundeffecttype.b() * 0.8F); -+ } ++ // SPIGOT-1288 - play sound stripped from ItemBlock ++ if (this.item instanceof ItemBlock) { ++ SoundEffectType soundeffecttype = ((ItemBlock) this.item).getBlock().getStepSound(); ++ world.a(entityhuman, blockposition, soundeffecttype.e(), SoundCategory.BLOCKS, (soundeffecttype.a() + 1.0F) / 2.0F, soundeffecttype.b() * 0.8F); ++ } + -+ entityhuman.b(StatisticList.b(this.item)); -+ } - } -+ world.capturedTileEntities.clear(); -+ world.capturedBlockStates.clear(); -+ // CraftBukkit end ++ entityhuman.b(StatisticList.ITEM_USED.b(item)); ++ } + } ++ world.capturedTileEntities.clear(); ++ world.capturedBlockStates.clear(); ++ // CraftBukkit end - return enuminteractionresult; - } -@@ -122,7 +304,7 @@ + return enuminteractionresult; + } +@@ -135,7 +279,7 @@ + nbttagcompound.setString("id", minecraftkey == null ? "minecraft:air" : minecraftkey.toString()); nbttagcompound.setByte("Count", (byte) this.count); - nbttagcompound.setShort("Damage", (short) this.damage); if (this.tag != null) { - nbttagcompound.set("tag", this.tag); + nbttagcompound.set("tag", this.tag.clone()); // CraftBukkit - make defensive copy, data is going to another thread } return nbttagcompound; -@@ -157,11 +339,30 @@ - } - - public void setData(int i) { -+ // CraftBukkit start - Filter out data for items that shouldn't have it -+ // The crafting system uses this value for a special purpose so we have to allow it -+ if (i == 32767) { -+ this.damage = i; -+ return; -+ } -+ -+ // Is this a block? -+ if (CraftMagicNumbers.getBlock(CraftMagicNumbers.getId(this.getItem())) != Blocks.AIR) { -+ // If vanilla doesn't use data on it don't allow any -+ if (!(this.usesData() || this.getItem().usesDurability())) { -+ i = 0; -+ } -+ } -+ -+ // Filter invalid plant data -+ if (CraftMagicNumbers.getBlock(CraftMagicNumbers.getId(this.getItem())) == Blocks.DOUBLE_PLANT && (i > 5 || i < 0)) { -+ i = 0; -+ } -+ // CraftBukkit end - this.damage = i; - if (this.damage < 0) { -- this.damage = 0; -+ // this.damage = 0; // CraftBukkit - remove this. - } -- - } - - public int k() { -@@ -202,6 +403,11 @@ - if (this.f()) { +@@ -213,6 +357,11 @@ if (this.isDamaged(i, entityliving.getRandom(), entityliving instanceof EntityPlayer ? (EntityPlayer) entityliving : null)) { - entityliving.b(this); + entityliving.c(this); + Item item = this.getItem(); + // CraftBukkit start - Check for item breaking + if (this.count == 1 && entityliving instanceof EntityHuman) { + org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerItemBreakEvent((EntityHuman) entityliving, this); + } + // CraftBukkit end + this.subtract(1); if (entityliving instanceof EntityHuman) { - EntityHuman entityhuman = (EntityHuman) entityliving; -@@ -243,7 +449,7 @@ - } - - public ItemStack cloneItemStack() { -- ItemStack itemstack = new ItemStack(this.item, this.count, this.damage); -+ ItemStack itemstack = new ItemStack(this.item, this.count, this.damage, false); // CraftBukkit - - itemstack.d(this.D()); - if (this.tag != null) { -@@ -464,6 +670,14 @@ +@@ -480,6 +629,14 @@ } public void setRepairCost(int i) { @@ -315,19 +236,20 @@ + return; + } + // CraftBukkit end - if (!this.hasTag()) { - this.tag = new NBTTagCompound(); - } -@@ -513,6 +727,12 @@ - nbttaglist.add(nbttagcompound); + this.getOrCreateTag().setInt("RepairCost", i); } +@@ -522,6 +679,13 @@ + nbttaglist.add((NBTBase) nbttagcompound); + } + ++ // CraftBukkit start + @Deprecated + public void setItem(Item item) { + this.item = item; -+ this.setData(this.getData()); // CraftBukkit - Set data again to ensure it is filtered properly + } ++ // CraftBukkit end + - public IChatBaseComponent C() { - ChatComponentText chatcomponenttext = new ChatComponentText(this.getName()); + public IChatBaseComponent A() { + IChatBaseComponent ichatbasecomponent = (new ChatComponentText("")).addSibling(this.getName()); diff --git a/paper-server/nms-patches/ItemWaterLily.patch b/paper-server/nms-patches/ItemWaterLily.patch index 65b3ab61ed..0e9db92f51 100644 --- a/paper-server/nms-patches/ItemWaterLily.patch +++ b/paper-server/nms-patches/ItemWaterLily.patch @@ -1,12 +1,12 @@ --- a/net/minecraft/server/ItemWaterLily.java +++ b/net/minecraft/server/ItemWaterLily.java -@@ -24,7 +24,15 @@ - IBlockData iblockdata = world.getType(blockposition); +@@ -30,7 +30,15 @@ + Fluid fluid = world.b(blockposition); - if (iblockdata.getMaterial() == Material.WATER && ((Integer) iblockdata.get(BlockFluids.LEVEL)).intValue() == 0 && world.isEmpty(blockposition1)) { + if ((fluid.c() == FluidTypes.c || material == Material.ICE) && world.isEmpty(blockposition1)) { + // CraftBukkit start - special case for handling block placement with water lilies -+ org.bukkit.block.BlockState blockstate = org.bukkit.craftbukkit.block.CraftBlockState.getBlockState(world, blockposition1.getX(), blockposition1.getY(), blockposition1.getZ()); - world.setTypeAndData(blockposition1, Blocks.WATERLILY.getBlockData(), 11); ++ org.bukkit.block.BlockState blockstate = org.bukkit.craftbukkit.block.CraftBlockState.getBlockState(world, blockposition1); + world.setTypeAndData(blockposition1, Blocks.LILY_PAD.getBlockData(), 11); + org.bukkit.event.block.BlockPlaceEvent placeEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPlaceEvent(world, entityhuman, enumhand, blockstate, blockposition.getX(), blockposition.getY(), blockposition.getZ()); + if (placeEvent != null && (placeEvent.isCancelled() || !placeEvent.canBuild())) { + blockstate.update(true, false); @@ -14,5 +14,5 @@ + } + // CraftBukkit end if (entityhuman instanceof EntityPlayer) { - CriterionTriggers.x.a((EntityPlayer) entityhuman, blockposition1, itemstack); + CriterionTriggers.y.a((EntityPlayer) entityhuman, blockposition1, itemstack); } diff --git a/paper-server/nms-patches/ItemWorldMap.patch b/paper-server/nms-patches/ItemWorldMap.patch index 8705b2516c..c5dfff5d40 100644 --- a/paper-server/nms-patches/ItemWorldMap.patch +++ b/paper-server/nms-patches/ItemWorldMap.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/server/ItemWorldMap.java +++ b/net/minecraft/server/ItemWorldMap.java -@@ -5,6 +5,11 @@ - import com.google.common.collect.Multisets; +@@ -6,6 +6,11 @@ + import java.util.function.Function; import javax.annotation.Nullable; +// CraftBukkit start @@ -11,57 +11,62 @@ + public class ItemWorldMap extends ItemWorldMapBase { - protected ItemWorldMap() { -@@ -12,41 +17,50 @@ - } + public ItemWorldMap(Item.Info item_info) { +@@ -15,7 +20,7 @@ + public static ItemStack a(World world, int i, int j, byte b0, boolean flag, boolean flag1) { + ItemStack itemstack = new ItemStack(Items.FILLED_MAP); - public static ItemStack a(World world, double d0, double d1, byte b0, boolean flag, boolean flag1) { -- ItemStack itemstack = new ItemStack(Items.FILLED_MAP, 1, world.b("map")); -+ World worldMain = world.getServer().getServer().worlds.get(0); // CraftBukkit - store reference to primary world -+ ItemStack itemstack = new ItemStack(Items.FILLED_MAP, 1, worldMain.b("map")); // CraftBukkit - use primary world for maps - String s = "map_" + itemstack.getData(); - WorldMap worldmap = new WorldMap(s); - -- world.a(s, (PersistentBase) worldmap); -+ worldMain.a(s, (PersistentBase) worldmap); // CraftBukkit - worldmap.scale = b0; - worldmap.a(d0, d1, worldmap.scale); -- worldmap.map = (byte) world.worldProvider.getDimensionManager().getDimensionID(); -+ worldmap.map = (byte) ((WorldServer) world).dimension; // CraftBukkit - use bukkit dimension - worldmap.track = flag; - worldmap.unlimitedTracking = flag1; - worldmap.c(); -+ org.bukkit.craftbukkit.event.CraftEventFactory.callEvent(new org.bukkit.event.server.MapInitializeEvent(worldmap.mapView)); // CraftBukkit +- a(itemstack, world, i, j, b0, flag, flag1, world.worldProvider.getDimensionManager().getDimensionID()); ++ a(itemstack, world, i, j, b0, flag, flag1, ((WorldServer) world).dimension); // CraftBukkit - fixes Bukkit multiworld maps return itemstack; } - @Nullable - public WorldMap getSavedMap(ItemStack itemstack, World world) { -+ World worldMain = world.getServer().getServer().worlds.get(0); // CraftBukkit - store reference to primary world - String s = "map_" + itemstack.getData(); -- WorldMap worldmap = (WorldMap) world.a(WorldMap.class, s); -+ WorldMap worldmap = (WorldMap) worldMain.a(WorldMap.class, s); // CraftBukkit - use primary world for maps +@@ -24,7 +29,7 @@ + WorldMap worldmap = a((GeneratorAccess) world, "map_" + e(itemstack)); if (worldmap == null && !world.isClientSide) { -- itemstack.setData(world.b("map")); -+ itemstack.setData(worldMain.b("map")); // CraftBukkit - use primary world for maps - s = "map_" + itemstack.getData(); - worldmap = new WorldMap(s); - worldmap.scale = 3; - worldmap.a((double) world.getWorldData().b(), (double) world.getWorldData().d(), worldmap.scale); -- worldmap.map = (byte) world.worldProvider.getDimensionManager().getDimensionID(); -+ worldmap.map = (byte) ((WorldServer) world).dimension; // CraftBukkit - fixes Bukkit multiworld maps - worldmap.c(); -- world.a(s, (PersistentBase) worldmap); -+ worldMain.a(s, (PersistentBase) worldmap); // CraftBukkit - use primary world for maps -+ -+ // CraftBukkit start -+ MapInitializeEvent event = new MapInitializeEvent(worldmap.mapView); -+ Bukkit.getServer().getPluginManager().callEvent(event); -+ // CraftBukkit end +- worldmap = a(itemstack, world, world.getWorldData().b(), world.getWorldData().d(), 3, false, false, world.worldProvider.getDimensionManager().getDimensionID()); ++ worldmap = a(itemstack, world, world.getWorldData().b(), world.getWorldData().d(), 3, false, false, ((WorldServer) world).dimension); // CraftBukkit - fixes Bukkit multiworld maps } return worldmap; +@@ -33,26 +38,40 @@ + public static int e(ItemStack itemstack) { + NBTTagCompound nbttagcompound = itemstack.getTag(); + +- return nbttagcompound != null && nbttagcompound.hasKeyOfType("map", 99) ? nbttagcompound.getInt("map") : 0; ++ return nbttagcompound != null && nbttagcompound.hasKeyOfType("map", 99) ? nbttagcompound.getInt("map") : -1; // CraftBukkit - make new maps for no tag + } + + private static WorldMap a(ItemStack itemstack, World world, int i, int j, int k, boolean flag, boolean flag1, int l) { +- int i1 = world.b("map"); ++ World worldMain = world.getServer().getServer().worlds.get(0); // CraftBukkit - store reference to primary world ++ int i1 = worldMain.b("map"); // CraftBukkit - use primary world for maps + WorldMap worldmap = new WorldMap("map_" + i1); + + worldmap.a(i, j, k, flag, flag1, l); +- world.a(worldmap.getId(), (PersistentBase) worldmap); ++ worldMain.a(worldmap.getId(), (PersistentBase) worldmap); // CraftBukkit - use primary world for maps + itemstack.getOrCreateTag().setInt("map", i1); ++ ++ // CraftBukkit start ++ MapInitializeEvent event = new MapInitializeEvent(worldmap.mapView); ++ Bukkit.getServer().getPluginManager().callEvent(event); ++ // CraftBukkit end + return worldmap; + } + + @Nullable + public static WorldMap a(GeneratorAccess generatoraccess, String s) { +- return (WorldMap) generatoraccess.a(WorldMap::new, s); ++ // CraftBukkit start ++ WorldMap worldmap = (WorldMap) MinecraftServer.getServer().worlds.get(0).a(WorldMap::new, s); // CraftBukkit - use primary world for maps ++ if (worldmap != null) { ++ MapInitializeEvent event = new MapInitializeEvent(worldmap.mapView); ++ Bukkit.getServer().getPluginManager().callEvent(event); ++ } ++ return worldmap; ++ // CraftBukkit end } public void a(World world, Entity entity, WorldMap worldmap) { @@ -71,41 +76,13 @@ int i = 1 << worldmap.scale; int j = worldmap.centerX; int k = worldmap.centerZ; -@@ -309,6 +323,7 @@ - protected static void a(ItemStack itemstack, World world, int i) { - WorldMap worldmap = Items.FILLED_MAP.getSavedMap(itemstack, world); +@@ -199,7 +218,8 @@ + WorldMap worldmap = getSavedMap(itemstack, world); -+ world = world.getServer().getServer().worlds.get(0); // CraftBukkit - use primary world for maps - itemstack.setData(world.b("map")); - WorldMap worldmap1 = new WorldMap("map_" + itemstack.getData()); - -@@ -319,6 +334,10 @@ - worldmap1.map = worldmap.map; - worldmap1.c(); - world.a("map_" + itemstack.getData(), (PersistentBase) worldmap1); -+ // CraftBukkit start -+ MapInitializeEvent event = new MapInitializeEvent(worldmap1.mapView); -+ Bukkit.getServer().getPluginManager().callEvent(event); -+ // CraftBukkit end - } - - } -@@ -326,6 +345,7 @@ - protected static void b(ItemStack itemstack, World world) { - WorldMap worldmap = Items.FILLED_MAP.getSavedMap(itemstack, world); - -+ world = world.getServer().getServer().worlds.get(0); // CraftBukkit - use primary world for maps - itemstack.setData(world.b("map")); - WorldMap worldmap1 = new WorldMap("map_" + itemstack.getData()); - -@@ -337,6 +357,10 @@ - worldmap1.map = worldmap.map; - worldmap1.c(); - world.a("map_" + itemstack.getData(), (PersistentBase) worldmap1); -+ // CraftBukkit start -+ MapInitializeEvent event = new MapInitializeEvent(worldmap1.mapView); -+ Bukkit.getServer().getPluginManager().callEvent(event); -+ // CraftBukkit end - } - - } + if (worldmap != null) { +- if (world.worldProvider.getDimensionManager().getDimensionID() == worldmap.map) { ++ // CraftBukkit - world.worldProvider -> ((WorldServer) world) ++ if (((WorldServer) world).dimension == worldmap.map) { + int i = 1 << worldmap.scale; + int j = worldmap.centerX; + int k = worldmap.centerZ; diff --git a/paper-server/nms-patches/ItemWrittenBook.patch b/paper-server/nms-patches/ItemWrittenBook.patch index 3a4e476115..e43dd9090a 100644 --- a/paper-server/nms-patches/ItemWrittenBook.patch +++ b/paper-server/nms-patches/ItemWrittenBook.patch @@ -1,34 +1,34 @@ --- a/net/minecraft/server/ItemWrittenBook.java +++ b/net/minecraft/server/ItemWrittenBook.java -@@ -61,6 +61,23 @@ +@@ -62,6 +62,23 @@ - Object object; + Object object; -+ // CraftBukkit start -+ // Some commands use the worldserver variable but we leave it full of null values, -+ // so we must temporarily populate it with the world of the commandsender -+ WorldServer[] prev = MinecraftServer.getServer().worldServer; -+ MinecraftServer server = MinecraftServer.getServer(); -+ server.worldServer = new WorldServer[server.worlds.size()]; -+ server.worldServer[0] = (WorldServer) entityhuman.getWorld(); -+ int bpos = 0; -+ for (int pos = 1; pos < server.worldServer.length; pos++) { -+ WorldServer world = server.worlds.get(bpos++); -+ if (server.worldServer[0] == world) { -+ pos--; -+ continue; -+ } -+ server.worldServer[pos] = world; ++ // CraftBukkit start ++ // Some commands use the worldserver variable but we leave it full of null values, ++ // so we must temporarily populate it with the world of the commandsender ++ WorldServer[] prev = MinecraftServer.getServer().worldServer; ++ MinecraftServer server = MinecraftServer.getServer(); ++ server.worldServer = new WorldServer[server.worlds.size()]; ++ server.worldServer[0] = (WorldServer) entityhuman.getWorld(); ++ int bpos = 0; ++ for (int pos = 1; pos < server.worldServer.length; pos++) { ++ WorldServer world = server.worlds.get(bpos++); ++ if (server.worldServer[0] == world) { ++ pos--; ++ continue; + } -+ // CraftBukkit end - try { - IChatBaseComponent ichatbasecomponent = IChatBaseComponent.ChatSerializer.b(s); ++ server.worldServer[pos] = world; ++ } ++ // CraftBukkit end + try { + IChatBaseComponent ichatbasecomponent = IChatBaseComponent.ChatSerializer.b(s); -@@ -68,6 +85,7 @@ - } catch (Exception exception) { - object = new ChatComponentText(s); - } -+ finally { MinecraftServer.getServer().worldServer = prev; } // CraftBukkit - - nbttaglist.a(i, new NBTTagString(IChatBaseComponent.ChatSerializer.a((IChatBaseComponent) object))); +@@ -69,6 +86,7 @@ + } catch (Exception exception) { + object = new ChatComponentText(s); } ++ finally { MinecraftServer.getServer().worldServer = prev; } // CraftBukkit + + nbttaglist.set(i, (NBTBase) (new NBTTagString(IChatBaseComponent.ChatSerializer.a((IChatBaseComponent) object)))); + } diff --git a/paper-server/nms-patches/JsonList.patch b/paper-server/nms-patches/JsonList.patch index 9cdf691bfc..0db0f19870 100644 --- a/paper-server/nms-patches/JsonList.patch +++ b/paper-server/nms-patches/JsonList.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/server/JsonList.java +++ b/net/minecraft/server/JsonList.java -@@ -84,7 +84,7 @@ - +@@ -86,7 +86,7 @@ + @Nullable public V get(K k0) { this.h(); - return (JsonListEntry) this.d.get(this.a(k0)); @@ -9,7 +9,7 @@ } public void remove(K k0) { -@@ -102,6 +102,12 @@ +@@ -108,6 +108,12 @@ return (String[]) this.d.keySet().toArray(new String[this.d.size()]); } @@ -22,16 +22,25 @@ public boolean isEmpty() { return this.d.size() < 1; } -@@ -178,7 +184,7 @@ - JsonListEntry jsonlistentry = (JsonListEntry) iterator.next(); +@@ -137,7 +143,7 @@ + while (iterator.hasNext()) { + Object object = iterator.next(); - if (jsonlistentry.getKey() != null) { -- this.d.put(this.a(jsonlistentry.getKey()), jsonlistentry); -+ this.d.put(this.a((K) jsonlistentry.getKey()), (V) jsonlistentry); // CraftBukkit - fix decompile error +- this.d.remove(this.a(object)); ++ this.d.remove(this.a((K) object)); // CraftBukkit - decompile error + } + + } +@@ -180,7 +186,7 @@ + JsonListEntry jsonlistentry = (JsonListEntry) iterator.next(); + + if (jsonlistentry.getKey() != null) { +- this.d.put(this.a(jsonlistentry.getKey()), jsonlistentry); ++ this.d.put(this.a((K) jsonlistentry.getKey()), (V) jsonlistentry); // CraftBukkit - fix decompile error + } } } - } -@@ -207,11 +213,11 @@ +@@ -212,11 +218,11 @@ } } diff --git a/paper-server/nms-patches/LoginListener.patch b/paper-server/nms-patches/LoginListener.patch index 789331f05a..f1671027ec 100644 --- a/paper-server/nms-patches/LoginListener.patch +++ b/paper-server/nms-patches/LoginListener.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/LoginListener.java +++ b/net/minecraft/server/LoginListener.java -@@ -22,6 +22,12 @@ +@@ -19,6 +19,12 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -13,7 +13,7 @@ public class LoginListener implements PacketLoginInListener, ITickable { private static final AtomicInteger b = new AtomicInteger(0); -@@ -36,6 +42,7 @@ +@@ -33,6 +39,7 @@ private final String j; private SecretKey loginKey; private EntityPlayer l; @@ -21,7 +21,7 @@ public LoginListener(MinecraftServer minecraftserver, NetworkManager networkmanager) { this.g = LoginListener.EnumProtocolState.HELLO; -@@ -64,6 +71,20 @@ +@@ -61,6 +68,20 @@ } @@ -41,33 +41,24 @@ + public void disconnect(IChatBaseComponent ichatbasecomponent) { try { - LoginListener.c.info("Disconnecting {}: {}", this.c(), ichatbasecomponent.toPlainText()); -@@ -80,10 +101,12 @@ + LoginListener.c.info("Disconnecting {}: {}", this.c(), ichatbasecomponent.getString()); +@@ -77,10 +98,12 @@ this.i = this.a(this.i); } -- String s = this.server.getPlayerList().attemptLogin(this.networkManager.getSocketAddress(), this.i); +- IChatBaseComponent ichatbasecomponent = this.server.getPlayerList().attemptLogin(this.networkManager.getSocketAddress(), this.i); + // CraftBukkit start - fire PlayerLoginEvent + EntityPlayer s = this.server.getPlayerList().attemptLogin(this, this.i, hostname); -- if (s != null) { -- this.disconnect(new ChatMessage(s, new Object[0])); +- if (ichatbasecomponent != null) { +- this.disconnect(ichatbasecomponent); + if (s == null) { -+ // this.disconnect(new ChatMessage(s, new Object[0])); ++ // this.disconnect(ichatbasecomponent); + // CraftBukkit end } else { this.g = LoginListener.EnumProtocolState.ACCEPTED; - if (this.server.aG() >= 0 && !this.networkManager.isLocal()) { -@@ -92,7 +115,7 @@ - LoginListener.this.networkManager.setCompressionLevel(LoginListener.this.server.aG()); - } - -- public void operationComplete(Future future) throws Exception { -+ public void operationComplete(ChannelFuture future) throws Exception { // CraftBukkit - fix decompile error - this.a((ChannelFuture) future); - } - }, new GenericFutureListener[0]); -@@ -103,9 +126,9 @@ + if (this.server.ay() >= 0 && !this.networkManager.isLocal()) { +@@ -94,9 +117,9 @@ if (entityplayer != null) { this.g = LoginListener.EnumProtocolState.DELAY_ACCEPT; @@ -79,9 +70,9 @@ } } -@@ -150,6 +173,43 @@ +@@ -141,6 +164,43 @@ - LoginListener.this.i = LoginListener.this.server.az().hasJoinedServer(new GameProfile((UUID) null, gameprofile.getName()), s, this.a()); + LoginListener.this.i = LoginListener.this.server.ar().hasJoinedServer(new GameProfile((UUID) null, gameprofile.getName()), s, this.a()); if (LoginListener.this.i != null) { + // CraftBukkit start - fire PlayerPreLoginEvent + if (!networkManager.isConnected()) { @@ -122,8 +113,8 @@ + // CraftBukkit end LoginListener.c.info("UUID of player {} is {}", LoginListener.this.i.getName(), LoginListener.this.i.getId()); LoginListener.this.g = LoginListener.EnumProtocolState.READY_TO_ACCEPT; - } else if (LoginListener.this.server.R()) { -@@ -169,6 +229,11 @@ + } else if (LoginListener.this.server.J()) { +@@ -160,6 +220,11 @@ LoginListener.this.disconnect(new ChatMessage("multiplayer.disconnect.authservers_down", new Object[0])); LoginListener.c.error("Couldn\'t verify username because servers are unavailable"); } diff --git a/paper-server/nms-patches/MethodProfiler.patch b/paper-server/nms-patches/MethodProfiler.patch index b608e64a86..97e1ed3f73 100644 --- a/paper-server/nms-patches/MethodProfiler.patch +++ b/paper-server/nms-patches/MethodProfiler.patch @@ -5,63 +5,63 @@ public class MethodProfiler { + public static final boolean ENABLED = Boolean.getBoolean("enableDebugMethodProfiler"); // CraftBukkit - disable unless specified in JVM arguments - private static final Logger b = LogManager.getLogger(); - private final List c = Lists.newArrayList(); - private final List d = Lists.newArrayList(); -@@ -23,12 +24,14 @@ - public MethodProfiler() {} + private static final Logger a = LogManager.getLogger(); + private final List b = Lists.newArrayList(); + private final List c = Lists.newArrayList(); +@@ -41,6 +42,7 @@ + } - public void a() { -+ if (!ENABLED) return; // CraftBukkit - this.f.clear(); - this.e = ""; - this.c.clear(); + public void a(int i) { ++ if (!ENABLED) return; // CraftBukkit + if (!this.d) { + this.d = true; + this.f.clear(); +@@ -52,6 +54,7 @@ } public void a(String s) { -+ if (!ENABLED) return; // CraftBukkit - if (this.a) { ++ if (!ENABLED) return; // CraftBukkit + if (this.d) { if (!this.e.isEmpty()) { this.e = this.e + "."; -@@ -41,12 +44,14 @@ +@@ -64,12 +67,14 @@ } public void a(Supplier supplier) { -+ if (!ENABLED) return; // CraftBukkit - if (this.a) { ++ if (!ENABLED) return; // CraftBukkit + if (this.d) { this.a((String) supplier.get()); } } - public void b() { -+ if (!ENABLED) return; // CraftBukkit - if (this.a) { - long i = System.nanoTime(); - long j = ((Long) this.d.remove(this.d.size() - 1)).longValue(); -@@ -69,7 +74,7 @@ + public void e() { ++ if (!ENABLED) return; // CraftBukkit + if (this.d && !this.c.isEmpty()) { + long i = SystemUtils.c(); + long j = ((Long) this.c.remove(this.c.size() - 1)).longValue(); +@@ -92,6 +97,7 @@ } public List b(String s) { -- if (!this.a) { -+ if (!ENABLED || !this.a) { // CraftBukkit - return Collections.emptyList(); - } else { - long i = this.f.containsKey("root") ? ((Long) this.f.get("root")).longValue() : 0L; -@@ -135,11 +140,13 @@ ++ if (!ENABLED) return Collections.emptyList(); // CraftBukkit + long i = this.f.containsKey("root") ? ((Long) this.f.get("root")).longValue() : 0L; + long j = this.f.containsKey(s) ? ((Long) this.f.get(s)).longValue() : -1L; + ArrayList arraylist = Lists.newArrayList(); +@@ -154,11 +160,13 @@ } public void c(String s) { -+ if (!ENABLED) return; // CraftBukkit - this.b(); ++ if (!ENABLED) return; // CraftBukkit + this.e(); this.a(s); } - public String c() { -+ if (!ENABLED) return "[DISABLED]"; // CraftBukkit - return this.c.isEmpty() ? "[UNKNOWN]" : (String) this.c.get(this.c.size() - 1); + public String f() { ++ if (!ENABLED) return "[DISABLED]"; // CraftBukkit + return this.b.isEmpty() ? "[UNKNOWN]" : (String) this.b.get(this.b.size() - 1); } -@@ -159,7 +166,7 @@ +@@ -178,7 +186,7 @@ return methodprofiler_profilerinfo.a < this.a ? -1 : (methodprofiler_profilerinfo.a > this.a ? 1 : methodprofiler_profilerinfo.c.compareTo(this.c)); } diff --git a/paper-server/nms-patches/MinecraftServer.patch b/paper-server/nms-patches/MinecraftServer.patch index 1493d7e502..5d140dd509 100644 --- a/paper-server/nms-patches/MinecraftServer.patch +++ b/paper-server/nms-patches/MinecraftServer.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -41,6 +41,13 @@ +@@ -55,6 +55,13 @@ import org.apache.commons.lang3.Validate; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -12,13 +12,13 @@ +import org.bukkit.craftbukkit.Main; +// CraftBukkit end - public abstract class MinecraftServer implements ICommandListener, Runnable, IAsyncTaskHandler, IMojangStatistics { + public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStatistics, ICommandListener, Runnable { -@@ -98,19 +105,61 @@ - private Thread serverThread; - private long ab = aw(); +@@ -124,7 +131,22 @@ + private boolean an; + private float ao; -- public MinecraftServer(File file, Proxy proxy, DataConverterManager dataconvertermanager, YggdrasilAuthenticationService yggdrasilauthenticationservice, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache) { +- public MinecraftServer(@Nullable File file, Proxy proxy, DataFixer datafixer, CommandDispatcher commanddispatcher, YggdrasilAuthenticationService yggdrasilauthenticationservice, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache) { + // CraftBukkit start + public List worlds = new ArrayList(); + public org.bukkit.craftbukkit.CraftServer server; @@ -30,21 +30,36 @@ + public final Thread primaryThread; + public java.util.Queue processQueue = new java.util.concurrent.ConcurrentLinkedQueue(); + public int autosavePeriod; ++ public File bukkitDataPackFolder; + // CraftBukkit end + -+ public MinecraftServer(OptionSet options, Proxy proxy, DataConverterManager dataconvertermanager, YggdrasilAuthenticationService yggdrasilauthenticationservice, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache) { - this.e = proxy; - this.V = yggdrasilauthenticationservice; - this.W = minecraftsessionservice; - this.X = gameprofilerepository; - this.Y = usercache; ++ public MinecraftServer(OptionSet options, Proxy proxy, DataFixer datafixer, CommandDispatcher commanddispatcher, YggdrasilAuthenticationService yggdrasilauthenticationservice, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache) { ++ this.commandDispatcher = commanddispatcher; // CraftBukkit + this.ac = new ResourceManager(EnumResourcePackType.SERVER_DATA); + this.resourcePackRepository = new ResourcePackRepository(ResourcePackLoader::new); + this.ag = new CraftingManager(); +@@ -135,22 +157,51 @@ + this.al = new AdvancementDataWorld(); + this.am = new CustomFunctionData(this); + this.d = proxy; +- this.commandDispatcher = commanddispatcher; ++ // this.commandDispatcher = commanddispatcher; // CraftBukkit - moved up + this.U = yggdrasilauthenticationservice; + this.V = minecraftsessionservice; + this.W = gameprofilerepository; + this.X = usercache; - this.universe = file; +- this.m = file == null ? null : new ServerConnection(this); +- this.convertable = file == null ? null : new WorldLoaderServer(file.toPath(), file.toPath().resolve("../backups"), datafixer); + // this.universe = file; // CraftBukkit - this.p = new ServerConnection(this); - this.b = this.i(); -- this.convertable = new WorldLoaderServer(file, dataconvertermanager); -+ // this.convertable = new WorldLoaderServer(file); // CraftBukkit - moved to DedicatedServer.init - this.dataConverterManager = dataconvertermanager; ++ this.m = new ServerConnection(this); // CraftBukkit ++ // this.convertable = file == null ? null : new WorldLoaderServer(file.toPath(), file.toPath().resolve("../backups"), datafixer); // CraftBukkit - moved to DedicatedServer.init + this.dataConverterManager = datafixer; + this.ac.a((IResourcePackListener) this.ah); + this.ac.a((IResourcePackListener) this.ag); + this.ac.a((IResourcePackListener) this.ak); + this.ac.a((IResourcePackListener) this.am); + this.ac.a((IResourcePackListener) this.al); + // CraftBukkit start + this.options = options; + // Try to see if we're actually running in a terminal, disable jline if not @@ -76,21 +91,21 @@ + public abstract PropertyManager getPropertyManager(); + // CraftBukkit end + - protected CommandDispatcher i() { - return new CommandDispatcher(this); - } -@@ -148,6 +197,7 @@ + public abstract boolean init() throws IOException; + + protected void a(String s) { +@@ -184,6 +235,7 @@ this.a(s); - this.b("menu.loadingLevel"); + this.b((IChatBaseComponent) (new ChatMessage("menu.loadingLevel", new Object[0]))); this.worldServer = new WorldServer[3]; + /* CraftBukkit start - Remove ticktime arrays and worldsettings - this.i = new long[this.worldServer.length][100]; - IDataManager idatamanager = this.convertable.a(s, true); + this.f = new long[this.worldServer.length][100]; + IDataManager idatamanager = this.convertable.a(s, this); -@@ -171,36 +221,108 @@ - worlddata.a(s1); - worldsettings = new WorldSettings(worlddata); +@@ -209,40 +261,115 @@ } + + this.a(idatamanager.getDirectory(), worlddata); + */ + int worldCount = 3; @@ -98,6 +113,7 @@ - byte b0 = 0; + for (int j = 0; j < worldCount; ++j) { + WorldServer world; ++ WorldData worlddata; + byte dimension = 0; if (j == 1) { @@ -123,16 +139,16 @@ + + org.bukkit.generator.ChunkGenerator gen = this.server.getGenerator(name); + WorldSettings worldsettings = new WorldSettings(i, this.getGamemode(), this.getGenerateStructures(), this.isHardcore(), worldtype); -+ worldsettings.setGeneratorSettings(s2); ++ worldsettings.setGeneratorSettings(jsonelement); + if (j == 0) { -+ IDataManager idatamanager = new ServerNBTManager(server.getWorldContainer(), s1, true, this.dataConverterManager); -+ WorldData worlddata = idatamanager.getWorldData(); ++ IDataManager idatamanager = new ServerNBTManager(server.getWorldContainer(), s1, this, this.dataConverterManager); ++ worlddata = idatamanager.getWorldData(); + if (worlddata == null) { + worlddata = new WorldData(worldsettings, s1); + } + worlddata.checkName(s1); // CraftBukkit - Migration did not rewrite the level.dat; This forces 1.8 to take the last loaded world as respawn (in this case the end) - if (this.V()) { + if (this.N()) { - this.worldServer[j] = (WorldServer) (new DemoWorldServer(this, idatamanager, worlddata, b0, this.methodProfiler)).b(); + world = (WorldServer) (new DemoWorldServer(this, idatamanager, worlddata, dimension, this.methodProfiler)).b(); } else { @@ -142,6 +158,7 @@ - this.worldServer[j].a(worldsettings); + world.a(worldsettings); ++ this.a(idatamanager.getDirectory(), worlddata); + this.server.scoreboardManager = new org.bukkit.craftbukkit.scoreboard.CraftScoreboardManager(this, world.getScoreboard()); } else { - this.worldServer[j] = (WorldServer) (new SecondaryWorldServer(this, idatamanager, b0, this.worldServer[0], this.methodProfiler)).b(); @@ -180,9 +197,9 @@ + } + } + -+ IDataManager idatamanager = new ServerNBTManager(server.getWorldContainer(), name, true, this.dataConverterManager); ++ IDataManager idatamanager = new ServerNBTManager(server.getWorldContainer(), name, this, this.dataConverterManager); + // world =, b0 to dimension, s1 to name, added Environment and gen -+ WorldData worlddata = idatamanager.getWorldData(); ++ worlddata = idatamanager.getWorldData(); + if (worlddata == null) { + worlddata = new WorldData(worldsettings, name); + } @@ -194,77 +211,136 @@ + this.server.getPluginManager().callEvent(new org.bukkit.event.world.WorldInitEvent(world.getWorld())); + + world.addIWorldAccess(new WorldManager(this, world)); - if (!this.R()) { + if (!this.J()) { - this.worldServer[j].getWorldData().setGameType(this.getGamemode()); + world.getWorldData().setGameType(this.getGamemode()); } - } +- this.s.setPlayerFileData(this.worldServer); +- if (worlddata.P() != null) { +- this.aR().a(worlddata.P()); + worlds.add(world); + getPlayerList().setPlayerFileData(worlds.toArray(new WorldServer[worlds.size()])); ++ ++ if (worlddata.P() != null) { ++ this.aR().a(worlddata.P()); ++ } + } ++ this.s.setPlayerFileData(this.worldServer); ++ // CraftBukkit end + + this.a(this.getDifficulty()); + this.g_(); +@@ -251,6 +378,25 @@ + protected void a(File file, WorldData worlddata) { + this.resourcePackRepository.a((ResourcePackSource) (new ResourcePackSourceVanilla())); + this.resourcePackFolder = new ResourcePackSourceFolder(new File(file, "datapacks")); ++ // CraftBukkit start ++ bukkitDataPackFolder = new File(new File(file, "datapacks"), "bukkit"); ++ if (!bukkitDataPackFolder.exists()) { ++ bukkitDataPackFolder.mkdirs(); ++ } ++ File mcMeta = new File(bukkitDataPackFolder, "pack.mcmeta"); ++ if (!mcMeta.exists()) { ++ try { ++ com.google.common.io.Files.write("{\n" ++ + " \"pack\": {\n" ++ + " \"description\": \"Data pack for resources provided by Bukkit plugins\",\n" ++ + " \"pack_format\": 1\n" ++ + " }\n" ++ + "}", mcMeta, com.google.common.base.Charsets.UTF_8); ++ } catch (IOException ex) { ++ throw new RuntimeException("Could not initialize Bukkit datapack", ex); ++ } + } + // CraftBukkit end - this.v.setPlayerFileData(this.worldServer); - this.a(this.getDifficulty()); - this.l(); -@@ -216,25 +338,38 @@ - this.b("menu.generatingTerrain"); - boolean flag4 = false; + this.resourcePackRepository.a((ResourcePackSource) this.resourcePackFolder); + this.resourcePackRepository.a(); + ArrayList arraylist = Lists.newArrayList(); +@@ -281,41 +427,52 @@ + this.b((IChatBaseComponent) (new ChatMessage("menu.generatingTerrain", new Object[0]))); + boolean flag5 = false; - MinecraftServer.LOGGER.info("Preparing start region for level 0"); - WorldServer worldserver = this.worldServer[0]; - BlockPosition blockposition = worldserver.getSpawn(); -- long j = aw(); -- -- for (int k = -192; k <= 192 && this.isRunning(); k += 16) { -- for (int l = -192; l <= 192 && this.isRunning(); l += 16) { -- long i1 = aw(); -- -- if (i1 - j > 1000L) { -- this.a_("Preparing spawn area", i * 100 / 625); -- j = i1; -- } +- ArrayList arraylist = Lists.newArrayList(); +- Set set = Sets.newConcurrentHashSet(); + // CraftBukkit start - fire WorldLoadEvent and handle whether or not to keep the spawn in memory + Stopwatch stopwatch = Stopwatch.createStarted(); +- +- for (int i = -192; i <= 192 && this.isRunning(); i += 16) { +- for (int j = -192; j <= 192 && this.isRunning(); j += 16) { +- arraylist.add(new ChunkCoordIntPair(blockposition.getX() + i >> 4, blockposition.getZ() + j >> 4)); + for (int m = 0; m < worlds.size(); m++) { + WorldServer worldserver = this.worlds.get(m); + MinecraftServer.LOGGER.info("Preparing start region for level " + m + " (Seed: " + worldserver.getSeed() + ")"); -+ + if (!worldserver.getWorld().getKeepSpawnInMemory()) { + continue; -+ } -+ -+ BlockPosition blockposition = worldserver.getSpawn(); -+ long j = aw(); -+ i = 0; -+ -+ for (int k = -192; k <= 192 && this.isRunning(); k += 16) { -+ for (int l = -192; l <= 192 && this.isRunning(); l += 16) { -+ long i1 = aw(); -+ -+ if (i1 - j > 1000L) { -+ this.a_("Preparing spawn area", i * 100 / 625); -+ j = i1; -+ } - -- ++i; -- worldserver.getChunkProviderServer().getChunkAt(blockposition.getX() + k >> 4, blockposition.getZ() + l >> 4); -+ ++i; -+ worldserver.getChunkProviderServer().getChunkAt(blockposition.getX() + k >> 4, blockposition.getZ() + l >> 4); -+ } } + +- CompletableFuture completablefuture = worldserver.getChunkProviderServer().a((Iterable) arraylist, (chunk) -> { +- set.add(chunk.getPos()); +- }); ++ BlockPosition blockposition = worldserver.getSpawn(); ++ ArrayList arraylist = Lists.newArrayList(); ++ Set set = Sets.newConcurrentHashSet(); ++ ++ for (int i = -192; i <= 192 && this.isRunning(); i += 16) { ++ for (int j = -192; j <= 192 && this.isRunning(); j += 16) { ++ arraylist.add(new ChunkCoordIntPair(blockposition.getX() + i >> 4, blockposition.getZ() + j >> 4)); ++ } + +- while (!completablefuture.isDone()) { +- try { +- completablefuture.get(1L, TimeUnit.SECONDS); +- } catch (InterruptedException interruptedexception) { +- throw new RuntimeException(interruptedexception); +- } catch (ExecutionException executionexception) { +- if (executionexception.getCause() instanceof RuntimeException) { +- throw (RuntimeException) executionexception.getCause(); +- } ++ CompletableFuture completablefuture = worldserver.getChunkProviderServer().a((Iterable) arraylist, (chunk) -> { ++ set.add(chunk.getPos()); ++ }); + +- throw new RuntimeException(executionexception.getCause()); +- } catch (TimeoutException timeoutexception) { +- this.a(new ChatMessage("menu.preparingSpawn", new Object[0]), set.size() * 100 / 625); ++ while (!completablefuture.isDone()) { ++ try { ++ completablefuture.get(1L, TimeUnit.SECONDS); ++ } catch (InterruptedException interruptedexception) { ++ throw new RuntimeException(interruptedexception); ++ } catch (ExecutionException executionexception) { ++ if (executionexception.getCause() instanceof RuntimeException) { ++ throw (RuntimeException) executionexception.getCause(); ++ } ++ ++ 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.worlds) { + this.server.getPluginManager().callEvent(new org.bukkit.event.world.WorldLoadEvent(world.getWorld())); + } + // CraftBukkit end - this.t(); + this.m(); + MinecraftServer.LOGGER.info("Time elapsed: {} ms", Long.valueOf(stopwatch.elapsed(TimeUnit.MILLISECONDS))); } - -@@ -274,14 +409,17 @@ - protected void t() { - this.f = null; - this.g = 0; +@@ -354,14 +511,17 @@ + protected void m() { + this.w = null; + this.x = 0; + this.server.enablePlugins(org.bukkit.plugin.PluginLoadOrder.POSTWORLD); // CraftBukkit } @@ -281,15 +357,7 @@ if (worldserver != null) { if (!flag) { -@@ -290,6 +428,7 @@ - - try { - worldserver.save(true, (IProgressUpdate) null); -+ worldserver.saveLevel(); // CraftBukkit - } catch (ExceptionWorldConflict exceptionworldconflict) { - MinecraftServer.LOGGER.warn(exceptionworldconflict.getMessage()); - } -@@ -298,8 +437,24 @@ +@@ -378,8 +538,24 @@ } @@ -312,55 +380,58 @@ + this.server.disablePlugins(); + } + // CraftBukkit end - if (this.an() != null) { - this.an().b(); + if (this.getServerConnection() != null) { + this.getServerConnection().b(); } -@@ -308,6 +463,7 @@ +@@ -388,6 +564,7 @@ MinecraftServer.LOGGER.info("Saving players"); - this.v.savePlayers(); - this.v.u(); + this.s.savePlayers(); + this.s.u(); + try { Thread.sleep(100); } catch (InterruptedException ex) {} // CraftBukkit - SPIGOT-625 - give server at least a chance to send packets } if (this.worldServer != null) { -@@ -329,12 +485,14 @@ +@@ -398,8 +575,10 @@ + int j; + WorldServer worldserver; + +- for (j = 0; j < i; ++j) { +- worldserver = aworldserver[j]; ++ // CraftBukkit start ++ for (j = 0; j < worlds.size(); ++j) { ++ worldserver = worlds.get(j); ++ // CraftBukkit end + if (worldserver != null) { + worldserver.savingDisabled = false; + } +@@ -409,8 +588,10 @@ aworldserver = this.worldServer; i = aworldserver.length; -+ /* CraftBukkit start - Handled in saveChunks - for (j = 0; j < i; ++j) { - worldserver = aworldserver[j]; +- for (j = 0; j < i; ++j) { +- worldserver = aworldserver[j]; ++ // CraftBukkit start ++ for (j = 0; j < worlds.size(); ++j) { ++ worldserver = worlds.get(j); ++ // CraftBukkit end if (worldserver != null) { - worldserver.saveLevel(); + worldserver.close(); } - } -+ // CraftBukkit end */ - } +@@ -453,11 +634,13 @@ + if (i > 2000L && this.aa - this.Q >= 15000L) { + long j = i / 50L; - if (this.m.d()) { -@@ -374,6 +532,7 @@ - long k = j - this.ab; - - if (k > 2000L && this.ab - this.R >= 15000L) { + if (server.getWarnOnOverload()) // CraftBukkit - MinecraftServer.LOGGER.warn("Can\'t keep up! Did the system time change, or is the server overloaded? Running {}ms behind, skipping {} tick(s)", Long.valueOf(k), Long.valueOf(k / 50L)); - k = 2000L; - this.R = this.ab; -@@ -386,11 +545,12 @@ + MinecraftServer.LOGGER.warn("Can\'t keep up! Is the server overloaded? Running {}ms or {} ticks behind", Long.valueOf(i), Long.valueOf(j)); + this.aa += j * 50L; + this.Q = this.aa; + } - i += k; - this.ab = j; -- if (this.worldServer[0].everyoneDeeplySleeping()) { -+ if (this.worlds.get(0).everyoneDeeplySleeping()) { // CraftBukkit - this.C(); - i = 0L; - } else { - while (i > 50L) { -+ MinecraftServer.currentTick = (int) (System.currentTimeMillis() / 50); // CraftBukkit - i -= 50L; - this.C(); - } -@@ -428,6 +588,12 @@ ++ MinecraftServer.currentTick = (int) (System.currentTimeMillis() / 50); // CraftBukkit + this.v(); + this.aa += 50L; + +@@ -496,6 +679,12 @@ } catch (Throwable throwable1) { MinecraftServer.LOGGER.error("Exception stopping the server", throwable1); } finally { @@ -370,37 +441,28 @@ + } catch (Exception ignored) { + } + // CraftBukkit end - this.B(); + this.u(); } -@@ -471,7 +637,7 @@ - - public void B() {} - -- protected void C() { -+ protected void C() throws ExceptionWorldConflict { // CraftBukkit - added throws - long i = System.nanoTime(); - - ++this.ticks; -@@ -497,7 +663,7 @@ - this.q.b().a(agameprofile); +@@ -564,7 +753,7 @@ + this.n.b().a(agameprofile); } - if (this.ticks % 900 == 0) { + if (autosavePeriod > 0 && this.ticks % autosavePeriod == 0) { // CraftBukkit this.methodProfiler.a("save"); - this.v.savePlayers(); + this.s.savePlayers(); this.saveChunks(true); -@@ -521,6 +687,7 @@ +@@ -590,6 +779,7 @@ } - public void D() { + public void w() { + this.server.getScheduler().mainThreadHeartbeat(this.ticks); // CraftBukkit this.methodProfiler.a("jobs"); - Queue queue = this.j; - -@@ -532,22 +699,40 @@ + FutureTask futuretask; +@@ -602,22 +792,40 @@ + this.aD().X_(); this.methodProfiler.c("levels"); + // CraftBukkit start @@ -423,11 +485,11 @@ - for (i = 0; i < this.worldServer.length; ++i) { + for (i = 0; i < this.worlds.size(); ++i) { // CraftBukkit - long j = System.nanoTime(); + long j = SystemUtils.c(); - if (i == 0 || this.getAllowNether()) { - WorldServer worldserver = this.worldServer[i]; -+ // if (i == 0 || this.getAllowNether()) { ++ if (true || i == 0 || this.getAllowNether()) { // CraftBukkit + WorldServer worldserver = this.worlds.get(i); this.methodProfiler.a(() -> { @@ -436,27 +498,24 @@ + /* Drop global time updates if (this.ticks % 20 == 0) { this.methodProfiler.a("timeSync"); - this.v.a((Packet) (new PacketPlayOutUpdateTime(worldserver.getTime(), worldserver.getDayTime(), worldserver.getGameRules().getBoolean("doDaylightCycle"))), worldserver.worldProvider.getDimensionManager().getDimensionID()); - this.methodProfiler.b(); + this.s.a((Packet) (new PacketPlayOutUpdateTime(worldserver.getTime(), worldserver.getDayTime(), worldserver.getGameRules().getBoolean("doDaylightCycle"))), worldserver.worldProvider.getDimensionManager().getDimensionID()); + this.methodProfiler.e(); } + // CraftBukkit end */ this.methodProfiler.a("tick"); -@@ -574,9 +759,9 @@ - worldserver.getTracker().updatePlayers(); - this.methodProfiler.b(); - this.methodProfiler.b(); -- } -+ // } // CraftBukkit +@@ -646,7 +854,7 @@ + this.methodProfiler.e(); + } -- this.i[i][this.ticks % 100] = System.nanoTime() - j; -+ // this.i[i][this.ticks % 100] = System.nanoTime() - j; // CraftBukkit +- this.f[i][this.ticks % 100] = SystemUtils.c() - j; ++ // this.f[i][this.ticks % 100] = SystemUtils.c() - j; // CraftBukkit } this.methodProfiler.c("connection"); -@@ -602,10 +787,11 @@ - this.o.add(itickable); +@@ -670,10 +878,11 @@ + this.l.add(itickable); } - public static void main(String[] astring) { @@ -468,7 +527,7 @@ boolean flag = true; String s = null; String s1 = "."; -@@ -650,13 +836,16 @@ +@@ -718,13 +927,16 @@ ++j; } } @@ -484,12 +543,12 @@ + /* CraftBukkit start if (s != null) { - dedicatedserver.i(s); + dedicatedserver.h(s); } -@@ -687,6 +876,25 @@ - dedicatedserver.stop(); - } - }); +@@ -758,6 +970,25 @@ + + thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(MinecraftServer.LOGGER)); + Runtime.getRuntime().addShutdownHook(thread); + */ + + if (options.has("port")) { @@ -512,18 +571,21 @@ } catch (Exception exception) { MinecraftServer.LOGGER.fatal("Failed to start the minecraft server", exception); } -@@ -694,8 +902,10 @@ +@@ -765,11 +996,13 @@ } - public void F() { + public void y() { + /* CraftBukkit start - prevent abuse this.serverThread = new Thread(this, "Server thread"); + this.serverThread.setUncaughtExceptionHandler((thread, throwable) -> { + MinecraftServer.LOGGER.error(throwable); + }); this.serverThread.start(); + // CraftBukkit end */ } - public File d(String s) { -@@ -711,7 +921,14 @@ + public File c(String s) { +@@ -785,11 +1018,18 @@ } public WorldServer getWorldServer(int i) { @@ -538,8 +600,13 @@ + // CraftBukkit end } + public WorldServer a(DimensionManager dimensionmanager) { +- return dimensionmanager == DimensionManager.NETHER ? this.worldServer[1] : (dimensionmanager == DimensionManager.THE_END ? this.worldServer[2] : this.worldServer[0]); ++ return dimensionmanager == DimensionManager.NETHER ? this.worlds.get(1) : (dimensionmanager == DimensionManager.THE_END ? this.worlds.get(2) : this.worlds.get(0)); // CraftBukkit + } + public String getVersion() { -@@ -735,7 +952,7 @@ +@@ -809,7 +1049,7 @@ } public boolean isDebugging() { @@ -547,8 +614,8 @@ + return this.getPropertyManager().getBoolean("debug", false); // CraftBukkit - don't hardcode } - public void g(String s) { -@@ -750,7 +967,7 @@ + public void f(String s) { +@@ -824,7 +1064,7 @@ } public String getServerModName() { @@ -557,30 +624,16 @@ } public CrashReport b(CrashReport crashreport) { -@@ -779,6 +996,7 @@ +@@ -860,7 +1100,7 @@ } - public List tabCompleteCommand(ICommandListener icommandlistener, String s, @Nullable BlockPosition blockposition, boolean flag) { -+ /* CraftBukkit start - Allow tab-completion of Bukkit commands - ArrayList arraylist = Lists.newArrayList(); - boolean flag1 = s.startsWith("/"); - -@@ -821,10 +1039,13 @@ - - return arraylist; - } -+ */ -+ return server.tabComplete(icommandlistener, s, blockposition, flag); -+ // CraftBukkit end - } - - public boolean M() { + public boolean F() { - return this.universe != null; + return true; // CraftBukkit } - public String getName() { -@@ -880,11 +1101,13 @@ + public void sendMessage(IChatBaseComponent ichatbasecomponent) { +@@ -904,11 +1144,13 @@ } public void a(EnumDifficulty enumdifficulty) { @@ -597,7 +650,7 @@ if (worldserver != null) { if (worldserver.getWorldData().isHardcore()) { -@@ -951,13 +1174,11 @@ +@@ -975,13 +1217,11 @@ int i = 0; if (this.worldServer != null) { @@ -615,8 +668,8 @@ WorldData worlddata = worldserver.getWorldData(); mojangstatisticsgenerator.a("world[" + i + "][dimension]", Integer.valueOf(worldserver.worldProvider.getDimensionManager().getDimensionID())); -@@ -990,7 +1211,7 @@ - public abstract boolean aa(); +@@ -1007,7 +1247,7 @@ + public abstract boolean S(); public boolean getOnlineMode() { - return this.onlineMode; @@ -624,8 +677,8 @@ } public void setOnlineMode(boolean flag) { -@@ -1070,13 +1291,9 @@ - } +@@ -1089,13 +1329,9 @@ + public abstract boolean af(); public void setGamemode(EnumGamemode enumgamemode) { - WorldServer[] aworldserver = this.worldServer; @@ -641,70 +694,65 @@ } } -@@ -1100,7 +1317,7 @@ - } - - public World getWorld() { -- return this.worldServer[0]; -+ return this.worlds.get(0); // CraftBukkit - } - - public int getSpawnProtection() { -@@ -1160,8 +1377,10 @@ - WorldServer[] aworldserver = this.worldServer; - int i = aworldserver.length; - -- for (int j = 0; j < i; ++j) { -- WorldServer worldserver = aworldserver[j]; -+ // CraftBukkit start -+ for (int j = 0; j < worlds.size(); ++j) { -+ WorldServer worldserver = worlds.get(j); -+ // CraftBukkit end - - if (worldserver != null) { - Entity entity = worldserver.getEntity(uuid); -@@ -1176,7 +1395,7 @@ - } - - public boolean getSendCommandFeedback() { -- return this.worldServer[0].getGameRules().getBoolean("sendCommandFeedback"); -+ return worlds.get(0).getGameRules().getBoolean("sendCommandFeedback"); - } - - public MinecraftServer C_() { -@@ -1189,7 +1408,7 @@ +@@ -1168,7 +1404,7 @@ public ListenableFuture a(Callable callable) { Validate.notNull(callable); - if (!this.isMainThread() && !this.isStopped()) { + if (!this.isMainThread()) { // CraftBukkit && !this.isStopped()) { ListenableFutureTask listenablefuturetask = ListenableFutureTask.create(callable); - Queue queue = this.j; -@@ -1232,17 +1451,17 @@ - } - - public AdvancementDataWorld getAdvancementData() { -- return this.worldServer[0].z(); -+ return this.worlds.get(0).z(); // CraftBukkit - } - - public CustomFunctionData aL() { -- return this.worldServer[0].A(); -+ return this.worlds.get(0).A(); // CraftBukkit - } - - public void reload() { - if (this.isMainThread()) { + this.g.add(listenablefuturetask); +@@ -1225,7 +1461,7 @@ + } else { this.getPlayerList().savePlayers(); -- this.worldServer[0].getLootTableRegistry().reload(); -+ this.worlds.get(0).getLootTableRegistry().reload(); // CraftBukkit - this.getAdvancementData().reload(); - this.aL().f(); + this.resourcePackRepository.a(); +- this.a(this.worldServer[0].getWorldData()); ++ this.a(this.worlds.get(0).getWorldData()); // CraftBukkit this.getPlayerList().reload(); -@@ -1251,4 +1470,11 @@ } + } +@@ -1239,8 +1475,8 @@ + if (!worlddata.N().contains(resourcepackloader.e()) && !arraylist.contains(resourcepackloader)) { + MinecraftServer.LOGGER.info("Found new data pack {}, loading it automatically", resourcepackloader.e()); +- resourcepackloader.h().a(arraylist, resourcepackloader, (resourcepackloader) -> { +- return resourcepackloader; ++ resourcepackloader.h().a(arraylist, resourcepackloader, (resourcepackloader1) -> { // CraftBukkit - decompile error ++ return resourcepackloader1; // CraftBukkit - decompile error + }, false); + } + } +@@ -1249,7 +1485,7 @@ + ArrayList arraylist1 = Lists.newArrayList(); + + this.resourcePackRepository.d().forEach((resourcepackloader) -> { +- list.add(resourcepackloader.d()); ++ arraylist1.add(resourcepackloader.d()); // CraftBukkit - decompile error + }); + this.ac.a((List) arraylist1); + worlddata.O().clear(); +@@ -1299,7 +1535,7 @@ + } + + public CommandListenerWrapper getServerCommandListener() { +- return new CommandListenerWrapper(this, this.worldServer[0] == null ? Vec3D.a : new Vec3D(this.worldServer[0].getSpawn()), Vec2F.a, this.worldServer[0], 4, "Server", new ChatComponentText("Server"), this, (Entity) null); ++ return new CommandListenerWrapper(this, this.worlds.isEmpty() ? Vec3D.a : new Vec3D(this.worlds.get(0).getSpawn()), Vec2F.a, this.worlds.isEmpty() ? null : this.worlds.get(0), 4, "Server", new ChatComponentText("Server"), this, (Entity) null); // CraftBukkit + } + + public boolean a() { +@@ -1327,7 +1563,7 @@ + } + + public GameRules aQ() { +- return this.worldServer[0].getGameRules(); ++ return this.worlds.get(0).getGameRules(); // CraftBukkit + } + + public BossBattleCustomData aR() { +@@ -1341,4 +1577,11 @@ + public void k(boolean flag) { + this.an = flag; } + + // CraftBukkit start diff --git a/paper-server/nms-patches/MobEffectList.patch b/paper-server/nms-patches/MobEffectList.patch index cfe1bc3b34..22ff3c2198 100644 --- a/paper-server/nms-patches/MobEffectList.patch +++ b/paper-server/nms-patches/MobEffectList.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/server/MobEffectList.java +++ b/net/minecraft/server/MobEffectList.java -@@ -7,6 +7,11 @@ - import java.util.Map.Entry; +@@ -8,6 +8,11 @@ + import java.util.function.Supplier; import javax.annotation.Nullable; +// CraftBukkit start @@ -12,7 +12,7 @@ public class MobEffectList { public static final RegistryMaterials REGISTRY = new RegistryMaterials(); -@@ -24,7 +29,7 @@ +@@ -26,7 +31,7 @@ } public static int getId(MobEffectList mobeffectlist) { @@ -20,8 +20,8 @@ + return MobEffectList.REGISTRY.a(mobeffectlist); // CraftBukkit - decompile error } - @Nullable -@@ -51,11 +56,11 @@ + protected MobEffectList(boolean flag, int i) { +@@ -48,11 +53,11 @@ public void tick(EntityLiving entityliving, int i) { if (this == MobEffects.REGENERATION) { if (entityliving.getHealth() < entityliving.getMaxHealth()) { @@ -35,7 +35,7 @@ } } else if (this == MobEffects.WITHER) { entityliving.damageEntity(DamageSource.WITHER, 1.0F); -@@ -63,14 +68,25 @@ +@@ -60,14 +65,25 @@ ((EntityHuman) entityliving).applyExhaustion(0.005F * (float) (i + 1)); } else if (this == MobEffects.SATURATION && entityliving instanceof EntityHuman) { if (!entityliving.world.isClientSide) { @@ -53,8 +53,8 @@ + ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutUpdateHealth(((EntityPlayer) entityhuman).getBukkitEntity().getScaledHealth(), entityhuman.getFoodData().foodLevel, entityhuman.getFoodData().saturationLevel)); + // CraftBukkit end } - } else if ((this != MobEffects.HEAL || entityliving.cc()) && (this != MobEffects.HARM || !entityliving.cc())) { - if (this == MobEffects.HARM && !entityliving.cc() || this == MobEffects.HEAL && entityliving.cc()) { + } else if ((this != MobEffects.HEAL || entityliving.co()) && (this != MobEffects.HARM || !entityliving.co())) { + if (this == MobEffects.HARM && !entityliving.co() || this == MobEffects.HEAL && entityliving.co()) { entityliving.damageEntity(DamageSource.MAGIC, (float) (6 << i)); } } else { @@ -63,7 +63,7 @@ } } -@@ -89,7 +105,7 @@ +@@ -88,7 +104,7 @@ } } else { j = (int) (d0 * (double) (4 << i) + 0.5D); @@ -72,14 +72,15 @@ } } -@@ -208,5 +224,10 @@ - MobEffectList.REGISTRY.a(25, new MinecraftKey("levitation"), (new MobEffectList(true, 13565951)).c("effect.levitation").b(3, 2)); - MobEffectList.REGISTRY.a(26, new MinecraftKey("luck"), (new MobEffectList(false, 3381504)).c("effect.luck").b(5, 2).j().a(GenericAttributes.j, "03C3C89D-7037-4B42-869F-B146BCB64D2E", 1.0D, 0)); - MobEffectList.REGISTRY.a(27, new MinecraftKey("unluck"), (new MobEffectList(true, 12624973)).c("effect.unluck").b(6, 2).a(GenericAttributes.j, "CC5AF142-2BD2-4215-B636-2605AED11727", -1.0D, 0)); +@@ -217,6 +233,11 @@ + a(28, "slow_falling", (new MobEffectList(false, 16773073)).b(8, 0).l()); + a(29, "conduit_power", (new MobEffectList(false, 1950417)).b(9, 0).l()); + a(30, "dolphins_grace", (new MobEffectList(false, 8954814)).b(10, 0).l()); + // CraftBukkit start + for (Object effect : REGISTRY) { + org.bukkit.potion.PotionEffectType.registerPotionEffectType(new org.bukkit.craftbukkit.potion.CraftPotionEffectType((MobEffectList) effect)); + } + // CraftBukkit end } - } + + private static void a(int i, String s, MobEffectList mobeffectlist) { diff --git a/paper-server/nms-patches/MobSpawnerAbstract.patch b/paper-server/nms-patches/MobSpawnerAbstract.patch index 9f63bb2a99..abcecdf98a 100644 --- a/paper-server/nms-patches/MobSpawnerAbstract.patch +++ b/paper-server/nms-patches/MobSpawnerAbstract.patch @@ -1,39 +1,19 @@ --- a/net/minecraft/server/MobSpawnerAbstract.java +++ b/net/minecraft/server/MobSpawnerAbstract.java -@@ -12,13 +12,13 @@ - private MobSpawnerData spawnData = new MobSpawnerData(); - private double d; - private double e; -- private int minSpawnDelay = 200; -- private int maxSpawnDelay = 800; -- private int spawnCount = 4; -+ public int minSpawnDelay = 200; // CraftBukkit private -> public -+ public int maxSpawnDelay = 800; // CraftBukkit private -> public -+ public int spawnCount = 4; // CraftBukkit private -> public - private Entity i; -- private int maxNearbyEntities = 6; -- private int requiredPlayerRange = 16; -- private int spawnRange = 4; -+ public int maxNearbyEntities = 6; // CraftBukkit private -> public -+ public int requiredPlayerRange = 16; // CraftBukkit private -> public -+ public int spawnRange = 4; // CraftBukkit private -> public - - public MobSpawnerAbstract() {} - -@@ -32,6 +32,7 @@ - public void setMobName(@Nullable MinecraftKey minecraftkey) { - if (minecraftkey != null) { - this.spawnData.b().setString("id", minecraftkey.toString()); -+ this.mobs.clear(); // CraftBukkit - SPIGOT-3496, MC-92282 - } +@@ -41,6 +41,7 @@ + public void setMobName(EntityTypes entitytypes) { + this.spawnData.b().setString("id", ((MinecraftKey) EntityTypes.REGISTRY.b(entitytypes)).toString()); ++ this.mobs.clear(); // CraftBukkit - SPIGOT-3496, MC-92282 } -@@ -102,7 +103,7 @@ - ((EntityInsentient) entity).prepare(world.D(new BlockPosition(entity)), (GroupDataEntity) null); + + private boolean h() { +@@ -110,7 +111,7 @@ + ((EntityInsentient) entity).prepare(world.getDamageScaler(new BlockPosition(entity)), (GroupDataEntity) null, (NBTTagCompound) null); } -- ChunkRegionLoader.a(entity, world); -+ ChunkRegionLoader.a(entity, world, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER); // CraftBukkit +- ChunkRegionLoader.a(entity, (GeneratorAccess) world); ++ ChunkRegionLoader.a(entity, (GeneratorAccess) world, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER); // CraftBukkit world.triggerEffect(2004, blockposition, 0); if (entityinsentient != null) { entityinsentient.doSpawnEffect(); diff --git a/paper-server/nms-patches/NameReferencingFileConverter.patch b/paper-server/nms-patches/NameReferencingFileConverter.patch index c7bd0f7e95..b2978b2fa3 100644 --- a/paper-server/nms-patches/NameReferencingFileConverter.patch +++ b/paper-server/nms-patches/NameReferencingFileConverter.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/NameReferencingFileConverter.java +++ b/net/minecraft/server/NameReferencingFileConverter.java -@@ -88,8 +88,9 @@ +@@ -83,8 +83,9 @@ if (gameprofilebanlist.c().exists()) { try { gameprofilebanlist.load(); @@ -12,7 +12,7 @@ } } -@@ -146,8 +147,9 @@ +@@ -141,8 +142,9 @@ if (ipbanlist.c().exists()) { try { ipbanlist.load(); @@ -24,7 +24,7 @@ } } -@@ -187,8 +189,9 @@ +@@ -182,8 +184,9 @@ if (oplist.c().exists()) { try { oplist.load(); @@ -36,7 +36,7 @@ } } -@@ -231,8 +234,9 @@ +@@ -226,8 +229,9 @@ if (whitelist.c().exists()) { try { whitelist.load(); @@ -48,7 +48,7 @@ } } -@@ -350,6 +354,30 @@ +@@ -345,6 +349,30 @@ File file1 = new File(file2, s + ".dat"); File file3 = new File(file, s1 + ".dat"); @@ -79,7 +79,7 @@ NameReferencingFileConverter.b(file); if (!file1.renameTo(file3)) { throw new NameReferencingFileConverter.FileConversionException("Could not convert file for " + s, null); -@@ -358,7 +386,7 @@ +@@ -353,7 +381,7 @@ private String a(GameProfile gameprofile) { String s = null; @@ -88,7 +88,7 @@ int i = astring.length; for (int j = 0; j < i; ++j) { -@@ -471,7 +499,7 @@ +@@ -466,7 +494,7 @@ private static File d(PropertyManager propertymanager) { String s = propertymanager.getString("level-name", "world"); diff --git a/paper-server/nms-patches/NetworkManager.patch b/paper-server/nms-patches/NetworkManager.patch index 6e69467cae..5caf383c92 100644 --- a/paper-server/nms-patches/NetworkManager.patch +++ b/paper-server/nms-patches/NetworkManager.patch @@ -1,15 +1,24 @@ --- a/net/minecraft/server/NetworkManager.java +++ b/net/minecraft/server/NetworkManager.java -@@ -114,7 +114,7 @@ - protected void a(ChannelHandlerContext channelhandlercontext, Packet packet) throws Exception { - if (this.channel.isOpen()) { - try { -- packet.a(this.m); -+ ((Packet) packet).a(this.m); // CraftBukkit - decompile error - } catch (CancelledPacketHandleException cancelledpackethandleexception) { - ; - } -@@ -236,7 +236,7 @@ +@@ -103,7 +103,7 @@ + if (flag) { + NetworkManager.g.debug("Failed to sent packet", throwable); + this.sendPacket(new PacketPlayOutKickDisconnect(chatmessage), (future) -> { +- this.close(ichatbasecomponent); ++ this.close(chatmessage); // CraftBukkit - decompile error + }); + this.stopReading(); + } else { +@@ -130,7 +130,7 @@ + } + + private static void a(Packet packet, PacketListener packetlistener) { +- packet.a(packetlistener); ++ packet.a((T) packetlistener); // CraftBukkit - decompile error + } + + public void setPacketListener(PacketListener packetlistener) { +@@ -241,7 +241,7 @@ public void close(IChatBaseComponent ichatbasecomponent) { if (this.channel.isOpen()) { @@ -18,7 +27,7 @@ this.n = ichatbasecomponent; } -@@ -313,7 +313,7 @@ +@@ -319,7 +319,7 @@ } } diff --git a/paper-server/nms-patches/PacketDataSerializer.patch b/paper-server/nms-patches/PacketDataSerializer.patch index 4348da940d..acfca3b059 100644 --- a/paper-server/nms-patches/PacketDataSerializer.patch +++ b/paper-server/nms-patches/PacketDataSerializer.patch @@ -35,9 +35,9 @@ + if (itemstack.isEmpty() || itemstack.getItem() == null) { // CraftBukkit - NPE fix itemstack.getItem() this.writeShort(-1); } else { - this.writeShort(Item.getId(itemstack.getItem())); + Item item = itemstack.getItem(); @@ -263,6 +265,11 @@ - ItemStack itemstack = new ItemStack(Item.getById(short0), b0, short1); + ItemStack itemstack = new ItemStack(Item.getById(short0), b0); itemstack.setTag(this.j()); + // CraftBukkit start diff --git a/paper-server/nms-patches/PacketStatusListener.patch b/paper-server/nms-patches/PacketStatusListener.patch index c8a9a902cb..4d53d1464e 100644 --- a/paper-server/nms-patches/PacketStatusListener.patch +++ b/paper-server/nms-patches/PacketStatusListener.patch @@ -16,7 +16,7 @@ + public class PacketStatusListener implements PacketStatusInListener { - private static final IChatBaseComponent a = new ChatComponentText("Status request has been handled."); + private static final IChatBaseComponent a = new ChatMessage("multiplayer.status.request_handled", new Object[0]); @@ -19,8 +30,96 @@ this.networkManager.close(PacketStatusListener.a); } else { diff --git a/paper-server/nms-patches/PathfinderGoalBreakDoor.patch b/paper-server/nms-patches/PathfinderGoalBreakDoor.patch index e51d156918..9f16c309a6 100644 --- a/paper-server/nms-patches/PathfinderGoalBreakDoor.patch +++ b/paper-server/nms-patches/PathfinderGoalBreakDoor.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/server/PathfinderGoalBreakDoor.java +++ b/net/minecraft/server/PathfinderGoalBreakDoor.java -@@ -63,6 +63,12 @@ +@@ -44,6 +44,12 @@ } - if (this.g == 240 && this.a.world.getDifficulty() == EnumDifficulty.HARD) { + if (this.d == 240 && this.a.world.getDifficulty() == EnumDifficulty.HARD) { + // CraftBukkit start + if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityBreakDoorEvent(this.a, this.b.getX(), this.b.getY(), this.b.getZ()).isCancelled()) { + this.c(); @@ -12,4 +12,4 @@ + // CraftBukkit end this.a.world.setAir(this.b); this.a.world.triggerEffect(1021, this.b, 0); - this.a.world.triggerEffect(2001, this.b, Block.getId(this.c)); + this.a.world.triggerEffect(2001, this.b, Block.getCombinedId(this.a.world.getType(this.b))); diff --git a/paper-server/nms-patches/PathfinderGoalBreed.patch b/paper-server/nms-patches/PathfinderGoalBreed.patch index 2c1691108d..1504f5e3f3 100644 --- a/paper-server/nms-patches/PathfinderGoalBreed.patch +++ b/paper-server/nms-patches/PathfinderGoalBreed.patch @@ -24,24 +24,24 @@ + // CraftBukkit end if (entityplayer != null) { - entityplayer.b(StatisticList.C); + entityplayer.a(StatisticList.ANIMALS_BRED); @@ -92,7 +105,7 @@ this.partner.resetLove(); entityageable.setAgeRaw(-24000); entityageable.setPositionRotation(this.animal.locX, this.animal.locY, this.animal.locZ, 0.0F, 0.0F); -- this.a.addEntity(entityageable); -+ this.a.addEntity(entityageable, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - added SpawnReason +- this.b.addEntity(entityageable); ++ this.b.addEntity(entityageable, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - added SpawnReason Random random = this.animal.getRandom(); for (int i = 0; i < 7; ++i) { @@ -107,7 +120,11 @@ } - if (this.a.getGameRules().getBoolean("doMobLoot")) { -- this.a.addEntity(new EntityExperienceOrb(this.a, this.animal.locX, this.animal.locY, this.animal.locZ, random.nextInt(7) + 1)); + if (this.b.getGameRules().getBoolean("doMobLoot")) { +- this.b.addEntity(new EntityExperienceOrb(this.b, this.animal.locX, this.animal.locY, this.animal.locZ, random.nextInt(7) + 1)); + // CraftBukkit start - use event experience + if (experience > 0) { -+ this.a.addEntity(new EntityExperienceOrb(this.a, this.animal.locX, this.animal.locY, this.animal.locZ, experience)); ++ this.b.addEntity(new EntityExperienceOrb(this.b, this.animal.locX, this.animal.locY, this.animal.locZ, experience)); + } + // CraftBukkit end } diff --git a/paper-server/nms-patches/PathfinderGoalEatTile.patch b/paper-server/nms-patches/PathfinderGoalEatTile.patch index f3d98e5ca2..ecefdb1899 100644 --- a/paper-server/nms-patches/PathfinderGoalEatTile.patch +++ b/paper-server/nms-patches/PathfinderGoalEatTile.patch @@ -1,34 +1,33 @@ --- a/net/minecraft/server/PathfinderGoalEatTile.java +++ b/net/minecraft/server/PathfinderGoalEatTile.java -@@ -3,6 +3,11 @@ - import com.google.common.base.Predicate; - import com.google.common.base.Predicates; +@@ -2,6 +2,10 @@ + + import java.util.function.Predicate; +// CraftBukkit start +import org.bukkit.craftbukkit.event.CraftEventFactory; -+import org.bukkit.Material; +// CraftBukkit end + public class PathfinderGoalEatTile extends PathfinderGoal { - private static final Predicate b = BlockStatePredicate.a((Block) Blocks.TALLGRASS).a(BlockLongGrass.TYPE, Predicates.equalTo(BlockLongGrass.EnumTallGrassType.GRASS)); -@@ -50,7 +55,8 @@ - BlockPosition blockposition = new BlockPosition(this.c.locX, this.c.locY, this.c.locZ); + private static final Predicate a = BlockStatePredicate.a(Blocks.GRASS); +@@ -49,7 +53,8 @@ + BlockPosition blockposition = new BlockPosition(this.b.locX, this.b.locY, this.b.locZ); - if (PathfinderGoalEatTile.b.apply(this.d.getType(blockposition))) { -- if (this.d.getGameRules().getBoolean("mobGriefing")) { + if (PathfinderGoalEatTile.a.test(this.c.getType(blockposition))) { +- if (this.c.getGameRules().getBoolean("mobGriefing")) { + // CraftBukkit -+ if (!CraftEventFactory.callEntityChangeBlockEvent(this.c, this.c.world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), Material.AIR, !this.d.getGameRules().getBoolean("mobGriefing")).isCancelled()) { - this.d.setAir(blockposition, false); ++ if (!CraftEventFactory.callEntityChangeBlockEvent(this.b, blockposition, Blocks.AIR.getBlockData(), !this.c.getGameRules().getBoolean("mobGriefing")).isCancelled()) { + this.c.setAir(blockposition, false); } -@@ -59,7 +65,8 @@ +@@ -58,7 +63,8 @@ BlockPosition blockposition1 = blockposition.down(); - if (this.d.getType(blockposition1).getBlock() == Blocks.GRASS) { -- if (this.d.getGameRules().getBoolean("mobGriefing")) { + if (this.c.getType(blockposition1).getBlock() == Blocks.GRASS_BLOCK) { +- if (this.c.getGameRules().getBoolean("mobGriefing")) { + // CraftBukkit -+ if (!CraftEventFactory.callEntityChangeBlockEvent(this.c, this.c.world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), Material.AIR, !this.d.getGameRules().getBoolean("mobGriefing")).isCancelled()) { - this.d.triggerEffect(2001, blockposition1, Block.getId(Blocks.GRASS)); - this.d.setTypeAndData(blockposition1, Blocks.DIRT.getBlockData(), 2); ++ if (!CraftEventFactory.callEntityChangeBlockEvent(this.b, blockposition, Blocks.AIR.getBlockData(), !this.c.getGameRules().getBoolean("mobGriefing")).isCancelled()) { + this.c.triggerEffect(2001, blockposition1, Block.getCombinedId(Blocks.GRASS_BLOCK.getBlockData())); + this.c.setTypeAndData(blockposition1, Blocks.DIRT.getBlockData(), 2); } diff --git a/paper-server/nms-patches/PathfinderGoalFollowOwner.patch b/paper-server/nms-patches/PathfinderGoalFollowOwner.patch index 039f15a91d..df21289cc4 100644 --- a/paper-server/nms-patches/PathfinderGoalFollowOwner.patch +++ b/paper-server/nms-patches/PathfinderGoalFollowOwner.patch @@ -11,24 +11,24 @@ + public class PathfinderGoalFollowOwner extends PathfinderGoal { - private final EntityTameableAnimal d; + private final EntityTameableAnimal b; @@ -73,7 +79,18 @@ for (int l = 0; l <= 4; ++l) { for (int i1 = 0; i1 <= 4; ++i1) { if ((l < 1 || i1 < 1 || l > 3 || i1 > 3) && this.a(i, j, k, l, i1)) { -- this.d.setPositionRotation((double) ((float) (i + l) + 0.5F), (double) k, (double) ((float) (j + i1) + 0.5F), this.d.yaw, this.d.pitch); +- this.b.setPositionRotation((double) ((float) (i + l) + 0.5F), (double) k, (double) ((float) (j + i1) + 0.5F), this.b.yaw, this.b.pitch); + // CraftBukkit start -+ CraftEntity entity = this.d.getBukkitEntity(); -+ Location to = new Location(entity.getWorld(), (double) ((float) (i + l) + 0.5F), (double) k, (double) ((float) (j + i1) + 0.5F), this.d.yaw, this.d.pitch); ++ CraftEntity entity = this.b.getBukkitEntity(); ++ Location to = new Location(entity.getWorld(), (double) ((float) (i + l) + 0.5F), (double) k, (double) ((float) (j + i1) + 0.5F), this.b.yaw, this.b.pitch); + EntityTeleportEvent event = new EntityTeleportEvent(entity, entity.getLocation(), to); -+ this.d.world.getServer().getPluginManager().callEvent(event); ++ this.b.world.getServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { + return; + } + to = event.getTo(); + -+ this.d.setPositionRotation(to.getX(), to.getY(), to.getZ(), to.getYaw(), to.getPitch()); ++ this.b.setPositionRotation(to.getX(), to.getY(), to.getZ(), to.getYaw(), to.getPitch()); + // CraftBukkit end - this.g.p(); + this.e.r(); return; } diff --git a/paper-server/nms-patches/PathfinderGoalHorseTrap.patch b/paper-server/nms-patches/PathfinderGoalHorseTrap.patch index 0aa10ae063..47730fe02f 100644 --- a/paper-server/nms-patches/PathfinderGoalHorseTrap.patch +++ b/paper-server/nms-patches/PathfinderGoalHorseTrap.patch @@ -18,7 +18,7 @@ } @@ -42,7 +43,7 @@ - entityhorseskeleton.cW(); + entityhorseskeleton.di(); entityhorseskeleton.setTamed(true); entityhorseskeleton.setAgeRaw(0); - entityhorseskeleton.world.addEntity(entityhorseskeleton); diff --git a/paper-server/nms-patches/PathfinderGoalHurtByTarget.patch b/paper-server/nms-patches/PathfinderGoalHurtByTarget.patch index bd1581bbd3..37d9cc80db 100644 --- a/paper-server/nms-patches/PathfinderGoalHurtByTarget.patch +++ b/paper-server/nms-patches/PathfinderGoalHurtByTarget.patch @@ -7,7 +7,7 @@ - this.e.setGoalTarget(this.e.getLastDamager()); + this.e.setGoalTarget(this.e.getLastDamager(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY, true); // CraftBukkit - reason this.g = this.e.getGoalTarget(); - this.b = this.e.bT(); + this.b = this.e.cf(); this.h = 300; @@ -66,6 +66,6 @@ } diff --git a/paper-server/nms-patches/PathfinderGoalMakeLove.patch b/paper-server/nms-patches/PathfinderGoalMakeLove.patch index d7269cd0ac..4ef924b9d7 100644 --- a/paper-server/nms-patches/PathfinderGoalMakeLove.patch +++ b/paper-server/nms-patches/PathfinderGoalMakeLove.patch @@ -3,21 +3,21 @@ @@ -80,6 +80,11 @@ private void i() { - EntityVillager entityvillager = this.b.b((EntityAgeable) this.c); + EntityVillager entityvillager = this.a.b((EntityAgeable) this.b); + // CraftBukkit start - call EntityBreedEvent -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityBreedEvent(entityvillager, this.b, this.c, null, null, 0).isCancelled()) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityBreedEvent(entityvillager, this.a, this.b, null, null, 0).isCancelled()) { + return; + } + // CraftBukkit end - this.c.setAgeRaw(6000); this.b.setAgeRaw(6000); + this.a.setAgeRaw(6000); @@ -87,7 +92,7 @@ - this.b.s(false); + this.a.v(false); entityvillager.setAgeRaw(-24000); - entityvillager.setPositionRotation(this.b.locX, this.b.locY, this.b.locZ, 0.0F, 0.0F); -- this.d.addEntity(entityvillager); -+ this.d.addEntity(entityvillager, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - added SpawnReason - this.d.broadcastEntityEffect(entityvillager, (byte) 12); + entityvillager.setPositionRotation(this.a.locX, this.a.locY, this.a.locZ, 0.0F, 0.0F); +- this.c.addEntity(entityvillager); ++ this.c.addEntity(entityvillager, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - added SpawnReason + this.c.broadcastEntityEffect(entityvillager, (byte) 12); } } diff --git a/paper-server/nms-patches/PathfinderGoalNearestAttackableTarget.patch b/paper-server/nms-patches/PathfinderGoalNearestAttackableTarget.patch index d1ceb69a18..7ca3e982ee 100644 --- a/paper-server/nms-patches/PathfinderGoalNearestAttackableTarget.patch +++ b/paper-server/nms-patches/PathfinderGoalNearestAttackableTarget.patch @@ -1,15 +1,6 @@ --- a/net/minecraft/server/PathfinderGoalNearestAttackableTarget.java +++ b/net/minecraft/server/PathfinderGoalNearestAttackableTarget.java -@@ -35,7 +35,7 @@ - } - - public boolean apply(@Nullable Object object) { -- return this.a((EntityLiving) object); -+ return this.a((T) object); // CraftBukkit - fix decompile error - } - }; - } -@@ -50,11 +50,11 @@ +@@ -44,11 +44,11 @@ return false; } else { Collections.sort(list, this.b); @@ -23,7 +14,7 @@ @Nullable public Double a(@Nullable EntityHuman entityhuman) { ItemStack itemstack = entityhuman.getEquipment(EnumItemSlot.HEAD); -@@ -74,10 +74,10 @@ +@@ -57,10 +57,10 @@ } @Nullable @@ -36,7 +27,7 @@ return this.d != null; } } -@@ -87,7 +87,7 @@ +@@ -70,7 +70,7 @@ } public void c() { @@ -45,7 +36,7 @@ super.c(); } -@@ -106,7 +106,7 @@ +@@ -89,7 +89,7 @@ return d0 < d1 ? -1 : (d0 > d1 ? 1 : 0); } diff --git a/paper-server/nms-patches/PathfinderGoalNearestAttackableTargetInsentient.patch b/paper-server/nms-patches/PathfinderGoalNearestAttackableTargetInsentient.patch index 9dad5d795d..dcb68d54ad 100644 --- a/paper-server/nms-patches/PathfinderGoalNearestAttackableTargetInsentient.patch +++ b/paper-server/nms-patches/PathfinderGoalNearestAttackableTargetInsentient.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/PathfinderGoalNearestAttackableTargetInsentient.java +++ b/net/minecraft/server/PathfinderGoalNearestAttackableTargetInsentient.java -@@ -69,7 +69,7 @@ +@@ -62,7 +62,7 @@ } public void c() { diff --git a/paper-server/nms-patches/PathfinderGoalPanic.patch b/paper-server/nms-patches/PathfinderGoalPanic.patch index f599048726..f7030cd788 100644 --- a/paper-server/nms-patches/PathfinderGoalPanic.patch +++ b/paper-server/nms-patches/PathfinderGoalPanic.patch @@ -10,6 +10,6 @@ + return false; + } + // CraftBukkit end - return !this.a.getNavigation().o(); + return !this.a.getNavigation().q(); } diff --git a/paper-server/nms-patches/PathfinderGoalSit.patch b/paper-server/nms-patches/PathfinderGoalSit.patch index 80597cfeff..403a27af7e 100644 --- a/paper-server/nms-patches/PathfinderGoalSit.patch +++ b/paper-server/nms-patches/PathfinderGoalSit.patch @@ -6,6 +6,6 @@ if (!this.entity.isTamed()) { - return false; + return this.willSit && this.entity.getGoalTarget() == null; // CraftBukkit - Allow sitting for wild animals - } else if (this.entity.isInWater()) { + } else if (this.entity.aq()) { return false; } else if (!this.entity.onGround) { diff --git a/paper-server/nms-patches/PathfinderGoalTargetNearestPlayer.patch b/paper-server/nms-patches/PathfinderGoalTargetNearestPlayer.patch index 0b3f5342ea..560d9330b9 100644 --- a/paper-server/nms-patches/PathfinderGoalTargetNearestPlayer.patch +++ b/paper-server/nms-patches/PathfinderGoalTargetNearestPlayer.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/PathfinderGoalTargetNearestPlayer.java +++ b/net/minecraft/server/PathfinderGoalTargetNearestPlayer.java -@@ -92,7 +92,7 @@ +@@ -85,7 +85,7 @@ } public void c() { diff --git a/paper-server/nms-patches/PathfinderGoalTempt.patch b/paper-server/nms-patches/PathfinderGoalTempt.patch index ec9ecd2649..06dfabbc61 100644 --- a/paper-server/nms-patches/PathfinderGoalTempt.patch +++ b/paper-server/nms-patches/PathfinderGoalTempt.patch @@ -1,19 +1,19 @@ --- a/net/minecraft/server/PathfinderGoalTempt.java +++ b/net/minecraft/server/PathfinderGoalTempt.java -@@ -2,6 +2,12 @@ +@@ -1,5 +1,12 @@ + package net.minecraft.server; - import com.google.common.collect.Sets; - import java.util.Set; +// CraftBukkit start +import org.bukkit.craftbukkit.entity.CraftLivingEntity; +import org.bukkit.craftbukkit.event.CraftEventFactory; +import org.bukkit.event.entity.EntityTargetEvent; +import org.bukkit.event.entity.EntityTargetLivingEntityEvent; +// CraftBukkit end - ++ public class PathfinderGoalTempt extends PathfinderGoal { -@@ -12,7 +18,7 @@ + private final EntityCreature a; +@@ -9,7 +16,7 @@ private double e; private double f; private double g; @@ -21,8 +21,8 @@ + private EntityLiving target; // CraftBukkit private int i; private boolean j; - private final Set k; -@@ -39,7 +45,17 @@ + private final RecipeItemStack k; +@@ -36,7 +43,17 @@ return false; } else { this.target = this.a.world.findNearbyPlayer(this.a, 10.0D); diff --git a/paper-server/nms-patches/PathfinderGoalVillagerFarm.patch b/paper-server/nms-patches/PathfinderGoalVillagerFarm.patch index 2600cea082..19116f1ad1 100644 --- a/paper-server/nms-patches/PathfinderGoalVillagerFarm.patch +++ b/paper-server/nms-patches/PathfinderGoalVillagerFarm.patch @@ -3,15 +3,15 @@ @@ -40,7 +40,11 @@ Block block = iblockdata.getBlock(); - if (this.f == 0 && block instanceof BlockCrops && ((BlockCrops) block).z(iblockdata)) { + if (this.i == 0 && block instanceof BlockCrops && ((BlockCrops) block).w(iblockdata)) { - world.setAir(blockposition, true); + // CraftBukkit start -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.c, blockposition, Blocks.AIR, 0).isCancelled()) { ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.f, blockposition, Blocks.AIR.getBlockData()).isCancelled()) { + world.setAir(blockposition, true); + } + // CraftBukkit end - } else if (this.f == 1 && iblockdata.getMaterial() == Material.AIR) { - InventorySubcontainer inventorysubcontainer = this.c.dq(); + } else if (this.i == 1 && iblockdata.isAir()) { + InventorySubcontainer inventorysubcontainer = this.f.dD(); @@ -49,19 +53,28 @@ boolean flag = false; @@ -32,12 +32,12 @@ + planted = Blocks.CARROTS; flag = true; } else if (itemstack.getItem() == Items.BEETROOT_SEEDS) { -- world.setTypeAndData(blockposition, Blocks.BEETROOT.getBlockData(), 3); -+ planted = Blocks.BEETROOT; +- world.setTypeAndData(blockposition, Blocks.BEETROOTS.getBlockData(), 3); ++ planted = Blocks.BEETROOTS; flag = true; } + -+ if (planted != null && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.c, blockposition, planted, 0).isCancelled()) { ++ if (planted != null && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.f, blockposition, planted.getBlockData()).isCancelled()) { + world.setTypeAndData(blockposition, planted.getBlockData(), 3); + } else { + flag = false; diff --git a/paper-server/nms-patches/PlayerChunk.patch b/paper-server/nms-patches/PlayerChunk.patch index 2dc88641c0..e9e5e79c9e 100644 --- a/paper-server/nms-patches/PlayerChunk.patch +++ b/paper-server/nms-patches/PlayerChunk.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/PlayerChunk.java +++ b/net/minecraft/server/PlayerChunk.java -@@ -8,32 +8,48 @@ +@@ -7,21 +7,36 @@ import javax.annotation.Nullable; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -25,6 +25,8 @@ private boolean done; + // CraftBukkit start - add fields ++ // You know the drill, https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse ++ // All may seem good at first, but there's deeper issues if you play for a bit + private boolean loadInProgress = false; + private Runnable loadedRunnable = new Runnable() { + public void run() { @@ -37,71 +39,3 @@ public PlayerChunk(PlayerChunkMap playerchunkmap, int i, int j) { this.playerChunkMap = playerchunkmap; this.location = new ChunkCoordIntPair(i, j); -- this.chunk = playerchunkmap.getWorld().getChunkProviderServer().getOrLoadChunkAt(i, j); -+ // CraftBukkit start -+ loadInProgress = true; -+ this.chunk = playerchunkmap.getWorld().getChunkProviderServer().getChunkAt(i, j, loadedRunnable, false); -+ // CraftBukkit end - } - - public ChunkCoordIntPair a() { - return this.location; - } - -- public void a(EntityPlayer entityplayer) { -+ public void a(final EntityPlayer entityplayer) { // CraftBukkit - added final to argument - if (this.c.contains(entityplayer)) { - PlayerChunk.a.debug("Failed to add player. {} already is in chunk {}, {}", entityplayer, Integer.valueOf(this.location.x), Integer.valueOf(this.location.z)); - } else { -@@ -42,15 +58,32 @@ - } - - this.c.add(entityplayer); -+ // CraftBukkit start - use async chunk io -+ // if (this.done) { -+ // this.sendChunk(entityplayer); -+ // } - if (this.done) { - this.sendChunk(entityplayer); - } -+ // CraftBukkit end - - } - } - - public void b(EntityPlayer entityplayer) { - if (this.c.contains(entityplayer)) { -+ // CraftBukkit start - If we haven't loaded yet don't load the chunk just so we can clean it up -+ if (!this.done) { -+ this.c.remove(entityplayer); -+ -+ if (this.c.isEmpty()) { -+ ChunkIOExecutor.dropQueuedChunkLoad(this.playerChunkMap.getWorld(), this.location.x, this.location.z, this.loadedRunnable); -+ this.playerChunkMap.b(this); -+ } -+ -+ return; -+ } -+ // CraftBukkit end - if (this.done) { - entityplayer.playerConnection.sendPacket(new PacketPlayOutUnloadChunk(this.location.x, this.location.z)); - } -@@ -67,11 +100,18 @@ - if (this.chunk != null) { - return true; - } else { -+ /* CraftBukkit start - if (flag) { - this.chunk = this.playerChunkMap.getWorld().getChunkProviderServer().getChunkAt(this.location.x, this.location.z); - } else { - this.chunk = this.playerChunkMap.getWorld().getChunkProviderServer().getOrLoadChunkAt(this.location.x, this.location.z); - } -+ */ -+ if (!loadInProgress) { -+ loadInProgress = true; -+ this.chunk = playerChunkMap.getWorld().getChunkProviderServer().getChunkAt(this.location.x, this.location.z, loadedRunnable, flag); -+ } -+ // CraftBukkit end - - return this.chunk != null; - } diff --git a/paper-server/nms-patches/PlayerChunkMap.patch b/paper-server/nms-patches/PlayerChunkMap.patch index 37c4c4744d..40a1805e52 100644 --- a/paper-server/nms-patches/PlayerChunkMap.patch +++ b/paper-server/nms-patches/PlayerChunkMap.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/server/PlayerChunkMap.java +++ b/net/minecraft/server/PlayerChunkMap.java @@ -15,6 +15,10 @@ - import java.util.Set; + import java.util.function.Predicate; import javax.annotation.Nullable; +// CraftBukkit start @@ -10,8 +10,8 @@ + public class PlayerChunkMap { - private static final Predicate a = new Predicate() { -@@ -46,6 +50,7 @@ + private static final Predicate a = (entityplayer) -> { +@@ -34,6 +38,7 @@ private long k; private boolean l = true; private boolean m = true; @@ -19,7 +19,30 @@ public PlayerChunkMap(WorldServer worldserver) { this.world = worldserver; -@@ -169,7 +174,11 @@ +@@ -107,16 +112,18 @@ + + if (this.l && i % 4L == 0L) { + this.l = false; +- Collections.sort(this.h, (playerchunk, playerchunk1) -> { +- return ComparisonChain.start().compare(playerchunk.g(), playerchunk1.g()).result(); ++ // CraftBukkit start ++ Collections.sort(this.h, (playerchunkx, playerchunk1x) -> { ++ return ComparisonChain.start().compare(playerchunkx.g(), playerchunk1x.g()).result(); + }); + } + + if (this.m && i % 4L == 2L) { + this.m = false; +- Collections.sort(this.g, (playerchunk, playerchunk1) -> { +- return ComparisonChain.start().compare(playerchunk.g(), playerchunk1.g()).result(); ++ Collections.sort(this.g, (playerchunkx, playerchunk1x) -> { ++ return ComparisonChain.start().compare(playerchunkx.g(), playerchunk1x.g()).result(); + }); ++ // CraftBukkit end + } + + if (!this.h.isEmpty()) { +@@ -141,7 +148,11 @@ break; } } @@ -31,7 +54,7 @@ } } -@@ -231,6 +240,16 @@ +@@ -203,6 +214,16 @@ return playerchunk; } @@ -48,7 +71,7 @@ public void flagDirty(BlockPosition blockposition) { int i = blockposition.getX() >> 4; int j = blockposition.getZ() >> 4; -@@ -249,12 +268,22 @@ +@@ -221,12 +242,22 @@ entityplayer.d = entityplayer.locX; entityplayer.e = entityplayer.locZ; @@ -72,7 +95,7 @@ this.managedPlayers.add(entityplayer); this.e(); } -@@ -298,11 +327,14 @@ +@@ -270,11 +301,14 @@ int j1 = i - k; int k1 = j - l; @@ -88,7 +111,7 @@ } if (!this.a(l1 - j1, i2 - k1, i, j, i1)) { -@@ -318,6 +350,13 @@ +@@ -290,6 +324,13 @@ entityplayer.d = entityplayer.locX; entityplayer.e = entityplayer.locZ; this.e(); @@ -102,7 +125,7 @@ } } } -@@ -402,4 +441,47 @@ +@@ -374,4 +415,47 @@ } } diff --git a/paper-server/nms-patches/PlayerConnection.patch b/paper-server/nms-patches/PlayerConnection.patch index e67b453821..f5611f325b 100644 --- a/paper-server/nms-patches/PlayerConnection.patch +++ b/paper-server/nms-patches/PlayerConnection.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/PlayerConnection.java +++ b/net/minecraft/server/PlayerConnection.java -@@ -15,6 +15,49 @@ +@@ -15,6 +15,50 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -14,6 +14,7 @@ +import org.bukkit.craftbukkit.inventory.CraftInventoryView; +import org.bukkit.craftbukkit.inventory.CraftItemStack; +import org.bukkit.craftbukkit.util.CraftChatMessage; ++import org.bukkit.craftbukkit.util.CraftMagicNumbers; +import org.bukkit.craftbukkit.util.LazyPlayerSet; +import org.bukkit.craftbukkit.util.Waitable; +import org.bukkit.entity.Player; @@ -50,7 +51,7 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable { private static final Logger LOGGER = LogManager.getLogger(); -@@ -25,7 +68,10 @@ +@@ -25,7 +69,10 @@ private long f; private boolean g; private long h; @@ -62,7 +63,7 @@ private int j; private final IntHashMap k = new IntHashMap(); private double l; -@@ -58,7 +104,34 @@ +@@ -57,7 +104,33 @@ networkmanager.setPacketListener(this); this.player = entityplayer; entityplayer.playerConnection = this; @@ -92,24 +93,23 @@ + public CraftPlayer getPlayer() { + return (this.player == null) ? null : (CraftPlayer) this.player.getBukkitEntity(); } -+ private final static HashSet invalidItems = new HashSet(java.util.Arrays.asList(8, 9, 10, 11, 26, 34, 36, 43, 51, 55, 59, 62, 63, 64, 68, 71, 74, 75, 83, 90, 92, 93, 94, 104, 105, 115, 117, 118, 119, 125, 127, 132, 140, 141, 142, 144)); // TODO: Check after every update. + // CraftBukkit end - public void e() { + public void X_() { this.syncPosition(); -@@ -104,7 +177,7 @@ +@@ -103,7 +176,7 @@ this.minecraftServer.methodProfiler.a("keepAlive"); - long i = this.d(); + long i = SystemUtils.b(); - if (i - this.f >= 15000L) { + if (i - this.f >= 25000L) { // CraftBukkit if (this.g) { this.disconnect(new ChatMessage("disconnect.timeout", new Object[0])); } else { -@@ -116,15 +189,21 @@ +@@ -115,15 +188,21 @@ } - this.minecraftServer.methodProfiler.b(); + this.minecraftServer.methodProfiler.e(); + // CraftBukkit start + for (int spam; (spam = this.chatThrottle) > 0 && !chatSpamField.compareAndSet(this, spam, spam - 1); ) ; + /* Use thread-safe field access instead @@ -123,22 +123,18 @@ --this.j; } - if (this.player.J() > 0L && this.minecraftServer.getIdleTimeout() > 0 && MinecraftServer.aw() - this.player.J() > (long) (this.minecraftServer.getIdleTimeout() * 1000 * 60)) { + if (this.player.F() > 0L && this.minecraftServer.getIdleTimeout() > 0 && SystemUtils.b() - this.player.F() > (long) (this.minecraftServer.getIdleTimeout() * 1000 * 60)) { + this.player.resetIdleTimer(); // CraftBukkit - SPIGOT-854 this.disconnect(new ChatMessage("multiplayer.disconnect.idling", new Object[0])); } -@@ -143,18 +222,48 @@ +@@ -142,16 +221,46 @@ return this.networkManager; } -- public void disconnect(final IChatBaseComponent ichatbasecomponent) { -- this.networkManager.sendPacket(new PacketPlayOutKickDisconnect(ichatbasecomponent), new GenericFutureListener() { -- public void operationComplete(Future future) throws Exception { -- PlayerConnection.this.networkManager.close(ichatbasecomponent); + // CraftBukkit start + @Deprecated -+ public void disconnect(IChatBaseComponent ichatbasecomponent) { + public void disconnect(IChatBaseComponent ichatbasecomponent) { + disconnect(CraftChatMessage.fromComponent(ichatbasecomponent, EnumChatFormat.WHITE)); + } + // CraftBukkit end @@ -163,31 +159,28 @@ + // Send the possibly modified leave message + s = event.getReason(); + // CraftBukkit end -+ final ChatComponentText chatcomponenttext = new ChatComponentText(s); ++ final ChatComponentText ichatbasecomponent = new ChatComponentText(s); + -+ this.networkManager.sendPacket(new PacketPlayOutKickDisconnect(chatcomponenttext), new GenericFutureListener() { -+ public void operationComplete(Future future) throws Exception { // CraftBukkit - decompile error -+ PlayerConnection.this.networkManager.close(chatcomponenttext); - } - }, new GenericFutureListener[0]); -+ this.a(chatcomponenttext); // CraftBukkit - fire quit instantly + this.networkManager.sendPacket(new PacketPlayOutKickDisconnect(ichatbasecomponent), (future) -> { + this.networkManager.close(ichatbasecomponent); + }); ++ this.a(ichatbasecomponent); // CraftBukkit - fire quit instantly this.networkManager.stopReading(); -- Futures.getUnchecked(this.minecraftServer.postToMainThread(new Runnable() { + MinecraftServer minecraftserver = this.minecraftServer; + NetworkManager networkmanager = this.networkManager; + + this.networkManager.getClass(); +- Futures.getUnchecked(minecraftserver.postToMainThread(networkmanager::handleDisconnection)); + // CraftBukkit - Don't wait -+ this.minecraftServer.postToMainThread(new Runnable() { - public void run() { - PlayerConnection.this.networkManager.handleDisconnection(); - } -- })); -+ }); ++ minecraftserver.postToMainThread(networkmanager::handleDisconnection); } public void a(PacketPlayInSteerVehicle packetplayinsteervehicle) { -@@ -193,7 +302,34 @@ +@@ -190,7 +299,34 @@ double d9 = entity.motX * entity.motX + entity.motY * entity.motY + entity.motZ * entity.motZ; double d10 = d6 * d6 + d7 * d7 + d8 * d8; -- if (d10 - d9 > 100.0D && (!this.minecraftServer.R() || !this.minecraftServer.Q().equals(entity.getName()))) { +- if (d10 - d9 > 100.0D && (!this.minecraftServer.J() || !this.minecraftServer.I().equals(entity.getDisplayName().getString()))) { + + // CraftBukkit start - handle custom speeds and skipped ticks + this.allowedPlayerTicks += (System.currentTimeMillis() / 50) - this.lastTick; @@ -206,7 +199,7 @@ + } else { + allowedPlayerTicks = 20; + } -+ float speed; ++ double speed; + if (player.abilities.isFlying) { + speed = player.abilities.flySpeed * 20f; + } else { @@ -214,12 +207,12 @@ + } + speed *= 2f; // TODO: Get the speed of the vehicle instead of the player + -+ if (d10 - d9 > Math.max(100.0D, Math.pow((double) (10.0F * (float) i * speed), 2)) && (!this.minecraftServer.R() || !this.minecraftServer.Q().equals(entity.getName()))) { ++ if (d10 - d9 > Math.max(100.0D, Math.pow((double) (10.0F * (float) i * speed), 2)) && (!this.minecraftServer.J() || !this.minecraftServer.I().equals(entity.getDisplayName().getString()))) { + // CraftBukkit end - PlayerConnection.LOGGER.warn("{} (vehicle of {}) moved too quickly! {},{},{}", entity.getName(), this.player.getName(), Double.valueOf(d6), Double.valueOf(d7), Double.valueOf(d8)); + PlayerConnection.LOGGER.warn("{} (vehicle of {}) moved too quickly! {},{},{}", entity.getDisplayName().getString(), this.player.getDisplayName().getString(), Double.valueOf(d6), Double.valueOf(d7), Double.valueOf(d8)); this.networkManager.sendPacket(new PacketPlayOutVehicleMove(entity)); return; -@@ -231,6 +367,62 @@ +@@ -228,6 +364,62 @@ return; } @@ -281,17 +274,62 @@ + this.minecraftServer.getPlayerList().d(this.player); this.player.checkMovement(this.player.locX - d0, this.player.locY - d1, this.player.locZ - d2); - this.D = d11 >= -0.03125D && !this.minecraftServer.getAllowFlight() && !worldserver.c(entity.getBoundingBox().g(0.0625D).b(0.0D, -0.55D, 0.0D)); -@@ -244,7 +436,7 @@ + this.D = d11 >= -0.03125D && !this.minecraftServer.getAllowFlight() && !worldserver.a(entity.getBoundingBox().g(0.0625D).b(0.0D, -0.55D, 0.0D)); +@@ -241,7 +433,7 @@ public void a(PacketPlayInTeleportAccept packetplayinteleportaccept) { - PlayerConnectionUtils.ensureMainThread(packetplayinteleportaccept, this, this.player.x()); -- if (packetplayinteleportaccept.a() == this.teleportAwait) { -+ if (packetplayinteleportaccept.a() == this.teleportAwait && this.teleportPos != null) { // CraftBukkit + PlayerConnectionUtils.ensureMainThread(packetplayinteleportaccept, this, this.player.getWorldServer()); +- if (packetplayinteleportaccept.b() == this.teleportAwait) { ++ if (packetplayinteleportaccept.b() == this.teleportAwait && this.teleportPos != null) { // CraftBukkit this.player.setLocation(this.teleportPos.x, this.teleportPos.y, this.teleportPos.z, this.player.yaw, this.player.pitch); - if (this.player.L()) { + if (this.player.H()) { this.o = this.teleportPos.x; -@@ -289,7 +481,7 @@ +@@ -287,10 +479,16 @@ + + public void a(PacketPlayInTabComplete packetplayintabcomplete) { + PlayerConnectionUtils.ensureMainThread(packetplayintabcomplete, this, this.player.getWorldServer()); ++ // CraftBukkit start ++ if (chatSpamField.addAndGet(this, 5) > 500 && !this.minecraftServer.getPlayerList().isOp(this.player.getProfile())) { ++ this.disconnect(new ChatMessage("disconnect.spam", new Object[0])); ++ return; ++ } ++ // CraftBukkit end + ParseResults parseresults = this.minecraftServer.getCommandDispatcher().a().parse(packetplayintabcomplete.c(), this.player.getCommandListener()); + + this.minecraftServer.getCommandDispatcher().a().getCompletionSuggestions(parseresults).thenAccept((suggestions) -> { +- this.networkManager.sendPacket(new PacketPlayOutTabComplete(packetplayintabcomplete.b(), suggestions)); ++ this.networkManager.sendPacket(new PacketPlayOutTabComplete(packetplayintabcomplete.b(), (Suggestions) suggestions)); // CraftBukkit - decompile error + }); + } + +@@ -484,6 +682,14 @@ + } + + public void a(PacketPlayInBEdit packetplayinbedit) { ++ // CraftBukkit start ++ PlayerConnectionUtils.ensureMainThread(packetplayinbedit, this, this.player.getWorldServer()); ++ if (this.lastBookTick + 20 > MinecraftServer.currentTick) { ++ this.disconnect("Book edited too quickly!"); ++ return; ++ } ++ this.lastBookTick = MinecraftServer.currentTick; ++ // CraftBukkit end + ItemStack itemstack = packetplayinbedit.b(); + + if (!itemstack.isEmpty()) { +@@ -508,9 +714,10 @@ + } + + itemstack2.a("pages", (NBTBase) nbttaglist); +- this.player.setSlot(EnumItemSlot.MAINHAND, itemstack2); ++ CraftEventFactory.handleEditBookEvent(player, itemstack2); // CraftBukkit + } else { + itemstack1.a("pages", (NBTBase) itemstack.getTag().getList("pages", 8)); ++ CraftEventFactory.handleEditBookEvent(player, itemstack1); // CraftBukkit + } + } + +@@ -550,7 +757,7 @@ } else { WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); @@ -300,7 +338,7 @@ if (this.e == 0) { this.syncPosition(); } -@@ -299,13 +491,21 @@ +@@ -560,13 +767,21 @@ this.A = this.e; this.a(this.teleportPos.x, this.teleportPos.y, this.teleportPos.z, this.player.yaw, this.player.pitch); } @@ -323,7 +361,7 @@ double d0 = this.player.locX; double d1 = this.player.locY; double d2 = this.player.locZ; -@@ -330,15 +530,33 @@ +@@ -591,15 +806,33 @@ ++this.receivedMovePackets; int i = this.receivedMovePackets - this.processedMovePackets; @@ -334,7 +372,7 @@ + this.lastTick = (int) (System.currentTimeMillis() / 50); + + if (i > Math.max(this.allowedPlayerTicks, 5)) { - PlayerConnection.LOGGER.debug("{} is sending move packets too frequently ({} packets since last tick)", this.player.getName(), Integer.valueOf(i)); + PlayerConnection.LOGGER.debug("{} is sending move packets too frequently ({} packets since last tick)", this.player.getDisplayName().getString(), Integer.valueOf(i)); i = 1; } @@ -343,23 +381,23 @@ + } else { + allowedPlayerTicks = 20; + } -+ float speed; ++ double speed; + if (player.abilities.isFlying) { + speed = player.abilities.flySpeed * 20f; + } else { + speed = player.abilities.walkSpeed * 10f; + } + - if (!this.player.L() && (!this.player.x().getGameRules().getBoolean("disableElytraMovementCheck") || !this.player.cP())) { - float f2 = this.player.cP() ? 300.0F : 100.0F; + if (!this.player.H() && (!this.player.getWorldServer().getGameRules().getBoolean("disableElytraMovementCheck") || !this.player.db())) { + float f2 = this.player.db() ? 300.0F : 100.0F; -- if (d11 - d10 > (double) (f2 * (float) i) && (!this.minecraftServer.R() || !this.minecraftServer.Q().equals(this.player.getName()))) { -+ if (d11 - d10 > Math.max(f2, Math.pow((double) (10.0F * (float) i * speed), 2)) && (!this.minecraftServer.R() || !this.minecraftServer.Q().equals(this.player.getName()))) { +- if (d11 - d10 > (double) (f2 * (float) i) && (!this.minecraftServer.J() || !this.minecraftServer.I().equals(this.player.getProfile().getName()))) { ++ if (d11 - d10 > Math.max(f2, Math.pow((double) (10.0F * (float) i * speed), 2)) && (!this.minecraftServer.J() || !this.minecraftServer.I().equals(this.player.getProfile().getName()))) { + // CraftBukkit end - PlayerConnection.LOGGER.warn("{} moved too quickly! {},{},{}", this.player.getName(), Double.valueOf(d7), Double.valueOf(d8), Double.valueOf(d9)); + PlayerConnection.LOGGER.warn("{} moved too quickly! {},{},{}", this.player.getDisplayName().getString(), Double.valueOf(d7), Double.valueOf(d8), Double.valueOf(d9)); this.a(this.player.locX, this.player.locY, this.player.locZ, this.player.yaw, this.player.pitch); return; -@@ -384,6 +602,69 @@ +@@ -645,6 +878,69 @@ } } @@ -428,8 +466,8 @@ + this.B = d12 >= -0.03125D; this.B &= !this.minecraftServer.getAllowFlight() && !this.player.abilities.canFly; - this.B &= !this.player.hasEffect(MobEffects.LEVITATION) && !this.player.cP() && !worldserver.c(this.player.getBoundingBox().g(0.0625D).b(0.0D, -0.55D, 0.0D)); -@@ -401,10 +682,76 @@ + this.B &= !this.player.hasEffect(MobEffects.LEVITATION) && !this.player.db() && !worldserver.a(this.player.getBoundingBox().g(0.0625D).b(0.0D, -0.55D, 0.0D)); +@@ -662,10 +958,76 @@ } public void a(double d0, double d1, double d2, float f, float f1) { @@ -507,8 +545,8 @@ double d3 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.X) ? this.player.locX : 0.0D; double d4 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.Y) ? this.player.locY : 0.0D; double d5 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.Z) ? this.player.locZ : 0.0D; -@@ -421,6 +768,14 @@ - f3 = f1 + this.player.pitch; +@@ -677,6 +1039,14 @@ + this.teleportAwait = 0; } + // CraftBukkit start - update last location @@ -519,35 +557,45 @@ + this.lastPitch = f3; + // CraftBukkit end + - if (++this.teleportAwait == Integer.MAX_VALUE) { - this.teleportAwait = 0; - } -@@ -432,6 +787,7 @@ + this.A = this.e; + this.player.setLocation(d0, d1, d2, f, f1); + this.player.playerConnection.sendPacket(new PacketPlayOutPosition(d0 - d3, d1 - d4, d2 - d5, f - f2, f1 - f3, set, this.teleportAwait)); +@@ -684,6 +1054,7 @@ public void a(PacketPlayInBlockDig packetplayinblockdig) { - PlayerConnectionUtils.ensureMainThread(packetplayinblockdig, this, this.player.x()); + PlayerConnectionUtils.ensureMainThread(packetplayinblockdig, this, this.player.getWorldServer()); + if (this.player.isFrozen()) return; // CraftBukkit WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); - BlockPosition blockposition = packetplayinblockdig.a(); + BlockPosition blockposition = packetplayinblockdig.b(); -@@ -441,7 +797,15 @@ +@@ -693,14 +1064,46 @@ if (!this.player.isSpectator()) { ItemStack itemstack = this.player.b(EnumHand.OFF_HAND); - this.player.a(EnumHand.OFF_HAND, this.player.b(EnumHand.MAIN_HAND)); -+ // CraftBukkit start -+ PlayerSwapHandItemsEvent swapItemsEvent = new PlayerSwapHandItemsEvent(getPlayer(), CraftItemStack.asBukkitCopy(itemstack), CraftItemStack.asBukkitCopy(this.player.b(EnumHand.MAIN_HAND))); +- this.player.a(EnumHand.MAIN_HAND, itemstack); ++ // CraftBukkit start - inspiration taken from DispenserRegistry (See SpigotCraft#394) ++ CraftItemStack mainHand = CraftItemStack.asCraftMirror(itemstack); ++ CraftItemStack offHand = CraftItemStack.asCraftMirror(this.player.b(EnumHand.MAIN_HAND)); ++ PlayerSwapHandItemsEvent swapItemsEvent = new PlayerSwapHandItemsEvent(getPlayer(), mainHand.clone(), offHand.clone()); + this.server.getPluginManager().callEvent(swapItemsEvent); + if (swapItemsEvent.isCancelled()) { + return; + } -+ itemstack = CraftItemStack.asNMSCopy(swapItemsEvent.getMainHandItem()); -+ this.player.a(EnumHand.OFF_HAND, CraftItemStack.asNMSCopy(swapItemsEvent.getOffHandItem())); ++ if (swapItemsEvent.getOffHandItem().equals(offHand)) { ++ this.player.a(EnumHand.OFF_HAND, this.player.b(EnumHand.MAIN_HAND)); ++ } else { ++ this.player.a(EnumHand.OFF_HAND, CraftItemStack.asNMSCopy(swapItemsEvent.getOffHandItem())); ++ } ++ if (swapItemsEvent.getMainHandItem().equals(mainHand)) { ++ this.player.a(EnumHand.MAIN_HAND, itemstack); ++ } else { ++ this.player.a(EnumHand.MAIN_HAND, CraftItemStack.asNMSCopy(swapItemsEvent.getMainHandItem())); ++ } + // CraftBukkit end - this.player.a(EnumHand.MAIN_HAND, itemstack); } -@@ -449,6 +813,21 @@ + return; case DROP_ITEM: if (!this.player.isSpectator()) { @@ -569,12 +617,12 @@ this.player.a(false); } -@@ -482,7 +861,15 @@ +@@ -734,7 +1137,15 @@ if (!this.minecraftServer.a(worldserver, blockposition, this.player) && worldserver.getWorldBorder().a(blockposition)) { - this.player.playerInteractManager.a(blockposition, packetplayinblockdig.b()); + this.player.playerInteractManager.a(blockposition, packetplayinblockdig.c()); } else { + // CraftBukkit start - fire PlayerInteractEvent -+ CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, blockposition, packetplayinblockdig.b(), this.player.inventory.getItemInHand(), EnumHand.MAIN_HAND); ++ CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, blockposition, packetplayinblockdig.c(), this.player.inventory.getItemInHand(), EnumHand.MAIN_HAND); this.player.playerConnection.sendPacket(new PacketPlayOutBlockChange(worldserver, blockposition)); + // Update any tile entity data for this block + TileEntity tileentity = worldserver.getTileEntity(blockposition); @@ -584,8 +632,8 @@ + // CraftBukkit end } } else { - if (packetplayinblockdig.c() == PacketPlayInBlockDig.EnumPlayerDigType.STOP_DESTROY_BLOCK) { -@@ -502,10 +889,12 @@ + if (packetplayinblockdig.d() == PacketPlayInBlockDig.EnumPlayerDigType.STOP_DESTROY_BLOCK) { +@@ -754,10 +1165,12 @@ default: throw new IllegalArgumentException("Invalid player action"); } @@ -593,14 +641,14 @@ } public void a(PacketPlayInUseItem packetplayinuseitem) { - PlayerConnectionUtils.ensureMainThread(packetplayinuseitem, this, this.player.x()); + PlayerConnectionUtils.ensureMainThread(packetplayinuseitem, this, this.player.getWorldServer()); + if (this.player.isFrozen()) return; // CraftBukkit WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); - EnumHand enumhand = packetplayinuseitem.c(); + EnumHand enumhand = packetplayinuseitem.d(); ItemStack itemstack = this.player.b(enumhand); -@@ -519,6 +908,13 @@ - chatmessage.getChatModifier().setColor(EnumChatFormat.RED); - this.player.playerConnection.sendPacket(new PacketPlayOutChat(chatmessage, ChatMessageType.GAME_INFO)); +@@ -770,6 +1183,13 @@ + + this.player.playerConnection.sendPacket(new PacketPlayOutChat(ichatbasecomponent, ChatMessageType.GAME_INFO)); } else if (this.teleportPos == null && this.player.d((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) < 64.0D && !this.minecraftServer.a(worldserver, blockposition, this.player) && worldserver.getWorldBorder().a(blockposition)) { + // CraftBukkit start - Check if we can actually do something over this large a distance + Location eyeLoc = this.getPlayer().getEyeLocation(); @@ -609,16 +657,16 @@ + return; + } + // CraftBukkit end - this.player.playerInteractManager.a(this.player, worldserver, itemstack, enumhand, blockposition, enumdirection, packetplayinuseitem.d(), packetplayinuseitem.e(), packetplayinuseitem.f()); + this.player.playerInteractManager.a(this.player, worldserver, itemstack, enumhand, blockposition, enumdirection, packetplayinuseitem.e(), packetplayinuseitem.f(), packetplayinuseitem.g()); } -@@ -528,13 +924,52 @@ +@@ -779,13 +1199,52 @@ public void a(PacketPlayInBlockPlace packetplayinblockplace) { - PlayerConnectionUtils.ensureMainThread(packetplayinblockplace, this, this.player.x()); + PlayerConnectionUtils.ensureMainThread(packetplayinblockplace, this, this.player.getWorldServer()); + if (this.player.isFrozen()) return; // CraftBukkit WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); - EnumHand enumhand = packetplayinblockplace.a(); + EnumHand enumhand = packetplayinblockplace.b(); ItemStack itemstack = this.player.b(enumhand); this.player.resetIdleTimer(); @@ -641,7 +689,7 @@ + float f8 = f3 * f5; + double d3 = player.playerInteractManager.getGameMode()== EnumGamemode.CREATIVE ? 5.0D : 4.5D; + Vec3D vec3d1 = vec3d.add((double) f7 * d3, (double) f6 * d3, (double) f8 * d3); -+ MovingObjectPosition movingobjectposition = this.player.world.rayTrace(vec3d, vec3d1, false); ++ MovingObjectPosition movingobjectposition = this.player.world.rayTrace(vec3d, vec3d1); + + boolean cancelled; + if (movingobjectposition == null || movingobjectposition.type != MovingObjectPosition.EnumMovingObjectType.BLOCK) { @@ -666,7 +714,7 @@ } } -@@ -545,8 +980,8 @@ +@@ -796,8 +1255,8 @@ WorldServer[] aworldserver = this.minecraftServer.worldServer; int i = aworldserver.length; @@ -677,38 +725,16 @@ if (worldserver != null) { entity = packetplayinspectate.a(worldserver); -@@ -559,6 +994,8 @@ +@@ -808,7 +1267,7 @@ + } + if (entity != null) { - this.player.setSpectatorTarget(this.player); - this.player.stopRiding(); -+ -+ /* CraftBukkit start - replace with bukkit handling for multi-world - if (entity.world == this.player.world) { - this.player.enderTeleportTo(entity.locX, entity.locY, entity.locZ); - } else { -@@ -584,12 +1021,20 @@ - this.minecraftServer.getPlayerList().b(this.player, worldserver2); - this.minecraftServer.getPlayerList().updateClient(this.player); - } -+ */ -+ this.player.getBukkitEntity().teleport(entity.getBukkitEntity(), PlayerTeleportEvent.TeleportCause.SPECTATE); -+ // CraftBukkit end +- this.player.a((WorldServer) entity.world, entity.locX, entity.locY, entity.locZ, entity.yaw, entity.pitch); ++ this.player.a((WorldServer) entity.world, entity.locX, entity.locY, entity.locZ, entity.yaw, entity.pitch, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.SPECTATE); // CraftBukkit } } - } - -- public void a(PacketPlayInResourcePackStatus packetplayinresourcepackstatus) {} -+ // CraftBukkit start -+ public void a(PacketPlayInResourcePackStatus packetplayinresourcepackstatus) { -+ PlayerConnectionUtils.ensureMainThread(packetplayinresourcepackstatus, this, this.player.x()); -+ this.server.getPluginManager().callEvent(new PlayerResourcePackStatusEvent(getPlayer(), PlayerResourcePackStatusEvent.Status.values()[packetplayinresourcepackstatus.status.ordinal()])); -+ } -+ // CraftBukkit end - - public void a(PacketPlayInBoatMove packetplayinboatmove) { - PlayerConnectionUtils.ensureMainThread(packetplayinboatmove, this, this.player.x()); -@@ -602,14 +1047,29 @@ +@@ -827,11 +1286,26 @@ } public void a(IChatBaseComponent ichatbasecomponent) { @@ -719,27 +745,24 @@ + this.processedDisconnect = true; + } + // CraftBukkit end - PlayerConnection.LOGGER.info("{} lost connection: {}", this.player.getName(), ichatbasecomponent.toPlainText()); + PlayerConnection.LOGGER.info("{} lost connection: {}", this.player.getDisplayName().getString(), ichatbasecomponent.getString()); + // CraftBukkit start - Replace vanilla quit message handling with our own. + /* - this.minecraftServer.aD(); - ChatMessage chatmessage = new ChatMessage("multiplayer.player.left", new Object[] { this.player.getScoreboardDisplayName()}); - - chatmessage.getChatModifier().setColor(EnumChatFormat.YELLOW); - this.minecraftServer.getPlayerList().sendMessage(chatmessage); + this.minecraftServer.av(); + this.minecraftServer.getPlayerList().sendMessage((new ChatMessage("multiplayer.player.left", new Object[] { this.player.getScoreboardDisplayName()})).a(EnumChatFormat.YELLOW)); + */ + - this.player.s(); + this.player.n(); - this.minecraftServer.getPlayerList().disconnect(this.player); + String quitMessage = this.minecraftServer.getPlayerList().disconnect(this.player); + if ((quitMessage != null) && (quitMessage.length() > 0)) { + this.minecraftServer.getPlayerList().sendMessage(CraftChatMessage.fromString(quitMessage)); + } + // CraftBukkit end - if (this.minecraftServer.R() && this.player.getName().equals(this.minecraftServer.Q())) { + if (this.minecraftServer.J() && this.player.getDisplayName().getString().equals(this.minecraftServer.I())) { PlayerConnection.LOGGER.info("Stopping singleplayer server as player logged out"); this.minecraftServer.safeShutdown(); -@@ -631,6 +1091,15 @@ +@@ -857,6 +1331,15 @@ } } @@ -753,15 +776,15 @@ + // CraftBukkit end + try { - this.networkManager.sendPacket(packet); + this.networkManager.sendPacket(packet, genericfuturelistener); } catch (Throwable throwable) { -@@ -652,17 +1121,37 @@ +@@ -872,17 +1355,37 @@ public void a(PacketPlayInHeldItemSlot packetplayinhelditemslot) { - PlayerConnectionUtils.ensureMainThread(packetplayinhelditemslot, this, this.player.x()); + PlayerConnectionUtils.ensureMainThread(packetplayinhelditemslot, this, this.player.getWorldServer()); + if (this.player.isFrozen()) return; // CraftBukkit - if (packetplayinhelditemslot.a() >= 0 && packetplayinhelditemslot.a() < PlayerInventory.getHotbarSize()) { -+ PlayerItemHeldEvent event = new PlayerItemHeldEvent(this.getPlayer(), this.player.inventory.itemInHandIndex, packetplayinhelditemslot.a()); + if (packetplayinhelditemslot.b() >= 0 && packetplayinhelditemslot.b() < PlayerInventory.getHotbarSize()) { ++ PlayerItemHeldEvent event = new PlayerItemHeldEvent(this.getPlayer(), this.player.inventory.itemInHandIndex, packetplayinhelditemslot.b()); + this.server.getPluginManager().callEvent(event); + if (event.isCancelled()) { + this.sendPacket(new PacketPlayOutHeldItemSlot(this.player.inventory.itemInHandIndex)); @@ -769,16 +792,16 @@ + return; + } + // CraftBukkit end - this.player.inventory.itemInHandIndex = packetplayinhelditemslot.a(); + this.player.inventory.itemInHandIndex = packetplayinhelditemslot.b(); this.player.resetIdleTimer(); } else { - PlayerConnection.LOGGER.warn("{} tried to set an invalid carried item", this.player.getName()); + PlayerConnection.LOGGER.warn("{} tried to set an invalid carried item", this.player.getDisplayName().getString()); + this.disconnect("Nope!"); // CraftBukkit } } public void a(PacketPlayInChat packetplayinchat) { -- PlayerConnectionUtils.ensureMainThread(packetplayinchat, this, this.player.x()); +- PlayerConnectionUtils.ensureMainThread(packetplayinchat, this, this.player.getWorldServer()); - if (this.player.getChatFlags() == EntityHuman.EnumChatVisibility.HIDDEN) { + // CraftBukkit start - async chat + // SPIGOT-3638 @@ -786,16 +809,16 @@ + return; + } + -+ boolean isSync = packetplayinchat.a().startsWith("/"); -+ if (packetplayinchat.a().startsWith("/")) { -+ PlayerConnectionUtils.ensureMainThread(packetplayinchat, this, this.player.x()); ++ boolean isSync = packetplayinchat.b().startsWith("/"); ++ if (packetplayinchat.b().startsWith("/")) { ++ PlayerConnectionUtils.ensureMainThread(packetplayinchat, this, this.player.getWorldServer()); + } + // CraftBukkit end + if (this.player.dead || this.player.getChatFlags() == EntityHuman.EnumChatVisibility.HIDDEN) { // CraftBukkit - dead men tell no tales - ChatMessage chatmessage = new ChatMessage("chat.cannotSend", new Object[0]); - - chatmessage.getChatModifier().setColor(EnumChatFormat.RED); -@@ -675,39 +1164,249 @@ + this.sendPacket(new PacketPlayOutChat((new ChatMessage("chat.cannotSend", new Object[0])).a(EnumChatFormat.RED))); + } else { + this.player.resetIdleTimer(); +@@ -892,39 +1395,249 @@ for (int i = 0; i < s.length(); ++i) { if (!SharedConstants.isAllowedChatCharacter(s.charAt(i))) { @@ -850,9 +873,9 @@ + this.chat(s, true); + // CraftBukkit end - the below is for reference. :) } else { - ChatMessage chatmessage1 = new ChatMessage("chat.type.text", new Object[] { this.player.getScoreboardDisplayName(), s}); + ChatMessage chatmessage = new ChatMessage("chat.type.text", new Object[] { this.player.getScoreboardDisplayName(), s}); - this.minecraftServer.getPlayerList().sendMessage(chatmessage1, false); + this.minecraftServer.getPlayerList().sendMessage(chatmessage, false); } - this.chatThrottle += 20; @@ -963,8 +986,8 @@ + // CraftBukkit end + private void handleCommand(String s) { -- this.minecraftServer.getCommandHandler().a(this.player, s); -+ // CraftBukkit start - whole method +- this.minecraftServer.getCommandDispatcher().a(this.player.getCommandListener(), s); ++ // CraftBukkit start - whole method + this.LOGGER.info(this.player.getName() + " issued server command: " + s); + + CraftPlayer player = this.getPlayer(); @@ -985,12 +1008,12 @@ + java.util.logging.Logger.getLogger(PlayerConnection.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + return; + } -+ // this.minecraftServer.getCommandHandler().a(this.player, s); ++ // this.minecraftServer.getCommandDispatcher().a(this.player.getCommandListener(), s); + // CraftBukkit end } public void a(PacketPlayInArmAnimation packetplayinarmanimation) { - PlayerConnectionUtils.ensureMainThread(packetplayinarmanimation, this, this.player.x()); + PlayerConnectionUtils.ensureMainThread(packetplayinarmanimation, this, this.player.getWorldServer()); + if (this.player.isFrozen()) return; // CraftBukkit this.player.resetIdleTimer(); + // CraftBukkit start - Raytrace to look for 'rogue armswings' @@ -1009,7 +1032,7 @@ + float f8 = f3 * f5; + double d3 = player.playerInteractManager.getGameMode()== EnumGamemode.CREATIVE ? 5.0D : 4.5D; + Vec3D vec3d1 = vec3d.add((double) f7 * d3, (double) f6 * d3, (double) f8 * d3); -+ MovingObjectPosition movingobjectposition = this.player.world.rayTrace(vec3d, vec3d1, false); ++ MovingObjectPosition movingobjectposition = this.player.world.rayTrace(vec3d, vec3d1); + + if (movingobjectposition == null || movingobjectposition.type != MovingObjectPosition.EnumMovingObjectType.BLOCK) { + CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_AIR, this.player.inventory.getItemInHand(), EnumHand.MAIN_HAND); @@ -1021,17 +1044,17 @@ + + if (event.isCancelled()) return; + // CraftBukkit end - this.player.a(packetplayinarmanimation.a()); + this.player.a(packetplayinarmanimation.b()); } public void a(PacketPlayInEntityAction packetplayinentityaction) { - PlayerConnectionUtils.ensureMainThread(packetplayinentityaction, this, this.player.x()); + PlayerConnectionUtils.ensureMainThread(packetplayinentityaction, this, this.player.getWorldServer()); + // CraftBukkit start + if (this.player.dead) return; -+ switch (packetplayinentityaction.b()) { ++ switch (packetplayinentityaction.c()) { + case START_SNEAKING: + case STOP_SNEAKING: -+ PlayerToggleSneakEvent event = new PlayerToggleSneakEvent(this.getPlayer(), packetplayinentityaction.b() == PacketPlayInEntityAction.EnumPlayerAction.START_SNEAKING); ++ PlayerToggleSneakEvent event = new PlayerToggleSneakEvent(this.getPlayer(), packetplayinentityaction.c() == PacketPlayInEntityAction.EnumPlayerAction.START_SNEAKING); + this.server.getPluginManager().callEvent(event); + + if (event.isCancelled()) { @@ -1040,7 +1063,7 @@ + break; + case START_SPRINTING: + case STOP_SPRINTING: -+ PlayerToggleSprintEvent e2 = new PlayerToggleSprintEvent(this.getPlayer(), packetplayinentityaction.b() == PacketPlayInEntityAction.EnumPlayerAction.START_SPRINTING); ++ PlayerToggleSprintEvent e2 = new PlayerToggleSprintEvent(this.getPlayer(), packetplayinentityaction.c() == PacketPlayInEntityAction.EnumPlayerAction.START_SPRINTING); + this.server.getPluginManager().callEvent(e2); + + if (e2.isCancelled()) { @@ -1052,31 +1075,31 @@ this.player.resetIdleTimer(); IJumpable ijumpable; -@@ -779,6 +1478,7 @@ +@@ -996,6 +1709,7 @@ public void a(PacketPlayInUseEntity packetplayinuseentity) { - PlayerConnectionUtils.ensureMainThread(packetplayinuseentity, this, this.player.x()); + PlayerConnectionUtils.ensureMainThread(packetplayinuseentity, this, this.player.getWorldServer()); + if (this.player.isFrozen()) return; // CraftBukkit WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); Entity entity = packetplayinuseentity.a((World) worldserver); -@@ -794,20 +1494,68 @@ +@@ -1011,20 +1725,68 @@ if (this.player.h(entity) < d0) { EnumHand enumhand; -+ ItemStack itemInHand = this.player.b(packetplayinuseentity.b() == null ? EnumHand.MAIN_HAND : packetplayinuseentity.b()); // CraftBukkit ++ ItemStack itemInHand = this.player.b(packetplayinuseentity.c() == null ? EnumHand.MAIN_HAND : packetplayinuseentity.c()); // CraftBukkit + -+ if (packetplayinuseentity.a() == PacketPlayInUseEntity.EnumEntityUseAction.INTERACT -+ || packetplayinuseentity.a() == PacketPlayInUseEntity.EnumEntityUseAction.INTERACT_AT) { ++ if (packetplayinuseentity.b() == PacketPlayInUseEntity.EnumEntityUseAction.INTERACT ++ || packetplayinuseentity.b() == PacketPlayInUseEntity.EnumEntityUseAction.INTERACT_AT) { + // CraftBukkit start + boolean triggerLeashUpdate = itemInHand != null && itemInHand.getItem() == Items.LEAD && entity instanceof EntityInsentient; + Item origItem = this.player.inventory.getItemInHand() == null ? null : this.player.inventory.getItemInHand().getItem(); + PlayerInteractEntityEvent event; -+ if (packetplayinuseentity.a() == PacketPlayInUseEntity.EnumEntityUseAction.INTERACT) { -+ event = new PlayerInteractEntityEvent((Player) this.getPlayer(), entity.getBukkitEntity(), (packetplayinuseentity.b() == EnumHand.OFF_HAND) ? EquipmentSlot.OFF_HAND : EquipmentSlot.HAND); ++ if (packetplayinuseentity.b() == PacketPlayInUseEntity.EnumEntityUseAction.INTERACT) { ++ event = new PlayerInteractEntityEvent((Player) this.getPlayer(), entity.getBukkitEntity(), (packetplayinuseentity.c() == EnumHand.OFF_HAND) ? EquipmentSlot.OFF_HAND : EquipmentSlot.HAND); + } else { -+ Vec3D target = packetplayinuseentity.c(); -+ event = new PlayerInteractAtEntityEvent((Player) this.getPlayer(), entity.getBukkitEntity(), new org.bukkit.util.Vector(target.x, target.y, target.z), (packetplayinuseentity.b() == EnumHand.OFF_HAND) ? EquipmentSlot.OFF_HAND : EquipmentSlot.HAND); ++ Vec3D target = packetplayinuseentity.d(); ++ event = new PlayerInteractAtEntityEvent((Player) this.getPlayer(), entity.getBukkitEntity(), new org.bukkit.util.Vector(target.x, target.y, target.z), (packetplayinuseentity.c() == EnumHand.OFF_HAND) ? EquipmentSlot.OFF_HAND : EquipmentSlot.HAND); + } + this.server.getPluginManager().callEvent(event); + @@ -1096,27 +1119,27 @@ + // CraftBukkit end + } + - if (packetplayinuseentity.a() == PacketPlayInUseEntity.EnumEntityUseAction.INTERACT) { - enumhand = packetplayinuseentity.b(); + if (packetplayinuseentity.b() == PacketPlayInUseEntity.EnumEntityUseAction.INTERACT) { + enumhand = packetplayinuseentity.c(); this.player.a(entity, enumhand); + // CraftBukkit start + if (!itemInHand.isEmpty() && itemInHand.getCount() <= -1) { + this.player.updateInventory(this.player.activeContainer); + } + // CraftBukkit end - } else if (packetplayinuseentity.a() == PacketPlayInUseEntity.EnumEntityUseAction.INTERACT_AT) { - enumhand = packetplayinuseentity.b(); - entity.a(this.player, packetplayinuseentity.c(), enumhand); + } else if (packetplayinuseentity.b() == PacketPlayInUseEntity.EnumEntityUseAction.INTERACT_AT) { + enumhand = packetplayinuseentity.c(); + entity.a(this.player, packetplayinuseentity.d(), enumhand); + // CraftBukkit start + if (!itemInHand.isEmpty() && itemInHand.getCount() <= -1) { + this.player.updateInventory(this.player.activeContainer); + } + // CraftBukkit end - } else if (packetplayinuseentity.a() == PacketPlayInUseEntity.EnumEntityUseAction.ATTACK) { + } else if (packetplayinuseentity.b() == PacketPlayInUseEntity.EnumEntityUseAction.ATTACK) { - if (entity instanceof EntityItem || entity instanceof EntityExperienceOrb || entity instanceof EntityArrow || entity == this.player) { + if (entity instanceof EntityItem || entity instanceof EntityExperienceOrb || entity instanceof EntityArrow || (entity == this.player && !player.isSpectator())) { // CraftBukkit this.disconnect(new ChatMessage("multiplayer.disconnect.invalid_entity_attacked", new Object[0])); - this.minecraftServer.warning("Player " + this.player.getName() + " tried to attack an invalid entity"); + this.minecraftServer.warning("Player " + this.player.getDisplayName().getString() + " tried to attack an invalid entity"); return; } @@ -1130,49 +1153,49 @@ } } } -@@ -823,7 +1571,8 @@ +@@ -1040,7 +1802,8 @@ case PERFORM_RESPAWN: if (this.player.viewingCredits) { this.player.viewingCredits = false; - this.player = this.minecraftServer.getPlayerList().moveToWorld(this.player, 0, true); + // this.player = this.minecraftServer.getPlayerList().moveToWorld(this.player, 0, true); + this.minecraftServer.getPlayerList().changeDimension(this.player, 0, PlayerTeleportEvent.TeleportCause.END_PORTAL); // CraftBukkit - reroute logic through custom portal management - CriterionTriggers.u.a(this.player, DimensionManager.THE_END, DimensionManager.OVERWORLD); + CriterionTriggers.v.a(this.player, DimensionManager.THE_END, DimensionManager.OVERWORLD); } else { if (this.player.getHealth() > 0.0F) { -@@ -846,14 +1595,20 @@ +@@ -1063,14 +1826,20 @@ public void a(PacketPlayInCloseWindow packetplayinclosewindow) { - PlayerConnectionUtils.ensureMainThread(packetplayinclosewindow, this, this.player.x()); + PlayerConnectionUtils.ensureMainThread(packetplayinclosewindow, this, this.player.getWorldServer()); + + if (this.player.isFrozen()) return; // CraftBukkit + CraftEventFactory.handleInventoryCloseEvent(this.player); // CraftBukkit + - this.player.r(); + this.player.m(); } public void a(PacketPlayInWindowClick packetplayinwindowclick) { - PlayerConnectionUtils.ensureMainThread(packetplayinwindowclick, this, this.player.x()); + PlayerConnectionUtils.ensureMainThread(packetplayinwindowclick, this, this.player.getWorldServer()); + if (this.player.isFrozen()) return; // CraftBukkit this.player.resetIdleTimer(); -- if (this.player.activeContainer.windowId == packetplayinwindowclick.a() && this.player.activeContainer.c(this.player)) { +- if (this.player.activeContainer.windowId == packetplayinwindowclick.b() && this.player.activeContainer.c(this.player)) { - if (this.player.isSpectator()) { -+ if (this.player.activeContainer.windowId == packetplayinwindowclick.a() && this.player.activeContainer.c(this.player) && this.player.activeContainer.canUse(this.player)) { // CraftBukkit ++ if (this.player.activeContainer.windowId == packetplayinwindowclick.b() && this.player.activeContainer.c(this.player) && this.player.activeContainer.canUse(this.player)) { // CraftBukkit + boolean cancelled = this.player.isSpectator(); // CraftBukkit - see below if + if (false/*this.player.isSpectator()*/) { // CraftBukkit NonNullList nonnulllist = NonNullList.a(); for (int i = 0; i < this.player.activeContainer.slots.size(); ++i) { -@@ -862,8 +1617,274 @@ +@@ -1079,8 +1848,274 @@ this.player.a(this.player.activeContainer, nonnulllist); } else { -- ItemStack itemstack = this.player.activeContainer.a(packetplayinwindowclick.b(), packetplayinwindowclick.c(), packetplayinwindowclick.f(), this.player); +- ItemStack itemstack = this.player.activeContainer.a(packetplayinwindowclick.c(), packetplayinwindowclick.d(), packetplayinwindowclick.g(), this.player); + // CraftBukkit start - Call InventoryClickEvent -+ if (packetplayinwindowclick.b() < -1 && packetplayinwindowclick.b() != -999) { ++ if (packetplayinwindowclick.c() < -1 && packetplayinwindowclick.c() != -999) { + return; + } -+ + + InventoryView inventory = this.player.activeContainer.getBukkitView(); + SlotType type = CraftInventoryView.getSlotType(inventory, packetplayinwindowclick.b()); + @@ -1182,36 +1205,36 @@ + + ItemStack itemstack = ItemStack.a; + -+ switch (packetplayinwindowclick.f()) { ++ switch (packetplayinwindowclick.g()) { + case PICKUP: -+ if (packetplayinwindowclick.c() == 0) { ++ if (packetplayinwindowclick.d() == 0) { + click = ClickType.LEFT; -+ } else if (packetplayinwindowclick.c() == 1) { ++ } else if (packetplayinwindowclick.d() == 1) { + click = ClickType.RIGHT; + } -+ if (packetplayinwindowclick.c() == 0 || packetplayinwindowclick.c() == 1) { ++ if (packetplayinwindowclick.d() == 0 || packetplayinwindowclick.d() == 1) { + action = InventoryAction.NOTHING; // Don't want to repeat ourselves -+ if (packetplayinwindowclick.b() == -999) { ++ if (packetplayinwindowclick.c() == -999) { + if (!player.inventory.getCarried().isEmpty()) { -+ action = packetplayinwindowclick.c() == 0 ? InventoryAction.DROP_ALL_CURSOR : InventoryAction.DROP_ONE_CURSOR; ++ action = packetplayinwindowclick.d() == 0 ? InventoryAction.DROP_ALL_CURSOR : InventoryAction.DROP_ONE_CURSOR; + } -+ } else if (packetplayinwindowclick.b() < 0) { ++ } else if (packetplayinwindowclick.c() < 0) { + action = InventoryAction.NOTHING; + } else { -+ Slot slot = this.player.activeContainer.getSlot(packetplayinwindowclick.b()); ++ Slot slot = this.player.activeContainer.getSlot(packetplayinwindowclick.c()); + if (slot != null) { + ItemStack clickedItem = slot.getItem(); + ItemStack cursor = player.inventory.getCarried(); + if (clickedItem.isEmpty()) { + if (!cursor.isEmpty()) { -+ action = packetplayinwindowclick.c() == 0 ? InventoryAction.PLACE_ALL : InventoryAction.PLACE_ONE; ++ action = packetplayinwindowclick.d() == 0 ? InventoryAction.PLACE_ALL : InventoryAction.PLACE_ONE; + } + } else if (slot.isAllowed(player)) { + if (cursor.isEmpty()) { -+ action = packetplayinwindowclick.c() == 0 ? InventoryAction.PICKUP_ALL : InventoryAction.PICKUP_HALF; ++ action = packetplayinwindowclick.d() == 0 ? InventoryAction.PICKUP_ALL : InventoryAction.PICKUP_HALF; + } else if (slot.isAllowed(cursor)) { + if (clickedItem.doMaterialsMatch(cursor) && ItemStack.equals(clickedItem, cursor)) { -+ int toPlace = packetplayinwindowclick.c() == 0 ? cursor.getCount() : 1; ++ int toPlace = packetplayinwindowclick.d() == 0 ? cursor.getCount() : 1; + toPlace = Math.min(toPlace, clickedItem.getMaxStackSize() - clickedItem.getCount()); + toPlace = Math.min(toPlace, slot.inventory.getMaxStackSize() - clickedItem.getCount()); + if (toPlace == 1) { @@ -1226,7 +1249,7 @@ + } else if (cursor.getCount() <= slot.getMaxStackSize()) { + action = InventoryAction.SWAP_WITH_CURSOR; + } -+ } else if (cursor.getItem() == clickedItem.getItem() && (!cursor.usesData() || cursor.getData() == clickedItem.getData()) && ItemStack.equals(cursor, clickedItem)) { ++ } else if (cursor.getItem() == clickedItem.getItem() && ItemStack.equals(cursor, clickedItem)) { + if (clickedItem.getCount() >= 0) { + if (clickedItem.getCount() + cursor.getCount() <= cursor.getMaxStackSize()) { + // As of 1.5, this is result slots only @@ -1241,16 +1264,16 @@ + break; + // TODO check on updates + case QUICK_MOVE: -+ if (packetplayinwindowclick.c() == 0) { ++ if (packetplayinwindowclick.d() == 0) { + click = ClickType.SHIFT_LEFT; -+ } else if (packetplayinwindowclick.c() == 1) { ++ } else if (packetplayinwindowclick.d() == 1) { + click = ClickType.SHIFT_RIGHT; + } -+ if (packetplayinwindowclick.c() == 0 || packetplayinwindowclick.c() == 1) { -+ if (packetplayinwindowclick.b() < 0) { ++ if (packetplayinwindowclick.d() == 0 || packetplayinwindowclick.d() == 1) { ++ if (packetplayinwindowclick.c() < 0) { + action = InventoryAction.NOTHING; + } else { -+ Slot slot = this.player.activeContainer.getSlot(packetplayinwindowclick.b()); ++ Slot slot = this.player.activeContainer.getSlot(packetplayinwindowclick.c()); + if (slot != null && slot.isAllowed(this.player) && slot.hasItem()) { + action = InventoryAction.MOVE_TO_OTHER_INVENTORY; + } else { @@ -1260,11 +1283,11 @@ + } + break; + case SWAP: -+ if (packetplayinwindowclick.c() >= 0 && packetplayinwindowclick.c() < 9) { ++ if (packetplayinwindowclick.d() >= 0 && packetplayinwindowclick.d() < 9) { + click = ClickType.NUMBER_KEY; -+ Slot clickedSlot = this.player.activeContainer.getSlot(packetplayinwindowclick.b()); ++ Slot clickedSlot = this.player.activeContainer.getSlot(packetplayinwindowclick.c()); + if (clickedSlot.isAllowed(player)) { -+ ItemStack hotbar = this.player.inventory.getItem(packetplayinwindowclick.c()); ++ ItemStack hotbar = this.player.inventory.getItem(packetplayinwindowclick.d()); + boolean canCleanSwap = hotbar.isEmpty() || (clickedSlot.inventory == player.inventory && clickedSlot.isAllowed(hotbar)); // the slot will accept the hotbar item + if (clickedSlot.hasItem()) { + if (canCleanSwap) { @@ -1283,12 +1306,12 @@ + } + break; + case CLONE: -+ if (packetplayinwindowclick.c() == 2) { ++ if (packetplayinwindowclick.d() == 2) { + click = ClickType.MIDDLE; -+ if (packetplayinwindowclick.b() == -999) { ++ if (packetplayinwindowclick.c() == -999) { + action = InventoryAction.NOTHING; + } else { -+ Slot slot = this.player.activeContainer.getSlot(packetplayinwindowclick.b()); ++ Slot slot = this.player.activeContainer.getSlot(packetplayinwindowclick.c()); + if (slot != null && slot.hasItem() && player.abilities.canInstantlyBuild && player.inventory.getCarried().isEmpty()) { + action = InventoryAction.CLONE_STACK; + } else { @@ -1301,18 +1324,18 @@ + } + break; + case THROW: -+ if (packetplayinwindowclick.b() >= 0) { -+ if (packetplayinwindowclick.c() == 0) { ++ if (packetplayinwindowclick.c() >= 0) { ++ if (packetplayinwindowclick.d() == 0) { + click = ClickType.DROP; -+ Slot slot = this.player.activeContainer.getSlot(packetplayinwindowclick.b()); ++ Slot slot = this.player.activeContainer.getSlot(packetplayinwindowclick.c()); + if (slot != null && slot.hasItem() && slot.isAllowed(player) && !slot.getItem().isEmpty() && slot.getItem().getItem() != Item.getItemOf(Blocks.AIR)) { + action = InventoryAction.DROP_ONE_SLOT; + } else { + action = InventoryAction.NOTHING; + } -+ } else if (packetplayinwindowclick.c() == 1) { ++ } else if (packetplayinwindowclick.d() == 1) { + click = ClickType.CONTROL_DROP; -+ Slot slot = this.player.activeContainer.getSlot(packetplayinwindowclick.b()); ++ Slot slot = this.player.activeContainer.getSlot(packetplayinwindowclick.c()); + if (slot != null && slot.hasItem() && slot.isAllowed(player) && !slot.getItem().isEmpty() && slot.getItem().getItem() != Item.getItemOf(Blocks.AIR)) { + action = InventoryAction.DROP_ALL_SLOT; + } else { @@ -1322,23 +1345,23 @@ + } else { + // Sane default (because this happens when they are holding nothing. Don't ask why.) + click = ClickType.LEFT; -+ if (packetplayinwindowclick.c() == 1) { ++ if (packetplayinwindowclick.d() == 1) { + click = ClickType.RIGHT; + } + action = InventoryAction.NOTHING; + } + break; + case QUICK_CRAFT: -+ itemstack = this.player.activeContainer.a(packetplayinwindowclick.b(), packetplayinwindowclick.c(), packetplayinwindowclick.f(), this.player); ++ itemstack = this.player.activeContainer.a(packetplayinwindowclick.c(), packetplayinwindowclick.d(), packetplayinwindowclick.g(), this.player); + break; + case PICKUP_ALL: + click = ClickType.DOUBLE_CLICK; + action = InventoryAction.NOTHING; -+ if (packetplayinwindowclick.b() >= 0 && !this.player.inventory.getCarried().isEmpty()) { ++ if (packetplayinwindowclick.c() >= 0 && !this.player.inventory.getCarried().isEmpty()) { + ItemStack cursor = this.player.inventory.getCarried(); + action = InventoryAction.NOTHING; + // Quick check for if we have any of the item -+ if (inventory.getTopInventory().contains(org.bukkit.Material.getMaterial(Item.getId(cursor.getItem()))) || inventory.getBottomInventory().contains(org.bukkit.Material.getMaterial(Item.getId(cursor.getItem())))) { ++ if (inventory.getTopInventory().contains(CraftMagicNumbers.getMaterial(cursor.getItem())) || inventory.getBottomInventory().contains(CraftMagicNumbers.getMaterial(cursor.getItem()))) { + action = InventoryAction.COLLECT_TO_CURSOR; + } + } @@ -1346,22 +1369,22 @@ + default: + break; + } - -+ if (packetplayinwindowclick.f() != InventoryClickType.QUICK_CRAFT) { ++ ++ if (packetplayinwindowclick.g() != InventoryClickType.QUICK_CRAFT) { + if (click == ClickType.NUMBER_KEY) { -+ event = new InventoryClickEvent(inventory, type, packetplayinwindowclick.b(), click, action, packetplayinwindowclick.c()); ++ event = new InventoryClickEvent(inventory, type, packetplayinwindowclick.c(), click, action, packetplayinwindowclick.d()); + } else { -+ event = new InventoryClickEvent(inventory, type, packetplayinwindowclick.b(), click, action); ++ event = new InventoryClickEvent(inventory, type, packetplayinwindowclick.c(), click, action); + } + + org.bukkit.inventory.Inventory top = inventory.getTopInventory(); -+ if (packetplayinwindowclick.b() == 0 && top instanceof CraftingInventory) { ++ if (packetplayinwindowclick.c() == 0 && top instanceof CraftingInventory) { + org.bukkit.inventory.Recipe recipe = ((CraftingInventory) top).getRecipe(); + if (recipe != null) { + if (click == ClickType.NUMBER_KEY) { -+ event = new CraftItemEvent(recipe, inventory, type, packetplayinwindowclick.b(), click, action, packetplayinwindowclick.c()); ++ event = new CraftItemEvent(recipe, inventory, type, packetplayinwindowclick.c(), click, action, packetplayinwindowclick.d()); + } else { -+ event = new CraftItemEvent(recipe, inventory, type, packetplayinwindowclick.b(), click, action); ++ event = new CraftItemEvent(recipe, inventory, type, packetplayinwindowclick.c(), click, action); + } + } + } @@ -1376,7 +1399,7 @@ + switch (event.getResult()) { + case ALLOW: + case DEFAULT: -+ itemstack = this.player.activeContainer.a(packetplayinwindowclick.b(), packetplayinwindowclick.c(), packetplayinwindowclick.f(), this.player); ++ itemstack = this.player.activeContainer.a(packetplayinwindowclick.c(), packetplayinwindowclick.d(), packetplayinwindowclick.g(), this.player); + break; + case DENY: + /* Needs enum constructor in InventoryAction @@ -1436,25 +1459,22 @@ + } + } + // CraftBukkit end - if (ItemStack.matches(packetplayinwindowclick.e(), itemstack)) { - this.player.playerConnection.sendPacket(new PacketPlayOutTransaction(packetplayinwindowclick.a(), packetplayinwindowclick.d(), true)); + if (ItemStack.matches(packetplayinwindowclick.f(), itemstack)) { + this.player.playerConnection.sendPacket(new PacketPlayOutTransaction(packetplayinwindowclick.b(), packetplayinwindowclick.e(), true)); this.player.f = true; -@@ -900,6 +1921,7 @@ +@@ -1123,6 +2158,7 @@ public void a(PacketPlayInEnchantItem packetplayinenchantitem) { - PlayerConnectionUtils.ensureMainThread(packetplayinenchantitem, this, this.player.x()); + PlayerConnectionUtils.ensureMainThread(packetplayinenchantitem, this, this.player.getWorldServer()); + if (this.player.isFrozen()) return; // CraftBukkit this.player.resetIdleTimer(); - if (this.player.activeContainer.windowId == packetplayinenchantitem.a() && this.player.activeContainer.c(this.player) && !this.player.isSpectator()) { - this.player.activeContainer.a(this.player, packetplayinenchantitem.b()); -@@ -933,7 +1955,45 @@ - } + if (this.player.activeContainer.windowId == packetplayinenchantitem.b() && this.player.activeContainer.c(this.player) && !this.player.isSpectator()) { + this.player.activeContainer.a(this.player, packetplayinenchantitem.c()); +@@ -1154,6 +2190,43 @@ - boolean flag1 = packetplayinsetcreativeslot.a() >= 1 && packetplayinsetcreativeslot.a() <= 45; -- boolean flag2 = itemstack.isEmpty() || itemstack.getData() >= 0 && itemstack.getCount() <= 64 && !itemstack.isEmpty(); -+ // CraftBukkit - Add invalidItems check -+ boolean flag2 = itemstack.isEmpty() || itemstack.getData() >= 0 && itemstack.getCount() <= 64 && !itemstack.isEmpty() && !invalidItems.contains(Item.getId(itemstack.getItem())); -+ if (flag || (flag1 && !ItemStack.matches(this.player.defaultContainer.getSlot(packetplayinsetcreativeslot.a()).getItem(), packetplayinsetcreativeslot.getItemStack()))) { // Insist on valid slot + boolean flag1 = packetplayinsetcreativeslot.b() >= 1 && packetplayinsetcreativeslot.b() <= 45; + boolean flag2 = itemstack.isEmpty() || itemstack.getDamage() >= 0 && itemstack.getCount() <= 64 && !itemstack.isEmpty(); ++ if (flag || (flag1 && !ItemStack.matches(this.player.defaultContainer.getSlot(packetplayinsetcreativeslot.b()).getItem(), packetplayinsetcreativeslot.getItemStack()))) { // Insist on valid slot + // CraftBukkit start - Call click event + InventoryView inventory = this.player.defaultContainer.getBukkitView(); + org.bukkit.inventory.ItemStack item = CraftItemStack.asBukkitCopy(packetplayinsetcreativeslot.getItemStack()); @@ -1462,14 +1482,14 @@ + SlotType type = SlotType.QUICKBAR; + if (flag) { + type = SlotType.OUTSIDE; -+ } else if (packetplayinsetcreativeslot.a() < 36) { -+ if (packetplayinsetcreativeslot.a() >= 5 && packetplayinsetcreativeslot.a() < 9) { ++ } else if (packetplayinsetcreativeslot.b() < 36) { ++ if (packetplayinsetcreativeslot.b() >= 5 && packetplayinsetcreativeslot.b() < 9) { + type = SlotType.ARMOR; + } else { + type = SlotType.CONTAINER; + } + } -+ InventoryCreativeEvent event = new InventoryCreativeEvent(inventory, type, flag ? -999 : packetplayinsetcreativeslot.a(), item); ++ InventoryCreativeEvent event = new InventoryCreativeEvent(inventory, type, flag ? -999 : packetplayinsetcreativeslot.b(), item); + server.getPluginManager().callEvent(event); + + itemstack = CraftItemStack.asNMSCopy(event.getCursor()); @@ -1483,8 +1503,8 @@ + break; + case DENY: + // Reset the slot -+ if (packetplayinsetcreativeslot.a() >= 0) { -+ this.player.playerConnection.sendPacket(new PacketPlayOutSetSlot(this.player.defaultContainer.windowId, packetplayinsetcreativeslot.a(), this.player.defaultContainer.getSlot(packetplayinsetcreativeslot.a()).getItem())); ++ if (packetplayinsetcreativeslot.b() >= 0) { ++ this.player.playerConnection.sendPacket(new PacketPlayOutSetSlot(this.player.defaultContainer.windowId, packetplayinsetcreativeslot.b(), this.player.defaultContainer.getSlot(packetplayinsetcreativeslot.b()).getItem())); + this.player.playerConnection.sendPacket(new PacketPlayOutSetSlot(-1, -1, ItemStack.a)); + } + return; @@ -1494,42 +1514,42 @@ if (flag1 && flag2) { if (itemstack.isEmpty()) { -@@ -957,6 +2017,7 @@ +@@ -1177,6 +2250,7 @@ public void a(PacketPlayInTransaction packetplayintransaction) { - PlayerConnectionUtils.ensureMainThread(packetplayintransaction, this, this.player.x()); + PlayerConnectionUtils.ensureMainThread(packetplayintransaction, this, this.player.getWorldServer()); + if (this.player.isFrozen()) return; // CraftBukkit Short oshort = (Short) this.k.get(this.player.activeContainer.windowId); - if (oshort != null && packetplayintransaction.b() == oshort.shortValue() && this.player.activeContainer.windowId == packetplayintransaction.a() && !this.player.activeContainer.c(this.player) && !this.player.isSpectator()) { -@@ -967,6 +2028,7 @@ + if (oshort != null && packetplayintransaction.c() == oshort.shortValue() && this.player.activeContainer.windowId == packetplayintransaction.b() && !this.player.activeContainer.c(this.player) && !this.player.isSpectator()) { +@@ -1187,6 +2261,7 @@ public void a(PacketPlayInUpdateSign packetplayinupdatesign) { - PlayerConnectionUtils.ensureMainThread(packetplayinupdatesign, this, this.player.x()); + PlayerConnectionUtils.ensureMainThread(packetplayinupdatesign, this, this.player.getWorldServer()); + if (this.player.isFrozen()) return; // CraftBukkit this.player.resetIdleTimer(); WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); - BlockPosition blockposition = packetplayinupdatesign.a(); -@@ -983,14 +2045,30 @@ + BlockPosition blockposition = packetplayinupdatesign.b(); +@@ -1203,14 +2278,30 @@ - if (!tileentitysign.a() || tileentitysign.e() != this.player) { - this.minecraftServer.warning("Player " + this.player.getName() + " just tried to change non-editable sign"); + if (!tileentitysign.d() || tileentitysign.e() != this.player) { + this.minecraftServer.warning("Player " + this.player.getDisplayName().getString() + " just tried to change non-editable sign"); + this.sendPacket(tileentity.getUpdatePacket()); // CraftBukkit return; } - String[] astring = packetplayinupdatesign.b(); + String[] astring = packetplayinupdatesign.c(); + // CraftBukkit start + Player player = this.server.getPlayer(this.player); -+ int x = packetplayinupdatesign.a().getX(); -+ int y = packetplayinupdatesign.a().getY(); -+ int z = packetplayinupdatesign.a().getZ(); ++ int x = packetplayinupdatesign.b().getX(); ++ int y = packetplayinupdatesign.b().getY(); ++ int z = packetplayinupdatesign.b().getZ(); + String[] lines = new String[4]; + for (int i = 0; i < astring.length; ++i) { -- tileentitysign.lines[i] = new ChatComponentText(EnumChatFormat.a(astring[i])); -+ lines[i] = EnumChatFormat.a(new ChatComponentText(EnumChatFormat.a(astring[i])).toPlainText()); +- tileentitysign.lines[i] = new ChatComponentText(EnumChatFormat.b(astring[i])); ++ lines[i] = EnumChatFormat.b(new ChatComponentText(EnumChatFormat.b(astring[i])).getString()); } + SignChangeEvent event = new SignChangeEvent((org.bukkit.craftbukkit.block.CraftBlock) player.getWorld().getBlockAt(x, y, z), this.server.getPlayer(this.player), lines); + this.server.getPluginManager().callEvent(event); @@ -1542,18 +1562,18 @@ tileentitysign.update(); worldserver.notify(blockposition, iblockdata, iblockdata, 3); -@@ -999,6 +2077,7 @@ +@@ -1219,6 +2310,7 @@ } public void a(PacketPlayInKeepAlive packetplayinkeepalive) { -+ PlayerConnectionUtils.ensureMainThread(packetplayinkeepalive, this, this.player.x()); // CraftBukkit - if (this.g && packetplayinkeepalive.a() == this.h) { - int i = (int) (this.d() - this.f); ++ PlayerConnectionUtils.ensureMainThread(packetplayinkeepalive, this, this.player.getWorldServer()); // CraftBukkit + if (this.g && packetplayinkeepalive.b() == this.h) { + int i = (int) (SystemUtils.b() - this.f); -@@ -1016,11 +2095,27 @@ +@@ -1232,7 +2324,17 @@ public void a(PacketPlayInAbilities packetplayinabilities) { - PlayerConnectionUtils.ensureMainThread(packetplayinabilities, this, this.player.x()); + PlayerConnectionUtils.ensureMainThread(packetplayinabilities, this, this.player.getWorldServer()); - this.player.abilities.isFlying = packetplayinabilities.isFlying() && this.player.abilities.canFly; + // CraftBukkit start + if (this.player.abilities.canFly && this.player.abilities.isFlying != packetplayinabilities.isFlying()) { @@ -1568,155 +1588,53 @@ + // CraftBukkit end } - public void a(PacketPlayInTabComplete packetplayintabcomplete) { - PlayerConnectionUtils.ensureMainThread(packetplayintabcomplete, this, this.player.x()); -+ // CraftBukkit start -+ if (chatSpamField.addAndGet(this, 10) > 500 && !this.minecraftServer.getPlayerList().isOp(this.player.getProfile())) { -+ this.disconnect(new ChatMessage("disconnect.spam", new Object[0])); -+ return; -+ } -+ // CraftBukkit end - ArrayList arraylist = Lists.newArrayList(); - Iterator iterator = this.minecraftServer.tabCompleteCommand(this.player, packetplayintabcomplete.a(), packetplayintabcomplete.b(), packetplayintabcomplete.c()).iterator(); - -@@ -1046,6 +2141,13 @@ - ItemStack itemstack1; - - if ("MC|BEdit".equals(s)) { -+ // CraftBukkit start -+ if (this.lastBookTick + 20 > MinecraftServer.currentTick) { -+ this.disconnect("Book edited too quickly!"); -+ return; -+ } -+ this.lastBookTick = MinecraftServer.currentTick; -+ // CraftBukkit end - packetdataserializer = packetplayincustompayload.b(); - - try { -@@ -1065,14 +2167,23 @@ - - if (itemstack.getItem() == Items.WRITABLE_BOOK && itemstack.getItem() == itemstack1.getItem()) { - itemstack1.a("pages", (NBTBase) itemstack.getTag().getList("pages", 8)); -+ CraftEventFactory.handleEditBookEvent(player, itemstack1); // CraftBukkit - } - } catch (Exception exception) { - PlayerConnection.LOGGER.error("Couldn\'t handle book info", exception); -+ this.disconnect("Invalid book data!"); // CraftBukkit - } - } else { - String s1; - - if ("MC|BSign".equals(s)) { -+ // CraftBukkit start -+ if (this.lastBookTick + 20 > MinecraftServer.currentTick) { -+ this.disconnect("Book edited too quickly!"); -+ return; -+ } -+ this.lastBookTick = MinecraftServer.currentTick; -+ // CraftBukkit end - packetdataserializer = packetplayincustompayload.b(); - - try { -@@ -1106,10 +2217,11 @@ - } - - itemstack2.a("pages", (NBTBase) nbttaglist); -- this.player.setSlot(EnumItemSlot.MAINHAND, itemstack2); -+ CraftEventFactory.handleEditBookEvent(player, itemstack2); // CraftBukkit - } - } catch (Exception exception1) { - PlayerConnection.LOGGER.error("Couldn\'t sign book", exception1); -+ this.disconnect("Invalid book data!"); // CraftBukkit - } - } else if ("MC|TrSel".equals(s)) { - try { -@@ -1121,6 +2233,7 @@ - } - } catch (Exception exception2) { - PlayerConnection.LOGGER.error("Couldn\'t select trade", exception2); -+ this.disconnect("Invalid trade data!"); // CraftBukkit - } - } else { - TileEntity tileentity; -@@ -1170,6 +2283,7 @@ - } - } catch (Exception exception3) { - PlayerConnection.LOGGER.error("Couldn\'t set command block", exception3); -+ this.disconnect("Invalid command data!"); // CraftBukkit - } - } else if ("MC|AutoCmd".equals(s)) { - if (!this.minecraftServer.getEnableCommandBlock()) { -@@ -1237,6 +2351,7 @@ - } - } catch (Exception exception4) { - PlayerConnection.LOGGER.error("Couldn\'t set command block", exception4); -+ this.disconnect("Invalid command data!"); // CraftBukkit - } - } else { - int k; -@@ -1260,6 +2375,7 @@ - } - } catch (Exception exception5) { - PlayerConnection.LOGGER.error("Couldn\'t set beacon", exception5); -+ this.disconnect("Invalid beacon data!"); // CraftBukkit - } - } - } else if ("MC|ItemName".equals(s)) { -@@ -1346,6 +2462,7 @@ - } - } catch (Exception exception6) { - PlayerConnection.LOGGER.error("Couldn\'t set structure block", exception6); -+ this.disconnect("Invalid structure data!"); // CraftBukkit - } - } else if ("MC|PickItem".equals(s)) { - packetdataserializer = packetplayincustompayload.b(); -@@ -1358,11 +2475,49 @@ - this.player.playerConnection.sendPacket(new PacketPlayOutHeldItemSlot(this.player.inventory.itemInHandIndex)); - } catch (Exception exception7) { - PlayerConnection.LOGGER.error("Couldn\'t pick item", exception7); -+ this.disconnect("Invalid pick item!"); // CraftBukkit - } - } -+ // CraftBukkit start -+ else if (packetplayincustompayload.a().equals("REGISTER")) { -+ try { -+ String channels = packetplayincustompayload.b().toString(com.google.common.base.Charsets.UTF_8); -+ for (String channel : channels.split("\0")) { -+ getPlayer().addChannel(channel); -+ } -+ } catch (Exception ex) { -+ PlayerConnection.LOGGER.error("Couldn\'t register custom payload", ex); -+ this.disconnect("Invalid payload REGISTER!"); -+ } -+ } else if (packetplayincustompayload.a().equals("UNREGISTER")) { -+ try { -+ String channels = packetplayincustompayload.b().toString(com.google.common.base.Charsets.UTF_8); -+ for (String channel : channels.split("\0")) { -+ getPlayer().removeChannel(channel); -+ } -+ } catch (Exception ex) { -+ PlayerConnection.LOGGER.error("Couldn\'t unregister custom payload", ex); -+ this.disconnect("Invalid payload UNREGISTER!"); -+ } -+ } else { -+ try { -+ byte[] data = new byte[packetplayincustompayload.b().readableBytes()]; -+ packetplayincustompayload.b().readBytes(data); -+ server.getMessenger().dispatchIncomingMessage(player.getBukkitEntity(), packetplayincustompayload.a(), data); -+ } catch (Exception ex) { -+ PlayerConnection.LOGGER.error("Couldn\'t dispatch custom payload", ex); -+ this.disconnect("Invalid custom payload!"); -+ } -+ } -+ // CraftBukkit end - } - } - } - + public void a(PacketPlayInSettings packetplayinsettings) { +@@ -1240,5 +2342,47 @@ + this.player.a(packetplayinsettings); } + +- public void a(PacketPlayInCustomPayload packetplayincustompayload) {} ++ // CraftBukkit start ++ private static final MinecraftKey CUSTOM_REGISTER = new MinecraftKey("register"); ++ private static final MinecraftKey CUSTOM_UNREGISTER = new MinecraftKey("unregister"); ++ ++ public void a(PacketPlayInCustomPayload packetplayincustompayload) { ++ PlayerConnectionUtils.ensureMainThread(packetplayincustompayload, this, this.player.getWorldServer()); ++ if (packetplayincustompayload.tag.equals(CUSTOM_REGISTER)) { ++ try { ++ String channels = packetplayincustompayload.data.toString(com.google.common.base.Charsets.UTF_8); ++ for (String channel : channels.split("\0")) { ++ getPlayer().addChannel(channel); ++ } ++ } catch (Exception ex) { ++ PlayerConnection.LOGGER.error("Couldn\'t register custom payload", ex); ++ this.disconnect("Invalid payload REGISTER!"); ++ } ++ } else if (packetplayincustompayload.tag.equals(CUSTOM_UNREGISTER)) { ++ try { ++ String channels = packetplayincustompayload.data.toString(com.google.common.base.Charsets.UTF_8); ++ for (String channel : channels.split("\0")) { ++ getPlayer().removeChannel(channel); ++ } ++ } catch (Exception ex) { ++ PlayerConnection.LOGGER.error("Couldn\'t unregister custom payload", ex); ++ this.disconnect("Invalid payload UNREGISTER!"); ++ } ++ } else { ++ try { ++ byte[] data = new byte[packetplayincustompayload.data.readableBytes()]; ++ packetplayincustompayload.data.readBytes(data); ++ server.getMessenger().dispatchIncomingMessage(player.getBukkitEntity(), packetplayincustompayload.tag.toString(), data); ++ } catch (Exception ex) { ++ PlayerConnection.LOGGER.error("Couldn\'t dispatch custom payload", ex); ++ this.disconnect("Invalid custom payload!"); ++ } ++ } ++ ++ } + -+ // CraftBukkit start - Add "isDisconnected" method + public final boolean isDisconnected() { + return !this.player.joining && !this.networkManager.isConnected(); + } ++ // CraftBukkit end } diff --git a/paper-server/nms-patches/PlayerInteractManager.patch b/paper-server/nms-patches/PlayerInteractManager.patch index 319bef8d45..eccbf57419 100644 --- a/paper-server/nms-patches/PlayerInteractManager.patch +++ b/paper-server/nms-patches/PlayerInteractManager.patch @@ -53,7 +53,7 @@ if (this.isCreative()) { if (!this.world.douseFire((EntityHuman) null, blockposition, enumdirection)) { this.breakBlock(blockposition); -@@ -123,14 +145,48 @@ +@@ -122,15 +144,49 @@ } } @@ -61,23 +61,24 @@ + // this.world.douseFire((EntityHuman) null, blockposition, enumdirection); // CraftBukkit - Moved down this.lastDigTick = this.currentTick; float f = 1.0F; + IBlockData iblockdata = this.world.getType(blockposition); -- if (iblockdata.getMaterial() != Material.AIR) { +- if (!iblockdata.isAir()) { + // CraftBukkit start - Swings at air do *NOT* exist. + if (event.useInteractedBlock() == Event.Result.DENY) { + // If we denied a door from opening, we need to send a correcting update to the client, as it already opened the door. + IBlockData data = this.world.getType(blockposition); -+ if (block == Blocks.WOODEN_DOOR) { ++ if (data.getBlock() instanceof BlockDoor) { + // For some reason *BOTH* the bottom/top part have to be marked updated. -+ boolean bottom = data.get(BlockDoor.HALF) == BlockDoor.EnumDoorHalf.LOWER; ++ boolean bottom = data.get(BlockDoor.HALF) == BlockPropertyDoubleBlockHalf.LOWER; + ((EntityPlayer) this.player).playerConnection.sendPacket(new PacketPlayOutBlockChange(this.world, blockposition)); + ((EntityPlayer) this.player).playerConnection.sendPacket(new PacketPlayOutBlockChange(this.world, bottom ? blockposition.up() : blockposition.down())); -+ } else if (block == Blocks.TRAPDOOR) { ++ } else if (data.getBlock() instanceof BlockTrapdoor) { + ((EntityPlayer) this.player).playerConnection.sendPacket(new PacketPlayOutBlockChange(this.world, blockposition)); + } -+ } else if (iblockdata.getMaterial() != Material.AIR) { - block.attack(this.world, blockposition, this.player); - f = iblockdata.a((EntityHuman) this.player, this.player.world, blockposition); ++ } else if (!iblockdata.isAir()) { + iblockdata.attack(this.world, blockposition, this.player); + f = iblockdata.getDamage(this.player, this.player.world, blockposition); + // Allow fire punching to be blocked + this.world.douseFire((EntityHuman) null, blockposition, enumdirection); + } @@ -102,9 +103,9 @@ } + // CraftBukkit end - if (iblockdata.getMaterial() != Material.AIR && f >= 1.0F) { + if (!iblockdata.isAir() && f >= 1.0F) { this.breakBlock(blockposition); -@@ -148,6 +204,7 @@ +@@ -149,6 +205,7 @@ public void a(BlockPosition blockposition) { if (blockposition.equals(this.f)) { @@ -112,7 +113,7 @@ int i = this.currentTick - this.lastDigTick; IBlockData iblockdata = this.world.getType(blockposition); -@@ -165,6 +222,10 @@ +@@ -166,6 +223,10 @@ this.j = this.lastDigTick; } } @@ -123,11 +124,10 @@ } } -@@ -188,13 +249,86 @@ - } +@@ -190,13 +251,88 @@ public boolean breakBlock(BlockPosition blockposition) { -- if (this.gamemode.isCreative() && !this.player.getItemInMainHand().isEmpty() && this.player.getItemInMainHand().getItem() instanceof ItemSword) { + IBlockData iblockdata = this.world.getType(blockposition); + // CraftBukkit start - fire BlockBreakEvent + BlockBreakEvent event = null; + @@ -135,7 +135,7 @@ + org.bukkit.block.Block block = this.world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); + + // Sword + Creative mode pre-cancel -+ boolean isSwordNoBreak = this.gamemode.isCreative() && !this.player.getItemInMainHand().isEmpty() && this.player.getItemInMainHand().getItem() instanceof ItemSword; ++ boolean isSwordNoBreak = !this.player.getItemInMainHand().getItem().a(iblockdata, this.world, blockposition, (EntityHuman) this.player); + + // Tell client the block is gone immediately then process events + // Don't tell the client if its a creative sword break because its not broken! @@ -159,13 +159,14 @@ + if (nmsBlock != null && !event.isCancelled() && !this.isCreative() && this.player.hasBlock(nmsBlock.getBlockData())) { + // Copied from block.a(World world, EntityHuman entityhuman, BlockPosition blockposition, IBlockData iblockdata, @Nullable TileEntity tileentity, ItemStack itemstack) + // PAIL: checkme each update -+ if (!(nmsBlock.o() && EnchantmentManager.getEnchantmentLevel(Enchantments.SILK_TOUCH, itemstack) > 0)) { ++ if (!(nmsBlock.k() && EnchantmentManager.getEnchantmentLevel(Enchantments.SILK_TOUCH, itemstack) > 0)) { + int bonusLevel = EnchantmentManager.getEnchantmentLevel(Enchantments.LOOT_BONUS_BLOCKS, itemstack); + -+ event.setExpToDrop(nmsBlock.getExpDrop(this.world, nmsData, bonusLevel)); ++ event.setExpToDrop(nmsBlock.getExpDrop(nmsData, this.world, blockposition, bonusLevel)); + } + } -+ + +- if (!this.player.getItemInMainHand().getItem().a(iblockdata, this.world, blockposition, (EntityHuman) this.player)) { + this.world.getServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { @@ -176,7 +177,7 @@ + ((EntityPlayer) this.player).playerConnection.sendPacket(new PacketPlayOutBlockChange(this.world, blockposition)); + // Send other half of the door + if (nmsBlock instanceof BlockDoor) { -+ boolean bottom = nmsData.get(BlockDoor.HALF) == BlockDoor.EnumDoorHalf.LOWER; ++ boolean bottom = nmsData.get(BlockDoor.HALF) == BlockPropertyDoubleBlockHalf.LOWER; + ((EntityPlayer) this.player).playerConnection.sendPacket(new PacketPlayOutBlockChange(world, bottom ? blockposition.up() : blockposition.down())); + } + // Update any tile entity data for this block @@ -187,23 +188,25 @@ + return false; + } + } -+ if (false && this.gamemode.isCreative() && !this.player.getItemInMainHand().isEmpty() && this.player.getItemInMainHand().getItem() instanceof ItemSword) { // CraftBukkit - false ++ // CraftBukkit end ++ ++ if (false && !this.player.getItemInMainHand().getItem().a(iblockdata, this.world, blockposition, (EntityHuman) this.player)) { // CraftBukkit - false return false; } else { - IBlockData iblockdata = this.world.getType(blockposition); -+ if (iblockdata.getBlock() == Blocks.AIR) return false; // CraftBukkit - A plugin set block to air without cancelling ++ iblockdata = this.world.getType(blockposition); // CraftBukkit - update state from plugins ++ if (iblockdata.isAir()) return false; // CraftBukkit - A plugin set block to air without cancelling TileEntity tileentity = this.world.getTileEntity(blockposition); Block block = iblockdata.getBlock(); + // CraftBukkit start - Special case skulls, their item data comes from a tile entity (Also check if block should drop items) -+ if (iblockdata.getBlock() == Blocks.SKULL && !this.isCreative() && event.isDropItems()) { -+ iblockdata.getBlock().dropNaturally(world, blockposition, iblockdata, 1.0F, 0); ++ if (iblockdata.getBlock() instanceof BlockSkull && !this.isCreative() && event.isDropItems()) { ++ iblockdata.getBlock().dropNaturally(iblockdata, world, blockposition, 1.0F, 0); + return this.c(blockposition); + } + + // And shulker boxes too for duplication on cancel reasons (Also check if block should drop items) + if (iblockdata.getBlock() instanceof BlockShulkerBox && event.isDropItems()) { -+ iblockdata.getBlock().dropNaturally(world, blockposition, iblockdata, 1.0F, 0); ++ iblockdata.getBlock().dropNaturally(iblockdata, world, blockposition, 1.0F, 0); + return this.c(blockposition); + } + // CraftBukkit end @@ -211,10 +214,10 @@ if ((block instanceof BlockCommand || block instanceof BlockStructure) && !this.player.isCreativeAndOp()) { this.world.notify(blockposition, iblockdata, iblockdata, 3); return false; -@@ -218,7 +352,16 @@ +@@ -221,19 +357,36 @@ + } } - this.world.a(this.player, 2001, blockposition, Block.getCombinedId(iblockdata)); + // CraftBukkit start + world.captureDrops = new ArrayList<>(); boolean flag = this.c(blockposition); @@ -226,30 +229,30 @@ + world.captureDrops = null; + // CraftBukkit end - if (this.isCreative()) { - this.player.playerConnection.sendPacket(new PacketPlayOutBlockChange(this.world, blockposition)); -@@ -231,11 +374,19 @@ - itemstack1.a(this.world, iblockdata, blockposition, this.player); - } + if (!this.isCreative()) { + ItemStack itemstack1 = this.player.getItemInMainHand(); + boolean flag1 = this.player.hasBlock(iblockdata); + itemstack1.a(this.world, iblockdata, blockposition, this.player); - if (flag && flag1) { + // CraftBukkit start - Check if block should drop items + if (flag && flag1 && event.isDropItems()) { + ItemStack itemstack2 = itemstack1.isEmpty() ? ItemStack.a : itemstack1.cloneItemStack(); + iblockdata.getBlock().a(this.world, this.player, blockposition, iblockdata, tileentity, itemstack2); } + // CraftBukkit end - } - ++ } ++ + // CraftBukkit start - Drop event experience + if (flag && event != null) { + iblockdata.getBlock().dropExperience(this.world, blockposition, event.getExpToDrop()); -+ } + } + // CraftBukkit end -+ + return flag; } - } -@@ -278,63 +429,90 @@ +@@ -277,11 +430,40 @@ } } @@ -257,116 +260,67 @@ + public boolean interactResult = false; + public boolean firedInteract = false; public EnumInteractionResult a(EntityHuman entityhuman, World world, ItemStack itemstack, EnumHand enumhand, BlockPosition blockposition, EnumDirection enumdirection, float f, float f1, float f2) { -- if (this.gamemode == EnumGamemode.SPECTATOR) { -- TileEntity tileentity = world.getTileEntity(blockposition); -+ IBlockData blockdata = world.getType(blockposition); + IBlockData iblockdata = world.getType(blockposition); + EnumInteractionResult enuminteractionresult = EnumInteractionResult.FAIL; -+ if (blockdata.getBlock() != Blocks.AIR) { -+ boolean cancelledBlock = false; ++ if (iblockdata.isAir()) return enuminteractionresult; ++ boolean cancelledBlock = false; + + if (this.gamemode == EnumGamemode.SPECTATOR) { + TileEntity tileentity = world.getTileEntity(blockposition); ++ cancelledBlock = !(tileentity instanceof ITileInventory || tileentity instanceof IInventory); ++ } + -+ if (this.gamemode == EnumGamemode.SPECTATOR) { -+ TileEntity tileentity = world.getTileEntity(blockposition); -+ cancelledBlock = !(tileentity instanceof ITileInventory || tileentity instanceof IInventory); ++ if (entityhuman.getCooldownTracker().a(itemstack.getItem())) { ++ cancelledBlock = true; ++ } ++ ++ PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(entityhuman, Action.RIGHT_CLICK_BLOCK, blockposition, enumdirection, itemstack, cancelledBlock, enumhand); ++ firedInteract = true; ++ interactResult = event.useItemInHand() == Event.Result.DENY; ++ ++ if (event.useInteractedBlock() == Event.Result.DENY) { ++ // If we denied a door from opening, we need to send a correcting update to the client, as it already opened the door. ++ if (iblockdata.getBlock() instanceof BlockDoor) { ++ boolean bottom = iblockdata.get(BlockDoor.HALF) == BlockPropertyDoubleBlockHalf.LOWER; ++ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutBlockChange(world, bottom ? blockposition.up() : blockposition.down())); ++ } else if (iblockdata.getBlock() instanceof BlockCake) { ++ ((EntityPlayer) entityhuman).getBukkitEntity().sendHealthUpdate(); // SPIGOT-1341 - reset health for cake + } ++ ((EntityPlayer) entityhuman).getBukkitEntity().updateInventory(); // SPIGOT-2867 ++ enuminteractionresult = (event.useItemInHand() != Event.Result.ALLOW) ? EnumInteractionResult.SUCCESS : EnumInteractionResult.PASS; ++ } else if (this.gamemode == EnumGamemode.SPECTATOR) { ++ TileEntity tileentity = world.getTileEntity(blockposition); -- if (tileentity instanceof ITileInventory) { -- Block block = world.getType(blockposition).getBlock(); -- ITileInventory itileinventory = (ITileInventory) tileentity; -+ if (entityhuman.getCooldownTracker().a(itemstack.getItem())) { -+ cancelledBlock = true; -+ } + if (tileentity instanceof ITileInventory) { + Block block = iblockdata.getBlock(); +@@ -304,26 +486,26 @@ + } else { + boolean flag = entityhuman.getItemInMainHand().isEmpty(); -- if (itileinventory instanceof TileEntityChest && block instanceof BlockChest) { -- itileinventory = ((BlockChest) block).getInventory(world, blockposition); -- } -+ if (itemstack.getItem() instanceof ItemBlock && !entityhuman.isCreativeAndOp()) { -+ Block block1 = ((ItemBlock) itemstack.getItem()).getBlock(); - -- if (itileinventory != null) { -- entityhuman.openContainer(itileinventory); -- return EnumInteractionResult.SUCCESS; -+ if (block1 instanceof BlockCommand || block1 instanceof BlockStructure) { -+ cancelledBlock = true; - } -- } else if (tileentity instanceof IInventory) { -- entityhuman.openContainer((IInventory) tileentity); +- if ((!entityhuman.isSneaking() || flag && entityhuman.getItemInOffHand().isEmpty()) && iblockdata.interact(world, blockposition, entityhuman, enumhand, enumdirection, f, f1, f2)) { - return EnumInteractionResult.SUCCESS; - } - -- return EnumInteractionResult.PASS; -- } else { -- if (!entityhuman.isSneaking() || entityhuman.getItemInMainHand().isEmpty() && entityhuman.getItemInOffHand().isEmpty()) { -- IBlockData iblockdata = world.getType(blockposition); -+ PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(entityhuman, Action.RIGHT_CLICK_BLOCK, blockposition, enumdirection, itemstack, cancelledBlock, enumhand); -+ firedInteract = true; -+ interactResult = event.useItemInHand() == Event.Result.DENY; -+ -+ if (event.useInteractedBlock() == Event.Result.DENY) { -+ // If we denied a door from opening, we need to send a correcting update to the client, as it already opened the door. -+ if (blockdata.getBlock() instanceof BlockDoor) { -+ boolean bottom = blockdata.get(BlockDoor.HALF) == BlockDoor.EnumDoorHalf.LOWER; -+ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutBlockChange(world, bottom ? blockposition.up() : blockposition.down())); -+ } else if (blockdata.getBlock() instanceof BlockCake) { -+ ((EntityPlayer) entityhuman).getBukkitEntity().sendHealthUpdate(); // SPIGOT-1341 - reset health for cake -+ } -+ ((EntityPlayer) entityhuman).getBukkitEntity().updateInventory(); // SPIGOT-2867 -+ enuminteractionresult = (event.useItemInHand() != Event.Result.ALLOW) ? EnumInteractionResult.SUCCESS : EnumInteractionResult.PASS; -+ } else if (this.gamemode == EnumGamemode.SPECTATOR) { -+ TileEntity tileentity = world.getTileEntity(blockposition); - -- if (iblockdata.getBlock().interact(world, blockposition, iblockdata, entityhuman, enumhand, enumdirection, f, f1, f2)) { -+ if (tileentity instanceof ITileInventory) { -+ Block block = world.getType(blockposition).getBlock(); -+ ITileInventory itileinventory = (ITileInventory) tileentity; -+ -+ if (itileinventory instanceof TileEntityChest && block instanceof BlockChest) { -+ itileinventory = ((BlockChest) block).getInventory(world, blockposition); -+ } -+ -+ if (itileinventory != null) { -+ entityhuman.openContainer(itileinventory); -+ return EnumInteractionResult.SUCCESS; -+ } -+ } else if (tileentity instanceof IInventory) { -+ entityhuman.openContainer((IInventory) tileentity); - return EnumInteractionResult.SUCCESS; - } -- } - -- if (itemstack.isEmpty()) { +- } else if (flag) { - return EnumInteractionResult.PASS; - } else if (entityhuman.getCooldownTracker().a(itemstack.getItem())) { - return EnumInteractionResult.PASS; - } else { -- if (itemstack.getItem() instanceof ItemBlock && !entityhuman.isCreativeAndOp()) { -- Block block1 = ((ItemBlock) itemstack.getItem()).getBlock(); -+ if (!entityhuman.isSneaking() || entityhuman.getItemInMainHand().isEmpty() && entityhuman.getItemInOffHand().isEmpty()) { -+ IBlockData iblockdata = world.getType(blockposition); - -- if (block1 instanceof BlockCommand || block1 instanceof BlockStructure) { -- return EnumInteractionResult.FAIL; -- } -+ enuminteractionresult = iblockdata.getBlock().interact(world, blockposition, iblockdata, entityhuman, enumhand, enumdirection, f, f1, f2) ? EnumInteractionResult.SUCCESS : EnumInteractionResult.PASS; - } +- return EnumInteractionResult.PASS; +- } else { ++ if ((!entityhuman.isSneaking() || flag && entityhuman.getItemInOffHand().isEmpty())) { ++ enuminteractionresult = iblockdata.interact(world, blockposition, entityhuman, enumhand, enumdirection, f, f1, f2) ? EnumInteractionResult.SUCCESS : EnumInteractionResult.FAIL; + } - -- if (this.isCreative()) { -- int i = itemstack.getData(); -- int j = itemstack.getCount(); -- EnumInteractionResult enuminteractionresult = itemstack.placeItem(entityhuman, world, blockposition, enumhand, enumdirection, f, f1, f2); -+ if (!itemstack.isEmpty() && enuminteractionresult != EnumInteractionResult.SUCCESS && !interactResult) { // add !interactResult SPIGOT-764 -+ int i = itemstack.getData(); -+ int j = itemstack.getCount(); + -+ enuminteractionresult = itemstack.placeItem(entityhuman, world, blockposition, enumhand, enumdirection, f, f1, f2); ++ if (!itemstack.isEmpty() && !flag && enuminteractionresult != EnumInteractionResult.SUCCESS && !interactResult) { // add !interactResult SPIGOT-764 // MC-133478 - add isEmpty + ItemActionContext itemactioncontext = new ItemActionContext(entityhuman, entityhuman.b(enumhand), blockposition, enumdirection, f, f1, f2); -+ // The item count should not decrement in Creative mode. -+ if (this.isCreative()) { - itemstack.setData(i); - itemstack.setCount(j); -- return enuminteractionresult; -- } else { -- return itemstack.placeItem(entityhuman, world, blockposition, enumhand, enumdirection, f, f1, f2); + if (this.isCreative()) { + int i = itemstack.getCount(); +- EnumInteractionResult enuminteractionresult = itemstack.placeItem(itemactioncontext); ++ enuminteractionresult = itemstack.placeItem(itemactioncontext, enumhand); + + itemstack.setCount(i); + return enuminteractionresult; + } else { +- return itemstack.placeItem(itemactioncontext); ++ return itemstack.placeItem(itemactioncontext, enumhand); } } } diff --git a/paper-server/nms-patches/PlayerInventory.patch b/paper-server/nms-patches/PlayerInventory.patch index 2b4f94a0a4..9058f9888d 100644 --- a/paper-server/nms-patches/PlayerInventory.patch +++ b/paper-server/nms-patches/PlayerInventory.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/server/PlayerInventory.java +++ b/net/minecraft/server/PlayerInventory.java -@@ -5,6 +5,15 @@ - import java.util.List; +@@ -6,6 +6,15 @@ + import java.util.function.Predicate; import javax.annotation.Nullable; +// CraftBukkit start @@ -16,7 +16,7 @@ public class PlayerInventory implements IInventory { public final NonNullList items; -@@ -16,6 +25,49 @@ +@@ -17,6 +26,49 @@ private ItemStack carried; private int h; @@ -66,8 +66,8 @@ public PlayerInventory(EntityHuman entityhuman) { this.items = NonNullList.a(36, ItemStack.a); this.armor = NonNullList.a(4, ItemStack.a); -@@ -41,6 +93,23 @@ - return itemstack.getItem() == itemstack1.getItem() && (!itemstack.usesData() || itemstack.getData() == itemstack1.getData()) && ItemStack.equals(itemstack, itemstack1); +@@ -42,6 +94,23 @@ + return itemstack.getItem() == itemstack1.getItem() && ItemStack.equals(itemstack, itemstack1); } + // CraftBukkit start - Watch method above! :D @@ -78,7 +78,7 @@ + if (itemstack1.isEmpty()) return itemstack.getCount(); + + // Taken from firstPartial(ItemStack) -+ if (!itemstack1.isEmpty() && itemstack1.getItem() == itemstack.getItem() && itemstack1.isStackable() && itemstack1.getCount() < itemstack1.getMaxStackSize() && itemstack1.getCount() < this.getMaxStackSize() && (!itemstack1.usesData() || itemstack1.getData() == itemstack.getData()) && ItemStack.equals(itemstack1, itemstack)) { ++ if (!this.a(itemstack, itemstack1)) { + remains -= (itemstack1.getMaxStackSize() < this.getMaxStackSize() ? itemstack1.getMaxStackSize() : this.getMaxStackSize()) - itemstack1.getCount(); + } + if (remains <= 0) return itemstack.getCount(); @@ -90,7 +90,7 @@ public int getFirstEmptySlotIndex() { for (int i = 0; i < this.items.size(); ++i) { if (((ItemStack) this.items.get(i)).isEmpty()) { -@@ -524,7 +593,7 @@ +@@ -502,7 +571,7 @@ } public int getMaxStackSize() { @@ -99,7 +99,7 @@ } public boolean b(IBlockData iblockdata) { -@@ -580,6 +649,11 @@ +@@ -552,6 +621,11 @@ } public ItemStack getCarried() { diff --git a/paper-server/nms-patches/PlayerList.patch b/paper-server/nms-patches/PlayerList.patch index b50031bcdb..29ed252223 100644 --- a/paper-server/nms-patches/PlayerList.patch +++ b/paper-server/nms-patches/PlayerList.patch @@ -74,8 +74,8 @@ + // this.p = Maps.newHashMap(); + // CraftBukkit end this.server = minecraftserver; - this.k.a(false); - this.l.a(false); + this.getProfileBans().a(true); + this.getIPBans().a(true); @@ -65,6 +100,12 @@ usercache.a(gameprofile); @@ -93,9 +93,9 @@ s1 = networkmanager.getSocketAddress().toString(); } -- PlayerList.f.info("{}[{}] logged in with entity id {} at ({}, {}, {})", entityplayer.getName(), s1, Integer.valueOf(entityplayer.getId()), Double.valueOf(entityplayer.locX), Double.valueOf(entityplayer.locY), Double.valueOf(entityplayer.locZ)); +- PlayerList.f.info("{}[{}] logged in with entity id {} at ({}, {}, {})", entityplayer.getDisplayName().getString(), s1, Integer.valueOf(entityplayer.getId()), Double.valueOf(entityplayer.locX), Double.valueOf(entityplayer.locY), Double.valueOf(entityplayer.locZ)); + // CraftBukkit - Moved message to after join -+ // PlayerList.f.info("{}[{}] logged in with entity id {} at ({}, {}, {})", entityplayer.getName(), s1, Integer.valueOf(entityplayer.getId()), Double.valueOf(entityplayer.locX), Double.valueOf(entityplayer.locY), Double.valueOf(entityplayer.locZ)); ++ // PlayerList.f.info("{}[{}] logged in with entity id {} at ({}, {}, {})", entityplayer.getDisplayName().getString(), s1, Integer.valueOf(entityplayer.getId()), Double.valueOf(entityplayer.locX), Double.valueOf(entityplayer.locY), Double.valueOf(entityplayer.locZ)); WorldServer worldserver = this.server.getWorldServer(entityplayer.dimension); WorldData worlddata = worldserver.getWorldData(); @@ -104,49 +104,32 @@ playerconnection.sendPacket(new PacketPlayOutLogin(entityplayer.getId(), entityplayer.playerInteractManager.getGameMode(), worlddata.isHardcore(), worldserver.worldProvider.getDimensionManager().getDimensionID(), worldserver.getDifficulty(), this.getMaxPlayers(), worlddata.getType(), worldserver.getGameRules().getBoolean("reducedDebugInfo"))); + entityplayer.getBukkitEntity().sendSupportedChannels(); // CraftBukkit - playerconnection.sendPacket(new PacketPlayOutCustomPayload("MC|Brand", (new PacketDataSerializer(Unpooled.buffer())).a(this.getServer().getServerModName()))); + playerconnection.sendPacket(new PacketPlayOutCustomPayload(PacketPlayOutCustomPayload.b, (new PacketDataSerializer(Unpooled.buffer())).a(this.getServer().getServerModName()))); playerconnection.sendPacket(new PacketPlayOutServerDifficulty(worlddata.getDifficulty(), worlddata.isDifficultyLocked())); playerconnection.sendPacket(new PacketPlayOutAbilities(entityplayer.abilities)); -@@ -91,17 +134,23 @@ - entityplayer.F().a(entityplayer); - this.sendScoreboard((ScoreboardServer) worldserver.getScoreboard(), entityplayer); - this.server.aD(); -- ChatMessage chatmessage; -+ // CraftBukkit start - login message is handled in the event -+ // ChatMessage chatmessage; - -+ String joinMessage; - if (entityplayer.getName().equalsIgnoreCase(s)) { -- chatmessage = new ChatMessage("multiplayer.player.joined", new Object[] { entityplayer.getScoreboardDisplayName()}); -+ // chatmessage = new ChatMessage("multiplayer.player.joined", new Object[] { entityplayer.getScoreboardDisplayName()}); -+ joinMessage = "\u00A7e" + LocaleI18n.a("multiplayer.player.joined", entityplayer.getName()); - } else { -- chatmessage = new ChatMessage("multiplayer.player.joined.renamed", new Object[] { entityplayer.getScoreboardDisplayName(), s}); -+ // chatmessage = new ChatMessage("multiplayer.player.joined.renamed", new Object[] { entityplayer.getScoreboardDisplayName(), s}); -+ joinMessage = "\u00A7e" + LocaleI18n.a("multiplayer.player.joined.renamed", entityplayer.getName(), s); +@@ -101,8 +144,10 @@ + chatmessage = new ChatMessage("multiplayer.player.joined.renamed", new Object[] { entityplayer.getScoreboardDisplayName(), s}); } -- chatmessage.getChatModifier().setColor(EnumChatFormat.YELLOW); -- this.sendMessage(chatmessage); +- this.sendMessage(chatmessage.a(EnumChatFormat.YELLOW)); - this.onPlayerJoin(entityplayer); -+ // chatmessage.getChatModifier().setColor(EnumChatFormat.YELLOW); -+ // this.sendMessage(chatmessage); -+ this.onPlayerJoin(entityplayer, joinMessage); ++ chatmessage.a(EnumChatFormat.YELLOW); ++ this.onPlayerJoin(entityplayer, CraftChatMessage.fromComponent(chatmessage)); + // CraftBukkit end + worldserver = server.getWorldServer(entityplayer.dimension); // CraftBukkit - Update in case join event changed it playerconnection.a(entityplayer.locX, entityplayer.locY, entityplayer.locZ, entityplayer.yaw, entityplayer.pitch); this.b(entityplayer, worldserver); if (!this.server.getResourcePack().isEmpty()) { -@@ -153,6 +202,8 @@ +@@ -154,6 +199,8 @@ } entityplayer.syncInventory(); + // CraftBukkit - Moved from above, added world -+ PlayerList.f.info(entityplayer.getName() + "[" + s1 + "] logged in with entity id " + entityplayer.getId() + " at ([" + entityplayer.world.worldData.getName() + "]" + entityplayer.locX + ", " + entityplayer.locY + ", " + entityplayer.locZ + ")"); ++ PlayerList.f.info("{}[{}] logged in with entity id {} at ([{}]{}, {}, {})", entityplayer.getDisplayName().getString(), s1, Integer.valueOf(entityplayer.getId()), entityplayer.world.worldData.getName(), Double.valueOf(entityplayer.locX), Double.valueOf(entityplayer.locY), Double.valueOf(entityplayer.locZ)); } public void sendScoreboard(ScoreboardServer scoreboardserver, EntityPlayer entityplayer) { -@@ -185,26 +236,27 @@ +@@ -186,26 +233,27 @@ } public void setPlayerFileData(WorldServer[] aworldserver) { @@ -179,7 +162,7 @@ } public void b(WorldBorder worldborder, double d0) {} -@@ -237,7 +289,7 @@ +@@ -238,7 +286,7 @@ @Nullable public NBTTagCompound a(EntityPlayer entityplayer) { @@ -187,8 +170,8 @@ + NBTTagCompound nbttagcompound = this.server.worlds.get(0).getWorldData().h(); // CraftBukkit NBTTagCompound nbttagcompound1; - if (entityplayer.getName().equals(this.server.Q()) && nbttagcompound != null) { -@@ -253,13 +305,13 @@ + if (entityplayer.getDisplayName().getString().equals(this.server.I()) && nbttagcompound != null) { +@@ -254,13 +302,13 @@ protected void savePlayerFile(EntityPlayer entityplayer) { this.playerFileData.save(entityplayer); @@ -196,7 +179,7 @@ + ServerStatisticManager serverstatisticmanager = (ServerStatisticManager) entityplayer.getStatisticManager(); // CraftBukkit if (serverstatisticmanager != null) { - serverstatisticmanager.b(); + serverstatisticmanager.a(); } - AdvancementDataPlayer advancementdataplayer = (AdvancementDataPlayer) this.p.get(entityplayer.getUniqueID()); @@ -204,7 +187,7 @@ if (advancementdataplayer != null) { advancementdataplayer.c(); -@@ -267,28 +319,79 @@ +@@ -268,29 +316,80 @@ } @@ -259,23 +242,25 @@ - worldserver.addEntity(entityplayer); - this.a(entityplayer, (WorldServer) null); +- this.server.aR().a(entityplayer); + // CraftBukkit start - Only add if the player wasn't moved in the event + if (entityplayer.world == worldserver && !worldserver.players.contains(entityplayer)) { + worldserver.addEntity(entityplayer); + this.a(entityplayer, (WorldServer) null); ++ this.server.aR().a(entityplayer); + } + // CraftBukkit end } public void d(EntityPlayer entityplayer) { - entityplayer.x().getPlayerChunkMap().movePlayer(entityplayer); + entityplayer.getWorldServer().getPlayerChunkMap().movePlayer(entityplayer); } - public void disconnect(EntityPlayer entityplayer) { + public String disconnect(EntityPlayer entityplayer) { // CraftBukkit - return string - WorldServer worldserver = entityplayer.x(); + WorldServer worldserver = entityplayer.getWorldServer(); - entityplayer.b(StatisticList.f); + entityplayer.a(StatisticList.LEAVE_GAME); + + // CraftBukkit start - Quitting must be before we do final save of data, in case plugins need to modify it + org.bukkit.craftbukkit.event.CraftEventFactory.handleInventoryCloseEvent(entityplayer); @@ -289,8 +274,8 @@ + this.savePlayerFile(entityplayer); if (entityplayer.isPassenger()) { - Entity entity = entityplayer.getVehicle(); -@@ -318,17 +421,67 @@ + Entity entity = entityplayer.getRootVehicle(); +@@ -321,18 +420,68 @@ if (entityplayer1 == entityplayer) { this.j.remove(uuid); @@ -324,9 +309,13 @@ + return playerQuitEvent.getQuitMessage(); // CraftBukkit } -- public String attemptLogin(SocketAddress socketaddress, GameProfile gameprofile) { +- @Nullable +- public IChatBaseComponent attemptLogin(SocketAddress socketaddress, GameProfile gameprofile) { + // CraftBukkit start - Whole method, SocketAddress to LoginListener, added hostname to signature, return EntityPlayer + public EntityPlayer attemptLogin(LoginListener loginlistener, GameProfile gameprofile, String hostname) { + ChatMessage chatmessage; + +- if (this.k.isBanned(gameprofile)) { + // Moved from processLogin + UUID uuid = EntityHuman.a(gameprofile); + ArrayList arraylist = Lists.newArrayList(); @@ -353,52 +342,50 @@ + // depending on the outcome. + SocketAddress socketaddress = loginlistener.networkManager.getSocketAddress(); + -+ EntityPlayer entity = new EntityPlayer(server, server.getWorldServer(0), gameprofile, new PlayerInteractManager(server.getWorldServer(0))); ++ EntityPlayer entity = new EntityPlayer(this.server, this.server.a(DimensionManager.OVERWORLD), gameprofile, new PlayerInteractManager(this.server.a(DimensionManager.OVERWORLD))); + Player player = entity.getBukkitEntity(); + PlayerLoginEvent event = new PlayerLoginEvent(player, hostname, ((java.net.InetSocketAddress) socketaddress).getAddress()); - String s; - -- if (this.k.isBanned(gameprofile)) { ++ + if (getProfileBans().isBanned(gameprofile) && !getProfileBans().get(gameprofile).hasExpired()) { GameProfileBanEntry gameprofilebanentry = (GameProfileBanEntry) this.k.get(gameprofile); - s = "You are banned from this server!\nReason: " + gameprofilebanentry.getReason(); -@@ -336,10 +489,12 @@ - s = s + "\nYour ban will be removed on " + PlayerList.g.format(gameprofilebanentry.getExpires()); + chatmessage = new ChatMessage("multiplayer.disconnect.banned.reason", new Object[] { gameprofilebanentry.getReason()}); +@@ -340,10 +489,12 @@ + chatmessage.addSibling(new ChatMessage("multiplayer.disconnect.banned.expiration", new Object[] { PlayerList.g.format(gameprofilebanentry.getExpires())})); } -- return s; -+ // return s; -+ event.disallow(PlayerLoginEvent.Result.KICK_BANNED, s); +- return chatmessage; ++ // return chatmessage; ++ event.disallow(PlayerLoginEvent.Result.KICK_BANNED, CraftChatMessage.fromComponent(chatmessage)); } else if (!this.isWhitelisted(gameprofile)) { -- return "You are not white-listed on this server!"; +- return new ChatMessage("multiplayer.disconnect.not_whitelisted", new Object[0]); - } else if (this.l.isBanned(socketaddress)) { -+ // return "You are not white-listed on this server!"; -+ event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, "You are not white-listed on this server!"); ++ chatmessage = new ChatMessage("multiplayer.disconnect.not_whitelisted", new Object[0]); ++ event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, CraftChatMessage.fromComponent(chatmessage)); + } else if (getIPBans().isBanned(socketaddress) && !getIPBans().get(socketaddress).hasExpired()) { IpBanEntry ipbanentry = this.l.get(socketaddress); - s = "Your IP address is banned from this server!\nReason: " + ipbanentry.getReason(); -@@ -347,13 +502,25 @@ - s = s + "\nYour ban will be removed on " + PlayerList.g.format(ipbanentry.getExpires()); + chatmessage = new ChatMessage("multiplayer.disconnect.banned_ip.reason", new Object[] { ipbanentry.getReason()}); +@@ -351,13 +502,25 @@ + chatmessage.addSibling(new ChatMessage("multiplayer.disconnect.banned_ip.expiration", new Object[] { PlayerList.g.format(ipbanentry.getExpires())})); } -- return s; -+ // return s; -+ event.disallow(PlayerLoginEvent.Result.KICK_BANNED, s); +- return chatmessage; ++ // return chatmessage; ++ event.disallow(PlayerLoginEvent.Result.KICK_BANNED, CraftChatMessage.fromComponent(chatmessage)); } else { -- return this.players.size() >= this.maxPlayers && !this.f(gameprofile) ? "The server is full!" : null; -+ // return this.players.size() >= this.maxPlayers && !this.f(gameprofile) ? "The server is full!" : null; +- return this.players.size() >= this.maxPlayers && !this.f(gameprofile) ? new ChatMessage("multiplayer.disconnect.server_full", new Object[0]) : null; ++ // return this.players.size() >= this.maxPlayers && !this.f(gameprofile) ? new ChatMessage("multiplayer.disconnect.server_full", new Object[0]) : null; + if (this.players.size() >= this.maxPlayers && !this.f(gameprofile)) { + event.disallow(PlayerLoginEvent.Result.KICK_FULL, "The server is full"); + } - } ++ } + + cserver.getPluginManager().callEvent(event); + if (event.getResult() != PlayerLoginEvent.Result.ALLOWED) { + loginlistener.disconnect(event.getKickMessage()); + return null; -+ } + } + return entity; } @@ -408,10 +395,10 @@ UUID uuid = EntityHuman.a(gameprofile); ArrayList arraylist = Lists.newArrayList(); -@@ -388,17 +555,27 @@ +@@ -392,17 +555,27 @@ } - return new EntityPlayer(this.server, this.server.getWorldServer(0), gameprofile, (PlayerInteractManager) object); + return new EntityPlayer(this.server, this.server.a(DimensionManager.OVERWORLD), gameprofile, (PlayerInteractManager) object); + */ + return player; + // CraftBukkit end @@ -424,10 +411,10 @@ + + public EntityPlayer moveToWorld(EntityPlayer entityplayer, int i, boolean flag, Location location, boolean avoidSuffocation) { + entityplayer.stopRiding(); // CraftBukkit - entityplayer.x().getTracker().untrackPlayer(entityplayer); -- entityplayer.x().getTracker().untrackEntity(entityplayer); -+ // entityplayer.x().getTracker().untrackEntity(entityplayer); // CraftBukkit - entityplayer.x().getPlayerChunkMap().removePlayer(entityplayer); + entityplayer.getWorldServer().getTracker().untrackPlayer(entityplayer); +- entityplayer.getWorldServer().getTracker().untrackEntity(entityplayer); ++ // entityplayer.getWorldServer().getTracker().untrackEntity(entityplayer); // CraftBukkit + entityplayer.getWorldServer().getPlayerChunkMap().removePlayer(entityplayer); this.players.remove(entityplayer); this.server.getWorldServer(entityplayer.dimension).removeEntity(entityplayer); BlockPosition blockposition = entityplayer.getBed(); @@ -437,7 +424,7 @@ entityplayer.dimension = i; Object object; -@@ -409,6 +586,11 @@ +@@ -413,6 +586,11 @@ } EntityPlayer entityplayer1 = new EntityPlayer(this.server, this.server.getWorldServer(entityplayer.dimension), entityplayer.getProfile(), (PlayerInteractManager) object); @@ -449,7 +436,7 @@ entityplayer1.playerConnection = entityplayer.playerConnection; entityplayer1.copyFrom(entityplayer, flag); -@@ -423,43 +605,166 @@ +@@ -426,43 +604,166 @@ entityplayer1.addScoreboardTag(s); } @@ -484,7 +471,7 @@ + + if (location == null) { + cworld = (CraftWorld) this.server.server.getWorlds().get(0); -+ blockposition = entityplayer1.getSpawnPoint(this.server, cworld.getHandle()); ++ blockposition = entityplayer1.getSpawnPoint(cworld.getHandle()); + location = new Location(cworld, (double) ((float) blockposition.getX() + 0.5F), (double) ((float) blockposition.getY() + 0.1F), (double) ((float) blockposition.getZ() + 0.5F)); } + @@ -503,8 +490,8 @@ worldserver.getChunkProviderServer().getChunkAt((int) entityplayer1.locX >> 4, (int) entityplayer1.locZ >> 4); -- while (!worldserver.getCubes(entityplayer1, entityplayer1.getBoundingBox()).isEmpty() && entityplayer1.locY < 256.0D) { -+ while (avoidSuffocation && !worldserver.getCubes(entityplayer1, entityplayer1.getBoundingBox()).isEmpty() && entityplayer1.locY < 256.0D) { +- while (!worldserver.getCubes(entityplayer1, entityplayer1.getBoundingBox()) && entityplayer1.locY < 256.0D) { ++ while (avoidSuffocation && !worldserver.getCubes(entityplayer1, entityplayer1.getBoundingBox()) && entityplayer1.locY < 256.0D) { entityplayer1.setPosition(entityplayer1.locX, entityplayer1.locY + 1.0D, entityplayer1.locZ); } + // CraftBukkit start @@ -549,9 +536,9 @@ + } + + // Fire advancement trigger -+ CriterionTriggers.u.a(entityplayer, ((CraftWorld) fromWorld).getHandle().worldProvider.getDimensionManager(), worldserver.worldProvider.getDimensionManager()); -+ if (((CraftWorld) fromWorld).getHandle().worldProvider.getDimensionManager() == DimensionManager.NETHER && worldserver.worldProvider.getDimensionManager() == DimensionManager.OVERWORLD && entityplayer.Q() != null) { -+ CriterionTriggers.B.a(entityplayer, entityplayer.Q()); ++ CriterionTriggers.v.a(entityplayer, ((CraftWorld) fromWorld).getHandle().worldProvider.getDimensionManager(), worldserver.worldProvider.getDimensionManager()); ++ if (((CraftWorld) fromWorld).getHandle().worldProvider.getDimensionManager() == DimensionManager.NETHER && worldserver.worldProvider.getDimensionManager() == DimensionManager.OVERWORLD && entityplayer.M() != null) { ++ CriterionTriggers.C.a(entityplayer, entityplayer.M()); + } + + // Don't fire on respawn @@ -588,7 +575,7 @@ + // THE_END -> NORMAL; use bed if available, otherwise default spawn + exit = ((org.bukkit.craftbukkit.entity.CraftPlayer) entityplayer.getBukkitEntity()).getBedSpawnLocation(); + if (exit == null || ((CraftWorld) exit.getWorld()).getHandle().dimension != 0) { -+ BlockPosition randomSpawn = entityplayer.getSpawnPoint(server, exitWorld); ++ BlockPosition randomSpawn = entityplayer.getSpawnPoint(exitWorld); + exit = new Location(exitWorld.getWorld(), randomSpawn.getX(), randomSpawn.getY(), randomSpawn.getZ()); + } else { + exit = exit.add(0.5F, 0.1F, 0.5F); // SPIGOT-3879 @@ -633,7 +620,16 @@ public void f(EntityPlayer entityplayer) { GameProfile gameprofile = entityplayer.getProfile(); int i = this.isOp(gameprofile) ? this.operators.a(gameprofile) : 0; -@@ -498,12 +803,111 @@ +@@ -470,7 +771,7 @@ + boolean flag1 = flag && this.server.I().equalsIgnoreCase(entityplayer.getProfile().getName()); + int j = flag1 ? 4 : 2; + +- i = flag && this.server.worldServer[0].getWorldData().u() ? j : i; ++ i = flag && this.server.worlds.get(0).getWorldData().u() ? j : i; // CraftBukkit + i = this.u ? j : i; + this.b(entityplayer, i); + } +@@ -504,12 +805,111 @@ } public void changeWorld(Entity entity, int i, WorldServer worldserver, WorldServer worldserver1) { @@ -655,13 +651,13 @@ + double d1 = enter.getZ(); + double d2 = 8.0D; + /* -+ double d0 = entity.locX; -+ double d1 = entity.locZ; -+ double d2 = 8.0D; -+ float f = entity.yaw; + double d0 = entity.locX; + double d1 = entity.locZ; + double d2 = 8.0D; + float f = entity.yaw; + */ -+ -+ worldserver.methodProfiler.a("moving"); + + worldserver.methodProfiler.a("moving"); + if (worldserver1.dimension == -1) { + d0 = MathHelper.a(d0 / d2, worldserver1.getWorldBorder().b()+ 16.0D, worldserver1.getWorldBorder().d() - 16.0D); + d1 = MathHelper.a(d1 / d2, worldserver1.getWorldBorder().c() + 16.0D, worldserver1.getWorldBorder().e() - 16.0D); @@ -730,13 +726,13 @@ + int i = worldserver.dimension; + + /* - double d0 = entity.locX; - double d1 = entity.locZ; - double d2 = 8.0D; - float f = entity.yaw; ++ double d0 = entity.locX; ++ double d1 = entity.locZ; ++ double d2 = 8.0D; ++ float f = entity.yaw; + */ - - worldserver.methodProfiler.a("moving"); ++ ++ worldserver.methodProfiler.a("moving"); + entity.setPositionRotation(exit.getX(), exit.getY(), exit.getZ(), exit.getYaw(), exit.getPitch()); + if (entity.isAlive()) { + worldserver.entityJoinedWorld(entity, false); @@ -745,7 +741,7 @@ if (entity.dimension == -1) { d0 = MathHelper.a(d0 / 8.0D, worldserver1.getWorldBorder().b() + 16.0D, worldserver1.getWorldBorder().d() - 16.0D); d1 = MathHelper.a(d1 / 8.0D, worldserver1.getWorldBorder().c() + 16.0D, worldserver1.getWorldBorder().e() - 16.0D); -@@ -522,6 +926,8 @@ +@@ -528,6 +928,8 @@ BlockPosition blockposition; if (i == 1) { @@ -754,13 +750,13 @@ blockposition = worldserver1.getSpawn(); } else { blockposition = worldserver1.getDimensionSpawn(); -@@ -535,16 +941,27 @@ +@@ -541,16 +943,27 @@ worldserver.entityJoinedWorld(entity, false); } } + */ - worldserver.methodProfiler.b(); + worldserver.methodProfiler.e(); if (i != 1) { worldserver.methodProfiler.a("placing"); + /* @@ -785,7 +781,7 @@ worldserver1.entityJoinedWorld(entity, false); } -@@ -552,11 +969,23 @@ +@@ -558,11 +971,23 @@ } entity.spawnIn(worldserver1); @@ -810,7 +806,7 @@ this.v = 0; } -@@ -569,6 +998,25 @@ +@@ -575,6 +1000,25 @@ } @@ -836,40 +832,24 @@ public void a(Packet packet, int i) { for (int j = 0; j < this.players.size(); ++j) { EntityPlayer entityplayer = (EntityPlayer) this.players.get(j); -@@ -667,11 +1115,23 @@ +@@ -677,6 +1121,7 @@ + entityplayer.playerConnection.sendPacket(new PacketPlayOutEntityStatus(entityplayer, b0)); + } - this.operators.add(new OpListEntry(gameprofile, this.server.q(), this.operators.b(gameprofile))); - this.b(this.a(gameprofile.getId()), i); -+ // CraftBukkit start -+ Player player = server.server.getPlayer(gameprofile.getId()); -+ if (player != null) { -+ player.recalculatePermissions(); -+ } -+ // CraftBukkit end ++ entityplayer.getBukkitEntity().recalculatePermissions(); // CraftBukkit + this.server.getCommandDispatcher().a(entityplayer); } - public void removeOp(GameProfile gameprofile) { - this.operators.remove(gameprofile); - this.b(this.a(gameprofile.getId()), 0); -+ // CraftBukkit start -+ Player player = server.server.getPlayer(gameprofile.getId()); -+ if (player != null) { -+ player.recalculatePermissions(); -+ } -+ // CraftBukkit end - } - - private void b(EntityPlayer entityplayer, int i) { -@@ -696,7 +1156,7 @@ +@@ -685,7 +1130,7 @@ } public boolean isOp(GameProfile gameprofile) { -- return this.operators.d(gameprofile) || this.server.R() && this.server.worldServer[0].getWorldData().u() && this.server.Q().equalsIgnoreCase(gameprofile.getName()) || this.u; -+ return this.operators.d(gameprofile) || this.server.R() && this.server.worlds.get(0).getWorldData().u() && this.server.Q().equalsIgnoreCase(gameprofile.getName()) || this.u; // CraftBukkit +- return this.operators.d(gameprofile) || this.server.J() && this.server.worldServer[0].getWorldData().u() && this.server.I().equalsIgnoreCase(gameprofile.getName()) || this.u; ++ return this.operators.d(gameprofile) || this.server.J() && this.server.worlds.get(0).getWorldData().u() && this.server.I().equalsIgnoreCase(gameprofile.getName()) || this.u; // CraftBukkit } @Nullable -@@ -720,6 +1180,12 @@ +@@ -709,6 +1154,12 @@ for (int j = 0; j < this.players.size(); ++j) { EntityPlayer entityplayer = (EntityPlayer) this.players.get(j); @@ -882,7 +862,7 @@ if (entityplayer != entityhuman && entityplayer.dimension == i) { double d4 = d0 - entityplayer.locX; double d5 = d1 - entityplayer.locY; -@@ -767,7 +1233,7 @@ +@@ -748,7 +1199,7 @@ public void reloadWhitelist() {} public void b(EntityPlayer entityplayer, WorldServer worldserver) { @@ -891,17 +871,17 @@ entityplayer.playerConnection.sendPacket(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.INITIALIZE)); entityplayer.playerConnection.sendPacket(new PacketPlayOutUpdateTime(worldserver.getTime(), worldserver.getDayTime(), worldserver.getGameRules().getBoolean("doDaylightCycle"))); -@@ -775,16 +1241,21 @@ +@@ -756,16 +1207,21 @@ entityplayer.playerConnection.sendPacket(new PacketPlayOutSpawnPosition(blockposition)); if (worldserver.isRaining()) { - entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(1, 0.0F)); -- entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(7, worldserver.j(1.0F))); -- entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(8, worldserver.h(1.0F))); +- entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(7, worldserver.i(1.0F))); +- entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(8, worldserver.g(1.0F))); + // CraftBukkit start - handle player weather + // entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(1, 0.0F)); -+ // entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(7, worldserver.j(1.0F))); -+ // entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(8, worldserver.h(1.0F))); ++ // entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(7, worldserver.i(1.0F))); ++ // entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(8, worldserver.g(1.0F))); + entityplayer.setPlayerWeather(org.bukkit.WeatherType.DOWNFALL, false); + entityplayer.updateWeather(-worldserver.o, worldserver.o, -worldserver.q, worldserver.q); + // CraftBukkit end @@ -917,7 +897,7 @@ entityplayer.playerConnection.sendPacket(new PacketPlayOutHeldItemSlot(entityplayer.inventory.itemInHandIndex)); } -@@ -797,7 +1268,7 @@ +@@ -778,7 +1234,7 @@ } public String[] getSeenPlayers() { @@ -926,7 +906,7 @@ } public boolean getHasWhitelist() { -@@ -846,26 +1317,39 @@ +@@ -827,26 +1283,39 @@ } public void u() { @@ -970,17 +950,17 @@ + // CraftBukkit end if (serverstatisticmanager == null) { - File file = new File(this.server.getWorldServer(0).getDataManager().getDirectory(), "stats"); -@@ -881,7 +1365,7 @@ + File file = new File(this.server.a(DimensionManager.OVERWORLD).getDataManager().getDirectory(), "stats"); +@@ -861,7 +1330,7 @@ + } serverstatisticmanager = new ServerStatisticManager(this.server, file1); - serverstatisticmanager.a(); - this.o.put(uuid, serverstatisticmanager); + // this.o.put(uuid, serverstatisticmanager); // CraftBukkit } return serverstatisticmanager; -@@ -889,14 +1373,14 @@ +@@ -869,14 +1338,14 @@ public AdvancementDataPlayer h(EntityPlayer entityplayer) { UUID uuid = entityplayer.getUniqueID(); @@ -988,7 +968,7 @@ + AdvancementDataPlayer advancementdataplayer = (AdvancementDataPlayer) entityplayer.getAdvancementData(); // CraftBukkit if (advancementdataplayer == null) { - File file = new File(this.server.getWorldServer(0).getDataManager().getDirectory(), "advancements"); + File file = new File(this.server.a(DimensionManager.OVERWORLD).getDataManager().getDirectory(), "advancements"); File file1 = new File(file, uuid + ".json"); advancementdataplayer = new AdvancementDataPlayer(this.server, file1, entityplayer); @@ -997,7 +977,7 @@ } advancementdataplayer.a(entityplayer); -@@ -909,8 +1393,10 @@ +@@ -889,8 +1358,10 @@ WorldServer[] aworldserver = this.server.worldServer; int j = aworldserver.length; @@ -1010,7 +990,7 @@ if (worldserver != null) { worldserver.getPlayerChunkMap().a(i); -@@ -934,13 +1420,20 @@ +@@ -915,13 +1386,20 @@ } public void reload() { @@ -1030,5 +1010,5 @@ } + // CraftBukkit end - } - } + this.sendAll(new PacketPlayOutTags(this.server.getTagRegistry())); + PacketPlayOutRecipeUpdate packetplayoutrecipeupdate = new PacketPlayOutRecipeUpdate(this.server.getCraftingManager().b()); diff --git a/paper-server/nms-patches/PortalTravelAgent.patch b/paper-server/nms-patches/PortalTravelAgent.patch index 0c1c4e78ce..fd81d2dcdf 100644 --- a/paper-server/nms-patches/PortalTravelAgent.patch +++ b/paper-server/nms-patches/PortalTravelAgent.patch @@ -12,7 +12,7 @@ public class PortalTravelAgent { -@@ -26,8 +31,21 @@ +@@ -27,8 +32,21 @@ int i = MathHelper.floor(entity.locX); int j = MathHelper.floor(entity.locY) - 1; int k = MathHelper.floor(entity.locZ); @@ -36,7 +36,7 @@ for (int l = -2; l <= 2; ++l) { for (int i1 = -2; i1 <= 2; ++i1) { -@@ -42,18 +60,63 @@ +@@ -43,18 +61,63 @@ } } @@ -94,7 +94,7 @@ + + public BlockPosition findPortal(double x, double y, double z, int radius) { + if (this.world.getWorld().getEnvironment() == org.bukkit.World.Environment.THE_END) { -+ return this.findEndPortal(this.world.worldProvider.h()); ++ return this.findEndPortal(this.world.worldProvider.d()); + } + // CraftBukkit end double d0 = -1.0D; @@ -107,7 +107,7 @@ boolean flag1 = true; Object object = BlockPosition.ZERO; long k = ChunkCoordIntPair.a(i, j); -@@ -66,12 +129,12 @@ +@@ -67,12 +130,12 @@ portaltravelagent_chunkcoordinatesportal.b = this.world.getTime(); flag1 = false; } else { @@ -120,12 +120,12 @@ - for (int i1 = -128; i1 <= 128; ++i1) { + for (int i1 = -radius; i1 <= radius; ++i1) { - for (BlockPosition blockposition2 = blockposition.a(l, this.world.ab() - 1 - blockposition.getY(), i1); blockposition2.getY() >= 0; blockposition2 = blockposition1) { + for (BlockPosition blockposition2 = blockposition.a(l, this.world.aa() - 1 - blockposition.getY(), i1); blockposition2.getY() >= 0; blockposition2 = blockposition1) { blockposition1 = blockposition2.down(); - if (this.world.getType(blockposition2).getBlock() == Blocks.PORTAL) { -@@ -95,6 +158,29 @@ + if (this.world.getType(blockposition2).getBlock() == PortalTravelAgent.a) { +@@ -96,6 +159,29 @@ if (flag1) { - this.c.put(k, new PortalTravelAgent.ChunkCoordinatesPortal((BlockPosition) object, this.world.getTime())); + this.d.put(k, new PortalTravelAgent.ChunkCoordinatesPortal((BlockPosition) object, this.world.getTime())); } + // CraftBukkit start - Move entity teleportation logic into exit + return (BlockPosition) object; @@ -153,7 +153,7 @@ double d2 = (double) ((BlockPosition) object).getX() + 0.5D; double d3 = (double) ((BlockPosition) object).getZ() + 0.5D; -@@ -132,30 +218,59 @@ +@@ -133,31 +219,59 @@ f4 = 1.0F; } @@ -165,6 +165,7 @@ - entity.yaw = f - (float) (entity.getPortalDirection().opposite().get2DRotationValue() * 90) + (float) (shapedetector_shapedetectorcollection.getFacing().get2DRotationValue() * 90); - if (entity instanceof EntityPlayer) { - ((EntityPlayer) entity).playerConnection.a(d2, d5, d3, entity.yaw, entity.pitch); +- ((EntityPlayer) entity).playerConnection.syncPosition(); - } else { - entity.setPositionRotation(d2, d5, d3, entity.yaw, entity.pitch); - } @@ -231,7 +232,7 @@ int l = i; int i1 = j; int j1 = k; -@@ -180,10 +295,10 @@ +@@ -182,10 +296,10 @@ double d4; for (i2 = i - 16; i2 <= i + 16; ++i2) { @@ -242,9 +243,9 @@ - d2 = (double) j2 + 0.5D - entity.locZ; + d2 = (double) j2 + 0.5D - z; // CraftBukkit - label271: - for (k2 = this.world.ab() - 1; k2 >= 0; --k2) { -@@ -215,7 +330,7 @@ + label257: + for (k2 = this.world.aa() - 1; k2 >= 0; --k2) { +@@ -217,7 +331,7 @@ } } @@ -253,7 +254,7 @@ d4 = d1 * d1 + d3 * d3 + d2 * d2; if (d0 < 0.0D || d4 < d0) { d0 = d4; -@@ -232,10 +347,10 @@ +@@ -234,10 +348,10 @@ if (d0 < 0.0D) { for (i2 = i - 16; i2 <= i + 16; ++i2) { @@ -264,9 +265,9 @@ - d2 = (double) j2 + 0.5D - entity.locZ; + d2 = (double) j2 + 0.5D - z; // CraftBukkit - label219: - for (k2 = this.world.ab() - 1; k2 >= 0; --k2) { -@@ -260,7 +375,7 @@ + label205: + for (k2 = this.world.aa() - 1; k2 >= 0; --k2) { +@@ -262,7 +376,7 @@ } } @@ -275,7 +276,7 @@ d4 = d1 * d1 + d3 * d3 + d2 * d2; if (d0 < 0.0D || d4 < d0) { d0 = d4; -@@ -359,5 +474,10 @@ +@@ -354,5 +468,10 @@ super(blockposition.getX(), blockposition.getY(), blockposition.getZ()); this.b = i; } diff --git a/paper-server/nms-patches/RecipeArmorDye.patch b/paper-server/nms-patches/RecipeArmorDye.patch index 02407e68bc..6a4959d538 100644 --- a/paper-server/nms-patches/RecipeArmorDye.patch +++ b/paper-server/nms-patches/RecipeArmorDye.patch @@ -1,18 +1,18 @@ --- a/net/minecraft/server/RecipeArmorDye.java +++ b/net/minecraft/server/RecipeArmorDye.java -@@ -3,9 +3,13 @@ +@@ -3,11 +3,13 @@ import com.google.common.collect.Lists; import java.util.ArrayList; --public class RecipeArmorDye implements IRecipe { +-public class RecipeArmorDye extends IRecipeComplex { +public class RecipeArmorDye extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends -- public RecipeArmorDye() {} + // CraftBukkit start - Delegate to new parent class with bogus info -+ public RecipeArmorDye() { -+ super("", new ItemStack(Items.LEATHER_HELMET, 0, 0), NonNullList.a(RecipeItemStack.a, RecipeItemStack.a(Items.DYE))); -+ } + public RecipeArmorDye(MinecraftKey minecraftkey) { +- super(minecraftkey); ++ super(minecraftkey, "", new ItemStack(Items.LEATHER_HELMET, 0), NonNullList.a(RecipeItemStack.a, RecipeItemStack.a(Items.BONE_MEAL))); + } + // CraftBukkit end - public boolean a(InventoryCrafting inventorycrafting, World world) { - ItemStack itemstack = ItemStack.a; + public boolean a(IInventory iinventory, World world) { + if (!(iinventory instanceof InventoryCrafting)) { diff --git a/paper-server/nms-patches/RecipeBannerAdd.patch b/paper-server/nms-patches/RecipeBannerAdd.patch new file mode 100644 index 0000000000..372051982b --- /dev/null +++ b/paper-server/nms-patches/RecipeBannerAdd.patch @@ -0,0 +1,18 @@ +--- a/net/minecraft/server/RecipeBannerAdd.java ++++ b/net/minecraft/server/RecipeBannerAdd.java +@@ -2,11 +2,13 @@ + + import javax.annotation.Nullable; + +-public class RecipeBannerAdd extends IRecipeComplex { ++public class RecipeBannerAdd extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends + ++ // CraftBukkit start - Delegate to new parent class with bogus info + public RecipeBannerAdd(MinecraftKey minecraftkey) { +- super(minecraftkey); ++ super(minecraftkey, "", new ItemStack(Items.WHITE_BANNER, 0), NonNullList.a(RecipeItemStack.a, RecipeItemStack.a(Items.WHITE_BANNER))); + } ++ // CraftBukkit end + + public boolean a(IInventory iinventory, World world) { + if (!(iinventory instanceof InventoryCrafting)) { diff --git a/paper-server/nms-patches/RecipeBannerDuplicate.patch b/paper-server/nms-patches/RecipeBannerDuplicate.patch new file mode 100644 index 0000000000..f4020aca74 --- /dev/null +++ b/paper-server/nms-patches/RecipeBannerDuplicate.patch @@ -0,0 +1,17 @@ +--- a/net/minecraft/server/RecipeBannerDuplicate.java ++++ b/net/minecraft/server/RecipeBannerDuplicate.java +@@ -1,10 +1,12 @@ + package net.minecraft.server; + +-public class RecipeBannerDuplicate extends IRecipeComplex { ++public class RecipeBannerDuplicate extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends + ++ // CraftBukkit start - Delegate to new parent class with bogus info + public RecipeBannerDuplicate(MinecraftKey minecraftkey) { +- super(minecraftkey); ++ super(minecraftkey, "", new ItemStack(Items.WHITE_BANNER, 0), NonNullList.a(RecipeItemStack.a, RecipeItemStack.a(Items.WHITE_BANNER))); + } ++ // CraftBukkit end + + public boolean a(IInventory iinventory, World world) { + if (!(iinventory instanceof InventoryCrafting)) { diff --git a/paper-server/nms-patches/RecipeBookClone.patch b/paper-server/nms-patches/RecipeBookClone.patch index d5417aa5ed..3db8854686 100644 --- a/paper-server/nms-patches/RecipeBookClone.patch +++ b/paper-server/nms-patches/RecipeBookClone.patch @@ -1,16 +1,17 @@ --- a/net/minecraft/server/RecipeBookClone.java +++ b/net/minecraft/server/RecipeBookClone.java -@@ -1,8 +1,11 @@ +@@ -1,10 +1,12 @@ package net.minecraft.server; --public class RecipeBookClone implements IRecipe { +-public class RecipeBookClone extends IRecipeComplex { +public class RecipeBookClone extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends -- public RecipeBookClone() {} -+ public RecipeBookClone() { -+ super("", new ItemStack(Items.WRITTEN_BOOK, 0, -1), NonNullList.a(RecipeItemStack.a, RecipeItemStack.a(Items.WRITABLE_BOOK))); -+ } ++ // CraftBukkit start - Delegate to new parent class with bogus info + public RecipeBookClone(MinecraftKey minecraftkey) { +- super(minecraftkey); ++ super(minecraftkey, "", new ItemStack(Items.WRITTEN_BOOK, 0), NonNullList.a(RecipeItemStack.a, RecipeItemStack.a(Items.WRITABLE_BOOK))); + } + // CraftBukkit end - public boolean a(InventoryCrafting inventorycrafting, World world) { - int i = 0; + public boolean a(IInventory iinventory, World world) { + if (!(iinventory instanceof InventoryCrafting)) { diff --git a/paper-server/nms-patches/RecipeFireworks.patch b/paper-server/nms-patches/RecipeFireworks.patch index 43478e0282..22a7a3b8b7 100644 --- a/paper-server/nms-patches/RecipeFireworks.patch +++ b/paper-server/nms-patches/RecipeFireworks.patch @@ -1,20 +1,21 @@ --- a/net/minecraft/server/RecipeFireworks.java +++ b/net/minecraft/server/RecipeFireworks.java -@@ -3,13 +3,16 @@ - import com.google.common.collect.Lists; - import java.util.ArrayList; +@@ -1,14 +1,16 @@ + package net.minecraft.server; --public class RecipeFireworks implements IRecipe { +-public class RecipeFireworks extends IRecipeComplex { +public class RecipeFireworks extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends - private ItemStack a; + private static final RecipeItemStack a = RecipeItemStack.a(new IMaterial[] { Items.PAPER}); + private static final RecipeItemStack b = RecipeItemStack.a(new IMaterial[] { Items.GUNPOWDER}); + private static final RecipeItemStack c = RecipeItemStack.a(new IMaterial[] { Items.FIREWORK_STAR}); + // CraftBukkit start - Delegate to new parent class with bogus info - public RecipeFireworks() { -+ super("", new ItemStack(Items.FIREWORKS, 0, 0), NonNullList.a(RecipeItemStack.a, RecipeItemStack.a(Items.GUNPOWDER))); - this.a = ItemStack.a; + public RecipeFireworks(MinecraftKey minecraftkey) { +- super(minecraftkey); ++ super(minecraftkey, "", new ItemStack(Items.FIREWORK_ROCKET, 0), NonNullList.a(RecipeItemStack.a, RecipeItemStack.a(Items.GUNPOWDER))); } + // CraftBukkit end - public boolean a(InventoryCrafting inventorycrafting, World world) { - this.a = ItemStack.a; + public boolean a(IInventory iinventory, World world) { + if (!(iinventory instanceof InventoryCrafting)) { diff --git a/paper-server/nms-patches/RecipeFireworksFade.patch b/paper-server/nms-patches/RecipeFireworksFade.patch new file mode 100644 index 0000000000..31b863eb6b --- /dev/null +++ b/paper-server/nms-patches/RecipeFireworksFade.patch @@ -0,0 +1,20 @@ +--- a/net/minecraft/server/RecipeFireworksFade.java ++++ b/net/minecraft/server/RecipeFireworksFade.java +@@ -4,13 +4,15 @@ + import java.util.ArrayList; + import java.util.List; + +-public class RecipeFireworksFade extends IRecipeComplex { ++public class RecipeFireworksFade extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends + + private static final RecipeItemStack a = RecipeItemStack.a(new IMaterial[] { Items.FIREWORK_STAR}); + ++ // CraftBukkit start - Delegate to new parent class with bogus info + public RecipeFireworksFade(MinecraftKey minecraftkey) { +- super(minecraftkey); ++ super(minecraftkey, "", new ItemStack(Items.FIREWORK_STAR, 0), NonNullList.a(RecipeItemStack.a, RecipeItemStack.a(Items.FIREWORK_STAR, Items.BONE_MEAL))); + } ++ // CraftBukkit end + + public boolean a(IInventory iinventory, World world) { + if (!(iinventory instanceof InventoryCrafting)) { diff --git a/paper-server/nms-patches/RecipeFireworksStar.patch b/paper-server/nms-patches/RecipeFireworksStar.patch new file mode 100644 index 0000000000..e490056593 --- /dev/null +++ b/paper-server/nms-patches/RecipeFireworksStar.patch @@ -0,0 +1,30 @@ +--- a/net/minecraft/server/RecipeFireworksStar.java ++++ b/net/minecraft/server/RecipeFireworksStar.java +@@ -8,12 +8,12 @@ + import java.util.Map; + import java.util.function.Consumer; + +-public class RecipeFireworksStar extends IRecipeComplex { ++public class RecipeFireworksStar extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends + + private static final RecipeItemStack a = RecipeItemStack.a(new IMaterial[] { Items.FIRE_CHARGE, Items.FEATHER, Items.GOLD_NUGGET, Items.SKELETON_SKULL, Items.WITHER_SKELETON_SKULL, Items.CREEPER_HEAD, Items.PLAYER_HEAD, Items.DRAGON_HEAD, Items.ZOMBIE_HEAD}); + private static final RecipeItemStack b = RecipeItemStack.a(new IMaterial[] { Items.DIAMOND}); + private static final RecipeItemStack c = RecipeItemStack.a(new IMaterial[] { Items.GLOWSTONE_DUST}); +- private static final Map d = (Map) SystemUtils.a((Object) Maps.newHashMap(), (hashmap) -> { ++ private static final Map d = (Map) SystemUtils.a(Maps.newHashMap(), (hashmap) -> { // CraftBukkit - decompile error + hashmap.put(Items.FIRE_CHARGE, ItemFireworks.EffectType.LARGE_BALL); + hashmap.put(Items.FEATHER, ItemFireworks.EffectType.BURST); + hashmap.put(Items.GOLD_NUGGET, ItemFireworks.EffectType.STAR); +@@ -26,9 +26,11 @@ + }); + private static final RecipeItemStack e = RecipeItemStack.a(new IMaterial[] { Items.GUNPOWDER}); + ++ // CraftBukkit start - Delegate to new parent class with bogus info + public RecipeFireworksStar(MinecraftKey minecraftkey) { +- super(minecraftkey); ++ super(minecraftkey, "", new ItemStack(Items.FIREWORK_STAR, 0), NonNullList.a(RecipeItemStack.a, RecipeItemStack.a(Items.GUNPOWDER))); + } ++ // CraftBukkit end + + public boolean a(IInventory iinventory, World world) { + if (!(iinventory instanceof InventoryCrafting)) { diff --git a/paper-server/nms-patches/RecipeMapClone.patch b/paper-server/nms-patches/RecipeMapClone.patch index 0405727243..b801676511 100644 --- a/paper-server/nms-patches/RecipeMapClone.patch +++ b/paper-server/nms-patches/RecipeMapClone.patch @@ -1,17 +1,17 @@ --- a/net/minecraft/server/RecipeMapClone.java +++ b/net/minecraft/server/RecipeMapClone.java -@@ -1,8 +1,12 @@ +@@ -1,10 +1,12 @@ package net.minecraft.server; --public class RecipeMapClone implements IRecipe { +-public class RecipeMapClone extends IRecipeComplex { +public class RecipeMapClone extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends -- public RecipeMapClone() {} + // CraftBukkit start - Delegate to new parent class -+ public RecipeMapClone() { -+ super("", new ItemStack(Items.MAP, 0, -1), NonNullList.a(RecipeItemStack.a, RecipeItemStack.a(Items.MAP))); -+ } + public RecipeMapClone(MinecraftKey minecraftkey) { +- super(minecraftkey); ++ super(minecraftkey, "", new ItemStack(Items.MAP, 0), NonNullList.a(RecipeItemStack.a, RecipeItemStack.a(Items.MAP))); + } + // CraftBukkit end - public boolean a(InventoryCrafting inventorycrafting, World world) { - int i = 0; + public boolean a(IInventory iinventory, World world) { + if (!(iinventory instanceof InventoryCrafting)) { diff --git a/paper-server/nms-patches/RecipeRepair.patch b/paper-server/nms-patches/RecipeRepair.patch index 7deebd5c74..388dbc10ab 100644 --- a/paper-server/nms-patches/RecipeRepair.patch +++ b/paper-server/nms-patches/RecipeRepair.patch @@ -1,38 +1,38 @@ --- a/net/minecraft/server/RecipeRepair.java +++ b/net/minecraft/server/RecipeRepair.java -@@ -3,9 +3,13 @@ +@@ -2,12 +2,15 @@ + import com.google.common.collect.Lists; import java.util.ArrayList; ++import java.util.stream.Stream; --public class RecipeRepair implements IRecipe { +-public class RecipeRepair extends IRecipeComplex { +public class RecipeRepair extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends -- public RecipeRepair() {} + // CraftBukkit start - Delegate to new parent class -+ public RecipeRepair() { -+ super("", new ItemStack(Items.LEATHER_HELMET), NonNullList.a(RecipeItemStack.a, RecipeItemStack.a(Items.LEATHER_HELMET))); -+ } + public RecipeRepair(MinecraftKey minecraftkey) { +- super(minecraftkey); ++ super(minecraftkey, "", new ItemStack(Items.LEATHER_HELMET), NonNullList.a(RecipeItemStack.a, RecipeItemStack.a(Items.LEATHER_HELMET))); + } + // CraftBukkit end - public boolean a(InventoryCrafting inventorycrafting, World world) { - ArrayList arraylist = Lists.newArrayList(); -@@ -62,7 +66,18 @@ - i1 = 0; - } + public boolean a(IInventory iinventory, World world) { + if (!(iinventory instanceof InventoryCrafting)) { +@@ -71,6 +74,17 @@ + ItemStack itemstack3 = new ItemStack(itemstack2.getItem()); -- return new ItemStack(itemstack2.getItem(), 1, i1); + itemstack3.setDamage(i1); + // CraftBukkit start - Construct a dummy repair recipe -+ ItemStack result = new ItemStack(itemstack.getItem(), 1, i1); -+ NonNullList ingredients = NonNullList.a(); -+ ingredients.add(RecipeItemStack.a(new ItemStack[]{itemstack2.cloneItemStack()})); -+ ingredients.add(RecipeItemStack.a(new ItemStack[]{itemstack.cloneItemStack()})); -+ ShapelessRecipes recipe = new ShapelessRecipes("", result.cloneItemStack(), ingredients); -+ recipe.key = new MinecraftKey("repairitem"); -+ inventorycrafting.currentRecipe = recipe; -+ result = org.bukkit.craftbukkit.event.CraftEventFactory.callPreCraftEvent(inventorycrafting, result, inventorycrafting.container.getBukkitView(), true); -+ return result; -+ // return new ItemStack(itemstack2.getItem(), 1, i1); ++ if (iinventory instanceof InventoryCrafting) { ++ InventoryCrafting inventorycrafting = (InventoryCrafting) iinventory; ++ NonNullList 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/paper-server/nms-patches/RecipeShulkerBox.patch b/paper-server/nms-patches/RecipeShulkerBox.patch index f3eab88bd6..65eefa1ee3 100644 --- a/paper-server/nms-patches/RecipeShulkerBox.patch +++ b/paper-server/nms-patches/RecipeShulkerBox.patch @@ -1,20 +1,17 @@ --- a/net/minecraft/server/RecipeShulkerBox.java +++ b/net/minecraft/server/RecipeShulkerBox.java -@@ -1,8 +1,15 @@ +@@ -1,10 +1,12 @@ package net.minecraft.server; --public class RecipeShulkerBox { public static class Dye implements IRecipe { -+// CraftBukkit - decompile weirdness -+public class RecipeShulkerBox { +-public class RecipeShulkerBox extends IRecipeComplex { ++public class RecipeShulkerBox extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends -- public Dye() {} -+ public static class Dye extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends -+ -+ // CraftBukkit start - Delegate to new parent class with bogus info -+ public Dye() { -+ super("", new ItemStack(Blocks.WHITE_SHULKER_BOX, 0, 0), NonNullList.a(RecipeItemStack.a, RecipeItemStack.a(Items.DYE))); -+ } -+ // CraftBukkit end ++ // CraftBukkit start - Delegate to new parent class with bogus info + public RecipeShulkerBox(MinecraftKey minecraftkey) { +- super(minecraftkey); ++ super(minecraftkey, "", new ItemStack(Blocks.WHITE_SHULKER_BOX, 0), NonNullList.a(RecipeItemStack.a, RecipeItemStack.a(Items.BONE_MEAL))); + } ++ // CraftBukkit end - public boolean a(InventoryCrafting inventorycrafting, World world) { - int i = 0; + public boolean a(IInventory iinventory, World world) { + if (!(iinventory instanceof InventoryCrafting)) { diff --git a/paper-server/nms-patches/RecipeTippedArrow.patch b/paper-server/nms-patches/RecipeTippedArrow.patch index 04840d4f2b..2e2e84caa0 100644 --- a/paper-server/nms-patches/RecipeTippedArrow.patch +++ b/paper-server/nms-patches/RecipeTippedArrow.patch @@ -1,22 +1,22 @@ --- a/net/minecraft/server/RecipeTippedArrow.java +++ b/net/minecraft/server/RecipeTippedArrow.java -@@ -2,9 +2,17 @@ +@@ -2,11 +2,17 @@ import java.util.Collection; --public class RecipeTippedArrow implements IRecipe { +-public class RecipeTippedArrow extends IRecipeComplex { +public class RecipeTippedArrow extends ShapedRecipes implements IRecipe { // CraftBukkit -- public RecipeTippedArrow() {} + // CraftBukkit start -+ public RecipeTippedArrow() { -+ super("", 3, 3, NonNullList.a(RecipeItemStack.a, + public RecipeTippedArrow(MinecraftKey minecraftkey) { +- super(minecraftkey); ++ super(minecraftkey, "", 3, 3, NonNullList.a(RecipeItemStack.a, + RecipeItemStack.a(Items.ARROW), RecipeItemStack.a(Items.ARROW), RecipeItemStack.a(Items.ARROW), + RecipeItemStack.a(Items.ARROW), RecipeItemStack.a(Items.LINGERING_POTION), RecipeItemStack.a(Items.ARROW), + RecipeItemStack.a(Items.ARROW), RecipeItemStack.a(Items.ARROW), RecipeItemStack.a(Items.ARROW)), + new ItemStack(Items.TIPPED_ARROW, 8)); -+ } + } + // CraftBukkit end - public boolean a(InventoryCrafting inventorycrafting, World world) { - if (inventorycrafting.j() == 3 && inventorycrafting.i() == 3) { + public boolean a(IInventory iinventory, World world) { + if (iinventory.U_() == 3 && iinventory.n() == 3) { diff --git a/paper-server/nms-patches/RecipesBanner.patch b/paper-server/nms-patches/RecipesBanner.patch deleted file mode 100644 index 293911afe8..0000000000 --- a/paper-server/nms-patches/RecipesBanner.patch +++ /dev/null @@ -1,37 +0,0 @@ ---- a/net/minecraft/server/RecipesBanner.java -+++ b/net/minecraft/server/RecipesBanner.java -@@ -2,9 +2,16 @@ - - import javax.annotation.Nullable; - --public class RecipesBanner { public static class AddRecipe implements IRecipe { -+// CraftBukkit - decompile weirdness -+public class RecipesBanner { - -- public AddRecipe() {} -+ public static class AddRecipe extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends -+ -+ // CraftBukkit start - Delegate to new parent class with bogus info -+ public AddRecipe() { -+ super("", new ItemStack(Items.BANNER, 0, 0), NonNullList.a(RecipeItemStack.a, RecipeItemStack.a(Items.BANNER))); -+ } -+ // CraftBukkit end - - public boolean a(InventoryCrafting inventorycrafting, World world) { - boolean flag = false; -@@ -186,9 +193,13 @@ - } - } - -- public static class DuplicateRecipe implements IRecipe { -+ public static class DuplicateRecipe extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends - -- public DuplicateRecipe() {} -+ // CraftBukkit start - Delegate to new parent class with bogus info -+ public DuplicateRecipe() { -+ super("", new ItemStack(Items.BANNER, 0, 0), NonNullList.a(RecipeItemStack.a, RecipeItemStack.a(Items.DYE))); -+ } -+ // CraftBukkit end - - public boolean a(InventoryCrafting inventorycrafting, World world) { - ItemStack itemstack = ItemStack.a; diff --git a/paper-server/nms-patches/RecipesFurnace.patch b/paper-server/nms-patches/RecipesFurnace.patch deleted file mode 100644 index ccc7b3335d..0000000000 --- a/paper-server/nms-patches/RecipesFurnace.patch +++ /dev/null @@ -1,80 +0,0 @@ ---- a/net/minecraft/server/RecipesFurnace.java -+++ b/net/minecraft/server/RecipesFurnace.java -@@ -8,8 +8,10 @@ - public class RecipesFurnace { - - private static final RecipesFurnace a = new RecipesFurnace(); -- public final Map recipes = Maps.newHashMap(); -+ public Map recipes = Maps.newHashMap(); - private final Map experience = Maps.newHashMap(); -+ public Map customRecipes = Maps.newHashMap(); // CraftBukkit - add field -+ public Map customExperience = Maps.newHashMap(); // CraftBukkit - add field - - public static RecipesFurnace getInstance() { - return RecipesFurnace.a; -@@ -94,6 +96,13 @@ - this.a(new ItemStack(Blocks.STAINED_HARDENED_CLAY, 1, EnumColor.BLACK.getColorIndex()), new ItemStack(Blocks.dQ), 0.1F); - } - -+ // CraftBukkit start - add method -+ public void registerRecipe(ItemStack itemstack, ItemStack itemstack1, float f) { -+ this.customRecipes.put(itemstack, itemstack1); -+ this.customExperience.put(itemstack, f); -+ } -+ // CraftBukkit end -+ - public void registerRecipe(Block block, ItemStack itemstack, float f) { - this.a(Item.getItemOf(block), itemstack, f); - } -@@ -108,13 +117,23 @@ - } - - public ItemStack getResult(ItemStack itemstack) { -- Iterator iterator = this.recipes.entrySet().iterator(); -+ // CraftBukkit start - initialize to customRecipes -+ boolean vanilla = false; -+ Iterator> iterator = this.customRecipes.entrySet().iterator(); -+ // CraftBukkit end - - Entry entry; - - do { - if (!iterator.hasNext()) { -- return ItemStack.a; -+ // CraftBukkit start - fall back to vanilla recipes -+ if (!vanilla && !this.recipes.isEmpty()) { -+ iterator = this.recipes.entrySet().iterator(); -+ vanilla = true; -+ } else { -+ return ItemStack.a; -+ } -+ // CraftBukkit end - } - - entry = (Entry) iterator.next(); -@@ -132,13 +151,23 @@ - } - - public float b(ItemStack itemstack) { -- Iterator iterator = this.experience.entrySet().iterator(); -+ // CraftBukkit start - initialize to customRecipes -+ boolean vanilla = false; -+ Iterator> iterator = this.customExperience.entrySet().iterator(); -+ // CraftBukkit end - - Entry entry; - - do { - if (!iterator.hasNext()) { -- return 0.0F; -+ // CraftBukkit start - fall back to vanilla recipes -+ if (!vanilla && !this.experience.isEmpty()) { -+ iterator = this.experience.entrySet().iterator(); -+ vanilla = true; -+ } else { -+ return 0.0F; -+ } -+ // CraftBukkit end - } - - entry = (Entry) iterator.next(); diff --git a/paper-server/nms-patches/RecipiesShield.patch b/paper-server/nms-patches/RecipiesShield.patch index bfdd5ea222..39ab5d66c5 100644 --- a/paper-server/nms-patches/RecipiesShield.patch +++ b/paper-server/nms-patches/RecipiesShield.patch @@ -1,20 +1,17 @@ --- a/net/minecraft/server/RecipiesShield.java +++ b/net/minecraft/server/RecipiesShield.java -@@ -1,8 +1,15 @@ +@@ -1,10 +1,12 @@ package net.minecraft.server; --public class RecipiesShield { public static class Decoration implements IRecipe { -+// CraftBukkit - decompile weirdness -+public class RecipiesShield { +-public class RecipiesShield extends IRecipeComplex { ++public class RecipiesShield extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends -- public Decoration() {} -+ public static class Decoration extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends -+ -+ // CraftBukkit start - Delegate to new parent class with bogus info -+ public Decoration() { -+ super("", new ItemStack(Items.SHIELD, 0, 0), NonNullList.a(RecipeItemStack.a, RecipeItemStack.a(Items.BANNER))); -+ } -+ // CraftBukkit end ++ // CraftBukkit start - Delegate to new parent class with bogus info + public RecipiesShield(MinecraftKey minecraftkey) { +- super(minecraftkey); ++ super(minecraftkey, "", new ItemStack(Items.SHIELD, 0), NonNullList.a(RecipeItemStack.a, RecipeItemStack.a(Items.WHITE_BANNER))); + } ++ // CraftBukkit end - public boolean a(InventoryCrafting inventorycrafting, World world) { - ItemStack itemstack = ItemStack.a; + public boolean a(IInventory iinventory, World world) { + if (!(iinventory instanceof InventoryCrafting)) { diff --git a/paper-server/nms-patches/RegionFileCache.patch b/paper-server/nms-patches/RegionFileCache.patch index 84697d79f5..c91a0f6067 100644 --- a/paper-server/nms-patches/RegionFileCache.patch +++ b/paper-server/nms-patches/RegionFileCache.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/server/RegionFileCache.java +++ b/net/minecraft/server/RegionFileCache.java -@@ -74,17 +74,27 @@ - RegionFileCache.a.clear(); +@@ -76,18 +76,28 @@ } + @Nullable - public static DataInputStream d(File file, int i, int j) { + // CraftBukkit start - call sites hoisted for synchronization + public static synchronized NBTTagCompound d(File file, int i, int j) throws IOException { @@ -19,6 +19,7 @@ + return NBTCompressedStreamTools.a(datainputstream); } + @Nullable - public static DataOutputStream e(File file, int i, int j) { + public static synchronized void e(File file, int i, int j, NBTTagCompound nbttagcompound) throws IOException { RegionFile regionfile = a(file, i, j); diff --git a/paper-server/nms-patches/RegionLimitedWorldAccess.patch b/paper-server/nms-patches/RegionLimitedWorldAccess.patch new file mode 100644 index 0000000000..7e68d92633 --- /dev/null +++ b/paper-server/nms-patches/RegionLimitedWorldAccess.patch @@ -0,0 +1,30 @@ +--- a/net/minecraft/server/RegionLimitedWorldAccess.java ++++ b/net/minecraft/server/RegionLimitedWorldAccess.java +@@ -25,10 +25,10 @@ + private final Random k; + private final WorldProvider l; + private final GeneratorSettings m; +- private final TickList n = new TickListWorldGen((blockposition) -> { ++ private final TickList n = new TickListWorldGen<>((blockposition) -> { // CraftBukkit - decompile error + return this.y(blockposition).k(); + }); +- private final TickList o = new TickListWorldGen((blockposition) -> { ++ private final TickList o = new TickListWorldGen<>((blockposition) -> { // CraftBukkit - decompile error + return this.y(blockposition).l(); + }); + +@@ -204,7 +204,14 @@ + this.y(blockposition).e(blockposition); + } + ++ // CraftBukkit start + public boolean addEntity(Entity entity) { ++ return addEntity(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT); ++ } ++ ++ @Override ++ public boolean addEntity(Entity entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) { ++ // CraftBukkit end + int i = MathHelper.floor(entity.locX / 16.0D); + int j = MathHelper.floor(entity.locZ / 16.0D); + diff --git a/paper-server/nms-patches/RemoteControlCommandListener.patch b/paper-server/nms-patches/RemoteControlCommandListener.patch index 22369f8904..def02f17e1 100644 --- a/paper-server/nms-patches/RemoteControlCommandListener.patch +++ b/paper-server/nms-patches/RemoteControlCommandListener.patch @@ -1,15 +1,20 @@ --- a/net/minecraft/server/RemoteControlCommandListener.java +++ b/net/minecraft/server/RemoteControlCommandListener.java -@@ -21,6 +21,12 @@ - return "Rcon"; +@@ -23,6 +23,17 @@ + return new CommandListenerWrapper(this, new Vec3D(worldserver.getSpawn()), Vec2F.a, worldserver, 4, "Recon", new ChatComponentText("Rcon"), this.b, (Entity) null); } + // CraftBukkit start - Send a String + public void sendMessage(String message) { + this.a.append(message); + } ++ ++ @Override ++ public org.bukkit.command.CommandSender getBukkitSender(CommandListenerWrapper wrapper) { ++ return b.remoteConsole; ++ } + // CraftBukkit end + public void sendMessage(IChatBaseComponent ichatbasecomponent) { - this.a.append(ichatbasecomponent.toPlainText()); + this.a.append(ichatbasecomponent.getString()); } diff --git a/paper-server/nms-patches/ScoreboardServer.patch b/paper-server/nms-patches/ScoreboardServer.patch index 36e6f5ec59..d441899002 100644 --- a/paper-server/nms-patches/ScoreboardServer.patch +++ b/paper-server/nms-patches/ScoreboardServer.patch @@ -1,31 +1,32 @@ --- a/net/minecraft/server/ScoreboardServer.java +++ b/net/minecraft/server/ScoreboardServer.java -@@ -21,7 +21,7 @@ +@@ -22,7 +22,7 @@ public void handleScoreChanged(ScoreboardScore scoreboardscore) { super.handleScoreChanged(scoreboardscore); if (this.b.contains(scoreboardscore.getObjective())) { -- this.a.getPlayerList().sendAll(new PacketPlayOutScoreboardScore(scoreboardscore)); -+ this.sendAll(new PacketPlayOutScoreboardScore(scoreboardscore)); +- this.a.getPlayerList().sendAll(new PacketPlayOutScoreboardScore(ScoreboardServer.Action.CHANGE, scoreboardscore.getObjective().getName(), scoreboardscore.getPlayerName(), scoreboardscore.getScore())); ++ this.sendAll(new PacketPlayOutScoreboardScore(ScoreboardServer.Action.CHANGE, scoreboardscore.getObjective().getName(), scoreboardscore.getPlayerName(), scoreboardscore.getScore())); } this.b(); -@@ -29,13 +29,13 @@ +@@ -30,14 +30,14 @@ public void handlePlayerRemoved(String s) { super.handlePlayerRemoved(s); -- this.a.getPlayerList().sendAll(new PacketPlayOutScoreboardScore(s)); -+ this.sendAll(new PacketPlayOutScoreboardScore(s)); +- this.a.getPlayerList().sendAll(new PacketPlayOutScoreboardScore(ScoreboardServer.Action.REMOVE, (String) null, s, 0)); ++ this.sendAll(new PacketPlayOutScoreboardScore(ScoreboardServer.Action.REMOVE, (String) null, s, 0)); this.b(); } public void a(String s, ScoreboardObjective scoreboardobjective) { super.a(s, scoreboardobjective); -- this.a.getPlayerList().sendAll(new PacketPlayOutScoreboardScore(s, scoreboardobjective)); -+ this.sendAll(new PacketPlayOutScoreboardScore(s, scoreboardobjective)); - this.b(); - } + if (this.b.contains(scoreboardobjective)) { +- this.a.getPlayerList().sendAll(new PacketPlayOutScoreboardScore(ScoreboardServer.Action.REMOVE, scoreboardobjective.getName(), s, 0)); ++ this.sendAll(new PacketPlayOutScoreboardScore(ScoreboardServer.Action.REMOVE, scoreboardobjective.getName(), s, 0)); + } -@@ -45,7 +45,7 @@ + this.b(); +@@ -49,7 +49,7 @@ super.setDisplaySlot(i, scoreboardobjective); if (scoreboardobjective1 != scoreboardobjective && scoreboardobjective1 != null) { if (this.h(scoreboardobjective1) > 0) { @@ -34,7 +35,7 @@ } else { this.g(scoreboardobjective1); } -@@ -53,7 +53,7 @@ +@@ -57,7 +57,7 @@ if (scoreboardobjective != null) { if (this.b.contains(scoreboardobjective)) { @@ -43,16 +44,16 @@ } else { this.e(scoreboardobjective); } -@@ -66,7 +66,7 @@ - if (super.addPlayerToTeam(s, s1)) { - ScoreboardTeam scoreboardteam = this.getTeam(s1); +@@ -68,7 +68,7 @@ + public boolean addPlayerToTeam(String s, ScoreboardTeam scoreboardteam) { + if (super.addPlayerToTeam(s, scoreboardteam)) { - this.a.getPlayerList().sendAll(new PacketPlayOutScoreboardTeam(scoreboardteam, Arrays.asList(new String[] { s}), 3)); + this.sendAll(new PacketPlayOutScoreboardTeam(scoreboardteam, Arrays.asList(new String[] { s}), 3)); this.b(); return true; } else { -@@ -76,7 +76,7 @@ +@@ -78,7 +78,7 @@ public void removePlayerFromTeam(String s, ScoreboardTeam scoreboardteam) { super.removePlayerFromTeam(s, scoreboardteam); @@ -61,7 +62,7 @@ this.b(); } -@@ -88,7 +88,7 @@ +@@ -90,7 +90,7 @@ public void handleObjectiveChanged(ScoreboardObjective scoreboardobjective) { super.handleObjectiveChanged(scoreboardobjective); if (this.b.contains(scoreboardobjective)) { @@ -70,7 +71,7 @@ } this.b(); -@@ -105,19 +105,19 @@ +@@ -107,19 +107,19 @@ public void handleTeamAdded(ScoreboardTeam scoreboardteam) { super.handleTeamAdded(scoreboardteam); @@ -93,7 +94,7 @@ this.b(); } -@@ -166,6 +166,7 @@ +@@ -168,6 +168,7 @@ while (iterator.hasNext()) { EntityPlayer entityplayer = (EntityPlayer) iterator.next(); @@ -101,7 +102,7 @@ Iterator iterator1 = list.iterator(); while (iterator1.hasNext()) { -@@ -198,6 +199,7 @@ +@@ -200,6 +201,7 @@ while (iterator.hasNext()) { EntityPlayer entityplayer = (EntityPlayer) iterator.next(); @@ -109,11 +110,10 @@ Iterator iterator1 = list.iterator(); while (iterator1.hasNext()) { -@@ -221,4 +223,14 @@ - +@@ -224,6 +226,16 @@ return i; } -+ + + // CraftBukkit start - Send to players + private void sendAll(Packet packet) { + for (EntityPlayer entityplayer : (List) this.a.getPlayerList().players) { @@ -123,4 +123,7 @@ + } + } + // CraftBukkit end - } ++ + public static enum Action { + + CHANGE, REMOVE; diff --git a/paper-server/nms-patches/ScoreboardTeam.patch b/paper-server/nms-patches/ScoreboardTeam.patch new file mode 100644 index 0000000000..7e9da9c2b4 --- /dev/null +++ b/paper-server/nms-patches/ScoreboardTeam.patch @@ -0,0 +1,47 @@ +--- a/net/minecraft/server/ScoreboardTeam.java ++++ b/net/minecraft/server/ScoreboardTeam.java +@@ -36,7 +36,7 @@ + } + + public String getDisplayName() { +- return this.d; ++ return this.prefix + this.d + this.suffix; // CraftBukkit + } + + public IChatBaseComponent d() { +@@ -165,4 +165,35 @@ + public EnumChatFormat getColor() { + return this.k; + } ++ ++ // CraftBukkit start ++ private String prefix; ++ private String suffix; ++ ++ public String getPrefix() { ++ return prefix; ++ } ++ ++ public void setPrefix(String prefix) { ++ if (prefix == null) { ++ throw new IllegalArgumentException("Prefix cannot be null"); ++ } ++ ++ this.prefix = prefix; ++ this.a.handleTeamChanged(this); ++ } ++ ++ public String getSuffix() { ++ return suffix; ++ } ++ ++ public void setSuffix(String suffix) { ++ if (prefix == null) { ++ throw new IllegalArgumentException("Suffix cannot be null"); ++ } ++ ++ this.suffix = suffix; ++ this.a.handleTeamChanged(this); ++ } ++ // CraftBukkit end + } diff --git a/paper-server/nms-patches/SecondaryWorldServer.patch b/paper-server/nms-patches/SecondaryWorldServer.patch index f05e64bbee..f92f953142 100644 --- a/paper-server/nms-patches/SecondaryWorldServer.patch +++ b/paper-server/nms-patches/SecondaryWorldServer.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/SecondaryWorldServer.java +++ b/net/minecraft/server/SecondaryWorldServer.java -@@ -4,9 +4,12 @@ +@@ -6,9 +6,12 @@ private final WorldServer a; @@ -15,7 +15,7 @@ worldserver.getWorldBorder().a(new IWorldBorderListener() { public void a(WorldBorder worldborder, double d0) { SecondaryWorldServer.this.getWorldBorder().setSize(d0); -@@ -36,9 +39,10 @@ +@@ -38,9 +41,10 @@ SecondaryWorldServer.this.getWorldBorder().setDamageBuffer(d0); } }); @@ -25,9 +25,9 @@ - protected void a() {} + // protected void a() {} // CraftBukkit - public World b() { - this.worldMaps = this.a.Z(); -@@ -56,7 +60,7 @@ + public GeneratorAccess b() { + this.worldMaps = this.a.s_(); +@@ -55,7 +59,7 @@ this.villages.a((World) this); } @@ -35,4 +35,4 @@ + return super.b(); // CraftBukkit } - public void c() { + public void t_() { diff --git a/paper-server/nms-patches/ShapedRecipes.patch b/paper-server/nms-patches/ShapedRecipes.patch index e5c8474d70..b68788a112 100644 --- a/paper-server/nms-patches/ShapedRecipes.patch +++ b/paper-server/nms-patches/ShapedRecipes.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/server/ShapedRecipes.java +++ b/net/minecraft/server/ShapedRecipes.java -@@ -14,6 +14,10 @@ +@@ -13,6 +13,10 @@ + import java.util.Iterator; import java.util.Map; import java.util.Map.Entry; - import javax.annotation.Nullable; +// CraftBukkit start +import org.bukkit.craftbukkit.inventory.CraftItemStack; +import org.bukkit.craftbukkit.inventory.CraftShapedRecipe; @@ -11,22 +11,7 @@ public class ShapedRecipes implements IRecipe { -@@ -22,6 +26,14 @@ - private final NonNullList items; - private final ItemStack result; - private final String e; -+ // CraftBukkit start -+ public MinecraftKey key; -+ -+ @Override -+ public void setKey(MinecraftKey key) { -+ this.key = key; -+ } -+ // CraftBukkit end - - public ShapedRecipes(String s, int i, int j, NonNullList nonnulllist, ItemStack itemstack) { - this.e = s; -@@ -31,6 +43,63 @@ +@@ -32,6 +36,64 @@ this.result = itemstack; } @@ -77,9 +62,10 @@ + } + char c = 'a'; + for (RecipeItemStack list : this.items) { -+ if (list != null && list.choices.length > 0) { ++ list.buildChoices(); ++ if (list.choices.length > 0) { + net.minecraft.server.ItemStack stack = list.choices[0]; -+ recipe.setIngredient(c, org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(stack.getItem()), (list.choices.length) > 1 ? 32767 : stack.getData()); ++ recipe.setIngredient(c, org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(stack.getItem()), (list.choices.length) > 1 ? 32767 : 0); + } + c++; + } @@ -87,6 +73,20 @@ + } + // CraftBukkit end + - public ItemStack b() { - return this.result; + public MinecraftKey getKey() { + return this.e; + } +@@ -302,11 +364,11 @@ + packetdataserializer.a(shapedrecipes.result); + } + +- public IRecipe a(MinecraftKey minecraftkey, PacketDataSerializer packetdataserializer) { ++ public ShapedRecipes a(MinecraftKey minecraftkey, PacketDataSerializer packetdataserializer) { // CraftBukkit - decompile error + return this.b(minecraftkey, packetdataserializer); + } + +- public IRecipe a(MinecraftKey minecraftkey, JsonObject jsonobject) { ++ public ShapedRecipes a(MinecraftKey minecraftkey, JsonObject jsonobject) { // CraftBukkit - decompile error + return this.b(minecraftkey, jsonobject); + } } diff --git a/paper-server/nms-patches/ShapelessRecipes.patch b/paper-server/nms-patches/ShapelessRecipes.patch index d91e17c727..9f214f4ce5 100644 --- a/paper-server/nms-patches/ShapelessRecipes.patch +++ b/paper-server/nms-patches/ShapelessRecipes.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/ShapelessRecipes.java +++ b/net/minecraft/server/ShapelessRecipes.java -@@ -6,12 +6,24 @@ +@@ -5,6 +5,10 @@ import com.google.gson.JsonParseException; - import java.util.ArrayList; + import it.unimi.dsi.fastutil.ints.IntList; import java.util.Iterator; +// CraftBukkit start +import org.bukkit.craftbukkit.inventory.CraftItemStack; @@ -11,21 +11,7 @@ public class ShapelessRecipes implements IRecipe { - private final ItemStack result; - private final NonNullList ingredients; - private final String c; -+ // CraftBukkit start -+ public MinecraftKey key; -+ -+ @Override -+ public void setKey(MinecraftKey key) { -+ this.key = key; -+ } -+ // CraftBukkit end - - public ShapelessRecipes(String s, ItemStack itemstack, NonNullList nonnulllist) { - this.c = s; -@@ -19,6 +31,21 @@ +@@ -20,6 +24,20 @@ this.ingredients = nonnulllist; } @@ -35,15 +21,28 @@ + CraftItemStack result = CraftItemStack.asCraftMirror(this.result); + CraftShapelessRecipe recipe = new CraftShapelessRecipe(result, this); + for (RecipeItemStack list : this.ingredients) { -+ if (list != null) { -+ net.minecraft.server.ItemStack stack = list.choices[0]; -+ recipe.addIngredient(org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(stack.getItem()), (list.choices.length) > 1 ? 32767 : stack.getData()); -+ } ++ list.buildChoices(); ++ net.minecraft.server.ItemStack stack = list.choices[0]; ++ recipe.addIngredient(org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(stack.getItem()), (list.choices.length) > 1 ? 32767 : 0); + } + return recipe; + } + // CraftBukkit end + - public ItemStack b() { - return this.result; + public MinecraftKey getKey() { + return this.a; + } +@@ -127,11 +145,11 @@ + packetdataserializer.a(shapelessrecipes.result); + } + +- public IRecipe a(MinecraftKey minecraftkey, PacketDataSerializer packetdataserializer) { ++ public ShapelessRecipes a(MinecraftKey minecraftkey, PacketDataSerializer packetdataserializer) { // CraftBukkit - decompile error + return this.b(minecraftkey, packetdataserializer); + } + +- public IRecipe a(MinecraftKey minecraftkey, JsonObject jsonobject) { ++ public ShapelessRecipes a(MinecraftKey minecraftkey, JsonObject jsonobject) { // CraftBukkit - decompile error + return this.b(minecraftkey, jsonobject); + } } diff --git a/paper-server/nms-patches/SlotFurnaceResult.patch b/paper-server/nms-patches/SlotFurnaceResult.patch index bcc110d72f..eee722f9aa 100644 --- a/paper-server/nms-patches/SlotFurnaceResult.patch +++ b/paper-server/nms-patches/SlotFurnaceResult.patch @@ -1,32 +1,32 @@ --- a/net/minecraft/server/SlotFurnaceResult.java +++ b/net/minecraft/server/SlotFurnaceResult.java -@@ -1,5 +1,10 @@ - package net.minecraft.server; +@@ -2,6 +2,10 @@ + import java.util.Iterator; + import java.util.Map.Entry; +// CraftBukkit start +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.FurnaceExtractEvent; +// CraftBukkit end -+ + public class SlotFurnaceResult extends Slot { - private final EntityHuman a; -@@ -51,6 +56,18 @@ - i = j; - } +@@ -66,6 +70,18 @@ + i = j; + } -+ // CraftBukkit start - fire FurnaceExtractEvent -+ Player player = (Player) a.getBukkitEntity(); -+ TileEntityFurnace furnace = ((TileEntityFurnace) this.inventory); -+ org.bukkit.block.Block block = a.world.getWorld().getBlockAt(furnace.position.getX(), furnace.position.getY(), furnace.position.getZ()); ++ // CraftBukkit start - fire FurnaceExtractEvent ++ Player player = (Player) a.getBukkitEntity(); ++ TileEntityFurnace furnace = ((TileEntityFurnace) this.inventory); ++ org.bukkit.block.Block block = a.world.getWorld().getBlockAt(furnace.position.getX(), furnace.position.getY(), furnace.position.getZ()); + -+ if (b != 0) { -+ FurnaceExtractEvent event = new FurnaceExtractEvent(player, block, org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(itemstack.getItem()), b, i); -+ a.world.getServer().getPluginManager().callEvent(event); -+ i = event.getExpToDrop(); -+ } -+ // CraftBukkit end ++ if (b != 0) { ++ FurnaceExtractEvent event = new FurnaceExtractEvent(player, block, org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(itemstack.getItem()), b, i); ++ a.world.getServer().getPluginManager().callEvent(event); ++ i = event.getExpToDrop(); ++ } ++ // CraftBukkit end + - while (i > 0) { - j = EntityExperienceOrb.getOrbValue(i); - i -= j; + while (i > 0) { + j = EntityExperienceOrb.getOrbValue(i); + i -= j; diff --git a/paper-server/nms-patches/SpawnerCreature.patch b/paper-server/nms-patches/SpawnerCreature.patch index ce90948fb3..0bfac793fe 100644 --- a/paper-server/nms-patches/SpawnerCreature.patch +++ b/paper-server/nms-patches/SpawnerCreature.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/SpawnerCreature.java +++ b/net/minecraft/server/SpawnerCreature.java -@@ -6,10 +6,16 @@ - import java.util.Random; - import java.util.Set; +@@ -9,11 +9,17 @@ + import org.apache.logging.log4j.LogManager; + import org.apache.logging.log4j.Logger; +// CraftBukkit start +import org.bukkit.craftbukkit.util.LongHash; @@ -12,32 +12,33 @@ + public final class SpawnerCreature { - private static final int a = (int) Math.pow(17.0D, 2.0D); -- private final Set b = Sets.newHashSet(); -+ private final LongHashSet b = new LongHashSet(); // CraftBukkit + private static final Logger a = LogManager.getLogger(); + private static final int b = (int) Math.pow(17.0D, 2.0D); +- private final Set c = Sets.newHashSet(); ++ private final LongHashSet c = new LongHashSet(); // CraftBukkit public SpawnerCreature() {} -@@ -38,13 +44,16 @@ +@@ -42,13 +48,16 @@ boolean flag4 = i1 == -8 || i1 == 8 || k == -8 || k == 8; ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(i1 + l, k + j); -- if (!this.b.contains(chunkcoordintpair)) { +- if (!this.c.contains(chunkcoordintpair)) { + // CraftBukkit start - use LongHash and LongHashSet + long chunkCoords = LongHash.toLong(chunkcoordintpair.x, chunkcoordintpair.z); -+ if (!this.b.contains(chunkCoords)) { ++ if (!this.c.contains(chunkCoords)) { ++i; if (!flag4 && worldserver.getWorldBorder().isInBounds(chunkcoordintpair)) { PlayerChunk playerchunk = worldserver.getPlayerChunkMap().getChunk(chunkcoordintpair.x, chunkcoordintpair.z); if (playerchunk != null && playerchunk.e()) { -- this.b.add(chunkcoordintpair); -+ this.b.add(chunkCoords); +- this.c.add(chunkcoordintpair); ++ this.c.add(chunkCoords); + // CraftBukkit end } } } -@@ -62,9 +71,31 @@ +@@ -66,9 +75,31 @@ for (int k1 = 0; k1 < j; ++k1) { EnumCreatureType enumcreaturetype = aenumcreaturetype[k1]; @@ -63,16 +64,16 @@ + } + // CraftBukkit end + - if ((!enumcreaturetype.d() || flag1) && (enumcreaturetype.d() || flag) && (!enumcreaturetype.e() || flag2)) { + if ((!enumcreaturetype.c() || flag1) && (enumcreaturetype.c() || flag) && (!enumcreaturetype.d() || flag2)) { k = worldserver.a(enumcreaturetype.a()); -- int l1 = enumcreaturetype.b() * i / SpawnerCreature.a; -+ int l1 = limit * i / a; // CraftBukkit - use per-world limits +- int l1 = enumcreaturetype.b() * i / SpawnerCreature.b; ++ int l1 = limit * i / b; // CraftBukkit - use per-world limits if (k <= l1) { BlockPosition.MutableBlockPosition blockposition_mutableblockposition = new BlockPosition.MutableBlockPosition(); -@@ -72,8 +103,10 @@ +@@ -76,8 +107,10 @@ - label120: + label128: while (iterator1.hasNext()) { - ChunkCoordIntPair chunkcoordintpair1 = (ChunkCoordIntPair) iterator1.next(); - BlockPosition blockposition1 = getRandomPosition(worldserver, chunkcoordintpair1.x, chunkcoordintpair1.z); @@ -83,29 +84,28 @@ int i2 = blockposition1.getX(); int j2 = blockposition1.getY(); int k2 = blockposition1.getZ(); -@@ -125,8 +158,11 @@ - if (entityinsentient.P() && entityinsentient.canSpawn()) { - groupdataentity = entityinsentient.prepare(worldserver.D(new BlockPosition(entityinsentient)), groupdataentity); - if (entityinsentient.canSpawn()) { -- ++l2; -- worldserver.addEntity(entityinsentient); -+ // CraftBukkit start -+ if (worldserver.addEntity(entityinsentient, SpawnReason.NATURAL)) { -+ ++l2; -+ } -+ // CraftBukkit end - } else { - entityinsentient.die(); - } -@@ -226,8 +262,10 @@ +@@ -136,9 +169,12 @@ + if (entityinsentient.M() && entityinsentient.a((IWorldReader) worldserver)) { + groupdataentity = entityinsentient.prepare(worldserver.getDamageScaler(new BlockPosition(entityinsentient)), groupdataentity, (NBTTagCompound) null); + if (entityinsentient.a((IWorldReader) worldserver)) { +- ++l2; +- ++j4; +- worldserver.addEntity(entityinsentient); ++ // CraftBukkit start ++ if (worldserver.addEntity(entityinsentient, SpawnReason.NATURAL)) { ++ ++l2; ++ ++j4; ++ } ++ // CraftBukkit end + } else { + entityinsentient.die(); + } +@@ -255,7 +291,7 @@ + entityinsentient.setPositionRotation((double) f, (double) blockposition.getY(), (double) f1, random.nextFloat() * 360.0F, 0.0F); + if (entityinsentient.a(generatoraccess) && entityinsentient.a((IWorldReader) generatoraccess)) { + groupdataentity = entityinsentient.prepare(generatoraccess.getDamageScaler(new BlockPosition(entityinsentient)), groupdataentity, (NBTTagCompound) null); +- generatoraccess.addEntity(entityinsentient); ++ generatoraccess.addEntity(entityinsentient, SpawnReason.CHUNK_GEN); // CraftBukkit + flag = true; } - - entityinsentient.setPositionRotation((double) ((float) j1 + 0.5F), (double) blockposition.getY(), (double) ((float) k1 + 0.5F), random.nextFloat() * 360.0F, 0.0F); -- world.addEntity(entityinsentient); -+ // CraftBukkit start - Added a reason for spawning this creature, moved entityinsentient.prepare(groupdataentity) up - groupdataentity = entityinsentient.prepare(world.D(new BlockPosition(entityinsentient)), groupdataentity); -+ world.addEntity(entityinsentient, SpawnReason.CHUNK_GEN); -+ // CraftBukkit end - flag = true; } - diff --git a/paper-server/nms-patches/StatisticManager.patch b/paper-server/nms-patches/StatisticManager.patch index 93e6895aab..1d6c4129a0 100644 --- a/paper-server/nms-patches/StatisticManager.patch +++ b/paper-server/nms-patches/StatisticManager.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/server/StatisticManager.java +++ b/net/minecraft/server/StatisticManager.java -@@ -10,6 +10,12 @@ - public StatisticManager() {} +@@ -13,6 +13,12 @@ + } - public void b(EntityHuman entityhuman, Statistic statistic, int i) { + public void b(EntityHuman entityhuman, Statistic statistic, int i) { + // CraftBukkit start - fire Statistic events + org.bukkit.event.Cancellable cancellable = org.bukkit.craftbukkit.event.CraftEventFactory.handleStatisticsIncrease(entityhuman, statistic, this.getStatisticValue(statistic), i); + if (cancellable != null && cancellable.isCancelled()) { diff --git a/paper-server/nms-patches/TickListServer.patch b/paper-server/nms-patches/TickListServer.patch new file mode 100644 index 0000000000..50a952e327 --- /dev/null +++ b/paper-server/nms-patches/TickListServer.patch @@ -0,0 +1,111 @@ +--- a/net/minecraft/server/TickListServer.java ++++ b/net/minecraft/server/TickListServer.java +@@ -11,14 +11,15 @@ + import java.util.function.Consumer; + import java.util.function.Function; + import java.util.function.Predicate; ++import org.bukkit.craftbukkit.util.HashTreeSet; // CraftBukkit + + public class TickListServer implements TickList { + + protected final Predicate a; + protected final Function b; + protected final Function c; +- protected final Set> nextTickListHash = Sets.newHashSet(); +- protected final TreeSet> nextTickList = new TreeSet(); ++ // protected final Set> nextTickListHash = Sets.newHashSet(); ++ protected final HashTreeSet nextTickList = new HashTreeSet<>(); // CraftBukkit - HashTreeSet + private final WorldServer f; + private final List> g = Lists.newArrayList(); + private final Consumer> h; +@@ -34,16 +35,22 @@ + public void a() { + int i = this.nextTickList.size(); + +- if (i != this.nextTickListHash.size()) { ++ if (false) { // CraftBukkit + throw new IllegalStateException("TickNextTick list out of synch"); + } else { + if (i > 65536) { +- i = 65536; ++ // CraftBukkit start - If the server has too much to process over time, try to alleviate that ++ if (i > 20 * 65536) { ++ i = i / 20; ++ } else { ++ i = 65536; ++ } ++ // CraftBukkit end + } + + this.f.methodProfiler.a("cleaning"); + +- NextTickListEntry nextticklistentry; ++ NextTickListEntry nextticklistentry; // CraftBukkit - decompile error + + for (int j = 0; j < i; ++j) { + nextticklistentry = (NextTickListEntry) this.nextTickList.first(); +@@ -52,7 +59,7 @@ + } + + this.nextTickList.remove(nextticklistentry); +- this.nextTickListHash.remove(nextticklistentry); ++ // this.nextTickListHash.remove(nextticklistentry); // CraftBukkit - use nextTickList + this.g.add(nextticklistentry); + } + +@@ -118,7 +125,7 @@ + if (blockposition.getX() >= structureboundingbox.a && blockposition.getX() < structureboundingbox.d && blockposition.getZ() >= structureboundingbox.c && blockposition.getZ() < structureboundingbox.f) { + if (flag) { + if (i == 0) { +- this.nextTickListHash.remove(nextticklistentry); ++ // this.nextTickListHash.remove(nextticklistentry); // CraftBukkit - removed + } + + iterator.remove(); +@@ -141,7 +148,7 @@ + Iterator iterator = list.iterator(); + + while (iterator.hasNext()) { +- NextTickListEntry nextticklistentry = (NextTickListEntry) iterator.next(); ++ NextTickListEntry nextticklistentry = (NextTickListEntry) iterator.next(); // CraftBukkit - decompile error + + if (structureboundingbox.b((BaseBlockPosition) nextticklistentry.a)) { + BlockPosition blockposition1 = nextticklistentry.a.a((BaseBlockPosition) blockposition); +@@ -159,7 +166,7 @@ + Iterator iterator = list.iterator(); + + while (iterator.hasNext()) { +- NextTickListEntry nextticklistentry = (NextTickListEntry) iterator.next(); ++ NextTickListEntry nextticklistentry = (NextTickListEntry) iterator.next(); // CraftBukkit - decompile error + NBTTagCompound nbttagcompound = new NBTTagCompound(); + + nbttagcompound.setString("i", ((MinecraftKey) this.b.apply(nextticklistentry.a())).toString()); +@@ -177,7 +184,7 @@ + public void a(NBTTagList nbttaglist) { + for (int i = 0; i < nbttaglist.size(); ++i) { + NBTTagCompound nbttagcompound = nbttaglist.getCompound(i); +- Object object = this.c.apply(new MinecraftKey(nbttagcompound.getString("i"))); ++ T object = this.c.apply(new MinecraftKey(nbttagcompound.getString("i"))); // CraftBukkit - decompile error + + if (object != null) { + this.b(new BlockPosition(nbttagcompound.getInt("x"), nbttagcompound.getInt("y"), nbttagcompound.getInt("z")), object, nbttagcompound.getInt("t"), TickListPriority.a(nbttagcompound.getInt("p"))); +@@ -187,7 +194,7 @@ + } + + public boolean a(BlockPosition blockposition, T t0) { +- return this.nextTickListHash.contains(new NextTickListEntry(blockposition, t0)); ++ return this.nextTickList.contains(new NextTickListEntry(blockposition, t0)); // CraftBukkit + } + + public void a(BlockPosition blockposition, T t0, int i, TickListPriority ticklistpriority) { +@@ -209,8 +216,8 @@ + private void c(BlockPosition blockposition, T t0, int i, TickListPriority ticklistpriority) { + NextTickListEntry nextticklistentry = new NextTickListEntry(blockposition, t0, (long) i + this.f.getTime(), ticklistpriority); + +- if (!this.nextTickListHash.contains(nextticklistentry)) { +- this.nextTickListHash.add(nextticklistentry); ++ // CraftBukkit - use nextTickList ++ if (!this.nextTickList.contains(nextticklistentry)) { + this.nextTickList.add(nextticklistentry); + } + diff --git a/paper-server/nms-patches/TileEntity.patch b/paper-server/nms-patches/TileEntity.patch index 6ebe08e984..b0dbdfbc61 100644 --- a/paper-server/nms-patches/TileEntity.patch +++ b/paper-server/nms-patches/TileEntity.patch @@ -9,9 +9,33 @@ public abstract class TileEntity { private static final Logger a = LogManager.getLogger(); -@@ -251,4 +253,13 @@ - a("shulker_box", TileEntityShulkerBox.class); - a("bed", TileEntityBed.class); +@@ -54,8 +56,15 @@ + } + } + ++ // CraftBukkit start + @Nullable + public static TileEntity create(NBTTagCompound nbttagcompound) { ++ return create(nbttagcompound, null); ++ } ++ ++ @Nullable ++ public static TileEntity create(NBTTagCompound nbttagcompound, @Nullable World world) { ++ // CraftBukkit end + TileEntity tileentity = null; + String s = nbttagcompound.getString("id"); + +@@ -67,6 +76,7 @@ + + if (tileentity != null) { + try { ++ tileentity.setWorld(world); // CraftBukkit + tileentity.load(nbttagcompound); + } catch (Throwable throwable1) { + TileEntity.a.error("Failed to load data for block entity {}", s, throwable1); +@@ -156,4 +166,13 @@ + public TileEntityTypes C() { + return this.e; } + + // CraftBukkit start - add method diff --git a/paper-server/nms-patches/TileEntityBanner.patch b/paper-server/nms-patches/TileEntityBanner.patch index c9294ee0b2..4f501b82de 100644 --- a/paper-server/nms-patches/TileEntityBanner.patch +++ b/paper-server/nms-patches/TileEntityBanner.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/server/TileEntityBanner.java +++ b/net/minecraft/server/TileEntityBanner.java -@@ -23,6 +23,11 @@ +@@ -30,6 +30,11 @@ if (nbttagcompound != null && nbttagcompound.hasKeyOfType("Patterns", 9)) { - this.patterns = nbttagcompound.getList("Patterns", 10).d(); + this.patterns = nbttagcompound.getList("Patterns", 10).c(); + // CraftBukkit start + while (this.patterns.size() > 20) { + this.patterns.remove(20); @@ -11,16 +11,16 @@ + // CraftBukkit end } - this.color = flag ? d(itemstack) : ItemBanner.c(itemstack); -@@ -67,6 +72,11 @@ + this.color = enumcolor; +@@ -79,6 +84,11 @@ + } - this.color = EnumColor.fromInvColorIndex(nbttagcompound.getInt("Base")); this.patterns = nbttagcompound.getList("Patterns", 10); + // CraftBukkit start + while (this.patterns.size() > 20) { + this.patterns.remove(20); + } + // CraftBukkit end + this.h = null; this.i = null; this.j = null; - this.k = null; diff --git a/paper-server/nms-patches/TileEntityBeacon.patch b/paper-server/nms-patches/TileEntityBeacon.patch index 477bd68ec1..84fcb11fbf 100644 --- a/paper-server/nms-patches/TileEntityBeacon.patch +++ b/paper-server/nms-patches/TileEntityBeacon.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/server/TileEntityBeacon.java +++ b/net/minecraft/server/TileEntityBeacon.java @@ -9,6 +9,13 @@ - import java.util.Set; + import java.util.stream.Collectors; import javax.annotation.Nullable; +// CraftBukkit start @@ -11,13 +11,13 @@ +import org.bukkit.potion.PotionEffect; +// CraftBukkit end + - public class TileEntityBeacon extends TileEntityContainer implements ITickable, IWorldInventory { + public class TileEntityBeacon extends TileEntityContainer implements IWorldInventory, ITickable { public static final MobEffectList[][] a = new MobEffectList[][] { { MobEffects.FASTER_MOVEMENT, MobEffects.FASTER_DIG}, { MobEffects.RESISTANCE, MobEffects.JUMP}, { MobEffects.INCREASE_DAMAGE}, { MobEffects.REGENERATION}}; -@@ -22,6 +29,38 @@ +@@ -23,6 +30,38 @@ public MobEffectList secondaryEffect; private ItemStack inventorySlot; - private String o; + private IChatBaseComponent o; + // CraftBukkit start - add fields and methods + public List transaction = new java.util.ArrayList(); + private int maxStack = MAX_STACK; @@ -52,13 +52,13 @@ + // CraftBukkit end public TileEntityBeacon() { - this.inventorySlot = ItemStack.a; -@@ -42,41 +81,79 @@ - + super(TileEntityTypes.o); +@@ -56,41 +95,79 @@ + this.world.a((EntityHuman) null, this.position, soundeffect, SoundCategory.BLOCKS, 1.0F, 1.0F); } -- private void E() { -- if (this.j && this.levels > 0 && !this.world.isClientSide && this.primaryEffect != null) { +- private void D() { +- if (this.i && this.levels > 0 && !this.world.isClientSide && this.primaryEffect != null) { - double d0 = (double) (this.levels * 10 + 10); + // CraftBukkit start - split into components + private byte getAmplification() { @@ -123,8 +123,8 @@ + } + } + -+ private void E() { -+ if (this.j && this.levels > 0 && !this.world.isClientSide && this.primaryEffect != null) { ++ private void D() { ++ if (this.i && this.levels > 0 && !this.world.isClientSide && this.primaryEffect != null) { + byte b0 = getAmplification(); + + int i = getLevel(); @@ -140,14 +140,14 @@ } + // CraftBukkit end - private void F() { + private void E() { int i = this.position.getX(); -@@ -195,8 +272,10 @@ +@@ -210,8 +287,10 @@ public void load(NBTTagCompound nbttagcompound) { super.load(nbttagcompound); -- this.primaryEffect = f(nbttagcompound.getInt("Primary")); -- this.secondaryEffect = f(nbttagcompound.getInt("Secondary")); +- this.primaryEffect = e(nbttagcompound.getInt("Primary")); +- this.secondaryEffect = e(nbttagcompound.getInt("Secondary")); + // Craftbukkit start - persist manually set non-default beacon effects (SPIGOT-3598) + this.primaryEffect = MobEffectList.fromId(nbttagcompound.getInt("Primary")); + this.secondaryEffect = MobEffectList.fromId(nbttagcompound.getInt("Secondary")); diff --git a/paper-server/nms-patches/TileEntityBrewingStand.patch b/paper-server/nms-patches/TileEntityBrewingStand.patch index fe3d21e34d..bafd46eee0 100644 --- a/paper-server/nms-patches/TileEntityBrewingStand.patch +++ b/paper-server/nms-patches/TileEntityBrewingStand.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/TileEntityBrewingStand.java +++ b/net/minecraft/server/TileEntityBrewingStand.java -@@ -3,6 +3,16 @@ - import java.util.Arrays; +@@ -4,6 +4,16 @@ import java.util.Iterator; + import javax.annotation.Nullable; +// CraftBukkit start +import java.util.List; @@ -14,12 +14,12 @@ +import org.bukkit.inventory.InventoryHolder; +// CraftBukkit end + - public class TileEntityBrewingStand extends TileEntityContainer implements ITickable, IWorldInventory { + public class TileEntityBrewingStand extends TileEntityContainer implements IWorldInventory, ITickable { private static final int[] a = new int[] { 3}; -@@ -14,6 +24,31 @@ - private Item k; - private String l; +@@ -15,6 +25,31 @@ + private Item j; + private IChatBaseComponent k; private int fuelLevel; + // CraftBukkit start - add fields and methods + private int lastTick = MinecraftServer.currentTick; @@ -48,8 +48,8 @@ + // CraftBukkit end public TileEntityBrewingStand() { - this.items = NonNullList.a(5, ItemStack.a); -@@ -55,8 +90,19 @@ + super(TileEntityTypes.l); +@@ -62,8 +97,19 @@ ItemStack itemstack = (ItemStack) this.items.get(4); if (this.fuelLevel <= 0 && itemstack.getItem() == Items.BLAZE_POWDER) { @@ -71,7 +71,7 @@ this.update(); } -@@ -64,9 +110,14 @@ +@@ -71,9 +117,14 @@ boolean flag1 = this.brewTime > 0; ItemStack itemstack1 = (ItemStack) this.items.get(3); @@ -87,10 +87,10 @@ + // CraftBukkit end if (flag2 && flag) { - this.p(); -@@ -140,6 +191,16 @@ + this.r(); +@@ -147,6 +198,16 @@ - private void p() { + private void r() { ItemStack itemstack = (ItemStack) this.items.get(3); + // CraftBukkit start + InventoryHolder owner = this.getOwner(); @@ -105,7 +105,7 @@ for (int i = 0; i < 3; ++i) { this.items.set(i, PotionBrewer.d(itemstack, (ItemStack) this.items.get(i))); -@@ -210,7 +271,7 @@ +@@ -213,7 +274,7 @@ } public int getMaxStackSize() { diff --git a/paper-server/nms-patches/TileEntityChest.patch b/paper-server/nms-patches/TileEntityChest.patch index c302cf6447..80ec408604 100644 --- a/paper-server/nms-patches/TileEntityChest.patch +++ b/paper-server/nms-patches/TileEntityChest.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/server/TileEntityChest.java +++ b/net/minecraft/server/TileEntityChest.java -@@ -3,6 +3,10 @@ +@@ -2,6 +2,10 @@ + import java.util.Iterator; import java.util.List; - import javax.annotation.Nullable; +// CraftBukkit start +import org.bukkit.craftbukkit.entity.CraftHumanEntity; +import org.bukkit.entity.HumanEntity; @@ -11,9 +11,9 @@ public class TileEntityChest extends TileEntityLootable implements ITickable { -@@ -18,6 +22,31 @@ - private int q; - private BlockChest.Type r; +@@ -11,6 +15,31 @@ + protected int f; + private int k; + // CraftBukkit start - add fields and methods + public List transaction = new java.util.ArrayList(); @@ -40,10 +40,10 @@ + } + // CraftBukkit end + - public TileEntityChest() { + protected TileEntityChest(TileEntityTypes tileentitytypes) { + super(tileentitytypes); this.items = NonNullList.a(27, ItemStack.a); - } -@@ -82,7 +111,7 @@ +@@ -75,7 +104,7 @@ } public int getMaxStackSize() { @@ -51,54 +51,50 @@ + return maxStack; // CraftBukkit } - public void invalidateBlockCache() { -@@ -258,9 +287,21 @@ - if (this.l < 0) { - this.l = 0; + public void X_() { +@@ -170,8 +199,20 @@ + if (this.f < 0) { + this.f = 0; } -+ int oldPower = Math.max(0, Math.min(15, this.l)); // CraftBukkit - Get power before new viewer is added ++ int oldPower = Math.max(0, Math.min(15, this.f)); // CraftBukkit - Get power before new viewer is added - ++this.l; + ++this.f; + if (this.world == null) return; // CraftBukkit - this.world.playBlockAction(this.position, this.getBlock(), 1, this.l); + + // CraftBukkit start - Call redstone event + if (this.getBlock() == Blocks.TRAPPED_CHEST) { -+ int newPower = Math.max(0, Math.min(15, this.l)); ++ int newPower = Math.max(0, Math.min(15, this.f)); + + if (oldPower != newPower) { -+ org.bukkit.craftbukkit.event.CraftEventFactory.callRedstoneChange(world, position.getX(), position.getY(), position.getZ(), oldPower, newPower); ++ org.bukkit.craftbukkit.event.CraftEventFactory.callRedstoneChange(world, position, oldPower, newPower); + } + } + // CraftBukkit end - this.world.applyPhysics(this.position, this.getBlock(), false); - if (this.p() == BlockChest.Type.TRAP) { - this.world.applyPhysics(this.position.down(), this.getBlock(), false); -@@ -271,12 +312,21 @@ - - public void closeContainer(EntityHuman entityhuman) { - if (!entityhuman.isSpectator() && this.getBlock() instanceof BlockChest) { -+ int oldPower = Math.max(0, Math.min(15, this.l)); // CraftBukkit - Get power before new viewer is added - --this.l; - this.world.playBlockAction(this.position, this.getBlock(), 1, this.l); - this.world.applyPhysics(this.position, this.getBlock(), false); -+ -+ // CraftBukkit start - Call redstone event - if (this.p() == BlockChest.Type.TRAP) { -+ int newPower = Math.max(0, Math.min(15, this.l)); -+ -+ if (oldPower != newPower) { -+ org.bukkit.craftbukkit.event.CraftEventFactory.callRedstoneChange(world, position.getX(), position.getY(), position.getZ(), oldPower, newPower); -+ } - this.world.applyPhysics(this.position.down(), this.getBlock(), false); - } -+ // CraftBukkit end + this.p(); } - } -@@ -311,4 +361,11 @@ - protected NonNullList q() { - return this.items; +@@ -179,7 +220,18 @@ + + 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; ++ ++ // CraftBukkit start - Call redstone event ++ if (this.getBlock() == Blocks.TRAPPED_CHEST) { ++ int newPower = Math.max(0, Math.min(15, this.f)); ++ ++ if (oldPower != newPower) { ++ org.bukkit.craftbukkit.event.CraftEventFactory.callRedstoneChange(world, position, oldPower, newPower); ++ } ++ } ++ // CraftBukkit end + this.p(); + } + +@@ -232,4 +284,11 @@ + tileentitychest.a(tileentitychest1.q()); + tileentitychest1.a(nonnulllist); } + + // CraftBukkit start diff --git a/paper-server/nms-patches/TileEntityCommand.patch b/paper-server/nms-patches/TileEntityCommand.patch index c31a6b8180..b23a8e4cea 100644 --- a/paper-server/nms-patches/TileEntityCommand.patch +++ b/paper-server/nms-patches/TileEntityCommand.patch @@ -1,12 +1,16 @@ --- a/net/minecraft/server/TileEntityCommand.java +++ b/net/minecraft/server/TileEntityCommand.java -@@ -9,6 +9,9 @@ +@@ -9,6 +9,13 @@ + private boolean f; private boolean g; - private boolean h; - private final CommandBlockListenerAbstract i = new CommandBlockListenerAbstract() { -+ { -+ sender = new org.bukkit.craftbukkit.command.CraftBlockCommandSender(this); // CraftBukkit - add sender + private final CommandBlockListenerAbstract h = new CommandBlockListenerAbstract() { ++ // CraftBukkit start ++ @Override ++ public org.bukkit.command.CommandSender getBukkitSender(CommandListenerWrapper wrapper) { ++ return new org.bukkit.craftbukkit.command.CraftBlockCommandSender(wrapper); + } - public BlockPosition getChunkCoordinates() { - return TileEntityCommand.this.position; - } ++ // CraftBukkit end ++ + public void setCommand(String s) { + super.setCommand(s); + TileEntityCommand.this.update(); diff --git a/paper-server/nms-patches/TileEntityContainer.patch b/paper-server/nms-patches/TileEntityContainer.patch index e49e2ca979..b01f802589 100644 --- a/paper-server/nms-patches/TileEntityContainer.patch +++ b/paper-server/nms-patches/TileEntityContainer.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/TileEntityContainer.java +++ b/net/minecraft/server/TileEntityContainer.java -@@ -37,4 +37,12 @@ - public IChatBaseComponent getScoreboardDisplayName() { - return (IChatBaseComponent) (this.hasCustomName() ? new ChatComponentText(this.getName()) : new ChatMessage(this.getName(), new Object[0])); +@@ -34,4 +34,12 @@ + public void setLock(ChestLock chestlock) { + this.a = chestlock; } + + // CraftBukkit start diff --git a/paper-server/nms-patches/TileEntityDispenser.patch b/paper-server/nms-patches/TileEntityDispenser.patch index 3414c8aa5f..54a1325409 100644 --- a/paper-server/nms-patches/TileEntityDispenser.patch +++ b/paper-server/nms-patches/TileEntityDispenser.patch @@ -41,10 +41,10 @@ + } + // CraftBukkit end + - public TileEntityDispenser() { + protected TileEntityDispenser(TileEntityTypes tileentitytypes) { + super(tileentitytypes); this.items = NonNullList.a(9, ItemStack.a); - } -@@ -92,7 +123,7 @@ +@@ -97,7 +128,7 @@ } public int getMaxStackSize() { diff --git a/paper-server/nms-patches/TileEntityEndGateway.patch b/paper-server/nms-patches/TileEntityEndGateway.patch index 7fc375f1d5..585f0f16e9 100644 --- a/paper-server/nms-patches/TileEntityEndGateway.patch +++ b/paper-server/nms-patches/TileEntityEndGateway.patch @@ -13,9 +13,9 @@ public class TileEntityEndGateway extends TileEntityEnderPortal implements ITickable { -@@ -111,6 +117,26 @@ +@@ -113,6 +119,26 @@ if (this.exitPortal != null) { - BlockPosition blockposition = this.exactTeleport ? this.exitPortal : this.j(); + BlockPosition blockposition = this.exactTeleport ? this.exitPortal : this.i(); + // CraftBukkit start - Fire PlayerTeleportEvent + if (entity instanceof EntityPlayer) { @@ -31,7 +31,7 @@ + } + + ((EntityPlayer) entity).playerConnection.teleport(teleEvent.getTo()); -+ this.h(); // CraftBukkit - call at end of method ++ this.f(); // CraftBukkit - call at end of method + return; + + } diff --git a/paper-server/nms-patches/TileEntityFurnace.patch b/paper-server/nms-patches/TileEntityFurnace.patch index c3e32116af..e5861798b3 100644 --- a/paper-server/nms-patches/TileEntityFurnace.patch +++ b/paper-server/nms-patches/TileEntityFurnace.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/server/TileEntityFurnace.java +++ b/net/minecraft/server/TileEntityFurnace.java -@@ -1,6 +1,15 @@ - package net.minecraft.server; - - import java.util.Iterator; +@@ -9,6 +9,15 @@ + import java.util.Map; + import java.util.Map.Entry; + import javax.annotation.Nullable; +// CraftBukkit start +import java.util.List; + @@ -14,11 +14,11 @@ +import org.bukkit.craftbukkit.entity.CraftHumanEntity; +// CraftBukkit end - public class TileEntityFurnace extends TileEntityContainer implements ITickable, IWorldInventory { + public class TileEntityFurnace extends TileEntityContainer implements IWorldInventory, RecipeHolder, AutoRecipeOutput, ITickable { -@@ -14,6 +23,32 @@ - private int cookTimeTotal; - private String m; +@@ -98,6 +107,32 @@ + return linkedhashmap; + } + // CraftBukkit start - add fields and methods + private int lastTick = MinecraftServer.currentTick; @@ -47,14 +47,14 @@ + // CraftBukkit end + public TileEntityFurnace() { + super(TileEntityTypes.b); this.items = NonNullList.a(3, ItemStack.a); - } -@@ -119,11 +154,29 @@ +@@ -225,11 +260,30 @@ } - public void e() { + public void X_() { - boolean flag = this.isBurning(); -+ boolean flag = (this.getBlock() == Blocks.LIT_FURNACE); // CraftBukkit - SPIGOT-844 - Check if furnace block is lit using the block instead of burn time ++ boolean flag = this.getBlock().get(BlockFurnace.LIT); // CraftBukkit - SPIGOT-844 - Check if furnace block is lit using the block instead of burn time boolean flag1 = false; + // CraftBukkit start - Use wall time instead of ticks for cooking @@ -62,12 +62,13 @@ + this.lastTick = MinecraftServer.currentTick; + + // CraftBukkit - moved from below - edited for wall time -+ if (this.isBurning() && this.canBurn()) { ++ IRecipe irecipe = this.world.D().b(this, this.world); ++ if (this.isBurning() && this.canBurn(irecipe)) { + this.cookTime += elapsedTicks; + if (this.cookTime >= this.cookTimeTotal) { + this.cookTime = 0; -+ this.cookTimeTotal = this.a((ItemStack) this.items.get(0)); -+ this.burn(); ++ this.cookTimeTotal = this.s(); ++ this.burn(irecipe); + flag1 = true; + } + } else { @@ -81,21 +82,22 @@ } if (!this.world.isClientSide) { -@@ -134,10 +187,21 @@ +@@ -240,12 +294,21 @@ this.cookTime = MathHelper.clamp(this.cookTime - 2, 0, this.cookTimeTotal); } } else { -- if (!this.isBurning() && this.canBurn()) { -- this.burnTime = fuelTime(itemstack); -- this.ticksForCurrentFuel = this.burnTime; -- if (this.isBurning()) { +- IRecipe irecipe = this.world.D().b(this, this.world); + // CraftBukkit start - Handle multiple elapsed ticks -+ if (this.burnTime <= 0 && this.canBurn()) { // CraftBukkit - == to <= ++ if (this.burnTime <= 0 && this.canBurn(irecipe)) { // CraftBukkit - == to <= + CraftItemStack fuel = CraftItemStack.asCraftMirror(itemstack); + + FurnaceBurnEvent furnaceBurnEvent = new FurnaceBurnEvent(this.world.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ()), fuel, fuelTime(itemstack)); + this.world.getServer().getPluginManager().callEvent(furnaceBurnEvent); -+ + +- if (!this.isBurning() && this.canBurn(irecipe)) { +- this.burnTime = fuelTime(itemstack); +- this.ticksForCurrentFuel = this.burnTime; +- if (this.isBurning()) { + if (furnaceBurnEvent.isCancelled()) { + return; + } @@ -107,15 +109,15 @@ flag1 = true; if (!itemstack.isEmpty()) { Item item = itemstack.getItem(); -@@ -152,6 +216,7 @@ +@@ -260,6 +323,7 @@ } } + /* CraftBukkit start - Moved up - if (this.isBurning() && this.canBurn()) { + if (this.isBurning() && this.canBurn(irecipe)) { ++this.cookTime; if (this.cookTime == this.cookTimeTotal) { -@@ -163,11 +228,13 @@ +@@ -271,11 +335,13 @@ } else { this.cookTime = 0; } @@ -124,12 +126,12 @@ if (flag != this.isBurning()) { flag1 = true; - BlockFurnace.a(this.isBurning(), this.world, this.position); -+ this.invalidateBlockCache(); // CraftBukkit - Invalidate tile entity's cached block type + this.world.setTypeAndData(this.position, (IBlockData) this.world.getType(this.position).set(BlockFurnace.LIT, Boolean.valueOf(this.isBurning())), 3); ++ this.invalidateBlockCache(); // CraftBukkit - Invalidate tile entity's cached block type } } -@@ -192,7 +259,8 @@ +@@ -300,7 +366,8 @@ } else { ItemStack itemstack1 = (ItemStack) this.items.get(2); @@ -137,10 +139,10 @@ + // CraftBukkit - consider resultant count instead of current count + return itemstack1.isEmpty() ? true : (!itemstack1.doMaterialsMatch(itemstack) ? false : (itemstack1.getCount() + itemstack.getCount() <= this.getMaxStackSize() && itemstack1.getCount() + itemstack.getCount() < itemstack1.getMaxStackSize() ? true : itemstack1.getCount() + itemstack.getCount() <= itemstack.getMaxStackSize())); } - } - } -@@ -203,11 +271,38 @@ - ItemStack itemstack1 = RecipesFurnace.getInstance().getResult(itemstack); + } else { + return false; +@@ -313,11 +380,38 @@ + ItemStack itemstack1 = irecipe.d(); ItemStack itemstack2 = (ItemStack) this.items.get(2); + // CraftBukkit start - fire FurnaceSmeltEvent @@ -176,5 +178,5 @@ + */ + // CraftBukkit end - if (itemstack.getItem() == Item.getItemOf(Blocks.SPONGE) && itemstack.getData() == 1 && !((ItemStack) this.items.get(1)).isEmpty() && ((ItemStack) this.items.get(1)).getItem() == Items.BUCKET) { - this.items.set(1, new ItemStack(Items.WATER_BUCKET)); + if (!this.world.isClientSide) { + this.a(this.world, (EntityPlayer) null, irecipe); diff --git a/paper-server/nms-patches/TileEntityHopper.patch b/paper-server/nms-patches/TileEntityHopper.patch index 17005f2ace..467d842d3d 100644 --- a/paper-server/nms-patches/TileEntityHopper.patch +++ b/paper-server/nms-patches/TileEntityHopper.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/server/TileEntityHopper.java +++ b/net/minecraft/server/TileEntityHopper.java -@@ -4,12 +4,46 @@ - import java.util.List; +@@ -7,12 +7,46 @@ + import java.util.stream.Collectors; import javax.annotation.Nullable; +// CraftBukkit start @@ -17,7 +17,7 @@ private NonNullList items; private int f; - private long g; + private long j; + // CraftBukkit start - add fields and methods + public List transaction = new java.util.ArrayList(); @@ -45,8 +45,8 @@ + // CraftBukkit end + public TileEntityHopper() { + super(TileEntityTypes.r); this.items = NonNullList.a(5, ItemStack.a); - this.f = -1; @@ -72,7 +106,7 @@ } @@ -55,8 +55,8 @@ + return maxStack; // CraftBukkit } - public void e() { -@@ -163,10 +197,35 @@ + public void X_() { +@@ -165,10 +199,35 @@ for (int i = 0; i < this.getSize(); ++i) { if (!this.getItem(i).isEmpty()) { ItemStack itemstack = this.getItem(i).cloneItemStack(); @@ -94,7 +94,7 @@ return true; } -@@ -288,10 +347,41 @@ +@@ -290,10 +349,41 @@ if (!itemstack.isEmpty() && b(iinventory, itemstack, i, enumdirection)) { ItemStack itemstack1 = itemstack.cloneItemStack(); @@ -138,17 +138,17 @@ return true; } -@@ -307,6 +397,13 @@ - if (entityitem == null) { - return false; - } else { -+ // CraftBukkit start -+ InventoryPickupItemEvent event = new InventoryPickupItemEvent(iinventory1.getOwner().getInventory(), (org.bukkit.entity.Item) entityitem.getBukkitEntity()); -+ entityitem.world.getServer().getPluginManager().callEvent(event); -+ if (event.isCancelled()) { -+ return false; -+ } -+ // CraftBukkit end - ItemStack itemstack = entityitem.getItemStack().cloneItemStack(); - ItemStack itemstack1 = addItem(iinventory, iinventory1, itemstack, (EnumDirection) null); +@@ -305,6 +395,13 @@ + + public static boolean a(IInventory iinventory, EntityItem entityitem) { + boolean flag = false; ++ // CraftBukkit start ++ InventoryPickupItemEvent event = new InventoryPickupItemEvent(iinventory.getOwner().getInventory(), (org.bukkit.entity.Item) entityitem.getBukkitEntity()); ++ entityitem.world.getServer().getPluginManager().callEvent(event); ++ if (event.isCancelled()) { ++ return false; ++ } ++ // CraftBukkit end + ItemStack itemstack = entityitem.getItemStack().cloneItemStack(); + ItemStack itemstack1 = addItem((IInventory) null, iinventory, itemstack, (EnumDirection) null); diff --git a/paper-server/nms-patches/TileEntityJukeBox.patch b/paper-server/nms-patches/TileEntityJukeBox.patch new file mode 100644 index 0000000000..2fb3714509 --- /dev/null +++ b/paper-server/nms-patches/TileEntityJukeBox.patch @@ -0,0 +1,14 @@ +--- a/net/minecraft/server/TileEntityJukeBox.java ++++ b/net/minecraft/server/TileEntityJukeBox.java +@@ -31,6 +31,11 @@ + } + + public void setRecord(ItemStack itemstack) { ++ // CraftBukkit start - There can only be one ++ if (!itemstack.isEmpty()) { ++ itemstack.setCount(1); ++ } ++ // CraftBukkit end + this.a = itemstack; + this.update(); + } diff --git a/paper-server/nms-patches/TileEntityNote.patch b/paper-server/nms-patches/TileEntityNote.patch deleted file mode 100644 index e0498c3907..0000000000 --- a/paper-server/nms-patches/TileEntityNote.patch +++ /dev/null @@ -1,16 +0,0 @@ ---- a/net/minecraft/server/TileEntityNote.java -+++ b/net/minecraft/server/TileEntityNote.java -@@ -70,7 +70,12 @@ - b0 = 9; - } - -- world.playBlockAction(blockposition, Blocks.NOTEBLOCK, b0, this.note); -+ // CraftBukkit start -+ org.bukkit.event.block.NotePlayEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callNotePlayEvent(this.world, blockposition.getX(), blockposition.getY(), blockposition.getZ(), b0, this.note); -+ if (!event.isCancelled()) { -+ world.playBlockAction(blockposition, Blocks.NOTEBLOCK, event.getInstrument().getType(), event.getNote().getId()); -+ } -+ // CraftBukkit end - } - } - } diff --git a/paper-server/nms-patches/TileEntityShulkerBox.patch b/paper-server/nms-patches/TileEntityShulkerBox.patch index 6af5516b9d..1f77fc497c 100644 --- a/paper-server/nms-patches/TileEntityShulkerBox.patch +++ b/paper-server/nms-patches/TileEntityShulkerBox.patch @@ -1,18 +1,18 @@ --- a/net/minecraft/server/TileEntityShulkerBox.java +++ b/net/minecraft/server/TileEntityShulkerBox.java -@@ -3,6 +3,10 @@ - import java.util.Iterator; +@@ -4,6 +4,10 @@ import java.util.List; + import java.util.stream.IntStream; import javax.annotation.Nullable; +// CraftBukkit start +import org.bukkit.craftbukkit.entity.CraftHumanEntity; +import org.bukkit.entity.HumanEntity; +// CraftBukkit end - public class TileEntityShulkerBox extends TileEntityLootable implements ITickable, IWorldInventory { + public class TileEntityShulkerBox extends TileEntityLootable implements IWorldInventory, ITickable { -@@ -16,6 +20,31 @@ - private EnumColor l; +@@ -18,6 +22,31 @@ + private boolean o; private boolean p; + // CraftBukkit start - add fields and methods @@ -20,7 +20,7 @@ + private int maxStack = MAX_STACK; + + public List getContents() { -+ return this.f; ++ return this.e; + } + + public void onOpen(CraftHumanEntity who) { @@ -40,10 +40,10 @@ + } + // CraftBukkit end + - public TileEntityShulkerBox() { - this((EnumColor) null); - } -@@ -144,7 +173,7 @@ + public TileEntityShulkerBox(@Nullable EnumColor enumcolor) { + super(TileEntityTypes.x); + this.e = NonNullList.a(27, ItemStack.a); +@@ -148,7 +177,7 @@ } public int getMaxStackSize() { diff --git a/paper-server/nms-patches/TileEntitySign.patch b/paper-server/nms-patches/TileEntitySign.patch index 88ab430616..d25d0893b4 100644 --- a/paper-server/nms-patches/TileEntitySign.patch +++ b/paper-server/nms-patches/TileEntitySign.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/TileEntitySign.java +++ b/net/minecraft/server/TileEntitySign.java -@@ -21,6 +21,12 @@ +@@ -23,6 +23,12 @@ nbttagcompound.setString("Text" + (i + 1), s); } @@ -10,12 +10,12 @@ + } + // CraftBukkit end + - this.i.b(nbttagcompound); return nbttagcompound; } -@@ -58,14 +64,34 @@ - } - }; + +@@ -30,18 +36,38 @@ + this.isEditable = false; + super.load(nbttagcompound); + // CraftBukkit start - Add an option to convert signs correctly + // This is done with a flag instead of all the time because @@ -30,10 +30,11 @@ + s = "\"\""; + } - try { -- this.lines[i] = ChatComponentUtils.filterForDisplay(icommandlistener, ichatbasecomponent, (Entity) null); -- } catch (CommandException commandexception) { -- this.lines[i] = ichatbasecomponent; +- if (this.world instanceof WorldServer) { +- try { +- this.lines[i] = ChatComponentUtils.filterForDisplay(this.a((EntityPlayer) null), ichatbasecomponent, (Entity) null); +- } catch (CommandSyntaxException commandsyntaxexception) { ++ try { + IChatBaseComponent ichatbasecomponent = IChatBaseComponent.ChatSerializer.a(s); + + if (oldSign) { @@ -42,29 +43,33 @@ + } + // CraftBukkit end + -+ try { -+ this.lines[i] = ChatComponentUtils.filterForDisplay(icommandlistener, ichatbasecomponent, (Entity) null); -+ } catch (CommandException commandexception) { -+ this.lines[i] = ichatbasecomponent; -+ } ++ if (this.world instanceof WorldServer) { ++ try { ++ this.lines[i] = ChatComponentUtils.filterForDisplay(this.a((EntityPlayer) null), ichatbasecomponent, (Entity) null); ++ } catch (CommandSyntaxException commandsyntaxexception) { ++ this.lines[i] = ichatbasecomponent; ++ } ++ } else { + this.lines[i] = ichatbasecomponent; + } +- } else { +- this.lines[i] = ichatbasecomponent; + } catch (com.google.gson.JsonParseException jsonparseexception) { + this.lines[i] = new ChatComponentText(s); } } -@@ -155,7 +181,14 @@ - ChatClickable chatclickable = chatmodifier.h(); +@@ -94,6 +120,13 @@ - if (chatclickable.a() == ChatClickable.EnumClickAction.RUN_COMMAND) { -- entityhuman.C_().getCommandHandler().a(icommandlistener, chatclickable.b()); -+ // CraftBukkit start -+ // entityhuman.C_().getCommandHandler().a(icommandlistener, chatclickable.b()); -+ CommandBlockListenerAbstract.executeSafely(icommandlistener, new org.bukkit.craftbukkit.command.ProxiedNativeCommandSender( -+ icommandlistener, -+ new org.bukkit.craftbukkit.command.CraftBlockCommandSender(icommandlistener), -+ entityhuman.getBukkitEntity() -+ ), chatclickable.b()); -+ // CraftBukkit end - } - } - } + public void sendMessage(IChatBaseComponent ichatbasecomponent) {} + ++ // CraftBukkit start ++ @Override ++ public org.bukkit.command.CommandSender getBukkitSender(CommandListenerWrapper wrapper) { ++ return wrapper.f() != null ? wrapper.f().getBukkitSender(wrapper) : new org.bukkit.craftbukkit.command.CraftBlockCommandSender(wrapper); ++ } ++ // CraftBukkit end ++ + public CommandListenerWrapper a(@Nullable EntityPlayer entityplayer) { + String s = entityplayer == null ? "Sign" : entityplayer.getDisplayName().getString(); + Object object = entityplayer == null ? new ChatComponentText("Sign") : entityplayer.getScoreboardDisplayName(); diff --git a/paper-server/nms-patches/TileEntitySkull.patch b/paper-server/nms-patches/TileEntitySkull.patch new file mode 100644 index 0000000000..e7425b53db --- /dev/null +++ b/paper-server/nms-patches/TileEntitySkull.patch @@ -0,0 +1,23 @@ +--- a/net/minecraft/server/TileEntitySkull.java ++++ b/net/minecraft/server/TileEntitySkull.java +@@ -119,13 +119,19 @@ + } + } + ++ // CraftBukkit start + public static void a(IBlockAccess iblockaccess, BlockPosition blockposition) { ++ setShouldDrop(iblockaccess, blockposition, false); ++ } ++ ++ public static void setShouldDrop(IBlockAccess iblockaccess, BlockPosition blockposition, boolean flag) { ++ // CraftBukkit end + TileEntity tileentity = iblockaccess.getTileEntity(blockposition); + + if (tileentity instanceof TileEntitySkull) { + TileEntitySkull tileentityskull = (TileEntitySkull) tileentity; + +- tileentityskull.drop = false; ++ tileentityskull.drop = flag; // CraftBukkit + } + + } diff --git a/paper-server/nms-patches/TileEntityStructure.patch b/paper-server/nms-patches/TileEntityStructure.patch deleted file mode 100644 index f7f05e4cfe..0000000000 --- a/paper-server/nms-patches/TileEntityStructure.patch +++ /dev/null @@ -1,36 +0,0 @@ ---- a/net/minecraft/server/TileEntityStructure.java -+++ b/net/minecraft/server/TileEntityStructure.java -@@ -10,20 +10,20 @@ - - public class TileEntityStructure extends TileEntity { - -- private String a = ""; -- private String f = ""; -- private String g = ""; -- private BlockPosition h = new BlockPosition(0, 1, 0); -- private BlockPosition i; -- private EnumBlockMirror j; -- private EnumBlockRotation k; -- private TileEntityStructure.UsageMode l; -- private boolean m; -+ private String a = ""; // PAIL: rename name -+ public String f = ""; // PAIL: private -> public -+ public String g = ""; // PAIL: private -> public -+ public BlockPosition h = new BlockPosition(0, 1, 0); // PAIL: private -> public -+ public BlockPosition i; // PAIL: private -> public -+ public EnumBlockMirror j; // PAIL: private -> public -+ public EnumBlockRotation k; // PAIL: private -> public -+ private TileEntityStructure.UsageMode l; // PAIL: rename -+ public boolean m; // PAIL: private -> public - private boolean n; -- private boolean o; -- private boolean p; -- private float q; -- private long r; -+ public boolean o; // PAIL: private -> public -+ public boolean p; // PAIL: private -> public -+ public float q; // PAIL: private -> public -+ public long r; // PAIL: private -> public - - public TileEntityStructure() { - this.i = BlockPosition.ZERO; diff --git a/paper-server/nms-patches/UserCache.patch b/paper-server/nms-patches/UserCache.patch index d04921fc2e..a91279c607 100644 --- a/paper-server/nms-patches/UserCache.patch +++ b/paper-server/nms-patches/UserCache.patch @@ -9,7 +9,7 @@ private final GameProfileRepository g; protected final Gson b; private final File h; -@@ -337,11 +337,11 @@ +@@ -330,11 +330,11 @@ } } diff --git a/paper-server/nms-patches/Village.patch b/paper-server/nms-patches/Village.patch index a142c50abd..ea50abc5eb 100644 --- a/paper-server/nms-patches/Village.patch +++ b/paper-server/nms-patches/Village.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/server/Village.java +++ b/net/minecraft/server/Village.java -@@ -64,7 +64,7 @@ - EntityIronGolem entityirongolem = new EntityIronGolem(this.a); +@@ -73,7 +73,7 @@ + BlockPosition blockposition1 = blockposition.a(this.a.random.nextInt(16) - 8, this.a.random.nextInt(6) - 3, this.a.random.nextInt(16) - 8); - entityirongolem.setPosition(vec3d.x, vec3d.y, vec3d.z); -- this.a.addEntity(entityirongolem); -+ this.a.addEntity(entityirongolem, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.VILLAGE_DEFENSE); // CraftBukkit - ++this.l; - } - } + if (this.a(blockposition1)) { +- EntityIronGolem entityirongolem = (EntityIronGolem) EntityTypes.IRON_GOLEM.b(this.a, (NBTTagCompound) null, (IChatBaseComponent) null, (EntityHuman) null, blockposition1, false, false); ++ EntityIronGolem entityirongolem = (EntityIronGolem) EntityTypes.IRON_GOLEM.spawnCreature(this.a, (NBTTagCompound) null, (IChatBaseComponent) null, (EntityHuman) null, blockposition1, false, false, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.VILLAGE_DEFENSE); // CraftBukkit + + if (entityirongolem != null) { + if (entityirongolem.M() && entityirongolem.a((IWorldReader) this.a)) { diff --git a/paper-server/nms-patches/World.patch b/paper-server/nms-patches/World.patch index e4f6e07129..93eaaad180 100644 --- a/paper-server/nms-patches/World.patch +++ b/paper-server/nms-patches/World.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/World.java +++ b/net/minecraft/server/World.java -@@ -14,6 +14,21 @@ - import java.util.function.Supplier; - import javax.annotation.Nullable; +@@ -15,6 +15,23 @@ + import org.apache.logging.log4j.LogManager; + import org.apache.logging.log4j.Logger; +// CraftBukkit start +import com.google.common.collect.Maps; @@ -11,6 +11,8 @@ +import org.bukkit.block.BlockState; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.craftbukkit.CraftWorld; ++import org.bukkit.craftbukkit.block.CraftBlockState; ++import org.bukkit.craftbukkit.block.data.CraftBlockData; +import org.bukkit.craftbukkit.event.CraftEventFactory; +import org.bukkit.craftbukkit.util.CraftMagicNumbers; +import org.bukkit.event.block.BlockCanBuildEvent; @@ -19,12 +21,12 @@ +import org.bukkit.generator.ChunkGenerator; +// CraftBukkit end + - public abstract class World implements IBlockAccess { + public abstract class World implements GeneratorAccess, IIBlockAccess, AutoCloseable { - private int a = 63; -@@ -59,7 +74,52 @@ - private final WorldBorder P; - int[] J; + protected static final Logger e = LogManager.getLogger(); +@@ -55,7 +72,52 @@ + private final WorldBorder K; + int[] F; - protected World(IDataManager idatamanager, WorldData worlddata, WorldProvider worldprovider, MethodProfiler methodprofiler, boolean flag) { + // CraftBukkit start Added the following @@ -35,18 +37,18 @@ + + public boolean captureBlockStates = false; + public boolean captureTreeGeneration = false; -+ public ArrayList capturedBlockStates= new ArrayList(){ ++ public ArrayList capturedBlockStates = new ArrayList() { + @Override -+ public boolean add( BlockState blockState ) { -+ Iterator blockStateIterator = this.iterator(); -+ while( blockStateIterator.hasNext() ) { ++ public boolean add(CraftBlockState blockState) { ++ Iterator blockStateIterator = this.iterator(); ++ while (blockStateIterator.hasNext()) { + BlockState blockState1 = blockStateIterator.next(); -+ if ( blockState1.getLocation().equals( blockState.getLocation() ) ) { ++ if (blockState1.getLocation().equals(blockState.getLocation())) { + return false; + } + } + -+ return super.add( blockState ); ++ return super.add(blockState); + } + }; + public List captureDrops; @@ -73,13 +75,13 @@ + this.ticksPerAnimalSpawns = this.getServer().getTicksPerAnimalSpawns(); // CraftBukkit + this.ticksPerMonsterSpawns = this.getServer().getTicksPerMonsterSpawns(); // CraftBukkit + // CraftBukkit end - this.u = Lists.newArrayList(new IWorldAccess[] { this.t}); - this.N = Calendar.getInstance(); - this.scoreboard = new Scoreboard(); -@@ -72,6 +132,36 @@ + this.v = Lists.newArrayList(new IWorldAccess[] { this.u}); + this.allowMonsters = true; + this.allowAnimals = true; +@@ -66,6 +128,36 @@ this.worldProvider = worldprovider; this.isClientSide = flag; - this.P = worldprovider.getWorldBorder(); + this.K = worldprovider.getWorldBorder(); + // CraftBukkit start + getWorldBorder().world = (WorldServer) this; + // From PlayerList.setPlayerFileData @@ -112,17 +114,17 @@ + // CraftBukkit end } - public World b() { -@@ -209,6 +299,27 @@ + public GeneratorAccess b() { +@@ -138,6 +230,26 @@ } public boolean setTypeAndData(BlockPosition blockposition, IBlockData iblockdata, int i) { + // CraftBukkit start - tree generation + if (this.captureTreeGeneration) { -+ BlockState blockstate = null; -+ Iterator it = capturedBlockStates.iterator(); ++ CraftBlockState blockstate = null; ++ Iterator it = capturedBlockStates.iterator(); + while (it.hasNext()) { -+ BlockState previous = it.next(); ++ CraftBlockState previous = it.next(); + if (previous.getX() == blockposition.getX() && previous.getY() == blockposition.getY() && previous.getZ() == blockposition.getZ()) { + blockstate = previous; + it.remove(); @@ -130,31 +132,30 @@ + } + } + if (blockstate == null) { -+ blockstate = org.bukkit.craftbukkit.block.CraftBlockState.getBlockState(this, blockposition.getX(), blockposition.getY(), blockposition.getZ(), i); ++ blockstate = org.bukkit.craftbukkit.block.CraftBlockState.getBlockState(this, blockposition, i); + } -+ blockstate.setTypeId(CraftMagicNumbers.getId(iblockdata.getBlock())); -+ blockstate.setRawData((byte) iblockdata.getBlock().toLegacyData(iblockdata)); ++ blockstate.setData(iblockdata); + this.capturedBlockStates.add(blockstate); + return true; + } + // CraftBukkit end - if (this.E(blockposition)) { + if (k(blockposition)) { return false; } else if (!this.isClientSide && this.worldData.getType() == WorldType.DEBUG_ALL_BLOCK_STATES) { -@@ -216,9 +327,23 @@ +@@ -145,9 +257,23 @@ } else { Chunk chunk = this.getChunkAtWorldCoords(blockposition); Block block = iblockdata.getBlock(); + + // CraftBukkit start - capture blockstates -+ BlockState blockstate = null; ++ CraftBlockState blockstate = null; + if (this.captureBlockStates) { -+ blockstate = org.bukkit.craftbukkit.block.CraftBlockState.getBlockState(this, blockposition.getX(), blockposition.getY(), blockposition.getZ(), i); ++ blockstate = org.bukkit.craftbukkit.block.CraftBlockState.getBlockState(this, blockposition, i); + this.capturedBlockStates.add(blockstate); + } + // CraftBukkit end + - IBlockData iblockdata1 = chunk.a(blockposition, iblockdata); + IBlockData iblockdata1 = chunk.a(blockposition, iblockdata, (i & 64) != 0); if (iblockdata1 == null) { + // CraftBukkit start - remove blockstate if failed @@ -164,25 +165,25 @@ + // CraftBukkit end return false; } else { - if (iblockdata.c() != iblockdata1.c() || iblockdata.d() != iblockdata1.d()) { -@@ -227,6 +352,7 @@ - this.methodProfiler.b(); + IBlockData iblockdata2 = this.getType(blockposition); +@@ -158,6 +284,7 @@ + this.methodProfiler.e(); } + /* - if ((i & 2) != 0 && (!this.isClientSide || (i & 4) == 0) && chunk.isReady()) { - this.notify(blockposition, iblockdata1, iblockdata, i); - } -@@ -239,12 +365,37 @@ - } else if (!this.isClientSide && (i & 16) == 0) { - this.c(blockposition, block); + if (iblockdata2 == iblockdata) { + if (iblockdata1 != iblockdata2) { + this.a(blockposition, blockposition); +@@ -182,12 +309,52 @@ + iblockdata.b(this, blockposition, j); + } } + */ + + // CraftBukkit start + if (!this.captureBlockStates) { // Don't notify clients or update physics while capturing blockstates + // Modularize client and physic updates -+ notifyAndUpdatePhysics(blockposition, chunk, iblockdata1, iblockdata, i); ++ notifyAndUpdatePhysics(blockposition, chunk, iblockdata1, iblockdata, iblockdata2, i); + } + // CraftBukkit end @@ -192,45 +193,60 @@ } + // CraftBukkit start - Split off from above in order to directly send client and physic updates -+ public void notifyAndUpdatePhysics(BlockPosition blockposition, Chunk chunk, IBlockData oldBlock, IBlockData newBlock, int i) { -+ if ((i & 2) != 0 && (!this.isClientSide || (i & 4) == 0) && (chunk == null || chunk.isReady())) { // allow chunk to be null here as chunk.isReady() is false when we send our notification during block placement -+ this.notify(blockposition, oldBlock, newBlock, i); -+ } -+ -+ if (!this.isClientSide && (i & 1) != 0) { -+ this.update(blockposition, oldBlock.getBlock(), true); -+ if (newBlock.n()) { -+ this.updateAdjacentComparators(blockposition, newBlock.getBlock()); ++ public void notifyAndUpdatePhysics(BlockPosition blockposition, Chunk chunk, IBlockData oldBlock, IBlockData newBlock, IBlockData actualBlock, int i) { ++ IBlockData iblockdata = newBlock; ++ IBlockData iblockdata1 = oldBlock; ++ IBlockData iblockdata2 = actualBlock; ++ if (iblockdata2 == iblockdata) { ++ if (iblockdata1 != iblockdata2) { ++ this.a(blockposition, blockposition); ++ } ++ ++ if ((i & 2) != 0 && (!this.isClientSide || (i & 4) == 0) && (chunk == null || chunk.isReady())) { // allow chunk to be null here as chunk.isReady() is false when we send our notification during block placement ++ this.notify(blockposition, iblockdata1, iblockdata, i); ++ } ++ ++ if (!this.isClientSide && (i & 1) != 0) { ++ this.update(blockposition, iblockdata1.getBlock()); ++ if (iblockdata.isComplexRedstone()) { ++ this.updateAdjacentComparators(blockposition, newBlock.getBlock()); ++ } ++ } ++ ++ if ((i & 16) == 0) { ++ int j = i & -2; ++ ++ iblockdata1.b(this, blockposition, j); ++ iblockdata.a((GeneratorAccess) this, blockposition, j); ++ iblockdata.b(this, blockposition, j); + } -+ } else if (!this.isClientSide && (i & 16) == 0) { -+ this.c(blockposition, newBlock.getBlock()); + } + } + // CraftBukkit end + public boolean setAir(BlockPosition blockposition) { - return this.setTypeAndData(blockposition, Blocks.AIR.getBlockData(), 3); - } -@@ -278,6 +429,11 @@ + Fluid fluid = this.b(blockposition); - public void update(BlockPosition blockposition, Block block, boolean flag) { +@@ -224,6 +391,11 @@ + + public void update(BlockPosition blockposition, Block block) { if (this.worldData.getType() != WorldType.DEBUG_ALL_BLOCK_STATES) { + // CraftBukkit start + if (populating) { + return; + } + // CraftBukkit end - this.applyPhysics(blockposition, block, flag); + this.applyPhysics(blockposition, block); } -@@ -366,6 +522,17 @@ +@@ -299,6 +471,17 @@ IBlockData iblockdata = this.getType(blockposition); try { + // CraftBukkit start + CraftWorld world = ((WorldServer) this).getWorld(); + if (world != null) { -+ BlockPhysicsEvent event = new BlockPhysicsEvent(world.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), CraftMagicNumbers.getId(block)); ++ BlockPhysicsEvent event = new BlockPhysicsEvent(world.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), CraftBlockData.fromData(iblockdata)); + this.getServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { @@ -241,25 +257,34 @@ iblockdata.doPhysics(this, blockposition, block, blockposition1); } catch (Throwable throwable) { CrashReport crashreport = CrashReport.a(throwable, "Exception while updating neighbours"); -@@ -583,6 +750,17 @@ +@@ -307,7 +490,7 @@ + crashreportsystemdetails.a("Source block type", () -> { + try { + return String.format("ID #%s (%s // %s)", new Object[] { Block.REGISTRY.b(block), block.m(), block.getClass().getCanonicalName()}); +- } catch (Throwable throwable) { ++ } catch (Throwable throwablex) { // CraftBukkit - decompile error + return "ID #" + Block.REGISTRY.b(block); + } + }); +@@ -393,6 +576,17 @@ } public IBlockData getType(BlockPosition blockposition) { + // CraftBukkit start - tree generation + if (captureTreeGeneration) { -+ Iterator it = capturedBlockStates.iterator(); ++ Iterator it = capturedBlockStates.iterator(); + while (it.hasNext()) { -+ BlockState previous = it.next(); ++ CraftBlockState previous = it.next(); + if (previous.getX() == blockposition.getX() && previous.getY() == blockposition.getY() && previous.getZ() == blockposition.getZ()) { -+ return CraftMagicNumbers.getBlock(previous.getTypeId()).fromLegacyData(previous.getRawData()); ++ return previous.getHandle(); + } + } + } + // CraftBukkit end - if (this.E(blockposition)) { - return Blocks.AIR.getBlockData(); + if (k(blockposition)) { + return Blocks.VOID_AIR.getBlockData(); } else { -@@ -788,6 +966,42 @@ +@@ -639,6 +833,42 @@ } public boolean addEntity(Entity entity) { @@ -302,23 +327,23 @@ int i = MathHelper.floor(entity.locX / 16.0D); int j = MathHelper.floor(entity.locZ / 16.0D); boolean flag = entity.attachedToPlayer; -@@ -818,6 +1032,7 @@ - ((IWorldAccess) this.u.get(i)).a(entity); +@@ -669,6 +899,7 @@ + ((IWorldAccess) this.v.get(i)).a(entity); } + entity.valid = true; // CraftBukkit } protected void c(Entity entity) { -@@ -825,6 +1040,7 @@ - ((IWorldAccess) this.u.get(i)).b(entity); +@@ -676,6 +907,7 @@ + ((IWorldAccess) this.v.get(i)).b(entity); } + entity.valid = false; // CraftBukkit } public void kill(Entity entity) { -@@ -860,7 +1076,15 @@ +@@ -711,7 +943,15 @@ this.getChunkAt(i, j).b(entity); } @@ -335,19 +360,10 @@ this.c(entity); } -@@ -977,7 +1201,7 @@ - } +@@ -746,6 +986,11 @@ - public boolean a(AxisAlignedBB axisalignedbb) { -- return this.a((Entity) null, axisalignedbb, true, Lists.newArrayList()); -+ return this.a((Entity) null, axisalignedbb, true, Lists.newArrayList()); // CraftBukkit - decompile error - } - - public int a(float f) { -@@ -1047,6 +1271,11 @@ - - for (i = 0; i < this.j.size(); ++i) { - entity = (Entity) this.j.get(i); + for (i = 0; i < this.k.size(); ++i) { + entity = (Entity) this.k.get(i); + // CraftBukkit start - Fixed an NPE + if (entity == null) { + continue; @@ -356,7 +372,7 @@ try { ++entity.ticksLived; -@@ -1095,8 +1324,10 @@ +@@ -794,8 +1039,10 @@ CrashReportSystemDetails crashreportsystemdetails1; CrashReport crashreport1; @@ -366,10 +382,10 @@ + for (this.tickPosition = 0; this.tickPosition < this.entityList.size(); ++this.tickPosition) { + entity = (Entity) this.entityList.get(this.tickPosition); + // CraftBukkit end - Entity entity1 = entity.bJ(); + Entity entity1 = entity.getVehicle(); if (entity1 != null) { -@@ -1129,7 +1360,7 @@ +@@ -828,7 +1075,7 @@ this.getChunkAt(j, l).b(entity); } @@ -378,10 +394,10 @@ this.c(entity); } -@@ -1184,9 +1415,11 @@ - TileEntity tileentity1 = (TileEntity) this.b.get(i1); +@@ -883,9 +1130,11 @@ + TileEntity tileentity1 = (TileEntity) this.c.get(i1); - if (!tileentity1.y()) { + if (!tileentity1.x()) { + /* CraftBukkit start - Order matters, moved down if (!this.tileEntityList.contains(tileentity1)) { this.a(tileentity1); @@ -390,7 +406,7 @@ if (this.isLoaded(tileentity1.getPosition())) { Chunk chunk = this.getChunkAtWorldCoords(tileentity1.getPosition()); -@@ -1194,6 +1427,12 @@ +@@ -893,6 +1142,12 @@ chunk.a(tileentity1.getPosition(), tileentity1); this.notify(tileentity1.getPosition(), iblockdata, iblockdata, 3); @@ -403,7 +419,7 @@ } } } -@@ -1247,15 +1486,13 @@ +@@ -946,15 +1201,13 @@ int i; int j; @@ -423,24 +439,24 @@ } + // CraftBukkit end - entity.M = entity.locX; - entity.N = entity.locY; -@@ -1268,6 +1505,7 @@ - entity.aE(); + entity.N = entity.locX; + entity.O = entity.locY; +@@ -967,6 +1220,7 @@ + entity.aH(); } else { - entity.B_(); + entity.tick(); + entity.postTick(); // CraftBukkit } } -@@ -1559,11 +1797,18 @@ +@@ -1296,11 +1550,18 @@ } } + public Map capturedTileEntities = Maps.newHashMap(); @Nullable public TileEntity getTileEntity(BlockPosition blockposition) { - if (this.E(blockposition)) { + if (k(blockposition)) { return null; } else { + // CraftBukkit start @@ -451,26 +467,26 @@ + TileEntity tileentity = null; - if (this.O) { -@@ -1598,6 +1843,14 @@ + if (this.J) { +@@ -1335,6 +1596,14 @@ public void setTileEntity(BlockPosition blockposition, @Nullable TileEntity tileentity) { - if (!this.E(blockposition)) { - if (tileentity != null && !tileentity.y()) { -+ // CraftBukkit start -+ if (captureBlockStates) { -+ tileentity.a(this); -+ tileentity.setPosition(blockposition); -+ capturedTileEntities.put(blockposition, tileentity); -+ return; -+ } -+ // CraftBukkit end - if (this.O) { + if (!k(blockposition)) { + if (tileentity != null && !tileentity.x()) { ++ // CraftBukkit start ++ if (captureBlockStates) { ++ tileentity.setWorld(this); ++ tileentity.setPosition(blockposition); ++ capturedTileEntities.put(blockposition, tileentity); ++ return; ++ } ++ // CraftBukkit end + if (this.J) { tileentity.setPosition(blockposition); - Iterator iterator = this.b.iterator(); -@@ -1757,6 +2010,14 @@ + Iterator iterator = this.c.iterator(); +@@ -1494,6 +1763,14 @@ } - this.o = MathHelper.a(this.o, 0.0F, 1.0F); + this.p = MathHelper.a(this.p, 0.0F, 1.0F); + + // CraftBukkit start + for (int idx = 0; idx < this.players.size(); ++idx) { @@ -482,7 +498,7 @@ } } } -@@ -1894,7 +2155,10 @@ +@@ -1579,7 +1856,10 @@ } public boolean c(EnumSkyBlock enumskyblock, BlockPosition blockposition) { @@ -494,25 +510,25 @@ return false; } else { int i = 0; -@@ -2061,7 +2325,7 @@ +@@ -1750,7 +2030,7 @@ while (iterator.hasNext()) { Entity entity = (Entity) iterator.next(); -- if (oclass.isAssignableFrom(entity.getClass()) && predicate.apply(entity)) { -+ if (oclass.isAssignableFrom(entity.getClass()) && predicate.apply((T) entity)) { +- if (oclass.isAssignableFrom(entity.getClass()) && predicate.test(entity)) { ++ if (oclass.isAssignableFrom(entity.getClass()) && predicate.test((T) entity)) { arraylist.add(entity); } } -@@ -2076,7 +2340,7 @@ +@@ -1765,7 +2045,7 @@ while (iterator.hasNext()) { Entity entity = (Entity) iterator.next(); -- if (oclass.isAssignableFrom(entity.getClass()) && predicate.apply(entity)) { -+ if (oclass.isAssignableFrom(entity.getClass()) && predicate.apply((T) entity)) { // CraftBukkit - fix decompile error +- if (oclass.isAssignableFrom(entity.getClass()) && predicate.test(entity)) { ++ if (oclass.isAssignableFrom(entity.getClass()) && predicate.test((T) entity)) { // CraftBukkit - fix decompile error arraylist.add(entity); } } -@@ -2125,7 +2389,7 @@ +@@ -1814,7 +2094,7 @@ } } @@ -521,7 +537,7 @@ } @Nullable -@@ -2146,8 +2410,17 @@ +@@ -1835,8 +2115,17 @@ while (iterator.hasNext()) { Entity entity = (Entity) iterator.next(); @@ -540,7 +556,7 @@ ++i; } } -@@ -2156,12 +2429,18 @@ +@@ -1845,12 +2134,18 @@ } public void a(Collection collection) { @@ -560,22 +576,7 @@ this.b(entity); } -@@ -2175,7 +2454,13 @@ - IBlockData iblockdata = this.getType(blockposition); - AxisAlignedBB axisalignedbb = flag ? null : block.getBlockData().d(this, blockposition); - -- return axisalignedbb != Block.k && !this.a(axisalignedbb.a(blockposition), entity) ? false : (iblockdata.getMaterial() == Material.ORIENTABLE && block == Blocks.ANVIL ? true : iblockdata.getMaterial().isReplaceable() && block.canPlace(this, blockposition, enumdirection)); -+ // CraftBukkit start - store default return -+ boolean defaultReturn = axisalignedbb != Block.k && !this.a(axisalignedbb.a(blockposition), entity) ? false : (iblockdata.getMaterial() == Material.ORIENTABLE && block == Blocks.ANVIL ? true : iblockdata.getMaterial().isReplaceable() && block.canPlace(this, blockposition, enumdirection)); -+ BlockCanBuildEvent event = new BlockCanBuildEvent(this.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), CraftMagicNumbers.getId(block), defaultReturn); -+ this.getServer().getPluginManager().callEvent(event); -+ -+ return event.isBuildable(); -+ // CraftBukkit end - } - - public int getSeaLevel() { -@@ -2285,6 +2570,11 @@ +@@ -1954,6 +2249,11 @@ for (int i = 0; i < this.players.size(); ++i) { EntityHuman entityhuman1 = (EntityHuman) this.players.get(i); @@ -585,9 +586,9 @@ + } + // CraftBukkit end - if (predicate.apply(entityhuman1)) { + if (predicate.test(entityhuman1)) { double d5 = entityhuman1.d(d0, d1, d2); -@@ -2453,6 +2743,16 @@ +@@ -2122,6 +2422,16 @@ public void everyoneSleeping() {} @@ -601,10 +602,10 @@ + } + // CraftBukkit end + - public float h(float f) { - return (this.p + (this.q - this.p) * f) * this.j(f); + public float g(float f) { + return (this.q + (this.r - this.q) * f) * this.i(f); } -@@ -2670,7 +2970,7 @@ +@@ -2296,7 +2606,7 @@ int l = j * 16 + 8 - blockposition.getZ(); boolean flag = true; diff --git a/paper-server/nms-patches/WorldData.patch b/paper-server/nms-patches/WorldData.patch index d81876aa88..568e11a84f 100644 --- a/paper-server/nms-patches/WorldData.patch +++ b/paper-server/nms-patches/WorldData.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/server/WorldData.java +++ b/net/minecraft/server/WorldData.java -@@ -5,6 +5,11 @@ - import java.util.Map; +@@ -11,6 +11,11 @@ + import java.util.Set; import java.util.Map.Entry; import javax.annotation.Nullable; +// CraftBukkit start @@ -12,15 +12,23 @@ public class WorldData { -@@ -49,6 +54,7 @@ - private int M; - private final Map N; - private GameRules O; +@@ -62,6 +67,7 @@ + private final Map S; + private NBTTagCompound T; + private final GameRules U; + public WorldServer world; // CraftBukkit protected WorldData() { this.f = WorldType.NORMAL; -@@ -437,6 +443,16 @@ +@@ -296,6 +302,7 @@ + nbttagcompound2.setBoolean("Snapshot", true); + nbttagcompound.set("Version", nbttagcompound2); + nbttagcompound.setInt("DataVersion", 1513); ++ if (org.bukkit.craftbukkit.util.CraftMagicNumbers.DATA_VERSION != 1513) throw new AssertionError(); // CraftBukkit - sentinel + nbttagcompound.setLong("RandomSeed", this.e); + nbttagcompound.setString("generatorName", this.f.name()); + nbttagcompound.setInt("generatorVersion", this.f.getVersion()); +@@ -466,6 +473,16 @@ } public void setThundering(boolean flag) { @@ -34,10 +42,10 @@ + } + } + // CraftBukkit end - this.v = flag; + this.y = flag; } -@@ -453,6 +469,16 @@ +@@ -482,6 +499,16 @@ } public void setStorm(boolean flag) { @@ -51,13 +59,13 @@ + } + } + // CraftBukkit end - this.t = flag; + this.w = flag; } -@@ -598,6 +624,12 @@ +@@ -631,6 +658,12 @@ public void setDifficulty(EnumDifficulty enumdifficulty) { - this.C = enumdifficulty; + this.F = enumdifficulty; + // CraftBukkit start + PacketPlayOutServerDifficulty packet = new PacketPlayOutServerDifficulty(this.getDifficulty(), this.isDifficultyLocked()); + for (EntityPlayer player : (java.util.List) (java.util.List) world.players) { @@ -67,9 +75,9 @@ } public boolean isDifficultyLocked() { -@@ -716,4 +748,12 @@ - public void a(DimensionManager dimensionmanager, NBTTagCompound nbttagcompound) { - this.N.put(dimensionmanager, nbttagcompound); +@@ -712,4 +745,12 @@ + public void c(@Nullable NBTTagCompound nbttagcompound) { + this.T = nbttagcompound; } + + // CraftBukkit start - Check if the name stored in NBT is the correct one diff --git a/paper-server/nms-patches/WorldGenGroundBush.patch b/paper-server/nms-patches/WorldGenGroundBush.patch index bbd0306b2b..4afb31ce10 100644 --- a/paper-server/nms-patches/WorldGenGroundBush.patch +++ b/paper-server/nms-patches/WorldGenGroundBush.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/WorldGenGroundBush.java +++ b/net/minecraft/server/WorldGenGroundBush.java -@@ -45,7 +45,12 @@ +@@ -46,7 +46,12 @@ } } } diff --git a/paper-server/nms-patches/WorldGenMegaTreeAbstract.patch b/paper-server/nms-patches/WorldGenMegaTreeAbstract.patch deleted file mode 100644 index 99dd51eb58..0000000000 --- a/paper-server/nms-patches/WorldGenMegaTreeAbstract.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/server/WorldGenMegaTreeAbstract.java -+++ b/net/minecraft/server/WorldGenMegaTreeAbstract.java -@@ -42,7 +42,7 @@ - - for (int k = -b0; k <= b0 && flag; ++k) { - for (int l = -b0; l <= b0 && flag; ++l) { -- if (blockposition.getY() + j < 0 || blockposition.getY() + j >= 256 || !this.a(world.getType(blockposition.a(k, j, l)).getBlock())) { -+ if (blockposition.getY() + j < 0 || blockposition.getY() + j >= 256 || (!this.a(world.getType(blockposition.a(k, j, l)).getBlock()) && world.getType(blockposition.a(k, j, l)).getBlock() != Blocks.SAPLING)) { // CraftBukkit - ignore our own saplings - flag = false; - } - } diff --git a/paper-server/nms-patches/WorldGenRegistration.patch b/paper-server/nms-patches/WorldGenRegistration.patch deleted file mode 100644 index 63364bcb4e..0000000000 --- a/paper-server/nms-patches/WorldGenRegistration.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/server/WorldGenRegistration.java -+++ b/net/minecraft/server/WorldGenRegistration.java -@@ -157,7 +157,7 @@ - entitywitch.cW(); - entitywitch.setPositionRotation((double) i + 0.5D, (double) j, (double) k + 0.5D, 0.0F, 0.0F); - entitywitch.prepare(world.D(new BlockPosition(i, j, k)), (GroupDataEntity) null); -- world.addEntity(entitywitch); -+ world.addEntity(entitywitch, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CHUNK_GEN); // CraftBukkit - add SpawnReason - } - } - diff --git a/paper-server/nms-patches/WorldGenTreeProvider.patch b/paper-server/nms-patches/WorldGenTreeProvider.patch new file mode 100644 index 0000000000..c8da90acfd --- /dev/null +++ b/paper-server/nms-patches/WorldGenTreeProvider.patch @@ -0,0 +1,40 @@ +--- a/net/minecraft/server/WorldGenTreeProvider.java ++++ b/net/minecraft/server/WorldGenTreeProvider.java +@@ -2,6 +2,7 @@ + + import java.util.Random; + import javax.annotation.Nullable; ++import org.bukkit.TreeType; // CraftBukkit + + public abstract class WorldGenTreeProvider { + +@@ -16,6 +17,29 @@ + if (worldgentreeabstract == null) { + return false; + } else { ++ // CraftBukkit start ++ if (worldgentreeabstract instanceof WorldGenAcaciaTree) { ++ BlockSapling.treeType = TreeType.ACACIA; ++ } else if (worldgentreeabstract instanceof WorldGenBigTree) { ++ BlockSapling.treeType = TreeType.BIG_TREE; ++ } else if (worldgentreeabstract instanceof WorldGenForest) { ++ BlockSapling.treeType = TreeType.BIRCH; ++ } else if (worldgentreeabstract instanceof WorldGenForestTree) { ++ BlockSapling.treeType = TreeType.DARK_OAK; ++ } else if (worldgentreeabstract instanceof WorldGenJungleTree) { ++ BlockSapling.treeType = TreeType.JUNGLE; ++ } else if (worldgentreeabstract instanceof WorldGenMegaTree) { ++ BlockSapling.treeType = TreeType.MEGA_REDWOOD; ++ } else if (worldgentreeabstract instanceof WorldGenTaiga1) { ++ BlockSapling.treeType = TreeType.REDWOOD; ++ } else if (worldgentreeabstract instanceof WorldGenTaiga2) { ++ BlockSapling.treeType = TreeType.REDWOOD; ++ } else if (worldgentreeabstract instanceof WorldGenTrees) { ++ BlockSapling.treeType = TreeType.TREE; ++ } else { ++ throw new IllegalArgumentException("Unknown tree generator " + worldgentreeabstract); ++ } ++ // CraftBukkit end + generatoraccess.setTypeAndData(blockposition, Blocks.AIR.getBlockData(), 4); + if (worldgentreeabstract.generate(generatoraccess, generatoraccess.getChunkProvider().getChunkGenerator(), random, blockposition, WorldGenFeatureConfiguration.e)) { + return true; diff --git a/paper-server/nms-patches/WorldGenVillagePieces.patch b/paper-server/nms-patches/WorldGenVillagePieces.patch index ca0efd5fad..e55f15ceb6 100644 --- a/paper-server/nms-patches/WorldGenVillagePieces.patch +++ b/paper-server/nms-patches/WorldGenVillagePieces.patch @@ -1,45 +1,19 @@ --- a/net/minecraft/server/WorldGenVillagePieces.java +++ b/net/minecraft/server/WorldGenVillagePieces.java -@@ -238,10 +238,10 @@ - - protected void a(NBTTagCompound nbttagcompound) { - super.a(nbttagcompound); -- nbttagcompound.setInt("CA", Block.REGISTRY.a((Object) this.a)); -- nbttagcompound.setInt("CB", Block.REGISTRY.a((Object) this.b)); -- nbttagcompound.setInt("CC", Block.REGISTRY.a((Object) this.c)); -- nbttagcompound.setInt("CD", Block.REGISTRY.a((Object) this.d)); -+ nbttagcompound.setInt("CA", Block.REGISTRY.a(this.a)); -+ nbttagcompound.setInt("CB", Block.REGISTRY.a(this.b)); -+ nbttagcompound.setInt("CC", Block.REGISTRY.a(this.c)); -+ nbttagcompound.setInt("CD", Block.REGISTRY.a(this.d)); - } - - protected void a(NBTTagCompound nbttagcompound, DefinedStructureManager definedstructuremanager) { -@@ -371,8 +371,8 @@ - - protected void a(NBTTagCompound nbttagcompound) { - super.a(nbttagcompound); -- nbttagcompound.setInt("CA", Block.REGISTRY.a((Object) this.a)); -- nbttagcompound.setInt("CB", Block.REGISTRY.a((Object) this.b)); -+ nbttagcompound.setInt("CA", Block.REGISTRY.a(this.a)); -+ nbttagcompound.setInt("CB", Block.REGISTRY.a(this.b)); - } - - protected void a(NBTTagCompound nbttagcompound, DefinedStructureManager definedstructuremanager) { -@@ -1672,14 +1672,14 @@ - entityzombievillager.prepare(world.D(new BlockPosition(entityzombievillager)), (GroupDataEntity) null); +@@ -1662,14 +1662,14 @@ + entityzombievillager.prepare(generatoraccess.getDamageScaler(new BlockPosition(entityzombievillager)), (GroupDataEntity) null, (NBTTagCompound) null); entityzombievillager.setProfession(this.c(i1, 0)); - entityzombievillager.cW(); -- world.addEntity(entityzombievillager); -+ world.addEntity(entityzombievillager, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CHUNK_GEN); // CraftBukkit - add SpawnReason + entityzombievillager.di(); +- generatoraccess.addEntity(entityzombievillager); ++ generatoraccess.addEntity(entityzombievillager, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CHUNK_GEN); // CraftBukkit - add SpawnReason } else { - EntityVillager entityvillager = new EntityVillager(world); + EntityVillager entityvillager = new EntityVillager(generatoraccess.getMinecraftWorld()); entityvillager.setPositionRotation((double) j1 + 0.5D, (double) k1, (double) l1 + 0.5D, 0.0F, 0.0F); - entityvillager.setProfession(this.c(i1, world.random.nextInt(6))); - entityvillager.a(world.D(new BlockPosition(entityvillager)), (GroupDataEntity) null, false); -- world.addEntity(entityvillager); -+ world.addEntity(entityvillager, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CHUNK_GEN); // CraftBukkit - add SpawnReason + entityvillager.setProfession(this.c(i1, generatoraccess.m().nextInt(6))); + entityvillager.a(generatoraccess.getDamageScaler(new BlockPosition(entityvillager)), (GroupDataEntity) null, (NBTTagCompound) null, false); +- generatoraccess.addEntity(entityvillager); ++ generatoraccess.addEntity(entityvillager, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CHUNK_GEN); // CraftBukkit - add SpawnReason } } diff --git a/paper-server/nms-patches/WorldGenWitchHut.patch b/paper-server/nms-patches/WorldGenWitchHut.patch new file mode 100644 index 0000000000..70c91680a9 --- /dev/null +++ b/paper-server/nms-patches/WorldGenWitchHut.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/server/WorldGenWitchHut.java ++++ b/net/minecraft/server/WorldGenWitchHut.java +@@ -86,7 +86,7 @@ + entitywitch.di(); + entitywitch.setPositionRotation((double) i + 0.5D, (double) j, (double) k + 0.5D, 0.0F, 0.0F); + entitywitch.prepare(generatoraccess.getDamageScaler(new BlockPosition(i, j, k)), (GroupDataEntity) null, (NBTTagCompound) null); +- generatoraccess.addEntity(entitywitch); ++ generatoraccess.addEntity(entitywitch, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CHUNK_GEN); // CraftBukkit - add SpawnReason + } + } + diff --git a/paper-server/nms-patches/WorldMap.patch b/paper-server/nms-patches/WorldMap.patch index 5c8d8157c3..622228b638 100644 --- a/paper-server/nms-patches/WorldMap.patch +++ b/paper-server/nms-patches/WorldMap.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/WorldMap.java +++ b/net/minecraft/server/WorldMap.java -@@ -7,6 +7,14 @@ +@@ -7,6 +7,15 @@ import java.util.Map; import javax.annotation.Nullable; @@ -10,13 +10,14 @@ +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.craftbukkit.CraftWorld; +import org.bukkit.craftbukkit.map.CraftMapView; ++import org.bukkit.craftbukkit.util.CraftChatMessage; +// CraftBukkit end + public class WorldMap extends PersistentBase { public int centerX; -@@ -20,8 +28,18 @@ - private final Map k = Maps.newHashMap(); +@@ -21,8 +30,18 @@ + private final Map k = Maps.newHashMap(); public Map decorations = Maps.newLinkedHashMap(); + // CraftBukkit start @@ -33,8 +34,8 @@ + // CraftBukkit end } - public void a(double d0, double d1, int i) { -@@ -34,7 +52,30 @@ + public void a(int i, int j, int k, boolean flag, boolean flag1, int l) { +@@ -44,7 +63,30 @@ } public void a(NBTTagCompound nbttagcompound) { @@ -65,8 +66,8 @@ + // CraftBukkit end this.centerX = nbttagcompound.getInt("xCenter"); this.centerZ = nbttagcompound.getInt("zCenter"); - this.scale = nbttagcompound.getByte("scale"); -@@ -76,6 +117,25 @@ + this.scale = (byte) MathHelper.clamp(nbttagcompound.getByte("scale"), 0, 4); +@@ -67,6 +109,25 @@ } public NBTTagCompound b(NBTTagCompound nbttagcompound) { @@ -92,7 +93,7 @@ nbttagcompound.setByte("dimension", this.map); nbttagcompound.setInt("xCenter", this.centerX); nbttagcompound.setInt("zCenter", this.centerZ); -@@ -265,12 +325,26 @@ +@@ -315,12 +376,25 @@ @Nullable public Packet a(ItemStack itemstack) { @@ -104,18 +105,17 @@ + for ( org.bukkit.map.MapCursor cursor : render.cursors) { + + if (cursor.isVisible()) { -+ icons.add(new MapIcon(MapIcon.Type.a(cursor.getRawType()), cursor.getX(), cursor.getY(), cursor.getDirection())); ++ icons.add(new MapIcon(MapIcon.Type.a(cursor.getRawType()), cursor.getX(), cursor.getY(), cursor.getDirection(), CraftChatMessage.fromStringOrNull(cursor.getCaption()))); + } + } + if (this.d) { this.d = false; -- return new PacketPlayOutMap(itemstack.getData(), WorldMap.this.scale, WorldMap.this.track, WorldMap.this.decorations.values(), WorldMap.this.colors, this.e, this.f, this.g + 1 - this.e, this.h + 1 - this.f); -+ // PAIL: this.e -+ return new PacketPlayOutMap(itemstack.getData(), WorldMap.this.scale, WorldMap.this.track, icons, render.buffer, this.e, this.f, this.g + 1 - this.e, this.h + 1 - this.f); +- return new PacketPlayOutMap(ItemWorldMap.e(itemstack), WorldMap.this.scale, WorldMap.this.track, WorldMap.this.decorations.values(), WorldMap.this.colors, this.e, this.f, this.g + 1 - this.e, this.h + 1 - this.f); ++ return new PacketPlayOutMap(ItemWorldMap.e(itemstack), WorldMap.this.scale, WorldMap.this.track, icons, render.buffer, this.e, this.f, this.g + 1 - this.e, this.h + 1 - this.f); } else { -- return this.i++ % 5 == 0 ? new PacketPlayOutMap(itemstack.getData(), WorldMap.this.scale, WorldMap.this.track, WorldMap.this.decorations.values(), WorldMap.this.colors, 0, 0, 0, 0) : null; -+ return this.i++ % 5 == 0 ? new PacketPlayOutMap(itemstack.getData(), WorldMap.this.scale, WorldMap.this.track, icons, render.buffer, 0, 0, 0, 0) : null; +- return this.i++ % 5 == 0 ? new PacketPlayOutMap(ItemWorldMap.e(itemstack), WorldMap.this.scale, WorldMap.this.track, WorldMap.this.decorations.values(), WorldMap.this.colors, 0, 0, 0, 0) : null; ++ return this.i++ % 5 == 0 ? new PacketPlayOutMap(ItemWorldMap.e(itemstack), WorldMap.this.scale, WorldMap.this.track, icons, render.buffer, 0, 0, 0, 0) : null; } + // CraftBukkit end } diff --git a/paper-server/nms-patches/WorldNBTStorage.patch b/paper-server/nms-patches/WorldNBTStorage.patch index c39f4ef7bf..675a06b507 100644 --- a/paper-server/nms-patches/WorldNBTStorage.patch +++ b/paper-server/nms-patches/WorldNBTStorage.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/WorldNBTStorage.java +++ b/net/minecraft/server/WorldNBTStorage.java -@@ -12,6 +12,11 @@ +@@ -14,6 +14,11 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -12,15 +12,15 @@ public class WorldNBTStorage implements IDataManager, IPlayerFileData { private static final Logger b = LogManager.getLogger(); -@@ -22,6 +27,7 @@ +@@ -24,6 +29,7 @@ private final String g; private final DefinedStructureManager h; - protected final DataConverterManager a; + protected final DataFixer a; + private UUID uuid = null; // CraftBukkit - public WorldNBTStorage(File file, String s, boolean flag, DataConverterManager dataconvertermanager) { - this.a = dataconvertermanager; -@@ -168,12 +174,38 @@ + public WorldNBTStorage(File file, String s, @Nullable MinecraftServer minecraftserver, DataFixer datafixer) { + this.a = datafixer; +@@ -170,6 +176,16 @@ } if (nbttagcompound != null) { @@ -34,9 +34,10 @@ + } + } + // CraftBukkit end - entityhuman.f(this.a.a((DataConverterType) DataConverterTypes.PLAYER, nbttagcompound)); - } + int i = nbttagcompound.hasKeyOfType("DataVersion", 3) ? nbttagcompound.getInt("DataVersion") : -1; + entityhuman.f(GameProfileSerializer.a(this.a, DataFixTypes.PLAYER, nbttagcompound, i)); +@@ -178,6 +194,22 @@ return nbttagcompound; } @@ -59,9 +60,9 @@ public IPlayerFileData getPlayerFileData() { return this; } -@@ -203,4 +235,50 @@ - public DefinedStructureManager h() { - return this.h; +@@ -211,4 +243,50 @@ + public DataFixer i() { + return this.a; } + + // CraftBukkit start diff --git a/paper-server/nms-patches/WorldProviderHell.patch b/paper-server/nms-patches/WorldProviderHell.patch index 3b43b31649..f3660cd7f0 100644 --- a/paper-server/nms-patches/WorldProviderHell.patch +++ b/paper-server/nms-patches/WorldProviderHell.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/WorldProviderHell.java +++ b/net/minecraft/server/WorldProviderHell.java -@@ -44,11 +44,11 @@ +@@ -56,11 +56,11 @@ public WorldBorder getWorldBorder() { return new WorldBorder() { public double getCenterX() { diff --git a/paper-server/nms-patches/WorldServer.patch b/paper-server/nms-patches/WorldServer.patch index 682421efe1..6c1c381e54 100644 --- a/paper-server/nms-patches/WorldServer.patch +++ b/paper-server/nms-patches/WorldServer.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/WorldServer.java +++ b/net/minecraft/server/WorldServer.java -@@ -20,14 +20,26 @@ +@@ -20,6 +20,18 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -19,22 +19,13 @@ public class WorldServer extends World implements IAsyncTaskHandler { private static final Logger a = LogManager.getLogger(); - private final MinecraftServer server; - public EntityTracker tracker; - private final PlayerChunkMap manager; -- private final Set nextTickListHash = Sets.newHashSet(); -- private final TreeSet nextTickList = new TreeSet(); -+ // private final Set nextTickListHash = Sets.newHashSet(); -+ private final HashTreeSet nextTickList = new HashTreeSet(); // CraftBukkit - HashTreeSet - private final Map entitiesByUUID = Maps.newHashMap(); - public boolean savingDisabled; +@@ -38,28 +50,36 @@ + ObjectLinkedOpenHashSet d; private boolean Q; -@@ -39,14 +51,22 @@ - private int V; - private final List W = Lists.newArrayList(); - public WorldServer(MinecraftServer minecraftserver, IDataManager idatamanager, WorldData worlddata, int i, MethodProfiler methodprofiler) { - super(idatamanager, worlddata, DimensionManager.a(i).d(), methodprofiler, false); +- Predicate predicate = (block) -> { + // CraftBukkit start + public final int dimension; + @@ -45,52 +36,60 @@ + this.pvpMode = minecraftserver.getPVP(); + worlddata.world = this; + // CraftBukkit end ++ Predicate predicate = (block) -> { // CraftBukkit - decompile error + return block == null || block.getBlockData().isAir(); + }; + RegistryBlocks registryblocks = Block.REGISTRY; + + Block.REGISTRY.getClass(); + Function function = registryblocks::b; +- RegistryBlocks registryblocks1 = Block.REGISTRY; ++ RegistryBlocks registryblocks1 = Block.REGISTRY; // CraftBukkit - decompile error + + Block.REGISTRY.getClass(); +- this.nextTickListBlock = new TickListServer(this, predicate, function, registryblocks1::get, this::b); +- predicate = (fluidtype) -> { ++ this.nextTickListBlock = new TickListServer<>(this, predicate, function, registryblocks1::get, this::b); // CraftBukkit - decompile error ++ Predicate predicate2 = (fluidtype) -> { + return fluidtype == null || fluidtype == FluidTypes.a; + }; + registryblocks = FluidType.c; + FluidType.c.getClass(); + function = registryblocks::b; +- registryblocks1 = FluidType.c; ++ RegistryBlocks registryblocks2 = FluidType.c; // CraftBukkit - decompile error + FluidType.c.getClass(); +- this.nextTickListFluid = new TickListServer(this, predicate, function, registryblocks1::get, this::a); ++ this.nextTickListFluid = new TickListServer<>(this, predicate2, function, registryblocks2::get, this::a); // CraftBukkit - decompile error + this.siegeManager = new VillageSiege(this); + this.d = new ObjectLinkedOpenHashSet(); this.server = minecraftserver; - this.tracker = new EntityTracker(this); +@@ -67,7 +87,7 @@ this.manager = new PlayerChunkMap(this); this.worldProvider.a((World) this); - this.chunkProvider = this.n(); + this.chunkProvider = this.q(); - this.portalTravelAgent = new PortalTravelAgent(this); + this.portalTravelAgent = new org.bukkit.craftbukkit.CraftTravelAgent(this); // CraftBukkit - this.J(); - this.K(); - this.getWorldBorder().a(minecraftserver.aE()); -@@ -65,6 +85,7 @@ + this.O(); + this.P(); + this.getWorldBorder().a(minecraftserver.aw()); +@@ -86,6 +106,7 @@ this.villages.a((World) this); } + if (getServer().getScoreboardManager() == null) { // CraftBukkit - this.scoreboard = new ScoreboardServer(this.server); - PersistentScoreboard persistentscoreboard = (PersistentScoreboard) this.worldMaps.get(PersistentScoreboard.class, "scoreboard"); + PersistentScoreboard persistentscoreboard = (PersistentScoreboard) this.worldMaps.get(PersistentScoreboard::new, "scoreboard"); -@@ -75,9 +96,24 @@ + if (persistentscoreboard == null) { +@@ -95,6 +116,7 @@ - persistentscoreboard.a(this.scoreboard); - ((ScoreboardServer) this.scoreboard).a((Runnable) (new RunnableSaveScoreboard(persistentscoreboard))); -+ // CraftBukkit start -+ } else { -+ this.scoreboard = getServer().getScoreboardManager().getMainScoreboard().getHandle(); -+ } -+ // CraftBukkit end -+ - this.B = new LootTableRegistry(new File(new File(this.dataManager.getDirectory(), "data"), "loot_tables")); -- this.C = new AdvancementDataWorld(new File(new File(this.dataManager.getDirectory(), "data"), "advancements")); -- this.D = new CustomFunctionData(new File(new File(this.dataManager.getDirectory(), "data"), "functions"), this.server); -+ // CraftBukkit start -+ if (this.dimension != 0) { // SPIGOT-3899 multiple worlds of advancements not supported -+ this.C = this.server.getAdvancementData(); -+ } -+ if (this.C == null) { -+ this.C = new AdvancementDataWorld(new File(new File(this.dataManager.getDirectory(), "data"), "advancements")); -+ } -+ if (this.D == null) { -+ this.D = new CustomFunctionData(new File(new File(this.dataManager.getDirectory(), "data"), "functions"), this.server); -+ } -+ // CraftBukkit end + persistentscoreboard.a((Scoreboard) this.server.getScoreboard()); + this.server.getScoreboard().a((Runnable) (new RunnableSaveScoreboard(persistentscoreboard))); ++ } // CraftBukkit this.getWorldBorder().setCenter(this.worldData.B(), this.worldData.C()); this.getWorldBorder().setDamageAmount(this.worldData.H()); this.getWorldBorder().setDamageBuffer(this.worldData.G()); -@@ -89,9 +125,146 @@ +@@ -106,9 +128,130 @@ this.getWorldBorder().setSize(this.worldData.D()); } @@ -126,18 +125,14 @@ + result = fixTileEntity(pos, type, result); + } + } else if (type == Blocks.JUKEBOX) { -+ if (!(result instanceof BlockJukeBox.TileEntityRecordPlayer)) { ++ if (!(result instanceof TileEntityJukeBox)) { + result = fixTileEntity(pos, type, result); + } -+ } else if (type == Blocks.NOTEBLOCK) { -+ if (!(result instanceof TileEntityNote)) { -+ result = fixTileEntity(pos, type, result); -+ } -+ } else if (type == Blocks.MOB_SPAWNER) { ++ } else if (type == Blocks.SPAWNER) { + if (!(result instanceof TileEntityMobSpawner)) { + result = fixTileEntity(pos, type, result); + } -+ } else if ((type == Blocks.STANDING_SIGN) || (type == Blocks.WALL_SIGN)) { ++ } else if ((type == Blocks.SIGN) || (type == Blocks.WALL_SIGN)) { + if (!(result instanceof TileEntitySign)) { + result = fixTileEntity(pos, type, result); + } @@ -165,23 +160,19 @@ + if (!(result instanceof TileEntityEnderPortal)) { + result = fixTileEntity(pos, type, result); + } -+ } else if (type == Blocks.SKULL) { ++ } else if (type instanceof BlockSkullAbstract) { + if (!(result instanceof TileEntitySkull)) { + result = fixTileEntity(pos, type, result); + } -+ } else if (type == Blocks.DAYLIGHT_DETECTOR || type == Blocks.DAYLIGHT_DETECTOR_INVERTED) { ++ } else if (type == Blocks.DAYLIGHT_DETECTOR) { + if (!(result instanceof TileEntityLightDetector)) { + result = fixTileEntity(pos, type, result); + } -+ } else if (type == Blocks.POWERED_COMPARATOR || type == Blocks.UNPOWERED_COMPARATOR) { ++ } else if (type == Blocks.COMPARATOR) { + if (!(result instanceof TileEntityComparator)) { + result = fixTileEntity(pos, type, result); + } -+ } else if (type == Blocks.FLOWER_POT) { -+ if (!(result instanceof TileEntityFlowerPot)) { -+ result = fixTileEntity(pos, type, result); -+ } -+ } else if (type == Blocks.STANDING_BANNER || type == Blocks.WALL_BANNER) { ++ }else if (type instanceof BlockBannerAbstract) { + if (!(result instanceof TileEntityBanner)) { + result = fixTileEntity(pos, type, result); + } @@ -201,7 +192,7 @@ + if (!(result instanceof TileEntityStructure)) { + result = fixTileEntity(pos, type, result); + } -+ } else if (type == Blocks.BED) { ++ } else if (type instanceof BlockBed) { + if (!(result instanceof TileEntityBed)) { + result = fixTileEntity(pos, type, result); + } @@ -212,10 +203,10 @@ + + private TileEntity fixTileEntity(BlockPosition pos, Block type, TileEntity found) { + this.getServer().getLogger().log(Level.SEVERE, "Block at {0},{1},{2} is {3} but has {4}" + ". " -+ + "Bukkit will attempt to fix this, but there may be additional damage that we cannot recover.", new Object[]{pos.getX(), pos.getY(), pos.getZ(), org.bukkit.Material.getMaterial(Block.getId(type)).toString(), found}); ++ + "Bukkit will attempt to fix this, but there may be additional damage that we cannot recover.", new Object[]{pos.getX(), pos.getY(), pos.getZ(), type, found}); + + if (type instanceof ITileEntity) { -+ TileEntity replacement = ((ITileEntity) type).a(this, type.toLegacyData(this.getType(pos))); ++ TileEntity replacement = ((ITileEntity) type).a(this); + replacement.world = this; + this.setTileEntity(pos, replacement); + return replacement; @@ -224,43 +215,37 @@ + return found; + } + } -+ -+ private boolean canSpawn(int x, int z) { -+ if (this.generator != null) { -+ return this.generator.canSpawn(this.getWorld(), x, z); -+ } else { -+ return this.worldProvider.canSpawn(x, z); -+ } -+ } + // CraftBukkit end + public void doTick() { + this.Q = true; super.doTick(); - if (this.getWorldData().isHardcore() && this.getDifficulty() != EnumDifficulty.HARD) { -@@ -110,8 +283,11 @@ +@@ -128,9 +271,12 @@ } - this.methodProfiler.a("mobSpawner"); + this.methodProfiler.a("spawner"); - if (this.getGameRules().getBoolean("doMobSpawning") && this.worldData.getType() != WorldType.DEBUG_ALL_BLOCK_STATES) { - this.spawnerCreature.a(this, this.allowMonsters, this.allowAnimals, this.worldData.getTime() % 400L == 0L); +- this.getChunkProviderServer().a(this, this.allowMonsters, this.allowAnimals); + // CraftBukkit start - Only call spawner if we have players online and the world allows for mobs or animals + long time = this.worldData.getTime(); + if (this.getGameRules().getBoolean("doMobSpawning") && this.worldData.getType() != WorldType.DEBUG_ALL_BLOCK_STATES && (this.allowMonsters || this.allowAnimals) && (this instanceof WorldServer && this.players.size() > 0)) { + this.spawnerCreature.a(this, this.allowMonsters && (this.ticksPerMonsterSpawns != 0 && time % this.ticksPerMonsterSpawns == 0L), this.allowAnimals && (this.ticksPerAnimalSpawns != 0 && time % this.ticksPerAnimalSpawns == 0L), this.worldData.getTime() % 400L == 0L); ++ this.getChunkProviderServer().a(this, this.allowMonsters && (this.ticksPerMonsterSpawns != 0 && time % this.ticksPerMonsterSpawns == 0L), this.allowAnimals && (this.ticksPerAnimalSpawns != 0 && time % this.ticksPerAnimalSpawns == 0L)); + // CraftBukkit end } this.methodProfiler.c("chunkSource"); -@@ -140,6 +316,8 @@ - this.portalTravelAgent.a(this.getTime()); - this.methodProfiler.b(); - this.aq(); +@@ -160,6 +306,8 @@ + this.methodProfiler.e(); + this.am(); + this.Q = false; + + this.getWorld().processChunkGC(); // CraftBukkit } - @Nullable -@@ -167,7 +345,7 @@ + public boolean j_() { +@@ -191,7 +339,7 @@ if (entityhuman.isSpectator()) { ++i; @@ -269,14 +254,14 @@ ++j; } } -@@ -195,25 +373,46 @@ +@@ -223,25 +371,46 @@ } - private void c() { + private void ai() { - this.worldData.setWeatherDuration(0); ++ // CraftBukkit start this.worldData.setStorm(false); - this.worldData.setThunderDuration(0); -+ // CraftBukkit start + // If we stop due to everyone sleeping we should reset the weather duration to some other random value. + // Not that everyone ever manages to get the whole server to sleep at the same time.... + if (!this.worldData.hasStorm()) { @@ -294,7 +279,7 @@ } public boolean everyoneDeeplySleeping() { - if (this.Q && !this.isClientSide) { + if (this.K && !this.isClientSide) { Iterator iterator = this.players.iterator(); + // CraftBukkit - This allows us to assume that some people are in bed but not really, allowing time to pass in spite of AFKers @@ -320,8 +305,8 @@ return false; } else { -@@ -283,7 +482,7 @@ - entityhorseskeleton.p(true); +@@ -315,7 +484,7 @@ + entityhorseskeleton.s(true); entityhorseskeleton.setAgeRaw(0); entityhorseskeleton.setPosition((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ()); - this.addEntity(entityhorseskeleton); @@ -329,51 +314,30 @@ this.strikeLightning(new EntityLightning(this, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), true)); } else { this.strikeLightning(new EntityLightning(this, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), false)); -@@ -299,11 +498,11 @@ - BlockPosition blockposition1 = blockposition.down(); +@@ -332,11 +501,11 @@ + BiomeBase biomebase = this.getBiome(blockposition); - if (this.v(blockposition1)) { + if (biomebase.a((IWorldReader) this, blockposition1)) { - this.setTypeUpdate(blockposition1, Blocks.ICE.getBlockData()); + org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this, blockposition1, Blocks.ICE.getBlockData(), null); // CraftBukkit } - if (flag && this.f(blockposition, true)) { -- this.setTypeUpdate(blockposition, Blocks.SNOW_LAYER.getBlockData()); -+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this, blockposition, Blocks.SNOW_LAYER.getBlockData(), null); // CraftBukkit + if (flag && biomebase.b(this, blockposition)) { +- this.setTypeUpdate(blockposition, Blocks.SNOW.getBlockData()); ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this, blockposition1, Blocks.ICE.getBlockData(), null); // CraftBukkit } - if (flag && this.getBiome(blockposition1).d()) { -@@ -378,7 +577,7 @@ - public boolean b(BlockPosition blockposition, Block block) { - NextTickListEntry nextticklistentry = new NextTickListEntry(blockposition, block); - -- return this.nextTickListHash.contains(nextticklistentry); -+ return this.nextTickList.contains(nextticklistentry); // CraftBukkit - } - - public void a(BlockPosition blockposition, Block block, int i) { -@@ -412,8 +611,8 @@ - nextticklistentry.a(j); - } - -- if (!this.nextTickListHash.contains(nextticklistentry)) { -- this.nextTickListHash.add(nextticklistentry); -+ // CraftBukkit - use nextTickList -+ if (!this.nextTickList.contains(nextticklistentry)) { - this.nextTickList.add(nextticklistentry); - } - } -@@ -430,15 +629,15 @@ - nextticklistentry.a((long) i + this.worldData.getTime()); - } - -- if (!this.nextTickListHash.contains(nextticklistentry)) { -- this.nextTickListHash.add(nextticklistentry); -+ // CraftBukkit - use nextTickList -+ if (!this.nextTickList.contains(nextticklistentry)) { - this.nextTickList.add(nextticklistentry); - } + if (flag && this.getBiome(blockposition1).c() == BiomeBase.Precipitation.RAIN) { +@@ -385,7 +554,7 @@ + protected BlockPosition a(BlockPosition blockposition) { + BlockPosition blockposition1 = this.getHighestBlockYAt(HeightMap.Type.MOTION_BLOCKING, blockposition); + AxisAlignedBB axisalignedbb = (new AxisAlignedBB(blockposition1, new BlockPosition(blockposition1.getX(), this.getHeight(), blockposition1.getZ()))).g(3.0D); +- List list = this.a(EntityLiving.class, axisalignedbb, (entityliving) -> { ++ List list = this.a(EntityLiving.class, axisalignedbb, (Predicate) (entityliving) -> { // CraftBukkit - decompile error + return entityliving != null && entityliving.isAlive() && this.e(entityliving.getChunkCoordinates()); + }); +@@ -401,7 +570,7 @@ } public void tickEntities() { @@ -382,55 +346,15 @@ if (this.emptyTime++ >= 300) { return; } -@@ -508,11 +707,17 @@ - } else { - int i = this.nextTickList.size(); +@@ -490,6 +659,7 @@ -- if (i != this.nextTickListHash.size()) { -+ if (false) { // CraftBukkit - throw new IllegalStateException("TickNextTick list out of synch"); - } else { - if (i > 65536) { -- i = 65536; -+ // CraftBukkit start - If the server has too much to process over time, try to alleviate that -+ if (i > 20 * 65536) { -+ i = i / 20; -+ } else { -+ i = 65536; -+ } -+ // CraftBukkit end - } - - this.methodProfiler.a("cleaning"); -@@ -525,8 +730,9 @@ - break; - } - -+ // CraftBukkit - use nextTickList - this.nextTickList.remove(nextticklistentry); -- this.nextTickListHash.remove(nextticklistentry); -+ // this.nextTickListHash.remove(nextticklistentry); - this.W.add(nextticklistentry); - } - -@@ -596,7 +802,7 @@ - if (blockposition.getX() >= structureboundingbox.a && blockposition.getX() < structureboundingbox.d && blockposition.getZ() >= structureboundingbox.c && blockposition.getZ() < structureboundingbox.f) { - if (flag) { - if (i == 0) { -- this.nextTickListHash.remove(nextticklistentry); -+ // this.nextTickListHash.remove(nextticklistentry); // CraftBukkit - removed - } - - iterator.remove(); -@@ -614,6 +820,7 @@ - return arraylist; } + /* CraftBukkit start - We prevent spawning in general, so this butchering is not needed public void entityJoinedWorld(Entity entity, boolean flag) { if (!this.getSpawnAnimals() && (entity instanceof EntityAnimal || entity instanceof EntityWaterAnimal)) { entity.die(); -@@ -625,6 +832,7 @@ +@@ -501,6 +671,7 @@ super.entityJoinedWorld(entity, flag); } @@ -438,11 +362,11 @@ private boolean getSpawnNPCs() { return this.server.getSpawnNPCs(); -@@ -637,7 +845,54 @@ - protected IChunkProvider n() { +@@ -513,7 +684,21 @@ + protected IChunkProvider q() { IChunkLoader ichunkloader = this.dataManager.createChunkLoader(this.worldProvider); -- return new ChunkProviderServer(this, ichunkloader, this.worldProvider.getChunkGenerator()); +- return new ChunkProviderServer(this, ichunkloader, this.worldProvider.getChunkGenerator(), this.server); + // CraftBukkit start + org.bukkit.craftbukkit.generator.InternalChunkGenerator gen; + @@ -456,47 +380,14 @@ + gen = new org.bukkit.craftbukkit.generator.NormalChunkGenerator(this, this.getSeed()); + } + -+ return new ChunkProviderServer(this, ichunkloader, gen); ++ return new ChunkProviderServer(this, ichunkloader, gen, this.server); + // CraftBukkit end -+ } -+ -+ public List getTileEntities(int i, int j, int k, int l, int i1, int j1) { -+ ArrayList arraylist = Lists.newArrayList(); -+ -+ // CraftBukkit start - Get tile entities from chunks instead of world -+ for (int chunkX = (i >> 4); chunkX <= ((l - 1) >> 4); chunkX++) { -+ for (int chunkZ = (k >> 4); chunkZ <= ((j1 - 1) >> 4); chunkZ++) { -+ Chunk chunk = getChunkAt(chunkX, chunkZ); -+ if (chunk == null) { -+ continue; -+ } -+ for (Object te : chunk.tileEntities.values()) { -+ TileEntity tileentity = (TileEntity) te; -+ if ((tileentity.position.getX() >= i) && (tileentity.position.getY() >= j) && (tileentity.position.getZ() >= k) && (tileentity.position.getX() < l) && (tileentity.position.getY() < i1) && (tileentity.position.getZ() < j1)) { -+ arraylist.add(tileentity); -+ } -+ } -+ } -+ } -+ /* -+ for (int k1 = 0; k1 < this.tileEntityList.size(); ++k1) { -+ TileEntity tileentity = (TileEntity) this.tileEntityList.get(k1); -+ BlockPosition blockposition = tileentity.getPosition(); -+ -+ if (blockposition.getX() >= i && blockposition.getY() >= j && blockposition.getZ() >= k && blockposition.getX() < l && blockposition.getY() < i1 && blockposition.getZ() < j1) { -+ arraylist.add(tileentity); -+ } -+ } -+ */ -+ // CraftBukkit end -+ -+ return arraylist; } public boolean a(EntityHuman entityhuman, BlockPosition blockposition) { -@@ -699,6 +954,23 @@ - int j = this.worldProvider.getSeaLevel(); - int k = 8; +@@ -572,6 +757,22 @@ + BlockPosition blockposition = worldchunkmanager.a(0, 0, 256, list, random); + ChunkCoordIntPair chunkcoordintpair = blockposition == null ? new ChunkCoordIntPair(0, 0) : new ChunkCoordIntPair(blockposition); + // CraftBukkit start + if (this.generator != null) { @@ -508,34 +399,24 @@ + throw new IllegalStateException("Cannot set spawn point for " + this.worldData.getName() + " to be in another world (" + spawn.getWorld().getName() + ")"); + } else { + this.worldData.setSpawn(new BlockPosition(spawn.getBlockX(), spawn.getBlockY(), spawn.getBlockZ())); -+ this.isLoading = false; + return; + } + } + } + // CraftBukkit end + - if (blockposition != null) { - i = blockposition.getX(); - k = blockposition.getZ(); -@@ -708,7 +980,7 @@ - - int l = 0; - -- while (!this.worldProvider.canSpawn(i, k)) { -+ while (!this.canSpawn(i, k)) { // CraftBukkit - use our own canSpawn - i += random.nextInt(64) - random.nextInt(64); - k += random.nextInt(64) - random.nextInt(64); - ++l; -@@ -750,6 +1022,7 @@ + if (blockposition == null) { + WorldServer.a.warn("Unable to find spawn biome"); + } +@@ -647,6 +848,7 @@ ChunkProviderServer chunkproviderserver = this.getChunkProviderServer(); if (chunkproviderserver.e()) { + org.bukkit.Bukkit.getPluginManager().callEvent(new org.bukkit.event.world.WorldSaveEvent(getWorld())); // CraftBukkit if (iprogressupdate != null) { - iprogressupdate.a("Saving level"); + iprogressupdate.a(new ChatMessage("menu.savingLevel", new Object[0])); } -@@ -760,7 +1033,8 @@ +@@ -657,7 +859,8 @@ } chunkproviderserver.a(flag); @@ -545,20 +426,20 @@ Iterator iterator = arraylist.iterator(); while (iterator.hasNext()) { -@@ -795,6 +1069,12 @@ +@@ -692,6 +895,12 @@ } } + // CraftBukkit start - Save secondary data for nether/end + if (this instanceof SecondaryWorldServer) { -+ ((SecondaryWorldServer) this).c(); ++ ((SecondaryWorldServer) this).c(); // As above + } + // CraftBukkit end + this.worldData.a(this.getWorldBorder().getSize()); this.worldData.d(this.getWorldBorder().getCenterX()); this.worldData.c(this.getWorldBorder().getCenterZ()); -@@ -808,9 +1088,13 @@ +@@ -706,9 +915,13 @@ this.worldMaps.a(); } @@ -574,25 +455,25 @@ public void a(Collection collection) { ArrayList arraylist = Lists.newArrayList(collection); -@@ -829,7 +1113,7 @@ +@@ -727,7 +940,7 @@ private boolean j(Entity entity) { if (entity.dead) { -- WorldServer.a.warn("Tried to add entity {} but it was marked as removed already", EntityTypes.a(entity)); -+ // WorldServer.a.warn("Tried to add entity {} but it was marked as removed already", EntityTypes.a(entity)); // CraftBukkit +- WorldServer.a.warn("Tried to add entity {} but it was marked as removed already", EntityTypes.getName(entity.P())); ++ // WorldServer.a.warn("Tried to add entity {} but it was marked as removed already", EntityTypes.getName(entity.P())); // CraftBukkit return false; } else { UUID uuid = entity.getUniqueID(); -@@ -841,7 +1125,7 @@ - this.f.remove(entity1); +@@ -739,7 +952,7 @@ + this.g.remove(entity1); } else { if (!(entity instanceof EntityHuman)) { -- WorldServer.a.warn("Keeping entity {} that already exists with UUID {}", EntityTypes.a(entity1), uuid.toString()); -+ // WorldServer.a.warn("Keeping entity {} that already exists with UUID {}", EntityTypes.a(entity1), uuid.toString()); // CraftBukkit +- WorldServer.a.warn("Keeping entity {} that already exists with UUID {}", EntityTypes.getName(entity1.P()), uuid.toString()); ++ // WorldServer.a.warn("Keeping entity {} that already exists with UUID {}", EntityTypes.getName(entity1.P()), uuid.toString()); // CraftBukkit return false; } -@@ -894,8 +1178,16 @@ +@@ -792,8 +1005,16 @@ } public boolean strikeLightning(Entity entity) { @@ -610,12 +491,12 @@ return true; } else { return false; -@@ -911,10 +1203,20 @@ +@@ -809,6 +1030,14 @@ } - public Explosion createExplosion(@Nullable Entity entity, double d0, double d1, double d2, float f, boolean flag, boolean flag1) { + public Explosion createExplosion(@Nullable Entity entity, DamageSource damagesource, double d0, double d1, double d2, float f, boolean flag, boolean flag1) { + // CraftBukkit start -+ Explosion explosion = super.createExplosion(entity, d0, d1, d2, f, flag, flag1); ++ Explosion explosion = super.createExplosion(entity, damagesource, d0, d1, d2, f, flag, flag1); + + if (explosion.wasCanceled) { + return explosion; @@ -624,6 +505,9 @@ + /* Remove Explosion explosion = new Explosion(this, entity, d0, d1, d2, f, flag, flag1); + if (damagesource != null) { +@@ -817,6 +1046,8 @@ + explosion.a(); explosion.a(false); + */ @@ -631,27 +515,27 @@ if (!flag1) { explosion.clearBlocks(); } -@@ -960,7 +1262,8 @@ - BlockActionData blockactiondata = (BlockActionData) iterator.next(); +@@ -843,7 +1074,8 @@ + BlockActionData blockactiondata = (BlockActionData) this.d.removeFirst(); - if (this.a(blockactiondata)) { -- this.server.getPlayerList().sendPacketNearby((EntityHuman) null, (double) blockactiondata.a().getX(), (double) blockactiondata.a().getY(), (double) blockactiondata.a().getZ(), 64.0D, this.worldProvider.getDimensionManager().getDimensionID(), new PacketPlayOutBlockAction(blockactiondata.a(), blockactiondata.d(), blockactiondata.b(), blockactiondata.c())); -+ // CraftBukkit - this.worldProvider.dimension -> this.dimension -+ this.server.getPlayerList().sendPacketNearby((EntityHuman) null, (double) blockactiondata.a().getX(), (double) blockactiondata.a().getY(), (double) blockactiondata.a().getZ(), 64.0D, dimension, new PacketPlayOutBlockAction(blockactiondata.a(), blockactiondata.d(), blockactiondata.b(), blockactiondata.c())); - } + if (this.a(blockactiondata)) { +- this.server.getPlayerList().sendPacketNearby((EntityHuman) null, (double) blockactiondata.a().getX(), (double) blockactiondata.a().getY(), (double) blockactiondata.a().getZ(), 64.0D, this.worldProvider.getDimensionManager().getDimensionID(), new PacketPlayOutBlockAction(blockactiondata.a(), blockactiondata.b(), blockactiondata.c(), blockactiondata.d())); ++ // CraftBukkit - this.worldProvider.dimension -> this.dimension ++ this.server.getPlayerList().sendPacketNearby((EntityHuman) null, (double) blockactiondata.a().getX(), (double) blockactiondata.a().getY(), (double) blockactiondata.a().getZ(), 64.0D, dimension, new PacketPlayOutBlockAction(blockactiondata.a(), blockactiondata.b(), blockactiondata.c(), blockactiondata.d())); } + } -@@ -983,6 +1286,7 @@ +@@ -864,6 +1096,7 @@ boolean flag = this.isRaining(); - super.t(); + super.v(); + /* CraftBukkit start - if (this.n != this.o) { - this.server.getPlayerList().a((Packet) (new PacketPlayOutGameStateChange(7, this.o)), this.worldProvider.getDimensionManager().getDimensionID()); + if (this.o != this.p) { + this.server.getPlayerList().a((Packet) (new PacketPlayOutGameStateChange(7, this.p)), this.worldProvider.getDimensionManager().getDimensionID()); } -@@ -1001,6 +1305,21 @@ - this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(7, this.o)); - this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(8, this.q)); +@@ -882,6 +1115,21 @@ + this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(7, this.p)); + this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(8, this.r)); } + // */ + if (flag != this.isRaining()) { @@ -664,31 +548,29 @@ + } + for (int i = 0; i < this.players.size(); ++i) { + if (((EntityPlayer) this.players.get(i)).world == this) { -+ ((EntityPlayer) this.players.get(i)).updateWeather(this.n, this.o, this.p, this.q); ++ ((EntityPlayer) this.players.get(i)).updateWeather(this.o, this.p, this.q, this.r); + } + } + // CraftBukkit end } -@@ -1030,10 +1349,20 @@ +@@ -915,11 +1163,18 @@ } - public void a(EnumParticle enumparticle, boolean flag, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6, int... aint) { + public int a(T t0, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6) { + // CraftBukkit - visibility api support -+ sendParticles(null, enumparticle, flag, d0, d1, d2, i, d3, d4, d5, d6, aint); ++ return sendParticles(null, t0, d0, d1, d2, i, d3, d4, d5, d6); + } + -+ public void sendParticles(EntityPlayer sender, EnumParticle enumparticle, boolean flag, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6, int... aint) { ++ public int sendParticles(EntityPlayer sender, T t0, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6) { + // CraftBukkit end - PacketPlayOutWorldParticles packetplayoutworldparticles = new PacketPlayOutWorldParticles(enumparticle, flag, (float) d0, (float) d1, (float) d2, (float) d3, (float) d4, (float) d5, (float) d6, i, aint); + PacketPlayOutWorldParticles packetplayoutworldparticles = new PacketPlayOutWorldParticles(t0, false, (float) d0, (float) d1, (float) d2, (float) d3, (float) d4, (float) d5, (float) d6, i); + int j = 0; - for (int j = 0; j < this.players.size(); ++j) { - EntityPlayer entityplayer = (EntityPlayer) this.players.get(j); + for (int k = 0; k < this.players.size(); ++k) { + EntityPlayer entityplayer = (EntityPlayer) this.players.get(k); + if (sender != null && !entityplayer.getBukkitEntity().canSee(sender.getBukkitEntity())) continue; // CraftBukkit -+ BlockPosition blockposition = entityplayer.getChunkCoordinates(); -+ double d7 = blockposition.distanceSquared(d0, d1, d2); -+ - this.a(entityplayer, flag, d0, d1, d2, packetplayoutworldparticles); - } + if (this.a(entityplayer, false, d0, d1, d2, packetplayoutworldparticles)) { + ++j; diff --git a/paper-server/pom.xml b/paper-server/pom.xml index 2cf28b13d5..9d8810cc4a 100644 --- a/paper-server/pom.xml +++ b/paper-server/pom.xml @@ -4,15 +4,15 @@ org.bukkit craftbukkit jar - 1.12.2-R0.1-SNAPSHOT + 1.13-pre7-R0.1-SNAPSHOT CraftBukkit http://www.bukkit.org UTF-8 unknown - 1.12.2 - 1_12_R1 + 1.13-pre7 + 1_13_R1 git-Bukkit- yyyyMMdd-HHmm @@ -21,13 +21,6 @@ - - - io.netty - netty-all - 4.1.24.Final - compile - org.bukkit bukkit @@ -40,28 +33,28 @@ ${minecraft.version}-SNAPSHOT compile - - net.sf.jopt-simple - jopt-simple - 5.0.4 - compile - jline jline 2.12.1 compile + + org.ow2.asm + asm + 6.2 + compile + org.xerial sqlite-jdbc - 3.21.0.1 + 3.23.1 runtime mysql mysql-connector-java - 5.1.45 + 5.1.46 runtime @@ -115,7 +108,7 @@ org.apache.maven.plugins maven-jar-plugin - 3.0.2 + 2.4 @@ -153,7 +146,7 @@ org.apache.maven.plugins maven-shade-plugin - 3.1.0 + 3.1.1 package @@ -215,8 +208,7 @@ org.apache.maven.plugins maven-surefire-plugin - - 2.20 + 2.12.4 ${basedir}/target/test-server @@ -235,7 +227,7 @@ org.codehaus.mojo animal-sniffer-maven-plugin - 1.16 + 1.17 process-classes diff --git a/paper-server/src/main/java/com/mojang/brigadier/tree/CommandNode.java b/paper-server/src/main/java/com/mojang/brigadier/tree/CommandNode.java new file mode 100644 index 0000000000..1196df6b6c --- /dev/null +++ b/paper-server/src/main/java/com/mojang/brigadier/tree/CommandNode.java @@ -0,0 +1,200 @@ +package com.mojang.brigadier.tree; + +import com.google.common.collect.ComparisonChain; +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; +import com.mojang.brigadier.AmbiguityConsumer; +import com.mojang.brigadier.Command; +import com.mojang.brigadier.RedirectModifier; +import com.mojang.brigadier.StringReader; +import com.mojang.brigadier.builder.ArgumentBuilder; +import com.mojang.brigadier.context.CommandContext; +import com.mojang.brigadier.context.CommandContextBuilder; +import com.mojang.brigadier.exceptions.CommandSyntaxException; +import com.mojang.brigadier.suggestion.Suggestions; +import com.mojang.brigadier.suggestion.SuggestionsBuilder; + +import java.util.Collection; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.CompletableFuture; +import java.util.function.Predicate; +import java.util.stream.Collectors; + +import net.minecraft.server.CommandListenerWrapper; // CraftBukkit + +public abstract class CommandNode implements Comparable> { + private Map> children = Maps.newLinkedHashMap(); + private Map> literals = Maps.newLinkedHashMap(); + private Map> arguments = Maps.newLinkedHashMap(); + private final Predicate requirement; + private final CommandNode redirect; + private final RedirectModifier modifier; + private final boolean forks; + private Command command; + + protected CommandNode(final Command command, final Predicate requirement, final CommandNode redirect, final RedirectModifier modifier, final boolean forks) { + this.command = command; + this.requirement = requirement; + this.redirect = redirect; + this.modifier = modifier; + this.forks = forks; + } + + public Command getCommand() { + return command; + } + + public Collection> getChildren() { + return children.values(); + } + + public CommandNode getChild(final String name) { + return children.get(name); + } + + public CommandNode getRedirect() { + return redirect; + } + + public RedirectModifier getRedirectModifier() { + return modifier; + } + + public boolean canUse(final S source) { + // CraftBukkit start + if (source instanceof CommandListenerWrapper) { + try { + ((CommandListenerWrapper) source).currentCommand = this; + return requirement.test(source); + } finally { + ((CommandListenerWrapper) source).currentCommand = null; + } + } + // CraftBukkit end + return requirement.test(source); + } + + public void addChild(final CommandNode node) { + if (node instanceof RootCommandNode) { + throw new UnsupportedOperationException("Cannot add a RootCommandNode as a child to any other CommandNode"); + } + + final CommandNode child = children.get(node.getName()); + if (child != null) { + // We've found something to merge onto + if (node.getCommand() != null) { + child.command = node.getCommand(); + } + for (final CommandNode grandchild : node.getChildren()) { + child.addChild(grandchild); + } + } else { + children.put(node.getName(), node); + if (node instanceof LiteralCommandNode) { + literals.put(node.getName(), (LiteralCommandNode) node); + } else if (node instanceof ArgumentCommandNode) { + arguments.put(node.getName(), (ArgumentCommandNode) node); + } + } + + children = children.entrySet().stream().sorted(Map.Entry.comparingByValue()).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e1, LinkedHashMap::new)); + } + + public void findAmbiguities(final AmbiguityConsumer consumer) { + Set matches = Sets.newHashSet(); + + for (final CommandNode child : children.values()) { + for (final CommandNode sibling : children.values()) { + if (child == sibling) { + continue; + } + + for (final String input : child.getExamples()) { + if (sibling.isValidInput(input)) { + matches.add(input); + } + } + + if (matches.size() > 0) { + consumer.ambiguous(this, child, sibling, matches); + matches = Sets.newHashSet(); + } + } + + child.findAmbiguities(consumer); + } + } + + protected abstract boolean isValidInput(final String input); + + @Override + public boolean equals(final Object o) { + if (this == o) return true; + if (!(o instanceof CommandNode)) return false; + + final CommandNode that = (CommandNode) o; + + if (!children.equals(that.children)) return false; + if (command != null ? !command.equals(that.command) : that.command != null) return false; + + return true; + } + + @Override + public int hashCode() { + return 31 * children.hashCode() + (command != null ? command.hashCode() : 0); + } + + public Predicate getRequirement() { + return requirement; + } + + public abstract String getName(); + + public abstract String getUsageText(); + + public abstract void parse(StringReader reader, CommandContextBuilder contextBuilder) throws CommandSyntaxException; + + public abstract CompletableFuture listSuggestions(CommandContext context, SuggestionsBuilder builder) throws CommandSyntaxException; + + public abstract ArgumentBuilder createBuilder(); + + protected abstract String getSortedKey(); + + public Collection> getRelevantNodes(final StringReader input) { + if (literals.size() > 0) { + final int cursor = input.getCursor(); + while (input.canRead() && input.peek() != ' ') { + input.skip(); + } + final String text = input.getString().substring(cursor, input.getCursor()); + input.setCursor(cursor); + final LiteralCommandNode literal = literals.get(text); + if (literal != null) { + return Collections.singleton(literal); + } else { + return arguments.values(); + } + } else { + return arguments.values(); + } + } + + @Override + public int compareTo(final CommandNode o) { + return ComparisonChain + .start() + .compareTrueFirst(this instanceof LiteralCommandNode, o instanceof LiteralCommandNode) + .compare(getSortedKey(), o.getSortedKey()) + .result(); + } + + public boolean isFork() { + return forks; + } + + public abstract Collection getExamples(); +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftArt.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftArt.java index 6f94348dc2..1b17fd2b59 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftArt.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftArt.java @@ -1,74 +1,33 @@ package org.bukkit.craftbukkit; -import net.minecraft.server.EntityPainting.EnumArt; +import com.google.common.base.Preconditions; +import com.google.common.collect.BiMap; +import com.google.common.collect.ImmutableBiMap; +import net.minecraft.server.MinecraftKey; +import net.minecraft.server.Paintings; import org.bukkit.Art; -// Safety class, will break if either side changes public class CraftArt { + private static final BiMap artwork; - public static Art NotchToBukkit(EnumArt art) { - switch (art) { - case KEBAB: return Art.KEBAB; - case AZTEC: return Art.AZTEC; - case ALBAN: return Art.ALBAN; - case AZTEC_2: return Art.AZTEC2; - case BOMB: return Art.BOMB; - case PLANT: return Art.PLANT; - case WASTELAND: return Art.WASTELAND; - case POOL: return Art.POOL; - case COURBET: return Art.COURBET; - case SEA: return Art.SEA; - case SUNSET: return Art.SUNSET; - case CREEBET: return Art.CREEBET; - case WANDERER: return Art.WANDERER; - case GRAHAM: return Art.GRAHAM; - case MATCH: return Art.MATCH; - case BUST: return Art.BUST; - case STAGE: return Art.STAGE; - case VOID: return Art.VOID; - case SKULL_AND_ROSES: return Art.SKULL_AND_ROSES; - case FIGHTERS: return Art.FIGHTERS; - case POINTER: return Art.POINTER; - case PIGSCENE: return Art.PIGSCENE; - case BURNING_SKULL: return Art.BURNINGSKULL; - case SKELETON: return Art.SKELETON; - case DONKEY_KONG: return Art.DONKEYKONG; - case WITHER: return Art.WITHER; - default: - throw new AssertionError(art); + static { + ImmutableBiMap.Builder artworkBuilder = ImmutableBiMap.builder(); + for (MinecraftKey key : Paintings.a.keySet()) { + artworkBuilder.put(Paintings.a.get(key), Art.getByName(key.getKey())); } + + artwork = artworkBuilder.build(); } - public static EnumArt BukkitToNotch(Art art) { - switch (art) { - case KEBAB: return EnumArt.KEBAB; - case AZTEC: return EnumArt.AZTEC; - case ALBAN: return EnumArt.ALBAN; - case AZTEC2: return EnumArt.AZTEC_2; - case BOMB: return EnumArt.BOMB; - case PLANT: return EnumArt.PLANT; - case WASTELAND: return EnumArt.WASTELAND; - case POOL: return EnumArt.POOL; - case COURBET: return EnumArt.COURBET; - case SEA: return EnumArt.SEA; - case SUNSET: return EnumArt.SUNSET; - case CREEBET: return EnumArt.CREEBET; - case WANDERER: return EnumArt.WANDERER; - case GRAHAM: return EnumArt.GRAHAM; - case MATCH: return EnumArt.MATCH; - case BUST: return EnumArt.BUST; - case STAGE: return EnumArt.STAGE; - case VOID: return EnumArt.VOID; - case SKULL_AND_ROSES: return EnumArt.SKULL_AND_ROSES; - case FIGHTERS: return EnumArt.FIGHTERS; - case POINTER: return EnumArt.POINTER; - case PIGSCENE: return EnumArt.PIGSCENE; - case BURNINGSKULL: return EnumArt.BURNING_SKULL; - case SKELETON: return EnumArt.SKELETON; - case DONKEYKONG: return EnumArt.DONKEY_KONG; - case WITHER: return EnumArt.WITHER; - default: - throw new AssertionError(art); - } + public static Art NotchToBukkit(Paintings art) { + Art bukkit = artwork.get(art); + Preconditions.checkArgument(bukkit != null); + return bukkit; + } + + public static Paintings BukkitToNotch(Art art) { + Paintings nms = artwork.inverse().get(art); + Preconditions.checkArgument(nms != null); + return nms; } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunk.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunk.java index 0cc838ccfb..b0297c64b6 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunk.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunk.java @@ -20,7 +20,7 @@ public class CraftChunk implements Chunk { private final int x; private final int z; private static final byte[] emptyData = new byte[2048]; - private static final short[] emptyBlockIDs = new short[4096]; + private static final DataPaletteBlock emptyBlockIDs = new ChunkSection(0, false).getBlocks(); private static final byte[] emptySkyLight = new byte[2048]; public CraftChunk(net.minecraft.server.Chunk chunk) { @@ -69,7 +69,7 @@ public class CraftChunk implements Chunk { } public Block getBlock(int x, int y, int z) { - return new CraftBlock(this, (getX() << 4) | (x & 0xF), y, (getZ() << 4) | (z & 0xF)); + return new CraftBlock(worldServer, new BlockPosition((this.x << 4) | x, y, (this.z << 4) | z)); } public Entity[] getEntities() { @@ -133,7 +133,7 @@ public class CraftChunk implements Chunk { @Override public boolean isSlimeChunk() { // 987234911L is deterimined in EntitySlime when seeing if a slime can spawn in a chunk - return getHandle().a(987234911L).nextInt(10) == 0; + return SeededRandom.a(getX(), getZ(), getWorld().getSeed(), 987234911L).nextInt(10) == 0; } public boolean unload(boolean save) { @@ -152,8 +152,7 @@ public class CraftChunk implements Chunk { net.minecraft.server.Chunk chunk = getHandle(); ChunkSection[] cs = chunk.getSections(); - short[][] sectionBlockIDs = new short[cs.length][]; - byte[][] sectionBlockData = new byte[cs.length][]; + DataPaletteBlock[] sectionBlockIDs = new DataPaletteBlock[cs.length]; byte[][] sectionSkyLights = new byte[cs.length][]; byte[][] sectionEmitLights = new byte[cs.length][]; boolean[] sectionEmpty = new boolean[cs.length]; @@ -161,28 +160,20 @@ public class CraftChunk implements Chunk { for (int i = 0; i < cs.length; i++) { if (cs[i] == null) { // Section is empty? sectionBlockIDs[i] = emptyBlockIDs; - sectionBlockData[i] = emptyData; sectionSkyLights[i] = emptySkyLight; sectionEmitLights[i] = emptyData; sectionEmpty[i] = true; } else { // Not empty - short[] blockids = new short[4096]; + NBTTagCompound data = new NBTTagCompound(); + cs[i].getBlocks().b(data, "Spigot", "Magic"); - byte[] rawIds = new byte[4096]; - NibbleArray data = new NibbleArray(); - cs[i].getBlocks().exportData(rawIds, data); - - byte[] dataValues = sectionBlockData[i] = data.asBytes(); - - // Copy base IDs - for (int j = 0; j < 4096; j++) { - blockids[j] = (short) (rawIds[j] & 0xFF); - } + 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"); sectionBlockIDs[i] = blockids; if (cs[i].getSkyLightArray() == null) { - sectionSkyLights[i] = emptyData; + sectionSkyLights[i] = emptySkyLight; } else { sectionSkyLights[i] = new byte[2048]; System.arraycopy(cs[i].getSkyLightArray().asBytes(), 0, sectionSkyLights[i], 0, 2048); @@ -192,57 +183,46 @@ public class CraftChunk implements Chunk { } } - int[] hmap = null; + HeightMap hmap = null; if (includeMaxBlockY) { - hmap = new int[256]; // Get copy of height map - System.arraycopy(chunk.heightMap, 0, hmap, 0, 256); + hmap = new HeightMap(null, HeightMap.Type.LIGHT_BLOCKING); + hmap.a(chunk.heightMap.get(HeightMap.Type.LIGHT_BLOCKING).b()); } BiomeBase[] biome = null; double[] biomeTemp = null; - double[] biomeRain = null; if (includeBiome || includeBiomeTempRain) { - WorldChunkManager wcm = chunk.world.getWorldChunkManager(); + WorldChunkManager wcm = worldServer.getChunkProvider().getChunkGenerator().getWorldChunkManager(); if (includeBiome) { biome = new BiomeBase[256]; for (int i = 0; i < 256; i++) { - biome[i] = chunk.getBiome(new BlockPosition(i & 0xF, 0, i >> 4), wcm); + biome[i] = chunk.getBiome(new BlockPosition(i & 0xF, 0, i >> 4)); } } if (includeBiomeTempRain) { biomeTemp = new double[256]; - biomeRain = new double[256]; float[] dat = getTemperatures(wcm, getX() << 4, getZ() << 4); for (int i = 0; i < 256; i++) { biomeTemp[i] = dat[i]; } - - /* Removed 15w46a - dat = wcm.getWetness(null, getX() << 4, getZ() << 4, 16, 16); - - for (int i = 0; i < 256; i++) { - biomeRain[i] = dat[i]; - } - */ } } World world = getWorld(); - return new CraftChunkSnapshot(getX(), getZ(), world.getName(), world.getFullTime(), sectionBlockIDs, sectionBlockData, sectionSkyLights, sectionEmitLights, sectionEmpty, hmap, biome, biomeTemp, biomeRain); + return new CraftChunkSnapshot(getX(), getZ(), world.getName(), world.getFullTime(), sectionBlockIDs, sectionSkyLights, sectionEmitLights, sectionEmpty, hmap, biome, biomeTemp); } public static ChunkSnapshot getEmptyChunkSnapshot(int x, int z, CraftWorld world, boolean includeBiome, boolean includeBiomeTempRain) { BiomeBase[] biome = null; double[] biomeTemp = null; - double[] biomeRain = null; if (includeBiome || includeBiomeTempRain) { - WorldChunkManager wcm = world.getHandle().getWorldChunkManager(); + WorldChunkManager wcm = world.getHandle().getChunkProvider().getChunkGenerator().getWorldChunkManager(); if (includeBiome) { biome = new BiomeBase[256]; @@ -253,44 +233,33 @@ public class CraftChunk implements Chunk { if (includeBiomeTempRain) { biomeTemp = new double[256]; - biomeRain = new double[256]; float[] dat = getTemperatures(wcm, x << 4, z << 4); for (int i = 0; i < 256; i++) { biomeTemp[i] = dat[i]; } - - /* Removed 15w46a - dat = wcm.getWetness(null, x << 4, z << 4, 16, 16); - - for (int i = 0; i < 256; i++) { - biomeRain[i] = dat[i]; - } - */ } } /* Fill with empty data */ int hSection = world.getMaxHeight() >> 4; - short[][] blockIDs = new short[hSection][]; + DataPaletteBlock[] blockIDs = new DataPaletteBlock[hSection]; byte[][] skyLight = new byte[hSection][]; byte[][] emitLight = new byte[hSection][]; - byte[][] blockData = new byte[hSection][]; boolean[] empty = new boolean[hSection]; for (int i = 0; i < hSection; i++) { blockIDs[i] = emptyBlockIDs; skyLight[i] = emptySkyLight; emitLight[i] = emptyData; - blockData[i] = emptyData; empty[i] = true; } - return new CraftChunkSnapshot(x, z, world.getName(), world.getFullTime(), blockIDs, blockData, skyLight, emitLight, empty, new int[256], biome, biomeTemp, biomeRain); + return new CraftChunkSnapshot(x, z, world.getName(), world.getFullTime(), blockIDs, skyLight, emitLight, empty, new HeightMap(null, HeightMap.Type.LIGHT_BLOCKING), biome, biomeTemp); } private static float[] getTemperatures(WorldChunkManager chunkmanager, int chunkX, int chunkZ) { - BiomeBase[] biomes = chunkmanager.getBiomes(null, chunkX, chunkZ, 16, 16); + BiomeBase[] biomes = chunkmanager.getBiomes(chunkX, chunkZ, 16, 16); float[] temps = new float[biomes.length]; for (int i = 0; i < biomes.length; i++) { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunkSnapshot.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunkSnapshot.java index c0fb34b954..8032f358bf 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunkSnapshot.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunkSnapshot.java @@ -3,9 +3,15 @@ package org.bukkit.craftbukkit; import org.bukkit.ChunkSnapshot; import org.bukkit.Material; import org.bukkit.block.Biome; +import org.bukkit.block.data.BlockData; import org.bukkit.craftbukkit.block.CraftBlock; +import org.bukkit.craftbukkit.block.data.CraftBlockData; +import org.bukkit.craftbukkit.util.CraftMagicNumbers; import net.minecraft.server.BiomeBase; +import net.minecraft.server.DataPaletteBlock; +import net.minecraft.server.HeightMap; +import net.minecraft.server.IBlockData; /** * Represents a static, thread-safe snapshot of chunk of blocks @@ -14,31 +20,27 @@ import net.minecraft.server.BiomeBase; public class CraftChunkSnapshot implements ChunkSnapshot { private final int x, z; private final String worldname; - private final short[][] blockids; /* Block IDs, by section */ - private final byte[][] blockdata; + private final DataPaletteBlock[] blockids; private final byte[][] skylight; private final byte[][] emitlight; private final boolean[] empty; - private final int[] hmap; // Height map + private final HeightMap hmap; // Height map private final long captureFulltime; private final BiomeBase[] biome; private final double[] biomeTemp; - private final double[] biomeRain; - CraftChunkSnapshot(int x, int z, String wname, long wtime, short[][] sectionBlockIDs, byte[][] sectionBlockData, byte[][] sectionSkyLights, byte[][] sectionEmitLights, boolean[] sectionEmpty, int[] hmap, BiomeBase[] biome, double[] biomeTemp, double[] biomeRain) { + CraftChunkSnapshot(int x, int z, String wname, long wtime, DataPaletteBlock[] sectionBlockIDs, byte[][] sectionSkyLights, byte[][] sectionEmitLights, boolean[] sectionEmpty, HeightMap hmap, BiomeBase[] biome, double[] biomeTemp) { this.x = x; this.z = z; this.worldname = wname; this.captureFulltime = wtime; this.blockids = sectionBlockIDs; - this.blockdata = sectionBlockData; this.skylight = sectionSkyLights; this.emitlight = sectionEmitLights; this.empty = sectionEmpty; this.hmap = hmap; this.biome = biome; this.biomeTemp = biomeTemp; - this.biomeRain = biomeRain; } public int getX() { @@ -55,16 +57,17 @@ public class CraftChunkSnapshot implements ChunkSnapshot { @Override public Material getBlockType(int x, int y, int z) { - return Material.getMaterial(getBlockTypeId(x, y, z)); + return CraftMagicNumbers.getMaterial(blockids[y >> 4].a(x, y & 0xF, z).getBlock()); } - public final int getBlockTypeId(int x, int y, int z) { - return blockids[y >> 4][((y & 0xF) << 8) | (z << 4) | x]; + @Override + public final BlockData getBlockData(int x, int y, int z) { + return CraftBlockData.fromData(blockids[y >> 4].a(x, y & 0xF, z)); } - public final int getBlockData(int x, int y, int z) { - int off = ((y & 0xF) << 7) | (z << 3) | (x >> 1); - return (blockdata[y >> 4][off] >> ((x & 1) << 2)) & 0xF; + @Override + public final int getData(int x, int y, int z) { + return CraftMagicNumbers.toLegacyData(blockids[y >> 4].a(x, y & 0xF, z)); } public final int getBlockSkyLight(int x, int y, int z) { @@ -78,7 +81,7 @@ public class CraftChunkSnapshot implements ChunkSnapshot { } public final int getHighestBlockYAt(int x, int z) { - return hmap[z << 4 | x]; + return hmap.a(x, z); } public final Biome getBiome(int x, int z) { @@ -89,10 +92,6 @@ public class CraftChunkSnapshot implements ChunkSnapshot { return biomeTemp[z << 4 | x]; } - public final double getRawBiomeRainfall(int x, int z) { - return biomeRain[z << 4 | x]; - } - public final long getCaptureFullTime() { return captureFulltime; } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftCrashReport.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftCrashReport.java index 67f285668c..921a57f5a6 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftCrashReport.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftCrashReport.java @@ -12,6 +12,7 @@ import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginDescriptionFile; import net.minecraft.server.MinecraftServer; +import org.bukkit.craftbukkit.util.CraftMagicNumbers; public class CraftCrashReport implements CrashReportCallable { @@ -22,7 +23,8 @@ public class CraftCrashReport implements CrashReportCallable { value.append("\n Plugins: {"); for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) { PluginDescriptionFile description = plugin.getDescription(); - value.append(' ').append(description.getFullName()).append(' ').append(description.getMain()).append(' ').append(Arrays.toString(description.getAuthors().toArray())).append(','); + boolean legacy = CraftMagicNumbers.isLegacy(description); + value.append(' ').append(description.getFullName()).append(legacy ? "*" : "").append(' ').append(description.getMain()).append(' ').append(Arrays.toString(description.getAuthors().toArray())).append(','); } value.append("}\n Warnings: ").append(Bukkit.getWarningState().name()); value.append("\n Reload Count: ").append(String.valueOf(MinecraftServer.getServer().server.reloadCount)); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftEffect.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftEffect.java index 16721835a2..c6edd7a507 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftEffect.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftEffect.java @@ -1,9 +1,12 @@ package org.bukkit.craftbukkit; +import net.minecraft.server.Block; +import net.minecraft.server.Item; import org.apache.commons.lang.Validate; import org.bukkit.Effect; import org.bukkit.Material; import org.bukkit.block.BlockFace; +import org.bukkit.craftbukkit.util.CraftMagicNumbers; import org.bukkit.potion.Potion; public class CraftEffect { @@ -18,7 +21,7 @@ public class CraftEffect { break; case RECORD_PLAY: Validate.isTrue(((Material) data).isRecord(), "Invalid record type!"); - datavalue = ((Material) data).getId(); + datavalue = Item.getId(CraftMagicNumbers.getItem((Material) data)); break; case SMOKE: switch((BlockFace) data) { // TODO: Verify (Where did these values come from...?) @@ -56,7 +59,7 @@ public class CraftEffect { break; case STEP_SOUND: Validate.isTrue(((Material) data).isBlock(), "Material is not a block!"); - datavalue = ((Material) data).getId(); + datavalue = Block.getCombinedId(CraftMagicNumbers.getBlock((Material) data).getBlockData()); break; default: datavalue = 0; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java index 45217866bb..7b49f67335 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java @@ -9,6 +9,7 @@ import java.util.UUID; import net.minecraft.server.EntityPlayer; import net.minecraft.server.NBTTagCompound; +import net.minecraft.server.WhiteListEntry; import net.minecraft.server.WorldNBTStorage; import org.bukkit.BanList; @@ -115,9 +116,9 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa public void setWhitelisted(boolean value) { if (value) { - server.getHandle().addWhitelist(profile); + server.getHandle().getWhitelist().add(new WhiteListEntry(profile)); } else { - server.getHandle().removeWhitelist(profile); + server.getHandle().getWhitelist().remove(profile); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftParticle.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftParticle.java index 4128e8384d..291f46fedd 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftParticle.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftParticle.java @@ -1,41 +1,151 @@ package org.bukkit.craftbukkit; -import net.minecraft.server.Block; -import net.minecraft.server.EnumParticle; -import net.minecraft.server.IBlockData; +import com.google.common.base.Preconditions; +import com.google.common.collect.BiMap; +import com.google.common.collect.HashBiMap; +import java.util.HashMap; +import java.util.Map; +import net.minecraft.server.MinecraftKey; +import net.minecraft.server.ParticleParam; +import net.minecraft.server.ParticleParamBlock; +import net.minecraft.server.ParticleParamItem; +import net.minecraft.server.ParticleParamRedstone; +import net.minecraft.server.ParticleType; +import org.bukkit.Color; import org.bukkit.Particle; +import org.bukkit.block.data.BlockData; +import org.bukkit.craftbukkit.block.data.CraftBlockData; +import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.craftbukkit.util.CraftMagicNumbers; import org.bukkit.inventory.ItemStack; import org.bukkit.material.MaterialData; -public class CraftParticle { +public enum CraftParticle { - public static EnumParticle toNMS(Particle bukkit) { - return EnumParticle.valueOf(bukkit.name()); + EXPLOSION_NORMAL("poof"), + EXPLOSION_LARGE("explosion"), + EXPLOSION_HUGE("explosion_emitter"), + FIREWORKS_SPARK("firework"), + WATER_BUBBLE("bubble"), + WATER_SPLASH("splash"), + WATER_WAKE("fishing"), + SUSPENDED("underwater"), + SUSPENDED_DEPTH("underwater"), + CRIT("crit"), + CRIT_MAGIC("enchanted_hit"), + SMOKE_NORMAL("smoke"), + SMOKE_LARGE("large_smoke"), + SPELL("effect"), + SPELL_INSTANT("instant_effect"), + SPELL_MOB("entity_effect"), + SPELL_MOB_AMBIENT("ambient_entity_effect"), + SPELL_WITCH("witch"), + DRIP_WATER("dripping_water"), + DRIP_LAVA("dripping_lava"), + VILLAGER_ANGRY("angry_villager"), + VILLAGER_HAPPY("happy_villager"), + TOWN_AURA("mycelium"), + NOTE("note"), + PORTAL("portal"), + ENCHANTMENT_TABLE("enchant"), + FLAME("flame"), + LAVA("lava"), + CLOUD("cloud"), + REDSTONE("dust"), + SNOWBALL("item_snowball"), + SNOW_SHOVEL("item_snowball"), + SLIME("item_slime"), + HEART("heart"), + BARRIER("barrier"), + ITEM_CRACK("item"), + BLOCK_CRACK("block"), + BLOCK_DUST("block"), + WATER_DROP("rain"), + MOB_APPEARANCE("elder_guardian"), + DRAGON_BREATH("dragon_breath"), + END_ROD("end_rod"), + DAMAGE_INDICATOR("damage_indicator"), + SWEEP_ATTACK("sweep_attack"), + FALLING_DUST("falling_dust"), + TOTEM("totem_of_undying"), + SPIT("spit"), + SQUID_INK("squid_ink"), + BUBBLE_POP("bubble_pop"), + CURRENT_DOWN("current_down"), + BUBBLE_COLUMN_UP("bubble_column_up"), + NAUTILUS("nautilus"), + DOLPHIN("dolphin"), + // ----- Legacy Separator ----- + LEGACY_BLOCK_CRACK("block"), + LEGACY_BLOCK_DUST("block"), + LEGACY_FALLING_DUST("falling_dust"); + private final MinecraftKey minecraftKey; + private final Particle bukkit; + private static final BiMap particles; + private static final Map aliases; + + static { + particles = HashBiMap.create(); + aliases = new HashMap<>(); + + for (CraftParticle particle : CraftParticle.values()) { + if (particles.containsValue(particle.minecraftKey)) { + aliases.put(particle.bukkit, particles.inverse().get(particle.minecraftKey)); + } else { + particles.put(particle.bukkit, particle.minecraftKey); + } + } } - public static Particle toBukkit(EnumParticle nms) { - return Particle.valueOf(nms.name()); + private CraftParticle(String minecraftKey) { + this.minecraftKey = new MinecraftKey(minecraftKey); + + this.bukkit = Particle.valueOf(this.name()); + Preconditions.checkState(bukkit != null, "Bukkit particle %s does not exist", this.name()); } - public static int[] toData(Particle particle, Object obj) { + public static ParticleParam toNMS(Particle bukkit) { + return toNMS(bukkit, null); + } + + public static ParticleParam toNMS(Particle particle, T obj) { + Particle canonical = particle; + if (aliases.containsKey(particle)) { + canonical = aliases.get(particle); + } + + net.minecraft.server.Particle nms = net.minecraft.server.Particle.REGISTRY.get(particles.get(canonical)); + Preconditions.checkArgument(nms != null, "No NMS particle %s", particle); + if (particle.getDataType().equals(Void.class)) { - return new int[0]; + return (ParticleType) nms; } + Preconditions.checkArgument(obj != null, "Particle %s requires data, null provided", particle); if (particle.getDataType().equals(ItemStack.class)) { - if (obj == null) { - return new int[]{0, 0}; - } ItemStack itemStack = (ItemStack) obj; - return new int[]{itemStack.getType().getId(), itemStack.getDurability()}; + return new ParticleParamItem((net.minecraft.server.Particle) nms, CraftItemStack.asNMSCopy(itemStack)); } - if (particle.getDataType().equals(MaterialData.class)) { - if (obj == null) { - return new int[]{0}; - } + if (particle.getDataType() == MaterialData.class) { MaterialData data = (MaterialData) obj; - return new int[]{data.getItemTypeId() + ((int)(data.getData()) << 12)}; + return new ParticleParamBlock((net.minecraft.server.Particle) nms, CraftMagicNumbers.getBlock(data)); + } + if (particle.getDataType() == BlockData.class) { + BlockData data = (BlockData) obj; + return new ParticleParamBlock((net.minecraft.server.Particle) nms, ((CraftBlockData) data).getState()); + } + if (particle.getDataType() == Particle.DustOptions.class) { + Particle.DustOptions data = (Particle.DustOptions) obj; + Color color = data.getColor(); + return new ParticleParamRedstone(color.getRed(), color.getGreen(), color.getBlue(), data.getSize()); } throw new IllegalArgumentException(particle.getDataType().toString()); } + + public static Particle toBukkit(net.minecraft.server.ParticleParam nms) { + return toBukkit(nms.b()); + } + + public static Particle toBukkit(net.minecraft.server.Particle nms) { + return particles.inverse().get(nms.d()); + } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java index 0eaf9dabcc..db82051c25 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -8,6 +8,7 @@ import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; import java.util.Collections; import java.util.HashSet; import java.util.Iterator; @@ -17,6 +18,7 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.UUID; +import java.util.function.Consumer; import java.util.logging.Level; import java.util.logging.Logger; import java.util.regex.Pattern; @@ -52,7 +54,6 @@ import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.serialization.ConfigurationSerialization; import org.bukkit.conversations.Conversable; import org.bukkit.craftbukkit.boss.CraftBossBar; -import org.bukkit.craftbukkit.command.VanillaCommandWrapper; import org.bukkit.craftbukkit.entity.CraftPlayer; import org.bukkit.craftbukkit.generator.CraftChunkData; import org.bukkit.craftbukkit.help.SimpleHelpMap; @@ -122,14 +123,28 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterators; import com.google.common.collect.Lists; import com.google.common.collect.MapMaker; +import com.google.gson.JsonElement; +import com.google.gson.JsonParser; import com.mojang.authlib.GameProfile; +import com.mojang.brigadier.builder.LiteralArgumentBuilder; +import com.mojang.brigadier.tree.CommandNode; +import com.mojang.brigadier.tree.LiteralCommandNode; import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBufOutputStream; import io.netty.buffer.Unpooled; import io.netty.handler.codec.base64.Base64; +import java.util.HashMap; import jline.console.ConsoleReader; +import org.bukkit.Keyed; import org.bukkit.NamespacedKey; +import org.bukkit.block.data.BlockData; +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.tag.CraftBlockTag; +import org.bukkit.craftbukkit.tag.CraftItemTag; import org.bukkit.craftbukkit.util.CraftNamespacedKey; import org.bukkit.event.server.TabCompleteEvent; @@ -140,7 +155,7 @@ public final class CraftServer implements Server { private final Logger logger = Logger.getLogger("Minecraft"); private final ServicesManager servicesManager = new SimpleServicesManager(); private final CraftScheduler scheduler = new CraftScheduler(); - private final SimpleCommandMap commandMap = new SimpleCommandMap(this); + private final CraftCommandMap commandMap = new CraftCommandMap(this); private final SimpleHelpMap helpMap = new SimpleHelpMap(this); private final StandardMessenger messenger = new StandardMessenger(); private final SimplePluginManager pluginManager = new SimplePluginManager(this, commandMap); @@ -168,7 +183,6 @@ public final class CraftServer implements Server { private boolean printSaveWarning; private CraftIconCache icon; private boolean overrideAllCommandBlockCommands = false; - private boolean unrestrictedAdvancements; private final List playerView; public int reloadCount; @@ -245,7 +259,6 @@ public final class CraftServer implements Server { saveCommandsConfig(); overrideAllCommandBlockCommands = commandsConfiguration.getStringList("command-block-overrides").contains("*"); - unrestrictedAdvancements = commandsConfiguration.getBoolean("unrestricted-advancements"); pluginManager.useTimings(configuration.getBoolean("settings.plugin-profiling")); monsterSpawn = configuration.getInt("spawn-limits.monsters"); animalSpawn = configuration.getInt("spawn-limits.animals"); @@ -258,14 +271,6 @@ public final class CraftServer implements Server { loadIcon(); } - public boolean getPermissionOverride(ICommandListener listener) { - while (listener instanceof CommandListenerWrapper) { - listener = ((CommandListenerWrapper) listener).base; - } - - return unrestrictedAdvancements && listener instanceof AdvancementRewards.AdvancementCommandListener; - } - public boolean getCommandBlockOverride(String command) { return overrideAllCommandBlockCommands || commandsConfiguration.getStringList("command-block-overrides").contains(command); } @@ -337,6 +342,7 @@ public final class CraftServer implements Server { DefaultPermissions.registerCorePermissions(); CraftDefaultPermissions.registerCorePermissions(); helpMap.initializeCommands(); + syncCommands(); } } @@ -345,9 +351,43 @@ public final class CraftServer implements Server { } private void setVanillaCommands() { - Map commands = new CommandDispatcher(console).getCommands(); - for (ICommand cmd : commands.values()) { - commandMap.register("minecraft", new VanillaCommandWrapper((CommandAbstract) cmd, LocaleI18n.get(cmd.getUsage(null)))); + CommandDispatcher dispatcher = console.getCommandDispatcher(); + + // Build a list of all Vanilla commands and create wrappers + for (CommandNode cmd : dispatcher.a().getRoot().getChildren()) { + commandMap.register("minecraft", new VanillaCommandWrapper(dispatcher, cmd)); + } + } + + private void syncCommands() { + // Clear existing commands + CommandDispatcher dispatcher = console.commandDispatcher = new CommandDispatcher(); + + // Register all commands, vanilla ones will be using the old dispatcher references + for (Map.Entry entry : commandMap.getKnownCommands().entrySet()) { + String label = entry.getKey(); + Command command = entry.getValue(); + + if (command instanceof VanillaCommandWrapper) { + LiteralCommandNode node = (LiteralCommandNode) ((VanillaCommandWrapper) command).vanillaCommand; + if (!node.getLiteral().equals(label)) { + LiteralCommandNode clone = new LiteralCommandNode(label, node.getCommand(), node.getRequirement(), node.getRedirect(), node.getRedirectModifier(), node.isFork()); + + for (CommandNode child : node.getChildren()) { + clone.addChild(child); + } + node = clone; + } + + dispatcher.a().getRoot().addChild(node); + } else { + new BukkitCommandWrapper(this, entry.getValue()).register(dispatcher.a(), label); + } + } + + // Refresh commands + for (EntityPlayer player : getHandle().players) { + dispatcher.a(player); } } @@ -837,23 +877,23 @@ public final class CraftServer implements Server { generator = getGenerator(name); } - Convertable converter = new WorldLoaderServer(getWorldContainer(), getHandle().getServer().dataConverterManager); + Convertable converter = new WorldLoaderServer(getWorldContainer().toPath(), getWorldContainer().toPath().resolveSibling("../backups"), getHandle().getServer().dataConverterManager); if (converter.isConvertable(name)) { getLogger().info("Converting world '" + name + "'"); converter.convert(name, new IProgressUpdate() { private long b = System.currentTimeMillis(); - public void a(String s) {} + public void a(IChatBaseComponent ichatbasecomponent) {} public void a(int i) { if (System.currentTimeMillis() - this.b >= 1000L) { this.b = System.currentTimeMillis(); - MinecraftServer.LOGGER.info("Converting... " + i + "%"); + MinecraftServer.LOGGER.info("Converting... {}%", Integer.valueOf(i)); } } - public void c(String s) {} + public void c(IChatBaseComponent ichatbasecomponent) {} }); } @@ -870,12 +910,15 @@ public final class CraftServer implements Server { } while(used); boolean hardcore = false; - IDataManager sdm = new ServerNBTManager(getWorldContainer(), name, true, getHandle().getServer().dataConverterManager); + IDataManager sdm = new ServerNBTManager(getWorldContainer(), name, getServer(), getHandle().getServer().dataConverterManager); WorldData worlddata = sdm.getWorldData(); WorldSettings worldSettings = null; if (worlddata == null) { worldSettings = new WorldSettings(creator.seed(), EnumGamemode.getById(getDefaultGameMode().getValue()), generateStructures, hardcore, type); - worldSettings.setGeneratorSettings(creator.generatorSettings()); + JsonElement parsedSettings = new JsonParser().parse(creator.generatorSettings()); + if (parsedSettings.isJsonObject()) { + worldSettings.setGeneratorSettings(parsedSettings.getAsJsonObject()); + } 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) @@ -888,7 +931,6 @@ public final class CraftServer implements Server { if (worldSettings != null) { internal.a(worldSettings); } - internal.scoreboard = getScoreboardManager().getMainScoreboard().getHandle(); internal.tracker = new EntityTracker(internal); internal.addIWorldAccess(new WorldManager(console, internal)); @@ -962,7 +1004,7 @@ public final class CraftServer implements Server { if (save) { try { handle.save(true, null); - handle.saveLevel(); + handle.close(); } catch (ExceptionWorldConflict ex) { getLogger().log(Level.SEVERE, null, ex); } @@ -1075,19 +1117,12 @@ public final class CraftServer implements Server { @Override public void clearRecipes() { - CraftingManager.recipes = new RegistryMaterials(); - RecipesFurnace.getInstance().recipes.clear(); - RecipesFurnace.getInstance().customRecipes.clear(); - RecipesFurnace.getInstance().customExperience.clear(); + console.getCraftingManager().recipes.clear(); } @Override public void resetRecipes() { - CraftingManager.recipes = new RegistryMaterials(); - CraftingManager.init(); - RecipesFurnace.getInstance().recipes = new RecipesFurnace().recipes; - RecipesFurnace.getInstance().customRecipes.clear(); - RecipesFurnace.getInstance().customExperience.clear(); + console.getCraftingManager().a(console.getResourceManager()); } @Override @@ -1192,7 +1227,7 @@ public final class CraftServer implements Server { @Deprecated public CraftMapView getMap(short id) { PersistentCollection collection = console.worlds.get(0).worldMaps; - WorldMap worldmap = (WorldMap) collection.get(WorldMap.class, "map_" + id); + WorldMap worldmap = (WorldMap) collection.get(WorldMap::new, "map_" + id); if (worldmap == null) { return null; } @@ -1203,8 +1238,8 @@ public final class CraftServer implements Server { public CraftMapView createMap(World world) { Validate.notNull(world, "World cannot be null"); - net.minecraft.server.ItemStack stack = new net.minecraft.server.ItemStack(Items.MAP, 1, -1); - WorldMap worldmap = Items.FILLED_MAP.getSavedMap(stack, ((CraftWorld) world).getHandle()); + net.minecraft.server.ItemStack stack = new net.minecraft.server.ItemStack(Items.MAP, 1); + WorldMap worldmap = ItemWorldMap.getSavedMap(stack, ((CraftWorld) world).getHandle()); return worldmap.mapView; } @@ -1522,15 +1557,15 @@ public final class CraftServer implements Server { return warningState; } - public List tabComplete(net.minecraft.server.ICommandListener sender, String message, BlockPosition pos, boolean forceCommand) { - if (!(sender instanceof EntityPlayer)) { + public List tabComplete(CommandSender sender, String message, WorldServer world, Vec3D pos, boolean forceCommand) { + if (!(sender instanceof Player)) { return ImmutableList.of(); } List offers; - Player player = ((EntityPlayer) sender).getBukkitEntity(); + Player player = (Player) sender; if (message.startsWith("/") || forceCommand) { - offers = tabCompleteCommand(player, message, pos); + offers = tabCompleteCommand(player, message, world, pos); } else { offers = tabCompleteChat(player, message); } @@ -1541,7 +1576,7 @@ public final class CraftServer implements Server { return tabEvent.isCancelled() ? Collections.EMPTY_LIST : tabEvent.getCompletions(); } - public List tabCompleteCommand(Player player, String message, BlockPosition pos) { + public List tabCompleteCommand(Player player, String message, WorldServer world, Vec3D pos) { List completions = null; try { if (message.startsWith("/")) { @@ -1551,7 +1586,7 @@ public final class CraftServer implements Server { if (pos == null) { completions = getCommandMap().tabComplete(player, message); } else { - completions = getCommandMap().tabComplete(player, message, new Location(player.getWorld(), pos.getX(), pos.getY(), pos.getZ())); + completions = getCommandMap().tabComplete(player, message, new Location(world.getWorld(), pos.x, pos.y, pos.z)); } } catch (CommandException ex) { player.sendMessage(ChatColor.RED + "An internal error occurred while attempting to tab-complete this command"); @@ -1660,8 +1695,15 @@ public final class CraftServer implements Server { @Override public Entity getEntity(UUID uuid) { Validate.notNull(uuid, "UUID cannot be null"); - net.minecraft.server.Entity entity = console.a(uuid); // PAIL: getEntity - return entity == null ? null : entity.getBukkitEntity(); + + for (WorldServer world : getServer().worlds) { + net.minecraft.server.Entity entity = world.getEntity(uuid); + if (entity != null) { + return entity.getBukkitEntity(); + } + } + + return null; } @Override @@ -1674,7 +1716,7 @@ public final class CraftServer implements Server { @Override public Iterator advancementIterator() { - return Iterators.unmodifiableIterator(Iterators.transform(console.getAdvancementData().c().iterator(), new Function() { // PAIL: rename + return Iterators.unmodifiableIterator(Iterators.transform(console.getAdvancementData().b().iterator(), new Function() { // PAIL: rename @Override public org.bukkit.advancement.Advancement apply(Advancement advancement) { return advancement.bukkit; @@ -1682,6 +1724,55 @@ public final class CraftServer implements Server { })); } + @Override + public BlockData createBlockData(org.bukkit.Material material) { + Validate.isTrue(material != null, "Must provide material"); + + return createBlockData(material, (String) null); + } + + @Override + public BlockData createBlockData(org.bukkit.Material material, Consumer consumer) { + BlockData data = createBlockData(material); + + if (consumer != null) { + consumer.accept(data); + } + + return data; + } + + @Override + public BlockData createBlockData(String data) throws IllegalArgumentException { + Validate.isTrue(data != null, "Must provide data"); + + return createBlockData(null, data); + } + + @Override + public BlockData createBlockData(org.bukkit.Material material, String data) { + Validate.isTrue(material != null || data != null, "Must provide one of material or data"); + + return CraftBlockData.newData(material, data); + } + + @Override + @SuppressWarnings("unchecked") + public org.bukkit.Tag getTag(String registry, NamespacedKey tag, Class clazz) { + switch (registry) { + case org.bukkit.Tag.REGISTRY_BLOCKS: + Preconditions.checkArgument(clazz == org.bukkit.Material.class, "Block namespace must have material type"); + + return (org.bukkit.Tag) new CraftBlockTag(console.getTagRegistry().a().b(CraftNamespacedKey.toMinecraft(tag))); + case org.bukkit.Tag.REGISTRY_ITEMS: + Preconditions.checkArgument(clazz == org.bukkit.Material.class, "Item namespace must have material type"); + + return (org.bukkit.Tag) new CraftItemTag(console.getTagRegistry().b().b(CraftNamespacedKey.toMinecraft(tag))); + default: + throw new IllegalArgumentException(); + } + } + @Deprecated @Override public UnsafeValues getUnsafe() { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftSound.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftSound.java index 8871c6f3a5..1181701ef2 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftSound.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftSound.java @@ -10,6 +10,12 @@ import org.bukkit.Sound; public enum CraftSound { AMBIENT_CAVE("ambient.cave"), + AMBIENT_UNDERWATER_ENTER("ambient.underwater.enter"), + AMBIENT_UNDERWATER_EXIT("ambient.underwater.exit"), + AMBIENT_UNDERWATER_LOOP("ambient.underwater.loop"), + AMBIENT_UNDERWATER_LOOP_ADDITIONS("ambient.underwater.loop.additions"), + AMBIENT_UNDERWATER_LOOP_ADDITIONS_RARE("ambient.underwater.loop.additions.rare"), + AMBIENT_UNDERWATER_LOOP_ADDITIONS_ULTRA_RARE("ambient.underwater.loop.additions.ultra_rare"), BLOCK_ANVIL_BREAK("block.anvil.break"), BLOCK_ANVIL_DESTROY("block.anvil.destroy"), BLOCK_ANVIL_FALL("block.anvil.fall"), @@ -18,24 +24,38 @@ public enum CraftSound { BLOCK_ANVIL_PLACE("block.anvil.place"), BLOCK_ANVIL_STEP("block.anvil.step"), BLOCK_ANVIL_USE("block.anvil.use"), + 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_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_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_CLOTH_BREAK("block.cloth.break"), - BLOCK_CLOTH_FALL("block.cloth.fall"), - BLOCK_CLOTH_HIT("block.cloth.hit"), - BLOCK_CLOTH_PLACE("block.cloth.place"), - BLOCK_CLOTH_STEP("block.cloth.step"), BLOCK_COMPARATOR_CLICK("block.comparator.click"), + BLOCK_CONDUIT_ACTIVATE("block.conduit.activate"), + BLOCK_CONDUIT_AMBIENT("block.conduit.ambient"), + BLOCK_CONDUIT_AMBIENT_SHORT("block.conduit.ambient.short"), + BLOCK_CONDUIT_ATTACK_TARGET("block.conduit.attack.target"), + BLOCK_CONDUIT_DEACTIVATE("block.conduit.deactivate"), + BLOCK_CORAL_BLOCK_BREAK("block.coral_block.break"), + BLOCK_CORAL_BLOCK_FALL("block.coral_block.fall"), + 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_DISPENSER_DISPENSE("block.dispenser.dispense"), BLOCK_DISPENSER_FAIL("block.dispenser.fail"), BLOCK_DISPENSER_LAUNCH("block.dispenser.launch"), BLOCK_ENCHANTMENT_TABLE_USE("block.enchantment_table.use"), - BLOCK_ENDERCHEST_CLOSE("block.enderchest.close"), - BLOCK_ENDERCHEST_OPEN("block.enderchest.open"), + BLOCK_ENDER_CHEST_CLOSE("block.ender_chest.close"), + BLOCK_ENDER_CHEST_OPEN("block.ender_chest.open"), BLOCK_END_GATEWAY_SPAWN("block.end_gateway.spawn"), BLOCK_END_PORTAL_FRAME_FILL("block.end_portal_frame.fill"), BLOCK_END_PORTAL_SPAWN("block.end_portal.spawn"), @@ -72,29 +92,31 @@ public enum CraftSound { BLOCK_LAVA_EXTINGUISH("block.lava.extinguish"), BLOCK_LAVA_POP("block.lava.pop"), BLOCK_LEVER_CLICK("block.lever.click"), + BLOCK_LILY_PAD_PLACE("block.lily_pad.place"), BLOCK_METAL_BREAK("block.metal.break"), BLOCK_METAL_FALL("block.metal.fall"), BLOCK_METAL_HIT("block.metal.hit"), BLOCK_METAL_PLACE("block.metal.place"), - BLOCK_METAL_PRESSUREPLATE_CLICK_OFF("block.metal_pressureplate.click_off"), - BLOCK_METAL_PRESSUREPLATE_CLICK_ON("block.metal_pressureplate.click_on"), + 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_NOTE_BASEDRUM("block.note.basedrum"), - BLOCK_NOTE_BASS("block.note.bass"), - BLOCK_NOTE_BELL("block.note.bell"), - BLOCK_NOTE_CHIME("block.note.chime"), - BLOCK_NOTE_FLUTE("block.note.flute"), - BLOCK_NOTE_GUITAR("block.note.guitar"), - BLOCK_NOTE_HARP("block.note.harp"), - BLOCK_NOTE_HAT("block.note.hat"), - BLOCK_NOTE_PLING("block.note.pling"), - BLOCK_NOTE_SNARE("block.note.snare"), - BLOCK_NOTE_XYLOPHONE("block.note.xylophone"), + 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_CHIME("block.note_block.chime"), + 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_PLING("block.note_block.pling"), + BLOCK_NOTE_BLOCK_SNARE("block.note_block.snare"), + BLOCK_NOTE_BLOCK_XYLOPHONE("block.note_block.xylophone"), BLOCK_PISTON_CONTRACT("block.piston.contract"), BLOCK_PISTON_EXTEND("block.piston.extend"), BLOCK_PORTAL_AMBIENT("block.portal.ambient"), BLOCK_PORTAL_TRAVEL("block.portal.travel"), BLOCK_PORTAL_TRIGGER("block.portal.trigger"), + BLOCK_PUMPKIN_CARVE("block.pumpkin.carve"), BLOCK_REDSTONE_TORCH_BURNOUT("block.redstone_torch.burnout"), BLOCK_SAND_BREAK("block.sand.break"), BLOCK_SAND_FALL("block.sand.fall"), @@ -103,11 +125,11 @@ public enum CraftSound { BLOCK_SAND_STEP("block.sand.step"), BLOCK_SHULKER_BOX_CLOSE("block.shulker_box.close"), BLOCK_SHULKER_BOX_OPEN("block.shulker_box.open"), - BLOCK_SLIME_BREAK("block.slime.break"), - BLOCK_SLIME_FALL("block.slime.fall"), - BLOCK_SLIME_HIT("block.slime.hit"), - BLOCK_SLIME_PLACE("block.slime.place"), - BLOCK_SLIME_STEP("block.slime.step"), + BLOCK_SLIME_BLOCK_BREAK("block.slime_block.break"), + BLOCK_SLIME_BLOCK_FALL("block.slime_block.fall"), + 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_SNOW_BREAK("block.snow.break"), BLOCK_SNOW_FALL("block.snow.fall"), BLOCK_SNOW_HIT("block.snow.hit"), @@ -119,33 +141,42 @@ public enum CraftSound { BLOCK_STONE_FALL("block.stone.fall"), BLOCK_STONE_HIT("block.stone.hit"), BLOCK_STONE_PLACE("block.stone.place"), - BLOCK_STONE_PRESSUREPLATE_CLICK_OFF("block.stone_pressureplate.click_off"), - BLOCK_STONE_PRESSUREPLATE_CLICK_ON("block.stone_pressureplate.click_on"), + 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_TRIPWIRE_ATTACH("block.tripwire.attach"), BLOCK_TRIPWIRE_CLICK_OFF("block.tripwire.click_off"), BLOCK_TRIPWIRE_CLICK_ON("block.tripwire.click_on"), BLOCK_TRIPWIRE_DETACH("block.tripwire.detach"), - BLOCK_WATERLILY_PLACE("block.waterlily.place"), BLOCK_WATER_AMBIENT("block.water.ambient"), + BLOCK_WET_GRASS_BREAK("block.wet_grass.break"), + BLOCK_WET_GRASS_FALL("block.wet_grass.fall"), + BLOCK_WET_GRASS_HIT("block.wet_grass.hit"), + BLOCK_WET_GRASS_PLACE("block.wet_grass.place"), + BLOCK_WET_GRASS_STEP("block.wet_grass.step"), + BLOCK_WOODEN_BUTTON_CLICK_OFF("block.wooden_button.click_off"), + BLOCK_WOODEN_BUTTON_CLICK_ON("block.wooden_button.click_on"), BLOCK_WOODEN_DOOR_CLOSE("block.wooden_door.close"), BLOCK_WOODEN_DOOR_OPEN("block.wooden_door.open"), + BLOCK_WOODEN_PRESSURE_PLATE_CLICK_OFF("block.wooden_pressure_plate.click_off"), + BLOCK_WOODEN_PRESSURE_PLATE_CLICK_ON("block.wooden_pressure_plate.click_on"), BLOCK_WOODEN_TRAPDOOR_CLOSE("block.wooden_trapdoor.close"), BLOCK_WOODEN_TRAPDOOR_OPEN("block.wooden_trapdoor.open"), BLOCK_WOOD_BREAK("block.wood.break"), - BLOCK_WOOD_BUTTON_CLICK_OFF("block.wood_button.click_off"), - BLOCK_WOOD_BUTTON_CLICK_ON("block.wood_button.click_on"), BLOCK_WOOD_FALL("block.wood.fall"), BLOCK_WOOD_HIT("block.wood.hit"), BLOCK_WOOD_PLACE("block.wood.place"), - BLOCK_WOOD_PRESSUREPLATE_CLICK_OFF("block.wood_pressureplate.click_off"), - BLOCK_WOOD_PRESSUREPLATE_CLICK_ON("block.wood_pressureplate.click_on"), BLOCK_WOOD_STEP("block.wood.step"), + BLOCK_WOOL_BREAK("block.wool.break"), + BLOCK_WOOL_FALL("block.wool.fall"), + BLOCK_WOOL_HIT("block.wool.hit"), + BLOCK_WOOL_PLACE("block.wool.place"), + BLOCK_WOOL_STEP("block.wool.step"), ENCHANT_THORNS_HIT("enchant.thorns.hit"), - ENTITY_ARMORSTAND_BREAK("entity.armorstand.break"), - ENTITY_ARMORSTAND_FALL("entity.armorstand.fall"), - ENTITY_ARMORSTAND_HIT("entity.armorstand.hit"), - ENTITY_ARMORSTAND_PLACE("entity.armorstand.place"), + ENTITY_ARMOR_STAND_BREAK("entity.armor_stand.break"), + ENTITY_ARMOR_STAND_FALL("entity.armor_stand.fall"), + ENTITY_ARMOR_STAND_HIT("entity.armor_stand.hit"), + ENTITY_ARMOR_STAND_PLACE("entity.armor_stand.place"), ENTITY_ARROW_HIT("entity.arrow.hit"), ENTITY_ARROW_HIT_PLAYER("entity.arrow.hit_player"), ENTITY_ARROW_SHOOT("entity.arrow.shoot"), @@ -161,9 +192,6 @@ public enum CraftSound { ENTITY_BLAZE_SHOOT("entity.blaze.shoot"), ENTITY_BOAT_PADDLE_LAND("entity.boat.paddle_land"), ENTITY_BOAT_PADDLE_WATER("entity.boat.paddle_water"), - ENTITY_BOBBER_RETRIEVE("entity.bobber.retrieve"), - ENTITY_BOBBER_SPLASH("entity.bobber.splash"), - ENTITY_BOBBER_THROW("entity.bobber.throw"), ENTITY_CAT_AMBIENT("entity.cat.ambient"), ENTITY_CAT_DEATH("entity.cat.death"), ENTITY_CAT_HISS("entity.cat.hiss"), @@ -175,6 +203,10 @@ public enum CraftSound { ENTITY_CHICKEN_EGG("entity.chicken.egg"), ENTITY_CHICKEN_HURT("entity.chicken.hurt"), ENTITY_CHICKEN_STEP("entity.chicken.step"), + ENTITY_COD_AMBIENT("entity.cod.ambient"), + ENTITY_COD_DEATH("entity.cod.death"), + ENTITY_COD_FLOP("entity.cod.flop"), + ENTITY_COD_HURT("entity.cod.hurt"), ENTITY_COW_AMBIENT("entity.cow.ambient"), ENTITY_COW_DEATH("entity.cow.death"), ENTITY_COW_HURT("entity.cow.hurt"), @@ -183,11 +215,31 @@ public enum CraftSound { ENTITY_CREEPER_DEATH("entity.creeper.death"), ENTITY_CREEPER_HURT("entity.creeper.hurt"), ENTITY_CREEPER_PRIMED("entity.creeper.primed"), + ENTITY_DOLPHIN_AMBIENT("entity.dolphin.ambient"), + ENTITY_DOLPHIN_AMBIENT_WATER("entity.dolphin.ambient_water"), + ENTITY_DOLPHIN_ATTACK("entity.dolphin.attack"), + ENTITY_DOLPHIN_DEATH("entity.dolphin.death"), + ENTITY_DOLPHIN_EAT("entity.dolphin.eat"), + ENTITY_DOLPHIN_HURT("entity.dolphin.hurt"), + ENTITY_DOLPHIN_JUMP("entity.dolphin.jump"), + ENTITY_DOLPHIN_PLAY("entity.dolphin.play"), + ENTITY_DOLPHIN_SPLASH("entity.dolphin.splash"), + ENTITY_DOLPHIN_SWIM("entity.dolphin.swim"), ENTITY_DONKEY_AMBIENT("entity.donkey.ambient"), ENTITY_DONKEY_ANGRY("entity.donkey.angry"), ENTITY_DONKEY_CHEST("entity.donkey.chest"), ENTITY_DONKEY_DEATH("entity.donkey.death"), ENTITY_DONKEY_HURT("entity.donkey.hurt"), + ENTITY_DRAGON_FIREBALL_EXPLODE("entity.dragon_fireball.explode"), + ENTITY_DROWNED_AMBIENT("entity.drowned.ambient"), + ENTITY_DROWNED_AMBIENT_WATER("entity.drowned.ambient_water"), + ENTITY_DROWNED_DEATH("entity.drowned.death"), + ENTITY_DROWNED_DEATH_WATER("entity.drowned.death_water"), + ENTITY_DROWNED_HURT("entity.drowned.hurt"), + ENTITY_DROWNED_HURT_WATER("entity.drowned.hurt_water"), + ENTITY_DROWNED_SHOOT("entity.drowned.shoot"), + ENTITY_DROWNED_STEP("entity.drowned.step"), + ENTITY_DROWNED_SWIM("entity.drowned.swim"), ENTITY_EGG_THROW("entity.egg.throw"), ENTITY_ELDER_GUARDIAN_AMBIENT("entity.elder_guardian.ambient"), ENTITY_ELDER_GUARDIAN_AMBIENT_LAND("entity.elder_guardian.ambient_land"), @@ -197,44 +249,47 @@ public enum CraftSound { ENTITY_ELDER_GUARDIAN_FLOP("entity.elder_guardian.flop"), ENTITY_ELDER_GUARDIAN_HURT("entity.elder_guardian.hurt"), ENTITY_ELDER_GUARDIAN_HURT_LAND("entity.elder_guardian.hurt_land"), - ENTITY_ENDERDRAGON_AMBIENT("entity.enderdragon.ambient"), - ENTITY_ENDERDRAGON_DEATH("entity.enderdragon.death"), - ENTITY_ENDERDRAGON_FIREBALL_EXPLODE("entity.enderdragon_fireball.explode"), - ENTITY_ENDERDRAGON_FLAP("entity.enderdragon.flap"), - ENTITY_ENDERDRAGON_GROWL("entity.enderdragon.growl"), - ENTITY_ENDERDRAGON_HURT("entity.enderdragon.hurt"), - ENTITY_ENDERDRAGON_SHOOT("entity.enderdragon.shoot"), - ENTITY_ENDEREYE_DEATH("entity.endereye.death"), - ENTITY_ENDEREYE_LAUNCH("entity.endereye.launch"), - ENTITY_ENDERMEN_AMBIENT("entity.endermen.ambient"), - ENTITY_ENDERMEN_DEATH("entity.endermen.death"), - ENTITY_ENDERMEN_HURT("entity.endermen.hurt"), - ENTITY_ENDERMEN_SCREAM("entity.endermen.scream"), - ENTITY_ENDERMEN_STARE("entity.endermen.stare"), - ENTITY_ENDERMEN_TELEPORT("entity.endermen.teleport"), + ENTITY_ENDERMAN_AMBIENT("entity.enderman.ambient"), + ENTITY_ENDERMAN_DEATH("entity.enderman.death"), + ENTITY_ENDERMAN_HURT("entity.enderman.hurt"), + ENTITY_ENDERMAN_SCREAM("entity.enderman.scream"), + ENTITY_ENDERMAN_STARE("entity.enderman.stare"), + ENTITY_ENDERMAN_TELEPORT("entity.enderman.teleport"), ENTITY_ENDERMITE_AMBIENT("entity.endermite.ambient"), ENTITY_ENDERMITE_DEATH("entity.endermite.death"), ENTITY_ENDERMITE_HURT("entity.endermite.hurt"), ENTITY_ENDERMITE_STEP("entity.endermite.step"), - ENTITY_ENDERPEARL_THROW("entity.enderpearl.throw"), - ENTITY_EVOCATION_FANGS_ATTACK("entity.evocation_fangs.attack"), - ENTITY_EVOCATION_ILLAGER_AMBIENT("entity.evocation_illager.ambient"), - ENTITY_EVOCATION_ILLAGER_CAST_SPELL("entity.evocation_illager.cast_spell"), - ENTITY_EVOCATION_ILLAGER_DEATH("entity.evocation_illager.death"), - ENTITY_EVOCATION_ILLAGER_HURT("entity.evocation_illager.hurt"), - ENTITY_EVOCATION_ILLAGER_PREPARE_ATTACK("entity.evocation_illager.prepare_attack"), - ENTITY_EVOCATION_ILLAGER_PREPARE_SUMMON("entity.evocation_illager.prepare_summon"), - ENTITY_EVOCATION_ILLAGER_PREPARE_WOLOLO("entity.evocation_illager.prepare_wololo"), + ENTITY_ENDER_DRAGON_AMBIENT("entity.ender_dragon.ambient"), + ENTITY_ENDER_DRAGON_DEATH("entity.ender_dragon.death"), + ENTITY_ENDER_DRAGON_FLAP("entity.ender_dragon.flap"), + ENTITY_ENDER_DRAGON_GROWL("entity.ender_dragon.growl"), + ENTITY_ENDER_DRAGON_HURT("entity.ender_dragon.hurt"), + ENTITY_ENDER_DRAGON_SHOOT("entity.ender_dragon.shoot"), + ENTITY_ENDER_EYE_DEATH("entity.ender_eye.death"), + ENTITY_ENDER_EYE_LAUNCH("entity.ender_eye.launch"), + ENTITY_ENDER_PEARL_THROW("entity.ender_pearl.throw"), + ENTITY_EVOKER_AMBIENT("entity.evoker.ambient"), + ENTITY_EVOKER_CAST_SPELL("entity.evoker.cast_spell"), + ENTITY_EVOKER_DEATH("entity.evoker.death"), + ENTITY_EVOKER_FANGS_ATTACK("entity.evoker_fangs.attack"), + ENTITY_EVOKER_HURT("entity.evoker.hurt"), + ENTITY_EVOKER_PREPARE_ATTACK("entity.evoker.prepare_attack"), + ENTITY_EVOKER_PREPARE_SUMMON("entity.evoker.prepare_summon"), + ENTITY_EVOKER_PREPARE_WOLOLO("entity.evoker.prepare_wololo"), ENTITY_EXPERIENCE_BOTTLE_THROW("entity.experience_bottle.throw"), ENTITY_EXPERIENCE_ORB_PICKUP("entity.experience_orb.pickup"), - ENTITY_FIREWORK_BLAST("entity.firework.blast"), - ENTITY_FIREWORK_BLAST_FAR("entity.firework.blast_far"), - ENTITY_FIREWORK_LARGE_BLAST("entity.firework.large_blast"), - ENTITY_FIREWORK_LARGE_BLAST_FAR("entity.firework.large_blast_far"), - ENTITY_FIREWORK_LAUNCH("entity.firework.launch"), - ENTITY_FIREWORK_SHOOT("entity.firework.shoot"), - ENTITY_FIREWORK_TWINKLE("entity.firework.twinkle"), - ENTITY_FIREWORK_TWINKLE_FAR("entity.firework.twinkle_far"), + ENTITY_FIREWORK_ROCKET_BLAST("entity.firework_rocket.blast"), + ENTITY_FIREWORK_ROCKET_BLAST_FAR("entity.firework_rocket.blast_far"), + ENTITY_FIREWORK_ROCKET_LARGE_BLAST("entity.firework_rocket.large_blast"), + ENTITY_FIREWORK_ROCKET_LARGE_BLAST_FAR("entity.firework_rocket.large_blast_far"), + ENTITY_FIREWORK_ROCKET_LAUNCH("entity.firework_rocket.launch"), + ENTITY_FIREWORK_ROCKET_SHOOT("entity.firework_rocket.shoot"), + ENTITY_FIREWORK_ROCKET_TWINKLE("entity.firework_rocket.twinkle"), + ENTITY_FIREWORK_ROCKET_TWINKLE_FAR("entity.firework_rocket.twinkle_far"), + ENTITY_FISHING_BOBBER_RETRIEVE("entity.fishing_bobber.retrieve"), + ENTITY_FISHING_BOBBER_SPLASH("entity.fishing_bobber.splash"), + ENTITY_FISHING_BOBBER_THROW("entity.fishing_bobber.throw"), + ENTITY_FISH_SWIM("entity.fish.swim"), ENTITY_GENERIC_BIG_FALL("entity.generic.big_fall"), ENTITY_GENERIC_BURN("entity.generic.burn"), ENTITY_GENERIC_DEATH("entity.generic.death"), @@ -280,32 +335,33 @@ public enum CraftSound { ENTITY_HOSTILE_SPLASH("entity.hostile.splash"), ENTITY_HOSTILE_SWIM("entity.hostile.swim"), ENTITY_HUSK_AMBIENT("entity.husk.ambient"), + ENTITY_HUSK_CONVERTED_TO_ZOMBIE("entity.husk.converted_to_zombie"), ENTITY_HUSK_DEATH("entity.husk.death"), ENTITY_HUSK_HURT("entity.husk.hurt"), ENTITY_HUSK_STEP("entity.husk.step"), - ENTITY_ILLUSION_ILLAGER_AMBIENT("entity.illusion_illager.ambient"), - ENTITY_ILLUSION_ILLAGER_CAST_SPELL("entity.illusion_illager.cast_spell"), - ENTITY_ILLUSION_ILLAGER_DEATH("entity.illusion_illager.death"), - ENTITY_ILLUSION_ILLAGER_HURT("entity.illusion_illager.hurt"), - ENTITY_ILLUSION_ILLAGER_MIRROR_MOVE("entity.illusion_illager.mirror_move"), - ENTITY_ILLUSION_ILLAGER_PREPARE_BLINDNESS("entity.illusion_illager.prepare_blindness"), - ENTITY_ILLUSION_ILLAGER_PREPARE_MIRROR("entity.illusion_illager.prepare_mirror"), - ENTITY_IRONGOLEM_ATTACK("entity.irongolem.attack"), - ENTITY_IRONGOLEM_DEATH("entity.irongolem.death"), - ENTITY_IRONGOLEM_HURT("entity.irongolem.hurt"), - ENTITY_IRONGOLEM_STEP("entity.irongolem.step"), - ENTITY_ITEMFRAME_ADD_ITEM("entity.itemframe.add_item"), - ENTITY_ITEMFRAME_BREAK("entity.itemframe.break"), - ENTITY_ITEMFRAME_PLACE("entity.itemframe.place"), - ENTITY_ITEMFRAME_REMOVE_ITEM("entity.itemframe.remove_item"), - ENTITY_ITEMFRAME_ROTATE_ITEM("entity.itemframe.rotate_item"), + ENTITY_ILLUSIONER_AMBIENT("entity.illusioner.ambient"), + ENTITY_ILLUSIONER_CAST_SPELL("entity.illusioner.cast_spell"), + ENTITY_ILLUSIONER_DEATH("entity.illusioner.death"), + ENTITY_ILLUSIONER_HURT("entity.illusioner.hurt"), + ENTITY_ILLUSIONER_MIRROR_MOVE("entity.illusioner.mirror_move"), + ENTITY_ILLUSIONER_PREPARE_BLINDNESS("entity.illusioner.prepare_blindness"), + ENTITY_ILLUSIONER_PREPARE_MIRROR("entity.illusioner.prepare_mirror"), + ENTITY_IRON_GOLEM_ATTACK("entity.iron_golem.attack"), + ENTITY_IRON_GOLEM_DEATH("entity.iron_golem.death"), + ENTITY_IRON_GOLEM_HURT("entity.iron_golem.hurt"), + ENTITY_IRON_GOLEM_STEP("entity.iron_golem.step"), ENTITY_ITEM_BREAK("entity.item.break"), + ENTITY_ITEM_FRAME_ADD_ITEM("entity.item_frame.add_item"), + ENTITY_ITEM_FRAME_BREAK("entity.item_frame.break"), + ENTITY_ITEM_FRAME_PLACE("entity.item_frame.place"), + ENTITY_ITEM_FRAME_REMOVE_ITEM("entity.item_frame.remove_item"), + ENTITY_ITEM_FRAME_ROTATE_ITEM("entity.item_frame.rotate_item"), ENTITY_ITEM_PICKUP("entity.item.pickup"), - ENTITY_LEASHKNOT_BREAK("entity.leashknot.break"), - ENTITY_LEASHKNOT_PLACE("entity.leashknot.place"), - ENTITY_LIGHTNING_IMPACT("entity.lightning.impact"), - ENTITY_LIGHTNING_THUNDER("entity.lightning.thunder"), - ENTITY_LINGERINGPOTION_THROW("entity.lingeringpotion.throw"), + ENTITY_LEASH_KNOT_BREAK("entity.leash_knot.break"), + ENTITY_LEASH_KNOT_PLACE("entity.leash_knot.place"), + ENTITY_LIGHTNING_BOLT_IMPACT("entity.lightning_bolt.impact"), + ENTITY_LIGHTNING_BOLT_THUNDER("entity.lightning_bolt.thunder"), + ENTITY_LINGERING_POTION_THROW("entity.lingering_potion.throw"), ENTITY_LLAMA_AMBIENT("entity.llama.ambient"), ENTITY_LLAMA_ANGRY("entity.llama.angry"), ENTITY_LLAMA_CHEST("entity.llama.chest"), @@ -315,10 +371,13 @@ public enum CraftSound { ENTITY_LLAMA_SPIT("entity.llama.spit"), ENTITY_LLAMA_STEP("entity.llama.step"), ENTITY_LLAMA_SWAG("entity.llama.swag"), - ENTITY_MAGMACUBE_DEATH("entity.magmacube.death"), - ENTITY_MAGMACUBE_HURT("entity.magmacube.hurt"), - ENTITY_MAGMACUBE_JUMP("entity.magmacube.jump"), - ENTITY_MAGMACUBE_SQUISH("entity.magmacube.squish"), + ENTITY_MAGMA_CUBE_DEATH("entity.magma_cube.death"), + ENTITY_MAGMA_CUBE_DEATH_SMALL("entity.magma_cube.death_small"), + ENTITY_MAGMA_CUBE_HURT("entity.magma_cube.hurt"), + ENTITY_MAGMA_CUBE_HURT_SMALL("entity.magma_cube.hurt_small"), + ENTITY_MAGMA_CUBE_JUMP("entity.magma_cube.jump"), + ENTITY_MAGMA_CUBE_SQUISH("entity.magma_cube.squish"), + ENTITY_MAGMA_CUBE_SQUISH_SMALL("entity.magma_cube.squish_small"), ENTITY_MINECART_INSIDE("entity.minecart.inside"), ENTITY_MINECART_RIDING("entity.minecart.riding"), ENTITY_MOOSHROOM_SHEAR("entity.mooshroom.shear"), @@ -335,15 +394,17 @@ public enum CraftSound { ENTITY_PARROT_HURT("entity.parrot.hurt"), ENTITY_PARROT_IMITATE_BLAZE("entity.parrot.imitate.blaze"), ENTITY_PARROT_IMITATE_CREEPER("entity.parrot.imitate.creeper"), + ENTITY_PARROT_IMITATE_DROWNED("entity.parrot.imitate.drowned"), ENTITY_PARROT_IMITATE_ELDER_GUARDIAN("entity.parrot.imitate.elder_guardian"), - ENTITY_PARROT_IMITATE_ENDERDRAGON("entity.parrot.imitate.enderdragon"), ENTITY_PARROT_IMITATE_ENDERMAN("entity.parrot.imitate.enderman"), ENTITY_PARROT_IMITATE_ENDERMITE("entity.parrot.imitate.endermite"), - ENTITY_PARROT_IMITATE_EVOCATION_ILLAGER("entity.parrot.imitate.evocation_illager"), + 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_HUSK("entity.parrot.imitate.husk"), - ENTITY_PARROT_IMITATE_ILLUSION_ILLAGER("entity.parrot.imitate.illusion_illager"), - ENTITY_PARROT_IMITATE_MAGMACUBE("entity.parrot.imitate.magmacube"), + ENTITY_PARROT_IMITATE_ILLUSIONER("entity.parrot.imitate.illusioner"), + ENTITY_PARROT_IMITATE_MAGMA_CUBE("entity.parrot.imitate.magma_cube"), + ENTITY_PARROT_IMITATE_PHANTOM("entity.parrot.imitate.phantom"), ENTITY_PARROT_IMITATE_POLAR_BEAR("entity.parrot.imitate.polar_bear"), ENTITY_PARROT_IMITATE_SHULKER("entity.parrot.imitate.shulker"), ENTITY_PARROT_IMITATE_SILVERFISH("entity.parrot.imitate.silverfish"), @@ -352,7 +413,7 @@ public enum CraftSound { ENTITY_PARROT_IMITATE_SPIDER("entity.parrot.imitate.spider"), ENTITY_PARROT_IMITATE_STRAY("entity.parrot.imitate.stray"), ENTITY_PARROT_IMITATE_VEX("entity.parrot.imitate.vex"), - ENTITY_PARROT_IMITATE_VINDICATION_ILLAGER("entity.parrot.imitate.vindication_illager"), + ENTITY_PARROT_IMITATE_VINDICATOR("entity.parrot.imitate.vindicator"), ENTITY_PARROT_IMITATE_WITCH("entity.parrot.imitate.witch"), ENTITY_PARROT_IMITATE_WITHER("entity.parrot.imitate.wither"), ENTITY_PARROT_IMITATE_WITHER_SKELETON("entity.parrot.imitate.wither_skeleton"), @@ -361,6 +422,12 @@ public enum CraftSound { ENTITY_PARROT_IMITATE_ZOMBIE_PIGMAN("entity.parrot.imitate.zombie_pigman"), ENTITY_PARROT_IMITATE_ZOMBIE_VILLAGER("entity.parrot.imitate.zombie_villager"), ENTITY_PARROT_STEP("entity.parrot.step"), + ENTITY_PHANTOM_AMBIENT("entity.phantom.ambient"), + ENTITY_PHANTOM_BITE("entity.phantom.bite"), + ENTITY_PHANTOM_DEATH("entity.phantom.death"), + ENTITY_PHANTOM_FLAP("entity.phantom.flap"), + ENTITY_PHANTOM_HURT("entity.phantom.hurt"), + ENTITY_PHANTOM_SWOOP("entity.phantom.swoop"), ENTITY_PIG_AMBIENT("entity.pig.ambient"), ENTITY_PIG_DEATH("entity.pig.death"), ENTITY_PIG_HURT("entity.pig.hurt"), @@ -382,18 +449,30 @@ public enum CraftSound { ENTITY_PLAYER_LEVELUP("entity.player.levelup"), ENTITY_PLAYER_SMALL_FALL("entity.player.small_fall"), ENTITY_PLAYER_SPLASH("entity.player.splash"), + ENTITY_PLAYER_SPLASH_HIGH_SPEED("entity.player.splash.high_speed"), ENTITY_PLAYER_SWIM("entity.player.swim"), ENTITY_POLAR_BEAR_AMBIENT("entity.polar_bear.ambient"), - ENTITY_POLAR_BEAR_BABY_AMBIENT("entity.polar_bear.baby_ambient"), + ENTITY_POLAR_BEAR_AMBIENT_BABY("entity.polar_bear.ambient_baby"), ENTITY_POLAR_BEAR_DEATH("entity.polar_bear.death"), ENTITY_POLAR_BEAR_HURT("entity.polar_bear.hurt"), ENTITY_POLAR_BEAR_STEP("entity.polar_bear.step"), ENTITY_POLAR_BEAR_WARNING("entity.polar_bear.warning"), + ENTITY_PUFFER_FISH_AMBIENT("entity.puffer_fish.ambient"), + ENTITY_PUFFER_FISH_BLOW_OUT("entity.puffer_fish.blow_out"), + ENTITY_PUFFER_FISH_BLOW_UP("entity.puffer_fish.blow_up"), + ENTITY_PUFFER_FISH_DEATH("entity.puffer_fish.death"), + ENTITY_PUFFER_FISH_FLOP("entity.puffer_fish.flop"), + ENTITY_PUFFER_FISH_HURT("entity.puffer_fish.hurt"), + ENTITY_PUFFER_FISH_STING("entity.puffer_fish.sting"), ENTITY_RABBIT_AMBIENT("entity.rabbit.ambient"), ENTITY_RABBIT_ATTACK("entity.rabbit.attack"), ENTITY_RABBIT_DEATH("entity.rabbit.death"), ENTITY_RABBIT_HURT("entity.rabbit.hurt"), ENTITY_RABBIT_JUMP("entity.rabbit.jump"), + ENTITY_SALMON_AMBIENT("entity.salmon.ambient"), + ENTITY_SALMON_DEATH("entity.salmon.death"), + ENTITY_SALMON_FLOP("entity.salmon.flop"), + ENTITY_SALMON_HURT("entity.salmon.hurt"), ENTITY_SHEEP_AMBIENT("entity.sheep.ambient"), ENTITY_SHEEP_DEATH("entity.sheep.death"), ENTITY_SHEEP_HURT("entity.sheep.hurt"), @@ -416,28 +495,30 @@ public enum CraftSound { ENTITY_SKELETON_AMBIENT("entity.skeleton.ambient"), ENTITY_SKELETON_DEATH("entity.skeleton.death"), ENTITY_SKELETON_HORSE_AMBIENT("entity.skeleton_horse.ambient"), + ENTITY_SKELETON_HORSE_AMBIENT_WATER("entity.skeleton_horse.ambient_water"), ENTITY_SKELETON_HORSE_DEATH("entity.skeleton_horse.death"), + ENTITY_SKELETON_HORSE_GALLOP_WATER("entity.skeleton_horse.gallop_water"), ENTITY_SKELETON_HORSE_HURT("entity.skeleton_horse.hurt"), + ENTITY_SKELETON_HORSE_JUMP_WATER("entity.skeleton_horse.jump_water"), + ENTITY_SKELETON_HORSE_STEP_WATER("entity.skeleton_horse.step_water"), + ENTITY_SKELETON_HORSE_SWIM("entity.skeleton_horse.swim"), ENTITY_SKELETON_HURT("entity.skeleton.hurt"), ENTITY_SKELETON_SHOOT("entity.skeleton.shoot"), ENTITY_SKELETON_STEP("entity.skeleton.step"), ENTITY_SLIME_ATTACK("entity.slime.attack"), ENTITY_SLIME_DEATH("entity.slime.death"), + ENTITY_SLIME_DEATH_SMALL("entity.slime.death_small"), ENTITY_SLIME_HURT("entity.slime.hurt"), + ENTITY_SLIME_HURT_SMALL("entity.slime.hurt_small"), ENTITY_SLIME_JUMP("entity.slime.jump"), + ENTITY_SLIME_JUMP_SMALL("entity.slime.jump_small"), ENTITY_SLIME_SQUISH("entity.slime.squish"), - ENTITY_SMALL_MAGMACUBE_DEATH("entity.small_magmacube.death"), - ENTITY_SMALL_MAGMACUBE_HURT("entity.small_magmacube.hurt"), - ENTITY_SMALL_MAGMACUBE_SQUISH("entity.small_magmacube.squish"), - ENTITY_SMALL_SLIME_DEATH("entity.small_slime.death"), - ENTITY_SMALL_SLIME_HURT("entity.small_slime.hurt"), - ENTITY_SMALL_SLIME_JUMP("entity.small_slime.jump"), - ENTITY_SMALL_SLIME_SQUISH("entity.small_slime.squish"), + ENTITY_SLIME_SQUISH_SMALL("entity.slime.squish_small"), ENTITY_SNOWBALL_THROW("entity.snowball.throw"), - ENTITY_SNOWMAN_AMBIENT("entity.snowman.ambient"), - ENTITY_SNOWMAN_DEATH("entity.snowman.death"), - ENTITY_SNOWMAN_HURT("entity.snowman.hurt"), - ENTITY_SNOWMAN_SHOOT("entity.snowman.shoot"), + ENTITY_SNOW_GOLEM_AMBIENT("entity.snow_golem.ambient"), + ENTITY_SNOW_GOLEM_DEATH("entity.snow_golem.death"), + ENTITY_SNOW_GOLEM_HURT("entity.snow_golem.hurt"), + ENTITY_SNOW_GOLEM_SHOOT("entity.snow_golem.shoot"), ENTITY_SPIDER_AMBIENT("entity.spider.ambient"), ENTITY_SPIDER_DEATH("entity.spider.death"), ENTITY_SPIDER_HURT("entity.spider.hurt"), @@ -447,11 +528,28 @@ public enum CraftSound { ENTITY_SQUID_AMBIENT("entity.squid.ambient"), ENTITY_SQUID_DEATH("entity.squid.death"), ENTITY_SQUID_HURT("entity.squid.hurt"), + ENTITY_SQUID_SQUIRT("entity.squid.squirt"), ENTITY_STRAY_AMBIENT("entity.stray.ambient"), ENTITY_STRAY_DEATH("entity.stray.death"), ENTITY_STRAY_HURT("entity.stray.hurt"), ENTITY_STRAY_STEP("entity.stray.step"), ENTITY_TNT_PRIMED("entity.tnt.primed"), + ENTITY_TROPICAL_FISH_AMBIENT("entity.tropical_fish.ambient"), + ENTITY_TROPICAL_FISH_DEATH("entity.tropical_fish.death"), + ENTITY_TROPICAL_FISH_FLOP("entity.tropical_fish.flop"), + ENTITY_TROPICAL_FISH_HURT("entity.tropical_fish.hurt"), + ENTITY_TURTLE_AMBIENT_LAND("entity.turtle.ambient_land"), + ENTITY_TURTLE_DEATH("entity.turtle.death"), + ENTITY_TURTLE_DEATH_BABY("entity.turtle.death_baby"), + ENTITY_TURTLE_EGG_BREAK("entity.turtle.egg_break"), + ENTITY_TURTLE_EGG_CRACK("entity.turtle.egg_crack"), + ENTITY_TURTLE_EGG_HATCH("entity.turtle.egg_hatch"), + ENTITY_TURTLE_HURT("entity.turtle.hurt"), + ENTITY_TURTLE_HURT_BABY("entity.turtle.hurt_baby"), + ENTITY_TURTLE_LAY_EGG("entity.turtle.lay_egg"), + ENTITY_TURTLE_SHAMBLE("entity.turtle.shamble"), + ENTITY_TURTLE_SHAMBLE_BABY("entity.turtle.shamble_baby"), + ENTITY_TURTLE_SWIM("entity.turtle.swim"), ENTITY_VEX_AMBIENT("entity.vex.ambient"), ENTITY_VEX_CHARGE("entity.vex.charge"), ENTITY_VEX_DEATH("entity.vex.death"), @@ -460,11 +558,11 @@ public enum CraftSound { ENTITY_VILLAGER_DEATH("entity.villager.death"), ENTITY_VILLAGER_HURT("entity.villager.hurt"), ENTITY_VILLAGER_NO("entity.villager.no"), - ENTITY_VILLAGER_TRADING("entity.villager.trading"), + ENTITY_VILLAGER_TRADE("entity.villager.trade"), ENTITY_VILLAGER_YES("entity.villager.yes"), - ENTITY_VINDICATION_ILLAGER_AMBIENT("entity.vindication_illager.ambient"), - ENTITY_VINDICATION_ILLAGER_DEATH("entity.vindication_illager.death"), - ENTITY_VINDICATION_ILLAGER_HURT("entity.vindication_illager.hurt"), + ENTITY_VINDICATOR_AMBIENT("entity.vindicator.ambient"), + ENTITY_VINDICATOR_DEATH("entity.vindicator.death"), + ENTITY_VINDICATOR_HURT("entity.vindicator.hurt"), ENTITY_WITCH_AMBIENT("entity.witch.ambient"), ENTITY_WITCH_DEATH("entity.witch.death"), ENTITY_WITCH_DRINK("entity.witch.drink"), @@ -490,19 +588,21 @@ public enum CraftSound { ENTITY_WOLF_STEP("entity.wolf.step"), ENTITY_WOLF_WHINE("entity.wolf.whine"), ENTITY_ZOMBIE_AMBIENT("entity.zombie.ambient"), - ENTITY_ZOMBIE_ATTACK_DOOR_WOOD("entity.zombie.attack_door_wood"), ENTITY_ZOMBIE_ATTACK_IRON_DOOR("entity.zombie.attack_iron_door"), - ENTITY_ZOMBIE_BREAK_DOOR_WOOD("entity.zombie.break_door_wood"), + ENTITY_ZOMBIE_ATTACK_WOODEN_DOOR("entity.zombie.attack_wooden_door"), + ENTITY_ZOMBIE_BREAK_WOODEN_DOOR("entity.zombie.break_wooden_door"), + ENTITY_ZOMBIE_CONVERTED_TO_DROWNED("entity.zombie.converted_to_drowned"), ENTITY_ZOMBIE_DEATH("entity.zombie.death"), + ENTITY_ZOMBIE_DESTROY_EGG("entity.zombie.destroy_egg"), ENTITY_ZOMBIE_HORSE_AMBIENT("entity.zombie_horse.ambient"), ENTITY_ZOMBIE_HORSE_DEATH("entity.zombie_horse.death"), ENTITY_ZOMBIE_HORSE_HURT("entity.zombie_horse.hurt"), ENTITY_ZOMBIE_HURT("entity.zombie.hurt"), ENTITY_ZOMBIE_INFECT("entity.zombie.infect"), - ENTITY_ZOMBIE_PIG_AMBIENT("entity.zombie_pig.ambient"), - ENTITY_ZOMBIE_PIG_ANGRY("entity.zombie_pig.angry"), - ENTITY_ZOMBIE_PIG_DEATH("entity.zombie_pig.death"), - ENTITY_ZOMBIE_PIG_HURT("entity.zombie_pig.hurt"), + ENTITY_ZOMBIE_PIGMAN_AMBIENT("entity.zombie_pigman.ambient"), + ENTITY_ZOMBIE_PIGMAN_ANGRY("entity.zombie_pigman.angry"), + ENTITY_ZOMBIE_PIGMAN_DEATH("entity.zombie_pigman.death"), + ENTITY_ZOMBIE_PIGMAN_HURT("entity.zombie_pigman.hurt"), ENTITY_ZOMBIE_STEP("entity.zombie.step"), ENTITY_ZOMBIE_VILLAGER_AMBIENT("entity.zombie_villager.ambient"), ENTITY_ZOMBIE_VILLAGER_CONVERTED("entity.zombie_villager.converted"), @@ -517,12 +617,16 @@ public enum CraftSound { ITEM_ARMOR_EQUIP_GOLD("item.armor.equip_gold"), ITEM_ARMOR_EQUIP_IRON("item.armor.equip_iron"), ITEM_ARMOR_EQUIP_LEATHER("item.armor.equip_leather"), + ITEM_ARMOR_EQUIP_TURTLE("item.armor.equip_turtle"), + ITEM_AXE_STRIP("item.axe.strip"), ITEM_BOTTLE_EMPTY("item.bottle.empty"), ITEM_BOTTLE_FILL("item.bottle.fill"), ITEM_BOTTLE_FILL_DRAGONBREATH("item.bottle.fill_dragonbreath"), ITEM_BUCKET_EMPTY("item.bucket.empty"), + ITEM_BUCKET_EMPTY_FISH("item.bucket.empty_fish"), ITEM_BUCKET_EMPTY_LAVA("item.bucket.empty_lava"), ITEM_BUCKET_FILL("item.bucket.fill"), + 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_ELYTRA_FLYING("item.elytra.flying"), @@ -533,25 +637,34 @@ public enum CraftSound { ITEM_SHIELD_BREAK("item.shield.break"), ITEM_SHOVEL_FLATTEN("item.shovel.flatten"), ITEM_TOTEM_USE("item.totem.use"), + ITEM_TRIDENT_HIT("item.trident.hit"), + ITEM_TRIDENT_HIT_GROUND("item.trident.hit_ground"), + ITEM_TRIDENT_RETURN("item.trident.return"), + ITEM_TRIDENT_RIPTIDE_1("item.trident.riptide_1"), + ITEM_TRIDENT_RIPTIDE_2("item.trident.riptide_2"), + ITEM_TRIDENT_RIPTIDE_3("item.trident.riptide_3"), + ITEM_TRIDENT_THROW("item.trident.throw"), + ITEM_TRIDENT_THUNDER("item.trident.thunder"), MUSIC_CREATIVE("music.creative"), MUSIC_CREDITS("music.credits"), + MUSIC_DISC_11("music_disc.11"), + MUSIC_DISC_13("music_disc.13"), + MUSIC_DISC_BLOCKS("music_disc.blocks"), + MUSIC_DISC_CAT("music_disc.cat"), + MUSIC_DISC_CHIRP("music_disc.chirp"), + MUSIC_DISC_FAR("music_disc.far"), + MUSIC_DISC_MALL("music_disc.mall"), + MUSIC_DISC_MELLOHI("music_disc.mellohi"), + MUSIC_DISC_STAL("music_disc.stal"), + MUSIC_DISC_STRAD("music_disc.strad"), + MUSIC_DISC_WAIT("music_disc.wait"), + MUSIC_DISC_WARD("music_disc.ward"), MUSIC_DRAGON("music.dragon"), MUSIC_END("music.end"), MUSIC_GAME("music.game"), MUSIC_MENU("music.menu"), MUSIC_NETHER("music.nether"), - RECORD_11("record.11"), - RECORD_13("record.13"), - RECORD_BLOCKS("record.blocks"), - RECORD_CAT("record.cat"), - RECORD_CHIRP("record.chirp"), - RECORD_FAR("record.far"), - RECORD_MALL("record.mall"), - RECORD_MELLOHI("record.mellohi"), - RECORD_STAL("record.stal"), - RECORD_STRAD("record.strad"), - RECORD_WAIT("record.wait"), - RECORD_WARD("record.ward"), + MUSIC_UNDER_WATER("music.under_water"), UI_BUTTON_CLICK("ui.button.click"), UI_TOAST_CHALLENGE_COMPLETE("ui.toast.challenge_complete"), UI_TOAST_IN("ui.toast.in"), diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftStatistic.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftStatistic.java index 5c06958665..b07b36809b 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftStatistic.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftStatistic.java @@ -1,94 +1,141 @@ package org.bukkit.craftbukkit; -import net.minecraft.server.EntityTypes; -import net.minecraft.server.EntityTypes.MonsterEggInfo; import net.minecraft.server.StatisticList; import org.bukkit.Statistic; import org.bukkit.Material; import org.bukkit.entity.EntityType; -import com.google.common.base.CaseFormat; +import com.google.common.base.Preconditions; import com.google.common.collect.BiMap; import com.google.common.collect.ImmutableBiMap; import net.minecraft.server.Block; +import net.minecraft.server.EntityTypes; import net.minecraft.server.Item; import net.minecraft.server.MinecraftKey; +import net.minecraft.server.RegistryMaterials; import org.bukkit.craftbukkit.util.CraftMagicNumbers; -public class CraftStatistic { - private static final BiMap statistics; +public enum CraftStatistic { + DAMAGE_DEALT("damage_dealt"), + DAMAGE_TAKEN("damage_taken"), + DEATHS("deaths"), + MOB_KILLS("mob_kills"), + PLAYER_KILLS("player_kills"), + FISH_CAUGHT("fish_caught"), + ANIMALS_BRED("animals_bred"), + LEAVE_GAME("leave_game"), + JUMP("jump"), + DROP_COUNT("drop"), + DROP("dropped"), + PICKUP("picked_up"), + PLAY_ONE_MINUTE("play_one_minute"), + WALK_ONE_CM("walk_one_cm"), + WALK_ON_WATER_ONE_CM("walk_on_water_one_cm"), + FALL_ONE_CM("fall_one_cm"), + SNEAK_TIME("sneak_time"), + CLIMB_ONE_CM("climb_one_cm"), + FLY_ONE_CM("fly_one_cm"), + WALK_UNDER_WATER_ONE_CM("walk_under_water_one_cm"), + MINECART_ONE_CM("minecart_one_cm"), + BOAT_ONE_CM("boat_one_cm"), + PIG_ONE_CM("pig_one_cm"), + HORSE_ONE_CM("horse_one_cm"), + SPRINT_ONE_CM("sprint_one_cm"), + CROUCH_ONE_CM("crouch_one_cm"), + AVIATE_ONE_CM("aviate_one_cm"), + MINE_BLOCK("mined"), + USE_ITEM("used"), + BREAK_ITEM("broken"), + CRAFT_ITEM("crafted"), + KILL_ENTITY("killed"), + ENTITY_KILLED_BY("killed_by"), + TIME_SINCE_DEATH("time_since_death"), + TALKED_TO_VILLAGER("talked_to_villager"), + TRADED_WITH_VILLAGER("traded_with_villager"), + CAKE_SLICES_EATEN("eat_cake_slice"), + CAULDRON_FILLED("fill_cauldron"), + CAULDRON_USED("use_cauldron"), + ARMOR_CLEANED("clean_armor"), + BANNER_CLEANED("clean_banner"), + BREWINGSTAND_INTERACTION("interact_with_brewingstand"), + BEACON_INTERACTION("interact_with_beacon"), + DROPPER_INSPECTED("inspect_dropper"), + HOPPER_INSPECTED("inspect_hopper"), + DISPENSER_INSPECTED("inspect_dispenser"), + NOTEBLOCK_PLAYED("play_noteblock"), + NOTEBLOCK_TUNED("tune_noteblock"), + FLOWER_POTTED("pot_flower"), + TRAPPED_CHEST_TRIGGERED("trigger_trapped_chest"), + ENDERCHEST_OPENED("open_enderchest"), + ITEM_ENCHANTED("enchant_item"), + RECORD_PLAYED("play_record"), + FURNACE_INTERACTION("interact_with_furnace"), + CRAFTING_TABLE_INTERACTION("interact_with_crafting_table"), + CHEST_OPENED("open_chest"), + SLEEP_IN_BED("sleep_in_bed"), + SHULKER_BOX_OPENED("open_shulker_box"), + TIME_SINCE_REST("time_since_rest"), + SWIM_ONE_CM("swim_one_cm"); + private final MinecraftKey minecraftKey; + private final org.bukkit.Statistic bukkit; + private static final BiMap statistics; static { - ImmutableBiMap.Builder statisticBuilder = ImmutableBiMap.builder(); - for (Statistic statistic : Statistic.values()) { - if (statistic == Statistic.PLAY_ONE_TICK) { - statisticBuilder.put("stat.playOneMinute", statistic); - } else { - statisticBuilder.put("stat." + CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, statistic.name()), statistic); - } + ImmutableBiMap.Builder statisticBuilder = ImmutableBiMap.builder(); + for (CraftStatistic statistic : CraftStatistic.values()) { + statisticBuilder.put(statistic.minecraftKey, statistic.bukkit); } statistics = statisticBuilder.build(); } - private CraftStatistic() {} + private CraftStatistic(String minecraftKey) { + this.minecraftKey = new MinecraftKey(minecraftKey); - public static org.bukkit.Statistic getBukkitStatistic(net.minecraft.server.Statistic statistic) { - return getBukkitStatisticByName(statistic.name); + this.bukkit = org.bukkit.Statistic.valueOf(this.name()); + Preconditions.checkState(bukkit != null, "Bukkit statistic %s does not exist", this.name()); } - public static org.bukkit.Statistic getBukkitStatisticByName(String name) { - if (name.startsWith("stat.killEntity.")) { - name = "stat.killEntity"; + public static org.bukkit.Statistic getBukkitStatistic(net.minecraft.server.Statistic statistic) { + RegistryMaterials statRegistry = statistic.a().a(); + MinecraftKey nmsKey = StatisticList.REGISTRY.b(statistic.a()); + + if (statRegistry == StatisticList.REGISTRY_CUSTOM) { + nmsKey = (MinecraftKey) statistic.b(); } - if (name.startsWith("stat.entityKilledBy.")) { - name = "stat.entityKilledBy"; - } - if (name.startsWith("stat.breakItem.")) { - name = "stat.breakItem"; - } - if (name.startsWith("stat.useItem.")) { - name = "stat.useItem"; - } - if (name.startsWith("stat.mineBlock.")) { - name = "stat.mineBlock"; - } - if (name.startsWith("stat.craftItem.")) { - name = "stat.craftItem"; - } - if (name.startsWith("stat.drop.")) { - name = "stat.drop"; - } - if (name.startsWith("stat.pickup.")) { - name = "stat.pickup"; - } - return statistics.get(name); + + return statistics.get(nmsKey); } - public static net.minecraft.server.Statistic getNMSStatistic(org.bukkit.Statistic statistic) { - return StatisticList.getStatistic(statistics.inverse().get(statistic)); + public static net.minecraft.server.Statistic getNMSStatistic(org.bukkit.Statistic bukkit) { + Preconditions.checkArgument(bukkit.getType() == Statistic.Type.UNTYPED, "This method only accepts untyped statistics"); + + net.minecraft.server.Statistic nms = StatisticList.CUSTOM.b(statistics.inverse().get(bukkit)); + Preconditions.checkArgument(nms != null, "NMS Statistic %s does not exist", bukkit); + + return nms; } public static net.minecraft.server.Statistic getMaterialStatistic(org.bukkit.Statistic stat, Material material) { try { if (stat == Statistic.MINE_BLOCK) { - return StatisticList.a(CraftMagicNumbers.getBlock(material)); // PAIL: getMineBlockStatistic + return StatisticList.BLOCK_MINED.b(CraftMagicNumbers.getBlock(material)); } if (stat == Statistic.CRAFT_ITEM) { - return StatisticList.a(CraftMagicNumbers.getItem(material)); // PAIL: getCraftItemStatistic + return StatisticList.ITEM_CRAFTED.b(CraftMagicNumbers.getItem(material)); } if (stat == Statistic.USE_ITEM) { - return StatisticList.b(CraftMagicNumbers.getItem(material)); // PAIL: getUseItemStatistic + return StatisticList.ITEM_USED.b(CraftMagicNumbers.getItem(material)); } if (stat == Statistic.BREAK_ITEM) { - return StatisticList.c(CraftMagicNumbers.getItem(material)); // PAIL: getBreakItemStatistic + return StatisticList.ITEM_BROKEN.b(CraftMagicNumbers.getItem(material)); } if (stat == Statistic.PICKUP) { - return StatisticList.d(CraftMagicNumbers.getItem(material)); // PAIL: getPickupStatistic + return StatisticList.ITEM_PICKED_UP.b(CraftMagicNumbers.getItem(material)); } if (stat == Statistic.DROP) { - return StatisticList.e(CraftMagicNumbers.getItem(material)); // PAIL: getDropItemStatistic + return StatisticList.ITEM_DROPPED.b(CraftMagicNumbers.getItem(material)); } } catch (ArrayIndexOutOfBoundsException e) { return null; @@ -97,39 +144,31 @@ public class CraftStatistic { } public static net.minecraft.server.Statistic getEntityStatistic(org.bukkit.Statistic stat, EntityType entity) { - MonsterEggInfo monsteregginfo = (MonsterEggInfo) EntityTypes.eggInfo.get(new MinecraftKey(entity.getName())); + if (entity.getName() != null) { + EntityTypes nmsEntity = EntityTypes.REGISTRY.get(new MinecraftKey(entity.getName())); - if (monsteregginfo != null) { if (stat == org.bukkit.Statistic.KILL_ENTITY) { - return monsteregginfo.killEntityStatistic; + return net.minecraft.server.StatisticList.ENTITY_KILLED.b(nmsEntity); } if (stat == org.bukkit.Statistic.ENTITY_KILLED_BY) { - return monsteregginfo.killedByEntityStatistic; + return net.minecraft.server.StatisticList.ENTITY_KILLED_BY.b(nmsEntity); } } return null; } - public static EntityType getEntityTypeFromStatistic(net.minecraft.server.Statistic statistic) { - String statisticString = statistic.name; - return EntityType.fromName(statisticString.substring(statisticString.lastIndexOf(".") + 1)); + public static EntityType getEntityTypeFromStatistic(net.minecraft.server.Statistic> statistic) { + MinecraftKey name = EntityTypes.getName(statistic.b()); + return EntityType.fromName(name.getKey()); } - public static Material getMaterialFromStatistic(net.minecraft.server.Statistic statistic) { - String statisticString = statistic.name; - String val = statisticString.substring(statisticString.lastIndexOf(".") + 1); - Item item = (Item) Item.REGISTRY.get(new MinecraftKey(val)); - if (item != null) { - return Material.getMaterial(Item.getId(item)); + public static Material getMaterialFromStatistic(net.minecraft.server.Statistic statistic) { + if (statistic.b() instanceof Item) { + return CraftMagicNumbers.getMaterial((Item) statistic.b()); } - Block block = (Block) Block.REGISTRY.get(new MinecraftKey(val)); - if (block != null) { - return Material.getMaterial(Block.getId(block)); - } - try { - return Material.getMaterial(Integer.parseInt(val)); - } catch (NumberFormatException e) { - return null; + if (statistic.b() instanceof Block) { + return CraftMagicNumbers.getMaterial((Block) statistic.b()); } + return null; } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index 8f6653f773..162c79e88d 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -1,6 +1,7 @@ package org.bukkit.craftbukkit; import com.google.common.base.Preconditions; +import com.google.common.util.concurrent.Futures; import java.io.File; import java.util.ArrayList; import java.util.Collection; @@ -31,8 +32,10 @@ import org.bukkit.block.Biome; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.block.BlockState; +import org.bukkit.block.data.BlockData; import org.bukkit.craftbukkit.block.CraftBlock; import org.bukkit.craftbukkit.block.CraftBlockState; +import org.bukkit.craftbukkit.block.data.CraftBlockData; import org.bukkit.craftbukkit.entity.*; import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.craftbukkit.metadata.BlockMetadataStore; @@ -92,11 +95,7 @@ public class CraftWorld implements World { } public Block getBlockAt(int x, int y, int z) { - return getChunkAt(x >> 4, z >> 4).getBlock(x & 0xF, y, z & 0xF); - } - - public int getBlockTypeIdAt(int x, int y, int z) { - return CraftMagicNumbers.getId(world.getType(new BlockPosition(x, y, z)).getBlock()); + return CraftBlock.at(world, new BlockPosition(x, y, z)); } public int getHighestBlockYAt(int x, int z) { @@ -104,7 +103,7 @@ public class CraftWorld implements World { loadChunk(x >> 4, z >> 4); } - return world.getHighestBlockYAt(new BlockPosition(x, 0, z)).getY(); + return world.getHighestBlockYAt(HeightMap.Type.LIGHT_BLOCKING, new BlockPosition(x, 0, z)).getY(); } public Location getSpawnLocation() { @@ -219,7 +218,7 @@ public class CraftWorld implements World { net.minecraft.server.Chunk chunk = null; - chunk = world.getChunkProviderServer().chunkGenerator.getOrCreateChunk(x, z); + chunk = Futures.getUnchecked(world.getChunkProviderServer().generateChunk(x, z)); PlayerChunk playerChunk = world.getPlayerChunkMap().getChunk(x, z); if (playerChunk != null) { playerChunk.chunk = chunk; @@ -229,7 +228,6 @@ public class CraftWorld implements World { world.getChunkProviderServer().chunks.put(chunkKey, chunk); chunk.addEntities(); - chunk.loadNearby(world.getChunkProviderServer(), world.getChunkProviderServer().chunkGenerator, true); refreshChunk(x, z); } @@ -286,7 +284,6 @@ public class CraftWorld implements World { public org.bukkit.entity.Item dropItem(Location loc, ItemStack item) { Validate.notNull(item, "Cannot drop a Null item."); - Validate.isTrue(item.getTypeId() != 0, "Cannot drop AIR."); EntityItem entity = new EntityItem(world, loc.getX(), loc.getY(), loc.getZ(), CraftItemStack.asNMSCopy(item)); entity.pickupDelay = 10; world.addEntity(entity, SpawnReason.CUSTOM); @@ -346,6 +343,8 @@ public class CraftWorld implements World { ((EntityTippedArrow) arrow).setType(CraftPotionUtil.fromBukkit(new PotionData(PotionType.WATER, false, false))); } else if (SpectralArrow.class.isAssignableFrom(clazz)) { arrow = new EntitySpectralArrow(world); + } else if (Trident.class.isAssignableFrom(clazz)){ + arrow = new EntityThrownTrident(world); } else { arrow = new EntityTippedArrow(world); } @@ -390,30 +389,22 @@ public class CraftWorld implements World { gen = new WorldGenTaiga1(); break; case JUNGLE: - IBlockData iblockdata1 = Blocks.LOG.getBlockData().set(BlockLog1.VARIANT, BlockWood.EnumLogVariant.JUNGLE); - IBlockData iblockdata2 = Blocks.LEAVES.getBlockData().set(BlockLeaves1.VARIANT, BlockWood.EnumLogVariant.JUNGLE).set(BlockLeaves.CHECK_DECAY, Boolean.valueOf(false)); - gen = new WorldGenJungleTree(true, 10, 20, iblockdata1, iblockdata2); // Magic values as in BlockSapling + gen = new WorldGenJungleTree(true, 10, 20, Blocks.JUNGLE_LOG.getBlockData(), Blocks.JUNGLE_LEAVES.getBlockData()); break; case SMALL_JUNGLE: - iblockdata1 = Blocks.LOG.getBlockData().set(BlockLog1.VARIANT, BlockWood.EnumLogVariant.JUNGLE); - iblockdata2 = Blocks.LEAVES.getBlockData().set(BlockLeaves1.VARIANT, BlockWood.EnumLogVariant.JUNGLE).set(BlockLeaves.CHECK_DECAY, Boolean.valueOf(false)); - gen = new WorldGenTrees(true, 4 + rand.nextInt(7), iblockdata1, iblockdata2, false); + gen = new WorldGenTrees(true, 4 + rand.nextInt(7), Blocks.JUNGLE_LOG.getBlockData(), Blocks.JUNGLE_LEAVES.getBlockData(), false); break; case COCOA_TREE: - iblockdata1 = Blocks.LOG.getBlockData().set(BlockLog1.VARIANT, BlockWood.EnumLogVariant.JUNGLE); - iblockdata2 = Blocks.LEAVES.getBlockData().set(BlockLeaves1.VARIANT, BlockWood.EnumLogVariant.JUNGLE).set(BlockLeaves.CHECK_DECAY, Boolean.valueOf(false)); - gen = new WorldGenTrees(true, 4 + rand.nextInt(7), iblockdata1, iblockdata2, true); + gen = new WorldGenJungleTree(true, 10, 20, Blocks.JUNGLE_LOG.getBlockData(), Blocks.JUNGLE_LEAVES.getBlockData()); break; case JUNGLE_BUSH: - iblockdata1 = Blocks.LOG.getBlockData().set(BlockLog1.VARIANT, BlockWood.EnumLogVariant.JUNGLE); - iblockdata2 = Blocks.LEAVES.getBlockData().set(BlockLeaves1.VARIANT, BlockWood.EnumLogVariant.OAK).set(BlockLeaves.CHECK_DECAY, Boolean.valueOf(false)); - gen = new WorldGenGroundBush(iblockdata1, iblockdata2); + gen = new WorldGenGroundBush(Blocks.JUNGLE_LOG.getBlockData(), Blocks.OAK_LEAVES.getBlockData()); break; case RED_MUSHROOM: - gen = new WorldGenHugeMushroom(Blocks.RED_MUSHROOM_BLOCK); + gen = new WorldGenHugeMushroomRed(); break; case BROWN_MUSHROOM: - gen = new WorldGenHugeMushroom(Blocks.BROWN_MUSHROOM_BLOCK); + gen = new WorldGenHugeMushroomBrown(); break; case SWAMP: gen = new WorldGenSwampTree(); @@ -431,7 +422,7 @@ public class CraftWorld implements World { gen = new WorldGenForest(true, true); break; case CHORUS_PLANT: - BlockChorusFlower.a(world, pos, rand, 8); + ((BlockChorusFlower) Blocks.CHORUS_FLOWER).a(world, pos, rand, 8); return true; case TREE: default: @@ -439,7 +430,7 @@ public class CraftWorld implements World { break; } - return gen.generate(world, rand, pos); + return gen.generate(world, world.worldProvider.getChunkGenerator(), rand, pos, new WorldGenFeatureEmptyConfiguration()); } public boolean generateTree(Location loc, TreeType type, BlockChangeDelegate delegate) { @@ -455,12 +446,10 @@ public class CraftWorld implements World { int z = blockstate.getZ(); BlockPosition position = new BlockPosition(x, y, z); net.minecraft.server.IBlockData oldBlock = world.getType(position); - int typeId = blockstate.getTypeId(); - int data = blockstate.getRawData(); - int flag = ((CraftBlockState)blockstate).getFlag(); - delegate.setTypeIdAndData(x, y, z, typeId, data); + int flag = ((CraftBlockState) blockstate).getFlag(); + delegate.setBlockData(x, y, z, blockstate.getBlockData()); net.minecraft.server.IBlockData newBlock = world.getType(position); - world.notifyAndUpdatePhysics(position, null, oldBlock, newBlock, flag); + world.notifyAndUpdatePhysics(position, null, oldBlock, newBlock, newBlock, flag); } world.capturedBlockStates.clear(); return true; @@ -565,10 +554,6 @@ public class CraftWorld implements World { return getBlockAt(location.getBlockX(), location.getBlockY(), location.getBlockZ()); } - public int getBlockTypeIdAt(Location location) { - return getBlockTypeIdAt(location.getBlockX(), location.getBlockY(), location.getBlockZ()); - } - public int getHighestBlockYAt(Location location) { return getHighestBlockYAt(location.getBlockX(), location.getBlockZ()); } @@ -603,8 +588,8 @@ public class CraftWorld implements World { net.minecraft.server.Chunk chunk = this.world.getChunkAtWorldCoords(new BlockPosition(x, 0, z)); if (chunk != null) { - byte[] biomevals = chunk.getBiomeIndex(); - biomevals[((z & 0xF) << 4) | (x & 0xF)] = (byte) BiomeBase.REGISTRY_ID.a(bb); + BiomeBase[] biomevals = chunk.getBiomeIndex(); + biomevals[((z & 0xF) << 4) | (x & 0xF)] = bb; chunk.markDirty(); // SPIGOT-2890 } @@ -881,15 +866,23 @@ public class CraftWorld implements World { Validate.notNull(material, "Material cannot be null"); Validate.isTrue(material.isBlock(), "Material must be a block"); - EntityFallingBlock entity = new EntityFallingBlock(world, location.getX(), location.getY(), location.getZ(), CraftMagicNumbers.getBlock(material).fromLegacyData(data)); + EntityFallingBlock entity = new EntityFallingBlock(world, location.getX(), location.getY(), location.getZ(), CraftMagicNumbers.getBlock(material).getBlockData()); entity.ticksLived = 1; world.addEntity(entity, SpawnReason.CUSTOM); return (FallingBlock) entity.getBukkitEntity(); } - public FallingBlock spawnFallingBlock(Location location, int blockId, byte blockData) throws IllegalArgumentException { - return spawnFallingBlock(location, org.bukkit.Material.getMaterial(blockId), blockData); + @Override + public FallingBlock spawnFallingBlock(Location location, BlockData data) throws IllegalArgumentException { + Validate.notNull(location, "Location cannot be null"); + Validate.notNull(data, "Material cannot be null"); + + EntityFallingBlock entity = new EntityFallingBlock(world, location.getX(), location.getY(), location.getZ(), ((CraftBlockData) data).getState()); + entity.ticksLived = 1; + + world.addEntity(entity, SpawnReason.CUSTOM); + return (FallingBlock) entity.getBukkitEntity(); } @SuppressWarnings("unchecked") @@ -923,6 +916,8 @@ public class CraftWorld implements World { ((EntityTippedArrow) entity).setType(CraftPotionUtil.fromBukkit(new PotionData(PotionType.WATER, false, false))); } else if (SpectralArrow.class.isAssignableFrom(clazz)) { entity = new EntitySpectralArrow(world); + } else if (Trident.class.isAssignableFrom(clazz)) { + entity = new EntityThrownTrident(world); } else { entity = new EntityTippedArrow(world); } @@ -1060,6 +1055,8 @@ public class CraftWorld implements World { entity = new EntityZombieHusk(world); } else if (ZombieVillager.class.isAssignableFrom(clazz)) { entity = new EntityZombieVillager(world); + } else if (Drowned.class.isAssignableFrom(clazz)) { + entity = new EntityDrowned(world); } else { entity = new EntityZombie(world); } @@ -1111,6 +1108,22 @@ public class CraftWorld implements World { } else if (Vindicator.class.isAssignableFrom(clazz)) { entity = new EntityVindicator(world); } + } else if (Turtle.class.isAssignableFrom(clazz)) { + entity = new EntityTurtle(world); + } else if (Phantom.class.isAssignableFrom(clazz)) { + entity = new EntityPhantom(world); + } else if (Fish.class.isAssignableFrom(clazz)) { + if (Cod.class.isAssignableFrom(clazz)) { + entity = new EntityCod(world); + } else if (PufferFish.class.isAssignableFrom(clazz)) { + entity = new EntityPufferFish(world); + } else if (Salmon.class.isAssignableFrom(clazz)) { + entity = new EntitySalmon(world); + } else if (TropicalFish.class.isAssignableFrom(clazz)) { + entity = new EntityTropicalFish(world); + } + } else if (Dolphin.class.isAssignableFrom(clazz)) { + entity = new EntityDolphin(world); } if (entity != null) { @@ -1118,7 +1131,6 @@ public class CraftWorld implements World { entity.setHeadRotation(yaw); // SPIGOT-3587 } } else if (Hanging.class.isAssignableFrom(clazz)) { - Block block = getBlockAt(location); BlockFace face = BlockFace.SELF; int width = 16; // 1 full block, also painting smallest size. @@ -1135,8 +1147,8 @@ public class CraftWorld implements World { BlockFace[] faces = new BlockFace[]{BlockFace.EAST, BlockFace.NORTH, BlockFace.WEST, BlockFace.SOUTH}; final BlockPosition pos = new BlockPosition((int) x, (int) y, (int) z); for (BlockFace dir : faces) { - net.minecraft.server.Block nmsBlock = CraftMagicNumbers.getBlock(block.getRelative(dir)); - if (nmsBlock.getBlockData().getMaterial().isBuildable() || BlockDiodeAbstract.isDiode(nmsBlock.getBlockData())) { + IBlockData nmsBlock = world.getType(pos.shift(CraftBlock.blockFaceToNotch(dir))); + if (nmsBlock.getMaterial().isBuildable() || BlockDiodeAbstract.isDiode(nmsBlock)) { boolean taken = false; AxisAlignedBB bb = EntityHanging.calculateBoundingBox(null, pos, CraftBlock.blockFaceToNotch(dir).opposite(), width, height); List list = (List) world.getEntities(null, bb); @@ -1207,7 +1219,7 @@ public class CraftWorld implements World { Preconditions.checkArgument(entity != null, "Cannot spawn null entity"); if (entity instanceof EntityInsentient) { - ((EntityInsentient) entity).prepare(getHandle().D(new BlockPosition(entity)), (GroupDataEntity) null); + ((EntityInsentient) entity).prepare(getHandle().getDamageScaler(new BlockPosition(entity)), (GroupDataEntity) null, null); } if (function != null) { @@ -1428,12 +1440,18 @@ public class CraftWorld implements World { double y = loc.getY(); double z = loc.getZ(); - PacketPlayOutCustomSoundEffect packet = new PacketPlayOutCustomSoundEffect(sound, SoundCategory.valueOf(category.name()), x, y, z, volume, pitch); + PacketPlayOutCustomSoundEffect packet = new PacketPlayOutCustomSoundEffect(new MinecraftKey(sound), SoundCategory.valueOf(category.name()), new Vec3D(x, y, z), volume, pitch); world.getMinecraftServer().getPlayerList().sendPacketNearby(null, x, y, z, volume > 1.0F ? 16.0F * volume : 16.0D, this.world.dimension, packet); } public String getGameRuleValue(String rule) { - return getHandle().getGameRules().get(rule); + // In method contract for some reason + if (rule == null) { + return null; + } + + GameRules.GameRuleValue value = getHandle().getGameRules().get(rule); + return value != null ? value.a() : ""; } public boolean setGameRuleValue(String rule, String value) { @@ -1442,16 +1460,16 @@ public class CraftWorld implements World { if (!isGameRule(rule)) return false; - getHandle().getGameRules().set(rule, value); + getHandle().getGameRules().set(rule, value, getHandle().getMinecraftServer()); return true; } public String[] getGameRules() { - return getHandle().getGameRules().getGameRules(); + return GameRules.getGameRules().keySet().toArray(new String[GameRules.getGameRules().size()]); } public boolean isGameRule(String rule) { - return getHandle().getGameRules().contains(rule); + return GameRules.getGameRules().containsKey(rule); } @Override @@ -1525,14 +1543,11 @@ public class CraftWorld implements World { } getHandle().sendParticles( null, // Sender - CraftParticle.toNMS(particle), // Particle - true, // Extended range + CraftParticle.toNMS(particle, data), // Particle x, y, z, // Position count, // Count offsetX, offsetY, offsetZ, // Random offset - extra, // Speed? - CraftParticle.toData(particle, data) - + extra // Speed? ); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/Main.java b/paper-server/src/main/java/org/bukkit/craftbukkit/Main.java index f4e1ca79ee..e8bf55e89b 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/Main.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/Main.java @@ -145,6 +145,12 @@ public class Main { return; } + float javaVersion = Float.parseFloat(System.getProperty("java.class.version")); + if (javaVersion > 55.0) { + System.err.println("Unsupported Java detected (" + javaVersion + "). Only up to Java 11 is supported."); + return; + } + try { // This trick bypasses Maven Shade's clever rewriting of our getProperty call when using String literals String jline_UnsupportedTerminal = new String(new char[] {'j','l','i','n','e','.','U','n','s','u','p','p','o','r','t','e','d','T','e','r','m','i','n','a','l'}); @@ -169,11 +175,11 @@ public class Main { useConsole = false; } - if (false && Main.class.getPackage().getImplementationVendor() != null && System.getProperty("IReallyKnowWhatIAmDoingISwear") == null) { + if (Main.class.getPackage().getImplementationVendor() != null && System.getProperty("IReallyKnowWhatIAmDoingISwear") == null) { Date buildDate = new SimpleDateFormat("yyyyMMdd-HHmm").parse(Main.class.getPackage().getImplementationVendor()); Calendar deadline = Calendar.getInstance(); - deadline.add(Calendar.DAY_OF_YEAR, -14); + deadline.add(Calendar.DAY_OF_YEAR, -3); if (buildDate.before(deadline.getTime())) { System.err.println("*** Error, this build is outdated ***"); System.err.println("*** Please download a new build as per instructions from https://www.spigotmc.org/ ***"); @@ -182,6 +188,8 @@ public class Main { } } + System.err.println("*** WARNING: This is a development build. It is not meant for production server usage! Please keep backups and update frequently."); + System.out.println("Loading libraries, please wait..."); MinecraftServer.main(options); } catch (Throwable t) { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBanner.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBanner.java index e2c9a9b77e..6672e80459 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBanner.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBanner.java @@ -30,7 +30,7 @@ public class CraftBanner extends CraftBlockEntityState impleme public void load(TileEntityBanner banner) { super.load(banner); - base = DyeColor.getByDyeData((byte) banner.color.getInvColorIndex()); + base = DyeColor.getByWoolData((byte) banner.color.getColorIndex()); patterns = new ArrayList(); if (banner.patterns != null) { @@ -90,7 +90,7 @@ public class CraftBanner extends CraftBlockEntityState impleme public void applyTo(TileEntityBanner banner) { super.applyTo(banner); - banner.color = EnumColor.fromInvColorIndex(base.getDyeData()); + banner.color = EnumColor.fromColorIndex(base.getWoolData()); NBTTagList newPatterns = new NBTTagList(); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java index afec900c67..5b908d3bf5 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java @@ -10,6 +10,7 @@ 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; @@ -87,11 +88,11 @@ public class CraftBeacon extends CraftContainer implements Bea @Override public String getCustomName() { TileEntityBeacon beacon = this.getSnapshot(); - return beacon.hasCustomName() ? beacon.getName() : null; + return beacon.hasCustomName() ? CraftChatMessage.fromComponent(beacon.getCustomName()) : null; } @Override public void setCustomName(String name) { - this.getSnapshot().setCustomName(name); + this.getSnapshot().setCustomName(CraftChatMessage.fromStringOrNull(name)); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBed.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBed.java index 27756d8587..e91497d855 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBed.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBed.java @@ -10,8 +10,6 @@ import org.bukkit.block.Block; public class CraftBed extends CraftBlockEntityState implements Bed { - private DyeColor color; - public CraftBed(Block block) { super(block, TileEntityBed.class); } @@ -20,29 +18,48 @@ public class CraftBed extends CraftBlockEntityState implements Be super(material, te); } - @Override - public void load(TileEntityBed bed) { - super.load(bed); - - color = DyeColor.getByWoolData((byte) bed.a().getColorIndex()); - } - @Override public DyeColor getColor() { - return color; + switch (getType()) { + case BLACK_BED: + return DyeColor.BLACK; + case BLUE_BED: + return DyeColor.BLUE; + case BROWN_BED: + return DyeColor.BROWN; + case CYAN_BED: + return DyeColor.CYAN; + case GRAY_BED: + return DyeColor.GRAY; + case GREEN_BED: + return DyeColor.GREEN; + case LIGHT_BLUE_BED: + return DyeColor.LIGHT_BLUE; + case LIGHT_GRAY_BED: + return DyeColor.SILVER; + case LIME_BED: + return DyeColor.LIME; + case MAGENTA_BED: + return DyeColor.MAGENTA; + case ORANGE_BED: + return DyeColor.ORANGE; + case PINK_BED: + return DyeColor.PINK; + case PURPLE_BED: + return DyeColor.PURPLE; + case RED_BED: + return DyeColor.RED; + case WHITE_BED: + return DyeColor.WHITE; + case YELLOW_BED: + return DyeColor.YELLOW; + default: + throw new IllegalArgumentException("Unknown DyeColor for " + getType()); + } } @Override public void setColor(DyeColor color) { - Preconditions.checkArgument(color != null, "color"); - - this.color = color; - } - - @Override - public void applyTo(TileEntityBed bed) { - super.applyTo(bed); - - bed.a(EnumColor.fromColorIndex(color.getWoolData())); + throw new UnsupportedOperationException("Must set block type to appropriate bed colour"); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java index 46670c3466..bfed2d988a 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java @@ -1,5 +1,6 @@ package org.bukkit.craftbukkit.block; +import com.google.common.base.Preconditions; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -16,7 +17,10 @@ import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.block.BlockState; import org.bukkit.block.PistonMoveReaction; +import org.bukkit.block.data.BlockData; import org.bukkit.craftbukkit.CraftChunk; +import org.bukkit.craftbukkit.CraftWorld; +import org.bukkit.craftbukkit.block.data.CraftBlockData; import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.craftbukkit.util.CraftMagicNumbers; import org.bukkit.inventory.ItemStack; @@ -25,40 +29,44 @@ import org.bukkit.plugin.Plugin; import org.bukkit.util.BlockVector; public class CraftBlock implements Block { - private final CraftChunk chunk; - private final int x; - private final int y; - private final int z; + private final net.minecraft.server.GeneratorAccess world; + private final BlockPosition position; - public CraftBlock(CraftChunk chunk, int x, int y, int z) { - this.x = x; - this.y = y; - this.z = z; - this.chunk = chunk; + public CraftBlock(GeneratorAccess world, BlockPosition position) { + this.world = world; + this.position = position; + } + + public static CraftBlock at(GeneratorAccess world, BlockPosition position) { + return new CraftBlock(world, position); } private net.minecraft.server.Block getNMSBlock() { - return CraftMagicNumbers.getBlock(this); // TODO: UPDATE THIS + return getNMS().getBlock(); } - private static net.minecraft.server.Block getNMSBlock(int type) { - return CraftMagicNumbers.getBlock(type); + protected net.minecraft.server.IBlockData getNMS() { + return world.getType(position); } public World getWorld() { - return chunk.getWorld(); + return world.getMinecraftWorld().getWorld(); + } + + public CraftWorld getCraftWorld() { + return (CraftWorld) getWorld(); } public Location getLocation() { - return new Location(getWorld(), x, y, z); + return new Location(getWorld(), position.getX(), position.getY(), position.getZ()); } public Location getLocation(Location loc) { if (loc != null) { loc.setWorld(getWorld()); - loc.setX(x); - loc.setY(y); - loc.setZ(z); + loc.setX(position.getX()); + loc.setY(position.getY()); + loc.setZ(position.getZ()); loc.setYaw(0); loc.setPitch(0); } @@ -67,23 +75,23 @@ public class CraftBlock implements Block { } public BlockVector getVector() { - return new BlockVector(x, y, z); + return new BlockVector(getX(), getY(), getZ()); } public int getX() { - return x; + return position.getX(); } public int getY() { - return y; + return position.getY(); } public int getZ() { - return z; + return position.getZ(); } public Chunk getChunk() { - return chunk; + return getWorld().getChunkAt(this); } public void setData(final byte data) { @@ -99,19 +107,21 @@ public class CraftBlock implements Block { } private void setData(final byte data, int flag) { - net.minecraft.server.World world = chunk.getHandle().getWorld(); - BlockPosition position = new BlockPosition(x, y, z); - IBlockData blockData = world.getType(position); - world.setTypeAndData(position, blockData.getBlock().fromLegacyData(data), flag); + world.setTypeAndData(position, CraftMagicNumbers.getBlock(getType(), data), flag); } private IBlockData getData0() { - return chunk.getHandle().getBlockData(new BlockPosition(x, y, z)); + return world.getType(position); } public byte getData() { - IBlockData blockData = chunk.getHandle().getBlockData(new BlockPosition(x, y, z)); - return (byte) blockData.getBlock().toLegacyData(blockData); + IBlockData blockData = world.getType(position); + return CraftMagicNumbers.toLegacyData(blockData); + } + + @Override + public BlockData getBlockData() { + return CraftBlockData.fromData(getData0()); } public void setType(final Material type) { @@ -120,34 +130,36 @@ public class CraftBlock implements Block { @Override public void setType(Material type, boolean applyPhysics) { - setTypeId(type.getId(), applyPhysics); + setTypeAndData(type, (byte) 0, applyPhysics); } - public boolean setTypeId(final int type) { - return setTypeId(type, true); + @Override + public void setBlockData(BlockData data) { + setBlockData(data, true); } - public boolean setTypeId(final int type, final boolean applyPhysics) { - net.minecraft.server.Block block = getNMSBlock(type); - return setTypeIdAndData(type, (byte) block.toLegacyData(block.getBlockData()), applyPhysics); + @Override + public void setBlockData(BlockData data, boolean applyPhysics) { + setTypeAndData(((CraftBlockData) data).getState(), applyPhysics); } - public boolean setTypeIdAndData(final int type, final byte data, final boolean applyPhysics) { - IBlockData blockData = getNMSBlock(type).fromLegacyData(data); - BlockPosition position = new BlockPosition(x, y, z); + public boolean setTypeAndData(final Material type, final byte data, final boolean applyPhysics) { + return setTypeAndData(CraftMagicNumbers.getBlock(type, data), applyPhysics); + } + 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 (type != 0 && blockData.getBlock() instanceof BlockTileEntity && type != getTypeId()) { - chunk.getHandle().getWorld().setTypeAndData(position, Blocks.AIR.getBlockData(), 0); + if (!blockData.isAir() && blockData.getBlock() instanceof BlockTileEntity && blockData.getBlock() != getNMSBlock()) { + world.setTypeAndData(position, Blocks.AIR.getBlockData(), 0); } if (applyPhysics) { - return chunk.getHandle().getWorld().setTypeAndData(position, blockData, 3); + return world.setTypeAndData(position, blockData, 3); } else { - IBlockData old = chunk.getHandle().getBlockData(position); - boolean success = chunk.getHandle().getWorld().setTypeAndData(position, blockData, 18); // NOTIFY | NO_OBSERVER + IBlockData old = world.getType(position); + boolean success = world.setTypeAndData(position, blockData, 18); // NOTIFY | NO_OBSERVER if (success) { - chunk.getHandle().getWorld().notify( + world.getMinecraftWorld().notify( position, old, blockData, @@ -159,25 +171,19 @@ public class CraftBlock implements Block { } public Material getType() { - return Material.getMaterial(getTypeId()); - } - - @Deprecated - @Override - public int getTypeId() { - return CraftMagicNumbers.getId(chunk.getHandle().getBlockData(new BlockPosition(this.x, this.y, this.z)).getBlock()); + return CraftMagicNumbers.getMaterial(world.getType(position).getBlock()); } public byte getLightLevel() { - return (byte) chunk.getHandle().getWorld().getLightLevel(new BlockPosition(this.x, this.y, this.z)); + return (byte) world.getMinecraftWorld().getLightLevel(position); } public byte getLightFromSky() { - return (byte) chunk.getHandle().getWorld().getBrightness(EnumSkyBlock.SKY, new BlockPosition(this.x, this.y, this.z)); + return (byte) world.getBrightness(EnumSkyBlock.SKY, position); } public byte getLightFromBlocks() { - return (byte) chunk.getHandle().getWorld().getBrightness(EnumSkyBlock.BLOCK, new BlockPosition(this.x, this.y, this.z)); + return (byte) world.getBrightness(EnumSkyBlock.BLOCK, position); } @@ -218,7 +224,7 @@ public class CraftBlock implements Block { @Override public String toString() { - return "CraftBlock{" + "chunk=" + chunk + ",x=" + x + ",y=" + y + ",z=" + z + ",type=" + getType() + ",data=" + getData() + '}'; + return "CraftBlock{pos=" + position + ",type=" + getType() + ",data=" + getData() + '}'; } public static BlockFace notchToBlockFace(EnumDirection notch) { @@ -265,13 +271,11 @@ public class CraftBlock implements Block { switch (material) { case SIGN: - case SIGN_POST: case WALL_SIGN: return new CraftSign(this); case CHEST: case TRAPPED_CHEST: return new CraftChest(this); - case BURNING_FURNACE: case FURNACE: return new CraftFurnace(this); case DISPENSER: @@ -282,28 +286,65 @@ public class CraftBlock implements Block { return new CraftEndGateway(this); case HOPPER: return new CraftHopper(this); - case MOB_SPAWNER: + case SPAWNER: return new CraftCreatureSpawner(this); - case NOTE_BLOCK: - return new CraftNoteBlock(this); case JUKEBOX: return new CraftJukebox(this); case BREWING_STAND: return new CraftBrewingStand(this); - case SKULL: + case CREEPER_HEAD: + case CREEPER_WALL_HEAD: + case DRAGON_HEAD: + case DRAGON_WALL_HEAD: + case PISTON_HEAD: + case PLAYER_HEAD: + case PLAYER_WALL_HEAD: + case SKELETON_SKULL: + case SKELETON_WALL_SKULL: + case WITHER_SKELETON_SKULL: + case WITHER_SKELETON_WALL_SKULL: + case ZOMBIE_HEAD: + case ZOMBIE_WALL_HEAD: return new CraftSkull(this); - case COMMAND: - case COMMAND_CHAIN: - case COMMAND_REPEATING: + case COMMAND_BLOCK: + case CHAIN_COMMAND_BLOCK: + case REPEATING_COMMAND_BLOCK: return new CraftCommandBlock(this); case BEACON: return new CraftBeacon(this); - case BANNER: - case WALL_BANNER: - case STANDING_BANNER: + case BLACK_BANNER: + case BLACK_WALL_BANNER: + case BLUE_BANNER: + case BLUE_WALL_BANNER: + case BROWN_BANNER: + case BROWN_WALL_BANNER: + case CYAN_BANNER: + case CYAN_WALL_BANNER: + case GRAY_BANNER: + case GRAY_WALL_BANNER: + case GREEN_BANNER: + case GREEN_WALL_BANNER: + case LIGHT_BLUE_BANNER: + case LIGHT_BLUE_WALL_BANNER: + case LIGHT_GRAY_BANNER: + case LIGHT_GRAY_WALL_BANNER: + case LIME_BANNER: + case LIME_WALL_BANNER: + case MAGENTA_BANNER: + case MAGENTA_WALL_BANNER: + case ORANGE_BANNER: + case ORANGE_WALL_BANNER: + case PINK_BANNER: + case PINK_WALL_BANNER: + case PURPLE_BANNER: + case PURPLE_WALL_BANNER: + case RED_BANNER: + case RED_WALL_BANNER: + case WHITE_BANNER: + case WHITE_WALL_BANNER: + case YELLOW_BANNER: + case YELLOW_WALL_BANNER: return new CraftBanner(this); - case FLOWER_POT: - return new CraftFlowerPot(this); case STRUCTURE_BLOCK: return new CraftStructureBlock(this); case WHITE_SHULKER_BOX: @@ -314,7 +355,7 @@ public class CraftBlock implements Block { case LIME_SHULKER_BOX: case PINK_SHULKER_BOX: case GRAY_SHULKER_BOX: - case SILVER_SHULKER_BOX: + case LIGHT_GRAY_SHULKER_BOX: case CYAN_SHULKER_BOX: case PURPLE_SHULKER_BOX: case BLUE_SHULKER_BOX: @@ -323,20 +364,35 @@ public class CraftBlock implements Block { case RED_SHULKER_BOX: case BLACK_SHULKER_BOX: return new CraftShulkerBox(this); - case ENCHANTMENT_TABLE: + case ENCHANTING_TABLE: return new CraftEnchantingTable(this); case ENDER_CHEST: return new CraftEnderChest(this); case DAYLIGHT_DETECTOR: - case DAYLIGHT_DETECTOR_INVERTED: return new CraftDaylightDetector(this); - case REDSTONE_COMPARATOR_OFF: - case REDSTONE_COMPARATOR_ON: + case COMPARATOR: return new CraftComparator(this); - case BED_BLOCK: + case BLACK_BED: + case BLUE_BED: + case BROWN_BED: + case CYAN_BED: + case GRAY_BED: + case GREEN_BED: + case LIGHT_BLUE_BED: + case LIGHT_GRAY_BED: + case LIME_BED: + case MAGENTA_BED: + case ORANGE_BED: + case PINK_BED: + case PURPLE_BED: + case RED_BED: + case WHITE_BED: + case YELLOW_BED: return new CraftBed(this); + case CONDUIT: + return new CraftConduit(this); default: - TileEntity tileEntity = chunk.getCraftWorld().getTileEntityAt(x, y, z); + TileEntity tileEntity = world.getTileEntity(position); if (tileEntity != null) { // block with unhandled TileEntity: return new CraftBlockEntityState(this, (Class) tileEntity.getClass()); @@ -348,11 +404,11 @@ public class CraftBlock implements Block { } public Biome getBiome() { - return getWorld().getBiome(x, z); + return getWorld().getBiome(getX(), getZ()); } public void setBiome(Biome bio) { - getWorld().setBiome(x, z, bio); + getWorld().setBiome(getX(), getZ(), bio); } public static Biome biomeBaseToBiome(BiomeBase base) { @@ -372,19 +428,19 @@ public class CraftBlock implements Block { } public double getTemperature() { - return getWorld().getTemperature(x, z); + return getWorld().getTemperature(getX(), getZ()); } public double getHumidity() { - return getWorld().getHumidity(x, z); + return getWorld().getHumidity(getX(), getZ()); } public boolean isBlockPowered() { - return chunk.getHandle().getWorld().getBlockPower(new BlockPosition(x, y, z)) > 0; + return world.getMinecraftWorld().getBlockPower(position) > 0; } public boolean isBlockIndirectlyPowered() { - return chunk.getHandle().getWorld().isBlockIndirectlyPowered(new BlockPosition(x, y, z)); + return world.getMinecraftWorld().isBlockIndirectlyPowered(position); } @Override @@ -393,20 +449,20 @@ public class CraftBlock implements Block { if (!(o instanceof CraftBlock)) return false; CraftBlock other = (CraftBlock) o; - return this.x == other.x && this.y == other.y && this.z == other.z && this.getWorld().equals(other.getWorld()); + return this.position.equals(other.position) && this.getWorld().equals(other.getWorld()); } @Override public int hashCode() { - return this.y << 24 ^ this.x ^ this.z ^ this.getWorld().hashCode(); + return this.position.hashCode() ^ this.getWorld().hashCode(); } public boolean isBlockFacePowered(BlockFace face) { - return chunk.getHandle().getWorld().isBlockFacePowered(new BlockPosition(x, y, z), blockFaceToNotch(face)); + return world.getMinecraftWorld().isBlockFacePowered(position, blockFaceToNotch(face)); } public boolean isBlockFaceIndirectlyPowered(BlockFace face) { - int power = chunk.getHandle().getWorld().getBlockFacePower(new BlockPosition(x, y, z), blockFaceToNotch(face)); + int power = world.getMinecraftWorld().getBlockFacePower(position, blockFaceToNotch(face)); Block relative = getRelative(face); if (relative.getType() == Material.REDSTONE_WIRE) { @@ -418,8 +474,11 @@ public class CraftBlock implements Block { public int getBlockPower(BlockFace face) { int power = 0; - BlockRedstoneWire wire = Blocks.REDSTONE_WIRE; - net.minecraft.server.World world = chunk.getHandle().getWorld(); + BlockRedstoneWire wire = (BlockRedstoneWire) Blocks.REDSTONE_WIRE; + net.minecraft.server.World world = this.world.getMinecraftWorld(); + int x = getX(); + int y = getY(); + int z = getZ(); if ((face == BlockFace.DOWN || face == BlockFace.SELF) && world.isBlockFacePowered(new BlockPosition(x, y - 1, z), EnumDirection.DOWN)) power = wire.getPower(world, new BlockPosition(x, y - 1, z), power); if ((face == BlockFace.UP || face == BlockFace.SELF) && world.isBlockFacePowered(new BlockPosition(x, y + 1, z), EnumDirection.UP)) power = wire.getPower(world, new BlockPosition(x, y + 1, z), power); if ((face == BlockFace.EAST || face == BlockFace.SELF) && world.isBlockFacePowered(new BlockPosition(x + 1, y, z), EnumDirection.EAST)) power = wire.getPower(world, new BlockPosition(x + 1, y, z), power); @@ -438,31 +497,30 @@ public class CraftBlock implements Block { } public boolean isLiquid() { - return (getType() == Material.WATER) || (getType() == Material.STATIONARY_WATER) || (getType() == Material.LAVA) || (getType() == Material.STATIONARY_LAVA); + return (getType() == Material.WATER) || (getType() == Material.LAVA); } public PistonMoveReaction getPistonMoveReaction() { - return PistonMoveReaction.getById(getNMSBlock().h(getNMSBlock().fromLegacyData(getData())).ordinal()); + return PistonMoveReaction.getById(getNMS().getPushReaction().ordinal()); } private boolean itemCausesDrops(ItemStack item) { net.minecraft.server.Block block = this.getNMSBlock(); - net.minecraft.server.Item itemType = item != null ? net.minecraft.server.Item.getById(item.getTypeId()) : null; + 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() { // Order matters here, need to drop before setting to air so skulls can get their data net.minecraft.server.Block block = this.getNMSBlock(); - byte data = getData(); boolean result = false; if (block != null && block != Blocks.AIR) { - block.dropNaturally(chunk.getHandle().getWorld(), new BlockPosition(x, y, z), block.fromLegacyData(data), 1.0F, 0); + block.dropNaturally(getNMS(), world.getMinecraftWorld(), position, 1.0F, 0); result = true; } - setTypeId(Material.AIR.getId()); + setType(Material.AIR); return result; } @@ -470,7 +528,7 @@ public class CraftBlock implements Block { if (itemCausesDrops(item)) { return breakNaturally(); } else { - return setTypeId(Material.AIR.getId()); + return setTypeAndData(Material.AIR, (byte) 0, true); } } @@ -481,21 +539,20 @@ public class CraftBlock implements Block { if (block != Blocks.AIR) { IBlockData data = getData0(); // based on nms.Block.dropNaturally - int count = block.getDropCount(0, chunk.getHandle().getWorld().random); + int count = block.getDropCount(data, 0, world.getMinecraftWorld(), position, world.getMinecraftWorld().random); for (int i = 0; i < count; ++i) { - Item item = block.getDropType(data, chunk.getHandle().getWorld().random, 0); - if (item != Items.a) { + 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 (Blocks.SKULL == block) { - net.minecraft.server.ItemStack nmsStack = new net.minecraft.server.ItemStack(item, 1, block.getDropData(data)); - TileEntitySkull tileentityskull = (TileEntitySkull) chunk.getHandle().getWorld().getTileEntity(new BlockPosition(x, y, z)); + if (block instanceof BlockSkullAbstract) { + net.minecraft.server.ItemStack nmsStack = block.a((IBlockAccess) world, position, data); + TileEntitySkull tileentityskull = (TileEntitySkull) world.getTileEntity(position); - if (tileentityskull.getSkullType() == 3 && tileentityskull.getGameProfile() != null) { - nmsStack.setTag(new NBTTagCompound()); + if ((block == Blocks.PLAYER_HEAD || block == Blocks.PLAYER_WALL_HEAD) && tileentityskull.getGameProfile() != null) { NBTTagCompound nbttagcompound = new NBTTagCompound(); GameProfileSerializer.serialize(nbttagcompound, tileentityskull.getGameProfile()); - nmsStack.getTag().set("SkullOwner", nbttagcompound); + nmsStack.getOrCreateTag().set("SkullOwner", nbttagcompound); } drops.add(CraftItemStack.asBukkitCopy(nmsStack)); @@ -504,10 +561,10 @@ public class CraftBlock implements 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.INK_SACK, 1, (short) 3)); + drops.add(new ItemStack(Material.COCOA_BEANS, 1)); } } else { - drops.add(new ItemStack(org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(item), 1, (short) block.getDropData(data))); + drops.add(new ItemStack(org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(item), 1)); } } } @@ -524,18 +581,18 @@ public class CraftBlock implements Block { } public void setMetadata(String metadataKey, MetadataValue newMetadataValue) { - chunk.getCraftWorld().getBlockMetadata().setMetadata(this, metadataKey, newMetadataValue); + getCraftWorld().getBlockMetadata().setMetadata(this, metadataKey, newMetadataValue); } public List getMetadata(String metadataKey) { - return chunk.getCraftWorld().getBlockMetadata().getMetadata(this, metadataKey); + return getCraftWorld().getBlockMetadata().getMetadata(this, metadataKey); } public boolean hasMetadata(String metadataKey) { - return chunk.getCraftWorld().getBlockMetadata().hasMetadata(this, metadataKey); + return getCraftWorld().getBlockMetadata().hasMetadata(this, metadataKey); } public void removeMetadata(String metadataKey, Plugin owningPlugin) { - chunk.getCraftWorld().getBlockMetadata().removeMetadata(this, metadataKey, owningPlugin); + getCraftWorld().getBlockMetadata().removeMetadata(this, metadataKey, owningPlugin); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java index 8328ed0052..ac9b4297b2 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java @@ -3,6 +3,7 @@ package org.bukkit.craftbukkit.block; import net.minecraft.server.BlockPosition; import net.minecraft.server.NBTTagCompound; import net.minecraft.server.TileEntity; +import net.minecraft.server.World; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.craftbukkit.CraftWorld; @@ -23,7 +24,7 @@ public class CraftBlockEntityState extends CraftBlockState this.tileEntity = tileEntityClass.cast(world.getTileEntityAt(this.getX(), this.getY(), this.getZ())); // copy tile entity data: - this.snapshot = this.createSnapshot(tileEntity); + this.snapshot = this.createSnapshot(tileEntity, world.getHandle()); this.load(snapshot); } @@ -34,17 +35,17 @@ public class CraftBlockEntityState extends CraftBlockState this.tileEntity = tileEntity; // copy tile entity data: - this.snapshot = this.createSnapshot(tileEntity); + this.snapshot = this.createSnapshot(tileEntity, null); this.load(snapshot); } - private T createSnapshot(T tileEntity) { + private T createSnapshot(T tileEntity, World world) { if (tileEntity == null) { return null; } NBTTagCompound nbtTagCompound = tileEntity.save(new NBTTagCompound()); - T snapshot = (T) TileEntity.create(null, nbtTagCompound); + T snapshot = (T) TileEntity.create(nbtTagCompound, world); return snapshot; } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java index 2a1b731c0c..08f73c8f40 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java @@ -7,8 +7,10 @@ import org.bukkit.Chunk; import org.bukkit.Material; import org.bukkit.World; import org.bukkit.block.BlockState; +import org.bukkit.block.data.BlockData; import org.bukkit.craftbukkit.CraftChunk; import org.bukkit.craftbukkit.CraftWorld; +import org.bukkit.craftbukkit.block.data.CraftBlockData; import org.bukkit.craftbukkit.util.CraftMagicNumbers; import org.bukkit.material.Attachable; import org.bukkit.material.MaterialData; @@ -16,6 +18,7 @@ import org.bukkit.metadata.MetadataValue; import org.bukkit.plugin.Plugin; import java.util.List; +import net.minecraft.server.GeneratorAccess; import net.minecraft.server.IBlockData; public class CraftBlockState implements BlockState { @@ -24,8 +27,7 @@ public class CraftBlockState implements BlockState { private final int x; private final int y; private final int z; - protected int type; - protected MaterialData data; + protected IBlockData data; protected int flag; public CraftBlockState(final Block block) { @@ -33,11 +35,9 @@ public class CraftBlockState implements BlockState { this.x = block.getX(); this.y = block.getY(); this.z = block.getZ(); - this.type = block.getTypeId(); + this.data = ((CraftBlock) block).getNMS(); this.chunk = (CraftChunk) block.getChunk(); this.flag = 3; - - createData(block.getData()); } public CraftBlockState(final Block block, int flag) { @@ -47,17 +47,17 @@ public class CraftBlockState implements BlockState { public CraftBlockState(Material material) { world = null; - type = material.getId(); + data = CraftMagicNumbers.getBlock(material).getBlockData(); chunk = null; x = y = z = 0; } - public static CraftBlockState getBlockState(net.minecraft.server.World world, int x, int y, int z) { - return new CraftBlockState(world.getWorld().getBlockAt(x, y, z)); + public static CraftBlockState getBlockState(GeneratorAccess world, net.minecraft.server.BlockPosition pos) { + return new CraftBlockState(CraftBlock.at(world, pos)); } - public static CraftBlockState getBlockState(net.minecraft.server.World world, int x, int y, int z, int flag) { - return new CraftBlockState(world.getWorld().getBlockAt(x, y, z), flag); + public static CraftBlockState getBlockState(net.minecraft.server.World world, net.minecraft.server.BlockPosition pos, int flag) { + return new CraftBlockState(world.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()), flag); } public World getWorld() { @@ -82,14 +82,32 @@ public class CraftBlockState implements BlockState { return chunk; } + public void setData(IBlockData data) { + this.data = data; + } + + public IBlockData getHandle() { + return this.data; + } + + @Override + public BlockData getBlockData() { + return CraftBlockData.fromData(data); + } + + @Override + public void setBlockData(BlockData data) { + this.data = ((CraftBlockData) data).getState(); + } + public void setData(final MaterialData data) { Material mat = getType(); if ((mat == null) || (mat.getData() == null)) { - this.data = data; + this.data = CraftMagicNumbers.getBlock(data); } else { if ((data.getClass() == mat.getData()) || (data.getClass() == MaterialData.class)) { - this.data = data; + this.data = CraftMagicNumbers.getBlock(data); } else { throw new IllegalArgumentException("Provided data is not of type " + mat.getData().getName() + ", found " + data.getClass().getName()); @@ -98,24 +116,17 @@ public class CraftBlockState implements BlockState { } public MaterialData getData() { - return data; + return CraftMagicNumbers.getMaterial(data); } public void setType(final Material type) { - setTypeId(type.getId()); - } - - public boolean setTypeId(final int type) { - if (this.type != type) { - this.type = type; - - createData((byte) 0); + if (this.getType() != type) { + this.data = CraftMagicNumbers.getBlock(type).getBlockData(); } - return true; } public Material getType() { - return Material.getMaterial(getTypeId()); + return CraftMagicNumbers.getMaterial(data.getBlock()); } public void setFlag(int flag) { @@ -126,17 +137,13 @@ public class CraftBlockState implements BlockState { return flag; } - public int getTypeId() { - return type; - } - public byte getLightLevel() { return getBlock().getLightLevel(); } - public Block getBlock() { + public CraftBlock getBlock() { requirePlaced(); - return world.getBlockAt(x, y, z); + return (CraftBlock) world.getBlockAt(x, y, z); } public boolean update() { @@ -151,7 +158,7 @@ public class CraftBlockState implements BlockState { if (!isPlaced()) { return true; } - Block block = getBlock(); + CraftBlock block = getBlock(); if (block.getType() != getType()) { if (!force) { @@ -160,34 +167,25 @@ public class CraftBlockState implements BlockState { } BlockPosition pos = new BlockPosition(x, y, z); - IBlockData newBlock = CraftMagicNumbers.getBlock(getType()).fromLegacyData(getRawData()); - block.setTypeIdAndData(getTypeId(), getRawData(), applyPhysics); + IBlockData newBlock = this.data; + block.setTypeAndData(newBlock, applyPhysics); world.getHandle().notify( pos, - CraftMagicNumbers.getBlock(block).fromLegacyData(block.getData()), + block.getNMS(), newBlock, 3 ); // Update levers etc if (applyPhysics && getData() instanceof Attachable) { - world.getHandle().applyPhysics(pos.shift(CraftBlock.blockFaceToNotch(((Attachable) getData()).getAttachedFace())), newBlock.getBlock(), false); + world.getHandle().applyPhysics(pos.shift(CraftBlock.blockFaceToNotch(((Attachable) getData()).getAttachedFace())), newBlock.getBlock()); } return true; } - private void createData(final byte data) { - Material mat = getType(); - if (mat == null || mat.getData() == null) { - this.data = new MaterialData(type, data); - } else { - this.data = mat.getNewData(data); - } - } - public byte getRawData() { - return data.getData(); + return CraftMagicNumbers.toLegacyData(data); } public Location getLocation() { @@ -208,7 +206,7 @@ public class CraftBlockState implements BlockState { } public void setRawData(byte data) { - this.data.setData(data); + this.data = CraftMagicNumbers.getBlock(getType(), data); } @Override @@ -232,9 +230,6 @@ public class CraftBlockState implements BlockState { if (this.z != other.z) { return false; } - if (this.type != other.type) { - return false; - } if (this.data != other.data && (this.data == null || !this.data.equals(other.data))) { return false; } @@ -248,7 +243,6 @@ public class CraftBlockState implements BlockState { hash = 73 * hash + this.x; hash = 73 * hash + this.y; hash = 73 * hash + this.z; - hash = 73 * hash + this.type; hash = 73 * hash + (this.data != null ? this.data.hashCode() : 0); return hash; } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBrewingStand.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBrewingStand.java index 9c336e6445..dafaa6fb3c 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBrewingStand.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBrewingStand.java @@ -5,6 +5,7 @@ import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BrewingStand; import org.bukkit.craftbukkit.inventory.CraftInventoryBrewer; +import org.bukkit.craftbukkit.util.CraftChatMessage; import org.bukkit.inventory.BrewerInventory; public class CraftBrewingStand extends CraftContainer implements BrewingStand { @@ -54,12 +55,12 @@ public class CraftBrewingStand extends CraftContainer im @Override public String getCustomName() { TileEntityBrewingStand brewingStand = this.getSnapshot(); - return brewingStand.hasCustomName() ? brewingStand.getName() : null; + return brewingStand.hasCustomName() ? CraftChatMessage.fromComponent(brewingStand.getCustomName()) : null; } @Override public void setCustomName(String name) { - this.getSnapshot().setCustomName(name); + this.getSnapshot().setCustomName(CraftChatMessage.fromStringOrNull(name)); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java index 85f3bb2720..6a54f2a166 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java @@ -1,6 +1,10 @@ package org.bukkit.craftbukkit.block; +import net.minecraft.server.BlockChest; import net.minecraft.server.BlockPosition; +import net.minecraft.server.Blocks; +import net.minecraft.server.ITileInventory; +import net.minecraft.server.InventoryLargeChest; import net.minecraft.server.TileEntityChest; import org.bukkit.Material; @@ -48,30 +52,10 @@ public class CraftChest extends CraftLootable implements Chest int z = this.getZ(); CraftWorld world = (CraftWorld) this.getWorld(); - int id; - if (world.getBlockTypeIdAt(x, y, z) == Material.CHEST.getId()) { - id = Material.CHEST.getId(); - } else if (world.getBlockTypeIdAt(x, y, z) == Material.TRAPPED_CHEST.getId()) { - id = Material.TRAPPED_CHEST.getId(); - } else { - throw new IllegalStateException("CraftChest is not a chest but is instead " + world.getBlockAt(x, y, z)); - } + ITileInventory nms = ((BlockChest) Blocks.CHEST).getInventory(data, world.getHandle(), new BlockPosition(x, y, z), true); - if (world.getBlockTypeIdAt(x - 1, y, z) == id) { - CraftInventory left = new CraftInventory((TileEntityChest) world.getHandle().getTileEntity(new BlockPosition(x - 1, y, z))); - inventory = new CraftInventoryDoubleChest(left, inventory); - } - if (world.getBlockTypeIdAt(x + 1, y, z) == id) { - CraftInventory right = new CraftInventory((TileEntityChest) world.getHandle().getTileEntity(new BlockPosition(x + 1, y, z))); - inventory = new CraftInventoryDoubleChest(inventory, right); - } - if (world.getBlockTypeIdAt(x, y, z - 1) == id) { - CraftInventory left = new CraftInventory((TileEntityChest) world.getHandle().getTileEntity(new BlockPosition(x, y, z - 1))); - inventory = new CraftInventoryDoubleChest(left, inventory); - } - if (world.getBlockTypeIdAt(x, y, z + 1) == id) { - CraftInventory right = new CraftInventory((TileEntityChest) world.getHandle().getTileEntity(new BlockPosition(x, y, z + 1))); - inventory = new CraftInventoryDoubleChest(inventory, right); + if (nms instanceof InventoryLargeChest) { + inventory = new CraftInventoryDoubleChest((InventoryLargeChest) nms); } return inventory; } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftCommandBlock.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftCommandBlock.java index dd5b83cf55..5c9bfe9513 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftCommandBlock.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftCommandBlock.java @@ -4,6 +4,7 @@ import net.minecraft.server.TileEntityCommand; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.CommandBlock; +import org.bukkit.craftbukkit.util.CraftChatMessage; public class CraftCommandBlock extends CraftBlockEntityState implements CommandBlock { @@ -23,7 +24,7 @@ public class CraftCommandBlock extends CraftBlockEntityState super.load(commandBlock); command = commandBlock.getCommandBlock().getCommand(); - name = commandBlock.getCommandBlock().getName(); + name = CraftChatMessage.fromComponent(commandBlock.getCommandBlock().getName()); } @Override @@ -51,6 +52,6 @@ public class CraftCommandBlock extends CraftBlockEntityState super.applyTo(commandBlock); commandBlock.getCommandBlock().setCommand(command); - commandBlock.getCommandBlock().setName(name); + commandBlock.getCommandBlock().setName(CraftChatMessage.fromStringOrNull(name)); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftConduit.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftConduit.java new file mode 100644 index 0000000000..5116a3765c --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftConduit.java @@ -0,0 +1,17 @@ +package org.bukkit.craftbukkit.block; + +import net.minecraft.server.TileEntityConduit; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.Conduit; + +public class CraftConduit extends CraftBlockEntityState implements Conduit { + + public CraftConduit(Block block) { + super(block, TileEntityConduit.class); + } + + public CraftConduit(Material material, TileEntityConduit te) { + super(material, te); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java index 2ec7084346..aa63b854d1 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java @@ -1,6 +1,7 @@ package org.bukkit.craftbukkit.block; import com.google.common.base.Preconditions; +import net.minecraft.server.EntityTypes; import net.minecraft.server.MinecraftKey; import net.minecraft.server.TileEntityMobSpawner; import org.bukkit.Material; @@ -31,7 +32,7 @@ public class CraftCreatureSpawner extends CraftBlockEntityState implements EnchantingTable { @@ -18,12 +19,12 @@ public class CraftEnchantingTable extends CraftBlockEntityState implements FlowerPot { - - private MaterialData contents; - - public CraftFlowerPot(Block block) { - super(block, TileEntityFlowerPot.class); - } - - public CraftFlowerPot(Material material, TileEntityFlowerPot te) { - super(material, te); - } - - @Override - public void load(TileEntityFlowerPot pot) { - super.load(pot); - - contents = (pot.getItem() == null) ? null : CraftItemStack.asBukkitCopy(pot.getContents()).getData(); - } - - @Override - public MaterialData getContents() { - return contents; - } - - @Override - public void setContents(MaterialData item) { - contents = item; - } - - @Override - public void applyTo(TileEntityFlowerPot pot) { - super.applyTo(pot); - - pot.setContents(contents == null ? ItemStack.a : CraftItemStack.asNMSCopy(contents.toItemStack(1))); - } -} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftFurnace.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftFurnace.java index 047dbe2e57..469dc4ff2b 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftFurnace.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftFurnace.java @@ -5,6 +5,7 @@ import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.Furnace; import org.bukkit.craftbukkit.inventory.CraftInventoryFurnace; +import org.bukkit.craftbukkit.util.CraftChatMessage; import org.bukkit.inventory.FurnaceInventory; public class CraftFurnace extends CraftContainer implements Furnace { @@ -54,12 +55,12 @@ public class CraftFurnace extends CraftContainer implements F @Override public String getCustomName() { TileEntityFurnace furnace = this.getSnapshot(); - return furnace.hasCustomName() ? furnace.getName() : null; + return furnace.hasCustomName() ? CraftChatMessage.fromComponent(furnace.getCustomName()) : null; } @Override public void setCustomName(String name) { - this.getSnapshot().setCustomName(name); + this.getSnapshot().setCustomName(CraftChatMessage.fromStringOrNull(name)); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftJukebox.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftJukebox.java index d259cfb82f..57160a9495 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftJukebox.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftJukebox.java @@ -1,11 +1,12 @@ package org.bukkit.craftbukkit.block; import net.minecraft.server.BlockJukeBox; -import net.minecraft.server.BlockJukeBox.TileEntityRecordPlayer; import net.minecraft.server.BlockPosition; import net.minecraft.server.Blocks; +import net.minecraft.server.Item; import net.minecraft.server.ItemStack; import net.minecraft.server.TileEntity; +import net.minecraft.server.TileEntityJukeBox; import org.bukkit.Effect; import org.bukkit.Material; import org.bukkit.block.Block; @@ -13,13 +14,13 @@ import org.bukkit.block.Jukebox; import org.bukkit.craftbukkit.CraftWorld; import org.bukkit.craftbukkit.util.CraftMagicNumbers; -public class CraftJukebox extends CraftBlockEntityState implements Jukebox { +public class CraftJukebox extends CraftBlockEntityState implements Jukebox { public CraftJukebox(final Block block) { - super(block, TileEntityRecordPlayer.class); + super(block, TileEntityJukeBox.class); } - public CraftJukebox(final Material material, TileEntityRecordPlayer te) { + public CraftJukebox(final Material material, TileEntityJukeBox te) { super(material, te); } @@ -39,7 +40,7 @@ public class CraftJukebox extends CraftBlockEntityState Blocks.JUKEBOX.getBlockData() .set(BlockJukeBox.HAS_RECORD, true), 3); } - world.playEffect(this.getLocation(), Effect.RECORD_PLAY, record.getId()); + world.playEffect(this.getLocation(), Effect.RECORD_PLAY, Item.getId(CraftMagicNumbers.getItem((Material) record))); } return result; @@ -77,12 +78,12 @@ public class CraftJukebox extends CraftBlockEntityState public boolean eject() { requirePlaced(); TileEntity tileEntity = this.getTileEntityFromWorld(); - if (!(tileEntity instanceof TileEntityRecordPlayer)) return false; + if (!(tileEntity instanceof TileEntityJukeBox)) return false; - TileEntityRecordPlayer jukebox = (TileEntityRecordPlayer) tileEntity; + TileEntityJukeBox jukebox = (TileEntityJukeBox) tileEntity; boolean result = !jukebox.getRecord().isEmpty(); CraftWorld world = (CraftWorld) this.getWorld(); - ((BlockJukeBox) Blocks.JUKEBOX).dropRecord(world.getHandle(), new BlockPosition(getX(), getY(), getZ()), null); + ((BlockJukeBox) Blocks.JUKEBOX).dropRecord(world.getHandle(), new BlockPosition(getX(), getY(), getZ())); return result; } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftLootable.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftLootable.java index e2af111d57..d7677192fa 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftLootable.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftLootable.java @@ -4,6 +4,7 @@ import net.minecraft.server.TileEntityLootable; import org.bukkit.Material; import org.bukkit.Nameable; import org.bukkit.block.Block; +import org.bukkit.craftbukkit.util.CraftChatMessage; public abstract class CraftLootable extends CraftContainer implements Nameable { @@ -18,12 +19,12 @@ public abstract class CraftLootable extends CraftC @Override public String getCustomName() { T lootable = this.getSnapshot(); - return lootable.hasCustomName() ? lootable.getName() : null; + return lootable.hasCustomName() ? CraftChatMessage.fromComponent(lootable.getCustomName()) : null; } @Override public void setCustomName(String name) { - this.getSnapshot().setCustomName(name); + this.getSnapshot().setCustomName(CraftChatMessage.fromStringOrNull(name)); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftNoteBlock.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftNoteBlock.java deleted file mode 100644 index 880831d417..0000000000 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftNoteBlock.java +++ /dev/null @@ -1,83 +0,0 @@ -package org.bukkit.craftbukkit.block; - -import net.minecraft.server.BlockPosition; -import net.minecraft.server.TileEntityNote; - -import org.bukkit.Instrument; -import org.bukkit.Material; -import org.bukkit.Note; -import org.bukkit.block.Block; -import org.bukkit.block.NoteBlock; -import org.bukkit.craftbukkit.CraftWorld; -import org.bukkit.craftbukkit.util.CraftMagicNumbers; - -public class CraftNoteBlock extends CraftBlockEntityState implements NoteBlock { - - public CraftNoteBlock(final Block block) { - super(block, TileEntityNote.class); - } - - public CraftNoteBlock(final Material material, final TileEntityNote te) { - super(material, te); - } - - @Override - public Note getNote() { - return new Note(this.getSnapshot().note); - } - - @Override - public byte getRawNote() { - return this.getSnapshot().note; - } - - @Override - public void setNote(Note note) { - this.getSnapshot().note = note.getId(); - } - - @Override - public void setRawNote(byte note) { - this.getSnapshot().note = note; - } - - @Override - public boolean play() { - Block block = getBlock(); - - if (block.getType() == Material.NOTE_BLOCK) { - TileEntityNote note = (TileEntityNote) this.getTileEntityFromWorld(); - CraftWorld world = (CraftWorld) this.getWorld(); - note.play(world.getHandle(), new BlockPosition(getX(), getY(), getZ())); - return true; - } else { - return false; - } - } - - @Override - public boolean play(byte instrument, byte note) { - Block block = getBlock(); - - if (block.getType() == Material.NOTE_BLOCK) { - CraftWorld world = (CraftWorld) this.getWorld(); - world.getHandle().playBlockAction(new BlockPosition(getX(), getY(), getZ()), CraftMagicNumbers.getBlock(block), instrument, note); - return true; - } else { - return false; - } - } - - @Override - public boolean play(Instrument instrument, Note note) { - Block block = getBlock(); - - if (block.getType() == Material.NOTE_BLOCK) { - CraftWorld world = (CraftWorld) this.getWorld(); - world.getHandle().playBlockAction(new BlockPosition(getX(), getY(), getZ()), CraftMagicNumbers.getBlock(block), instrument.getType(), note.getId()); - return true; - } else { - return false; - } - } -} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftSkull.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftSkull.java index f2865688a5..f113da713a 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftSkull.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftSkull.java @@ -12,13 +12,12 @@ import org.bukkit.SkullType; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.block.Skull; +import org.bukkit.block.data.Rotatable; public class CraftSkull extends CraftBlockEntityState implements Skull { private static final int MAX_OWNER_LENGTH = 16; private GameProfile profile; - private SkullType skullType; - private byte rotation; public CraftSkull(final Block block) { super(block, TileEntitySkull.class); @@ -33,26 +32,6 @@ public class CraftSkull extends CraftBlockEntityState implement super.load(skull); profile = skull.getGameProfile(); - skullType = getSkullType(skull.getSkullType()); - rotation = (byte) skull.rotation; - } - - static SkullType getSkullType(int id) { - switch (id) { - default: - case 0: - return SkullType.SKELETON; - case 1: - return SkullType.WITHER; - case 2: - return SkullType.ZOMBIE; - case 3: - return SkullType.PLAYER; - case 4: - return SkullType.CREEPER; - case 5: - return SkullType.DRAGON; - } } static int getSkullType(SkullType type) { @@ -73,84 +52,6 @@ public class CraftSkull extends CraftBlockEntityState implement } } - static byte getBlockFace(BlockFace rotation) { - switch (rotation) { - case NORTH: - return 0; - case NORTH_NORTH_EAST: - return 1; - case NORTH_EAST: - return 2; - case EAST_NORTH_EAST: - return 3; - case EAST: - return 4; - case EAST_SOUTH_EAST: - return 5; - case SOUTH_EAST: - return 6; - case SOUTH_SOUTH_EAST: - return 7; - case SOUTH: - return 8; - case SOUTH_SOUTH_WEST: - return 9; - case SOUTH_WEST: - return 10; - case WEST_SOUTH_WEST: - return 11; - case WEST: - return 12; - case WEST_NORTH_WEST: - return 13; - case NORTH_WEST: - return 14; - case NORTH_NORTH_WEST: - return 15; - default: - throw new IllegalArgumentException("Invalid BlockFace rotation: " + rotation); - } - } - - static BlockFace getBlockFace(byte rotation) { - switch (rotation) { - case 0: - return BlockFace.NORTH; - case 1: - return BlockFace.NORTH_NORTH_EAST; - case 2: - return BlockFace.NORTH_EAST; - case 3: - return BlockFace.EAST_NORTH_EAST; - case 4: - return BlockFace.EAST; - case 5: - return BlockFace.EAST_SOUTH_EAST; - case 6: - return BlockFace.SOUTH_EAST; - case 7: - return BlockFace.SOUTH_SOUTH_EAST; - case 8: - return BlockFace.SOUTH; - case 9: - return BlockFace.SOUTH_SOUTH_WEST; - case 10: - return BlockFace.SOUTH_WEST; - case 11: - return BlockFace.WEST_SOUTH_WEST; - case 12: - return BlockFace.WEST; - case 13: - return BlockFace.WEST_NORTH_WEST; - case 14: - return BlockFace.NORTH_WEST; - case 15: - return BlockFace.NORTH_NORTH_WEST; - default: - throw new AssertionError(rotation); - } - } - @Override public boolean hasOwner() { return profile != null; @@ -172,10 +73,6 @@ public class CraftSkull extends CraftBlockEntityState implement return false; } - if (skullType != SkullType.PLAYER) { - skullType = SkullType.PLAYER; - } - this.profile = profile; return true; } @@ -199,47 +96,58 @@ public class CraftSkull extends CraftBlockEntityState implement public void setOwningPlayer(OfflinePlayer player) { Preconditions.checkNotNull(player, "player"); - if (skullType != SkullType.PLAYER) { - skullType = SkullType.PLAYER; - } - this.profile = new GameProfile(player.getUniqueId(), player.getName()); } @Override public BlockFace getRotation() { - return getBlockFace(rotation); + return ((Rotatable) getBlockData()).getRotation(); } @Override public void setRotation(BlockFace rotation) { - this.rotation = getBlockFace(rotation); + Rotatable blockData = (Rotatable) getBlockData(); + blockData.setRotation(rotation); + setBlockData(blockData); } @Override public SkullType getSkullType() { - return skullType; + switch (getType()) { + case SKELETON_SKULL: + case SKELETON_WALL_SKULL: + return SkullType.SKELETON; + case WITHER_SKELETON_SKULL: + case WITHER_SKELETON_WALL_SKULL: + return SkullType.WITHER; + case ZOMBIE_HEAD: + case ZOMBIE_WALL_HEAD: + return SkullType.ZOMBIE; + case PLAYER_HEAD: + case PLAYER_WALL_HEAD: + return SkullType.PLAYER; + case CREEPER_HEAD: + case CREEPER_WALL_HEAD: + return SkullType.CREEPER; + case DRAGON_HEAD: + case DRAGON_WALL_HEAD: + return SkullType.DRAGON; + default: + throw new IllegalArgumentException("Unknown SkullType for " + getType()); + } } @Override public void setSkullType(SkullType skullType) { - this.skullType = skullType; - - if (skullType != SkullType.PLAYER) { - profile = null; - } + throw new UnsupportedOperationException("Must change block type"); } @Override public void applyTo(TileEntitySkull skull) { super.applyTo(skull); - if (skullType == SkullType.PLAYER) { + if (getSkullType() == SkullType.PLAYER) { skull.setGameProfile(profile); - } else { - skull.setSkullType(getSkullType(skullType)); } - - skull.setRotation(rotation); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftStructureBlock.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftStructureBlock.java index 2fadc70361..86095fbe7d 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftStructureBlock.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftStructureBlock.java @@ -2,6 +2,7 @@ package org.bukkit.craftbukkit.block; import com.google.common.base.Preconditions; import net.minecraft.server.BlockPosition; +import net.minecraft.server.BlockPropertyStructureMode; import net.minecraft.server.EnumBlockMirror; import net.minecraft.server.EnumBlockRotation; import net.minecraft.server.TileEntityStructure; @@ -30,35 +31,35 @@ public class CraftStructureBlock extends CraftBlockEntityState HALF = getEnum("half"); + + @Override + public Half getHalf() { + return get(HALF, Half.class); + } + + @Override + public void setHalf(Half half) { + set(HALF, half); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java new file mode 100644 index 0000000000..78cec61b1d --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java @@ -0,0 +1,356 @@ +package org.bukkit.craftbukkit.block.data; + +import com.google.common.base.Preconditions; +import com.google.common.collect.BiMap; +import com.google.common.collect.HashBiMap; +import com.google.common.collect.ImmutableSet; +import com.mojang.brigadier.StringReader; +import com.mojang.brigadier.exceptions.CommandSyntaxException; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; +import net.minecraft.server.ArgumentBlock; +import net.minecraft.server.Block; +import net.minecraft.server.BlockStateBoolean; +import net.minecraft.server.BlockStateEnum; +import net.minecraft.server.BlockStateInteger; +import net.minecraft.server.EnumDirection; +import net.minecraft.server.IBlockData; +import net.minecraft.server.IBlockState; +import net.minecraft.server.INamable; +import org.bukkit.Material; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.BlockData; +import org.bukkit.craftbukkit.block.CraftBlock; +import org.bukkit.craftbukkit.util.CraftMagicNumbers; + +public class CraftBlockData implements BlockData { + + private IBlockData state; + + protected CraftBlockData() { + throw new AssertionError("Template Constructor"); + } + + protected CraftBlockData(IBlockData state) { + this.state = state; + } + + @Override + public Material getMaterial() { + return CraftMagicNumbers.getMaterial(state.getBlock()); + } + + public IBlockData getState() { + return state; + } + + protected > B get(BlockStateEnum nms, Class bukkit) { + return toBukkit(state.get(nms), bukkit); + } + + @SuppressWarnings("unchecked") + protected > Set getValues(BlockStateEnum nms, Class bukkit) { + ImmutableSet.Builder values = ImmutableSet.builder(); + + for (Enum e : nms.d()) { + values.add(toBukkit(e, bukkit)); + } + + return values.build(); + } + + protected , N extends Enum & INamable> void set(BlockStateEnum nms, Enum bukkit) { + this.state = this.state.set(nms, toNMS(bukkit, nms.b())); + } + + private static final BiMap, Enum> nmsToBukkit = HashBiMap.create(); + + @SuppressWarnings("unchecked") + private static > B toBukkit(Enum nms, Class bukkit) { + Enum converted = nmsToBukkit.get(nms); + if (converted != null) { + return (B) converted; + } + + if (nms instanceof EnumDirection) { + converted = CraftBlock.notchToBlockFace((EnumDirection) nms); + } else { + converted = bukkit.getEnumConstants()[nms.ordinal()]; + } + + Preconditions.checkState(converted != null, "Could not convert enum %s->%s", nms, bukkit); + nmsToBukkit.put(nms, converted); + + return (B) converted; + } + + @SuppressWarnings("unchecked") + private static & INamable> N toNMS(Enum bukkit, Class nms) { + Enum converted = nmsToBukkit.inverse().get(bukkit); + if (converted != null) { + return (N) converted; + } + + if (bukkit instanceof BlockFace) { + converted = CraftBlock.blockFaceToNotch((BlockFace) bukkit); + } else { + converted = nms.getEnumConstants()[bukkit.ordinal()]; + } + + Preconditions.checkState(converted != null, "Could not convert enum %s->%s", nms, bukkit); + nmsToBukkit.put(converted, bukkit); + + return (N) converted; + } + + protected > T get(IBlockState ibs) { + // Straight integer or boolean getter + return this.state.get(ibs); + } + + public , V extends T> void set(IBlockState ibs, V v) { + // Straight integer or boolean setter + this.state = this.state.set(ibs, v); + } + + @Override + public String getAsString() { + return state.toString(); + } + + @Override + public BlockData clone() { + try { + return (BlockData) super.clone(); + } catch (CloneNotSupportedException ex) { + throw new AssertionError("Clone not supported", ex); + } + } + + @Override + public String toString() { + return "CraftBlockData{" + state.toString() + "}"; + } + + @Override + public boolean equals(Object obj) { + return obj instanceof CraftBlockData && state.equals(((CraftBlockData) obj).state); + } + + @Override + public int hashCode() { + return state.hashCode(); + } + + protected static BlockStateBoolean getBoolean(String name) { + throw new AssertionError("Template Method"); + } + + protected static BlockStateBoolean getBoolean(String name, boolean optional) { + throw new AssertionError("Template Method"); + } + + protected static BlockStateEnum getEnum(String name) { + throw new AssertionError("Template Method"); + } + + protected static BlockStateInteger getInteger(String name) { + throw new AssertionError("Template Method"); + } + + protected static BlockStateBoolean getBoolean(Class block, String name) { + return (BlockStateBoolean) getState(block, name, false); + } + + protected static BlockStateBoolean getBoolean(Class block, String name, boolean optional) { + return (BlockStateBoolean) getState(block, name, optional); + } + + protected static BlockStateEnum getEnum(Class block, String name) { + return (BlockStateEnum) getState(block, name, false); + } + + protected static BlockStateInteger getInteger(Class block, String name) { + return (BlockStateInteger) getState(block, name, false); + } + + private static IBlockState getState(Class block, String name, boolean optional) { + IBlockState state = null; + + for (Block instance : (Iterable) Block.REGISTRY) { // Eclipse fail + if (instance.getClass() == block) { + if (state == null) { + state = instance.getStates().a(name); + } else { + IBlockState newState = instance.getStates().a(name); + + Preconditions.checkState(state == newState, "State mistmatch %s,%s", state, newState); + } + } + } + + Preconditions.checkState(optional || state != null, "Null state for %s,%s", block, name); + + return state; + } + + protected static int getMin(BlockStateInteger state) { + return state.min; + } + + protected static int getMax(BlockStateInteger state) { + return state.max; + } + + // + private static final Map, Class> MAP = new HashMap<>(); + + static { + register(net.minecraft.server.BlockAnvil.class, org.bukkit.craftbukkit.block.impl.CraftAnvil.class); + register(net.minecraft.server.BlockBanner.class, org.bukkit.craftbukkit.block.impl.CraftBanner.class); + register(net.minecraft.server.BlockBannerWall.class, org.bukkit.craftbukkit.block.impl.CraftBannerWall.class); + register(net.minecraft.server.BlockBed.class, org.bukkit.craftbukkit.block.impl.CraftBed.class); + register(net.minecraft.server.BlockBeetroot.class, org.bukkit.craftbukkit.block.impl.CraftBeetroot.class); + register(net.minecraft.server.BlockBrewingStand.class, org.bukkit.craftbukkit.block.impl.CraftBrewingStand.class); + register(net.minecraft.server.BlockBubbleColumn.class, org.bukkit.craftbukkit.block.impl.CraftBubbleColumn.class); + register(net.minecraft.server.BlockCactus.class, org.bukkit.craftbukkit.block.impl.CraftCactus.class); + register(net.minecraft.server.BlockCake.class, org.bukkit.craftbukkit.block.impl.CraftCake.class); + register(net.minecraft.server.BlockCarrots.class, org.bukkit.craftbukkit.block.impl.CraftCarrots.class); + register(net.minecraft.server.BlockCauldron.class, org.bukkit.craftbukkit.block.impl.CraftCauldron.class); + register(net.minecraft.server.BlockChest.class, org.bukkit.craftbukkit.block.impl.CraftChest.class); + register(net.minecraft.server.BlockChestTrapped.class, org.bukkit.craftbukkit.block.impl.CraftChestTrapped.class); + register(net.minecraft.server.BlockChorusFlower.class, org.bukkit.craftbukkit.block.impl.CraftChorusFlower.class); + register(net.minecraft.server.BlockChorusFruit.class, org.bukkit.craftbukkit.block.impl.CraftChorusFruit.class); + register(net.minecraft.server.BlockCobbleWall.class, org.bukkit.craftbukkit.block.impl.CraftCobbleWall.class); + register(net.minecraft.server.BlockCocoa.class, org.bukkit.craftbukkit.block.impl.CraftCocoa.class); + register(net.minecraft.server.BlockCommand.class, org.bukkit.craftbukkit.block.impl.CraftCommand.class); + register(net.minecraft.server.BlockCoralFan.class, org.bukkit.craftbukkit.block.impl.CraftCoralFan.class); + register(net.minecraft.server.BlockCrops.class, org.bukkit.craftbukkit.block.impl.CraftCrops.class); + register(net.minecraft.server.BlockDaylightDetector.class, org.bukkit.craftbukkit.block.impl.CraftDaylightDetector.class); + register(net.minecraft.server.BlockDirtSnow.class, org.bukkit.craftbukkit.block.impl.CraftDirtSnow.class); + register(net.minecraft.server.BlockDispenser.class, org.bukkit.craftbukkit.block.impl.CraftDispenser.class); + register(net.minecraft.server.BlockDoor.class, org.bukkit.craftbukkit.block.impl.CraftDoor.class); + register(net.minecraft.server.BlockDropper.class, org.bukkit.craftbukkit.block.impl.CraftDropper.class); + register(net.minecraft.server.BlockEndRod.class, org.bukkit.craftbukkit.block.impl.CraftEndRod.class); + register(net.minecraft.server.BlockEnderChest.class, org.bukkit.craftbukkit.block.impl.CraftEnderChest.class); + register(net.minecraft.server.BlockEnderPortalFrame.class, org.bukkit.craftbukkit.block.impl.CraftEnderPortalFrame.class); + register(net.minecraft.server.BlockFence.class, org.bukkit.craftbukkit.block.impl.CraftFence.class); + register(net.minecraft.server.BlockFenceGate.class, org.bukkit.craftbukkit.block.impl.CraftFenceGate.class); + register(net.minecraft.server.BlockFire.class, org.bukkit.craftbukkit.block.impl.CraftFire.class); + register(net.minecraft.server.BlockFloorSign.class, org.bukkit.craftbukkit.block.impl.CraftFloorSign.class); + register(net.minecraft.server.BlockFluids.class, org.bukkit.craftbukkit.block.impl.CraftFluids.class); + register(net.minecraft.server.BlockFurnace.class, org.bukkit.craftbukkit.block.impl.CraftFurnace.class); + register(net.minecraft.server.BlockGlassPane.class, org.bukkit.craftbukkit.block.impl.CraftGlassPane.class); + register(net.minecraft.server.BlockGlazedTerracotta.class, org.bukkit.craftbukkit.block.impl.CraftGlazedTerracotta.class); + register(net.minecraft.server.BlockGrass.class, org.bukkit.craftbukkit.block.impl.CraftGrass.class); + register(net.minecraft.server.BlockHay.class, org.bukkit.craftbukkit.block.impl.CraftHay.class); + register(net.minecraft.server.BlockHopper.class, org.bukkit.craftbukkit.block.impl.CraftHopper.class); + register(net.minecraft.server.BlockHugeMushroom.class, org.bukkit.craftbukkit.block.impl.CraftHugeMushroom.class); + register(net.minecraft.server.BlockIceFrost.class, org.bukkit.craftbukkit.block.impl.CraftIceFrost.class); + register(net.minecraft.server.BlockIronBars.class, org.bukkit.craftbukkit.block.impl.CraftIronBars.class); + register(net.minecraft.server.BlockJukeBox.class, org.bukkit.craftbukkit.block.impl.CraftJukeBox.class); + register(net.minecraft.server.BlockKelp.class, org.bukkit.craftbukkit.block.impl.CraftKelp.class); + register(net.minecraft.server.BlockLadder.class, org.bukkit.craftbukkit.block.impl.CraftLadder.class); + register(net.minecraft.server.BlockLeaves.class, org.bukkit.craftbukkit.block.impl.CraftLeaves.class); + register(net.minecraft.server.BlockLever.class, org.bukkit.craftbukkit.block.impl.CraftLever.class); + register(net.minecraft.server.BlockLogAbstract.class, org.bukkit.craftbukkit.block.impl.CraftLogAbstract.class); + register(net.minecraft.server.BlockMinecartDetector.class, org.bukkit.craftbukkit.block.impl.CraftMinecartDetector.class); + register(net.minecraft.server.BlockMinecartTrack.class, org.bukkit.craftbukkit.block.impl.CraftMinecartTrack.class); + register(net.minecraft.server.BlockMycel.class, org.bukkit.craftbukkit.block.impl.CraftMycel.class); + register(net.minecraft.server.BlockNetherWart.class, org.bukkit.craftbukkit.block.impl.CraftNetherWart.class); + register(net.minecraft.server.BlockNote.class, org.bukkit.craftbukkit.block.impl.CraftNote.class); + register(net.minecraft.server.BlockObserver.class, org.bukkit.craftbukkit.block.impl.CraftObserver.class); + register(net.minecraft.server.BlockPiston.class, org.bukkit.craftbukkit.block.impl.CraftPiston.class); + register(net.minecraft.server.BlockPistonExtension.class, org.bukkit.craftbukkit.block.impl.CraftPistonExtension.class); + register(net.minecraft.server.BlockPistonMoving.class, org.bukkit.craftbukkit.block.impl.CraftPistonMoving.class); + register(net.minecraft.server.BlockPortal.class, org.bukkit.craftbukkit.block.impl.CraftPortal.class); + register(net.minecraft.server.BlockPotatoes.class, org.bukkit.craftbukkit.block.impl.CraftPotatoes.class); + register(net.minecraft.server.BlockPoweredRail.class, org.bukkit.craftbukkit.block.impl.CraftPoweredRail.class); + register(net.minecraft.server.BlockPressurePlateBinary.class, org.bukkit.craftbukkit.block.impl.CraftPressurePlateBinary.class); + register(net.minecraft.server.BlockPressurePlateWeighted.class, org.bukkit.craftbukkit.block.impl.CraftPressurePlateWeighted.class); + register(net.minecraft.server.BlockPumpkinCarved.class, org.bukkit.craftbukkit.block.impl.CraftPumpkinCarved.class); + register(net.minecraft.server.BlockRedstoneComparator.class, org.bukkit.craftbukkit.block.impl.CraftRedstoneComparator.class); + register(net.minecraft.server.BlockRedstoneLamp.class, org.bukkit.craftbukkit.block.impl.CraftRedstoneLamp.class); + register(net.minecraft.server.BlockRedstoneOre.class, org.bukkit.craftbukkit.block.impl.CraftRedstoneOre.class); + register(net.minecraft.server.BlockRedstoneTorch.class, org.bukkit.craftbukkit.block.impl.CraftRedstoneTorch.class); + register(net.minecraft.server.BlockRedstoneTorchWall.class, org.bukkit.craftbukkit.block.impl.CraftRedstoneTorchWall.class); + register(net.minecraft.server.BlockRedstoneWire.class, org.bukkit.craftbukkit.block.impl.CraftRedstoneWire.class); + register(net.minecraft.server.BlockReed.class, org.bukkit.craftbukkit.block.impl.CraftReed.class); + register(net.minecraft.server.BlockRepeater.class, org.bukkit.craftbukkit.block.impl.CraftRepeater.class); + register(net.minecraft.server.BlockRotatable.class, org.bukkit.craftbukkit.block.impl.CraftRotatable.class); + register(net.minecraft.server.BlockSapling.class, org.bukkit.craftbukkit.block.impl.CraftSapling.class); + register(net.minecraft.server.BlockSeaPickle.class, org.bukkit.craftbukkit.block.impl.CraftSeaPickle.class); + register(net.minecraft.server.BlockShulkerBox.class, org.bukkit.craftbukkit.block.impl.CraftShulkerBox.class); + register(net.minecraft.server.BlockSkull.class, org.bukkit.craftbukkit.block.impl.CraftSkull.class); + register(net.minecraft.server.BlockSkullPlayer.class, org.bukkit.craftbukkit.block.impl.CraftSkullPlayer.class); + register(net.minecraft.server.BlockSkullPlayerWall.class, org.bukkit.craftbukkit.block.impl.CraftSkullPlayerWall.class); + register(net.minecraft.server.BlockSkullWall.class, org.bukkit.craftbukkit.block.impl.CraftSkullWall.class); + register(net.minecraft.server.BlockSnow.class, org.bukkit.craftbukkit.block.impl.CraftSnow.class); + register(net.minecraft.server.BlockSoil.class, org.bukkit.craftbukkit.block.impl.CraftSoil.class); + register(net.minecraft.server.BlockStainedGlassPane.class, org.bukkit.craftbukkit.block.impl.CraftStainedGlassPane.class); + register(net.minecraft.server.BlockStairs.class, org.bukkit.craftbukkit.block.impl.CraftStairs.class); + register(net.minecraft.server.BlockStem.class, org.bukkit.craftbukkit.block.impl.CraftStem.class); + register(net.minecraft.server.BlockStemAttached.class, org.bukkit.craftbukkit.block.impl.CraftStemAttached.class); + register(net.minecraft.server.BlockStepAbstract.class, org.bukkit.craftbukkit.block.impl.CraftStepAbstract.class); + register(net.minecraft.server.BlockStoneButton.class, org.bukkit.craftbukkit.block.impl.CraftStoneButton.class); + register(net.minecraft.server.BlockStructure.class, org.bukkit.craftbukkit.block.impl.CraftStructure.class); + register(net.minecraft.server.BlockTallPlantFlower.class, org.bukkit.craftbukkit.block.impl.CraftTallPlantFlower.class); + register(net.minecraft.server.BlockTallPlantShearable.class, org.bukkit.craftbukkit.block.impl.CraftTallPlantShearable.class); + register(net.minecraft.server.BlockTallSeaGrass.class, org.bukkit.craftbukkit.block.impl.CraftTallSeaGrass.class); + register(net.minecraft.server.BlockTorchWall.class, org.bukkit.craftbukkit.block.impl.CraftTorchWall.class); + register(net.minecraft.server.BlockTrapdoor.class, org.bukkit.craftbukkit.block.impl.CraftTrapdoor.class); + register(net.minecraft.server.BlockTripwire.class, org.bukkit.craftbukkit.block.impl.CraftTripwire.class); + register(net.minecraft.server.BlockTripwireHook.class, org.bukkit.craftbukkit.block.impl.CraftTripwireHook.class); + register(net.minecraft.server.BlockTurtleEgg.class, org.bukkit.craftbukkit.block.impl.CraftTurtleEgg.class); + register(net.minecraft.server.BlockVine.class, org.bukkit.craftbukkit.block.impl.CraftVine.class); + register(net.minecraft.server.BlockWallSign.class, org.bukkit.craftbukkit.block.impl.CraftWallSign.class); + register(net.minecraft.server.BlockWitherSkull.class, org.bukkit.craftbukkit.block.impl.CraftWitherSkull.class); + register(net.minecraft.server.BlockWitherSkullWall.class, org.bukkit.craftbukkit.block.impl.CraftWitherSkullWall.class); + register(net.minecraft.server.BlockWoodButton.class, org.bukkit.craftbukkit.block.impl.CraftWoodButton.class); + } + + private static void register(Class nms, Class bukkit) { + Preconditions.checkState(MAP.put(nms, bukkit) == null, "Duplicate mapping %s->%s", nms, bukkit); + } + + public static CraftBlockData newData(Material material, String data) { + IBlockData blockData; + Block block = CraftMagicNumbers.getBlock(material); + + // Data provided, use it + if (data != null) { + try { + // Material provided, force that material in + if (block != null) { + data = Block.REGISTRY.b(block) + data; + } + + ArgumentBlock arg = new ArgumentBlock(new StringReader(data), false).a(false); + blockData = arg.b(); + } catch (CommandSyntaxException ex) { + throw new IllegalArgumentException("Could not parse data: " + data, ex); + } + } else { + blockData = block.getBlockData(); + } + + return fromData(blockData); + } + + public static CraftBlockData fromData(IBlockData data) { + Class craft = MAP.get(data.getBlock().getClass()); + if (craft == null) { + craft = CraftBlockData.class; + } + + CraftBlockData ret; + try { + ret = craft.getDeclaredConstructor(IBlockData.class).newInstance(data); + } catch (ReflectiveOperationException ex) { + throw new RuntimeException(ex); + } + + return ret; + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftDirectional.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftDirectional.java new file mode 100644 index 0000000000..7b3ec8811c --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftDirectional.java @@ -0,0 +1,23 @@ +package org.bukkit.craftbukkit.block.data; + +import org.bukkit.block.data.Directional; + +public abstract class CraftDirectional extends CraftBlockData implements Directional { + + private static final net.minecraft.server.BlockStateEnum FACING = getEnum("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/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftLevelled.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftLevelled.java new file mode 100644 index 0000000000..3d4afa7482 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftLevelled.java @@ -0,0 +1,23 @@ +package org.bukkit.craftbukkit.block.data; + +import org.bukkit.block.data.Levelled; + +public abstract class CraftLevelled extends CraftBlockData implements Levelled { + + private static final net.minecraft.server.BlockStateInteger LEVEL = getInteger("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/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftLightable.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftLightable.java new file mode 100644 index 0000000000..cfe4b26e41 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftLightable.java @@ -0,0 +1,18 @@ +package org.bukkit.craftbukkit.block.data; + +import org.bukkit.block.data.Lightable; + +public abstract class CraftLightable extends CraftBlockData implements Lightable { + + private static final net.minecraft.server.BlockStateBoolean LIT = getBoolean("lit"); + + @Override + public boolean isLit() { + return get(LIT); + } + + @Override + public void setLit(boolean lit) { + set(LIT, lit); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftMultipleFacing.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftMultipleFacing.java new file mode 100644 index 0000000000..5d2cc2a9fa --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftMultipleFacing.java @@ -0,0 +1,46 @@ +package org.bukkit.craftbukkit.block.data; + +import org.bukkit.block.data.MultipleFacing; + +public abstract class CraftMultipleFacing extends CraftBlockData implements MultipleFacing { + + private static final net.minecraft.server.BlockStateBoolean[] FACES = new net.minecraft.server.BlockStateBoolean[]{ + getBoolean("north", true), getBoolean("east", true), getBoolean("south", true), getBoolean("west", true), getBoolean("up", true), getBoolean("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(); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftOpenable.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftOpenable.java new file mode 100644 index 0000000000..31abd411ed --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftOpenable.java @@ -0,0 +1,18 @@ +package org.bukkit.craftbukkit.block.data; + +import org.bukkit.block.data.Openable; + +public abstract class CraftOpenable extends CraftBlockData implements Openable { + + private static final net.minecraft.server.BlockStateBoolean OPEN = getBoolean("open"); + + @Override + public boolean isOpen() { + return get(OPEN); + } + + @Override + public void setOpen(boolean open) { + set(OPEN, open); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftOrientable.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftOrientable.java new file mode 100644 index 0000000000..72cc0aa978 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftOrientable.java @@ -0,0 +1,23 @@ +package org.bukkit.craftbukkit.block.data; + +import org.bukkit.block.data.Orientable; + +public class CraftOrientable extends CraftBlockData implements Orientable { + + private static final net.minecraft.server.BlockStateEnum AXIS = getEnum("axis"); + + @Override + public org.bukkit.Axis getAxis() { + return get(AXIS, org.bukkit.Axis.class); + } + + @Override + public void setAxis(org.bukkit.Axis axis) { + set(AXIS, axis); + } + + @Override + public java.util.Set getAxes() { + return getValues(AXIS, org.bukkit.Axis.class); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftPowerable.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftPowerable.java new file mode 100644 index 0000000000..f932cf17fd --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftPowerable.java @@ -0,0 +1,18 @@ +package org.bukkit.craftbukkit.block.data; + +import org.bukkit.block.data.Powerable; + +public abstract class CraftPowerable extends CraftBlockData implements Powerable { + + private static final net.minecraft.server.BlockStateBoolean POWERED = getBoolean("powered"); + + @Override + public boolean isPowered() { + return get(POWERED); + } + + @Override + public void setPowered(boolean powered) { + set(POWERED, powered); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftRail.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftRail.java new file mode 100644 index 0000000000..5ee64559b6 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftRail.java @@ -0,0 +1,23 @@ +package org.bukkit.craftbukkit.block.data; + +import org.bukkit.block.data.Rail; + +public abstract class CraftRail extends CraftBlockData implements Rail { + + private static final net.minecraft.server.BlockStateEnum SHAPE = getEnum("shape"); + + @Override + public Shape getShape() { + return get(SHAPE, Shape.class); + } + + @Override + public void setShape(Shape shape) { + set(SHAPE, shape); + } + + @Override + public java.util.Set getShapes() { + return getValues(SHAPE, Shape.class); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftRotatable.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftRotatable.java new file mode 100644 index 0000000000..78668da5b4 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftRotatable.java @@ -0,0 +1,107 @@ +package org.bukkit.craftbukkit.block.data; + +import org.bukkit.block.data.Rotatable; + +public abstract class CraftRotatable extends CraftBlockData implements Rotatable { + + private static final net.minecraft.server.BlockStateInteger ROTATION = getInteger("rotation"); + + @Override + public org.bukkit.block.BlockFace getRotation() { + int data = get(ROTATION); + switch (data) { + case 0x0: + return org.bukkit.block.BlockFace.SOUTH; + case 0x1: + return org.bukkit.block.BlockFace.SOUTH_SOUTH_WEST; + case 0x2: + return org.bukkit.block.BlockFace.SOUTH_WEST; + case 0x3: + return org.bukkit.block.BlockFace.WEST_SOUTH_WEST; + case 0x4: + return org.bukkit.block.BlockFace.WEST; + case 0x5: + return org.bukkit.block.BlockFace.WEST_NORTH_WEST; + case 0x6: + return org.bukkit.block.BlockFace.NORTH_WEST; + case 0x7: + return org.bukkit.block.BlockFace.NORTH_NORTH_WEST; + case 0x8: + return org.bukkit.block.BlockFace.NORTH; + case 0x9: + return org.bukkit.block.BlockFace.NORTH_NORTH_EAST; + case 0xA: + return org.bukkit.block.BlockFace.NORTH_EAST; + case 0xB: + return org.bukkit.block.BlockFace.EAST_NORTH_EAST; + case 0xC: + return org.bukkit.block.BlockFace.EAST; + case 0xD: + return org.bukkit.block.BlockFace.EAST_SOUTH_EAST; + case 0xE: + return org.bukkit.block.BlockFace.SOUTH_EAST; + case 0xF: + return org.bukkit.block.BlockFace.SOUTH_SOUTH_EAST; + default: + throw new IllegalArgumentException("Unknown rotation " + data); + } + } + + @Override + public void setRotation(org.bukkit.block.BlockFace rotation) { + int val; + switch (rotation) { + case SOUTH: + val = 0x0; + break; + case SOUTH_SOUTH_WEST: + val = 0x1; + break; + case SOUTH_WEST: + val = 0x2; + break; + case WEST_SOUTH_WEST: + val = 0x3; + break; + case WEST: + val = 0x4; + break; + case WEST_NORTH_WEST: + val = 0x5; + break; + case NORTH_WEST: + val = 0x6; + break; + case NORTH_NORTH_WEST: + val = 0x7; + break; + case NORTH: + val = 0x8; + break; + case NORTH_NORTH_EAST: + val = 0x9; + break; + case NORTH_EAST: + val = 0xA; + break; + case EAST_NORTH_EAST: + val = 0xB; + break; + case EAST: + val = 0xC; + break; + case EAST_SOUTH_EAST: + val = 0xD; + break; + case SOUTH_EAST: + val = 0xE; + break; + case SOUTH_SOUTH_EAST: + val = 0xF; + break; + default: + throw new IllegalArgumentException("Illegal rotation " + rotation); + } + set(ROTATION, val); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftSnowable.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftSnowable.java new file mode 100644 index 0000000000..e59c3d230b --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftSnowable.java @@ -0,0 +1,18 @@ +package org.bukkit.craftbukkit.block.data; + +import org.bukkit.block.data.Snowable; + +public abstract class CraftSnowable extends CraftBlockData implements Snowable { + + private static final net.minecraft.server.BlockStateBoolean SNOWY = getBoolean("snowy"); + + @Override + public boolean isSnowy() { + return get(SNOWY); + } + + @Override + public void setSnowy(boolean snowy) { + set(SNOWY, snowy); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftWaterlogged.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftWaterlogged.java new file mode 100644 index 0000000000..011c9aea84 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftWaterlogged.java @@ -0,0 +1,19 @@ +package org.bukkit.craftbukkit.block.data; + +import org.bukkit.block.data.Waterlogged; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +public abstract class CraftWaterlogged extends CraftBlockData implements Waterlogged { + + private static final net.minecraft.server.BlockStateBoolean WATERLOGGED = getBoolean("waterlogged"); + + @Override + public boolean isWaterlogged() { + return get(WATERLOGGED); + } + + @Override + public void setWaterlogged(boolean waterlogged) { + set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftBed.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftBed.java new file mode 100644 index 0000000000..f86ed2591a --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftBed.java @@ -0,0 +1,25 @@ +package org.bukkit.craftbukkit.block.data.type; + +import org.bukkit.block.data.type.Bed; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +public abstract class CraftBed extends CraftBlockData implements Bed { + + private static final net.minecraft.server.BlockStateEnum PART = getEnum("part"); + private static final net.minecraft.server.BlockStateBoolean OCCUPIED = getBoolean("occupied"); + + @Override + public Part getPart() { + return get(PART, Part.class); + } + + @Override + public void setPart(Part part) { + set(PART, part); + } + + @Override + public boolean isOccupied() { + return get(OCCUPIED); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftBrewingStand.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftBrewingStand.java new file mode 100644 index 0000000000..9349e02fe9 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftBrewingStand.java @@ -0,0 +1,39 @@ +package org.bukkit.craftbukkit.block.data.type; + +import org.bukkit.block.data.type.BrewingStand; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +public abstract class CraftBrewingStand extends CraftBlockData implements BrewingStand { + + private static final net.minecraft.server.BlockStateBoolean[] HAS_BOTTLE = new net.minecraft.server.BlockStateBoolean[]{ + getBoolean("has_bottle_0"), getBoolean("has_bottle_1"), getBoolean("has_bottle_2") + }; + + @Override + public boolean hasBottle(int bottle) { + return get(HAS_BOTTLE[bottle]); + } + + @Override + public void setBottle(int bottle, boolean has) { + set(HAS_BOTTLE[bottle], has); + } + + @Override + public java.util.Set getBottles() { + com.google.common.collect.ImmutableSet.Builder bottles = com.google.common.collect.ImmutableSet.builder(); + + for (int index = 0; index < getMaximumBottles(); index++) { + if (hasBottle(index)) { + bottles.add(index); + } + } + + return bottles.build(); + } + + @Override + public int getMaximumBottles() { + return HAS_BOTTLE.length; + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftBubbleColumn.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftBubbleColumn.java new file mode 100644 index 0000000000..eedb510222 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftBubbleColumn.java @@ -0,0 +1,19 @@ +package org.bukkit.craftbukkit.block.data.type; + +import org.bukkit.block.data.type.BubbleColumn; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +public abstract class CraftBubbleColumn extends CraftBlockData implements BubbleColumn { + + private static final net.minecraft.server.BlockStateBoolean DRAG = getBoolean("drag"); + + @Override + public boolean isDrag() { + return get(DRAG); + } + + @Override + public void setDrag(boolean drag) { + set(DRAG, drag); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftCake.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftCake.java new file mode 100644 index 0000000000..aae60937b1 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftCake.java @@ -0,0 +1,24 @@ +package org.bukkit.craftbukkit.block.data.type; + +import org.bukkit.block.data.type.Cake; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +public abstract class CraftCake extends CraftBlockData implements Cake { + + private static final net.minecraft.server.BlockStateInteger BITES = getInteger("bites"); + + @Override + public int getBites() { + return get(BITES); + } + + @Override + public void setBites(int bites) { + set(BITES, bites); + } + + @Override + public int getMaximumBites() { + return getMax(BITES); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftChest.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftChest.java new file mode 100644 index 0000000000..70473ef420 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftChest.java @@ -0,0 +1,19 @@ +package org.bukkit.craftbukkit.block.data.type; + +import org.bukkit.block.data.type.Chest; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +public abstract class CraftChest extends CraftBlockData implements Chest { + + private static final net.minecraft.server.BlockStateEnum TYPE = getEnum("type"); + + @Override + public Type getType() { + return get(TYPE, Type.class); + } + + @Override + public void setType(Type type) { + set(TYPE, type); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftCommandBlock.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftCommandBlock.java new file mode 100644 index 0000000000..ddb9ac5e02 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftCommandBlock.java @@ -0,0 +1,19 @@ +package org.bukkit.craftbukkit.block.data.type; + +import org.bukkit.block.data.type.CommandBlock; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +public abstract class CraftCommandBlock extends CraftBlockData implements CommandBlock { + + private static final net.minecraft.server.BlockStateBoolean CONDITIONAL = getBoolean("conditional"); + + @Override + public boolean isConditional() { + return get(CONDITIONAL); + } + + @Override + public void setConditional(boolean conditional) { + set(CONDITIONAL, conditional); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftComparator.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftComparator.java new file mode 100644 index 0000000000..4f3130a5f4 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftComparator.java @@ -0,0 +1,19 @@ +package org.bukkit.craftbukkit.block.data.type; + +import org.bukkit.block.data.type.Comparator; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +public abstract class CraftComparator extends CraftBlockData implements Comparator { + + private static final net.minecraft.server.BlockStateEnum MODE = getEnum("mode"); + + @Override + public Mode getMode() { + return get(MODE, Mode.class); + } + + @Override + public void setMode(Mode mode) { + set(MODE, mode); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftDaylightDetector.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftDaylightDetector.java new file mode 100644 index 0000000000..842fe51f98 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftDaylightDetector.java @@ -0,0 +1,19 @@ +package org.bukkit.craftbukkit.block.data.type; + +import org.bukkit.block.data.type.DaylightDetector; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +public abstract class CraftDaylightDetector extends CraftBlockData implements DaylightDetector { + + private static final net.minecraft.server.BlockStateBoolean INVERTED = getBoolean("inverted"); + + @Override + public boolean isInverted() { + return get(INVERTED); + } + + @Override + public void setInverted(boolean inverted) { + set(INVERTED, inverted); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftDispenser.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftDispenser.java new file mode 100644 index 0000000000..5d43240e7a --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftDispenser.java @@ -0,0 +1,19 @@ +package org.bukkit.craftbukkit.block.data.type; + +import org.bukkit.block.data.type.Dispenser; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +public abstract class CraftDispenser extends CraftBlockData implements Dispenser { + + private static final net.minecraft.server.BlockStateBoolean TRIGGERED = getBoolean("triggered"); + + @Override + public boolean isTriggered() { + return get(TRIGGERED); + } + + @Override + public void setTriggered(boolean triggered) { + set(TRIGGERED, triggered); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftDoor.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftDoor.java new file mode 100644 index 0000000000..3fc75dd2a6 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftDoor.java @@ -0,0 +1,19 @@ +package org.bukkit.craftbukkit.block.data.type; + +import org.bukkit.block.data.type.Door; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +public abstract class CraftDoor extends CraftBlockData implements Door { + + private static final net.minecraft.server.BlockStateEnum HINGE = getEnum("hinge"); + + @Override + public Hinge getHinge() { + return get(HINGE, Hinge.class); + } + + @Override + public void setHinge(Hinge hinge) { + set(HINGE, hinge); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftEndPortalFrame.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftEndPortalFrame.java new file mode 100644 index 0000000000..84cd1d0391 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftEndPortalFrame.java @@ -0,0 +1,19 @@ +package org.bukkit.craftbukkit.block.data.type; + +import org.bukkit.block.data.type.EndPortalFrame; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +public abstract class CraftEndPortalFrame extends CraftBlockData implements EndPortalFrame { + + private static final net.minecraft.server.BlockStateBoolean EYE = getBoolean("eye"); + + @Override + public boolean hasEye() { + return get(EYE); + } + + @Override + public void setEye(boolean eye) { + set(EYE, eye); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftFarmland.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftFarmland.java new file mode 100644 index 0000000000..515ee588ca --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftFarmland.java @@ -0,0 +1,24 @@ +package org.bukkit.craftbukkit.block.data.type; + +import org.bukkit.block.data.type.Farmland; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +public abstract class CraftFarmland extends CraftBlockData implements Farmland { + + private static final net.minecraft.server.BlockStateInteger MOISTURE = getInteger("moisture"); + + @Override + public int getMoisture() { + return get(MOISTURE); + } + + @Override + public void setMoisture(int moisture) { + set(MOISTURE, moisture); + } + + @Override + public int getMaximumMoisture() { + return getMax(MOISTURE); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftGate.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftGate.java new file mode 100644 index 0000000000..1f6ad5d98c --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftGate.java @@ -0,0 +1,19 @@ +package org.bukkit.craftbukkit.block.data.type; + +import org.bukkit.block.data.type.Gate; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +public abstract class CraftGate extends CraftBlockData implements Gate { + + private static final net.minecraft.server.BlockStateBoolean IN_WALL = getBoolean("in_wall"); + + @Override + public boolean isInWall() { + return get(IN_WALL); + } + + @Override + public void setInWall(boolean inWall) { + set(IN_WALL, inWall); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftHopper.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftHopper.java new file mode 100644 index 0000000000..055629fde5 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftHopper.java @@ -0,0 +1,19 @@ +package org.bukkit.craftbukkit.block.data.type; + +import org.bukkit.block.data.type.Hopper; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +public abstract class CraftHopper extends CraftBlockData implements Hopper { + + private static final net.minecraft.server.BlockStateBoolean ENABLED = getBoolean("enabled"); + + @Override + public boolean isEnabled() { + return get(ENABLED); + } + + @Override + public void setEnabled(boolean enabled) { + set(ENABLED, enabled); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftJukebox.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftJukebox.java new file mode 100644 index 0000000000..32eab86d7d --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftJukebox.java @@ -0,0 +1,14 @@ +package org.bukkit.craftbukkit.block.data.type; + +import org.bukkit.craftbukkit.block.data.CraftBlockData; +import org.bukkit.block.data.type.Jukebox; + +public abstract class CraftJukebox extends CraftBlockData implements Jukebox { + + private static final net.minecraft.server.BlockStateBoolean HAS_RECORD = getBoolean("has_record"); + + @Override + public boolean hasRecord() { + return get(HAS_RECORD); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftLeaves.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftLeaves.java new file mode 100644 index 0000000000..a233f55502 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftLeaves.java @@ -0,0 +1,30 @@ +package org.bukkit.craftbukkit.block.data.type; + +import org.bukkit.block.data.type.Leaves; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +public class CraftLeaves extends CraftBlockData implements Leaves { + + private static final net.minecraft.server.BlockStateInteger DISTANCE = getInteger("distance"); + private static final net.minecraft.server.BlockStateBoolean PERSISTENT = getBoolean("persistent"); + + @Override + public boolean isPersistent() { + return get(PERSISTENT); + } + + @Override + public void setPersistent(boolean persistent) { + set(PERSISTENT, persistent); + } + + @Override + public int getDistance() { + return get(DISTANCE); + } + + @Override + public void setDistance(int distance) { + set(DISTANCE, distance); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftNoteBlock.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftNoteBlock.java new file mode 100644 index 0000000000..51814a4975 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftNoteBlock.java @@ -0,0 +1,30 @@ +package org.bukkit.craftbukkit.block.data.type; + +import org.bukkit.block.data.type.NoteBlock; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +public abstract class CraftNoteBlock extends CraftBlockData implements NoteBlock { + + private static final net.minecraft.server.BlockStateEnum INSTRUMENT = getEnum("instrument"); + private static final net.minecraft.server.BlockStateInteger NOTE = getInteger("note"); + + @Override + public org.bukkit.Instrument getInstrument() { + return get(INSTRUMENT, org.bukkit.Instrument.class); + } + + @Override + public void setInstrument(org.bukkit.Instrument instrument) { + set(INSTRUMENT, instrument); + } + + @Override + public org.bukkit.Note getNote() { + return new org.bukkit.Note(get(NOTE)); + } + + @Override + public void setNote(org.bukkit.Note note) { + set(NOTE, (int) note.getId()); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftPiston.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftPiston.java new file mode 100644 index 0000000000..8cebb751e1 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftPiston.java @@ -0,0 +1,19 @@ +package org.bukkit.craftbukkit.block.data.type; + +import org.bukkit.block.data.type.Piston; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +public abstract class CraftPiston extends CraftBlockData implements Piston { + + private static final net.minecraft.server.BlockStateBoolean EXTENDED = getBoolean("extended"); + + @Override + public boolean isExtended() { + return get(EXTENDED); + } + + @Override + public void setExtended(boolean extended) { + set(EXTENDED, extended); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftPistonHead.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftPistonHead.java new file mode 100644 index 0000000000..3fb24d4b85 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftPistonHead.java @@ -0,0 +1,19 @@ +package org.bukkit.craftbukkit.block.data.type; + +import org.bukkit.block.data.type.PistonHead; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +public abstract class CraftPistonHead extends CraftBlockData implements PistonHead { + + private static final net.minecraft.server.BlockStateBoolean SHORT = getBoolean("short"); + + @Override + public boolean isShort() { + return get(SHORT); + } + + @Override + public void setShort(boolean _short) { + set(SHORT, _short); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftRedstoneWire.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftRedstoneWire.java new file mode 100644 index 0000000000..34923dad6d --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftRedstoneWire.java @@ -0,0 +1,49 @@ +package org.bukkit.craftbukkit.block.data.type; + +import org.bukkit.block.data.type.RedstoneWire; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +public abstract class CraftRedstoneWire extends CraftBlockData implements RedstoneWire { + + private static final net.minecraft.server.BlockStateEnum NORTH = getEnum("north"); + private static final net.minecraft.server.BlockStateEnum EAST = getEnum("east"); + private static final net.minecraft.server.BlockStateEnum SOUTH = getEnum("south"); + private static final net.minecraft.server.BlockStateEnum WEST = getEnum("west"); + + @Override + public Connection getFace(org.bukkit.block.BlockFace face) { + switch (face) { + case NORTH: + return get(NORTH, Connection.class); + case EAST: + return get(EAST, Connection.class); + case SOUTH: + return get(SOUTH, Connection.class); + case WEST: + return get(WEST, Connection.class); + default: + throw new IllegalArgumentException("Cannot have face " + face); + } + } + + @Override + public void setFace(org.bukkit.block.BlockFace face, Connection connection) { + switch (face) { + case NORTH: + set(NORTH, connection); + case EAST: + set(EAST, connection); + case SOUTH: + set(SOUTH, connection); + case WEST: + set(WEST, connection); + default: + throw new IllegalArgumentException("Cannot have face " + face); + } + } + + @Override + public java.util.Set getAllowedFaces() { + return com.google.common.collect.ImmutableSet.of(org.bukkit.block.BlockFace.NORTH, org.bukkit.block.BlockFace.EAST, org.bukkit.block.BlockFace.SOUTH, org.bukkit.block.BlockFace.WEST); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftRepeater.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftRepeater.java new file mode 100644 index 0000000000..482a4ed758 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftRepeater.java @@ -0,0 +1,40 @@ +package org.bukkit.craftbukkit.block.data.type; + +import org.bukkit.block.data.type.Repeater; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +public abstract class CraftRepeater extends CraftBlockData implements Repeater { + + private static final net.minecraft.server.BlockStateInteger DELAY = getInteger("delay"); + private static final net.minecraft.server.BlockStateBoolean LOCKED = getBoolean("locked"); + + @Override + public int getDelay() { + return get(DELAY); + } + + @Override + public void setDelay(int delay) { + set(DELAY, delay); + } + + @Override + public int getMinimumDelay() { + return getMin(DELAY); + } + + @Override + public int getMaximumDelay() { + return getMax(DELAY); + } + + @Override + public boolean isLocked() { + return get(LOCKED); + } + + @Override + public void setLocked(boolean locked) { + set(LOCKED, locked); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftSapling.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftSapling.java new file mode 100644 index 0000000000..dd96acff1b --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftSapling.java @@ -0,0 +1,24 @@ +package org.bukkit.craftbukkit.block.data.type; + +import org.bukkit.block.data.type.Sapling; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +public abstract class CraftSapling extends CraftBlockData implements Sapling { + + private static final net.minecraft.server.BlockStateInteger STAGE = getInteger("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/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftSeaPickle.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftSeaPickle.java new file mode 100644 index 0000000000..dc138d9c76 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftSeaPickle.java @@ -0,0 +1,29 @@ +package org.bukkit.craftbukkit.block.data.type; + +import org.bukkit.block.data.type.SeaPickle; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +public abstract class CraftSeaPickle extends CraftBlockData implements SeaPickle { + + private static final net.minecraft.server.BlockStateInteger PICKLES = getInteger("pickles"); + + @Override + public int getPickles() { + return get(PICKLES); + } + + @Override + public void setPickles(int pickles) { + set(PICKLES, pickles); + } + + @Override + public int getMinimumPickles() { + return getMin(PICKLES); + } + + @Override + public int getMaximumPickles() { + return getMax(PICKLES); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftSlab.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftSlab.java new file mode 100644 index 0000000000..1fde489e55 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftSlab.java @@ -0,0 +1,19 @@ +package org.bukkit.craftbukkit.block.data.type; + +import org.bukkit.block.data.type.Slab; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +public abstract class CraftSlab extends CraftBlockData implements Slab { + + private static final net.minecraft.server.BlockStateEnum TYPE = getEnum("type"); + + @Override + public Type getType() { + return get(TYPE, Type.class); + } + + @Override + public void setType(Type type) { + set(TYPE, type); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftSnow.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftSnow.java new file mode 100644 index 0000000000..879a5d679a --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftSnow.java @@ -0,0 +1,29 @@ +package org.bukkit.craftbukkit.block.data.type; + +import org.bukkit.block.data.type.Snow; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +public class CraftSnow extends CraftBlockData implements Snow { + + private static final net.minecraft.server.BlockStateInteger LAYERS = getInteger("layers"); + + @Override + public int getLayers() { + return get(LAYERS); + } + + @Override + public void setLayers(int layers) { + set(LAYERS, layers); + } + + @Override + public int getMinimumLayers() { + return getMin(LAYERS); + } + + @Override + public int getMaximumLayers() { + return getMax(LAYERS); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftStairs.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftStairs.java new file mode 100644 index 0000000000..c6ccd382f0 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftStairs.java @@ -0,0 +1,19 @@ +package org.bukkit.craftbukkit.block.data.type; + +import org.bukkit.block.data.type.Stairs; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +public abstract class CraftStairs extends CraftBlockData implements Stairs { + + private static final net.minecraft.server.BlockStateEnum SHAPE = getEnum("shape"); + + @Override + public Shape getShape() { + return get(SHAPE, Shape.class); + } + + @Override + public void setShape(Shape shape) { + set(SHAPE, shape); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftStructureBlock.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftStructureBlock.java new file mode 100644 index 0000000000..8b8a82bd36 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftStructureBlock.java @@ -0,0 +1,19 @@ +package org.bukkit.craftbukkit.block.data.type; + +import org.bukkit.block.data.type.StructureBlock; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +public abstract class CraftStructureBlock extends CraftBlockData implements StructureBlock { + + private static final net.minecraft.server.BlockStateEnum MODE = getEnum("mode"); + + @Override + public Mode getMode() { + return get(MODE, Mode.class); + } + + @Override + public void setMode(Mode mode) { + set(MODE, mode); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftSwitch.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftSwitch.java new file mode 100644 index 0000000000..2761b3710b --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftSwitch.java @@ -0,0 +1,19 @@ +package org.bukkit.craftbukkit.block.data.type; + +import org.bukkit.block.data.type.Switch; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +public abstract class CraftSwitch extends CraftBlockData implements Switch { + + private static final net.minecraft.server.BlockStateEnum FACE = getEnum("face"); + + @Override + public Face getFace() { + return get(FACE, Face.class); + } + + @Override + public void setFace(Face face) { + set(FACE, face); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftTechnicalPiston.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftTechnicalPiston.java new file mode 100644 index 0000000000..e42fe0d675 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftTechnicalPiston.java @@ -0,0 +1,19 @@ +package org.bukkit.craftbukkit.block.data.type; + +import org.bukkit.block.data.type.TechnicalPiston; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +public abstract class CraftTechnicalPiston extends CraftBlockData implements TechnicalPiston { + + private static final net.minecraft.server.BlockStateEnum TYPE = getEnum("type"); + + @Override + public Type getType() { + return get(TYPE, Type.class); + } + + @Override + public void setType(Type type) { + set(TYPE, type); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftTripwire.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftTripwire.java new file mode 100644 index 0000000000..55bacd2e5b --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftTripwire.java @@ -0,0 +1,19 @@ +package org.bukkit.craftbukkit.block.data.type; + +import org.bukkit.block.data.type.Tripwire; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +public abstract class CraftTripwire extends CraftBlockData implements Tripwire { + + private static final net.minecraft.server.BlockStateBoolean DISARMED = getBoolean("disarmed"); + + @Override + public boolean isDisarmed() { + return get(DISARMED); + } + + @Override + public void setDisarmed(boolean disarmed) { + set(DISARMED, disarmed); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftTurtleEgg.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftTurtleEgg.java new file mode 100644 index 0000000000..dca37886e5 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftTurtleEgg.java @@ -0,0 +1,45 @@ +package org.bukkit.craftbukkit.block.data.type; + +import org.bukkit.block.data.type.TurtleEgg; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +public abstract class CraftTurtleEgg extends CraftBlockData implements TurtleEgg { + + private static final net.minecraft.server.BlockStateInteger EGGS = getInteger("eggs"); + private static final net.minecraft.server.BlockStateInteger HATCH = getInteger("hatch"); + + @Override + public int getEggs() { + return get(EGGS); + } + + @Override + public void setEggs(int eggs) { + set(EGGS, eggs); + } + + @Override + public int getMinimumEggs() { + return getMin(EGGS); + } + + @Override + public int getMaximumEggs() { + return getMax(EGGS); + } + + @Override + public int getHatch() { + return get(HATCH); + } + + @Override + public void setHatch(int hatch) { + set(HATCH, hatch); + } + + @Override + public int getMaximumHatch() { + return getMax(HATCH); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftAnvil.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftAnvil.java new file mode 100644 index 0000000000..3010e8fe12 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftAnvil.java @@ -0,0 +1,34 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftAnvil extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Directional { + + public CraftAnvil() { + super(); + } + + public CraftAnvil(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.BlockAnvil.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/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftBanner.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftBanner.java new file mode 100644 index 0000000000..d95c548bc4 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftBanner.java @@ -0,0 +1,118 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftBanner extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Rotatable { + + public CraftBanner() { + super(); + } + + public CraftBanner(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.CraftRotatable + + private static final net.minecraft.server.BlockStateInteger ROTATION = getInteger(net.minecraft.server.BlockBanner.class, "rotation"); + + @Override + public org.bukkit.block.BlockFace getRotation() { + int data = get(ROTATION); + switch (data) { + case 0x0: + return org.bukkit.block.BlockFace.SOUTH; + case 0x1: + return org.bukkit.block.BlockFace.SOUTH_SOUTH_WEST; + case 0x2: + return org.bukkit.block.BlockFace.SOUTH_WEST; + case 0x3: + return org.bukkit.block.BlockFace.WEST_SOUTH_WEST; + case 0x4: + return org.bukkit.block.BlockFace.WEST; + case 0x5: + return org.bukkit.block.BlockFace.WEST_NORTH_WEST; + case 0x6: + return org.bukkit.block.BlockFace.NORTH_WEST; + case 0x7: + return org.bukkit.block.BlockFace.NORTH_NORTH_WEST; + case 0x8: + return org.bukkit.block.BlockFace.NORTH; + case 0x9: + return org.bukkit.block.BlockFace.NORTH_NORTH_EAST; + case 0xA: + return org.bukkit.block.BlockFace.NORTH_EAST; + case 0xB: + return org.bukkit.block.BlockFace.EAST_NORTH_EAST; + case 0xC: + return org.bukkit.block.BlockFace.EAST; + case 0xD: + return org.bukkit.block.BlockFace.EAST_SOUTH_EAST; + case 0xE: + return org.bukkit.block.BlockFace.SOUTH_EAST; + case 0xF: + return org.bukkit.block.BlockFace.SOUTH_SOUTH_EAST; + default: + throw new IllegalArgumentException("Unknown rotation " + data); + } + } + + @Override + public void setRotation(org.bukkit.block.BlockFace rotation) { + int val; + switch (rotation) { + case SOUTH: + val = 0x0; + break; + case SOUTH_SOUTH_WEST: + val = 0x1; + break; + case SOUTH_WEST: + val = 0x2; + break; + case WEST_SOUTH_WEST: + val = 0x3; + break; + case WEST: + val = 0x4; + break; + case WEST_NORTH_WEST: + val = 0x5; + break; + case NORTH_WEST: + val = 0x6; + break; + case NORTH_NORTH_WEST: + val = 0x7; + break; + case NORTH: + val = 0x8; + break; + case NORTH_NORTH_EAST: + val = 0x9; + break; + case NORTH_EAST: + val = 0xA; + break; + case EAST_NORTH_EAST: + val = 0xB; + break; + case EAST: + val = 0xC; + break; + case EAST_SOUTH_EAST: + val = 0xD; + break; + case SOUTH_EAST: + val = 0xE; + break; + case SOUTH_SOUTH_EAST: + val = 0xF; + break; + default: + throw new IllegalArgumentException("Illegal rotation " + rotation); + } + set(ROTATION, val); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftBannerWall.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftBannerWall.java new file mode 100644 index 0000000000..48215035fc --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftBannerWall.java @@ -0,0 +1,34 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftBannerWall extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Directional { + + public CraftBannerWall() { + super(); + } + + public CraftBannerWall(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.BlockBannerWall.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/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftBed.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftBed.java new file mode 100644 index 0000000000..c625c964e2 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftBed.java @@ -0,0 +1,54 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftBed extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Bed, org.bukkit.block.data.Directional { + + public CraftBed() { + super(); + } + + public CraftBed(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.type.CraftBed + + private static final net.minecraft.server.BlockStateEnum PART = getEnum(net.minecraft.server.BlockBed.class, "part"); + private static final net.minecraft.server.BlockStateBoolean OCCUPIED = getBoolean(net.minecraft.server.BlockBed.class, "occupied"); + + @Override + public Part getPart() { + return get(PART, Part.class); + } + + @Override + public void setPart(Part part) { + set(PART, part); + } + + @Override + public boolean isOccupied() { + return get(OCCUPIED); + } + + // org.bukkit.craftbukkit.block.data.CraftDirectional + + private static final net.minecraft.server.BlockStateEnum FACING = getEnum(net.minecraft.server.BlockBed.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/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftBeetroot.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftBeetroot.java new file mode 100644 index 0000000000..4e9a27f47c --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftBeetroot.java @@ -0,0 +1,34 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftBeetroot extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Ageable { + + public CraftBeetroot() { + super(); + } + + public CraftBeetroot(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.BlockBeetroot.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/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftBrewingStand.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftBrewingStand.java new file mode 100644 index 0000000000..fe0e7dec6e --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftBrewingStand.java @@ -0,0 +1,49 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftBrewingStand extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.BrewingStand { + + public CraftBrewingStand() { + super(); + } + + public CraftBrewingStand(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.type.CraftBrewingStand + + private static final net.minecraft.server.BlockStateBoolean[] HAS_BOTTLE = new net.minecraft.server.BlockStateBoolean[]{ + getBoolean(net.minecraft.server.BlockBrewingStand.class, "has_bottle_0"), getBoolean(net.minecraft.server.BlockBrewingStand.class, "has_bottle_1"), getBoolean(net.minecraft.server.BlockBrewingStand.class, "has_bottle_2") + }; + + @Override + public boolean hasBottle(int bottle) { + return get(HAS_BOTTLE[bottle]); + } + + @Override + public void setBottle(int bottle, boolean has) { + set(HAS_BOTTLE[bottle], has); + } + + @Override + public java.util.Set getBottles() { + com.google.common.collect.ImmutableSet.Builder bottles = com.google.common.collect.ImmutableSet.builder(); + + for (int index = 0; index < getMaximumBottles(); index++) { + if (hasBottle(index)) { + bottles.add(index); + } + } + + return bottles.build(); + } + + @Override + public int getMaximumBottles() { + return HAS_BOTTLE.length; + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftBubbleColumn.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftBubbleColumn.java new file mode 100644 index 0000000000..574a5b9a71 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftBubbleColumn.java @@ -0,0 +1,29 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftBubbleColumn extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.BubbleColumn { + + public CraftBubbleColumn() { + super(); + } + + public CraftBubbleColumn(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.type.CraftBubbleColumn + + private static final net.minecraft.server.BlockStateBoolean DRAG = getBoolean(net.minecraft.server.BlockBubbleColumn.class, "drag"); + + @Override + public boolean isDrag() { + return get(DRAG); + } + + @Override + public void setDrag(boolean drag) { + set(DRAG, drag); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCactus.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCactus.java new file mode 100644 index 0000000000..e62f4dd17f --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCactus.java @@ -0,0 +1,34 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftCactus extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Ageable { + + public CraftCactus() { + super(); + } + + public CraftCactus(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.BlockCactus.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/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCake.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCake.java new file mode 100644 index 0000000000..fee523abe8 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCake.java @@ -0,0 +1,34 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftCake extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Cake { + + public CraftCake() { + super(); + } + + public CraftCake(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.type.CraftCake + + private static final net.minecraft.server.BlockStateInteger BITES = getInteger(net.minecraft.server.BlockCake.class, "bites"); + + @Override + public int getBites() { + return get(BITES); + } + + @Override + public void setBites(int bites) { + set(BITES, bites); + } + + @Override + public int getMaximumBites() { + return getMax(BITES); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCarrots.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCarrots.java new file mode 100644 index 0000000000..9ab29636e5 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCarrots.java @@ -0,0 +1,34 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftCarrots extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Ageable { + + public CraftCarrots() { + super(); + } + + public CraftCarrots(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.BlockCarrots.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/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCauldron.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCauldron.java new file mode 100644 index 0000000000..5ddeb71582 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCauldron.java @@ -0,0 +1,34 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftCauldron extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Levelled { + + public CraftCauldron() { + super(); + } + + public CraftCauldron(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.BlockCauldron.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/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftChest.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftChest.java new file mode 100644 index 0000000000..44f3a5328b --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftChest.java @@ -0,0 +1,62 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftChest extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Chest, org.bukkit.block.data.Directional, org.bukkit.block.data.Waterlogged { + + public CraftChest() { + super(); + } + + public CraftChest(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.type.CraftChest + + private static final net.minecraft.server.BlockStateEnum TYPE = getEnum(net.minecraft.server.BlockChest.class, "type"); + + @Override + public Type getType() { + return get(TYPE, Type.class); + } + + @Override + public void setType(Type type) { + set(TYPE, type); + } + + // org.bukkit.craftbukkit.block.data.CraftDirectional + + private static final net.minecraft.server.BlockStateEnum FACING = getEnum(net.minecraft.server.BlockChest.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.CraftWaterlogged + + private static final net.minecraft.server.BlockStateBoolean WATERLOGGED = getBoolean(net.minecraft.server.BlockChest.class, "waterlogged"); + + @Override + public boolean isWaterlogged() { + return get(WATERLOGGED); + } + + @Override + public void setWaterlogged(boolean waterlogged) { + set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftChestTrapped.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftChestTrapped.java new file mode 100644 index 0000000000..cc8f88baad --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftChestTrapped.java @@ -0,0 +1,62 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftChestTrapped extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Chest, org.bukkit.block.data.Directional, org.bukkit.block.data.Waterlogged { + + public CraftChestTrapped() { + super(); + } + + public CraftChestTrapped(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.type.CraftChest + + private static final net.minecraft.server.BlockStateEnum TYPE = getEnum(net.minecraft.server.BlockChestTrapped.class, "type"); + + @Override + public Type getType() { + return get(TYPE, Type.class); + } + + @Override + public void setType(Type type) { + set(TYPE, type); + } + + // org.bukkit.craftbukkit.block.data.CraftDirectional + + private static final net.minecraft.server.BlockStateEnum FACING = getEnum(net.minecraft.server.BlockChestTrapped.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.CraftWaterlogged + + private static final net.minecraft.server.BlockStateBoolean WATERLOGGED = getBoolean(net.minecraft.server.BlockChestTrapped.class, "waterlogged"); + + @Override + public boolean isWaterlogged() { + return get(WATERLOGGED); + } + + @Override + public void setWaterlogged(boolean waterlogged) { + set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftChorusFlower.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftChorusFlower.java new file mode 100644 index 0000000000..af1e85bcdb --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftChorusFlower.java @@ -0,0 +1,34 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftChorusFlower extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Ageable { + + public CraftChorusFlower() { + super(); + } + + public CraftChorusFlower(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.BlockChorusFlower.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/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftChorusFruit.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftChorusFruit.java new file mode 100644 index 0000000000..27ae41a929 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftChorusFruit.java @@ -0,0 +1,57 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftChorusFruit extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.MultipleFacing { + + public CraftChorusFruit() { + super(); + } + + public CraftChorusFruit(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.BlockChorusFruit.class, "north", true), getBoolean(net.minecraft.server.BlockChorusFruit.class, "east", true), getBoolean(net.minecraft.server.BlockChorusFruit.class, "south", true), getBoolean(net.minecraft.server.BlockChorusFruit.class, "west", true), getBoolean(net.minecraft.server.BlockChorusFruit.class, "up", true), getBoolean(net.minecraft.server.BlockChorusFruit.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(); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCobbleWall.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCobbleWall.java new file mode 100644 index 0000000000..b1acc7c441 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCobbleWall.java @@ -0,0 +1,71 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftCobbleWall extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Fence, org.bukkit.block.data.MultipleFacing, org.bukkit.block.data.Waterlogged { + + public CraftCobbleWall() { + super(); + } + + public CraftCobbleWall(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.BlockCobbleWall.class, "north", true), getBoolean(net.minecraft.server.BlockCobbleWall.class, "east", true), getBoolean(net.minecraft.server.BlockCobbleWall.class, "south", true), getBoolean(net.minecraft.server.BlockCobbleWall.class, "west", true), getBoolean(net.minecraft.server.BlockCobbleWall.class, "up", true), getBoolean(net.minecraft.server.BlockCobbleWall.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.BlockCobbleWall.class, "waterlogged"); + + @Override + public boolean isWaterlogged() { + return get(WATERLOGGED); + } + + @Override + public void setWaterlogged(boolean waterlogged) { + set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCocoa.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCocoa.java new file mode 100644 index 0000000000..79b2b52cac --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCocoa.java @@ -0,0 +1,53 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftCocoa extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Cocoa, org.bukkit.block.data.Ageable, org.bukkit.block.data.Directional { + + public CraftCocoa() { + super(); + } + + public CraftCocoa(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.BlockCocoa.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.CraftDirectional + + private static final net.minecraft.server.BlockStateEnum FACING = getEnum(net.minecraft.server.BlockCocoa.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/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCommand.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCommand.java new file mode 100644 index 0000000000..ed1684a63d --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCommand.java @@ -0,0 +1,48 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftCommand extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.CommandBlock, org.bukkit.block.data.Directional { + + public CraftCommand() { + super(); + } + + public CraftCommand(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.type.CraftCommandBlock + + private static final net.minecraft.server.BlockStateBoolean CONDITIONAL = getBoolean(net.minecraft.server.BlockCommand.class, "conditional"); + + @Override + public boolean isConditional() { + return get(CONDITIONAL); + } + + @Override + public void setConditional(boolean conditional) { + set(CONDITIONAL, conditional); + } + + // org.bukkit.craftbukkit.block.data.CraftDirectional + + private static final net.minecraft.server.BlockStateEnum FACING = getEnum(net.minecraft.server.BlockCommand.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/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCoralFan.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCoralFan.java new file mode 100644 index 0000000000..3385af14d6 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCoralFan.java @@ -0,0 +1,34 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftCoralFan extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Directional { + + public CraftCoralFan() { + super(); + } + + public CraftCoralFan(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.BlockCoralFan.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/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCrops.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCrops.java new file mode 100644 index 0000000000..61921a2a5e --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCrops.java @@ -0,0 +1,34 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftCrops extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Ageable { + + public CraftCrops() { + super(); + } + + public CraftCrops(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.BlockCrops.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/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftDaylightDetector.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftDaylightDetector.java new file mode 100644 index 0000000000..ffed5c9a38 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftDaylightDetector.java @@ -0,0 +1,48 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftDaylightDetector extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.DaylightDetector, org.bukkit.block.data.AnaloguePowerable { + + public CraftDaylightDetector() { + super(); + } + + public CraftDaylightDetector(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.type.CraftDaylightDetector + + private static final net.minecraft.server.BlockStateBoolean INVERTED = getBoolean(net.minecraft.server.BlockDaylightDetector.class, "inverted"); + + @Override + public boolean isInverted() { + return get(INVERTED); + } + + @Override + public void setInverted(boolean inverted) { + set(INVERTED, inverted); + } + + // org.bukkit.craftbukkit.block.data.CraftAnaloguePowerable + + private static final net.minecraft.server.BlockStateInteger POWER = getInteger(net.minecraft.server.BlockDaylightDetector.class, "power"); + + @Override + public int getPower() { + return get(POWER); + } + + @Override + public void setPower(int power) { + set(POWER, power); + } + + @Override + public int getMaximumPower() { + return getMax(POWER); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftDirtSnow.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftDirtSnow.java new file mode 100644 index 0000000000..7c3857e925 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftDirtSnow.java @@ -0,0 +1,29 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftDirtSnow extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Snowable { + + public CraftDirtSnow() { + super(); + } + + public CraftDirtSnow(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.CraftSnowable + + private static final net.minecraft.server.BlockStateBoolean SNOWY = getBoolean(net.minecraft.server.BlockDirtSnow.class, "snowy"); + + @Override + public boolean isSnowy() { + return get(SNOWY); + } + + @Override + public void setSnowy(boolean snowy) { + set(SNOWY, snowy); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftDispenser.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftDispenser.java new file mode 100644 index 0000000000..cea8f941e6 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftDispenser.java @@ -0,0 +1,48 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftDispenser extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Dispenser, org.bukkit.block.data.Directional { + + public CraftDispenser() { + super(); + } + + public CraftDispenser(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.type.CraftDispenser + + private static final net.minecraft.server.BlockStateBoolean TRIGGERED = getBoolean(net.minecraft.server.BlockDispenser.class, "triggered"); + + @Override + public boolean isTriggered() { + return get(TRIGGERED); + } + + @Override + public void setTriggered(boolean triggered) { + set(TRIGGERED, triggered); + } + + // org.bukkit.craftbukkit.block.data.CraftDirectional + + private static final net.minecraft.server.BlockStateEnum FACING = getEnum(net.minecraft.server.BlockDispenser.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/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftDoor.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftDoor.java new file mode 100644 index 0000000000..ec8639bf12 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftDoor.java @@ -0,0 +1,90 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftDoor extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Door, org.bukkit.block.data.Bisected, org.bukkit.block.data.Directional, org.bukkit.block.data.Openable, org.bukkit.block.data.Powerable { + + public CraftDoor() { + super(); + } + + public CraftDoor(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.type.CraftDoor + + private static final net.minecraft.server.BlockStateEnum HINGE = getEnum(net.minecraft.server.BlockDoor.class, "hinge"); + + @Override + public Hinge getHinge() { + return get(HINGE, Hinge.class); + } + + @Override + public void setHinge(Hinge hinge) { + set(HINGE, hinge); + } + + // org.bukkit.craftbukkit.block.data.CraftBisected + + private static final net.minecraft.server.BlockStateEnum HALF = getEnum(net.minecraft.server.BlockDoor.class, "half"); + + @Override + public Half getHalf() { + return get(HALF, Half.class); + } + + @Override + public void setHalf(Half half) { + set(HALF, half); + } + + // org.bukkit.craftbukkit.block.data.CraftDirectional + + private static final net.minecraft.server.BlockStateEnum FACING = getEnum(net.minecraft.server.BlockDoor.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.CraftOpenable + + private static final net.minecraft.server.BlockStateBoolean OPEN = getBoolean(net.minecraft.server.BlockDoor.class, "open"); + + @Override + public boolean isOpen() { + return get(OPEN); + } + + @Override + public void setOpen(boolean open) { + set(OPEN, open); + } + + // org.bukkit.craftbukkit.block.data.CraftPowerable + + private static final net.minecraft.server.BlockStateBoolean POWERED = getBoolean(net.minecraft.server.BlockDoor.class, "powered"); + + @Override + public boolean isPowered() { + return get(POWERED); + } + + @Override + public void setPowered(boolean powered) { + set(POWERED, powered); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftDropper.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftDropper.java new file mode 100644 index 0000000000..82486f1b0a --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftDropper.java @@ -0,0 +1,48 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftDropper extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Dispenser, org.bukkit.block.data.Directional { + + public CraftDropper() { + super(); + } + + public CraftDropper(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.type.CraftDispenser + + private static final net.minecraft.server.BlockStateBoolean TRIGGERED = getBoolean(net.minecraft.server.BlockDropper.class, "triggered"); + + @Override + public boolean isTriggered() { + return get(TRIGGERED); + } + + @Override + public void setTriggered(boolean triggered) { + set(TRIGGERED, triggered); + } + + // org.bukkit.craftbukkit.block.data.CraftDirectional + + private static final net.minecraft.server.BlockStateEnum FACING = getEnum(net.minecraft.server.BlockDropper.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/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftEndRod.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftEndRod.java new file mode 100644 index 0000000000..d72c9d0509 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftEndRod.java @@ -0,0 +1,34 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftEndRod extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Directional { + + public CraftEndRod() { + super(); + } + + public CraftEndRod(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.BlockEndRod.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/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftEnderChest.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftEnderChest.java new file mode 100644 index 0000000000..2f83808073 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftEnderChest.java @@ -0,0 +1,48 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftEnderChest extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.EnderChest, org.bukkit.block.data.Directional, org.bukkit.block.data.Waterlogged { + + public CraftEnderChest() { + super(); + } + + public CraftEnderChest(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.BlockEnderChest.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.CraftWaterlogged + + private static final net.minecraft.server.BlockStateBoolean WATERLOGGED = getBoolean(net.minecraft.server.BlockEnderChest.class, "waterlogged"); + + @Override + public boolean isWaterlogged() { + return get(WATERLOGGED); + } + + @Override + public void setWaterlogged(boolean waterlogged) { + set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftEnderPortalFrame.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftEnderPortalFrame.java new file mode 100644 index 0000000000..f57cbbeca1 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftEnderPortalFrame.java @@ -0,0 +1,48 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftEnderPortalFrame extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.EndPortalFrame, org.bukkit.block.data.Directional { + + public CraftEnderPortalFrame() { + super(); + } + + public CraftEnderPortalFrame(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.type.CraftEndPortalFrame + + private static final net.minecraft.server.BlockStateBoolean EYE = getBoolean(net.minecraft.server.BlockEnderPortalFrame.class, "eye"); + + @Override + public boolean hasEye() { + return get(EYE); + } + + @Override + public void setEye(boolean eye) { + set(EYE, eye); + } + + // org.bukkit.craftbukkit.block.data.CraftDirectional + + private static final net.minecraft.server.BlockStateEnum FACING = getEnum(net.minecraft.server.BlockEnderPortalFrame.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/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftFence.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftFence.java new file mode 100644 index 0000000000..1333b997f0 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftFence.java @@ -0,0 +1,71 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftFence extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Fence, org.bukkit.block.data.MultipleFacing, org.bukkit.block.data.Waterlogged { + + public CraftFence() { + super(); + } + + public CraftFence(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.BlockFence.class, "north", true), getBoolean(net.minecraft.server.BlockFence.class, "east", true), getBoolean(net.minecraft.server.BlockFence.class, "south", true), getBoolean(net.minecraft.server.BlockFence.class, "west", true), getBoolean(net.minecraft.server.BlockFence.class, "up", true), getBoolean(net.minecraft.server.BlockFence.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.BlockFence.class, "waterlogged"); + + @Override + public boolean isWaterlogged() { + return get(WATERLOGGED); + } + + @Override + public void setWaterlogged(boolean waterlogged) { + set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftFenceGate.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftFenceGate.java new file mode 100644 index 0000000000..4fc2944527 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftFenceGate.java @@ -0,0 +1,76 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftFenceGate extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Gate, org.bukkit.block.data.Directional, org.bukkit.block.data.Openable, org.bukkit.block.data.Powerable { + + public CraftFenceGate() { + super(); + } + + public CraftFenceGate(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.type.CraftGate + + private static final net.minecraft.server.BlockStateBoolean IN_WALL = getBoolean(net.minecraft.server.BlockFenceGate.class, "in_wall"); + + @Override + public boolean isInWall() { + return get(IN_WALL); + } + + @Override + public void setInWall(boolean inWall) { + set(IN_WALL, inWall); + } + + // org.bukkit.craftbukkit.block.data.CraftDirectional + + private static final net.minecraft.server.BlockStateEnum FACING = getEnum(net.minecraft.server.BlockFenceGate.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.CraftOpenable + + private static final net.minecraft.server.BlockStateBoolean OPEN = getBoolean(net.minecraft.server.BlockFenceGate.class, "open"); + + @Override + public boolean isOpen() { + return get(OPEN); + } + + @Override + public void setOpen(boolean open) { + set(OPEN, open); + } + + // org.bukkit.craftbukkit.block.data.CraftPowerable + + private static final net.minecraft.server.BlockStateBoolean POWERED = getBoolean(net.minecraft.server.BlockFenceGate.class, "powered"); + + @Override + public boolean isPowered() { + return get(POWERED); + } + + @Override + public void setPowered(boolean powered) { + set(POWERED, powered); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftFire.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftFire.java new file mode 100644 index 0000000000..a580935527 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftFire.java @@ -0,0 +1,76 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftFire extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Fire, org.bukkit.block.data.Ageable, org.bukkit.block.data.MultipleFacing { + + public CraftFire() { + super(); + } + + public CraftFire(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.BlockFire.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.CraftMultipleFacing + + private static final net.minecraft.server.BlockStateBoolean[] FACES = new net.minecraft.server.BlockStateBoolean[]{ + getBoolean(net.minecraft.server.BlockFire.class, "north", true), getBoolean(net.minecraft.server.BlockFire.class, "east", true), getBoolean(net.minecraft.server.BlockFire.class, "south", true), getBoolean(net.minecraft.server.BlockFire.class, "west", true), getBoolean(net.minecraft.server.BlockFire.class, "up", true), getBoolean(net.minecraft.server.BlockFire.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(); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftFloorSign.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftFloorSign.java new file mode 100644 index 0000000000..aa52ec7770 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftFloorSign.java @@ -0,0 +1,132 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftFloorSign extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Sign, org.bukkit.block.data.Rotatable, org.bukkit.block.data.Waterlogged { + + public CraftFloorSign() { + super(); + } + + public CraftFloorSign(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.CraftRotatable + + private static final net.minecraft.server.BlockStateInteger ROTATION = getInteger(net.minecraft.server.BlockFloorSign.class, "rotation"); + + @Override + public org.bukkit.block.BlockFace getRotation() { + int data = get(ROTATION); + switch (data) { + case 0x0: + return org.bukkit.block.BlockFace.SOUTH; + case 0x1: + return org.bukkit.block.BlockFace.SOUTH_SOUTH_WEST; + case 0x2: + return org.bukkit.block.BlockFace.SOUTH_WEST; + case 0x3: + return org.bukkit.block.BlockFace.WEST_SOUTH_WEST; + case 0x4: + return org.bukkit.block.BlockFace.WEST; + case 0x5: + return org.bukkit.block.BlockFace.WEST_NORTH_WEST; + case 0x6: + return org.bukkit.block.BlockFace.NORTH_WEST; + case 0x7: + return org.bukkit.block.BlockFace.NORTH_NORTH_WEST; + case 0x8: + return org.bukkit.block.BlockFace.NORTH; + case 0x9: + return org.bukkit.block.BlockFace.NORTH_NORTH_EAST; + case 0xA: + return org.bukkit.block.BlockFace.NORTH_EAST; + case 0xB: + return org.bukkit.block.BlockFace.EAST_NORTH_EAST; + case 0xC: + return org.bukkit.block.BlockFace.EAST; + case 0xD: + return org.bukkit.block.BlockFace.EAST_SOUTH_EAST; + case 0xE: + return org.bukkit.block.BlockFace.SOUTH_EAST; + case 0xF: + return org.bukkit.block.BlockFace.SOUTH_SOUTH_EAST; + default: + throw new IllegalArgumentException("Unknown rotation " + data); + } + } + + @Override + public void setRotation(org.bukkit.block.BlockFace rotation) { + int val; + switch (rotation) { + case SOUTH: + val = 0x0; + break; + case SOUTH_SOUTH_WEST: + val = 0x1; + break; + case SOUTH_WEST: + val = 0x2; + break; + case WEST_SOUTH_WEST: + val = 0x3; + break; + case WEST: + val = 0x4; + break; + case WEST_NORTH_WEST: + val = 0x5; + break; + case NORTH_WEST: + val = 0x6; + break; + case NORTH_NORTH_WEST: + val = 0x7; + break; + case NORTH: + val = 0x8; + break; + case NORTH_NORTH_EAST: + val = 0x9; + break; + case NORTH_EAST: + val = 0xA; + break; + case EAST_NORTH_EAST: + val = 0xB; + break; + case EAST: + val = 0xC; + break; + case EAST_SOUTH_EAST: + val = 0xD; + break; + case SOUTH_EAST: + val = 0xE; + break; + case SOUTH_SOUTH_EAST: + val = 0xF; + break; + default: + throw new IllegalArgumentException("Illegal rotation " + rotation); + } + set(ROTATION, val); + } + + // org.bukkit.craftbukkit.block.data.CraftWaterlogged + + private static final net.minecraft.server.BlockStateBoolean WATERLOGGED = getBoolean(net.minecraft.server.BlockFloorSign.class, "waterlogged"); + + @Override + public boolean isWaterlogged() { + return get(WATERLOGGED); + } + + @Override + public void setWaterlogged(boolean waterlogged) { + set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftFluids.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftFluids.java new file mode 100644 index 0000000000..21c30c7c75 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftFluids.java @@ -0,0 +1,34 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftFluids extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Levelled { + + public CraftFluids() { + super(); + } + + public CraftFluids(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.BlockFluids.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/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftFurnace.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftFurnace.java new file mode 100644 index 0000000000..1ca1a9c796 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftFurnace.java @@ -0,0 +1,48 @@ +/** + * Automatically generated file, changes will be lost. + */ +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 CraftFurnace() { + super(); + } + + public CraftFurnace(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"); + + @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.BlockFurnace.class, "lit"); + + @Override + public boolean isLit() { + return get(LIT); + } + + @Override + public void setLit(boolean lit) { + set(LIT, lit); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftGlassPane.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftGlassPane.java new file mode 100644 index 0000000000..4c8bfcb733 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftGlassPane.java @@ -0,0 +1,71 @@ +/** + * 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/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftGlazedTerracotta.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftGlazedTerracotta.java new file mode 100644 index 0000000000..89cc7f95f2 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftGlazedTerracotta.java @@ -0,0 +1,34 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftGlazedTerracotta extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Directional { + + public CraftGlazedTerracotta() { + super(); + } + + public CraftGlazedTerracotta(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.BlockGlazedTerracotta.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/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftGrass.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftGrass.java new file mode 100644 index 0000000000..08fcfb0b44 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftGrass.java @@ -0,0 +1,29 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftGrass extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Snowable { + + public CraftGrass() { + super(); + } + + public CraftGrass(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.CraftSnowable + + private static final net.minecraft.server.BlockStateBoolean SNOWY = getBoolean(net.minecraft.server.BlockGrass.class, "snowy"); + + @Override + public boolean isSnowy() { + return get(SNOWY); + } + + @Override + public void setSnowy(boolean snowy) { + set(SNOWY, snowy); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftHay.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftHay.java new file mode 100644 index 0000000000..db7d61ad6c --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftHay.java @@ -0,0 +1,34 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftHay extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Orientable { + + public CraftHay() { + super(); + } + + public CraftHay(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.CraftOrientable + + private static final net.minecraft.server.BlockStateEnum AXIS = getEnum(net.minecraft.server.BlockHay.class, "axis"); + + @Override + public org.bukkit.Axis getAxis() { + return get(AXIS, org.bukkit.Axis.class); + } + + @Override + public void setAxis(org.bukkit.Axis axis) { + set(AXIS, axis); + } + + @Override + public java.util.Set getAxes() { + return getValues(AXIS, org.bukkit.Axis.class); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftHopper.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftHopper.java new file mode 100644 index 0000000000..f131151779 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftHopper.java @@ -0,0 +1,48 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftHopper extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Hopper, org.bukkit.block.data.Directional { + + public CraftHopper() { + super(); + } + + public CraftHopper(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.type.CraftHopper + + private static final net.minecraft.server.BlockStateBoolean ENABLED = getBoolean(net.minecraft.server.BlockHopper.class, "enabled"); + + @Override + public boolean isEnabled() { + return get(ENABLED); + } + + @Override + public void setEnabled(boolean enabled) { + set(ENABLED, enabled); + } + + // org.bukkit.craftbukkit.block.data.CraftDirectional + + private static final net.minecraft.server.BlockStateEnum FACING = getEnum(net.minecraft.server.BlockHopper.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/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftHugeMushroom.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftHugeMushroom.java new file mode 100644 index 0000000000..fb6e205077 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftHugeMushroom.java @@ -0,0 +1,57 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftHugeMushroom extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.MultipleFacing { + + public CraftHugeMushroom() { + super(); + } + + public CraftHugeMushroom(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.BlockHugeMushroom.class, "north", true), getBoolean(net.minecraft.server.BlockHugeMushroom.class, "east", true), getBoolean(net.minecraft.server.BlockHugeMushroom.class, "south", true), getBoolean(net.minecraft.server.BlockHugeMushroom.class, "west", true), getBoolean(net.minecraft.server.BlockHugeMushroom.class, "up", true), getBoolean(net.minecraft.server.BlockHugeMushroom.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(); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftIceFrost.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftIceFrost.java new file mode 100644 index 0000000000..7b297dc22d --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftIceFrost.java @@ -0,0 +1,34 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftIceFrost extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Ageable { + + public CraftIceFrost() { + super(); + } + + public CraftIceFrost(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.BlockIceFrost.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/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftIronBars.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftIronBars.java new file mode 100644 index 0000000000..cf6da2dfed --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftIronBars.java @@ -0,0 +1,71 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftIronBars extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Fence, org.bukkit.block.data.MultipleFacing, org.bukkit.block.data.Waterlogged { + + public CraftIronBars() { + super(); + } + + public CraftIronBars(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.BlockIronBars.class, "north", true), getBoolean(net.minecraft.server.BlockIronBars.class, "east", true), getBoolean(net.minecraft.server.BlockIronBars.class, "south", true), getBoolean(net.minecraft.server.BlockIronBars.class, "west", true), getBoolean(net.minecraft.server.BlockIronBars.class, "up", true), getBoolean(net.minecraft.server.BlockIronBars.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.BlockIronBars.class, "waterlogged"); + + @Override + public boolean isWaterlogged() { + return get(WATERLOGGED); + } + + @Override + public void setWaterlogged(boolean waterlogged) { + set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftJukeBox.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftJukeBox.java new file mode 100644 index 0000000000..b87801f3a5 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftJukeBox.java @@ -0,0 +1,24 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftJukeBox extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Jukebox { + + public CraftJukeBox() { + super(); + } + + public CraftJukeBox(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.type.CraftJukebox + + private static final net.minecraft.server.BlockStateBoolean HAS_RECORD = getBoolean(net.minecraft.server.BlockJukeBox.class, "has_record"); + + @Override + public boolean hasRecord() { + return get(HAS_RECORD); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftKelp.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftKelp.java new file mode 100644 index 0000000000..e9ba8ade49 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftKelp.java @@ -0,0 +1,34 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftKelp extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Ageable { + + public CraftKelp() { + super(); + } + + public CraftKelp(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.BlockKelp.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/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftLadder.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftLadder.java new file mode 100644 index 0000000000..2c7f396fa3 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftLadder.java @@ -0,0 +1,48 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftLadder extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Ladder, org.bukkit.block.data.Directional, org.bukkit.block.data.Waterlogged { + + public CraftLadder() { + super(); + } + + public CraftLadder(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.BlockLadder.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.CraftWaterlogged + + private static final net.minecraft.server.BlockStateBoolean WATERLOGGED = getBoolean(net.minecraft.server.BlockLadder.class, "waterlogged"); + + @Override + public boolean isWaterlogged() { + return get(WATERLOGGED); + } + + @Override + public void setWaterlogged(boolean waterlogged) { + set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftLeaves.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftLeaves.java new file mode 100644 index 0000000000..2e2f091b9e --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftLeaves.java @@ -0,0 +1,40 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftLeaves extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Leaves { + + public CraftLeaves() { + super(); + } + + public CraftLeaves(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.type.CraftLeaves + + private static final net.minecraft.server.BlockStateInteger DISTANCE = getInteger(net.minecraft.server.BlockLeaves.class, "distance"); + private static final net.minecraft.server.BlockStateBoolean PERSISTENT = getBoolean(net.minecraft.server.BlockLeaves.class, "persistent"); + + @Override + public boolean isPersistent() { + return get(PERSISTENT); + } + + @Override + public void setPersistent(boolean persistent) { + set(PERSISTENT, persistent); + } + + @Override + public int getDistance() { + return get(DISTANCE); + } + + @Override + public void setDistance(int distance) { + set(DISTANCE, distance); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftLever.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftLever.java new file mode 100644 index 0000000000..a8b030f2fd --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftLever.java @@ -0,0 +1,62 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftLever extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Switch, org.bukkit.block.data.Directional, org.bukkit.block.data.Powerable { + + public CraftLever() { + super(); + } + + public CraftLever(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.type.CraftSwitch + + private static final net.minecraft.server.BlockStateEnum FACE = getEnum(net.minecraft.server.BlockLever.class, "face"); + + @Override + public Face getFace() { + return get(FACE, Face.class); + } + + @Override + public void setFace(Face face) { + set(FACE, face); + } + + // org.bukkit.craftbukkit.block.data.CraftDirectional + + private static final net.minecraft.server.BlockStateEnum FACING = getEnum(net.minecraft.server.BlockLever.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.BlockLever.class, "powered"); + + @Override + public boolean isPowered() { + return get(POWERED); + } + + @Override + public void setPowered(boolean powered) { + set(POWERED, powered); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftLogAbstract.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftLogAbstract.java new file mode 100644 index 0000000000..efa4049023 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftLogAbstract.java @@ -0,0 +1,34 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftLogAbstract extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Orientable { + + public CraftLogAbstract() { + super(); + } + + public CraftLogAbstract(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.CraftOrientable + + private static final net.minecraft.server.BlockStateEnum AXIS = getEnum(net.minecraft.server.BlockLogAbstract.class, "axis"); + + @Override + public org.bukkit.Axis getAxis() { + return get(AXIS, org.bukkit.Axis.class); + } + + @Override + public void setAxis(org.bukkit.Axis axis) { + set(AXIS, axis); + } + + @Override + public java.util.Set getAxes() { + return getValues(AXIS, org.bukkit.Axis.class); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftMinecartDetector.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftMinecartDetector.java new file mode 100644 index 0000000000..9ad25f9fed --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftMinecartDetector.java @@ -0,0 +1,48 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftMinecartDetector extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.RedstoneRail, org.bukkit.block.data.Powerable, org.bukkit.block.data.Rail { + + public CraftMinecartDetector() { + super(); + } + + public CraftMinecartDetector(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.CraftPowerable + + private static final net.minecraft.server.BlockStateBoolean POWERED = getBoolean(net.minecraft.server.BlockMinecartDetector.class, "powered"); + + @Override + public boolean isPowered() { + return get(POWERED); + } + + @Override + public void setPowered(boolean powered) { + set(POWERED, powered); + } + + // org.bukkit.craftbukkit.block.data.CraftRail + + private static final net.minecraft.server.BlockStateEnum SHAPE = getEnum(net.minecraft.server.BlockMinecartDetector.class, "shape"); + + @Override + public Shape getShape() { + return get(SHAPE, Shape.class); + } + + @Override + public void setShape(Shape shape) { + set(SHAPE, shape); + } + + @Override + public java.util.Set getShapes() { + return getValues(SHAPE, Shape.class); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftMinecartTrack.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftMinecartTrack.java new file mode 100644 index 0000000000..127681a63e --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftMinecartTrack.java @@ -0,0 +1,34 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftMinecartTrack extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Rail { + + public CraftMinecartTrack() { + super(); + } + + public CraftMinecartTrack(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.CraftRail + + private static final net.minecraft.server.BlockStateEnum SHAPE = getEnum(net.minecraft.server.BlockMinecartTrack.class, "shape"); + + @Override + public Shape getShape() { + return get(SHAPE, Shape.class); + } + + @Override + public void setShape(Shape shape) { + set(SHAPE, shape); + } + + @Override + public java.util.Set getShapes() { + return getValues(SHAPE, Shape.class); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftMycel.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftMycel.java new file mode 100644 index 0000000000..ca9d60f3ae --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftMycel.java @@ -0,0 +1,29 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftMycel extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Snowable { + + public CraftMycel() { + super(); + } + + public CraftMycel(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.CraftSnowable + + private static final net.minecraft.server.BlockStateBoolean SNOWY = getBoolean(net.minecraft.server.BlockMycel.class, "snowy"); + + @Override + public boolean isSnowy() { + return get(SNOWY); + } + + @Override + public void setSnowy(boolean snowy) { + set(SNOWY, snowy); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftNetherWart.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftNetherWart.java new file mode 100644 index 0000000000..449d0f6f5d --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftNetherWart.java @@ -0,0 +1,34 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftNetherWart extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Ageable { + + public CraftNetherWart() { + super(); + } + + public CraftNetherWart(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.BlockNetherWart.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/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftNote.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftNote.java new file mode 100644 index 0000000000..03a736bd70 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftNote.java @@ -0,0 +1,54 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftNote extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.NoteBlock, org.bukkit.block.data.Powerable { + + public CraftNote() { + super(); + } + + public CraftNote(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.type.CraftNoteBlock + + private static final net.minecraft.server.BlockStateEnum INSTRUMENT = getEnum(net.minecraft.server.BlockNote.class, "instrument"); + private static final net.minecraft.server.BlockStateInteger NOTE = getInteger(net.minecraft.server.BlockNote.class, "note"); + + @Override + public org.bukkit.Instrument getInstrument() { + return get(INSTRUMENT, org.bukkit.Instrument.class); + } + + @Override + public void setInstrument(org.bukkit.Instrument instrument) { + set(INSTRUMENT, instrument); + } + + @Override + public org.bukkit.Note getNote() { + return new org.bukkit.Note(get(NOTE)); + } + + @Override + public void setNote(org.bukkit.Note note) { + set(NOTE, (int) note.getId()); + } + + // org.bukkit.craftbukkit.block.data.CraftPowerable + + private static final net.minecraft.server.BlockStateBoolean POWERED = getBoolean(net.minecraft.server.BlockNote.class, "powered"); + + @Override + public boolean isPowered() { + return get(POWERED); + } + + @Override + public void setPowered(boolean powered) { + set(POWERED, powered); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftObserver.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftObserver.java new file mode 100644 index 0000000000..ba3a4f072f --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftObserver.java @@ -0,0 +1,48 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftObserver extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Observer, org.bukkit.block.data.Directional, org.bukkit.block.data.Powerable { + + public CraftObserver() { + super(); + } + + public CraftObserver(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.BlockObserver.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.BlockObserver.class, "powered"); + + @Override + public boolean isPowered() { + return get(POWERED); + } + + @Override + public void setPowered(boolean powered) { + set(POWERED, powered); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPiston.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPiston.java new file mode 100644 index 0000000000..f16404f492 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPiston.java @@ -0,0 +1,48 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftPiston extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Piston, org.bukkit.block.data.Directional { + + public CraftPiston() { + super(); + } + + public CraftPiston(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.type.CraftPiston + + private static final net.minecraft.server.BlockStateBoolean EXTENDED = getBoolean(net.minecraft.server.BlockPiston.class, "extended"); + + @Override + public boolean isExtended() { + return get(EXTENDED); + } + + @Override + public void setExtended(boolean extended) { + set(EXTENDED, extended); + } + + // org.bukkit.craftbukkit.block.data.CraftDirectional + + private static final net.minecraft.server.BlockStateEnum FACING = getEnum(net.minecraft.server.BlockPiston.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/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPistonExtension.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPistonExtension.java new file mode 100644 index 0000000000..038e584338 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPistonExtension.java @@ -0,0 +1,62 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftPistonExtension extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.PistonHead, org.bukkit.block.data.type.TechnicalPiston, org.bukkit.block.data.Directional { + + public CraftPistonExtension() { + super(); + } + + public CraftPistonExtension(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.type.CraftPistonHead + + private static final net.minecraft.server.BlockStateBoolean SHORT = getBoolean(net.minecraft.server.BlockPistonExtension.class, "short"); + + @Override + public boolean isShort() { + return get(SHORT); + } + + @Override + public void setShort(boolean _short) { + set(SHORT, _short); + } + + // org.bukkit.craftbukkit.block.data.type.CraftTechnicalPiston + + private static final net.minecraft.server.BlockStateEnum TYPE = getEnum(net.minecraft.server.BlockPistonExtension.class, "type"); + + @Override + public Type getType() { + return get(TYPE, Type.class); + } + + @Override + public void setType(Type type) { + set(TYPE, type); + } + + // org.bukkit.craftbukkit.block.data.CraftDirectional + + private static final net.minecraft.server.BlockStateEnum FACING = getEnum(net.minecraft.server.BlockPistonExtension.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/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPistonMoving.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPistonMoving.java new file mode 100644 index 0000000000..38b098e0ac --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPistonMoving.java @@ -0,0 +1,48 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftPistonMoving extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.TechnicalPiston, org.bukkit.block.data.Directional { + + public CraftPistonMoving() { + super(); + } + + public CraftPistonMoving(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.type.CraftTechnicalPiston + + private static final net.minecraft.server.BlockStateEnum TYPE = getEnum(net.minecraft.server.BlockPistonMoving.class, "type"); + + @Override + public Type getType() { + return get(TYPE, Type.class); + } + + @Override + public void setType(Type type) { + set(TYPE, type); + } + + // org.bukkit.craftbukkit.block.data.CraftDirectional + + private static final net.minecraft.server.BlockStateEnum FACING = getEnum(net.minecraft.server.BlockPistonMoving.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/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPortal.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPortal.java new file mode 100644 index 0000000000..7701ca85d9 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPortal.java @@ -0,0 +1,34 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftPortal extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Orientable { + + public CraftPortal() { + super(); + } + + public CraftPortal(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.CraftOrientable + + private static final net.minecraft.server.BlockStateEnum AXIS = getEnum(net.minecraft.server.BlockPortal.class, "axis"); + + @Override + public org.bukkit.Axis getAxis() { + return get(AXIS, org.bukkit.Axis.class); + } + + @Override + public void setAxis(org.bukkit.Axis axis) { + set(AXIS, axis); + } + + @Override + public java.util.Set getAxes() { + return getValues(AXIS, org.bukkit.Axis.class); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPotatoes.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPotatoes.java new file mode 100644 index 0000000000..c09a9c78cd --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPotatoes.java @@ -0,0 +1,34 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftPotatoes extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Ageable { + + public CraftPotatoes() { + super(); + } + + public CraftPotatoes(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.BlockPotatoes.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/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPoweredRail.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPoweredRail.java new file mode 100644 index 0000000000..ea904ef00d --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPoweredRail.java @@ -0,0 +1,48 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftPoweredRail extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.RedstoneRail, org.bukkit.block.data.Powerable, org.bukkit.block.data.Rail { + + public CraftPoweredRail() { + super(); + } + + public CraftPoweredRail(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.CraftPowerable + + private static final net.minecraft.server.BlockStateBoolean POWERED = getBoolean(net.minecraft.server.BlockPoweredRail.class, "powered"); + + @Override + public boolean isPowered() { + return get(POWERED); + } + + @Override + public void setPowered(boolean powered) { + set(POWERED, powered); + } + + // org.bukkit.craftbukkit.block.data.CraftRail + + private static final net.minecraft.server.BlockStateEnum SHAPE = getEnum(net.minecraft.server.BlockPoweredRail.class, "shape"); + + @Override + public Shape getShape() { + return get(SHAPE, Shape.class); + } + + @Override + public void setShape(Shape shape) { + set(SHAPE, shape); + } + + @Override + public java.util.Set getShapes() { + return getValues(SHAPE, Shape.class); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPressurePlateBinary.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPressurePlateBinary.java new file mode 100644 index 0000000000..806ad25654 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPressurePlateBinary.java @@ -0,0 +1,29 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftPressurePlateBinary extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Powerable { + + public CraftPressurePlateBinary() { + super(); + } + + public CraftPressurePlateBinary(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.CraftPowerable + + private static final net.minecraft.server.BlockStateBoolean POWERED = getBoolean(net.minecraft.server.BlockPressurePlateBinary.class, "powered"); + + @Override + public boolean isPowered() { + return get(POWERED); + } + + @Override + public void setPowered(boolean powered) { + set(POWERED, powered); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPressurePlateWeighted.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPressurePlateWeighted.java new file mode 100644 index 0000000000..840506640e --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPressurePlateWeighted.java @@ -0,0 +1,34 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftPressurePlateWeighted extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.AnaloguePowerable { + + public CraftPressurePlateWeighted() { + super(); + } + + public CraftPressurePlateWeighted(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.CraftAnaloguePowerable + + private static final net.minecraft.server.BlockStateInteger POWER = getInteger(net.minecraft.server.BlockPressurePlateWeighted.class, "power"); + + @Override + public int getPower() { + return get(POWER); + } + + @Override + public void setPower(int power) { + set(POWER, power); + } + + @Override + public int getMaximumPower() { + return getMax(POWER); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPumpkinCarved.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPumpkinCarved.java new file mode 100644 index 0000000000..b258e7449f --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPumpkinCarved.java @@ -0,0 +1,34 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftPumpkinCarved extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Directional { + + public CraftPumpkinCarved() { + super(); + } + + public CraftPumpkinCarved(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.BlockPumpkinCarved.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/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftRedstoneComparator.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftRedstoneComparator.java new file mode 100644 index 0000000000..2456e30717 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftRedstoneComparator.java @@ -0,0 +1,62 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftRedstoneComparator extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Comparator, org.bukkit.block.data.Directional, org.bukkit.block.data.Powerable { + + public CraftRedstoneComparator() { + super(); + } + + public CraftRedstoneComparator(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.type.CraftComparator + + private static final net.minecraft.server.BlockStateEnum MODE = getEnum(net.minecraft.server.BlockRedstoneComparator.class, "mode"); + + @Override + public Mode getMode() { + return get(MODE, Mode.class); + } + + @Override + public void setMode(Mode mode) { + set(MODE, mode); + } + + // org.bukkit.craftbukkit.block.data.CraftDirectional + + private static final net.minecraft.server.BlockStateEnum FACING = getEnum(net.minecraft.server.BlockRedstoneComparator.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.BlockRedstoneComparator.class, "powered"); + + @Override + public boolean isPowered() { + return get(POWERED); + } + + @Override + public void setPowered(boolean powered) { + set(POWERED, powered); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftRedstoneLamp.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftRedstoneLamp.java new file mode 100644 index 0000000000..7769c93c8f --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftRedstoneLamp.java @@ -0,0 +1,29 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftRedstoneLamp extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Lightable { + + public CraftRedstoneLamp() { + super(); + } + + public CraftRedstoneLamp(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.CraftLightable + + private static final net.minecraft.server.BlockStateBoolean LIT = getBoolean(net.minecraft.server.BlockRedstoneLamp.class, "lit"); + + @Override + public boolean isLit() { + return get(LIT); + } + + @Override + public void setLit(boolean lit) { + set(LIT, lit); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftRedstoneOre.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftRedstoneOre.java new file mode 100644 index 0000000000..effe08ead1 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftRedstoneOre.java @@ -0,0 +1,29 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftRedstoneOre extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Lightable { + + public CraftRedstoneOre() { + super(); + } + + public CraftRedstoneOre(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.CraftLightable + + private static final net.minecraft.server.BlockStateBoolean LIT = getBoolean(net.minecraft.server.BlockRedstoneOre.class, "lit"); + + @Override + public boolean isLit() { + return get(LIT); + } + + @Override + public void setLit(boolean lit) { + set(LIT, lit); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftRedstoneTorch.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftRedstoneTorch.java new file mode 100644 index 0000000000..d9d142016a --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftRedstoneTorch.java @@ -0,0 +1,29 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftRedstoneTorch extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Lightable { + + public CraftRedstoneTorch() { + super(); + } + + public CraftRedstoneTorch(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.CraftLightable + + private static final net.minecraft.server.BlockStateBoolean LIT = getBoolean(net.minecraft.server.BlockRedstoneTorch.class, "lit"); + + @Override + public boolean isLit() { + return get(LIT); + } + + @Override + public void setLit(boolean lit) { + set(LIT, lit); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftRedstoneTorchWall.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftRedstoneTorchWall.java new file mode 100644 index 0000000000..8125b4004f --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftRedstoneTorchWall.java @@ -0,0 +1,48 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftRedstoneTorchWall extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.RedstoneWallTorch, org.bukkit.block.data.Directional, org.bukkit.block.data.Lightable { + + public CraftRedstoneTorchWall() { + super(); + } + + public CraftRedstoneTorchWall(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.BlockRedstoneTorchWall.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.BlockRedstoneTorchWall.class, "lit"); + + @Override + public boolean isLit() { + return get(LIT); + } + + @Override + public void setLit(boolean lit) { + set(LIT, lit); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftRedstoneWire.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftRedstoneWire.java new file mode 100644 index 0000000000..f5b0e84d58 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftRedstoneWire.java @@ -0,0 +1,78 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftRedstoneWire extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.RedstoneWire, org.bukkit.block.data.AnaloguePowerable { + + public CraftRedstoneWire() { + super(); + } + + public CraftRedstoneWire(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.type.CraftRedstoneWire + + private static final net.minecraft.server.BlockStateEnum NORTH = getEnum(net.minecraft.server.BlockRedstoneWire.class, "north"); + private static final net.minecraft.server.BlockStateEnum EAST = getEnum(net.minecraft.server.BlockRedstoneWire.class, "east"); + private static final net.minecraft.server.BlockStateEnum SOUTH = getEnum(net.minecraft.server.BlockRedstoneWire.class, "south"); + private static final net.minecraft.server.BlockStateEnum WEST = getEnum(net.minecraft.server.BlockRedstoneWire.class, "west"); + + @Override + public Connection getFace(org.bukkit.block.BlockFace face) { + switch (face) { + case NORTH: + return get(NORTH, Connection.class); + case EAST: + return get(EAST, Connection.class); + case SOUTH: + return get(SOUTH, Connection.class); + case WEST: + return get(WEST, Connection.class); + default: + throw new IllegalArgumentException("Cannot have face " + face); + } + } + + @Override + public void setFace(org.bukkit.block.BlockFace face, Connection connection) { + switch (face) { + case NORTH: + set(NORTH, connection); + case EAST: + set(EAST, connection); + case SOUTH: + set(SOUTH, connection); + case WEST: + set(WEST, connection); + default: + throw new IllegalArgumentException("Cannot have face " + face); + } + } + + @Override + public java.util.Set getAllowedFaces() { + return com.google.common.collect.ImmutableSet.of(org.bukkit.block.BlockFace.NORTH, org.bukkit.block.BlockFace.EAST, org.bukkit.block.BlockFace.SOUTH, org.bukkit.block.BlockFace.WEST); + } + + // org.bukkit.craftbukkit.block.data.CraftAnaloguePowerable + + private static final net.minecraft.server.BlockStateInteger POWER = getInteger(net.minecraft.server.BlockRedstoneWire.class, "power"); + + @Override + public int getPower() { + return get(POWER); + } + + @Override + public void setPower(int power) { + set(POWER, power); + } + + @Override + public int getMaximumPower() { + return getMax(POWER); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftReed.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftReed.java new file mode 100644 index 0000000000..138b8701bb --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftReed.java @@ -0,0 +1,34 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftReed extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Ageable { + + public CraftReed() { + super(); + } + + public CraftReed(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.BlockReed.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/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftRepeater.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftRepeater.java new file mode 100644 index 0000000000..97724f6829 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftRepeater.java @@ -0,0 +1,83 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftRepeater extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Repeater, org.bukkit.block.data.Directional, org.bukkit.block.data.Powerable { + + public CraftRepeater() { + super(); + } + + public CraftRepeater(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.type.CraftRepeater + + private static final net.minecraft.server.BlockStateInteger DELAY = getInteger(net.minecraft.server.BlockRepeater.class, "delay"); + private static final net.minecraft.server.BlockStateBoolean LOCKED = getBoolean(net.minecraft.server.BlockRepeater.class, "locked"); + + @Override + public int getDelay() { + return get(DELAY); + } + + @Override + public void setDelay(int delay) { + set(DELAY, delay); + } + + @Override + public int getMinimumDelay() { + return getMin(DELAY); + } + + @Override + public int getMaximumDelay() { + return getMax(DELAY); + } + + @Override + public boolean isLocked() { + return get(LOCKED); + } + + @Override + public void setLocked(boolean locked) { + set(LOCKED, locked); + } + + // org.bukkit.craftbukkit.block.data.CraftDirectional + + private static final net.minecraft.server.BlockStateEnum FACING = getEnum(net.minecraft.server.BlockRepeater.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.BlockRepeater.class, "powered"); + + @Override + public boolean isPowered() { + return get(POWERED); + } + + @Override + public void setPowered(boolean powered) { + set(POWERED, powered); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftRotatable.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftRotatable.java new file mode 100644 index 0000000000..c44f23e64b --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftRotatable.java @@ -0,0 +1,34 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftRotatable extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Orientable { + + public CraftRotatable() { + super(); + } + + public CraftRotatable(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.CraftOrientable + + private static final net.minecraft.server.BlockStateEnum AXIS = getEnum(net.minecraft.server.BlockRotatable.class, "axis"); + + @Override + public org.bukkit.Axis getAxis() { + return get(AXIS, org.bukkit.Axis.class); + } + + @Override + public void setAxis(org.bukkit.Axis axis) { + set(AXIS, axis); + } + + @Override + public java.util.Set getAxes() { + return getValues(AXIS, org.bukkit.Axis.class); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftSapling.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftSapling.java new file mode 100644 index 0000000000..0654c9e7b8 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftSapling.java @@ -0,0 +1,34 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftSapling extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Sapling { + + public CraftSapling() { + super(); + } + + public CraftSapling(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.type.CraftSapling + + private static final net.minecraft.server.BlockStateInteger STAGE = getInteger(net.minecraft.server.BlockSapling.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/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftSeaPickle.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftSeaPickle.java new file mode 100644 index 0000000000..a0078bd8b6 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftSeaPickle.java @@ -0,0 +1,53 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftSeaPickle extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.SeaPickle, org.bukkit.block.data.Waterlogged { + + public CraftSeaPickle() { + super(); + } + + public CraftSeaPickle(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.type.CraftSeaPickle + + private static final net.minecraft.server.BlockStateInteger PICKLES = getInteger(net.minecraft.server.BlockSeaPickle.class, "pickles"); + + @Override + public int getPickles() { + return get(PICKLES); + } + + @Override + public void setPickles(int pickles) { + set(PICKLES, pickles); + } + + @Override + public int getMinimumPickles() { + return getMin(PICKLES); + } + + @Override + public int getMaximumPickles() { + return getMax(PICKLES); + } + + // org.bukkit.craftbukkit.block.data.CraftWaterlogged + + private static final net.minecraft.server.BlockStateBoolean WATERLOGGED = getBoolean(net.minecraft.server.BlockSeaPickle.class, "waterlogged"); + + @Override + public boolean isWaterlogged() { + return get(WATERLOGGED); + } + + @Override + public void setWaterlogged(boolean waterlogged) { + set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftShulkerBox.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftShulkerBox.java new file mode 100644 index 0000000000..631f5cffb9 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftShulkerBox.java @@ -0,0 +1,34 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftShulkerBox extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Directional { + + public CraftShulkerBox() { + super(); + } + + public CraftShulkerBox(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.BlockShulkerBox.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/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftSkull.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftSkull.java new file mode 100644 index 0000000000..5677a9f0b8 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftSkull.java @@ -0,0 +1,118 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftSkull extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Rotatable { + + public CraftSkull() { + super(); + } + + public CraftSkull(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.CraftRotatable + + private static final net.minecraft.server.BlockStateInteger ROTATION = getInteger(net.minecraft.server.BlockSkull.class, "rotation"); + + @Override + public org.bukkit.block.BlockFace getRotation() { + int data = get(ROTATION); + switch (data) { + case 0x0: + return org.bukkit.block.BlockFace.SOUTH; + case 0x1: + return org.bukkit.block.BlockFace.SOUTH_SOUTH_WEST; + case 0x2: + return org.bukkit.block.BlockFace.SOUTH_WEST; + case 0x3: + return org.bukkit.block.BlockFace.WEST_SOUTH_WEST; + case 0x4: + return org.bukkit.block.BlockFace.WEST; + case 0x5: + return org.bukkit.block.BlockFace.WEST_NORTH_WEST; + case 0x6: + return org.bukkit.block.BlockFace.NORTH_WEST; + case 0x7: + return org.bukkit.block.BlockFace.NORTH_NORTH_WEST; + case 0x8: + return org.bukkit.block.BlockFace.NORTH; + case 0x9: + return org.bukkit.block.BlockFace.NORTH_NORTH_EAST; + case 0xA: + return org.bukkit.block.BlockFace.NORTH_EAST; + case 0xB: + return org.bukkit.block.BlockFace.EAST_NORTH_EAST; + case 0xC: + return org.bukkit.block.BlockFace.EAST; + case 0xD: + return org.bukkit.block.BlockFace.EAST_SOUTH_EAST; + case 0xE: + return org.bukkit.block.BlockFace.SOUTH_EAST; + case 0xF: + return org.bukkit.block.BlockFace.SOUTH_SOUTH_EAST; + default: + throw new IllegalArgumentException("Unknown rotation " + data); + } + } + + @Override + public void setRotation(org.bukkit.block.BlockFace rotation) { + int val; + switch (rotation) { + case SOUTH: + val = 0x0; + break; + case SOUTH_SOUTH_WEST: + val = 0x1; + break; + case SOUTH_WEST: + val = 0x2; + break; + case WEST_SOUTH_WEST: + val = 0x3; + break; + case WEST: + val = 0x4; + break; + case WEST_NORTH_WEST: + val = 0x5; + break; + case NORTH_WEST: + val = 0x6; + break; + case NORTH_NORTH_WEST: + val = 0x7; + break; + case NORTH: + val = 0x8; + break; + case NORTH_NORTH_EAST: + val = 0x9; + break; + case NORTH_EAST: + val = 0xA; + break; + case EAST_NORTH_EAST: + val = 0xB; + break; + case EAST: + val = 0xC; + break; + case EAST_SOUTH_EAST: + val = 0xD; + break; + case SOUTH_EAST: + val = 0xE; + break; + case SOUTH_SOUTH_EAST: + val = 0xF; + break; + default: + throw new IllegalArgumentException("Illegal rotation " + rotation); + } + set(ROTATION, val); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftSkullPlayer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftSkullPlayer.java new file mode 100644 index 0000000000..6e6e0033fe --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftSkullPlayer.java @@ -0,0 +1,118 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftSkullPlayer extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Rotatable { + + public CraftSkullPlayer() { + super(); + } + + public CraftSkullPlayer(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.CraftRotatable + + private static final net.minecraft.server.BlockStateInteger ROTATION = getInteger(net.minecraft.server.BlockSkullPlayer.class, "rotation"); + + @Override + public org.bukkit.block.BlockFace getRotation() { + int data = get(ROTATION); + switch (data) { + case 0x0: + return org.bukkit.block.BlockFace.SOUTH; + case 0x1: + return org.bukkit.block.BlockFace.SOUTH_SOUTH_WEST; + case 0x2: + return org.bukkit.block.BlockFace.SOUTH_WEST; + case 0x3: + return org.bukkit.block.BlockFace.WEST_SOUTH_WEST; + case 0x4: + return org.bukkit.block.BlockFace.WEST; + case 0x5: + return org.bukkit.block.BlockFace.WEST_NORTH_WEST; + case 0x6: + return org.bukkit.block.BlockFace.NORTH_WEST; + case 0x7: + return org.bukkit.block.BlockFace.NORTH_NORTH_WEST; + case 0x8: + return org.bukkit.block.BlockFace.NORTH; + case 0x9: + return org.bukkit.block.BlockFace.NORTH_NORTH_EAST; + case 0xA: + return org.bukkit.block.BlockFace.NORTH_EAST; + case 0xB: + return org.bukkit.block.BlockFace.EAST_NORTH_EAST; + case 0xC: + return org.bukkit.block.BlockFace.EAST; + case 0xD: + return org.bukkit.block.BlockFace.EAST_SOUTH_EAST; + case 0xE: + return org.bukkit.block.BlockFace.SOUTH_EAST; + case 0xF: + return org.bukkit.block.BlockFace.SOUTH_SOUTH_EAST; + default: + throw new IllegalArgumentException("Unknown rotation " + data); + } + } + + @Override + public void setRotation(org.bukkit.block.BlockFace rotation) { + int val; + switch (rotation) { + case SOUTH: + val = 0x0; + break; + case SOUTH_SOUTH_WEST: + val = 0x1; + break; + case SOUTH_WEST: + val = 0x2; + break; + case WEST_SOUTH_WEST: + val = 0x3; + break; + case WEST: + val = 0x4; + break; + case WEST_NORTH_WEST: + val = 0x5; + break; + case NORTH_WEST: + val = 0x6; + break; + case NORTH_NORTH_WEST: + val = 0x7; + break; + case NORTH: + val = 0x8; + break; + case NORTH_NORTH_EAST: + val = 0x9; + break; + case NORTH_EAST: + val = 0xA; + break; + case EAST_NORTH_EAST: + val = 0xB; + break; + case EAST: + val = 0xC; + break; + case EAST_SOUTH_EAST: + val = 0xD; + break; + case SOUTH_EAST: + val = 0xE; + break; + case SOUTH_SOUTH_EAST: + val = 0xF; + break; + default: + throw new IllegalArgumentException("Illegal rotation " + rotation); + } + set(ROTATION, val); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftSkullPlayerWall.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftSkullPlayerWall.java new file mode 100644 index 0000000000..d2b3ce935f --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftSkullPlayerWall.java @@ -0,0 +1,34 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftSkullPlayerWall extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Directional { + + public CraftSkullPlayerWall() { + super(); + } + + public CraftSkullPlayerWall(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.BlockSkullPlayerWall.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/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftSkullWall.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftSkullWall.java new file mode 100644 index 0000000000..020e5b715e --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftSkullWall.java @@ -0,0 +1,34 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftSkullWall extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Directional { + + public CraftSkullWall() { + super(); + } + + public CraftSkullWall(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.BlockSkullWall.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/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftSnow.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftSnow.java new file mode 100644 index 0000000000..d4f0bfa80f --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftSnow.java @@ -0,0 +1,39 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftSnow extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Snow { + + public CraftSnow() { + super(); + } + + public CraftSnow(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.type.CraftSnow + + private static final net.minecraft.server.BlockStateInteger LAYERS = getInteger(net.minecraft.server.BlockSnow.class, "layers"); + + @Override + public int getLayers() { + return get(LAYERS); + } + + @Override + public void setLayers(int layers) { + set(LAYERS, layers); + } + + @Override + public int getMinimumLayers() { + return getMin(LAYERS); + } + + @Override + public int getMaximumLayers() { + return getMax(LAYERS); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftSoil.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftSoil.java new file mode 100644 index 0000000000..09cfa46719 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftSoil.java @@ -0,0 +1,34 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftSoil extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Farmland { + + public CraftSoil() { + super(); + } + + public CraftSoil(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.type.CraftFarmland + + private static final net.minecraft.server.BlockStateInteger MOISTURE = getInteger(net.minecraft.server.BlockSoil.class, "moisture"); + + @Override + public int getMoisture() { + return get(MOISTURE); + } + + @Override + public void setMoisture(int moisture) { + set(MOISTURE, moisture); + } + + @Override + public int getMaximumMoisture() { + return getMax(MOISTURE); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftStainedGlassPane.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftStainedGlassPane.java new file mode 100644 index 0000000000..0eb5c66071 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftStainedGlassPane.java @@ -0,0 +1,71 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftStainedGlassPane 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 CraftStainedGlassPane() { + super(); + } + + public CraftStainedGlassPane(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.BlockStainedGlassPane.class, "north", true), getBoolean(net.minecraft.server.BlockStainedGlassPane.class, "east", true), getBoolean(net.minecraft.server.BlockStainedGlassPane.class, "south", true), getBoolean(net.minecraft.server.BlockStainedGlassPane.class, "west", true), getBoolean(net.minecraft.server.BlockStainedGlassPane.class, "up", true), getBoolean(net.minecraft.server.BlockStainedGlassPane.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.BlockStainedGlassPane.class, "waterlogged"); + + @Override + public boolean isWaterlogged() { + return get(WATERLOGGED); + } + + @Override + public void setWaterlogged(boolean waterlogged) { + set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftStairs.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftStairs.java new file mode 100644 index 0000000000..804a90f213 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftStairs.java @@ -0,0 +1,76 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftStairs extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Stairs, org.bukkit.block.data.Bisected, org.bukkit.block.data.Directional, org.bukkit.block.data.Waterlogged { + + public CraftStairs() { + super(); + } + + public CraftStairs(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.type.CraftStairs + + private static final net.minecraft.server.BlockStateEnum SHAPE = getEnum(net.minecraft.server.BlockStairs.class, "shape"); + + @Override + public Shape getShape() { + return get(SHAPE, Shape.class); + } + + @Override + public void setShape(Shape shape) { + set(SHAPE, shape); + } + + // org.bukkit.craftbukkit.block.data.CraftBisected + + private static final net.minecraft.server.BlockStateEnum HALF = getEnum(net.minecraft.server.BlockStairs.class, "half"); + + @Override + public Half getHalf() { + return get(HALF, Half.class); + } + + @Override + public void setHalf(Half half) { + set(HALF, half); + } + + // org.bukkit.craftbukkit.block.data.CraftDirectional + + private static final net.minecraft.server.BlockStateEnum FACING = getEnum(net.minecraft.server.BlockStairs.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.CraftWaterlogged + + private static final net.minecraft.server.BlockStateBoolean WATERLOGGED = getBoolean(net.minecraft.server.BlockStairs.class, "waterlogged"); + + @Override + public boolean isWaterlogged() { + return get(WATERLOGGED); + } + + @Override + public void setWaterlogged(boolean waterlogged) { + set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftStem.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftStem.java new file mode 100644 index 0000000000..2a91e95826 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftStem.java @@ -0,0 +1,34 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftStem extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Ageable { + + public CraftStem() { + super(); + } + + public CraftStem(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.BlockStem.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/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftStemAttached.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftStemAttached.java new file mode 100644 index 0000000000..c6d9223d18 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftStemAttached.java @@ -0,0 +1,34 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftStemAttached extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Directional { + + public CraftStemAttached() { + super(); + } + + public CraftStemAttached(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.BlockStemAttached.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/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftStepAbstract.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftStepAbstract.java new file mode 100644 index 0000000000..922d41b1a5 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftStepAbstract.java @@ -0,0 +1,43 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftStepAbstract extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Slab, org.bukkit.block.data.Waterlogged { + + public CraftStepAbstract() { + super(); + } + + public CraftStepAbstract(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.type.CraftSlab + + private static final net.minecraft.server.BlockStateEnum TYPE = getEnum(net.minecraft.server.BlockStepAbstract.class, "type"); + + @Override + public Type getType() { + return get(TYPE, Type.class); + } + + @Override + public void setType(Type type) { + set(TYPE, type); + } + + // org.bukkit.craftbukkit.block.data.CraftWaterlogged + + private static final net.minecraft.server.BlockStateBoolean WATERLOGGED = getBoolean(net.minecraft.server.BlockStepAbstract.class, "waterlogged"); + + @Override + public boolean isWaterlogged() { + return get(WATERLOGGED); + } + + @Override + public void setWaterlogged(boolean waterlogged) { + set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftStoneButton.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftStoneButton.java new file mode 100644 index 0000000000..84097d5efe --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftStoneButton.java @@ -0,0 +1,62 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftStoneButton extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Switch, org.bukkit.block.data.Directional, org.bukkit.block.data.Powerable { + + public CraftStoneButton() { + super(); + } + + public CraftStoneButton(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.type.CraftSwitch + + private static final net.minecraft.server.BlockStateEnum FACE = getEnum(net.minecraft.server.BlockStoneButton.class, "face"); + + @Override + public Face getFace() { + return get(FACE, Face.class); + } + + @Override + public void setFace(Face face) { + set(FACE, face); + } + + // org.bukkit.craftbukkit.block.data.CraftDirectional + + private static final net.minecraft.server.BlockStateEnum FACING = getEnum(net.minecraft.server.BlockStoneButton.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.BlockStoneButton.class, "powered"); + + @Override + public boolean isPowered() { + return get(POWERED); + } + + @Override + public void setPowered(boolean powered) { + set(POWERED, powered); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftStructure.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftStructure.java new file mode 100644 index 0000000000..f2435d34ed --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftStructure.java @@ -0,0 +1,29 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftStructure extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.StructureBlock { + + public CraftStructure() { + super(); + } + + public CraftStructure(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.type.CraftStructureBlock + + private static final net.minecraft.server.BlockStateEnum MODE = getEnum(net.minecraft.server.BlockStructure.class, "mode"); + + @Override + public Mode getMode() { + return get(MODE, Mode.class); + } + + @Override + public void setMode(Mode mode) { + set(MODE, mode); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTallPlantFlower.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTallPlantFlower.java new file mode 100644 index 0000000000..3ae8201c4e --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTallPlantFlower.java @@ -0,0 +1,29 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftTallPlantFlower extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Bisected { + + public CraftTallPlantFlower() { + super(); + } + + public CraftTallPlantFlower(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.BlockTallPlantFlower.class, "half"); + + @Override + public Half getHalf() { + return get(HALF, Half.class); + } + + @Override + public void setHalf(Half half) { + set(HALF, half); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTallPlantShearable.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTallPlantShearable.java new file mode 100644 index 0000000000..c98414b3bc --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTallPlantShearable.java @@ -0,0 +1,29 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftTallPlantShearable extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Bisected { + + public CraftTallPlantShearable() { + super(); + } + + public CraftTallPlantShearable(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"); + + @Override + public Half getHalf() { + return get(HALF, Half.class); + } + + @Override + public void setHalf(Half half) { + set(HALF, half); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTallSeaGrass.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTallSeaGrass.java new file mode 100644 index 0000000000..d51e3ec4d4 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTallSeaGrass.java @@ -0,0 +1,29 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftTallSeaGrass extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Bisected { + + public CraftTallSeaGrass() { + super(); + } + + public CraftTallSeaGrass(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.BlockTallSeaGrass.class, "half"); + + @Override + public Half getHalf() { + return get(HALF, Half.class); + } + + @Override + public void setHalf(Half half) { + set(HALF, half); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTorchWall.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTorchWall.java new file mode 100644 index 0000000000..d98f21aaf3 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTorchWall.java @@ -0,0 +1,34 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftTorchWall extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Directional { + + public CraftTorchWall() { + super(); + } + + public CraftTorchWall(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.BlockTorchWall.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/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTrapdoor.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTrapdoor.java new file mode 100644 index 0000000000..2ec18b29c1 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTrapdoor.java @@ -0,0 +1,90 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftTrapdoor extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.TrapDoor, org.bukkit.block.data.Bisected, org.bukkit.block.data.Directional, org.bukkit.block.data.Openable, org.bukkit.block.data.Powerable, org.bukkit.block.data.Waterlogged { + + public CraftTrapdoor() { + super(); + } + + public CraftTrapdoor(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.BlockTrapdoor.class, "half"); + + @Override + public Half getHalf() { + return get(HALF, Half.class); + } + + @Override + public void setHalf(Half half) { + set(HALF, half); + } + + // org.bukkit.craftbukkit.block.data.CraftDirectional + + private static final net.minecraft.server.BlockStateEnum FACING = getEnum(net.minecraft.server.BlockTrapdoor.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.CraftOpenable + + private static final net.minecraft.server.BlockStateBoolean OPEN = getBoolean(net.minecraft.server.BlockTrapdoor.class, "open"); + + @Override + public boolean isOpen() { + return get(OPEN); + } + + @Override + public void setOpen(boolean open) { + set(OPEN, open); + } + + // org.bukkit.craftbukkit.block.data.CraftPowerable + + private static final net.minecraft.server.BlockStateBoolean POWERED = getBoolean(net.minecraft.server.BlockTrapdoor.class, "powered"); + + @Override + public boolean isPowered() { + return get(POWERED); + } + + @Override + public void setPowered(boolean powered) { + set(POWERED, powered); + } + + // org.bukkit.craftbukkit.block.data.CraftWaterlogged + + private static final net.minecraft.server.BlockStateBoolean WATERLOGGED = getBoolean(net.minecraft.server.BlockTrapdoor.class, "waterlogged"); + + @Override + public boolean isWaterlogged() { + return get(WATERLOGGED); + } + + @Override + public void setWaterlogged(boolean waterlogged) { + set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTripwire.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTripwire.java new file mode 100644 index 0000000000..e39e79c42f --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTripwire.java @@ -0,0 +1,99 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftTripwire extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Tripwire, org.bukkit.block.data.Attachable, org.bukkit.block.data.MultipleFacing, org.bukkit.block.data.Powerable { + + public CraftTripwire() { + super(); + } + + public CraftTripwire(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.type.CraftTripwire + + private static final net.minecraft.server.BlockStateBoolean DISARMED = getBoolean(net.minecraft.server.BlockTripwire.class, "disarmed"); + + @Override + public boolean isDisarmed() { + return get(DISARMED); + } + + @Override + public void setDisarmed(boolean disarmed) { + set(DISARMED, disarmed); + } + + // org.bukkit.craftbukkit.block.data.CraftAttachable + + private static final net.minecraft.server.BlockStateBoolean ATTACHED = getBoolean(net.minecraft.server.BlockTripwire.class, "attached"); + + @Override + public boolean isAttached() { + return get(ATTACHED); + } + + @Override + public void setAttached(boolean attached) { + set(ATTACHED, attached); + } + + // org.bukkit.craftbukkit.block.data.CraftMultipleFacing + + private static final net.minecraft.server.BlockStateBoolean[] FACES = new net.minecraft.server.BlockStateBoolean[]{ + getBoolean(net.minecraft.server.BlockTripwire.class, "north", true), getBoolean(net.minecraft.server.BlockTripwire.class, "east", true), getBoolean(net.minecraft.server.BlockTripwire.class, "south", true), getBoolean(net.minecraft.server.BlockTripwire.class, "west", true), getBoolean(net.minecraft.server.BlockTripwire.class, "up", true), getBoolean(net.minecraft.server.BlockTripwire.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.CraftPowerable + + private static final net.minecraft.server.BlockStateBoolean POWERED = getBoolean(net.minecraft.server.BlockTripwire.class, "powered"); + + @Override + public boolean isPowered() { + return get(POWERED); + } + + @Override + public void setPowered(boolean powered) { + set(POWERED, powered); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTripwireHook.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTripwireHook.java new file mode 100644 index 0000000000..bd7b43ade5 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTripwireHook.java @@ -0,0 +1,62 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftTripwireHook extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.TripwireHook, org.bukkit.block.data.Attachable, org.bukkit.block.data.Directional, org.bukkit.block.data.Powerable { + + public CraftTripwireHook() { + super(); + } + + public CraftTripwireHook(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.CraftAttachable + + private static final net.minecraft.server.BlockStateBoolean ATTACHED = getBoolean(net.minecraft.server.BlockTripwireHook.class, "attached"); + + @Override + public boolean isAttached() { + return get(ATTACHED); + } + + @Override + public void setAttached(boolean attached) { + set(ATTACHED, attached); + } + + // org.bukkit.craftbukkit.block.data.CraftDirectional + + private static final net.minecraft.server.BlockStateEnum FACING = getEnum(net.minecraft.server.BlockTripwireHook.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.BlockTripwireHook.class, "powered"); + + @Override + public boolean isPowered() { + return get(POWERED); + } + + @Override + public void setPowered(boolean powered) { + set(POWERED, powered); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTurtleEgg.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTurtleEgg.java new file mode 100644 index 0000000000..64812ad12e --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTurtleEgg.java @@ -0,0 +1,55 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftTurtleEgg extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.TurtleEgg { + + public CraftTurtleEgg() { + super(); + } + + public CraftTurtleEgg(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.type.CraftTurtleEgg + + private static final net.minecraft.server.BlockStateInteger EGGS = getInteger(net.minecraft.server.BlockTurtleEgg.class, "eggs"); + private static final net.minecraft.server.BlockStateInteger HATCH = getInteger(net.minecraft.server.BlockTurtleEgg.class, "hatch"); + + @Override + public int getEggs() { + return get(EGGS); + } + + @Override + public void setEggs(int eggs) { + set(EGGS, eggs); + } + + @Override + public int getMinimumEggs() { + return getMin(EGGS); + } + + @Override + public int getMaximumEggs() { + return getMax(EGGS); + } + + @Override + public int getHatch() { + return get(HATCH); + } + + @Override + public void setHatch(int hatch) { + set(HATCH, hatch); + } + + @Override + public int getMaximumHatch() { + return getMax(HATCH); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftVine.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftVine.java new file mode 100644 index 0000000000..90e025cef0 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftVine.java @@ -0,0 +1,57 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftVine extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.MultipleFacing { + + public CraftVine() { + super(); + } + + public CraftVine(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.BlockVine.class, "north", true), getBoolean(net.minecraft.server.BlockVine.class, "east", true), getBoolean(net.minecraft.server.BlockVine.class, "south", true), getBoolean(net.minecraft.server.BlockVine.class, "west", true), getBoolean(net.minecraft.server.BlockVine.class, "up", true), getBoolean(net.minecraft.server.BlockVine.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(); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftWallSign.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftWallSign.java new file mode 100644 index 0000000000..ffa7e3c4b5 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftWallSign.java @@ -0,0 +1,48 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftWallSign extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.WallSign, org.bukkit.block.data.Directional, org.bukkit.block.data.Waterlogged { + + public CraftWallSign() { + super(); + } + + public CraftWallSign(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.BlockWallSign.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.CraftWaterlogged + + private static final net.minecraft.server.BlockStateBoolean WATERLOGGED = getBoolean(net.minecraft.server.BlockWallSign.class, "waterlogged"); + + @Override + public boolean isWaterlogged() { + return get(WATERLOGGED); + } + + @Override + public void setWaterlogged(boolean waterlogged) { + set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftWitherSkull.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftWitherSkull.java new file mode 100644 index 0000000000..0aec1dbed5 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftWitherSkull.java @@ -0,0 +1,118 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftWitherSkull extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Rotatable { + + public CraftWitherSkull() { + super(); + } + + public CraftWitherSkull(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.CraftRotatable + + private static final net.minecraft.server.BlockStateInteger ROTATION = getInteger(net.minecraft.server.BlockWitherSkull.class, "rotation"); + + @Override + public org.bukkit.block.BlockFace getRotation() { + int data = get(ROTATION); + switch (data) { + case 0x0: + return org.bukkit.block.BlockFace.SOUTH; + case 0x1: + return org.bukkit.block.BlockFace.SOUTH_SOUTH_WEST; + case 0x2: + return org.bukkit.block.BlockFace.SOUTH_WEST; + case 0x3: + return org.bukkit.block.BlockFace.WEST_SOUTH_WEST; + case 0x4: + return org.bukkit.block.BlockFace.WEST; + case 0x5: + return org.bukkit.block.BlockFace.WEST_NORTH_WEST; + case 0x6: + return org.bukkit.block.BlockFace.NORTH_WEST; + case 0x7: + return org.bukkit.block.BlockFace.NORTH_NORTH_WEST; + case 0x8: + return org.bukkit.block.BlockFace.NORTH; + case 0x9: + return org.bukkit.block.BlockFace.NORTH_NORTH_EAST; + case 0xA: + return org.bukkit.block.BlockFace.NORTH_EAST; + case 0xB: + return org.bukkit.block.BlockFace.EAST_NORTH_EAST; + case 0xC: + return org.bukkit.block.BlockFace.EAST; + case 0xD: + return org.bukkit.block.BlockFace.EAST_SOUTH_EAST; + case 0xE: + return org.bukkit.block.BlockFace.SOUTH_EAST; + case 0xF: + return org.bukkit.block.BlockFace.SOUTH_SOUTH_EAST; + default: + throw new IllegalArgumentException("Unknown rotation " + data); + } + } + + @Override + public void setRotation(org.bukkit.block.BlockFace rotation) { + int val; + switch (rotation) { + case SOUTH: + val = 0x0; + break; + case SOUTH_SOUTH_WEST: + val = 0x1; + break; + case SOUTH_WEST: + val = 0x2; + break; + case WEST_SOUTH_WEST: + val = 0x3; + break; + case WEST: + val = 0x4; + break; + case WEST_NORTH_WEST: + val = 0x5; + break; + case NORTH_WEST: + val = 0x6; + break; + case NORTH_NORTH_WEST: + val = 0x7; + break; + case NORTH: + val = 0x8; + break; + case NORTH_NORTH_EAST: + val = 0x9; + break; + case NORTH_EAST: + val = 0xA; + break; + case EAST_NORTH_EAST: + val = 0xB; + break; + case EAST: + val = 0xC; + break; + case EAST_SOUTH_EAST: + val = 0xD; + break; + case SOUTH_EAST: + val = 0xE; + break; + case SOUTH_SOUTH_EAST: + val = 0xF; + break; + default: + throw new IllegalArgumentException("Illegal rotation " + rotation); + } + set(ROTATION, val); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftWitherSkullWall.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftWitherSkullWall.java new file mode 100644 index 0000000000..fa9597da20 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftWitherSkullWall.java @@ -0,0 +1,34 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftWitherSkullWall extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Directional { + + public CraftWitherSkullWall() { + super(); + } + + public CraftWitherSkullWall(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.BlockWitherSkullWall.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/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftWoodButton.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftWoodButton.java new file mode 100644 index 0000000000..799714178f --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftWoodButton.java @@ -0,0 +1,62 @@ +/** + * Automatically generated file, changes will be lost. + */ +package org.bukkit.craftbukkit.block.impl; + +public final class CraftWoodButton extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Switch, org.bukkit.block.data.Directional, org.bukkit.block.data.Powerable { + + public CraftWoodButton() { + super(); + } + + public CraftWoodButton(net.minecraft.server.IBlockData state) { + super(state); + } + + // org.bukkit.craftbukkit.block.data.type.CraftSwitch + + private static final net.minecraft.server.BlockStateEnum FACE = getEnum(net.minecraft.server.BlockWoodButton.class, "face"); + + @Override + public Face getFace() { + return get(FACE, Face.class); + } + + @Override + public void setFace(Face face) { + set(FACE, face); + } + + // org.bukkit.craftbukkit.block.data.CraftDirectional + + private static final net.minecraft.server.BlockStateEnum FACING = getEnum(net.minecraft.server.BlockWoodButton.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.BlockWoodButton.class, "powered"); + + @Override + public boolean isPowered() { + return get(POWERED); + } + + @Override + public void setPowered(boolean powered) { + set(POWERED, powered); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/boss/CraftBossBar.java b/paper-server/src/main/java/org/bukkit/craftbukkit/boss/CraftBossBar.java index 9696fe5d02..d9e5433146 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/boss/CraftBossBar.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/boss/CraftBossBar.java @@ -68,7 +68,7 @@ public class CraftBossBar implements BossBar { @Override public String getTitle() { - return CraftChatMessage.fromComponent(handle.e()); + return CraftChatMessage.fromComponent(handle.title); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOProvider.java b/paper-server/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOProvider.java index f1c1dc4957..413dd35f06 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOProvider.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOProvider.java @@ -18,7 +18,7 @@ class ChunkIOProvider implements AsynchronousExecutor.CallBackProvider {}); if (data != null) { queuedChunk.compound = (NBTTagCompound) data[1]; @@ -35,20 +35,14 @@ class ChunkIOProvider implements AsynchronousExecutor.CallBackProvider, Predicate, SuggestionProvider { + + private final CraftServer server; + private final Command command; + + public BukkitCommandWrapper(CraftServer server, Command command) { + this.server = server; + this.command = command; + } + + public LiteralCommandNode register(CommandDispatcher dispatcher, String label) { + return dispatcher.register( + LiteralArgumentBuilder.literal(label).requires(this).executes(this) + .then(RequiredArgumentBuilder.argument("args", StringArgumentType.greedyString()).suggests(this).executes(this)) + ); + } + + @Override + public boolean test(CommandListenerWrapper wrapper) { + return command.testPermissionSilent(wrapper.getBukkitSender()); + } + + @Override + public int run(CommandContext context) throws CommandSyntaxException { + return server.dispatchCommand(context.getSource().getBukkitSender(), context.getInput()) ? 1 : 0; + } + + @Override + public CompletableFuture getSuggestions(CommandContext context, SuggestionsBuilder builder) throws CommandSyntaxException { + List results = server.tabComplete(context.getSource().getBukkitSender(), builder.getInput(), context.getSource().getWorld(), context.getSource().getPosition(), true); + for (String s : results) { + builder.suggest(s); + } + + return builder.buildFuture(); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/command/CraftBlockCommandSender.java b/paper-server/src/main/java/org/bukkit/craftbukkit/command/CraftBlockCommandSender.java index 251ea5e0bc..3ad7dfdbf6 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/command/CraftBlockCommandSender.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/command/CraftBlockCommandSender.java @@ -1,7 +1,10 @@ package org.bukkit.craftbukkit.command; +import net.minecraft.server.CommandBlockListenerAbstract; +import net.minecraft.server.CommandListenerWrapper; import net.minecraft.server.ICommandListener; import net.minecraft.server.IChatBaseComponent; +import net.minecraft.server.Vec3D; import org.bukkit.block.Block; import org.bukkit.command.BlockCommandSender; @@ -11,20 +14,21 @@ import org.bukkit.craftbukkit.util.CraftChatMessage; * Represents input from a command block */ public class CraftBlockCommandSender extends ServerCommandSender implements BlockCommandSender { - private final ICommandListener block; + private final CommandListenerWrapper block; - public CraftBlockCommandSender(ICommandListener commandBlockListenerAbstract) { + public CraftBlockCommandSender(CommandListenerWrapper commandBlockListenerAbstract) { super(); this.block = commandBlockListenerAbstract; } public Block getBlock() { - return block.getWorld().getWorld().getBlockAt(block.getChunkCoordinates().getX(), block.getChunkCoordinates().getY(), block.getChunkCoordinates().getZ()); + Vec3D pos = block.getPosition(); + return block.getWorld().getWorld().getBlockAt((int) pos.x, (int) pos.y, (int) pos.z); } public void sendMessage(String message) { for (IChatBaseComponent component : CraftChatMessage.fromString(message)) { - block.sendMessage(component); + block.base.sendMessage(component); } } @@ -46,7 +50,7 @@ public class CraftBlockCommandSender extends ServerCommandSender implements Bloc throw new UnsupportedOperationException("Cannot change operator status of a block"); } - public ICommandListener getTileEntity() { + public CommandListenerWrapper getWrapper() { return block; } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/command/CraftCommandMap.java b/paper-server/src/main/java/org/bukkit/craftbukkit/command/CraftCommandMap.java new file mode 100644 index 0000000000..2fd69c0f91 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/command/CraftCommandMap.java @@ -0,0 +1,17 @@ +package org.bukkit.craftbukkit.command; + +import java.util.Map; +import org.bukkit.Server; +import org.bukkit.command.Command; +import org.bukkit.command.SimpleCommandMap; + +public class CraftCommandMap extends SimpleCommandMap { + + public CraftCommandMap(Server server) { + super(server); + } + + public Map getKnownCommands() { + return knownCommands; + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/command/CraftFunctionCommandSender.java b/paper-server/src/main/java/org/bukkit/craftbukkit/command/CraftFunctionCommandSender.java deleted file mode 100644 index 6bb69bb41e..0000000000 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/command/CraftFunctionCommandSender.java +++ /dev/null @@ -1,47 +0,0 @@ -package org.bukkit.craftbukkit.command; - -import net.minecraft.server.IChatBaseComponent; -import net.minecraft.server.ICommandListener; -import org.bukkit.craftbukkit.util.CraftChatMessage; - -public class CraftFunctionCommandSender extends ServerCommandSender { - - private final ICommandListener handle; - - public CraftFunctionCommandSender(ICommandListener handle) { - this.handle = handle; - } - - @Override - public void sendMessage(String message) { - for (IChatBaseComponent component : CraftChatMessage.fromString(message)) { - handle.sendMessage(component); - } - } - - @Override - public void sendMessage(String[] messages) { - for (String message : messages) { - sendMessage(message); - } - } - - @Override - public String getName() { - return handle.getName(); - } - - @Override - public boolean isOp() { - return true; - } - - @Override - public void setOp(boolean value) { - throw new UnsupportedOperationException("Cannot change operator status of server function sender"); - } - - public ICommandListener getHandle() { - return handle; - } -} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/command/ProxiedNativeCommandSender.java b/paper-server/src/main/java/org/bukkit/craftbukkit/command/ProxiedNativeCommandSender.java index 9acd92c357..07c34cb202 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/command/ProxiedNativeCommandSender.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/command/ProxiedNativeCommandSender.java @@ -2,7 +2,7 @@ package org.bukkit.craftbukkit.command; import java.util.Set; -import net.minecraft.server.ICommandListener; +import net.minecraft.server.CommandListenerWrapper; import org.bukkit.Server; import org.bukkit.command.CommandSender; @@ -14,17 +14,17 @@ import org.bukkit.plugin.Plugin; public class ProxiedNativeCommandSender implements ProxiedCommandSender { - private final ICommandListener orig; + private final CommandListenerWrapper orig; private final CommandSender caller; private final CommandSender callee; - public ProxiedNativeCommandSender(ICommandListener orig, CommandSender caller, CommandSender callee) { + public ProxiedNativeCommandSender(CommandListenerWrapper orig, CommandSender caller, CommandSender callee) { this.orig = orig; this.caller = caller; this.callee = callee; } - public ICommandListener getHandle() { + public CommandListenerWrapper getHandle() { return orig; } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java b/paper-server/src/main/java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java index 6247bbda1c..5de49fe00e 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java @@ -1,12 +1,18 @@ package org.bukkit.craftbukkit.command; -import java.util.Iterator; +import com.google.common.base.Joiner; +import com.mojang.brigadier.ParseResults; +import com.mojang.brigadier.suggestion.Suggestion; +import com.mojang.brigadier.tree.CommandNode; +import java.util.ArrayList; +import java.util.Collections; import java.util.List; - -import net.minecraft.server.*; - +import net.minecraft.server.CommandDispatcher; +import net.minecraft.server.CommandListenerWrapper; +import net.minecraft.server.DedicatedServer; +import net.minecraft.server.EntityMinecartCommandBlock; +import net.minecraft.server.MinecraftServer; import org.apache.commons.lang.Validate; -import org.apache.logging.log4j.Level; import org.bukkit.Location; import org.bukkit.command.BlockCommandSender; import org.bukkit.command.CommandSender; @@ -21,27 +27,23 @@ import org.bukkit.entity.Player; import org.bukkit.entity.minecart.CommandMinecart; public final class VanillaCommandWrapper extends BukkitCommand { - protected final CommandAbstract vanillaCommand; - public VanillaCommandWrapper(CommandAbstract vanillaCommand, String usage) { - super(vanillaCommand.getCommand(), "A Mojang provided command.", usage, vanillaCommand.getAliases()); + private final CommandDispatcher dispatcher; + public final CommandNode vanillaCommand; + + public VanillaCommandWrapper(CommandDispatcher dispatcher, CommandNode vanillaCommand) { + super(vanillaCommand.getName(), "A Mojang provided command.", vanillaCommand.getUsageText(), Collections.EMPTY_LIST); + this.dispatcher = dispatcher; this.vanillaCommand = vanillaCommand; - this.setPermission("minecraft.command." + vanillaCommand.getCommand()); + this.setPermission(getPermission(vanillaCommand)); } @Override public boolean execute(CommandSender sender, String commandLabel, String[] args) { if (!testPermission(sender)) return true; - ICommandListener icommandlistener = getListener(sender); - try { - dispatchVanillaCommand(sender, icommandlistener, args); - } catch (CommandException commandexception) { - // Taken from CommandHandler - ChatMessage chatmessage = new ChatMessage(commandexception.getMessage(), commandexception.getArgs()); - chatmessage.getChatModifier().setColor(EnumChatFormat.RED); - icommandlistener.sendMessage(chatmessage); - } + CommandListenerWrapper icommandlistener = getListener(sender); + dispatcher.a(icommandlistener, toDispatcher(args)); return true; } @@ -50,135 +52,46 @@ public final class VanillaCommandWrapper extends BukkitCommand { Validate.notNull(sender, "Sender cannot be null"); Validate.notNull(args, "Arguments cannot be null"); Validate.notNull(alias, "Alias cannot be null"); - return (List) vanillaCommand.tabComplete(MinecraftServer.getServer(), getListener(sender), args, (location) == null ? null : new BlockPosition(location.getX(), location.getY(), location.getZ())); + + CommandListenerWrapper icommandlistener = getListener(sender); + ParseResults parsed = dispatcher.a().parse(toDispatcher(args), icommandlistener); + + List results = new ArrayList<>(); + dispatcher.a().getCompletionSuggestions(parsed).thenAccept((suggestions) -> { + suggestions.getList().forEach((s) -> results.add(s.getText())); + }); + + return results; } - public static CommandSender lastSender = null; // Nasty :( - - public final int dispatchVanillaCommand(CommandSender bSender, ICommandListener icommandlistener, String[] as) throws CommandException { - // Copied from net.minecraft.server.CommandHandler - int i = getPlayerListSize(as); - int j = 0; - // Some commands use the worldserver variable but we leave it full of null values, - // so we must temporarily populate it with the world of the commandsender - WorldServer[] prev = MinecraftServer.getServer().worldServer; - MinecraftServer server = MinecraftServer.getServer(); - server.worldServer = new WorldServer[server.worlds.size()]; - server.worldServer[0] = (WorldServer) icommandlistener.getWorld(); - int bpos = 0; - for (int pos = 1; pos < server.worldServer.length; pos++) { - WorldServer world = server.worlds.get(bpos++); - if (server.worldServer[0] == world) { - pos--; - continue; - } - server.worldServer[pos] = world; - } - - try { - if (vanillaCommand.canUse(server, icommandlistener)) { - if (i > -1) { - List list = ((List)PlayerSelector.getPlayers(icommandlistener, as[i], Entity.class)); - String s2 = as[i]; - - icommandlistener.a(CommandObjectiveExecutor.EnumCommandResult.AFFECTED_ENTITIES, list.size()); - Iterator iterator = list.iterator(); - - while (iterator.hasNext()) { - Entity entity = iterator.next(); - - CommandSender oldSender = lastSender; - lastSender = bSender; - try { - as[i] = entity.getUniqueID().toString(); - vanillaCommand.execute(server, icommandlistener, as); - j++; - } catch (ExceptionUsage exceptionusage) { - ChatMessage chatmessage = new ChatMessage("commands.generic.usage", new Object[] { new ChatMessage(exceptionusage.getMessage(), exceptionusage.getArgs())}); - chatmessage.getChatModifier().setColor(EnumChatFormat.RED); - icommandlistener.sendMessage(chatmessage); - } catch (CommandException commandexception) { - CommandAbstract.a(icommandlistener, vanillaCommand, 0, commandexception.getMessage(), commandexception.getArgs()); - } finally { - lastSender = oldSender; - } - } - as[i] = s2; - } else { - icommandlistener.a(CommandObjectiveExecutor.EnumCommandResult.AFFECTED_ENTITIES, 1); - vanillaCommand.execute(server, icommandlistener, as); - j++; - } - } else { - ChatMessage chatmessage = new ChatMessage("commands.generic.permission", new Object[0]); - chatmessage.getChatModifier().setColor(EnumChatFormat.RED); - icommandlistener.sendMessage(chatmessage); - } - } catch (ExceptionUsage exceptionusage) { - ChatMessage chatmessage1 = new ChatMessage("commands.generic.usage", new Object[] { new ChatMessage(exceptionusage.getMessage(), exceptionusage.getArgs()) }); - chatmessage1.getChatModifier().setColor(EnumChatFormat.RED); - icommandlistener.sendMessage(chatmessage1); - } catch (CommandException commandexception) { - CommandAbstract.a(icommandlistener, vanillaCommand, 0, commandexception.getMessage(), commandexception.getArgs()); - } catch (Throwable throwable) { - ChatMessage chatmessage3 = new ChatMessage("commands.generic.exception", new Object[0]); - chatmessage3.getChatModifier().setColor(EnumChatFormat.RED); - icommandlistener.sendMessage(chatmessage3); - if (icommandlistener.f() instanceof EntityMinecartCommandBlock) { - MinecraftServer.LOGGER.log(Level.WARN, String.format("MinecartCommandBlock at (%d,%d,%d) failed to handle command", icommandlistener.getChunkCoordinates().getX(), icommandlistener.getChunkCoordinates().getY(), icommandlistener.getChunkCoordinates().getZ()), throwable); - } else if(icommandlistener instanceof CommandBlockListenerAbstract) { - CommandBlockListenerAbstract listener = (CommandBlockListenerAbstract) icommandlistener; - MinecraftServer.LOGGER.log(Level.WARN, String.format("CommandBlock at (%d,%d,%d) failed to handle command", listener.getChunkCoordinates().getX(), listener.getChunkCoordinates().getY(), listener.getChunkCoordinates().getZ()), throwable); - } else { - MinecraftServer.LOGGER.log(Level.WARN, String.format("Unknown CommandBlock failed to handle command"), throwable); - } - } finally { - icommandlistener.a(CommandObjectiveExecutor.EnumCommandResult.SUCCESS_COUNT, j); - MinecraftServer.getServer().worldServer = prev; - } - return j; - } - - private ICommandListener getListener(CommandSender sender) { + private CommandListenerWrapper getListener(CommandSender sender) { if (sender instanceof Player) { - return ((CraftPlayer) sender).getHandle(); + return ((CraftPlayer) sender).getHandle().getCommandListener(); } if (sender instanceof BlockCommandSender) { - return ((CraftBlockCommandSender) sender).getTileEntity(); + return ((CraftBlockCommandSender) sender).getWrapper(); } if (sender instanceof CommandMinecart) { - return ((EntityMinecartCommandBlock) ((CraftMinecartCommand) sender).getHandle()).getCommandBlock(); + return ((EntityMinecartCommandBlock) ((CraftMinecartCommand) sender).getHandle()).getCommandBlock().getWrapper(); } if (sender instanceof RemoteConsoleCommandSender) { - return ((DedicatedServer)MinecraftServer.getServer()).remoteControlCommandListener; + return ((DedicatedServer) MinecraftServer.getServer()).remoteControlCommandListener.f(); } if (sender instanceof ConsoleCommandSender) { - return ((CraftServer) sender.getServer()).getServer(); + return ((CraftServer) sender.getServer()).getServer().getServerCommandListener(); } if (sender instanceof ProxiedCommandSender) { return ((ProxiedNativeCommandSender) sender).getHandle(); } - if (sender instanceof CraftFunctionCommandSender) { - return ((CraftFunctionCommandSender) sender).getHandle(); - } + throw new IllegalArgumentException("Cannot make " + sender + " a vanilla command listener"); } - private int getPlayerListSize(String as[]) throws CommandException { - for (int i = 0; i < as.length; i++) { - if (vanillaCommand.isListStart(as, i) && PlayerSelector.isList(as[i])) { - return i; - } - } - return -1; + public static String getPermission(CommandNode vanillaCommand) { + return "minecraft.command." + ((vanillaCommand.getRedirect() == null) ? vanillaCommand.getName() : vanillaCommand.getRedirect().getName()); } - public static String[] dropFirstArgument(String as[]) { - String as1[] = new String[as.length - 1]; - for (int i = 1; i < as.length; i++) { - as1[i - 1] = as[i]; - } - - return as1; + private String toDispatcher(String[] args) { + return getName() + ((args.length > 0) ? " " + Joiner.on(' ').join(args) : ""); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java b/paper-server/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java index f98e3e9a04..4ce4449520 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java @@ -1,6 +1,9 @@ package org.bukkit.craftbukkit.enchantments; +import net.minecraft.server.EnchantmentBinding; +import net.minecraft.server.EnchantmentVanishing; import org.bukkit.craftbukkit.inventory.CraftItemStack; +import org.bukkit.craftbukkit.util.CraftNamespacedKey; import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.EnchantmentTarget; import org.bukkit.enchantments.EnchantmentWrapper; @@ -10,7 +13,7 @@ public class CraftEnchantment extends Enchantment { private final net.minecraft.server.Enchantment target; public CraftEnchantment(net.minecraft.server.Enchantment target) { - super(net.minecraft.server.Enchantment.getId(target)); + super(CraftNamespacedKey.fromMinecraft(net.minecraft.server.Enchantment.enchantments.b(target))); this.target = target; } @@ -51,6 +54,8 @@ public class CraftEnchantment extends Enchantment { return EnchantmentTarget.BREAKABLE; case WEARABLE: return EnchantmentTarget.WEARABLE; + case TRIDENT: + return EnchantmentTarget.TRIDENT; default: return null; } @@ -63,7 +68,7 @@ public class CraftEnchantment extends Enchantment { @Override public boolean isCursed() { - return target.isCursed(); + return target instanceof EnchantmentBinding || target instanceof EnchantmentVanishing; } @Override @@ -73,7 +78,8 @@ public class CraftEnchantment extends Enchantment { @Override public String getName() { - switch (getId()) { + // PAIL: migration paths + switch (net.minecraft.server.Enchantment.enchantments.a(target)) { case 0: return "PROTECTION_ENVIRONMENTAL"; case 1: @@ -96,46 +102,54 @@ public class CraftEnchantment extends Enchantment { return "FROST_WALKER"; case 10: return "BINDING_CURSE"; - case 16: + case 11: return "DAMAGE_ALL"; - case 17: + case 12: return "DAMAGE_UNDEAD"; - case 18: + case 13: return "DAMAGE_ARTHROPODS"; - case 19: + case 14: return "KNOCKBACK"; - case 20: + case 15: return "FIRE_ASPECT"; - case 21: + case 16: return "LOOT_BONUS_MOBS"; - case 22: + case 17: return "SWEEPING_EDGE"; - case 32: + case 18: return "DIG_SPEED"; - case 33: + case 19: return "SILK_TOUCH"; - case 34: + case 20: return "DURABILITY"; - case 35: + case 21: return "LOOT_BONUS_BLOCKS"; - case 48: + case 22: return "ARROW_DAMAGE"; - case 49: + case 23: return "ARROW_KNOCKBACK"; - case 50: + case 24: return "ARROW_FIRE"; - case 51: + case 25: return "ARROW_INFINITE"; - case 61: + case 26: return "LUCK"; - case 62: + case 27: return "LURE"; - case 70: + case 28: + return "LOYALTY"; + case 29: + return "IMPALING"; + case 30: + return "RIPTIDE"; + case 31: + return "CHANNELING"; + case 32: return "MENDING"; - case 71: + case 33: return "VANISHING_CURSE"; default: - return "UNKNOWN_ENCHANT_" + getId(); + return "UNKNOWN_ENCHANT_" + getName(); } } @@ -160,7 +174,7 @@ public class CraftEnchantment extends Enchantment { return false; } CraftEnchantment ench = (CraftEnchantment) other; - return !target.c(ench.target); + return !target.b(ench.target); } public net.minecraft.server.Enchantment getHandle() { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java index 9942576716..e47080db88 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java @@ -59,7 +59,7 @@ public class CraftArrow extends AbstractProjectile implements Arrow { } EntityArrow handle = getHandle(); - return getWorld().getBlockAt(handle.h, handle.at, handle.au); // PAIL: rename tileX, tileY, tileZ + return getWorld().getBlockAt(handle.tileX, handle.tileY, handle.tileZ); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCod.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCod.java new file mode 100644 index 0000000000..9cda680c0b --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCod.java @@ -0,0 +1,28 @@ +package org.bukkit.craftbukkit.entity; + +import net.minecraft.server.EntityCod; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.entity.Cod; +import org.bukkit.entity.EntityType; + +public class CraftCod extends CraftFish implements Cod { + + public CraftCod(CraftServer server, EntityCod entity) { + super(server, entity); + } + + @Override + public EntityCod getHandle() { + return (EntityCod) super.getHandle(); + } + + @Override + public String toString() { + return "CraftCod"; + } + + @Override + public EntityType getType() { + return EntityType.COD; + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftDolphin.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftDolphin.java new file mode 100644 index 0000000000..7a838f3818 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftDolphin.java @@ -0,0 +1,28 @@ +package org.bukkit.craftbukkit.entity; + +import net.minecraft.server.EntityDolphin; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.entity.Dolphin; +import org.bukkit.entity.EntityType; + +public class CraftDolphin extends CraftCreature implements Dolphin { + + public CraftDolphin(CraftServer server, EntityDolphin entity) { + super(server, entity); + } + + @Override + public EntityDolphin getHandle() { + return (EntityDolphin) super.getHandle(); + } + + @Override + public String toString() { + return "CraftDolphin"; + } + + @Override + public EntityType getType() { + return EntityType.DOLPHIN; + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftDrowned.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftDrowned.java new file mode 100644 index 0000000000..6e41dfd923 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftDrowned.java @@ -0,0 +1,28 @@ +package org.bukkit.craftbukkit.entity; + +import net.minecraft.server.EntityDrowned; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.entity.Drowned; +import org.bukkit.entity.EntityType; + +public class CraftDrowned extends CraftZombie implements Drowned { + + public CraftDrowned(CraftServer server, EntityDrowned entity) { + super(server, entity); + } + + @Override + public EntityDrowned getHandle() { + return (EntityDrowned) entity; + } + + @Override + public String toString() { + return "CraftDrowned"; + } + + @Override + public EntityType getType() { + return EntityType.DROWNED; + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderSignal.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderSignal.java index aaa624aeec..d771fdc6ed 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderSignal.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderSignal.java @@ -30,7 +30,7 @@ public class CraftEnderSignal extends CraftEntity implements EnderSignal { @Override public Location getTargetLocation() { - return new Location(getWorld(), getHandle().a, getHandle().b, getHandle().c, getHandle().yaw, getHandle().pitch); // PAIL rename targetX, targetY, targetZ + return new Location(getWorld(), getHandle().targetX, getHandle().targetY, getHandle().targetZ, getHandle().yaw, getHandle().pitch); } @Override @@ -41,21 +41,21 @@ public class CraftEnderSignal extends CraftEntity implements EnderSignal { @Override public boolean getDropItem() { - return getHandle().e; // PAIL rename getDropItem + return getHandle().shouldDropItem; } @Override public void setDropItem(boolean shouldDropItem) { - getHandle().e = shouldDropItem; // PAIL rename getDropItem + getHandle().shouldDropItem = shouldDropItem; } @Override public int getDespawnTimer() { - return getHandle().d; // PAIL rename despawnTimer + return getHandle().despawnTimer; } @Override public void setDespawnTimer(int time) { - getHandle().d = time; // PAIL rename despawnTimer + getHandle().despawnTimer = time; } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderman.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderman.java index f602c2313c..5998530a8f 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderman.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderman.java @@ -3,8 +3,9 @@ package org.bukkit.craftbukkit.entity; import net.minecraft.server.EntityEnderman; import net.minecraft.server.IBlockData; -import org.bukkit.Material; +import org.bukkit.block.data.BlockData; import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.craftbukkit.block.data.CraftBlockData; import org.bukkit.craftbukkit.util.CraftMagicNumbers; import org.bukkit.entity.Enderman; import org.bukkit.entity.EntityType; @@ -17,11 +18,22 @@ public class CraftEnderman extends CraftMonster implements Enderman { public MaterialData getCarriedMaterial() { IBlockData blockData = getHandle().getCarried(); - return (blockData == null) ? Material.AIR.getNewData((byte) 0) : CraftMagicNumbers.getMaterial(blockData.getBlock()).getNewData((byte) blockData.getBlock().toLegacyData(blockData)); + return CraftMagicNumbers.getMaterial(blockData); + } + + @Override + public BlockData getCarriedBlock() { + IBlockData blockData = getHandle().getCarried(); + return CraftBlockData.fromData(blockData); } public void setCarriedMaterial(MaterialData data) { - getHandle().setCarried(CraftMagicNumbers.getBlock(data.getItemTypeId()).fromLegacyData(data.getData())); + getHandle().setCarried(CraftMagicNumbers.getBlock(data)); + } + + @Override + public void setCarriedBlock(BlockData blockData) { + getHandle().setCarried(((CraftBlockData) blockData).getState()); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java index 961cf24c24..f0a52de5bd 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java @@ -16,6 +16,7 @@ import org.bukkit.World; import org.bukkit.block.PistonMoveReaction; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftWorld; +import org.bukkit.craftbukkit.util.CraftChatMessage; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; import org.bukkit.metadata.MetadataValue; @@ -52,6 +53,14 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { // Water Animals else if (entity instanceof EntityWaterAnimal) { if (entity instanceof EntitySquid) { return new CraftSquid(server, (EntitySquid) entity); } + else if (entity instanceof EntityFish) { + if (entity instanceof EntityCod) { return new CraftCod(server, (EntityCod) entity); } + else if (entity instanceof EntityPufferFish) { return new CraftPufferFish(server, (EntityPufferFish) entity); } + else if (entity instanceof EntitySalmon) { return new CraftSalmon(server, (EntitySalmon) entity); } + else if (entity instanceof EntityTropicalFish) { return new CraftTropicalFish(server, (EntityTropicalFish) entity); } + else { return new CraftFish(server, (EntityFish) entity); } + } + else if (entity instanceof EntityDolphin) { return new CraftDolphin(server, (EntityDolphin) entity); } else { return new CraftWaterMob(server, (EntityWaterAnimal) entity); } } else if (entity instanceof EntityCreature) { @@ -80,6 +89,7 @@ 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 { return new CraftAnimals(server, (EntityAnimal) entity); } } // Monsters @@ -88,6 +98,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { if (entity instanceof EntityPigZombie) { return new CraftPigZombie(server, (EntityPigZombie) entity); } else if (entity instanceof EntityZombieHusk) { return new CraftHusk(server, (EntityZombieHusk) entity); } else if (entity instanceof EntityZombieVillager) { return new CraftVillagerZombie(server, (EntityZombieVillager) entity); } + else if (entity instanceof EntityDrowned) { return new CraftDrowned(server, (EntityDrowned) entity); } else { return new CraftZombie(server, (EntityZombie) entity); } } else if (entity instanceof EntityCreeper) { return new CraftCreeper(server, (EntityCreeper) entity); } @@ -140,6 +151,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { // Flying else if (entity instanceof EntityFlying) { if (entity instanceof EntityGhast) { return new CraftGhast(server, (EntityGhast) entity); } + else if (entity instanceof EntityPhantom) { return new CraftPhantom(server, (EntityPhantom) entity); } else { return new CraftFlying(server, (EntityFlying) entity); } } else if (entity instanceof EntityEnderDragon) { @@ -164,7 +176,10 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { else { return new CraftArrow(server, (EntityArrow) entity); } } else if (entity instanceof EntitySpectralArrow) { return new CraftSpectralArrow(server, (EntitySpectralArrow) entity); } - else if (entity instanceof EntityArrow) { return new CraftArrow(server, (EntityArrow) entity); } + else if (entity instanceof EntityArrow) { + if (entity instanceof EntityThrownTrident) { return new CraftTrident(server, (EntityThrownTrident) entity); } + else { return new CraftArrow(server, (EntityArrow) entity); } + } else if (entity instanceof EntityBoat) { return new CraftBoat(server, (EntityBoat) entity); } else if (entity instanceof EntityProjectile) { if (entity instanceof EntityEgg) { return new CraftEgg(server, (EntityEgg) entity); } @@ -186,7 +201,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { } else if (entity instanceof EntityEnderSignal) { return new CraftEnderSignal(server, (EntityEnderSignal) entity); } else if (entity instanceof EntityEnderCrystal) { return new CraftEnderCrystal(server, (EntityEnderCrystal) entity); } - else if (entity instanceof EntityFishingHook) { return new CraftFish(server, (EntityFishingHook) 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); } @@ -507,7 +522,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { return null; } - return getHandle().bJ().getBukkitEntity(); // PAIL: rename getVehicle() -> getRootVehicle(), bJ() -> getVehicle() + return getHandle().getVehicle().getBukkitEntity(); } @Override @@ -516,18 +531,23 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { name = ""; } - getHandle().setCustomName(name); + // sane limit for name length + if (name.length() > 256) { + name = name.substring(0, 256); + } + + getHandle().setCustomName(CraftChatMessage.fromStringOrNull(name)); } @Override public String getCustomName() { - String name = getHandle().getCustomName(); + IChatBaseComponent name = getHandle().getCustomName(); - if (name == null || name.length() == 0) { + if (name == null) { return null; } - return name; + return CraftChatMessage.fromComponent(name); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingBlock.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingBlock.java index b0a7f63926..b4322dff66 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingBlock.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingBlock.java @@ -3,7 +3,9 @@ package org.bukkit.craftbukkit.entity; import net.minecraft.server.EntityFallingBlock; import org.bukkit.Material; +import org.bukkit.block.data.BlockData; import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.craftbukkit.block.data.CraftBlockData; import org.bukkit.craftbukkit.util.CraftMagicNumbers; import org.bukkit.entity.EntityType; import org.bukkit.entity.FallingBlock; @@ -29,15 +31,11 @@ public class CraftFallingBlock extends CraftEntity implements FallingBlock { } public Material getMaterial() { - return Material.getMaterial(getBlockId()); + return CraftMagicNumbers.getMaterial(getHandle().getBlock()).getItemType(); } - public int getBlockId() { - return CraftMagicNumbers.getId(getHandle().getBlock().getBlock()); - } - - public byte getBlockData() { - return (byte) getHandle().getBlock().getBlock().toLegacyData(getHandle().getBlock()); + public BlockData getBlockData() { + return CraftBlockData.fromData(getHandle().getBlock()); } public boolean getDropItem() { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java index 99746b3c2a..7b3b206823 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java @@ -24,15 +24,15 @@ public class CraftFirework extends CraftEntity implements Firework { ItemStack item = getHandle().getDataWatcher().get(EntityFireworks.FIREWORK_ITEM); if (item.isEmpty()) { - item = new ItemStack(Items.FIREWORKS); + item = new ItemStack(Items.FIREWORK_ROCKET); getHandle().getDataWatcher().set(EntityFireworks.FIREWORK_ITEM, item); } this.item = CraftItemStack.asCraftMirror(item); // Ensure the item is a firework... - if (this.item.getType() != Material.FIREWORK) { - this.item.setType(Material.FIREWORK); + if (this.item.getType() != Material.FIREWORK_ROCKET) { + this.item.setType(Material.FIREWORK_ROCKET); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFish.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFish.java index d555597dc4..aaa6bed335 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFish.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFish.java @@ -1,65 +1,22 @@ package org.bukkit.craftbukkit.entity; -import net.minecraft.server.BlockPosition; -import net.minecraft.server.EntityFishingHook; -import net.minecraft.server.EntityHuman; -import net.minecraft.server.MathHelper; - -import org.apache.commons.lang.Validate; +import net.minecraft.server.EntityFish; import org.bukkit.craftbukkit.CraftServer; -import org.bukkit.entity.EntityType; import org.bukkit.entity.Fish; -import org.bukkit.projectiles.ProjectileSource; -public class CraftFish extends AbstractProjectile implements Fish { - private double biteChance = -1; +public class CraftFish extends CraftCreature implements Fish { - public CraftFish(CraftServer server, EntityFishingHook entity) { + public CraftFish(CraftServer server, EntityFish entity) { super(server, entity); } - public ProjectileSource getShooter() { - if (getHandle().owner != null) { - return getHandle().owner.getBukkitEntity(); - } - - return null; - } - - public void setShooter(ProjectileSource shooter) { - if (shooter instanceof CraftHumanEntity) { - getHandle().owner = (EntityHuman) ((CraftHumanEntity) shooter).entity; - } - } - @Override - public EntityFishingHook getHandle() { - return (EntityFishingHook) entity; + public EntityFish getHandle() { + return (EntityFish) entity; } @Override public String toString() { return "CraftFish"; } - - public EntityType getType() { - return EntityType.FISHING_HOOK; - } - - public double getBiteChance() { - EntityFishingHook hook = getHandle(); - - if (this.biteChance == -1) { - if (hook.world.isRainingAt(new BlockPosition(MathHelper.floor(hook.locX), MathHelper.floor(hook.locY) + 1, MathHelper.floor(hook.locZ)))) { - return 1/300.0; - } - return 1/500.0; - } - return this.biteChance; - } - - public void setBiteChance(double chance) { - Validate.isTrue(chance >= 0 && chance <= 1, "The bite chance must be between 0 and 1."); - this.biteChance = chance; - } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFishHook.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFishHook.java new file mode 100644 index 0000000000..8392b16b3b --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFishHook.java @@ -0,0 +1,65 @@ +package org.bukkit.craftbukkit.entity; + +import net.minecraft.server.BlockPosition; +import net.minecraft.server.EntityFishingHook; +import net.minecraft.server.EntityHuman; +import net.minecraft.server.MathHelper; + +import org.apache.commons.lang.Validate; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.FishHook; +import org.bukkit.projectiles.ProjectileSource; + +public class CraftFishHook extends AbstractProjectile implements FishHook { + private double biteChance = -1; + + public CraftFishHook(CraftServer server, EntityFishingHook entity) { + super(server, entity); + } + + public ProjectileSource getShooter() { + if (getHandle().owner != null) { + return getHandle().owner.getBukkitEntity(); + } + + return null; + } + + public void setShooter(ProjectileSource shooter) { + if (shooter instanceof CraftHumanEntity) { + getHandle().owner = (EntityHuman) ((CraftHumanEntity) shooter).entity; + } + } + + @Override + public EntityFishingHook getHandle() { + return (EntityFishingHook) entity; + } + + @Override + public String toString() { + return "CraftFishingHook"; + } + + public EntityType getType() { + return EntityType.FISHING_HOOK; + } + + public double getBiteChance() { + EntityFishingHook hook = getHandle(); + + if (this.biteChance == -1) { + if (hook.world.isRainingAt(new BlockPosition(MathHelper.floor(hook.locX), MathHelper.floor(hook.locY) + 1, MathHelper.floor(hook.locZ)))) { + return 1/300.0; + } + return 1/500.0; + } + return this.biteChance; + } + + public void setBiteChance(double chance) { + Validate.isTrue(chance >= 0 && chance <= 1, "The bite chance must be between 0 and 1."); + this.biteChance = chance; + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java index a54548f024..269bbd8e77 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java @@ -48,10 +48,6 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { enderChest = new CraftInventory(entity.getEnderChest()); } - public String getName() { - return getHandle().getName(); - } - public PlayerInventory getInventory() { return inventory; } @@ -295,7 +291,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { public InventoryView openWorkbench(Location location, boolean force) { if (!force) { Block block = location.getBlock(); - if (block.getType() != Material.WORKBENCH) { + if (block.getType() != Material.CRAFTING_TABLE) { return null; } } @@ -312,7 +308,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { public InventoryView openEnchanting(Location location, boolean force) { if (!force) { Block block = location.getBlock(); - if (block.getType() != Material.ENCHANTMENT_TABLE) { + if (block.getType() != Material.ENCHANTING_TABLE) { return null; } } @@ -325,7 +321,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { TileEntity container = getHandle().world.getTileEntity(pos); if (container == null && force) { container = new TileEntityEnchantTable(); - container.a(getHandle().world); + container.setWorld(getHandle().world); container.setPosition(pos); } getHandle().openTileEntity((ITileEntityContainer) container); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java index bf4428e1c7..0b12ed8197 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java @@ -27,6 +27,7 @@ import net.minecraft.server.EntitySnowball; import net.minecraft.server.EntityThrownExpBottle; import net.minecraft.server.EntityTippedArrow; import net.minecraft.server.EntitySpectralArrow; +import net.minecraft.server.EntityThrownTrident; import net.minecraft.server.EntityWither; import net.minecraft.server.EntityWitherSkull; import net.minecraft.server.GenericAttributes; @@ -65,6 +66,7 @@ import org.bukkit.entity.SpectralArrow; import org.bukkit.entity.ThrownExpBottle; import org.bukkit.entity.ThrownPotion; import org.bukkit.entity.TippedArrow; +import org.bukkit.entity.Trident; import org.bukkit.entity.WitherSkull; import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.inventory.EntityEquipment; @@ -318,6 +320,8 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { ((EntityTippedArrow) launch).setType(CraftPotionUtil.fromBukkit(new PotionData(PotionType.WATER, false, false))); } else if (SpectralArrow.class.isAssignableFrom(projectile)) { launch = new EntitySpectralArrow(world, getHandle()); + } else if (Trident.class.isAssignableFrom(projectile)) { + launch = new EntityThrownTrident(world, getHandle(), net.minecraft.server.ItemStack.a); } else { launch = new EntityTippedArrow(world, getHandle()); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java index 485998771b..7d31981208 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java @@ -4,7 +4,9 @@ import net.minecraft.server.Blocks; import net.minecraft.server.EntityMinecartAbstract; import net.minecraft.server.IBlockData; +import org.bukkit.block.data.BlockData; import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.craftbukkit.block.data.CraftBlockData; import org.bukkit.craftbukkit.util.CraftMagicNumbers; import org.bukkit.entity.Minecart; import org.bukkit.material.MaterialData; @@ -64,7 +66,19 @@ public abstract class CraftMinecart extends CraftVehicle implements Minecart { public void setDisplayBlock(MaterialData material) { if(material != null) { - IBlockData block = CraftMagicNumbers.getBlock(material.getItemTypeId()).fromLegacyData(material.getData()); + IBlockData block = CraftMagicNumbers.getBlock(material); + this.getHandle().setDisplayBlock(block); + } else { + // Set block to air (default) and set the flag to not have a display block. + this.getHandle().setDisplayBlock(Blocks.AIR.getBlockData()); + this.getHandle().a(false); + } + } + + @Override + public void setDisplayBlockData(BlockData blockData) { + if (blockData != null) { + IBlockData block = ((CraftBlockData) blockData).getState(); this.getHandle().setDisplayBlock(block); } else { // Set block to air (default) and set the flag to not have a display block. @@ -75,7 +89,13 @@ public abstract class CraftMinecart extends CraftVehicle implements Minecart { public MaterialData getDisplayBlock() { IBlockData blockData = getHandle().getDisplayBlock(); - return CraftMagicNumbers.getMaterial(blockData.getBlock()).getNewData((byte) blockData.getBlock().toLegacyData(blockData)); + return CraftMagicNumbers.getMaterial(blockData); + } + + @Override + public BlockData getDisplayBlockData() { + IBlockData blockData = getHandle().getDisplayBlock(); + return CraftBlockData.fromData(blockData); } public void setDisplayBlockOffset(int offset) { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartCommand.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartCommand.java index 58f3cf7871..b178acd475 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartCommand.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartCommand.java @@ -7,6 +7,7 @@ import net.minecraft.server.EntityMinecartCommandBlock; import org.bukkit.Bukkit; import org.bukkit.Server; import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.craftbukkit.util.CraftChatMessage; import org.bukkit.entity.EntityType; import org.bukkit.entity.minecart.CommandMinecart; import org.bukkit.permissions.PermissibleBase; @@ -40,7 +41,7 @@ public class CraftMinecartCommand extends CraftMinecart implements CommandMineca @Override public void setName(String name) { - getHandle().getCommandBlock().setName(name != null ? name : "@"); + getHandle().getCommandBlock().setName(CraftChatMessage.fromStringOrNull(name)); } @Override @@ -63,7 +64,7 @@ public class CraftMinecartCommand extends CraftMinecart implements CommandMineca @Override public String getName() { - return getHandle().getCommandBlock().getName(); + return CraftChatMessage.fromComponent(getHandle().getCommandBlock().getName()); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java index 3e9448a923..9c29a56da6 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java @@ -1,7 +1,7 @@ package org.bukkit.craftbukkit.entity; import net.minecraft.server.EntityPainting; -import net.minecraft.server.EntityPainting.EnumArt; +import net.minecraft.server.Paintings; import net.minecraft.server.WorldServer; import org.bukkit.Art; @@ -19,7 +19,7 @@ public class CraftPainting extends CraftHanging implements Painting { } public Art getArt() { - EnumArt art = getHandle().art; + Paintings art = getHandle().art; return CraftArt.NotchToBukkit(art); } @@ -29,7 +29,7 @@ public class CraftPainting extends CraftHanging implements Painting { public boolean setArt(Art art, boolean force) { EntityPainting painting = this.getHandle(); - EnumArt oldArt = painting.art; + Paintings oldArt = painting.art; painting.art = CraftArt.BukkitToNotch(art); painting.setDirection(painting.direction); if (!force && !painting.survives()) { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPhantom.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPhantom.java new file mode 100644 index 0000000000..9f9ee92390 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPhantom.java @@ -0,0 +1,38 @@ +package org.bukkit.craftbukkit.entity; + +import net.minecraft.server.EntityPhantom; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Phantom; + +public class CraftPhantom extends CraftFlying implements Phantom { + + public CraftPhantom(CraftServer server, EntityPhantom entity) { + super(server, entity); + } + + @Override + public EntityPhantom getHandle() { + return (EntityPhantom) super.getHandle(); + } + + @Override + public int getSize() { + return getHandle().getSize(); + } + + @Override + public void setSize(int sz) { + getHandle().setSize(sz); + } + + @Override + public String toString() { + return "CraftPhantom"; + } + + @Override + public EntityType getType() { + return EntityType.PHANTOM; + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index 4c44a1988c..042287e44c 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -24,8 +24,46 @@ import java.util.WeakHashMap; import java.util.logging.Level; import java.util.logging.Logger; -import net.minecraft.server.*; -import net.minecraft.server.PacketPlayOutTitle.EnumTitleAction; +import net.minecraft.server.AdvancementDataPlayer; +import net.minecraft.server.AdvancementProgress; +import net.minecraft.server.AttributeInstance; +import net.minecraft.server.AttributeMapServer; +import net.minecraft.server.AttributeModifiable; +import net.minecraft.server.AttributeRanged; +import net.minecraft.server.BlockPosition; +import net.minecraft.server.Container; +import net.minecraft.server.Entity; +import net.minecraft.server.EntityHuman; +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; +import net.minecraft.server.MapIcon; +import net.minecraft.server.MinecraftKey; +import net.minecraft.server.NBTTagCompound; +import net.minecraft.server.PacketDataSerializer; +import net.minecraft.server.PacketPlayOutBlockChange; +import net.minecraft.server.PacketPlayOutChat; +import net.minecraft.server.PacketPlayOutCustomPayload; +import net.minecraft.server.PacketPlayOutCustomSoundEffect; +import net.minecraft.server.PacketPlayOutMap; +import net.minecraft.server.PacketPlayOutNamedSoundEffect; +import net.minecraft.server.PacketPlayOutPlayerInfo; +import net.minecraft.server.PacketPlayOutSpawnPosition; +import net.minecraft.server.PacketPlayOutStopSound; +import net.minecraft.server.PacketPlayOutTitle; +import net.minecraft.server.PacketPlayOutUpdateAttributes; +import net.minecraft.server.PacketPlayOutUpdateHealth; +import net.minecraft.server.PacketPlayOutWorldEvent; +import net.minecraft.server.PacketPlayOutWorldParticles; +import net.minecraft.server.PlayerConnection; +import net.minecraft.server.TileEntitySign; +import net.minecraft.server.Vec3D; +import net.minecraft.server.WhiteListEntry; +import net.minecraft.server.WorldServer; import org.apache.commons.lang.Validate; import org.apache.commons.lang.NotImplementedException; @@ -36,12 +74,14 @@ import org.bukkit.Statistic; import org.bukkit.Material; import org.bukkit.Statistic.Type; import org.bukkit.World; +import org.bukkit.block.data.BlockData; import org.bukkit.configuration.serialization.DelegateDeserialization; import org.bukkit.conversations.Conversation; import org.bukkit.conversations.ConversationAbandonedEvent; import org.bukkit.conversations.ManuallyAbandonedConversationCanceller; import org.bukkit.craftbukkit.CraftParticle; import org.bukkit.craftbukkit.block.CraftSign; +import org.bukkit.craftbukkit.block.data.CraftBlockData; import org.bukkit.craftbukkit.conversations.ConversationTracker; import org.bukkit.craftbukkit.CraftEffect; import org.bukkit.craftbukkit.CraftOfflinePlayer; @@ -58,7 +98,6 @@ import org.bukkit.craftbukkit.util.CraftChatMessage; import org.bukkit.craftbukkit.util.CraftMagicNumbers; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; -import org.bukkit.event.player.PlayerGameModeChangeEvent; import org.bukkit.event.player.PlayerRegisterChannelEvent; import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.event.player.PlayerUnregisterChannelEvent; @@ -66,7 +105,6 @@ import org.bukkit.inventory.InventoryView.Property; import org.bukkit.map.MapCursor; import org.bukkit.map.MapView; import org.bukkit.metadata.MetadataValue; -import org.bukkit.plugin.IllegalPluginAccessException; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.messaging.StandardMessenger; import org.bukkit.scoreboard.Scoreboard; @@ -182,7 +220,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { if (name == null) { name = getName(); } - getHandle().listName = name.equals(getName()) ? null : CraftChatMessage.fromString(name)[0]; + getHandle().listName = name.equals(getName()) ? null : CraftChatMessage.fromStringOrNull(name); for (EntityPlayer player : (List)server.getHandle().players) { if (player.getBukkitEntity().canSee(this)) { player.playerConnection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_DISPLAY_NAME, getHandle())); @@ -347,7 +385,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { public void playSound(Location loc, String sound, org.bukkit.SoundCategory category, float volume, float pitch) { if (loc == null || sound == null || category == null || getHandle().playerConnection == null) return; - PacketPlayOutCustomSoundEffect packet = new PacketPlayOutCustomSoundEffect(sound, net.minecraft.server.SoundCategory.valueOf(category.name()), loc.getX(), loc.getY(), loc.getZ(), volume, pitch); + PacketPlayOutCustomSoundEffect packet = new PacketPlayOutCustomSoundEffect(new MinecraftKey(sound), net.minecraft.server.SoundCategory.valueOf(category.name()), new Vec3D(loc.getX(), loc.getY(), loc.getZ()), volume, pitch); getHandle().playerConnection.sendPacket(packet); } @@ -369,11 +407,8 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @Override public void stopSound(String sound, org.bukkit.SoundCategory category) { if (getHandle().playerConnection == null) return; - PacketDataSerializer packetdataserializer = new PacketDataSerializer(Unpooled.buffer()); - packetdataserializer.a(category == null ? "" : net.minecraft.server.SoundCategory.valueOf(category.name()).a()); - packetdataserializer.a(sound); - getHandle().playerConnection.sendPacket(new PacketPlayOutCustomPayload("MC|StopSound", packetdataserializer)); + getHandle().playerConnection.sendPacket(new PacketPlayOutStopSound(new MinecraftKey(sound), category == null ? net.minecraft.server.SoundCategory.MASTER : net.minecraft.server.SoundCategory.valueOf(category.name()))); } @Override @@ -399,16 +434,21 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @Override public void sendBlockChange(Location loc, Material material, byte data) { - sendBlockChange(loc, material.getId(), data); - } - - @Override - public void sendBlockChange(Location loc, int material, byte data) { if (getHandle().playerConnection == null) return; PacketPlayOutBlockChange packet = new PacketPlayOutBlockChange(((CraftWorld) loc.getWorld()).getHandle(), new BlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())); - packet.block = CraftMagicNumbers.getBlock(material).fromLegacyData(data); + packet.block = CraftMagicNumbers.getBlock(material, data); + getHandle().playerConnection.sendPacket(packet); + } + + @Override + public void sendBlockChange(Location loc, BlockData block) { + if (getHandle().playerConnection == null) return; + + PacketPlayOutBlockChange packet = new PacketPlayOutBlockChange(((CraftWorld) loc.getWorld()).getHandle(), new BlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())); + + packet.block = ((CraftBlockData) block).getState(); getHandle().playerConnection.sendPacket(packet); } @@ -477,7 +517,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { Collection icons = new ArrayList(); for (MapCursor cursor : data.cursors) { if (cursor.isVisible()) { - icons.add(new MapIcon(MapIcon.Type.a(cursor.getRawType()), cursor.getX(), cursor.getY(), cursor.getDirection())); + icons.add(new MapIcon(MapIcon.Type.a(cursor.getRawType()), cursor.getX(), cursor.getY(), cursor.getDirection(), CraftChatMessage.fromStringOrNull(cursor.getCaption()))); } } @@ -783,9 +823,9 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @Override public void setWhitelisted(boolean value) { if (value) { - server.getHandle().addWhitelist(getProfile()); + server.getHandle().getWhitelist().add(new WhiteListEntry(getProfile())); } else { - server.getHandle().removeWhitelist(getProfile()); + server.getHandle().getWhitelist().remove(getProfile()); } } @@ -1129,7 +1169,8 @@ public class CraftPlayer extends CraftHumanEntity implements Player { if (getHandle().playerConnection == null) return; if (channels.contains(channel)) { - PacketPlayOutCustomPayload packet = new PacketPlayOutCustomPayload(channel, new PacketDataSerializer(Unpooled.wrappedBuffer(message))); + channel = StandardMessenger.validateAndCorrectChannel(channel); + PacketPlayOutCustomPayload packet = new PacketPlayOutCustomPayload(new MinecraftKey(channel), new PacketDataSerializer(Unpooled.wrappedBuffer(message))); getHandle().playerConnection.sendPacket(packet); } } @@ -1156,12 +1197,14 @@ public class CraftPlayer extends CraftHumanEntity implements Player { } public void addChannel(String channel) { + channel = StandardMessenger.validateAndCorrectChannel(channel); if (channels.add(channel)) { server.getPluginManager().callEvent(new PlayerRegisterChannelEvent(this, channel)); } } public void removeChannel(String channel) { + channel = StandardMessenger.validateAndCorrectChannel(channel); if (channels.remove(channel)) { server.getPluginManager().callEvent(new PlayerUnregisterChannelEvent(this, channel)); } @@ -1188,7 +1231,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { } } - getHandle().playerConnection.sendPacket(new PacketPlayOutCustomPayload("REGISTER", new PacketDataSerializer(Unpooled.wrappedBuffer(stream.toByteArray())))); + getHandle().playerConnection.sendPacket(new PacketPlayOutCustomPayload(new MinecraftKey("register"), new PacketDataSerializer(Unpooled.wrappedBuffer(stream.toByteArray())))); } } @@ -1290,7 +1333,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @Override public float getFlySpeed() { - return getHandle().abilities.flySpeed * 2f; + return (float) getHandle().abilities.flySpeed * 2f; } @Override @@ -1436,19 +1479,19 @@ public class CraftPlayer extends CraftHumanEntity implements Player { getHandle().playerConnection.sendPacket(times); if (title != null) { - PacketPlayOutTitle packetTitle = new PacketPlayOutTitle(EnumTitleAction.TITLE, CraftChatMessage.fromString(title)[0]); + PacketPlayOutTitle packetTitle = new PacketPlayOutTitle(PacketPlayOutTitle.EnumTitleAction.TITLE, CraftChatMessage.fromStringOrNull(title)); getHandle().playerConnection.sendPacket(packetTitle); } if (subtitle != null) { - PacketPlayOutTitle packetSubtitle = new PacketPlayOutTitle(EnumTitleAction.SUBTITLE, CraftChatMessage.fromString(subtitle)[0]); + PacketPlayOutTitle packetSubtitle = new PacketPlayOutTitle(PacketPlayOutTitle.EnumTitleAction.SUBTITLE, CraftChatMessage.fromStringOrNull(subtitle)); getHandle().playerConnection.sendPacket(packetSubtitle); } } @Override public void resetTitle() { - PacketPlayOutTitle packetReset = new PacketPlayOutTitle(EnumTitleAction.RESET, null); + PacketPlayOutTitle packetReset = new PacketPlayOutTitle(PacketPlayOutTitle.EnumTitleAction.RESET, null); getHandle().playerConnection.sendPacket(packetReset); } @@ -1512,7 +1555,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { if (data != null && !particle.getDataType().isInstance(data)) { throw new IllegalArgumentException("data should be " + particle.getDataType() + " got " + data.getClass()); } - PacketPlayOutWorldParticles packetplayoutworldparticles = new PacketPlayOutWorldParticles(CraftParticle.toNMS(particle), true, (float) x, (float) y, (float) z, (float) offsetX, (float) offsetY, (float) offsetZ, (float) extra, count, CraftParticle.toData(particle, data)); + PacketPlayOutWorldParticles packetplayoutworldparticles = new PacketPlayOutWorldParticles(CraftParticle.toNMS(particle, data), true, (float) x, (float) y, (float) z, (float) offsetX, (float) offsetY, (float) offsetZ, (float) extra, count); getHandle().playerConnection.sendPacket(packetplayoutworldparticles); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftProjectile.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftProjectile.java index 6cf74ce875..335acc24d6 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftProjectile.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftProjectile.java @@ -19,12 +19,10 @@ public abstract class CraftProjectile extends AbstractProjectile implements Proj public void setShooter(ProjectileSource shooter) { if (shooter instanceof CraftLivingEntity) { getHandle().shooter = (EntityLiving) ((CraftLivingEntity) shooter).entity; - if (shooter instanceof CraftHumanEntity) { - getHandle().shooterName = ((CraftHumanEntity) shooter).getName(); - } + getHandle().shooterId = ((CraftLivingEntity) shooter).getUniqueId(); } else { getHandle().shooter = null; - getHandle().shooterName = null; + getHandle().shooterId = null; } getHandle().projectileSource = shooter; } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPufferFish.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPufferFish.java new file mode 100644 index 0000000000..2701de75ad --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPufferFish.java @@ -0,0 +1,38 @@ +package org.bukkit.craftbukkit.entity; + +import net.minecraft.server.EntityPufferFish; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.entity.PufferFish; +import org.bukkit.entity.EntityType; + +public class CraftPufferFish extends CraftFish implements PufferFish { + + public CraftPufferFish(CraftServer server, EntityPufferFish entity) { + super(server, entity); + } + + @Override + public EntityPufferFish getHandle() { + return (EntityPufferFish) super.getHandle(); + } + + @Override + public int getPuffState() { + return getHandle().getPuffState(); + } + + @Override + public void setPuffState(int state) { + getHandle().setPuffState(state); + } + + @Override + public String toString() { + return "CraftPufferFish"; + } + + @Override + public EntityType getType() { + return EntityType.PUFFERFISH; + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSalmon.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSalmon.java new file mode 100644 index 0000000000..4d91f57605 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSalmon.java @@ -0,0 +1,28 @@ +package org.bukkit.craftbukkit.entity; + +import net.minecraft.server.EntitySalmon; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.entity.Salmon; +import org.bukkit.entity.EntityType; + +public class CraftSalmon extends CraftFish implements Salmon { + + public CraftSalmon(CraftServer server, EntitySalmon entity) { + super(server, entity); + } + + @Override + public EntitySalmon getHandle() { + return (EntitySalmon) super.getHandle(); + } + + @Override + public String toString() { + return "CraftSalmon"; + } + + @Override + public EntityType getType() { + return EntityType.SALMON; + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTrident.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTrident.java new file mode 100644 index 0000000000..0518e6c683 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTrident.java @@ -0,0 +1,28 @@ +package org.bukkit.craftbukkit.entity; + +import net.minecraft.server.EntityThrownTrident; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Trident; + +public class CraftTrident extends CraftArrow implements Trident { + + public CraftTrident(CraftServer server, EntityThrownTrident entity) { + super(server, entity); + } + + @Override + public EntityThrownTrident getHandle() { + return (EntityThrownTrident) super.getHandle(); + } + + @Override + public String toString() { + return "CraftTrident"; + } + + @Override + public EntityType getType() { + return EntityType.TRIDENT; + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTropicalFish.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTropicalFish.java new file mode 100644 index 0000000000..42d1d4def8 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTropicalFish.java @@ -0,0 +1,111 @@ +package org.bukkit.craftbukkit.entity; + +import java.util.HashMap; +import java.util.Map; +import net.minecraft.server.EntityTropicalFish; +import org.bukkit.DyeColor; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.entity.TropicalFish; + +public class CraftTropicalFish extends CraftFish implements TropicalFish { + + public CraftTropicalFish(CraftServer server, EntityTropicalFish entity) { + super(server, entity); + } + + @Override + public EntityTropicalFish getHandle() { + return (EntityTropicalFish) entity; + } + + @Override + public String toString() { + return "CraftTropicalFish"; + } + + @Override + public DyeColor getPatternColor() { + return getPatternColor(getHandle().getVariant()); + } + + @Override + public void setPatternColor(DyeColor color) { + getHandle().setVariant(getData(color, getBodyColor(), getPattern())); + } + + @Override + public DyeColor getBodyColor() { + return getBodyColor(getHandle().getVariant()); + } + + @Override + public void setBodyColor(DyeColor color) { + getHandle().setVariant(getData(getPatternColor(), color, getPattern())); + } + + @Override + public Pattern getPattern() { + return getPattern(getHandle().getVariant()); + } + + @Override + public void setPattern(Pattern pattern) { + getHandle().setVariant(getData(getPatternColor(), getBodyColor(), pattern)); + } + + public static enum CraftPattern { + KOB(0, false), + SUNSTREAK(1, false), + SNOOPER(2, false), + DASHER(3, false), + BRINELY(4, false), + SPOTTY(5, false), + FLOPPER(0, true), + STRIPEY(1, true), + GLITTER(2, true), + BLOCKFISH(3, true), + BETTY(4, true), + CLAYFISH(5, true); + + private final int variant; + private final boolean large; + + // + private static final Map BY_DATA = new HashMap<>(); + + static { + for (CraftPattern type : values()) { + BY_DATA.put(type.getDataValue(), Pattern.values()[type.ordinal()]); + } + } + + public static Pattern fromData(int data) { + return BY_DATA.get(data); + } + + private CraftPattern(int variant, boolean large) { + this.variant = variant; + this.large = large; + } + + public int getDataValue() { + return variant << 8 | ((large) ? 1 : 0); + } + } + + public static int getData(DyeColor patternColor, DyeColor bodyColor, Pattern type) { + return patternColor.getWoolData() << 24 | bodyColor.getWoolData() << 16 | CraftPattern.values()[type.ordinal()].getDataValue(); + } + + public static DyeColor getPatternColor(int data) { + return DyeColor.getByWoolData((byte) ((data >> 24) & 0xFF)); + } + + public static DyeColor getBodyColor(int data) { + return DyeColor.getByWoolData((byte) ((data >> 16) & 0xFF)); + } + + public static Pattern getPattern(int data) { + return CraftPattern.fromData(data & 0xFFFF); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTurtle.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTurtle.java new file mode 100644 index 0000000000..123a2c75ca --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTurtle.java @@ -0,0 +1,28 @@ +package org.bukkit.craftbukkit.entity; + +import net.minecraft.server.EntityTurtle; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Turtle; + +public class CraftTurtle extends CraftAnimals implements Turtle { + + public CraftTurtle(CraftServer server, EntityTurtle entity) { + super(server, entity); + } + + @Override + public EntityTurtle getHandle() { + return (EntityTurtle) super.getHandle(); + } + + @Override + public String toString() { + return "CraftTurtle"; + } + + @Override + public EntityType getType() { + return EntityType.TURTLE; + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java index 503bd0661c..a6ee01ca62 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java @@ -51,7 +51,7 @@ public class CraftVillager extends CraftAgeable implements Villager, InventoryHo @Override public Career getCareer() { - return getCareer(getProfession(), getHandle().bK); + return getCareer(getProfession(), getHandle().careerId); } @Override @@ -62,15 +62,15 @@ public class CraftVillager extends CraftAgeable implements Villager, InventoryHo @Override public void setCareer(Career career, boolean resetTrades) { if (career == null) { - getHandle().bK = 0; // reset career + getHandle().careerId = 0; // reset career } else { Validate.isTrue(career.getProfession() == getProfession(), "Career assignment mismatch. Found (" + getProfession() + ") Required (" + career.getProfession() + ")"); - getHandle().bK = getCareerID(career); + getHandle().careerId = getCareerID(career); } if (resetTrades) { getHandle().trades = null; - getHandle().dx(); + getHandle().populateTrades(); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index c4bc628bc5..527af08c0a 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -361,21 +361,24 @@ public class CraftEventFactory { /** * BlockFadeEvent */ - public static BlockFadeEvent callBlockFadeEvent(Block block, net.minecraft.server.Block type) { - BlockState state = block.getState(); - state.setTypeId(net.minecraft.server.Block.getId(type)); + public static BlockFadeEvent callBlockFadeEvent(GeneratorAccess world, BlockPosition pos, IBlockData newBlock) { + CraftBlockState state = CraftBlockState.getBlockState(world, pos); + state.setData(newBlock); - BlockFadeEvent event = new BlockFadeEvent(block, state); + BlockFadeEvent event = new BlockFadeEvent(state.getBlock(), state); Bukkit.getPluginManager().callEvent(event); return event; } - public static boolean handleBlockSpreadEvent(Block block, Block source, net.minecraft.server.Block type, int data) { - BlockState state = block.getState(); - state.setTypeId(net.minecraft.server.Block.getId(type)); - state.setRawData((byte) data); + public static boolean handleBlockSpreadEvent(World world, BlockPosition source, BlockPosition target, IBlockData block) { + return handleBlockSpreadEvent(world, source, target, block, 2); + } - BlockSpreadEvent event = new BlockSpreadEvent(block, source, state); + public static boolean handleBlockSpreadEvent(World world, BlockPosition source, BlockPosition target, IBlockData block, int flag) { + CraftBlockState state = CraftBlockState.getBlockState(world, target, flag); + state.setData(block); + + BlockSpreadEvent event = new BlockSpreadEvent(world.getWorld().getBlockAt(target.getX(), target.getY(), target.getZ()), world.getWorld().getBlockAt(source.getX(), source.getY(), source.getZ()), state); Bukkit.getPluginManager().callEvent(event); if (!event.isCancelled()) { @@ -558,6 +561,8 @@ public class CraftEventFactory { cause = DamageCause.FLY_INTO_WALL; } else if (source == DamageSource.CRAMMING) { cause = DamageCause.CRAMMING; + } else if (source == DamageSource.DRYOUT) { + cause = DamageCause.DRYOUT; } else if (source == DamageSource.GENERIC) { cause = DamageCause.CUSTOM; } @@ -656,11 +661,14 @@ public class CraftEventFactory { return event; } - public static boolean handleBlockGrowEvent(World world, int x, int y, int z, net.minecraft.server.Block type, int data) { - Block block = world.getWorld().getBlockAt(x, y, z); + public static boolean handleBlockGrowEvent(World world, BlockPosition pos, IBlockData block) { + return handleBlockGrowEvent(world, pos, block, 3); + } + + public static boolean handleBlockGrowEvent(World world, BlockPosition pos, IBlockData newData, int flag) { + Block block = world.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()); CraftBlockState state = (CraftBlockState) block.getState(); - state.setTypeId(net.minecraft.server.Block.getId(type)); - state.setRawData((byte) data); + state.setData(newData); BlockGrowEvent event = new BlockGrowEvent(block, state); Bukkit.getPluginManager().callEvent(event); @@ -690,33 +698,17 @@ public class CraftEventFactory { return event; } - public static EntityChangeBlockEvent callEntityChangeBlockEvent(org.bukkit.entity.Entity entity, Block block, Material material) { - return callEntityChangeBlockEvent(entity, block, material, 0); + public static EntityChangeBlockEvent callEntityChangeBlockEvent(Entity entity, BlockPosition position, IBlockData newBlock) { + return callEntityChangeBlockEvent(entity, position, newBlock, false); } - public static EntityChangeBlockEvent callEntityChangeBlockEvent(Entity entity, Block block, Material material) { - return callEntityChangeBlockEvent(entity.getBukkitEntity(), block, material, 0); - } - - public static EntityChangeBlockEvent callEntityChangeBlockEvent(Entity entity, Block block, Material material, boolean cancelled) { - return callEntityChangeBlockEvent(entity.getBukkitEntity(), block, material, 0, cancelled); - } - - public static EntityChangeBlockEvent callEntityChangeBlockEvent(Entity entity, BlockPosition position, net.minecraft.server.Block type, int data) { + public static EntityChangeBlockEvent callEntityChangeBlockEvent(Entity entity, BlockPosition position, IBlockData newBlock, boolean cancelled) { Block block = entity.world.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ()); - Material material = CraftMagicNumbers.getMaterial(type); + Material material = CraftMagicNumbers.getMaterial(newBlock).getItemType(); - return callEntityChangeBlockEvent(entity.getBukkitEntity(), block, material, data); - } - - public static EntityChangeBlockEvent callEntityChangeBlockEvent(org.bukkit.entity.Entity entity, Block block, Material material, int data) { - return callEntityChangeBlockEvent(entity, block, material, data, false); - } - - public static EntityChangeBlockEvent callEntityChangeBlockEvent(org.bukkit.entity.Entity entity, Block block, Material material, int data, boolean cancelled) { - EntityChangeBlockEvent event = new EntityChangeBlockEvent(entity, block, material, (byte) data); + EntityChangeBlockEvent event = new EntityChangeBlockEvent(entity.getBukkitEntity(), block, material, (byte) 0); event.setCancelled(cancelled); - entity.getServer().getPluginManager().callEvent(event); + event.getEntity().getServer().getPluginManager().callEvent(event); return event; } @@ -773,8 +765,8 @@ public class CraftEventFactory { return container; } - public static ItemStack callPreCraftEvent(InventoryCrafting matrix, ItemStack result, InventoryView lastCraftView, boolean isRepair) { - CraftInventoryCrafting inventory = new CraftInventoryCrafting(matrix, matrix.resultInventory); + public static ItemStack callPreCraftEvent(IInventory matrix, IInventory resultInventory, ItemStack result, InventoryView lastCraftView, boolean isRepair) { + CraftInventoryCrafting inventory = new CraftInventoryCrafting(matrix, resultInventory); inventory.setResult(CraftItemStack.asCraftMirror(result)); PrepareItemCraftEvent event = new PrepareItemCraftEvent(inventory, lastCraftView, isRepair); @@ -811,14 +803,14 @@ public class CraftEventFactory { return event; } - public static BlockRedstoneEvent callRedstoneChange(World world, int x, int y, int z, int oldCurrent, int newCurrent) { - BlockRedstoneEvent event = new BlockRedstoneEvent(world.getWorld().getBlockAt(x, y, z), oldCurrent, newCurrent); + public static BlockRedstoneEvent callRedstoneChange(World world, BlockPosition pos, int oldCurrent, int newCurrent) { + BlockRedstoneEvent event = new BlockRedstoneEvent(world.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()), oldCurrent, newCurrent); world.getServer().getPluginManager().callEvent(event); return event; } - public static NotePlayEvent callNotePlayEvent(World world, int x, int y, int z, byte instrument, byte note) { - NotePlayEvent event = new NotePlayEvent(world.getWorld().getBlockAt(x, y, z), org.bukkit.Instrument.getByType(instrument), new org.bukkit.Note(note)); + public static NotePlayEvent callNotePlayEvent(World world, BlockPosition pos, BlockPropertyInstrument instrument, int note) { + NotePlayEvent event = new NotePlayEvent(world.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()), org.bukkit.Instrument.getByType((byte) instrument.ordinal()), new org.bukkit.Note(note)); world.getServer().getPluginManager().callEvent(event); return event; } @@ -829,13 +821,12 @@ public class CraftEventFactory { Bukkit.getPluginManager().callEvent(event); } - public static BlockIgniteEvent callBlockIgniteEvent(World world, int x, int y, int z, int igniterX, int igniterY, int igniterZ) { + public static BlockIgniteEvent callBlockIgniteEvent(World world, BlockPosition block, BlockPosition source) { org.bukkit.World bukkitWorld = world.getWorld(); - Block igniter = bukkitWorld.getBlockAt(igniterX, igniterY, igniterZ); + Block igniter = bukkitWorld.getBlockAt(source.getX(), source.getY(), source.getZ()); IgniteCause cause; switch (igniter.getType()) { case LAVA: - case STATIONARY_LAVA: cause = IgniteCause.LAVA; break; case DISPENSER: @@ -846,12 +837,12 @@ public class CraftEventFactory { cause = IgniteCause.SPREAD; } - BlockIgniteEvent event = new BlockIgniteEvent(bukkitWorld.getBlockAt(x, y, z), cause, igniter); + BlockIgniteEvent event = new BlockIgniteEvent(bukkitWorld.getBlockAt(block.getX(), block.getY(), block.getZ()), cause, igniter); world.getServer().getPluginManager().callEvent(event); return event; } - public static BlockIgniteEvent callBlockIgniteEvent(World world, int x, int y, int z, Entity igniter) { + public static BlockIgniteEvent callBlockIgniteEvent(World world, BlockPosition pos, Entity igniter) { org.bukkit.World bukkitWorld = world.getWorld(); org.bukkit.entity.Entity bukkitIgniter = igniter.getBukkitEntity(); IgniteCause cause; @@ -870,7 +861,7 @@ public class CraftEventFactory { cause = IgniteCause.FLINT_AND_STEEL; } - BlockIgniteEvent event = new BlockIgniteEvent(bukkitWorld.getBlockAt(x, y, z), cause, bukkitIgniter); + BlockIgniteEvent event = new BlockIgniteEvent(bukkitWorld.getBlockAt(pos.getX(), pos.getY(), pos.getZ()), cause, bukkitIgniter); world.getServer().getPluginManager().callEvent(event); return event; } @@ -884,8 +875,8 @@ public class CraftEventFactory { return event; } - public static BlockIgniteEvent callBlockIgniteEvent(World world, int x, int y, int z, IgniteCause cause, Entity igniter) { - BlockIgniteEvent event = new BlockIgniteEvent(world.getWorld().getBlockAt(x, y, z), cause, igniter.getBukkitEntity()); + public static BlockIgniteEvent callBlockIgniteEvent(World world, BlockPosition pos, IgniteCause cause, Entity igniter) { + BlockIgniteEvent event = new BlockIgniteEvent(world.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()), cause, igniter.getBukkitEntity()); world.getServer().getPluginManager().callEvent(event); return event; } @@ -932,7 +923,7 @@ public class CraftEventFactory { c.setChatModifier(modi); if (c instanceof ChatMessage) { ChatMessage cm = (ChatMessage) c; - Object[] oo = cm.j(); + Object[] oo = cm.i(); for (int i = 0; i < oo.length; i++) { Object o = oo[i]; if (o instanceof IChatBaseComponent) { @@ -961,7 +952,7 @@ public class CraftEventFactory { return event; } - public static Cancellable handleStatisticsIncrease(EntityHuman entityHuman, net.minecraft.server.Statistic statistic, int current, int incrementation) { + public static Cancellable handleStatisticsIncrease(EntityHuman entityHuman, net.minecraft.server.Statistic statistic, int current, int incrementation) { Player player = ((EntityPlayer) entityHuman).getBukkitEntity(); Event event; if (true) { @@ -974,12 +965,13 @@ public class CraftEventFactory { case FALL_ONE_CM: case BOAT_ONE_CM: case CLIMB_ONE_CM: - case DIVE_ONE_CM: + case WALK_ON_WATER_ONE_CM: + case WALK_UNDER_WATER_ONE_CM: case FLY_ONE_CM: case HORSE_ONE_CM: case MINECART_ONE_CM: case PIG_ONE_CM: - case PLAY_ONE_TICK: + case PLAY_ONE_MINUTE: case SWIM_ONE_CM: case WALK_ONE_CM: case SPRINT_ONE_CM: @@ -993,7 +985,7 @@ public class CraftEventFactory { if (stat.getType() == Type.UNTYPED) { event = new PlayerStatisticIncrementEvent(player, stat, current, current + incrementation); } else if (stat.getType() == Type.ENTITY) { - EntityType entityType = CraftStatistic.getEntityTypeFromStatistic(statistic); + EntityType entityType = CraftStatistic.getEntityTypeFromStatistic((net.minecraft.server.Statistic>) statistic); event = new PlayerStatisticIncrementEvent(player, stat, current, current + incrementation, entityType); } else { Material material = CraftStatistic.getMaterialFromStatistic(statistic); @@ -1045,17 +1037,28 @@ public class CraftEventFactory { return event; } - public static BlockPhysicsEvent callBlockPhysicsEvent(World world, BlockPosition blockposition) { - org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); - BlockPhysicsEvent event = new BlockPhysicsEvent(block, block.getTypeId()); - world.getServer().getPluginManager().callEvent(event); + 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); return event; } + public static boolean handleBlockFormEvent(World world, BlockPosition pos, IBlockData block) { + return handleBlockFormEvent(world, pos, block, 3); + } + public static boolean handleBlockFormEvent(World world, BlockPosition pos, IBlockData block, @Nullable Entity entity) { - BlockState blockState = world.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()).getState(); - blockState.setType(CraftMagicNumbers.getMaterial(block.getBlock())); - blockState.setRawData((byte) block.getBlock().toLegacyData(block)); + return handleBlockFormEvent(world, pos, block, 3, entity); + } + + public static boolean handleBlockFormEvent(World world, BlockPosition pos, IBlockData block, int flag) { + return handleBlockFormEvent(world, pos, block, flag, null); + } + + public static boolean handleBlockFormEvent(World world, BlockPosition pos, IBlockData block, int flag, @Nullable Entity entity) { + CraftBlockState blockState = CraftBlockState.getBlockState(world, pos, flag); + blockState.setData(block); BlockFormEvent event = (entity == null) ? new BlockFormEvent(blockState.getBlock(), blockState) : new EntityBlockFormEvent(entity.getBukkitEntity(), blockState.getBlock(), blockState); world.getServer().getPluginManager().callEvent(event); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/generator/CraftChunkData.java b/paper-server/src/main/java/org/bukkit/craftbukkit/generator/CraftChunkData.java index 01264a7ed4..a0fda9298d 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/generator/CraftChunkData.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/generator/CraftChunkData.java @@ -1,12 +1,13 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ package org.bukkit.craftbukkit.generator; -import java.util.Arrays; +import net.minecraft.server.Blocks; +import net.minecraft.server.ChunkSection; +import net.minecraft.server.IBlockData; import org.bukkit.Material; import org.bukkit.World; +import org.bukkit.block.data.BlockData; +import org.bukkit.craftbukkit.block.data.CraftBlockData; +import org.bukkit.craftbukkit.util.CraftMagicNumbers; import org.bukkit.generator.ChunkGenerator; import org.bukkit.material.MaterialData; @@ -15,7 +16,7 @@ import org.bukkit.material.MaterialData; */ public final class CraftChunkData implements ChunkGenerator.ChunkData { private final int maxHeight; - private final char[][] sections; + private final ChunkSection[] sections; public CraftChunkData(World world) { this(world.getMaxHeight()); @@ -26,8 +27,7 @@ public final class CraftChunkData implements ChunkGenerator.ChunkData { throw new IllegalArgumentException("World height exceeded max chunk height"); } this.maxHeight = maxHeight; - // Minecraft hardcodes this to 16 chunk sections. - sections = new char[16][]; + sections = new ChunkSection[maxHeight >> 4]; } @Override @@ -37,41 +37,50 @@ public final class CraftChunkData implements ChunkGenerator.ChunkData { @Override public void setBlock(int x, int y, int z, Material material) { - setBlock(x, y, z, material.getId()); + setBlock(x, y, z, CraftMagicNumbers.getBlock(material, (byte) 0)); } @Override public void setBlock(int x, int y, int z, MaterialData material) { - setBlock(x, y, z, material.getItemTypeId(), material.getData()); + setBlock(x, y, z, CraftMagicNumbers.getBlock(material)); + } + + @Override + public void setBlock(int x, int y, int z, BlockData blockData) { + setBlock(x, y, z, ((CraftBlockData) blockData).getState()); } @Override public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, Material material) { - setRegion(xMin, yMin, zMin, xMax, yMax, zMax, material.getId()); + setRegion(xMin, yMin, zMin, xMax, yMax, zMax, CraftMagicNumbers.getBlock(material, (byte) 0)); } @Override public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, MaterialData material) { - setRegion(xMin, yMin, zMin, xMax, yMax, zMax, material.getItemTypeId(), material.getData()); + setRegion(xMin, yMin, zMin, xMax, yMax, zMax, CraftMagicNumbers.getBlock(material)); + } + + @Override + public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, BlockData blockData) { + setRegion(xMin, yMin, zMin, xMax, yMax, zMax, ((CraftBlockData) blockData).getState()); } @Override public Material getType(int x, int y, int z) { - return Material.getMaterial(getTypeId(x, y, z)); + return getTypeAndData(x, y, z).getItemType(); } @Override public MaterialData getTypeAndData(int x, int y, int z) { - return getType(x, y, z).getNewData(getData(x, y, z)); + return CraftMagicNumbers.getMaterial(getTypeId(x, y, z)); } @Override - public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, int blockId) { - setRegion(xMin, yMin, zMin, xMax, yMax, zMax, blockId, (byte) 0); + public BlockData getBlockData(int x, int y, int z) { + return CraftBlockData.fromData(getTypeId(x, y, z)); } - @Override - public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, int blockId, int data) { + public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, IBlockData type) { // Clamp to sane values. if (xMin > 0xf || yMin >= maxHeight || zMin > 0xf) { return; @@ -97,103 +106,51 @@ public final class CraftChunkData implements ChunkGenerator.ChunkData { if (xMin >= xMax || yMin >= yMax || zMin >= zMax) { return; } - char typeChar = (char) ((blockId << 4) | data); - if (xMin == 0 && xMax == 0x10) { - if (zMin == 0 && zMax == 0x10) { - for (int y = yMin & 0xf0; y < yMax; y += 0x10) { - char[] section = getChunkSection(y, true); - if (y <= yMin) { - if (y + 0x10 > yMax) { - // First and last chunk section - Arrays.fill(section, (yMin & 0xf) << 8, (yMax & 0xf) << 8, typeChar); - } else { - // First chunk section - Arrays.fill(section, (yMin & 0xf) << 8, 0x1000, typeChar); - } - } else if (y + 0x10 > yMax) { - // Last chunk section - Arrays.fill(section, 0, (yMax & 0xf) << 8, typeChar); - } else { - // Full chunk section - Arrays.fill(section, 0, 0x1000, typeChar); - } - } - } else { - for (int y = yMin; y < yMax; y++) { - char[] section = getChunkSection(y, true); - int offsetBase = (y & 0xf) << 8; - int min = offsetBase | (zMin << 4); - // Need to add zMax as it can be 16, which overlaps the y coordinate bits - int max = offsetBase + (zMax << 4); - Arrays.fill(section, min, max, typeChar); - } - } - } else { - for (int y = yMin; y < yMax; y++) { - char[] section = getChunkSection(y, true); - int offsetBase = (y & 0xf) << 8; + for (int y = yMin; y < yMax; y++) { + ChunkSection section = getChunkSection(y, true); + int offsetBase = y & 0xf; + for (int x = xMin; x < xMax; x++) { for (int z = zMin; z < zMax; z++) { - int offset = offsetBase | (z << 4); - // Need to add xMax as it can be 16, which overlaps the z coordinate bits - Arrays.fill(section, offset | xMin, offset + xMax, typeChar); + section.setType(x, offsetBase, z, type); } } } } - @Override - public void setBlock(int x, int y, int z, int blockId) { - setBlock(x, y, z, blockId, (byte) 0); - } - - @Override - public void setBlock(int x, int y, int z, int blockId, byte data) { - setBlock(x, y, z, (char) (blockId << 4 | data)); - } - - @Override - public int getTypeId(int x, int y, int z) { + public IBlockData getTypeId(int x, int y, int z) { if (x != (x & 0xf) || y < 0 || y >= maxHeight || z != (z & 0xf)) { - return 0; + return Blocks.AIR.getBlockData(); } - char[] section = getChunkSection(y, false); + ChunkSection section = getChunkSection(y, false); if (section == null) { - return 0; + return Blocks.AIR.getBlockData(); } else { - return section[(y & 0xf) << 8 | z << 4 | x] >> 4; + return section.getType(x, y & 0xf, z); } } @Override public byte getData(int x, int y, int z) { - if (x != (x & 0xf) || y < 0 || y >= maxHeight || z != (z & 0xf)) { - return (byte) 0; - } - char[] section = getChunkSection(y, false); - if (section == null) { - return (byte) 0; - } else { - return (byte) (section[(y & 0xf) << 8 | z << 4 | x] & 0xf); - } + return CraftMagicNumbers.toLegacyData(getTypeId(x, y, z)); } - private void setBlock(int x, int y, int z, char type) { + private void setBlock(int x, int y, int z, IBlockData type) { if (x != (x & 0xf) || y < 0 || y >= maxHeight || z != (z & 0xf)) { return; } - char[] section = getChunkSection(y, true); - section[(y & 0xf) << 8 | z << 4 | x] = type; + ChunkSection section = getChunkSection(y, true); + section.setType(x, y & 0xf, z, type); } - private char[] getChunkSection(int y, boolean create) { - char[] section = sections[y >> 4]; + private ChunkSection getChunkSection(int y, boolean create) { + ChunkSection section = sections[y >> 4]; if (create && section == null) { - sections[y >> 4] = section = new char[0x1000]; + sections[y >> 4] = section = new ChunkSection(y, create); } return section; } - char[][] getRawChunkData() { + ChunkSection[] getRawChunkData() { return sections; } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java b/paper-server/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java index 9942f0c750..4280be5ae7 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java @@ -1,6 +1,11 @@ package org.bukkit.craftbukkit.generator; +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.*; @@ -10,11 +15,14 @@ import org.bukkit.generator.BlockPopulator; import org.bukkit.generator.ChunkGenerator; import org.bukkit.craftbukkit.block.CraftBlock; -public class CustomChunkGenerator extends InternalChunkGenerator { +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 static class CustomBiomeGrid implements BiomeGrid { BiomeBase[] biome; @@ -26,181 +34,52 @@ public class CustomChunkGenerator extends InternalChunkGenerator { @Override public void setBiome(int x, int z, Biome bio) { - biome[(z << 4) | x] = CraftBlock.biomeToBiomeBase(bio); + biome[(z << 4) | x] = CraftBlock.biomeToBiomeBase(bio); } } public CustomChunkGenerator(World world, long seed, ChunkGenerator generator) { this.world = (WorldServer) world; this.generator = generator; + this.seed = seed; this.random = new Random(seed); + this.chunkManager = world.worldProvider.getChunkGenerator().getWorldChunkManager(); } @Override - public Chunk getOrCreateChunk(int x, int z) { + public void createChunk(IChunkAccess ichunkaccess) { + int x = ichunkaccess.getPos().x; + int z = ichunkaccess.getPos().z; random.setSeed((long) x * 341873128712L + (long) z * 132897987541L); - Chunk chunk; - // Get default biome data for chunk CustomBiomeGrid biomegrid = new CustomBiomeGrid(); - biomegrid.biome = new BiomeBase[256]; - world.getWorldChunkManager().getBiomeBlock(biomegrid.biome, x << 4, z << 4, 16, 16); + biomegrid.biome = chunkManager.getBiomeBlock(x << 4, z << 4, 16, 16); - // Try ChunkData method (1.8+) CraftChunkData data = (CraftChunkData) generator.generateChunkData(this.world.getWorld(), random, x, z, biomegrid); - if (data != null) { - char[][] sections = data.getRawChunkData(); - chunk = new Chunk(this.world, x, z); - - ChunkSection[] csect = chunk.getSections(); - int scnt = Math.min(csect.length, sections.length); - - // Loop through returned sections - for (int sec = 0; sec < scnt; sec++) { - if(sections[sec] == null) { - continue; - } - char[] section = sections[sec]; - char emptyTest = 0; - for (int i = 0; i < 4096; i++) { - // Filter invalid block id & data values. - if (Block.REGISTRY_ID.fromId(section[i]) == null) { - section[i] = 0; - } - emptyTest |= section[i]; - } - // Build chunk section - if (emptyTest != 0) { - csect[sec] = new ChunkSection(sec << 4, true, section); - } - } - } - else { - // Try extended block method (1.2+) - short[][] xbtypes = generator.generateExtBlockSections(this.world.getWorld(), this.random, x, z, biomegrid); - if (xbtypes != null) { - chunk = new Chunk(this.world, x, z); - - ChunkSection[] csect = chunk.getSections(); - int scnt = Math.min(csect.length, xbtypes.length); - - // Loop through returned sections - for (int sec = 0; sec < scnt; sec++) { - if (xbtypes[sec] == null) { - continue; - } - char[] secBlkID = new char[4096]; // Allocate blk ID bytes - short[] bdata = xbtypes[sec]; - for (int i = 0; i < bdata.length; i++) { - Block b = Block.getById(bdata[i]); - secBlkID[i] = (char) Block.REGISTRY_ID.getId(b.getBlockData()); - } - // Build chunk section - csect[sec] = new ChunkSection(sec << 4, true, secBlkID); - } - } - else { // Else check for byte-per-block section data - byte[][] btypes = generator.generateBlockSections(this.world.getWorld(), this.random, x, z, biomegrid); - - if (btypes != null) { - chunk = new Chunk(this.world, x, z); - - ChunkSection[] csect = chunk.getSections(); - int scnt = Math.min(csect.length, btypes.length); - - for (int sec = 0; sec < scnt; sec++) { - if (btypes[sec] == null) { - continue; - } - - char[] secBlkID = new char[4096]; // Allocate block ID bytes - for (int i = 0; i < secBlkID.length; i++) { - Block b = Block.getById(btypes[sec][i] & 0xFF); - secBlkID[i] = (char) Block.REGISTRY_ID.getId(b.getBlockData()); - } - csect[sec] = new ChunkSection(sec << 4, true, secBlkID); - } - } - else { // Else, fall back to pre 1.2 method - @SuppressWarnings("deprecation") - byte[] types = generator.generate(this.world.getWorld(), this.random, x, z); - int ydim = types.length / 256; - int scnt = ydim / 16; - - chunk = new Chunk(this.world, x, z); // Create empty chunk - - ChunkSection[] csect = chunk.getSections(); - - scnt = Math.min(scnt, csect.length); - // Loop through sections - for (int sec = 0; sec < scnt; sec++) { - char[] csbytes = null; // Add sections when needed - - for (int cy = 0; cy < 16; cy++) { - int cyoff = cy | (sec << 4); - - for (int cx = 0; cx < 16; cx++) { - int cxyoff = (cx * ydim * 16) + cyoff; - - for (int cz = 0; cz < 16; cz++) { - byte blk = types[cxyoff + (cz * ydim)]; - - if (blk != 0) { // If non-empty - if (csbytes == null) { // If no section yet, get one - csbytes = new char[16*16*16]; - } - - Block b = Block.getById(blk & 0xFF); - csbytes[(cy << 8) | (cz << 4) | cx] = (char) Block.REGISTRY_ID.getId(b.getBlockData()); - } - } - } - } - // If section built, finish prepping its state - if (csbytes != null) { - ChunkSection cs = csect[sec] = new ChunkSection(sec << 4, true, csbytes); - cs.recalcBlockCounts(); - } - } - } + ChunkSection[] sections = data.getRawChunkData(); + + ChunkSection[] csect = ichunkaccess.getSections(); + int scnt = Math.min(csect.length, sections.length); + + // Loop through returned sections + for (int sec = 0; sec < scnt; sec++) { + if (sections[sec] == null) { + continue; } + ChunkSection section = sections[sec]; + + csect[sec] = section; } + // Set biome grid - byte[] biomeIndex = chunk.getBiomeIndex(); - for (int i = 0; i < biomeIndex.length; i++) { - biomeIndex[i] = (byte) (BiomeBase.REGISTRY_ID.a(biomegrid.biome[i]) & 0xFF); // PAIL : rename - } - // Initialize lighting - chunk.initLighting(); - - return chunk; + ichunkaccess.a(biomegrid.biome); } @Override - public boolean a(Chunk chunk, int i, int i1) { - return false; - } - - @SuppressWarnings("deprecation") - @Override - public byte[] generate(org.bukkit.World world, Random random, int x, int z) { - return generator.generate(world, random, x, z); - } - - @Override - public byte[][] generateBlockSections(org.bukkit.World world, Random random, int x, int z, BiomeGrid biomes) { - return generator.generateBlockSections(world, random, x, z, biomes); - } - - @Override - public short[][] generateExtBlockSections(org.bukkit.World world, Random random, int x, int z, BiomeGrid biomes) { - return generator.generateExtBlockSections(world, random, x, z, biomes); - } - - public Chunk getChunkAt(int x, int z) { - return getOrCreateChunk(x, z); + public ChunkData generateChunkData(org.bukkit.World world, Random random, int x, int z, BiomeGrid biome) { + return generator.generateChunkData(world, random, x, z, biome); } @Override @@ -221,20 +100,79 @@ public class CustomChunkGenerator extends InternalChunkGenerator { } @Override - public boolean a(World world, String type, BlockPosition position) { - return "Stronghold".equals(type) && this.strongholdGen != null ? this.strongholdGen.b(position) : false; + public void addFeatures(RegionLimitedWorldAccess regionlimitedworldaccess, WorldGenStage.Features worldgenstage_features) { } @Override - public BlockPosition findNearestMapFeature(World world, String type, BlockPosition position, boolean flag) { - return "Stronghold".equals(type) && this.strongholdGen != null ? this.strongholdGen.getNearestGeneratedFeature(world, position, flag) : null; + public void addDecorations(RegionLimitedWorldAccess regionlimitedworldaccess) { } @Override - public void recreateStructures(int i, int j) {} + public void addMobs(RegionLimitedWorldAccess regionlimitedworldaccess) { + } @Override - public void recreateStructures(Chunk chunk, int i, int j) { - strongholdGen.a(this.world, i, j, (ChunkSnapshot) null); + public BlockPosition findNearestMapFeature(World world, String type, BlockPosition position, int i) { + return "Stronghold".equals(type) && this.strongholdGen != null ? this.strongholdGen.getNearestGeneratedFeature(world, this, position, i) : null; + } + + @Override + public GeneratorSettingsDefault getSettings() { + return settings; + } + + @Override + public int a(World world, boolean flag, boolean flag1) { + return 0; + } + + @Override + public boolean canSpawnStructure(BiomeBase biomebase, StructureGenerator structuregenerator) { + return biomebase.a(structuregenerator); + } + + @Override + public WorldGenFeatureConfiguration getFeatureConfiguration(BiomeBase biomebase, StructureGenerator 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; + } + + @Override + public int getSpawnHeight() { + return world.getSeaLevel() + 1; + } + + @Override + public int e() { + return world.getHeight(); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/generator/InternalChunkGenerator.java b/paper-server/src/main/java/org/bukkit/craftbukkit/generator/InternalChunkGenerator.java index d2e71b8711..b0710cd825 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/generator/InternalChunkGenerator.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/generator/InternalChunkGenerator.java @@ -1,8 +1,8 @@ package org.bukkit.craftbukkit.generator; -import net.minecraft.server.IChunkProvider; +import net.minecraft.server.GeneratorSettings; import org.bukkit.generator.ChunkGenerator; // 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 ChunkGenerator implements net.minecraft.server.ChunkGenerator { } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/generator/NormalChunkGenerator.java b/paper-server/src/main/java/org/bukkit/craftbukkit/generator/NormalChunkGenerator.java index be07fb8e79..4356d2bff9 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/generator/NormalChunkGenerator.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/generator/NormalChunkGenerator.java @@ -1,29 +1,30 @@ 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.craftbukkit.CraftWorld; import org.bukkit.generator.BlockPopulator; -public class NormalChunkGenerator extends InternalChunkGenerator { - private final ChunkGenerator generator; +public class NormalChunkGenerator extends InternalChunkGenerator { + private final ChunkGenerator generator; public NormalChunkGenerator(World world, long seed) { generator = world.worldProvider.getChunkGenerator(); } @Override - public byte[] generate(org.bukkit.World world, Random random, int x, int z) { + 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 ((CraftWorld) world).getHandle().worldProvider.canSpawn(x, z); + return true; // PAIL } @Override @@ -31,38 +32,83 @@ public class NormalChunkGenerator extends InternalChunkGenerator { return new ArrayList(); } - @Override - public Chunk getOrCreateChunk(int i, int i1) { - return generator.getOrCreateChunk(i, i1); - } - - @Override - public void recreateStructures(int i, int i1) { - generator.recreateStructures(i, i1); - } - - @Override - public boolean a(Chunk chunk, int i, int i1) { - return generator.a(chunk, i, i1); - } - @Override public List getMobsFor(EnumCreatureType enumCreatureType, BlockPosition blockPosition) { return generator.getMobsFor(enumCreatureType, blockPosition); } @Override - public BlockPosition findNearestMapFeature(World world, String s, BlockPosition blockPosition, boolean flag) { - return generator.findNearestMapFeature(world, s, blockPosition, flag); + public BlockPosition findNearestMapFeature(World world, String s, BlockPosition blockPosition, int i) { + return generator.findNearestMapFeature(world, s, blockPosition, i); } @Override - public void recreateStructures(Chunk chunk, int i, int i1) { - generator.recreateStructures(chunk, i, i1); + public void createChunk(IChunkAccess ichunkaccess) { + generator.createChunk(ichunkaccess); } @Override - public boolean a(World world, String string, BlockPosition bp) { - return generator.a(world, string, bp); + 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 e() { + return generator.e(); // PAIL: Gen depth } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftFurnaceRecipe.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftFurnaceRecipe.java index ef3b8045c5..b513f8d2f7 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftFurnaceRecipe.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftFurnaceRecipe.java @@ -1,26 +1,31 @@ package org.bukkit.craftbukkit.inventory; -import net.minecraft.server.RecipesFurnace; +import java.util.stream.Stream; +import net.minecraft.server.MinecraftServer; +import net.minecraft.server.RecipeItemStack; +import org.bukkit.NamespacedKey; +import org.bukkit.craftbukkit.util.CraftNamespacedKey; import org.bukkit.inventory.FurnaceRecipe; import org.bukkit.inventory.ItemStack; public class CraftFurnaceRecipe extends FurnaceRecipe implements CraftRecipe { - public CraftFurnaceRecipe(ItemStack result, ItemStack source) { - super(result, source.getType(), source.getDurability()); + public CraftFurnaceRecipe(NamespacedKey key, ItemStack result, ItemStack source, float experience, int cookingTime) { + super(key, result, source.getType(), source.getDurability(), experience, cookingTime); } public static CraftFurnaceRecipe fromBukkitRecipe(FurnaceRecipe recipe) { if (recipe instanceof CraftFurnaceRecipe) { return (CraftFurnaceRecipe) recipe; } - return new CraftFurnaceRecipe(recipe.getResult(), recipe.getInput()); + return new CraftFurnaceRecipe(recipe.getKey(), recipe.getResult(), recipe.getInput(), recipe.getExperience(), recipe.getCookingTime()); } @Override public void addToCraftingManager() { ItemStack result = this.getResult(); - ItemStack input = this.getInput(); - RecipesFurnace.getInstance().registerRecipe(CraftItemStack.asNMSCopy(input), CraftItemStack.asNMSCopy(result), getExperience()); + RecipeItemStack input = new RecipeItemStack(Stream.of(new RecipeItemStack.StackProvider(CraftItemStack.asNMSCopy(this.getInput())))); + + MinecraftServer.getServer().getCraftingManager().a(new net.minecraft.server.FurnaceRecipe(CraftNamespacedKey.toMinecraft(this.getKey()), "", input, CraftItemStack.asNMSCopy(result), getExperience(), getCookingTime())); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java index 4866d1aee6..94afb704fc 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java @@ -25,6 +25,7 @@ import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.ItemStack; import org.bukkit.Material; +import org.bukkit.craftbukkit.util.CraftChatMessage; public class CraftInventory implements Inventory { protected final IInventory inventory; @@ -42,7 +43,7 @@ public class CraftInventory implements Inventory { } public String getName() { - return getInventory().getName(); + return CraftChatMessage.fromComponent(getInventory().getDisplayName()); } public ItemStack getItem(int index) { @@ -96,20 +97,16 @@ public class CraftInventory implements Inventory { getInventory().setItem(index, CraftItemStack.asNMSCopy(item)); } - public boolean contains(int materialId) { + public boolean contains(Material material) { + Validate.notNull(material, "Material cannot be null"); for (ItemStack item : getStorageContents()) { - if (item != null && item.getTypeId() == materialId) { + if (item != null && item.getType() == material) { return true; } } return false; } - public boolean contains(Material material) { - Validate.notNull(material, "Material cannot be null"); - return contains(material.getId()); - } - public boolean contains(ItemStack item) { if (item == null) { return false; @@ -122,12 +119,13 @@ public class CraftInventory implements Inventory { return false; } - public boolean contains(int materialId, int amount) { + public boolean contains(Material material, int amount) { + Validate.notNull(material, "Material cannot be null"); if (amount <= 0) { return true; } for (ItemStack item : getStorageContents()) { - if (item != null && item.getTypeId() == materialId) { + if (item != null && item.getType()== material) { if ((amount -= item.getAmount()) <= 0) { return true; } @@ -136,11 +134,6 @@ public class CraftInventory implements Inventory { return false; } - public boolean contains(Material material, int amount) { - Validate.notNull(material, "Material cannot be null"); - return contains(material.getId(), amount); - } - public boolean contains(ItemStack item, int amount) { if (item == null) { return false; @@ -171,24 +164,20 @@ public class CraftInventory implements Inventory { return false; } - public HashMap all(int materialId) { + public HashMap all(Material material) { + Validate.notNull(material, "Material cannot be null"); HashMap slots = new HashMap(); ItemStack[] inventory = getStorageContents(); for (int i = 0; i < inventory.length; i++) { ItemStack item = inventory[i]; - if (item != null && item.getTypeId() == materialId) { + if (item != null && item.getType()== material) { slots.put(i, item); } } return slots; } - public HashMap all(Material material) { - Validate.notNull(material, "Material cannot be null"); - return all(material.getId()); - } - public HashMap all(ItemStack item) { HashMap slots = new HashMap(); if (item != null) { @@ -202,22 +191,18 @@ public class CraftInventory implements Inventory { return slots; } - public int first(int materialId) { - ItemStack[] inventory = getStorageContents(); + public int first(Material material) { + Validate.notNull(material, "Material cannot be null"); + ItemStack[] inventory = getStorageContents(); for (int i = 0; i < inventory.length; i++) { ItemStack item = inventory[i]; - if (item != null && item.getTypeId() == materialId) { + if (item != null && item.getType()== material) { return i; } } return -1; } - public int first(Material material) { - Validate.notNull(material, "Material cannot be null"); - return first(material.getId()); - } - public int first(ItemStack item) { return first(item, true); } @@ -247,22 +232,18 @@ public class CraftInventory implements Inventory { return -1; } - public int firstPartial(int materialId) { + public int firstPartial(Material material) { + Validate.notNull(material, "Material cannot be null"); ItemStack[] inventory = getStorageContents(); for (int i = 0; i < inventory.length; i++) { ItemStack item = inventory[i]; - if (item != null && item.getTypeId() == materialId && item.getAmount() < item.getMaxStackSize()) { + if (item != null && item.getType()== material && item.getAmount() < item.getMaxStackSize()) { return i; } } return -1; } - public int firstPartial(Material material) { - Validate.notNull(material, "Material cannot be null"); - return firstPartial(material.getId()); - } - private int firstPartial(ItemStack item) { ItemStack[] inventory = getStorageContents(); ItemStack filteredItem = CraftItemStack.asCraftCopy(item); @@ -390,20 +371,16 @@ public class CraftInventory implements Inventory { return getInventory().getMaxStackSize(); } - public void remove(int materialId) { + public void remove(Material material) { + Validate.notNull(material, "Material cannot be null"); ItemStack[] items = getStorageContents(); for (int i = 0; i < items.length; i++) { - if (items[i] != null && items[i].getTypeId() == materialId) { + if (items[i] != null && items[i].getType()== material) { clear(i); } } } - public void remove(Material material) { - Validate.notNull(material, "Material cannot be null"); - remove(material.getId()); - } - public void remove(ItemStack item) { ItemStack[] items = getStorageContents(); for (int i = 0; i < items.length; i++) { @@ -439,7 +416,7 @@ public class CraftInventory implements Inventory { } public String getTitle() { - return inventory.getName(); + return getName(); } public InventoryType getType() { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCrafting.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCrafting.java index 0f0dd1997f..3a375e77da 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCrafting.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCrafting.java @@ -5,7 +5,6 @@ import java.util.List; import net.minecraft.server.IRecipe; import net.minecraft.server.IInventory; -import net.minecraft.server.InventoryCrafting; import org.bukkit.inventory.CraftingInventory; import org.bukkit.inventory.ItemStack; @@ -14,7 +13,7 @@ import org.bukkit.inventory.Recipe; public class CraftInventoryCrafting extends CraftInventory implements CraftingInventory { private final IInventory resultInventory; - public CraftInventoryCrafting(InventoryCrafting inventory, IInventory resultInventory) { + public CraftInventoryCrafting(IInventory inventory, IInventory resultInventory) { super(inventory); this.resultInventory = resultInventory; } @@ -116,7 +115,7 @@ public class CraftInventoryCrafting extends CraftInventory implements CraftingIn } public Recipe getRecipe() { - IRecipe recipe = ((InventoryCrafting)getInventory()).currentRecipe; + IRecipe recipe = getInventory().getCurrentRecipe(); return recipe == null ? null : recipe.toBukkitRecipe(); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java index a1a0ab7dc1..2212e09cb5 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java @@ -17,6 +17,7 @@ import net.minecraft.server.EntityHuman; import net.minecraft.server.IInventory; import net.minecraft.server.ItemStack; import net.minecraft.server.NonNullList; +import org.bukkit.craftbukkit.util.CraftChatMessage; public class CraftInventoryCustom extends CraftInventory { public CraftInventoryCustom(InventoryHolder owner, InventoryType type) { @@ -39,7 +40,7 @@ public class CraftInventoryCustom extends CraftInventory { private final NonNullList items; private int maxStack = MAX_STACK; private final List viewers; - private final String title; + private final IChatBaseComponent title; private InventoryType type; private final InventoryHolder owner; @@ -60,7 +61,7 @@ public class CraftInventoryCustom extends CraftInventory { public MinecraftInventory(InventoryHolder owner, int size, String title) { Validate.notNull(title, "Title cannot be null"); this.items = NonNullList.a(size, ItemStack.a); - this.title = title; + this.title = CraftChatMessage.fromStringOrNull(title); this.viewers = new ArrayList(); this.owner = owner; this.type = InventoryType.CHEST; @@ -182,7 +183,12 @@ public class CraftInventoryCustom extends CraftInventory { } @Override - public String getName() { + public IChatBaseComponent getDisplayName() { + return title; + } + + @Override + public IChatBaseComponent getCustomName() { return title; } @@ -193,7 +199,7 @@ public class CraftInventoryCustom extends CraftInventory { @Override public IChatBaseComponent getScoreboardDisplayName() { - return new ChatComponentText(title); + return title; } @Override @@ -202,7 +208,7 @@ public class CraftInventoryCustom extends CraftInventory { } @Override - public boolean x_() { + public boolean P_() { Iterator iterator = this.items.iterator(); ItemStack itemstack; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryDoubleChest.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryDoubleChest.java index f028b339a9..799f8ea5d2 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryDoubleChest.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryDoubleChest.java @@ -1,5 +1,6 @@ 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; @@ -14,7 +15,7 @@ public class CraftInventoryDoubleChest extends CraftInventory implements DoubleC private final CraftInventory right; public CraftInventoryDoubleChest(CraftInventory left, CraftInventory right) { - super(new InventoryLargeChest("Large chest", (ITileInventory) left.getInventory(), (ITileInventory) right.getInventory())); + super(new InventoryLargeChest(new ChatMessage("container.chestDouble"), (ITileInventory) left.getInventory(), (ITileInventory) right.getInventory())); this.left = left; this.right = right; } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryPlayer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryPlayer.java index 67c54899de..6cbe069562 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryPlayer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryPlayer.java @@ -184,23 +184,6 @@ public class CraftInventoryPlayer extends CraftInventory implements org.bukkit.i setSlots(items, getInventory().items.size() + getInventory().armor.size(), getInventory().extraSlots.size()); } - public int clear(int id, int data) { - int count = 0; - ItemStack[] items = getContents(); - - for (int i = 0; i < items.length; i++) { - ItemStack item = items[i]; - if (item == null) continue; - if (id > -1 && item.getTypeId() != id) continue; - if (data > -1 && item.getData().getData() != data) continue; - - count += item.getAmount(); - setItem(i, null); - } - - return count; - } - @Override public HumanEntity getHolder() { return (HumanEntity) inventory.getOwner(); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java index 49ebad22ed..e305d663aa 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java @@ -6,6 +6,7 @@ import org.apache.commons.lang.Validate; import org.bukkit.Color; import org.bukkit.Material; import org.bukkit.configuration.serialization.ConfigurationSerialization; +import org.bukkit.craftbukkit.util.CraftLegacy; import org.bukkit.inventory.ItemFactory; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; @@ -47,6 +48,7 @@ public final class CraftItemFactory implements ItemFactory { } public boolean isApplicable(ItemMeta meta, Material type) { + type = CraftLegacy.fromLegacy(type); // This may be called from legacy item stacks, try to get the right material if (type == null || meta == null) { return false; } @@ -63,14 +65,27 @@ public final class CraftItemFactory implements ItemFactory { } private ItemMeta getItemMeta(Material material, CraftMetaItem meta) { + material = CraftLegacy.fromLegacy(material); // This may be called from legacy item stacks, try to get the right material switch (material) { case AIR: return null; case WRITTEN_BOOK: return meta instanceof CraftMetaBookSigned ? meta : new CraftMetaBookSigned(meta); - case BOOK_AND_QUILL: + case WRITABLE_BOOK: return meta != null && meta.getClass().equals(CraftMetaBook.class) ? meta : new CraftMetaBook(meta); - case SKULL_ITEM: + case CREEPER_HEAD: + case CREEPER_WALL_HEAD: + case DRAGON_HEAD: + case DRAGON_WALL_HEAD: + case PISTON_HEAD: + case PLAYER_HEAD: + case PLAYER_WALL_HEAD: + case SKELETON_SKULL: + case SKELETON_WALL_SKULL: + case WITHER_SKELETON_SKULL: + case WITHER_SKELETON_WALL_SKULL: + case ZOMBIE_HEAD: + case ZOMBIE_WALL_HEAD: return meta instanceof CraftMetaSkull ? meta : new CraftMetaSkull(meta); case LEATHER_HELMET: case LEATHER_CHESTPLATE: @@ -82,17 +97,90 @@ public final class CraftItemFactory implements ItemFactory { case LINGERING_POTION: case TIPPED_ARROW: return meta instanceof CraftMetaPotion ? meta : new CraftMetaPotion(meta); - case MAP: + case FILLED_MAP: return meta instanceof CraftMetaMap ? meta : new CraftMetaMap(meta); - case FIREWORK: + case FIREWORK_ROCKET: return meta instanceof CraftMetaFirework ? meta : new CraftMetaFirework(meta); - case FIREWORK_CHARGE: + case FIREWORK_STAR: return meta instanceof CraftMetaCharge ? meta : new CraftMetaCharge(meta); case ENCHANTED_BOOK: return meta instanceof CraftMetaEnchantedBook ? meta : new CraftMetaEnchantedBook(meta); - case BANNER: + case BLACK_BANNER: + case BLACK_WALL_BANNER: + case BLUE_BANNER: + case BLUE_WALL_BANNER: + case BROWN_BANNER: + case BROWN_WALL_BANNER: + case CYAN_BANNER: + case CYAN_WALL_BANNER: + case GRAY_BANNER: + case GRAY_WALL_BANNER: + case GREEN_BANNER: + case GREEN_WALL_BANNER: + case LIGHT_BLUE_BANNER: + case LIGHT_BLUE_WALL_BANNER: + case LIGHT_GRAY_BANNER: + case LIGHT_GRAY_WALL_BANNER: + case LIME_BANNER: + case LIME_WALL_BANNER: + case MAGENTA_BANNER: + case MAGENTA_WALL_BANNER: + case ORANGE_BANNER: + case ORANGE_WALL_BANNER: + case PINK_BANNER: + case PINK_WALL_BANNER: + case PURPLE_BANNER: + case PURPLE_WALL_BANNER: + case RED_BANNER: + case RED_WALL_BANNER: + case WHITE_BANNER: + case WHITE_WALL_BANNER: + case YELLOW_BANNER: + case YELLOW_WALL_BANNER: return meta instanceof CraftMetaBanner ? meta : new CraftMetaBanner(meta); - case MONSTER_EGG: + case BAT_SPAWN_EGG: + case BLAZE_SPAWN_EGG: + case CAVE_SPIDER_SPAWN_EGG: + case CHICKEN_SPAWN_EGG: + case COW_SPAWN_EGG: + case CREEPER_SPAWN_EGG: + case DONKEY_SPAWN_EGG: + case ELDER_GUARDIAN_SPAWN_EGG: + case ENDERMAN_SPAWN_EGG: + case ENDERMITE_SPAWN_EGG: + case EVOKER_SPAWN_EGG: + case GHAST_SPAWN_EGG: + case GUARDIAN_SPAWN_EGG: + case HORSE_SPAWN_EGG: + case HUSK_SPAWN_EGG: + case LLAMA_SPAWN_EGG: + case MAGMA_CUBE_SPAWN_EGG: + case MOOSHROOM_SPAWN_EGG: + case MULE_SPAWN_EGG: + case OCELOT_SPAWN_EGG: + case PARROT_SPAWN_EGG: + case PIG_SPAWN_EGG: + case POLAR_BEAR_SPAWN_EGG: + case RABBIT_SPAWN_EGG: + case SHEEP_SPAWN_EGG: + case SHULKER_SPAWN_EGG: + case SILVERFISH_SPAWN_EGG: + case SKELETON_HORSE_SPAWN_EGG: + case SKELETON_SPAWN_EGG: + case SLIME_SPAWN_EGG: + case SPIDER_SPAWN_EGG: + case SQUID_SPAWN_EGG: + case STRAY_SPAWN_EGG: + case VEX_SPAWN_EGG: + case VILLAGER_SPAWN_EGG: + case VINDICATOR_SPAWN_EGG: + case WITCH_SPAWN_EGG: + case WITHER_SKELETON_SPAWN_EGG: + case WOLF_SPAWN_EGG: + case ZOMBIE_HORSE_SPAWN_EGG: + case ZOMBIE_PIGMAN_SPAWN_EGG: + case ZOMBIE_SPAWN_EGG: + case ZOMBIE_VILLAGER_SPAWN_EGG: return meta instanceof CraftMetaSpawnEgg ? meta : new CraftMetaSpawnEgg(meta); case KNOWLEDGE_BOOK: return meta instanceof CraftMetaKnowledgeBook ? meta : new CraftMetaKnowledgeBook(meta); @@ -103,19 +191,17 @@ public final class CraftItemFactory implements ItemFactory { case DISPENSER: case DROPPER: case SIGN: - case MOB_SPAWNER: + case SPAWNER: case NOTE_BLOCK: - case BREWING_STAND_ITEM: - case ENCHANTMENT_TABLE: - case COMMAND: - case COMMAND_REPEATING: - case COMMAND_CHAIN: + case BREWING_STAND: + case ENCHANTING_TABLE: + case COMMAND_BLOCK: + case REPEATING_COMMAND_BLOCK: + case CHAIN_COMMAND_BLOCK: case BEACON: case DAYLIGHT_DETECTOR: - case DAYLIGHT_DETECTOR_INVERTED: case HOPPER: - case REDSTONE_COMPARATOR: - case FLOWER_POT_ITEM: + case COMPARATOR: case SHIELD: case STRUCTURE_BLOCK: case WHITE_SHULKER_BOX: @@ -126,7 +212,7 @@ public final class CraftItemFactory implements ItemFactory { case LIME_SHULKER_BOX: case PINK_SHULKER_BOX: case GRAY_SHULKER_BOX: - case SILVER_SHULKER_BOX: + case LIGHT_GRAY_SHULKER_BOX: case CYAN_SHULKER_BOX: case PURPLE_SHULKER_BOX: case BLUE_SHULKER_BOX: @@ -136,6 +222,8 @@ public final class CraftItemFactory implements ItemFactory { case BLACK_SHULKER_BOX: case ENDER_CHEST: return new CraftMetaBlockState(meta, material); + case TROPICAL_FISH_BUCKET: + return meta instanceof CraftMetaTropicalFishBucket ? meta : new CraftMetaTropicalFishBucket(meta); default: return new CraftMetaItem(meta); } @@ -194,4 +282,9 @@ public final class CraftItemFactory implements ItemFactory { public Color getDefaultLeatherColor() { return DEFAULT_LEATHER_COLOR; } + + @Override + public Material updateMaterial(ItemMeta meta, Material material) throws IllegalArgumentException { + return ((CraftMetaItem) meta).updateMaterial(material); + } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java index fb1dc542dd..4c4f04557e 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java @@ -18,9 +18,11 @@ import org.bukkit.craftbukkit.util.CraftMagicNumbers; import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.material.MaterialData; import com.google.common.collect.ImmutableMap; import org.bukkit.craftbukkit.enchantments.CraftEnchantment; +import org.bukkit.craftbukkit.util.CraftNamespacedKey; @DelegateDeserialization(ItemStack.class) public final class CraftItemStack extends ItemStack { @@ -30,17 +32,17 @@ public final class CraftItemStack extends ItemStack { CraftItemStack stack = (CraftItemStack) original; return stack.handle == null ? net.minecraft.server.ItemStack.a : stack.handle.cloneItemStack(); } - if (original == null || original.getTypeId() <= 0) { + if (original == null || original.getType() == Material.AIR) { return net.minecraft.server.ItemStack.a; } - Item item = CraftMagicNumbers.getItem(original.getType()); + Item item = CraftMagicNumbers.getItem(original.getType(), original.getDurability()); if (item == null) { return net.minecraft.server.ItemStack.a; } - net.minecraft.server.ItemStack stack = new net.minecraft.server.ItemStack(item, original.getAmount(), original.getDurability(), false); + net.minecraft.server.ItemStack stack = new net.minecraft.server.ItemStack(item, original.getAmount()); if (original.hasItemMeta()) { setItemMeta(stack, original.getItemMeta()); } else { @@ -63,7 +65,7 @@ public final class CraftItemStack extends ItemStack { if (original.isEmpty()) { return new ItemStack(Material.AIR); } - ItemStack stack = new ItemStack(CraftMagicNumbers.getMaterial(original.getItem()), original.getCount(), (short) original.getData()); + ItemStack stack = new ItemStack(CraftMagicNumbers.getMaterial(original.getItem()), original.getCount()); if (hasItemMeta(original)) { stack.setItemMeta(getItemMeta(original)); } @@ -100,7 +102,7 @@ public final class CraftItemStack extends ItemStack { } private CraftItemStack(ItemStack item) { - this(item.getTypeId(), item.getAmount(), item.getDurability(), item.hasItemMeta() ? item.getItemMeta() : null); + this(item.getType(), item.getAmount(), item.getDurability(), item.hasItemMeta() ? item.getItemMeta() : null); } private CraftItemStack(Material type, int amount, short durability, ItemMeta itemMeta) { @@ -110,26 +112,26 @@ public final class CraftItemStack extends ItemStack { setItemMeta(itemMeta); } - private CraftItemStack(int typeId, int amount, short durability, ItemMeta itemMeta) { - this(Material.getMaterial(typeId), amount, durability, itemMeta); - + @Override + public MaterialData getData() { + return handle != null ? CraftMagicNumbers.getMaterialData(handle.getItem()) : super.getData(); } @Override - public int getTypeId() { - return handle != null ? CraftMagicNumbers.getId(handle.getItem()) : 0; + public Material getType() { + return handle != null ? CraftMagicNumbers.getMaterial(handle.getItem()) : Material.AIR; } @Override - public void setTypeId(int type) { - if (getTypeId() == type) { + public void setType(Material type) { + if (getType() == type) { return; - } else if (type == 0) { + } else if (type == Material.AIR) { handle = null; } else if (CraftMagicNumbers.getItem(type) == null) { // :( handle = null; } else if (handle == null) { - handle = new net.minecraft.server.ItemStack(CraftMagicNumbers.getItem(type), 1, 0); + handle = new net.minecraft.server.ItemStack(CraftMagicNumbers.getItem(type), 1); } else { handle.setItem(CraftMagicNumbers.getItem(type)); if (hasItemMeta()) { @@ -161,14 +163,14 @@ public final class CraftItemStack extends ItemStack { public void setDurability(final short durability) { // Ignore damage if item is null if (handle != null) { - handle.setData(durability); + handle.setDamage(durability); } } @Override public short getDurability() { if (handle != null) { - return (short) handle.getData(); + return (short) handle.getDamage(); } else { return -1; } @@ -195,14 +197,14 @@ public final class CraftItemStack extends ItemStack { for (int i = 0; i < size; i++) { NBTTagCompound tag = (NBTTagCompound) list.get(i); - short id = tag.getShort(ENCHANTMENTS_ID.NBT); - if (id == ench.getId()) { + String id = tag.getString(ENCHANTMENTS_ID.NBT); + if (id.equals(ench.getKey().toString())) { tag.setShort(ENCHANTMENTS_LVL.NBT, (short) level); return; } } NBTTagCompound tag = new NBTTagCompound(); - tag.setShort(ENCHANTMENTS_ID.NBT, (short) ench.getId()); + tag.setString(ENCHANTMENTS_ID.NBT, ench.getKey().toString()); tag.setShort(ENCHANTMENTS_LVL.NBT, (short) level); list.add(tag); } @@ -247,8 +249,8 @@ public final class CraftItemStack extends ItemStack { for (int i = 0; i < size; i++) { NBTTagCompound enchantment = (NBTTagCompound) list.get(i); - int id = 0xffff & enchantment.getShort(ENCHANTMENTS_ID.NBT); - if (id == ench.getId()) { + String id = enchantment.getString(ENCHANTMENTS_ID.NBT); + if (id.equals(ench.getKey().toString())) { index = i; level = 0xffff & enchantment.getShort(ENCHANTMENTS_LVL.NBT); break; @@ -293,10 +295,10 @@ public final class CraftItemStack extends ItemStack { ImmutableMap.Builder result = ImmutableMap.builder(); for (int i = 0; i < list.size(); i++) { - int id = 0xffff & ((NBTTagCompound) list.get(i)).getShort(ENCHANTMENTS_ID.NBT); + String id = ((NBTTagCompound) list.get(i)).getString(ENCHANTMENTS_ID.NBT); int level = 0xffff & ((NBTTagCompound) list.get(i)).getShort(ENCHANTMENTS_LVL.NBT); - result.put(Enchantment.getById(id), level); + result.put(Enchantment.getByKey(CraftNamespacedKey.fromString(id)), level); } return result.build(); @@ -327,9 +329,21 @@ public final class CraftItemStack extends ItemStack { switch (getType(item)) { case WRITTEN_BOOK: return new CraftMetaBookSigned(item.getTag()); - case BOOK_AND_QUILL: + case WRITABLE_BOOK: return new CraftMetaBook(item.getTag()); - case SKULL_ITEM: + case CREEPER_HEAD: + case CREEPER_WALL_HEAD: + case DRAGON_HEAD: + case DRAGON_WALL_HEAD: + case PISTON_HEAD: + case PLAYER_HEAD: + case PLAYER_WALL_HEAD: + case SKELETON_SKULL: + case SKELETON_WALL_SKULL: + case WITHER_SKELETON_SKULL: + case WITHER_SKELETON_WALL_SKULL: + case ZOMBIE_HEAD: + case ZOMBIE_WALL_HEAD: return new CraftMetaSkull(item.getTag()); case LEATHER_HELMET: case LEATHER_CHESTPLATE: @@ -341,17 +355,90 @@ public final class CraftItemStack extends ItemStack { case LINGERING_POTION: case TIPPED_ARROW: return new CraftMetaPotion(item.getTag()); - case MAP: + case FILLED_MAP: return new CraftMetaMap(item.getTag()); - case FIREWORK: + case FIREWORK_ROCKET: return new CraftMetaFirework(item.getTag()); - case FIREWORK_CHARGE: + case FIREWORK_STAR: return new CraftMetaCharge(item.getTag()); case ENCHANTED_BOOK: return new CraftMetaEnchantedBook(item.getTag()); - case BANNER: + case BLACK_BANNER: + case BLACK_WALL_BANNER: + case BLUE_BANNER: + case BLUE_WALL_BANNER: + case BROWN_BANNER: + case BROWN_WALL_BANNER: + case CYAN_BANNER: + case CYAN_WALL_BANNER: + case GRAY_BANNER: + case GRAY_WALL_BANNER: + case GREEN_BANNER: + case GREEN_WALL_BANNER: + case LIGHT_BLUE_BANNER: + case LIGHT_BLUE_WALL_BANNER: + case LIGHT_GRAY_BANNER: + case LIGHT_GRAY_WALL_BANNER: + case LIME_BANNER: + case LIME_WALL_BANNER: + case MAGENTA_BANNER: + case MAGENTA_WALL_BANNER: + case ORANGE_BANNER: + case ORANGE_WALL_BANNER: + case PINK_BANNER: + case PINK_WALL_BANNER: + case PURPLE_BANNER: + case PURPLE_WALL_BANNER: + case RED_BANNER: + case RED_WALL_BANNER: + case WHITE_BANNER: + case WHITE_WALL_BANNER: + case YELLOW_BANNER: + case YELLOW_WALL_BANNER: return new CraftMetaBanner(item.getTag()); - case MONSTER_EGG: + case BAT_SPAWN_EGG: + case BLAZE_SPAWN_EGG: + case CAVE_SPIDER_SPAWN_EGG: + case CHICKEN_SPAWN_EGG: + case COW_SPAWN_EGG: + case CREEPER_SPAWN_EGG: + case DONKEY_SPAWN_EGG: + case ELDER_GUARDIAN_SPAWN_EGG: + case ENDERMAN_SPAWN_EGG: + case ENDERMITE_SPAWN_EGG: + case EVOKER_SPAWN_EGG: + case GHAST_SPAWN_EGG: + case GUARDIAN_SPAWN_EGG: + case HORSE_SPAWN_EGG: + case HUSK_SPAWN_EGG: + case LLAMA_SPAWN_EGG: + case MAGMA_CUBE_SPAWN_EGG: + case MOOSHROOM_SPAWN_EGG: + case MULE_SPAWN_EGG: + case OCELOT_SPAWN_EGG: + case PARROT_SPAWN_EGG: + case PIG_SPAWN_EGG: + case POLAR_BEAR_SPAWN_EGG: + case RABBIT_SPAWN_EGG: + case SHEEP_SPAWN_EGG: + case SHULKER_SPAWN_EGG: + case SILVERFISH_SPAWN_EGG: + case SKELETON_HORSE_SPAWN_EGG: + case SKELETON_SPAWN_EGG: + case SLIME_SPAWN_EGG: + case SPIDER_SPAWN_EGG: + case SQUID_SPAWN_EGG: + case STRAY_SPAWN_EGG: + case VEX_SPAWN_EGG: + case VILLAGER_SPAWN_EGG: + case VINDICATOR_SPAWN_EGG: + case WITCH_SPAWN_EGG: + case WITHER_SKELETON_SPAWN_EGG: + case WOLF_SPAWN_EGG: + case ZOMBIE_HORSE_SPAWN_EGG: + case ZOMBIE_PIGMAN_SPAWN_EGG: + case ZOMBIE_SPAWN_EGG: + case ZOMBIE_VILLAGER_SPAWN_EGG: return new CraftMetaSpawnEgg(item.getTag()); case KNOWLEDGE_BOOK: return new CraftMetaKnowledgeBook(item.getTag()); @@ -362,19 +449,17 @@ public final class CraftItemStack extends ItemStack { case DISPENSER: case DROPPER: case SIGN: - case MOB_SPAWNER: + case SPAWNER: case NOTE_BLOCK: - case BREWING_STAND_ITEM: - case ENCHANTMENT_TABLE: - case COMMAND: - case COMMAND_REPEATING: - case COMMAND_CHAIN: + case BREWING_STAND: + case ENCHANTING_TABLE: + case COMMAND_BLOCK: + case REPEATING_COMMAND_BLOCK: + case CHAIN_COMMAND_BLOCK: case BEACON: case DAYLIGHT_DETECTOR: - case DAYLIGHT_DETECTOR_INVERTED: case HOPPER: - case REDSTONE_COMPARATOR: - case FLOWER_POT_ITEM: + case COMPARATOR: case SHIELD: case STRUCTURE_BLOCK: case WHITE_SHULKER_BOX: @@ -385,7 +470,7 @@ public final class CraftItemStack extends ItemStack { case LIME_SHULKER_BOX: case PINK_SHULKER_BOX: case GRAY_SHULKER_BOX: - case SILVER_SHULKER_BOX: + case LIGHT_GRAY_SHULKER_BOX: case CYAN_SHULKER_BOX: case PURPLE_SHULKER_BOX: case BLUE_SHULKER_BOX: @@ -395,14 +480,15 @@ public final class CraftItemStack extends ItemStack { case BLACK_SHULKER_BOX: case ENDER_CHEST: return new CraftMetaBlockState(item.getTag(), CraftMagicNumbers.getMaterial(item.getItem())); + case TROPICAL_FISH_BUCKET: + return new CraftMetaTropicalFishBucket(item.getTag()); default: return new CraftMetaItem(item.getTag()); } } static Material getType(net.minecraft.server.ItemStack item) { - Material material = Material.getMaterial(item == null ? 0 : CraftMagicNumbers.getId(item.getItem())); - return material == null ? Material.AIR : material; + return item == null ? Material.AIR : CraftMagicNumbers.getMaterial(item.getItem()); } @Override @@ -425,6 +511,12 @@ public final class CraftItemStack extends ItemStack { itemMeta = CraftItemFactory.instance().asMetaFor(itemMeta, getType(item)); if (itemMeta == null) return true; + Item oldItem = item.getItem(); + Item newItem = CraftMagicNumbers.getItem(CraftItemFactory.instance().updateMaterial(itemMeta, CraftMagicNumbers.getMaterial(oldItem))); + if (oldItem != newItem) { + item.setItem(newItem); + } + NBTTagCompound tag = new NBTTagCompound(); item.setTag(tag); @@ -453,7 +545,7 @@ public final class CraftItemStack extends ItemStack { if (handle == null || that.handle == null) { return false; } - if (!(that.getTypeId() == getTypeId() && getDurability() == that.getDurability())) { + if (!(that.getType() == getType() && getDurability() == that.getDurability())) { return false; } return hasItemMeta() ? that.hasItemMeta() && handle.getTag().equals(that.handle.getTag()) : !that.hasItemMeta(); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java index 527e7ba969..bc898d6960 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java @@ -62,12 +62,12 @@ public class CraftMerchantCustom extends CraftMerchant { } @Override - public World u_() { + public World getWorld() { return null; } @Override - public BlockPosition v_() { + public BlockPosition getPosition() { return null; } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBanner.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBanner.java index 7b35678944..4d1cc88a75 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBanner.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBanner.java @@ -52,7 +52,7 @@ public class CraftMetaBanner extends CraftMetaItem implements BannerMeta { if (entityTag.hasKey(PATTERNS.NBT)) { NBTTagList patterns = entityTag.getList(PATTERNS.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND); for (int i = 0; i < Math.min(patterns.size(), 20); i++) { - NBTTagCompound p = patterns.get(i); + NBTTagCompound p = patterns.getCompound(i); this.patterns.add(new Pattern(DyeColor.getByDyeData((byte) p.getInt(COLOR.NBT)), PatternType.getByIdentifier(p.getString(PATTERN.NBT)))); } } @@ -198,7 +198,43 @@ public class CraftMetaBanner extends CraftMetaItem implements BannerMeta { @Override boolean applicableTo(Material type) { - return type == Material.BANNER; + switch (type) { + case BLACK_BANNER: + case BLACK_WALL_BANNER: + case BLUE_BANNER: + case BLUE_WALL_BANNER: + case BROWN_BANNER: + case BROWN_WALL_BANNER: + case CYAN_BANNER: + case CYAN_WALL_BANNER: + case GRAY_BANNER: + case GRAY_WALL_BANNER: + case GREEN_BANNER: + case GREEN_WALL_BANNER: + case LIGHT_BLUE_BANNER: + case LIGHT_BLUE_WALL_BANNER: + case LIGHT_GRAY_BANNER: + case LIGHT_GRAY_WALL_BANNER: + case LIME_BANNER: + case LIME_WALL_BANNER: + case MAGENTA_BANNER: + case MAGENTA_WALL_BANNER: + case ORANGE_BANNER: + case ORANGE_WALL_BANNER: + case PINK_BANNER: + case PINK_WALL_BANNER: + case PURPLE_BANNER: + case PURPLE_WALL_BANNER: + case RED_BANNER: + case RED_WALL_BANNER: + case WHITE_BANNER: + case WHITE_WALL_BANNER: + case YELLOW_BANNER: + case YELLOW_WALL_BANNER: + return true; + default: + return false; + } } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java index 3bd9ee47b1..2e44d13304 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java @@ -18,12 +18,11 @@ import net.minecraft.server.TileEntityDropper; import net.minecraft.server.TileEntityEnchantTable; import net.minecraft.server.TileEntityEndGateway; import net.minecraft.server.TileEntityEnderChest; -import net.minecraft.server.TileEntityFlowerPot; import net.minecraft.server.TileEntityFurnace; import net.minecraft.server.TileEntityHopper; +import net.minecraft.server.TileEntityJukeBox; import net.minecraft.server.TileEntityLightDetector; import net.minecraft.server.TileEntityMobSpawner; -import net.minecraft.server.TileEntityNote; import net.minecraft.server.TileEntityShulkerBox; import net.minecraft.server.TileEntitySign; import net.minecraft.server.TileEntitySkull; @@ -46,11 +45,9 @@ import org.bukkit.craftbukkit.block.CraftDropper; import org.bukkit.craftbukkit.block.CraftEnchantingTable; import org.bukkit.craftbukkit.block.CraftEndGateway; import org.bukkit.craftbukkit.block.CraftEnderChest; -import org.bukkit.craftbukkit.block.CraftFlowerPot; import org.bukkit.craftbukkit.block.CraftFurnace; import org.bukkit.craftbukkit.block.CraftHopper; import org.bukkit.craftbukkit.block.CraftJukebox; -import org.bukkit.craftbukkit.block.CraftNoteBlock; import org.bukkit.craftbukkit.block.CraftShulkerBox; import org.bukkit.craftbukkit.block.CraftSign; import org.bukkit.craftbukkit.block.CraftSkull; @@ -176,19 +173,17 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta case DISPENSER: case DROPPER: case SIGN: - case MOB_SPAWNER: + case SPAWNER: case NOTE_BLOCK: - case BREWING_STAND_ITEM: - case ENCHANTMENT_TABLE: - case COMMAND: - case COMMAND_REPEATING: - case COMMAND_CHAIN: + case BREWING_STAND: + case ENCHANTING_TABLE: + case COMMAND_BLOCK: + case REPEATING_COMMAND_BLOCK: + case CHAIN_COMMAND_BLOCK: case BEACON: case DAYLIGHT_DETECTOR: - case DAYLIGHT_DETECTOR_INVERTED: case HOPPER: - case REDSTONE_COMPARATOR: - case FLOWER_POT_ITEM: + case COMPARATOR: case SHIELD: case STRUCTURE_BLOCK: case WHITE_SHULKER_BOX: @@ -199,7 +194,7 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta case LIME_SHULKER_BOX: case PINK_SHULKER_BOX: case GRAY_SHULKER_BOX: - case SILVER_SHULKER_BOX: + case LIGHT_GRAY_SHULKER_BOX: case CYAN_SHULKER_BOX: case PURPLE_SHULKER_BOX: case BLUE_SHULKER_BOX: @@ -217,7 +212,7 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta public CraftMetaBlockState clone() { CraftMetaBlockState meta = (CraftMetaBlockState) super.clone(); if (blockEntityTag != null) { - meta.blockEntityTag = blockEntityTag.g(); + meta.blockEntityTag = blockEntityTag.clone(); } return meta; } @@ -242,7 +237,7 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta case LIME_SHULKER_BOX: case PINK_SHULKER_BOX: case GRAY_SHULKER_BOX: - case SILVER_SHULKER_BOX: + case LIGHT_GRAY_SHULKER_BOX: case CYAN_SHULKER_BOX: case PURPLE_SHULKER_BOX: case BLUE_SHULKER_BOX: @@ -254,11 +249,10 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta break; } } - TileEntity te = (blockEntityTag == null) ? null : TileEntity.create(null, blockEntityTag); + TileEntity te = (blockEntityTag == null) ? null : TileEntity.create(blockEntityTag); switch (material) { case SIGN: - case SIGN_POST: case WALL_SIGN: if (te == null) { te = new TileEntitySign(); @@ -270,7 +264,6 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta te = new TileEntityChest(); } return new CraftChest(material, (TileEntityChest) te); - case BURNING_FURNACE: case FURNACE: if (te == null) { te = new TileEntityFurnace(); @@ -296,34 +289,41 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta te = new TileEntityHopper(); } return new CraftHopper(material, (TileEntityHopper) te); - case MOB_SPAWNER: + case SPAWNER: if (te == null) { te = new TileEntityMobSpawner(); } return new CraftCreatureSpawner(material, (TileEntityMobSpawner) te); - case NOTE_BLOCK: - if (te == null) { - te = new TileEntityNote(); - } - return new CraftNoteBlock(material, (TileEntityNote) te); case JUKEBOX: if (te == null) { - te = new BlockJukeBox.TileEntityRecordPlayer(); + te = new TileEntityJukeBox(); } - return new CraftJukebox(material, (BlockJukeBox.TileEntityRecordPlayer) te); - case BREWING_STAND_ITEM: + return new CraftJukebox(material, (TileEntityJukeBox) te); + case BREWING_STAND: if (te == null) { te = new TileEntityBrewingStand(); } return new CraftBrewingStand(material, (TileEntityBrewingStand) te); - case SKULL: + case CREEPER_HEAD: + case CREEPER_WALL_HEAD: + case DRAGON_HEAD: + case DRAGON_WALL_HEAD: + case PISTON_HEAD: + case PLAYER_HEAD: + case PLAYER_WALL_HEAD: + case SKELETON_SKULL: + case SKELETON_WALL_SKULL: + case WITHER_SKELETON_SKULL: + case WITHER_SKELETON_WALL_SKULL: + case ZOMBIE_HEAD: + case ZOMBIE_WALL_HEAD: if (te == null) { te = new TileEntitySkull(); } return new CraftSkull(material, (TileEntitySkull) te); - case COMMAND: - case COMMAND_REPEATING: - case COMMAND_CHAIN: + case COMMAND_BLOCK: + case REPEATING_COMMAND_BLOCK: + case CHAIN_COMMAND_BLOCK: if (te == null) { te = new TileEntityCommand(); } @@ -334,18 +334,42 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta } return new CraftBeacon(material, (TileEntityBeacon) te); case SHIELD: - case BANNER: - case WALL_BANNER: - case STANDING_BANNER: + case BLACK_BANNER: + case BLACK_WALL_BANNER: + case BLUE_BANNER: + case BLUE_WALL_BANNER: + case BROWN_BANNER: + case BROWN_WALL_BANNER: + case CYAN_BANNER: + case CYAN_WALL_BANNER: + case GRAY_BANNER: + case GRAY_WALL_BANNER: + case GREEN_BANNER: + case GREEN_WALL_BANNER: + case LIGHT_BLUE_BANNER: + case LIGHT_BLUE_WALL_BANNER: + case LIGHT_GRAY_BANNER: + case LIGHT_GRAY_WALL_BANNER: + case LIME_BANNER: + case LIME_WALL_BANNER: + case MAGENTA_BANNER: + case MAGENTA_WALL_BANNER: + case ORANGE_BANNER: + case ORANGE_WALL_BANNER: + case PINK_BANNER: + case PINK_WALL_BANNER: + case PURPLE_BANNER: + case PURPLE_WALL_BANNER: + case RED_BANNER: + case RED_WALL_BANNER: + case WHITE_BANNER: + case WHITE_WALL_BANNER: + case YELLOW_BANNER: + case YELLOW_WALL_BANNER: if (te == null) { te = new TileEntityBanner(); } return new CraftBanner(material, (TileEntityBanner) te); - case FLOWER_POT_ITEM: - if (te == null) { - te = new TileEntityFlowerPot(); - } - return new CraftFlowerPot(material, (TileEntityFlowerPot) te); case STRUCTURE_BLOCK: if (te == null) { te = new TileEntityStructure(); @@ -359,7 +383,7 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta case LIME_SHULKER_BOX: case PINK_SHULKER_BOX: case GRAY_SHULKER_BOX: - case SILVER_SHULKER_BOX: + case LIGHT_GRAY_SHULKER_BOX: case CYAN_SHULKER_BOX: case PURPLE_SHULKER_BOX: case BLUE_SHULKER_BOX: @@ -371,7 +395,7 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta te = new TileEntityShulkerBox(); } return new CraftShulkerBox(material, (TileEntityShulkerBox) te); - case ENCHANTMENT_TABLE: + case ENCHANTING_TABLE: if (te == null) { te = new TileEntityEnchantTable(); } @@ -382,17 +406,15 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta } return new CraftEnderChest(material, (TileEntityEnderChest) te); case DAYLIGHT_DETECTOR: - case DAYLIGHT_DETECTOR_INVERTED: if (te == null){ te = new TileEntityLightDetector(); } return new CraftDaylightDetector(material, (TileEntityLightDetector) te); - case REDSTONE_COMPARATOR: + case COMPARATOR: if (te == null){ te = new TileEntityComparator(); } return new CraftComparator(material, (TileEntityComparator) te); - case PISTON_BASE: default: throw new IllegalStateException("Missing blockState for " + material); } @@ -405,7 +427,6 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta boolean valid; switch (material) { case SIGN: - case SIGN_POST: case WALL_SIGN: valid = blockState instanceof CraftSign; break; @@ -413,7 +434,6 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta case TRAPPED_CHEST: valid = blockState instanceof CraftChest; break; - case BURNING_FURNACE: case FURNACE: valid = blockState instanceof CraftFurnace; break; @@ -429,38 +449,73 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta case HOPPER: valid = blockState instanceof CraftHopper; break; - case MOB_SPAWNER: + case SPAWNER: valid = blockState instanceof CraftCreatureSpawner; break; - case NOTE_BLOCK: - valid = blockState instanceof CraftNoteBlock; - break; case JUKEBOX: valid = blockState instanceof CraftJukebox; break; - case BREWING_STAND_ITEM: + case BREWING_STAND: valid = blockState instanceof CraftBrewingStand; break; - case SKULL: + case CREEPER_HEAD: + case CREEPER_WALL_HEAD: + case DRAGON_HEAD: + case DRAGON_WALL_HEAD: + case PISTON_HEAD: + case PLAYER_HEAD: + case PLAYER_WALL_HEAD: + case SKELETON_SKULL: + case SKELETON_WALL_SKULL: + case WITHER_SKELETON_SKULL: + case WITHER_SKELETON_WALL_SKULL: + case ZOMBIE_HEAD: + case ZOMBIE_WALL_HEAD: valid = blockState instanceof CraftSkull; break; - case COMMAND: - case COMMAND_REPEATING: - case COMMAND_CHAIN: + case COMMAND_BLOCK: + case REPEATING_COMMAND_BLOCK: + case CHAIN_COMMAND_BLOCK: valid = blockState instanceof CraftCommandBlock; break; case BEACON: valid = blockState instanceof CraftBeacon; break; case SHIELD: - case BANNER: - case WALL_BANNER: - case STANDING_BANNER: + case BLACK_BANNER: + case BLACK_WALL_BANNER: + case BLUE_BANNER: + case BLUE_WALL_BANNER: + case BROWN_BANNER: + case BROWN_WALL_BANNER: + case CYAN_BANNER: + case CYAN_WALL_BANNER: + case GRAY_BANNER: + case GRAY_WALL_BANNER: + case GREEN_BANNER: + case GREEN_WALL_BANNER: + case LIGHT_BLUE_BANNER: + case LIGHT_BLUE_WALL_BANNER: + case LIGHT_GRAY_BANNER: + case LIGHT_GRAY_WALL_BANNER: + case LIME_BANNER: + case LIME_WALL_BANNER: + case MAGENTA_BANNER: + case MAGENTA_WALL_BANNER: + case ORANGE_BANNER: + case ORANGE_WALL_BANNER: + case PINK_BANNER: + case PINK_WALL_BANNER: + case PURPLE_BANNER: + case PURPLE_WALL_BANNER: + case RED_BANNER: + case RED_WALL_BANNER: + case WHITE_BANNER: + case WHITE_WALL_BANNER: + case YELLOW_BANNER: + case YELLOW_WALL_BANNER: valid = blockState instanceof CraftBanner; break; - case FLOWER_POT_ITEM: - valid = blockState instanceof CraftFlowerPot; - break; case STRUCTURE_BLOCK: valid = blockState instanceof CraftStructureBlock; break; @@ -472,7 +527,7 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta case LIME_SHULKER_BOX: case PINK_SHULKER_BOX: case GRAY_SHULKER_BOX: - case SILVER_SHULKER_BOX: + case LIGHT_GRAY_SHULKER_BOX: case CYAN_SHULKER_BOX: case PURPLE_SHULKER_BOX: case BLUE_SHULKER_BOX: @@ -482,17 +537,16 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta case BLACK_SHULKER_BOX: valid = blockState instanceof CraftShulkerBox; break; - case ENCHANTMENT_TABLE: + case ENCHANTING_TABLE: valid = blockState instanceof CraftEnchantingTable; break; case ENDER_CHEST: valid = blockState instanceof CraftEnderChest; break; case DAYLIGHT_DETECTOR: - case DAYLIGHT_DETECTOR_INVERTED: valid = blockState instanceof CraftDaylightDetector; break; - case REDSTONE_COMPARATOR: + case COMPARATOR: valid = blockState instanceof CraftComparator; break; default: diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java index 9c9ef2951d..c8654c68fb 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java @@ -158,7 +158,7 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta { boolean applicableTo(Material type) { switch (type) { case WRITTEN_BOOK: - case BOOK_AND_QUILL: + case WRITABLE_BOOK: return true; default: return false; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBookSigned.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBookSigned.java index bffbe9013b..5050b60991 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBookSigned.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBookSigned.java @@ -96,7 +96,7 @@ class CraftMetaBookSigned extends CraftMetaBook implements BookMeta { boolean applicableTo(Material type) { switch (type) { case WRITTEN_BOOK: - case BOOK_AND_QUILL: + case WRITABLE_BOOK: return true; default: return false; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaCharge.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaCharge.java index 6c6fde739d..267581ec2e 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaCharge.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaCharge.java @@ -67,7 +67,7 @@ class CraftMetaCharge extends CraftMetaItem implements FireworkEffectMeta { @Override boolean applicableTo(Material type) { switch (type) { - case FIREWORK_CHARGE: + case FIREWORK_STAR: return true; default: return false; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaFirework.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaFirework.java index 682c2287de..b82e2fdf7c 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaFirework.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaFirework.java @@ -253,7 +253,7 @@ class CraftMetaFirework extends CraftMetaItem implements FireworkMeta { @Override boolean applicableTo(Material type) { switch(type) { - case FIREWORK: + case FIREWORK_ROCKET: return true; default: return false; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java index 8d82c4dca5..dfd6e66bff 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java @@ -13,6 +13,7 @@ import java.util.List; import java.util.Map; import java.util.NoSuchElementException; +import net.minecraft.server.IChatBaseComponent; import net.minecraft.server.NBTBase; import net.minecraft.server.NBTTagCompound; import net.minecraft.server.NBTTagList; @@ -25,9 +26,12 @@ import org.bukkit.configuration.serialization.DelegateDeserialization; import org.bukkit.configuration.serialization.SerializableAs; import org.bukkit.craftbukkit.Overridden; import org.bukkit.craftbukkit.inventory.CraftMetaItem.ItemMetaKey.Specific; +import org.bukkit.craftbukkit.util.CraftChatMessage; import org.bukkit.craftbukkit.util.CraftMagicNumbers; +import org.bukkit.craftbukkit.util.CraftNamespacedKey; import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.ItemFlag; +import org.bukkit.inventory.meta.Damageable; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.Repairable; @@ -70,7 +74,7 @@ import org.apache.commons.codec.binary.Base64; *
  • SerializableMeta.Deserializers deserializer() */ @DelegateDeserialization(CraftMetaItem.SerializableMeta.class) -class CraftMetaItem implements ItemMeta, Repairable { +class CraftMetaItem implements ItemMeta, Damageable, Repairable { static class ItemMetaKey { @@ -120,6 +124,7 @@ class CraftMetaItem implements ItemMeta, Repairable { .put(CraftMetaFirework.class, "FIREWORK") .put(CraftMetaCharge.class, "FIREWORK_EFFECT") .put(CraftMetaKnowledgeBook.class, "KNOWLEDGE_BOOK") + .put(CraftMetaTropicalFishBucket.class, "TROPICAL_FISH_BUCKET") .put(CraftMetaItem.class, "UNSPECIFIC") .build(); @@ -192,7 +197,7 @@ class CraftMetaItem implements ItemMeta, Repairable { @Specific(Specific.To.NBT) static final ItemMetaKey DISPLAY = new ItemMetaKey("display"); static final ItemMetaKey LORE = new ItemMetaKey("Lore", "lore"); - static final ItemMetaKey ENCHANTMENTS = new ItemMetaKey("ench", "enchants"); + static final ItemMetaKey ENCHANTMENTS = new ItemMetaKey("Enchantments", "enchants"); @Specific(Specific.To.NBT) static final ItemMetaKey ENCHANTMENTS_ID = new ItemMetaKey("id"); @Specific(Specific.To.NBT) @@ -216,14 +221,17 @@ class CraftMetaItem implements ItemMeta, Repairable { static final ItemMetaKey HIDEFLAGS = new ItemMetaKey("HideFlags", "ItemFlags"); @Specific(Specific.To.NBT) static final ItemMetaKey UNBREAKABLE = new ItemMetaKey("Unbreakable"); + @Specific(Specific.To.NBT) + static final ItemMetaKey DAMAGE = new ItemMetaKey("Damage"); - private String displayName; - private String locName; + private IChatBaseComponent displayName; + private IChatBaseComponent locName; private List lore; private Map enchantments; private int repairCost; private int hideFlag; private boolean unbreakable; + private int damage; private static final Set HANDLED_TAGS = Sets.newHashSet(); @@ -249,6 +257,7 @@ class CraftMetaItem implements ItemMeta, Repairable { this.repairCost = meta.repairCost; this.hideFlag = meta.hideFlag; this.unbreakable = meta.unbreakable; + this.damage = meta.damage; this.unhandledTags.putAll(meta.unhandledTags); this.internalTag = meta.internalTag; @@ -262,11 +271,11 @@ class CraftMetaItem implements ItemMeta, Repairable { NBTTagCompound display = tag.getCompound(DISPLAY.NBT); if (display.hasKey(NAME.NBT)) { - displayName = display.getString(NAME.NBT); + displayName = IChatBaseComponent.ChatSerializer.a(display.getString(NAME.NBT)); } if (display.hasKey(LOCNAME.NBT)) { - locName = display.getString(LOCNAME.NBT); + locName = IChatBaseComponent.ChatSerializer.a(display.getString(LOCNAME.NBT)); } if (display.hasKey(LORE.NBT)) { @@ -292,6 +301,9 @@ class CraftMetaItem implements ItemMeta, Repairable { if (tag.hasKey(UNBREAKABLE.NBT)) { unbreakable = tag.getBoolean(UNBREAKABLE.NBT); } + if (tag.hasKey(DAMAGE.NBT)) { + damage = tag.getInt(DAMAGE.NBT); + } if (tag.get(ATTRIBUTES.NBT) instanceof NBTTagList) { NBTTagList save = null; @@ -339,7 +351,7 @@ class CraftMetaItem implements ItemMeta, Repairable { unhandledTags.put(ATTRIBUTES.NBT, save); } - Set keys = tag.c(); + Set keys = tag.getKeys(); for (String key : keys) { if (!getHandledTags().contains(key)) { unhandledTags.put(key, tag.get(key)); @@ -356,10 +368,10 @@ class CraftMetaItem implements ItemMeta, Repairable { Map enchantments = new HashMap(ench.size()); for (int i = 0; i < ench.size(); i++) { - int id = 0xffff & ((NBTTagCompound) ench.get(i)).getShort(ENCHANTMENTS_ID.NBT); + String id = ((NBTTagCompound) ench.get(i)).getString(ENCHANTMENTS_ID.NBT); int level = 0xffff & ((NBTTagCompound) ench.get(i)).getShort(ENCHANTMENTS_LVL.NBT); - Enchantment enchant = Enchantment.getById(id); + Enchantment enchant = Enchantment.getByKey(CraftNamespacedKey.fromString(id)); if (enchant != null) { enchantments.put(enchant, level); } @@ -402,13 +414,18 @@ class CraftMetaItem implements ItemMeta, Repairable { setUnbreakable(unbreakable); } + Integer damage = SerializableMeta.getObject(Integer.class, map, DAMAGE.BUKKIT, true); + if (damage != null) { + setDamage(damage); + } + String internal = SerializableMeta.getString(map, "internal", true); if (internal != null) { ByteArrayInputStream buf = new ByteArrayInputStream(Base64.decodeBase64(internal)); try { internalTag = NBTCompressedStreamTools.a(buf); deserializeInternal(internalTag); - Set keys = internalTag.c(); + Set keys = internalTag.getKeys(); for (String key : keys) { if (!getHandledTags().contains(key)) { unhandledTags.put(key, internalTag.get(key)); @@ -449,10 +466,10 @@ class CraftMetaItem implements ItemMeta, Repairable { @Overridden void applyToItem(NBTTagCompound itemTag) { if (hasDisplayName()) { - setDisplayTag(itemTag, NAME.NBT, new NBTTagString(displayName)); + setDisplayTag(itemTag, NAME.NBT, new NBTTagString(CraftChatMessage.toJSON(displayName))); } if (hasLocalizedName()){ - setDisplayTag(itemTag, LOCNAME.NBT, new NBTTagString(locName)); + setDisplayTag(itemTag, LOCNAME.NBT, new NBTTagString(CraftChatMessage.toJSON(locName))); } if (hasLore()) { @@ -473,6 +490,10 @@ class CraftMetaItem implements ItemMeta, Repairable { itemTag.setBoolean(UNBREAKABLE.NBT, unbreakable); } + if (hasDamage()) { + itemTag.setInt(DAMAGE.NBT, damage); + } + for (Map.Entry e : unhandledTags.entrySet()) { itemTag.set(e.getKey(), e.getValue()); } @@ -501,7 +522,7 @@ class CraftMetaItem implements ItemMeta, Repairable { for (Map.Entry entry : enchantments.entrySet()) { NBTTagCompound subtag = new NBTTagCompound(); - subtag.setShort(ENCHANTMENTS_ID.NBT, (short) entry.getKey().getId()); + subtag.setString(ENCHANTMENTS_ID.NBT, entry.getKey().getKey().toString()); subtag.setShort(ENCHANTMENTS_LVL.NBT, entry.getValue().shortValue()); list.add(subtag); @@ -527,34 +548,34 @@ class CraftMetaItem implements ItemMeta, Repairable { @Overridden boolean isEmpty() { - return !(hasDisplayName() || hasLocalizedName() || hasEnchants() || hasLore() || hasRepairCost() || !unhandledTags.isEmpty() || hideFlag != 0 || isUnbreakable()); + return !(hasDisplayName() || hasLocalizedName() || hasEnchants() || hasLore() || hasRepairCost() || !unhandledTags.isEmpty() || hideFlag != 0 || isUnbreakable() || hasDamage()); } public String getDisplayName() { - return displayName; + return CraftChatMessage.fromComponent(displayName); } public final void setDisplayName(String name) { - this.displayName = name; + this.displayName = CraftChatMessage.fromStringOrNull(name); } public boolean hasDisplayName() { - return !Strings.isNullOrEmpty(displayName); + return displayName != null; } @Override public String getLocalizedName() { - return locName; + return CraftChatMessage.fromComponent(locName); } @Override public void setLocalizedName(String name) { - this.locName = name; + this.locName = CraftChatMessage.fromStringOrNull(name); } @Override public boolean hasLocalizedName() { - return !Strings.isNullOrEmpty(locName); + return locName != null; } public boolean hasLore() { @@ -681,6 +702,21 @@ class CraftMetaItem implements ItemMeta, Repairable { this.unbreakable = unbreakable; } + @Override + public boolean hasDamage() { + return damage > 0; + } + + @Override + public int getDamage() { + return damage; + } + + @Override + public void setDamage(int damage) { + this.damage = damage; + } + @Override public final boolean equals(Object object) { if (object == null) { @@ -709,7 +745,8 @@ class CraftMetaItem implements ItemMeta, Repairable { && (this.hasRepairCost() ? that.hasRepairCost() && this.repairCost == that.repairCost : !that.hasRepairCost()) && (this.unhandledTags.equals(that.unhandledTags)) && (this.hideFlag == that.hideFlag) - && (this.isUnbreakable() == that.isUnbreakable()); + && (this.isUnbreakable() == that.isUnbreakable()) + && (this.hasDamage() ? that.hasDamage() && this.damage == that.damage : !that.hasDamage()); } /** @@ -738,6 +775,7 @@ class CraftMetaItem implements ItemMeta, Repairable { hash = 61 * hash + unhandledTags.hashCode(); hash = 61 * hash + hideFlag; hash = 61 * hash + (isUnbreakable() ? 1231 : 1237); + hash = 61 * hash + (hasDamage() ? this.damage : 0); return hash; } @@ -754,6 +792,7 @@ class CraftMetaItem implements ItemMeta, Repairable { } clone.hideFlag = this.hideFlag; clone.unbreakable = this.unbreakable; + clone.damage = this.damage; return clone; } catch (CloneNotSupportedException e) { throw new Error(e); @@ -770,10 +809,10 @@ class CraftMetaItem implements ItemMeta, Repairable { @Overridden ImmutableMap.Builder serialize(ImmutableMap.Builder builder) { if (hasDisplayName()) { - builder.put(NAME.BUKKIT, displayName); + builder.put(NAME.BUKKIT, CraftChatMessage.fromComponent(displayName)); } if (hasLocalizedName()) { - builder.put(LOCNAME.BUKKIT, locName); + builder.put(LOCNAME.BUKKIT, CraftChatMessage.fromComponent(locName)); } if (hasLore()) { @@ -798,6 +837,10 @@ class CraftMetaItem implements ItemMeta, Repairable { builder.put(UNBREAKABLE.BUKKIT, unbreakable); } + if (hasDamage()) { + builder.put(DAMAGE.BUKKIT, damage); + } + final Map internalTags = new HashMap(unhandledTags); serializeInternal(internalTags); if (!internalTags.isEmpty()) { @@ -820,6 +863,10 @@ class CraftMetaItem implements ItemMeta, Repairable { void serializeInternal(final Map unhandledTags) { } + Material updateMaterial(Material material) { + return material; + } + static void serializeEnchantments(Map enchantments, ImmutableMap.Builder builder, ItemMetaKey key) { if (enchantments == null || enchantments.isEmpty()) { return; @@ -885,6 +932,7 @@ class CraftMetaItem implements ItemMeta, Repairable { ENCHANTMENTS.NBT, HIDEFLAGS.NBT, UNBREAKABLE.NBT, + DAMAGE.NBT, CraftMetaMap.MAP_SCALING.NBT, CraftMetaPotion.POTION_EFFECTS.NBT, CraftMetaPotion.DEFAULT_POTION.NBT, @@ -901,7 +949,8 @@ class CraftMetaItem implements ItemMeta, Repairable { CraftMetaEnchantedBook.STORED_ENCHANTMENTS.NBT, CraftMetaCharge.EXPLOSION.NBT, CraftMetaBlockState.BLOCK_ENTITY_TAG.NBT, - CraftMetaKnowledgeBook.BOOK_RECIPES.NBT + CraftMetaKnowledgeBook.BOOK_RECIPES.NBT, + CraftMetaTropicalFishBucket.VARIANT.NBT )); } return HANDLED_TAGS; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMap.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMap.java index de695e4e7b..d35c5b0365 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMap.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMap.java @@ -99,7 +99,7 @@ class CraftMetaMap extends CraftMetaItem implements MapMeta { @Override boolean applicableTo(Material type) { switch (type) { - case MAP: + case FILLED_MAP: return true; default: return false; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaPotion.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaPotion.java index 4fec167688..6a58ab56cd 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaPotion.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaPotion.java @@ -69,7 +69,7 @@ class CraftMetaPotion extends CraftMetaItem implements PotionMeta { customEffects = new ArrayList(length); for (int i = 0; i < length; i++) { - NBTTagCompound effect = list.get(i); + NBTTagCompound effect = list.getCompound(i); PotionEffectType type = PotionEffectType.getById(effect.getByte(ID.NBT)); int amp = effect.getByte(AMPLIFIER.NBT); int duration = effect.getInt(DURATION.NBT); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java index 8c5d3effcd..e39511038e 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java @@ -96,8 +96,20 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta { @Override boolean applicableTo(Material type) { - switch(type) { - case SKULL_ITEM: + switch (type) { + case CREEPER_HEAD: + case CREEPER_WALL_HEAD: + case DRAGON_HEAD: + case DRAGON_WALL_HEAD: + case PISTON_HEAD: + case PLAYER_HEAD: + case PLAYER_WALL_HEAD: + case SKELETON_SKULL: + case SKELETON_WALL_SKULL: + case WITHER_SKELETON_SKULL: + case WITHER_SKELETON_WALL_SKULL: + case ZOMBIE_HEAD: + case ZOMBIE_WALL_HEAD: return true; default: return false; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSpawnEgg.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSpawnEgg.java index 70616a2f96..892cc10ab4 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSpawnEgg.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSpawnEgg.java @@ -1,17 +1,21 @@ package org.bukkit.craftbukkit.inventory; -import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableMap.Builder; +import com.mojang.datafixers.Dynamic; import java.util.Map; import net.minecraft.server.DataConverterTypes; +import net.minecraft.server.DynamicOpsNBT; import net.minecraft.server.MinecraftKey; import net.minecraft.server.MinecraftServer; import net.minecraft.server.NBTBase; import net.minecraft.server.NBTTagCompound; import org.bukkit.Material; import org.bukkit.configuration.serialization.DelegateDeserialization; +import org.bukkit.craftbukkit.util.CraftLegacy; +import org.bukkit.craftbukkit.util.CraftMagicNumbers; import org.bukkit.entity.EntityType; import org.bukkit.inventory.meta.SpawnEggMeta; +import org.bukkit.material.MaterialData; @DelegateDeserialization(CraftMetaItem.SerializableMeta.class) public class CraftMetaSpawnEgg extends CraftMetaItem implements SpawnEggMeta { @@ -32,6 +36,8 @@ public class CraftMetaSpawnEgg extends CraftMetaItem implements SpawnEggMeta { CraftMetaSpawnEgg egg = (CraftMetaSpawnEgg) meta; this.spawnedType = egg.spawnedType; + + updateMaterial(null); // Trigger type population } CraftMetaSpawnEgg(NBTTagCompound tag) { @@ -39,10 +45,6 @@ public class CraftMetaSpawnEgg extends CraftMetaItem implements SpawnEggMeta { if (tag.hasKey(ENTITY_TAG.NBT)) { entityTag = tag.getCompound(ENTITY_TAG.NBT); - - if (entityTag.hasKey(ENTITY_ID.NBT)) { - this.spawnedType = EntityType.fromName(new MinecraftKey(entityTag.getString(ENTITY_ID.NBT)).getKey()); - } } } @@ -50,7 +52,9 @@ public class CraftMetaSpawnEgg extends CraftMetaItem implements SpawnEggMeta { super(map); String entityType = SerializableMeta.getString(map, ENTITY_ID.BUKKIT, true); - setSpawnedType(EntityType.fromName(entityType)); + if (entityType != null) { + this.spawnedType = EntityType.fromName(entityType); + } } @Override @@ -59,7 +63,7 @@ public class CraftMetaSpawnEgg extends CraftMetaItem implements SpawnEggMeta { if (tag.hasKey(ENTITY_TAG.NBT)) { entityTag = tag.getCompound(ENTITY_TAG.NBT); - MinecraftServer.getServer().dataConverterManager.a(DataConverterTypes.ENTITY, entityTag); // PAIL: convert + MinecraftServer.getServer().dataConverterManager.update(DataConverterTypes.ENTITY, new Dynamic(DynamicOpsNBT.a, entityTag), -1, CraftMagicNumbers.DATA_VERSION); if (entityTag.hasKey(ENTITY_ID.NBT)) { this.spawnedType = EntityType.fromName(new MinecraftKey(entityTag.getString(ENTITY_ID.NBT)).getKey()); @@ -82,10 +86,6 @@ public class CraftMetaSpawnEgg extends CraftMetaItem implements SpawnEggMeta { entityTag = new NBTTagCompound(); } - if (hasSpawnedType()) { - entityTag.setString(ENTITY_ID.NBT, new MinecraftKey(spawnedType.getName()).toString()); - } - if (entityTag != null) { tag.set(ENTITY_TAG.NBT, entityTag); } @@ -94,7 +94,49 @@ public class CraftMetaSpawnEgg extends CraftMetaItem implements SpawnEggMeta { @Override boolean applicableTo(Material type) { switch (type) { - case MONSTER_EGG: + case BAT_SPAWN_EGG: + case BLAZE_SPAWN_EGG: + case CAVE_SPIDER_SPAWN_EGG: + case CHICKEN_SPAWN_EGG: + case COW_SPAWN_EGG: + case CREEPER_SPAWN_EGG: + case DONKEY_SPAWN_EGG: + case ELDER_GUARDIAN_SPAWN_EGG: + case ENDERMAN_SPAWN_EGG: + case ENDERMITE_SPAWN_EGG: + case EVOKER_SPAWN_EGG: + case GHAST_SPAWN_EGG: + case GUARDIAN_SPAWN_EGG: + case HORSE_SPAWN_EGG: + case HUSK_SPAWN_EGG: + case LLAMA_SPAWN_EGG: + case MAGMA_CUBE_SPAWN_EGG: + case MOOSHROOM_SPAWN_EGG: + case MULE_SPAWN_EGG: + case OCELOT_SPAWN_EGG: + case PARROT_SPAWN_EGG: + case PIG_SPAWN_EGG: + case POLAR_BEAR_SPAWN_EGG: + case RABBIT_SPAWN_EGG: + case SHEEP_SPAWN_EGG: + case SHULKER_SPAWN_EGG: + case SILVERFISH_SPAWN_EGG: + case SKELETON_HORSE_SPAWN_EGG: + case SKELETON_SPAWN_EGG: + case SLIME_SPAWN_EGG: + case SPIDER_SPAWN_EGG: + case SQUID_SPAWN_EGG: + case STRAY_SPAWN_EGG: + case VEX_SPAWN_EGG: + case VILLAGER_SPAWN_EGG: + case VINDICATOR_SPAWN_EGG: + case WITCH_SPAWN_EGG: + case WITHER_SKELETON_SPAWN_EGG: + case WOLF_SPAWN_EGG: + case ZOMBIE_HORSE_SPAWN_EGG: + case ZOMBIE_PIGMAN_SPAWN_EGG: + case ZOMBIE_SPAWN_EGG: + case ZOMBIE_VILLAGER_SPAWN_EGG: return true; default: return false; @@ -116,14 +158,12 @@ public class CraftMetaSpawnEgg extends CraftMetaItem implements SpawnEggMeta { @Override public EntityType getSpawnedType() { - return spawnedType; + throw new UnsupportedOperationException("Must check item type to get spawned type"); } @Override public void setSpawnedType(EntityType type) { - Preconditions.checkArgument(type == null || type.getName() != null, "Spawn egg type must have name (%s)", type); - - this.spawnedType = type; + throw new UnsupportedOperationException("Must change item type to set spawned type"); } @Override @@ -164,10 +204,6 @@ public class CraftMetaSpawnEgg extends CraftMetaItem implements SpawnEggMeta { Builder serialize(Builder builder) { super.serialize(builder); - if (hasSpawnedType()) { - builder.put(ENTITY_ID.BUKKIT, spawnedType.getName()); - } - return builder; } @@ -177,9 +213,23 @@ public class CraftMetaSpawnEgg extends CraftMetaItem implements SpawnEggMeta { clone.spawnedType = spawnedType; if (entityTag != null) { - clone.entityTag = entityTag.g(); + clone.entityTag = entityTag.clone(); } return clone; } + + @Override + final Material updateMaterial(Material material) { + if (spawnedType == null) { + spawnedType = EntityType.fromId(getDamage()); + setDamage(0); + } + + if (spawnedType != null) { + return CraftLegacy.fromLegacy(new MaterialData(Material.LEGACY_MONSTER_EGG, (byte) spawnedType.getTypeId())); + } + + return super.updateMaterial(material); + } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaTropicalFishBucket.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaTropicalFishBucket.java new file mode 100644 index 0000000000..f27df320b5 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaTropicalFishBucket.java @@ -0,0 +1,168 @@ +package org.bukkit.craftbukkit.inventory; + +import java.util.Map; + +import net.minecraft.server.NBTTagCompound; +import org.bukkit.Material; +import org.bukkit.configuration.serialization.DelegateDeserialization; +import org.bukkit.craftbukkit.inventory.CraftMetaItem.SerializableMeta; + +import com.google.common.collect.ImmutableMap; +import org.bukkit.DyeColor; +import org.bukkit.craftbukkit.entity.CraftTropicalFish; +import org.bukkit.craftbukkit.util.CraftMagicNumbers; +import org.bukkit.entity.TropicalFish; +import org.bukkit.inventory.meta.TropicalFishBucketMeta; + +@DelegateDeserialization(SerializableMeta.class) +class CraftMetaTropicalFishBucket extends CraftMetaItem implements TropicalFishBucketMeta { + static final ItemMetaKey VARIANT = new ItemMetaKey("BucketVariantTag", "fish-variant"); + + private Integer variant; + + CraftMetaTropicalFishBucket(CraftMetaItem meta) { + super(meta); + + if (!(meta instanceof CraftMetaTropicalFishBucket)) { + return; + } + + CraftMetaTropicalFishBucket bucket = (CraftMetaTropicalFishBucket) meta; + this.variant = bucket.variant; + } + + CraftMetaTropicalFishBucket(NBTTagCompound tag) { + super(tag); + + if (tag.hasKeyOfType(VARIANT.NBT, CraftMagicNumbers.NBT.TAG_INT)) { + this.variant = tag.getInt(VARIANT.NBT); + } + } + + CraftMetaTropicalFishBucket(Map map) { + super(map); + + Integer variant = SerializableMeta.getObject(Integer.class, map, VARIANT.BUKKIT, true); + if (variant != null) { + this.variant = variant; + } + } + + @Override + void applyToItem(NBTTagCompound tag) { + super.applyToItem(tag); + + if (hasVariant()) { + tag.setInt(VARIANT.NBT, variant); + } + } + + @Override + boolean applicableTo(Material type) { + switch (type) { + case TROPICAL_FISH_BUCKET: + return true; + default: + return false; + } + } + + @Override + boolean isEmpty() { + return super.isEmpty() && isBucketEmpty(); + } + + boolean isBucketEmpty() { + return !(hasVariant()); + } + + @Override + public DyeColor getPatternColor() { + return CraftTropicalFish.getPatternColor(variant); + } + + @Override + public void setPatternColor(DyeColor color) { + if (variant == null) { + variant = 0; + } + variant = CraftTropicalFish.getData(color, getPatternColor(), getPattern()); + } + + @Override + public DyeColor getBodyColor() { + return CraftTropicalFish.getBodyColor(variant); + } + + @Override + public void setBodyColor(DyeColor color) { + if (variant == null) { + variant = 0; + } + variant = CraftTropicalFish.getData(getPatternColor(), color, getPattern()); + } + + @Override + public TropicalFish.Pattern getPattern() { + return CraftTropicalFish.getPattern(variant); + } + + @Override + public void setPattern(TropicalFish.Pattern pattern) { + if (variant == null) { + variant = 0; + } + variant = CraftTropicalFish.getData(getPatternColor(), getBodyColor(), pattern); + } + + @Override + public boolean hasVariant() { + return variant != null; + } + + @Override + boolean equalsCommon(CraftMetaItem meta) { + if (!super.equalsCommon(meta)) { + return false; + } + if (meta instanceof CraftMetaTropicalFishBucket) { + CraftMetaTropicalFishBucket that = (CraftMetaTropicalFishBucket) meta; + + return (hasVariant() ? that.hasVariant() && this.variant.equals(that.variant) : !that.hasVariant()); + } + return true; + } + + @Override + boolean notUncommon(CraftMetaItem meta) { + return super.notUncommon(meta) && (meta instanceof CraftMetaTropicalFishBucket || isBucketEmpty()); + } + + @Override + int applyHash() { + final int original; + int hash = original = super.applyHash(); + + if (hasVariant()) { + hash = 61 * hash + variant; + } + + return original != hash ? CraftMetaTropicalFishBucket.class.hashCode() ^ hash : hash; + } + + + public CraftMetaTropicalFishBucket clone() { + return (CraftMetaTropicalFishBucket) super.clone(); + } + + @Override + ImmutableMap.Builder serialize(ImmutableMap.Builder builder) { + super.serialize(builder); + + if (hasVariant()) { + builder.put(VARIANT.BUKKIT, variant); + } + + return builder; + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapedRecipe.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapedRecipe.java index 44df930192..efd0e76a1b 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapedRecipe.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapedRecipe.java @@ -1,8 +1,9 @@ package org.bukkit.craftbukkit.inventory; import java.util.Map; +import java.util.stream.Stream; -import net.minecraft.server.CraftingManager; +import net.minecraft.server.MinecraftServer; import net.minecraft.server.NonNullList; import net.minecraft.server.RecipeItemStack; import net.minecraft.server.ShapedRecipes; @@ -21,7 +22,7 @@ public class CraftShapedRecipe extends ShapedRecipe implements CraftRecipe { } public CraftShapedRecipe(ItemStack result, ShapedRecipes recipe) { - this(CraftNamespacedKey.fromMinecraft(recipe.key), result); + this(CraftNamespacedKey.fromMinecraft(recipe.getKey()), result); this.recipe = recipe; } @@ -51,10 +52,10 @@ public class CraftShapedRecipe extends ShapedRecipe implements CraftRecipe { for (int i = 0; i < shape.length; i++) { String row = shape[i]; for (int j = 0; j < row.length(); j++) { - data.set(i * width + j, RecipeItemStack.a(new net.minecraft.server.ItemStack[]{CraftItemStack.asNMSCopy(ingred.get(row.charAt(j)))})); + data.set(i * width + j, new RecipeItemStack(Stream.of(new RecipeItemStack.StackProvider(CraftItemStack.asNMSCopy(ingred.get(row.charAt(j))))))); } } - CraftingManager.a(CraftNamespacedKey.toMinecraft(this.getKey()), new ShapedRecipes("", width, shape.length, data, CraftItemStack.asNMSCopy(this.getResult()))); + MinecraftServer.getServer().getCraftingManager().a(new ShapedRecipes(CraftNamespacedKey.toMinecraft(this.getKey()), "", width, shape.length, data, CraftItemStack.asNMSCopy(this.getResult()))); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapelessRecipe.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapelessRecipe.java index 211898c514..dbbcb67925 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapelessRecipe.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapelessRecipe.java @@ -1,8 +1,9 @@ package org.bukkit.craftbukkit.inventory; import java.util.List; +import java.util.stream.Stream; -import net.minecraft.server.CraftingManager; +import net.minecraft.server.MinecraftServer; import net.minecraft.server.NonNullList; import net.minecraft.server.RecipeItemStack; import net.minecraft.server.ShapelessRecipes; @@ -21,7 +22,7 @@ public class CraftShapelessRecipe extends ShapelessRecipe implements CraftRecipe } public CraftShapelessRecipe(ItemStack result, ShapelessRecipes recipe) { - this(CraftNamespacedKey.fromMinecraft(recipe.key), result); + this(CraftNamespacedKey.fromMinecraft(recipe.getKey()), result); this.recipe = recipe; } @@ -40,9 +41,9 @@ public class CraftShapelessRecipe extends ShapelessRecipe implements CraftRecipe List ingred = this.getIngredientList(); NonNullList data = NonNullList.a(ingred.size(), RecipeItemStack.a); for (int i = 0; i < ingred.size(); i++) { - data.set(i, RecipeItemStack.a(new net.minecraft.server.ItemStack[]{CraftItemStack.asNMSCopy(ingred.get(i))})); + data.set(i, new RecipeItemStack(Stream.of(new RecipeItemStack.StackProvider(CraftItemStack.asNMSCopy(ingred.get(i)))))); } - CraftingManager.a(CraftNamespacedKey.toMinecraft(this.getKey()), new ShapelessRecipes("", CraftItemStack.asNMSCopy(this.getResult()), data)); + MinecraftServer.getServer().getCraftingManager().a(new ShapelessRecipes(CraftNamespacedKey.toMinecraft(this.getKey()), "", CraftItemStack.asNMSCopy(this.getResult()), data)); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/InventoryWrapper.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/InventoryWrapper.java index 6cbcc9d30b..9c5ec924eb 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/InventoryWrapper.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/InventoryWrapper.java @@ -160,18 +160,23 @@ public class InventoryWrapper implements IInventory { } @Override - public String getName() { - return inventory.getName(); + public IChatBaseComponent getDisplayName() { + return CraftChatMessage.fromStringOrNull(inventory.getName()); + } + + @Override + public IChatBaseComponent getCustomName() { + return getDisplayName(); } @Override public boolean hasCustomName() { - return getName() != null; + return inventory.getName() != null; } @Override public IChatBaseComponent getScoreboardDisplayName() { - return CraftChatMessage.fromString(getName())[0]; + return getDisplayName(); } @Override @@ -180,7 +185,7 @@ public class InventoryWrapper implements IInventory { } @Override - public boolean x_() { + public boolean P_() { return Iterables.any(inventory, Predicates.notNull()); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/RecipeIterator.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/RecipeIterator.java index f03f8baa84..165225e732 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/RecipeIterator.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/RecipeIterator.java @@ -4,50 +4,25 @@ import java.util.Iterator; import org.bukkit.inventory.Recipe; -import net.minecraft.server.CraftingManager; import net.minecraft.server.IRecipe; -import net.minecraft.server.RecipesFurnace; +import net.minecraft.server.MinecraftServer; public class RecipeIterator implements Iterator { private final Iterator recipes; - private final Iterator smeltingCustom; - private final Iterator smeltingVanilla; - private Iterator removeFrom = null; public RecipeIterator() { - this.recipes = CraftingManager.recipes.iterator(); - this.smeltingCustom = RecipesFurnace.getInstance().customRecipes.keySet().iterator(); - this.smeltingVanilla = RecipesFurnace.getInstance().recipes.keySet().iterator(); + this.recipes = MinecraftServer.getServer().getCraftingManager().recipes.values().iterator(); } public boolean hasNext() { - return recipes.hasNext() || smeltingCustom.hasNext() || smeltingVanilla.hasNext(); + return recipes.hasNext(); } public Recipe next() { - if (recipes.hasNext()) { - removeFrom = recipes; - return recipes.next().toBukkitRecipe(); - } else { - net.minecraft.server.ItemStack item; - if (smeltingCustom.hasNext()) { - removeFrom = smeltingCustom; - item = smeltingCustom.next(); - } else { - removeFrom = smeltingVanilla; - item = smeltingVanilla.next(); - } - - CraftItemStack stack = CraftItemStack.asCraftMirror(RecipesFurnace.getInstance().getResult(item)); - - return new CraftFurnaceRecipe(stack, CraftItemStack.asCraftMirror(item)); - } + return recipes.next().toBukkitRecipe(); } public void remove() { - if (removeFrom == null) { - throw new IllegalStateException(); - } - removeFrom.remove(); + recipes.remove(); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/map/CraftMapRenderer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/map/CraftMapRenderer.java index a55915a4f3..0a3eb3b58e 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/map/CraftMapRenderer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/map/CraftMapRenderer.java @@ -42,7 +42,7 @@ public class CraftMapRenderer extends MapRenderer { } MapIcon decoration = (MapIcon) worldMap.decorations.get(key); - cursors.addCursor(decoration.getX(), decoration.getY(), (byte) (decoration.getRotation() & 15), decoration.getType()); + cursors.addCursor(decoration.getX(), decoration.getY(), (byte) (decoration.getRotation() & 15), decoration.b().a()); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/map/CraftMapView.java b/paper-server/src/main/java/org/bukkit/craftbukkit/map/CraftMapView.java index b951bfda3f..4d5eb2c162 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/map/CraftMapView.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/map/CraftMapView.java @@ -29,7 +29,7 @@ public final class CraftMapView implements MapView { } public short getId() { - String text = worldMap.id; + String text = worldMap.getId(); if (text.startsWith("map_")) { try { return Short.parseShort(text.substring("map_".length())); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionEffectType.java b/paper-server/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionEffectType.java index b06fddf729..09f44ed625 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionEffectType.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionEffectType.java @@ -79,6 +79,10 @@ public class CraftPotionEffectType extends PotionEffectType { return "LUCK"; case 27: return "UNLUCK"; + case 28: + return "SLOW_FALLING"; + case 29: + return "CONDUIT_POWER"; default: return "UNKNOWN_EFFECT_TYPE_" + getId(); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionUtil.java b/paper-server/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionUtil.java index 8483cd85d9..2392b457f6 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionUtil.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionUtil.java @@ -34,6 +34,8 @@ public class CraftPotionUtil { .put(PotionType.STRENGTH, "strength") .put(PotionType.WEAKNESS, "weakness") .put(PotionType.LUCK, "luck") + .put(PotionType.TURTLE_MASTER, "turtle_master") + .put(PotionType.SLOW_FALLING, "slow_falling") .build(); private static final BiMap upgradeable = ImmutableBiMap.builder() .put(PotionType.JUMP, "strong_leaping") @@ -43,6 +45,8 @@ public class CraftPotionUtil { .put(PotionType.POISON, "strong_poison") .put(PotionType.REGEN, "strong_regeneration") .put(PotionType.STRENGTH, "strong_strength") + .put(PotionType.SLOWNESS, "strong_slowness") + .put(PotionType.TURTLE_MASTER, "strong_turtle_master") .build(); private static final BiMap extendable = ImmutableBiMap.builder() .put(PotionType.NIGHT_VISION, "long_night_vision") @@ -56,6 +60,8 @@ public class CraftPotionUtil { .put(PotionType.REGEN, "long_regeneration") .put(PotionType.STRENGTH, "long_strength") .put(PotionType.WEAKNESS, "long_weakness") + .put(PotionType.TURTLE_MASTER, "long_turtle_master") + .put(PotionType.SLOW_FALLING, "long_slow_falling") .build(); public static String fromBukkit(PotionData data) { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftObjective.java b/paper-server/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftObjective.java index 239ceca0eb..822600fe5d 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftObjective.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftObjective.java @@ -2,6 +2,7 @@ package org.bukkit.craftbukkit.scoreboard; import net.minecraft.server.Scoreboard; import net.minecraft.server.ScoreboardObjective; +import net.minecraft.server.ScoreboardServer; import org.apache.commons.lang.Validate; import org.bukkit.OfflinePlayer; @@ -40,7 +41,8 @@ final class CraftObjective extends CraftScoreboardComponent implements Objective Validate.isTrue(displayName.length() <= 32, "Display name '" + displayName + "' is longer than the limit of 32 characters"); CraftScoreboard scoreboard = checkState(); - objective.setDisplayName(displayName); + objective.displayName = displayName; + ((ScoreboardServer) scoreboard.board).handleObjectiveChanged(objective); } public String getCriteria() throws IllegalStateException { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboard.java b/paper-server/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboard.java index 00b30f8c80..573b9cd18e 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboard.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboard.java @@ -24,14 +24,22 @@ public final class CraftScoreboard implements org.bukkit.scoreboard.Scoreboard { this.board = board; } + @Override public CraftObjective registerNewObjective(String name, String criteria) throws IllegalArgumentException { + return registerNewObjective(name, criteria, name); + } + + @Override + public CraftObjective registerNewObjective(String name, String criteria, String displayName) throws IllegalArgumentException { Validate.notNull(name, "Objective name cannot be null"); Validate.notNull(criteria, "Criteria cannot be null"); + Validate.notNull(displayName, "Display name cannot be null"); Validate.isTrue(name.length() <= 16, "The name '" + name + "' is longer than the limit of 16 characters"); + Validate.isTrue(displayName.length() <= 32, "The display name '" + displayName + "' is longer than the limit of 32 characters"); Validate.isTrue(board.getObjective(name) == null, "An objective of name '" + name + "' already exists"); CraftCriteria craftCriteria = CraftCriteria.getFromBukkit(criteria); - ScoreboardObjective objective = board.registerObjective(name, craftCriteria.criteria); + ScoreboardObjective objective = board.registerObjective(name, craftCriteria.criteria, displayName); return new CraftObjective(this, objective); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardManager.java b/paper-server/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardManager.java index 69fcb10821..cac87d3069 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardManager.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardManager.java @@ -7,6 +7,7 @@ import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.function.Consumer; import net.minecraft.server.EntityPlayer; import net.minecraft.server.IScoreboardCriteria; @@ -99,13 +100,10 @@ public final class CraftScoreboardManager implements ScoreboardManager { } // CraftBukkit method - public Collection getScoreboardScores(IScoreboardCriteria criteria, String name, Collection collection) { + public void getScoreboardScores(IScoreboardCriteria criteria, String name, Consumer consumer) { for (CraftScoreboard scoreboard : scoreboards) { Scoreboard board = scoreboard.board; - for (ScoreboardObjective objective : (Iterable) board.getObjectivesForCriteria(criteria)) { - collection.add(board.getPlayerScoreForObjective(name, objective)); - } + board.getObjectivesForCriteria(criteria, name, (score) -> consumer.accept(score)); } - return collection; } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java b/paper-server/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java index 18616fc8db..17865e65e0 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java @@ -160,7 +160,7 @@ final class CraftTeam extends CraftScoreboardComponent implements Team { Validate.notNull(entry, "Entry cannot be null"); CraftScoreboard scoreboard = checkState(); - scoreboard.board.addPlayerToTeam(entry, team.getName()); + scoreboard.board.addPlayerToTeam(entry, team); } public boolean removePlayer(OfflinePlayer player) throws IllegalStateException, IllegalArgumentException { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/tag/CraftBlockTag.java b/paper-server/src/main/java/org/bukkit/craftbukkit/tag/CraftBlockTag.java new file mode 100644 index 0000000000..4b3ac51a39 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/tag/CraftBlockTag.java @@ -0,0 +1,28 @@ +package org.bukkit.craftbukkit.tag; + +import java.util.Collections; +import java.util.Set; +import java.util.stream.Collectors; +import net.minecraft.server.Block; +import org.bukkit.Material; +import org.bukkit.Tag; +import org.bukkit.craftbukkit.util.CraftMagicNumbers; + +public class CraftBlockTag implements Tag { + + private final net.minecraft.server.Tag handle; + + public CraftBlockTag(net.minecraft.server.Tag handle) { + this.handle = handle; + } + + @Override + public boolean isTagged(Material item) { + return handle.isTagged(CraftMagicNumbers.getBlock(item)); + } + + @Override + public Set getValues() { + return Collections.unmodifiableSet(handle.a().stream().map((block) -> CraftMagicNumbers.getMaterial(block)).collect(Collectors.toSet())); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/tag/CraftItemTag.java b/paper-server/src/main/java/org/bukkit/craftbukkit/tag/CraftItemTag.java new file mode 100644 index 0000000000..b6b90e3e56 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/tag/CraftItemTag.java @@ -0,0 +1,28 @@ +package org.bukkit.craftbukkit.tag; + +import java.util.Collections; +import java.util.Set; +import java.util.stream.Collectors; +import net.minecraft.server.Item; +import org.bukkit.Material; +import org.bukkit.Tag; +import org.bukkit.craftbukkit.util.CraftMagicNumbers; + +public class CraftItemTag implements Tag { + + private final net.minecraft.server.Tag handle; + + public CraftItemTag(net.minecraft.server.Tag handle) { + this.handle = handle; + } + + @Override + public boolean isTagged(Material item) { + return handle.isTagged(CraftMagicNumbers.getItem(item)); + } + + @Override + public Set getValues() { + return Collections.unmodifiableSet(handle.a().stream().map((item) -> CraftMagicNumbers.getMaterial(item)).collect(Collectors.toSet())); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/BlockStateListPopulator.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/BlockStateListPopulator.java index 2dbedd2d09..3db85a3b2c 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/BlockStateListPopulator.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/BlockStateListPopulator.java @@ -3,50 +3,35 @@ package org.bukkit.craftbukkit.util; import java.util.ArrayList; import java.util.List; -import net.minecraft.server.Block; import net.minecraft.server.BlockPosition; import net.minecraft.server.IBlockData; +import net.minecraft.server.World; -import org.bukkit.World; import org.bukkit.block.BlockState; +import org.bukkit.craftbukkit.block.CraftBlockState; public class BlockStateListPopulator { private final World world; - private final List list; + private final List list; public BlockStateListPopulator(World world) { - this(world, new ArrayList()); + this(world, new ArrayList()); } - public BlockStateListPopulator(World world, List list) { + public BlockStateListPopulator(World world, List list) { this.world = world; this.list = list; } - public void setTypeAndData(int x, int y, int z, Block block, int data, int light) { - BlockState state = world.getBlockAt(x, y, z).getState(); - state.setTypeId(Block.getId(block)); - state.setRawData((byte) data); - list.add(state); - } - public void setTypeId(int x, int y, int z, int type) { - BlockState state = world.getBlockAt(x, y, z).getState(); - state.setTypeId(type); + public void setTypeUpdate(BlockPosition position, IBlockData data) { + CraftBlockState state = CraftBlockState.getBlockState(world, position); + state.setData(data); list.add(state); } - public void setTypeUpdate(int x, int y, int z, Block block) { - this.setType(x, y, z, block); - } - - public void setTypeUpdate(BlockPosition position, IBlockData data) { - setTypeAndData(position.getX(), position.getY(), position.getZ(), data.getBlock(), data.getBlock().toLegacyData(data), 0); - - } - - public void setType(int x, int y, int z, Block block) { - BlockState state = world.getBlockAt(x, y, z).getState(); - state.setTypeId(Block.getId(block)); + public void setTypeAndData(BlockPosition position, IBlockData data, int flag) { + CraftBlockState state = CraftBlockState.getBlockState(world, position, flag); + state.setData(data); list.add(state); } @@ -56,7 +41,7 @@ public class BlockStateListPopulator { } } - public List getList() { + public List getList() { return list; } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/Commodore.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/Commodore.java new file mode 100644 index 0000000000..aefba1492a --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/Commodore.java @@ -0,0 +1,268 @@ +package org.bukkit.craftbukkit.util; + +import com.google.common.io.ByteStreams; +import java.io.File; +import java.io.FileOutputStream; +import java.io.InputStream; +import java.util.Arrays; +import java.util.Enumeration; +import java.util.HashSet; +import java.util.Set; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; +import java.util.jar.JarOutputStream; +import java.util.zip.ZipEntry; +import joptsimple.OptionParser; +import joptsimple.OptionSet; +import joptsimple.OptionSpec; +import org.bukkit.Material; +import org.bukkit.plugin.AuthorNagException; +import org.objectweb.asm.ClassReader; +import org.objectweb.asm.ClassVisitor; +import org.objectweb.asm.ClassWriter; +import org.objectweb.asm.MethodVisitor; +import org.objectweb.asm.Opcodes; +import org.objectweb.asm.Type; + +/** + * This file is imported from Commodore. + * + * @author md_5 + */ +public class Commodore +{ + + private static final Set EVIL = new HashSet<>( Arrays.asList( + "org/bukkit/World (III)I getBlockTypeIdAt", + "org/bukkit/World (Lorg/bukkit/Location;)I getBlockTypeIdAt", + "org/bukkit/block/Block ()I getTypeId", + "org/bukkit/block/Block (I)Z setTypeId", + "org/bukkit/block/Block (IZ)Z setTypeId", + "org/bukkit/block/Block (IBZ)Z setTypeIdAndData", + "org/bukkit/inventory/ItemStack ()I getTypeId", + "org/bukkit/inventory/ItemStack (I)V setTypeId" + ) ); + + public static void main(String[] args) + { + OptionParser parser = new OptionParser(); + OptionSpec inputFlag = parser.acceptsAll( Arrays.asList( "i", "input" ) ).withRequiredArg().ofType( File.class ).required(); + OptionSpec outputFlag = parser.acceptsAll( Arrays.asList( "o", "output" ) ).withRequiredArg().ofType( File.class ).required(); + + OptionSet options = parser.parse( args ); + + File input = options.valueOf( inputFlag ); + File output = options.valueOf( outputFlag ); + + if ( input.isDirectory() ) + { + if ( !output.isDirectory() ) + { + System.err.println( "If input directory specified, output directory required too" ); + return; + } + + for ( File in : input.listFiles() ) + { + if ( in.getName().endsWith( ".jar" ) ) + { + convert( in, new File( output, in.getName() ) ); + } + } + } else + { + convert( input, output ); + } + } + + private static void convert(File in, File out) + { + System.out.println( "Attempting to convert " + in + " to " + out ); + + try + { + try ( JarFile inJar = new JarFile( in, false ) ) + { + JarEntry entry = inJar.getJarEntry( ".commodore" ); + if ( entry != null ) + { + return; + } + + try ( JarOutputStream outJar = new JarOutputStream( new FileOutputStream( out ) ) ) + { + for ( Enumeration entries = inJar.entries(); entries.hasMoreElements(); ) + { + entry = entries.nextElement(); + + try ( InputStream is = inJar.getInputStream( entry ) ) + { + byte[] b = ByteStreams.toByteArray( is ); + + if ( entry.getName().endsWith( ".class" ) ) + { + b = convert( b, false ); + entry = new JarEntry( entry.getName() ); + } + + outJar.putNextEntry( entry ); + outJar.write( b ); + } + } + + outJar.putNextEntry( new ZipEntry( ".commodore" ) ); + } + } + } catch ( Exception ex ) + { + System.err.println( "Fatal error trying to convert " + in ); + ex.printStackTrace(); + } + } + + public static byte[] convert(byte[] b, final boolean modern) + { + ClassReader cr = new ClassReader( b ); + ClassWriter cw = new ClassWriter( cr, 0 ); + + cr.accept( new ClassVisitor( Opcodes.ASM6, cw ) + { + @Override + public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) + { + return new MethodVisitor( api, super.visitMethod( access, name, desc, signature, exceptions ) ) + { + + @Override + public void visitFieldInsn(int opcode, String owner, String name, String desc) + { + if ( modern ) + { + super.visitFieldInsn( opcode, owner, name, desc ); + return; + } + + if ( owner.equals( "org/bukkit/Material" ) ) + { + try + { + Material.valueOf( "LEGACY_" + name ); + } catch ( IllegalArgumentException ex ) + { + throw new AuthorNagException( "No legacy enum constant for " + name + ". Did you forget to define api-version: 1.13 in your plugin.yml?" ); + } + + super.visitFieldInsn( opcode, owner, "LEGACY_" + name, desc ); + return; + } + + if ( owner.equals( "org/bukkit/Art" ) ) + { + switch ( name ) + { + case "BURNINGSKULL": + super.visitFieldInsn( opcode, owner, "BURNING_SKULL", desc ); + return; + case "DONKEYKONG": + super.visitFieldInsn( opcode, owner, "DONKEY_KONG", desc ); + return; + } + } + + if ( owner.equals( "org/bukkit/Particle" ) ) + { + switch ( name ) + { + case "BLOCK_CRACK": + case "BLOCK_DUST": + case "FALLING_DUST": + super.visitFieldInsn( opcode, owner, "LEGACY_" + name, desc ); + return; + } + } + + super.visitFieldInsn( opcode, owner, name, desc ); + } + + @Override + public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) + { + if ( modern ) + { + if ( owner.equals( "org/bukkit/Material" ) ) + { + switch ( name ) + { + case "values": + super.visitMethodInsn( opcode, "org/bukkit/craftbukkit/util/CraftLegacy", "modern_" + name, desc, itf ); + return; + } + } + + super.visitMethodInsn( opcode, owner, name, desc, itf ); + return; + } + + if ( owner.equals( "org/bukkit/ChunkSnapshot" ) && name.equals( "getBlockData" ) && desc.equals( "(III)I" ) ) + { + super.visitMethodInsn( opcode, owner, "getData", desc, itf ); + return; + } + + Type retType = Type.getReturnType( desc ); + + if ( EVIL.contains( owner + " " + desc + " " + name ) + || ( owner.startsWith( "org/bukkit/block/" ) && ( desc + " " + name ).equals( "()I getTypeId" ) ) + || ( owner.startsWith( "org/bukkit/block/" ) && ( desc + " " + name ).equals( "(I)Z setTypeId" ) ) ) + { + Type[] args = Type.getArgumentTypes( desc ); + Type[] newArgs = new Type[ args.length + 1 ]; + newArgs[0] = Type.getObjectType( owner ); + System.arraycopy( args, 0, newArgs, 1, args.length ); + + super.visitMethodInsn( Opcodes.INVOKESTATIC, "org/bukkit/craftbukkit/util/CraftEvil", name, Type.getMethodDescriptor( retType, newArgs ), false ); + return; + } + + if ( owner.equals( "org/bukkit/Material" ) ) + { + if ( name.equals( "getMaterial" ) && desc.equals( "(I)Lorg/bukkit/Material;" ) ) + { + super.visitMethodInsn( opcode, "org/bukkit/craftbukkit/util/CraftEvil", name, desc, itf ); + return; + } + + switch ( name ) + { + case "values": + case "valueOf": + case "getMaterial": + case "matchMaterial": + super.visitMethodInsn( opcode, "org/bukkit/craftbukkit/util/CraftLegacy", name, desc, itf ); + return; + case "ordinal": + super.visitMethodInsn( Opcodes.INVOKESTATIC, "org/bukkit/craftbukkit/util/CraftLegacy", "ordinal", "(Lorg/bukkit/Material;)I", false ); + return; + case "name": + case "toString": + super.visitMethodInsn( Opcodes.INVOKESTATIC, "org/bukkit/craftbukkit/util/CraftLegacy", name, "(Lorg/bukkit/Material;)Ljava/lang/String;", false ); + return; + } + } + + if ( retType.getSort() == Type.OBJECT && retType.getInternalName().equals( "org/bukkit/Material" ) && owner.startsWith( "org/bukkit" ) ) + { + super.visitMethodInsn( opcode, owner, name, desc, itf ); + super.visitMethodInsn( Opcodes.INVOKESTATIC, "org/bukkit/craftbukkit/util/CraftLegacy", "toLegacy", "(Lorg/bukkit/Material;)Lorg/bukkit/Material;", false ); + return; + } + + super.visitMethodInsn( opcode, owner, name, desc, itf ); + } + }; + } + }, 0 ); + + return cw.toByteArray(); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java index dbbed1be79..da2d070efa 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java @@ -138,22 +138,30 @@ public final class CraftChatMessage { } } + public static IChatBaseComponent fromStringOrNull(String message) { + return (message == null) ? null : fromString(message)[0]; + } + public static IChatBaseComponent[] fromString(String message) { return fromString(message, false); } - + public static IChatBaseComponent[] fromString(String message, boolean keepNewlines) { return new StringMessage(message, keepNewlines).getOutput(); } - + public static String fromComponent(IChatBaseComponent component) { return fromComponent(component, EnumChatFormat.BLACK); } + public static String toJSON(IChatBaseComponent component) { + return IChatBaseComponent.ChatSerializer.a(component); + } + public static String fromComponent(IChatBaseComponent component, EnumChatFormat defaultColor) { if (component == null) return ""; StringBuilder out = new StringBuilder(); - + for (IChatBaseComponent c : (Iterable) component) { ChatModifier modi = c.getChatModifier(); out.append(modi.getColor() == null ? defaultColor : modi.getColor()); @@ -185,7 +193,7 @@ public final class CraftChatMessage { private static IChatBaseComponent fixComponent(IChatBaseComponent component, Matcher matcher) { if (component instanceof ChatComponentText) { ChatComponentText text = ((ChatComponentText) component); - String msg = text.g(); + String msg = text.f(); if (matcher.reset(msg).find()) { matcher.reset(); @@ -236,7 +244,7 @@ public final class CraftChatMessage { } if (component instanceof ChatMessage) { - Object[] subs = ((ChatMessage) component).j(); + Object[] subs = ((ChatMessage) component).i(); for (int i = 0; i < subs.length; i++) { Object comp = subs[i]; if (comp instanceof IChatBaseComponent) { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftEvil.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftEvil.java new file mode 100644 index 0000000000..14fef6f41e --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftEvil.java @@ -0,0 +1,80 @@ +package org.bukkit.craftbukkit.util; + +import com.google.common.base.Preconditions; +import it.unimi.dsi.fastutil.ints.Int2ObjectLinkedOpenHashMap; +import it.unimi.dsi.fastutil.ints.Int2ObjectMap; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.World; +import org.bukkit.block.Block; +import org.bukkit.block.BlockState; +import org.bukkit.inventory.ItemStack; + +/** + * @deprecated do not use for any reason + */ +@Deprecated +public class CraftEvil { + + private static final Int2ObjectMap byId = new Int2ObjectLinkedOpenHashMap<>(); + + static { + for (Material material : Material.values()) { + Preconditions.checkState(!byId.containsKey(material.getId()), "Duplicate material ID for", material); + byId.put(material.getId(), material); + } + } + + public static int getBlockTypeIdAt(World world, int x, int y, int z) { + return getId(world.getBlockAt(x, y, z).getType()); + } + + public static int getBlockTypeIdAt(World world, Location location) { + return getId(world.getBlockAt(location).getType()); + } + + public static int getTypeId(Block block) { + return getId(block.getType()); + } + + public static boolean setTypeId(Block block, int type) { + block.setType(getMaterial(type)); + return true; + } + + public static boolean setTypeId(Block block, int type, boolean applyPhysics) { + block.setType(getMaterial(type), applyPhysics); + return true; + } + + public static boolean setTypeIdAndData(Block block, int type, byte data, boolean applyPhysics) { + block.setType(getMaterial(type), applyPhysics); + block.setData(data); + return true; + } + + public static int getTypeId(BlockState state) { + return getId(state.getType()); + } + + public static boolean setTypeId(BlockState state, int type) { + state.setType(getMaterial(type)); + return true; + } + + public static int getTypeId(ItemStack stack) { + return getId(stack.getType()); + } + + public static void setTypeId(ItemStack stack, int type) { + stack.setType(getMaterial(type)); + } + + public static Material getMaterial(int id) { + return byId.get(id); + } + + public static int getId(Material material) { + return CraftLegacy.toLegacy(material).getId(); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftLegacy.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftLegacy.java new file mode 100644 index 0000000000..5965e82c2b --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftLegacy.java @@ -0,0 +1,366 @@ +package org.bukkit.craftbukkit.util; + +import com.google.common.base.Preconditions; +import com.mojang.datafixers.Dynamic; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import net.minecraft.server.Block; +import net.minecraft.server.BlockStateList; +import net.minecraft.server.Blocks; +import net.minecraft.server.DataConverterFlattenData; +import net.minecraft.server.DataConverterMaterialId; +import net.minecraft.server.DataConverterRegistry; +import net.minecraft.server.DataConverterTypes; +import net.minecraft.server.DispenserRegistry; +import net.minecraft.server.DynamicOpsNBT; +import net.minecraft.server.IBlockData; +import net.minecraft.server.IBlockState; +import net.minecraft.server.Item; +import net.minecraft.server.MinecraftKey; +import net.minecraft.server.NBTBase; +import net.minecraft.server.NBTTagCompound; +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.material.MaterialData; + +/** + * This class may seem unnecessarily slow and complicated/repetitive however it + * is able to handle a lot more edge cases and invertible transformations (many + * of which are not immediately obvious) than any other alternative. If you do + * make changes to this class please make sure to contribute them back + * https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse so + * that all may benefit. + * + * @deprecated legacy use only + */ +@Deprecated +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 Map materialToItem = new HashMap<>(); + private static final Map itemToMaterial = new HashMap<>(); + private static final Map materialToData = new HashMap<>(); + private static final Map dataToMaterial = new HashMap<>(); + private static final Map materialToBlock = new HashMap<>(); + private static final Map blockToMaterial = new HashMap<>(); + + public static Material toLegacy(Material material) { + if (material == null || material.isLegacy()) { + return material; + } + + return toLegacyData(material).getItemType(); + } + + public static MaterialData toLegacyData(Material material) { + Preconditions.checkArgument(!material.isLegacy(), "toLegacy on legacy Material"); + MaterialData mappedData; + + if (material.isBlock()) { + Block block = CraftMagicNumbers.getBlock(material); + IBlockData blockData = block.getBlockData(); + + // Try exact match first + mappedData = dataToMaterial.get(blockData); + // Fallback to any block + if (mappedData == null) { + mappedData = blockToMaterial.get(block); + // Fallback to matching item + if (mappedData == null) { + mappedData = itemToMaterial.get(block.getItem()); + } + } + } else { + Item item = CraftMagicNumbers.getItem(material); + mappedData = itemToMaterial.get(item); + } + + return (mappedData == null) ? new MaterialData(Material.LEGACY_AIR) : mappedData; + } + + public static IBlockData fromLegacyData(Material material, Block block, byte data) { + Preconditions.checkArgument(material.isLegacy(), "fromLegacyData on modern Material"); + + MaterialData materialData = new MaterialData(material, data); + + // Try exact match first + IBlockData converted = materialToData.get(materialData); + if (converted != null) { + return converted; + } + + // Fallback to any block + Block convertedBlock = materialToBlock.get(materialData); + if (convertedBlock != null) { + return convertedBlock.getBlockData(); + } + + // Return existing block + return block.getBlockData(); + } + + public static Item fromLegacyData(Material material, Item item, short data) { + Preconditions.checkArgument(material.isLegacy(), "fromLegacyData on modern Material. Did you forget to define api-version: 1.13 in your plugin.yml?"); + + MaterialData materialData = new MaterialData(material, (byte) data); + + if (material.isBlock()) { + // Try exact match first + IBlockData converted = materialToData.get(materialData); + if (converted != null) { + return converted.getBlock().getItem(); + } + + // Fallback to any block + Block convertedBlock = materialToBlock.get(materialData); + if (convertedBlock != null) { + return convertedBlock.getItem(); + } + } + + // Fallback to matching item + Item convertedItem = materialToItem.get(materialData); + if (convertedItem != null) { + return convertedItem; + } + + // Return existing item + return item; + } + + public static byte toLegacyData(IBlockData blockData) { + MaterialData mappedData; + + // Try exact match first + mappedData = dataToMaterial.get(blockData); + // Fallback to any block + if (mappedData == null) { + mappedData = blockToMaterial.get(blockData.getBlock()); + } + + return (mappedData == null) ? 0 : mappedData.getData(); + } + + public static Material fromLegacy(Material material) { + return fromLegacy(new MaterialData(material)); + } + + public static Material fromLegacy(MaterialData materialData) { + Material material = materialData.getItemType(); + if (material == null || !material.isLegacy()) { + return material; + } + + Material mappedData = null; + + if (material.isBlock()) { + // Try exact match first + IBlockData iblock = materialToData.get(materialData); + if (iblock != null) { + mappedData = CraftMagicNumbers.getMaterial(iblock.getBlock()); + } + + // Fallback to any block + if (mappedData == null) { + Block block = materialToBlock.get(materialData); + if (block != null) { + mappedData = CraftMagicNumbers.getMaterial(block); + } + } + } + + // Fallback to matching item + if (mappedData == null) { + Item item = materialToItem.get(materialData); + if (item != null) { + mappedData = CraftMagicNumbers.getMaterial(item); + } + } + + return (mappedData == null) ? Material.AIR : mappedData; + } + + public static Material[] values() { + Material[] values = Material.values(); + return Arrays.copyOfRange(values, Material.LEGACY_AIR.ordinal(), values.length); + } + + public static Material valueOf(String name) { + return (name.startsWith(Material.LEGACY_PREFIX)) ? Material.valueOf(name) : Material.valueOf(Material.LEGACY_PREFIX + name); + } + + public static Material getMaterial(String name) { + return (name.startsWith(Material.LEGACY_PREFIX)) ? Material.getMaterial(name) : Material.getMaterial(Material.LEGACY_PREFIX + name); + } + + public static Material matchMaterial(String name) { + return (name.startsWith(Material.LEGACY_PREFIX)) ? Material.matchMaterial(name) : Material.matchMaterial(Material.LEGACY_PREFIX + name); + } + + public static int ordinal(Material material) { + Preconditions.checkArgument(material.isLegacy(), "ordinal on modern Material"); + + return material.ordinal() - Material.LEGACY_AIR.ordinal(); + } + + public static String name(Material material) { + return material.name().substring(Material.LEGACY_PREFIX.length()); + } + + public static String toString(Material material) { + return name(material); + } + + public static Material[] modern_values() { + Material[] values = Material.values(); + return Arrays.copyOfRange(values, 0, Material.LEGACY_AIR.ordinal()); + } + + static { + SPAWN_EGGS.put(EntityType.BAT, Material.BAT_SPAWN_EGG); + SPAWN_EGGS.put(EntityType.BLAZE, Material.BLAZE_SPAWN_EGG); + SPAWN_EGGS.put(EntityType.CAVE_SPIDER, Material.CAVE_SPIDER_SPAWN_EGG); + SPAWN_EGGS.put(EntityType.CHICKEN, Material.CHICKEN_SPAWN_EGG); + SPAWN_EGGS.put(EntityType.COW, Material.COW_SPAWN_EGG); + SPAWN_EGGS.put(EntityType.CREEPER, Material.CREEPER_SPAWN_EGG); + SPAWN_EGGS.put(EntityType.ENDERMAN, Material.ENDERMAN_SPAWN_EGG); + SPAWN_EGGS.put(EntityType.ENDERMITE, Material.ENDERMITE_SPAWN_EGG); + SPAWN_EGGS.put(EntityType.GHAST, Material.GHAST_SPAWN_EGG); + SPAWN_EGGS.put(EntityType.GUARDIAN, Material.GUARDIAN_SPAWN_EGG); + SPAWN_EGGS.put(EntityType.HORSE, Material.HORSE_SPAWN_EGG); + SPAWN_EGGS.put(EntityType.MAGMA_CUBE, Material.MAGMA_CUBE_SPAWN_EGG); + SPAWN_EGGS.put(EntityType.MUSHROOM_COW, Material.MOOSHROOM_SPAWN_EGG); + SPAWN_EGGS.put(EntityType.OCELOT, Material.OCELOT_SPAWN_EGG); + SPAWN_EGGS.put(EntityType.PIG, Material.PIG_SPAWN_EGG); + SPAWN_EGGS.put(EntityType.RABBIT, Material.RABBIT_SPAWN_EGG); + SPAWN_EGGS.put(EntityType.SHEEP, Material.SHEEP_SPAWN_EGG); + SPAWN_EGGS.put(EntityType.SHULKER, Material.SHULKER_SPAWN_EGG); + SPAWN_EGGS.put(EntityType.SILVERFISH, Material.SILVERFISH_SPAWN_EGG); + SPAWN_EGGS.put(EntityType.SKELETON, Material.SKELETON_SPAWN_EGG); + SPAWN_EGGS.put(EntityType.SLIME, Material.SLIME_SPAWN_EGG); + SPAWN_EGGS.put(EntityType.SPIDER, Material.SPIDER_SPAWN_EGG); + SPAWN_EGGS.put(EntityType.SQUID, Material.SQUID_SPAWN_EGG); + SPAWN_EGGS.put(EntityType.VILLAGER, Material.VILLAGER_SPAWN_EGG); + SPAWN_EGGS.put(EntityType.WITCH, Material.WITCH_SPAWN_EGG); + SPAWN_EGGS.put(EntityType.WOLF, Material.WOLF_SPAWN_EGG); + SPAWN_EGGS.put(EntityType.PIG_ZOMBIE, Material.ZOMBIE_PIGMAN_SPAWN_EGG); + SPAWN_EGGS.put(EntityType.ZOMBIE, Material.ZOMBIE_SPAWN_EGG); + + DispenserRegistry.c(); + + for (Material material : Material.values()) { + if (!material.isLegacy()) { + continue; + } + + // Handle blocks + if (material.isBlock()) { + for (byte data = 0; data < 16; data++) { + 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%%")) { + continue; + } + + String name = blockTag.getString("Name"); + // TODO: need to fix + if (name.equals("minecraft:portal")) { + name = "minecraft:nether_portal"; + } + + Block block = Block.REGISTRY.get(new MinecraftKey(name)); + IBlockData blockData = block.getBlockData(); + BlockStateList states = block.getStates(); + + Optional propMap = blockTag.get("Properties"); + if (propMap.isPresent()) { + NBTTagCompound properties = (NBTTagCompound) propMap.get().getValue(); + for (String dataKey : properties.getKeys()) { + IBlockState state = states.a(dataKey); + + if (state == null) { + if (whitelistedStates.contains(dataKey)) { + continue; + } + throw new IllegalStateException("No state for " + dataKey); + } + + Preconditions.checkState(!properties.getString(dataKey).isEmpty(), "Empty data string"); + Optional opt = state.b(properties.getString(dataKey)); + + blockData = blockData.set(state, (Comparable) opt.get()); + } + } + + if (block == Blocks.AIR) { + continue; + } + + materialToData.put(matData, blockData); + if (!dataToMaterial.containsKey(blockData)) { + dataToMaterial.put(blockData, matData); + } + + materialToBlock.put(matData, block); + if (!blockToMaterial.containsKey(block)) { + blockToMaterial.put(block, matData); + } + } + } + + // Handle items (and second fallback for blocks) + int maxData = material.getMaxDurability() == 0 ? 16 : 1; + // Manually do oldold spawn eggs + if (material == Material.LEGACY_MONSTER_EGG) { + maxData = 121; // Vilager + 1 + } + + for (byte data = 0; data < maxData; data++) { + // Manually skip invalid oldold spawn + if (material == Material.LEGACY_MONSTER_EGG /*&& data != 0 && EntityType.fromId(data) == null*/) { // Mojang broke 18w19b + continue; + } + // Skip non item stacks for now (18w19b) + if (DataConverterMaterialId.a(material.getId()) == null) { + continue; + } + + MaterialData matData = new MaterialData(material, data); + + NBTTagCompound stack = new NBTTagCompound(); + stack.setInt("id", material.getId()); + stack.setShort("Damage", data); + + Dynamic converted = DataConverterRegistry.a().update(DataConverterTypes.ITEM_STACK, new Dynamic(DynamicOpsNBT.a, stack), -1, CraftMagicNumbers.DATA_VERSION); + + String newId = converted.getString("id"); + // Recover spawn eggs with invalid data + if (newId.equals("minecraft:spawn_egg")) { + newId = "minecraft:pig_spawn_egg"; + } + + // Preconditions.checkState(newId.contains("minecraft:"), "Unknown new material for " + matData); + Item newMaterial = Item.REGISTRY.get(new MinecraftKey(newId)); + + materialToItem.put(matData, newMaterial); + if (!itemToMaterial.containsKey(newMaterial)) { + itemToMaterial.put(newMaterial, matData); + } + } + + for (Map.Entry entry : SPAWN_EGGS.entrySet()) { + MaterialData matData = new MaterialData(Material.LEGACY_MONSTER_EGG, (byte) entry.getKey().getTypeId()); + Item newMaterial = CraftMagicNumbers.getItem(entry.getValue()); + + materialToItem.put(matData, newMaterial); + itemToMaterial.put(newMaterial, matData); + } + } + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java index a1be7ec490..fbdfdc47dc 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java @@ -1,43 +1,41 @@ package org.bukkit.craftbukkit.util; import com.google.common.base.Charsets; -import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.io.Files; +import com.mojang.brigadier.exceptions.CommandSyntaxException; import java.io.File; import java.io.IOException; -import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Set; +import java.util.Locale; +import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; -import net.minecraft.server.AdvancementDataWorld; +import net.minecraft.server.AdvancementDataWorld; import net.minecraft.server.Block; -import net.minecraft.server.Blocks; import net.minecraft.server.ChatDeserializer; +import net.minecraft.server.IBlockData; import net.minecraft.server.Item; import net.minecraft.server.MinecraftKey; import net.minecraft.server.MinecraftServer; -import net.minecraft.server.MojangsonParseException; import net.minecraft.server.MojangsonParser; import net.minecraft.server.NBTTagCompound; -import net.minecraft.server.StatisticList; -import org.bukkit.Achievement; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.NamespacedKey; -import org.bukkit.Statistic; import org.bukkit.UnsafeValues; import org.bukkit.advancement.Advancement; -import org.bukkit.craftbukkit.CraftStatistic; +import org.bukkit.block.data.BlockData; +import org.bukkit.craftbukkit.block.data.CraftBlockData; import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.inventory.ItemStack; -import org.bukkit.util.StringUtil; +import org.bukkit.material.MaterialData; +import org.bukkit.plugin.PluginAwareness; +import org.bukkit.plugin.PluginDescriptionFile; +import org.bukkit.plugin.UnknownDependencyException; @SuppressWarnings("deprecation") public final class CraftMagicNumbers implements UnsafeValues { @@ -45,81 +43,106 @@ public final class CraftMagicNumbers implements UnsafeValues { private CraftMagicNumbers() {} - public static Block getBlock(org.bukkit.block.Block block) { - return getBlock(block.getType()); + public static IBlockData getBlock(MaterialData material) { + return getBlock(material.getItemType(), material.getData()); } - @Deprecated - // A bad method for bad magic. - public static Block getBlock(int id) { - return getBlock(Material.getMaterial(id)); + public static IBlockData getBlock(Material material, byte data) { + return CraftLegacy.fromLegacyData(CraftLegacy.toLegacy(material), getBlock(material), data); } - @Deprecated - // A bad method for bad magic. - public static int getId(Block block) { - return Block.getId(block); + public static MaterialData getMaterial(IBlockData data) { + return CraftLegacy.toLegacy(getMaterial(data.getBlock())).getNewData(toLegacyData(data)); + } + + public static Item getItem(Material material, short data) { + if (material.isLegacy()) { + return CraftLegacy.fromLegacyData(CraftLegacy.toLegacy(material), getItem(material), data); + } + + return getItem(material); + } + + public static MaterialData getMaterialData(Item item) { + return CraftLegacy.toLegacyData(getMaterial(item)); + } + + // ======================================================================== + private static final Map BLOCK_MATERIAL = new HashMap<>(); + private static final Map ITEM_MATERIAL = new HashMap<>(); + private static final Map MATERIAL_ITEM = new HashMap<>(); + private static final Map MATERIAL_BLOCK = new HashMap<>(); + + static { + for (Block block : (Iterable) Block.REGISTRY) { // Eclipse fail + BLOCK_MATERIAL.put(block, Material.getMaterial(Block.REGISTRY.b(block).getKey().toUpperCase(Locale.ROOT))); + } + + for (Item item : (Iterable) Item.REGISTRY) { // Eclipse fail + ITEM_MATERIAL.put(item, Material.getMaterial(Item.REGISTRY.b(item).getKey().toUpperCase(Locale.ROOT))); + } + + for (Material material : Material.values()) { + MinecraftKey key = key(material); + MATERIAL_ITEM.put(material, Item.REGISTRY.get(key)); + MATERIAL_BLOCK.put(material, Block.REGISTRY.get(key)); + } } public static Material getMaterial(Block block) { - return Material.getMaterial(Block.getId(block)); - } - - public static Item getItem(Material material) { - // TODO: Don't use ID - Item item = Item.getById(material.getId()); - return item; - } - - @Deprecated - // A bad method for bad magic. - public static Item getItem(int id) { - return Item.getById(id); - } - - @Deprecated - // A bad method for bad magic. - public static int getId(Item item) { - return Item.getId(item); + return BLOCK_MATERIAL.get(block); } public static Material getMaterial(Item item) { - // TODO: Don't use ID - Material material = Material.getMaterial(Item.getId(item)); + return ITEM_MATERIAL.getOrDefault(item, Material.AIR); + } - if (material == null) { - return Material.AIR; - } - - return material; + public static Item getItem(Material material) { + return MATERIAL_ITEM.get(material); } public static Block getBlock(Material material) { - if (material == null) { - return null; - } - // TODO: Don't use ID - Block block = Block.getById(material.getId()); + return MATERIAL_BLOCK.get(material); + } - if (block == null) { - return Blocks.AIR; + public static MinecraftKey key(Material mat) { + if (mat.isLegacy()) { + mat = CraftLegacy.fromLegacy(mat); } - return block; + return CraftNamespacedKey.toMinecraft(mat.getKey()); + } + // ======================================================================== + + public static byte toLegacyData(IBlockData data) { + return CraftLegacy.toLegacyData(data); } @Override - public Material getMaterialFromInternalName(String name) { - return getMaterial((Item) Item.REGISTRY.get(new MinecraftKey(name))); + public Material toLegacy(Material material) { + return CraftLegacy.toLegacy(material); } @Override - public List tabCompleteInternalMaterialName(String token, List completions) { - ArrayList results = Lists.newArrayList(); - for (MinecraftKey key : (Set)Item.REGISTRY.keySet()) { - results.add(key.toString()); - } - return StringUtil.copyPartialMatches(token, results, completions); + public Material fromLegacy(Material material) { + return CraftLegacy.fromLegacy(material); + } + + @Override + public Material fromLegacy(MaterialData material) { + return CraftLegacy.fromLegacy(material); + } + + @Override + public BlockData fromLegacy(Material material, byte data) { + return CraftBlockData.fromData(getBlock(material, data)); + } + + public static final int DATA_VERSION = 1513; + + @Override + public int getDataVersion() { + return DATA_VERSION; } @Override @@ -128,7 +151,7 @@ public final class CraftMagicNumbers implements UnsafeValues { try { nmsStack.setTag((NBTTagCompound) MojangsonParser.parse(arguments)); - } catch (MojangsonParseException ex) { + } catch (CommandSyntaxException ex) { Logger.getLogger(CraftMagicNumbers.class.getName()).log(Level.SEVERE, null, ex); } @@ -137,29 +160,6 @@ public final class CraftMagicNumbers implements UnsafeValues { return stack; } - @Override - public Statistic getStatisticFromInternalName(String name) { - return CraftStatistic.getBukkitStatisticByName(name); - } - - @Override - public Achievement getAchievementFromInternalName(String name) { - throw new UnsupportedOperationException("Not supported in this Minecraft version."); - } - - @Override - public List tabCompleteInternalStatisticOrAchievementName(String token, List completions) { - List matches = new ArrayList(); - Iterator iterator = StatisticList.stats.iterator(); - while (iterator.hasNext()) { - String statistic = ((net.minecraft.server.Statistic) iterator.next()).name; - if (statistic.startsWith(token)) { - matches.add(statistic); - } - } - return matches; - } - @Override public Advancement loadAdvancement(NamespacedKey key, String advancement) { if (Bukkit.getAdvancement(key) != null) { @@ -172,7 +172,7 @@ public final class CraftMagicNumbers implements UnsafeValues { Advancement bukkit = Bukkit.getAdvancement(key); if (bukkit != null) { - File file = new File(MinecraftServer.getServer().getAdvancementData().folder, key.getNamespace() + File.separator + key.getKey() + ".json"); + File file = new File(MinecraftServer.getServer().bukkitDataPackFolder, "data" + File.separator + key.getNamespace() + File.separator + "advancements" + File.separator + key.getKey() + ".json"); file.getParentFile().mkdirs(); try { @@ -192,10 +192,34 @@ public final class CraftMagicNumbers implements UnsafeValues { @Override public boolean removeAdvancement(NamespacedKey key) { - File file = new File(MinecraftServer.getServer().getAdvancementData().folder, key.getNamespace() + File.separator + key.getKey() + ".json"); + File file = new File(MinecraftServer.getServer().bukkitDataPackFolder, "data" + File.separator + key.getNamespace() + File.separator + "advancements" + File.separator + key.getKey() + ".json"); return file.delete(); } + @Override + public void checkSupported(PluginDescriptionFile pdf) { + if (pdf.getAPIVersion() != null) { + if (!pdf.getAPIVersion().equals("1.13")) { + throw new UnknownDependencyException("Unsupported API version " + pdf.getAPIVersion()); + } + } + } + + public static boolean isLegacy(PluginDescriptionFile pdf) { + return pdf.getAPIVersion() == null; + } + + @Override + public byte[] processClass(PluginDescriptionFile pdf, byte[] clazz) { + try { + clazz = Commodore.convert(clazz, !isLegacy(pdf)); + } catch (Exception ex) { + Bukkit.getLogger().log(Level.SEVERE, "Fatal error trying to convert " + pdf.getFullName(), ex); + } + + return clazz; + } + /** * This helper class represents the different NBT Tags. *

    diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java new file mode 100644 index 0000000000..1833ee7299 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java @@ -0,0 +1,254 @@ +package org.bukkit.craftbukkit.util; + +import java.util.List; +import java.util.Random; +import java.util.function.Function; +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.DifficultyDamageScaler; +import net.minecraft.server.Entity; +import net.minecraft.server.EntityHuman; +import net.minecraft.server.EnumDirection; +import net.minecraft.server.EnumSkyBlock; +import net.minecraft.server.Fluid; +import net.minecraft.server.FluidType; +import net.minecraft.server.GeneratorAccess; +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.PersistentBase; +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 { + + public static final GeneratorAccess INSTANCE = new DummyGeneratorAccess(); + + private DummyGeneratorAccess() { + } + + @Override + public long getSeed() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public TickList I() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public TickList H() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public IChunkAccess c(int i, int i1) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public World getMinecraftWorld() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public WorldData getWorldData() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public DifficultyDamageScaler getDamageScaler(BlockPosition bp) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public T a(Function fnctn, String string) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public PersistentCollection s_() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void a(String string, PersistentBase pb) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public IChunkProvider getChunkProvider() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public IDataManager getDataManager() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Random m() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void update(BlockPosition bp, Block block) { + 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."); + } + + @Override + public void addParticle(ParticleParam pp, double d, double d1, double d2, double d3, double d4, double d5) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean isEmpty(BlockPosition bp) { + 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."); + } + + @Override + public int getLightLevel(BlockPosition bp, int i) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean isChunkLoaded(int i, int i1, boolean bln) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean e(BlockPosition bp) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int a(HeightMap.Type type, int i, int i1) { + 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."); + } + + @Override + public WorldBorder getWorldBorder() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean a(Entity entity, VoxelShape vs) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public List getEntities(Entity entity, AxisAlignedBB aabb) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int a(BlockPosition bp, EnumDirection ed) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean e() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getSeaLevel() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public WorldProvider o() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public TileEntity getTileEntity(BlockPosition bp) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public IBlockData getType(BlockPosition bp) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Fluid b(BlockPosition bp) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean setTypeAndData(BlockPosition blockposition, IBlockData iblockdata, int i) { + return false; + } + + @Override + public boolean addEntity(Entity entity) { + 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) { + throw new UnsupportedOperationException("Not supported yet."); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/StructureGrowDelegate.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/StructureGrowDelegate.java deleted file mode 100644 index f9cc7d6f6b..0000000000 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/StructureGrowDelegate.java +++ /dev/null @@ -1,70 +0,0 @@ -package org.bukkit.craftbukkit.util; - -import java.util.ArrayList; -import java.util.List; - -import net.minecraft.server.Block; -import net.minecraft.server.Blocks; -import net.minecraft.server.World; - -import org.bukkit.BlockChangeDelegate; -import org.bukkit.block.BlockState; -import org.bukkit.craftbukkit.CraftWorld; -import org.bukkit.material.MaterialData; - -public class StructureGrowDelegate implements BlockChangeDelegate { - private final CraftWorld world; - private final List blocks = new ArrayList(); - - public StructureGrowDelegate(World world) { - this.world = world.getWorld(); - } - - public boolean setRawTypeId(int x, int y, int z, int type) { - return setRawTypeIdAndData(x, y, z, type, 0); - } - - public boolean setRawTypeIdAndData(int x, int y, int z, int type, int data) { - BlockState state = world.getBlockAt(x, y, z).getState(); - state.setTypeId(type); - state.setData(new MaterialData(type, (byte) data)); - blocks.add(state); - return true; - } - - public boolean setTypeId(int x, int y, int z, int typeId) { - return setRawTypeId(x, y, z, typeId); - } - - public boolean setTypeIdAndData(int x, int y, int z, int typeId, int data) { - return setRawTypeIdAndData(x, y, z, typeId, data); - } - - public int getTypeId(int x, int y, int z) { - for (BlockState state : blocks) { - if (state.getX() == x && state.getY() == y && state.getZ() == z) { - return state.getTypeId(); - } - } - - return world.getBlockTypeIdAt(x, y, z); - } - - public int getHeight() { - return world.getMaxHeight(); - } - - public List getBlocks() { - return blocks; - } - - public boolean isEmpty(int x, int y, int z) { - for (BlockState state : blocks) { - if (state.getX() == x && state.getY() == y && state.getZ() == z) { - return Block.getById(state.getTypeId()) == Blocks.AIR; - } - } - - return world.getBlockAt(x, y, z).isEmpty(); - } -} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/permissions/CommandPermissions.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/permissions/CommandPermissions.java index 39ef2ef980..c928c2b67f 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/permissions/CommandPermissions.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/permissions/CommandPermissions.java @@ -15,7 +15,7 @@ public final class CommandPermissions { DefaultPermissions.registerPermission(PREFIX + "kill", "Allows the user to commit suicide", PermissionDefault.OP, commands); DefaultPermissions.registerPermission(PREFIX + "me", "Allows the user to perform a chat action", PermissionDefault.TRUE, commands); - DefaultPermissions.registerPermission(PREFIX + "tell", "Allows the user to privately message another player", PermissionDefault.TRUE, commands); + DefaultPermissions.registerPermission(PREFIX + "msg", "Allows the user to privately message another player", PermissionDefault.TRUE, commands); DefaultPermissions.registerPermission(PREFIX + "say", "Allows the user to talk as the console", PermissionDefault.OP, commands); DefaultPermissions.registerPermission(PREFIX + "give", "Allows the user to give items to players", PermissionDefault.OP, commands); DefaultPermissions.registerPermission(PREFIX + "teleport", "Allows the user to teleport players", PermissionDefault.OP, commands); diff --git a/paper-server/src/test/java/org/bukkit/ArtTest.java b/paper-server/src/test/java/org/bukkit/ArtTest.java index 7f40288922..29d14d4b62 100644 --- a/paper-server/src/test/java/org/bukkit/ArtTest.java +++ b/paper-server/src/test/java/org/bukkit/ArtTest.java @@ -5,10 +5,12 @@ import static org.hamcrest.Matchers.*; import java.util.Collections; import java.util.EnumMap; +import java.util.HashMap; import java.util.List; import java.util.Map; -import net.minecraft.server.EntityPainting.EnumArt; +import net.minecraft.server.MinecraftKey; +import net.minecraft.server.Paintings; import org.bukkit.craftbukkit.CraftArt; import org.junit.Test; @@ -22,15 +24,15 @@ public class ArtTest { public void verifyMapping() { List arts = Lists.newArrayList(Art.values()); - for (EnumArt enumArt : EnumArt.values()) { - int id = enumArt.ordinal(); - String name = enumArt.B; - int width = enumArt.C / UNIT_MULTIPLIER; - int height = enumArt.D / UNIT_MULTIPLIER; + for (MinecraftKey key : Paintings.a.keySet()) { + Paintings enumArt = Paintings.a.get(key); + String name = key.getKey(); + int width = enumArt.b() / UNIT_MULTIPLIER; + int height = enumArt.c() / UNIT_MULTIPLIER; - Art subject = Art.getById(id); + Art subject = CraftArt.NotchToBukkit(enumArt); - String message = String.format("org.bukkit.Art is missing id: %d named: '%s'", id, name); + String message = String.format("org.bukkit.Art is missing '%s'", name); assertNotNull(message, subject); assertThat(Art.getByName(name), is(subject)); @@ -45,9 +47,9 @@ public class ArtTest { @Test public void testCraftArtToNotch() { - Map cache = new EnumMap(EnumArt.class); + Map cache = new HashMap<>(); for (Art art : Art.values()) { - EnumArt enumArt = CraftArt.BukkitToNotch(art); + Paintings enumArt = CraftArt.BukkitToNotch(art); assertNotNull(art.name(), enumArt); assertThat(art.name(), cache.put(enumArt, art), is(nullValue())); } @@ -55,11 +57,11 @@ public class ArtTest { @Test public void testCraftArtToBukkit() { - Map cache = new EnumMap(Art.class); - for (EnumArt enumArt : EnumArt.values()) { + Map cache = new EnumMap(Art.class); + for (Paintings enumArt : (Iterable) Paintings.a) { // Eclipse fail Art art = CraftArt.NotchToBukkit(enumArt); - assertNotNull(enumArt.name(), art); - assertThat(enumArt.name(), cache.put(art, enumArt), is(nullValue())); + assertNotNull("Could not CraftArt.NotchToBukkit " + enumArt, art); + assertThat("Duplicate artwork " + enumArt, cache.put(art, enumArt), is(nullValue())); } } } diff --git a/paper-server/src/test/java/org/bukkit/BlockDataTest.java b/paper-server/src/test/java/org/bukkit/BlockDataTest.java new file mode 100644 index 0000000000..a5cea50bec --- /dev/null +++ b/paper-server/src/test/java/org/bukkit/BlockDataTest.java @@ -0,0 +1,58 @@ +package org.bukkit; + +import net.minecraft.server.BlockCake; +import net.minecraft.server.Blocks; +import org.bukkit.block.data.BlockData; +import org.bukkit.block.data.type.Cake; +import org.bukkit.craftbukkit.block.data.CraftBlockData; +import org.bukkit.support.AbstractTestingBase; +import static org.hamcrest.Matchers.*; +import org.junit.Assert; +import org.junit.Test; + +public class BlockDataTest extends AbstractTestingBase { + + @Test + public void testParsing() { + BlockData cakeTest = CraftBlockData.fromData(Blocks.CAKE.getBlockData().set(BlockCake.BITES, 3)); + + BlockData materialString = CraftBlockData.newData(Material.CAKE, "[bites=3]"); + Assert.assertThat(materialString, is(cakeTest)); + + BlockData combined = CraftBlockData.newData(null, "cake[bites=3]"); + Assert.assertThat(combined, is(cakeTest)); + + BlockData combinedMinecraft = CraftBlockData.newData(null, "minecraft:cake[bites=3]"); + Assert.assertThat(combinedMinecraft, is(cakeTest)); + + BlockData inverted = CraftBlockData.newData(null, cakeTest.getAsString()); + Assert.assertThat(inverted, is(cakeTest)); + } + + @Test(expected = IllegalArgumentException.class) + public void testBadMaterial() { + CraftBlockData.newData(null, "invalid"); + } + + @Test(expected = IllegalArgumentException.class) + public void testBadSyntax() { + CraftBlockData.newData(null, "minecraft:cake[bites=3"); + } + + @Test(expected = IllegalArgumentException.class) + public void testDoubleMaterial() { + CraftBlockData.newData(Material.CAKE, "minecraft:cake[bites=3]"); + } + + @Test + public void testClone() { + Cake cakeTest = (Cake) CraftBlockData.fromData(Blocks.CAKE.getBlockData().set(BlockCake.BITES, 3)); + Cake clone = (Cake) cakeTest.clone(); + + Assert.assertFalse("Clone did not return new object", cakeTest == clone); + Assert.assertThat("Clone is not equal", clone, is(cakeTest)); + + clone.setBites(1); + Assert.assertThat("Clone is not actually clone", clone, is(not(cakeTest))); + } +} diff --git a/paper-server/src/test/java/org/bukkit/DyeColorsTest.java b/paper-server/src/test/java/org/bukkit/DyeColorsTest.java index 020714da68..45a5caed2b 100644 --- a/paper-server/src/test/java/org/bukkit/DyeColorsTest.java +++ b/paper-server/src/test/java/org/bukkit/DyeColorsTest.java @@ -7,7 +7,6 @@ import java.util.ArrayList; import java.util.List; import net.minecraft.server.EnumColor; -import net.minecraft.server.ItemDye; import org.bukkit.support.AbstractTestingBase; import org.junit.Test; @@ -33,7 +32,7 @@ public class DyeColorsTest extends AbstractTestingBase { @Test public void checkColor() { Color color = dye.getColor(); - float[] nmsColorArray = EnumColor.fromColorIndex(dye.getWoolData()).f(); + float[] nmsColorArray = EnumColor.fromColorIndex(dye.getWoolData()).d(); Color nmsColor = Color.fromRGB((int) (nmsColorArray[0] * 255), (int) (nmsColorArray[1] * 255), (int) (nmsColorArray[2] * 255)); assertThat(color, is(nmsColor)); } @@ -41,7 +40,7 @@ public class DyeColorsTest extends AbstractTestingBase { @Test public void checkFireworkColor() { Color color = dye.getFireworkColor(); - int nmsColor = ItemDye.a[dye.getDyeData()]; + int nmsColor = EnumColor.fromColorIndex(dye.getWoolData()).f(); assertThat(color, is(Color.fromRGB(nmsColor))); } } diff --git a/paper-server/src/test/java/org/bukkit/EnchantmentTest.java b/paper-server/src/test/java/org/bukkit/EnchantmentTest.java new file mode 100644 index 0000000000..86bfbb45a4 --- /dev/null +++ b/paper-server/src/test/java/org/bukkit/EnchantmentTest.java @@ -0,0 +1,24 @@ +package org.bukkit; + +import net.minecraft.server.MinecraftKey; +import org.bukkit.craftbukkit.util.CraftNamespacedKey; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.support.AbstractTestingBase; +import org.junit.Assert; +import org.junit.Test; + +public class EnchantmentTest extends AbstractTestingBase { + + @Test + public void verifyMapping() { + for (MinecraftKey key : net.minecraft.server.Enchantment.enchantments.keySet()) { + net.minecraft.server.Enchantment nms = net.minecraft.server.Enchantment.enchantments.get(key); + + Enchantment bukkitById = Enchantment.getByKey(CraftNamespacedKey.fromMinecraft(key)); + + Assert.assertFalse("Unknown enchant name for " + key, bukkitById.getName().startsWith("UNKNOWN")); + + Assert.assertNotNull("Unknown target for " + key, bukkitById.getItemTarget()); + } + } +} diff --git a/paper-server/src/test/java/org/bukkit/LegacyTest.java b/paper-server/src/test/java/org/bukkit/LegacyTest.java new file mode 100644 index 0000000000..543e75815d --- /dev/null +++ b/paper-server/src/test/java/org/bukkit/LegacyTest.java @@ -0,0 +1,89 @@ +package org.bukkit; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; +import org.bukkit.craftbukkit.util.CraftLegacy; +import org.bukkit.material.MaterialData; +import org.bukkit.support.AbstractTestingBase; +import org.junit.Assert; +import org.junit.Test; + +public class LegacyTest extends AbstractTestingBase { + + private final Set INVALIDATED_MATERIALS = new HashSet<>(Arrays.asList(Material.ACACIA_BUTTON, Material.ACACIA_PRESSURE_PLATE, Material.ACACIA_TRAPDOOR, Material.AIR, Material.ATTACHED_MELON_STEM, Material.ATTACHED_PUMPKIN_STEM, + Material.BIRCH_BUTTON, Material.BIRCH_PRESSURE_PLATE, Material.BIRCH_TRAPDOOR, Material.BLACK_WALL_BANNER, Material.BLUE_WALL_BANNER, Material.BROWN_WALL_BANNER, Material.BUBBLE_COLUMN, Material.CAVE_AIR, Material.CREEPER_WALL_HEAD, + Material.CYAN_WALL_BANNER, Material.DARK_OAK_BUTTON, Material.DARK_OAK_PRESSURE_PLATE, Material.DARK_OAK_TRAPDOOR, Material.DARK_PRISMARINE_SLAB, Material.DARK_PRISMARINE_STAIRS, Material.DEBUG_STICK, Material.DONKEY_SPAWN_EGG, + Material.DRAGON_WALL_HEAD, Material.DRIED_KELP, Material.DRIED_KELP_BLOCK, Material.ELDER_GUARDIAN_SPAWN_EGG, Material.EVOKER_SPAWN_EGG, Material.GRAY_WALL_BANNER, Material.GREEN_WALL_BANNER, Material.HUSK_SPAWN_EGG, + Material.JUNGLE_BUTTON, Material.JUNGLE_PRESSURE_PLATE, Material.JUNGLE_TRAPDOOR, Material.KELP, Material.KELP_PLANT, Material.LIGHT_BLUE_WALL_BANNER, Material.LIGHT_GRAY_WALL_BANNER, Material.LIME_WALL_BANNER, Material.LLAMA_SPAWN_EGG, + Material.MAGENTA_WALL_BANNER, Material.MULE_SPAWN_EGG, Material.ORANGE_WALL_BANNER, Material.PARROT_SPAWN_EGG, Material.PHANTOM_SPAWN_EGG, Material.PINK_WALL_BANNER, Material.PLAYER_WALL_HEAD, Material.POLAR_BEAR_SPAWN_EGG, + Material.POTTED_ACACIA_SAPLING, Material.POTTED_ALLIUM, Material.POTTED_AZURE_BLUET, Material.POTTED_BIRCH_SAPLING, Material.POTTED_BLUE_ORCHID, Material.POTTED_BROWN_MUSHROOM, Material.POTTED_DANDELION, Material.POTTED_DARK_OAK_SAPLING, + Material.POTTED_DEAD_BUSH, Material.POTTED_FERN, Material.POTTED_JUNGLE_SAPLING, Material.POTTED_OAK_SAPLING, Material.POTTED_ORANGE_TULIP, Material.POTTED_OXEYE_DAISY, Material.POTTED_PINK_TULIP, Material.POTTED_POPPY, + Material.POTTED_RED_MUSHROOM, Material.POTTED_RED_TULIP, Material.POTTED_SPRUCE_SAPLING, Material.POTTED_WHITE_TULIP, Material.PRISMARINE_BRICK_SLAB, Material.PRISMARINE_BRICK_STAIRS, Material.PRISMARINE_SLAB, Material.PRISMARINE_STAIRS, + Material.PUMPKIN, Material.PURPLE_WALL_BANNER, Material.RED_WALL_BANNER, Material.SEAGRASS, Material.SKELETON_HORSE_SPAWN_EGG, Material.SKELETON_WALL_SKULL, Material.SPRUCE_BUTTON, Material.SPRUCE_PRESSURE_PLATE, Material.SPRUCE_TRAPDOOR, + Material.STRAY_SPAWN_EGG, Material.STRIPPED_ACACIA_LOG, Material.STRIPPED_BIRCH_LOG, Material.STRIPPED_DARK_OAK_LOG, Material.STRIPPED_JUNGLE_LOG, Material.STRIPPED_OAK_LOG, Material.STRIPPED_SPRUCE_LOG, Material.TALL_SEAGRASS, + Material.TRIDENT, Material.TURTLE_EGG, Material.TURTLE_HELMET, Material.SCUTE, Material.TURTLE_SPAWN_EGG, Material.VEX_SPAWN_EGG, Material.VINDICATOR_SPAWN_EGG, Material.VOID_AIR, Material.WHITE_BED, + Material.WITHER_SKELETON_SPAWN_EGG, Material.WITHER_SKELETON_WALL_SKULL, Material.YELLOW_WALL_BANNER, Material.ZOMBIE_HORSE_SPAWN_EGG, Material.ZOMBIE_VILLAGER_SPAWN_EGG, Material.ZOMBIE_WALL_HEAD, + Material.COD_BUCKET, Material.COD_SPAWN_EGG, Material.PUFFERFISH_BUCKET, Material.PUFFERFISH_SPAWN_EGG, Material.SALMON_BUCKET, Material.SALMON_SPAWN_EGG, + Material.TROPICAL_FISH_BUCKET, Material.DROWNED_SPAWN_EGG, Material.SHULKER_BOX, Material.TROPICAL_FISH_SPAWN_EGG, + Material.BLUE_ICE, Material.BRAIN_CORAL, Material.BRAIN_CORAL_BLOCK, Material.BRAIN_CORAL_FAN, Material.BUBBLE_CORAL, Material.BUBBLE_CORAL_BLOCK, Material.BUBBLE_CORAL_FAN, Material.CONDUIT, Material.DEAD_BRAIN_CORAL_BLOCK, + Material.DEAD_BUBBLE_CORAL_BLOCK, Material.DEAD_FIRE_CORAL_BLOCK, Material.DEAD_HORN_CORAL_BLOCK, Material.DEAD_TUBE_CORAL_BLOCK, Material.DOLPHIN_SPAWN_EGG, Material.FIRE_CORAL, Material.FIRE_CORAL_BLOCK, Material.FIRE_CORAL_FAN, + Material.HEART_OF_THE_SEA, Material.HORN_CORAL, Material.HORN_CORAL_BLOCK, Material.HORN_CORAL_FAN, Material.NAUTILUS_SHELL, Material.PHANTOM_MEMBRANE, Material.SEA_PICKLE, Material.TUBE_CORAL, Material.TUBE_CORAL_BLOCK, + Material.TUBE_CORAL_FAN, Material.STRIPPED_ACACIA_WOOD, Material.STRIPPED_BIRCH_WOOD, Material.STRIPPED_DARK_OAK_WOOD, Material.STRIPPED_JUNGLE_WOOD, Material.STRIPPED_OAK_WOOD, Material.STRIPPED_SPRUCE_WOOD, + Material.ACACIA_WOOD, Material.BIRCH_WOOD, Material.DARK_OAK_WOOD, Material.JUNGLE_WOOD, Material.OAK_WOOD, Material.SPRUCE_WOOD, + // + 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)); + + private final Set INVERSION_FAILS = new HashSet<>(Arrays.asList(Material.LEGACY_DOUBLE_STEP, Material.LEGACY_GLOWING_REDSTONE_ORE, Material.LEGACY_DIODE_BLOCK_ON, Material.LEGACY_REDSTONE_LAMP_ON, Material.LEGACY_WOOD_DOUBLE_STEP, + Material.LEGACY_DAYLIGHT_DETECTOR_INVERTED, Material.LEGACY_DOUBLE_STONE_SLAB2, Material.LEGACY_PURPUR_DOUBLE_SLAB, Material.LEGACY_WHEAT, Material.LEGACY_SIGN, Material.LEGACY_WOOD_DOOR, Material.LEGACY_IRON_DOOR, Material.LEGACY_SUGAR_CANE, + Material.LEGACY_CAKE, Material.LEGACY_BED, Material.LEGACY_DIODE, Material.LEGACY_NETHER_STALK, Material.LEGACY_BREWING_STAND_ITEM, Material.LEGACY_CAULDRON_ITEM, Material.LEGACY_REDSTONE_COMPARATOR, Material.LEGACY_SPRUCE_DOOR_ITEM, + Material.LEGACY_BIRCH_DOOR_ITEM, Material.LEGACY_JUNGLE_DOOR_ITEM, Material.LEGACY_ACACIA_DOOR_ITEM, Material.LEGACY_DARK_OAK_DOOR_ITEM, Material.LEGACY_STATIONARY_LAVA, Material.LEGACY_STATIONARY_WATER)); + + @Test + public void toLegacyMaterial() { + for (Material material : Material.values()) { + if (!INVALIDATED_MATERIALS.contains(material) && !material.isLegacy()) { + MaterialData converted = CraftLegacy.toLegacyData(material); + + Assert.assertNotEquals("Could not toLegacy " + material, Material.LEGACY_AIR, converted.getItemType()); + + if (!INVALIDATED_MATERIALS.contains(converted.getItemType())) { + Assert.assertNotEquals("Could not fromLegacy(toLegacy) " + converted + "(" + material + ")", Material.AIR, CraftLegacy.fromLegacy(converted)); + } + if (!INVERSION_FAILS.contains(material)) { + Assert.assertEquals("Could not fromLegacy(toLegacy) " + converted + "(" + material + ")", material, CraftLegacy.fromLegacy(converted)); + } + } + } + + Assert.assertEquals("Could not toLegacy Air", Material.LEGACY_AIR, CraftLegacy.toLegacy(Material.AIR)); + } + + @Test + public void fromLegacyMaterial() { + for (Material material : Material.values()) { + if (!INVALIDATED_MATERIALS.contains(material) && material.isLegacy()) { + Material converted = CraftLegacy.fromLegacy(material); + Assert.assertNotEquals("Could not fromLegacy " + material, Material.AIR, converted); + + Assert.assertNotEquals("Could not toLegacy(fromLegacy) " + converted + "(" + material + ")", Material.AIR, CraftLegacy.toLegacy(converted)); + if (!INVERSION_FAILS.contains(material)) { + Assert.assertEquals("Could not toLegacy(fromLegacy) " + converted + "(" + material + ")", material, CraftLegacy.toLegacy(converted)); + } + } + } + + Assert.assertEquals("Could not fromLegacy Air", Material.AIR, CraftLegacy.fromLegacy(Material.LEGACY_AIR)); + } + + @Test + public void testRestricted() { + for (Material material : CraftLegacy.values()) { + Assert.assertTrue("Must iterate only legacy materials", material.isLegacy()); + } + + for (Material material : CraftLegacy.modern_values()) { + Assert.assertFalse("Must iterate only modern materials", material.isLegacy()); + } + } +} diff --git a/paper-server/src/test/java/org/bukkit/MaterialTest.java b/paper-server/src/test/java/org/bukkit/MaterialTest.java index a9b4e525e1..be0690f31c 100644 --- a/paper-server/src/test/java/org/bukkit/MaterialTest.java +++ b/paper-server/src/test/java/org/bukkit/MaterialTest.java @@ -7,6 +7,7 @@ import java.util.Collections; import java.util.Map; import net.minecraft.server.Item; +import net.minecraft.server.MinecraftKey; import org.bukkit.support.AbstractTestingBase; import org.junit.Test; @@ -19,13 +20,13 @@ public class MaterialTest extends AbstractTestingBase { @Test public void verifyMapping() { - Map materials = Maps.newHashMap(); + Map materials = Maps.newHashMap(); for (Material material : Material.values()) { if (INVALIDATED_MATERIALS.contains(material)) { continue; } - materials.put(material.getId(), material); + materials.put(CraftMagicNumbers.key(material), material); } Iterator items = Item.REGISTRY.iterator(); @@ -34,12 +35,13 @@ public class MaterialTest extends AbstractTestingBase { Item item = items.next(); if (item == null) continue; - int id = CraftMagicNumbers.getId(item); + MinecraftKey id = Item.REGISTRY.b(item); String name = item.getName(); Material material = materials.remove(id); assertThat("Missing " + name + "(" + id + ")", material, is(not(nullValue()))); + assertNotNull("No item mapping for " + name, CraftMagicNumbers.getMaterial(item)); } assertThat(materials, is(Collections.EMPTY_MAP)); diff --git a/paper-server/src/test/java/org/bukkit/ParticleTest.java b/paper-server/src/test/java/org/bukkit/ParticleTest.java index c00869ba65..c0cb4a1edd 100644 --- a/paper-server/src/test/java/org/bukkit/ParticleTest.java +++ b/paper-server/src/test/java/org/bukkit/ParticleTest.java @@ -1,19 +1,34 @@ package org.bukkit; -import net.minecraft.server.EnumParticle; +import org.bukkit.block.data.BlockData; import org.bukkit.craftbukkit.CraftParticle; +import org.bukkit.craftbukkit.block.data.CraftBlockData; +import org.bukkit.inventory.ItemStack; +import org.bukkit.material.MaterialData; +import org.bukkit.support.AbstractTestingBase; import org.junit.Assert; import org.junit.Test; -public class ParticleTest { +public class ParticleTest extends AbstractTestingBase { @Test public void verifyMapping() { for (Particle bukkit : Particle.values()) { - Assert.assertNotNull("Missing Bukkit->NMS particle mapping", CraftParticle.toNMS(bukkit)); + Object data = null; + if (bukkit.getDataType().equals(ItemStack.class)) { + data = new ItemStack(Material.STONE); + } else if (bukkit.getDataType() == MaterialData.class) { + data = new MaterialData(Material.LEGACY_STONE); + } else if (bukkit.getDataType() == Particle.DustOptions.class) { + data = new Particle.DustOptions(Color.BLACK, 0); + } else if (bukkit.getDataType() == BlockData.class) { + data = CraftBlockData.newData(Material.STONE, ""); + } + + Assert.assertNotNull("Missing Bukkit->NMS particle mapping for " + bukkit, CraftParticle.toNMS(bukkit, data)); } - for (EnumParticle nms : EnumParticle.values()) { - Assert.assertNotNull("Missing NMS->Bukkit particle mapping", CraftParticle.toBukkit(nms)); + for (net.minecraft.server.Particle nms : (Iterable>) net.minecraft.server.Particle.REGISTRY) { // Eclipse fail + Assert.assertNotNull("Missing NMS->Bukkit particle mapping for " + nms, CraftParticle.toBukkit(nms)); } } } diff --git a/paper-server/src/test/java/org/bukkit/PerMaterialTest.java b/paper-server/src/test/java/org/bukkit/PerMaterialTest.java index ed5242a99c..dfa24769a2 100644 --- a/paper-server/src/test/java/org/bukkit/PerMaterialTest.java +++ b/paper-server/src/test/java/org/bukkit/PerMaterialTest.java @@ -43,13 +43,22 @@ public class PerMaterialTest extends AbstractTestingBase { public static List data() { List list = Lists.newArrayList(); for (Material material : Material.values()) { - list.add(new Object[] {material}); + if (!material.isLegacy()) { + list.add(new Object[] {material}); + } } return list; } @Parameter public Material material; + @Test + public void isBlock() { + if (material != Material.AIR && material != Material.CAVE_AIR && material != Material.VOID_AIR) { + assertThat(material.isBlock(), is(not(CraftMagicNumbers.getBlock(material).getBlockData().isAir()))); + } + } + @Test public void isSolid() { if (material == Material.AIR) { @@ -106,7 +115,7 @@ public class PerMaterialTest extends AbstractTestingBase { if (material == Material.AIR) { assertTrue(material.isTransparent()); } else if (material.isBlock()) { - assertThat(material.isTransparent(), is(not(CraftMagicNumbers.getBlock(material).getBlockData().getMaterial().blocksLight()))); + // assertThat(material.isTransparent(), is(not(CraftMagicNumbers.getBlock(material).getBlockData().getMaterial().blocksLight()))); // PAIL: not unit testable anymore (17w50a) } else { assertFalse(material.isTransparent()); } @@ -163,6 +172,15 @@ public class PerMaterialTest extends AbstractTestingBase { } } + @Test + public void testDurability() { + if (!material.isBlock()) { + assertThat(material.getMaxDurability(), is((short) CraftMagicNumbers.getItem(material).getMaxDurability())); + } else { + assertThat(material.getMaxDurability(), is((short) 0)); + } + } + @Test public void testBlock() { if (material == Material.AIR) { diff --git a/paper-server/src/test/java/org/bukkit/StatisticsAndAchievementsTest.java b/paper-server/src/test/java/org/bukkit/StatisticsAndAchievementsTest.java index e05e7330f2..055bc4262c 100644 --- a/paper-server/src/test/java/org/bukkit/StatisticsAndAchievementsTest.java +++ b/paper-server/src/test/java/org/bukkit/StatisticsAndAchievementsTest.java @@ -3,10 +3,13 @@ package org.bukkit; import static org.junit.Assert.*; import static org.hamcrest.Matchers.*; -import java.util.List; - +import net.minecraft.server.Block; +import net.minecraft.server.EntityTypes; +import net.minecraft.server.Item; import net.minecraft.server.StatisticList; +import net.minecraft.server.StatisticWrapper; +import org.bukkit.entity.EntityType; import org.bukkit.craftbukkit.CraftStatistic; import org.bukkit.support.AbstractTestingBase; import org.junit.Test; @@ -15,19 +18,40 @@ import com.google.common.collect.HashMultiset; public class StatisticsAndAchievementsTest extends AbstractTestingBase { + @Test + @SuppressWarnings("unchecked") + public void verifyEntityMapping() throws Throwable { + for (Statistic statistic : Statistic.values()) { + if (statistic.getType() == Statistic.Type.ENTITY) { + for (EntityType entity : EntityType.values()) { + if (entity.getName() != null) { + assertNotNull(statistic + " missing for " + entity, CraftStatistic.getEntityStatistic(statistic, entity)); + } + } + } + } + } + @Test @SuppressWarnings("unchecked") public void verifyStatisticMapping() throws Throwable { HashMultiset statistics = HashMultiset.create(); - for (net.minecraft.server.Statistic statistic : (List) StatisticList.stats) { - String name = statistic.name; + for (StatisticWrapper wrapper : (Iterable>) StatisticList.REGISTRY) { // Eclipse fail + for (Object child : wrapper.a()) { + net.minecraft.server.Statistic statistic = wrapper.b(child); + String message = String.format("org.bukkit.Statistic is missing: '%s'", statistic); - String message = String.format("org.bukkit.Statistic is missing: '%s'", name); + Statistic subject = CraftStatistic.getBukkitStatistic(statistic); + assertThat(message, subject, is(not(nullValue()))); - Statistic subject = CraftStatistic.getBukkitStatistic(statistic); - assertThat(message, subject, is(not(nullValue()))); + if (wrapper.a() == Block.REGISTRY || wrapper.a() == Item.REGISTRY) { + assertNotNull("Material type map missing for " + child, CraftStatistic.getMaterialFromStatistic(statistic)); + } else if (wrapper.a() == EntityTypes.REGISTRY) { + assertNotNull("Entity type map missing for " + EntityTypes.getName((EntityTypes) child), CraftStatistic.getEntityTypeFromStatistic((net.minecraft.server.Statistic>) statistic)); + } - statistics.add(subject); + statistics.add(subject); + } } for (Statistic statistic : Statistic.values()) { diff --git a/paper-server/src/test/java/org/bukkit/craftbukkit/generator/ChunkDataTest.java b/paper-server/src/test/java/org/bukkit/craftbukkit/generator/ChunkDataTest.java index 225df40a72..792e1fc6fb 100644 --- a/paper-server/src/test/java/org/bukkit/craftbukkit/generator/ChunkDataTest.java +++ b/paper-server/src/test/java/org/bukkit/craftbukkit/generator/ChunkDataTest.java @@ -1,32 +1,31 @@ package org.bukkit.craftbukkit.generator; -import org.bukkit.DyeColor; import org.bukkit.Material; -import org.bukkit.material.MaterialData; -import org.bukkit.material.Wool; +import org.bukkit.block.data.BlockData; +import org.bukkit.support.AbstractTestingBase; import org.junit.Test; import static org.junit.Assert.*; -public class ChunkDataTest { +public class ChunkDataTest extends AbstractTestingBase { - private static final MaterialData RED_WOOL = new Wool(DyeColor.RED); - private static final MaterialData AIR = new MaterialData(Material.AIR); + private static final BlockData RED_WOOL = Material.RED_WOOL.createBlockData(); + private static final BlockData AIR = Material.AIR.createBlockData(); - private boolean testSetBlock(CraftChunkData data, int x, int y, int z, MaterialData type, MaterialData expected) { + private boolean testSetBlock(CraftChunkData data, int x, int y, int z, BlockData type, BlockData expected) { data.setBlock(x, y, z, type); - return expected.equals(data.getTypeAndData(x, y, z)); + return expected.equals(data.getBlockData(x, y, z)); } - private void testSetRegion(CraftChunkData data, int minx, int miny, int minz, int maxx, int maxy, int maxz, MaterialData type) { + private void testSetRegion(CraftChunkData data, int minx, int miny, int minz, int maxx, int maxy, int maxz, BlockData type) { data.setRegion(minx, miny, minz, maxx, maxy, maxz, type); for (int y = 0; y < data.getMaxHeight(); y++) { for (int z = 0; z < 16; z++) { for (int x = 0; x < 16; x++) { boolean inRegion = miny <= y && y < maxy && minx <= x && x < maxx && minz <= z && z < maxz; - if (inRegion != type.equals(data.getTypeAndData(x, y, z))) { + if (inRegion != type.equals(data.getBlockData(x, y, z))) { throw new IllegalStateException( "setRegion(" + minx + ", " + miny + ", " + minz + ", " + maxx + ", " + maxy + ", " + maxz + ", " + type + ")" - + "-> block at " + x + ", " + y + ", " + z + " is " + data.getTypeAndData(x, y, z)); + + "-> block at " + x + ", " + y + ", " + z + " is " + data.getBlockData(x, y, z)); } } } diff --git a/paper-server/src/test/java/org/bukkit/craftbukkit/inventory/CompositeSerialization.java b/paper-server/src/test/java/org/bukkit/craftbukkit/inventory/CompositeSerialization.java index 1349a7f18d..2a0791bb98 100644 --- a/paper-server/src/test/java/org/bukkit/craftbukkit/inventory/CompositeSerialization.java +++ b/paper-server/src/test/java/org/bukkit/craftbukkit/inventory/CompositeSerialization.java @@ -6,6 +6,7 @@ import static org.hamcrest.Matchers.*; import java.util.ArrayList; import java.util.List; +import org.bukkit.Material; import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.enchantments.Enchantment; @@ -25,23 +26,23 @@ public class CompositeSerialization extends AbstractTestingBase { YamlConfiguration out = getConfig(); List stacks = new ArrayList(); - stacks.add(new ItemStack(1)); - stacks.add(new ItemStack(2)); - stacks.add(new ItemStack(3)); - stacks.add(new ItemStack(4, 17)); - stacks.add(new ItemStack(5, 63)); - stacks.add(new ItemStack(6, 1, (short) 1)); - stacks.add(new ItemStack(18, 32, (short) 2)); + stacks.add(new ItemStack(Material.STONE)); + stacks.add(new ItemStack(Material.GRASS)); + stacks.add(new ItemStack(Material.DIRT)); + stacks.add(new ItemStack(Material.COBBLESTONE, 17)); + stacks.add(new ItemStack(Material.OAK_PLANKS, 63)); + stacks.add(new ItemStack(Material.OAK_SAPLING, 1, (short) 1)); + stacks.add(new ItemStack(Material.OAK_LEAVES, 32, (short) 2)); - ItemStack item7 = new ItemStack(256); - item7.addUnsafeEnchantment(Enchantment.getById(1), 1); + ItemStack item7 = new ItemStack(Material.IRON_SHOVEL); + item7.addUnsafeEnchantment(Enchantment.PROTECTION_FIRE, 1); stacks.add(item7); - ItemStack item8 = new ItemStack(257); - item8.addUnsafeEnchantment(Enchantment.getById(2), 2); - item8.addUnsafeEnchantment(Enchantment.getById(3), 1); - item8.addUnsafeEnchantment(Enchantment.getById(4), 5); - item8.addUnsafeEnchantment(Enchantment.getById(5), 4); + ItemStack item8 = new ItemStack(Material.IRON_PICKAXE); + item8.addUnsafeEnchantment(Enchantment.PROTECTION_FALL, 2); + item8.addUnsafeEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 1); + item8.addUnsafeEnchantment(Enchantment.PROTECTION_PROJECTILE, 5); + item8.addUnsafeEnchantment(Enchantment.OXYGEN, 4); stacks.add(item8); out.set("composite-list.abc.def", stacks); diff --git a/paper-server/src/test/java/org/bukkit/craftbukkit/inventory/ItemFactoryTest.java b/paper-server/src/test/java/org/bukkit/craftbukkit/inventory/ItemFactoryTest.java index f5bcbdbe12..18f3e1ff65 100644 --- a/paper-server/src/test/java/org/bukkit/craftbukkit/inventory/ItemFactoryTest.java +++ b/paper-server/src/test/java/org/bukkit/craftbukkit/inventory/ItemFactoryTest.java @@ -10,7 +10,7 @@ import java.util.HashSet; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; -import net.minecraft.server.CommandAbstract; +import net.minecraft.server.IAnimal; import net.minecraft.server.IAttribute; import org.bukkit.support.AbstractTestingBase; @@ -20,7 +20,7 @@ public class ItemFactoryTest extends AbstractTestingBase { @Test public void testKnownAttributes() throws Throwable { - final ZipInputStream nmsZipStream = new ZipInputStream(CommandAbstract.class/* Magic class that isn't imported! */.getProtectionDomain().getCodeSource().getLocation().openStream()); + final ZipInputStream nmsZipStream = new ZipInputStream(IAnimal.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/paper-server/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java b/paper-server/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java index 1f537d5844..74e37cd985 100644 --- a/paper-server/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java +++ b/paper-server/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java @@ -3,13 +3,14 @@ package org.bukkit.craftbukkit.inventory; import static org.junit.Assert.*; import static org.hamcrest.Matchers.*; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; import net.minecraft.server.Block; import net.minecraft.server.ITileEntity; import net.minecraft.server.Item; import net.minecraft.server.ItemBlock; -import net.minecraft.server.ItemReed; +import net.minecraft.server.ItemBlockWallable; import org.bukkit.Bukkit; import org.bukkit.Color; @@ -26,6 +27,7 @@ import org.bukkit.craftbukkit.inventory.ItemStackTest.BukkitWrapper; import org.bukkit.craftbukkit.inventory.ItemStackTest.CraftWrapper; import org.bukkit.enchantments.Enchantment; 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.BlockStateMeta; @@ -39,6 +41,7 @@ import org.bukkit.inventory.meta.LeatherArmorMeta; import org.bukkit.inventory.meta.MapMeta; import org.bukkit.inventory.meta.PotionMeta; import org.bukkit.inventory.meta.SpawnEggMeta; +import org.bukkit.inventory.meta.TropicalFishBucketMeta; import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionData; import org.bukkit.potion.PotionType; @@ -125,12 +128,12 @@ public class ItemMetaTest extends AbstractTestingBase { } private static FireworkMeta newFireworkMeta() { - return ((FireworkMeta) Bukkit.getItemFactory().getItemMeta(Material.FIREWORK)); + return ((FireworkMeta) Bukkit.getItemFactory().getItemMeta(Material.FIREWORK_ROCKET)); } @Test public void testCrazyEquality() { - CraftItemStack craft = CraftItemStack.asCraftCopy(new ItemStack(1)); + CraftItemStack craft = CraftItemStack.asCraftCopy(new ItemStack(Material.STONE)); craft.setItemMeta(craft.getItemMeta()); ItemStack bukkit = new ItemStack(craft); assertThat(craft, is(bukkit)); @@ -139,21 +142,24 @@ public class ItemMetaTest extends AbstractTestingBase { @Test public void testBlockStateMeta() { - for (Item item : (Iterable) Item.REGISTRY) { - Block block = null; + List queue = new ArrayList<>(); + for (Item item : (Iterable) Item.REGISTRY) { // Eclipse fail if (item instanceof ItemBlock) { - block = ((ItemBlock) item).getBlock(); - } else if (item instanceof ItemReed) { - block = ((ItemReed) item).a; + queue.add(((ItemBlock) item).getBlock()); } + if (item instanceof ItemBlockWallable) { + queue.add(((ItemBlockWallable) item).wallBlock); + } + } + for (Block block : queue) { if (block != null) { if (block instanceof ITileEntity) { ItemStack stack = CraftItemStack.asNewCraftStack(Item.getItemOf(block)); // Command blocks aren't unit testable atm - if (stack.getType() == Material.AIR || stack.getType() == Material.COMMAND || stack.getType() == Material.COMMAND_CHAIN || stack.getType() == Material.COMMAND_REPEATING) { + if (stack.getType() == Material.COMMAND_BLOCK || stack.getType() == Material.CHAIN_COMMAND_BLOCK || stack.getType() == Material.REPEATING_COMMAND_BLOCK) { return; } @@ -172,7 +178,7 @@ public class ItemMetaTest extends AbstractTestingBase { @Test public void testEachExtraData() { final List providers = Arrays.asList( - new StackProvider(Material.BOOK_AND_QUILL) { + new StackProvider(Material.WRITABLE_BOOK) { @Override ItemStack operate(final ItemStack cleanStack) { final BookMeta meta = (BookMeta) cleanStack.getItemMeta(); meta.setAuthor("Some author"); @@ -202,7 +208,7 @@ public class ItemMetaTest extends AbstractTestingBase { } }, */ - new StackProvider(Material.MAP) { + new StackProvider(Material.FILLED_MAP) { @Override ItemStack operate(final ItemStack cleanStack) { final MapMeta meta = (MapMeta) cleanStack.getItemMeta(); meta.setScaling(true); @@ -227,7 +233,7 @@ public class ItemMetaTest extends AbstractTestingBase { return cleanStack; } }, - new StackProvider(Material.FIREWORK) { + new StackProvider(Material.FIREWORK_ROCKET) { @Override ItemStack operate(final ItemStack cleanStack) { final FireworkMeta meta = (FireworkMeta) cleanStack.getItemMeta(); meta.addEffect(FireworkEffect.builder().withColor(Color.GREEN).withFade(Color.OLIVE).with(Type.BALL_LARGE).build()); @@ -243,7 +249,7 @@ public class ItemMetaTest extends AbstractTestingBase { return cleanStack; } }, - new StackProvider(Material.FIREWORK_CHARGE) { + new StackProvider(Material.FIREWORK_STAR) { @Override ItemStack operate(final ItemStack cleanStack) { final FireworkEffectMeta meta = (FireworkEffectMeta) cleanStack.getItemMeta(); meta.setEffect(FireworkEffect.builder().withColor(Color.MAROON, Color.BLACK).with(Type.CREEPER).withFlicker().build()); @@ -251,7 +257,7 @@ public class ItemMetaTest extends AbstractTestingBase { return cleanStack; } }, - new StackProvider(Material.BANNER) { + new StackProvider(Material.WHITE_BANNER) { @Override ItemStack operate(ItemStack cleanStack) { final BannerMeta meta = (BannerMeta) cleanStack.getItemMeta(); meta.setBaseColor(DyeColor.CYAN); @@ -259,26 +265,38 @@ public class ItemMetaTest extends AbstractTestingBase { cleanStack.setItemMeta(meta); return cleanStack; } - }, - new StackProvider(Material.MONSTER_EGG) { + }, + /* No distinguishing features, add back with virtual entity API + new StackProvider(Material.ZOMBIE_SPAWN_EGG) { @Override ItemStack operate(ItemStack cleanStack) { final SpawnEggMeta meta = (SpawnEggMeta) cleanStack.getItemMeta(); meta.setSpawnedType(EntityType.ZOMBIE); cleanStack.setItemMeta(meta); return cleanStack; - } - }, - new StackProvider(Material.KNOWLEDGE_BOOK) { + } + }, + */ + new StackProvider(Material.KNOWLEDGE_BOOK) { @Override ItemStack operate(ItemStack cleanStack) { final KnowledgeBookMeta meta = (KnowledgeBookMeta) cleanStack.getItemMeta(); meta.addRecipe(new NamespacedKey("minecraft", "test"), new NamespacedKey("plugin", "test")); cleanStack.setItemMeta(meta); return cleanStack; } + }, + new StackProvider(Material.TROPICAL_FISH_BUCKET) { + @Override ItemStack operate(ItemStack cleanStack) { + final TropicalFishBucketMeta meta = (TropicalFishBucketMeta) cleanStack.getItemMeta(); + meta.setBodyColor(DyeColor.ORANGE); + meta.setPatternColor(DyeColor.BLACK); + meta.setPattern(TropicalFish.Pattern.DASHER); + cleanStack.setItemMeta(meta); + return cleanStack; + } } ); - assertThat("Forgotten test?", providers, hasSize(ItemStackTest.COMPOUND_MATERIALS.length - 3/* Normal item meta, skulls and tile entities */)); + assertThat("Forgotten test?", providers, hasSize(ItemStackTest.COMPOUND_MATERIALS.length - 4/* Normal item meta, skulls, eggs and tile entities */)); for (final StackProvider provider : providers) { downCastTest(new BukkitWrapper(provider)); @@ -288,7 +306,7 @@ public class ItemMetaTest extends AbstractTestingBase { private void downCastTest(final StackWrapper provider) { final String name = provider.toString(); - final ItemStack blank = new ItemStack(1); + final ItemStack blank = new ItemStack(Material.STONE); final ItemStack craftBlank = CraftItemStack.asCraftCopy(blank); downCastTest(name, provider.stack(), blank); @@ -304,7 +322,7 @@ public class ItemMetaTest extends AbstractTestingBase { assertThat(name, stack, is(not(blank))); assertThat(name, stack.getItemMeta(), is(not(blank.getItemMeta()))); - stack.setTypeId(1); + stack.setType(Material.STONE); assertThat(name, stack, is(blank)); } diff --git a/paper-server/src/test/java/org/bukkit/craftbukkit/inventory/ItemStackBookTest.java b/paper-server/src/test/java/org/bukkit/craftbukkit/inventory/ItemStackBookTest.java index a7edc048b7..c16c5611d5 100644 --- a/paper-server/src/test/java/org/bukkit/craftbukkit/inventory/ItemStackBookTest.java +++ b/paper-server/src/test/java/org/bukkit/craftbukkit/inventory/ItemStackBookTest.java @@ -17,7 +17,7 @@ public class ItemStackBookTest extends ItemStackTest { @Parameters(name="[{index}]:{" + NAME_PARAMETER + "}") public static List data() { - return StackProvider.compound(operators(), "%s %s", NAME_PARAMETER, Material.WRITTEN_BOOK, Material.BOOK_AND_QUILL); + return StackProvider.compound(operators(), "%s %s", NAME_PARAMETER, Material.WRITTEN_BOOK, Material.WRITABLE_BOOK); } @SuppressWarnings("unchecked") diff --git a/paper-server/src/test/java/org/bukkit/craftbukkit/inventory/ItemStackFireworkChargeTest.java b/paper-server/src/test/java/org/bukkit/craftbukkit/inventory/ItemStackFireworkChargeTest.java index cb38cd2747..fbfce58c5f 100644 --- a/paper-server/src/test/java/org/bukkit/craftbukkit/inventory/ItemStackFireworkChargeTest.java +++ b/paper-server/src/test/java/org/bukkit/craftbukkit/inventory/ItemStackFireworkChargeTest.java @@ -20,7 +20,7 @@ public class ItemStackFireworkChargeTest extends ItemStackTest { @Parameters(name="[{index}]:{" + NAME_PARAMETER + "}") public static List data() { - return StackProvider.compound(operators(), "%s %s", NAME_PARAMETER, Material.FIREWORK_CHARGE); + return StackProvider.compound(operators(), "%s %s", NAME_PARAMETER, Material.FIREWORK_STAR); } @SuppressWarnings("unchecked") diff --git a/paper-server/src/test/java/org/bukkit/craftbukkit/inventory/ItemStackFireworkTest.java b/paper-server/src/test/java/org/bukkit/craftbukkit/inventory/ItemStackFireworkTest.java index 40b1d19da7..55e6629bc4 100644 --- a/paper-server/src/test/java/org/bukkit/craftbukkit/inventory/ItemStackFireworkTest.java +++ b/paper-server/src/test/java/org/bukkit/craftbukkit/inventory/ItemStackFireworkTest.java @@ -20,7 +20,7 @@ public class ItemStackFireworkTest extends ItemStackTest { @Parameters(name="[{index}]:{" + NAME_PARAMETER + "}") public static List data() { - return StackProvider.compound(operators(), "%s %s", NAME_PARAMETER, Material.FIREWORK); + return StackProvider.compound(operators(), "%s %s", NAME_PARAMETER, Material.FIREWORK_ROCKET); } @SuppressWarnings("unchecked") diff --git a/paper-server/src/test/java/org/bukkit/craftbukkit/inventory/ItemStackMapTest.java b/paper-server/src/test/java/org/bukkit/craftbukkit/inventory/ItemStackMapTest.java index 9c49985848..c13f6d5790 100644 --- a/paper-server/src/test/java/org/bukkit/craftbukkit/inventory/ItemStackMapTest.java +++ b/paper-server/src/test/java/org/bukkit/craftbukkit/inventory/ItemStackMapTest.java @@ -17,7 +17,7 @@ public class ItemStackMapTest extends ItemStackTest { @Parameters(name="[{index}]:{" + NAME_PARAMETER + "}") public static List data() { - return StackProvider.compound(operators(), "%s %s", NAME_PARAMETER, Material.MAP); + return StackProvider.compound(operators(), "%s %s", NAME_PARAMETER, Material.FILLED_MAP); } @SuppressWarnings("unchecked") diff --git a/paper-server/src/test/java/org/bukkit/craftbukkit/inventory/ItemStackSkullTest.java b/paper-server/src/test/java/org/bukkit/craftbukkit/inventory/ItemStackSkullTest.java index a79d443e7d..1561bf885d 100644 --- a/paper-server/src/test/java/org/bukkit/craftbukkit/inventory/ItemStackSkullTest.java +++ b/paper-server/src/test/java/org/bukkit/craftbukkit/inventory/ItemStackSkullTest.java @@ -17,7 +17,7 @@ public class ItemStackSkullTest extends ItemStackTest { @Parameters(name="[{index}]:{" + NAME_PARAMETER + "}") public static List data() { - return StackProvider.compound(operators(), "%s %s", NAME_PARAMETER, Material.SKULL_ITEM); + return StackProvider.compound(operators(), "%s %s", NAME_PARAMETER, Material.PLAYER_HEAD); } @SuppressWarnings("unchecked") diff --git a/paper-server/src/test/java/org/bukkit/craftbukkit/inventory/NMSCraftItemStackTest.java b/paper-server/src/test/java/org/bukkit/craftbukkit/inventory/NMSCraftItemStackTest.java index 1f5a6a32f1..5a43fd867f 100644 --- a/paper-server/src/test/java/org/bukkit/craftbukkit/inventory/NMSCraftItemStackTest.java +++ b/paper-server/src/test/java/org/bukkit/craftbukkit/inventory/NMSCraftItemStackTest.java @@ -21,7 +21,6 @@ public class NMSCraftItemStackTest extends AbstractTestingBase { assertThat(clone.getAmount(), is(itemStack.getAmount())); assertThat(clone.getDurability(), is(itemStack.getDurability())); assertThat(clone.getEnchantments(), is(itemStack.getEnchantments())); - assertThat(clone.getTypeId(), is(itemStack.getTypeId())); assertThat(clone.getData(), is(itemStack.getData())); assertThat(clone, is(itemStack)); } diff --git a/paper-server/src/test/java/org/bukkit/entity/EntityTypesTest.java b/paper-server/src/test/java/org/bukkit/entity/EntityTypesTest.java new file mode 100644 index 0000000000..d8c3b013cc --- /dev/null +++ b/paper-server/src/test/java/org/bukkit/entity/EntityTypesTest.java @@ -0,0 +1,29 @@ +package org.bukkit.entity; + +import java.util.Arrays; +import java.util.Set; +import java.util.stream.Collectors; +import net.minecraft.server.EntityTypes; +import net.minecraft.server.MinecraftKey; +import org.junit.Assert; +import org.junit.Test; + +public class EntityTypesTest { + + @Test + public void testMaps() { + Set allBukkit = Arrays.stream(EntityType.values()).filter((b) -> b.getName() != null).collect(Collectors.toSet()); + + for (Object o : EntityTypes.REGISTRY) { + EntityTypes nms = (EntityTypes) o; // Eclipse fail + MinecraftKey key = EntityTypes.getName(nms); + + EntityType bukkit = EntityType.fromName(key.getKey()); + Assert.assertNotNull("Missing nms->bukkit " + key, bukkit); + + Assert.assertTrue("Duplicate entity nms->" + bukkit, allBukkit.remove(bukkit)); + } + + Assert.assertTrue("Unmapped bukkit entities " + allBukkit, allBukkit.isEmpty()); + } +} diff --git a/paper-server/src/test/java/org/bukkit/entity/TropicalFishTest.java b/paper-server/src/test/java/org/bukkit/entity/TropicalFishTest.java new file mode 100644 index 0000000000..63ddb467ac --- /dev/null +++ b/paper-server/src/test/java/org/bukkit/entity/TropicalFishTest.java @@ -0,0 +1,45 @@ +package org.bukkit.entity; + +import static org.junit.Assert.*; +import static org.hamcrest.Matchers.*; +import org.bukkit.DyeColor; +import org.bukkit.craftbukkit.entity.CraftTropicalFish; +import org.bukkit.entity.TropicalFish.Pattern; + +import org.junit.Test; + +public class TropicalFishTest { + + @Test + public void testVariants() { + testVariant(65536, DyeColor.ORANGE, DyeColor.WHITE, Pattern.KOB); + testVariant(917504, DyeColor.RED, DyeColor.WHITE, Pattern.KOB); + testVariant(918273, DyeColor.RED, DyeColor.WHITE, Pattern.BLOCKFISH); + testVariant(918529, DyeColor.RED, DyeColor.WHITE, Pattern.BETTY); + testVariant(16778497, DyeColor.WHITE, DyeColor.ORANGE, Pattern.CLAYFISH); + testVariant(50660352, DyeColor.LIME, DyeColor.LIGHT_BLUE, Pattern.BRINELY); + testVariant(50726144, DyeColor.PINK, DyeColor.LIGHT_BLUE, Pattern.SPOTTY); + testVariant(50790656, DyeColor.GRAY, DyeColor.LIGHT_BLUE, Pattern.SUNSTREAK); + testVariant(67108865, DyeColor.WHITE, DyeColor.YELLOW, Pattern.FLOPPER); + testVariant(67110144, DyeColor.WHITE, DyeColor.YELLOW, Pattern.SPOTTY); + testVariant(67371265, DyeColor.YELLOW, DyeColor.YELLOW, Pattern.STRIPEY); + testVariant(67764993, DyeColor.PURPLE, DyeColor.YELLOW, Pattern.BLOCKFISH); + testVariant(101253888, DyeColor.CYAN, DyeColor.PINK, Pattern.DASHER); + testVariant(117441025, DyeColor.WHITE, DyeColor.GRAY, Pattern.GLITTER); + testVariant(117441280, DyeColor.WHITE, DyeColor.GRAY, Pattern.DASHER); + testVariant(117441536, DyeColor.WHITE, DyeColor.GRAY, Pattern.BRINELY); + testVariant(117506305, DyeColor.ORANGE, DyeColor.GRAY, Pattern.STRIPEY); + testVariant(117899265, DyeColor.GRAY, DyeColor.GRAY, Pattern.FLOPPER); + testVariant(118161664, DyeColor.BLUE, DyeColor.GRAY, Pattern.SUNSTREAK); + testVariant(134217984, DyeColor.WHITE, DyeColor.SILVER, Pattern.SUNSTREAK); + testVariant(234882305, DyeColor.WHITE, DyeColor.RED, Pattern.CLAYFISH); + testVariant(235340288, DyeColor.GRAY, DyeColor.RED, Pattern.SNOOPER); + } + + private void testVariant(int variant, DyeColor bodyColor, DyeColor patternColor, Pattern pattern) { + assertThat("variant write", CraftTropicalFish.getData(patternColor, bodyColor, pattern), is(variant)); + assertThat("pattern colour read", CraftTropicalFish.getPatternColor(variant), is(patternColor)); + assertThat("body colour read", CraftTropicalFish.getBodyColor(variant), is(bodyColor)); + assertThat("pattern read", CraftTropicalFish.getPattern(variant), is(pattern)); + } +} diff --git a/paper-server/src/test/java/org/bukkit/map/MapTest.java b/paper-server/src/test/java/org/bukkit/map/MapTest.java index f4788a1871..2dde26d3fd 100644 --- a/paper-server/src/test/java/org/bukkit/map/MapTest.java +++ b/paper-server/src/test/java/org/bukkit/map/MapTest.java @@ -24,7 +24,7 @@ public class MapTest { if (nmsColors[i] == null) { break; } - int rgb = nmsColors[i].ac; + int rgb = nmsColors[i].rgb; int r = (rgb >> 16) & 0xFF; int g = (rgb >> 8) & 0xFF; diff --git a/paper-server/src/test/java/org/bukkit/potion/PotionTest.java b/paper-server/src/test/java/org/bukkit/potion/PotionTest.java index e46429a59b..74ed926f1c 100644 --- a/paper-server/src/test/java/org/bukkit/potion/PotionTest.java +++ b/paper-server/src/test/java/org/bukkit/potion/PotionTest.java @@ -30,6 +30,6 @@ public class PotionTest extends AbstractTestingBase { effects.put(enumType, enumType.name()); } - assertEquals(effects.entrySet().size(), PotionType.values().length - /* PotionTypes with no Effects */ 5); + assertEquals(effects.entrySet().size(), PotionType.values().length - /* PotionTypes with no/shared Effects */ 6); } } diff --git a/paper-server/src/test/java/org/bukkit/support/AbstractTestingBase.java b/paper-server/src/test/java/org/bukkit/support/AbstractTestingBase.java index 86c2b97135..6266dc32b9 100644 --- a/paper-server/src/test/java/org/bukkit/support/AbstractTestingBase.java +++ b/paper-server/src/test/java/org/bukkit/support/AbstractTestingBase.java @@ -1,10 +1,16 @@ package org.bukkit.support; import com.google.common.collect.ImmutableList; +import java.util.Collections; import java.util.List; import net.minecraft.server.DispenserRegistry; +import net.minecraft.server.EnumResourcePackType; +import net.minecraft.server.ResourceManager; +import net.minecraft.server.ResourcePackVanilla; +import net.minecraft.server.TagRegistry; import org.bukkit.Material; -import org.junit.BeforeClass; +import org.bukkit.craftbukkit.util.CraftMagicNumbers; +import org.junit.Assert; /** * If you are getting: java.lang.ExceptionInInitializerError @@ -15,67 +21,28 @@ import org.junit.BeforeClass; * extend this class to solve it. */ public abstract class AbstractTestingBase { - public static final List INVALIDATED_MATERIALS = ImmutableList.builder() - .add( - Material.BREWING_STAND, - Material.BED_BLOCK, - Material.NETHER_WARTS, - Material.CAULDRON, - Material.FLOWER_POT, - Material.CROPS, - Material.SUGAR_CANE_BLOCK, - Material.CAKE_BLOCK, - Material.SKULL, - Material.PISTON_EXTENSION, - Material.PISTON_MOVING_PIECE, - Material.GLOWING_REDSTONE_ORE, - Material.DIODE_BLOCK_ON, - Material.PUMPKIN_STEM, - Material.SIGN_POST, - Material.REDSTONE_COMPARATOR_ON, - Material.TRIPWIRE, - Material.REDSTONE_LAMP_ON, - Material.MELON_STEM, - Material.REDSTONE_TORCH_OFF, - Material.REDSTONE_COMPARATOR_OFF, - Material.REDSTONE_WIRE, - Material.WALL_SIGN, - Material.DIODE_BLOCK_OFF, - Material.IRON_DOOR_BLOCK, - Material.WOODEN_DOOR, - Material.WATER, - Material.STATIONARY_WATER, - Material.LAVA, - Material.STATIONARY_LAVA, - Material.DOUBLE_STEP, - Material.DOUBLE_STEP, - Material.FIRE, - Material.PORTAL, - Material.ENDER_PORTAL, - Material.WOOD_DOUBLE_STEP, - Material.COCOA, - Material.CARROT, - Material.POTATO, - Material.STANDING_BANNER, - Material.WALL_BANNER, - Material.DAYLIGHT_DETECTOR_INVERTED, - Material.DOUBLE_STONE_SLAB2, - Material.SPRUCE_DOOR, - Material.BIRCH_DOOR, - Material.JUNGLE_DOOR, - Material.ACACIA_DOOR, - Material.DARK_OAK_DOOR, - Material.PURPUR_DOUBLE_SLAB, - Material.BEETROOT_BLOCK, - Material.END_GATEWAY, - Material.BURNING_FURNACE, - Material.FROSTED_ICE - ).build(); + // Materials that only exist in block form (or are legacy) + public static final List INVALIDATED_MATERIALS; - @BeforeClass - public static void setup() { + static { DispenserRegistry.c(); + // Set up resource manager + ResourceManager resourceManager = new ResourceManager(EnumResourcePackType.SERVER_DATA); + // add tags for unit tests + resourceManager.a(new TagRegistry()); + // Register vanilla pack + resourceManager.a(Collections.singletonList(new ResourcePackVanilla("minecraft"))); + DummyServer.setup(); DummyEnchantments.setup(); + + ImmutableList.Builder builder = ImmutableList.builder(); + for (Material m : Material.values()) { + if (m.isLegacy() || CraftMagicNumbers.getItem(m) == null) { + builder.add(m); + } + } + INVALIDATED_MATERIALS = builder.build(); + Assert.assertTrue("Expected 533 invalidated materials (got " + INVALIDATED_MATERIALS.size() + ")", INVALIDATED_MATERIALS.size() == 533); } -} \ No newline at end of file +} diff --git a/paper-server/src/test/java/org/bukkit/support/DummyServer.java b/paper-server/src/test/java/org/bukkit/support/DummyServer.java index e5215bb4e5..a6e7651a29 100644 --- a/paper-server/src/test/java/org/bukkit/support/DummyServer.java +++ b/paper-server/src/test/java/org/bukkit/support/DummyServer.java @@ -7,8 +7,11 @@ import java.util.HashMap; import java.util.logging.Logger; import org.bukkit.Bukkit; +import org.bukkit.Material; import org.bukkit.Server; +import org.bukkit.craftbukkit.block.data.CraftBlockData; import org.bukkit.craftbukkit.inventory.CraftItemFactory; +import org.bukkit.craftbukkit.util.CraftMagicNumbers; import org.bukkit.craftbukkit.util.Versioning; public class DummyServer implements InvocationHandler { @@ -59,6 +62,23 @@ public class DummyServer implements InvocationHandler { } } ); + methods.put( + Server.class.getMethod("getUnsafe"), + new MethodHandler() { + public Object handle(DummyServer server, Object[] args) { + return CraftMagicNumbers.INSTANCE; + } + } + ); + methods.put( + Server.class.getMethod("createBlockData", Material.class), + new MethodHandler() { + final Logger logger = Logger.getLogger(DummyServer.class.getCanonicalName()); + public Object handle(DummyServer server, Object[] args) { + return CraftBlockData.newData((Material) args[0], null); + } + } + ); Bukkit.setServer(Proxy.getProxyClass(Server.class.getClassLoader(), Server.class).asSubclass(Server.class).getConstructor(InvocationHandler.class).newInstance(new DummyServer())); } catch (Throwable t) { throw new Error(t);