diff --git a/nms-patches/BehaviorCareer.patch b/nms-patches/BehaviorCareer.patch index 7ad04f3248..4f1e37fd1b 100644 --- a/nms-patches/BehaviorCareer.patch +++ b/nms-patches/BehaviorCareer.patch @@ -18,10 +18,10 @@ entityvillager.getBehaviorController().removeMemory(MemoryModuleType.POTENTIAL_JOB_SITE); - entityvillager.getBehaviorController().setMemory(MemoryModuleType.JOB_SITE, (Object) globalpos); + entityvillager.getBehaviorController().setMemory(MemoryModuleType.JOB_SITE, globalpos); // CraftBukkit - decompile error + worldserver.broadcastEntityEffect(entityvillager, (byte) 14); if (entityvillager.getVillagerData().getProfession() == VillagerProfession.NONE) { MinecraftServer minecraftserver = worldserver.getMinecraftServer(); - -@@ -30,7 +35,14 @@ +@@ -31,7 +36,14 @@ return villagerprofession.b() == villageplacetype; }).findFirst(); }).ifPresent((villagerprofession) -> { @@ -34,6 +34,6 @@ + + entityvillager.setVillagerData(entityvillager.getVillagerData().withProfession(CraftVillager.bukkitToNmsProfession(event.getProfession()))); + // CraftBukkit end - entityvillager.b(worldserver); + entityvillager.c(worldserver); }); } diff --git a/nms-patches/BehaviorInteractDoor.patch b/nms-patches/BehaviorInteractDoor.patch index 575e7d3340..7d4df2a0d2 100644 --- a/nms-patches/BehaviorInteractDoor.patch +++ b/nms-patches/BehaviorInteractDoor.patch @@ -1,22 +1,48 @@ --- a/net/minecraft/server/BehaviorInteractDoor.java +++ b/net/minecraft/server/BehaviorInteractDoor.java -@@ -46,11 +46,18 @@ - if (TagsBlock.WOODEN_DOORS.isTagged(block) && block instanceof BlockDoor) { - boolean flag = j >= i; +@@ -52,6 +52,13 @@ + BlockDoor blockdoor = (BlockDoor) iblockdata.getBlock(); + if (!blockdoor.h(iblockdata)) { + // CraftBukkit start - entities opening doors + org.bukkit.event.entity.EntityInteractEvent event = new org.bukkit.event.entity.EntityInteractEvent(entityliving.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(entityliving.world, blockposition)); + entityliving.world.getServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { + return; + } -+ // CaftBukkit end - ((BlockDoor) block).setDoor(worldserver, blockposition, flag); - GlobalPos globalpos = GlobalPos.create(worldserver.getDimensionKey(), blockposition); ++ // CraftBukkit end + blockdoor.setDoor(worldserver, iblockdata, blockposition, true); + } - if (!behaviorcontroller.getMemory(MemoryModuleType.OPENED_DOORS).isPresent() && flag) { -- behaviorcontroller.setMemory(MemoryModuleType.OPENED_DOORS, (Object) Sets.newHashSet(new GlobalPos[]{globalpos})); -+ behaviorcontroller.setMemory(MemoryModuleType.OPENED_DOORS, Sets.newHashSet(new GlobalPos[]{globalpos})); // CraftBukkit - decompile error - } else { - behaviorcontroller.getMemory(MemoryModuleType.OPENED_DOORS).ifPresent((set1) -> { - if (flag) { +@@ -65,6 +72,13 @@ + BlockDoor blockdoor1 = (BlockDoor) iblockdata1.getBlock(); + + if (!blockdoor1.h(iblockdata1)) { ++ // CraftBukkit start - entities opening doors ++ org.bukkit.event.entity.EntityInteractEvent event = new org.bukkit.event.entity.EntityInteractEvent(entityliving.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(entityliving.world, blockposition)); ++ entityliving.world.getServer().getPluginManager().callEvent(event); ++ if (event.isCancelled()) { ++ return; ++ } ++ // CraftBukkit end + blockdoor1.setDoor(worldserver, iblockdata1, blockposition1, true); + this.c(worldserver, entityliving, blockposition1); + } +@@ -113,7 +127,7 @@ + private static boolean a(WorldServer worldserver, EntityLiving entityliving, BlockPosition blockposition) { + BehaviorController behaviorcontroller = entityliving.getBehaviorController(); + +- return !behaviorcontroller.hasMemory(MemoryModuleType.MOBS) ? false : ((List) behaviorcontroller.getMemory(MemoryModuleType.MOBS).get()).stream().filter((entityliving1) -> { ++ return !behaviorcontroller.hasMemory(MemoryModuleType.MOBS) ? false : (behaviorcontroller.getMemory(MemoryModuleType.MOBS).get()).stream().filter((entityliving1) -> { // CraftBukkit - decompile error + return entityliving1.getEntityType() == entityliving.getEntityType(); + }).filter((entityliving1) -> { + return blockposition.a((IPosition) entityliving1.getPositionVector(), 2.0D); +@@ -155,7 +169,7 @@ + if (behaviorcontroller.getMemory(MemoryModuleType.DOORS_TO_CLOSE).isPresent()) { + ((Set) behaviorcontroller.getMemory(MemoryModuleType.DOORS_TO_CLOSE).get()).add(globalpos); + } else { +- behaviorcontroller.setMemory(MemoryModuleType.DOORS_TO_CLOSE, (Object) Sets.newHashSet(new GlobalPos[]{globalpos})); ++ behaviorcontroller.setMemory(MemoryModuleType.DOORS_TO_CLOSE, Sets.newHashSet(new GlobalPos[]{globalpos})); // CraftBukkit - decompile error + } + + } diff --git a/nms-patches/BehaviorMakeLove.patch b/nms-patches/BehaviorMakeLove.patch index 32154cb3e7..935ea5590b 100644 --- a/nms-patches/BehaviorMakeLove.patch +++ b/nms-patches/BehaviorMakeLove.patch @@ -2,8 +2,8 @@ +++ b/net/minecraft/server/BehaviorMakeLove.java @@ -93,6 +93,11 @@ - private Optional a(EntityVillager entityvillager, EntityVillager entityvillager1) { - EntityVillager entityvillager2 = entityvillager.createChild(entityvillager1); + private Optional b(WorldServer worldserver, EntityVillager entityvillager, EntityVillager entityvillager1) { + EntityVillager entityvillager2 = entityvillager.createChild(worldserver, entityvillager1); + // CraftBukkit start - call EntityBreedEvent + if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityBreedEvent(entityvillager2, entityvillager, entityvillager1, null, null, 0).isCancelled()) { + return Optional.empty(); @@ -16,9 +16,9 @@ entityvillager1.setAgeRaw(6000); entityvillager2.setAgeRaw(-24000); entityvillager2.setPositionRotation(entityvillager.locX(), entityvillager.locY(), entityvillager.locZ(), 0.0F, 0.0F); -- entityvillager.world.addEntity(entityvillager2); -+ entityvillager.world.addEntity(entityvillager2, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - added SpawnReason - entityvillager.world.broadcastEntityEffect(entityvillager2, (byte) 12); +- worldserver.addAllEntities(entityvillager2); ++ worldserver.addAllEntities(entityvillager2, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - added SpawnReason + worldserver.broadcastEntityEffect(entityvillager2, (byte) 12); return Optional.of(entityvillager2); } @@ -110,6 +115,6 @@ diff --git a/nms-patches/BehaviorProfession.patch b/nms-patches/BehaviorProfession.patch index 0f08c136c3..facca964f6 100644 --- a/nms-patches/BehaviorProfession.patch +++ b/nms-patches/BehaviorProfession.patch @@ -25,6 +25,6 @@ + + entityvillager.setVillagerData(entityvillager.getVillagerData().withProfession(CraftVillager.bukkitToNmsProfession(event.getProfession()))); + // CraftBukkit end - entityvillager.b(worldserver); + entityvillager.c(worldserver); } } diff --git a/nms-patches/BehaviorWork.patch b/nms-patches/BehaviorWork.patch deleted file mode 100644 index b2973100e2..0000000000 --- a/nms-patches/BehaviorWork.patch +++ /dev/null @@ -1,26 +0,0 @@ ---- a/net/minecraft/server/BehaviorWork.java -+++ b/net/minecraft/server/BehaviorWork.java -@@ -27,19 +27,19 @@ - protected void a(WorldServer worldserver, EntityVillager entityvillager, long i) { - BehaviorController behaviorcontroller = entityvillager.getBehaviorController(); - -- behaviorcontroller.setMemory(MemoryModuleType.LAST_WORKED_AT_POI, (Object) i); -+ behaviorcontroller.setMemory(MemoryModuleType.LAST_WORKED_AT_POI, i); // CraftBukkit - decompile error - behaviorcontroller.getMemory(MemoryModuleType.JOB_SITE).ifPresent((globalpos) -> { -- behaviorcontroller.setMemory(MemoryModuleType.LOOK_TARGET, (Object) (new BehaviorTarget(globalpos.getBlockPosition()))); -+ behaviorcontroller.setMemory(MemoryModuleType.LOOK_TARGET, (new BehaviorTarget(globalpos.getBlockPosition()))); // CraftBukkit - decompile error - }); - entityvillager.fd(); -- this.a(worldserver, entityvillager); -+ this.doWork(worldserver, entityvillager); // PAIL - if (entityvillager.fc()) { - entityvillager.fb(); - } - - } - -- protected void a(WorldServer worldserver, EntityVillager entityvillager) {} -+ protected void doWork(WorldServer worldserver, EntityVillager entityvillager) {} // PAIL - - protected boolean b(WorldServer worldserver, EntityVillager entityvillager, long i) { - Optional optional = entityvillager.getBehaviorController().getMemory(MemoryModuleType.JOB_SITE); diff --git a/nms-patches/BehaviorWorkComposter.patch b/nms-patches/BehaviorWorkComposter.patch index 1c02031df3..e13157e0ee 100644 --- a/nms-patches/BehaviorWorkComposter.patch +++ b/nms-patches/BehaviorWorkComposter.patch @@ -9,21 +9,21 @@ Optional optional = entityvillager.getBehaviorController().getMemory(MemoryModuleType.JOB_SITE); if (optional.isPresent()) { -@@ -28,7 +28,7 @@ +@@ -30,7 +30,7 @@ + BlockPosition blockposition = globalpos.getBlockPosition(); - private void a(WorldServer worldserver, EntityVillager entityvillager, GlobalPos globalpos, IBlockData iblockdata) { if ((Integer) iblockdata.get(BlockComposter.a) == 8) { -- iblockdata = BlockComposter.d(iblockdata, (World) worldserver, globalpos.getBlockPosition()); -+ iblockdata = BlockComposter.d(iblockdata, (World) worldserver, globalpos.getBlockPosition(), entityvillager); // CraftBukkit +- iblockdata = BlockComposter.d(iblockdata, (World) worldserver, blockposition); ++ iblockdata = BlockComposter.d(iblockdata, (World) worldserver, blockposition, entityvillager); // CraftBukkit } int i = 20; -@@ -52,7 +52,7 @@ +@@ -55,7 +55,7 @@ i -= k1; for (int l1 = 0; l1 < k1; ++l1) { -- iblockdata = BlockComposter.a(iblockdata, worldserver, itemstack, globalpos.getBlockPosition()); -+ iblockdata = BlockComposter.a(iblockdata, worldserver, itemstack, globalpos.getBlockPosition(), entityvillager); // CraftBukkit - if ((Integer) iblockdata.get(BlockComposter.a) == 7) { +- iblockdata1 = BlockComposter.a(iblockdata1, worldserver, itemstack, blockposition); ++ iblockdata1 = BlockComposter.a(iblockdata1, worldserver, itemstack, blockposition, entityvillager); // CraftBukkit + if ((Integer) iblockdata1.get(BlockComposter.a) == 7) { + this.a(worldserver, iblockdata, blockposition, iblockdata1); return; - } diff --git a/nms-patches/BiomeStorage.patch b/nms-patches/BiomeStorage.patch index a3c6902bc7..278584550d 100644 --- a/nms-patches/BiomeStorage.patch +++ b/nms-patches/BiomeStorage.patch @@ -1,26 +1,8 @@ --- a/net/minecraft/server/BiomeStorage.java +++ b/net/minecraft/server/BiomeStorage.java -@@ -88,7 +88,7 @@ - int[] aint = new int[this.g.length]; +@@ -87,4 +87,14 @@ - for (int i = 0; i < this.g.length; ++i) { -- aint[i] = IRegistry.BIOME.a((Object) this.g[i]); -+ aint[i] = IRegistry.BIOME.a(this.g[i]); // CraftBukkit - decompile error - } - - return aint; -@@ -101,7 +101,7 @@ - for (int j = 0; j < i; ++j) { - BiomeBase biomebase = abiomebase[j]; - -- packetdataserializer.writeInt(IRegistry.BIOME.a((Object) biomebase)); -+ packetdataserializer.writeInt(IRegistry.BIOME.a(biomebase)); // CraftBukkit - decompile error - } - - } -@@ -118,4 +118,14 @@ - - return this.g[i1 << BiomeStorage.e + BiomeStorage.e | j1 << BiomeStorage.e | l]; + return this.h[i1 << BiomeStorage.e + BiomeStorage.e | j1 << BiomeStorage.e | l]; } + + // CraftBukkit start @@ -29,7 +11,7 @@ + int i1 = MathHelper.clamp(j, 0, BiomeStorage.c); + int j1 = k & BiomeStorage.b; + -+ this.g[i1 << BiomeStorage.e + BiomeStorage.e | j1 << BiomeStorage.e | l] = biome; ++ this.h[i1 << BiomeStorage.e + BiomeStorage.e | j1 << BiomeStorage.e | l] = biome; + } + // CraftBukkit end } diff --git a/nms-patches/Block.patch b/nms-patches/Block.patch index d1232830bd..b7478480fc 100644 --- a/nms-patches/Block.patch +++ b/nms-patches/Block.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/Block.java +++ b/net/minecraft/server/Block.java -@@ -217,7 +217,13 @@ +@@ -209,7 +209,13 @@ EntityItem entityitem = new EntityItem(world, (double) blockposition.getX() + d0, (double) blockposition.getY() + d1, (double) blockposition.getZ() + d2, itemstack); entityitem.defaultPickupDelay(); @@ -15,12 +15,12 @@ } } -@@ -344,6 +350,12 @@ +@@ -336,6 +342,12 @@ return this; } + // CraftBukkit start -+ public int getExpDrop(IBlockData iblockdata, World world, BlockPosition blockposition, ItemStack itemstack) { ++ public int getExpDrop(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, ItemStack itemstack) { + return 0; + } + // CraftBukkit end diff --git a/nms-patches/BlockBamboo.patch b/nms-patches/BlockBamboo.patch index 2ed22225a9..af220d3a5b 100644 --- a/nms-patches/BlockBamboo.patch +++ b/nms-patches/BlockBamboo.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/BlockBamboo.java +++ b/net/minecraft/server/BlockBamboo.java -@@ -168,14 +168,18 @@ +@@ -170,14 +170,18 @@ BlockPosition blockposition1 = blockposition.down(2); IBlockData iblockdata2 = world.getType(blockposition1); BlockPropertyBambooSize blockpropertybamboosize = BlockPropertyBambooSize.NONE; @@ -21,7 +21,7 @@ } } } else { -@@ -186,7 +190,14 @@ +@@ -188,7 +192,14 @@ int j = (Integer) iblockdata.get(BlockBamboo.d) != 1 && !iblockdata2.a(Blocks.BAMBOO) ? 0 : 1; int k = (i < 11 || random.nextFloat() >= 0.25F) && i != 15 ? 0 : 1; diff --git a/nms-patches/BlockBed.patch b/nms-patches/BlockBed.patch index 7cab7a89a8..9b349be8b1 100644 --- a/nms-patches/BlockBed.patch +++ b/nms-patches/BlockBed.patch @@ -56,12 +56,3 @@ } private boolean a(World world, BlockPosition blockposition) { -@@ -225,7 +254,7 @@ - AxisAlignedBB axisalignedbb = entitytypes.a(vec3d.x, vec3d.y, vec3d.z); - - if (iworldreader.b(axisalignedbb)) { -- Stream stream = iworldreader.a(axisalignedbb.b(0.0D, -0.20000000298023224D, 0.0D)); -+ Stream stream = iworldreader.a(axisalignedbb.b(0.0D, -0.20000000298023224D, 0.0D)); // CraftBukkit - decompile error - - entitytypes.getClass(); - if (stream.noneMatch(entitytypes::a)) { diff --git a/nms-patches/BlockChorusFlower.patch b/nms-patches/BlockChorusFlower.patch index f66e68b71c..4ca36ec163 100644 --- a/nms-patches/BlockChorusFlower.patch +++ b/nms-patches/BlockChorusFlower.patch @@ -14,11 +14,11 @@ if (flag && b((IWorldReader) worldserver, blockposition1, (EnumDirection) null) && worldserver.isEmpty(blockposition.up(2))) { - worldserver.setTypeAndData(blockposition, this.b.a((IBlockAccess) worldserver, blockposition), 2); -- this.b(worldserver, blockposition1, i); +- this.a(worldserver, blockposition1, i); + // CraftBukkit start - add event + if (CraftEventFactory.handleBlockSpreadEvent(worldserver, blockposition, blockposition1, this.getBlockData().set(BlockChorusFlower.AGE, Integer.valueOf(i)), 2)) { + worldserver.setTypeAndData(blockposition, this.b.a((IBlockAccess) worldserver, blockposition), 2); -+ this.b(worldserver, blockposition1, i); ++ this.a(worldserver, blockposition1, i); + } + // CraftBukkit end } else if (i < 4) { @@ -28,11 +28,11 @@ BlockPosition blockposition2 = blockposition.shift(enumdirection); if (worldserver.isEmpty(blockposition2) && worldserver.isEmpty(blockposition2.down()) && b((IWorldReader) worldserver, blockposition2, enumdirection.opposite())) { -- this.b(worldserver, blockposition2, i + 1); +- this.a(worldserver, blockposition2, i + 1); - flag2 = true; + // CraftBukkit start - add event + if (CraftEventFactory.handleBlockSpreadEvent(worldserver, blockposition, blockposition2, this.getBlockData().set(BlockChorusFlower.AGE, Integer.valueOf(i + 1)), 2)) { -+ this.b(worldserver, blockposition2, i + 1); ++ this.a(worldserver, blockposition2, i + 1); + flag2 = true; + } + // CraftBukkit end diff --git a/nms-patches/BlockComposter.patch b/nms-patches/BlockComposter.patch index 02af604e98..3121dd5a13 100644 --- a/nms-patches/BlockComposter.patch +++ b/nms-patches/BlockComposter.patch @@ -47,8 +47,8 @@ + // CraftBukkit end itemstack.subtract(1); - worldserver.triggerEffect(1500, blockposition, iblockdata != iblockdata1 ? 1 : 0); -@@ -177,7 +188,15 @@ + return iblockdata1; +@@ -176,7 +187,15 @@ } } @@ -65,7 +65,7 @@ if (!world.isClientSide) { float f = 0.7F; double d0 = (double) (world.random.nextFloat() * 0.7F) + 0.15000000596046448D; -@@ -203,10 +222,16 @@ +@@ -202,10 +221,16 @@ } private static IBlockData b(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition, ItemStack itemstack) { @@ -83,7 +83,7 @@ return iblockdata; } else { int j = i + 1; -@@ -254,7 +279,8 @@ +@@ -253,7 +278,8 @@ public IWorldInventory a(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition) { int i = (Integer) iblockdata.get(BlockComposter.a); @@ -93,7 +93,7 @@ } static class ContainerInput extends InventorySubcontainer implements IWorldInventory { -@@ -266,6 +292,7 @@ +@@ -265,6 +291,7 @@ public ContainerInput(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition) { super(1); @@ -101,7 +101,7 @@ this.a = iblockdata; this.b = generatoraccess; this.c = blockposition; -@@ -318,6 +345,7 @@ +@@ -317,6 +344,7 @@ this.blockData = iblockdata; this.generatorAccess = generatoraccess; this.blockPosition = blockposition; @@ -109,7 +109,7 @@ } @Override -@@ -342,15 +370,23 @@ +@@ -341,15 +369,23 @@ @Override public void update() { diff --git a/nms-patches/BlockConcretePowder.patch b/nms-patches/BlockConcretePowder.patch index 5c40d1d0d2..802db9bdd0 100644 --- a/nms-patches/BlockConcretePowder.patch +++ b/nms-patches/BlockConcretePowder.patch @@ -46,18 +46,22 @@ } private static boolean canHarden(IBlockAccess iblockaccess, BlockPosition blockposition, IBlockData iblockdata) { -@@ -59,6 +81,20 @@ +@@ -59,6 +81,24 @@ @Override public IBlockData updateState(IBlockData iblockdata, EnumDirection enumdirection, IBlockData iblockdata1, GeneratorAccess generatoraccess, BlockPosition blockposition, BlockPosition blockposition1) { - return a((IBlockAccess) generatoraccess, blockposition) ? this.a : super.updateState(iblockdata, enumdirection, iblockdata1, generatoraccess, blockposition, blockposition1); + // CraftBukkit start + if (a((IBlockAccess) generatoraccess, blockposition)) { ++ // Suppress during worldgen ++ if (!(generatoraccess instanceof World)) { ++ return this.a; ++ } + CraftBlockState blockState = CraftBlockState.getBlockState(generatoraccess, blockposition); + blockState.setData(this.a); + + BlockFormEvent event = new BlockFormEvent(blockState.getBlock(), blockState); -+ generatoraccess.getMinecraftWorld().getMinecraftServer().server.getPluginManager().callEvent(event); ++ ((World) generatoraccess).getServer().getPluginManager().callEvent(event); + + if (!event.isCancelled()) { + return blockState.getHandle(); diff --git a/nms-patches/BlockDoor.patch b/nms-patches/BlockDoor.patch index a4cd74c32e..7e29c5cff8 100644 --- a/nms-patches/BlockDoor.patch +++ b/nms-patches/BlockDoor.patch @@ -9,7 +9,7 @@ public class BlockDoor extends Block { public static final BlockStateDirection FACING = BlockFacingHorizontal.FACING; -@@ -155,9 +157,24 @@ +@@ -157,9 +159,24 @@ @Override public void doPhysics(IBlockData iblockdata, World world, BlockPosition blockposition, Block block, BlockPosition blockposition1, boolean flag) { @@ -34,5 +34,5 @@ + boolean flag1 = eventRedstone.getNewCurrent() > 0; + // CraftBukkit end if (flag1 != (Boolean) iblockdata.get(BlockDoor.OPEN)) { - this.b(world, blockposition, flag1); + this.a(world, blockposition, flag1); } diff --git a/nms-patches/BlockDropper.patch b/nms-patches/BlockDropper.patch index 23ac1e1846..b29190759a 100644 --- a/nms-patches/BlockDropper.patch +++ b/nms-patches/BlockDropper.patch @@ -29,7 +29,7 @@ + } + + InventoryMoveItemEvent event = new InventoryMoveItemEvent(tileentitydispenser.getOwner().getInventory(), oitemstack.clone(), destinationInventory, true); -+ world.getServer().getPluginManager().callEvent(event); ++ worldserver.getServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { + return; + } diff --git a/nms-patches/BlockEnderPortal.patch b/nms-patches/BlockEnderPortal.patch index 9338d0cf17..b70bbb2595 100644 --- a/nms-patches/BlockEnderPortal.patch +++ b/nms-patches/BlockEnderPortal.patch @@ -24,10 +24,10 @@ + world.getServer().getPluginManager().callEvent(event); + + if (entity instanceof EntityPlayer) { -+ ((EntityPlayer) entity).a(worldserver, PlayerTeleportEvent.TeleportCause.END_PORTAL); ++ ((EntityPlayer) entity).b(worldserver, PlayerTeleportEvent.TeleportCause.END_PORTAL); + return; + } + // CraftBukkit end - entity.a(worldserver); + entity.b(worldserver); } diff --git a/nms-patches/BlockFire.patch b/nms-patches/BlockFire.patch index 029ce90921..2788f4cd45 100644 --- a/nms-patches/BlockFire.patch +++ b/nms-patches/BlockFire.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/BlockFire.java +++ b/net/minecraft/server/BlockFire.java -@@ -5,6 +5,13 @@ - import java.util.Map; - import java.util.Random; +@@ -8,6 +8,13 @@ + import java.util.function.Function; + import java.util.stream.Collectors; +// CraftBukkit start +import org.bukkit.craftbukkit.block.CraftBlockState; @@ -14,7 +14,7 @@ public class BlockFire extends BlockFireAbstract { public static final BlockStateInteger AGE = BlockProperties.aj; -@@ -26,7 +33,24 @@ +@@ -64,7 +71,24 @@ @Override public IBlockData updateState(IBlockData iblockdata, EnumDirection enumdirection, IBlockData iblockdata1, GeneratorAccess generatoraccess, BlockPosition blockposition, BlockPosition blockposition1) { @@ -29,7 +29,7 @@ + blockState.setData(Blocks.AIR.getBlockData()); + + BlockFadeEvent event = new BlockFadeEvent(blockState.getBlock(), blockState); -+ generatoraccess.getMinecraftWorld().getMinecraftServer().server.getPluginManager().callEvent(event); ++ ((World) generatoraccess).getServer().getPluginManager().callEvent(event); + + if (!event.isCancelled()) { + return blockState.getHandle(); @@ -40,7 +40,7 @@ } @Override -@@ -97,7 +121,7 @@ +@@ -113,7 +137,7 @@ worldserver.getBlockTickList().a(blockposition, this, a(worldserver.random)); if (worldserver.getGameRules().getBoolean(GameRules.DO_FIRE_TICK)) { if (!iblockdata.canPlace(worldserver, blockposition)) { @@ -49,7 +49,7 @@ } IBlockData iblockdata1 = worldserver.getType(blockposition.down()); -@@ -105,7 +129,7 @@ +@@ -121,7 +145,7 @@ int i = (Integer) iblockdata.get(BlockFire.AGE); if (!flag && worldserver.isRaining() && this.a((World) worldserver, blockposition) && random.nextFloat() < 0.2F + (float) i * 0.03F) { @@ -58,7 +58,7 @@ } else { int j = Math.min(15, i + random.nextInt(3) / 2); -@@ -119,14 +143,14 @@ +@@ -135,14 +159,14 @@ BlockPosition blockposition1 = blockposition.down(); if (!worldserver.getType(blockposition1).d(worldserver, blockposition1, EnumDirection.UP) || i > 3) { @@ -75,7 +75,7 @@ return; } } -@@ -134,12 +158,14 @@ +@@ -150,12 +174,14 @@ boolean flag1 = worldserver.u(blockposition); int k = flag1 ? -50 : 0; @@ -96,7 +96,7 @@ BlockPosition.MutableBlockPosition blockposition_mutableblockposition = new BlockPosition.MutableBlockPosition(); for (int l = -1; l <= 1; ++l) { -@@ -165,7 +191,15 @@ +@@ -181,7 +207,15 @@ if (i2 > 0 && random.nextInt(k1) <= i2 && (!worldserver.isRaining() || !this.a((World) worldserver, (BlockPosition) blockposition_mutableblockposition))) { int j2 = Math.min(15, i + random.nextInt(5) / 4); @@ -113,7 +113,7 @@ } } } -@@ -189,12 +223,24 @@ +@@ -205,12 +239,24 @@ return iblockdata.b(BlockProperties.C) && (Boolean) iblockdata.get(BlockProperties.C) ? 0 : this.flameChances.getInt(iblockdata.getBlock()); } diff --git a/nms-patches/BlockFireAbstract.patch b/nms-patches/BlockFireAbstract.patch index 42f69a61f5..8060e1c125 100644 --- a/nms-patches/BlockFireAbstract.patch +++ b/nms-patches/BlockFireAbstract.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/BlockFireAbstract.java +++ b/net/minecraft/server/BlockFireAbstract.java -@@ -41,7 +41,14 @@ +@@ -36,7 +36,14 @@ if (!entity.isFireProof()) { entity.setFireTicks(entity.getFireTicks() + 1); if (entity.getFireTicks() == 0) { @@ -15,23 +15,27 @@ + // CraftBukkit end } - entity.damageEntity(DamageSource.FIRE, this.g); -@@ -53,9 +60,10 @@ - @Override - public void onPlace(IBlockData iblockdata, World world, BlockPosition blockposition, IBlockData iblockdata1, boolean flag) { - if (!iblockdata1.a(iblockdata.getBlock())) { -- if (world.getDimensionKey() != World.OVERWORLD && world.getDimensionKey() != World.THE_NETHER || !BlockPortal.a((GeneratorAccess) world, blockposition)) { -+ // CraftBukkit - getTypeKey() -+ if (world.getTypeKey() != DimensionManager.OVERWORLD && world.getTypeKey() != DimensionManager.THE_NETHER || !BlockPortal.a((GeneratorAccess) world, blockposition)) { - if (!iblockdata.canPlace(world, blockposition)) { -- world.a(blockposition, false); -+ fireExtinguished(world, blockposition); // CraftBukkit - fuel block broke - } - + entity.damageEntity(DamageSource.FIRE, this.b); +@@ -58,14 +65,14 @@ } -@@ -92,4 +100,12 @@ - return true; + if (!iblockdata.canPlace(world, blockposition)) { +- world.a(blockposition, false); ++ fireExtinguished(world, blockposition); // CraftBukkit - fuel block broke + } + + } + } + + private static boolean a(World world) { +- return world.getDimensionKey() == World.OVERWORLD || world.getDimensionKey() == World.THE_NETHER; ++ return world.getTypeKey() != DimensionManager.OVERWORLD && world.getTypeKey() != DimensionManager.THE_NETHER; // CraftBukkit - getTypeKey() + } + + @Override +@@ -103,4 +110,12 @@ + return flag && BlockPortalShape.a((GeneratorAccess) world, blockposition, enumdirection.h().n()).isPresent(); + } } + + // CraftBukkit start diff --git a/nms-patches/BlockFungi.patch b/nms-patches/BlockFungi.patch index db581eb317..b10cddf1ba 100644 --- a/nms-patches/BlockFungi.patch +++ b/nms-patches/BlockFungi.patch @@ -11,6 +11,6 @@ + BlockSapling.treeType = org.bukkit.TreeType.CRIMSON_FUNGUS; + } + // CraftBukkit end - ((WorldGenFeatureConfigured) this.b.get()).a(worldserver, worldserver.getStructureManager(), worldserver.getChunkProvider().getChunkGenerator(), random, blockposition); + ((WorldGenFeatureConfigured) this.b.get()).a(worldserver, worldserver.getChunkProvider().getChunkGenerator(), random, blockposition); } } diff --git a/nms-patches/BlockGrass.patch b/nms-patches/BlockGrass.patch index f1d453345a..f5eb144deb 100644 --- a/nms-patches/BlockGrass.patch +++ b/nms-patches/BlockGrass.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/BlockGrass.java +++ b/net/minecraft/server/BlockGrass.java -@@ -63,7 +63,7 @@ +@@ -64,7 +64,7 @@ } if (iblockdata3.canPlace(worldserver, blockposition2)) { diff --git a/nms-patches/BlockGrowingTop.patch b/nms-patches/BlockGrowingTop.patch index 9549e95255..4c565c223b 100644 --- a/nms-patches/BlockGrowingTop.patch +++ b/nms-patches/BlockGrowingTop.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/BlockGrowingTop.java +++ b/net/minecraft/server/BlockGrowingTop.java -@@ -36,7 +36,7 @@ +@@ -29,7 +29,7 @@ BlockPosition blockposition1 = blockposition.shift(this.a); if (this.h(worldserver.getType(blockposition1))) { diff --git a/nms-patches/BlockMinecartDetector.patch b/nms-patches/BlockMinecartDetector.patch index b63276b3dc..4a0f051af5 100644 --- a/nms-patches/BlockMinecartDetector.patch +++ b/nms-patches/BlockMinecartDetector.patch @@ -9,20 +9,20 @@ public class BlockMinecartDetector extends BlockMinecartTrackAbstract { public static final BlockStateEnum SHAPE = BlockProperties.ad; -@@ -57,6 +59,16 @@ - } +@@ -58,6 +60,16 @@ + } - IBlockData iblockdata1; -+ // CraftBukkit start -+ if (flag != flag1) { -+ org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); + IBlockData iblockdata1; ++ // CraftBukkit start ++ if (flag != flag1) { ++ org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); + -+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, flag ? 15 : 0, flag1 ? 15 : 0); -+ world.getServer().getPluginManager().callEvent(eventRedstone); ++ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, flag ? 15 : 0, flag1 ? 15 : 0); ++ world.getServer().getPluginManager().callEvent(eventRedstone); + -+ flag1 = eventRedstone.getNewCurrent() > 0; -+ } -+ // CraftBukkit end ++ flag1 = eventRedstone.getNewCurrent() > 0; ++ } ++ // CraftBukkit end - if (flag1 && !flag) { - iblockdata1 = (IBlockData) iblockdata.set(BlockMinecartDetector.POWERED, true); + if (flag1 && !flag) { + iblockdata1 = (IBlockData) iblockdata.set(BlockMinecartDetector.POWERED, true); diff --git a/nms-patches/BlockMobSpawner.patch b/nms-patches/BlockMobSpawner.patch index 19ce837bad..d93b2c5582 100644 --- a/nms-patches/BlockMobSpawner.patch +++ b/nms-patches/BlockMobSpawner.patch @@ -2,18 +2,18 @@ +++ b/net/minecraft/server/BlockMobSpawner.java @@ -14,9 +14,19 @@ @Override - public void dropNaturally(IBlockData iblockdata, World world, BlockPosition blockposition, ItemStack itemstack) { - super.dropNaturally(iblockdata, world, blockposition, itemstack); + public void dropNaturally(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, ItemStack itemstack) { + super.dropNaturally(iblockdata, worldserver, blockposition, itemstack); + /* CraftBukkit start - Delegate to getExpDrop - int i = 15 + world.random.nextInt(15) + world.random.nextInt(15); + int i = 15 + worldserver.random.nextInt(15) + worldserver.random.nextInt(15); - this.dropExperience(world, blockposition, i); + this.dropExperience(worldserver, blockposition, i); + */ + } + + @Override -+ public int getExpDrop(IBlockData iblockdata, World world, BlockPosition blockposition, ItemStack itemstack) { -+ int i = 15 + world.random.nextInt(15) + world.random.nextInt(15); ++ public int getExpDrop(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, ItemStack itemstack) { ++ int i = 15 + worldserver.random.nextInt(15) + worldserver.random.nextInt(15); + + return i; + // CraftBukkit end diff --git a/nms-patches/BlockMonsterEggs.patch b/nms-patches/BlockMonsterEggs.patch index 08a2a82950..74a1530637 100644 --- a/nms-patches/BlockMonsterEggs.patch +++ b/nms-patches/BlockMonsterEggs.patch @@ -10,11 +10,11 @@ private final Block a; @@ -26,7 +28,7 @@ - EntitySilverfish entitysilverfish = (EntitySilverfish) EntityTypes.SILVERFISH.a(world); + EntitySilverfish entitysilverfish = (EntitySilverfish) EntityTypes.SILVERFISH.a((World) worldserver); entitysilverfish.setPositionRotation((double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, 0.0F, 0.0F); -- world.addEntity(entitysilverfish); -+ world.addEntity(entitysilverfish, SpawnReason.SILVERFISH_BLOCK); // CraftBukkit - add SpawnReason +- worldserver.addEntity(entitysilverfish); ++ worldserver.addEntity(entitysilverfish, SpawnReason.SILVERFISH_BLOCK); // CraftBukkit - add SpawnReason entitysilverfish.doSpawnEffect(); } diff --git a/nms-patches/BlockMushroom.patch b/nms-patches/BlockMushroom.patch index 33c0bbf9d8..671f3734aa 100644 --- a/nms-patches/BlockMushroom.patch +++ b/nms-patches/BlockMushroom.patch @@ -20,22 +20,19 @@ } } -@@ -69,14 +73,16 @@ +@@ -69,6 +73,7 @@ WorldGenFeatureConfigured worldgenfeatureconfigured; if (this == Blocks.BROWN_MUSHROOM) { -- worldgenfeatureconfigured = WorldGenerator.HUGE_BROWN_MUSHROOM.b((WorldGenFeatureConfiguration) BiomeDecoratorGroups.HUGE_BROWN_MUSHROOM); + BlockSapling.treeType = TreeType.BROWN_MUSHROOM; // CraftBukkit -+ worldgenfeatureconfigured = WorldGenerator.HUGE_BROWN_MUSHROOM.b(BiomeDecoratorGroups.HUGE_BROWN_MUSHROOM); // CraftBukkit - decompile error + worldgenfeatureconfigured = BiomeDecoratorGroups.HUGE_BROWN_MUSHROOM; } else { if (this != Blocks.RED_MUSHROOM) { - worldserver.setTypeAndData(blockposition, iblockdata, 3); +@@ -76,6 +81,7 @@ return false; } -- worldgenfeatureconfigured = WorldGenerator.HUGE_RED_MUSHROOM.b((WorldGenFeatureConfiguration) BiomeDecoratorGroups.HUGE_RED_MUSHROOM); + BlockSapling.treeType = TreeType.RED_MUSHROOM; // CraftBukkit -+ worldgenfeatureconfigured = WorldGenerator.HUGE_RED_MUSHROOM.b(BiomeDecoratorGroups.HUGE_RED_MUSHROOM); // CraftBukkit - decompile error + worldgenfeatureconfigured = BiomeDecoratorGroups.HUGE_RED_MUSHROOM; } - if (worldgenfeatureconfigured.a(worldserver, worldserver.getStructureManager(), worldserver.getChunkProvider().getChunkGenerator(), random, blockposition)) { diff --git a/nms-patches/BlockOre.patch b/nms-patches/BlockOre.patch index 9ac9284134..597134ad52 100644 --- a/nms-patches/BlockOre.patch +++ b/nms-patches/BlockOre.patch @@ -2,14 +2,14 @@ +++ b/net/minecraft/server/BlockOre.java @@ -15,6 +15,7 @@ @Override - public void dropNaturally(IBlockData iblockdata, World world, BlockPosition blockposition, ItemStack itemstack) { - super.dropNaturally(iblockdata, world, blockposition, itemstack); + public void dropNaturally(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, ItemStack itemstack) { + super.dropNaturally(iblockdata, worldserver, blockposition, itemstack); + /* CraftBukkit start - Delegated to getExpDrop if (EnchantmentManager.getEnchantmentLevel(Enchantments.SILK_TOUCH, itemstack) == 0) { - int i = this.a(world.random); + int i = this.a(worldserver.random); @@ -22,6 +23,21 @@ - this.dropExperience(world, blockposition, i); + this.dropExperience(worldserver, blockposition, i); } } + // */ @@ -17,9 +17,9 @@ } + + @Override -+ public int getExpDrop(IBlockData iblockdata, World world, BlockPosition blockposition, ItemStack itemstack) { ++ public int getExpDrop(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, ItemStack itemstack) { + if (EnchantmentManager.getEnchantmentLevel(Enchantments.SILK_TOUCH, itemstack) == 0) { -+ int i = this.a(world.random); ++ int i = this.a(worldserver.random); + + if (i > 0) { + return i; diff --git a/nms-patches/BlockPiston.patch b/nms-patches/BlockPiston.patch index 8eaade117f..041c191f61 100644 --- a/nms-patches/BlockPiston.patch +++ b/nms-patches/BlockPiston.patch @@ -34,7 +34,7 @@ world.playBlockAction(blockposition, this, b0, enumdirection.c()); } -@@ -277,6 +297,48 @@ +@@ -279,6 +299,48 @@ IBlockData[] aiblockdata = new IBlockData[list.size() + list2.size()]; EnumDirection enumdirection1 = flag ? enumdirection : enumdirection.opposite(); int j = 0; diff --git a/nms-patches/BlockPortal.patch b/nms-patches/BlockPortal.patch index 1e178e37e6..c4b1aa516f 100644 --- a/nms-patches/BlockPortal.patch +++ b/nms-patches/BlockPortal.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/BlockPortal.java +++ b/net/minecraft/server/BlockPortal.java -@@ -4,6 +4,13 @@ +@@ -2,6 +2,13 @@ + import java.util.Random; - import javax.annotation.Nullable; +// CraftBukkit start +import org.bukkit.craftbukkit.block.CraftBlock; @@ -14,7 +14,7 @@ public class BlockPortal extends Block { public static final BlockStateEnum AXIS = BlockProperties.E; -@@ -34,7 +41,8 @@ +@@ -32,7 +39,8 @@ } if (worldserver.getType(blockposition).a((IBlockAccess) worldserver, blockposition, EntityTypes.ZOMBIFIED_PIGLIN)) { @@ -23,21 +23,8 @@ + Entity entity = EntityTypes.ZOMBIFIED_PIGLIN.spawnCreature(worldserver, (NBTTagCompound) null, (IChatBaseComponent) null, (EntityHuman) null, blockposition.up(), EnumMobSpawn.STRUCTURE, false, false, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NETHER_PORTAL); if (entity != null) { - entity.portalCooldown = entity.getDefaultPortalCooldown(); -@@ -48,8 +56,10 @@ - BlockPortal.Shape blockportal_shape = b(generatoraccess, blockposition); - - if (blockportal_shape != null) { -- blockportal_shape.createPortal(); -- return true; -+ // CraftBukkit start - return portalcreator -+ return blockportal_shape.createPortal(); -+ // return true; -+ // CraftBukkit end - } else { - return false; - } -@@ -80,6 +90,10 @@ + entity.resetPortalCooldown(); +@@ -54,6 +62,10 @@ @Override public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { if (!entity.isPassenger() && !entity.isVehicle() && entity.canPortal()) { @@ -48,92 +35,3 @@ entity.d(blockposition); } -@@ -172,6 +186,7 @@ - private BlockPosition position; - private int height; - private int width; -+ java.util.List blocks = new java.util.ArrayList(); // CraftBukkit - add field - - public Shape(GeneratorAccess generatoraccess, BlockPosition blockposition, EnumDirection.EnumAxis enumdirection_enumaxis) { - this.a = generatoraccess; -@@ -228,6 +243,9 @@ - } - - protected int c() { -+ // CraftBukkit start -+ this.blocks.clear(); -+ // CraftBukkit end - int i; - - label56: -@@ -247,9 +265,19 @@ - if (i == 0) { - if (!this.a.getType(blockposition.shift(this.d)).a(Blocks.OBSIDIAN)) { - break label56; -+ // CraftBukkit start - add the block to our list -+ } else { -+ BlockPosition pos = blockposition.shift(this.d); -+ blocks.add(CraftBlock.at(this.a, pos).getState()); -+ // CraftBukkit end - } - } else if (i == this.width - 1 && !this.a.getType(blockposition.shift(this.c)).a(Blocks.OBSIDIAN)) { - break label56; -+ // CraftBukkit start - add the block to our list -+ } else { -+ BlockPosition pos = blockposition.shift(this.c); -+ blocks.add(CraftBlock.at(this.a, pos).getState()); -+ // CraftBukkit end - } - } - } -@@ -258,6 +286,11 @@ - if (!this.a.getType(this.position.shift(this.c, i).up(this.height)).a(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(CraftBlock.at(this.a, pos).getState()); -+ // CraftBukkit end - } - } - -@@ -279,7 +312,29 @@ - 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.getMinecraftWorld().getWorld(); -+ -+ // Copy below for loop -+ for (int i = 0; i < this.width; ++i) { -+ BlockPosition blockposition = this.position.shift(this.c, i); -+ -+ for (int j = 0; j < this.height; ++j) { -+ BlockPosition pos = blockposition.up(j); -+ CraftBlockState state = CraftBlockState.getBlockState(this.a.getMinecraftWorld(), pos, 18); -+ state.setData((IBlockData) Blocks.NETHER_PORTAL.getBlockData().set(BlockPortal.AXIS, this.b)); -+ blocks.add(state); -+ } -+ } -+ -+ PortalCreateEvent event = new PortalCreateEvent(blocks, bworld, null, PortalCreateEvent.CreateReason.FIRE); -+ this.a.getMinecraftWorld().getMinecraftServer().server.getPluginManager().callEvent(event); -+ -+ if (event.isCancelled()) { -+ return false; -+ } -+ // CraftBukkit end - for (int i = 0; i < this.width; ++i) { - BlockPosition blockposition = this.position.shift(this.c, i); - -@@ -288,6 +343,7 @@ - } - } - -+ return true; // CraftBukkit - } - - private boolean g() { diff --git a/nms-patches/BlockPortalShape.patch b/nms-patches/BlockPortalShape.patch new file mode 100644 index 0000000000..392adc9ca1 --- /dev/null +++ b/nms-patches/BlockPortalShape.patch @@ -0,0 +1,72 @@ +--- a/net/minecraft/server/BlockPortalShape.java ++++ b/net/minecraft/server/BlockPortalShape.java +@@ -4,6 +4,13 @@ + import java.util.function.Predicate; + import javax.annotation.Nullable; + ++// CraftBukkit start ++import org.bukkit.craftbukkit.block.CraftBlock; ++import org.bukkit.craftbukkit.block.CraftBlockState; ++import org.bukkit.event.entity.EntityPortalEnterEvent; ++import org.bukkit.event.world.PortalCreateEvent; ++// CraftBukkit end ++ + public class BlockPortalShape { + + private static final BlockBase.e a = (iblockdata, iblockaccess, blockposition) -> { +@@ -17,6 +24,7 @@ + private BlockPosition position; + private int height; + private int width; ++ java.util.List blocks = new java.util.ArrayList(); // CraftBukkit - add field + + public static Optional a(GeneratorAccess generatoraccess, BlockPosition blockposition, EnumDirection.EnumAxis enumdirection_enumaxis) { + return a(generatoraccess, blockposition, (blockportalshape) -> { +@@ -81,6 +89,7 @@ + + if (!a(iblockdata)) { + if (BlockPortalShape.a.test(iblockdata, this.b, blockposition_mutableblockposition)) { ++ blocks.add(CraftBlock.at(this.b, blockposition_mutableblockposition).getState()); // CraftBukkit + return i; + } + break; +@@ -152,12 +161,30 @@ + 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.b.getMinecraftWorld().getWorld(); ++ ++ // Copy below for loop + IBlockData iblockdata = (IBlockData) Blocks.NETHER_PORTAL.getBlockData().set(BlockPortal.AXIS, this.c); + + BlockPosition.a(this.position, this.position.shift(EnumDirection.UP, this.height - 1).shift(this.d, this.width - 1)).forEach((blockposition) -> { ++ CraftBlockState state = CraftBlockState.getBlockState(this.b.getMinecraftWorld(), blockposition, 18); ++ state.setData(iblockdata); ++ blocks.add(state); ++ }); ++ ++ PortalCreateEvent event = new PortalCreateEvent(blocks, bworld, null, PortalCreateEvent.CreateReason.FIRE); ++ this.b.getMinecraftWorld().getMinecraftServer().server.getPluginManager().callEvent(event); ++ ++ if (event.isCancelled()) { ++ return false; ++ } ++ // CraftBukkit end ++ BlockPosition.a(this.position, this.position.shift(EnumDirection.UP, this.height - 1).shift(this.d, this.width - 1)).forEach((blockposition) -> { + this.b.setTypeAndData(blockposition, iblockdata, 18); + }); ++ return true; // CraftBukkit + } + + public boolean c() { +@@ -208,6 +235,6 @@ + boolean flag = enumdirection_enumaxis1 == EnumDirection.EnumAxis.X; + Vec3D vec3d3 = new Vec3D((double) blockposition.getX() + (flag ? d2 : d4), (double) blockposition.getY() + d3, (double) blockposition.getZ() + (flag ? d4 : d2)); + +- return new ShapeDetectorShape(vec3d3, vec3d2, f + (float) i, f1); ++ return new ShapeDetectorShape(vec3d3, vec3d2, f + (float) i, f1, worldserver); // CraftBukkit + } + } diff --git a/nms-patches/BlockRedstoneOre.patch b/nms-patches/BlockRedstoneOre.patch index b651f806eb..e7740d32d5 100644 --- a/nms-patches/BlockRedstoneOre.patch +++ b/nms-patches/BlockRedstoneOre.patch @@ -85,22 +85,22 @@ @@ -60,12 +91,25 @@ @Override - public void dropNaturally(IBlockData iblockdata, World world, BlockPosition blockposition, ItemStack itemstack) { - super.dropNaturally(iblockdata, world, blockposition, itemstack); + public void dropNaturally(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, ItemStack itemstack) { + super.dropNaturally(iblockdata, worldserver, blockposition, itemstack); + /* CraftBukkit start - Delegated to getExpDrop if (EnchantmentManager.getEnchantmentLevel(Enchantments.SILK_TOUCH, itemstack) == 0) { - int i = 1 + world.random.nextInt(5); + int i = 1 + worldserver.random.nextInt(5); - this.dropExperience(world, blockposition, i); + this.dropExperience(worldserver, blockposition, i); } + // */ + + } + @Override -+ public int getExpDrop(IBlockData iblockdata, World world, BlockPosition blockposition, ItemStack itemstack) { ++ public int getExpDrop(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, ItemStack itemstack) { + if (EnchantmentManager.getEnchantmentLevel(Enchantments.SILK_TOUCH, itemstack) == 0) { -+ int i = 1 + world.random.nextInt(5); ++ int i = 1 + worldserver.random.nextInt(5); + + return i; + } diff --git a/nms-patches/BlockSponge.patch b/nms-patches/BlockSponge.patch index 2e98c72d4e..c991e8a02b 100644 --- a/nms-patches/BlockSponge.patch +++ b/nms-patches/BlockSponge.patch @@ -52,9 +52,9 @@ + // CraftBukkit start + // TileEntity tileentity = iblockdata.getBlock().isTileEntity() ? world.getTileEntity(blockposition2) : null; -- a(iblockdata, world, blockposition2, tileentity); +- a(iblockdata, (GeneratorAccess) world, blockposition2, tileentity); - world.setTypeAndData(blockposition2, Blocks.AIR.getBlockData(), 3); -+ // a(iblockdata, world, blockposition2, tileentity); ++ // a(iblockdata, (GeneratorAccess) world, blockposition2, tileentity); + blockList.setTypeAndData(blockposition2, Blocks.AIR.getBlockData(), 3); + // CraftBukkit end ++i; diff --git a/nms-patches/BlockVine.patch b/nms-patches/BlockVine.patch index c1940952f6..4b8c62e9d2 100644 --- a/nms-patches/BlockVine.patch +++ b/nms-patches/BlockVine.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/server/BlockVine.java +++ b/net/minecraft/server/BlockVine.java -@@ -5,6 +5,8 @@ - import java.util.Random; +@@ -8,6 +8,8 @@ + import java.util.stream.Collectors; import javax.annotation.Nullable; +import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit @@ -9,7 +9,7 @@ public class BlockVine extends Block { public static final BlockStateBoolean UP = BlockSprawling.e; -@@ -166,20 +168,24 @@ +@@ -175,20 +177,24 @@ BlockPosition blockposition3 = blockposition2.shift(enumdirection1); BlockPosition blockposition4 = blockposition2.shift(enumdirection2); @@ -39,7 +39,7 @@ } } else if (a((IBlockAccess) worldserver, blockposition2, enumdirection)) { worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(getDirection(enumdirection), true), 2); -@@ -209,7 +215,7 @@ +@@ -218,7 +224,7 @@ } if (this.canSpread(iblockdata2)) { @@ -48,7 +48,7 @@ } return; -@@ -224,7 +230,7 @@ +@@ -233,7 +239,7 @@ IBlockData iblockdata4 = this.a(iblockdata, iblockdata3, random); if (iblockdata3 != iblockdata4 && this.canSpread(iblockdata4)) { diff --git a/nms-patches/BlockWitherSkull.patch b/nms-patches/BlockWitherSkull.patch index 777c67a074..1bdd7edaf8 100644 --- a/nms-patches/BlockWitherSkull.patch +++ b/nms-patches/BlockWitherSkull.patch @@ -39,7 +39,7 @@ @@ -50,6 +58,15 @@ entitywither.setPositionRotation((double) blockposition1.getX() + 0.5D, (double) blockposition1.getY() + 0.55D, (double) blockposition1.getZ() + 0.5D, shapedetector_shapedetectorcollection.getFacing().n() == EnumDirection.EnumAxis.X ? 0.0F : 90.0F, 0.0F); - entitywither.aH = shapedetector_shapedetectorcollection.getFacing().n() == EnumDirection.EnumAxis.X ? 0.0F : 90.0F; + entitywither.aA = shapedetector_shapedetectorcollection.getFacing().n() == EnumDirection.EnumAxis.X ? 0.0F : 90.0F; entitywither.beginSpawnSequence(); + // CraftBukkit start + if (!world.addEntity(entitywither, SpawnReason.BUILD_WITHER)) { diff --git a/nms-patches/Chunk.patch b/nms-patches/Chunk.patch index 07c86933ee..a673e1b833 100644 --- a/nms-patches/Chunk.patch +++ b/nms-patches/Chunk.patch @@ -88,7 +88,7 @@ if (tileentity == null) { NBTTagCompound nbttagcompound = (NBTTagCompound) this.e.remove(blockposition); @@ -424,6 +449,13 @@ - tileentity1.an_(); + tileentity1.al_(); } + // CraftBukkit start diff --git a/nms-patches/ChunkGenerator.patch b/nms-patches/ChunkGenerator.patch index 03b8ee7077..8f2c8cab5c 100644 --- a/nms-patches/ChunkGenerator.patch +++ b/nms-patches/ChunkGenerator.patch @@ -1,30 +1,34 @@ --- a/net/minecraft/server/ChunkGenerator.java +++ b/net/minecraft/server/ChunkGenerator.java -@@ -214,6 +214,13 @@ +@@ -210,7 +210,16 @@ while (iterator.hasNext()) { - StructureFeature structurefeature = (StructureFeature) iterator.next(); + Supplier> supplier = (Supplier) iterator.next(); +- this.a((StructureFeature) supplier.get(), iregistrycustom, structuremanager, ichunkaccess, definedstructuremanager, i, chunkcoordintpair, biomebase); + // CraftBukkit start -+ if (structurefeature.b == StructureGenerator.STRONGHOLD) { ++ StructureFeature structurefeature = (StructureFeature) supplier.get(); ++ if (structurefeature.c == StructureGenerator.STRONGHOLD) { + synchronized (structurefeature) { -+ this.a(structurefeature, structuremanager, ichunkaccess, definedstructuremanager, i, chunkcoordintpair, biomebase); ++ this.a(structurefeature, iregistrycustom, structuremanager, ichunkaccess, definedstructuremanager, i, chunkcoordintpair, biomebase); + } -+ } else ++ } else { ++ this.a(structurefeature, iregistrycustom, structuremanager, ichunkaccess, definedstructuremanager, i, chunkcoordintpair, biomebase); ++ } + // CraftBukkit end - this.a(structurefeature, structuremanager, ichunkaccess, definedstructuremanager, i, chunkcoordintpair, biomebase); } -@@ -293,9 +300,11 @@ + } +@@ -294,9 +303,11 @@ } static { - IRegistry.a(IRegistry.CHUNK_GENERATOR, "noise", (Object) ChunkGeneratorAbstract.d); - IRegistry.a(IRegistry.CHUNK_GENERATOR, "flat", (Object) ChunkProviderFlat.d); -- IRegistry.a(IRegistry.CHUNK_GENERATOR, "debug", (Object) ChunkProviderDebug.e); +- IRegistry.a(IRegistry.CHUNK_GENERATOR, "debug", (Object) ChunkProviderDebug.d); + // CraftBukkit start - decompile errors + IRegistry.a(IRegistry.CHUNK_GENERATOR, "noise", ChunkGeneratorAbstract.d); + IRegistry.a(IRegistry.CHUNK_GENERATOR, "flat", ChunkProviderFlat.d); -+ IRegistry.a(IRegistry.CHUNK_GENERATOR, "debug", ChunkProviderDebug.e); ++ IRegistry.a(IRegistry.CHUNK_GENERATOR, "debug", ChunkProviderDebug.d); + // CraftBukkit end a = IRegistry.CHUNK_GENERATOR.dispatchStable(ChunkGenerator::a, Function.identity()); } diff --git a/nms-patches/ChunkGeneratorAbstract.patch b/nms-patches/ChunkGeneratorAbstract.patch index b4220bc8c3..edb3116e57 100644 --- a/nms-patches/ChunkGeneratorAbstract.patch +++ b/nms-patches/ChunkGeneratorAbstract.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/ChunkGeneratorAbstract.java +++ b/net/minecraft/server/ChunkGeneratorAbstract.java -@@ -23,7 +23,7 @@ +@@ -24,7 +24,7 @@ return chunkgeneratorabstract.h; })).apply(instance, instance.stable(ChunkGeneratorAbstract::new)); }); @@ -9,7 +9,7 @@ for (int i = 0; i < 24; ++i) { for (int j = 0; j < 24; ++j) { for (int k = 0; k < 24; ++k) { -@@ -33,7 +33,7 @@ +@@ -34,7 +34,7 @@ } }); @@ -18,7 +18,7 @@ for (int i = -2; i <= 2; ++i) { for (int j = -2; j <= 2; ++j) { float f = 10.0F / MathHelper.c((float) (i * i + j * j) + 0.2F); -@@ -190,6 +190,11 @@ +@@ -193,6 +193,11 @@ f6 = f4; f7 = f5; } diff --git a/nms-patches/ChunkStatus.patch b/nms-patches/ChunkStatus.patch index 5893431741..49ba728860 100644 --- a/nms-patches/ChunkStatus.patch +++ b/nms-patches/ChunkStatus.patch @@ -6,7 +6,7 @@ if (!ichunkaccess.getChunkStatus().b(chunkstatus)) { - if (worldserver.getMinecraftServer().getSaveData().getGeneratorSettings().shouldGenerateMapFeatures()) { + if (worldserver.worldDataServer.getGeneratorSettings().shouldGenerateMapFeatures()) { // CraftBukkit - chunkgenerator.createStructures(worldserver.getStructureManager(), ichunkaccess, definedstructuremanager, worldserver.getSeed()); + chunkgenerator.createStructures(worldserver.r(), worldserver.getStructureManager(), ichunkaccess, definedstructuremanager, worldserver.getSeed()); } @@ -90,7 +90,7 @@ diff --git a/nms-patches/CommandDispatcher.patch b/nms-patches/CommandDispatcher.patch index 11f9aaac45..1dae2226a4 100644 --- a/nms-patches/CommandDispatcher.patch +++ b/nms-patches/CommandDispatcher.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/CommandDispatcher.java +++ b/net/minecraft/server/CommandDispatcher.java -@@ -17,12 +17,21 @@ +@@ -19,12 +19,21 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -22,7 +22,7 @@ CommandAdvancement.a(this.b); CommandAttribute.a(this.b); CommandExecute.a(this.b); -@@ -103,14 +112,57 @@ +@@ -105,14 +114,57 @@ } this.b.findAmbiguities((commandnode, commandnode1, commandnode2, collection) -> { @@ -83,7 +83,7 @@ StringReader stringreader = new StringReader(s); if (stringreader.canRead() && stringreader.peek() == '/') { -@@ -137,7 +189,7 @@ +@@ -139,7 +191,7 @@ if (commandsyntaxexception.getInput() != null && commandsyntaxexception.getCursor() >= 0) { int j = Math.min(commandsyntaxexception.getInput().length(), commandsyntaxexception.getCursor()); IChatMutableComponent ichatmutablecomponent = (new ChatComponentText("")).a(EnumChatFormat.GRAY).format((chatmodifier) -> { @@ -92,7 +92,7 @@ }); if (j > 10) { -@@ -187,11 +239,36 @@ +@@ -189,11 +241,36 @@ } public void a(EntityPlayer entityplayer) { @@ -130,7 +130,7 @@ entityplayer.playerConnection.sendPacket(new PacketPlayOutCommands(rootcommandnode)); } -@@ -202,7 +279,7 @@ +@@ -204,7 +281,7 @@ CommandNode commandnode2 = (CommandNode) iterator.next(); if (commandnode2.canUse(commandlistenerwrapper)) { @@ -139,7 +139,7 @@ argumentbuilder.requires((icompletionprovider) -> { return true; -@@ -225,7 +302,7 @@ +@@ -227,7 +304,7 @@ argumentbuilder.redirect((CommandNode) map.get(argumentbuilder.getRedirect())); } diff --git a/nms-patches/CommandListenerWrapper.patch b/nms-patches/CommandListenerWrapper.patch index 070458cc12..df7c9051ce 100644 --- a/nms-patches/CommandListenerWrapper.patch +++ b/nms-patches/CommandListenerWrapper.patch @@ -16,7 +16,7 @@ public CommandListenerWrapper(ICommandListener icommandlistener, Vec3D vec3d, Vec2F vec2f, WorldServer worldserver, int i, String s, IChatBaseComponent ichatbasecomponent, MinecraftServer minecraftserver, @Nullable Entity entity) { this(icommandlistener, vec3d, vec2f, worldserver, i, s, ichatbasecomponent, minecraftserver, entity, false, (commandcontext, flag, j) -> { -@@ -121,9 +123,22 @@ +@@ -128,9 +130,22 @@ @Override public boolean hasPermission(int i) { @@ -39,7 +39,7 @@ public Vec3D getPosition() { return this.d; } -@@ -185,7 +200,7 @@ +@@ -192,7 +207,7 @@ while (iterator.hasNext()) { EntityPlayer entityplayer = (EntityPlayer) iterator.next(); @@ -48,9 +48,9 @@ entityplayer.sendMessage(ichatmutablecomponent, SystemUtils.b); } } -@@ -240,4 +255,10 @@ - public Set> p() { - return this.i.E(); +@@ -252,4 +267,10 @@ + public IRegistryCustom q() { + return this.i.aX(); } + + // CraftBukkit start diff --git a/nms-patches/CommandReload.patch b/nms-patches/CommandReload.patch index c1d0f19612..4257289f41 100644 --- a/nms-patches/CommandReload.patch +++ b/nms-patches/CommandReload.patch @@ -6,7 +6,7 @@ + // CraftBukkit start + public static void reload(MinecraftServer minecraftserver) { -+ ResourcePackRepository resourcepackrepository = minecraftserver.getResourcePackRepository(); ++ ResourcePackRepository resourcepackrepository = minecraftserver.getResourcePackRepository(); + SaveData savedata = minecraftserver.getSaveData(); + Collection collection = resourcepackrepository.d(); + Collection collection1 = a(resourcepackrepository, savedata, collection); diff --git a/nms-patches/ContainerAnvilAbstract.patch b/nms-patches/ContainerAnvilAbstract.patch index 6129102138..eadec44f6e 100644 --- a/nms-patches/ContainerAnvilAbstract.patch +++ b/nms-patches/ContainerAnvilAbstract.patch @@ -6,5 +6,5 @@ public boolean canUse(EntityHuman entityhuman) { + if (!this.checkReachable) return true; // CraftBukkit return (Boolean) this.containerAccess.a((world, blockposition) -> { - return !this.a(world.getType(blockposition)) ? false : entityhuman.g((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) <= 64.0D; + return !this.a(world.getType(blockposition)) ? false : entityhuman.h((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) <= 64.0D; }, true); diff --git a/nms-patches/ContainerCartography.patch b/nms-patches/ContainerCartography.patch index 3566a15644..9b6587a7dd 100644 --- a/nms-patches/ContainerCartography.patch +++ b/nms-patches/ContainerCartography.patch @@ -28,9 +28,9 @@ + } + // CraftBukkit end private final ContainerAccess containerAccess; - private boolean e; - private long f; -@@ -27,6 +49,13 @@ + private long e; + public final IInventory inventory; +@@ -26,6 +48,13 @@ ContainerCartography.this.a((IInventory) this); super.update(); } @@ -44,7 +44,7 @@ }; this.containerAccess = containeraccess; this.a(new Slot(this.inventory, 0, 15, 15) { -@@ -104,10 +133,12 @@ +@@ -78,10 +107,12 @@ this.a(new Slot(playerinventory, j, 8 + j * 18, 142)); } diff --git a/nms-patches/ContainerFurnace.patch b/nms-patches/ContainerFurnace.patch index 6e3fb76306..5c6c8c83a3 100644 --- a/nms-patches/ContainerFurnace.patch +++ b/nms-patches/ContainerFurnace.patch @@ -11,9 +11,9 @@ public abstract class ContainerFurnace extends ContainerRecipeBook { private final IInventory furnace; -@@ -7,6 +12,22 @@ - protected final World c; +@@ -8,6 +13,22 @@ private final Recipes f; + private final RecipeBookType g; + // CraftBukkit start + private CraftInventoryView bukkitEntity = null; @@ -31,10 +31,10 @@ + } + // CraftBukkit end + - protected ContainerFurnace(Containers containers, Recipes recipes, int i, PlayerInventory playerinventory) { - this(containers, recipes, i, playerinventory, new InventorySubcontainer(3), new ContainerProperties(4)); + protected ContainerFurnace(Containers containers, Recipes recipes, RecipeBookType recipebooktype, int i, PlayerInventory playerinventory) { + this(containers, recipes, recipebooktype, i, playerinventory, new InventorySubcontainer(3), new ContainerProperties(4)); } -@@ -22,6 +43,7 @@ +@@ -24,6 +45,7 @@ this.a(new Slot(iinventory, 0, 56, 17)); this.a((Slot) (new SlotFurnaceFuel(this, iinventory, 1, 56, 53))); this.a((Slot) (new SlotFurnaceResult(playerinventory.player, iinventory, 2, 116, 35))); @@ -42,7 +42,7 @@ int j; -@@ -53,7 +75,7 @@ +@@ -55,7 +77,7 @@ @Override public void a(boolean flag, IRecipe irecipe, EntityPlayer entityplayer) { @@ -51,7 +51,7 @@ } @Override -@@ -78,6 +100,7 @@ +@@ -80,6 +102,7 @@ @Override public boolean canUse(EntityHuman entityhuman) { @@ -59,7 +59,7 @@ return this.furnace.a(entityhuman); } -@@ -133,7 +156,7 @@ +@@ -135,7 +158,7 @@ } protected boolean a(ItemStack itemstack) { diff --git a/nms-patches/ContainerSmithing.patch b/nms-patches/ContainerSmithing.patch index 5f6f167f3b..168390f113 100644 --- a/nms-patches/ContainerSmithing.patch +++ b/nms-patches/ContainerSmithing.patch @@ -18,7 +18,7 @@ public ContainerSmithing(int i, PlayerInventory playerinventory) { this(i, playerinventory, ContainerAccess.a); -@@ -52,12 +57,12 @@ +@@ -54,13 +59,13 @@ List list = this.g.getCraftingManager().b(Recipes.SMITHING, this.repairInventory, this.g); if (list.isEmpty()) { @@ -28,14 +28,15 @@ this.h = (RecipeSmithing) list.get(0); ItemStack itemstack = this.h.a(this.repairInventory); + this.resultInventory.a((IRecipe) this.h); - this.resultInventory.setItem(0, itemstack); + org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareSmithingEvent(getBukkitView(), itemstack); // CraftBukkit } } -@@ -68,4 +73,18 @@ - return recipesmithing.a(itemstack); - }); +@@ -76,4 +81,18 @@ + public boolean a(ItemStack itemstack, Slot slot) { + return slot.inventory != this.resultInventory && super.a(itemstack, slot); } + + // CraftBukkit start diff --git a/nms-patches/ContainerStonecutter.patch b/nms-patches/ContainerStonecutter.patch index 6e58fda629..3ae0ad8155 100644 --- a/nms-patches/ContainerStonecutter.patch +++ b/nms-patches/ContainerStonecutter.patch @@ -34,7 +34,7 @@ public ContainerStonecutter(int i, PlayerInventory playerinventory) { this(i, playerinventory, ContainerAccess.a); -@@ -81,10 +101,12 @@ +@@ -82,10 +102,12 @@ } this.a(this.containerProperty); diff --git a/nms-patches/Convertable.patch b/nms-patches/Convertable.patch index 00a4d8269c..80941e2b5d 100644 --- a/nms-patches/Convertable.patch +++ b/nms-patches/Convertable.patch @@ -1,6 +1,31 @@ --- a/net/minecraft/server/Convertable.java +++ b/net/minecraft/server/Convertable.java -@@ -175,8 +175,10 @@ +@@ -73,21 +73,21 @@ + Logger logger1 = Convertable.LOGGER; + + logger1.getClass(); +- IRegistry iregistry = (IRegistry) dataresult1.resultOrPartial(SystemUtils.a("Dimension type registry: ", logger1::error)).orElseThrow(() -> { ++ IRegistry iregistry = (IRegistry) ((DataResult>) dataresult1).resultOrPartial(SystemUtils.a("Dimension type registry: ", logger1::error)).orElseThrow(() -> { // CraftBukkit - decompile error + return new IllegalStateException("Failed to get dimension registry"); + }); + + dataresult1 = RegistryLookupCodec.a(IRegistry.ay).codec().parse(dynamic2); + logger1 = Convertable.LOGGER; + logger1.getClass(); +- IRegistry iregistry1 = (IRegistry) dataresult1.resultOrPartial(SystemUtils.a("Biome registry: ", logger1::error)).orElseThrow(() -> { ++ IRegistry iregistry1 = (IRegistry) ((DataResult>) dataresult1).resultOrPartial(SystemUtils.a("Biome registry: ", logger1::error)).orElseThrow(() -> { // CraftBukkit - decompile error + return new IllegalStateException("Failed to get biome registry"); + }); + + dataresult1 = RegistryLookupCodec.a(IRegistry.ar).codec().parse(dynamic2); + logger1 = Convertable.LOGGER; + logger1.getClass(); +- IRegistry iregistry2 = (IRegistry) dataresult1.resultOrPartial(SystemUtils.a("Noise settings registry: ", logger1::error)).orElseThrow(() -> { ++ IRegistry iregistry2 = (IRegistry) ((DataResult>) dataresult1).resultOrPartial(SystemUtils.a("Noise settings registry: ", logger1::error)).orElseThrow(() -> { // CraftBukkit - decompile error + return new IllegalStateException("Failed to get noise settings registry"); + }); + +@@ -195,8 +195,10 @@ }; } @@ -13,7 +38,7 @@ } public class ConversionSession implements AutoCloseable { -@@ -185,8 +187,12 @@ +@@ -205,8 +207,12 @@ public final java.nio.file.Path folder; private final String levelName; private final Map e = Maps.newHashMap(); @@ -27,7 +52,7 @@ this.levelName = s; this.folder = Convertable.this.universe.resolve(s); this.lock = SessionLock.a(this.folder); -@@ -203,9 +209,23 @@ +@@ -223,9 +229,23 @@ } public File a(ResourceKey resourcekey) { diff --git a/nms-patches/CraftingManager.patch b/nms-patches/CraftingManager.patch index 1b4fc9a20c..73dc061201 100644 --- a/nms-patches/CraftingManager.patch +++ b/nms-patches/CraftingManager.patch @@ -88,7 +88,7 @@ public > NonNullList c(Recipes recipes, C c0, World world) { @@ -102,7 +127,7 @@ - public Optional> a(MinecraftKey minecraftkey) { + public Optional> getRecipe(MinecraftKey minecraftkey) { return this.recipes.values().stream().map((map) -> { - return (IRecipe) map.get(minecraftkey); + return map.get(minecraftkey); // CraftBukkit - decompile error diff --git a/nms-patches/DedicatedServer.patch b/nms-patches/DedicatedServer.patch index 4e210d2d8f..3aebd2f4d8 100644 --- a/nms-patches/DedicatedServer.patch +++ b/nms-patches/DedicatedServer.patch @@ -22,10 +22,10 @@ @Nullable private ServerGUI q; -- public DedicatedServer(Thread thread, IRegistryCustom.Dimension iregistrycustom_dimension, Convertable.ConversionSession convertable_conversionsession, ResourcePackRepository resourcepackrepository, DataPackResources datapackresources, SaveData savedata, DedicatedServerSettings dedicatedserversettings, DataFixer datafixer, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache, WorldLoadListenerFactory worldloadlistenerfactory) { +- public DedicatedServer(Thread thread, IRegistryCustom.Dimension iregistrycustom_dimension, Convertable.ConversionSession convertable_conversionsession, ResourcePackRepository resourcepackrepository, DataPackResources datapackresources, SaveData savedata, DedicatedServerSettings dedicatedserversettings, DataFixer datafixer, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache, WorldLoadListenerFactory worldloadlistenerfactory) { - super(thread, iregistrycustom_dimension, convertable_conversionsession, savedata, resourcepackrepository, Proxy.NO_PROXY, datafixer, datapackresources, minecraftsessionservice, gameprofilerepository, usercache, worldloadlistenerfactory); + // CraftBukkit start - Signature changed -+ public DedicatedServer(joptsimple.OptionSet options, DataPackConfiguration datapackconfiguration, Thread thread, IRegistryCustom.Dimension iregistrycustom_dimension, Convertable.ConversionSession convertable_conversionsession, ResourcePackRepository resourcepackrepository, DataPackResources datapackresources, SaveData savedata, DedicatedServerSettings dedicatedserversettings, DataFixer datafixer, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache, WorldLoadListenerFactory worldloadlistenerfactory) { ++ public DedicatedServer(joptsimple.OptionSet options, DataPackConfiguration datapackconfiguration, Thread thread, IRegistryCustom.Dimension iregistrycustom_dimension, Convertable.ConversionSession convertable_conversionsession, ResourcePackRepository resourcepackrepository, DataPackResources datapackresources, SaveData savedata, DedicatedServerSettings dedicatedserversettings, DataFixer datafixer, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache, WorldLoadListenerFactory worldloadlistenerfactory) { + super(options, datapackconfiguration, thread, iregistrycustom_dimension, convertable_conversionsession, savedata, resourcepackrepository, Proxy.NO_PROXY, datafixer, datapackresources, minecraftsessionservice, gameprofilerepository, usercache, worldloadlistenerfactory); + // CraftBukkit end this.propertyManager = dedicatedserversettings; @@ -147,15 +147,15 @@ long j = SystemUtils.getMonotonicNanos() - i; String s = String.format(Locale.ROOT, "%.3fs", (double) j / 1.0E9D); -@@ -151,6 +222,7 @@ +@@ -149,6 +220,7 @@ + if (dedicatedserverproperties.enableRcon) { DedicatedServer.LOGGER.info("Starting remote control listener"); - this.remoteControlListener = new RemoteControlListener(this); - this.remoteControlListener.a(); + this.remoteControlListener = RemoteControlListener.a((IMinecraftServer) this); + this.remoteConsole = new org.bukkit.craftbukkit.command.CraftRemoteConsoleCommandSender(this.remoteControlCommandListener); // CraftBukkit } if (this.getMaxTickTime() > 0L) { -@@ -261,6 +333,7 @@ +@@ -259,6 +331,7 @@ this.remoteStatusListener.b(); } @@ -163,7 +163,7 @@ } @Override -@@ -289,7 +362,15 @@ +@@ -287,7 +360,15 @@ while (!this.serverCommandQueue.isEmpty()) { ServerCommand servercommand = (ServerCommand) this.serverCommandQueue.remove(0); @@ -180,7 +180,7 @@ } } -@@ -494,14 +575,45 @@ +@@ -497,14 +578,45 @@ @Override public String getPlugins() { @@ -228,7 +228,7 @@ }); return this.remoteControlCommandListener.getMessages(); } -@@ -537,4 +649,15 @@ +@@ -540,4 +652,15 @@ public boolean isSyncChunkWrites() { return this.propertyManager.getProperties().syncChunkWrites; } diff --git a/nms-patches/DedicatedServerProperties.patch b/nms-patches/DedicatedServerProperties.patch index d4d2bd2b07..edcec8b4f4 100644 --- a/nms-patches/DedicatedServerProperties.patch +++ b/nms-patches/DedicatedServerProperties.patch @@ -12,35 +12,35 @@ public final boolean onlineMode = this.getBoolean("online-mode", true); public final boolean preventProxyConnections = this.getBoolean("prevent-proxy-connections", false); public final String serverIp = this.getString("server-ip", ""); -@@ -53,8 +55,10 @@ +@@ -54,8 +56,10 @@ public final PropertyManager.EditableProperty whiteList; public final GeneratorSettings generatorSettings; -- public DedicatedServerProperties(Properties properties) { +- public DedicatedServerProperties(Properties properties, IRegistryCustom iregistrycustom) { - super(properties); + // CraftBukkit start -+ public DedicatedServerProperties(Properties properties, OptionSet optionset) { ++ public DedicatedServerProperties(Properties properties, IRegistryCustom iregistrycustom, OptionSet optionset) { + super(properties, optionset); + // CraftBukkit end this.difficulty = (EnumDifficulty) this.a("difficulty", a(EnumDifficulty::getById, EnumDifficulty::a), EnumDifficulty::c, EnumDifficulty.EASY); this.gamemode = (EnumGamemode) this.a("gamemode", a(EnumGamemode::getById, EnumGamemode::a), EnumGamemode::b, EnumGamemode.SURVIVAL); this.levelName = this.getString("level-name", "world"); -@@ -103,12 +107,14 @@ - this.generatorSettings = GeneratorSettings.a(properties); +@@ -105,12 +109,14 @@ + this.generatorSettings = GeneratorSettings.a(iregistrycustom, properties); } -- public static DedicatedServerProperties load(java.nio.file.Path java_nio_file_path) { -- return new DedicatedServerProperties(loadPropertiesFile(java_nio_file_path)); +- public static DedicatedServerProperties load(IRegistryCustom iregistrycustom, java.nio.file.Path java_nio_file_path) { +- return new DedicatedServerProperties(loadPropertiesFile(java_nio_file_path), iregistrycustom); + // CraftBukkit start -+ public static DedicatedServerProperties load(java.nio.file.Path java_nio_file_path, OptionSet optionset) { -+ return new DedicatedServerProperties(loadPropertiesFile(java_nio_file_path), optionset); ++ public static DedicatedServerProperties load(IRegistryCustom iregistrycustom, java.nio.file.Path java_nio_file_path, OptionSet optionset) { ++ return new DedicatedServerProperties(loadPropertiesFile(java_nio_file_path), iregistrycustom, optionset); } @Override -- protected DedicatedServerProperties reload(Properties properties) { -- return new DedicatedServerProperties(properties); -+ protected DedicatedServerProperties reload(Properties properties, OptionSet optionset) { -+ return new DedicatedServerProperties(properties, optionset); +- protected DedicatedServerProperties reload(IRegistryCustom iregistrycustom, Properties properties) { +- return new DedicatedServerProperties(properties, iregistrycustom); ++ protected DedicatedServerProperties reload(IRegistryCustom iregistrycustom, Properties properties, OptionSet optionset) { ++ return new DedicatedServerProperties(properties, iregistrycustom, optionset); + // CraftBukkit end } } diff --git a/nms-patches/DedicatedServerSettings.patch b/nms-patches/DedicatedServerSettings.patch index 59c00acd33..ae3f30d0a2 100644 --- a/nms-patches/DedicatedServerSettings.patch +++ b/nms-patches/DedicatedServerSettings.patch @@ -14,13 +14,13 @@ private final java.nio.file.Path path; private DedicatedServerProperties properties; -- public DedicatedServerSettings(java.nio.file.Path java_nio_file_path) { +- public DedicatedServerSettings(IRegistryCustom iregistrycustom, java.nio.file.Path java_nio_file_path) { - this.path = java_nio_file_path; -- this.properties = DedicatedServerProperties.load(java_nio_file_path); +- this.properties = DedicatedServerProperties.load(iregistrycustom, java_nio_file_path); + // CraftBukkit start -+ public DedicatedServerSettings(OptionSet optionset) { ++ public DedicatedServerSettings(IRegistryCustom iregistrycustom, OptionSet optionset) { + this.path = ((File) optionset.valueOf("config")).toPath(); -+ this.properties = DedicatedServerProperties.load(path, optionset); ++ this.properties = DedicatedServerProperties.load(iregistrycustom, path, optionset); + // CraftBukkit end } diff --git a/nms-patches/DefinedStructure.patch b/nms-patches/DefinedStructure.patch index 8b54713ac7..e259328e67 100644 --- a/nms-patches/DefinedStructure.patch +++ b/nms-patches/DefinedStructure.patch @@ -21,11 +21,11 @@ @@ -430,11 +430,13 @@ } - private static Optional a(GeneratorAccess generatoraccess, NBTTagCompound nbttagcompound) { + private static Optional a(WorldAccess worldaccess, NBTTagCompound nbttagcompound) { - try { + // CraftBukkit start + // try { - return EntityTypes.a(nbttagcompound, generatoraccess.getMinecraftWorld()); + return EntityTypes.a(nbttagcompound, (World) worldaccess.getMinecraftWorld()); - } catch (Exception exception) { - return Optional.empty(); - } diff --git a/nms-patches/DispenseBehaviorBoat.patch b/nms-patches/DispenseBehaviorBoat.patch index fe370d8df4..57296f2203 100644 --- a/nms-patches/DispenseBehaviorBoat.patch +++ b/nms-patches/DispenseBehaviorBoat.patch @@ -15,16 +15,16 @@ d3 = 0.0D; } -- EntityBoat entityboat = new EntityBoat(world, d0, d1 + d3, d2); -+ // EntityBoat entityboat = new EntityBoat(world, d0, d1 + d3, d2); +- EntityBoat entityboat = new EntityBoat(worldserver, d0, d1 + d3, d2); ++ // EntityBoat entityboat = new EntityBoat(worldserver, d0, d1 + d3, d2); + // CraftBukkit start + ItemStack itemstack1 = itemstack.cloneAndSubtract(1); -+ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); ++ org.bukkit.block.Block block = worldserver.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); + CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); + + BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(d0, d1 + d3, d2)); + if (!BlockDispenser.eventFired) { -+ world.getServer().getPluginManager().callEvent(event); ++ worldserver.getServer().getPluginManager().callEvent(event); + } + + if (event.isCancelled()) { @@ -43,14 +43,14 @@ + } + } + -+ EntityBoat entityboat = new EntityBoat(world, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ()); ++ EntityBoat entityboat = new EntityBoat(worldserver, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ()); + // CraftBukkit end entityboat.setType(this.c); entityboat.yaw = enumdirection.o(); -- world.addEntity(entityboat); +- worldserver.addEntity(entityboat); - itemstack.subtract(1); -+ if (!world.addEntity(entityboat)) itemstack.add(1); // CraftBukkit ++ if (!worldserver.addEntity(entityboat)) itemstack.add(1); // CraftBukkit + // itemstack.subtract(1); // CraftBukkit - handled during event processing return itemstack; } diff --git a/nms-patches/DispenseBehaviorProjectile.patch b/nms-patches/DispenseBehaviorProjectile.patch index 3d58d9fa24..bfcd57ec94 100644 --- a/nms-patches/DispenseBehaviorProjectile.patch +++ b/nms-patches/DispenseBehaviorProjectile.patch @@ -13,18 +13,18 @@ public DispenseBehaviorProjectile() {} @@ -11,9 +16,38 @@ EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING); - IProjectile iprojectile = this.a(world, iposition, itemstack); + IProjectile iprojectile = this.a((World) worldserver, iposition, itemstack); - iprojectile.shoot((double) enumdirection.getAdjacentX(), (double) ((float) enumdirection.getAdjacentY() + 0.1F), (double) enumdirection.getAdjacentZ(), this.getPower(), this.a()); + // iprojectile.shoot((double) enumdirection.getAdjacentX(), (double) ((float) enumdirection.getAdjacentY() + 0.1F), (double) enumdirection.getAdjacentZ(), this.getPower(), this.a()); + // CraftBukkit start + ItemStack itemstack1 = itemstack.cloneAndSubtract(1); -+ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); ++ org.bukkit.block.Block block = worldserver.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); + CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); + + BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector((double) enumdirection.getAdjacentX(), (double) ((float) enumdirection.getAdjacentY() + 0.1F), (double) enumdirection.getAdjacentZ())); + if (!BlockDispenser.eventFired) { -+ world.getServer().getPluginManager().callEvent(event); ++ worldserver.getServer().getPluginManager().callEvent(event); + } + + if (event.isCancelled()) { @@ -46,7 +46,7 @@ + iprojectile.shoot(event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), this.getPower(), this.a()); + ((Entity) iprojectile).projectileSource = new org.bukkit.craftbukkit.projectiles.CraftBlockProjectileSource((TileEntityDispenser) isourceblock.getTileEntity()); + // CraftBukkit end - world.addEntity(iprojectile); + worldserver.addEntity(iprojectile); - itemstack.subtract(1); + // itemstack.subtract(1); // CraftBukkit - Handled during event processing return itemstack; diff --git a/nms-patches/DispenseBehaviorShears.patch b/nms-patches/DispenseBehaviorShears.patch index cad396786c..d3d5ac13ee 100644 --- a/nms-patches/DispenseBehaviorShears.patch +++ b/nms-patches/DispenseBehaviorShears.patch @@ -15,14 +15,14 @@ @@ -10,11 +15,34 @@ @Override protected ItemStack a(ISourceBlock isourceblock, ItemStack itemstack) { - World world = isourceblock.getWorld(); + WorldServer worldserver = isourceblock.getWorld(); + // CraftBukkit start -+ org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); ++ org.bukkit.block.Block bukkitBlock = worldserver.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); + CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack); + + BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0)); + if (!BlockDispenser.eventFired) { -+ world.getServer().getPluginManager().callEvent(event); ++ worldserver.getServer().getPluginManager().callEvent(event); + } + + if (event.isCancelled()) { @@ -40,12 +40,12 @@ + } + // CraftBukkit end - if (!world.s_()) { + if (!worldserver.s_()) { BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING)); -- this.a(a((WorldServer) world, blockposition) || b((WorldServer) world, blockposition)); -+ this.a(a((WorldServer) world, blockposition) || b((WorldServer) world, blockposition, bukkitBlock, craftItem)); // CraftBukkit - if (this.a() && itemstack.isDamaged(1, world.getRandom(), (EntityPlayer) null)) { +- this.a(a((WorldServer) worldserver, blockposition) || b((WorldServer) worldserver, blockposition)); ++ this.a(a((WorldServer) worldserver, blockposition) || b((WorldServer) worldserver, blockposition, bukkitBlock, craftItem)); // CraftBukkit + if (this.a() && itemstack.isDamaged(1, worldserver.getRandom(), (EntityPlayer) null)) { itemstack.setCount(0); } @@ -40,7 +68,7 @@ diff --git a/nms-patches/DispenserRegistry.patch b/nms-patches/DispenserRegistry.patch index 0e35b55c7d..737d96bd14 100644 --- a/nms-patches/DispenserRegistry.patch +++ b/nms-patches/DispenserRegistry.patch @@ -17,8 +17,8 @@ public class DispenserRegistry { public static final PrintStream a = System.out; -@@ -30,6 +40,69 @@ - ArgumentRegistry.a(); +@@ -31,6 +41,69 @@ + TagStatic.b(); d(); } + // CraftBukkit start - easier than fixing the decompile diff --git a/nms-patches/EnderDragonBattle.patch b/nms-patches/EnderDragonBattle.patch deleted file mode 100644 index da691e877b..0000000000 --- a/nms-patches/EnderDragonBattle.patch +++ /dev/null @@ -1,33 +0,0 @@ ---- a/net/minecraft/server/EnderDragonBattle.java -+++ b/net/minecraft/server/EnderDragonBattle.java -@@ -245,7 +245,7 @@ - } - - @Nullable -- private ShapeDetector.ShapeDetectorCollection j() { -+ public ShapeDetector.ShapeDetectorCollection j() { // PAIL private -> public, rename getExitPortalShape() - int i; - int j; - -@@ -376,10 +376,10 @@ - - private void a(BlockPosition blockposition) { - this.world.triggerEffect(3000, blockposition, 0); -- WorldGenerator.END_GATEWAY.b((WorldGenFeatureConfiguration) WorldGenEndGatewayConfiguration.a()).a(this.world, this.world.getStructureManager(), this.world.getChunkProvider().getChunkGenerator(), new Random(), blockposition); -+ WorldGenerator.END_GATEWAY.b(WorldGenEndGatewayConfiguration.a()).a(this.world, this.world.getStructureManager(), this.world.getChunkProvider().getChunkGenerator(), new Random(), blockposition); // CraftBukkit - decompile error - } - -- private void a(boolean flag) { -+ public void a(boolean flag) { // PAIL private -> public, rename generateExitPortal() - WorldGenEndTrophy worldgenendtrophy = new WorldGenEndTrophy(flag); - - if (this.exitPortalLocation == null) { -@@ -388,7 +388,7 @@ - } - } - -- worldgenendtrophy.b((WorldGenFeatureConfiguration) WorldGenFeatureConfiguration.k).a(this.world, this.world.getStructureManager(), this.world.getChunkProvider().getChunkGenerator(), new Random(), this.exitPortalLocation); -+ worldgenendtrophy.b(WorldGenFeatureConfiguration.k).a(this.world, this.world.getStructureManager(), this.world.getChunkProvider().getChunkGenerator(), new Random(), this.exitPortalLocation); // CraftBukkit - decompile error - } - - private EntityEnderDragon o() { diff --git a/nms-patches/Entity.patch b/nms-patches/Entity.patch index 416fcb35a6..3af43eea2e 100644 --- a/nms-patches/Entity.patch +++ b/nms-patches/Entity.patch @@ -57,8 +57,8 @@ protected static final Logger LOGGER = LogManager.getLogger(); private static final AtomicInteger entityCount = new AtomicInteger(); private static final List c = Collections.emptyList(); -@@ -111,6 +159,20 @@ - private long aG; +@@ -106,6 +154,20 @@ + private long aB; private EntitySize size; private float headHeight; + // CraftBukkit start @@ -78,7 +78,7 @@ public Entity(EntityTypes entitytypes, World world) { this.id = Entity.entityCount.incrementAndGet(); -@@ -214,6 +276,12 @@ +@@ -212,6 +274,12 @@ } public void setPose(EntityPose entitypose) { @@ -91,7 +91,7 @@ this.datawatcher.set(Entity.POSE, entitypose); } -@@ -230,6 +298,33 @@ +@@ -228,6 +296,33 @@ } protected void setYawPitch(float f, float f1) { @@ -125,15 +125,15 @@ this.yaw = f % 360.0F; this.pitch = f1 % 360.0F; } -@@ -240,6 +335,7 @@ - float f1 = this.size.height; - - this.a(new AxisAlignedBB(d0 - (double) f, d1, d2 - (double) f, d0 + (double) f, d1 + (double) f1, d2 + (double) f)); +@@ -235,6 +330,7 @@ + public void setPosition(double d0, double d1, double d2) { + this.setPositionRaw(d0, d1, d2); + this.a(this.size.a(d0, d1, d2)); + if (valid) ((WorldServer) world).chunkCheck(this); // CraftBukkit } - protected void ac() { -@@ -254,6 +350,15 @@ + protected void ae() { +@@ -249,6 +345,15 @@ this.entityBaseTick(); } @@ -149,16 +149,16 @@ public void entityBaseTick() { this.world.getMethodProfiler().enter("entityBaseTick"); if (this.isPassenger() && this.getVehicle().dead) { -@@ -267,7 +372,7 @@ +@@ -262,7 +367,7 @@ this.z = this.A; this.lastPitch = this.pitch; this.lastYaw = this.yaw; - this.doPortalTick(); + if (this instanceof EntityPlayer) this.doPortalTick(); // CraftBukkit - // Moved up to postTick - if (this.aK()) { - this.aL(); + if (this.aN()) { + this.aO(); } -@@ -322,12 +427,44 @@ +@@ -325,12 +430,44 @@ protected void burnFromLava() { if (!this.isFireProof()) { @@ -204,7 +204,7 @@ int j = i * 20; if (this instanceof EntityLiving) { -@@ -424,6 +561,28 @@ +@@ -427,6 +564,28 @@ block.a((IBlockAccess) this.world, this); } @@ -230,10 +230,10 @@ + } + // CraftBukkit end + - if (this.onGround && !this.br()) { + if (this.onGround && !this.bu()) { block.stepOn(this.world, blockposition, this); } -@@ -698,6 +857,7 @@ +@@ -700,6 +859,7 @@ AxisAlignedBB axisalignedbb = this.getBoundingBox(); this.setPositionRaw((axisalignedbb.minX + axisalignedbb.maxX) / 2.0D, axisalignedbb.minY, (axisalignedbb.minZ + axisalignedbb.maxZ) / 2.0D); @@ -241,7 +241,7 @@ } protected SoundEffect getSoundSwim() { -@@ -1036,6 +1196,13 @@ +@@ -1025,6 +1185,13 @@ } public void spawnIn(World world) { @@ -255,15 +255,15 @@ this.world = world; } -@@ -1051,6 +1218,7 @@ - this.pitch = MathHelper.a(f1, -90.0F, 90.0F) % 360.0F; - this.lastYaw = this.yaw; - this.lastPitch = this.pitch; +@@ -1044,6 +1211,7 @@ + this.lastY = d1; + this.lastZ = d4; + this.setPosition(d3, d1, d4); + world.getChunkAt((int) Math.floor(this.locX()) >> 4, (int) Math.floor(this.locZ()) >> 4); // CraftBukkit } - public void c(Vec3D vec3d) { -@@ -1225,6 +1393,12 @@ + public void d(Vec3D vec3d) { +@@ -1218,6 +1386,12 @@ return false; } @@ -276,7 +276,7 @@ public void a(Entity entity, int i, DamageSource damagesource) { if (entity instanceof EntityPlayer) { CriterionTriggers.c.a((EntityPlayer) entity, this, damagesource); -@@ -1235,7 +1409,7 @@ +@@ -1228,7 +1402,7 @@ public boolean a_(NBTTagCompound nbttagcompound) { String s = this.getSaveID(); @@ -285,7 +285,7 @@ nbttagcompound.setString("id", s); this.save(nbttagcompound); return true; -@@ -1259,6 +1433,18 @@ +@@ -1252,6 +1426,18 @@ Vec3D vec3d = this.getMot(); nbttagcompound.set("Motion", this.a(vec3d.x, vec3d.y, vec3d.z)); @@ -304,7 +304,7 @@ nbttagcompound.set("Rotation", this.a(this.yaw, this.pitch)); nbttagcompound.setFloat("FallDistance", this.fallDistance); nbttagcompound.setShort("Fire", (short) this.fireTicks); -@@ -1267,6 +1453,12 @@ +@@ -1260,6 +1446,12 @@ nbttagcompound.setBoolean("Invulnerable", this.invulnerable); nbttagcompound.setInt("PortalCooldown", this.portalCooldown); nbttagcompound.a("UUID", this.getUniqueID()); @@ -317,7 +317,7 @@ IChatBaseComponent ichatbasecomponent = this.getCustomName(); if (ichatbasecomponent != null) { -@@ -1324,6 +1516,11 @@ +@@ -1317,6 +1509,11 @@ } } @@ -329,7 +329,7 @@ return nbttagcompound; } catch (Throwable throwable) { CrashReport crashreport = CrashReport.a(throwable, "Saving entity NBT"); -@@ -1401,6 +1598,43 @@ +@@ -1394,6 +1591,43 @@ } else { throw new IllegalStateException("Entity has invalid position"); } @@ -373,7 +373,7 @@ } catch (Throwable throwable) { CrashReport crashreport = CrashReport.a(throwable, "Loading entity NBT"); CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Entity being loaded"); -@@ -1476,9 +1710,22 @@ +@@ -1469,9 +1703,22 @@ } else if (this.world.isClientSide) { return null; } else { @@ -396,7 +396,7 @@ this.world.addEntity(entityitem); return entityitem; } -@@ -1559,7 +1806,7 @@ +@@ -1555,7 +1802,7 @@ this.setPose(EntityPose.STANDING); this.vehicle = entity; @@ -405,7 +405,7 @@ return true; } } -@@ -1584,7 +1831,7 @@ +@@ -1580,7 +1827,7 @@ Entity entity = this.vehicle; this.vehicle = null; @@ -414,8 +414,8 @@ } } -@@ -1593,10 +1840,31 @@ - this.bb(); +@@ -1589,10 +1836,31 @@ + this.be(); } - protected void addPassenger(Entity entity) { @@ -447,7 +447,7 @@ if (!this.world.isClientSide && entity instanceof EntityHuman && !(this.getRidingPassenger() instanceof EntityHuman)) { this.passengers.add(0, entity); } else { -@@ -1604,15 +1872,36 @@ +@@ -1600,15 +1868,36 @@ } } @@ -485,7 +485,7 @@ } protected boolean q(Entity entity) { -@@ -1661,11 +1950,17 @@ +@@ -1649,11 +1938,17 @@ ResourceKey resourcekey = this.world.getDimensionKey() == World.THE_NETHER ? World.OVERWORLD : World.THE_NETHER; WorldServer worldserver1 = minecraftserver.getWorldServer(resourcekey); @@ -493,19 +493,19 @@ + if (true && !this.isPassenger() && this.portalTicks++ >= i) { // CraftBukkit this.world.getMethodProfiler().enter("portal"); this.portalTicks = i; - this.portalCooldown = this.getDefaultPortalCooldown(); -- this.a(worldserver1); + this.resetPortalCooldown(); +- this.b(worldserver1); + // CraftBukkit start + if (this instanceof EntityPlayer) { -+ ((EntityPlayer) this).a(worldserver1, PlayerTeleportEvent.TeleportCause.NETHER_PORTAL); ++ ((EntityPlayer) this).b(worldserver1, PlayerTeleportEvent.TeleportCause.NETHER_PORTAL); + } else { -+ this.a(worldserver1); ++ this.b(worldserver1); + } + // CraftBukkit end this.world.getMethodProfiler().exit(); } -@@ -1765,6 +2060,13 @@ +@@ -1753,6 +2048,13 @@ } public void setSwimming(boolean flag) { @@ -519,7 +519,7 @@ this.setFlag(4, flag); } -@@ -1825,16 +2127,56 @@ +@@ -1813,16 +2115,56 @@ } public void setAirTicks(int i) { @@ -537,7 +537,7 @@ + // CraftBukkit end } - public void onLightningStrike(EntityLightning entitylightning) { + public void onLightningStrike(WorldServer worldserver, EntityLightning entitylightning) { this.setFireTicks(this.fireTicks + 1); + // CraftBukkit start + final org.bukkit.entity.Entity thisBukkitEntity = this.getBukkitEntity(); @@ -579,10 +579,10 @@ } public void k(boolean flag) { -@@ -1986,18 +2328,45 @@ +@@ -1972,15 +2314,32 @@ @Nullable - public Entity a(WorldServer worldserver) { + public Entity b(WorldServer worldserver) { + // CraftBukkit start + return teleportTo(worldserver, null); + } @@ -595,93 +595,129 @@ - this.decouple(); + // CraftBukkit start + // this.decouple(); -+ if (worldserver == null){ ++ if (worldserver == null) { + return null; + } + // CraftBukkit end this.world.getMethodProfiler().enter("reposition"); - Vec3D vec3d = this.getMot(); - float f = 0.0F; -- BlockPosition blockposition; -+ BlockPosition blockposition = location; // CraftBukkit +- ShapeDetectorShape shapedetectorshape = this.a(worldserver); ++ ShapeDetectorShape shapedetectorshape = (location == null) ? this.a(worldserver) : new ShapeDetectorShape(new Vec3D(location.getX(), location.getY(), location.getZ()), Vec3D.a, this.yaw, this.pitch, worldserver); // CraftBukkit -- if (this.world.getDimensionKey() == World.THE_END && worldserver.getDimensionKey() == World.OVERWORLD) { -- blockposition = worldserver.getHighestBlockYAt(HeightMap.Type.MOTION_BLOCKING_NO_LEAVES, worldserver.getSpawn()); -- } else if (worldserver.getDimensionKey() == World.THE_END) { -- blockposition = WorldServer.a; -+ if (blockposition == null) { // CraftBukkit -+ if (this.world.getTypeKey() == DimensionManager.THE_END && worldserver.getTypeKey() == DimensionManager.OVERWORLD) { // CraftBukkit -+ // CraftBukkit start -+ EntityPortalEvent event = CraftEventFactory.callEntityPortalEvent(this, worldserver, worldserver.getHighestBlockYAt(HeightMap.Type.MOTION_BLOCKING_NO_LEAVES, worldserver.getSpawn()), 0); -+ if (event == null) { -+ return null; -+ } -+ worldserver = ((CraftWorld) event.getTo().getWorld()).getHandle(); -+ blockposition = new BlockPosition(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ()); -+ // CraftBukkit end -+ } else if (worldserver.getTypeKey() == DimensionManager.THE_END) { // CraftBukkit -+ // CraftBukkit start -+ EntityPortalEvent event = CraftEventFactory.callEntityPortalEvent(this, worldserver, WorldServer.a, 0); -+ if (event == null) { -+ return null; -+ } -+ worldserver = ((CraftWorld) event.getTo().getWorld()).getHandle(); -+ blockposition = new BlockPosition(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ()); -+ // CraftBukkit end + if (shapedetectorshape == null) { + return null; } else { - double d0 = this.locX(); - double d1 = this.locZ(); -@@ -2023,7 +2392,16 @@ - Vec3D vec3d1 = this.getPortalOffset(); ++ // CraftBukkit start ++ worldserver = shapedetectorshape.world; ++ this.decouple(); ++ // CraftBukkit end ++ + this.world.getMethodProfiler().exitEnter("reloading"); + Entity entity = this.getEntityType().a((World) worldserver); - blockposition = new BlockPosition(d0, this.locY(), d1); -- ShapeDetector.Shape shapedetector_shape = worldserver.getTravelAgent().a(blockposition, vec3d, this.getPortalDirection(), vec3d1.x, vec3d1.y, this instanceof EntityHuman); +@@ -1989,9 +2348,17 @@ + entity.setPositionRotation(shapedetectorshape.position.x, shapedetectorshape.position.y, shapedetectorshape.position.z, shapedetectorshape.yaw, entity.pitch); + entity.setMot(shapedetectorshape.velocity); + worldserver.addEntityTeleport(entity); +- if (worldserver.getDimensionKey() == World.THE_END) { +- WorldServer.a(worldserver); ++ if (worldserver.getTypeKey() == DimensionManager.THE_END) { // CraftBukkit ++ WorldServer.a(worldserver, this); // CraftBukkit + } ++ // CraftBukkit start - Forward the CraftEntity to the new entity ++ this.getBukkitEntity().setHandle(entity); ++ entity.bukkitEntity = this.getBukkitEntity(); ++ ++ if (this instanceof EntityInsentient) { ++ ((EntityInsentient) this).unleash(true, false); // Unleash to prevent duping of leads. ++ } ++ // CraftBukkit end + } + + this.bM(); +@@ -2012,13 +2379,18 @@ + + @Nullable + protected ShapeDetectorShape a(WorldServer worldserver) { +- boolean flag = this.world.getDimensionKey() == World.THE_END && worldserver.getDimensionKey() == World.OVERWORLD; +- boolean flag1 = worldserver.getDimensionKey() == World.THE_END; ++ // CraftBukkit start ++ if (worldserver == null) { ++ return null; ++ } ++ boolean flag = this.world.getTypeKey() == DimensionManager.THE_END && worldserver.getTypeKey() == DimensionManager.OVERWORLD; ++ boolean flag1 = worldserver.getTypeKey() == DimensionManager.THE_END; ++ // CraftBukkit end + + if (!flag && !flag1) { +- boolean flag2 = worldserver.getDimensionKey() == World.THE_NETHER; ++ boolean flag2 = worldserver.getTypeKey() == DimensionManager.THE_NETHER; // CraftBukkit + +- if (this.world.getDimensionKey() != World.THE_NETHER && !flag2) { ++ if (this.world.getTypeKey() != DimensionManager.THE_NETHER && !flag2) { + return null; + } else { + WorldBorder worldborder = worldserver.getWorldBorder(); +@@ -2028,8 +2400,17 @@ + double d3 = Math.min(2.9999872E7D, worldborder.h() - 16.0D); + double d4 = DimensionManager.a(this.world.getDimensionManager(), worldserver.getDimensionManager()); + BlockPosition blockposition = new BlockPosition(MathHelper.a(this.locX() * d4, d0, d2), this.locY(), MathHelper.a(this.locZ() * d4, d1, d3)); + // CraftBukkit start + EntityPortalEvent event = CraftEventFactory.callEntityPortalEvent(this, worldserver, blockposition, 128); + if (event == null) { + return null; + } -+ worldserver = ((CraftWorld) event.getTo().getWorld()).getHandle(); ++ final WorldServer worldserverFinal = worldserver = ((CraftWorld) event.getTo().getWorld()).getHandle(); + blockposition = new BlockPosition(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ()); + int searchRadius = event.getSearchRadius(); + // CraftBukkit end -+ ShapeDetector.Shape shapedetector_shape = worldserver.getTravelAgent().findPortal(blockposition, vec3d, this.getPortalDirection(), vec3d1.x, vec3d1.y, this instanceof EntityHuman, searchRadius); // CraftBukkit - search radius - if (shapedetector_shape == null) { - return null; -@@ -2033,6 +2411,11 @@ - vec3d = shapedetector_shape.velocity; - f = (float) shapedetector_shape.yaw; +- return (ShapeDetectorShape) this.a(worldserver, blockposition, flag2).map((blockutil_rectangle) -> { ++ return (ShapeDetectorShape) this.a(worldserver, blockposition, flag2, searchRadius).map((blockutil_rectangle) -> { + IBlockData iblockdata = this.world.getType(this.ac); + EnumDirection.EnumAxis enumdirection_enumaxis; + Vec3D vec3d; +@@ -2046,8 +2427,8 @@ + vec3d = new Vec3D(0.5D, 0.0D, 0.0D); + } + +- return BlockPortalShape.a(worldserver, blockutil_rectangle, enumdirection_enumaxis, vec3d, this.a(this.getPose()), this.getMot(), this.yaw, this.pitch); +- }).orElse((Object) null); ++ return BlockPortalShape.a(worldserverFinal, blockutil_rectangle, enumdirection_enumaxis, vec3d, this.a(this.getPose()), this.getMot(), this.yaw, this.pitch); // CraftBukkit ++ }).orElse(null); // CraftBuukkit - decompile error + } + } else { + BlockPosition blockposition1; +@@ -2057,8 +2438,15 @@ + } else { + blockposition1 = worldserver.getHighestBlockYAt(HeightMap.Type.MOTION_BLOCKING_NO_LEAVES, worldserver.getSpawn()); } -+ } // CraftBukkit -+ + // CraftBukkit start -+ this.decouple(); ++ EntityPortalEvent event = CraftEventFactory.callEntityPortalEvent(this, worldserver, blockposition1, 0); ++ if (event == null) { ++ return null; ++ } ++ blockposition1 = new BlockPosition(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ()); + +- return new ShapeDetectorShape(new Vec3D((double) blockposition1.getX() + 0.5D, (double) blockposition1.getY(), (double) blockposition1.getZ() + 0.5D), this.getMot(), this.yaw, this.pitch); ++ return new ShapeDetectorShape(new Vec3D((double) blockposition1.getX() + 0.5D, (double) blockposition1.getY(), (double) blockposition1.getZ() + 0.5D), this.getMot(), this.yaw, this.pitch, ((CraftWorld) event.getTo().getWorld()).getHandle()); + // CraftBukkit end + } + } - this.world.getMethodProfiler().exitEnter("reloading"); - Entity entity = this.getEntityType().a((World) worldserver); -@@ -2042,9 +2425,17 @@ - entity.setPositionRotation(blockposition, entity.yaw + f, entity.pitch); - entity.setMot(vec3d); - worldserver.addEntityTeleport(entity); -- if (worldserver.getDimensionKey() == World.THE_END) { -- WorldServer.a(worldserver); -+ if (worldserver.getTypeKey() == DimensionManager.THE_END) { // CraftBukkit -+ WorldServer.a(worldserver, this); // CraftBukkit -+ } -+ // CraftBukkit start - Forward the CraftEntity to the new entity -+ this.getBukkitEntity().setHandle(entity); -+ entity.bukkitEntity = this.getBukkitEntity(); -+ -+ if (this instanceof EntityInsentient) { -+ ((EntityInsentient)this).unleash(true, false); // Unleash to prevent duping of leads. - } -+ // CraftBukkit end - } +@@ -2066,8 +2454,10 @@ + return BlockPortalShape.a(blockutil_rectangle, enumdirection_enumaxis, this.getPositionVector(), this.a(this.getPose())); + } - this.bJ(); -@@ -2253,7 +2644,26 @@ +- protected Optional a(WorldServer worldserver, BlockPosition blockposition, boolean flag) { +- return worldserver.getTravelAgent().findPortal(blockposition, flag); ++ // CraftBukkit start ++ protected Optional a(WorldServer worldserver, BlockPosition blockposition, boolean flag, int radius) { ++ return worldserver.getTravelAgent().findPortal(blockposition, radius); ++ // CraftBukkit end + } + + public boolean canPortal() { +@@ -2253,7 +2643,26 @@ } public void a(AxisAlignedBB axisalignedbb) { diff --git a/nms-patches/EntityAnimal.patch b/nms-patches/EntityAnimal.patch index 0285870160..b7850fbaa2 100644 --- a/nms-patches/EntityAnimal.patch +++ b/nms-patches/EntityAnimal.patch @@ -55,7 +55,7 @@ this.world.broadcastEntityEffect(this, (byte) 18); } @@ -186,11 +202,24 @@ - EntityAgeable entityageable = this.createChild(entityanimal); + EntityAgeable entityageable = this.createChild(worldserver, entityanimal); if (entityageable != null) { + // CraftBukkit start - set persistence for tame animals @@ -81,16 +81,16 @@ entityplayer.a(StatisticList.ANIMALS_BRED); @@ -203,10 +232,14 @@ entityanimal.resetLove(); - entityageable.a(true); + entityageable.setBaby(true); entityageable.setPositionRotation(this.locX(), this.locY(), this.locZ(), 0.0F, 0.0F); -- world.addEntity(entityageable); -+ world.addEntity(entityageable, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - added SpawnReason - world.broadcastEntityEffect(this, (byte) 18); - if (world.getGameRules().getBoolean(GameRules.DO_MOB_LOOT)) { -- world.addEntity(new EntityExperienceOrb(world, this.locX(), this.locY(), this.locZ(), this.getRandom().nextInt(7) + 1)); +- worldserver.addAllEntities(entityageable); ++ worldserver.addAllEntities(entityageable, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - added SpawnReason + worldserver.broadcastEntityEffect(this, (byte) 18); + if (worldserver.getGameRules().getBoolean(GameRules.DO_MOB_LOOT)) { +- worldserver.addEntity(new EntityExperienceOrb(worldserver, this.locX(), this.locY(), this.locZ(), this.getRandom().nextInt(7) + 1)); + // CraftBukkit start - use event experience + if (experience > 0) { -+ world.addEntity(new EntityExperienceOrb(world, this.locX(), this.locY(), this.locZ(), experience)); ++ worldserver.addEntity(new EntityExperienceOrb(worldserver, this.locX(), this.locY(), this.locZ(), experience)); + } + // CraftBukkit end } diff --git a/nms-patches/EntityArmorStand.patch b/nms-patches/EntityArmorStand.patch index c30970cb08..7de504dcde 100644 --- a/nms-patches/EntityArmorStand.patch +++ b/nms-patches/EntityArmorStand.patch @@ -15,8 +15,8 @@ + public class EntityArmorStand extends EntityLiving { - private static final Vector3f bq = new Vector3f(0.0F, 0.0F, 0.0F); -@@ -53,6 +62,13 @@ + private static final Vector3f bj = new Vector3f(0.0F, 0.0F, 0.0F); +@@ -55,6 +64,13 @@ this.setPosition(d0, d1, d2); } @@ -30,7 +30,7 @@ @Override public void updateSize() { double d0 = this.locX(); -@@ -381,6 +397,21 @@ +@@ -383,6 +399,21 @@ return false; } else { ItemStack itemstack2; @@ -52,7 +52,7 @@ if (entityhuman.abilities.canInstantlyBuild && itemstack1.isEmpty() && !itemstack.isEmpty()) { itemstack2 = itemstack.cloneItemStack(); -@@ -409,12 +440,22 @@ +@@ -411,12 +442,22 @@ public boolean damageEntity(DamageSource damagesource, float f) { if (!this.world.isClientSide && !this.dead) { if (DamageSource.OUT_OF_WORLD.equals(damagesource)) { @@ -78,7 +78,7 @@ return false; } else if (DamageSource.FIRE.equals(damagesource)) { if (this.isBurning()) { -@@ -439,7 +480,7 @@ +@@ -441,7 +482,7 @@ } else if (damagesource.v()) { this.F(); this.D(); @@ -87,7 +87,7 @@ return flag1; } else { long i = this.world.getTime(); -@@ -450,7 +491,7 @@ +@@ -452,7 +493,7 @@ } else { this.f(damagesource); this.D(); @@ -96,7 +96,7 @@ } return true; -@@ -477,7 +518,7 @@ +@@ -479,7 +520,7 @@ f1 -= f; if (f1 <= 0.5F) { this.g(damagesource); @@ -105,7 +105,7 @@ } else { this.setHealth(f1); } -@@ -485,13 +526,13 @@ +@@ -487,13 +528,13 @@ } private void f(DamageSource damagesource) { @@ -121,7 +121,7 @@ ItemStack itemstack; int i; -@@ -499,7 +540,7 @@ +@@ -501,7 +542,7 @@ for (i = 0; i < this.handItems.size(); ++i) { itemstack = (ItemStack) this.handItems.get(i); if (!itemstack.isEmpty()) { @@ -130,7 +130,7 @@ this.handItems.set(i, ItemStack.b); } } -@@ -507,10 +548,11 @@ +@@ -509,10 +550,11 @@ for (i = 0; i < this.armorItems.size(); ++i) { itemstack = (ItemStack) this.armorItems.get(i); if (!itemstack.isEmpty()) { @@ -143,7 +143,7 @@ } -@@ -611,8 +653,16 @@ +@@ -613,8 +655,16 @@ return this.isSmall(); } diff --git a/nms-patches/EntityBat.patch b/nms-patches/EntityBat.patch index dcd4e24e7c..7de5146171 100644 --- a/nms-patches/EntityBat.patch +++ b/nms-patches/EntityBat.patch @@ -39,7 +39,7 @@ } else { if (this.d != null && (!this.world.isEmpty(this.d) || this.d.getY() < 1)) { @@ -138,7 +147,11 @@ - this.ba = 0.5F; + this.aT = 0.5F; this.yaw += f1; if (this.random.nextInt(100) == 0 && this.world.getType(blockposition1).isOccluding(this.world, blockposition1)) { - this.setAsleep(true); diff --git a/nms-patches/EntityBee.patch b/nms-patches/EntityBee.patch index 193aaf8d65..16f7976880 100644 --- a/nms-patches/EntityBee.patch +++ b/nms-patches/EntityBee.patch @@ -18,7 +18,7 @@ + boolean result = super.damageEntity(damagesource, f); + + if (result && !this.world.isClientSide) { - this.bJ.l(); + this.bC.l(); } - return super.damageEntity(damagesource, f); @@ -53,7 +53,7 @@ + if (flag && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(EntityBee.this, blockposition, iblockdata.set(blockstateinteger, (Integer) iblockdata.get(blockstateinteger) + 1)).isCancelled()) { // Spigot EntityBee.this.world.triggerEffect(2005, blockposition, 0); EntityBee.this.world.setTypeUpdate(blockposition, (IBlockData) iblockdata.set(blockstateinteger, (Integer) iblockdata.get(blockstateinteger) + 1)); - EntityBee.this.fj(); + EntityBee.this.fi(); @@ -661,7 +665,7 @@ class i extends EntityBee.a { diff --git a/nms-patches/EntityBoat.patch b/nms-patches/EntityBoat.patch index f3a1b50fea..d3b5c01fa2 100644 --- a/nms-patches/EntityBoat.patch +++ b/nms-patches/EntityBoat.patch @@ -17,8 +17,8 @@ private static final DataWatcherObject b = DataWatcher.a(EntityBoat.class, DataWatcherRegistry.b); @@ -38,6 +47,14 @@ - private float aK; - private float aL; + private float aD; + private float aE; + // CraftBukkit start + // PAIL: Some of these haven't worked since a few updates, and since 1.9 they are less and less applicable. @@ -30,8 +30,8 @@ + public EntityBoat(EntityTypes entitytypes, World world) { super(entitytypes, world); - this.ao = new float[2]; -@@ -101,6 +118,19 @@ + this.ah = new float[2]; +@@ -108,6 +125,19 @@ if (this.isInvulnerable(damagesource)) { return false; } else if (!this.world.isClientSide && !this.dead) { @@ -51,7 +51,7 @@ this.c(-this.o()); this.b(10); this.setDamage(this.getDamage() + f * 10.0F); -@@ -108,6 +138,15 @@ +@@ -115,6 +145,15 @@ boolean flag = damagesource.getEntity() instanceof EntityHuman && ((EntityHuman) damagesource.getEntity()).abilities.canInstantlyBuild; if (flag || this.getDamage() > 40.0F) { @@ -67,7 +67,7 @@ if (!flag && this.world.getGameRules().getBoolean(GameRules.DO_ENTITY_DROPS)) { this.a((IMaterial) this.g()); } -@@ -142,9 +181,29 @@ +@@ -149,9 +188,29 @@ public void collide(Entity entity) { if (entity instanceof EntityBoat) { if (entity.getBoundingBox().minY < this.getBoundingBox().maxY) { @@ -97,15 +97,15 @@ super.collide(entity); } -@@ -178,6 +237,7 @@ +@@ -185,6 +244,7 @@ return this.getDirection().g(); } + private Location lastLocation; // CraftBukkit @Override public void tick() { - this.aF = this.aE; -@@ -218,6 +278,22 @@ + this.ay = this.ax; +@@ -225,6 +285,22 @@ this.setMot(Vec3D.a); } diff --git a/nms-patches/EntityCat.patch b/nms-patches/EntityCat.patch index 6039ba9399..79210fcfbc 100644 --- a/nms-patches/EntityCat.patch +++ b/nms-patches/EntityCat.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/server/EntityCat.java +++ b/net/minecraft/server/EntityCat.java @@ -15,7 +15,7 @@ - private static final DataWatcherObject bA = DataWatcher.a(EntityCat.class, DataWatcherRegistry.i); - private static final DataWatcherObject bB = DataWatcher.a(EntityCat.class, DataWatcherRegistry.i); - private static final DataWatcherObject bC = DataWatcher.a(EntityCat.class, DataWatcherRegistry.b); -- public static final Map bx = (Map) SystemUtils.a((Object) Maps.newHashMap(), (hashmap) -> { -+ public static final Map bx = (Map) SystemUtils.a(Maps.newHashMap(), (hashmap) -> { // CraftBukkit - decompile error + private static final DataWatcherObject bt = DataWatcher.a(EntityCat.class, DataWatcherRegistry.i); + private static final DataWatcherObject bu = DataWatcher.a(EntityCat.class, DataWatcherRegistry.i); + private static final DataWatcherObject bv = DataWatcher.a(EntityCat.class, DataWatcherRegistry.b); +- public static final Map bq = (Map) SystemUtils.a((Object) Maps.newHashMap(), (hashmap) -> { ++ public static final Map bq = (Map) SystemUtils.a(Maps.newHashMap(), (hashmap) -> { // CraftBukkit - decompile error hashmap.put(0, new MinecraftKey("textures/entity/cat/tabby.png")); hashmap.put(1, new MinecraftKey("textures/entity/cat/black.png")); hashmap.put(2, new MinecraftKey("textures/entity/cat/red.png")); diff --git a/nms-patches/EntityChicken.patch b/nms-patches/EntityChicken.patch index 8f0dbc3900..3f5b538545 100644 --- a/nms-patches/EntityChicken.patch +++ b/nms-patches/EntityChicken.patch @@ -10,10 +10,10 @@ + } + // CraftBukkit end super.movementTick(); - this.by = this.bv; - this.bx = this.bw; + this.br = this.bo; + this.bq = this.bp; @@ -59,7 +64,9 @@ - this.bv += this.bz * 2.0F; + this.bo += this.bs * 2.0F; if (!this.world.isClientSide && this.isAlive() && !this.isBaby() && !this.isChickenJockey() && --this.eggLayTime <= 0) { this.playSound(SoundEffects.ENTITY_CHICKEN_EGG, 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); + this.forceDrops = true; // CraftBukkit diff --git a/nms-patches/EntityCreature.patch b/nms-patches/EntityCreature.patch index 4d4f2fd450..e6700d638b 100644 --- a/nms-patches/EntityCreature.patch +++ b/nms-patches/EntityCreature.patch @@ -20,7 +20,7 @@ @@ -42,6 +47,7 @@ - this.t(f); + this.x(f); if (f > 10.0F) { + this.world.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE)); // CraftBukkit this.unleash(true, true); diff --git a/nms-patches/EntityCreeper.patch b/nms-patches/EntityCreeper.patch index 2f1d6dacc2..cbcbb5d899 100644 --- a/nms-patches/EntityCreeper.patch +++ b/nms-patches/EntityCreeper.patch @@ -14,8 +14,8 @@ @@ -165,9 +170,19 @@ @Override - public void onLightningStrike(EntityLightning entitylightning) { - super.onLightningStrike(entitylightning); + public void onLightningStrike(WorldServer worldserver, EntityLightning entitylightning) { + super.onLightningStrike(worldserver, entitylightning); - this.datawatcher.set(EntityCreeper.POWERED, true); + // CraftBukkit start + if (CraftEventFactory.callCreeperPowerEvent(this, entitylightning, org.bukkit.event.entity.CreeperPowerEvent.PowerCause.LIGHTNING).isCancelled()) { diff --git a/nms-patches/EntityDolphin.patch b/nms-patches/EntityDolphin.patch index 3daecc2064..e498398644 100644 --- a/nms-patches/EntityDolphin.patch +++ b/nms-patches/EntityDolphin.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/EntityDolphin.java +++ b/net/minecraft/server/EntityDolphin.java -@@ -107,7 +107,7 @@ +@@ -109,7 +109,7 @@ this.goalSelector.a(8, new EntityDolphin.d()); this.goalSelector.a(8, new PathfinderGoalFollowBoat(this)); this.goalSelector.a(9, new PathfinderGoalAvoidTarget<>(this, EntityGuardian.class, 8.0F, 1.0D, 1.0D)); @@ -8,8 +8,8 @@ + this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[]{EntityGuardian.class})).a(new Class[0])); // CraftBukkit - decompile error } - public static AttributeProvider.Builder eN() { -@@ -174,6 +174,11 @@ + public static AttributeProvider.Builder eM() { +@@ -176,6 +176,11 @@ ItemStack itemstack = entityitem.getItemStack(); if (this.canPickup(itemstack)) { @@ -21,7 +21,7 @@ this.a(entityitem); this.setSlot(EnumItemSlot.MAINHAND, itemstack); this.dropChanceHand[EnumItemSlot.MAINHAND.b()] = 2.0F; -@@ -315,7 +320,7 @@ +@@ -323,7 +328,7 @@ @Override public boolean a() { @@ -30,7 +30,7 @@ } @Override -@@ -424,7 +429,7 @@ +@@ -432,7 +437,7 @@ @Override public void c() { @@ -39,7 +39,7 @@ } @Override -@@ -443,7 +448,7 @@ +@@ -451,7 +456,7 @@ } if (this.c.isSwimming() && this.c.world.random.nextInt(6) == 0) { diff --git a/nms-patches/EntityEnderDragon.patch b/nms-patches/EntityEnderDragon.patch index 95ec8f9cbc..903655016a 100644 --- a/nms-patches/EntityEnderDragon.patch +++ b/nms-patches/EntityEnderDragon.patch @@ -15,9 +15,9 @@ private static final Logger LOGGER = LogManager.getLogger(); @@ -38,6 +44,7 @@ - private final PathPoint[] bQ = new PathPoint[24]; - private final int[] bR = new int[24]; - private final Path bS = new Path(); + private final PathPoint[] bJ = new PathPoint[24]; + private final int[] bK = new int[24]; + private final Path bL = new Path(); + private Explosion explosionSource = new Explosion(null, this, null, null, Double.NaN, Double.NaN, Double.NaN, Float.NaN, true, Explosion.Effect.DESTROY); // CraftBukkit - reusable source for CraftTNTPrimed.getSource() public EntityEnderDragon(EntityTypes entitytypes, World world) { @@ -105,12 +105,12 @@ + Block nmsBlock = craftBlock.getNMS().getBlock(); + if (nmsBlock.a(explosionSource)) { + TileEntity tileentity = nmsBlock.isTileEntity() ? this.world.getTileEntity(blockposition) : null; -+ LootTableInfo.Builder loottableinfo_builder = (new LootTableInfo.Builder((WorldServer) this.world)).a(this.world.random).set(LootContextParameters.POSITION, blockposition).set(LootContextParameters.TOOL, ItemStack.b).set(LootContextParameters.EXPLOSION_RADIUS, 1.0F / event.getYield()).setOptional(LootContextParameters.BLOCK_ENTITY, tileentity); ++ LootTableInfo.Builder loottableinfo_builder = (new LootTableInfo.Builder((WorldServer) this.world)).a(this.world.random).set(LootContextParameters.ORIGIN, Vec3D.a(blockposition)).set(LootContextParameters.TOOL, ItemStack.b).set(LootContextParameters.EXPLOSION_RADIUS, 1.0F / event.getYield()).setOptional(LootContextParameters.BLOCK_ENTITY, tileentity); + + craftBlock.getNMS().a(loottableinfo_builder).forEach((itemstack) -> { + Block.a(world, blockposition, itemstack); + }); -+ craftBlock.getNMS().dropNaturally(world, blockposition, ItemStack.b); ++ craftBlock.getNMS().dropNaturally((WorldServer) world, blockposition, ItemStack.b); + } + nmsBlock.wasExploded(world, blockposition, explosionSource); + diff --git a/nms-patches/EntityEnderman.patch b/nms-patches/EntityEnderman.patch index d47af191e7..5dbd840589 100644 --- a/nms-patches/EntityEnderman.patch +++ b/nms-patches/EntityEnderman.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/EntityEnderman.java +++ b/net/minecraft/server/EntityEnderman.java -@@ -52,7 +52,17 @@ +@@ -51,7 +51,17 @@ @Override public void setGoalTarget(@Nullable EntityLiving entityliving) { @@ -19,7 +19,7 @@ AttributeModifiable attributemodifiable = this.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED); if (entityliving == null) { -@@ -67,6 +77,7 @@ +@@ -66,6 +76,7 @@ attributemodifiable.b(EntityEnderman.c); } } @@ -27,31 +27,31 @@ } -@@ -360,8 +371,12 @@ +@@ -359,8 +370,12 @@ boolean flag = movingobjectpositionblock.getBlockPosition().equals(blockposition); if (block.a((Tag) TagsBlock.ENDERMAN_HOLDABLE) && flag) { -- this.enderman.setCarried(iblockdata); - world.a(blockposition, false); +- this.enderman.setCarried(iblockdata.getBlock().getBlockData()); + // CraftBukkit start - Pickup event + if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.enderman, blockposition, Blocks.AIR.getBlockData()).isCancelled()) { -+ this.enderman.setCarried(iblockdata); + world.a(blockposition, false); ++ this.enderman.setCarried(iblockdata.getBlock().getBlockData()); + } + // CraftBukkit end } } -@@ -394,8 +409,12 @@ - IBlockData iblockdata2 = this.a.getCarried(); +@@ -395,8 +410,12 @@ + if (iblockdata2 != null) { + iblockdata2 = Block.b(iblockdata2, (GeneratorAccess) this.a.world, blockposition); + if (this.a(world, blockposition, iblockdata2, iblockdata, iblockdata1, blockposition1)) { ++ // CraftBukkit start - Place event ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.a, blockposition, iblockdata2).isCancelled()) { + world.setTypeAndData(blockposition, iblockdata2, 3); + this.a.setCarried((IBlockData) null); ++ } ++ // CraftBukkit end + } - if (iblockdata2 != null && this.a(world, blockposition, iblockdata2, iblockdata, iblockdata1, blockposition1)) { -+ // CraftBukkit start - Place event -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.a, blockposition, iblockdata2).isCancelled()) { - world.setTypeAndData(blockposition, iblockdata2, 3); - this.a.setCarried((IBlockData) null); -+ } -+ // CraftBukkit end } - - } diff --git a/nms-patches/EntityFireball.patch b/nms-patches/EntityFireball.patch index 10955553f6..0855e4e7b8 100644 --- a/nms-patches/EntityFireball.patch +++ b/nms-patches/EntityFireball.patch @@ -18,7 +18,7 @@ @@ -14,6 +18,12 @@ this(entitytypes, world); this.setPositionRotation(d0, d1, d2, this.yaw, this.pitch); - this.ac(); + this.ae(); + // CraftBukkit start - Added setDirection method + this.setDirection(d3, d4, d5); + } @@ -40,8 +40,8 @@ + // CraftBukkit end } - Vec3D vec3d = this.getMot(); -@@ -132,6 +148,11 @@ + this.checkBlockCollisions(); +@@ -133,6 +149,11 @@ Entity entity = damagesource.getEntity(); if (entity != null) { diff --git a/nms-patches/EntityFireworks.patch b/nms-patches/EntityFireworks.patch index b45e1d1158..e51b4870a9 100644 --- a/nms-patches/EntityFireworks.patch +++ b/nms-patches/EntityFireworks.patch @@ -59,7 +59,7 @@ double d0 = 5.0D; @@ -197,7 +212,9 @@ if (flag) { - float f1 = f * (float) Math.sqrt((5.0D - (double) this.g(entityliving)) / 5.0D); + float f1 = f * (float) Math.sqrt((5.0D - (double) this.g((Entity) entityliving)) / 5.0D); + CraftEventFactory.entityDamage = this; // CraftBukkit entityliving.damageEntity(DamageSource.a(this, this.getShooter()), f1); diff --git a/nms-patches/EntityFishingHook.patch b/nms-patches/EntityFishingHook.patch index e6d79e8162..de8e8ab606 100644 --- a/nms-patches/EntityFishingHook.patch +++ b/nms-patches/EntityFishingHook.patch @@ -13,8 +13,8 @@ public class EntityFishingHook extends IProjectile { @@ -253,6 +258,10 @@ - this.ao = 0; - this.ap = 0; + this.ah = 0; + this.ai = 0; this.getDataWatcher().set(EntityFishingHook.f, false); + // CraftBukkit start + PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.getOwner().getBukkitEntity(), null, (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.FAILED_ATTEMPT); diff --git a/nms-patches/EntityFox.patch b/nms-patches/EntityFox.patch index f7e581b908..b9e912e694 100644 --- a/nms-patches/EntityFox.patch +++ b/nms-patches/EntityFox.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/server/EntityFox.java +++ b/net/minecraft/server/EntityFox.java @@ -264,8 +264,8 @@ - private List fb() { + private List fa() { List list = Lists.newArrayList(); - list.add(((Optional) this.datawatcher.get(EntityFox.FIRST_TRUSTED_PLAYER)).orElse((Object) null)); @@ -59,7 +59,7 @@ super(EntityFox.this, oclass, 10, flag, flag1, predicate); } -@@ -1204,6 +1209,14 @@ +@@ -1205,6 +1210,14 @@ if (entityplayer1 != null && entityplayer != entityplayer1) { entityfox.b(entityplayer1.getUniqueID()); } @@ -74,12 +74,12 @@ if (entityplayer2 != null) { entityplayer2.a(StatisticList.ANIMALS_BRED); -@@ -1216,10 +1229,14 @@ +@@ -1217,10 +1230,14 @@ this.partner.resetLove(); entityfox.setAgeRaw(-24000); entityfox.setPositionRotation(this.animal.locX(), this.animal.locY(), this.animal.locZ(), 0.0F, 0.0F); -- this.b.addEntity(entityfox); -+ this.b.addEntity(entityfox, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - added SpawnReason +- worldserver.addAllEntities(entityfox); ++ worldserver.addAllEntities(entityfox, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - added SpawnReason this.b.broadcastEntityEffect(this.animal, (byte) 18); if (this.b.getGameRules().getBoolean(GameRules.DO_MOB_LOOT)) { - this.b.addEntity(new EntityExperienceOrb(this.b, this.animal.locX(), this.animal.locY(), this.animal.locZ(), this.animal.getRandom().nextInt(7) + 1)); diff --git a/nms-patches/EntityHanging.patch b/nms-patches/EntityHanging.patch index 59a47ca02e..fdb1b72279 100644 --- a/nms-patches/EntityHanging.patch +++ b/nms-patches/EntityHanging.patch @@ -149,7 +149,7 @@ @@ -166,7 +230,7 @@ @Override - public void h(double d0, double d1, double d2) { + public void i(double d0, double d1, double d2) { - if (!this.world.isClientSide && !this.dead && d0 * d0 + d1 * d1 + d2 * d2 > 0.0D) { + if (false && !this.world.isClientSide && !this.dead && d0 * d0 + d1 * d1 + d2 * d2 > 0.0D) { // CraftBukkit - not needed this.die(); diff --git a/nms-patches/EntityHoglin.patch b/nms-patches/EntityHoglin.patch deleted file mode 100644 index 81eeadfa86..0000000000 --- a/nms-patches/EntityHoglin.patch +++ /dev/null @@ -1,51 +0,0 @@ ---- a/net/minecraft/server/EntityHoglin.java -+++ b/net/minecraft/server/EntityHoglin.java -@@ -10,10 +10,11 @@ - - private static final DataWatcherObject bx = DataWatcher.a(EntityHoglin.class, DataWatcherRegistry.i); - private int by; -- private int bz = 0; -- private boolean bA = false; -+ public int bz = 0; // PAIL -+ public boolean bA = false; // PAIL - protected static final ImmutableList>> bv = ImmutableList.of(SensorType.c, SensorType.d, SensorType.n, SensorType.m); -- protected static final ImmutableList> bw = ImmutableList.of(MemoryModuleType.BREED_TARGET, MemoryModuleType.MOBS, MemoryModuleType.VISIBLE_MOBS, MemoryModuleType.NEAREST_VISIBLE_PLAYER, MemoryModuleType.NEAREST_VISIBLE_TARGETABLE_PLAYER, MemoryModuleType.LOOK_TARGET, MemoryModuleType.WALK_TARGET, MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE, MemoryModuleType.PATH, MemoryModuleType.ATTACK_TARGET, MemoryModuleType.ATTACK_COOLING_DOWN, MemoryModuleType.NEAREST_VISIBLE_ADULT_PIGLIN, new MemoryModuleType[]{MemoryModuleType.AVOID_TARGET, MemoryModuleType.VISIBLE_ADULT_PIGLIN_COUNT, MemoryModuleType.VISIBLE_ADULT_HOGLIN_COUNT, MemoryModuleType.NEAREST_VISIBLE_ADULT_HOGLINS, MemoryModuleType.NEAREST_VISIBLE_ADULY, MemoryModuleType.NEAREST_REPELLENT, MemoryModuleType.PACIFIED}); -+ // CraftBukkit - decompile error -+ protected static final ImmutableList> bw = ImmutableList.>of(MemoryModuleType.BREED_TARGET, MemoryModuleType.MOBS, MemoryModuleType.VISIBLE_MOBS, MemoryModuleType.NEAREST_VISIBLE_PLAYER, MemoryModuleType.NEAREST_VISIBLE_TARGETABLE_PLAYER, MemoryModuleType.LOOK_TARGET, MemoryModuleType.WALK_TARGET, MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE, MemoryModuleType.PATH, MemoryModuleType.ATTACK_TARGET, MemoryModuleType.ATTACK_COOLING_DOWN, MemoryModuleType.NEAREST_VISIBLE_ADULT_PIGLIN, new MemoryModuleType[]{MemoryModuleType.AVOID_TARGET, MemoryModuleType.VISIBLE_ADULT_PIGLIN_COUNT, MemoryModuleType.VISIBLE_ADULT_HOGLIN_COUNT, MemoryModuleType.NEAREST_VISIBLE_ADULT_HOGLINS, MemoryModuleType.NEAREST_VISIBLE_ADULY, MemoryModuleType.NEAREST_REPELLENT, MemoryModuleType.PACIFIED}); - - public EntityHoglin(EntityTypes entitytypes, World world) { - super(entitytypes, world); -@@ -77,13 +78,13 @@ - - @Override - public BehaviorController getBehaviorController() { -- return super.getBehaviorController(); -+ return (BehaviorController) super.getBehaviorController(); // CraftBukkit - decompile error - } - - @Override - protected void mobTick() { - this.world.getMethodProfiler().enter("hoglinBrain"); -- this.getBehaviorController().a((WorldServer) this.world, (EntityLiving) this); -+ this.getBehaviorController().a((WorldServer) this.world, this); // CraftBukkit - decompile error - this.world.getMethodProfiler().exit(); - HoglinAI.a(this); - if (this.eO()) { -@@ -216,7 +217,7 @@ - this.getDataWatcher().set(EntityHoglin.bx, flag); - } - -- private boolean eW() { -+ public boolean eW() { // PAIL - return (Boolean) this.getDataWatcher().get(EntityHoglin.bx); - } - -@@ -256,7 +257,7 @@ - - @Override - protected SoundEffect getSoundAmbient() { -- return this.world.isClientSide ? null : (SoundEffect) HoglinAI.b(this).orElse((Object) null); -+ return this.world.isClientSide ? null : (SoundEffect) HoglinAI.b(this).orElse(null); // CraftBukkit - decompile error - } - - @Override diff --git a/nms-patches/EntityHorseAbstract.patch b/nms-patches/EntityHorseAbstract.patch index 649c9b98ca..8d2d2ac7eb 100644 --- a/nms-patches/EntityHorseAbstract.patch +++ b/nms-patches/EntityHorseAbstract.patch @@ -9,9 +9,9 @@ public abstract class EntityHorseAbstract extends EntityAnimal implements IInventoryListener, IJumpable, ISaddleable { @@ -34,6 +35,7 @@ - private float bR; - protected boolean bB = true; - protected int bC; + private float bK; + protected boolean bu = true; + protected int bv; + public int maxDomestication = 100; // CraftBukkit - store max domestication value protected EntityHorseAbstract(EntityTypes entitytypes, World world) { @@ -51,7 +51,7 @@ + this.heal(1.0F, RegainReason.REGEN); // CraftBukkit } - if (this.fm()) { + if (this.fl()) { @@ -718,6 +720,7 @@ if (this.getOwnerUUID() != null) { nbttagcompound.a("Owner", this.getOwnerUUID()); @@ -89,5 +89,5 @@ + } + // CraftBukkit end this.canSlide = true; - this.eV(); - this.fo(); + this.eU(); + this.fn(); diff --git a/nms-patches/EntityHuman.patch b/nms-patches/EntityHuman.patch index 0d08161796..a19d48d0cd 100644 --- a/nms-patches/EntityHuman.patch +++ b/nms-patches/EntityHuman.patch @@ -19,15 +19,15 @@ + public abstract class EntityHuman extends EntityLiving { - public static final EntitySize bo = EntitySize.b(0.6F, 1.8F); -- private static final Map b = ImmutableMap.builder().put(EntityPose.STANDING, EntityHuman.bo).put(EntityPose.SLEEPING, EntityHuman.ao).put(EntityPose.FALL_FLYING, EntitySize.b(0.6F, 0.6F)).put(EntityPose.SWIMMING, EntitySize.b(0.6F, 0.6F)).put(EntityPose.SPIN_ATTACK, EntitySize.b(0.6F, 0.6F)).put(EntityPose.CROUCHING, EntitySize.b(0.6F, 1.5F)).put(EntityPose.DYING, EntitySize.c(0.2F, 0.2F)).build(); + public static final EntitySize bh = EntitySize.b(0.6F, 1.8F); +- private static final Map b = ImmutableMap.builder().put(EntityPose.STANDING, EntityHuman.bh).put(EntityPose.SLEEPING, EntityHuman.ah).put(EntityPose.FALL_FLYING, EntitySize.b(0.6F, 0.6F)).put(EntityPose.SWIMMING, EntitySize.b(0.6F, 0.6F)).put(EntityPose.SPIN_ATTACK, EntitySize.b(0.6F, 0.6F)).put(EntityPose.CROUCHING, EntitySize.b(0.6F, 1.5F)).put(EntityPose.DYING, EntitySize.c(0.2F, 0.2F)).build(); + // CraftBukkit - decompile error -+ private static final Map b = ImmutableMap.builder().put(EntityPose.STANDING, EntityHuman.bo).put(EntityPose.SLEEPING, EntityHuman.ao).put(EntityPose.FALL_FLYING, EntitySize.b(0.6F, 0.6F)).put(EntityPose.SWIMMING, EntitySize.b(0.6F, 0.6F)).put(EntityPose.SPIN_ATTACK, EntitySize.b(0.6F, 0.6F)).put(EntityPose.CROUCHING, EntitySize.b(0.6F, 1.5F)).put(EntityPose.DYING, EntitySize.c(0.2F, 0.2F)).build(); ++ private static final Map b = ImmutableMap.builder().put(EntityPose.STANDING, EntityHuman.bh).put(EntityPose.SLEEPING, EntityHuman.ah).put(EntityPose.FALL_FLYING, EntitySize.b(0.6F, 0.6F)).put(EntityPose.SWIMMING, EntitySize.b(0.6F, 0.6F)).put(EntityPose.SPIN_ATTACK, EntitySize.b(0.6F, 0.6F)).put(EntityPose.CROUCHING, EntitySize.b(0.6F, 1.5F)).put(EntityPose.DYING, EntitySize.c(0.2F, 0.2F)).build(); private static final DataWatcherObject c = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.c); private static final DataWatcherObject d = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.b); - protected static final DataWatcherObject bp = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.a); + protected static final DataWatcherObject bi = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.a); @@ -28,10 +42,10 @@ - protected static final DataWatcherObject bs = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.p); + protected static final DataWatcherObject bl = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.p); private long e; public final PlayerInventory inventory = new PlayerInventory(this); - protected InventoryEnderChest enderChest = new InventoryEnderChest(); @@ -36,9 +36,9 @@ public Container activeContainer; - protected FoodMetaData foodData = new FoodMetaData(); + protected FoodMetaData foodData = new FoodMetaData(this); // CraftBukkit - add "this" to constructor - protected int by; - public float bz; - public float bA; + protected int br; + public float bs; + public float bt; @@ -57,6 +71,16 @@ @Nullable public EntityFishingHook hookedFish; @@ -53,9 +53,9 @@ + } + // CraftBukkit end + - public EntityHuman(World world, BlockPosition blockposition, GameProfile gameprofile) { + public EntityHuman(World world, BlockPosition blockposition, float f, GameProfile gameprofile) { super(EntityTypes.PLAYER, world); - this.bS = ItemStack.b; + this.bL = ItemStack.b; @@ -194,7 +218,7 @@ ItemStack itemstack = this.getEquipment(EnumItemSlot.HEAD); @@ -197,7 +197,7 @@ } @Override -@@ -928,7 +1009,7 @@ +@@ -932,7 +1013,7 @@ f *= 0.2F + f2 * f2 * 0.8F; f1 *= f2; @@ -206,7 +206,7 @@ if (f > 0.0F || f1 > 0.0F) { boolean flag = f2 > 0.9F; boolean flag1 = false; -@@ -967,8 +1048,15 @@ +@@ -971,8 +1052,15 @@ if (entity instanceof EntityLiving) { f3 = ((EntityLiving) entity).getHealth(); if (j > 0 && !entity.isBurning()) { @@ -224,7 +224,7 @@ } } -@@ -996,8 +1084,11 @@ +@@ -1000,8 +1088,11 @@ EntityLiving entityliving = (EntityLiving) iterator.next(); if (entityliving != this && entityliving != entity && !this.r(entityliving) && (!(entityliving instanceof EntityArmorStand) || !((EntityArmorStand) entityliving).isMarker()) && this.h((Entity) entityliving) < 9.0D) { @@ -237,7 +237,7 @@ } } -@@ -1006,9 +1097,26 @@ +@@ -1010,9 +1101,26 @@ } if (entity instanceof EntityPlayer && entity.velocityChanged) { @@ -264,7 +264,7 @@ } if (flag2) { -@@ -1053,7 +1161,14 @@ +@@ -1057,7 +1165,14 @@ this.a(StatisticList.DAMAGE_DEALT, Math.round(f5 * 10.0F)); if (j > 0) { @@ -280,7 +280,7 @@ } if (this.world instanceof WorldServer && f5 > 2.0F) { -@@ -1069,6 +1184,11 @@ +@@ -1073,6 +1188,11 @@ if (flag4) { entity.extinguish(); } @@ -292,7 +292,7 @@ } } -@@ -1129,17 +1249,40 @@ +@@ -1133,17 +1253,40 @@ } public Either sleep(BlockPosition blockposition) { @@ -333,9 +333,9 @@ this.sleepTicks = flag ? 0 : 100; } -@@ -1249,7 +1392,11 @@ +@@ -1253,7 +1396,11 @@ this.setMot(vec3d2.x, d3 * 0.6D, vec3d2.z); - this.aL = f; + this.aE = f; this.fallDistance = 0.0F; - this.setFlag(7, false); + // CraftBukkit start @@ -344,9 +344,9 @@ + } + // CraftBukkit end } else { - super.f(vec3d); + super.g(vec3d); } -@@ -1379,12 +1526,24 @@ +@@ -1383,12 +1530,24 @@ } public void startGliding() { @@ -372,7 +372,7 @@ } @Override -@@ -1599,26 +1758,31 @@ +@@ -1603,26 +1762,31 @@ protected void releaseShoulderEntities() { if (this.e + 20L < this.world.getTime()) { diff --git a/nms-patches/EntityInsentient.patch b/nms-patches/EntityInsentient.patch index 7eaedccac4..a138242c2b 100644 --- a/nms-patches/EntityInsentient.patch +++ b/nms-patches/EntityInsentient.patch @@ -21,22 +21,22 @@ private static final DataWatcherObject b = DataWatcher.a(EntityInsentient.class, DataWatcherRegistry.a); @@ -28,7 +40,7 @@ public final float[] dropChanceHand; - private final NonNullList bx; + private final NonNullList bq; public final float[] dropChanceArmor; - private boolean canPickUpLoot; + // private boolean canPickUpLoot; // CraftBukkit - moved up to EntityLiving public boolean persistent; - private final Map bA; + private final Map bt; public MinecraftKey lootTableKey; @@ -41,6 +53,8 @@ - private BlockPosition bG; - private float bH; + private BlockPosition bz; + private float bA; + public boolean aware = true; // CraftBukkit + protected EntityInsentient(EntityTypes entitytypes, World world) { super(entitytypes, world); - this.bw = NonNullList.a(2, ItemStack.b); + this.bp = NonNullList.a(2, ItemStack.b); @@ -64,6 +78,9 @@ this.initPathfinder(); } @@ -207,9 +207,9 @@ ++this.ticksFarFromPlayer; + if (!this.aware) return; // CraftBukkit this.world.getMethodProfiler().enter("sensing"); - this.bv.a(); + this.bo.a(); this.world.getMethodProfiler().exit(); -@@ -1014,6 +1097,12 @@ +@@ -1023,6 +1106,12 @@ if (!this.isAlive()) { return EnumInteractionResult.PASS; } else if (this.getLeashHolder() == entityhuman) { @@ -222,7 +222,7 @@ this.unleash(true, !entityhuman.abilities.canInstantlyBuild); return EnumInteractionResult.a(this.world.isClientSide); } else { -@@ -1032,6 +1121,12 @@ +@@ -1041,6 +1130,12 @@ ItemStack itemstack = entityhuman.b(enumhand); if (itemstack.getItem() == Items.LEAD && this.a(entityhuman)) { @@ -235,16 +235,28 @@ this.setLeashHolder(entityhuman, true); itemstack.subtract(1); return EnumInteractionResult.a(this.world.isClientSide); -@@ -1047,7 +1142,7 @@ +@@ -1056,7 +1151,7 @@ if (itemstack.getItem() instanceof ItemMonsterEgg) { - if (!this.world.isClientSide) { + if (this.world instanceof WorldServer) { ItemMonsterEgg itemmonsteregg = (ItemMonsterEgg) itemstack.getItem(); -- Optional optional = itemmonsteregg.a(entityhuman, this, this.getEntityType(), this.world, this.getPositionVector(), itemstack); -+ Optional optional = itemmonsteregg.a(entityhuman, this, (EntityTypes) this.getEntityType(), this.world, this.getPositionVector(), itemstack); // CraftBukkit - decompile error +- Optional optional = itemmonsteregg.a(entityhuman, this, this.getEntityType(), (WorldServer) this.world, this.getPositionVector(), itemstack); ++ Optional optional = itemmonsteregg.a(entityhuman, this, (EntityTypes) this.getEntityType(), (WorldServer) this.world, this.getPositionVector(), itemstack); // CraftBukkit - decompile error optional.ifPresent((entityinsentient) -> { this.a(entityhuman, entityinsentient); -@@ -1098,7 +1193,7 @@ +@@ -1102,12 +1197,19 @@ + return this.bA != -1.0F; + } + ++ // CraftBukkit start + @Nullable + public T a(EntityTypes entitytypes, boolean flag) { ++ return this.a(entitytypes, flag, EntityTransformEvent.TransformReason.UNKNOWN, CreatureSpawnEvent.SpawnReason.DEFAULT); ++ } ++ ++ @Nullable ++ public T a(EntityTypes entitytypes, boolean flag, EntityTransformEvent.TransformReason transformReason, CreatureSpawnEvent.SpawnReason spawnReason) { ++ // CraftBukkit end if (this.dead) { return null; } else { @@ -252,22 +264,22 @@ + T t0 = entitytypes.a(this.world); // CraftBukkit - decompile error t0.u(this); - t0.setCanPickupLoot(this.canPickupLoot()); -@@ -1128,7 +1223,12 @@ + t0.setBaby(this.isBaby()); +@@ -1139,7 +1241,12 @@ } } - this.world.addEntity(t0); + // CraftBukkit start -+ if (CraftEventFactory.callEntityTransformEvent(this, t0, EntityTransformEvent.TransformReason.DROWNED).isCancelled()) { ++ if (CraftEventFactory.callEntityTransformEvent(this, t0, transformReason).isCancelled()) { + return null; + } -+ this.world.addEntity(t0, CreatureSpawnEvent.SpawnReason.DROWNED); ++ this.world.addEntity(t0, spawnReason); + // CraftBukkit end - this.die(); - return t0; - } -@@ -1141,6 +1241,7 @@ + if (this.isPassenger()) { + Entity entity = this.getVehicle(); + +@@ -1159,6 +1266,7 @@ if (this.leashHolder != null) { if (!this.isAlive() || !this.leashHolder.isAlive()) { @@ -275,9 +287,9 @@ this.unleash(true, true); } -@@ -1157,7 +1258,9 @@ +@@ -1175,7 +1283,9 @@ this.leashHolder = null; - this.bF = null; + this.by = null; if (!this.world.isClientSide && flag1) { + this.forceDrops = true; // CraftBukkit this.a((IMaterial) Items.LEAD); @@ -285,7 +297,7 @@ } if (!this.world.isClientSide && flag && this.world instanceof WorldServer) { -@@ -1207,6 +1310,7 @@ +@@ -1225,6 +1335,7 @@ boolean flag1 = super.a(entity, flag); if (flag1 && this.isLeashed()) { @@ -293,7 +305,7 @@ this.unleash(true, true); } -@@ -1339,7 +1443,14 @@ +@@ -1357,7 +1468,14 @@ int i = EnchantmentManager.getFireAspectEnchantmentLevel(this); if (i > 0) { @@ -309,10 +321,10 @@ } boolean flag = entity.damageEntity(DamageSource.mobAttack(this), f); -@@ -1401,6 +1512,7 @@ +@@ -1419,6 +1537,7 @@ @Override - protected void bJ() { - super.bJ(); + protected void bM() { + super.bM(); + this.world.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.UNKNOWN)); // CraftBukkit this.unleash(true, false); } diff --git a/nms-patches/EntityItem.patch b/nms-patches/EntityItem.patch index 16c665dc91..c1631939d5 100644 --- a/nms-patches/EntityItem.patch +++ b/nms-patches/EntityItem.patch @@ -35,7 +35,7 @@ this.lastX = this.locX(); this.lastY = this.locY(); -@@ -103,9 +111,11 @@ +@@ -108,9 +116,11 @@ } } @@ -45,9 +45,9 @@ } + // CraftBukkit end */ - this.impulse |= this.aG(); + this.impulse |= this.aJ(); if (!this.world.isClientSide) { -@@ -117,6 +127,12 @@ +@@ -122,6 +132,12 @@ } if (!this.world.isClientSide && this.age >= 6000) { @@ -60,7 +60,7 @@ this.die(); } -@@ -192,10 +208,11 @@ +@@ -197,10 +213,11 @@ private static void a(EntityItem entityitem, ItemStack itemstack, ItemStack itemstack1) { ItemStack itemstack2 = a(itemstack, itemstack1, 64); @@ -73,7 +73,7 @@ a(entityitem, itemstack, itemstack1); entityitem.pickupDelay = Math.max(entityitem.pickupDelay, entityitem1.pickupDelay); entityitem.age = Math.min(entityitem.age, entityitem1.age); -@@ -219,6 +236,11 @@ +@@ -224,6 +241,11 @@ } else if (!this.getItemStack().getItem().a(damagesource)) { return false; } else { @@ -85,7 +85,7 @@ this.velocityChanged(); this.f = (int) ((float) this.f - f); if (this.f <= 0) { -@@ -280,6 +302,40 @@ +@@ -285,6 +307,40 @@ Item item = itemstack.getItem(); int i = itemstack.getCount(); @@ -126,7 +126,7 @@ if (this.pickupDelay == 0 && (this.owner == null || this.owner.equals(entityhuman.getUniqueID())) && entityhuman.inventory.pickup(itemstack)) { entityhuman.receive(this, i); if (itemstack.isEmpty()) { -@@ -323,7 +379,9 @@ +@@ -328,7 +384,9 @@ } public void setItemStack(ItemStack itemstack) { diff --git a/nms-patches/EntityItemFrame.patch b/nms-patches/EntityItemFrame.patch index 3c5c54278c..13cff21e36 100644 --- a/nms-patches/EntityItemFrame.patch +++ b/nms-patches/EntityItemFrame.patch @@ -1,14 +1,5 @@ --- a/net/minecraft/server/EntityItemFrame.java +++ b/net/minecraft/server/EntityItemFrame.java -@@ -11,7 +11,7 @@ - private static final DataWatcherObject ITEM = DataWatcher.a(EntityItemFrame.class, DataWatcherRegistry.g); - private static final DataWatcherObject g = DataWatcher.a(EntityItemFrame.class, DataWatcherRegistry.b); - private float an = 1.0F; -- private boolean ao; -+ public boolean ao; // PAIL private -> public // PAIL rename isFixed - - public EntityItemFrame(EntityTypes entitytypes, World world) { - super(entitytypes, world); @@ -53,16 +53,27 @@ @Override protected void updateBoundingBox() { diff --git a/nms-patches/EntityLightning.patch b/nms-patches/EntityLightning.patch index 61e5022b2a..e9e38bbe18 100644 --- a/nms-patches/EntityLightning.patch +++ b/nms-patches/EntityLightning.patch @@ -41,7 +41,7 @@ - if (this.lifeTicks >= 0) { + if (this.lifeTicks >= 0 && !this.isEffect) { // CraftBukkit - add !this.isEffect - if (this.world.isClientSide) { + if (!(this.world instanceof WorldServer)) { this.world.c(2); } else if (!this.isEffect) { @@ -89,7 +108,11 @@ diff --git a/nms-patches/EntityLiving.patch b/nms-patches/EntityLiving.patch index edba661b4c..693cac9711 100644 --- a/nms-patches/EntityLiving.patch +++ b/nms-patches/EntityLiving.patch @@ -28,9 +28,9 @@ private static final UUID b = UUID.fromString("662A6B8D-DA3E-4C1C-8813-96EA6097278D"); @@ -106,6 +126,21 @@ - private float bI; - private float bJ; - protected BehaviorController bn; + private float bB; + private float bC; + protected BehaviorController bg; + // CraftBukkit start + public int expToDrop; + public int maxAirTicks = 300; @@ -51,15 +51,15 @@ super(entitytypes, world); @@ -117,7 +152,9 @@ this.activeItem = ItemStack.b; - this.bF = Optional.empty(); + this.by = Optional.empty(); this.attributeMap = new AttributeMapBase(AttributeDefaults.a(entitytypes)); - this.setHealth(this.getMaxHealth()); + this.craftAttributes = new CraftAttributeMap(attributeMap); // CraftBukkit + // 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.MAX_HEALTH).getValue()); this.i = true; - this.aG = (float) ((Math.random() + 1.0D) * 0.009999999776482582D); - this.ac(); + this.az = (float) ((Math.random() + 1.0D) * 0.009999999776482582D); + this.ae(); @@ -184,7 +221,13 @@ double d1 = Math.min((double) (0.2F + f / 15.0F), 2.5D); int i = (int) (150.0D * d1); @@ -411,7 +411,7 @@ + } + // CraftBukkit end + - this.aw = 0.0F; + this.ap = 0.0F; Entity entity1 = damagesource.getEntity(); @@ -1050,19 +1265,29 @@ @@ -448,17 +448,19 @@ EntityPlayer entityplayer = (EntityPlayer) this; entityplayer.b(StatisticList.ITEM_USED.b(Items.TOTEM_OF_UNDYING)); -@@ -1070,13 +1295,15 @@ +@@ -1070,14 +1295,16 @@ } this.setHealth(1.0F); - this.removeAllEffects(); - this.addEffect(new MobEffect(MobEffects.REGENERATION, 900, 1)); - this.addEffect(new MobEffect(MobEffects.ABSORBTION, 100, 1)); +- this.addEffect(new MobEffect(MobEffects.FIRE_RESISTANCE, 800, 0)); + // CraftBukkit start + this.removeAllEffects(org.bukkit.event.entity.EntityPotionEffectEvent.Cause.TOTEM); + this.addEffect(new MobEffect(MobEffects.REGENERATION, 900, 1), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.TOTEM); + this.addEffect(new MobEffect(MobEffects.ABSORBTION, 100, 1), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.TOTEM); ++ this.addEffect(new MobEffect(MobEffects.FIRE_RESISTANCE, 800, 0), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.TOTEM); + // CraftBukkit end this.world.broadcastEntityEffect(this, (byte) 35); } @@ -468,7 +470,7 @@ } } -@@ -1193,28 +1420,46 @@ +@@ -1194,28 +1421,46 @@ boolean flag = this.lastDamageByPlayerTime > 0; @@ -517,7 +519,7 @@ } -@@ -1335,9 +1580,14 @@ +@@ -1336,9 +1581,14 @@ int i = this.e(f, f1); if (i > 0) { @@ -533,7 +535,7 @@ return true; } else { return flag; -@@ -1377,7 +1627,7 @@ +@@ -1378,7 +1628,7 @@ protected float applyArmorModifier(DamageSource damagesource, float f) { if (!damagesource.ignoresArmor()) { @@ -542,7 +544,7 @@ f = CombatMath.a(f, (float) this.getArmorStrength(), (float) this.b(GenericAttributes.ARMOR_TOUGHNESS)); } -@@ -1390,7 +1640,8 @@ +@@ -1391,7 +1641,8 @@ } else { int i; @@ -552,7 +554,7 @@ i = (this.getEffect(MobEffects.RESISTANCE).getAmplifier() + 1) * 5; int j = 25 - i; float f1 = f * (float) j; -@@ -1421,28 +1672,173 @@ +@@ -1422,28 +1673,173 @@ } } @@ -636,12 +638,9 @@ + if (event.isCancelled()) { + return false; + } - -- f = Math.max(f - this.getAbsorptionHearts(), 0.0F); -- this.setAbsorptionHearts(this.getAbsorptionHearts() - (f1 - f)); -- float f2 = f1 - f; ++ + f = (float) event.getFinalDamage(); - ++ + // Resistance + if (event.getDamage(DamageModifier.RESISTANCE) < 0) { + float f3 = (float) -event.getDamage(DamageModifier.RESISTANCE); @@ -666,13 +665,16 @@ + float armorDamage = (float) (event.getDamage() + event.getDamage(DamageModifier.BLOCKING) + event.getDamage(DamageModifier.HARD_HAT)); + this.damageArmor(damagesource, armorDamage); + } -+ + +- f = Math.max(f - this.getAbsorptionHearts(), 0.0F); +- this.setAbsorptionHearts(this.getAbsorptionHearts() - (f1 - f)); +- float f2 = f1 - f; + // Apply blocking code // PAIL: steal from above + if (event.getDamage(DamageModifier.BLOCKING) < 0) { + this.world.broadcastEntityEffect(this, (byte) 29); // SPIGOT-4635 - shield damage sound + this.damageShield((float) -event.getDamage(DamageModifier.BLOCKING)); + Entity entity = damagesource.j(); -+ + + if (entity instanceof EntityLiving) { + this.shieldBlock((EntityLiving) entity); + } @@ -736,7 +738,7 @@ } public CombatTracker getCombatTracker() { -@@ -1814,6 +2210,7 @@ +@@ -1815,6 +2211,7 @@ } if (this.onGround && !this.world.isClientSide) { @@ -744,7 +746,7 @@ this.setFlag(7, false); } } else { -@@ -2319,6 +2716,7 @@ +@@ -2320,6 +2717,7 @@ } if (!this.world.isClientSide) { @@ -752,7 +754,7 @@ this.setFlag(7, flag); } -@@ -2439,6 +2837,7 @@ +@@ -2440,6 +2838,7 @@ } public boolean hasLineOfSight(Entity entity) { @@ -760,7 +762,7 @@ Vec3D vec3d = new Vec3D(this.locX(), this.getHeadY(), this.locZ()); Vec3D vec3d1 = new Vec3D(entity.locX(), entity.getHeadY(), entity.locZ()); -@@ -2456,13 +2855,20 @@ +@@ -2457,13 +2856,20 @@ @Override public boolean isInteractable() { @@ -770,8 +772,8 @@ @Override public boolean isCollidable() { -- return this.isAlive() && !this.isClimbing(); -+ return this.isAlive() && !this.isClimbing() && this.collides; // CraftBukkit +- return this.isAlive() && !this.isSpectator() && !this.isClimbing(); ++ return this.isAlive() && !this.isSpectator() && !this.isClimbing() && this.collides; // CraftBukkit + } + + // CraftBukkit start - collidable API @@ -783,11 +785,11 @@ @Override protected void velocityChanged() { -@@ -2645,7 +3051,27 @@ +@@ -2657,7 +3063,25 @@ } else { if (!this.activeItem.isEmpty() && this.isHandRaised()) { this.b(this.activeItem, 16); -- this.a(this.getRaisedHand(), this.activeItem.a(this.world, this)); +- ItemStack itemstack = this.activeItem.a(this.world, this); + // CraftBukkit start - fire PlayerItemConsumeEvent + ItemStack itemstack; + if (this instanceof EntityPlayer) { @@ -806,13 +808,11 @@ + } else { + itemstack = this.activeItem.a(this.world, this); + } -+ -+ this.a(this.getRaisedHand(), itemstack); + // CraftBukkit end - this.clearActiveItem(); - } -@@ -2732,10 +3158,18 @@ + if (itemstack != this.activeItem) { + this.a(enumhand, itemstack); +@@ -2749,10 +3173,18 @@ } if (flag2) { @@ -834,7 +834,7 @@ } } -@@ -2832,7 +3266,7 @@ +@@ -2849,7 +3281,7 @@ } public void entityWakeup() { @@ -843,7 +843,7 @@ World world = this.world; this.world.getClass(); -@@ -2899,7 +3333,7 @@ +@@ -2920,7 +3352,7 @@ Pair pair = (Pair) iterator.next(); if (!world.isClientSide && pair.getFirst() != null && world.random.nextFloat() < (Float) pair.getSecond()) { diff --git a/nms-patches/EntityLlamaTrader.patch b/nms-patches/EntityLlamaTrader.patch index 47f6d27feb..17901f95aa 100644 --- a/nms-patches/EntityLlamaTrader.patch +++ b/nms-patches/EntityLlamaTrader.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/EntityLlamaTrader.java +++ b/net/minecraft/server/EntityLlamaTrader.java -@@ -128,7 +128,7 @@ +@@ -127,7 +127,7 @@ @Override public void c() { diff --git a/nms-patches/EntityMinecartAbstract.patch b/nms-patches/EntityMinecartAbstract.patch index 4e55d8a4a2..40d9b4c5b6 100644 --- a/nms-patches/EntityMinecartAbstract.patch +++ b/nms-patches/EntityMinecartAbstract.patch @@ -18,16 +18,16 @@ private static final DataWatcherObject b = DataWatcher.a(EntityMinecartAbstract.class, DataWatcherRegistry.b); @@ -20,7 +29,7 @@ private static final DataWatcherObject g = DataWatcher.a(EntityMinecartAbstract.class, DataWatcherRegistry.i); - private static final ImmutableMap> an = ImmutableMap.of(EntityPose.STANDING, ImmutableList.of(0, 1, -1), EntityPose.CROUCHING, ImmutableList.of(0, 1, -1), EntityPose.SWIMMING, ImmutableList.of(0, 1)); - private boolean ao; -- private static final Map> ap = (Map) SystemUtils.a((Object) Maps.newEnumMap(BlockPropertyTrackPosition.class), (enummap) -> { -+ private static final Map> ap = (Map) SystemUtils.a(Maps.newEnumMap(BlockPropertyTrackPosition.class), (enummap) -> { // CraftBukkit - decompile error + private static final ImmutableMap> ag = ImmutableMap.of(EntityPose.STANDING, ImmutableList.of(0, 1, -1), EntityPose.CROUCHING, ImmutableList.of(0, 1, -1), EntityPose.SWIMMING, ImmutableList.of(0, 1)); + private boolean ah; +- private static final Map> ai = (Map) SystemUtils.a((Object) Maps.newEnumMap(BlockPropertyTrackPosition.class), (enummap) -> { ++ private static final Map> ai = (Map) SystemUtils.a(Maps.newEnumMap(BlockPropertyTrackPosition.class), (enummap) -> { // CraftBukkit - decompile error BaseBlockPosition baseblockposition = EnumDirection.WEST.p(); BaseBlockPosition baseblockposition1 = EnumDirection.EAST.p(); BaseBlockPosition baseblockposition2 = EnumDirection.NORTH.p(); @@ -48,6 +57,17 @@ - private double au; - private double av; + private double an; + private double ao; + // CraftBukkit start + public boolean slowWhenEmpty = true; @@ -43,7 +43,7 @@ protected EntityMinecartAbstract(EntityTypes entitytypes, World world) { super(entitytypes, world); this.i = true; -@@ -168,6 +188,19 @@ +@@ -175,6 +195,19 @@ if (this.isInvulnerable(damagesource)) { return false; } else { @@ -63,7 +63,7 @@ this.d(-this.n()); this.c(10); this.velocityChanged(); -@@ -175,6 +208,15 @@ +@@ -182,6 +215,15 @@ boolean flag = damagesource.getEntity() instanceof EntityHuman && ((EntityHuman) damagesource.getEntity()).abilities.canInstantlyBuild; if (flag || this.getDamage() > 40.0F) { @@ -79,7 +79,7 @@ this.ejectPassengers(); if (flag && !this.hasCustomName()) { this.die(); -@@ -227,6 +269,14 @@ +@@ -234,6 +276,14 @@ @Override public void tick() { @@ -94,16 +94,16 @@ if (this.getType() > 0) { this.c(this.getType() - 1); } -@@ -239,7 +289,7 @@ - this.ai(); +@@ -246,7 +296,7 @@ + this.am(); } - this.doPortalTick(); + // this.doPortalTick(); // CraftBukkit - handled in postTick if (this.world.isClientSide) { - if (this.aq > 0) { - double d0 = this.locX() + (this.ar - this.locX()) / (double) this.aq; -@@ -302,6 +352,18 @@ + if (this.aj > 0) { + double d0 = this.locX() + (this.ak - this.locX()) / (double) this.aj; +@@ -309,6 +359,18 @@ } this.setYawPitch(this.yaw, this.pitch); @@ -119,10 +119,10 @@ + this.world.getServer().getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleMoveEvent(vehicle, from, to)); + } + // CraftBukkit end - if (this.getMinecartType() == EntityMinecartAbstract.EnumMinecartType.RIDEABLE && b(this.getMot()) > 0.01D) { + if (this.getMinecartType() == EntityMinecartAbstract.EnumMinecartType.RIDEABLE && c(this.getMot()) > 0.01D) { List list = this.world.getEntities(this, this.getBoundingBox().grow(0.20000000298023224D, 0.0D, 0.20000000298023224D), IEntitySelector.a(this)); -@@ -310,8 +372,26 @@ +@@ -317,8 +379,26 @@ Entity entity = (Entity) list.get(l); if (!(entity instanceof EntityHuman) && !(entity instanceof EntityIronGolem) && !(entity instanceof EntityMinecartAbstract) && !this.isVehicle() && !entity.isPassenger()) { @@ -149,7 +149,7 @@ entity.collide(this); } } -@@ -323,6 +403,14 @@ +@@ -330,6 +410,14 @@ Entity entity1 = (Entity) iterator.next(); if (!this.w(entity1) && entity1.isCollidable() && entity1 instanceof EntityMinecartAbstract) { @@ -164,7 +164,7 @@ entity1.collide(this); } } -@@ -333,7 +421,7 @@ +@@ -346,7 +434,7 @@ } protected double getMaxSpeed() { @@ -173,7 +173,7 @@ } public void a(int i, int j, int k, boolean flag) {} -@@ -344,12 +432,16 @@ +@@ -357,12 +445,16 @@ this.setMot(MathHelper.a(vec3d.x, -d0, d0), vec3d.y, MathHelper.a(vec3d.z, -d0, d0)); if (this.onGround) { @@ -192,7 +192,7 @@ } } -@@ -536,7 +628,7 @@ +@@ -549,7 +641,7 @@ } protected void decelerate() { @@ -201,7 +201,7 @@ this.setMot(this.getMot().d(d0, 0.0D, d0)); } -@@ -619,6 +711,14 @@ +@@ -632,6 +724,14 @@ if (!this.world.isClientSide) { if (!entity.noclip && !this.noclip) { if (!this.w(entity)) { @@ -216,7 +216,7 @@ double d0 = entity.locX() - this.locX(); double d1 = entity.locZ() - this.locZ(); double d2 = d0 * d0 + d1 * d1; -@@ -754,4 +854,26 @@ +@@ -767,4 +867,26 @@ private EnumMinecartType() {} } diff --git a/nms-patches/EntityMinecartCommandBlock.patch b/nms-patches/EntityMinecartCommandBlock.patch index 650ed8041d..1ecc34a91e 100644 --- a/nms-patches/EntityMinecartCommandBlock.patch +++ b/nms-patches/EntityMinecartCommandBlock.patch @@ -2,7 +2,7 @@ +++ b/net/minecraft/server/EntityMinecartCommandBlock.java @@ -103,5 +103,12 @@ public CommandListenerWrapper getWrapper() { - return new CommandListenerWrapper(this, EntityMinecartCommandBlock.this.getPositionVector(), EntityMinecartCommandBlock.this.be(), this.d(), 2, this.getName().getString(), EntityMinecartCommandBlock.this.getScoreboardDisplayName(), this.d().getMinecraftServer(), EntityMinecartCommandBlock.this); + return new CommandListenerWrapper(this, EntityMinecartCommandBlock.this.getPositionVector(), EntityMinecartCommandBlock.this.bh(), this.d(), 2, this.getName().getString(), EntityMinecartCommandBlock.this.getScoreboardDisplayName(), this.d().getMinecraftServer(), EntityMinecartCommandBlock.this); } + + // CraftBukkit start diff --git a/nms-patches/EntityOcelot.patch b/nms-patches/EntityOcelot.patch index 9fa78330f4..959492a645 100644 --- a/nms-patches/EntityOcelot.patch +++ b/nms-patches/EntityOcelot.patch @@ -8,9 +8,9 @@ + return !this.isTrusting() /*&& this.ticksLived > 2400*/; // CraftBukkit } - public static AttributeProvider.Builder eL() { + public static AttributeProvider.Builder eK() { @@ -135,7 +135,8 @@ - if ((this.by == null || this.by.h()) && !this.isTrusting() && this.k(itemstack) && entityhuman.h((Entity) this) < 9.0D) { + if ((this.br == null || this.br.h()) && !this.isTrusting() && this.k(itemstack) && entityhuman.h((Entity) this) < 9.0D) { this.a(entityhuman, itemstack); if (!this.world.isClientSide) { - if (this.random.nextInt(3) == 0) { @@ -19,7 +19,7 @@ this.setTrusting(true); this.u(true); this.world.broadcastEntityEffect(this, (byte) 41); -@@ -244,9 +245,9 @@ +@@ -243,9 +244,9 @@ private final EntityOcelot i; public a(EntityOcelot entityocelot, Class oclass, float f, double d0, double d1) { diff --git a/nms-patches/EntityPanda.patch b/nms-patches/EntityPanda.patch index 146868d9ff..66dda224be 100644 --- a/nms-patches/EntityPanda.patch +++ b/nms-patches/EntityPanda.patch @@ -8,7 +8,7 @@ + public class EntityPanda extends EntityAnimal { - private static final DataWatcherObject bw = DataWatcher.a(EntityPanda.class, DataWatcherRegistry.b); + private static final DataWatcherObject bp = DataWatcher.a(EntityPanda.class, DataWatcherRegistry.b); @@ -445,7 +447,7 @@ @Override @@ -18,7 +18,7 @@ this.a(entityitem); ItemStack itemstack = entityitem.getItemStack(); -@@ -667,7 +669,7 @@ +@@ -666,7 +668,7 @@ @Override protected void a(EntityInsentient entityinsentient, EntityLiving entityliving) { if (entityinsentient instanceof EntityPanda && ((EntityPanda) entityinsentient).isAggressive()) { @@ -27,7 +27,7 @@ } } -@@ -771,9 +773,9 @@ +@@ -770,9 +772,9 @@ private final EntityPanda i; public c(EntityPanda entitypanda, Class oclass, float f, double d0, double d1) { diff --git a/nms-patches/EntityParrot.patch b/nms-patches/EntityParrot.patch index 2ad80ef3f9..cdd56d662c 100644 --- a/nms-patches/EntityParrot.patch +++ b/nms-patches/EntityParrot.patch @@ -2,10 +2,10 @@ +++ b/net/minecraft/server/EntityParrot.java @@ -20,7 +20,7 @@ }; - private static final Item bD = Items.COOKIE; - private static final Set bE = Sets.newHashSet(new Item[]{Items.WHEAT_SEEDS, Items.MELON_SEEDS, Items.PUMPKIN_SEEDS, Items.BEETROOT_SEEDS}); -- private static final Map, SoundEffect> bF = (Map) SystemUtils.a((Object) Maps.newHashMap(), (hashmap) -> { -+ private static final Map, SoundEffect> bF = (Map) SystemUtils.a(Maps.newHashMap(), (hashmap) -> { // CraftBukkit - decompile error + private static final Item bw = Items.COOKIE; + private static final Set bx = Sets.newHashSet(new Item[]{Items.WHEAT_SEEDS, Items.MELON_SEEDS, Items.PUMPKIN_SEEDS, Items.BEETROOT_SEEDS}); +- private static final Map, SoundEffect> by = (Map) SystemUtils.a((Object) Maps.newHashMap(), (hashmap) -> { ++ private static final Map, SoundEffect> by = (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); diff --git a/nms-patches/EntityPig.patch b/nms-patches/EntityPig.patch index d50e205f56..6081ea393e 100644 --- a/nms-patches/EntityPig.patch +++ b/nms-patches/EntityPig.patch @@ -10,19 +10,19 @@ + public class EntityPig extends EntityAnimal implements ISteerable, ISaddleable { - private static final DataWatcherObject bv = DataWatcher.a(EntityPig.class, DataWatcherRegistry.i); + private static final DataWatcherObject bo = DataWatcher.a(EntityPig.class, DataWatcherRegistry.i); @@ -204,7 +208,13 @@ } entitypigzombie.setPersistent(); -- this.world.addEntity(entitypigzombie); +- worldserver.addEntity(entitypigzombie); + // CraftBukkit start + if (CraftEventFactory.callPigZapEvent(this, entitylightning, entitypigzombie).isCancelled()) { + return; + } + // CraftBukkit - added a reason for spawning this creature -+ this.world.addEntity(entitypigzombie, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING); ++ worldserver.addEntity(entitypigzombie, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING); + // CraftBukkit end this.die(); } else { - super.onLightningStrike(entitylightning); + super.onLightningStrike(worldserver, entitylightning); diff --git a/nms-patches/EntityPigZombie.patch b/nms-patches/EntityPigZombie.patch index df80e5d6ba..3c466b47b6 100644 --- a/nms-patches/EntityPigZombie.patch +++ b/nms-patches/EntityPigZombie.patch @@ -6,7 +6,7 @@ this.goalSelector.a(7, new PathfinderGoalRandomStrollLand(this, 1.0D)); - this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[0])).a()); + this.targetSelector.a(1, new PathfinderGoalHurtByTarget(this).a(new Class[0])); // CraftBukkit - decompile error - this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget<>(this, EntityHuman.class, 10, true, false, this::b)); + this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget<>(this, EntityHuman.class, 10, true, false, this::a_)); this.targetSelector.a(3, new PathfinderGoalUniversalAngerReset<>(this, true)); } @@ -108,7 +108,7 @@ @@ -25,8 +25,8 @@ - public void setGoalTarget(@Nullable EntityLiving entityliving) { + public boolean setGoalTarget(@Nullable EntityLiving entityliving, org.bukkit.event.entity.EntityTargetEvent.TargetReason reason, boolean fireEvent) { // CraftBukkit - signature if (this.getGoalTarget() == null && entityliving != null) { - this.bv = EntityPigZombie.d.a(this.random); - this.bA = EntityPigZombie.bz.a(this.random); + this.bo = EntityPigZombie.d.a(this.random); + this.bt = EntityPigZombie.bs.a(this.random); @@ -127,12 +127,21 @@ this.e((EntityHuman) entityliving); } @@ -37,10 +37,10 @@ @Override public void anger() { -- this.setAnger(EntityPigZombie.bw.a(this.random)); +- this.setAnger(EntityPigZombie.bp.a(this.random)); + // CraftBukkit start + Entity entity = ((WorldServer) this.world).getEntity(getAngerTarget()); -+ org.bukkit.event.entity.PigZombieAngerEvent event = new org.bukkit.event.entity.PigZombieAngerEvent((org.bukkit.entity.PigZombie) this.getBukkitEntity(), (entity == null) ? null : entity.getBukkitEntity(), EntityPigZombie.bw.a(this.random)); ++ org.bukkit.event.entity.PigZombieAngerEvent event = new org.bukkit.event.entity.PigZombieAngerEvent((org.bukkit.entity.PigZombie) this.getBukkitEntity(), (entity == null) ? null : entity.getBukkitEntity(), EntityPigZombie.bp.a(this.random)); + this.world.getServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { + this.setAngerTarget(null); diff --git a/nms-patches/EntityPiglin.patch b/nms-patches/EntityPiglin.patch deleted file mode 100644 index 6d00c83fe5..0000000000 --- a/nms-patches/EntityPiglin.patch +++ /dev/null @@ -1,59 +0,0 @@ ---- a/net/minecraft/server/EntityPiglin.java -+++ b/net/minecraft/server/EntityPiglin.java -@@ -16,9 +16,9 @@ - private static final DataWatcherObject bx = DataWatcher.a(EntityPiglin.class, DataWatcherRegistry.i); - private static final UUID by = UUID.fromString("766bfa64-11f3-11ea-8d71-362b9e155667"); - private static final AttributeModifier bz = new AttributeModifier(EntityPiglin.by, "Baby speed boost", 0.20000000298023224D, AttributeModifier.Operation.MULTIPLY_BASE); -- private int bA = 0; -+ public int bA = 0; // PAIL private -> public, rename conversionTicks - private final InventorySubcontainer bB = new InventorySubcontainer(8); -- private boolean bC = false; -+ public boolean bC = false; // PAIL private -> public, rename cannotHunt - protected static final ImmutableList>> b = ImmutableList.of(SensorType.c, SensorType.d, SensorType.b, SensorType.g, SensorType.e, SensorType.l); - protected static final ImmutableList> c = ImmutableList.of(MemoryModuleType.LOOK_TARGET, MemoryModuleType.INTERACTABLE_DOORS, MemoryModuleType.OPENED_DOORS, MemoryModuleType.MOBS, MemoryModuleType.VISIBLE_MOBS, MemoryModuleType.NEAREST_VISIBLE_PLAYER, MemoryModuleType.NEAREST_VISIBLE_TARGETABLE_PLAYER, MemoryModuleType.NEAREST_VISIBLE_ADULT_PIGLINS, MemoryModuleType.NEAREST_ADULT_PIGLINS, MemoryModuleType.NEAREST_VISIBLE_WANTED_ITEM, MemoryModuleType.HURT_BY, MemoryModuleType.HURT_BY_ENTITY, new MemoryModuleType[]{MemoryModuleType.WALK_TARGET, MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE, MemoryModuleType.ATTACK_TARGET, MemoryModuleType.ATTACK_COOLING_DOWN, MemoryModuleType.INTERACTION_TARGET, MemoryModuleType.PATH, MemoryModuleType.ANGRY_AT, MemoryModuleType.UNIVERSAL_ANGER, MemoryModuleType.AVOID_TARGET, MemoryModuleType.ADMIRING_ITEM, MemoryModuleType.ADMIRING_DISABLED, MemoryModuleType.CELEBRATE_LOCATION, MemoryModuleType.DANCING, MemoryModuleType.HUNTED_RECENTLY, MemoryModuleType.NEAREST_VISIBLE_BABY_HOGLIN, MemoryModuleType.NEAREST_VISIBLE_BABY_PIGLIN, MemoryModuleType.NEAREST_VISIBLE_NEMSIS, MemoryModuleType.NEAREST_VISIBLE_ZOMBIFIED, MemoryModuleType.RIDE_TARGET, MemoryModuleType.VISIBLE_ADULT_PIGLIN_COUNT, MemoryModuleType.VISIBLE_ADULT_HOGLIN_COUNT, MemoryModuleType.NEAREST_VISIBLE_HUNTABLE_HOGLIN, MemoryModuleType.NEAREST_TARGETABLE_PLAYER_NOT_WEARING_GOLD, MemoryModuleType.NEAREST_PLAYER_HOLDING_WANTED_ITEM, MemoryModuleType.ATE_RECENTLY, MemoryModuleType.NEAREST_REPELLENT}); - -@@ -157,7 +157,7 @@ - - @Override - public BehaviorController getBehaviorController() { -- return super.getBehaviorController(); -+ return (BehaviorController) super.getBehaviorController(); // CraftBukkit - decompile error - } - - @Override -@@ -217,7 +217,7 @@ - this.getDataWatcher().set(EntityPiglin.bv, flag); - } - -- private boolean eT() { -+ public boolean eT() { // PAIL private -> public, rename isImmuneToZombification - return (Boolean) this.getDataWatcher().get(EntityPiglin.bv); - } - -@@ -236,7 +236,7 @@ - @Override - protected void mobTick() { - this.world.getMethodProfiler().enter("piglinBrain"); -- this.getBehaviorController().a((WorldServer) this.world, (EntityLiving) this); -+ this.getBehaviorController().a((WorldServer) this.world, this); // CraftBukkit - decompile error - this.world.getMethodProfiler().exit(); - PiglinAI.b(this); - if (this.eO()) { -@@ -268,7 +268,7 @@ - @Nullable - @Override - public EntityLiving getGoalTarget() { -- return (EntityLiving) this.bn.getMemory(MemoryModuleType.ATTACK_TARGET).orElse((Object) null); -+ return (EntityLiving) this.bn.getMemory(MemoryModuleType.ATTACK_TARGET).orElse(null); // CraftBukkit - decompile error - } - - private ItemStack eU() { -@@ -396,7 +396,7 @@ - - @Override - protected SoundEffect getSoundAmbient() { -- return this.world.isClientSide ? null : (SoundEffect) PiglinAI.d(this).orElse((Object) null); -+ return this.world.isClientSide ? null : (SoundEffect) PiglinAI.d(this).orElse(null); // CraftBukkit - decompile error - } - - @Override diff --git a/nms-patches/EntityPlayer.patch b/nms-patches/EntityPlayer.patch index a3f17636a8..0ad2db146b 100644 --- a/nms-patches/EntityPlayer.patch +++ b/nms-patches/EntityPlayer.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/EntityPlayer.java +++ b/net/minecraft/server/EntityPlayer.java -@@ -14,6 +14,27 @@ +@@ -15,6 +15,27 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -28,7 +28,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting { private static final Logger LOGGER = LogManager.getLogger(); -@@ -56,6 +77,20 @@ +@@ -58,6 +79,20 @@ public int ping; public boolean viewingCredits; @@ -47,19 +47,19 @@ + // CraftBukkit end + public EntityPlayer(MinecraftServer minecraftserver, WorldServer worldserver, GameProfile gameprofile, PlayerInteractManager playerinteractmanager) { - super(worldserver, worldserver.getSpawn(), gameprofile); + super(worldserver, worldserver.getSpawn(), worldserver.v(), gameprofile); this.spawnDimension = World.OVERWORLD; -@@ -66,12 +101,56 @@ +@@ -68,12 +103,56 @@ this.advancementDataPlayer = minecraftserver.getPlayerList().f(this); this.G = 1.0F; - this.b(worldserver); + this.c(worldserver); + + // CraftBukkit start + this.displayName = this.getName(); + this.canPickUpLoot = true; + this.maxHealthCache = this.getMaxHealth(); -+ } -+ + } + + // 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) { @@ -96,10 +96,10 @@ + } + + return blockposition; - } ++ } + // CraftBukkit end - - private void b(WorldServer worldserver) { ++ + private void c(WorldServer worldserver) { BlockPosition blockposition = worldserver.getSpawn(); - if (worldserver.getDimensionManager().hasSkyLight() && worldserver.getMinecraftServer().getSaveData().getGameType() != EnumGamemode.ADVENTURE) { @@ -107,7 +107,7 @@ int i = Math.max(0, this.server.a(worldserver)); int j = MathHelper.floor(worldserver.getWorldBorder().b((double) blockposition.getX(), (double) blockposition.getZ())); -@@ -137,11 +216,20 @@ +@@ -139,11 +218,20 @@ if (nbttagcompound.hasKeyOfType("recipeBook", 10)) { this.recipeBook.a(nbttagcompound.getCompound("recipeBook"), this.server.getCraftingManager()); } @@ -128,7 +128,7 @@ if (nbttagcompound.hasKeyOfType("SpawnX", 99) && nbttagcompound.hasKeyOfType("SpawnY", 99) && nbttagcompound.hasKeyOfType("SpawnZ", 99)) { this.spawn = new BlockPosition(nbttagcompound.getInt("SpawnX"), nbttagcompound.getInt("SpawnY"), nbttagcompound.getInt("SpawnZ")); this.spawnForced = nbttagcompound.getBoolean("SpawnForced"); -@@ -174,7 +262,20 @@ +@@ -177,7 +265,20 @@ Entity entity = this.getRootVehicle(); Entity entity1 = this.getVehicle(); @@ -150,22 +150,22 @@ NBTTagCompound nbttagcompound2 = new NBTTagCompound(); NBTTagCompound nbttagcompound3 = new NBTTagCompound(); -@@ -191,7 +292,7 @@ - nbttagcompound.setInt("SpawnY", this.spawn.getY()); +@@ -195,7 +296,7 @@ nbttagcompound.setInt("SpawnZ", this.spawn.getZ()); nbttagcompound.setBoolean("SpawnForced", this.spawnForced); + nbttagcompound.setFloat("SpawnAngle", this.spawnAngle); - DataResult dataresult = MinecraftKey.a.encodeStart(DynamicOpsNBT.a, this.spawnDimension.a()); + DataResult dataresult = MinecraftKey.a.encodeStart(DynamicOpsNBT.a, this.spawnDimension.a()); // CraftBukkit - decompile error Logger logger = EntityPlayer.LOGGER; logger.getClass(); -@@ -199,8 +300,32 @@ +@@ -203,9 +304,33 @@ nbttagcompound.set("SpawnDimension", nbtbase); }); } + this.getBukkitEntity().setExtraData(nbttagcompound); // CraftBukkit -+ -+ } + + } + // CraftBukkit start - World fallback code, either respawn location or global spawn + public void spawnIn(World world) { @@ -176,7 +176,7 @@ + if (this.spawnDimension != null) { + world = this.getWorldServer().getServer().getHandle().getServer().getWorldServer(this.spawnDimension); + if (world != null && this.getSpawn() != null) { -+ position = EntityHuman.getBed((WorldServer) world, this.getSpawn(), false, false).orElse(null); ++ position = EntityHuman.getBed((WorldServer) world, this.getSpawn(), this.getSpawnAngle(), false, false).orElse(null); + } + } + if (world == null || position == null) { @@ -187,12 +187,13 @@ + this.setPosition(position.getX(), position.getY(), position.getZ()); + } + this.playerInteractManager.a((WorldServer) world); - } ++ } + // CraftBukkit end - ++ public void a(int i) { float f = (float) this.getExpToLevel(); -@@ -255,6 +380,11 @@ + float f1 = (f - 1.0F) / f; +@@ -259,6 +384,11 @@ @Override public void tick() { @@ -204,7 +205,7 @@ this.playerInteractManager.a(); --this.invulnerableTicks; if (this.noDamageTicks > 0) { -@@ -322,7 +452,7 @@ +@@ -326,7 +456,7 @@ } if (this.getHealth() != this.lastHealthSent || this.lastFoodSent != this.foodData.getFoodLevel() || this.foodData.getSaturationLevel() == 0.0F != this.lastSentSaturationZero) { @@ -213,7 +214,7 @@ this.lastHealthSent = this.getHealth(); this.lastFoodSent = this.foodData.getFoodLevel(); this.lastSentSaturationZero = this.foodData.getSaturationLevel() == 0.0F; -@@ -353,6 +483,12 @@ +@@ -357,6 +487,12 @@ this.a(IScoreboardCriteria.XP, MathHelper.f((float) this.lastExpTotalScored)); } @@ -226,7 +227,7 @@ if (this.expLevel != this.lastExpLevelScored) { this.lastExpLevelScored = this.expLevel; this.a(IScoreboardCriteria.LEVEL, MathHelper.f((float) this.lastExpLevelScored)); -@@ -367,6 +503,16 @@ +@@ -371,6 +507,16 @@ CriterionTriggers.p.a(this); } @@ -243,7 +244,7 @@ } catch (Throwable throwable) { CrashReport crashreport = CrashReport.a(throwable, "Ticking player"); CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Player being ticked"); -@@ -377,7 +523,8 @@ +@@ -381,7 +527,8 @@ } private void a(IScoreboardCriteria iscoreboardcriteria, int i) { @@ -253,7 +254,7 @@ scoreboardscore.setScore(i); }); } -@@ -385,9 +532,46 @@ +@@ -389,9 +536,46 @@ @Override public void die(DamageSource damagesource) { boolean flag = this.world.getGameRules().getBoolean(GameRules.SHOW_DEATH_MESSAGES); @@ -302,9 +303,9 @@ this.playerConnection.a((Packet) (new PacketPlayOutCombatEvent(this.getCombatTracker(), PacketPlayOutCombatEvent.EnumCombatEventType.ENTITY_DIED, ichatbasecomponent)), (future) -> { if (!future.isSuccess()) { -@@ -421,12 +605,18 @@ +@@ -425,12 +609,18 @@ if (this.world.getGameRules().getBoolean(GameRules.FORGIVE_DEAD_PLAYERS)) { - this.eW(); + this.eV(); } - - if (!this.isSpectator()) { @@ -325,7 +326,7 @@ EntityLiving entityliving = this.getKillingEntity(); if (entityliving != null) { -@@ -462,10 +652,12 @@ +@@ -466,10 +656,12 @@ String s = this.getName(); String s1 = entity.getName(); @@ -340,7 +341,7 @@ } else { this.a(StatisticList.MOB_KILLS); } -@@ -483,7 +675,8 @@ +@@ -487,7 +679,8 @@ int i = scoreboardteam.getColor().b(); if (i >= 0 && i < aiscoreboardcriteria.length) { @@ -350,7 +351,7 @@ } } -@@ -527,17 +720,27 @@ +@@ -531,7 +724,8 @@ } private boolean canPvP() { @@ -360,15 +361,30 @@ } @Nullable +@@ -539,10 +733,10 @@ + protected ShapeDetectorShape a(WorldServer worldserver) { + ShapeDetectorShape shapedetectorshape = super.a(worldserver); + +- if (shapedetectorshape != null && this.world.getDimensionKey() == World.OVERWORLD && worldserver.getDimensionKey() == World.THE_END) { ++ if (shapedetectorshape != null && this.world.getTypeKey() == DimensionManager.OVERWORLD && worldserver != null && worldserver.getTypeKey() == DimensionManager.THE_END) { // CraftBukkit + Vec3D vec3d = shapedetectorshape.position.add(0.0D, -1.0D, 0.0D); + +- return new ShapeDetectorShape(vec3d, Vec3D.a, 90.0F, 0.0F); ++ return new ShapeDetectorShape(vec3d, Vec3D.a, 90.0F, 0.0F, worldserver); // CraftBukkit + } else { + return shapedetectorshape; + } +@@ -551,11 +745,20 @@ + @Nullable @Override - public Entity a(WorldServer worldserver) { + public Entity b(WorldServer worldserver) { - this.worldChangeInvuln = true; + // CraftBukkit start -+ return a(worldserver, TeleportCause.UNKNOWN); ++ return b(worldserver, TeleportCause.UNKNOWN); + } + + @Nullable -+ public Entity a(WorldServer worldserver, PlayerTeleportEvent.TeleportCause cause) { ++ public Entity b(WorldServer worldserver, PlayerTeleportEvent.TeleportCause cause) { + // CraftBukkit end + if (this.isSleeping()) return this; // CraftBukkit - SPIGOT-3154 + // this.worldChangeInvuln = true; // CraftBukkit - Moved down and into PlayerList#changeDimension @@ -382,7 +398,7 @@ this.decouple(); this.getWorldServer().removePlayer(this); if (!this.viewingCredits) { -@@ -548,6 +751,8 @@ +@@ -566,6 +769,8 @@ return this; } else { @@ -390,119 +406,43 @@ + /* WorldData worlddata = worldserver.getWorldData(); - this.playerConnection.sendPacket(new PacketPlayOutRespawn(worldserver.getTypeKey(), worldserver.getDimensionKey(), BiomeManager.a(worldserver.getSeed()), this.playerInteractManager.getGameMode(), this.playerInteractManager.c(), worldserver.isDebugWorld(), worldserver.isFlatWorld(), true)); -@@ -557,6 +762,8 @@ + this.playerConnection.sendPacket(new PacketPlayOutRespawn(worldserver.getDimensionManager(), worldserver.getDimensionKey(), BiomeManager.a(worldserver.getSeed()), this.playerInteractManager.getGameMode(), this.playerInteractManager.c(), worldserver.isDebugWorld(), worldserver.isFlatWorld(), true)); +@@ -575,22 +780,65 @@ playerlist.d(this); worldserver1.removePlayer(this); this.dead = false; + */ + // CraftBukkit end - double d0 = this.locX(); - double d1 = this.locY(); - double d2 = this.locZ(); -@@ -567,7 +774,8 @@ - worldserver1.getMethodProfiler().enter("moving"); - double d3; + ShapeDetectorShape shapedetectorshape = this.a(worldserver); -- if (worldserver.getDimensionKey() == World.THE_END) { -+ if (worldserver == null) { } else // CraftBukkit - empty to fall through to null to event -+ if (worldserver.getTypeKey() == DimensionManager.THE_END) { // CraftBukkit - BlockPosition blockposition = WorldServer.a; - - d0 = (double) blockposition.getX(); -@@ -576,7 +784,7 @@ - f1 = 90.0F; - f = 0.0F; - } else { + if (shapedetectorshape != null) { + worldserver1.getMethodProfiler().enter("moving"); - if (resourcekey == World.OVERWORLD && worldserver.getDimensionKey() == World.THE_NETHER) { ++ worldserver = shapedetectorshape.world; // CraftBukkit ++ if (worldserver == null) { } else // CraftBukkit - empty to fall through to null to event + if (resourcekey == DimensionManager.OVERWORLD && worldserver.getTypeKey() == DimensionManager.THE_NETHER) { // CraftBukkit - this.cp = this.getPositionVector(); + this.ci = this.getPositionVector(); +- } else if (worldserver.getDimensionKey() == World.THE_END) { ++ } else if (worldserver.getTypeKey() == DimensionManager.THE_END) { // CraftBukkit + this.a(worldserver, new BlockPosition(shapedetectorshape.position)); } - -@@ -593,7 +801,26 @@ - } - } - -- this.setPositionRotation(d0, d1, d2, f1, f); -+ // CraftBukkit start ++ // CraftBukkit start ++ } + Location enter = this.getBukkitEntity().getLocation(); -+ Location exit = (worldserver == null) ? null : new Location(worldserver.getWorld(), d0, d1, d2, f1, f); ++ Location exit = (worldserver == null) ? null : new Location(worldserver.getWorld(), shapedetectorshape.position.x, shapedetectorshape.position.y, shapedetectorshape.position.z, shapedetectorshape.yaw, shapedetectorshape.pitch); + PlayerPortalEvent event = new PlayerPortalEvent(this.getBukkitEntity(), enter, exit, cause, 128, true, resourcekey == DimensionManager.THE_END ? 0 : 16); + Bukkit.getServer().getPluginManager().callEvent(event); + if (event.isCancelled() || event.getTo() == null) { + return null; + } -+ + +- worldserver1.getMethodProfiler().exit(); +- worldserver1.getMethodProfiler().enter("placing"); + exit = event.getTo(); + if (exit == null) { + return null; + } -+ worldserver = ((CraftWorld) exit.getWorld()).getHandle(); -+ d0 = exit.getX(); -+ d1 = exit.getY(); -+ d2 = exit.getZ(); -+ // CraftBukkit end + -+ // this.setPositionRotation(d0, d1, d2, f1, f); // CraftBukkit - PlayerTeleportEvent handles position changes - worldserver1.getMethodProfiler().exit(); - worldserver1.getMethodProfiler().enter("placing"); - double d4 = Math.min(-2.9999872E7D, worldserver.getWorldBorder().e() + 16.0D); -@@ -604,25 +831,74 @@ - - d0 = MathHelper.a(d0, d4, d5); - d2 = MathHelper.a(d2, d3, d6); -- this.setPositionRotation(d0, d1, d2, f1, f); -- if (worldserver.getDimensionKey() == World.THE_END) { -- int i = MathHelper.floor(this.locX()); -- int j = MathHelper.floor(this.locY()) - 1; -- int k = MathHelper.floor(this.locZ()); -- -- WorldServer.a(worldserver); -- this.setPositionRotation((double) i, (double) j, (double) k, f1, 0.0F); -- this.setMot(Vec3D.a); -- } else if (!worldserver.getTravelAgent().findAndTeleport(this, f2)) { -- worldserver.getTravelAgent().createPortal(this); -- worldserver.getTravelAgent().findAndTeleport(this, f2); -+ // this.setPositionRotation(d0, d1, d2, f1, f); // CraftBukkit - PlayerTeleportEvent handles position changes -+ // CraftBukkit start - PlayerPortalEvent implementation -+ Vec3D exitVelocity = Vec3D.a; -+ BlockPosition exitPosition = new BlockPosition(d0, d1, d2); -+ if (worldserver.getTypeKey() == DimensionManager.THE_END) { // CraftBukkit -+ int i = exitPosition.getX(); -+ int j = exitPosition.getY() - 1; -+ int k = exitPosition.getZ(); -+ if (event.getCanCreatePortal()) { -+ WorldServer.a(worldserver, this); -+ } -+ // handled below for PlayerTeleportEvent -+ // this.setPositionRotation((double) i, (double) j, (double) k, f1, 0.0F); -+ exit.setX(i); -+ exit.setY(j); -+ exit.setZ(k); -+ // this.setMot(Vec3D.a); -+ exitVelocity = Vec3D.a; -+ } else if (worldserver.getTypeKey() == DimensionManager.THE_NETHER || worldserver1.getTypeKey() == DimensionManager.THE_NETHER) { -+ ShapeDetector.Shape portalShape = worldserver.getTravelAgent().findAndTeleport(this, exitPosition, f2, event.getSearchRadius(), true); -+ if (portalShape == null && event.getCanCreatePortal()) { -+ if (worldserver.getTravelAgent().createPortal(this, exitPosition, event.getCreationRadius())) { // Only check for new portal if creation succeeded -+ portalShape = worldserver.getTravelAgent().findAndTeleport(this, exitPosition, f2, event.getSearchRadius(), true); -+ } -+ } -+ // Check if portal was found -+ if (portalShape == null) { -+ return null; -+ } -+ // Teleport handling - logic from PortalTravelAgent#findAndTeleport -+ exitVelocity = portalShape.velocity; -+ exit.setX(portalShape.position.getX()); -+ exit.setY(portalShape.position.getY()); -+ exit.setZ(portalShape.position.getZ()); -+ exit.setYaw(f2 + (float) portalShape.yaw); -+ // CraftBukkit end - } - - worldserver1.getMethodProfiler().exit(); -+ // CraftBukkit start - PlayerTeleportEvent + PlayerTeleportEvent tpEvent = new PlayerTeleportEvent(this.getBukkitEntity(), enter, exit, cause); + Bukkit.getServer().getPluginManager().callEvent(tpEvent); + if (tpEvent.isCancelled() || tpEvent.getTo() == null) { @@ -514,40 +454,55 @@ + return null; + } + worldserver = ((CraftWorld) exit.getWorld()).getHandle(); -+ this.worldChangeInvuln = true; // CraftBukkit - Set teleport invulnerability only if player changing worlds -+ -+ this.playerConnection.sendPacket(new PacketPlayOutRespawn(worldserver.getTypeKey(), worldserver.getDimensionKey(), BiomeManager.a(worldserver.getSeed()), this.playerInteractManager.getGameMode(), this.playerInteractManager.c(), worldserver.isDebugWorld(), worldserver.isFlatWorld(), true)); -+ this.playerConnection.sendPacket(new PacketPlayOutServerDifficulty(this.world.getDifficulty(), this.world.getWorldData().isDifficultyLocked())); -+ PlayerList playerlist = this.server.getPlayerList(); -+ -+ playerlist.d(this); -+ worldserver1.removePlayer(this); -+ this.dead = false; -+ -+ this.setMot(exitVelocity); + // CraftBukkit end - this.spawnIn(worldserver); - worldserver.addPlayerPortal(this); - this.triggerDimensionAdvancements(worldserver1); -- this.playerConnection.a(this.locX(), this.locY(), this.locZ(), f1, f); -+ this.playerConnection.teleport(exit); // CraftBukkit - use internal teleport without event -+ this.playerConnection.syncPosition(); // CraftBukkit - sync position after changing it (from PortalTravelAgent#findAndteleport) - this.playerInteractManager.a(worldserver); - this.playerConnection.sendPacket(new PacketPlayOutAbilities(this.abilities)); - playerlist.a(this, worldserver); -@@ -639,6 +915,11 @@ - this.lastSentExp = -1; - this.lastHealthSent = -1.0F; - this.lastFoodSent = -1; + -+ // CraftBukkit start -+ PlayerChangedWorldEvent changeEvent = new PlayerChangedWorldEvent(this.getBukkitEntity(), worldserver1.getWorld()); -+ this.world.getServer().getPluginManager().callEvent(changeEvent); -+ // CraftBukkit end ++ worldserver1.getMethodProfiler().exit(); ++ worldserver1.getMethodProfiler().enter("placing"); ++ if (true) { // CraftBukkit ++ this.worldChangeInvuln = true; // CraftBukkit - Set teleport invulnerability only if player changing worlds ++ ++ this.playerConnection.sendPacket(new PacketPlayOutRespawn(worldserver.getDimensionManager(), worldserver.getDimensionKey(), BiomeManager.a(worldserver.getSeed()), this.playerInteractManager.getGameMode(), this.playerInteractManager.c(), worldserver.isDebugWorld(), worldserver.isFlatWorld(), true)); ++ this.playerConnection.sendPacket(new PacketPlayOutServerDifficulty(this.world.getDifficulty(), this.world.getWorldData().isDifficultyLocked())); ++ PlayerList playerlist = this.server.getPlayerList(); ++ ++ playerlist.d(this); ++ worldserver1.removePlayer(this); ++ this.dead = false; ++ ++ // CraftBukkit end + this.spawnIn(worldserver); + worldserver.addPlayerPortal(this); +- this.setYawPitch(shapedetectorshape.yaw, shapedetectorshape.pitch); +- this.teleportAndSync(shapedetectorshape.position.x, shapedetectorshape.position.y, shapedetectorshape.position.z); ++ this.playerConnection.teleport(exit); // CraftBukkit - use internal teleport without event ++ this.playerConnection.syncPosition(); // CraftBukkit - sync position after changing it (from PortalTravelAgent#findAndteleport) + worldserver1.getMethodProfiler().exit(); + this.triggerDimensionAdvancements(worldserver1); + this.playerInteractManager.a(worldserver); +@@ -609,6 +857,11 @@ + this.lastSentExp = -1; + this.lastHealthSent = -1.0F; + this.lastFoodSent = -1; ++ ++ // CraftBukkit start ++ PlayerChangedWorldEvent changeEvent = new PlayerChangedWorldEvent(this.getBukkitEntity(), worldserver1.getWorld()); ++ this.world.getServer().getPluginManager().callEvent(changeEvent); ++ // CraftBukkit end + } + return this; - } +@@ -631,8 +884,8 @@ } -@@ -680,10 +961,8 @@ + + @Override +- protected Optional a(WorldServer worldserver, BlockPosition blockposition, boolean flag) { +- Optional optional = super.a(worldserver, blockposition, flag); ++ protected Optional a(WorldServer worldserver, BlockPosition blockposition, boolean flag, int radius) { // CraftBukkit ++ Optional optional = super.a(worldserver, blockposition, flag, radius); // CraftBukkit + + if (optional.isPresent()) { + return optional; +@@ -685,10 +938,8 @@ this.activeContainer.c(); } @@ -560,7 +515,7 @@ if (!this.isSleeping() && this.isAlive()) { if (!this.world.getDimensionManager().isNatural()) { return Either.left(EntityHuman.EnumBedResult.NOT_POSSIBLE_HERE); -@@ -709,7 +988,36 @@ +@@ -714,7 +965,36 @@ } } @@ -598,7 +553,7 @@ this.a(StatisticList.SLEEP_IN_BED); CriterionTriggers.q.a(this); }); -@@ -718,9 +1026,8 @@ +@@ -723,9 +1003,8 @@ return either; } } @@ -609,7 +564,7 @@ } @Override -@@ -747,6 +1054,7 @@ +@@ -752,6 +1031,7 @@ @Override public void wakeup(boolean flag, boolean flag1) { @@ -617,7 +572,7 @@ if (this.isSleeping()) { this.getWorldServer().getChunkProvider().broadcastIncludingSelf(this, new PacketPlayOutAnimation(this, 2)); } -@@ -818,8 +1126,9 @@ +@@ -823,8 +1103,9 @@ this.playerConnection.sendPacket(new PacketPlayOutOpenSignEditor(tileentitysign.getPosition())); } @@ -628,7 +583,7 @@ } @Override -@@ -834,6 +1143,24 @@ +@@ -839,6 +1120,24 @@ this.nextContainerCounter(); Container container = itileinventory.createMenu(this.containerCounter, this.inventory, this); @@ -653,7 +608,7 @@ if (container == null) { if (this.isSpectator()) { this.a((IChatBaseComponent) (new ChatMessage("container.spectatorCantOpen")).a(EnumChatFormat.RED), true); -@@ -841,9 +1168,11 @@ +@@ -846,9 +1145,11 @@ return OptionalInt.empty(); } else { @@ -667,7 +622,7 @@ return OptionalInt.of(this.containerCounter); } } -@@ -856,13 +1185,24 @@ +@@ -861,13 +1162,24 @@ @Override public void openHorseInventory(EntityHorseAbstract entityhorseabstract, IInventory iinventory) { @@ -694,7 +649,7 @@ this.activeContainer.addSlotListener(this); } -@@ -907,6 +1247,11 @@ +@@ -912,6 +1224,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())); @@ -706,7 +661,7 @@ } @Override -@@ -916,6 +1261,7 @@ +@@ -921,6 +1238,7 @@ @Override public void closeInventory() { @@ -714,7 +669,7 @@ this.playerConnection.sendPacket(new PacketPlayOutCloseWindow(this.activeContainer.windowId)); this.o(); } -@@ -950,7 +1296,7 @@ +@@ -955,7 +1273,7 @@ @Override public void a(Statistic statistic, int i) { this.serverStatisticManager.b(this, statistic, i); @@ -723,7 +678,7 @@ scoreboardscore.addScore(i); }); } -@@ -958,7 +1304,7 @@ +@@ -963,7 +1281,7 @@ @Override public void a(Statistic statistic) { this.serverStatisticManager.setStatistic(this, statistic, 0); @@ -732,7 +687,7 @@ } @Override -@@ -1007,7 +1353,16 @@ +@@ -1012,7 +1330,16 @@ public void triggerHealthUpdate() { this.lastHealthSent = -1.0E8F; @@ -749,23 +704,22 @@ @Override public void a(IChatBaseComponent ichatbasecomponent, boolean flag) { -@@ -1062,12 +1417,14 @@ +@@ -1065,12 +1392,13 @@ this.lastSentExp = -1; this.lastHealthSent = -1.0F; this.lastFoodSent = -1; - this.recipeBook.a((RecipeBook) entityplayer.recipeBook); + // this.recipeBook.a((RecipeBook) entityplayer.recipeBook); // CraftBukkit this.removeQueue.addAll(entityplayer.removeQueue); - this.ck = entityplayer.ck; - this.cp = entityplayer.cp; + this.cd = entityplayer.cd; + this.ci = entityplayer.ci; this.setShoulderEntityLeft(entityplayer.getShoulderEntityLeft()); this.setShoulderEntityRight(entityplayer.getShoulderEntityRight()); + -+ this.inLava = false; // SPIGOT-4767 } @Override -@@ -1135,6 +1492,18 @@ +@@ -1138,6 +1466,18 @@ @Override public void a(EnumGamemode enumgamemode) { @@ -784,7 +738,7 @@ this.playerInteractManager.setGameMode(enumgamemode); this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.d, (float) enumgamemode.getId())); if (enumgamemode == EnumGamemode.SPECTATOR) { -@@ -1184,7 +1553,20 @@ +@@ -1187,7 +1527,20 @@ return s; } @@ -802,10 +756,10 @@ + this.locale = packetplayinsettings.locale; + this.clientViewDistance = packetplayinsettings.viewDistance; + // CraftBukkit end - this.cf = packetplayinsettings.d(); - this.cg = packetplayinsettings.e(); - this.getDataWatcher().set(EntityPlayer.bp, (byte) packetplayinsettings.f()); -@@ -1220,13 +1602,13 @@ + this.bY = packetplayinsettings.d(); + this.bZ = packetplayinsettings.e(); + this.getDataWatcher().set(EntityPlayer.bi, (byte) packetplayinsettings.f()); +@@ -1223,13 +1576,13 @@ if (entity instanceof EntityHuman) { this.playerConnection.sendPacket(new PacketPlayOutEntityDestroy(new int[]{entity.getId()})); } else { @@ -821,7 +775,7 @@ } @Override -@@ -1250,7 +1632,7 @@ +@@ -1253,7 +1606,7 @@ this.spectatedEntity = (Entity) (entity == null ? this : entity); if (entity1 != this.spectatedEntity) { this.playerConnection.sendPacket(new PacketPlayOutCamera(this.spectatedEntity)); @@ -830,7 +784,7 @@ } } -@@ -1279,7 +1661,7 @@ +@@ -1282,7 +1635,7 @@ @Nullable public IChatBaseComponent getPlayerListName() { @@ -839,7 +793,7 @@ } @Override -@@ -1300,9 +1682,16 @@ +@@ -1303,9 +1656,16 @@ return this.advancementDataPlayer; } @@ -856,7 +810,7 @@ if (worldserver == this.world) { this.playerConnection.a(d0, d1, d2, f, f1); } else { -@@ -1323,6 +1712,9 @@ +@@ -1326,6 +1686,9 @@ this.server.getPlayerList().a(this, worldserver); this.server.getPlayerList().updateClient(this); } @@ -866,7 +820,7 @@ } -@@ -1409,4 +1801,144 @@ +@@ -1418,4 +1781,144 @@ return entityitem; } } diff --git a/nms-patches/EntityRabbit.patch b/nms-patches/EntityRabbit.patch index 6b9f7daeed..d6441f14ed 100644 --- a/nms-patches/EntityRabbit.patch +++ b/nms-patches/EntityRabbit.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/server/EntityRabbit.java +++ b/net/minecraft/server/EntityRabbit.java -@@ -17,11 +17,17 @@ +@@ -17,8 +17,14 @@ super(entitytypes, world); - this.bp = new EntityRabbit.ControllerJumpRabbit(this); + this.bi = new EntityRabbit.ControllerJumpRabbit(this); this.moveController = new EntityRabbit.ControllerMoveRabbit(this); + this.initializePathFinderGoals(); // CraftBukkit - moved code + } @@ -14,11 +14,7 @@ + // CraftBukkit end @Override -- protected void initPathfinder() { -+ public void initPathfinder() { - this.goalSelector.a(1, new PathfinderGoalFloat(this)); - this.goalSelector.a(1, new EntityRabbit.PathfinderGoalRabbitPanic(this, 2.2D)); - this.goalSelector.a(2, new PathfinderGoalBreed(this, 0.8D)); + public void initPathfinder() { @@ -285,7 +291,7 @@ if (i == 99) { this.getAttributeInstance(GenericAttributes.ARMOR).setValue(8.0D); diff --git a/nms-patches/EntitySheep.patch b/nms-patches/EntitySheep.patch index 0f8e9d9b28..7d5a18fbd0 100644 --- a/nms-patches/EntitySheep.patch +++ b/nms-patches/EntitySheep.patch @@ -12,9 +12,9 @@ + public class EntitySheep extends EntityAnimal implements IShearable { - private static final DataWatcherObject bv = DataWatcher.a(EntitySheep.class, DataWatcherRegistry.a); -- private static final Map bw = (Map) SystemUtils.a((Object) Maps.newEnumMap(EnumColor.class), (enummap) -> { -+ private static final Map bw = (Map) SystemUtils.a(Maps.newEnumMap(EnumColor.class), (enummap) -> { // CraftBukkit - decompile error + private static final DataWatcherObject bo = DataWatcher.a(EntitySheep.class, DataWatcherRegistry.a); +- private static final Map bp = (Map) SystemUtils.a((Object) Maps.newEnumMap(EnumColor.class), (enummap) -> { ++ private static final Map bp = (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); @@ -35,7 +35,7 @@ for (int j = 0; j < i; ++j) { + this.forceDrops = true; // CraftBukkit - EntityItem entityitem = this.a((IMaterial) EntitySheep.bw.get(this.getColor()), 1); + EntityItem entityitem = this.a((IMaterial) EntitySheep.bp.get(this.getColor()), 1); + this.forceDrops = false; // CraftBukkit if (entityitem != null) { diff --git a/nms-patches/EntityShulker.patch b/nms-patches/EntityShulker.patch index 686fb898bd..403d932102 100644 --- a/nms-patches/EntityShulker.patch +++ b/nms-patches/EntityShulker.patch @@ -40,7 +40,7 @@ @@ -319,6 +333,7 @@ } - this.f((double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D); + this.g((double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D); + if (valid) ((WorldServer) world).chunkCheck(this); // CraftBukkit } } diff --git a/nms-patches/EntityShulkerBullet.patch b/nms-patches/EntityShulkerBullet.patch index 3c5a3ddc9b..725f59b3e2 100644 --- a/nms-patches/EntityShulkerBullet.patch +++ b/nms-patches/EntityShulkerBullet.patch @@ -22,7 +22,7 @@ @Override public SoundCategory getSoundCategory() { return SoundCategory.HOSTILE; -@@ -255,7 +268,7 @@ +@@ -256,7 +269,7 @@ if (flag) { this.a(entityliving, entity); if (entity instanceof EntityLiving) { diff --git a/nms-patches/EntitySlime.patch b/nms-patches/EntitySlime.patch index b155a96a5e..529d3d7713 100644 --- a/nms-patches/EntitySlime.patch +++ b/nms-patches/EntitySlime.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/server/EntitySlime.java +++ b/net/minecraft/server/EntitySlime.java -@@ -3,6 +3,13 @@ - import java.util.EnumSet; +@@ -5,6 +5,13 @@ + import java.util.Optional; import java.util.Random; import javax.annotation.Nullable; +// CraftBukkit start @@ -14,7 +14,7 @@ public class EntitySlime extends EntityInsentient implements IMonster { -@@ -147,7 +154,7 @@ +@@ -149,7 +156,7 @@ @Override public EntityTypes getEntityType() { @@ -23,7 +23,7 @@ } @Override -@@ -161,6 +168,19 @@ +@@ -163,6 +170,19 @@ int j = i / 2; int k = 2 + this.random.nextInt(3); @@ -43,7 +43,7 @@ for (int l = 0; l < k; ++l) { float f1 = ((float) (l % 2) - 0.5F) * f; float f2 = ((float) (l / 2) - 0.5F) * f; -@@ -175,8 +195,17 @@ +@@ -177,8 +197,17 @@ entityslime.setInvulnerable(this.isInvulnerable()); entityslime.setSize(j, true); entityslime.setPositionRotation(this.locX() + (double) f1, this.locY() + 0.5D, this.locZ() + (double) f2, this.random.nextFloat() * 360.0F, 0.0F); diff --git a/nms-patches/EntitySpider.patch b/nms-patches/EntitySpider.patch index 98d6eebb47..989b281080 100644 --- a/nms-patches/EntitySpider.patch +++ b/nms-patches/EntitySpider.patch @@ -1,15 +1,6 @@ --- a/net/minecraft/server/EntitySpider.java +++ b/net/minecraft/server/EntitySpider.java -@@ -123,7 +123,7 @@ - entityskeleton.setPositionRotation(this.locX(), this.locY(), this.locZ(), this.yaw, 0.0F); - entityskeleton.prepare(generatoraccess, difficultydamagescaler, enummobspawn, (GroupDataEntity) null, (NBTTagCompound) null); - entityskeleton.startRiding(this); -- generatoraccess.addEntity(entityskeleton); -+ generatoraccess.addEntity(entityskeleton, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.JOCKEY); // CraftBukkit - add SpawnReason - } - - if (object == null) { -@@ -137,7 +137,7 @@ +@@ -136,7 +136,7 @@ MobEffectList mobeffectlist = ((EntitySpider.GroupDataSpider) object).a; if (mobeffectlist != null) { diff --git a/nms-patches/EntityStrider.patch b/nms-patches/EntityStrider.patch deleted file mode 100644 index 6c35120609..0000000000 --- a/nms-patches/EntityStrider.patch +++ /dev/null @@ -1,97 +0,0 @@ ---- a/net/minecraft/server/EntityStrider.java -+++ b/net/minecraft/server/EntityStrider.java -@@ -14,7 +14,7 @@ - private static final DataWatcherObject bx = DataWatcher.a(EntityStrider.class, DataWatcherRegistry.b); - private static final DataWatcherObject by = DataWatcher.a(EntityStrider.class, DataWatcherRegistry.i); - private static final DataWatcherObject bz = DataWatcher.a(EntityStrider.class, DataWatcherRegistry.i); -- private final SaddleStorage bA; -+ public final SaddleStorage bA; // CraftBukkit PAIL private -> public, rename saddleStorage - private PathfinderGoalTempt bB; - private PathfinderGoalPanic bC; - -@@ -264,7 +264,12 @@ - IBlockData iblockdata1 = this.aJ(); - boolean flag = iblockdata.a((Tag) TagsBlock.STRIDER_WARM_BLOCKS) || iblockdata1.a((Tag) TagsBlock.STRIDER_WARM_BLOCKS) || this.b((Tag) TagsFluid.LAVA) > 0.0D; - -- this.t(!flag); -+ // CraftBukkit start -+ if (!flag ^ this.eL()) { -+ org.bukkit.craftbukkit.event.CraftEventFactory.callStriderTemperatureChangeEvent(this, !flag); -+ this.t(!flag); -+ } -+ // CraftBukkit end - super.tick(); - this.eV(); - this.checkBlockCollisions(); -@@ -390,36 +395,36 @@ - @Override - public GroupDataEntity prepare(GeneratorAccess generatoraccess, DifficultyDamageScaler difficultydamagescaler, EnumMobSpawn enummobspawn, @Nullable GroupDataEntity groupdataentity, @Nullable NBTTagCompound nbttagcompound) { - EntityZombie.GroupDataZombie entityzombie_groupdatazombie = null; -- EntityStrider$GroupData$Rider entitystrider$groupdata$rider; -+ EntityStrider.GroupData.Rider entitystrider_groupdata_rider; - -- if (groupdataentity instanceof EntityStrider.a) { -- entitystrider$groupdata$rider = ((EntityStrider.a) groupdataentity).a; -+ if (groupdataentity instanceof EntityStrider.GroupData) { -+ entitystrider_groupdata_rider = ((EntityStrider.GroupData) groupdataentity).a; - } else if (!this.isBaby()) { - if (this.random.nextInt(30) == 0) { -- entitystrider$groupdata$rider = EntityStrider$GroupData$Rider.PIGLIN_RIDER; -+ entitystrider_groupdata_rider = EntityStrider.GroupData.Rider.PIGLIN_RIDER; - entityzombie_groupdatazombie = new EntityZombie.GroupDataZombie(EntityZombie.a(this.random), false); - } else if (this.random.nextInt(10) == 0) { -- entitystrider$groupdata$rider = EntityStrider$GroupData$Rider.BABY_RIDER; -+ entitystrider_groupdata_rider = EntityStrider.GroupData.Rider.BABY_RIDER; - } else { -- entitystrider$groupdata$rider = EntityStrider$GroupData$Rider.NO_RIDER; -+ entitystrider_groupdata_rider = EntityStrider.GroupData.Rider.NO_RIDER; - } - -- groupdataentity = new EntityStrider.a(entitystrider$groupdata$rider); -- ((EntityAgeable.a) groupdataentity).a(entitystrider$groupdata$rider == EntityStrider$GroupData$Rider.NO_RIDER ? 0.5F : 0.0F); -+ groupdataentity = new EntityStrider.GroupData(entitystrider_groupdata_rider); -+ ((EntityAgeable.a) groupdataentity).a(entitystrider_groupdata_rider == EntityStrider.GroupData.Rider.NO_RIDER ? 0.5F : 0.0F); - } else { -- entitystrider$groupdata$rider = EntityStrider$GroupData$Rider.NO_RIDER; -+ entitystrider_groupdata_rider = EntityStrider.GroupData.Rider.NO_RIDER; - } - - Object object = null; - -- if (entitystrider$groupdata$rider == EntityStrider$GroupData$Rider.BABY_RIDER) { -+ if (entitystrider_groupdata_rider == EntityStrider.GroupData.Rider.BABY_RIDER) { - EntityStrider entitystrider = (EntityStrider) EntityTypes.STRIDER.a(generatoraccess.getMinecraftWorld()); - - if (entitystrider != null) { - object = entitystrider; - entitystrider.setAgeRaw(-24000); - } -- } else if (entitystrider$groupdata$rider == EntityStrider$GroupData$Rider.PIGLIN_RIDER) { -+ } else if (entitystrider_groupdata_rider == EntityStrider.GroupData.Rider.PIGLIN_RIDER) { - EntityPigZombie entitypigzombie = (EntityPigZombie) EntityTypes.ZOMBIFIED_PIGLIN.a(generatoraccess.getMinecraftWorld()); - - if (entitypigzombie != null) { -@@ -461,12 +466,19 @@ - } - } - -- public static class a extends EntityAgeable.a { -+ public static class GroupData extends EntityAgeable.a { -+ -+ public final EntityStrider.GroupData.Rider a; -+ -+ public GroupData(EntityStrider.GroupData.Rider entitystrider_groupdata_rider) { -+ this.a = entitystrider_groupdata_rider; -+ } -+ -+ public static enum Rider { - -- public final EntityStrider$GroupData$Rider a; -+ NO_RIDER, BABY_RIDER, PIGLIN_RIDER; - -- public a(EntityStrider$GroupData$Rider entitystrider$groupdata$rider) { -- this.a = entitystrider$groupdata$rider; -+ private Rider() {} - } - } - } diff --git a/nms-patches/EntityTNTPrimed.patch b/nms-patches/EntityTNTPrimed.patch index 120712f36b..47d45cff27 100644 --- a/nms-patches/EntityTNTPrimed.patch +++ b/nms-patches/EntityTNTPrimed.patch @@ -30,7 +30,7 @@ + this.die(); + // CraftBukkit end } else { - this.aG(); + this.aJ(); if (this.world.isClientSide) { @@ -71,9 +77,16 @@ } diff --git a/nms-patches/EntityThrownTrident.patch b/nms-patches/EntityThrownTrident.patch index e3256f1cea..69da22e8eb 100644 --- a/nms-patches/EntityThrownTrident.patch +++ b/nms-patches/EntityThrownTrident.patch @@ -2,7 +2,7 @@ +++ b/net/minecraft/server/EntityThrownTrident.java @@ -132,7 +132,7 @@ - entitylightning.c(Vec3D.c((BaseBlockPosition) blockposition)); + entitylightning.d(Vec3D.c((BaseBlockPosition) blockposition)); entitylightning.d(entity1 instanceof EntityPlayer ? (EntityPlayer) entity1 : null); - this.world.addEntity(entitylightning); + ((WorldServer) this.world).strikeLightning(entitylightning, org.bukkit.event.weather.LightningStrikeEvent.Cause.TRIDENT); // CraftBukkit diff --git a/nms-patches/EntityTrackerEntry.patch b/nms-patches/EntityTrackerEntry.patch index d56735c925..bcd4869567 100644 --- a/nms-patches/EntityTrackerEntry.patch +++ b/nms-patches/EntityTrackerEntry.patch @@ -131,7 +131,7 @@ + // CraftBukkit end } - Packet packet = this.tracker.O(); + Packet packet = this.tracker.P(); @@ -205,6 +251,12 @@ if (this.tracker instanceof EntityLiving) { Collection collection = ((EntityLiving) this.tracker).getAttributeMap().b(); diff --git a/nms-patches/EntityTurtle.patch b/nms-patches/EntityTurtle.patch index 587655e1af..1a6b70b440 100644 --- a/nms-patches/EntityTurtle.patch +++ b/nms-patches/EntityTurtle.patch @@ -13,7 +13,7 @@ @@ -279,7 +281,9 @@ @Override - public void onLightningStrike(EntityLightning entitylightning) { + public void onLightningStrike(WorldServer worldserver, EntityLightning entitylightning) { + org.bukkit.craftbukkit.event.CraftEventFactory.entityDamage = entitylightning; // CraftBukkit this.damageEntity(DamageSource.LIGHTNING, Float.MAX_VALUE); + org.bukkit.craftbukkit.event.CraftEventFactory.entityDamage = null; // CraftBukkit @@ -21,7 +21,7 @@ static class g extends NavigationGuardian { @@ -438,8 +442,12 @@ - } else if (this.g.bC > 200) { + } else if (this.g.bv > 200) { World world = this.g.world; + // CraftBukkit start diff --git a/nms-patches/EntityTypes.patch b/nms-patches/EntityTypes.patch index 70f255ea63..409187aa2e 100644 --- a/nms-patches/EntityTypes.patch +++ b/nms-patches/EntityTypes.patch @@ -9,44 +9,44 @@ public static final EntityTypes ARMOR_STAND = a("armor_stand", EntityTypes.Builder.a(EntityArmorStand::new, EnumCreatureType.MISC).a(0.5F, 1.975F).trackingRange(10)); public static final EntityTypes ARROW = a("arrow", EntityTypes.Builder.a(EntityTippedArrow::new, EnumCreatureType.MISC).a(0.5F, 0.5F).trackingRange(4).updateInterval(20)); public static final EntityTypes BAT = a("bat", EntityTypes.Builder.a(EntityBat::new, EnumCreatureType.AMBIENT).a(0.5F, 0.9F).trackingRange(5)); -@@ -136,7 +136,7 @@ - private MinecraftKey bp; - private final EntitySize bq; +@@ -137,7 +137,7 @@ + private MinecraftKey bq; + private final EntitySize br; - private static EntityTypes a(String s, EntityTypes.Builder entitytypes_builder) { + private static EntityTypes a(String s, EntityTypes.Builder entitytypes_builder) { // CraftBukkit - decompile error return (EntityTypes) IRegistry.a((IRegistry) IRegistry.ENTITY_TYPE, s, (Object) entitytypes_builder.a(s)); } -@@ -168,10 +168,16 @@ +@@ -169,10 +169,17 @@ @Nullable - public T spawnCreature(World world, @Nullable NBTTagCompound nbttagcompound, @Nullable IChatBaseComponent ichatbasecomponent, @Nullable EntityHuman entityhuman, BlockPosition blockposition, EnumMobSpawn enummobspawn, boolean flag, boolean flag1) { + public T spawnCreature(WorldServer worldserver, @Nullable NBTTagCompound nbttagcompound, @Nullable IChatBaseComponent ichatbasecomponent, @Nullable EntityHuman entityhuman, BlockPosition blockposition, EnumMobSpawn enummobspawn, boolean flag, boolean flag1) { + // CraftBukkit start -+ return this.spawnCreature(world, nbttagcompound, ichatbasecomponent, entityhuman, blockposition, enummobspawn, flag, flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG); ++ return this.spawnCreature(worldserver, nbttagcompound, ichatbasecomponent, entityhuman, blockposition, enummobspawn, flag, flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG); + } + + @Nullable -+ public T spawnCreature(World world, @Nullable NBTTagCompound nbttagcompound, @Nullable IChatBaseComponent ichatbasecomponent, @Nullable EntityHuman entityhuman, BlockPosition blockposition, EnumMobSpawn enummobspawn, boolean flag, boolean flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) { - T t0 = this.createCreature(world, nbttagcompound, ichatbasecomponent, entityhuman, blockposition, enummobspawn, flag, flag1); ++ public T spawnCreature(WorldServer worldserver, @Nullable NBTTagCompound nbttagcompound, @Nullable IChatBaseComponent ichatbasecomponent, @Nullable EntityHuman entityhuman, BlockPosition blockposition, EnumMobSpawn enummobspawn, boolean flag, boolean flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) { + T t0 = this.createCreature(worldserver, nbttagcompound, ichatbasecomponent, entityhuman, blockposition, enummobspawn, flag, flag1); -- world.addEntity(t0); -- return t0; -+ return world.addEntity(t0, spawnReason) ? t0 : null; // Don't return an entity when CreatureSpawnEvent is canceled -+ // CraftBukkit end - } + if (t0 != null) { +- worldserver.addAllEntities(t0); ++ return worldserver.addAllEntities(t0, spawnReason) ? t0 : null; // Don't return an entity when CreatureSpawnEvent is canceled ++ // CraftBukkit end + } - @Nullable -@@ -204,7 +210,7 @@ + return t0; +@@ -208,7 +215,7 @@ t0.setCustomName(ichatbasecomponent); } -- a(world, entityhuman, t0, nbttagcompound); -+ try { a(world, entityhuman, t0, nbttagcompound); } catch (Throwable t) { LOGGER.warn("Error loading spawn egg NBT", t); } // CraftBukkit - SPIGOT-5665 +- a((World) worldserver, entityhuman, t0, nbttagcompound); ++ try { a((World) worldserver, entityhuman, t0, nbttagcompound); } catch (Throwable t) { LOGGER.warn("Error loading spawn egg NBT", t); } // CraftBukkit - SPIGOT-5665 return t0; } } -@@ -347,7 +353,7 @@ +@@ -351,7 +358,7 @@ } return entity; @@ -55,7 +55,7 @@ } private static Optional b(NBTTagCompound nbttagcompound, World world) { -@@ -399,7 +405,7 @@ +@@ -403,7 +410,7 @@ this.g = enumcreaturetype == EnumCreatureType.CREATURE || enumcreaturetype == EnumCreatureType.MISC; } diff --git a/nms-patches/EntityVillager.patch b/nms-patches/EntityVillager.patch index aed36be9c3..87a1ec525d 100644 --- a/nms-patches/EntityVillager.patch +++ b/nms-patches/EntityVillager.patch @@ -27,12 +27,12 @@ @Override @@ -83,7 +93,7 @@ - public void b(WorldServer worldserver) { + public void c(WorldServer worldserver) { BehaviorController behaviorcontroller = this.getBehaviorController(); - behaviorcontroller.b(worldserver, (EntityLiving) this); + behaviorcontroller.b(worldserver, this); // CraftBukkit - decompile error - this.bn = behaviorcontroller.h(); + this.bg = behaviorcontroller.h(); this.a(this.getBehaviorController()); } @@ -133,7 +143,7 @@ @@ -42,10 +42,10 @@ - this.getBehaviorController().a((WorldServer) this.world, (EntityLiving) this); + this.getBehaviorController().a((WorldServer) this.world, this); // CraftBukkit - decompile error this.world.getMethodProfiler().exit(); - if (this.bM) { - this.bM = false; + if (this.bF) { + this.bF = false; @@ -147,7 +157,7 @@ - this.bB = false; + this.bu = false; } - this.addEffect(new MobEffect(MobEffects.REGENERATION, 200, 0)); @@ -78,53 +78,44 @@ Logger logger = EntityVillager.LOGGER; logger.getClass(); -@@ -695,7 +712,12 @@ +@@ -700,7 +717,12 @@ } entitywitch.setPersistent(); -- this.world.addEntity(entitywitch); +- worldserver.addAllEntities(entitywitch); + // CraftBukkit start + if (CraftEventFactory.callEntityTransformEvent(this, entitywitch, EntityTransformEvent.TransformReason.LIGHTNING).isCancelled()) { + return; + } -+ this.world.addEntity(entitywitch, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING); ++ worldserver.addAllEntities(entitywitch, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING); + // CraftBukkit end + this.fq(); this.die(); } else { - super.onLightningStrike(entitylightning); -@@ -812,7 +834,7 @@ - } - - private void b(long i) { -- this.bn.setMemory(MemoryModuleType.GOLEM_LAST_SEEN_TIME, (Object) i); -+ this.bn.setMemory(MemoryModuleType.GOLEM_LAST_SEEN_TIME, i); // CraftBukkit - decompile error - } - - private boolean c(long i) { -@@ -845,7 +867,7 @@ +@@ -833,7 +855,7 @@ if (entityirongolem != null) { - if (entityirongolem.a((GeneratorAccess) this.world, EnumMobSpawn.MOB_SUMMONED) && entityirongolem.a((IWorldReader) this.world)) { -- this.world.addEntity(entityirongolem); -+ this.world.addEntity(entityirongolem, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.VILLAGE_DEFENSE); // CraftBukkit + if (entityirongolem.a((GeneratorAccess) worldserver, EnumMobSpawn.MOB_SUMMONED) && entityirongolem.a((IWorldReader) worldserver)) { +- worldserver.addAllEntities(entityirongolem); ++ worldserver.addAllEntities(entityirongolem, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.VILLAGE_DEFENSE); // CraftBukkit return entityirongolem; } -@@ -923,7 +945,7 @@ +@@ -911,7 +933,7 @@ @Override public void entitySleep(BlockPosition blockposition) { super.entitySleep(blockposition); -- this.bn.setMemory(MemoryModuleType.LAST_SLEPT, (Object) this.world.getTime()); -+ this.bn.setMemory(MemoryModuleType.LAST_SLEPT, this.world.getTime()); // CraftBukkit - decompile error - this.bn.removeMemory(MemoryModuleType.WALK_TARGET); - this.bn.removeMemory(MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE); +- this.bg.setMemory(MemoryModuleType.LAST_SLEPT, (Object) this.world.getTime()); ++ this.bg.setMemory(MemoryModuleType.LAST_SLEPT, this.world.getTime()); // CraftBukkit - decompile error + this.bg.removeMemory(MemoryModuleType.WALK_TARGET); + this.bg.removeMemory(MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE); } -@@ -931,7 +953,7 @@ +@@ -919,7 +941,7 @@ @Override public void entityWakeup() { super.entityWakeup(); -- this.bn.setMemory(MemoryModuleType.LAST_WOKEN, (Object) this.world.getTime()); -+ this.bn.setMemory(MemoryModuleType.LAST_WOKEN, this.world.getTime()); // CraftBukkit - decompile error +- this.bg.setMemory(MemoryModuleType.LAST_WOKEN, (Object) this.world.getTime()); ++ this.bg.setMemory(MemoryModuleType.LAST_WOKEN, this.world.getTime()); // CraftBukkit - decompile error } - private boolean d(long i) { + private boolean b(long i) { diff --git a/nms-patches/EntityVillagerAbstract.patch b/nms-patches/EntityVillagerAbstract.patch index f4aaf7d02f..f23405865e 100644 --- a/nms-patches/EntityVillagerAbstract.patch +++ b/nms-patches/EntityVillagerAbstract.patch @@ -22,7 +22,7 @@ + return (craftMerchant == null) ? craftMerchant = new CraftMerchant(this) : craftMerchant; + } + // CraftBukkit end - private static final DataWatcherObject bw = DataWatcher.a(EntityVillagerAbstract.class, DataWatcherRegistry.b); + private static final DataWatcherObject bp = DataWatcher.a(EntityVillagerAbstract.class, DataWatcherRegistry.b); @Nullable private EntityHuman tradingPlayer; @Nullable @@ -32,7 +32,7 @@ public EntityVillagerAbstract(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -214,7 +229,16 @@ +@@ -213,7 +228,16 @@ MerchantRecipe merchantrecipe = villagertrades_imerchantrecipeoption.a(this, this.random); if (merchantrecipe != null) { diff --git a/nms-patches/EntityWolf.patch b/nms-patches/EntityWolf.patch index 91f336ea2e..6ed6ffad37 100644 --- a/nms-patches/EntityWolf.patch +++ b/nms-patches/EntityWolf.patch @@ -11,16 +11,16 @@ + public class EntityWolf extends EntityTameableAnimal implements IEntityAngerable { - private static final DataWatcherObject by = DataWatcher.a(EntityWolf.class, DataWatcherRegistry.i); + private static final DataWatcherObject br = DataWatcher.a(EntityWolf.class, DataWatcherRegistry.i); @@ -43,7 +48,7 @@ this.goalSelector.a(10, new PathfinderGoalRandomLookaround(this)); this.targetSelector.a(1, new PathfinderGoalOwnerHurtByTarget(this)); this.targetSelector.a(2, new PathfinderGoalOwnerHurtTarget(this)); - this.targetSelector.a(3, (new PathfinderGoalHurtByTarget(this, new Class[0])).a()); + this.targetSelector.a(3, (new PathfinderGoalHurtByTarget(this, new Class[0])).a(new Class[0])); // CraftBukkit - decompile error - this.targetSelector.a(4, new PathfinderGoalNearestAttackableTarget<>(this, EntityHuman.class, 10, true, false, this::b)); - this.targetSelector.a(5, new PathfinderGoalRandomTargetNonTamed<>(this, EntityAnimal.class, false, EntityWolf.bx)); - this.targetSelector.a(6, new PathfinderGoalRandomTargetNonTamed<>(this, EntityTurtle.class, false, EntityTurtle.bv)); + this.targetSelector.a(4, new PathfinderGoalNearestAttackableTarget<>(this, EntityHuman.class, 10, true, false, this::a_)); + this.targetSelector.a(5, new PathfinderGoalRandomTargetNonTamed<>(this, EntityAnimal.class, false, EntityWolf.bq)); + this.targetSelector.a(6, new PathfinderGoalRandomTargetNonTamed<>(this, EntityTurtle.class, false, EntityTurtle.bo)); @@ -55,6 +60,24 @@ return EntityInsentient.p().a(GenericAttributes.MOVEMENT_SPEED, 0.30000001192092896D).a(GenericAttributes.MAX_HEALTH, 8.0D).a(GenericAttributes.ATTACK_DAMAGE, 2.0D); } @@ -46,7 +46,7 @@ @Override protected void initDatawatcher() { super.initDatawatcher(); -@@ -194,7 +217,7 @@ +@@ -201,7 +224,7 @@ } else { Entity entity = damagesource.getEntity(); @@ -55,7 +55,7 @@ if (entity != null && !(entity instanceof EntityHuman) && !(entity instanceof EntityArrow)) { f = (f + 1.0F) / 2.0F; } -@@ -219,7 +242,7 @@ +@@ -226,7 +249,7 @@ super.setTamed(flag); if (flag) { this.getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(20.0D); @@ -64,7 +64,7 @@ } else { this.getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(8.0D); } -@@ -243,7 +266,7 @@ +@@ -250,7 +273,7 @@ itemstack.subtract(1); } @@ -73,7 +73,7 @@ return EnumInteractionResult.SUCCESS; } -@@ -254,7 +277,7 @@ +@@ -261,7 +284,7 @@ this.setWillSit(!this.isWillSit()); this.jumping = false; this.navigation.o(); @@ -82,7 +82,7 @@ return EnumInteractionResult.SUCCESS; } -@@ -276,7 +299,8 @@ +@@ -283,7 +306,8 @@ itemstack.subtract(1); } diff --git a/nms-patches/EntityZombie.patch b/nms-patches/EntityZombie.patch index e674111da8..660fb36177 100644 --- a/nms-patches/EntityZombie.patch +++ b/nms-patches/EntityZombie.patch @@ -17,14 +17,14 @@ private static final UUID b = UUID.fromString("B9766B59-9566-4402-BC1F-2EE2A276D836"); @@ -23,6 +32,7 @@ - private boolean bz; - private int bA; + private boolean bs; + private int bt; public int drownedConversionTime; + private int lastTick = MinecraftServer.currentTick; // CraftBukkit - add field public EntityZombie(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -138,7 +148,10 @@ +@@ -139,7 +149,10 @@ public void tick() { if (!this.world.isClientSide && this.isAlive() && !this.isNoAI()) { if (this.isDrownConverting()) { @@ -34,9 +34,9 @@ + this.drownedConversionTime -= elapsedTicks; + // CraftBukkit end if (this.drownedConversionTime < 0) { - this.eQ(); + this.eP(); } -@@ -155,6 +168,7 @@ +@@ -156,6 +169,7 @@ } super.tick(); @@ -44,7 +44,7 @@ } @Override -@@ -187,6 +201,7 @@ +@@ -188,6 +202,7 @@ } public void startDrownedConversion(int i) { @@ -52,26 +52,34 @@ this.drownedConversionTime = i; this.getDataWatcher().set(EntityZombie.DROWN_CONVERTING, true); } -@@ -206,6 +221,7 @@ - entityzombie.u(entityzombie.world.getDamageScaler(entityzombie.getChunkCoordinates()).d()); - entityzombie.u(entityzombie.eL() && this.eV()); +@@ -201,12 +216,13 @@ + } + + protected void b(EntityTypes entitytypes) { +- EntityZombie entityzombie = (EntityZombie) this.a(entitytypes, true); ++ EntityZombie entityzombie = (EntityZombie) this.a(entitytypes, true, EntityTransformEvent.TransformReason.DROWNED, CreatureSpawnEvent.SpawnReason.DROWNED); + + if (entityzombie != null) { + entityzombie.y(entityzombie.world.getDamageScaler(entityzombie.getChunkCoordinates()).d()); + entityzombie.u(entityzombie.eK() && this.eU()); } + else { ((Zombie) getBukkitEntity()).setConversionTime(-1); } // CraftBukkit - SPIGOT-5208: End conversion to stop event spam } -@@ -239,8 +255,8 @@ - if (SpawnerCreature.a(entitypositiontypes_surface, (IWorldReader) this.world, blockposition, entitytypes) && EntityPositionTypes.a(entitytypes, this.world, EnumMobSpawn.REINFORCEMENT, blockposition, this.world.random)) { +@@ -245,9 +261,9 @@ + if (SpawnerCreature.a(entitypositiontypes_surface, (IWorldReader) this.world, blockposition, entitytypes) && EntityPositionTypes.a(entitytypes, worldserver, EnumMobSpawn.REINFORCEMENT, blockposition, this.world.random)) { entityzombie.setPosition((double) i1, (double) j1, (double) k1); - if (!this.world.isPlayerNearby((double) i1, (double) j1, (double) k1, 7.0D) && this.world.i(entityzombie) && this.world.getCubes(entityzombie) && !this.world.containsLiquid(entityzombie.getBoundingBox())) { -- this.world.addEntity(entityzombie); + if (!this.world.isPlayerNearby((double) i1, (double) j1, (double) k1, 7.0D) && this.world.j((Entity) entityzombie) && this.world.getCubes(entityzombie) && !this.world.containsLiquid(entityzombie.getBoundingBox())) { - entityzombie.setGoalTarget(entityliving); -+ this.world.addEntity(entityzombie, CreatureSpawnEvent.SpawnReason.REINFORCEMENTS); // CraftBukkit + entityzombie.setGoalTarget(entityliving, EntityTargetEvent.TargetReason.REINFORCEMENT_TARGET, true); // CraftBukkit - entityzombie.prepare(this.world, this.world.getDamageScaler(entityzombie.getChunkCoordinates()), EnumMobSpawn.REINFORCEMENT, (GroupDataEntity) null, (NBTTagCompound) null); + entityzombie.prepare(worldserver, this.world.getDamageScaler(entityzombie.getChunkCoordinates()), EnumMobSpawn.REINFORCEMENT, (GroupDataEntity) null, (NBTTagCompound) null); +- worldserver.addAllEntities(entityzombie); ++ worldserver.addAllEntities(entityzombie, CreatureSpawnEvent.SpawnReason.REINFORCEMENTS); // CraftBukkit this.getAttributeInstance(GenericAttributes.SPAWN_REINFORCEMENTS).addModifier(new AttributeModifier("Zombie reinforcement caller charge", -0.05000000074505806D, AttributeModifier.Operation.ADDITION)); entityzombie.getAttributeInstance(GenericAttributes.SPAWN_REINFORCEMENTS).addModifier(new AttributeModifier("Zombie reinforcement callee charge", -0.05000000074505806D, AttributeModifier.Operation.ADDITION)); -@@ -264,7 +280,14 @@ + break; +@@ -268,7 +284,14 @@ float f = this.world.getDamageScaler(this.getChunkCoordinates()).b(); if (this.getItemInMainHand().isEmpty() && this.isBurning() && this.random.nextFloat() < f * 0.3F) { @@ -87,36 +95,26 @@ } } -@@ -354,7 +377,7 @@ - EntityZombieVillager entityzombievillager = (EntityZombieVillager) EntityTypes.ZOMBIE_VILLAGER.a(this.world); - - entityzombievillager.u(entityvillager); -- entityvillager.die(); -+ // entityvillager.die(); // CraftBukkit - moved down - entityzombievillager.prepare(this.world, this.world.getDamageScaler(entityzombievillager.getChunkCoordinates()), EnumMobSpawn.CONVERSION, new EntityZombie.GroupDataZombie(false, true), (NBTTagCompound) null); - entityzombievillager.setVillagerData(entityvillager.getVillagerData()); - entityzombievillager.a((NBTBase) entityvillager.fj().a((DynamicOps) DynamicOpsNBT.a).getValue()); -@@ -372,7 +395,13 @@ +@@ -349,7 +372,12 @@ } - entityzombievillager.setInvulnerable(this.isInvulnerable()); -- this.world.addEntity(entityzombievillager); + EntityVillager entityvillager = (EntityVillager) entityliving; +- EntityZombieVillager entityzombievillager = (EntityZombieVillager) entityvillager.a(EntityTypes.ZOMBIE_VILLAGER, false); + // CraftBukkit start -+ if (CraftEventFactory.callEntityTransformEvent(this, entityzombievillager, EntityTransformEvent.TransformReason.INFECTION).isCancelled()) { ++ EntityZombieVillager entityzombievillager = (EntityZombieVillager) entityvillager.a(EntityTypes.ZOMBIE_VILLAGER, false, EntityTransformEvent.TransformReason.INFECTION, CreatureSpawnEvent.SpawnReason.INFECTION); ++ if (entityzombievillager == null) { + return; + } -+ entityvillager.die(); // CraftBukkit - from above -+ this.world.addEntity(entityzombievillager, CreatureSpawnEvent.SpawnReason.INFECTION); // CraftBukkit - add SpawnReason + // CraftBukkit end - if (!this.isSilent()) { - this.world.a((EntityHuman) null, 1026, this.getChunkCoordinates(), 0); - } -@@ -423,7 +452,7 @@ - entitychicken1.prepare(generatoraccess, difficultydamagescaler, EnumMobSpawn.JOCKEY, (GroupDataEntity) null, (NBTTagCompound) null); + + entityzombievillager.prepare(worldserver, worldserver.getDamageScaler(entityzombievillager.getChunkCoordinates()), EnumMobSpawn.CONVERSION, new EntityZombie.GroupDataZombie(false, true), (NBTTagCompound) null); + entityzombievillager.setVillagerData(entityvillager.getVillagerData()); +@@ -406,7 +434,7 @@ + entitychicken1.prepare(worldaccess, difficultydamagescaler, EnumMobSpawn.JOCKEY, (GroupDataEntity) null, (NBTTagCompound) null); entitychicken1.setChickenJockey(true); this.startRiding(entitychicken1); -- generatoraccess.addEntity(entitychicken1); -+ generatoraccess.addEntity(entitychicken1, CreatureSpawnEvent.SpawnReason.MOUNT); // CraftBukkit +- worldaccess.addEntity(entitychicken1); ++ worldaccess.addEntity(entitychicken1, CreatureSpawnEvent.SpawnReason.MOUNT); // CraftBukkit } } } diff --git a/nms-patches/EntityZombieVillager.patch b/nms-patches/EntityZombieVillager.patch index 47012258e6..5fbf0556bc 100644 --- a/nms-patches/EntityZombieVillager.patch +++ b/nms-patches/EntityZombieVillager.patch @@ -1,26 +1,27 @@ --- a/net/minecraft/server/EntityZombieVillager.java +++ b/net/minecraft/server/EntityZombieVillager.java -@@ -5,6 +5,11 @@ +@@ -5,6 +5,12 @@ import java.util.UUID; import javax.annotation.Nullable; import org.apache.logging.log4j.Logger; +// CraftBukkit start +import org.bukkit.craftbukkit.event.CraftEventFactory; +import org.bukkit.entity.ZombieVillager; ++import org.bukkit.event.entity.CreatureSpawnEvent; +import org.bukkit.event.entity.EntityTransformEvent; +// CraftBukkit end public class EntityZombieVillager extends EntityZombie implements VillagerDataHolder { -@@ -15,6 +20,7 @@ - private NBTBase bw; - private NBTTagCompound bx; - private int by; +@@ -15,6 +21,7 @@ + private NBTBase bp; + private NBTTagCompound bq; + private int br; + private int lastTick = MinecraftServer.currentTick; // CraftBukkit - add field public EntityZombieVillager(EntityTypes entitytypes, World world) { super(entitytypes, world); -@@ -31,7 +37,7 @@ +@@ -31,7 +38,7 @@ @Override public void saveData(NBTTagCompound nbttagcompound) { super.saveData(nbttagcompound); @@ -29,7 +30,7 @@ Logger logger = EntityZombieVillager.LOGGER; logger.getClass(); -@@ -87,6 +93,10 @@ +@@ -87,6 +94,10 @@ public void tick() { if (!this.world.isClientSide && this.isAlive() && this.isConverting()) { int i = this.getConversionProgress(); @@ -40,7 +41,7 @@ this.conversionTime -= i; if (this.conversionTime <= 0) { -@@ -95,6 +105,7 @@ +@@ -95,6 +106,7 @@ } super.tick(); @@ -48,7 +49,7 @@ } @Override -@@ -138,8 +149,11 @@ +@@ -138,13 +150,22 @@ this.conversionPlayer = uuid; this.conversionTime = i; this.getDataWatcher().set(EntityZombieVillager.CONVERTING, true); @@ -62,32 +63,19 @@ this.world.broadcastEntityEffect(this, (byte) 16); } -@@ -181,7 +195,7 @@ - entityvillager.setAgeRaw(-24000); - } - -- this.die(); -+ // this.die(); // CraftBukkit - moved down - entityvillager.setNoAI(this.isNoAI()); - if (this.hasCustomName()) { - entityvillager.setCustomName(this.getCustomName()); -@@ -193,7 +207,14 @@ - } - - entityvillager.setInvulnerable(this.isInvulnerable()); -- worldserver.addEntity(entityvillager); + private void c(WorldServer worldserver) { +- EntityVillager entityvillager = (EntityVillager) this.a(EntityTypes.VILLAGER, false); + // CraftBukkit start -+ if (CraftEventFactory.callEntityTransformEvent(this, entityvillager, EntityTransformEvent.TransformReason.CURED).isCancelled()) { ++ EntityVillager entityvillager = (EntityVillager) this.a(EntityTypes.VILLAGER, false, EntityTransformEvent.TransformReason.CURED, CreatureSpawnEvent.SpawnReason.CURED); ++ if (entityvillager == null) { + ((ZombieVillager) getBukkitEntity()).setConversionTime(-1); // SPIGOT-5208: End conversion to stop event spam + return; + } -+ this.die(); // CraftBukkit - from above -+ worldserver.addEntity(entityvillager, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CURED); // CraftBukkit - add SpawnReason + // CraftBukkit end - if (this.conversionPlayer != null) { - EntityHuman entityhuman = worldserver.b(this.conversionPlayer); + EnumItemSlot[] aenumitemslot = EnumItemSlot.values(); + int i = aenumitemslot.length; -@@ -203,7 +224,7 @@ +@@ -185,7 +206,7 @@ } } diff --git a/nms-patches/Explosion.patch b/nms-patches/Explosion.patch index ad41e34470..dda314e9ab 100644 --- a/nms-patches/Explosion.patch +++ b/nms-patches/Explosion.patch @@ -13,11 +13,11 @@ + public class Explosion { - private final boolean a; -@@ -31,11 +38,12 @@ - private final ExplosionDamageCalculator k; + private static final ExplosionDamageCalculator a = new ExplosionDamageCalculator(); +@@ -32,11 +39,12 @@ + private final ExplosionDamageCalculator l; private final List blocks = Lists.newArrayList(); - private final Map m = Maps.newHashMap(); + private final Map n = Maps.newHashMap(); + public boolean wasCanceled = false; // CraftBukkit - add field public Explosion(World world, @Nullable Entity entity, @Nullable DamageSource damagesource, @Nullable ExplosionDamageCalculator explosiondamagecalculator, double d0, double d1, double d2, float f, boolean flag, Explosion.Effect explosion_effect) { @@ -28,7 +28,7 @@ this.posX = d0; this.posY = d1; this.posZ = d2; -@@ -85,6 +93,11 @@ +@@ -86,6 +94,11 @@ } public void a() { @@ -40,16 +40,16 @@ Set set = Sets.newHashSet(); boolean flag = true; -@@ -118,7 +131,7 @@ +@@ -119,7 +132,7 @@ f -= ((Float) optional.get() + 0.3F) * 0.3F; } -- if (f > 0.0F && this.k.a(this, this.world, blockposition, iblockdata, f)) { -+ if (f > 0.0F && this.k.a(this, this.world, blockposition, iblockdata, f) && blockposition.getY() < 256 && blockposition.getY() >= 0) { // CraftBukkit - don't wrap explosions +- if (f > 0.0F && this.l.a(this, this.world, blockposition, iblockdata, f)) { ++ if (f > 0.0F && this.l.a(this, this.world, blockposition, iblockdata, f) && blockposition.getY() < 256 && blockposition.getY() >= 0) { // CraftBukkit - don't wrap explosions set.add(blockposition); } -@@ -162,7 +175,16 @@ +@@ -163,7 +176,16 @@ double d12 = (double) a(vec3d, entity); double d13 = (1.0D - d7) * d12; @@ -67,7 +67,7 @@ double d14 = d13; if (entity instanceof EntityLiving) { -@@ -204,6 +226,51 @@ +@@ -205,6 +227,51 @@ Collections.shuffle(this.blocks, this.world.random); Iterator iterator = this.blocks.iterator(); @@ -90,13 +90,13 @@ + float yield; + + if (explode != null) { -+ EntityExplodeEvent event = new EntityExplodeEvent(explode, location, blockList, this.b == Explosion.Effect.DESTROY ? 1.0F / this.size : 1.0F); ++ EntityExplodeEvent event = new EntityExplodeEvent(explode, location, blockList, this.c == Explosion.Effect.DESTROY ? 1.0F / this.size : 1.0F); + this.world.getServer().getPluginManager().callEvent(event); + cancelled = event.isCancelled(); + bukkitBlocks = event.blockList(); + yield = event.getYield(); + } else { -+ BlockExplodeEvent event = new BlockExplodeEvent(location.getBlock(), blockList, this.b == Explosion.Effect.DESTROY ? 1.0F / this.size : 1.0F); ++ BlockExplodeEvent event = new BlockExplodeEvent(location.getBlock(), blockList, this.c == Explosion.Effect.DESTROY ? 1.0F / this.size : 1.0F); + this.world.getServer().getPluginManager().callEvent(event); + cancelled = event.isCancelled(); + bukkitBlocks = event.blockList(); @@ -119,21 +119,21 @@ while (iterator.hasNext()) { BlockPosition blockposition = (BlockPosition) iterator.next(); -@@ -218,8 +285,8 @@ +@@ -219,8 +286,8 @@ TileEntity tileentity = block.isTileEntity() ? this.world.getTileEntity(blockposition) : null; - LootTableInfo.Builder loottableinfo_builder = (new LootTableInfo.Builder((WorldServer) this.world)).a(this.world.random).set(LootContextParameters.POSITION, blockposition).set(LootContextParameters.TOOL, ItemStack.b).setOptional(LootContextParameters.BLOCK_ENTITY, tileentity).setOptional(LootContextParameters.THIS_ENTITY, this.source); + LootTableInfo.Builder loottableinfo_builder = (new LootTableInfo.Builder((WorldServer) this.world)).a(this.world.random).set(LootContextParameters.ORIGIN, Vec3D.a((BaseBlockPosition) blockposition)).set(LootContextParameters.TOOL, ItemStack.b).setOptional(LootContextParameters.BLOCK_ENTITY, tileentity).setOptional(LootContextParameters.THIS_ENTITY, this.source); -- if (this.b == Explosion.Effect.DESTROY) { +- if (this.c == Explosion.Effect.DESTROY) { - loottableinfo_builder.set(LootContextParameters.EXPLOSION_RADIUS, this.size); -+ if (this.b == Explosion.Effect.DESTROY || yield < 1.0F) { // CraftBukkit - add yield ++ if (this.c == Explosion.Effect.DESTROY || yield < 1.0F) { // CraftBukkit - add yield + loottableinfo_builder.set(LootContextParameters.EXPLOSION_RADIUS, 1.0F / yield); // CraftBukkit - add yield } iblockdata.a(loottableinfo_builder).forEach((itemstack) -> { -@@ -249,7 +316,11 @@ +@@ -250,7 +317,11 @@ BlockPosition blockposition2 = (BlockPosition) iterator1.next(); - if (this.c.nextInt(3) == 0 && this.world.getType(blockposition2).isAir() && this.world.getType(blockposition2.down()).i(this.world, blockposition2.down())) { + if (this.d.nextInt(3) == 0 && this.world.getType(blockposition2).isAir() && this.world.getType(blockposition2.down()).i(this.world, blockposition2.down())) { - this.world.setTypeUpdate(blockposition2, BlockFireAbstract.a((IBlockAccess) this.world, blockposition2)); + // CraftBukkit start - Ignition by explosion + if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(this.world, blockposition2.getX(), blockposition2.getY(), blockposition2.getZ(), this).isCancelled()) { @@ -143,7 +143,7 @@ } } } -@@ -257,6 +328,7 @@ +@@ -258,6 +329,7 @@ } private static void a(ObjectArrayList> objectarraylist, ItemStack itemstack, BlockPosition blockposition) { diff --git a/nms-patches/GeneratorAccess.patch b/nms-patches/GeneratorAccess.patch new file mode 100644 index 0000000000..4b64d51665 --- /dev/null +++ b/nms-patches/GeneratorAccess.patch @@ -0,0 +1,9 @@ +--- a/net/minecraft/server/GeneratorAccess.java ++++ b/net/minecraft/server/GeneratorAccess.java +@@ -46,4 +46,6 @@ + default void triggerEffect(int i, BlockPosition blockposition, int j) { + this.a((EntityHuman) null, i, blockposition, j); + } ++ ++ WorldServer getMinecraftWorld(); // CraftBukkit + } diff --git a/nms-patches/HandshakeListener.patch b/nms-patches/HandshakeListener.patch index b41b2f002c..e8dce70591 100644 --- a/nms-patches/HandshakeListener.patch +++ b/nms-patches/HandshakeListener.patch @@ -63,7 +63,7 @@ this.c.close(chatmessage); } else { this.c.setPacketListener(new LoginListener(this.b, this.c)); -+ ((LoginListener) this.c.i()).hostname = packethandshakinginsetprotocol.hostname + ":" + packethandshakinginsetprotocol.port; // CraftBukkit - set hostname ++ ((LoginListener) this.c.j()).hostname = packethandshakinginsetprotocol.hostname + ":" + packethandshakinginsetprotocol.port; // CraftBukkit - set hostname } break; case STATUS: diff --git a/nms-patches/IBlockAccess.patch b/nms-patches/IBlockAccess.patch index 4bb9af12f6..bb7470bb8b 100644 --- a/nms-patches/IBlockAccess.patch +++ b/nms-patches/IBlockAccess.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/IBlockAccess.java +++ b/net/minecraft/server/IBlockAccess.java -@@ -30,8 +30,8 @@ +@@ -31,8 +31,8 @@ return BlockPosition.a(axisalignedbb).map(this::getType); } @@ -11,7 +11,7 @@ IBlockData iblockdata = this.getType(blockposition); Fluid fluid = this.getFluid(blockposition); Vec3D vec3d = raytrace1.b(); -@@ -44,6 +44,12 @@ +@@ -45,6 +45,12 @@ double d1 = movingobjectpositionblock1 == null ? Double.MAX_VALUE : raytrace1.b().distanceSquared(movingobjectpositionblock1.getPos()); return d0 <= d1 ? movingobjectpositionblock : movingobjectpositionblock1; @@ -24,7 +24,7 @@ }, (raytrace1) -> { Vec3D vec3d = raytrace1.b().d(raytrace1.a()); -@@ -101,7 +107,7 @@ +@@ -120,7 +126,7 @@ double d13 = d10 * (i1 > 0 ? 1.0D - MathHelper.h(d4) : MathHelper.h(d4)); double d14 = d11 * (j1 > 0 ? 1.0D - MathHelper.h(d5) : MathHelper.h(d5)); diff --git a/nms-patches/IDispenseBehavior.patch b/nms-patches/IDispenseBehavior.patch index b8b3fcf231..4981517469 100644 --- a/nms-patches/IDispenseBehavior.patch +++ b/nms-patches/IDispenseBehavior.patch @@ -66,14 +66,14 @@ EntityTypes entitytypes = ((ItemMonsterEgg) itemstack.getItem()).a(itemstack.getTag()); + // CraftBukkit start -+ World world = isourceblock.getWorld(); ++ WorldServer worldserver = isourceblock.getWorld(); + ItemStack itemstack1 = itemstack.cloneAndSubtract(1); -+ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); ++ org.bukkit.block.Block block = worldserver.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); + CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); + + BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0)); + if (!BlockDispenser.eventFired) { -+ world.getServer().getPluginManager().callEvent(event); ++ worldserver.getServer().getPluginManager().callEvent(event); + } + + if (event.isCancelled()) { @@ -102,16 +102,16 @@ @@ -146,12 +183,40 @@ EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING); BlockPosition blockposition = isourceblock.getBlockPosition().shift(enumdirection); - World world = isourceblock.getWorld(); + WorldServer worldserver = isourceblock.getWorld(); + + // CraftBukkit start + ItemStack itemstack1 = itemstack.cloneAndSubtract(1); -+ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); ++ org.bukkit.block.Block block = worldserver.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); + CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); + + BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0)); + if (!BlockDispenser.eventFired) { -+ world.getServer().getPluginManager().callEvent(event); ++ worldserver.getServer().getPluginManager().callEvent(event); + } + + if (event.isCancelled()) { @@ -131,11 +131,11 @@ + } + // CraftBukkit end + - EntityArmorStand entityarmorstand = new EntityArmorStand(world, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D); + EntityArmorStand entityarmorstand = new EntityArmorStand(worldserver, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D); - EntityTypes.a(world, (EntityHuman) null, (Entity) entityarmorstand, itemstack.getTag()); + EntityTypes.a((World) worldserver, (EntityHuman) null, (Entity) entityarmorstand, itemstack.getTag()); entityarmorstand.yaw = enumdirection.o(); - world.addEntity(entityarmorstand); + worldserver.addEntity(entityarmorstand); - itemstack.subtract(1); + // itemstack.subtract(1); // CraftBukkit - Handled during event processing return itemstack; @@ -146,14 +146,14 @@ public ItemStack a(ISourceBlock isourceblock, ItemStack itemstack) { EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING); + // CraftBukkit start -+ World world = isourceblock.getWorld(); ++ WorldServer worldserver = isourceblock.getWorld(); + ItemStack itemstack1 = itemstack.cloneAndSubtract(1); -+ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); ++ org.bukkit.block.Block block = worldserver.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(enumdirection.getAdjacentX(), enumdirection.getAdjacentY(), enumdirection.getAdjacentZ())); + if (!BlockDispenser.eventFired) { -+ world.getServer().getPluginManager().callEvent(event); ++ worldserver.getServer().getPluginManager().callEvent(event); + } + + if (event.isCancelled()) { @@ -188,18 +188,18 @@ double d4 = random.nextGaussian() * 0.05D + (double) enumdirection.getAdjacentY(); double d5 = random.nextGaussian() * 0.05D + (double) enumdirection.getAdjacentZ(); -- world.addEntity((Entity) SystemUtils.a((Object) (new EntitySmallFireball(world, d0, d1, d2, d3, d4, d5)), (entitysmallfireball) -> { +- worldserver.addEntity((Entity) SystemUtils.a((Object) (new EntitySmallFireball(worldserver, d0, d1, d2, d3, d4, d5)), (entitysmallfireball) -> { - entitysmallfireball.setItem(itemstack); - })); - itemstack.subtract(1); + // CraftBukkit start + ItemStack itemstack1 = itemstack.cloneAndSubtract(1); -+ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); ++ org.bukkit.block.Block block = worldserver.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); + CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); + + BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(d3, d4, d5)); + if (!BlockDispenser.eventFired) { -+ world.getServer().getPluginManager().callEvent(event); ++ worldserver.getServer().getPluginManager().callEvent(event); + } + + if (event.isCancelled()) { @@ -218,11 +218,11 @@ + } + } + -+ EntitySmallFireball entitysmallfireball = new EntitySmallFireball(world, d0, d1, d2, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ()); ++ EntitySmallFireball entitysmallfireball = new EntitySmallFireball(worldserver, d0, d1, d2, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ()); + entitysmallfireball.setItem(itemstack1); + entitysmallfireball.projectileSource = new org.bukkit.craftbukkit.projectiles.CraftBlockProjectileSource((TileEntityDispenser) isourceblock.getTileEntity()); + -+ world.addEntity(entitysmallfireball); ++ worldserver.addEntity(entitysmallfireball); + // itemstack.subtract(1); // Handled during event processing + // CraftBukkit end return itemstack; @@ -230,21 +230,21 @@ @@ -307,9 +430,52 @@ BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING)); - World world = isourceblock.getWorld(); + WorldServer worldserver = isourceblock.getWorld(); + // CraftBukkit start + int x = blockposition.getX(); + int y = blockposition.getY(); + int z = blockposition.getZ(); -+ IBlockData iblockdata = world.getType(blockposition); ++ IBlockData iblockdata = worldserver.getType(blockposition); + Material material = iblockdata.getMaterial(); -+ if (world.isEmpty(blockposition) || !material.isBuildable() || material.isReplaceable() || ((iblockdata.getBlock() instanceof IFluidContainer) && ((IFluidContainer) iblockdata.getBlock()).canPlace(world, blockposition, iblockdata, itembucket.fluidType))) { -+ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); ++ if (worldserver.isEmpty(blockposition) || !material.isBuildable() || material.isReplaceable() || ((iblockdata.getBlock() instanceof IFluidContainer) && ((IFluidContainer) iblockdata.getBlock()).canPlace(worldserver, blockposition, iblockdata, itembucket.fluidType))) { ++ org.bukkit.block.Block block = worldserver.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); + CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack); + + BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(x, y, z)); + if (!BlockDispenser.eventFired) { -+ world.getServer().getPluginManager().callEvent(event); ++ worldserver.getServer().getPluginManager().callEvent(event); + } + + if (event.isCancelled()) { @@ -265,8 +265,8 @@ + } + // CraftBukkit end + - if (itembucket.a((EntityHuman) null, world, blockposition, (MovingObjectPositionBlock) null)) { - itembucket.a(world, itemstack, blockposition); + if (itembucket.a((EntityHuman) null, (World) worldserver, blockposition, (MovingObjectPositionBlock) null)) { + itembucket.a((World) worldserver, itemstack, blockposition); - return new ItemStack(Items.BUCKET); + // CraftBukkit start - Handle stacked buckets + Item item = Items.BUCKET; @@ -286,7 +286,7 @@ Block block = iblockdata.getBlock(); if (block instanceof IFluidSource) { -- FluidType fluidtype = ((IFluidSource) block).removeFluid(world, blockposition, iblockdata); +- FluidType fluidtype = ((IFluidSource) block).removeFluid(worldserver, blockposition, iblockdata); + FluidType fluidtype = ((IFluidSource) block).removeFluid(DummyGeneratorAccess.INSTANCE, blockposition, iblockdata); // CraftBukkit if (!(fluidtype instanceof FluidTypeFlowing)) { @@ -295,12 +295,12 @@ Item item = fluidtype.a(); + // CraftBukkit start -+ org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); ++ org.bukkit.block.Block bukkitBlock = worldserver.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); ++ worldserver.getServer().getPluginManager().callEvent(event); + } + + if (event.isCancelled()) { @@ -317,23 +317,23 @@ + } + } + -+ fluidtype = ((IFluidSource) block).removeFluid(world, blockposition, iblockdata); // From above ++ fluidtype = ((IFluidSource) block).removeFluid(worldserver, blockposition, iblockdata); // From above + // CraftBukkit end + itemstack.subtract(1); if (itemstack.isEmpty()) { return new ItemStack(item); -@@ -361,12 +553,40 @@ +@@ -361,13 +553,41 @@ protected ItemStack a(ISourceBlock isourceblock, ItemStack itemstack) { - World world = isourceblock.getWorld(); + WorldServer worldserver = isourceblock.getWorld(); + // CraftBukkit start -+ org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); ++ org.bukkit.block.Block bukkitBlock = worldserver.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); + CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack); + + BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0)); + if (!BlockDispenser.eventFired) { -+ world.getServer().getPluginManager().callEvent(event); ++ worldserver.getServer().getPluginManager().callEvent(event); + } + + if (event.isCancelled()) { @@ -352,30 +352,31 @@ + // CraftBukkit end + this.a(true); - BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING)); - IBlockData iblockdata = world.getType(blockposition); + EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING); + BlockPosition blockposition = isourceblock.getBlockPosition().shift(enumdirection); + IBlockData iblockdata = worldserver.getType(blockposition); - if (BlockFireAbstract.a((GeneratorAccess) world, blockposition)) { -- world.setTypeUpdate(blockposition, BlockFireAbstract.a((IBlockAccess) world, blockposition)); + if (BlockFireAbstract.a((World) worldserver, blockposition, enumdirection)) { +- worldserver.setTypeUpdate(blockposition, BlockFireAbstract.a((IBlockAccess) worldserver, blockposition)); + // CraftBukkit start - Ignition by dispensing flint and steel -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition, isourceblock.getBlockPosition()).isCancelled()) { -+ world.setTypeUpdate(blockposition, BlockFireAbstract.a((IBlockAccess) world, blockposition)); ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(worldserver, blockposition, isourceblock.getBlockPosition()).isCancelled()) { ++ worldserver.setTypeUpdate(blockposition, BlockFireAbstract.a((IBlockAccess) worldserver, blockposition)); + } + // CraftBukkit end } else if (BlockCampfire.h(iblockdata)) { - world.setTypeUpdate(blockposition, (IBlockData) iblockdata.set(BlockProperties.r, true)); + worldserver.setTypeUpdate(blockposition, (IBlockData) iblockdata.set(BlockProperties.r, true)); } else if (iblockdata.getBlock() instanceof BlockTNT) { -@@ -389,12 +609,57 @@ +@@ -390,12 +610,57 @@ this.a(true); - World world = isourceblock.getWorld(); + WorldServer worldserver = isourceblock.getWorld(); BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING)); + // CraftBukkit start -+ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); ++ org.bukkit.block.Block block = worldserver.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); ++ worldserver.getServer().getPluginManager().callEvent(event); + } + + if (event.isCancelled()) { @@ -392,22 +393,22 @@ + } + } + -+ world.captureTreeGeneration = true; ++ worldserver.captureTreeGeneration = true; + // CraftBukkit end - if (!ItemBoneMeal.a(itemstack, world, blockposition) && !ItemBoneMeal.a(itemstack, world, blockposition, (EnumDirection) null)) { + if (!ItemBoneMeal.a(itemstack, (World) worldserver, blockposition) && !ItemBoneMeal.a(itemstack, (World) worldserver, blockposition, (EnumDirection) null)) { this.a(false); - } else if (!world.isClientSide) { - world.triggerEffect(2005, blockposition, 0); + } else if (!worldserver.isClientSide) { + worldserver.triggerEffect(2005, blockposition, 0); } + // CraftBukkit start -+ world.captureTreeGeneration = false; -+ if (world.capturedBlockStates.size() > 0) { ++ worldserver.captureTreeGeneration = false; ++ if (worldserver.capturedBlockStates.size() > 0) { + TreeType treeType = BlockSapling.treeType; + BlockSapling.treeType = null; -+ Location location = new Location(world.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ()); -+ List blocks = new java.util.ArrayList<>(world.capturedBlockStates.values()); -+ world.capturedBlockStates.clear(); ++ Location location = new Location(worldserver.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ()); ++ List blocks = new java.util.ArrayList<>(worldserver.capturedBlockStates.values()); ++ worldserver.capturedBlockStates.clear(); + StructureGrowEvent structureEvent = null; + if (treeType != null) { + structureEvent = new StructureGrowEvent(location, treeType, false, null, blocks); @@ -423,21 +424,21 @@ return itemstack; } -@@ -404,11 +669,40 @@ +@@ -405,11 +670,40 @@ protected ItemStack a(ISourceBlock isourceblock, ItemStack itemstack) { - World world = isourceblock.getWorld(); + WorldServer worldserver = isourceblock.getWorld(); BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING)); -- EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(world, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, (EntityLiving) null); +- EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(worldserver, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, (EntityLiving) null); + // EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(world, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, (EntityLiving) null); + + // CraftBukkit start + ItemStack itemstack1 = itemstack.cloneAndSubtract(1); -+ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); ++ org.bukkit.block.Block block = worldserver.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); + CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); + + BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector((double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D)); + if (!BlockDispenser.eventFired) { -+ world.getServer().getPluginManager().callEvent(event); ++ worldserver.getServer().getPluginManager().callEvent(event); + } + + if (event.isCancelled()) { @@ -456,27 +457,27 @@ + } + } + -+ EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(world, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), (EntityLiving) null); ++ EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(worldserver, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), (EntityLiving) null); + // CraftBukkit end - world.addEntity(entitytntprimed); - world.playSound((EntityHuman) null, entitytntprimed.locX(), entitytntprimed.locY(), entitytntprimed.locZ(), SoundEffects.ENTITY_TNT_PRIMED, SoundCategory.BLOCKS, 1.0F, 1.0F); + worldserver.addEntity(entitytntprimed); + worldserver.playSound((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; } })); -@@ -432,6 +726,30 @@ +@@ -433,6 +727,30 @@ EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING); BlockPosition blockposition = isourceblock.getBlockPosition().shift(enumdirection); + // CraftBukkit start -+ org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); ++ org.bukkit.block.Block bukkitBlock = worldserver.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); ++ worldserver.getServer().getPluginManager().callEvent(event); + } + + if (event.isCancelled()) { @@ -494,20 +495,20 @@ + } + // CraftBukkit end + - if (world.isEmpty(blockposition) && BlockWitherSkull.b(world, blockposition, itemstack)) { - world.setTypeAndData(blockposition, (IBlockData) Blocks.WITHER_SKELETON_SKULL.getBlockData().set(BlockSkull.a, enumdirection.n() == EnumDirection.EnumAxis.Y ? 0 : enumdirection.opposite().get2DRotationValue() * 4), 3); - TileEntity tileentity = world.getTileEntity(blockposition); -@@ -456,6 +774,30 @@ + if (worldserver.isEmpty(blockposition) && BlockWitherSkull.b((World) worldserver, blockposition, itemstack)) { + worldserver.setTypeAndData(blockposition, (IBlockData) Blocks.WITHER_SKELETON_SKULL.getBlockData().set(BlockSkull.a, enumdirection.n() == EnumDirection.EnumAxis.Y ? 0 : enumdirection.opposite().get2DRotationValue() * 4), 3); + TileEntity tileentity = worldserver.getTileEntity(blockposition); +@@ -457,6 +775,30 @@ BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING)); BlockPumpkinCarved blockpumpkincarved = (BlockPumpkinCarved) Blocks.CARVED_PUMPKIN; + // CraftBukkit start -+ org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); ++ org.bukkit.block.Block bukkitBlock = worldserver.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); ++ worldserver.getServer().getPluginManager().callEvent(event); + } + + if (event.isCancelled()) { @@ -525,20 +526,20 @@ + } + // CraftBukkit end + - if (world.isEmpty(blockposition) && blockpumpkincarved.a((IWorldReader) world, blockposition)) { - if (!world.isClientSide) { - world.setTypeAndData(blockposition, blockpumpkincarved.getBlockData(), 3); -@@ -503,6 +845,30 @@ + if (worldserver.isEmpty(blockposition) && blockpumpkincarved.a((IWorldReader) worldserver, blockposition)) { + if (!worldserver.isClientSide) { + worldserver.setTypeAndData(blockposition, blockpumpkincarved.getBlockData(), 3); +@@ -504,6 +846,30 @@ BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING)); - IBlockData iblockdata = world.getType(blockposition); + IBlockData iblockdata = worldserver.getType(blockposition); + // CraftBukkit start -+ org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); ++ org.bukkit.block.Block bukkitBlock = worldserver.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); ++ worldserver.getServer().getPluginManager().callEvent(event); + } + + if (event.isCancelled()) { diff --git a/nms-patches/InventoryCraftResult.patch b/nms-patches/InventoryCraftResult.patch index 3724f90b6c..101edf7f59 100644 --- a/nms-patches/InventoryCraftResult.patch +++ b/nms-patches/InventoryCraftResult.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/InventoryCraftResult.java +++ b/net/minecraft/server/InventoryCraftResult.java -@@ -2,12 +2,50 @@ +@@ -2,6 +2,11 @@ import java.util.Iterator; import javax.annotation.Nullable; @@ -12,7 +12,8 @@ public class InventoryCraftResult implements IInventory, RecipeHolder { - private final NonNullList items; +@@ -9,6 +14,39 @@ + @Nullable private IRecipe b; + // CraftBukkit start diff --git a/nms-patches/ItemArmorStand.patch b/nms-patches/ItemArmorStand.patch index 4694e638ac..08a1a16f64 100644 --- a/nms-patches/ItemArmorStand.patch +++ b/nms-patches/ItemArmorStand.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/ItemArmorStand.java +++ b/net/minecraft/server/ItemArmorStand.java -@@ -27,6 +27,11 @@ +@@ -38,6 +38,11 @@ entityarmorstand.setPositionRotation(entityarmorstand.locX(), entityarmorstand.locY(), entityarmorstand.locZ(), f, 0.0F); this.a(entityarmorstand, world.random); diff --git a/nms-patches/ItemFireball.patch b/nms-patches/ItemFireball.patch index 9a5088ab91..e37ba4c975 100644 --- a/nms-patches/ItemFireball.patch +++ b/nms-patches/ItemFireball.patch @@ -17,7 +17,7 @@ flag = true; } else { blockposition = blockposition.shift(itemactioncontext.getClickedFace()); - if (BlockFireAbstract.a((GeneratorAccess) world, blockposition)) { + if (BlockFireAbstract.a(world, blockposition, itemactioncontext.f())) { + // 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) { diff --git a/nms-patches/ItemFlintAndSteel.patch b/nms-patches/ItemFlintAndSteel.patch index abb0dcabf6..967252e112 100644 --- a/nms-patches/ItemFlintAndSteel.patch +++ b/nms-patches/ItemFlintAndSteel.patch @@ -12,7 +12,7 @@ @@ -27,6 +27,14 @@ BlockPosition blockposition1 = blockposition.shift(itemactioncontext.getClickedFace()); - if (BlockFireAbstract.a((GeneratorAccess) world, blockposition1)) { + if (BlockFireAbstract.a(world, blockposition1, itemactioncontext.f())) { + // CraftBukkit start - Store the clicked block + if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition1, org.bukkit.event.block.BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL, entityhuman).isCancelled()) { + itemactioncontext.getItemStack().damage(1, entityhuman, (entityhuman1) -> { diff --git a/nms-patches/ItemMinecart.patch b/nms-patches/ItemMinecart.patch index 2859151776..8d59fb0f73 100644 --- a/nms-patches/ItemMinecart.patch +++ b/nms-patches/ItemMinecart.patch @@ -15,16 +15,16 @@ } } -- EntityMinecartAbstract entityminecartabstract = EntityMinecartAbstract.a(world, d0, d1 + d3, d2, ((ItemMinecart) itemstack.getItem()).b); +- EntityMinecartAbstract entityminecartabstract = EntityMinecartAbstract.a(worldserver, d0, d1 + d3, d2, ((ItemMinecart) itemstack.getItem()).b); + // CraftBukkit start + // EntityMinecartAbstract entityminecartabstract = EntityMinecartAbstract.a(world, d0, d1 + d3, d2, ((ItemMinecart) itemstack.getItem()).b); + ItemStack itemstack1 = itemstack.cloneAndSubtract(1); -+ org.bukkit.block.Block block2 = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); ++ org.bukkit.block.Block block2 = worldserver.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); + CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); + + BlockDispenseEvent event = new BlockDispenseEvent(block2, craftItem.clone(), new org.bukkit.util.Vector(d0, d1 + d3, d2)); + if (!BlockDispenser.eventFired) { -+ world.getServer().getPluginManager().callEvent(event); ++ worldserver.getServer().getPluginManager().callEvent(event); + } + + if (event.isCancelled()) { @@ -44,15 +44,15 @@ + } + + itemstack1 = CraftItemStack.asNMSCopy(event.getItem()); -+ EntityMinecartAbstract entityminecartabstract = EntityMinecartAbstract.a(world, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), ((ItemMinecart) itemstack1.getItem()).b); ++ EntityMinecartAbstract entityminecartabstract = EntityMinecartAbstract.a(worldserver, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), ((ItemMinecart) itemstack1.getItem()).b); if (itemstack.hasName()) { entityminecartabstract.setCustomName(itemstack.getName()); } -- world.addEntity(entityminecartabstract); +- worldserver.addEntity(entityminecartabstract); - itemstack.subtract(1); -+ if (!world.addEntity(entityminecartabstract)) itemstack.add(1); ++ if (!worldserver.addEntity(entityminecartabstract)) itemstack.add(1); + // itemstack.subtract(1); // CraftBukkit - handled during event processing + // CraftBukkit end return itemstack; diff --git a/nms-patches/ItemMonsterEgg.patch b/nms-patches/ItemMonsterEgg.patch index 1d6c210a63..7bec16728b 100644 --- a/nms-patches/ItemMonsterEgg.patch +++ b/nms-patches/ItemMonsterEgg.patch @@ -4,8 +4,8 @@ return Optional.empty(); } else { ((EntityInsentient) object).setPositionRotation(vec3d.getX(), vec3d.getY(), vec3d.getZ(), 0.0F, 0.0F); -- world.addEntity((Entity) object); -+ world.addEntity((Entity) object, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG); // CraftBukkit +- worldserver.addAllEntities((Entity) object); ++ worldserver.addAllEntities((Entity) object, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG); // CraftBukkit if (itemstack.hasName()) { ((EntityInsentient) object).setCustomName(itemstack.getName()); } diff --git a/nms-patches/ItemStack.patch b/nms-patches/ItemStack.patch index bc0fdfe2ae..b449157c1d 100644 --- a/nms-patches/ItemStack.patch +++ b/nms-patches/ItemStack.patch @@ -33,7 +33,7 @@ + public static final DecimalFormat c = (DecimalFormat) SystemUtils.a((new DecimalFormat("#.##")), (decimalformat) -> { // CraftBukkit - decompile error decimalformat.setDecimalFormatSymbols(DecimalFormatSymbols.getInstance(Locale.ROOT)); }); - private static final ChatModifier e = ChatModifier.b.setColor(EnumChatFormat.DARK_PURPLE).setItalic(true); + private static final ChatModifier e = ChatModifier.a.setColor(EnumChatFormat.DARK_PURPLE).setItalic(true); @@ -67,23 +85,42 @@ this.checkEmpty(); } @@ -296,7 +296,7 @@ public NBTTagCompound getOrCreateTag() { if (this.tag == null) { this.setTag(new NBTTagCompound()); -@@ -516,6 +725,12 @@ +@@ -522,6 +731,12 @@ } public void setRepairCost(int i) { @@ -309,7 +309,7 @@ this.getOrCreateTag().setInt("RepairCost", i); } -@@ -565,6 +780,13 @@ +@@ -571,6 +786,13 @@ nbttaglist.add(nbttagcompound); } diff --git a/nms-patches/LoginListener.patch b/nms-patches/LoginListener.patch index ec7a494182..bc361908f4 100644 --- a/nms-patches/LoginListener.patch +++ b/nms-patches/LoginListener.patch @@ -57,7 +57,7 @@ + // CraftBukkit end } else { this.g = LoginListener.EnumProtocolState.ACCEPTED; - if (this.server.av() >= 0 && !this.networkManager.isLocal()) { + if (this.server.aw() >= 0 && !this.networkManager.isLocal()) { @@ -97,9 +120,9 @@ if (entityplayer != null) { diff --git a/nms-patches/LootContextParameters.patch b/nms-patches/LootContextParameters.patch index d1a317952a..d2993800f8 100644 --- a/nms-patches/LootContextParameters.patch +++ b/nms-patches/LootContextParameters.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/LootContextParameters.java +++ b/net/minecraft/server/LootContextParameters.java -@@ -13,6 +13,7 @@ +@@ -12,6 +12,7 @@ public static final LootContextParameter BLOCK_ENTITY = a("block_entity"); public static final LootContextParameter TOOL = a("tool"); public static final LootContextParameter EXPLOSION_RADIUS = a("explosion_radius"); diff --git a/nms-patches/Main.patch b/nms-patches/Main.patch index 6a520368f3..3d3d6df7bb 100644 --- a/nms-patches/Main.patch +++ b/nms-patches/Main.patch @@ -10,7 +10,7 @@ OptionParser optionparser = new OptionParser(); OptionSpec optionspec = optionparser.accepts("nogui"); OptionSpec optionspec1 = optionparser.accepts("initSettings", "Initializes 'server.properties' and 'eula.txt', then quits"); -@@ -52,19 +53,21 @@ +@@ -52,20 +53,22 @@ optionparser.printHelpOn(System.err); return; } @@ -21,9 +21,10 @@ DispenserRegistry.init(); DispenserRegistry.c(); SystemUtils.l(); + IRegistryCustom.Dimension iregistrycustom_dimension = IRegistryCustom.b(); java.nio.file.Path java_nio_file_path = Paths.get("server.properties"); -- DedicatedServerSettings dedicatedserversettings = new DedicatedServerSettings(java_nio_file_path); -+ DedicatedServerSettings dedicatedserversettings = new DedicatedServerSettings(optionset); // CraftBukkit - CLI argument support +- DedicatedServerSettings dedicatedserversettings = new DedicatedServerSettings(iregistrycustom_dimension, java_nio_file_path); ++ DedicatedServerSettings dedicatedserversettings = new DedicatedServerSettings(iregistrycustom_dimension, optionset); // CraftBukkit - CLI argument support dedicatedserversettings.save(); java.nio.file.Path java_nio_file_path1 = Paths.get("eula.txt"); @@ -34,7 +35,7 @@ Main.LOGGER.info("Initialized '{}' and '{}'", java_nio_file_path.toAbsolutePath(), java_nio_file_path1.toAbsolutePath()); return; } -@@ -74,24 +77,42 @@ +@@ -75,24 +78,42 @@ return; } @@ -60,7 +61,7 @@ Main.LOGGER.warn("Safe mode active, only vanilla datapack will be loaded"); } - ResourcePackRepository resourcepackrepository = new ResourcePackRepository<>(ResourcePackLoader::new, new ResourcePackSource[]{new ResourcePackSourceVanilla(), new ResourcePackSourceFolder(convertable_conversionsession.getWorldFolder(SavedFile.DATAPACKS).toFile(), PackSource.c)}); + ResourcePackRepository resourcepackrepository = new ResourcePackRepository(new ResourcePackSource[]{new ResourcePackSourceVanilla(), new ResourcePackSourceFolder(convertable_conversionsession.getWorldFolder(SavedFile.DATAPACKS).toFile(), PackSource.c)}); + // CraftBukkit start + File bukkitDataPackFolder = new File(convertable_conversionsession.getWorldFolder(SavedFile.DATAPACKS).toFile(), "bukkit"); + if (!bukkitDataPackFolder.exists()) { @@ -82,11 +83,11 @@ CompletableFuture completablefuture = DataPackResources.a(resourcepackrepository.f(), CommandDispatcher.ServerType.DEDICATED, dedicatedserversettings.getProperties().functionPermissionLevel, SystemUtils.f(), Runnable::run); @@ -107,6 +128,7 @@ + } datapackresources.i(); - IRegistryCustom.Dimension iregistrycustom_dimension = IRegistryCustom.b(); + /* - RegistryReadOps registryreadops = RegistryReadOps.a((DynamicOps) DynamicOpsNBT.a, datapackresources.h(), (IRegistryCustom) iregistrycustom_dimension); + RegistryReadOps registryreadops = RegistryReadOps.a((DynamicOps) DynamicOpsNBT.a, datapackresources.h(), iregistrycustom_dimension); Object object = convertable_conversionsession.a((DynamicOps) registryreadops, datapackconfiguration1); @@ -134,21 +156,32 @@ @@ -108,7 +109,7 @@ + boolean flag1 = !optionset.has("nogui") && !optionset.nonOptionArguments().contains("nogui"); if (flag1 && !GraphicsEnvironment.isHeadless()) { - dedicatedserver1.bb(); + dedicatedserver1.bc(); } + if (optionset.has("port")) { diff --git a/nms-patches/MinecraftServer.patch b/nms-patches/MinecraftServer.patch index fee1d6563e..d04a9f7419 100644 --- a/nms-patches/MinecraftServer.patch +++ b/nms-patches/MinecraftServer.patch @@ -67,10 +67,10 @@ return s0; } -- public MinecraftServer(Thread thread, IRegistryCustom.Dimension iregistrycustom_dimension, Convertable.ConversionSession convertable_conversionsession, SaveData savedata, ResourcePackRepository resourcepackrepository, Proxy proxy, DataFixer datafixer, DataPackResources datapackresources, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache, WorldLoadListenerFactory worldloadlistenerfactory) { -+ public MinecraftServer(OptionSet options, DataPackConfiguration datapackconfiguration, Thread thread, IRegistryCustom.Dimension iregistrycustom_dimension, Convertable.ConversionSession convertable_conversionsession, SaveData savedata, ResourcePackRepository resourcepackrepository, Proxy proxy, DataFixer datafixer, DataPackResources datapackresources, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache, WorldLoadListenerFactory worldloadlistenerfactory) { +- public MinecraftServer(Thread thread, IRegistryCustom.Dimension iregistrycustom_dimension, Convertable.ConversionSession convertable_conversionsession, SaveData savedata, ResourcePackRepository resourcepackrepository, Proxy proxy, DataFixer datafixer, DataPackResources datapackresources, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache, WorldLoadListenerFactory worldloadlistenerfactory) { ++ public MinecraftServer(OptionSet options, DataPackConfiguration datapackconfiguration, Thread thread, IRegistryCustom.Dimension iregistrycustom_dimension, Convertable.ConversionSession convertable_conversionsession, SaveData savedata, ResourcePackRepository resourcepackrepository, Proxy proxy, DataFixer datafixer, DataPackResources datapackresources, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache, WorldLoadListenerFactory worldloadlistenerfactory) { super("Server"); - this.m = new GameProfilerSwitcher(SystemUtils.a, this::ag); + this.m = new GameProfilerSwitcher(SystemUtils.a, this::ah); this.methodProfiler = GameProfilerDisabled.a; this.serverPing = new ServerPing(); this.r = new Random(); @@ -124,7 +124,7 @@ convertable_conversionsession.convert(new IProgressUpdate() { private long a = SystemUtils.getMonotonicMillis(); -@@ -209,48 +261,187 @@ +@@ -209,45 +261,184 @@ } @@ -213,7 +213,7 @@ + + IRegistryCustom.Dimension iregistrycustom_dimension = IRegistryCustom.b(); + -+ RegistryReadOps registryreadops = RegistryReadOps.a((DynamicOps) DynamicOpsNBT.a, this.dataPackResources.h(), (IRegistryCustom) iregistrycustom_dimension); ++ RegistryReadOps registryreadops = RegistryReadOps.a((DynamicOps) DynamicOpsNBT.a, this.dataPackResources.h(), iregistrycustom_dimension); + worlddata = (WorldDataServer) worldSession.a((DynamicOps) registryreadops, datapackconfiguration); + if (worlddata == null) { + WorldSettings worldsettings; @@ -221,12 +221,12 @@ + + if (this.isDemoMode()) { + worldsettings = MinecraftServer.c; -+ generatorsettings = GeneratorSettings.b; ++ generatorsettings = GeneratorSettings.a((IRegistryCustom) iregistrycustom_dimension); + } else { + DedicatedServerProperties dedicatedserverproperties = ((DedicatedServer) this).getDedicatedServerProperties(); + + worldsettings = new WorldSettings(dedicatedserverproperties.levelName, dedicatedserverproperties.gamemode, dedicatedserverproperties.hardcore, dedicatedserverproperties.difficulty, false, new GameRules(), datapackconfiguration); -+ generatorsettings = options.has("bonusChest") ? dedicatedserverproperties.generatorSettings.k() : dedicatedserverproperties.generatorSettings; ++ generatorsettings = options.has("bonusChest") ? dedicatedserverproperties.generatorSettings.j() : dedicatedserverproperties.generatorSettings; + } + + worlddata = new WorldDataServer(worldsettings, generatorsettings, Lifecycle.stable()); @@ -235,8 +235,8 @@ + if (options.has("forceUpgrade")) { + net.minecraft.server.Main.convertWorld(worldSession, DataConverterRegistry.a(), options.has("eraseCache"), () -> { + return true; -+ }, worlddata.getGeneratorSettings().e().c().stream().map((entry) -> { -+ return ResourceKey.a(IRegistry.ad, ((ResourceKey) entry.getKey()).a()); ++ }, worlddata.getGeneratorSettings().d().d().stream().map((entry) -> { ++ return ResourceKey.a(IRegistry.K, ((ResourceKey) entry.getKey()).a()); + }).collect(ImmutableSet.toImmutableSet())); + } + @@ -246,38 +246,36 @@ + long i = generatorsettings.getSeed(); + long j = BiomeManager.a(i); + List list = ImmutableList.of(new MobSpawnerPhantom(), new MobSpawnerPatrol(), new MobSpawnerCat(), new VillageSiege(), new MobSpawnerTrader(iworlddataserver)); -+ RegistryMaterials registrymaterials = generatorsettings.e(); ++ RegistryMaterials registrymaterials = generatorsettings.d(); + WorldDimension worlddimension = (WorldDimension) registrymaterials.a(dimensionKey); + DimensionManager dimensionmanager; + ChunkGenerator chunkgenerator; + + if (worlddimension == null) { -+ dimensionmanager = DimensionManager.a(); -+ chunkgenerator = GeneratorSettings.a((new Random()).nextLong()); ++ dimensionmanager = (DimensionManager) this.f.a().d(DimensionManager.OVERWORLD); ++ chunkgenerator = GeneratorSettings.a(this.f.b(IRegistry.ay), this.f.b(IRegistry.ar), (new Random()).nextLong()); + } else { + dimensionmanager = worlddimension.b(); + chunkgenerator = worlddimension.c(); + } + -+ ResourceKey typeKey = (ResourceKey) this.f.a().c(dimensionmanager).orElseThrow(() -> { -+ return new IllegalStateException("Unregistered dimension type: " + dimensionmanager); -+ }); -+ ResourceKey worldKey = ResourceKey.a(IRegistry.ae, dimensionKey.a()); -+ ++ ResourceKey worldKey = ResourceKey.a(IRegistry.L, dimensionKey.a()); + +- this.a(worldloadlistener); + if (worldId == 0) { + this.saveData = worlddata; + this.saveData.setGameType(((DedicatedServer) this).getDedicatedServerProperties().gamemode); // From DedicatedServer.init + + WorldLoadListener worldloadlistener = this.worldLoadListenerFactory.create(11); + -+ world = new WorldServer(this, this.executorService, worldSession, iworlddataserver, worldKey, typeKey, dimensionmanager, worldloadlistener, chunkgenerator, flag, j, list, true, org.bukkit.World.Environment.getEnvironment(dimension), gen); ++ world = new WorldServer(this, this.executorService, worldSession, iworlddataserver, worldKey, dimensionmanager, worldloadlistener, chunkgenerator, flag, j, list, true, org.bukkit.World.Environment.getEnvironment(dimension), gen); + WorldPersistentData worldpersistentdata = world.getWorldPersistentData(); + this.initializeScoreboards(worldpersistentdata); + this.server.scoreboardManager = new org.bukkit.craftbukkit.scoreboard.CraftScoreboardManager(this, world.getScoreboard()); + this.persistentCommandStorage = new PersistentCommandStorage(worldpersistentdata); + } else { + WorldLoadListener worldloadlistener = this.worldLoadListenerFactory.create(11); -+ world = new WorldServer(this, this.executorService, worldSession, iworlddataserver, worldKey, typeKey, dimensionmanager, worldloadlistener, chunkgenerator, flag, j, ImmutableList.of(), true, org.bukkit.World.Environment.getEnvironment(dimension), gen); ++ world = new WorldServer(this, this.executorService, worldSession, iworlddataserver, worldKey, dimensionmanager, worldloadlistener, chunkgenerator, flag, j, ImmutableList.of(), true, org.bukkit.World.Environment.getEnvironment(dimension), gen); + } + + worlddata.a(this.getServerModName(), this.getModded().isPresent()); @@ -286,8 +284,7 @@ + + this.worldServer.put(world.getDimensionKey(), world); + this.getPlayerList().setPlayerFileData(world); - -- this.a(worldloadlistener); ++ + if (worlddata.getCustomBossEvents() != null) { + this.getBossBattleCustomData().load(worlddata.getCustomBossEvents()); + } @@ -309,7 +306,7 @@ protected void updateWorldSettings() {} - protected void a(WorldLoadListener worldloadlistener) { -- IWorldDataServer iworlddataserver = this.saveData.G(); +- IWorldDataServer iworlddataserver = this.saveData.H(); - GeneratorSettings generatorsettings = this.saveData.getGeneratorSettings(); + // CraftBukkit start + public void initWorld(WorldServer worldserver, IWorldDataServer iworlddataserver, SaveData saveData, GeneratorSettings generatorsettings) { @@ -317,14 +314,14 @@ - long i = generatorsettings.getSeed(); - long j = BiomeManager.a(i); - List list = ImmutableList.of(new MobSpawnerPhantom(), new MobSpawnerPatrol(), new MobSpawnerCat(), new VillageSiege(), new MobSpawnerTrader(iworlddataserver)); -- RegistryMaterials registrymaterials = generatorsettings.e(); +- RegistryMaterials registrymaterials = generatorsettings.d(); - WorldDimension worlddimension = (WorldDimension) registrymaterials.a(WorldDimension.OVERWORLD); - DimensionManager dimensionmanager; - Object object; - - if (worlddimension == null) { -- dimensionmanager = DimensionManager.a(); -- object = GeneratorSettings.a((new Random()).nextLong()); +- dimensionmanager = (DimensionManager) this.f.a().d(DimensionManager.OVERWORLD); +- object = GeneratorSettings.a(this.f.b(IRegistry.ay), this.f.b(IRegistry.ar), (new Random()).nextLong()); - } else { - dimensionmanager = worlddimension.b(); - object = worlddimension.c(); @@ -333,10 +330,7 @@ + worldserver.getWorld().getPopulators().addAll(worldserver.generator.getDefaultPopulators(worldserver.getWorld())); } - -- ResourceKey resourcekey = (ResourceKey) this.f.a().c((Object) dimensionmanager).orElseThrow(() -> { -- return new IllegalStateException("Unregistered dimension type: " + dimensionmanager); -- }); -- WorldServer worldserver = new WorldServer(this, this.executorService, this.convertable, iworlddataserver, World.OVERWORLD, resourcekey, dimensionmanager, worldloadlistener, (ChunkGenerator) object, flag, j, list, true); +- WorldServer worldserver = new WorldServer(this, this.executorService, this.convertable, iworlddataserver, World.OVERWORLD, dimensionmanager, worldloadlistener, (ChunkGenerator) object, flag, j, list, true); - - this.worldServer.put(World.OVERWORLD, worldserver); - WorldPersistentData worldpersistentdata = worldserver.getWorldPersistentData(); @@ -345,8 +339,8 @@ - this.persistentCommandStorage = new PersistentCommandStorage(worldpersistentdata); WorldBorder worldborder = worldserver.getWorldBorder(); - worldborder.a(iworlddataserver.q()); -@@ -275,34 +466,8 @@ + worldborder.a(iworlddataserver.r()); +@@ -272,31 +463,8 @@ iworlddataserver.c(true); } @@ -356,24 +350,21 @@ - this.getBossBattleCustomData().load(this.saveData.getCustomBossEvents()); - } - -- Iterator iterator = registrymaterials.c().iterator(); +- Iterator iterator = registrymaterials.d().iterator(); - - while (iterator.hasNext()) { - Entry, WorldDimension> entry = (Entry) iterator.next(); -- ResourceKey resourcekey1 = (ResourceKey) entry.getKey(); +- ResourceKey resourcekey = (ResourceKey) entry.getKey(); - -- if (resourcekey1 != WorldDimension.OVERWORLD) { -- ResourceKey resourcekey2 = ResourceKey.a(IRegistry.ae, resourcekey1.a()); +- if (resourcekey != WorldDimension.OVERWORLD) { +- ResourceKey resourcekey1 = ResourceKey.a(IRegistry.L, resourcekey.a()); - DimensionManager dimensionmanager1 = ((WorldDimension) entry.getValue()).b(); -- ResourceKey resourcekey3 = (ResourceKey) this.f.a().c((Object) dimensionmanager1).orElseThrow(() -> { -- return new IllegalStateException("Unregistered dimension type: " + dimensionmanager1); -- }); - ChunkGenerator chunkgenerator = ((WorldDimension) entry.getValue()).c(); - SecondaryWorldData secondaryworlddata = new SecondaryWorldData(this.saveData, iworlddataserver); -- WorldServer worldserver1 = new WorldServer(this, this.executorService, this.convertable, secondaryworlddata, resourcekey2, resourcekey3, dimensionmanager1, worldloadlistener, chunkgenerator, flag, j, ImmutableList.of(), false); +- WorldServer worldserver1 = new WorldServer(this, this.executorService, this.convertable, secondaryworlddata, resourcekey1, dimensionmanager1, worldloadlistener, chunkgenerator, flag, j, ImmutableList.of(), false); - - worldborder.a((IWorldBorderListener) (new IWorldBorderListener.a(worldserver1.getWorldBorder()))); -- this.worldServer.put(resourcekey2, worldserver1); +- this.worldServer.put(resourcekey1, worldserver1); - } - } - @@ -382,9 +373,9 @@ private static void a(WorldServer worldserver, IWorldDataServer iworlddataserver, boolean flag, boolean flag1, boolean flag2) { ChunkGenerator chunkgenerator = worldserver.getChunkProvider().getChunkGenerator(); -@@ -317,6 +482,21 @@ - Random random = new Random(worldserver.getSeed()); - BlockPosition blockposition = worldchunkmanager.a(0, worldserver.getSeaLevel(), 0, 256, list, random); +@@ -312,6 +480,21 @@ + return biomebase.b().b(); + }, random); ChunkCoordIntPair chunkcoordintpair = blockposition == null ? new ChunkCoordIntPair(0, 0) : new ChunkCoordIntPair(blockposition); + // CraftBukkit start + if (worldserver.generator != null) { @@ -395,7 +386,7 @@ + if (spawn.getWorld() != worldserver.getWorld()) { + throw new IllegalStateException("Cannot set spawn point for " + iworlddataserver.getName() + " to be in another world (" + spawn.getWorld().getName() + ")"); + } else { -+ iworlddataserver.setSpawn(new BlockPosition(spawn.getBlockX(), spawn.getBlockY(), spawn.getBlockZ())); ++ iworlddataserver.setSpawn(new BlockPosition(spawn.getBlockX(), spawn.getBlockY(), spawn.getBlockZ()), spawn.getYaw()); + return; + } + } @@ -404,34 +395,25 @@ if (blockposition == null) { MinecraftServer.LOGGER.warn("Unable to find spawn biome"); -@@ -363,7 +543,7 @@ - } - - if (flag) { -- WorldGenFeatureConfigured worldgenfeatureconfigured = WorldGenerator.BONUS_CHEST.b((WorldGenFeatureConfiguration) WorldGenFeatureConfiguration.k); -+ WorldGenFeatureConfigured worldgenfeatureconfigured = WorldGenerator.BONUS_CHEST.b(WorldGenFeatureConfiguration.k); // CraftBukkit - decompile error - - worldgenfeatureconfigured.a(worldserver, worldserver.getStructureManager(), chunkgenerator, worldserver.random, new BlockPosition(iworlddataserver.a(), iworlddataserver.b(), iworlddataserver.c())); - } -@@ -383,8 +563,15 @@ +@@ -378,8 +561,15 @@ iworlddataserver.setGameType(EnumGamemode.SPECTATOR); } - public void loadSpawn(WorldLoadListener worldloadlistener) { -- WorldServer worldserver = this.D(); +- WorldServer worldserver = this.E(); + // CraftBukkit start + public void loadSpawn(WorldLoadListener worldloadlistener, WorldServer worldserver) { + if (!worldserver.getWorld().getKeepSpawnInMemory()) { + return; + } + -+ // WorldServer worldserver = this.D(); ++ // WorldServer worldserver = this.E(); + this.forceTicks = true; + // CraftBukkit end MinecraftServer.LOGGER.info("Preparing start region for dimension {}", worldserver.getDimensionKey().a()); BlockPosition blockposition = worldserver.getSpawn(); -@@ -397,17 +584,21 @@ +@@ -392,17 +582,21 @@ chunkproviderserver.addTicket(TicketType.START, new ChunkCoordIntPair(blockposition), 11, Unit.INSTANCE); while (chunkproviderserver.b() != 441) { @@ -462,7 +444,7 @@ if (forcedchunk != null) { LongIterator longiterator = forcedchunk.a().iterator(); -@@ -421,11 +612,17 @@ +@@ -416,11 +610,17 @@ } } @@ -474,7 +456,7 @@ + // CraftBukkit end worldloadlistener.b(); chunkproviderserver.getLightEngine().a(5); - this.ba(); + this.bb(); + + // CraftBukkit start + this.forceTicks = false; @@ -482,14 +464,14 @@ } protected void loadResourcesZip() { -@@ -470,12 +667,16 @@ +@@ -465,12 +665,16 @@ worldserver.save((IProgressUpdate) null, flag1, worldserver.savingDisabled && !flag2); } + // CraftBukkit start - moved to WorldServer.save + /* - WorldServer worldserver1 = this.D(); - IWorldDataServer iworlddataserver = this.saveData.G(); + WorldServer worldserver1 = this.E(); + IWorldDataServer iworlddataserver = this.saveData.H(); iworlddataserver.a(worldserver1.getWorldBorder().t()); this.saveData.setCustomBossEvents(this.getBossBattleCustomData().save()); @@ -499,7 +481,7 @@ return flag3; } -@@ -484,8 +685,29 @@ +@@ -479,8 +683,29 @@ this.stop(); } @@ -529,7 +511,7 @@ if (this.getServerConnection() != null) { this.getServerConnection().b(); } -@@ -494,6 +716,7 @@ +@@ -489,6 +714,7 @@ MinecraftServer.LOGGER.info("Saving players"); this.playerList.savePlayers(); this.playerList.shutdown(); @@ -537,7 +519,7 @@ } MinecraftServer.LOGGER.info("Saving worlds"); -@@ -571,14 +794,16 @@ +@@ -566,14 +792,16 @@ while (this.isRunning) { long i = SystemUtils.getMonotonicMillis() - this.nextTick; @@ -555,7 +537,7 @@ this.nextTick += 50L; GameProfilerTick gameprofilertick = GameProfilerTick.a("Server"); -@@ -624,6 +849,12 @@ +@@ -619,6 +847,12 @@ } catch (Throwable throwable1) { MinecraftServer.LOGGER.error("Exception stopping the server", throwable1); } finally { @@ -568,7 +550,7 @@ this.exit(); } -@@ -632,8 +863,15 @@ +@@ -627,8 +861,15 @@ } private boolean canSleepForTick() { @@ -585,7 +567,7 @@ protected void sleepForTick() { this.executeAll(); -@@ -739,7 +977,7 @@ +@@ -734,7 +975,7 @@ this.serverPing.b().a(agameprofile); } @@ -594,7 +576,7 @@ MinecraftServer.LOGGER.debug("Autosave started"); this.methodProfiler.enter("save"); this.playerList.savePlayers(); -@@ -769,22 +1007,39 @@ +@@ -764,22 +1005,39 @@ } protected void b(BooleanSupplier booleansupplier) { @@ -634,7 +616,7 @@ this.methodProfiler.enter("tick"); -@@ -868,7 +1123,7 @@ +@@ -863,7 +1121,7 @@ } public String getServerModName() { @@ -643,7 +625,7 @@ } public CrashReport b(CrashReport crashreport) { -@@ -1217,16 +1472,17 @@ +@@ -1214,16 +1472,17 @@ public CompletableFuture a(Collection collection) { CompletableFuture completablefuture = CompletableFuture.supplyAsync(() -> { @@ -663,7 +645,7 @@ this.resourcePackRepository.a(collection); this.saveData.a(a(this.resourcePackRepository)); datapackresources.i(); -@@ -1592,6 +1848,22 @@ +@@ -1589,6 +1848,22 @@ } diff --git a/nms-patches/MobSpawnerAbstract.patch b/nms-patches/MobSpawnerAbstract.patch index 6703cfdee5..7f76c8baba 100644 --- a/nms-patches/MobSpawnerAbstract.patch +++ b/nms-patches/MobSpawnerAbstract.patch @@ -8,12 +8,12 @@ } private boolean h() { -@@ -148,7 +149,7 @@ - } +@@ -132,7 +133,7 @@ + } + } - private void a(Entity entity) { -- if (this.a().addEntity(entity)) { -+ if (this.a().addEntity(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER)) { // CraftBukkit - Iterator iterator = entity.getPassengers().iterator(); - - while (iterator.hasNext()) { +- if (!worldserver.addAllEntitiesSafely(entity)) { ++ if (!worldserver.addAllEntitiesSafely(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER)) { // CraftBukkit + this.i(); + return; + } diff --git a/nms-patches/MobSpawnerPatrol.patch b/nms-patches/MobSpawnerPatrol.patch index 7f65850365..dc224a1ccd 100644 --- a/nms-patches/MobSpawnerPatrol.patch +++ b/nms-patches/MobSpawnerPatrol.patch @@ -3,9 +3,9 @@ @@ -102,7 +102,7 @@ entitymonsterpatrolling.setPosition((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ()); - entitymonsterpatrolling.prepare(world, world.getDamageScaler(blockposition), EnumMobSpawn.PATROL, (GroupDataEntity) null, (NBTTagCompound) null); -- world.addEntity(entitymonsterpatrolling); -+ world.addEntity(entitymonsterpatrolling, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.PATROL); // CraftBukkit + entitymonsterpatrolling.prepare(worldserver, worldserver.getDamageScaler(blockposition), EnumMobSpawn.PATROL, (GroupDataEntity) null, (NBTTagCompound) null); +- worldserver.addAllEntities(entitymonsterpatrolling); ++ worldserver.addAllEntities(entitymonsterpatrolling, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.PATROL); // CraftBukkit return true; } else { return false; diff --git a/nms-patches/MobSpawnerPhantom.patch b/nms-patches/MobSpawnerPhantom.patch index a554bae1a8..899a76a429 100644 --- a/nms-patches/MobSpawnerPhantom.patch +++ b/nms-patches/MobSpawnerPhantom.patch @@ -4,8 +4,8 @@ entityphantom.setPositionRotation(blockposition1, 0.0F, 0.0F); groupdataentity = entityphantom.prepare(worldserver, difficultydamagescaler, EnumMobSpawn.NATURAL, groupdataentity, (NBTTagCompound) null); -- worldserver.addEntity(entityphantom); -+ worldserver.addEntity(entityphantom, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); // CraftBukkit +- worldserver.addAllEntities(entityphantom); ++ worldserver.addAllEntities(entityphantom, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); // CraftBukkit } i += k; diff --git a/nms-patches/MobSpawnerTrader.patch b/nms-patches/MobSpawnerTrader.patch index 575e45215f..7065f27da6 100644 --- a/nms-patches/MobSpawnerTrader.patch +++ b/nms-patches/MobSpawnerTrader.patch @@ -10,11 +10,11 @@ if (entityvillagertrader != null) { for (int i = 0; i < 2; ++i) { @@ -106,7 +106,7 @@ - BlockPosition blockposition = this.a(entityvillagertrader.world, entityvillagertrader.getChunkCoordinates(), i); + BlockPosition blockposition = this.a((IWorldReader) worldserver, entityvillagertrader.getChunkCoordinates(), i); if (blockposition != null) { -- EntityLlamaTrader entityllamatrader = (EntityLlamaTrader) EntityTypes.TRADER_LLAMA.spawnCreature(entityvillagertrader.world, (NBTTagCompound) null, (IChatBaseComponent) null, (EntityHuman) null, blockposition, EnumMobSpawn.EVENT, false, false); -+ EntityLlamaTrader entityllamatrader = (EntityLlamaTrader) EntityTypes.TRADER_LLAMA.spawnCreature(entityvillagertrader.world, (NBTTagCompound) null, (IChatBaseComponent) null, (EntityHuman) null, blockposition, EnumMobSpawn.EVENT, false, false, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); // CraftBukkit +- EntityLlamaTrader entityllamatrader = (EntityLlamaTrader) EntityTypes.TRADER_LLAMA.spawnCreature(worldserver, (NBTTagCompound) null, (IChatBaseComponent) null, (EntityHuman) null, blockposition, EnumMobSpawn.EVENT, false, false); ++ EntityLlamaTrader entityllamatrader = (EntityLlamaTrader) EntityTypes.TRADER_LLAMA.spawnCreature(worldserver, (NBTTagCompound) null, (IChatBaseComponent) null, (EntityHuman) null, blockposition, EnumMobSpawn.EVENT, false, false, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); // CraftBukkit if (entityllamatrader != null) { entityllamatrader.setLeashHolder(entityvillagertrader, true); diff --git a/nms-patches/NetworkManager.patch b/nms-patches/NetworkManager.patch index ce04c3cf06..9f540d23c2 100644 --- a/nms-patches/NetworkManager.patch +++ b/nms-patches/NetworkManager.patch @@ -9,7 +9,7 @@ } public void setPacketListener(PacketListener packetlistener) { -@@ -233,7 +233,7 @@ +@@ -237,7 +237,7 @@ public void close(IChatBaseComponent ichatbasecomponent) { if (this.channel.isOpen()) { diff --git a/nms-patches/PacketDataSerializer.patch b/nms-patches/PacketDataSerializer.patch index 4c1bd0f0a4..2cf9923c06 100644 --- a/nms-patches/PacketDataSerializer.patch +++ b/nms-patches/PacketDataSerializer.patch @@ -27,7 +27,7 @@ throw new EncoderException(ioexception); } } -@@ -258,7 +260,7 @@ +@@ -268,7 +270,7 @@ } public PacketDataSerializer a(ItemStack itemstack) { @@ -36,7 +36,7 @@ this.writeBoolean(false); } else { this.writeBoolean(true); -@@ -287,6 +289,11 @@ +@@ -297,6 +299,11 @@ ItemStack itemstack = new ItemStack(Item.getById(i), b0); itemstack.setTag(this.l()); diff --git a/nms-patches/PacketPlayOutWorldBorder.patch b/nms-patches/PacketPlayOutWorldBorder.patch index f55857a473..90fd6b81e0 100644 --- a/nms-patches/PacketPlayOutWorldBorder.patch +++ b/nms-patches/PacketPlayOutWorldBorder.patch @@ -7,8 +7,8 @@ - this.c = worldborder.getCenterX(); - this.d = worldborder.getCenterZ(); + // CraftBukkit start - multiply out nether border -+ this.c = worldborder.getCenterX() * (worldborder.world.getDimensionManager().h() ? 8 : 1); -+ this.d = worldborder.getCenterZ() * (worldborder.world.getDimensionManager().h() ? 8 : 1); ++ this.c = worldborder.getCenterX() * worldborder.world.getDimensionManager().getCoordinateScale(); ++ this.d = worldborder.getCenterZ() * worldborder.world.getDimensionManager().getCoordinateScale(); + // CraftBukkit end this.f = worldborder.getSize(); this.e = worldborder.k(); diff --git a/nms-patches/PathfinderGoalHorseTrap.patch b/nms-patches/PathfinderGoalHorseTrap.patch index ad62e15112..85c0858fbf 100644 --- a/nms-patches/PathfinderGoalHorseTrap.patch +++ b/nms-patches/PathfinderGoalHorseTrap.patch @@ -1,15 +1,17 @@ --- a/net/minecraft/server/PathfinderGoalHorseTrap.java +++ b/net/minecraft/server/PathfinderGoalHorseTrap.java -@@ -24,16 +24,17 @@ +@@ -25,19 +25,20 @@ entitylightning.teleportAndSync(this.a.locX(), this.a.locY(), this.a.locZ()); entitylightning.setEffect(true); -- this.a.world.addEntity(entitylightning); -+ ((WorldServer) this.a.world).strikeLightning(entitylightning, org.bukkit.event.weather.LightningStrikeEvent.Cause.TRAP); // CraftBukkit +- worldserver.addEntity(entitylightning); ++ worldserver.strikeLightning(entitylightning, org.bukkit.event.weather.LightningStrikeEvent.Cause.TRAP); // CraftBukkit EntitySkeleton entityskeleton = this.a(difficultydamagescaler, this.a); - entityskeleton.startRiding(this.a); +- worldserver.addAllEntities(entityskeleton); + if (entityskeleton != null) entityskeleton.startRiding(this.a); // CraftBukkit ++ worldserver.addAllEntities(entityskeleton, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.TRAP); // CraftBukkit for (int i = 0; i < 3; ++i) { EntityHorseAbstract entityhorseabstract = this.a(difficultydamagescaler); @@ -18,24 +20,9 @@ - entityskeleton1.startRiding(entityhorseabstract); + if (entityskeleton1 != null) entityskeleton1.startRiding(entityhorseabstract); // CraftBukkit - entityhorseabstract.h(this.a.getRandom().nextGaussian() * 0.5D, 0.0D, this.a.getRandom().nextGaussian() * 0.5D); + entityhorseabstract.i(this.a.getRandom().nextGaussian() * 0.5D, 0.0D, this.a.getRandom().nextGaussian() * 0.5D); +- worldserver.addAllEntities(entityhorseabstract); ++ worldserver.addAllEntities(entityhorseabstract, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.JOCKEY); // CraftBukkit } -@@ -48,7 +49,7 @@ - entityhorseskeleton.setPersistent(); - entityhorseskeleton.setTamed(true); - entityhorseskeleton.setAgeRaw(0); -- entityhorseskeleton.world.addEntity(entityhorseskeleton); -+ if (!entityhorseskeleton.world.addEntity(entityhorseskeleton, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.TRAP)) return null; // CraftBukkit - return entityhorseskeleton; } - -@@ -65,7 +66,7 @@ - - entityskeleton.setSlot(EnumItemSlot.MAINHAND, EnchantmentManager.a(entityskeleton.getRandom(), entityskeleton.getItemInMainHand(), (int) (5.0F + difficultydamagescaler.d() * (float) entityskeleton.getRandom().nextInt(18)), false)); - entityskeleton.setSlot(EnumItemSlot.HEAD, EnchantmentManager.a(entityskeleton.getRandom(), entityskeleton.getEquipment(EnumItemSlot.HEAD), (int) (5.0F + difficultydamagescaler.d() * (float) entityskeleton.getRandom().nextInt(18)), false)); -- entityskeleton.world.addEntity(entityskeleton); -+ if (!entityskeleton.world.addEntity(entityskeleton, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.JOCKEY)) return null; // CraftBukkit - return entityskeleton; - } - } diff --git a/nms-patches/PathfinderGoalSit.patch b/nms-patches/PathfinderGoalSit.patch index d372bc16f7..7d6e8df64d 100644 --- a/nms-patches/PathfinderGoalSit.patch +++ b/nms-patches/PathfinderGoalSit.patch @@ -6,6 +6,6 @@ if (!this.entity.isTamed()) { - return false; + return this.entity.isWillSit() && this.entity.getGoalTarget() == null; // CraftBukkit - Allow sitting for wild animals - } else if (this.entity.aD()) { + } else if (this.entity.aG()) { return false; } else if (!this.entity.isOnGround()) { diff --git a/nms-patches/PiglinAI.patch b/nms-patches/PiglinAI.patch index 5b7a5c5f69..1e1657bcf4 100644 --- a/nms-patches/PiglinAI.patch +++ b/nms-patches/PiglinAI.patch @@ -3,10 +3,10 @@ @@ -52,7 +52,8 @@ private static void b(EntityPiglin entitypiglin, BehaviorController behaviorcontroller) { behaviorcontroller.a(Activity.FLIGHT, 10, ImmutableList.of(new BehaviorAttackTargetForget<>((entityliving) -> { - return !d(entitypiglin, entityliving); -- }), new BehaviorRunIf<>(PiglinAI::c, new BehaviorRetreat<>(5, 0.75F)), new BehaviorWalkAwayOutOfRange(1.0F), new BehaviorAttack(20), new BehaviorCrossbowAttack<>(), new BehaviorRememberHuntedHoglin<>(), new BehaviorRemoveMemory<>(PiglinAI::n, MemoryModuleType.ATTACK_TARGET)), MemoryModuleType.ATTACK_TARGET); + return !b(entitypiglin, entityliving); +- }), new BehaviorRunIf<>(PiglinAI::c, new BehaviorRetreat<>(5, 0.75F)), new BehaviorWalkAwayOutOfRange(1.0F), new BehaviorAttack(20), new BehaviorCrossbowAttack<>(), new BehaviorRememberHuntedHoglin<>(), new BehaviorRemoveMemory<>(PiglinAI::j, MemoryModuleType.ATTACK_TARGET)), MemoryModuleType.ATTACK_TARGET); + // CraftBukkit - decompile error -+ }), new BehaviorRunIf<>((l) -> PiglinAI.c((EntityLiving) l), new BehaviorRetreat<>(5, 0.75F)), new BehaviorWalkAwayOutOfRange(1.0F), new BehaviorAttack(20), new BehaviorCrossbowAttack<>(), new BehaviorRememberHuntedHoglin<>(), new BehaviorRemoveMemory<>(PiglinAI::n, MemoryModuleType.ATTACK_TARGET)), MemoryModuleType.ATTACK_TARGET); ++ }), new BehaviorRunIf<>((l) -> PiglinAI.c((EntityLiving) l), new BehaviorRetreat<>(5, 0.75F)), new BehaviorWalkAwayOutOfRange(1.0F), new BehaviorAttack(20), new BehaviorCrossbowAttack<>(), new BehaviorRememberHuntedHoglin<>(), new BehaviorRemoveMemory<>(PiglinAI::j, MemoryModuleType.ATTACK_TARGET)), MemoryModuleType.ATTACK_TARGET); } private static void c(BehaviorController behaviorcontroller) { @@ -44,7 +44,7 @@ if (activity != activity1) { d(entitypiglin).ifPresent(entitypiglin::a); @@ -130,14 +133,18 @@ - s(entitypiglin); + n(entitypiglin); ItemStack itemstack; - if (entityitem.getItemStack().getItem() == Items.GOLD_NUGGET) { @@ -64,25 +64,34 @@ Item item = itemstack.getItem(); -@@ -147,7 +154,7 @@ - } else if (c(item) && !A(entitypiglin)) { - y(entitypiglin); +@@ -148,7 +155,7 @@ + } else if (c(item) && !u(entitypiglin)) { + s(entitypiglin); } else { - boolean flag = entitypiglin.g(itemstack); + boolean flag = entitypiglin.g(itemstack, entityitem); // CraftBukkit if (!flag) { d(entitypiglin, itemstack); -@@ -583,7 +590,7 @@ +@@ -350,7 +357,7 @@ + } + + public static void a(EntityHuman entityhuman, boolean flag) { +- List list = entityhuman.world.a(EntityPiglin.class, entityhuman.getBoundingBox().g(16.0D)); ++ List list = entityhuman.world.a(EntityPiglin.class, entityhuman.getBoundingBox().g(16.0D)); // CraftBukkit - decompile error + + list.stream().filter(PiglinAI::d).filter((entitypiglin) -> { + return !flag || BehaviorUtil.c(entitypiglin, entityhuman); +@@ -586,7 +593,7 @@ EntityLiving entityliving = (EntityLiving) behaviorcontroller.getMemory(MemoryModuleType.AVOID_TARGET).get(); EntityTypes entitytypes = entityliving.getEntityType(); -- return entitytypes == EntityTypes.HOGLIN ? v(entitypiglin) : (a(entitytypes) ? !behaviorcontroller.b(MemoryModuleType.NEAREST_VISIBLE_ZOMBIFIED, (Object) entityliving) : false); -+ return entitytypes == EntityTypes.HOGLIN ? v(entitypiglin) : (a(entitytypes) ? !behaviorcontroller.b(MemoryModuleType.NEAREST_VISIBLE_ZOMBIFIED, entityliving) : false); // CraftBukkit - decompile error +- return entitytypes == EntityTypes.HOGLIN ? p(entitypiglin) : (a(entitytypes) ? !behaviorcontroller.b(MemoryModuleType.NEAREST_VISIBLE_ZOMBIFIED, (Object) entityliving) : false); ++ return entitytypes == EntityTypes.HOGLIN ? p(entitypiglin) : (a(entitytypes) ? !behaviorcontroller.b(MemoryModuleType.NEAREST_VISIBLE_ZOMBIFIED, entityliving) : false); // CraftBukkit - decompile error } } -@@ -665,7 +672,7 @@ +@@ -668,7 +675,7 @@ } public static boolean b(EntityLiving entityliving) { @@ -90,4 +99,4 @@ + return entityliving.getEntityType() == EntityTypes.PLAYER && entityliving.a((java.util.function.Predicate) PiglinAI::a); // CraftBukkit - decompile error } - private static boolean D(EntityPiglin entitypiglin) { + private static boolean x(EntityPiglin entitypiglin) { diff --git a/nms-patches/PlayerChunk.patch b/nms-patches/PlayerChunk.patch index d427e1d8d8..e0445c3fbc 100644 --- a/nms-patches/PlayerChunk.patch +++ b/nms-patches/PlayerChunk.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/server/PlayerChunk.java +++ b/net/minecraft/server/PlayerChunk.java -@@ -42,7 +42,7 @@ +@@ -44,7 +44,7 @@ this.fullChunkFuture = PlayerChunk.UNLOADED_CHUNK_FUTURE; this.tickingFuture = PlayerChunk.UNLOADED_CHUNK_FUTURE; this.entityTickingFuture = PlayerChunk.UNLOADED_CHUNK_FUTURE; - this.chunkSave = CompletableFuture.completedFuture((Object) null); + this.chunkSave = CompletableFuture.completedFuture(null); // CraftBukkit - decompile error - this.dirtyBlocks = new short[64]; + this.dirtyBlocks = new ShortSet[16]; this.location = chunkcoordintpair; this.lightEngine = lightengine; -@@ -54,6 +54,15 @@ +@@ -56,6 +56,15 @@ this.a(i); } @@ -25,7 +25,7 @@ public CompletableFuture> getStatusFutureUnchecked(ChunkStatus chunkstatus) { CompletableFuture> completablefuture = (CompletableFuture) this.statusFutures.get(chunkstatus.c()); -@@ -79,9 +88,9 @@ +@@ -81,9 +90,9 @@ @Nullable public Chunk getChunk() { CompletableFuture> completablefuture = this.a(); @@ -37,7 +37,7 @@ } @Nullable -@@ -210,7 +219,7 @@ +@@ -216,7 +225,7 @@ CompletableFuture> completablefuture = (CompletableFuture) this.statusFutures.get(i); if (completablefuture != null) { @@ -46,7 +46,7 @@ if (either == null || either.left().isPresent()) { return completablefuture; -@@ -265,6 +274,30 @@ +@@ -271,6 +280,30 @@ boolean flag1 = this.ticketLevel <= PlayerChunkMap.GOLDEN_TICKET; PlayerChunk.State playerchunk_state = getChunkState(this.oldTicketLevel); PlayerChunk.State playerchunk_state1 = getChunkState(this.ticketLevel); @@ -77,7 +77,7 @@ CompletableFuture completablefuture; if (flag) { -@@ -296,7 +329,7 @@ +@@ -302,7 +335,7 @@ if (flag2 && !flag3) { completablefuture = this.fullChunkFuture; this.fullChunkFuture = PlayerChunk.UNLOADED_CHUNK_FUTURE; @@ -86,9 +86,9 @@ playerchunkmap.getClass(); return either1.ifLeft(playerchunkmap::a); })); -@@ -334,6 +367,26 @@ +@@ -340,6 +373,26 @@ - this.v.a(this.location, this::k, this.ticketLevel, this::d); + this.u.a(this.location, this::k, this.ticketLevel, this::d); this.oldTicketLevel = this.ticketLevel; + // CraftBukkit start + // ChunkLoadEvent: Called after the chunk is loaded: isChunkLoaded returns true and chunk is ready to be modified by plugins. diff --git a/nms-patches/PlayerConnection.patch b/nms-patches/PlayerConnection.patch index ce8f237b77..caa5ed528d 100644 --- a/nms-patches/PlayerConnection.patch +++ b/nms-patches/PlayerConnection.patch @@ -300,16 +300,16 @@ } } -@@ -277,7 +470,7 @@ +@@ -276,7 +469,7 @@ + @Override public void a(PacketPlayInRecipeDisplayed packetplayinrecipedisplayed) { PlayerConnectionUtils.ensureMainThread(packetplayinrecipedisplayed, this, this.player.getWorldServer()); - if (packetplayinrecipedisplayed.b() == PacketPlayInRecipeDisplayed.Status.SHOWN) { -- Optional optional = this.minecraftServer.getCraftingManager().a(packetplayinrecipedisplayed.c()); -+ Optional> optional = this.minecraftServer.getCraftingManager().a(packetplayinrecipedisplayed.c()); // CraftBukkit - decompile error - RecipeBookServer recipebookserver = this.player.B(); +- Optional optional = this.minecraftServer.getCraftingManager().getRecipe(packetplayinrecipedisplayed.b()); ++ Optional> optional = this.minecraftServer.getCraftingManager().getRecipe(packetplayinrecipedisplayed.b()); // CraftBukkit - decompile error + RecipeBookServer recipebookserver = this.player.getRecipeBook(); - optional.ifPresent(recipebookserver::e); -@@ -311,6 +504,12 @@ + optional.ifPresent(recipebookserver::e); +@@ -305,6 +498,12 @@ @Override public void a(PacketPlayInTabComplete packetplayintabcomplete) { PlayerConnectionUtils.ensureMainThread(packetplayintabcomplete, this, this.player.getWorldServer()); @@ -322,7 +322,7 @@ StringReader stringreader = new StringReader(packetplayintabcomplete.c()); if (stringreader.canRead() && stringreader.peek() == '/') { -@@ -320,6 +519,7 @@ +@@ -314,6 +513,7 @@ ParseResults parseresults = this.minecraftServer.getCommandDispatcher().a().parse(stringreader, this.player.getCommandListener()); this.minecraftServer.getCommandDispatcher().a().getCompletionSuggestions(parseresults).thenAccept((suggestions) -> { @@ -330,7 +330,7 @@ this.networkManager.sendPacket(new PacketPlayOutTabComplete(packetplayintabcomplete.b(), suggestions)); }); } -@@ -548,6 +748,7 @@ +@@ -542,6 +742,7 @@ if (container instanceof ContainerMerchant) { ContainerMerchant containermerchant = (ContainerMerchant) container; @@ -338,7 +338,7 @@ containermerchant.d(i); containermerchant.g(i); -@@ -558,6 +759,14 @@ +@@ -552,6 +753,14 @@ @Override public void a(PacketPlayInBEdit packetplayinbedit) { PlayerConnectionUtils.ensureMainThread(packetplayinbedit, this, this.player.getWorldServer()); @@ -353,7 +353,7 @@ ItemStack itemstack = packetplayinbedit.b(); if (!itemstack.isEmpty()) { -@@ -586,9 +795,11 @@ +@@ -580,9 +789,11 @@ } itemstack2.a("pages", (NBTBase) nbttaglist); @@ -366,7 +366,7 @@ } } -@@ -630,7 +841,7 @@ +@@ -624,7 +835,7 @@ } else { WorldServer worldserver = this.player.getWorldServer(); @@ -375,7 +375,7 @@ if (this.e == 0) { this.syncPosition(); } -@@ -640,13 +851,21 @@ +@@ -634,13 +845,21 @@ this.A = this.e; this.a(this.teleportPos.x, this.teleportPos.y, this.teleportPos.z, this.player.yaw, this.player.pitch); } @@ -398,7 +398,7 @@ double d0 = this.player.locX(); double d1 = this.player.locY(); double d2 = this.player.locZ(); -@@ -671,15 +890,33 @@ +@@ -665,15 +884,33 @@ ++this.receivedMovePackets; int i = this.receivedMovePackets - this.processedMovePackets; @@ -434,15 +434,15 @@ PlayerConnection.LOGGER.warn("{} moved too quickly! {},{},{}", this.player.getDisplayName().getString(), d7, d8, d9); this.a(this.player.locX(), this.player.locY(), this.player.locZ(), this.player.yaw, this.player.pitch); return; -@@ -698,6 +935,7 @@ +@@ -692,6 +929,7 @@ } this.player.move(EnumMoveType.PLAYER, new Vec3D(d7, d8, d9)); -+ this.player.c(packetplayinflying.b()); // CraftBukkit - SPIGOT-5810, SPIGOT-5835: reset by this.player.move ++ this.player.setOnGround(packetplayinflying.b()); // CraftBukkit - SPIGOT-5810, SPIGOT-5835: reset by this.player.move double d12 = d8; d7 = d4 - this.player.locX(); -@@ -719,10 +957,74 @@ +@@ -713,10 +951,74 @@ if (!this.player.noclip && !this.player.isSleeping() && (flag1 && worldserver.getCubes(this.player, axisalignedbb) || this.a((IWorldReader) worldserver, axisalignedbb))) { this.a(d0, d1, d2, f, f1); } else { @@ -514,12 +514,12 @@ + // CraftBukkit end this.player.getWorldServer().getChunkProvider().movePlayer(this.player); this.player.a(this.player.locY() - d3, packetplayinflying.b()); -- this.player.c(packetplayinflying.b()); -+ // this.player.c(packetplayinflying.b()); // CraftBukkit - moved up +- this.player.setOnGround(packetplayinflying.b()); ++ // this.player.setOnGround(packetplayinflying.b()); // CraftBukkit - moved up if (flag) { this.player.fallDistance = 0.0F; } -@@ -751,10 +1053,66 @@ +@@ -745,10 +1047,66 @@ } public void a(double d0, double d1, double d2, float f, float f1) { @@ -587,7 +587,7 @@ double d3 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.X) ? this.player.locX() : 0.0D; double d4 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.Y) ? this.player.locY() : 0.0D; double d5 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.Z) ? this.player.locZ() : 0.0D; -@@ -766,6 +1124,14 @@ +@@ -760,6 +1118,14 @@ this.teleportAwait = 0; } @@ -602,7 +602,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)); -@@ -774,6 +1140,7 @@ +@@ -768,6 +1134,7 @@ @Override public void a(PacketPlayInBlockDig packetplayinblockdig) { PlayerConnectionUtils.ensureMainThread(packetplayinblockdig, this, this.player.getWorldServer()); @@ -610,7 +610,7 @@ BlockPosition blockposition = packetplayinblockdig.b(); this.player.resetIdleTimer(); -@@ -784,14 +1151,46 @@ +@@ -778,14 +1145,46 @@ if (!this.player.isSpectator()) { ItemStack itemstack = this.player.b(EnumHand.OFF_HAND); @@ -659,7 +659,7 @@ this.player.dropItem(false); } -@@ -828,6 +1227,7 @@ +@@ -822,6 +1221,7 @@ @Override public void a(PacketPlayInUseItem packetplayinuseitem) { PlayerConnectionUtils.ensureMainThread(packetplayinuseitem, this, this.player.getWorldServer()); @@ -667,10 +667,10 @@ WorldServer worldserver = this.player.getWorldServer(); EnumHand enumhand = packetplayinuseitem.b(); ItemStack itemstack = this.player.b(enumhand); -@@ -838,6 +1238,14 @@ +@@ -832,6 +1232,14 @@ this.player.resetIdleTimer(); if (blockposition.getY() < this.minecraftServer.getMaxBuildHeight()) { - if (this.teleportPos == null && this.player.g((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) < 64.0D && worldserver.a((EntityHuman) this.player, blockposition)) { + if (this.teleportPos == null && this.player.h((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) < 64.0D && worldserver.a((EntityHuman) this.player, blockposition)) { + // CraftBukkit start - Check if we can actually do something over this large a distance + Location eyeLoc = this.getPlayer().getEyeLocation(); + double reachDistance = NumberConversions.square(eyeLoc.getX() - blockposition.getX()) + NumberConversions.square(eyeLoc.getY() - blockposition.getY()) + NumberConversions.square(eyeLoc.getZ() - blockposition.getZ()); @@ -682,7 +682,7 @@ EnumInteractionResult enuminteractionresult = this.player.playerInteractManager.a(this.player, worldserver, itemstack, enumhand, movingobjectpositionblock); if (enumdirection == EnumDirection.UP && !enuminteractionresult.a() && blockposition.getY() >= this.minecraftServer.getMaxBuildHeight() - 1 && a(this.player, itemstack)) { -@@ -861,12 +1269,51 @@ +@@ -855,12 +1263,51 @@ @Override public void a(PacketPlayInBlockPlace packetplayinblockplace) { PlayerConnectionUtils.ensureMainThread(packetplayinblockplace, this, this.player.getWorldServer()); @@ -734,7 +734,7 @@ EnumInteractionResult enuminteractionresult = this.player.playerInteractManager.a(this.player, worldserver, itemstack, enumhand); if (enuminteractionresult.b()) { -@@ -887,7 +1334,7 @@ +@@ -881,7 +1328,7 @@ Entity entity = packetplayinspectate.a(worldserver); if (entity != null) { @@ -743,7 +743,7 @@ return; } } -@@ -896,7 +1343,12 @@ +@@ -890,7 +1337,12 @@ } @Override @@ -757,7 +757,7 @@ @Override public void a(PacketPlayInBoatMove packetplayinboatmove) { -@@ -911,11 +1363,26 @@ +@@ -905,11 +1357,26 @@ @Override public void a(IChatBaseComponent ichatbasecomponent) { @@ -785,7 +785,7 @@ if (this.isExemptPlayer()) { PlayerConnection.LOGGER.info("Stopping singleplayer server as player logged out"); this.minecraftServer.safeShutdown(false); -@@ -941,6 +1408,15 @@ +@@ -935,6 +1402,15 @@ } } @@ -801,7 +801,7 @@ try { this.networkManager.sendPacket(packet, genericfuturelistener); } catch (Throwable throwable) { -@@ -957,7 +1433,16 @@ +@@ -951,7 +1427,16 @@ @Override public void a(PacketPlayInHeldItemSlot packetplayinhelditemslot) { PlayerConnectionUtils.ensureMainThread(packetplayinhelditemslot, this, this.player.getWorldServer()); @@ -818,7 +818,7 @@ if (this.player.inventory.itemInHandIndex != packetplayinhelditemslot.b() && this.player.getRaisedHand() == EnumHand.MAIN_HAND) { this.player.clearActiveItem(); } -@@ -966,13 +1451,24 @@ +@@ -960,13 +1445,24 @@ this.player.resetIdleTimer(); } else { PlayerConnection.LOGGER.warn("{} tried to set an invalid carried item", this.player.getDisplayName().getString()); @@ -845,7 +845,7 @@ this.sendPacket(new PacketPlayOutChat((new ChatMessage("chat.cannotSend")).a(EnumChatFormat.RED), ChatMessageType.SYSTEM, SystemUtils.b)); } else { this.player.resetIdleTimer(); -@@ -980,41 +1476,254 @@ +@@ -974,41 +1470,254 @@ for (int i = 0; i < s.length(); ++i) { if (!SharedConstants.isAllowedChatCharacter(s.charAt(i))) { @@ -1107,7 +1107,7 @@ this.player.resetIdleTimer(); IJumpable ijumpable; -@@ -1072,6 +1781,7 @@ +@@ -1066,6 +1775,7 @@ @Override public void a(PacketPlayInUseEntity packetplayinuseentity) { PlayerConnectionUtils.ensureMainThread(packetplayinuseentity, this, this.player.getWorldServer()); @@ -1115,8 +1115,8 @@ WorldServer worldserver = this.player.getWorldServer(); Entity entity = packetplayinuseentity.a((World) worldserver); -@@ -1084,18 +1794,72 @@ - EnumHand enumhand = packetplayinuseentity.c(); +@@ -1079,18 +1789,72 @@ + ItemStack itemstack = enumhand != null ? this.player.b(enumhand).cloneItemStack() : ItemStack.b; Optional optional = Optional.empty(); + ItemStack itemInHand = this.player.b(packetplayinuseentity.c() == null ? EnumHand.MAIN_HAND : packetplayinuseentity.c()); // CraftBukkit @@ -1189,7 +1189,7 @@ } if (optional.isPresent() && ((EnumInteractionResult) optional.get()).a()) { -@@ -1142,15 +1906,21 @@ +@@ -1137,15 +1901,21 @@ @Override public void a(PacketPlayInCloseWindow packetplayinclosewindow) { PlayerConnectionUtils.ensureMainThread(packetplayinclosewindow, this, this.player.getWorldServer()); @@ -1213,7 +1213,7 @@ NonNullList nonnulllist = NonNullList.a(); for (int i = 0; i < this.player.activeContainer.slots.size(); ++i) { -@@ -1159,8 +1929,274 @@ +@@ -1154,8 +1924,274 @@ this.player.a(this.player.activeContainer, nonnulllist); } else { @@ -1489,7 +1489,7 @@ if (ItemStack.matches(packetplayinwindowclick.f(), itemstack)) { this.player.playerConnection.sendPacket(new PacketPlayOutTransaction(packetplayinwindowclick.b(), packetplayinwindowclick.e(), true)); this.player.e = true; -@@ -1200,6 +2236,7 @@ +@@ -1195,6 +2231,7 @@ @Override public void a(PacketPlayInEnchantItem packetplayinenchantitem) { PlayerConnectionUtils.ensureMainThread(packetplayinenchantitem, this, this.player.getWorldServer()); @@ -1497,7 +1497,7 @@ this.player.resetIdleTimer(); if (this.player.activeContainer.windowId == packetplayinenchantitem.b() && this.player.activeContainer.c(this.player) && !this.player.isSpectator()) { this.player.activeContainer.a((EntityHuman) this.player, packetplayinenchantitem.c()); -@@ -1232,6 +2269,43 @@ +@@ -1227,6 +2264,43 @@ boolean flag1 = packetplayinsetcreativeslot.b() >= 1 && packetplayinsetcreativeslot.b() <= 45; boolean flag2 = itemstack.isEmpty() || itemstack.getDamage() >= 0 && itemstack.getCount() <= 64 && !itemstack.isEmpty(); @@ -1541,7 +1541,7 @@ if (flag1 && flag2) { if (itemstack.isEmpty()) { -@@ -1253,6 +2327,7 @@ +@@ -1248,6 +2322,7 @@ @Override public void a(PacketPlayInTransaction packetplayintransaction) { PlayerConnectionUtils.ensureMainThread(packetplayintransaction, this, this.player.getWorldServer()); @@ -1549,7 +1549,7 @@ int i = this.player.activeContainer.windowId; if (i == packetplayintransaction.b() && this.k.getOrDefault(i, (short) (packetplayintransaction.c() + 1)) == packetplayintransaction.c() && !this.player.activeContainer.c(this.player) && !this.player.isSpectator()) { -@@ -1264,6 +2339,7 @@ +@@ -1259,6 +2334,7 @@ @Override public void a(PacketPlayInUpdateSign packetplayinupdatesign) { PlayerConnectionUtils.ensureMainThread(packetplayinupdatesign, this, this.player.getWorldServer()); @@ -1557,7 +1557,7 @@ this.player.resetIdleTimer(); WorldServer worldserver = this.player.getWorldServer(); BlockPosition blockposition = packetplayinupdatesign.b(); -@@ -1280,14 +2356,30 @@ +@@ -1275,14 +2351,30 @@ if (!tileentitysign.d() || tileentitysign.f() != this.player) { PlayerConnection.LOGGER.warn("Player {} just tried to change non-editable sign", this.player.getDisplayName().getString()); @@ -1589,7 +1589,7 @@ tileentitysign.update(); worldserver.notify(blockposition, iblockdata, iblockdata, 3); -@@ -1297,6 +2389,7 @@ +@@ -1292,6 +2384,7 @@ @Override public void a(PacketPlayInKeepAlive packetplayinkeepalive) { @@ -1597,7 +1597,7 @@ if (this.awaitingKeepAlive && packetplayinkeepalive.b() == this.h) { int i = (int) (SystemUtils.getMonotonicMillis() - this.lastKeepAlive); -@@ -1311,7 +2404,17 @@ +@@ -1306,7 +2399,17 @@ @Override public void a(PacketPlayInAbilities packetplayinabilities) { PlayerConnectionUtils.ensureMainThread(packetplayinabilities, this, this.player.getWorldServer()); @@ -1616,7 +1616,7 @@ } @Override -@@ -1320,8 +2423,50 @@ +@@ -1315,8 +2418,50 @@ this.player.a(packetplayinsettings); } diff --git a/nms-patches/PlayerList.patch b/nms-patches/PlayerList.patch index ab94d33202..1bc6499a5b 100644 --- a/nms-patches/PlayerList.patch +++ b/nms-patches/PlayerList.patch @@ -100,7 +100,7 @@ @@ -109,6 +149,7 @@ boolean flag1 = gamerules.getBoolean(GameRules.REDUCED_DEBUG_INFO); - playerconnection.sendPacket(new PacketPlayOutLogin(entityplayer.getId(), entityplayer.playerInteractManager.getGameMode(), entityplayer.playerInteractManager.c(), BiomeManager.a(worldserver1.getSeed()), worlddata.isHardcore(), this.server.E(), this.s, worldserver1.getTypeKey(), worldserver1.getDimensionKey(), this.getMaxPlayers(), this.viewDistance, flag1, !flag, worldserver1.isDebugWorld(), worldserver1.isFlatWorld())); + playerconnection.sendPacket(new PacketPlayOutLogin(entityplayer.getId(), entityplayer.playerInteractManager.getGameMode(), entityplayer.playerInteractManager.c(), BiomeManager.a(worldserver1.getSeed()), worlddata.isHardcore(), this.server.F(), this.s, worldserver1.getDimensionManager(), worldserver1.getDimensionKey(), this.getMaxPlayers(), this.viewDistance, flag1, !flag, worldserver1.isDebugWorld(), worldserver1.isFlatWorld())); + entityplayer.getBukkitEntity().sendSupportedChannels(); // CraftBukkit playerconnection.sendPacket(new PacketPlayOutCustomPayload(PacketPlayOutCustomPayload.a, (new PacketDataSerializer(Unpooled.buffer())).a(this.getServer().getServerModName()))); playerconnection.sendPacket(new PacketPlayOutServerDifficulty(worlddata.getDifficulty(), worlddata.isDifficultyLocked())); @@ -283,8 +283,9 @@ + // this.o.remove(uuid); + // this.p.remove(uuid); + // CraftBukkit end -+ } -+ + } + +- this.sendAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, new EntityPlayer[]{entityplayer})); + // CraftBukkit start + // this.sendAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, new EntityPlayer[]{entityplayer})); + PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, entityplayer); @@ -296,12 +297,11 @@ + } else { + entityplayer2.getBukkitEntity().removeDisconnectingPlayer(entityplayer.getBukkitEntity()); + } - } ++ } + // This removes the scoreboard (and player reference) for the specific player in the manager + cserver.getScoreboardManager().removePlayer(entityplayer.getBukkitEntity()); + // CraftBukkit end - -- this.sendAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, new EntityPlayer[]{entityplayer})); ++ + return playerQuitEvent.getQuitMessage(); // CraftBukkit } @@ -375,13 +375,13 @@ + if (this.players.size() >= this.maxPlayers && !this.f(gameprofile)) { + event.disallow(PlayerLoginEvent.Result.KICK_FULL, "The server is full"); + } - } ++ } + + cserver.getPluginManager().callEvent(event); + if (event.getResult() != PlayerLoginEvent.Result.ALLOWED) { + loginlistener.disconnect(event.getKickMessage()); + return null; -+ } + } + return entity; } @@ -391,7 +391,7 @@ UUID uuid = EntityHuman.a(gameprofile); List list = Lists.newArrayList(); -@@ -404,13 +567,23 @@ +@@ -404,14 +567,24 @@ } return new EntityPlayer(this.server, worldserver, gameprofile, (PlayerInteractManager) object); @@ -410,12 +410,13 @@ this.players.remove(entityplayer); entityplayer.getWorldServer().removePlayer(entityplayer); BlockPosition blockposition = entityplayer.getSpawn(); + float f = entityplayer.getSpawnAngle(); boolean flag1 = entityplayer.isSpawnForced(); + /* CraftBukkit start WorldServer worldserver = this.server.getWorldServer(entityplayer.getSpawnDimension()); Optional optional; -@@ -430,6 +603,11 @@ +@@ -431,6 +604,11 @@ } EntityPlayer entityplayer1 = new EntityPlayer(this.server, worldserver1, entityplayer.getProfile(), (PlayerInteractManager) object); @@ -427,7 +428,7 @@ entityplayer1.playerConnection = entityplayer.playerConnection; entityplayer1.copyFrom(entityplayer, flag); -@@ -443,41 +621,103 @@ +@@ -444,52 +622,114 @@ entityplayer1.addScoreboardTag(s); } @@ -436,38 +437,57 @@ boolean flag2 = false; - if (optional.isPresent()) { +- IBlockData iblockdata = worldserver1.getType(blockposition); +- boolean flag3 = iblockdata.a(Blocks.RESPAWN_ANCHOR); - Vec3D vec3d = (Vec3D) optional.get(); +- float f1; + // CraftBukkit start - fire PlayerRespawnEvent + if (location == null) { + boolean isBedSpawn = false; + WorldServer worldserver1 = this.server.getWorldServer(entityplayer.getSpawnDimension()); + if (worldserver1 != null) { + Optional optional; -+ + +- if (!iblockdata.a((Tag) TagsBlock.BEDS) && !flag3) { +- f1 = f; +- } else { +- Vec3D vec3d1 = Vec3D.c((BaseBlockPosition) blockposition).d(vec3d).d(); + if (blockposition != null) { -+ optional = EntityHuman.getBed(worldserver1, blockposition, flag1, flag); ++ optional = EntityHuman.getBed(worldserver1, blockposition, f, flag1, flag); + } else { + optional = Optional.empty(); + } - -- entityplayer1.setPositionRotation(vec3d.x, vec3d.y, vec3d.z, 0.0F, 0.0F); -- entityplayer1.setRespawnPosition(worldserver1.getDimensionKey(), blockposition, flag1, false); -- flag2 = !flag && worldserver1.getType(blockposition).getBlock() instanceof BlockRespawnAnchor; -- } else if (blockposition != null) { -- entityplayer1.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.a, 0.0F)); -+ if (optional.isPresent()) { -+ Vec3D vec3d = (Vec3D) optional.get(); + ++ if (optional.isPresent()) { ++ IBlockData iblockdata = worldserver1.getType(blockposition); ++ boolean flag3 = iblockdata.a(Blocks.RESPAWN_ANCHOR); ++ Vec3D vec3d = (Vec3D) optional.get(); ++ float f1; ++ ++ if (!iblockdata.a((Tag) TagsBlock.BEDS) && !flag3) { ++ f1 = f; ++ } else { ++ Vec3D vec3d1 = Vec3D.c((BaseBlockPosition) blockposition).d(vec3d).d(); ++ ++ f1 = (float) MathHelper.g(MathHelper.d(vec3d1.z, vec3d1.x) * 57.2957763671875D - 90.0D); ++ } + +- f1 = (float) MathHelper.g(MathHelper.d(vec3d1.z, vec3d1.x) * 57.2957763671875D - 90.0D); ++ entityplayer1.setPositionRotation(vec3d.x, vec3d.y, vec3d.z, f1, 0.0F); ++ entityplayer1.setRespawnPosition(worldserver1.getDimensionKey(), blockposition, f, flag1, false); ++ flag2 = !flag && flag3; + isBedSpawn = true; + location = new Location(worldserver1.getWorld(), vec3d.x, vec3d.y, vec3d.z); -+ -+ entityplayer1.setRespawnPosition(worldserver1.getDimensionKey(), blockposition, flag1, false); -+ flag2 = !flag && worldserver1.getType(blockposition).getBlock() instanceof BlockRespawnAnchor; + } else if (blockposition != null) { + entityplayer1.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.a, 0.0F)); + } -+ } -+ + } + +- entityplayer1.setPositionRotation(vec3d.x, vec3d.y, vec3d.z, f1, 0.0F); +- entityplayer1.setRespawnPosition(worldserver1.getDimensionKey(), blockposition, f, flag1, false); +- flag2 = !flag && flag3; +- } else if (blockposition != null) { +- entityplayer1.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.a, 0.0F)); + if (location == null) { + worldserver1 = this.server.getWorldServer(World.OVERWORLD); + blockposition = entityplayer1.getSpawnPoint(worldserver1); @@ -493,7 +513,7 @@ } + // CraftBukkit start + WorldData worlddata = worldserver1.getWorldData(); -+ entityplayer1.playerConnection.sendPacket(new PacketPlayOutRespawn(worldserver1.getTypeKey(), worldserver1.getDimensionKey(), BiomeManager.a(worldserver1.getSeed()), entityplayer1.playerInteractManager.getGameMode(), entityplayer1.playerInteractManager.c(), worldserver1.isDebugWorld(), worldserver1.isFlatWorld(), flag)); ++ entityplayer1.playerConnection.sendPacket(new PacketPlayOutRespawn(worldserver1.getDimensionManager(), worldserver1.getDimensionKey(), BiomeManager.a(worldserver1.getSeed()), entityplayer1.playerInteractManager.getGameMode(), entityplayer1.playerInteractManager.c(), worldserver1.isDebugWorld(), worldserver1.isFlatWorld(), flag)); + entityplayer1.spawnIn(worldserver1); + entityplayer1.dead = false; + entityplayer1.playerConnection.teleport(new Location(worldserver1.getWorld(), entityplayer1.locX(), entityplayer1.locY(), entityplayer1.locZ(), entityplayer1.yaw, entityplayer1.pitch)); @@ -501,10 +521,10 @@ - WorldData worlddata = entityplayer1.world.getWorldData(); - -- entityplayer1.playerConnection.sendPacket(new PacketPlayOutRespawn(entityplayer1.world.getTypeKey(), entityplayer1.world.getDimensionKey(), BiomeManager.a(entityplayer1.getWorldServer().getSeed()), entityplayer1.playerInteractManager.getGameMode(), entityplayer1.playerInteractManager.c(), entityplayer1.getWorldServer().isDebugWorld(), entityplayer1.getWorldServer().isFlatWorld(), flag)); +- entityplayer1.playerConnection.sendPacket(new PacketPlayOutRespawn(entityplayer1.world.getDimensionManager(), entityplayer1.world.getDimensionKey(), BiomeManager.a(entityplayer1.getWorldServer().getSeed()), entityplayer1.playerInteractManager.getGameMode(), entityplayer1.playerInteractManager.c(), entityplayer1.getWorldServer().isDebugWorld(), entityplayer1.getWorldServer().isFlatWorld(), flag)); - entityplayer1.playerConnection.a(entityplayer1.locX(), entityplayer1.locY(), entityplayer1.locZ(), entityplayer1.yaw, entityplayer1.pitch); + // entityplayer1.playerConnection.a(entityplayer1.locX(), entityplayer1.locY(), entityplayer1.locZ(), entityplayer1.yaw, entityplayer1.pitch); - entityplayer1.playerConnection.sendPacket(new PacketPlayOutSpawnPosition(worldserver1.getSpawn())); + entityplayer1.playerConnection.sendPacket(new PacketPlayOutSpawnPosition(worldserver1.getSpawn(), worldserver1.v())); entityplayer1.playerConnection.sendPacket(new PacketPlayOutServerDifficulty(worlddata.getDifficulty(), worlddata.isDifficultyLocked())); entityplayer1.playerConnection.sendPacket(new PacketPlayOutExperience(entityplayer1.exp, entityplayer1.expTotal, entityplayer1.expLevel)); this.a(entityplayer1, worldserver1); @@ -548,7 +568,7 @@ return entityplayer1; } -@@ -490,7 +730,18 @@ +@@ -502,7 +742,18 @@ public void tick() { if (++this.w > 600) { @@ -568,7 +588,7 @@ this.w = 0; } -@@ -503,6 +754,25 @@ +@@ -515,6 +766,25 @@ } @@ -594,7 +614,7 @@ public void a(Packet packet, ResourceKey resourcekey) { for (int i = 0; i < this.players.size(); ++i) { EntityPlayer entityplayer = (EntityPlayer) this.players.get(i); -@@ -603,6 +873,7 @@ +@@ -615,6 +885,7 @@ entityplayer.playerConnection.sendPacket(new PacketPlayOutEntityStatus(entityplayer, b0)); } @@ -602,7 +622,7 @@ this.server.getCommandDispatcher().a(entityplayer); } -@@ -635,6 +906,12 @@ +@@ -647,6 +918,12 @@ for (int i = 0; i < this.players.size(); ++i) { EntityPlayer entityplayer = (EntityPlayer) this.players.get(i); @@ -615,16 +635,16 @@ if (entityplayer != entityhuman && entityplayer.world.getDimensionKey() == resourcekey) { double d4 = d0 - entityplayer.locX(); double d5 = d1 - entityplayer.locY(); -@@ -674,23 +951,34 @@ +@@ -686,23 +963,34 @@ public void reloadWhitelist() {} public void a(EntityPlayer entityplayer, WorldServer worldserver) { -- WorldBorder worldborder = this.server.D().getWorldBorder(); +- WorldBorder worldborder = this.server.E().getWorldBorder(); + WorldBorder worldborder = entityplayer.world.getWorldBorder(); // CraftBukkit entityplayer.playerConnection.sendPacket(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.INITIALIZE)); entityplayer.playerConnection.sendPacket(new PacketPlayOutUpdateTime(worldserver.getTime(), worldserver.getDayTime(), worldserver.getGameRules().getBoolean(GameRules.DO_DAYLIGHT_CYCLE))); - entityplayer.playerConnection.sendPacket(new PacketPlayOutSpawnPosition(worldserver.getSpawn())); + entityplayer.playerConnection.sendPacket(new PacketPlayOutSpawnPosition(worldserver.getSpawn(), worldserver.v())); if (worldserver.isRaining()) { - entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.b, 0.0F)); - entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.h, worldserver.d(1.0F))); @@ -655,7 +675,7 @@ } public int getPlayerCount() { -@@ -743,31 +1031,54 @@ +@@ -755,31 +1043,54 @@ entityplayer.playerInteractManager.a(this.u, EnumGamemode.NOT_SET); } @@ -718,7 +738,7 @@ if (file2.exists() && file2.isFile()) { file2.renameTo(file1); -@@ -775,7 +1086,7 @@ +@@ -787,7 +1098,7 @@ } serverstatisticmanager = new ServerStatisticManager(this.server, file1); @@ -727,7 +747,7 @@ } return serverstatisticmanager; -@@ -783,14 +1094,14 @@ +@@ -795,14 +1106,14 @@ public AdvancementDataPlayer f(EntityPlayer entityplayer) { UUID uuid = entityplayer.getUniqueID(); @@ -744,7 +764,7 @@ } advancementdataplayer.a(entityplayer); -@@ -826,13 +1137,20 @@ +@@ -838,13 +1149,20 @@ } public void reload() { diff --git a/nms-patches/PortalTravelAgent.patch b/nms-patches/PortalTravelAgent.patch index f01b2029e9..9cda542f63 100644 --- a/nms-patches/PortalTravelAgent.patch +++ b/nms-patches/PortalTravelAgent.patch @@ -1,162 +1,93 @@ --- a/net/minecraft/server/PortalTravelAgent.java +++ b/net/minecraft/server/PortalTravelAgent.java -@@ -18,12 +18,19 @@ +@@ -13,13 +13,19 @@ } - public boolean findAndTeleport(Entity entity, float f) { + public Optional findPortal(BlockPosition blockposition, boolean flag) { + // CraftBukkit start -+ return findAndTeleport(entity, entity.getChunkCoordinates(), f, 128, false) != null; ++ return findPortal(blockposition, flag ? 16 : 128); // Search Radius + } + -+ public ShapeDetector.Shape findAndTeleport(Entity entity, BlockPosition findPosition, float f, int searchRadius, boolean searchOnly) { ++ public Optional findPortal(BlockPosition blockposition, int i) { + VillagePlace villageplace = this.world.y(); +- int i = flag ? 16 : 128; ++ // int i = flag ? 16 : 128; + // CraftBukkit end - Vec3D vec3d = entity.getPortalOffset(); - EnumDirection enumdirection = entity.getPortalDirection(); -- ShapeDetector.Shape shapedetector_shape = this.a(entity.getChunkCoordinates(), entity.getMot(), enumdirection, vec3d.x, vec3d.y, entity instanceof EntityHuman); -+ ShapeDetector.Shape shapedetector_shape = this.findPortal(findPosition, entity.getMot(), enumdirection, vec3d.x, vec3d.y, entity instanceof EntityHuman, searchRadius); // CraftBukkit - add location and searchRadius -+ if (searchOnly) return shapedetector_shape; // CraftBukkit - optional teleporting - if (shapedetector_shape == null) { -- return false; -+ return null; // CraftBukkit - return shape - } else { - Vec3D vec3d1 = shapedetector_shape.position; - Vec3D vec3d2 = shapedetector_shape.velocity; -@@ -31,19 +38,26 @@ - entity.setMot(vec3d2); - entity.yaw = f + (float) shapedetector_shape.yaw; - entity.teleportAndSync(vec3d1.x, vec3d1.y, vec3d1.z); -- return true; -+ return shapedetector_shape; // CraftBukkit - return shape - } - } - - @Nullable -- public ShapeDetector.Shape a(BlockPosition blockposition, Vec3D vec3d, EnumDirection enumdirection, double d0, double d1, boolean flag) { -+ public ShapeDetector.Shape a(BlockPosition blockposition, Vec3D vec3d, EnumDirection enumdirection, double d0, double d1, boolean flag) { // PAIL: rename to findPortal, d0 = portal offset x, d1 = portal offset z, flag = instanceof EntityHuman -+ // CraftBukkit start -+ return findPortal(blockposition, vec3d, enumdirection, d0, d1, flag, 128); -+ } -+ -+ @Nullable -+ public ShapeDetector.Shape findPortal(BlockPosition blockposition, Vec3D vec3d, EnumDirection enumdirection, double d0, double d1, boolean flag, int searchRadius) { -+ // CraftBukkit end - VillagePlace villageplace = this.world.x(); - - villageplace.a(this.world, blockposition, 128); - List list = (List) villageplace.b((villageplacetype) -> { + villageplace.a(this.world, blockposition, i); + Optional optional = villageplace.b((villageplacetype) -> { return villageplacetype == VillagePlaceType.v; -- }, blockposition, 128, VillagePlace.Occupancy.ANY).collect(Collectors.toList()); -- Optional optional = list.stream().min(Comparator.comparingDouble((villageplacerecord) -> { -+ }, blockposition, searchRadius, VillagePlace.Occupancy.ANY).collect(Collectors.toList()); // CraftBukkit - searchRadius -+ Optional optional = list.stream().min(Comparator.comparingDouble((villageplacerecord) -> { // CraftBukkit - decompile error +- }, blockposition, i, VillagePlace.Occupancy.ANY).sorted(Comparator.comparingDouble((villageplacerecord) -> { ++ }, blockposition, i, VillagePlace.Occupancy.ANY).sorted(Comparator.comparingDouble((VillagePlaceRecord villageplacerecord) -> { // CraftBukkit - decompile error return villageplacerecord.f().j(blockposition); }).thenComparingInt((villageplacerecord) -> { return villageplacerecord.f().getY(); -@@ -56,15 +70,23 @@ - ShapeDetector.ShapeDetectorCollection shapedetector_shapedetectorcollection = BlockPortal.c((GeneratorAccess) this.world, blockposition1); - - return shapedetector_shapedetectorcollection.a(enumdirection, blockposition1, d1, vec3d, d0); -- }).orElse((Object) null); -+ }).orElse(null); // CraftBukkit - decompile error +@@ -40,6 +46,12 @@ } - public boolean createPortal(Entity entity) { -+ // CraftBukkit start - providable position and creation radius -+ return createPortal(entity, entity.getChunkCoordinates(), 16); + public Optional createPortal(BlockPosition blockposition, EnumDirection.EnumAxis enumdirection_enumaxis) { ++ // CraftBukkit start ++ return this.createPortal(blockposition, enumdirection_enumaxis, null, 16); + } + -+ public boolean createPortal(Entity entity, BlockPosition createPosition, int createRadius) { ++ public Optional createPortal(BlockPosition blockposition, EnumDirection.EnumAxis enumdirection_enumaxis, Entity entity, int createRadius) { + // CraftBukkit end - boolean flag = true; + EnumDirection enumdirection = EnumDirection.a(EnumDirection.EnumAxisDirection.POSITIVE, enumdirection_enumaxis); double d0 = -1.0D; -- int i = MathHelper.floor(entity.locX()); -- int j = MathHelper.floor(entity.locY()); -- int k = MathHelper.floor(entity.locZ()); -+ // CraftBukkit start - providable position -+ int i = createPosition.getX(); -+ int j = createPosition.getY(); -+ int k = createPosition.getZ(); -+ // CraftBukkit end - int l = i; - int i1 = j; - int j1 = k; -@@ -88,11 +110,11 @@ - double d3; - double d4; + BlockPosition blockposition1 = null; +@@ -48,7 +60,7 @@ + WorldBorder worldborder = this.world.getWorldBorder(); + int i = this.world.getHeight() - 1; + BlockPosition.MutableBlockPosition blockposition_mutableblockposition = blockposition.i(); +- Iterator iterator = BlockPosition.a(blockposition, 16, EnumDirection.EAST, EnumDirection.SOUTH).iterator(); ++ Iterator iterator = BlockPosition.a(blockposition, createRadius, EnumDirection.EAST, EnumDirection.SOUTH).iterator(); // CraftBukkit -- for (i2 = i - 16; i2 <= i + 16; ++i2) { -- d1 = (double) i2 + 0.5D - entity.locX(); -+ for (i2 = i - createRadius; i2 <= i + createRadius; ++i2) { // CraftBukkit - createRadius -+ d1 = (double) i2 + 0.5D - createPosition.getX(); // CraftBukkit - providable position + int j; -- for (j2 = k - 16; j2 <= k + 16; ++j2) { -- d2 = (double) j2 + 0.5D - entity.locZ(); -+ for (j2 = k - createRadius; j2 <= k + createRadius; ++j2) { // CraftBukkit - createRadius -+ d2 = (double) j2 + 0.5D - createPosition.getZ(); // CraftBukkit - providable position +@@ -102,6 +114,7 @@ - label257: - for (k2 = this.world.getHeight() - 1; k2 >= 0; --k2) { -@@ -140,11 +162,11 @@ - } - - if (d0 < 0.0D) { -- for (i2 = i - 16; i2 <= i + 16; ++i2) { -- d1 = (double) i2 + 0.5D - entity.locX(); -+ for (i2 = i - createRadius; i2 <= i + createRadius; ++i2) { // CraftBukkit - createRadius -+ d1 = (double) i2 + 0.5D - createPosition.getX(); // CraftBukkit - providable position - -- for (j2 = k - 16; j2 <= k + 16; ++j2) { -- d2 = (double) j2 + 0.5D - entity.locZ(); -+ for (j2 = k - createRadius; j2 <= k + createRadius; ++j2) { // CraftBukkit - createRadius -+ d2 = (double) j2 + 0.5D - createPosition.getZ(); // CraftBukkit - providable position - - label205: - for (k2 = this.world.getHeight() - 1; k2 >= 0; --k2) { -@@ -197,6 +219,7 @@ - l5 = -l5; - } + int j1; + org.bukkit.craftbukkit.util.BlockStateListPopulator blockList = new org.bukkit.craftbukkit.util.BlockStateListPopulator(this.world); // CraftBukkit - Use BlockStateListPopulator - if (d0 < 0.0D) { - i1 = MathHelper.clamp(i1, 70, this.world.getHeight() - 10); - j5 = i1; -@@ -210,7 +233,7 @@ - boolean flag1 = l2 < 0; + if (d0 == -1.0D) { + blockposition1 = (new BlockPosition(blockposition.getX(), MathHelper.clamp(blockposition.getY(), 70, this.world.getHeight() - 10), blockposition.getZ())).immutableCopy(); + EnumDirection enumdirection1 = enumdirection.g(); +@@ -116,7 +129,7 @@ + IBlockData iblockdata = k1 < 0 ? Blocks.OBSIDIAN.getBlockData() : Blocks.AIR.getBlockData(); - blockposition_mutableblockposition.d(j3, l3, i4); -- this.world.setTypeUpdate(blockposition_mutableblockposition, flag1 ? Blocks.OBSIDIAN.getBlockData() : Blocks.AIR.getBlockData()); -+ blockList.setTypeAndData(blockposition_mutableblockposition, flag1 ? Blocks.OBSIDIAN.getBlockData() : Blocks.AIR.getBlockData(), 3); // CraftBukkit + blockposition_mutableblockposition.a((BaseBlockPosition) blockposition1, j * enumdirection.getAdjacentX() + j1 * enumdirection1.getAdjacentX(), k1, j * enumdirection.getAdjacentZ() + j1 * enumdirection1.getAdjacentZ()); +- this.world.setTypeUpdate(blockposition_mutableblockposition, iblockdata); ++ blockList.setTypeAndData(blockposition_mutableblockposition, iblockdata, 3); // CraftBukkit } } } -@@ -220,7 +243,7 @@ - for (i3 = -1; i3 < 4; ++i3) { - if (k2 == -1 || k2 == 2 || i3 == -1 || i3 == 3) { - blockposition_mutableblockposition.d(i5 + k2 * k5, j5 + i3, j2 + k2 * l5); +@@ -126,7 +139,7 @@ + for (j1 = -1; j1 < 4; ++j1) { + if (l1 == -1 || l1 == 2 || j1 == -1 || j1 == 3) { + blockposition_mutableblockposition.a((BaseBlockPosition) blockposition1, l1 * enumdirection.getAdjacentX(), j1, l1 * enumdirection.getAdjacentZ()); - this.world.setTypeAndData(blockposition_mutableblockposition, Blocks.OBSIDIAN.getBlockData(), 3); + blockList.setTypeAndData(blockposition_mutableblockposition, Blocks.OBSIDIAN.getBlockData(), 3); // CraftBukkit } } } -@@ -230,10 +253,19 @@ - for (i3 = 0; i3 < 2; ++i3) { - for (l2 = 0; l2 < 3; ++l2) { - blockposition_mutableblockposition.d(i5 + i3 * k5, j5 + l2, j2 + i3 * l5); -- this.world.setTypeAndData(blockposition_mutableblockposition, iblockdata, 18); -+ blockList.setTypeAndData(blockposition_mutableblockposition, iblockdata, 18); // CraftBukkit +@@ -136,10 +149,19 @@ + for (j1 = 0; j1 < 2; ++j1) { + for (j = 0; j < 3; ++j) { + blockposition_mutableblockposition.a((BaseBlockPosition) blockposition1, j1 * enumdirection.getAdjacentX(), j, j1 * enumdirection.getAdjacentZ()); +- this.world.setTypeAndData(blockposition_mutableblockposition, iblockdata1, 18); ++ blockList.setTypeAndData(blockposition_mutableblockposition, iblockdata1, 18); // CraftBukkit } } + // CraftBukkit start + org.bukkit.World bworld = this.world.getWorld(); -+ org.bukkit.event.world.PortalCreateEvent event = new org.bukkit.event.world.PortalCreateEvent((java.util.List) (java.util.List) blockList.getList(), bworld, entity.getBukkitEntity(), org.bukkit.event.world.PortalCreateEvent.CreateReason.NETHER_PAIR); ++ org.bukkit.event.world.PortalCreateEvent event = new org.bukkit.event.world.PortalCreateEvent((java.util.List) (java.util.List) blockList.getList(), bworld, (entity == null) ? null : entity.getBukkitEntity(), org.bukkit.event.world.PortalCreateEvent.CreateReason.NETHER_PAIR); + + this.world.getServer().getPluginManager().callEvent(event); + if (!event.isCancelled()) { + blockList.updateList(); + } + // CraftBukkit end - return true; + return Optional.of(new BlockUtil.Rectangle(blockposition1.immutableCopy(), 2, 3)); } - } + diff --git a/nms-patches/PropertyManager.patch b/nms-patches/PropertyManager.patch index f7c9a5b26c..ed74157a52 100644 --- a/nms-patches/PropertyManager.patch +++ b/nms-patches/PropertyManager.patch @@ -93,8 +93,8 @@ return properties; } -- protected abstract T reload(Properties properties); -+ protected abstract T reload(Properties properties, OptionSet optionset); // CraftBukkit +- protected abstract T reload(IRegistryCustom iregistrycustom, Properties properties); ++ protected abstract T reload(IRegistryCustom iregistrycustom, Properties properties, OptionSet optionset); // CraftBukkit public class EditableProperty implements Supplier { @@ -111,8 +111,8 @@ Properties properties = PropertyManager.this.a(); properties.put(this.b, this.d.apply(v0)); -- return PropertyManager.this.reload(properties); -+ return PropertyManager.this.reload(properties, PropertyManager.this.options); // CraftBukkit +- return PropertyManager.this.reload(iregistrycustom, properties); ++ return PropertyManager.this.reload(iregistrycustom, properties, PropertyManager.this.options); // CraftBukkit } } } diff --git a/nms-patches/Raid.patch b/nms-patches/Raid.patch index b5f4d8d2cd..8412ec4e8f 100644 --- a/nms-patches/Raid.patch +++ b/nms-patches/Raid.patch @@ -22,7 +22,7 @@ return; } @@ -205,13 +212,16 @@ - if (!this.world.b_(this.center)) { + if (!this.world.a_(this.center)) { if (this.groupsSpawned > 0) { this.status = Raid.Status.LOSS; + org.bukkit.craftbukkit.event.CraftEventFactory.callRaidFinishEvent(this, new java.util.ArrayList<>()); // CraftBukkit @@ -116,9 +116,9 @@ @@ -511,7 +534,7 @@ entityraider.prepare(this.world, this.world.getDamageScaler(blockposition), EnumMobSpawn.EVENT, (GroupDataEntity) null, (NBTTagCompound) null); entityraider.a(i, false); - entityraider.c(true); -- this.world.addEntity(entityraider); -+ this.world.addEntity(entityraider, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.RAID); // CraftBukkit + entityraider.setOnGround(true); +- this.world.addAllEntities(entityraider); ++ this.world.addAllEntities(entityraider, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.RAID); // CraftBukkit } } diff --git a/nms-patches/RecipeBook.patch b/nms-patches/RecipeBook.patch deleted file mode 100644 index 2034712bcb..0000000000 --- a/nms-patches/RecipeBook.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/server/RecipeBook.java -+++ b/net/minecraft/server/RecipeBook.java -@@ -6,7 +6,7 @@ - - public class RecipeBook { - -- protected final Set a = Sets.newHashSet(); -+ public final Set a = Sets.newHashSet(); // PAIL - protected final Set b = Sets.newHashSet(); - protected boolean c; - protected boolean d; diff --git a/nms-patches/RecipeBookServer.patch b/nms-patches/RecipeBookServer.patch index 2f34c04557..e298e422d4 100644 --- a/nms-patches/RecipeBookServer.patch +++ b/nms-patches/RecipeBookServer.patch @@ -12,8 +12,8 @@ IRecipe irecipe = (IRecipe) iterator.next(); MinecraftKey minecraftkey = irecipe.getKey(); -- if (!this.a.contains(minecraftkey) && !irecipe.isComplex()) { -+ if (!this.a.contains(minecraftkey) && !irecipe.isComplex() && CraftEventFactory.handlePlayerRecipeListUpdateEvent(entityplayer, minecraftkey)) { // CraftBukkit +- if (!this.recipes.contains(minecraftkey) && !irecipe.isComplex()) { ++ if (!this.recipes.contains(minecraftkey) && !irecipe.isComplex() && CraftEventFactory.handlePlayerRecipeListUpdateEvent(entityplayer, minecraftkey)) { // CraftBukkit this.a(minecraftkey); this.d(minecraftkey); list.add(minecraftkey); @@ -22,6 +22,6 @@ private void a(PacketPlayOutRecipes.Action packetplayoutrecipes_action, EntityPlayer entityplayer, List list) { + if (entityplayer.playerConnection == null) return; // SPIGOT-4478 during PlayerLoginEvent - entityplayer.playerConnection.sendPacket(new PacketPlayOutRecipes(packetplayoutrecipes_action, list, Collections.emptyList(), this.c, this.d, this.e, this.f)); + entityplayer.playerConnection.sendPacket(new PacketPlayOutRecipes(packetplayoutrecipes_action, list, Collections.emptyList(), this.a())); } diff --git a/nms-patches/RegionFileCache.patch b/nms-patches/RegionFileCache.patch index e00529c99e..3a17b2ae07 100644 --- a/nms-patches/RegionFileCache.patch +++ b/nms-patches/RegionFileCache.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/RegionFileCache.java +++ b/net/minecraft/server/RegionFileCache.java -@@ -20,7 +20,7 @@ +@@ -21,7 +21,7 @@ this.c = flag; } @@ -9,7 +9,7 @@ long i = ChunkCoordIntPair.pair(chunkcoordintpair.getRegionX(), chunkcoordintpair.getRegionZ()); RegionFile regionfile = (RegionFile) this.cache.getAndMoveToFirst(i); -@@ -36,6 +36,7 @@ +@@ -37,6 +37,7 @@ } File file = new File(this.b, "r." + chunkcoordintpair.getRegionX() + "." + chunkcoordintpair.getRegionZ() + ".mca"); @@ -17,7 +17,7 @@ RegionFile regionfile1 = new RegionFile(file, this.b, this.c); this.cache.putAndMoveToFirst(i, regionfile1); -@@ -45,7 +46,12 @@ +@@ -46,7 +47,12 @@ @Nullable public NBTTagCompound read(ChunkCoordIntPair chunkcoordintpair) throws IOException { @@ -31,7 +31,7 @@ DataInputStream datainputstream = regionfile.a(chunkcoordintpair); Throwable throwable = null; -@@ -80,7 +86,7 @@ +@@ -81,7 +87,7 @@ } protected void write(ChunkCoordIntPair chunkcoordintpair, NBTTagCompound nbttagcompound) throws IOException { diff --git a/nms-patches/RegionLimitedWorldAccess.patch b/nms-patches/RegionLimitedWorldAccess.patch index 37bf242ae9..8759110f03 100644 --- a/nms-patches/RegionLimitedWorldAccess.patch +++ b/nms-patches/RegionLimitedWorldAccess.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/RegionLimitedWorldAccess.java +++ b/net/minecraft/server/RegionLimitedWorldAccess.java -@@ -233,6 +233,13 @@ +@@ -234,6 +234,13 @@ @Override public boolean addEntity(Entity entity) { diff --git a/nms-patches/RemoteControlListener.patch b/nms-patches/RemoteControlListener.patch deleted file mode 100644 index 03a7df4020..0000000000 --- a/nms-patches/RemoteControlListener.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/server/RemoteControlListener.java -+++ b/net/minecraft/server/RemoteControlListener.java -@@ -109,7 +109,7 @@ - RemoteControlListener.LOGGER.debug("closeSocket: {}", serversocket); - - try { -- serversocket.close(); -+ if (serversocket != null) serversocket.close(); // CraftBukkit - SPIGOT-5867, MC-193339: NPE during shutdown if no password - } catch (IOException ioexception) { - RemoteControlListener.LOGGER.warn("Failed to close socket", ioexception); - } diff --git a/nms-patches/SaddleStorage.patch b/nms-patches/SaddleStorage.patch index ba3928f515..5e0a2003a6 100644 --- a/nms-patches/SaddleStorage.patch +++ b/nms-patches/SaddleStorage.patch @@ -6,10 +6,10 @@ + // CraftBukkit add setBoostTicks(int) + public void setBoostTicks(int ticks) { -+ this.a = true; // PAIL rename boosting -+ this.b = 0; // PAIL rename currentBoostTicks -+ this.c = ticks; // PAIL rename boostTicks -+ this.d.set(this.e, this.c); // PAIL rename dataWatcher, dataWatcherBoostTicks ++ this.boosting = true; ++ this.currentBoostTicks = 0; ++ this.boostTicks = ticks; ++ this.dataWatcher.set(this.dataWatcherBoostTicks, this.boostTicks); + } + // CraftBukkit end + diff --git a/nms-patches/ServerConnection.patch b/nms-patches/ServerConnection.patch index 906024952a..5d6f91bead 100644 --- a/nms-patches/ServerConnection.patch +++ b/nms-patches/ServerConnection.patch @@ -1,8 +1,13 @@ --- a/net/minecraft/server/ServerConnection.java +++ b/net/minecraft/server/ServerConnection.java -@@ -76,10 +76,20 @@ - channel.pipeline().addLast("packet_handler", networkmanager); - networkmanager.setPacketListener(new HandshakeListener(ServerConnection.this.e, networkmanager)); +@@ -74,14 +74,24 @@ + int j = ServerConnection.this.e.k(); + Object object = j > 0 ? new NetworkManagerServer(j) : new NetworkManager(EnumProtocolDirection.SERVERBOUND); + +- ServerConnection.this.connectedChannels.add(object); ++ ServerConnection.this.connectedChannels.add((NetworkManager) object); // CraftBukkit - decompile error + channel.pipeline().addLast("packet_handler", (ChannelHandler) object); + ((NetworkManager) object).setPacketListener(new HandshakeListener(ServerConnection.this.e, (NetworkManager) object)); } - }).group((EventLoopGroup) lazyinitvar.a()).localAddress(inetaddress, i)).bind().syncUninterruptibly()); + }).group((EventLoopGroup) lazyinitvar.a()).localAddress(inetaddress, i)).option(ChannelOption.AUTO_READ, false).bind().syncUninterruptibly()); // CraftBukkit diff --git a/nms-patches/ShapeDetectorShape.patch b/nms-patches/ShapeDetectorShape.patch new file mode 100644 index 0000000000..7d2311667f --- /dev/null +++ b/nms-patches/ShapeDetectorShape.patch @@ -0,0 +1,16 @@ +--- a/net/minecraft/server/ShapeDetectorShape.java ++++ b/net/minecraft/server/ShapeDetectorShape.java +@@ -6,8 +6,12 @@ + public final Vec3D velocity; + public final float yaw; + public final float pitch; ++ // CraftBukkit start ++ public final WorldServer world; + +- public ShapeDetectorShape(Vec3D vec3d, Vec3D vec3d1, float f, float f1) { ++ public ShapeDetectorShape(Vec3D vec3d, Vec3D vec3d1, float f, float f1, WorldServer world) { ++ this.world = world; ++ // CraftBukkit end + this.position = vec3d; + this.velocity = vec3d1; + this.yaw = f; diff --git a/nms-patches/SpawnerCreature.patch b/nms-patches/SpawnerCreature.patch index e8e0ae36f5..9d413d4f95 100644 --- a/nms-patches/SpawnerCreature.patch +++ b/nms-patches/SpawnerCreature.patch @@ -21,7 +21,7 @@ continue; } } -@@ -70,10 +75,49 @@ +@@ -69,10 +74,49 @@ EnumCreatureType[] aenumcreaturetype = SpawnerCreature.c; int i = aenumcreaturetype.length; @@ -72,16 +72,16 @@ a(enumcreaturetype, worldserver, chunk, (entitytypes, blockposition, ichunkaccess) -> { return spawnercreature_d.a(entitytypes, blockposition, ichunkaccess); }, (entityinsentient, ichunkaccess) -> { -@@ -148,10 +192,13 @@ +@@ -147,10 +191,13 @@ entityinsentient.setPositionRotation(d0, (double) i, d1, worldserver.random.nextFloat() * 360.0F, 0.0F); if (a(worldserver, entityinsentient, d2)) { groupdataentity = entityinsentient.prepare(worldserver, worldserver.getDamageScaler(entityinsentient.getChunkCoordinates()), EnumMobSpawn.NATURAL, groupdataentity, (NBTTagCompound) null); - ++j; - ++k1; -- worldserver.addEntity(entityinsentient); +- worldserver.addAllEntities(entityinsentient); - spawnercreature_a.run(entityinsentient, ichunkaccess); + // CraftBukkit start -+ if (worldserver.addEntity(entityinsentient, SpawnReason.NATURAL)) { ++ if (worldserver.addAllEntities(entityinsentient, SpawnReason.NATURAL)) { + ++j; + ++k1; + spawnercreature_a.run(entityinsentient, ichunkaccess); @@ -92,14 +92,14 @@ } @@ -333,7 +380,7 @@ - if (entityinsentient.a(generatoraccess, EnumMobSpawn.CHUNK_GENERATION) && entityinsentient.a((IWorldReader) generatoraccess)) { - groupdataentity = entityinsentient.prepare(generatoraccess, generatoraccess.getDamageScaler(entityinsentient.getChunkCoordinates()), EnumMobSpawn.CHUNK_GENERATION, groupdataentity, (NBTTagCompound) null); -- generatoraccess.addEntity(entityinsentient); -+ generatoraccess.addEntity(entityinsentient, SpawnReason.CHUNK_GEN); // CraftBukkit + if (entityinsentient.a((GeneratorAccess) worldaccess, EnumMobSpawn.CHUNK_GENERATION) && entityinsentient.a((IWorldReader) worldaccess)) { + groupdataentity = entityinsentient.prepare(worldaccess, worldaccess.getDamageScaler(entityinsentient.getChunkCoordinates()), EnumMobSpawn.CHUNK_GENERATION, groupdataentity, (NBTTagCompound) null); +- worldaccess.addAllEntities(entityinsentient); ++ worldaccess.addAllEntities(entityinsentient, SpawnReason.CHUNK_GEN); // CraftBukkit flag = true; } } -@@ -458,8 +505,10 @@ +@@ -456,8 +503,10 @@ return this.d; } diff --git a/nms-patches/TagRegistry.patch b/nms-patches/TagRegistry.patch deleted file mode 100644 index 78aedf0828..0000000000 --- a/nms-patches/TagRegistry.patch +++ /dev/null @@ -1,15 +0,0 @@ ---- a/net/minecraft/server/TagRegistry.java -+++ b/net/minecraft/server/TagRegistry.java -@@ -68,6 +68,12 @@ - this.itemTags.a((Map) completablefuture1.join()); - this.fluidTags.a((Map) completablefuture2.join()); - this.entityTags.a((Map) completablefuture3.join()); -+ // CraftBukkit start -+ this.blockTags.version++; -+ this.itemTags.version++; -+ this.fluidTags.version++; -+ this.entityTags.version++; -+ // CraftBukkit end - TagsInstance.a(this.blockTags, this.itemTags, this.fluidTags, this.entityTags); - Multimap multimap = HashMultimap.create(); - diff --git a/nms-patches/TagsServer.patch b/nms-patches/TagsServer.patch deleted file mode 100644 index 36747db4f8..0000000000 --- a/nms-patches/TagsServer.patch +++ /dev/null @@ -1,19 +0,0 @@ ---- a/net/minecraft/server/TagsServer.java -+++ b/net/minecraft/server/TagsServer.java -@@ -10,6 +10,7 @@ - public class TagsServer extends Tags { - - private final IRegistry a; -+ public int version; // CraftBukkit - - public TagsServer(IRegistry iregistry, String s, String s1) { - super(iregistry::getOptional, s, s1); -@@ -30,7 +31,7 @@ - Iterator iterator1 = ((Tag) entry.getValue()).getTagged().iterator(); - - while (iterator1.hasNext()) { -- T t0 = iterator1.next(); -+ T t0 = (T) iterator1.next(); // CraftBukkit - decompile error - - packetdataserializer.d(this.a.a(t0)); - } diff --git a/nms-patches/TileEntityBarrel.patch b/nms-patches/TileEntityBarrel.patch index 44a6fdec8e..b72513844e 100644 --- a/nms-patches/TileEntityBarrel.patch +++ b/nms-patches/TileEntityBarrel.patch @@ -64,18 +64,4 @@ + boolean flag = (Boolean) iblockdata.get(BlockBarrel.b) && !opened; // CraftBukkit - only set flag if Barrel isn't set open by API. if (flag) { - this.a(iblockdata, SoundEffects.BLOCK_BARREL_CLOSE); -@@ -118,11 +166,11 @@ - - } - -- private void a(IBlockData iblockdata, boolean flag) { -+ public void a(IBlockData iblockdata, boolean flag) { // PAIL private -> public, rename setFlag - this.world.setTypeAndData(this.getPosition(), (IBlockData) iblockdata.set(BlockBarrel.b, flag), 3); - } - -- private void a(IBlockData iblockdata, SoundEffect soundeffect) { -+ public void a(IBlockData iblockdata, SoundEffect soundeffect) { // PAIL private -> public, rename playSound - BaseBlockPosition baseblockposition = ((EnumDirection) iblockdata.get(BlockBarrel.a)).p(); - double d0 = (double) this.position.getX() + 0.5D + (double) baseblockposition.getX() / 2.0D; - double d1 = (double) this.position.getY() + 0.5D + (double) baseblockposition.getY() / 2.0D; + this.playOpenSound(iblockdata, SoundEffects.BLOCK_BARREL_CLOSE); diff --git a/nms-patches/TileEntityBeacon.patch b/nms-patches/TileEntityBeacon.patch index 3e775e2ec7..9c8369c377 100644 --- a/nms-patches/TileEntityBeacon.patch +++ b/nms-patches/TileEntityBeacon.patch @@ -31,7 +31,7 @@ public TileEntityBeacon() { super(TileEntityTypes.BEACON); @@ -192,39 +208,78 @@ - super.an_(); + super.al_(); } - private void applyEffects() { diff --git a/nms-patches/TileEntityChest.patch b/nms-patches/TileEntityChest.patch index 4629fee75b..31ada4dcb3 100644 --- a/nms-patches/TileEntityChest.patch +++ b/nms-patches/TileEntityChest.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/TileEntityChest.java +++ b/net/minecraft/server/TileEntityChest.java -@@ -2,15 +2,50 @@ +@@ -2,6 +2,10 @@ import java.util.Iterator; import java.util.List; @@ -11,11 +11,8 @@ public class TileEntityChest extends TileEntityLootable implements ITickable { - private NonNullList items; - protected float a; - protected float b; -- protected int viewingCount; -+ public int viewingCount; // PAIL protected -> public +@@ -11,6 +15,37 @@ + public int viewingCount; private int j; + // CraftBukkit start - add fields and methods @@ -64,17 +61,8 @@ + // CraftBukkit end + if (this.viewingCount > 0 && this.a == 0.0F) { - this.a(SoundEffects.BLOCK_CHEST_OPEN); + this.playOpenSound(SoundEffects.BLOCK_CHEST_OPEN); } -@@ -120,7 +162,7 @@ - return l; - } - -- private void a(SoundEffect soundeffect) { -+ public void a(SoundEffect soundeffect) { // PAIL private -> public, rename playSound - BlockPropertyChestType blockpropertychesttype = (BlockPropertyChestType) this.getBlock().get(BlockChest.c); - - if (blockpropertychesttype != BlockPropertyChestType.LEFT) { @@ -155,8 +197,20 @@ if (this.viewingCount < 0) { this.viewingCount = 0; diff --git a/nms-patches/TileEntityEndGateway.patch b/nms-patches/TileEntityEndGateway.patch index 924a0849fa..ea941e144d 100644 --- a/nms-patches/TileEntityEndGateway.patch +++ b/nms-patches/TileEntityEndGateway.patch @@ -13,8 +13,8 @@ public class TileEntityEndGateway extends TileEntityEnderPortal implements ITickable { -@@ -113,7 +119,7 @@ - public void a(Entity entity) { +@@ -117,7 +123,7 @@ + public void b(Entity entity) { if (this.world instanceof WorldServer && !this.f()) { this.c = 100; - if (this.exitPortal == null && this.world.getDimensionKey() == World.THE_END) { @@ -22,7 +22,7 @@ this.a((WorldServer) this.world); } -@@ -138,6 +144,26 @@ +@@ -142,6 +148,27 @@ entity1 = entity.getRootVehicle(); } @@ -39,6 +39,7 @@ + return; + } + ++ entity1.resetPortalCooldown(); + ((EntityPlayer) entity1).playerConnection.teleport(teleEvent.getTo()); + this.h(); // CraftBukkit - call at end of method + return; @@ -46,24 +47,15 @@ + } + // CraftBukkit end + + entity1.resetPortalCooldown(); entity1.enderTeleportAndLoad((double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D); } - -@@ -173,7 +199,7 @@ - if (this.exitPortal == null) { - this.exitPortal = new BlockPosition(vec3d1.x + 0.5D, 75.0D, vec3d1.z + 0.5D); - TileEntityEndGateway.LOGGER.debug("Failed to find suitable block, settling on {}", this.exitPortal); -- WorldGenerator.END_ISLAND.b((WorldGenFeatureConfiguration) WorldGenFeatureConfiguration.k).a(worldserver, worldserver.getStructureManager(), worldserver.getChunkProvider().getChunkGenerator(), new Random(this.exitPortal.asLong()), this.exitPortal); -+ WorldGenerator.END_ISLAND.b(WorldGenFeatureConfiguration.k).a(worldserver, worldserver.getStructureManager(), worldserver.getChunkProvider().getChunkGenerator(), new Random(this.exitPortal.asLong()), this.exitPortal); // CraftBukkit - decompile error - } else { - TileEntityEndGateway.LOGGER.debug("Found block at {}", this.exitPortal); - } -@@ -241,7 +267,7 @@ +@@ -246,7 +273,7 @@ } private void a(WorldServer worldserver, BlockPosition blockposition) { -- WorldGenerator.END_GATEWAY.b((WorldGenFeatureConfiguration) WorldGenEndGatewayConfiguration.a(this.getPosition(), false)).a(worldserver, worldserver.getStructureManager(), worldserver.getChunkProvider().getChunkGenerator(), new Random(), blockposition); -+ WorldGenerator.END_GATEWAY.b(WorldGenEndGatewayConfiguration.a(this.getPosition(), false)).a(worldserver, worldserver.getStructureManager(), worldserver.getChunkProvider().getChunkGenerator(), new Random(), blockposition); // CraftBukkit - decompile error +- WorldGenerator.END_GATEWAY.b((WorldGenFeatureConfiguration) WorldGenEndGatewayConfiguration.a(this.getPosition(), false)).a(worldserver, worldserver.getChunkProvider().getChunkGenerator(), new Random(), blockposition); ++ WorldGenerator.END_GATEWAY.b(WorldGenEndGatewayConfiguration.a(this.getPosition(), false)).a(worldserver, worldserver.getChunkProvider().getChunkGenerator(), new Random(), blockposition); // CraftBukkit - decompile error } public void a(BlockPosition blockposition, boolean flag) { diff --git a/nms-patches/TileEntityFurnace.patch b/nms-patches/TileEntityFurnace.patch index d275e5be8c..16d3e3aa11 100644 --- a/nms-patches/TileEntityFurnace.patch +++ b/nms-patches/TileEntityFurnace.patch @@ -154,7 +154,7 @@ @@ -462,14 +546,14 @@ - world.getCraftingManager().a((MinecraftKey) entry.getKey()).ifPresent((irecipe) -> { + world.getCraftingManager().getRecipe((MinecraftKey) entry.getKey()).ifPresent((irecipe) -> { list.add(irecipe); - a(world, vec3d, entry.getIntValue(), ((RecipeCooking) irecipe).getExperience()); + a(world, vec3d, entry.getIntValue(), ((RecipeCooking) irecipe).getExperience(), entityhuman, itemstack, amount); // CraftBukkit diff --git a/nms-patches/TileEntityShulkerBox.patch b/nms-patches/TileEntityShulkerBox.patch index caebc970a7..cc7d9da15a 100644 --- a/nms-patches/TileEntityShulkerBox.patch +++ b/nms-patches/TileEntityShulkerBox.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/TileEntityShulkerBox.java +++ b/net/minecraft/server/TileEntityShulkerBox.java -@@ -3,12 +3,16 @@ +@@ -3,6 +3,10 @@ import java.util.List; import java.util.stream.IntStream; import javax.annotation.Nullable; @@ -11,13 +11,6 @@ public class TileEntityShulkerBox extends TileEntityLootable implements IWorldInventory, ITickable { - private static final int[] a = IntStream.range(0, 27).toArray(); - private NonNullList contents; -- private int c; -+ public int c; // PAIL private -> public, rename viewerCount - private TileEntityShulkerBox.AnimationPhase i; - private float j; - private float k; @@ -16,6 +20,37 @@ private EnumColor l; private boolean m; @@ -59,16 +52,16 @@ @@ -178,6 +213,7 @@ } - ++this.c; + ++this.viewingCount; + if (opened) return; // CraftBukkit - only animate if the ShulkerBox hasn't been forced open already by an API call. - this.world.playBlockAction(this.position, this.getBlock().getBlock(), 1, this.c); - if (this.c == 1) { + this.world.playBlockAction(this.position, this.getBlock().getBlock(), 1, this.viewingCount); + if (this.viewingCount == 1) { this.world.playSound((EntityHuman) null, this.position, SoundEffects.BLOCK_SHULKER_BOX_OPEN, SoundCategory.BLOCKS, 0.5F, this.world.random.nextFloat() * 0.1F + 0.9F); @@ -190,6 +226,7 @@ public void closeContainer(EntityHuman entityhuman) { if (!entityhuman.isSpectator()) { - --this.c; + --this.viewingCount; + if (opened) return; // CraftBukkit - only animate if the ShulkerBox hasn't been forced open already by an API call. - this.world.playBlockAction(this.position, this.getBlock().getBlock(), 1, this.c); - if (this.c <= 0) { + this.world.playBlockAction(this.position, this.getBlock().getBlock(), 1, this.viewingCount); + if (this.viewingCount <= 0) { this.world.playSound((EntityHuman) null, this.position, SoundEffects.BLOCK_SHULKER_BOX_CLOSE, SoundCategory.BLOCKS, 0.5F, this.world.random.nextFloat() * 0.1F + 0.9F); diff --git a/nms-patches/UserCache.patch b/nms-patches/UserCache.patch deleted file mode 100644 index 561343e9e6..0000000000 --- a/nms-patches/UserCache.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/server/UserCache.java -+++ b/net/minecraft/server/UserCache.java -@@ -45,7 +45,7 @@ - private static boolean c; - private final Map d = Maps.newHashMap(); - private final Map e = Maps.newHashMap(); -- private final Deque f = Lists.newLinkedList(); -+ private final Deque f = new java.util.concurrent.LinkedBlockingDeque(); // CraftBukkit - private final GameProfileRepository g; - protected final Gson b; - private final File h; diff --git a/nms-patches/VillageSiege.patch b/nms-patches/VillageSiege.patch index 62f74972d9..7c6f8e2016 100644 --- a/nms-patches/VillageSiege.patch +++ b/nms-patches/VillageSiege.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/server/VillageSiege.java +++ b/net/minecraft/server/VillageSiege.java -@@ -105,7 +105,7 @@ +@@ -108,7 +108,7 @@ } entityzombie.setPositionRotation(vec3d.x, vec3d.y, vec3d.z, worldserver.random.nextFloat() * 360.0F, 0.0F); -- worldserver.addEntity(entityzombie); -+ worldserver.addEntity(entityzombie, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.VILLAGE_INVASION); // CraftBukkit +- worldserver.addAllEntities(entityzombie); ++ worldserver.addAllEntities(entityzombie, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.VILLAGE_INVASION); // CraftBukkit } } diff --git a/nms-patches/World.patch b/nms-patches/World.patch index b9d8f56632..a11ba7e5de 100644 --- a/nms-patches/World.patch +++ b/nms-patches/World.patch @@ -18,12 +18,13 @@ public abstract class World implements GeneratorAccess, AutoCloseable { protected static final Logger LOGGER = LogManager.getLogger(); -@@ -46,7 +57,41 @@ +@@ -45,7 +56,49 @@ + private final BiomeManager biomeManager; private final ResourceKey dimensionKey; - private final ResourceKey typeKey; -- protected World(WorldDataMutable worlddatamutable, ResourceKey resourcekey, ResourceKey resourcekey1, DimensionManager dimensionmanager, Supplier supplier, boolean flag, boolean flag1, long i) { +- protected World(WorldDataMutable worlddatamutable, ResourceKey resourcekey, final DimensionManager dimensionmanager, Supplier supplier, boolean flag, boolean flag1, long i) { + // CraftBukkit start Added the following ++ private final ResourceKey typeKey; + private final CraftWorld world; + public boolean pvpMode; + public boolean keepSpawnInMemory = true; @@ -49,7 +50,11 @@ + return (CraftServer) Bukkit.getServer(); + } + -+ protected World(WorldDataMutable worlddatamutable, ResourceKey resourcekey, ResourceKey resourcekey1, DimensionManager dimensionmanager, Supplier supplier, boolean flag, boolean flag1, long i, org.bukkit.generator.ChunkGenerator gen, org.bukkit.World.Environment env) { ++ public ResourceKey getTypeKey() { ++ return typeKey; ++ } ++ ++ protected World(WorldDataMutable worlddatamutable, ResourceKey resourcekey, final DimensionManager dimensionmanager, Supplier supplier, boolean flag, boolean flag1, long i, org.bukkit.generator.ChunkGenerator gen, org.bukkit.World.Environment env) { + this.generator = gen; + this.world = new CraftWorld((WorldServer) this, gen, env); + this.ticksPerAnimalSpawns = this.getServer().getTicksPerAnimalSpawns(); // CraftBukkit @@ -57,26 +62,29 @@ + this.ticksPerWaterSpawns = this.getServer().getTicksPerWaterSpawns(); // CraftBukkit + this.ticksPerWaterAmbientSpawns = this.getServer().getTicksPerWaterAmbientSpawns(); // CraftBukkit + this.ticksPerAmbientSpawns = this.getServer().getTicksPerAmbientSpawns(); // CraftBukkit ++ this.typeKey = (ResourceKey) this.getServer().getHandle().getServer().f.a().c(dimensionmanager).orElseThrow(() -> { ++ return new IllegalStateException("Unregistered dimension type: " + dimensionmanager); ++ }); + // CraftBukkit end this.methodProfiler = supplier; this.worldData = worlddatamutable; this.x = dimensionmanager; -@@ -57,12 +102,12 @@ +@@ -55,12 +108,12 @@ this.worldBorder = new WorldBorder() { @Override public double getCenterX() { -- return super.getCenterX() / 8.0D; +- return super.getCenterX() / dimensionmanager.getCoordinateScale(); + return super.getCenterX(); // CraftBukkit } @Override public double getCenterZ() { -- return super.getCenterZ() / 8.0D; +- return super.getCenterZ() / dimensionmanager.getCoordinateScale(); + return super.getCenterZ(); // CraftBukkit } }; } else { -@@ -72,6 +117,35 @@ +@@ -70,6 +123,35 @@ this.serverThread = Thread.currentThread(); this.biomeManager = new BiomeManager(this, i, dimensionmanager.getGenLayerZoomer()); this.debugWorld = flag1; @@ -112,7 +120,7 @@ } @Override -@@ -176,6 +250,17 @@ +@@ -133,6 +215,17 @@ @Override public boolean a(BlockPosition blockposition, IBlockData iblockdata, int i, int j) { @@ -130,7 +138,7 @@ if (isOutsideWorld(blockposition)) { return false; } else if (!this.isClientSide && this.isDebugWorld()) { -@@ -183,9 +268,24 @@ +@@ -140,9 +233,24 @@ } else { Chunk chunk = this.getChunkAtWorldCoords(blockposition); Block block = iblockdata.getBlock(); @@ -156,7 +164,7 @@ return false; } else { IBlockData iblockdata2 = this.getType(blockposition); -@@ -196,6 +296,7 @@ +@@ -153,6 +261,7 @@ this.getMethodProfiler().exit(); } @@ -164,7 +172,7 @@ if (iblockdata2 == iblockdata) { if (iblockdata1 != iblockdata2) { this.b(blockposition, iblockdata1, iblockdata2); -@@ -222,12 +323,65 @@ +@@ -179,12 +288,65 @@ this.a(blockposition, iblockdata1, iblockdata2); } @@ -230,7 +238,7 @@ public void a(BlockPosition blockposition, IBlockData iblockdata, IBlockData iblockdata1) {} @Override -@@ -309,6 +463,17 @@ +@@ -266,6 +428,17 @@ IBlockData iblockdata = this.getType(blockposition); try { @@ -248,7 +256,7 @@ iblockdata.doPhysics(this, blockposition, block, blockposition1, false); } catch (Throwable throwable) { CrashReport crashreport = CrashReport.a(throwable, "Exception while updating neighbours"); -@@ -351,6 +516,14 @@ +@@ -308,6 +481,14 @@ @Override public IBlockData getType(BlockPosition blockposition) { @@ -263,7 +271,7 @@ if (isOutsideWorld(blockposition)) { return Blocks.VOID_AIR.getBlockData(); } else { -@@ -498,9 +671,11 @@ +@@ -455,9 +636,11 @@ TileEntity tileentity1 = (TileEntity) this.tileEntityListPending.get(i); if (!tileentity1.isRemoved()) { @@ -275,7 +283,7 @@ if (this.isLoaded(tileentity1.getPosition())) { Chunk chunk = this.getChunkAtWorldCoords(tileentity1.getPosition()); -@@ -508,6 +683,12 @@ +@@ -465,6 +648,12 @@ chunk.setTileEntity(tileentity1.getPosition(), tileentity1); this.notify(tileentity1.getPosition(), iblockdata, iblockdata, 3); @@ -288,7 +296,7 @@ } } } -@@ -548,12 +729,25 @@ +@@ -505,12 +694,25 @@ @Nullable @Override @@ -314,7 +322,7 @@ TileEntity tileentity = null; if (this.tickingTileEntities) { -@@ -588,6 +782,13 @@ +@@ -545,6 +747,13 @@ public void setTileEntity(BlockPosition blockposition, @Nullable TileEntity tileentity) { if (!isOutsideWorld(blockposition)) { if (tileentity != null && !tileentity.isRemoved()) { @@ -328,7 +336,7 @@ if (this.tickingTileEntities) { tileentity.setLocation(this, blockposition); Iterator iterator = this.tileEntityListPending.iterator(); -@@ -612,7 +813,7 @@ +@@ -569,7 +778,7 @@ } public void removeTileEntity(BlockPosition blockposition) { @@ -336,4 +344,4 @@ + TileEntity tileentity = this.getTileEntity(blockposition, false); // CraftBukkit if (tileentity != null && this.tickingTileEntities) { - tileentity.an_(); + tileentity.al_(); diff --git a/nms-patches/WorldAccess.patch b/nms-patches/WorldAccess.patch new file mode 100644 index 0000000000..da85625cdf --- /dev/null +++ b/nms-patches/WorldAccess.patch @@ -0,0 +1,17 @@ +--- a/net/minecraft/server/WorldAccess.java ++++ b/net/minecraft/server/WorldAccess.java +@@ -5,6 +5,13 @@ + WorldServer getMinecraftWorld(); + + default void addAllEntities(Entity entity) { +- entity.co().forEach(this::addEntity); ++ // CraftBukkit start ++ this.addAllEntities(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT); + } ++ ++ default boolean addAllEntities(Entity entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) { ++ entity.co().forEach((e) -> this.addEntity(e, reason)); ++ return !entity.dead; ++ } ++ // CraftBukkit end + } diff --git a/nms-patches/WorldBorder.patch b/nms-patches/WorldBorder.patch index e89a3161fa..66e53f812f 100644 --- a/nms-patches/WorldBorder.patch +++ b/nms-patches/WorldBorder.patch @@ -3,7 +3,7 @@ @@ -17,6 +17,7 @@ private int i = 29999984; private WorldBorder.a j = new WorldBorder.d(6.0E7D); - public static final WorldBorder.c b = new WorldBorder.c(0.0D, 0.0D, 0.2D, 5.0D, 5, 15, 6.0E7D, 0L, 0.0D); + public static final WorldBorder.c c = new WorldBorder.c(0.0D, 0.0D, 0.2D, 5.0D, 5, 15, 6.0E7D, 0L, 0.0D); + public WorldServer world; // CraftBukkit public WorldBorder() {} diff --git a/nms-patches/WorldDataServer.patch b/nms-patches/WorldDataServer.patch index 3d2db78ea2..405815e06a 100644 --- a/nms-patches/WorldDataServer.patch +++ b/nms-patches/WorldDataServer.patch @@ -18,25 +18,25 @@ private final GeneratorSettings c; private final Lifecycle d; private int e; -@@ -50,6 +55,7 @@ - private final Set B; - private boolean C; - private final CustomFunctionCallbackTimerQueue D; +@@ -51,6 +56,7 @@ + private final Set C; + private boolean D; + private final CustomFunctionCallbackTimerQueue E; + public WorldServer world; // CraftBukkit - private WorldDataServer(@Nullable DataFixer datafixer, int i, @Nullable NBTTagCompound nbttagcompound, boolean flag, int j, int k, int l, long i1, long j1, int k1, int l1, int i2, boolean flag1, int j2, boolean flag2, boolean flag3, boolean flag4, WorldBorder.c worldborder_c, int k2, int l2, @Nullable UUID uuid, LinkedHashSet linkedhashset, CustomFunctionCallbackTimerQueue customfunctioncallbacktimerqueue, @Nullable NBTTagCompound nbttagcompound1, NBTTagCompound nbttagcompound2, WorldSettings worldsettings, GeneratorSettings generatorsettings, Lifecycle lifecycle) { - this.j = datafixer; -@@ -92,7 +98,8 @@ + private WorldDataServer(@Nullable DataFixer datafixer, int i, @Nullable NBTTagCompound nbttagcompound, boolean flag, int j, int k, int l, float f, long i1, long j1, int k1, int l1, int i2, boolean flag1, int j2, boolean flag2, boolean flag3, boolean flag4, WorldBorder.c worldborder_c, int k2, int l2, @Nullable UUID uuid, LinkedHashSet linkedhashset, CustomFunctionCallbackTimerQueue customfunctioncallbacktimerqueue, @Nullable NBTTagCompound nbttagcompound1, NBTTagCompound nbttagcompound2, WorldSettings worldsettings, GeneratorSettings generatorsettings, Lifecycle lifecycle) { + this.k = datafixer; +@@ -94,7 +100,8 @@ return (NBTBase) dynamic.get("DimensionData").get("1").get("DragonFight").orElseEmptyMap().getValue(); }); -- return new WorldDataServer(datafixer, i, nbttagcompound, dynamic.get("WasModded").asBoolean(false), dynamic.get("SpawnX").asInt(0), dynamic.get("SpawnY").asInt(0), dynamic.get("SpawnZ").asInt(0), j, dynamic.get("DayTime").asLong(j), levelversion.a(), dynamic.get("clearWeatherTime").asInt(0), dynamic.get("rainTime").asInt(0), dynamic.get("raining").asBoolean(false), dynamic.get("thunderTime").asInt(0), dynamic.get("thundering").asBoolean(false), dynamic.get("initialized").asBoolean(true), dynamic.get("DifficultyLocked").asBoolean(false), WorldBorder.c.a(dynamic, WorldBorder.b), dynamic.get("WanderingTraderSpawnDelay").asInt(0), dynamic.get("WanderingTraderSpawnChance").asInt(0), (UUID) dynamic.get("WanderingTraderId").read(MinecraftSerializableUUID.a).result().orElse((Object) null), (LinkedHashSet) dynamic.get("ServerBrands").asStream().flatMap((dynamic1) -> { +- return new WorldDataServer(datafixer, i, nbttagcompound, dynamic.get("WasModded").asBoolean(false), dynamic.get("SpawnX").asInt(0), dynamic.get("SpawnY").asInt(0), dynamic.get("SpawnZ").asInt(0), dynamic.get("SpawnAngle").asFloat(0.0F), j, dynamic.get("DayTime").asLong(j), levelversion.a(), dynamic.get("clearWeatherTime").asInt(0), dynamic.get("rainTime").asInt(0), dynamic.get("raining").asBoolean(false), dynamic.get("thunderTime").asInt(0), dynamic.get("thundering").asBoolean(false), dynamic.get("initialized").asBoolean(true), dynamic.get("DifficultyLocked").asBoolean(false), WorldBorder.c.a(dynamic, WorldBorder.c), dynamic.get("WanderingTraderSpawnDelay").asInt(0), dynamic.get("WanderingTraderSpawnChance").asInt(0), (UUID) dynamic.get("WanderingTraderId").read(MinecraftSerializableUUID.a).result().orElse((Object) null), (LinkedHashSet) dynamic.get("ServerBrands").asStream().flatMap((dynamic1) -> { + // CraftBukkit - decompile error -+ return new WorldDataServer(datafixer, i, nbttagcompound, dynamic.get("WasModded").asBoolean(false), dynamic.get("SpawnX").asInt(0), dynamic.get("SpawnY").asInt(0), dynamic.get("SpawnZ").asInt(0), j, dynamic.get("DayTime").asLong(j), levelversion.a(), dynamic.get("clearWeatherTime").asInt(0), dynamic.get("rainTime").asInt(0), dynamic.get("raining").asBoolean(false), dynamic.get("thunderTime").asInt(0), dynamic.get("thundering").asBoolean(false), dynamic.get("initialized").asBoolean(true), dynamic.get("DifficultyLocked").asBoolean(false), WorldBorder.c.a(dynamic, WorldBorder.b), dynamic.get("WanderingTraderSpawnDelay").asInt(0), dynamic.get("WanderingTraderSpawnChance").asInt(0), (UUID) dynamic.get("WanderingTraderId").read(MinecraftSerializableUUID.a).result().orElse(null), (LinkedHashSet) dynamic.get("ServerBrands").asStream().flatMap((dynamic1) -> { ++ return new WorldDataServer(datafixer, i, nbttagcompound, dynamic.get("WasModded").asBoolean(false), dynamic.get("SpawnX").asInt(0), dynamic.get("SpawnY").asInt(0), dynamic.get("SpawnZ").asInt(0), dynamic.get("SpawnAngle").asFloat(0.0F), j, dynamic.get("DayTime").asLong(j), levelversion.a(), dynamic.get("clearWeatherTime").asInt(0), dynamic.get("rainTime").asInt(0), dynamic.get("raining").asBoolean(false), dynamic.get("thunderTime").asInt(0), dynamic.get("thundering").asBoolean(false), dynamic.get("initialized").asBoolean(true), dynamic.get("DifficultyLocked").asBoolean(false), WorldBorder.c.a(dynamic, WorldBorder.c), dynamic.get("WanderingTraderSpawnDelay").asInt(0), dynamic.get("WanderingTraderSpawnChance").asInt(0), (UUID) dynamic.get("WanderingTraderId").read(MinecraftSerializableUUID.a).result().orElse(null), (LinkedHashSet) dynamic.get("ServerBrands").asStream().flatMap((dynamic1) -> { return SystemUtils.a(dynamic1.asString().result()); }).collect(Collectors.toCollection(Sets::newLinkedHashSet)), new CustomFunctionCallbackTimerQueue<>(CustomFunctionCallbackTimers.a, dynamic.get("ScheduledEvents").asStream()), (NBTTagCompound) dynamic.get("CustomBossEvents").orElseEmptyMap().getValue(), nbttagcompound1, worldsettings, generatorsettings, lifecycle); } -@@ -124,7 +131,7 @@ +@@ -126,7 +133,7 @@ nbttagcompound.set("Version", nbttagcompound2); nbttagcompound.setInt("DataVersion", SharedConstants.getGameVersion().getWorldVersion()); RegistryWriteOps registrywriteops = RegistryWriteOps.a(DynamicOpsNBT.a, iregistrycustom); @@ -45,15 +45,15 @@ Logger logger = WorldDataServer.LOGGER; logger.getClass(); -@@ -171,6 +178,7 @@ - nbttagcompound.a("WanderingTraderId", this.A); +@@ -174,6 +181,7 @@ + nbttagcompound.a("WanderingTraderId", this.B); } + nbttagcompound.setString("Bukkit.Version", Bukkit.getName() + "/" + Bukkit.getVersion() + "/" + Bukkit.getBukkitVersion()); // CraftBukkit } @Override -@@ -277,6 +285,20 @@ +@@ -291,6 +299,20 @@ @Override public void setThundering(boolean flag) { @@ -74,7 +74,7 @@ this.thundering = flag; } -@@ -297,6 +319,20 @@ +@@ -311,6 +333,20 @@ @Override public void setStorm(boolean flag) { @@ -95,7 +95,7 @@ this.raining = flag; } -@@ -363,6 +399,12 @@ +@@ -377,6 +413,12 @@ @Override public void setDifficulty(EnumDifficulty enumdifficulty) { this.b = this.b.a(enumdifficulty); @@ -108,8 +108,8 @@ } @Override -@@ -467,4 +509,12 @@ - public IWorldDataServer G() { +@@ -481,4 +523,12 @@ + public IWorldDataServer H() { return this; } + diff --git a/nms-patches/WorldGenMegaTreeProvider.patch b/nms-patches/WorldGenMegaTreeProvider.patch index af464d2b26..34602daaaa 100644 --- a/nms-patches/WorldGenMegaTreeProvider.patch +++ b/nms-patches/WorldGenMegaTreeProvider.patch @@ -3,7 +3,7 @@ @@ -30,6 +30,7 @@ return false; } else { - ((WorldGenFeatureTreeConfiguration) worldgenfeatureconfigured.e).a(); + ((WorldGenFeatureTreeConfiguration) worldgenfeatureconfigured.f).b(); + setTreeType(worldgenfeatureconfigured); // CraftBukkit IBlockData iblockdata1 = Blocks.AIR.getBlockData(); diff --git a/nms-patches/WorldGenTreeProvider.patch b/nms-patches/WorldGenTreeProvider.patch index 172c0f46cb..307357cbf6 100644 --- a/nms-patches/WorldGenTreeProvider.patch +++ b/nms-patches/WorldGenTreeProvider.patch @@ -14,8 +14,8 @@ } else { + setTreeType(worldgenfeatureconfigured); // CraftBukkit worldserver.setTypeAndData(blockposition, Blocks.AIR.getBlockData(), 4); - ((WorldGenFeatureTreeConfiguration) worldgenfeatureconfigured.e).a(); - if (worldgenfeatureconfigured.a(worldserver, worldserver.getStructureManager(), chunkgenerator, random, blockposition)) { + ((WorldGenFeatureTreeConfiguration) worldgenfeatureconfigured.f).b(); + if (worldgenfeatureconfigured.a(worldserver, chunkgenerator, random, blockposition)) { @@ -43,4 +45,46 @@ return true; @@ -23,39 +23,39 @@ + + // CraftBukkit start + protected void setTreeType(WorldGenFeatureConfigured worldgentreeabstract) { -+ if (worldgentreeabstract.e == BiomeDecoratorGroups.NORMAL_TREE || worldgentreeabstract.e == BiomeDecoratorGroups.NORMAL_TREE_BEES_005) { ++ if (worldgentreeabstract.f == BiomeDecoratorGroups.OAK || worldgentreeabstract.f == BiomeDecoratorGroups.OAK_BEES_005) { + BlockSapling.treeType = TreeType.TREE; -+ } else if (worldgentreeabstract.e == BiomeDecoratorGroups.HUGE_RED_MUSHROOM) { ++ } else if (worldgentreeabstract.f == BiomeDecoratorGroups.HUGE_RED_MUSHROOM) { + BlockSapling.treeType = TreeType.RED_MUSHROOM; -+ } else if (worldgentreeabstract.e == BiomeDecoratorGroups.HUGE_BROWN_MUSHROOM) { ++ } else if (worldgentreeabstract.f == BiomeDecoratorGroups.HUGE_BROWN_MUSHROOM) { + BlockSapling.treeType = TreeType.BROWN_MUSHROOM; -+ } else if (worldgentreeabstract.e == BiomeDecoratorGroups.JUNGLE_TREE) { ++ } else if (worldgentreeabstract.f == BiomeDecoratorGroups.JUNGLE_TREE) { + BlockSapling.treeType = TreeType.COCOA_TREE; -+ } else if (worldgentreeabstract.e == BiomeDecoratorGroups.JUNGLE_TREE_NOVINE) { ++ } else if (worldgentreeabstract.f == BiomeDecoratorGroups.JUNGLE_TREE_NO_VINE) { + BlockSapling.treeType = TreeType.SMALL_JUNGLE; -+ } else if (worldgentreeabstract.e == BiomeDecoratorGroups.PINE_TREE) { ++ } else if (worldgentreeabstract.f == BiomeDecoratorGroups.PINE) { + BlockSapling.treeType = TreeType.TALL_REDWOOD; -+ } else if (worldgentreeabstract.e == BiomeDecoratorGroups.SPRUCE_TREE) { ++ } else if (worldgentreeabstract.f == BiomeDecoratorGroups.SPRUCE) { + BlockSapling.treeType = TreeType.REDWOOD; -+ } else if (worldgentreeabstract.e == BiomeDecoratorGroups.ACACIA_TREE) { ++ } else if (worldgentreeabstract.f == BiomeDecoratorGroups.ACACIA) { + BlockSapling.treeType = TreeType.ACACIA; -+ } else if (worldgentreeabstract.e == BiomeDecoratorGroups.BIRCH_TREE || worldgentreeabstract.e == BiomeDecoratorGroups.BIRCH_TREE_BEES_005) { ++ } else if (worldgentreeabstract.f == BiomeDecoratorGroups.BIRCH || worldgentreeabstract.f == BiomeDecoratorGroups.BIRCH_BEES_005) { + BlockSapling.treeType = TreeType.BIRCH; -+ } else if (worldgentreeabstract.e == BiomeDecoratorGroups.TALL_BIRCH_TREE_BEES_0002) { ++ } else if (worldgentreeabstract.f == BiomeDecoratorGroups.SUPER_BIRCH_BEES_0002) { + BlockSapling.treeType = TreeType.TALL_BIRCH; -+ } else if (worldgentreeabstract.e == BiomeDecoratorGroups.SWAMP_TREE) { ++ } else if (worldgentreeabstract.f == BiomeDecoratorGroups.SWAMP_TREE) { + BlockSapling.treeType = TreeType.SWAMP; -+ } else if (worldgentreeabstract.e == BiomeDecoratorGroups.FANCY_TREE || worldgentreeabstract.e == BiomeDecoratorGroups.FANCY_TREE_BEES_005) { ++ } else if (worldgentreeabstract.f == BiomeDecoratorGroups.FANCY_OAK || worldgentreeabstract.f == BiomeDecoratorGroups.FANCY_OAK_BEES_005) { + BlockSapling.treeType = TreeType.BIG_TREE; -+ } else if (worldgentreeabstract.e == BiomeDecoratorGroups.JUNGLE_BUSH) { ++ } else if (worldgentreeabstract.f == BiomeDecoratorGroups.JUNGLE_BUSH) { + BlockSapling.treeType = TreeType.JUNGLE_BUSH; -+ } else if (worldgentreeabstract.e == BiomeDecoratorGroups.DARK_OAK_TREE) { ++ } else if (worldgentreeabstract.f == BiomeDecoratorGroups.DARK_OAK) { + BlockSapling.treeType = TreeType.DARK_OAK; -+ } else if (worldgentreeabstract.e == BiomeDecoratorGroups.MEGA_SPRUCE_TREE) { ++ } else if (worldgentreeabstract.f == BiomeDecoratorGroups.MEGA_SPRUCE) { + BlockSapling.treeType = TreeType.MEGA_REDWOOD; -+ } else if (worldgentreeabstract.e == BiomeDecoratorGroups.MEGA_PINE_TREE) { ++ } else if (worldgentreeabstract.f == BiomeDecoratorGroups.MEGA_PINE) { + BlockSapling.treeType = TreeType.MEGA_REDWOOD; -+ } else if (worldgentreeabstract.e == BiomeDecoratorGroups.MEGA_JUNGLE_TREE) { ++ } else if (worldgentreeabstract.f == BiomeDecoratorGroups.MEGA_JUNGLE_TREE) { + BlockSapling.treeType = TreeType.JUNGLE; + } else { + throw new IllegalArgumentException("Unknown tree generator " + worldgentreeabstract); diff --git a/nms-patches/WorldGenWitchHut.patch b/nms-patches/WorldGenWitchHut.patch index f5c7e8ea76..ffefc85eac 100644 --- a/nms-patches/WorldGenWitchHut.patch +++ b/nms-patches/WorldGenWitchHut.patch @@ -4,8 +4,17 @@ entitywitch.setPersistent(); entitywitch.setPositionRotation((double) j + 0.5D, (double) i, (double) k + 0.5D, 0.0F, 0.0F); entitywitch.prepare(generatoraccessseed, generatoraccessseed.getDamageScaler(new BlockPosition(j, i, k)), EnumMobSpawn.STRUCTURE, (GroupDataEntity) null, (NBTTagCompound) null); -- generatoraccessseed.addEntity(entitywitch); -+ generatoraccessseed.addEntity(entitywitch, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CHUNK_GEN); // CraftBukkit - add SpawnReason +- generatoraccessseed.addAllEntities(entitywitch); ++ generatoraccessseed.addAllEntities(entitywitch, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CHUNK_GEN); // CraftBukkit - add SpawnReason } } +@@ -107,7 +107,7 @@ + entitycat.setPersistent(); + entitycat.setPositionRotation((double) i + 0.5D, (double) j, (double) k + 0.5D, 0.0F, 0.0F); + entitycat.prepare(worldaccess, worldaccess.getDamageScaler(new BlockPosition(i, j, k)), EnumMobSpawn.STRUCTURE, (GroupDataEntity) null, (NBTTagCompound) null); +- worldaccess.addAllEntities(entitycat); ++ worldaccess.addAllEntities(entitycat, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CHUNK_GEN); // CraftBukkit - add SpawnReason + } + } + diff --git a/nms-patches/WorldNBTStorage.patch b/nms-patches/WorldNBTStorage.patch index 718c53f718..8d839716da 100644 --- a/nms-patches/WorldNBTStorage.patch +++ b/nms-patches/WorldNBTStorage.patch @@ -1,17 +1,19 @@ --- a/net/minecraft/server/WorldNBTStorage.java +++ b/net/minecraft/server/WorldNBTStorage.java -@@ -10,6 +10,10 @@ +@@ -6,6 +6,12 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +// CraftBukkit start ++import java.io.FileInputStream; ++import java.io.InputStream; +import org.bukkit.craftbukkit.entity.CraftPlayer; +// CraftBukkit end + public class WorldNBTStorage { private static final Logger LOGGER = LogManager.getLogger(); -@@ -53,6 +57,16 @@ +@@ -49,6 +55,16 @@ } if (nbttagcompound != null) { @@ -28,7 +30,7 @@ int i = nbttagcompound.hasKeyOfType("DataVersion", 3) ? nbttagcompound.getInt("DataVersion") : -1; entityhuman.load(GameProfileSerializer.a(this.a, DataFixTypes.PLAYER, nbttagcompound, i)); -@@ -61,6 +75,22 @@ +@@ -57,6 +73,22 @@ return nbttagcompound; } @@ -51,7 +53,7 @@ public String[] getSeenPlayers() { String[] astring = this.playerDir.list(); -@@ -76,4 +106,10 @@ +@@ -72,4 +104,10 @@ return astring; } diff --git a/nms-patches/WorldServer.patch b/nms-patches/WorldServer.patch index b02f3f7a1a..fa90a2719b 100644 --- a/nms-patches/WorldServer.patch +++ b/nms-patches/WorldServer.patch @@ -32,8 +32,8 @@ private final StructureManager structureManager; private final boolean Q; -- public WorldServer(MinecraftServer minecraftserver, Executor executor, Convertable.ConversionSession convertable_conversionsession, IWorldDataServer iworlddataserver, ResourceKey resourcekey, ResourceKey resourcekey1, DimensionManager dimensionmanager, WorldLoadListener worldloadlistener, ChunkGenerator chunkgenerator, boolean flag, long i, List list, boolean flag1) { -- super(iworlddataserver, resourcekey, resourcekey1, dimensionmanager, minecraftserver::getMethodProfiler, false, flag, i); +- public WorldServer(MinecraftServer minecraftserver, Executor executor, Convertable.ConversionSession convertable_conversionsession, IWorldDataServer iworlddataserver, ResourceKey resourcekey, DimensionManager dimensionmanager, WorldLoadListener worldloadlistener, ChunkGenerator chunkgenerator, boolean flag, long i, List list, boolean flag1) { +- super(iworlddataserver, resourcekey, dimensionmanager, minecraftserver::getMethodProfiler, false, flag, i); + + // CraftBukkit start + private int tickPosition; @@ -45,8 +45,8 @@ + } + + // Add env and gen to constructor, WorldData -> WorldDataServer -+ public WorldServer(MinecraftServer minecraftserver, Executor executor, Convertable.ConversionSession convertable_conversionsession, IWorldDataServer iworlddataserver, ResourceKey resourcekey, ResourceKey resourcekey1, DimensionManager dimensionmanager, WorldLoadListener worldloadlistener, ChunkGenerator chunkgenerator, boolean flag, long i, List list, boolean flag1, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen) { -+ super(iworlddataserver, resourcekey, resourcekey1, dimensionmanager, minecraftserver::getMethodProfiler, false, flag, i, gen, env); ++ public WorldServer(MinecraftServer minecraftserver, Executor executor, Convertable.ConversionSession convertable_conversionsession, IWorldDataServer iworlddataserver, ResourceKey resourcekey, DimensionManager dimensionmanager, WorldLoadListener worldloadlistener, ChunkGenerator chunkgenerator, boolean flag, long i, List list, boolean flag1, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen) { ++ super(iworlddataserver, resourcekey, dimensionmanager, minecraftserver::getMethodProfiler, false, flag, i, gen, env); + this.pvpMode = minecraftserver.getPVP(); + convertable = convertable_conversionsession; + uuid = WorldUUID.getUUID(convertable_conversionsession.folder.toFile()); @@ -67,12 +67,12 @@ + } + this.chunkProvider = new ChunkProviderServer(this, convertable_conversionsession, minecraftserver.getDataFixer(), minecraftserver.getDefinedStructureManager(), executor, chunkgenerator, minecraftserver.getPlayerList().getViewDistance(), minecraftserver.isSyncChunkWrites(), worldloadlistener, () -> { - return minecraftserver.D().getWorldPersistentData(); + return minecraftserver.E().getWorldPersistentData(); }); + // CraftBukkit end this.portalTravelAgent = new PortalTravelAgent(this); - this.N(); - this.O(); + this.P(); + this.Q(); @@ -91,14 +125,48 @@ iworlddataserver.setGameType(minecraftserver.getGamemode()); } @@ -80,8 +80,8 @@ - this.structureManager = new StructureManager(this, minecraftserver.getSaveData().getGeneratorSettings()); + this.structureManager = new StructureManager(this, this.worldDataServer.getGeneratorSettings()); // CraftBukkit if (this.getDimensionManager().isCreateDragonBattle()) { -- this.dragonBattle = new EnderDragonBattle(this, minecraftserver.getSaveData().getGeneratorSettings().getSeed(), minecraftserver.getSaveData().B()); -+ this.dragonBattle = new EnderDragonBattle(this, this.worldDataServer.getGeneratorSettings().getSeed(), this.worldDataServer.B()); // CraftBukkit +- this.dragonBattle = new EnderDragonBattle(this, minecraftserver.getSaveData().getGeneratorSettings().getSeed(), minecraftserver.getSaveData().C()); ++ this.dragonBattle = new EnderDragonBattle(this, this.worldDataServer.getGeneratorSettings().getSeed(), this.worldDataServer.C()); // CraftBukkit } else { this.dragonBattle = null; } @@ -186,7 +186,7 @@ this.clearWeather(); } @@ -240,7 +338,7 @@ - this.ah(); + this.aj(); this.ticking = false; gameprofilerfiller.exitEnter("entities"); - boolean flag3 = !this.players.isEmpty() || !this.getForceLoadedChunks().isEmpty(); @@ -229,7 +229,7 @@ EntityLightning entitylightning = (EntityLightning) EntityTypes.LIGHTNING_BOLT.a((World) this); - entitylightning.c(Vec3D.c((BaseBlockPosition) blockposition)); + entitylightning.d(Vec3D.c((BaseBlockPosition) blockposition)); entitylightning.setEffect(flag1); - this.addEntity(entitylightning); + this.strikeLightning(entitylightning, org.bukkit.event.weather.LightningStrikeEvent.Cause.WEATHER); // CraftBukkit @@ -239,7 +239,7 @@ @@ -385,11 +485,11 @@ BiomeBase biomebase = this.getBiome(blockposition); - if (biomebase.a((IWorldReader) this, blockposition1)) { + if (biomebase.a(this, blockposition1)) { - this.setTypeUpdate(blockposition1, Blocks.ICE.getBlockData()); + org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this, blockposition1, Blocks.ICE.getBlockData(), null); // CraftBukkit } @@ -249,14 +249,14 @@ + org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this, blockposition, Blocks.SNOW.getBlockData(), null); // CraftBukkit } - if (flag && this.getBiome(blockposition1).d() == BiomeBase.Precipitation.RAIN) { + if (flag && this.getBiome(blockposition1).c() == BiomeBase.Precipitation.RAIN) { @@ -436,7 +536,7 @@ protected BlockPosition a(BlockPosition blockposition) { BlockPosition blockposition1 = this.getHighestBlockYAt(HeightMap.Type.MOTION_BLOCKING, blockposition); AxisAlignedBB axisalignedbb = (new AxisAlignedBB(blockposition1, new BlockPosition(blockposition1.getX(), this.getBuildHeight(), blockposition1.getZ()))).g(3.0D); - List list = this.a(EntityLiving.class, axisalignedbb, (entityliving) -> { + List list = this.a(EntityLiving.class, axisalignedbb, (java.util.function.Predicate) (entityliving) -> { // CraftBukkit - decompile error - return entityliving != null && entityliving.isAlive() && this.f(entityliving.getChunkCoordinates()); + return entityliving != null && entityliving.isAlive() && this.e(entityliving.getChunkCoordinates()); }); @@ -465,7 +565,7 @@ @@ -323,7 +323,7 @@ + // CraftBukkit end } - private void ag() { + private void ai() { if (this.dragonBattle != null) { - this.server.getSaveData().a(this.dragonBattle.a()); + this.worldDataServer.a(this.dragonBattle.a()); // CraftBukkit @@ -378,16 +378,35 @@ IChunkAccess ichunkaccess = this.getChunkAt(MathHelper.floor(entity.locX() / 16.0D), MathHelper.floor(entity.locZ() / 16.0D), ChunkStatus.FULL, entity.attachedToPlayer); if (!(ichunkaccess instanceof Chunk)) { -@@ -779,7 +919,7 @@ +@@ -780,7 +920,7 @@ if (entity1 == null) { return false; } else { -- WorldServer.LOGGER.warn("Keeping entity {} that already exists with UUID {}", EntityTypes.getName(entity1.getEntityType()), entity.getUniqueID().toString()); -+ // WorldServer.LOGGER.warn("Keeping entity {} that already exists with UUID {}", EntityTypes.getName(entity1.getEntityType()), entity.getUniqueID().toString()); // CraftBukkit +- WorldServer.LOGGER.warn("Trying to add entity with duplicated UUID {}. Existing {}#{}, new: {}#{}", uuid, EntityTypes.getName(entity1.getEntityType()), entity1.getId(), EntityTypes.getName(entity.getEntityType()), entity.getId()); ++ // WorldServer.LOGGER.warn("Trying to add entity with duplicated UUID {}. Existing {}#{}, new: {}#{}", uuid, EntityTypes.getName(entity1.getEntityType()), entity1.getId(), EntityTypes.getName(entity.getEntityType()), entity.getId()); // CraftBukkit return true; } } -@@ -830,10 +970,17 @@ +@@ -809,11 +949,16 @@ + } + + public boolean addAllEntitiesSafely(Entity entity) { ++ // CraftBukkit start ++ return this.addAllEntitiesSafely(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT); ++ } ++ ++ public boolean addAllEntitiesSafely(Entity entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) { ++ // CraftBukkit end + if (entity.co().anyMatch(this::isUUIDTaken)) { + return false; + } else { +- this.addAllEntities(entity); +- return true; ++ return this.addAllEntities(entity, reason); // CraftBukkit + } + } + +@@ -863,10 +1008,17 @@ } this.getScoreboard().a(entity); @@ -405,7 +424,7 @@ } private void registerEntity(Entity entity) { -@@ -854,9 +1001,16 @@ +@@ -887,9 +1039,16 @@ this.entitiesByUUID.put(entity.getUniqueID(), entity); this.getChunkProvider().addEntity(entity); @@ -422,7 +441,7 @@ } } -@@ -886,10 +1040,33 @@ +@@ -919,10 +1078,33 @@ this.everyoneSleeping(); } @@ -456,7 +475,7 @@ while (iterator.hasNext()) { EntityPlayer entityplayer = (EntityPlayer) iterator.next(); -@@ -898,6 +1075,12 @@ +@@ -931,6 +1113,12 @@ double d1 = (double) blockposition.getY() - entityplayer.locY(); double d2 = (double) blockposition.getZ() - entityplayer.locZ(); @@ -469,7 +488,7 @@ if (d0 * d0 + d1 * d1 + d2 * d2 < 1024.0D) { entityplayer.playerConnection.sendPacket(new PacketPlayOutBlockBreakAnimation(i, blockposition, j)); } -@@ -958,10 +1141,20 @@ +@@ -991,10 +1179,20 @@ @Override public Explosion createExplosion(@Nullable Entity entity, @Nullable DamageSource damagesource, @Nullable ExplosionDamageCalculator explosiondamagecalculator, double d0, double d1, double d2, float f, boolean flag, Explosion.Effect explosion_effect) { @@ -490,7 +509,7 @@ if (explosion_effect == Explosion.Effect.NONE) { explosion.clearBlocks(); } -@@ -1026,13 +1219,20 @@ +@@ -1059,13 +1257,20 @@ } public int a(T t0, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6) { @@ -513,7 +532,7 @@ ++j; } } -@@ -1074,7 +1274,7 @@ +@@ -1107,7 +1312,7 @@ @Nullable public BlockPosition a(StructureGenerator structuregenerator, BlockPosition blockposition, int i, boolean flag) { @@ -522,10 +541,10 @@ } @Nullable -@@ -1105,7 +1305,13 @@ +@@ -1145,7 +1350,13 @@ @Override public WorldMap a(String s) { - return (WorldMap) this.getMinecraftServer().D().getWorldPersistentData().b(() -> { + return (WorldMap) this.getMinecraftServer().E().getWorldPersistentData().b(() -> { - return new WorldMap(s); + // CraftBukkit start + // We only get here when the data file exists, but is not a valid map @@ -537,7 +556,7 @@ }, s); } -@@ -1412,6 +1618,11 @@ +@@ -1456,6 +1667,11 @@ @Override public void update(BlockPosition blockposition, Block block) { if (!this.isDebugWorld()) { @@ -549,7 +568,7 @@ this.applyPhysics(blockposition, block); } -@@ -1426,12 +1637,12 @@ +@@ -1470,12 +1686,12 @@ } public boolean isFlatWorld() { @@ -564,7 +583,7 @@ } @Nullable -@@ -1440,16 +1651,32 @@ +@@ -1494,16 +1710,32 @@ } public static void a(WorldServer worldserver) { diff --git a/pom.xml b/pom.xml index 4298a9fd81..eb0ffbbfe6 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.bukkit craftbukkit jar - 1.16.1-R0.1-SNAPSHOT + 1.16.2-R0.1-SNAPSHOT CraftBukkit https://www.spigotmc.org/ @@ -12,8 +12,8 @@ true UTF-8 unknown - 1.16.1 - 1_16_R1 + 1.16.2 + 1_16_R2 1.8 1.8 diff --git a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java index ffdaff29af..e78687b629 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java @@ -16,6 +16,7 @@ import net.minecraft.server.EnumSkyBlock; import net.minecraft.server.GameProfileSerializer; import net.minecraft.server.HeightMap; import net.minecraft.server.IBlockData; +import net.minecraft.server.IRegistry; import net.minecraft.server.LightEngine; import net.minecraft.server.NBTTagCompound; import net.minecraft.server.NibbleArray; @@ -288,7 +289,7 @@ public class CraftChunk implements Chunk { BiomeStorage biome = null; if (includeBiome || includeBiomeTempRain) { - biome = chunk.getBiomeIndex().b(); + biome = chunk.getBiomeIndex(); } World world = getWorld(); @@ -300,7 +301,7 @@ public class CraftChunk implements Chunk { if (includeBiome || includeBiomeTempRain) { WorldChunkManager wcm = world.getHandle().getChunkProvider().getChunkGenerator().getWorldChunkManager(); - biome = new BiomeStorage(new ChunkCoordIntPair(x, z), wcm); + biome = new BiomeStorage(world.getHandle().r().b(IRegistry.ay), new ChunkCoordIntPair(x, z), wcm); } /* Fill with empty data */ diff --git a/src/main/java/org/bukkit/craftbukkit/CraftLootTable.java b/src/main/java/org/bukkit/craftbukkit/CraftLootTable.java index 584ca998e0..42194647fd 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftLootTable.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftLootTable.java @@ -4,7 +4,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.Random; -import net.minecraft.server.BlockPosition; import net.minecraft.server.DamageSource; import net.minecraft.server.Entity; import net.minecraft.server.EntityHuman; @@ -14,6 +13,7 @@ import net.minecraft.server.LootContextParameterSet; import net.minecraft.server.LootContextParameters; import net.minecraft.server.LootTable; import net.minecraft.server.LootTableInfo; +import net.minecraft.server.Vec3D; import net.minecraft.server.WorldServer; import org.bukkit.Location; import org.bukkit.NamespacedKey; @@ -82,7 +82,7 @@ public class CraftLootTable implements org.bukkit.loot.LootTable { Entity nmsLootedEntity = ((CraftEntity) context.getLootedEntity()).getHandle(); builder.set(LootContextParameters.THIS_ENTITY, nmsLootedEntity); builder.set(LootContextParameters.DAMAGE_SOURCE, DamageSource.GENERIC); - builder.set(LootContextParameters.POSITION, nmsLootedEntity.getChunkCoordinates()); + builder.set(LootContextParameters.ORIGIN, nmsLootedEntity.getPositionVector()); } if (context.getKiller() != null) { @@ -115,7 +115,7 @@ public class CraftLootTable implements org.bukkit.loot.LootTable { } public static LootContext convertContext(LootTableInfo info) { - BlockPosition position = info.getContextParameter(LootContextParameters.POSITION); + Vec3D position = info.getContextParameter(LootContextParameters.ORIGIN); Location location = new Location(info.getWorld().getWorld(), position.getX(), position.getY(), position.getZ()); LootContext.Builder contextBuilder = new LootContext.Builder(location); diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java index 0f0e381207..9c1792ef93 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -92,9 +92,8 @@ import net.minecraft.server.PlayerList; import net.minecraft.server.RegistryMaterials; import net.minecraft.server.RegistryReadOps; import net.minecraft.server.ResourceKey; -import net.minecraft.server.SaveData; import net.minecraft.server.ServerCommand; -import net.minecraft.server.TagsServer; +import net.minecraft.server.Tags; import net.minecraft.server.TicketType; import net.minecraft.server.Vec3D; import net.minecraft.server.VillageSiege; @@ -752,7 +751,7 @@ public final class CraftServer implements Server { configuration = YamlConfiguration.loadConfiguration(getConfigFile()); commandsConfiguration = YamlConfiguration.loadConfiguration(getCommandsConfigFile()); - console.propertyManager = new DedicatedServerSettings(console.options); + console.propertyManager = new DedicatedServerSettings(console.aX(), console.options); DedicatedServerProperties config = console.propertyManager.getProperties(); console.setPVP(config.pvp); @@ -986,7 +985,7 @@ public final class CraftServer implements Server { IRegistryCustom.Dimension iregistrycustom_dimension = IRegistryCustom.b(); - RegistryReadOps registryreadops = RegistryReadOps.a((DynamicOps) DynamicOpsNBT.a, console.dataPackResources.h(), (IRegistryCustom) iregistrycustom_dimension); + RegistryReadOps registryreadops = RegistryReadOps.a((DynamicOps) DynamicOpsNBT.a, console.dataPackResources.h(), iregistrycustom_dimension); WorldDataServer worlddata = (WorldDataServer) worldSession.a((DynamicOps) registryreadops, console.datapackconfiguration); WorldSettings worldSettings; @@ -998,7 +997,7 @@ public final class CraftServer implements Server { properties.put("generate-structures", Objects.toString(creator.generateStructures())); properties.put("level-type", Objects.toString(creator.type().getName())); - GeneratorSettings generatorsettings = GeneratorSettings.a(properties); + GeneratorSettings generatorsettings = GeneratorSettings.a(console.aX(), properties); worldSettings = new WorldSettings(name, EnumGamemode.getById(getDefaultGameMode().getValue()), hardcore, EnumDifficulty.EASY, false, new GameRules(), console.datapackconfiguration); worlddata = new WorldDataServer(worldSettings, generatorsettings, Lifecycle.stable()); } @@ -1008,32 +1007,29 @@ public final class CraftServer implements Server { if (console.options.has("forceUpgrade")) { net.minecraft.server.Main.convertWorld(worldSession, DataConverterRegistry.a(), console.options.has("eraseCache"), () -> { return true; - }, worlddata.getGeneratorSettings().e().c().stream().map((entry) -> { - return ResourceKey.a(IRegistry.ad, ((ResourceKey) entry.getKey()).a()); + }, worlddata.getGeneratorSettings().d().d().stream().map((entry) -> { + return ResourceKey.a(IRegistry.K, ((ResourceKey) entry.getKey()).a()); }).collect(ImmutableSet.toImmutableSet())); } long j = BiomeManager.a(creator.seed()); List list = ImmutableList.of(new MobSpawnerPhantom(), new MobSpawnerPatrol(), new MobSpawnerCat(), new VillageSiege(), new MobSpawnerTrader(worlddata)); - RegistryMaterials registrymaterials = worlddata.getGeneratorSettings().e(); + RegistryMaterials registrymaterials = worlddata.getGeneratorSettings().d(); WorldDimension worlddimension = (WorldDimension) registrymaterials.a(actualDimension); DimensionManager dimensionmanager; net.minecraft.server.ChunkGenerator chunkgenerator; if (worlddimension == null) { - dimensionmanager = DimensionManager.a(); - chunkgenerator = GeneratorSettings.a((new Random()).nextLong()); + dimensionmanager = (DimensionManager) console.f.a().d(DimensionManager.OVERWORLD); + chunkgenerator = GeneratorSettings.a(console.f.b(IRegistry.ay), console.f.b(IRegistry.ar), (new Random()).nextLong()); } else { dimensionmanager = worlddimension.b(); chunkgenerator = worlddimension.c(); } - ResourceKey typeKey = (ResourceKey) console.f.a().c(dimensionmanager).orElseThrow(() -> { - return new IllegalStateException("Unregistered dimension type: " + dimensionmanager); - }); - ResourceKey worldKey = ResourceKey.a(IRegistry.ae, new MinecraftKey(name.toLowerCase(java.util.Locale.ENGLISH))); + ResourceKey worldKey = ResourceKey.a(IRegistry.L, new MinecraftKey(name.toLowerCase(java.util.Locale.ENGLISH))); - WorldServer internal = (WorldServer) new WorldServer(console, console.executorService, worldSession, worlddata, worldKey, typeKey, dimensionmanager, getServer().worldLoadListenerFactory.create(11), + WorldServer internal = (WorldServer) new WorldServer(console, console.executorService, worldSession, worlddata, worldKey, dimensionmanager, getServer().worldLoadListenerFactory.create(11), chunkgenerator, worlddata.getGeneratorSettings().isDebugWorld(), j, creator.environment() == Environment.NORMAL ? list : ImmutableList.of(), true, creator.environment(), generator); if (!(worlds.containsKey(name.toLowerCase(java.util.Locale.ENGLISH)))) { @@ -1212,7 +1208,7 @@ public final class CraftServer implements Server { public Recipe getRecipe(NamespacedKey recipeKey) { Preconditions.checkArgument(recipeKey != null, "recipeKey == null"); - return getServer().getCraftingManager().a(CraftNamespacedKey.toMinecraft(recipeKey)).map(IRecipe::toBukkitRecipe).orElse(null); + return getServer().getCraftingManager().getRecipe(CraftNamespacedKey.toMinecraft(recipeKey)).map(IRecipe::toBukkitRecipe).orElse(null); } @Override @@ -1971,13 +1967,13 @@ public final class CraftServer implements Server { case org.bukkit.Tag.REGISTRY_BLOCKS: Preconditions.checkArgument(clazz == org.bukkit.Material.class, "Block namespace must have material type"); - TagsServer blockTags = console.getTagRegistry().getBlockTags(); - return blockTags.b().keySet().stream().map(key -> (org.bukkit.Tag) new CraftBlockTag(blockTags, key)).collect(ImmutableList.toImmutableList()); + Tags blockTags = console.getTagRegistry().getBlockTags(); + return blockTags.a().keySet().stream().map(key -> (org.bukkit.Tag) new CraftBlockTag(blockTags, key)).collect(ImmutableList.toImmutableList()); case org.bukkit.Tag.REGISTRY_ITEMS: Preconditions.checkArgument(clazz == org.bukkit.Material.class, "Item namespace must have material type"); - TagsServer itemTags = console.getTagRegistry().getItemTags(); - return itemTags.b().keySet().stream().map(key -> (org.bukkit.Tag) new CraftItemTag(itemTags, key)).collect(ImmutableList.toImmutableList()); + Tags itemTags = console.getTagRegistry().getItemTags(); + return itemTags.a().keySet().stream().map(key -> (org.bukkit.Tag) new CraftItemTag(itemTags, key)).collect(ImmutableList.toImmutableList()); default: throw new IllegalArgumentException(); } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftSound.java b/src/main/java/org/bukkit/craftbukkit/CraftSound.java index 7b565ddfff..9a2e6bedfc 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftSound.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftSound.java @@ -635,6 +635,7 @@ public enum CraftSound { ENTITY_PARROT_IMITATE_MAGMA_CUBE("entity.parrot.imitate.magma_cube"), ENTITY_PARROT_IMITATE_PHANTOM("entity.parrot.imitate.phantom"), ENTITY_PARROT_IMITATE_PIGLIN("entity.parrot.imitate.piglin"), + ENTITY_PARROT_IMITATE_PIGLIN_BRUTE("entity.parrot.imitate.piglin_brute"), ENTITY_PARROT_IMITATE_PILLAGER("entity.parrot.imitate.pillager"), ENTITY_PARROT_IMITATE_RAVAGER("entity.parrot.imitate.ravager"), ENTITY_PARROT_IMITATE_SHULKER("entity.parrot.imitate.shulker"), @@ -661,6 +662,12 @@ public enum CraftSound { ENTITY_PIGLIN_ADMIRING_ITEM("entity.piglin.admiring_item"), ENTITY_PIGLIN_AMBIENT("entity.piglin.ambient"), ENTITY_PIGLIN_ANGRY("entity.piglin.angry"), + ENTITY_PIGLIN_BRUTE_AMBIENT("entity.piglin_brute.ambient"), + ENTITY_PIGLIN_BRUTE_ANGRY("entity.piglin_brute.angry"), + ENTITY_PIGLIN_BRUTE_CONVERTED_TO_ZOMBIFIED("entity.piglin_brute.converted_to_zombified"), + ENTITY_PIGLIN_BRUTE_DEATH("entity.piglin_brute.death"), + ENTITY_PIGLIN_BRUTE_HURT("entity.piglin_brute.hurt"), + ENTITY_PIGLIN_BRUTE_STEP("entity.piglin_brute.step"), ENTITY_PIGLIN_CELEBRATE("entity.piglin.celebrate"), ENTITY_PIGLIN_CONVERTED_TO_ZOMBIFIED("entity.piglin.converted_to_zombified"), ENTITY_PIGLIN_DEATH("entity.piglin.death"), diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index b2a4a165cd..0c4ac2e71f 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -88,6 +88,7 @@ import net.minecraft.server.Ticket; import net.minecraft.server.TicketType; import net.minecraft.server.Unit; import net.minecraft.server.Vec3D; +import net.minecraft.server.WorldGenFeatureConfigured; import net.minecraft.server.WorldGenFeatureHugeFungiConfiguration; import net.minecraft.server.WorldGenerator; import net.minecraft.server.WorldServer; @@ -196,6 +197,7 @@ import org.bukkit.entity.Phantom; import org.bukkit.entity.Pig; import org.bukkit.entity.PigZombie; import org.bukkit.entity.Piglin; +import org.bukkit.entity.PiglinBrute; import org.bukkit.entity.Pillager; import org.bukkit.entity.Player; import org.bukkit.entity.PolarBear; @@ -317,7 +319,7 @@ public class CraftWorld implements World { public boolean setSpawnLocation(int x, int y, int z) { try { Location previousLocation = getSpawnLocation(); - world.worldData.setSpawn(new BlockPosition(x, y, z)); + world.worldData.setSpawn(new BlockPosition(x, y, z), 0.0F); // Notify anyone who's listening. SpawnChangeEvent event = new SpawnChangeEvent(this, previousLocation); @@ -664,88 +666,69 @@ public class CraftWorld implements World { public boolean generateTree(Location loc, TreeType type) { BlockPosition pos = new BlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); - net.minecraft.server.WorldGenerator gen; - net.minecraft.server.WorldGenFeatureConfiguration conf; + net.minecraft.server.WorldGenFeatureConfigured gen; switch (type) { case BIG_TREE: - gen = WorldGenerator.TREE; - conf = BiomeDecoratorGroups.FANCY_TREE; + gen = BiomeDecoratorGroups.FANCY_OAK; break; case BIRCH: - gen = WorldGenerator.TREE; - conf = BiomeDecoratorGroups.BIRCH_TREE; + gen = BiomeDecoratorGroups.BIRCH; break; case REDWOOD: - gen = WorldGenerator.TREE; - conf = BiomeDecoratorGroups.SPRUCE_TREE; + gen = BiomeDecoratorGroups.SPRUCE; break; case TALL_REDWOOD: - gen = WorldGenerator.TREE; - conf = BiomeDecoratorGroups.PINE_TREE; + gen = BiomeDecoratorGroups.PINE; break; case JUNGLE: - gen = WorldGenerator.TREE; - conf = BiomeDecoratorGroups.MEGA_JUNGLE_TREE; + gen = BiomeDecoratorGroups.MEGA_JUNGLE_TREE; break; case SMALL_JUNGLE: - gen = WorldGenerator.TREE; - conf = BiomeDecoratorGroups.JUNGLE_TREE_NOVINE; + gen = BiomeDecoratorGroups.JUNGLE_TREE_NO_VINE; break; case COCOA_TREE: - gen = WorldGenerator.TREE; - conf = BiomeDecoratorGroups.JUNGLE_TREE; + gen = BiomeDecoratorGroups.JUNGLE_TREE; break; case JUNGLE_BUSH: - gen = WorldGenerator.TREE; - conf = BiomeDecoratorGroups.JUNGLE_BUSH; + gen = BiomeDecoratorGroups.JUNGLE_BUSH; break; case RED_MUSHROOM: - gen = WorldGenerator.HUGE_RED_MUSHROOM; - conf = BiomeDecoratorGroups.HUGE_RED_MUSHROOM; + gen = BiomeDecoratorGroups.HUGE_RED_MUSHROOM; break; case BROWN_MUSHROOM: - gen = WorldGenerator.HUGE_BROWN_MUSHROOM; - conf = BiomeDecoratorGroups.HUGE_BROWN_MUSHROOM; + gen = BiomeDecoratorGroups.HUGE_BROWN_MUSHROOM; break; case SWAMP: - gen = WorldGenerator.TREE; - conf = BiomeDecoratorGroups.SWAMP_TREE; + gen = BiomeDecoratorGroups.SWAMP_TREE; break; case ACACIA: - gen = WorldGenerator.TREE; - conf = BiomeDecoratorGroups.ACACIA_TREE; + gen = BiomeDecoratorGroups.ACACIA; break; case DARK_OAK: - gen = WorldGenerator.TREE; - conf = BiomeDecoratorGroups.DARK_OAK_TREE; + gen = BiomeDecoratorGroups.DARK_OAK; break; case MEGA_REDWOOD: - gen = WorldGenerator.TREE; - conf = BiomeDecoratorGroups.MEGA_PINE_TREE; + gen = BiomeDecoratorGroups.MEGA_PINE; break; case TALL_BIRCH: - gen = WorldGenerator.TREE; - conf = BiomeDecoratorGroups.TALL_BIRCH_TREE_BEES_0002; + gen = BiomeDecoratorGroups.SUPER_BIRCH_BEES_0002; break; case CHORUS_PLANT: ((BlockChorusFlower) Blocks.CHORUS_FLOWER).a(world, pos, rand, 8); return true; case CRIMSON_FUNGUS: - gen = WorldGenerator.HUGE_FUNGUS; - conf = WorldGenFeatureHugeFungiConfiguration.b; + gen = BiomeDecoratorGroups.CRIMSON_FUNGI; break; case WARPED_FUNGUS: - gen = WorldGenerator.HUGE_FUNGUS; - conf = WorldGenFeatureHugeFungiConfiguration.d; + gen = BiomeDecoratorGroups.WARPED_FUNGI; break; case TREE: default: - gen = WorldGenerator.TREE; - conf = BiomeDecoratorGroups.NORMAL_TREE; + gen = BiomeDecoratorGroups.OAK; break; } - return gen.generate(world, world.getStructureManager(), world.getChunkProvider().getChunkGenerator(), rand, pos, conf); + return gen.e.generate(world, world.getChunkProvider().getChunkGenerator(), rand, pos, gen.f); } @Override @@ -1700,6 +1683,8 @@ public class CraftWorld implements World { entity = EntityTypes.HOGLIN.a(world); } else if (Piglin.class.isAssignableFrom(clazz)) { entity = EntityTypes.PIGLIN.a(world); + } else if (PiglinBrute.class.isAssignableFrom(clazz)) { + entity = EntityTypes.PIGLIN_BRUTE.a(world); } else if (Strider.class.isAssignableFrom(clazz)) { entity = EntityTypes.STRIDER.a(world); } else if (Zoglin.class.isAssignableFrom(clazz)) { diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java index 49c5f74b09..6ca11fdce3 100644 --- a/src/main/java/org/bukkit/craftbukkit/Main.java +++ b/src/main/java/org/bukkit/craftbukkit/Main.java @@ -177,11 +177,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 Date(Integer.parseInt(Main.class.getPackage().getImplementationVendor()) * 1000L); Calendar deadline = Calendar.getInstance(); - deadline.add(Calendar.DAY_OF_YEAR, -21); + deadline.add(Calendar.DAY_OF_YEAR, -2); 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/go/outdated-spigot ***"); diff --git a/src/main/java/org/bukkit/craftbukkit/block/CapturedBlockState.java b/src/main/java/org/bukkit/craftbukkit/block/CapturedBlockState.java index 27bd1916e0..e90e73af41 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CapturedBlockState.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CapturedBlockState.java @@ -4,7 +4,7 @@ import java.util.Random; import net.minecraft.server.BlockPosition; import net.minecraft.server.EntityBee; import net.minecraft.server.EntityTypes; -import net.minecraft.server.GeneratorAccess; +import net.minecraft.server.GeneratorAccessSeed; import net.minecraft.server.TileEntity; import net.minecraft.server.TileEntityBeehive; import net.minecraft.server.World; @@ -27,19 +27,19 @@ public final class CapturedBlockState extends CraftBlockState { // SPIGOT-5537: Horrible hack to manually add bees given World.captureTreeGeneration does not support tiles if (this.treeBlock && getType() == Material.BEE_NEST) { - GeneratorAccess generatoraccess = this.world.getHandle(); + GeneratorAccessSeed generatoraccessseed = this.world.getHandle(); BlockPosition blockposition1 = this.getPosition(); - Random random = generatoraccess.getRandom(); + Random random = generatoraccessseed.getRandom(); // Begin copied block from WorldGenFeatureTreeBeehive - TileEntity tileentity = generatoraccess.getTileEntity(blockposition1); + TileEntity tileentity = generatoraccessseed.getTileEntity(blockposition1); if (tileentity instanceof TileEntityBeehive) { TileEntityBeehive tileentitybeehive = (TileEntityBeehive) tileentity; int j = 2 + random.nextInt(2); for (int k = 0; k < j; ++k) { - EntityBee entitybee = new EntityBee(EntityTypes.BEE, generatoraccess.getMinecraftWorld()); + EntityBee entitybee = new EntityBee(EntityTypes.BEE, generatoraccessseed.getMinecraftWorld()); tileentitybeehive.a(entitybee, false, random.nextInt(599)); } diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBarrel.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBarrel.java index 6378a0a6e0..b6b87cfdf9 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBarrel.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBarrel.java @@ -38,8 +38,8 @@ public class CraftBarrel extends CraftLootable implements Barr requirePlaced(); if (!getTileEntity().opened) { IBlockData blockData = getTileEntity().getBlock(); - getTileEntity().a(blockData, true); - getTileEntity().a(blockData, SoundEffects.BLOCK_BARREL_OPEN); + getTileEntity().setOpenFlag(blockData, true); + getTileEntity().playOpenSound(blockData, SoundEffects.BLOCK_BARREL_OPEN); } getTileEntity().opened = true; } @@ -49,8 +49,8 @@ public class CraftBarrel extends CraftLootable implements Barr requirePlaced(); if (getTileEntity().opened) { IBlockData blockData = getTileEntity().getBlock(); - getTileEntity().a(blockData, false); - getTileEntity().a(blockData, SoundEffects.BLOCK_BARREL_CLOSE); + getTileEntity().setOpenFlag(blockData, false); + getTileEntity().playOpenSound(blockData, SoundEffects.BLOCK_BARREL_CLOSE); } getTileEntity().opened = false; } diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java index 606a89a905..a8c1cab3e8 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java @@ -19,6 +19,7 @@ import net.minecraft.server.IRegistry; import net.minecraft.server.MinecraftKey; import net.minecraft.server.MovingObjectPosition; import net.minecraft.server.RayTrace; +import net.minecraft.server.RegistryGeneration; import net.minecraft.server.TileEntity; import net.minecraft.server.Vec3D; import net.minecraft.server.VoxelShape; @@ -152,7 +153,7 @@ public class CraftBlock implements Block { @Override public BlockData getBlockData() { - return CraftBlockData.fromData(getNMS()); + return CraftBlockData.fromData(getNMS()); } @Override @@ -225,7 +226,6 @@ public class CraftBlock implements Block { return (byte) world.getBrightness(EnumSkyBlock.BLOCK, position); } - public Block getFace(final BlockFace face) { return getRelative(face, 1); } @@ -268,41 +268,43 @@ public class CraftBlock implements Block { } public static BlockFace notchToBlockFace(EnumDirection notch) { - if (notch == null) return BlockFace.SELF; - switch (notch) { - case DOWN: - return BlockFace.DOWN; - case UP: - return BlockFace.UP; - case NORTH: - return BlockFace.NORTH; - case SOUTH: - return BlockFace.SOUTH; - case WEST: - return BlockFace.WEST; - case EAST: - return BlockFace.EAST; - default: + if (notch == null) { return BlockFace.SELF; } + switch (notch) { + case DOWN: + return BlockFace.DOWN; + case UP: + return BlockFace.UP; + case NORTH: + return BlockFace.NORTH; + case SOUTH: + return BlockFace.SOUTH; + case WEST: + return BlockFace.WEST; + case EAST: + return BlockFace.EAST; + default: + return BlockFace.SELF; + } } public static EnumDirection blockFaceToNotch(BlockFace face) { switch (face) { - case DOWN: - return EnumDirection.DOWN; - case UP: - return EnumDirection.UP; - case NORTH: - return EnumDirection.NORTH; - case SOUTH: - return EnumDirection.SOUTH; - case WEST: - return EnumDirection.WEST; - case EAST: - return EnumDirection.EAST; - default: - return null; + case DOWN: + return EnumDirection.DOWN; + case UP: + return EnumDirection.UP; + case NORTH: + return EnumDirection.NORTH; + case SOUTH: + return EnumDirection.SOUTH; + case WEST: + return EnumDirection.WEST; + case EAST: + return EnumDirection.EAST; + default: + return null; } } @@ -311,168 +313,168 @@ public class CraftBlock implements Block { Material material = getType(); switch (material) { - case ACACIA_SIGN: - case ACACIA_WALL_SIGN: - case BIRCH_SIGN: - case BIRCH_WALL_SIGN: - case CRIMSON_SIGN: - case CRIMSON_WALL_SIGN: - case DARK_OAK_SIGN: - case DARK_OAK_WALL_SIGN: - case JUNGLE_SIGN: - case JUNGLE_WALL_SIGN: - case OAK_SIGN: - case OAK_WALL_SIGN: - case SPRUCE_SIGN: - case SPRUCE_WALL_SIGN: - case WARPED_SIGN: - case WARPED_WALL_SIGN: - return new CraftSign(this); - case CHEST: - case TRAPPED_CHEST: - return new CraftChest(this); - case FURNACE: - return new CraftFurnaceFurnace(this); - case DISPENSER: - return new CraftDispenser(this); - case DROPPER: - return new CraftDropper(this); - case END_GATEWAY: - return new CraftEndGateway(this); - case HOPPER: - return new CraftHopper(this); - case SPAWNER: - return new CraftCreatureSpawner(this); - case JUKEBOX: - return new CraftJukebox(this); - case BREWING_STAND: - return new CraftBrewingStand(this); - case CREEPER_HEAD: - case CREEPER_WALL_HEAD: - case DRAGON_HEAD: - case DRAGON_WALL_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_BLOCK: - case CHAIN_COMMAND_BLOCK: - case REPEATING_COMMAND_BLOCK: - return new CraftCommandBlock(this); - case BEACON: - return new CraftBeacon(this); - 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 STRUCTURE_BLOCK: - return new CraftStructureBlock(this); - case SHULKER_BOX: - case WHITE_SHULKER_BOX: - case ORANGE_SHULKER_BOX: - case MAGENTA_SHULKER_BOX: - case LIGHT_BLUE_SHULKER_BOX: - case YELLOW_SHULKER_BOX: - case LIME_SHULKER_BOX: - case PINK_SHULKER_BOX: - case GRAY_SHULKER_BOX: - case LIGHT_GRAY_SHULKER_BOX: - case CYAN_SHULKER_BOX: - case PURPLE_SHULKER_BOX: - case BLUE_SHULKER_BOX: - case BROWN_SHULKER_BOX: - case GREEN_SHULKER_BOX: - case RED_SHULKER_BOX: - case BLACK_SHULKER_BOX: - return new CraftShulkerBox(this); - case ENCHANTING_TABLE: - return new CraftEnchantingTable(this); - case ENDER_CHEST: - return new CraftEnderChest(this); - case DAYLIGHT_DETECTOR: - return new CraftDaylightDetector(this); - case COMPARATOR: - return new CraftComparator(this); - 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); - case BARREL: - return new CraftBarrel(this); - case BELL: - return new CraftBell(this); - case BLAST_FURNACE: - return new CraftBlastFurnace(this); - case CAMPFIRE: - case SOUL_CAMPFIRE: - return new CraftCampfire(this); - case JIGSAW: - return new CraftJigsaw(this); - case LECTERN: - return new CraftLectern(this); - case SMOKER: - return new CraftSmoker(this); - case BEEHIVE: - case BEE_NEST: - return new CraftBeehive(this); - default: - TileEntity tileEntity = world.getTileEntity(position); - if (tileEntity != null) { - // block with unhandled TileEntity: - return new CraftBlockEntityState(this, (Class) tileEntity.getClass()); - } else { - // Block without TileEntity: - return new CraftBlockState(this); - } + case ACACIA_SIGN: + case ACACIA_WALL_SIGN: + case BIRCH_SIGN: + case BIRCH_WALL_SIGN: + case CRIMSON_SIGN: + case CRIMSON_WALL_SIGN: + case DARK_OAK_SIGN: + case DARK_OAK_WALL_SIGN: + case JUNGLE_SIGN: + case JUNGLE_WALL_SIGN: + case OAK_SIGN: + case OAK_WALL_SIGN: + case SPRUCE_SIGN: + case SPRUCE_WALL_SIGN: + case WARPED_SIGN: + case WARPED_WALL_SIGN: + return new CraftSign(this); + case CHEST: + case TRAPPED_CHEST: + return new CraftChest(this); + case FURNACE: + return new CraftFurnaceFurnace(this); + case DISPENSER: + return new CraftDispenser(this); + case DROPPER: + return new CraftDropper(this); + case END_GATEWAY: + return new CraftEndGateway(this); + case HOPPER: + return new CraftHopper(this); + case SPAWNER: + return new CraftCreatureSpawner(this); + case JUKEBOX: + return new CraftJukebox(this); + case BREWING_STAND: + return new CraftBrewingStand(this); + case CREEPER_HEAD: + case CREEPER_WALL_HEAD: + case DRAGON_HEAD: + case DRAGON_WALL_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_BLOCK: + case CHAIN_COMMAND_BLOCK: + case REPEATING_COMMAND_BLOCK: + return new CraftCommandBlock(this); + case BEACON: + return new CraftBeacon(this); + 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 STRUCTURE_BLOCK: + return new CraftStructureBlock(this); + case SHULKER_BOX: + case WHITE_SHULKER_BOX: + case ORANGE_SHULKER_BOX: + case MAGENTA_SHULKER_BOX: + case LIGHT_BLUE_SHULKER_BOX: + case YELLOW_SHULKER_BOX: + case LIME_SHULKER_BOX: + case PINK_SHULKER_BOX: + case GRAY_SHULKER_BOX: + case LIGHT_GRAY_SHULKER_BOX: + case CYAN_SHULKER_BOX: + case PURPLE_SHULKER_BOX: + case BLUE_SHULKER_BOX: + case BROWN_SHULKER_BOX: + case GREEN_SHULKER_BOX: + case RED_SHULKER_BOX: + case BLACK_SHULKER_BOX: + return new CraftShulkerBox(this); + case ENCHANTING_TABLE: + return new CraftEnchantingTable(this); + case ENDER_CHEST: + return new CraftEnderChest(this); + case DAYLIGHT_DETECTOR: + return new CraftDaylightDetector(this); + case COMPARATOR: + return new CraftComparator(this); + 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); + case BARREL: + return new CraftBarrel(this); + case BELL: + return new CraftBell(this); + case BLAST_FURNACE: + return new CraftBlastFurnace(this); + case CAMPFIRE: + case SOUL_CAMPFIRE: + return new CraftCampfire(this); + case JIGSAW: + return new CraftJigsaw(this); + case LECTERN: + return new CraftLectern(this); + case SMOKER: + return new CraftSmoker(this); + case BEEHIVE: + case BEE_NEST: + return new CraftBeehive(this); + default: + TileEntity tileEntity = world.getTileEntity(position); + if (tileEntity != null) { + // block with unhandled TileEntity: + return new CraftBlockEntityState(this, (Class) tileEntity.getClass()); + } else { + // Block without TileEntity: + return new CraftBlockState(this); + } } } @@ -491,7 +493,7 @@ public class CraftBlock implements Block { return null; } - return Biome.valueOf(IRegistry.BIOME.getKey(base).getKey().toUpperCase(java.util.Locale.ENGLISH)); + return Biome.valueOf(RegistryGeneration.WORLDGEN_BIOME.getKey(base).getKey().toUpperCase(java.util.Locale.ENGLISH)); } public static BiomeBase biomeToBiomeBase(Biome bio) { @@ -499,7 +501,7 @@ public class CraftBlock implements Block { return null; } - return IRegistry.BIOME.get(new MinecraftKey(bio.name().toLowerCase(java.util.Locale.ENGLISH))); + return RegistryGeneration.WORLDGEN_BIOME.get(new MinecraftKey(bio.name().toLowerCase(java.util.Locale.ENGLISH))); } @Override @@ -524,8 +526,12 @@ public class CraftBlock implements Block { @Override public boolean equals(Object o) { - if (o == this) return true; - if (!(o instanceof CraftBlock)) return false; + if (o == this) { + return true; + } + if (!(o instanceof CraftBlock)) { + return false; + } CraftBlock other = (CraftBlock) o; return this.position.equals(other.position) && this.getWorld().equals(other.getWorld()); @@ -613,7 +619,7 @@ public class CraftBlock implements Block { boolean result = false; // Modelled off EntityHuman#hasBlock - if (block != Blocks.AIR && (item == null || !iblockdata.isAlwaysDestroyable() || nmsItem.canDestroySpecialBlock(iblockdata))) { + if (block != Blocks.AIR && (item == null || !iblockdata.isRequiresSpecialTool() || nmsItem.canDestroySpecialBlock(iblockdata))) { net.minecraft.server.Block.dropItems(iblockdata, world.getMinecraftWorld(), position, world.getTileEntity(position), null, nmsItem); result = true; } @@ -637,7 +643,7 @@ public class CraftBlock implements Block { net.minecraft.server.ItemStack nms = CraftItemStack.asNMSCopy(item); // Modelled off EntityHuman#hasBlock - if (item == null || !iblockdata.isAlwaysDestroyable() || nms.canDestroySpecialBlock(iblockdata)) { + if (item == null || !iblockdata.isRequiresSpecialTool() || nms.canDestroySpecialBlock(iblockdata)) { return net.minecraft.server.Block.getDrops(iblockdata, (WorldServer) world.getMinecraftWorld(), position, world.getTileEntity(position), entity == null ? null : ((CraftEntity) entity).getHandle(), nms) .stream().map(CraftItemStack::asBukkitCopy).collect(Collectors.toList()); } else { diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java index 11aa2dc18c..0f89e77681 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java @@ -12,7 +12,6 @@ import org.bukkit.World; import org.bukkit.block.Block; 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; diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java b/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java index 941cb98cc2..89df1d7f8b 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java @@ -62,7 +62,7 @@ public class CraftChest extends CraftLootable implements Chest if (!getTileEntity().opened) { net.minecraft.server.Block block = getTileEntity().getBlock().getBlock(); getTileEntity().getWorld().playBlockAction(getTileEntity().getPosition(), block, 1, getTileEntity().viewingCount + 1); - getTileEntity().a(SoundEffects.BLOCK_CHEST_OPEN); + getTileEntity().playOpenSound(SoundEffects.BLOCK_CHEST_OPEN); } getTileEntity().opened = true; } @@ -73,7 +73,7 @@ public class CraftChest extends CraftLootable implements Chest if (getTileEntity().opened) { net.minecraft.server.Block block = getTileEntity().getBlock().getBlock(); getTileEntity().getWorld().playBlockAction(getTileEntity().getPosition(), block, 1, 0); - getTileEntity().a(SoundEffects.BLOCK_CHEST_CLOSE); + getTileEntity().playOpenSound(SoundEffects.BLOCK_CHEST_CLOSE); } getTileEntity().opened = false; } diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftChain.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftChain.java index c75cc95e62..f99be1b36a 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftChain.java +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftChain.java @@ -3,7 +3,7 @@ */ package org.bukkit.craftbukkit.block.impl; -public final class CraftChain extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.Waterlogged { +public final class CraftChain extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Chain, org.bukkit.block.data.Orientable, org.bukkit.block.data.Waterlogged { public CraftChain() { super(); @@ -13,6 +13,25 @@ public final class CraftChain extends org.bukkit.craftbukkit.block.data.CraftBlo super(state); } + // org.bukkit.craftbukkit.block.data.CraftOrientable + + private static final net.minecraft.server.BlockStateEnum AXIS = getEnum(net.minecraft.server.BlockChain.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); + } + // org.bukkit.craftbukkit.block.data.CraftWaterlogged private static final net.minecraft.server.BlockStateBoolean WATERLOGGED = getBoolean(net.minecraft.server.BlockChain.class, "waterlogged"); diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftLantern.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftLantern.java index 8e279de3e0..461fc2c07d 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftLantern.java +++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftLantern.java @@ -3,7 +3,7 @@ */ package org.bukkit.craftbukkit.block.impl; -public final class CraftLantern extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Lantern { +public final class CraftLantern extends org.bukkit.craftbukkit.block.data.CraftBlockData implements org.bukkit.block.data.type.Lantern, org.bukkit.block.data.Waterlogged { public CraftLantern() { super(); @@ -26,4 +26,18 @@ public final class CraftLantern extends org.bukkit.craftbukkit.block.data.CraftB public void setHanging(boolean hanging) { set(HANGING, hanging); } + + // org.bukkit.craftbukkit.block.data.CraftWaterlogged + + private static final net.minecraft.server.BlockStateBoolean WATERLOGGED = getBoolean(net.minecraft.server.BlockLantern.class, "waterlogged"); + + @Override + public boolean isWaterlogged() { + return get(WATERLOGGED); + } + + @Override + public void setWaterlogged(boolean waterlogged) { + set(WATERLOGGED, waterlogged); + } } diff --git a/src/main/java/org/bukkit/craftbukkit/boss/CraftDragonBattle.java b/src/main/java/org/bukkit/craftbukkit/boss/CraftDragonBattle.java index dec7e8c600..349f894f7d 100644 --- a/src/main/java/org/bukkit/craftbukkit/boss/CraftDragonBattle.java +++ b/src/main/java/org/bukkit/craftbukkit/boss/CraftDragonBattle.java @@ -39,11 +39,11 @@ public class CraftDragonBattle implements DragonBattle { @Override public boolean generateEndPortal(boolean withPortals) { - if (handle.exitPortalLocation != null || handle.j() != null) { + if (handle.exitPortalLocation != null || handle.getExitPortalShape() != null) { return false; } - this.handle.a(withPortals); + this.handle.generateExitPortal(withPortals); return true; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java index c61fc26a92..096011a2a2 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java @@ -94,6 +94,8 @@ import net.minecraft.server.EntityPhantom; import net.minecraft.server.EntityPig; import net.minecraft.server.EntityPigZombie; import net.minecraft.server.EntityPiglin; +import net.minecraft.server.EntityPiglinAbstract; +import net.minecraft.server.EntityPiglinBrute; import net.minecraft.server.EntityPillager; import net.minecraft.server.EntityPlayer; import net.minecraft.server.EntityPolarBear; @@ -284,7 +286,11 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { else { return new CraftIllager(server, (EntityIllagerAbstract) entity); } } else if (entity instanceof EntityRavager) { return new CraftRavager(server, (EntityRavager) entity); } - else if (entity instanceof EntityPiglin) { return new CraftPiglin(server, (EntityPiglin) entity); } + else if (entity instanceof EntityPiglinAbstract) { + if (entity instanceof EntityPiglin) return new CraftPiglin(server, (EntityPiglin) entity); + else if (entity instanceof EntityPiglinBrute) { return new CraftPiglinBrute(server, (EntityPiglinBrute) entity); } + else { return new CraftPiglinAbstract(server, (EntityPiglinAbstract) entity); } + } else if (entity instanceof EntityZoglin) { return new CraftZoglin(server, (EntityZoglin) entity); } else { return new CraftMonster(server, (EntityMonster) entity); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHoglin.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHoglin.java index 12f064ebab..27bdc5e0de 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHoglin.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHoglin.java @@ -14,43 +14,43 @@ public class CraftHoglin extends CraftAnimals implements Hoglin { @Override public boolean isImmuneToZombification() { - return getHandle().eW(); + return getHandle().isImmuneToZombification(); } @Override public void setImmuneToZombification(boolean flag) { - getHandle().t(flag); + getHandle().setImmuneToZombification(flag); } @Override public boolean isAbleToBeHunted() { - return getHandle().bA; + return getHandle().cannotBeHunted; } @Override public void setIsAbleToBeHunted(boolean flag) { - getHandle().bA = flag; + getHandle().cannotBeHunted = flag; } @Override public int getConversionTime() { Preconditions.checkState(isConverting(), "Entity not converting"); - return getHandle().bz; + return getHandle().conversionTicks; } @Override public void setConversionTime(int time) { if (time < 0) { - getHandle().bz = -1; - getHandle().t(false); + getHandle().conversionTicks = -1; + getHandle().setImmuneToZombification(false); } else { - getHandle().bz = time; + getHandle().conversionTicks = time; } } @Override public boolean isConverting() { - return getHandle().eO(); // PAIL rename isConverting() + return getHandle().isConverting(); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java index 60ef17fdb1..c187670228 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java @@ -522,7 +522,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { CraftingManager manager = getHandle().world.getMinecraftServer().getCraftingManager(); for (NamespacedKey recipeKey : recipeKeys) { - Optional> recipe = manager.a(CraftNamespacedKey.toMinecraft(recipeKey)); + Optional> recipe = manager.getRecipe(CraftNamespacedKey.toMinecraft(recipeKey)); if (!recipe.isPresent()) { continue; } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftItemFrame.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftItemFrame.java index 79d443abb7..072c56b8a2 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftItemFrame.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftItemFrame.java @@ -140,12 +140,12 @@ public class CraftItemFrame extends CraftHanging implements ItemFrame { @Override public boolean isFixed() { - return getHandle().ao; + return getHandle().fixed; } @Override public void setFixed(boolean fixed) { - getHandle().ao = fixed; + getHandle().fixed = fixed; } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPig.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPig.java index c9f31715a3..db96ed3202 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPig.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPig.java @@ -25,7 +25,7 @@ public class CraftPig extends CraftAnimals implements Pig { @Override public int getBoostTicks() { - return getHandle().saddleStorage.a ? getHandle().saddleStorage.c : 0; + return getHandle().saddleStorage.boosting ? getHandle().saddleStorage.boostTicks : 0; } @Override @@ -37,19 +37,19 @@ public class CraftPig extends CraftAnimals implements Pig { @Override public int getCurrentBoostTicks() { - return getHandle().saddleStorage.a ? getHandle().saddleStorage.b : 0; + return getHandle().saddleStorage.boosting ? getHandle().saddleStorage.currentBoostTicks : 0; } @Override public void setCurrentBoostTicks(int ticks) { - if (!getHandle().saddleStorage.a) { + if (!getHandle().saddleStorage.boosting) { return; } - int max = getHandle().saddleStorage.c; + int max = getHandle().saddleStorage.boostTicks; Preconditions.checkArgument(ticks >= 0 && ticks <= max, "boost ticks must not exceed 0 or %d (inclusive)", max); - this.getHandle().saddleStorage.b = ticks; + this.getHandle().saddleStorage.currentBoostTicks = ticks; } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglin.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglin.java index 18250936d2..6f83387c4c 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglin.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglin.java @@ -1,66 +1,24 @@ package org.bukkit.craftbukkit.entity; -import com.google.common.base.Preconditions; import net.minecraft.server.EntityPiglin; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.EntityType; import org.bukkit.entity.Piglin; -public class CraftPiglin extends CraftMonster implements Piglin { +public class CraftPiglin extends CraftPiglinAbstract implements Piglin { public CraftPiglin(CraftServer server, EntityPiglin entity) { super(server, entity); } - @Override - public boolean isImmuneToZombification() { - return getHandle().eT(); - } - - @Override - public void setImmuneToZombification(boolean flag) { - getHandle().t(flag); - } - @Override public boolean isAbleToHunt() { - return getHandle().bC; + return getHandle().cannotHunt; } @Override public void setIsAbleToHunt(boolean flag) { - getHandle().bC = flag; - } - - @Override - public int getConversionTime() { - Preconditions.checkState(isConverting(), "Entity not converting"); - return getHandle().bA; - } - - @Override - public void setConversionTime(int time) { - if (time < 0) { - getHandle().bA = -1; - getHandle().t(false); - } else { - getHandle().bA = time; - } - } - - @Override - public boolean isConverting() { - return getHandle().eO(); // PAIL rename isConverting() - } - - @Override - public boolean isBaby() { - return getHandle().isBaby(); - } - - @Override - public void setBaby(boolean flag) { - getHandle().a(flag); + getHandle().cannotHunt = flag; } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglinAbstract.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglinAbstract.java new file mode 100644 index 0000000000..b926d828e1 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglinAbstract.java @@ -0,0 +1,59 @@ +package org.bukkit.craftbukkit.entity; + +import com.google.common.base.Preconditions; +import net.minecraft.server.EntityPiglinAbstract; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.entity.PiglinAbstract; + +public class CraftPiglinAbstract extends CraftMonster implements PiglinAbstract { + + public CraftPiglinAbstract(CraftServer server, EntityPiglinAbstract entity) { + super(server, entity); + } + + @Override + public boolean isImmuneToZombification() { + return getHandle().isImmuneToZombification(); + } + + @Override + public void setImmuneToZombification(boolean flag) { + getHandle().setImmuneToZombification(flag); + } + + @Override + public int getConversionTime() { + Preconditions.checkState(isConverting(), "Entity not converting"); + return getHandle().conversionTicks; + } + + @Override + public void setConversionTime(int time) { + if (time < 0) { + getHandle().conversionTicks = -1; + getHandle().setImmuneToZombification(false); + } else { + getHandle().conversionTicks = time; + } + } + + @Override + public boolean isConverting() { + return getHandle().isConverting(); + } + + @Override + public boolean isBaby() { + return getHandle().isBaby(); + } + + @Override + public void setBaby(boolean flag) { + getHandle().setBaby(flag); + } + + @Override + public EntityPiglinAbstract getHandle() { + return (EntityPiglinAbstract) super.getHandle(); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglinBrute.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglinBrute.java new file mode 100644 index 0000000000..d59f6a3e02 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglinBrute.java @@ -0,0 +1,28 @@ +package org.bukkit.craftbukkit.entity; + +import net.minecraft.server.EntityPiglinBrute; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.PiglinBrute; + +public class CraftPiglinBrute extends CraftPiglinAbstract implements PiglinBrute { + + public CraftPiglinBrute(CraftServer server, EntityPiglinBrute entity) { + super(server, entity); + } + + @Override + public EntityPiglinBrute getHandle() { + return (EntityPiglinBrute) super.getHandle(); + } + + @Override + public EntityType getType() { + return EntityType.PIGLIN_BRUTE; + } + + @Override + public String toString() { + return "CraftPiglinBrute"; + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index 6ee141c687..e9d4b763c8 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -314,7 +314,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { if (getHandle().playerConnection == null) return; // Do not directly assign here, from the packethandler we'll assign it. - getHandle().playerConnection.sendPacket(new PacketPlayOutSpawnPosition(new BlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()))); + getHandle().playerConnection.sendPacket(new PacketPlayOutSpawnPosition(new BlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()), loc.getYaw())); } @Override @@ -728,7 +728,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { BlockPosition bed = getHandle().getSpawn(); if (world != null && bed != null) { - Optional spawnLoc = EntityHuman.getBed(((CraftWorld) world).getHandle(), bed, getHandle().isSpawnForced(), true); + Optional spawnLoc = EntityHuman.getBed(((CraftWorld) world).getHandle(), bed, getHandle().getSpawnAngle(), getHandle().isSpawnForced(), true); if (spawnLoc.isPresent()) { Vec3D vec = spawnLoc.get(); return new Location(world, vec.x, vec.y, vec.z); @@ -745,9 +745,9 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @Override public void setBedSpawnLocation(Location location, boolean override) { if (location == null) { - getHandle().setRespawnPosition(null, null, override, false); + getHandle().setRespawnPosition(null, null, location.getYaw(), override, false); } else { - getHandle().setRespawnPosition(((CraftWorld) location.getWorld()).getHandle().getDimensionKey(), new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ()), override, false); + getHandle().setRespawnPosition(((CraftWorld) location.getWorld()).getHandle().getDimensionKey(), new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ()), location.getYaw(), override, false); } } @@ -762,13 +762,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @Override public boolean hasDiscoveredRecipe(NamespacedKey recipe) { Preconditions.checkArgument(recipe != null, "recipe cannot be null"); - return getHandle().B().b(CraftNamespacedKey.toMinecraft(recipe)); + return getHandle().getRecipeBook().hasDiscoveredRecipe(CraftNamespacedKey.toMinecraft(recipe)); } @Override public Set getDiscoveredRecipes() { ImmutableSet.Builder bukkitRecipeKeys = ImmutableSet.builder(); - getHandle().B().a.forEach(key -> bukkitRecipeKeys.add(CraftNamespacedKey.fromMinecraft(key))); + getHandle().getRecipeBook().recipes.forEach(key -> bukkitRecipeKeys.add(CraftNamespacedKey.fromMinecraft(key))); return bukkitRecipeKeys.build(); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftStrider.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftStrider.java index f42a6ea00d..a17027323c 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftStrider.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftStrider.java @@ -15,12 +15,12 @@ public class CraftStrider extends CraftAnimals implements Strider { @Override public boolean isShivering() { - return getHandle().eL(); // PAIL rename isShivering + return getHandle().isShivering(); } @Override public void setShivering(boolean shivering) { - this.getHandle().t(shivering); // PAIL rename setShivering + this.getHandle().setShivering(shivering); } @Override @@ -30,36 +30,36 @@ public class CraftStrider extends CraftAnimals implements Strider { @Override public void setSaddle(boolean saddled) { - getHandle().bA.setSaddle(saddled); + getHandle().saddleStorage.setSaddle(saddled); } @Override public int getBoostTicks() { - return getHandle().bA.a ? getHandle().bA.c : 0; + return getHandle().saddleStorage.boosting ? getHandle().saddleStorage.boostTicks : 0; } @Override public void setBoostTicks(int ticks) { Preconditions.checkArgument(ticks >= 0, "ticks must be >= 0"); - getHandle().bA.setBoostTicks(ticks); + getHandle().saddleStorage.setBoostTicks(ticks); } @Override public int getCurrentBoostTicks() { - return getHandle().bA.a ? getHandle().bA.b : 0; + return getHandle().saddleStorage.boosting ? getHandle().saddleStorage.currentBoostTicks : 0; } @Override public void setCurrentBoostTicks(int ticks) { - if (!getHandle().bA.a) { + if (!getHandle().saddleStorage.boosting) { return; } - int max = getHandle().bA.c; + int max = getHandle().saddleStorage.boostTicks; Preconditions.checkArgument(ticks >= 0 && ticks <= max, "boost ticks must not exceed 0 or %d (inclusive)", max); - this.getHandle().bA.b = ticks; + this.getHandle().saddleStorage.currentBoostTicks = ticks; } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftZoglin.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftZoglin.java index 3d1774cf22..e7e1782158 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftZoglin.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftZoglin.java @@ -18,7 +18,7 @@ public class CraftZoglin extends CraftMonster implements Zoglin { @Override public void setBaby(boolean flag) { - getHandle().a(flag); + getHandle().setBaby(flag); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index edbc1d9359..29294f91b0 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -1460,7 +1460,7 @@ public class CraftEventFactory { BlockPhysicsEvent event = new BlockPhysicsEvent(block, block.getBlockData()); // Suppress during worldgen if (world instanceof World) { - world.getMinecraftWorld().getMinecraftServer().server.getPluginManager().callEvent(event); + ((World) world).getMinecraftServer().server.getPluginManager().callEvent(event); } return event; } diff --git a/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java b/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java index b53d44f0c2..323beecc12 100644 --- a/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java +++ b/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java @@ -14,9 +14,12 @@ import net.minecraft.server.DefinedStructureManager; import net.minecraft.server.DimensionManager; import net.minecraft.server.EnumCreatureType; import net.minecraft.server.GeneratorAccess; +import net.minecraft.server.GeneratorAccessSeed; import net.minecraft.server.HeightMap; import net.minecraft.server.IBlockAccess; import net.minecraft.server.IChunkAccess; +import net.minecraft.server.IRegistry; +import net.minecraft.server.IRegistryCustom; import net.minecraft.server.ITileEntity; import net.minecraft.server.ProtoChunk; import net.minecraft.server.RegionLimitedWorldAccess; @@ -36,6 +39,7 @@ import org.bukkit.generator.ChunkGenerator.BiomeGrid; import org.bukkit.generator.ChunkGenerator.ChunkData; public class CustomChunkGenerator extends InternalChunkGenerator { + private final net.minecraft.server.ChunkGenerator delegate; private final ChunkGenerator generator; private final WorldServer world; @@ -81,7 +85,7 @@ public class CustomChunkGenerator extends InternalChunkGenerator { } @Override - public void createBiomes(IChunkAccess ichunkaccess) { + public void createBiomes(IRegistry iregistry, IChunkAccess ichunkaccess) { // Don't allow the server to override any custom biomes that have been set } @@ -91,8 +95,8 @@ public class CustomChunkGenerator extends InternalChunkGenerator { } @Override - public void storeStructures(GeneratorAccess generatoraccess, StructureManager structuremanager, IChunkAccess ichunkaccess) { - delegate.storeStructures(generatoraccess, structuremanager, ichunkaccess); + public void storeStructures(GeneratorAccessSeed generatoraccessseed, StructureManager structuremanager, IChunkAccess ichunkaccess) { + delegate.storeStructures(generatoraccessseed, structuremanager, ichunkaccess); } @Override @@ -108,7 +112,7 @@ public class CustomChunkGenerator extends InternalChunkGenerator { random.setSeed((long) x * 341873128712L + (long) z * 132897987541L); // Get default biome data for chunk - CustomBiomeGrid biomegrid = new CustomBiomeGrid(new BiomeStorage(ichunkaccess.getPos(), this.getWorldChunkManager())); + CustomBiomeGrid biomegrid = new CustomBiomeGrid(new BiomeStorage(world.r().b(IRegistry.ay), ichunkaccess.getPos(), this.getWorldChunkManager())); ChunkData data; if (generator.isParallelCapable()) { @@ -155,12 +159,13 @@ public class CustomChunkGenerator extends InternalChunkGenerator { } @Override - public void createStructures(StructureManager structuremanager, IChunkAccess ichunkaccess, DefinedStructureManager definedstructuremanager, long i) { + public void createStructures(IRegistryCustom iregistrycustom, StructureManager structuremanager, IChunkAccess ichunkaccess, DefinedStructureManager definedstructuremanager, long i) { if (generator.shouldGenerateStructures()) { // Still need a way of getting the biome of this chunk to pass to createStructures // Using default biomes for now. - delegate.createStructures(structuremanager, ichunkaccess, definedstructuremanager, i); + delegate.createStructures(iregistrycustom, structuremanager, ichunkaccess, definedstructuremanager, i); } + } @Override @@ -180,11 +185,6 @@ public class CustomChunkGenerator extends InternalChunkGenerator { return delegate.getBaseHeight(i, j, heightmap_type); } - @Override - public List getMobsFor(BiomeBase biomebase, StructureManager structuremanager, EnumCreatureType enumcreaturetype, BlockPosition blockposition) { - return delegate.getMobsFor(biomebase, structuremanager, enumcreaturetype, blockposition); - } - @Override public void addDecorations(RegionLimitedWorldAccess regionlimitedworldaccess, StructureManager structuremanager) { if (generator.shouldGenerateDecorations()) { diff --git a/src/main/java/org/bukkit/craftbukkit/projectiles/CraftBlockProjectileSource.java b/src/main/java/org/bukkit/craftbukkit/projectiles/CraftBlockProjectileSource.java index 46e9caf0fb..459a08984c 100644 --- a/src/main/java/org/bukkit/craftbukkit/projectiles/CraftBlockProjectileSource.java +++ b/src/main/java/org/bukkit/craftbukkit/projectiles/CraftBlockProjectileSource.java @@ -20,6 +20,7 @@ import net.minecraft.server.IProjectile; import net.minecraft.server.MathHelper; import net.minecraft.server.SourceBlock; import net.minecraft.server.TileEntityDispenser; +import net.minecraft.server.WorldServer; import org.apache.commons.lang.Validate; import org.bukkit.Material; import org.bukkit.block.Block; @@ -65,7 +66,7 @@ public class CraftBlockProjectileSource implements BlockProjectileSource { public T launchProjectile(Class projectile, Vector velocity) { Validate.isTrue(getBlock().getType() == Material.DISPENSER, "Block is no longer dispenser"); // Copied from BlockDispenser.dispense() - SourceBlock isourceblock = new SourceBlock(dispenserBlock.getWorld(), dispenserBlock.getPosition()); + SourceBlock isourceblock = new SourceBlock((WorldServer) dispenserBlock.getWorld(), dispenserBlock.getPosition()); // Copied from DispenseBehaviorProjectile IPosition iposition = BlockDispenser.a(isourceblock); EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING); diff --git a/src/main/java/org/bukkit/craftbukkit/tag/CraftBlockTag.java b/src/main/java/org/bukkit/craftbukkit/tag/CraftBlockTag.java index 694aff9b1b..da6ac82748 100644 --- a/src/main/java/org/bukkit/craftbukkit/tag/CraftBlockTag.java +++ b/src/main/java/org/bukkit/craftbukkit/tag/CraftBlockTag.java @@ -5,13 +5,13 @@ import java.util.Set; import java.util.stream.Collectors; import net.minecraft.server.Block; import net.minecraft.server.MinecraftKey; -import net.minecraft.server.TagsServer; +import net.minecraft.server.Tags; import org.bukkit.Material; import org.bukkit.craftbukkit.util.CraftMagicNumbers; public class CraftBlockTag extends CraftTag { - public CraftBlockTag(TagsServer registry, MinecraftKey tag) { + public CraftBlockTag(Tags registry, MinecraftKey tag) { super(registry, tag); } diff --git a/src/main/java/org/bukkit/craftbukkit/tag/CraftItemTag.java b/src/main/java/org/bukkit/craftbukkit/tag/CraftItemTag.java index cd72f07c5f..f6cfbc1084 100644 --- a/src/main/java/org/bukkit/craftbukkit/tag/CraftItemTag.java +++ b/src/main/java/org/bukkit/craftbukkit/tag/CraftItemTag.java @@ -5,13 +5,13 @@ import java.util.Set; import java.util.stream.Collectors; import net.minecraft.server.Item; import net.minecraft.server.MinecraftKey; -import net.minecraft.server.TagsServer; +import net.minecraft.server.Tags; import org.bukkit.Material; import org.bukkit.craftbukkit.util.CraftMagicNumbers; public class CraftItemTag extends CraftTag { - public CraftItemTag(TagsServer registry, MinecraftKey tag) { + public CraftItemTag(Tags registry, MinecraftKey tag) { super(registry, tag); } diff --git a/src/main/java/org/bukkit/craftbukkit/tag/CraftTag.java b/src/main/java/org/bukkit/craftbukkit/tag/CraftTag.java index c08671e232..682b06f93e 100644 --- a/src/main/java/org/bukkit/craftbukkit/tag/CraftTag.java +++ b/src/main/java/org/bukkit/craftbukkit/tag/CraftTag.java @@ -1,7 +1,7 @@ package org.bukkit.craftbukkit.tag; import net.minecraft.server.MinecraftKey; -import net.minecraft.server.TagsServer; +import net.minecraft.server.Tags; import org.bukkit.Keyed; import org.bukkit.NamespacedKey; import org.bukkit.Tag; @@ -9,23 +9,17 @@ import org.bukkit.craftbukkit.util.CraftNamespacedKey; public abstract class CraftTag implements Tag { - private final net.minecraft.server.TagsServer registry; + private final net.minecraft.server.Tags registry; private final MinecraftKey tag; // - private int version = -1; private net.minecraft.server.Tag handle; - public CraftTag(TagsServer registry, MinecraftKey tag) { + public CraftTag(Tags registry, MinecraftKey tag) { this.registry = registry; this.tag = tag; } protected net.minecraft.server.Tag getHandle() { - if (version != registry.version) { - handle = registry.b(tag); - version = registry.version; - } - return handle; } diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java b/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java index bfeea111b6..e796e95611 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java @@ -45,11 +45,11 @@ public final class CraftChatMessage { // Separate pattern with no group 3, new lines are part of previous string private static final Pattern INCREMENTAL_PATTERN_KEEP_NEWLINES = Pattern.compile("(" + String.valueOf(org.bukkit.ChatColor.COLOR_CHAR) + "[0-9a-fk-orx])|((?:(?:https?):\\/\\/)?(?:[-\\w_\\.]{2,}\\.[a-z]{2,4}.*?(?=[\\.\\?!,;:]?(?:[" + String.valueOf(org.bukkit.ChatColor.COLOR_CHAR) + " ]|$))))", Pattern.CASE_INSENSITIVE); // ChatColor.b does not explicitly reset, its more of empty - private static final ChatModifier RESET = ChatModifier.b.setBold(false).setItalic(false).setUnderline(false).setStrikethrough(false).setRandom(false); + private static final ChatModifier RESET = ChatModifier.a.setBold(false).setItalic(false).setUnderline(false).setStrikethrough(false).setRandom(false); private final List list = new ArrayList(); private IChatMutableComponent currentChatComponent = new ChatComponentText(""); - private ChatModifier modifier = ChatModifier.b; + private ChatModifier modifier = ChatModifier.a; private final IChatBaseComponent[] output; private int currentIndex; private StringBuilder hex; diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java index 1358c99c9f..1afaa24299 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java @@ -204,7 +204,7 @@ public final class CraftMagicNumbers implements UnsafeValues { * @return string */ public String getMappingsVersion() { - return "25afc67716a170ea965092c1067ff439"; + return "c2d5d7871edcc4fb0f81d18959c647af"; } @Override @@ -240,7 +240,7 @@ public final class CraftMagicNumbers implements UnsafeValues { JsonElement jsonelement = AdvancementDataWorld.DESERIALIZER.fromJson(advancement, JsonElement.class); JsonObject jsonobject = ChatDeserializer.m(jsonelement, "advancement"); - net.minecraft.server.Advancement.SerializedAdvancement nms = net.minecraft.server.Advancement.SerializedAdvancement.a(jsonobject, new LootDeserializationContext(minecraftkey, MinecraftServer.getServer().aI())); + net.minecraft.server.Advancement.SerializedAdvancement nms = net.minecraft.server.Advancement.SerializedAdvancement.a(jsonobject, new LootDeserializationContext(minecraftkey, MinecraftServer.getServer().getLootPredicateManager())); if (nms != null) { MinecraftServer.getServer().getAdvancementData().REGISTRY.a(Maps.newHashMap(Collections.singletonMap(minecraftkey, nms))); Advancement bukkit = Bukkit.getAdvancement(key); diff --git a/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java b/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java index eb87f37209..903899dc68 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java +++ b/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java @@ -20,16 +20,16 @@ import net.minecraft.server.HeightMap; import net.minecraft.server.IBlockData; import net.minecraft.server.IChunkAccess; import net.minecraft.server.IChunkProvider; +import net.minecraft.server.IRegistryCustom; import net.minecraft.server.LightEngine; import net.minecraft.server.ParticleParam; import net.minecraft.server.SoundCategory; import net.minecraft.server.SoundEffect; import net.minecraft.server.TickList; -import net.minecraft.server.TickListEmpty; import net.minecraft.server.TileEntity; -import net.minecraft.server.World; import net.minecraft.server.WorldBorder; import net.minecraft.server.WorldData; +import net.minecraft.server.WorldServer; public class DummyGeneratorAccess implements GeneratorAccess { @@ -40,16 +40,11 @@ public class DummyGeneratorAccess implements GeneratorAccess { @Override public TickList getBlockTickList() { - return TickListEmpty.b(); + throw new UnsupportedOperationException("Not supported yet."); } @Override public TickList getFluidTickList() { - return TickListEmpty.b(); - } - - @Override - public World getMinecraftWorld() { throw new UnsupportedOperationException("Not supported yet."); } @@ -59,7 +54,7 @@ public class DummyGeneratorAccess implements GeneratorAccess { } @Override - public DifficultyDamageScaler getDamageScaler(BlockPosition bp) { + public DifficultyDamageScaler getDamageScaler(BlockPosition blockposition) { throw new UnsupportedOperationException("Not supported yet."); } @@ -74,17 +69,27 @@ public class DummyGeneratorAccess implements GeneratorAccess { } @Override - public void playSound(EntityHuman eh, BlockPosition bp, SoundEffect se, SoundCategory sc, float f, float f1) { + public void playSound(EntityHuman entityhuman, BlockPosition blockposition, SoundEffect soundeffect, SoundCategory soundcategory, 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) { + public void addParticle(ParticleParam particleparam, double d0, double d1, double d2, double d3, double d4, double d5) { throw new UnsupportedOperationException("Not supported yet."); } @Override - public void a(EntityHuman eh, int i, BlockPosition bp, int i1) { + public void a(EntityHuman entityhuman, int i, BlockPosition blockposition, int j) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public WorldServer getMinecraftWorld() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public IRegistryCustom r() { throw new UnsupportedOperationException("Not supported yet."); } @@ -187,4 +192,9 @@ public class DummyGeneratorAccess implements GeneratorAccess { public boolean a(BlockPosition blockposition, boolean flag, Entity entity, int i) { throw new UnsupportedOperationException("Not supported yet."); } + + @Override + public long ab() { + throw new UnsupportedOperationException("Not supported yet."); + } } diff --git a/src/test/java/org/bukkit/BiomeTest.java b/src/test/java/org/bukkit/BiomeTest.java index 913c4cf3fc..04a11b6927 100644 --- a/src/test/java/org/bukkit/BiomeTest.java +++ b/src/test/java/org/bukkit/BiomeTest.java @@ -1,7 +1,7 @@ package org.bukkit; import net.minecraft.server.BiomeBase; -import net.minecraft.server.IRegistry; +import net.minecraft.server.RegistryGeneration; import org.bukkit.block.Biome; import org.bukkit.craftbukkit.block.CraftBlock; import org.bukkit.support.AbstractTestingBase; @@ -19,7 +19,7 @@ public class BiomeTest extends AbstractTestingBase { @Test public void testMinecraftToBukkit() { - for (Object biome : IRegistry.BIOME) { + for (Object biome : RegistryGeneration.WORLDGEN_BIOME) { Assert.assertNotNull("No Bukkit mapping for " + biome, CraftBlock.biomeBaseToBiome((BiomeBase) biome)); } } diff --git a/src/test/java/org/bukkit/MaterialTest.java b/src/test/java/org/bukkit/MaterialTest.java index efac35cb7b..f725598949 100644 --- a/src/test/java/org/bukkit/MaterialTest.java +++ b/src/test/java/org/bukkit/MaterialTest.java @@ -70,6 +70,6 @@ public class MaterialTest extends AbstractTestingBase { .sorted(Comparator.comparingInt(Material::getId)) .forEach(expectedOrder::add); - assertArrayEquals(Material.values(), expectedOrder.toArray()); + assertArrayEquals(expectedOrder.toArray(), Material.values()); } } diff --git a/src/test/java/org/bukkit/craftbukkit/legacy/LegacyTest.java b/src/test/java/org/bukkit/craftbukkit/legacy/LegacyTest.java index e39b87ae6d..5ce268bb25 100644 --- a/src/test/java/org/bukkit/craftbukkit/legacy/LegacyTest.java +++ b/src/test/java/org/bukkit/craftbukkit/legacy/LegacyTest.java @@ -62,6 +62,8 @@ public class LegacyTest extends AbstractTestingBase { Material.GILDED_BLACKSTONE, Material.LODESTONE, Material.PIGLIN_BANNER_PATTERN, Material.POLISHED_BLACKSTONE, Material.POLISHED_BLACKSTONE_BRICKS, Material.POLISHED_BLACKSTONE_BRICK_SLAB, Material.POLISHED_BLACKSTONE_BRICK_STAIRS, Material.POLISHED_BLACKSTONE_BRICK_WALL, Material.POLISHED_BLACKSTONE_BUTTON, Material.POLISHED_BLACKSTONE_PRESSURE_PLATE, Material.POLISHED_BLACKSTONE_SLAB, Material.POLISHED_BLACKSTONE_STAIRS, Material.POLISHED_BLACKSTONE_WALL, Material.QUARTZ_BRICKS, Material.SOUL_CAMPFIRE, Material.STRIDER_SPAWN_EGG, Material.WARPED_FUNGUS_ON_A_STICK, Material.ZOGLIN_SPAWN_EGG, Material.CHAIN, Material.MUSIC_DISC_PIGSTEP, + // 1.16.2 + Material.PIGLIN_BRUTE_SPAWN_EGG, // Material.LEGACY_AIR, Material.LEGACY_DEAD_BUSH, Material.LEGACY_BURNING_FURNACE, Material.LEGACY_WALL_SIGN, Material.LEGACY_REDSTONE_TORCH_OFF, Material.LEGACY_SKULL, Material.LEGACY_REDSTONE_COMPARATOR_ON, Material.LEGACY_WALL_BANNER, Material.LEGACY_MONSTER_EGG)); diff --git a/src/test/java/org/bukkit/support/AbstractTestingBase.java b/src/test/java/org/bukkit/support/AbstractTestingBase.java index d3281c81a4..75a5c0818d 100644 --- a/src/test/java/org/bukkit/support/AbstractTestingBase.java +++ b/src/test/java/org/bukkit/support/AbstractTestingBase.java @@ -42,7 +42,7 @@ public abstract class AbstractTestingBase { // Register vanilla pack resourceManager.a(MoreExecutors.directExecutor(), MoreExecutors.directExecutor(), Collections.singletonList(new ResourcePackVanilla("minecraft")), CompletableFuture.completedFuture(Unit.INSTANCE)).join(); // Bind tags - TAG_REGISTRY.bind(); + TAG_REGISTRY.a().bind(); DummyServer.setup(); DummyEnchantments.setup();