diff --git a/patches/unapplied/api/Add-ItemStackRecipeChoice-Draft-API.patch b/patches/api/Add-ItemStackRecipeChoice-Draft-API.patch similarity index 100% rename from patches/unapplied/api/Add-ItemStackRecipeChoice-Draft-API.patch rename to patches/api/Add-ItemStackRecipeChoice-Draft-API.patch diff --git a/patches/unapplied/api/Add-LivingEntity-getTargetEntity.patch b/patches/api/Add-LivingEntity-getTargetEntity.patch similarity index 100% rename from patches/unapplied/api/Add-LivingEntity-getTargetEntity.patch rename to patches/api/Add-LivingEntity-getTargetEntity.patch diff --git a/patches/unapplied/api/Add-Material-Tags.patch b/patches/api/Add-Material-Tags.patch similarity index 100% rename from patches/unapplied/api/Add-Material-Tags.patch rename to patches/api/Add-Material-Tags.patch diff --git a/patches/unapplied/api/Add-an-API-for-CanPlaceOn-and-CanDestroy-NBT-values.patch b/patches/api/Add-an-API-for-CanPlaceOn-and-CanDestroy-NBT-values.patch similarity index 100% rename from patches/unapplied/api/Add-an-API-for-CanPlaceOn-and-CanDestroy-NBT-values.patch rename to patches/api/Add-an-API-for-CanPlaceOn-and-CanDestroy-NBT-values.patch diff --git a/patches/unapplied/api/Add-spectator-target-events.patch b/patches/api/Add-spectator-target-events.patch similarity index 100% rename from patches/unapplied/api/Add-spectator-target-events.patch rename to patches/api/Add-spectator-target-events.patch diff --git a/patches/unapplied/api/Add-sun-related-API.patch b/patches/api/Add-sun-related-API.patch similarity index 100% rename from patches/unapplied/api/Add-sun-related-API.patch rename to patches/api/Add-sun-related-API.patch diff --git a/patches/unapplied/api/Here-s-Johnny.patch b/patches/api/Here-s-Johnny.patch similarity index 100% rename from patches/unapplied/api/Here-s-Johnny.patch rename to patches/api/Here-s-Johnny.patch diff --git a/patches/unapplied/api/Implement-furnace-cook-speed-multiplier-API.patch b/patches/api/Implement-furnace-cook-speed-multiplier-API.patch similarity index 100% rename from patches/unapplied/api/Implement-furnace-cook-speed-multiplier-API.patch rename to patches/api/Implement-furnace-cook-speed-multiplier-API.patch diff --git a/patches/unapplied/api/Material-API-additions.patch b/patches/api/Material-API-additions.patch similarity index 100% rename from patches/unapplied/api/Material-API-additions.patch rename to patches/api/Material-API-additions.patch diff --git a/patches/unapplied/api/Mob-Pathfinding-API.patch b/patches/api/Mob-Pathfinding-API.patch similarity index 100% rename from patches/unapplied/api/Mob-Pathfinding-API.patch rename to patches/api/Mob-Pathfinding-API.patch diff --git a/patches/unapplied/api/Performance-Concurrency-Improvements-to-Permissions.patch b/patches/api/Performance-Concurrency-Improvements-to-Permissions.patch similarity index 100% rename from patches/unapplied/api/Performance-Concurrency-Improvements-to-Permissions.patch rename to patches/api/Performance-Concurrency-Improvements-to-Permissions.patch diff --git a/patches/unapplied/api/PreSpawnerSpawnEvent.patch b/patches/api/PreSpawnerSpawnEvent.patch similarity index 100% rename from patches/unapplied/api/PreSpawnerSpawnEvent.patch rename to patches/api/PreSpawnerSpawnEvent.patch diff --git a/patches/unapplied/api/Turtle-API.patch b/patches/api/Turtle-API.patch similarity index 100% rename from patches/unapplied/api/Turtle-API.patch rename to patches/api/Turtle-API.patch diff --git a/patches/unapplied/server/Add-LivingEntity-getTargetEntity.patch b/patches/server/Add-LivingEntity-getTargetEntity.patch similarity index 100% rename from patches/unapplied/server/Add-LivingEntity-getTargetEntity.patch rename to patches/server/Add-LivingEntity-getTargetEntity.patch diff --git a/patches/unapplied/server/Add-sun-related-API.patch b/patches/server/Add-sun-related-API.patch similarity index 100% rename from patches/unapplied/server/Add-sun-related-API.patch rename to patches/server/Add-sun-related-API.patch diff --git a/patches/unapplied/server/Allow-chests-to-be-placed-with-NBT-data.patch b/patches/server/Allow-chests-to-be-placed-with-NBT-data.patch similarity index 100% rename from patches/unapplied/server/Allow-chests-to-be-placed-with-NBT-data.patch rename to patches/server/Allow-chests-to-be-placed-with-NBT-data.patch diff --git a/patches/unapplied/server/Call-player-spectator-target-events-and-improve-impl.patch b/patches/server/Call-player-spectator-target-events-and-improve-impl.patch similarity index 94% rename from patches/unapplied/server/Call-player-spectator-target-events-and-improve-impl.patch rename to patches/server/Call-player-spectator-target-events-and-improve-impl.patch index 8a2c107d5..e58380200 100644 --- a/patches/unapplied/server/Call-player-spectator-target-events-and-improve-impl.patch +++ b/patches/server/Call-player-spectator-target-events-and-improve-impl.patch @@ -25,18 +25,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ public class ServerPlayer extends Player { } - public void setCamera(Entity entity) { + public void setCamera(@Nullable Entity entity) { + // Paper start - Add PlayerStartSpectatingEntityEvent and PlayerStopSpectatingEntity Event and improve implementation Entity entity1 = this.getCamera(); - this.camera = (Entity) (entity == null ? this : entity); - if (entity1 != this.camera) { - this.connection.send(new ClientboundSetCameraPacket(this.camera)); -- this.connection.b(this.camera.getX(), this.camera.getY(), this.camera.getZ(), this.getYRot(), this.getXRot(), TeleportCause.SPECTATE); // CraftBukkit +- this.connection.teleport(this.camera.getX(), this.camera.getY(), this.camera.getZ(), this.getYRot(), this.getXRot(), TeleportCause.SPECTATE); // CraftBukkit + if (entity == null) { + entity = this; - } - ++ } ++ + if (entity1 == entity) return; // new spec target is the current spec target + + if (entity == this) { @@ -63,8 +63,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + MinecraftServer.LOGGER.debug("Blocking frozen player " + this + " from spectating entity " + entity); + return; + } -+ } -+ + } + + this.camera = entity; // only set after validating state + + if (entity != this) { diff --git a/patches/unapplied/server/Catch-JsonParseException-in-Entity-and-TE-names.patch b/patches/server/Catch-JsonParseException-in-Entity-and-TE-names.patch similarity index 99% rename from patches/unapplied/server/Catch-JsonParseException-in-Entity-and-TE-names.patch rename to patches/server/Catch-JsonParseException-in-Entity-and-TE-names.patch index bfb53789b..2ffae4e3c 100644 --- a/patches/unapplied/server/Catch-JsonParseException-in-Entity-and-TE-names.patch +++ b/patches/server/Catch-JsonParseException-in-Entity-and-TE-names.patch @@ -78,8 +78,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket; +import net.minecraft.server.MCUtil; import net.minecraft.world.Nameable; + import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.DyeColor; - import net.minecraft.world.item.ItemStack; @@ -0,0 +0,0 @@ public class BannerBlockEntity extends BlockEntity implements Nameable { public void load(CompoundTag nbt) { super.load(nbt); diff --git a/patches/unapplied/server/Configurable-connection-throttle-kick-message.patch b/patches/server/Configurable-connection-throttle-kick-message.patch similarity index 100% rename from patches/unapplied/server/Configurable-connection-throttle-kick-message.patch rename to patches/server/Configurable-connection-throttle-kick-message.patch diff --git a/patches/unapplied/server/Here-s-Johnny.patch b/patches/server/Here-s-Johnny.patch similarity index 100% rename from patches/unapplied/server/Here-s-Johnny.patch rename to patches/server/Here-s-Johnny.patch diff --git a/patches/unapplied/server/Honor-EntityAgeable.ageLock.patch b/patches/server/Honor-EntityAgeable.ageLock.patch similarity index 100% rename from patches/unapplied/server/Honor-EntityAgeable.ageLock.patch rename to patches/server/Honor-EntityAgeable.ageLock.patch diff --git a/patches/unapplied/server/Hook-into-CB-plugin-rewrites.patch b/patches/server/Hook-into-CB-plugin-rewrites.patch similarity index 100% rename from patches/unapplied/server/Hook-into-CB-plugin-rewrites.patch rename to patches/server/Hook-into-CB-plugin-rewrites.patch diff --git a/patches/unapplied/server/Implement-an-API-for-CanPlaceOn-and-CanDestroy-NBT-v.patch b/patches/server/Implement-an-API-for-CanPlaceOn-and-CanDestroy-NBT-v.patch similarity index 99% rename from patches/unapplied/server/Implement-an-API-for-CanPlaceOn-and-CanDestroy-NBT-v.patch rename to patches/server/Implement-an-API-for-CanPlaceOn-and-CanDestroy-NBT-v.patch index a6acb9bc2..a1a89f0a8 100644 --- a/patches/unapplied/server/Implement-an-API-for-CanPlaceOn-and-CanDestroy-NBT-v.patch +++ b/patches/server/Implement-an-API-for-CanPlaceOn-and-CanDestroy-NBT-v.patch @@ -125,7 +125,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + String internal = SerializableMeta.getString(map, "internal", true); if (internal != null) { - ByteArrayInputStream buf = new ByteArrayInputStream(Base64.decodeBase64(internal)); + ByteArrayInputStream buf = new ByteArrayInputStream(Base64.getDecoder().decode(internal)); @@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { if (this.hasDamage()) { itemTag.putInt(DAMAGE.NBT, damage); diff --git a/patches/unapplied/server/Implement-furnace-cook-speed-multiplier-API.patch b/patches/server/Implement-furnace-cook-speed-multiplier-API.patch similarity index 100% rename from patches/unapplied/server/Implement-furnace-cook-speed-multiplier-API.patch rename to patches/server/Implement-furnace-cook-speed-multiplier-API.patch diff --git a/patches/unapplied/server/Mob-Pathfinding-API.patch b/patches/server/Mob-Pathfinding-API.patch similarity index 100% rename from patches/unapplied/server/Mob-Pathfinding-API.patch rename to patches/server/Mob-Pathfinding-API.patch diff --git a/patches/unapplied/server/PreSpawnerSpawnEvent.patch b/patches/server/PreSpawnerSpawnEvent.patch similarity index 100% rename from patches/unapplied/server/PreSpawnerSpawnEvent.patch rename to patches/server/PreSpawnerSpawnEvent.patch diff --git a/patches/unapplied/server/Prevent-Mob-AI-Rules-from-Loading-Chunks.patch b/patches/server/Prevent-Mob-AI-Rules-from-Loading-Chunks.patch similarity index 100% rename from patches/unapplied/server/Prevent-Mob-AI-Rules-from-Loading-Chunks.patch rename to patches/server/Prevent-Mob-AI-Rules-from-Loading-Chunks.patch diff --git a/patches/unapplied/server/Prevent-chunk-loading-from-Fluid-Flowing.patch b/patches/server/Prevent-chunk-loading-from-Fluid-Flowing.patch similarity index 94% rename from patches/unapplied/server/Prevent-chunk-loading-from-Fluid-Flowing.patch rename to patches/server/Prevent-chunk-loading-from-Fluid-Flowing.patch index 02c2bf2d5..434e53ef2 100644 --- a/patches/unapplied/server/Prevent-chunk-loading-from-Fluid-Flowing.patch +++ b/patches/server/Prevent-chunk-loading-from-Fluid-Flowing.patch @@ -23,16 +23,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 Direction enumdirection = (Direction) iterator.next(); BlockPos blockposition1 = pos.relative(enumdirection); - BlockState iblockdata1 = world.getBlockState(blockposition1); ++ + BlockState iblockdata1 = world.getTypeIfLoaded(blockposition1); // Paper + if (iblockdata1 == null) continue; // Paper FluidState fluid = iblockdata1.getFluidState(); - if (fluid.getType().isSame((Fluid) this) && this.canPassThroughWall(enumdirection, (BlockGetter) world, pos, state, blockposition1, iblockdata1)) { + if (fluid.getType().isSame(this) && this.canPassThroughWall(enumdirection, world, pos, state, blockposition1, iblockdata1)) { @@ -0,0 +0,0 @@ public abstract class FlowingFluid extends Fluid { if (enumdirection1 != enumdirection) { BlockPos blockposition2 = blockposition.relative(enumdirection1); short short0 = FlowingFluid.getCacheKey(blockposition1, blockposition2); -- Pair pair = (Pair) short2objectmap.computeIfAbsent(short0, (k) -> { +- Pair pair = (Pair) short2objectmap.computeIfAbsent(short0, (short1) -> { - BlockState iblockdata1 = world.getBlockState(blockposition2); + // Paper start - avoid loading chunks + Pair pair = short2objectmap.get(short0); @@ -55,7 +56,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 Direction enumdirection = (Direction) iterator.next(); BlockPos blockposition1 = pos.relative(enumdirection); short short0 = FlowingFluid.getCacheKey(pos, blockposition1); -- Pair pair = (Pair) short2objectmap.computeIfAbsent(short0, (j) -> { +- Pair pair = (Pair) short2objectmap.computeIfAbsent(short0, (short1) -> { - BlockState iblockdata1 = world.getBlockState(blockposition1); - - return Pair.of(iblockdata1, iblockdata1.getFluidState()); diff --git a/patches/unapplied/server/Prevent-mob-spawning-from-loading-generating-chunks.patch b/patches/server/Prevent-mob-spawning-from-loading-generating-chunks.patch similarity index 95% rename from patches/unapplied/server/Prevent-mob-spawning-from-loading-generating-chunks.patch rename to patches/server/Prevent-mob-spawning-from-loading-generating-chunks.patch index acc3086a6..706a5a939 100644 --- a/patches/unapplied/server/Prevent-mob-spawning-from-loading-generating-chunks.patch +++ b/patches/server/Prevent-mob-spawning-from-loading-generating-chunks.patch @@ -28,5 +28,5 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - if (NaturalSpawner.isRightDistanceToPlayerAndSpawnPoint(world, chunk, blockposition_mutableblockposition, d2)) { + if (world.isLoadedAndInBounds(blockposition_mutableblockposition) && NaturalSpawner.isRightDistanceToPlayerAndSpawnPoint(world, chunk, blockposition_mutableblockposition, d2)) { // Paper - don't load chunks for mob spawn if (biomesettingsmobs_c == null) { - Optional optional = NaturalSpawner.getRandomSpawnMobAt(world, structuremanager, chunkgenerator, group, world.random, (BlockPos) blockposition_mutableblockposition); + Optional optional = NaturalSpawner.getRandomSpawnMobAt(world, structuremanager, chunkgenerator, group, world.random, blockposition_mutableblockposition); diff --git a/patches/unapplied/server/Turtle-API.patch b/patches/server/Turtle-API.patch similarity index 81% rename from patches/unapplied/server/Turtle-API.patch rename to patches/server/Turtle-API.patch index cc8ced853..22d62b109 100644 --- a/patches/unapplied/server/Turtle-API.patch +++ b/patches/server/Turtle-API.patch @@ -21,28 +21,20 @@ diff --git a/src/main/java/net/minecraft/world/entity/animal/Turtle.java b/src/m index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/animal/Turtle.java +++ b/src/main/java/net/minecraft/world/entity/animal/Turtle.java -@@ -0,0 +0,0 @@ import net.minecraft.nbt.CompoundTag; - import net.minecraft.network.syncher.EntityDataAccessor; - import net.minecraft.network.syncher.EntityDataSerializers; - import net.minecraft.network.syncher.SynchedEntityData; -+import net.minecraft.server.MCUtil; - import net.minecraft.server.level.ServerLevel; - import net.minecraft.server.level.ServerPlayer; - import net.minecraft.sounds.SoundEvent; @@ -0,0 +0,0 @@ public class Turtle extends Animal { if (!this.turtle.isInWater() && this.isReachedTarget()) { if (this.turtle.layEggCounter < 1) { - this.turtle.setLayingEgg(true); -+ this.turtle.setLayingEgg(new com.destroystokyo.paper.event.entity.TurtleStartDiggingEvent((org.bukkit.entity.Turtle) this.turtle.getBukkitEntity(), MCUtil.toLocation(this.turtle.level, this.getTargetPosition())).callEvent()); // Paper - } else if (this.turtle.layEggCounter > 200) { ++ this.turtle.setLayingEgg(new com.destroystokyo.paper.event.entity.TurtleStartDiggingEvent((org.bukkit.entity.Turtle) this.turtle.getBukkitEntity(), net.minecraft.server.MCUtil.toLocation(this.turtle.level, this.getTargetPosition())).callEvent()); // Paper + } else if (this.turtle.layEggCounter > this.adjustedTickDelay(200)) { Level world = this.turtle.level; // CraftBukkit start - if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.turtle, this.blockPos.above(), (BlockState) Blocks.TURTLE_EGG.defaultBlockState().setValue(TurtleEggBlock.EGGS, this.turtle.random.nextInt(4) + 1)).isCancelled()) { + // Paper start + int eggCount = this.turtle.random.nextInt(4) + 1; -+ com.destroystokyo.paper.event.entity.TurtleLayEggEvent layEggEvent = new com.destroystokyo.paper.event.entity.TurtleLayEggEvent((org.bukkit.entity.Turtle) this.turtle.getBukkitEntity(), MCUtil.toLocation(this.turtle.level, this.blockPos.above()), eggCount); ++ com.destroystokyo.paper.event.entity.TurtleLayEggEvent layEggEvent = new com.destroystokyo.paper.event.entity.TurtleLayEggEvent((org.bukkit.entity.Turtle) this.turtle.getBukkitEntity(), net.minecraft.server.MCUtil.toLocation(this.turtle.level, this.blockPos.above()), eggCount); + if (layEggEvent.callEvent() && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.turtle, this.blockPos.above(), Blocks.TURTLE_EGG.defaultBlockState().setValue(TurtleEggBlock.EGGS, layEggEvent.getEggCount())).isCancelled()) { world.playSound((Player) null, blockposition, SoundEvents.TURTLE_LAY_EGG, SoundSource.BLOCKS, 0.3F, 0.9F + world.random.nextFloat() * 0.2F); - world.setBlock(this.blockPos.above(), (BlockState) Blocks.TURTLE_EGG.defaultBlockState().setValue(TurtleEggBlock.EGGS, this.turtle.random.nextInt(4) + 1), 3); @@ -54,8 +46,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override public boolean canUse() { -- return this.turtle.isBaby() ? false : (this.turtle.hasEgg() ? true : (this.turtle.getRandom().nextInt(700) != 0 ? false : !this.turtle.getHomePos().closerThan((Position) this.turtle.position(), 64.0D))); -+ return this.turtle.isBaby() ? false : (this.turtle.hasEgg() ? true : (this.turtle.getRandom().nextInt(700) != 0 ? false : !this.turtle.getHomePos().closerThan((Position) this.turtle.position(), 64.0D))) && new com.destroystokyo.paper.event.entity.TurtleGoHomeEvent((org.bukkit.entity.Turtle) this.turtle.getBukkitEntity()).callEvent(); // Paper +- return this.turtle.isBaby() ? false : (this.turtle.hasEgg() ? true : (this.turtle.getRandom().nextInt(reducedTickDelay(700)) != 0 ? false : !this.turtle.getHomePos().closerThan((Position) this.turtle.position(), 64.0D))); ++ return this.turtle.isBaby() ? false : (this.turtle.hasEgg() ? true : (this.turtle.getRandom().nextInt(reducedTickDelay(700)) != 0 ? false : !this.turtle.getHomePos().closerThan((Position) this.turtle.position(), 64.0D))) && new com.destroystokyo.paper.event.entity.TurtleGoHomeEvent((org.bukkit.entity.Turtle) this.turtle.getBukkitEntity()).callEvent(); // Paper } @Override diff --git a/todo.txt b/todo.txt index 25f9921a9..0d8e21029 100644 --- a/todo.txt +++ b/todo.txt @@ -1,3 +1,4 @@ Add Timings to LevelTicks and EntityTickList Check IBlockDataList#GLOBAL_PALETTE Check if PlayerNaturallySpawnedEvent is called correctly +Make sure fluids aren't completly fucked, there may be more sync loads to nuke there as well