From 9a7acfee266e655335c90ad9c0b1265e642648de Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Sat, 12 Jun 2021 23:48:25 -0700 Subject: [PATCH] patches fix --- .../api-unmapped/PreSpawnerSpawnEvent.patch | 45 ----- .../Add-LivingEntity-getTargetEntity.patch | 0 .../Add-Material-Tags.patch | 0 .../Add-more-Witch-API.patch | 0 .../Add-spectator-target-events.patch | 0 .../Add-sun-related-API.patch | 0 .../{api-unmapped => api}/Here-s-Johnny.patch | 0 .../Material-API-additions.patch | 0 .../{api-unmapped => api}/Turtle-API.patch | 0 .../Add-LivingEntity-getTargetEntity.patch | 187 ------------------ .../PreSpawnerSpawnEvent.patch | 29 --- .../Add-LivingEntity-getTargetEntity.patch | 114 +++++++++++ .../Add-Velocity-IP-Forwarding-Support.patch | 112 +++-------- .../Add-more-Witch-API.patch | 13 -- ...event-players-from-moving-into-unloa.patch | 32 +-- .../Add-sun-related-API.patch | 9 +- ...tator-target-events-and-improve-impl.patch | 25 ++- ...arseException-in-Entity-and-TE-names.patch | 44 +++-- ...owned-for-Villager-Aggression-Config.patch | 6 +- ...ble-connection-throttle-kick-message.patch | 6 +- .../Here-s-Johnny.patch | 8 +- .../Honor-EntityAgeable.ageLock.patch | 8 +- .../Hook-into-CB-plugin-rewrites.patch | 0 ...ther-worlds-for-shooter-of-projectil.patch | 33 ++-- .../Turtle-API.patch | 38 ++-- 25 files changed, 245 insertions(+), 464 deletions(-) delete mode 100644 patches/api-unmapped/PreSpawnerSpawnEvent.patch rename patches/{api-unmapped => api}/Add-LivingEntity-getTargetEntity.patch (100%) rename patches/{api-unmapped => api}/Add-Material-Tags.patch (100%) rename patches/{api-unmapped => api}/Add-more-Witch-API.patch (100%) rename patches/{api-unmapped => api}/Add-spectator-target-events.patch (100%) rename patches/{api-unmapped => api}/Add-sun-related-API.patch (100%) rename patches/{api-unmapped => api}/Here-s-Johnny.patch (100%) rename patches/{api-unmapped => api}/Material-API-additions.patch (100%) rename patches/{api-unmapped => api}/Turtle-API.patch (100%) delete mode 100644 patches/server-remapped/Add-LivingEntity-getTargetEntity.patch delete mode 100644 patches/server-remapped/PreSpawnerSpawnEvent.patch create mode 100644 patches/server/Add-LivingEntity-getTargetEntity.patch rename patches/{server-remapped => server}/Add-Velocity-IP-Forwarding-Support.patch (69%) rename patches/{server-remapped => server}/Add-more-Witch-API.patch (92%) rename patches/{server-remapped => server}/Add-option-to-prevent-players-from-moving-into-unloa.patch (76%) rename patches/{server-remapped => server}/Add-sun-related-API.patch (86%) rename patches/{server-remapped => server}/Call-player-spectator-target-events-and-improve-impl.patch (78%) rename patches/{server-remapped => server}/Catch-JsonParseException-in-Entity-and-TE-names.patch (81%) rename patches/{server-remapped => server}/Check-Drowned-for-Villager-Aggression-Config.patch (78%) rename patches/{server-remapped => server}/Configurable-connection-throttle-kick-message.patch (84%) rename patches/{server-remapped => server}/Here-s-Johnny.patch (83%) rename patches/{server-remapped => server}/Honor-EntityAgeable.ageLock.patch (58%) rename patches/{server-remapped => server}/Hook-into-CB-plugin-rewrites.patch (100%) rename patches/{server-remapped => server}/MC-50319-Check-other-worlds-for-shooter-of-projectil.patch (52%) rename patches/{server-remapped => server}/Turtle-API.patch (80%) diff --git a/patches/api-unmapped/PreSpawnerSpawnEvent.patch b/patches/api-unmapped/PreSpawnerSpawnEvent.patch deleted file mode 100644 index ff92e4142..000000000 --- a/patches/api-unmapped/PreSpawnerSpawnEvent.patch +++ /dev/null @@ -1,45 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Phoenix616 -Date: Tue, 18 Sep 2018 23:50:10 +0100 -Subject: [PATCH] PreSpawnerSpawnEvent - -This adds a separate event before an entity is spawned by a spawner -which contains the location of the spawner too similarly to how the -SpawnerSpawnEvent gets called instead of the CreatureSpawnEvent for -spawners. - -diff --git a/src/main/java/com/destroystokyo/paper/event/entity/PreSpawnerSpawnEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/PreSpawnerSpawnEvent.java -new file mode 100644 -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 ---- /dev/null -+++ b/src/main/java/com/destroystokyo/paper/event/entity/PreSpawnerSpawnEvent.java -@@ -0,0 +0,0 @@ -+package com.destroystokyo.paper.event.entity; -+ -+ -+import com.google.common.base.Preconditions; -+import org.bukkit.Location; -+import org.bukkit.entity.EntityType; -+import org.bukkit.event.entity.CreatureSpawnEvent; -+import org.jetbrains.annotations.NotNull; -+ -+/** -+ * Called before an entity is spawned into a world by a spawner. -+ * -+ * This only includes the spawner's location and not the full BlockState snapshot for performance reasons. -+ * If you really need it you have to get the spawner yourself. -+ */ -+ -+public class PreSpawnerSpawnEvent extends PreCreatureSpawnEvent { -+ @NotNull private final Location spawnerLocation; -+ -+ public PreSpawnerSpawnEvent(@NotNull Location location, @NotNull EntityType type, @NotNull Location spawnerLocation) { -+ super(location, type, CreatureSpawnEvent.SpawnReason.SPAWNER); -+ this.spawnerLocation = Preconditions.checkNotNull(spawnerLocation, "Spawner location may not be null"); -+ } -+ -+ @NotNull -+ public Location getSpawnerLocation() { -+ return spawnerLocation; -+ } -+} diff --git a/patches/api-unmapped/Add-LivingEntity-getTargetEntity.patch b/patches/api/Add-LivingEntity-getTargetEntity.patch similarity index 100% rename from patches/api-unmapped/Add-LivingEntity-getTargetEntity.patch rename to patches/api/Add-LivingEntity-getTargetEntity.patch diff --git a/patches/api-unmapped/Add-Material-Tags.patch b/patches/api/Add-Material-Tags.patch similarity index 100% rename from patches/api-unmapped/Add-Material-Tags.patch rename to patches/api/Add-Material-Tags.patch diff --git a/patches/api-unmapped/Add-more-Witch-API.patch b/patches/api/Add-more-Witch-API.patch similarity index 100% rename from patches/api-unmapped/Add-more-Witch-API.patch rename to patches/api/Add-more-Witch-API.patch diff --git a/patches/api-unmapped/Add-spectator-target-events.patch b/patches/api/Add-spectator-target-events.patch similarity index 100% rename from patches/api-unmapped/Add-spectator-target-events.patch rename to patches/api/Add-spectator-target-events.patch diff --git a/patches/api-unmapped/Add-sun-related-API.patch b/patches/api/Add-sun-related-API.patch similarity index 100% rename from patches/api-unmapped/Add-sun-related-API.patch rename to patches/api/Add-sun-related-API.patch diff --git a/patches/api-unmapped/Here-s-Johnny.patch b/patches/api/Here-s-Johnny.patch similarity index 100% rename from patches/api-unmapped/Here-s-Johnny.patch rename to patches/api/Here-s-Johnny.patch diff --git a/patches/api-unmapped/Material-API-additions.patch b/patches/api/Material-API-additions.patch similarity index 100% rename from patches/api-unmapped/Material-API-additions.patch rename to patches/api/Material-API-additions.patch diff --git a/patches/api-unmapped/Turtle-API.patch b/patches/api/Turtle-API.patch similarity index 100% rename from patches/api-unmapped/Turtle-API.patch rename to patches/api/Turtle-API.patch diff --git a/patches/server-remapped/Add-LivingEntity-getTargetEntity.patch b/patches/server-remapped/Add-LivingEntity-getTargetEntity.patch deleted file mode 100644 index 12979a1fd..000000000 --- a/patches/server-remapped/Add-LivingEntity-getTargetEntity.patch +++ /dev/null @@ -1,187 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: BillyGalbreath -Date: Sat, 22 Sep 2018 00:33:08 -0500 -Subject: [PATCH] Add LivingEntity#getTargetEntity - - -diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/entity/Entity.java -+++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, CommandSource, net.minecraft.s - return this.calculateViewVector(pitch - 90.0F, yaw); - } - -+ public final Vec3 getEyePosition(float partialTicks) { return getEyePosition(partialTicks); } // Paper - OBFHELPER - public final Vec3 getEyePosition(float tickDelta) { - if (tickDelta == 1.0F) { - return new Vec3(this.getX(), this.getEyeY(), this.getZ()); -@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, CommandSource, net.minecraft.s - return this.getPassengers().size() < 1; - } - -+ public final float getCollisionBorderSize() { return getPickRadius(); } // Paper - OBFHELPER - public float getPickRadius() { - return 0.0F; - } -diff --git a/src/main/java/net/minecraft/world/entity/EntitySelector.java b/src/main/java/net/minecraft/world/entity/EntitySelector.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/entity/EntitySelector.java -+++ b/src/main/java/net/minecraft/world/entity/EntitySelector.java -@@ -0,0 +0,0 @@ public final class EntitySelector { - public static final Predicate NO_CREATIVE_OR_SPECTATOR = (entity) -> { - return !(entity instanceof Player) || !entity.isSpectator() && !((Player) entity).isCreative(); - }; -+ public static Predicate canAITarget() { return ATTACK_ALLOWED; } // Paper - OBFHELPER - public static final Predicate ATTACK_ALLOWED = (entity) -> { - return !(entity instanceof Player) || !entity.isSpectator() && !((Player) entity).isCreative() && entity.level.getDifficulty() != Difficulty.PEACEFUL; - }; -diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/entity/LivingEntity.java -+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java -@@ -0,0 +0,0 @@ import net.minecraft.world.level.storage.loot.LootTable; - import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets; - import net.minecraft.world.level.storage.loot.parameters.LootContextParams; - import net.minecraft.world.phys.AABB; -+import net.minecraft.world.phys.EntityHitResult; - import net.minecraft.world.phys.HitResult; - import net.minecraft.world.phys.Vec3; - import net.minecraft.world.scores.PlayerTeam; -@@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity { - return level.clip(raytrace); - } - -+ public EntityHitResult getTargetEntity(int maxDistance) { -+ if (maxDistance < 1 || maxDistance > 120) { -+ throw new IllegalArgumentException("maxDistance must be between 1-120"); -+ } -+ -+ Vec3 start = this.getEyePosition(1.0F); -+ Vec3 direction = this.getLookAngle(); -+ Vec3 end = start.add(direction.x * maxDistance, direction.y * maxDistance, direction.z * maxDistance); -+ -+ List entityList = level.getEntities(this, getBoundingBox().expand(direction.x * maxDistance, direction.y * maxDistance, direction.z * maxDistance).inflate(1.0D, 1.0D, 1.0D), EntitySelector.canAITarget().and(Entity::isPickable)); -+ -+ double distance = 0.0D; -+ EntityHitResult result = null; -+ -+ for (Entity entity : entityList) { -+ AABB aabb = entity.getBoundingBox().grow((double) entity.getCollisionBorderSize()); -+ Optional rayTraceResult = aabb.calculateIntercept(start, end); -+ -+ if (rayTraceResult.isPresent()) { -+ Vec3 rayTrace = rayTraceResult.get(); -+ double distanceTo = start.distanceToSqr(rayTrace); -+ if (distanceTo < distance || distance == 0.0D) { -+ result = new EntityHitResult(entity, rayTrace); -+ distance = distanceTo; -+ } -+ } -+ } -+ -+ return result; -+ } -+ - public int shieldBlockingDelay = level.paperConfig.shieldBlockingDelay; - - public int getShieldBlockingDelay() { -diff --git a/src/main/java/net/minecraft/world/phys/AABB.java b/src/main/java/net/minecraft/world/phys/AABB.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/phys/AABB.java -+++ b/src/main/java/net/minecraft/world/phys/AABB.java -@@ -0,0 +0,0 @@ public class AABB { - return this.expandTowards(scale.x, scale.y, scale.z); - } - -+ public final AABB expand(double x, double y, double z) { return expandTowards(x, y, z); } // Paper - OBFHELPER - public AABB expandTowards(double x, double y, double z) { - double d3 = this.minX; - double d4 = this.minY; -@@ -0,0 +0,0 @@ public class AABB { - return new AABB(d3, d4, d5, d6, d7, d8); - } - -+ // Paper start -+ public AABB grow(double d0) { -+ return inflate(d0, d0, d0); -+ } -+ // Paper end -+ - public AABB inflate(double x, double y, double z) { - double d3 = this.minX - x; - double d4 = this.minY - y; -@@ -0,0 +0,0 @@ public class AABB { - return this.minX < maxX && this.maxX > minX && this.minY < maxY && this.maxY > minY && this.minZ < maxZ && this.maxZ > minZ; - } - -+ public final boolean contains(Vec3 vec3d) { return contains(vec3d); } // Paper - OBFHELPER - public boolean contains(Vec3 vec) { - return this.contains(vec.x, vec.y, vec.z); - } -@@ -0,0 +0,0 @@ public class AABB { - return this.inflate(-value); - } - -+ public final Optional calculateIntercept(Vec3 vec3d, Vec3 vec3d1) { return clip(vec3d, vec3d1); } // Paper - OBFHELPER - public Optional clip(Vec3 min, Vec3 max) { - double[] adouble = new double[]{1.0D}; - double d0 = max.x - min.x; -diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java -+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java -@@ -0,0 +0,0 @@ - package org.bukkit.craftbukkit.entity; - - import com.destroystokyo.paper.block.TargetBlockInfo; -+import com.destroystokyo.paper.entity.TargetEntityInfo; - import com.google.common.base.Preconditions; - import com.google.common.collect.Sets; - import java.util.ArrayList; -@@ -0,0 +0,0 @@ import net.minecraft.world.entity.projectile.ThrownEgg; - import net.minecraft.world.entity.projectile.ThrownEnderpearl; - import net.minecraft.world.entity.projectile.ThrownExperienceBottle; - import net.minecraft.world.entity.projectile.ThrownTrident; -+import net.minecraft.world.level.ClipContext; - import net.minecraft.world.phys.BlockHitResult; -+import net.minecraft.world.phys.EntityHitResult; - import net.minecraft.world.phys.HitResult; -+import net.minecraft.world.phys.Vec3; - import org.apache.commons.lang.Validate; - import org.bukkit.FluidCollisionMode; - import org.bukkit.Location; -@@ -0,0 +0,0 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { - new TargetBlockInfo(CraftBlock.at(getHandle().level, ((BlockHitResult)rayTrace).getBlockPos()), - MCUtil.toBukkitBlockFace(((BlockHitResult)rayTrace).getDirection())); - } -+ -+ public Entity getTargetEntity(int maxDistance, boolean ignoreBlocks) { -+ EntityHitResult rayTrace = rayTraceEntity(maxDistance, ignoreBlocks); -+ return rayTrace == null ? null : rayTrace.getEntity().getBukkitEntity(); -+ } -+ -+ public TargetEntityInfo getTargetEntityInfo(int maxDistance, boolean ignoreBlocks) { -+ EntityHitResult rayTrace = rayTraceEntity(maxDistance, ignoreBlocks); -+ return rayTrace == null ? null : new TargetEntityInfo(rayTrace.getEntity().getBukkitEntity(), new org.bukkit.util.Vector(rayTrace.getLocation().x, rayTrace.getLocation().y, rayTrace.getLocation().z)); -+ } -+ -+ public EntityHitResult rayTraceEntity(int maxDistance, boolean ignoreBlocks) { -+ EntityHitResult rayTrace = getHandle().getTargetEntity(maxDistance); -+ if (rayTrace == null) { -+ return null; -+ } -+ if (!ignoreBlocks) { -+ HitResult rayTraceBlocks = getHandle().getRayTrace(maxDistance, ClipContext.Fluid.NONE); -+ if (rayTraceBlocks != null) { -+ Vec3 eye = getHandle().getEyePosition(1.0F); -+ if (eye.distanceToSqr(rayTraceBlocks.getLocation()) <= eye.distanceToSqr(rayTrace.getLocation())) { -+ return null; -+ } -+ } -+ } -+ return rayTrace; -+ } - // Paper end - - @Override diff --git a/patches/server-remapped/PreSpawnerSpawnEvent.patch b/patches/server-remapped/PreSpawnerSpawnEvent.patch deleted file mode 100644 index 2a8d90d78..000000000 --- a/patches/server-remapped/PreSpawnerSpawnEvent.patch +++ /dev/null @@ -1,29 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Phoenix616 -Date: Tue, 18 Sep 2018 23:53:23 +0100 -Subject: [PATCH] PreSpawnerSpawnEvent - -This adds a separate event before an entity is spawned by a spawner -which contains the location of the spawner too similarly to how the -SpawnerSpawnEvent gets called instead of the CreatureSpawnEvent for -spawners. - -diff --git a/src/main/java/net/minecraft/world/level/BaseSpawner.java b/src/main/java/net/minecraft/world/level/BaseSpawner.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/level/BaseSpawner.java -+++ b/src/main/java/net/minecraft/world/level/BaseSpawner.java -@@ -0,0 +0,0 @@ public abstract class BaseSpawner { - - org.bukkit.entity.EntityType type = org.bukkit.entity.EntityType.fromName(key); - if (type != null) { -- com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent event; -- event = new com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent( -+ com.destroystokyo.paper.event.entity.PreSpawnerSpawnEvent event; -+ event = new com.destroystokyo.paper.event.entity.PreSpawnerSpawnEvent( - MCUtil.toLocation(world, d3, d4, d5), - type, -- org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER -+ MCUtil.toLocation(world, blockposition) - ); - if (!event.callEvent()) { - flag = true; diff --git a/patches/server/Add-LivingEntity-getTargetEntity.patch b/patches/server/Add-LivingEntity-getTargetEntity.patch new file mode 100644 index 000000000..7519459f0 --- /dev/null +++ b/patches/server/Add-LivingEntity-getTargetEntity.patch @@ -0,0 +1,114 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: BillyGalbreath +Date: Sat, 22 Sep 2018 00:33:08 -0500 +Subject: [PATCH] Add LivingEntity#getTargetEntity + + +diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/entity/Entity.java ++++ b/src/main/java/net/minecraft/world/entity/Entity.java +@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n + this.setYHeadRot(yaw); + } + ++ public final float getCollisionBorderSize() { return getPickRadius(); } // Paper - OBFHELPER + public float getPickRadius() { + return 0.0F; + } +diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java ++++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java +@@ -0,0 +0,0 @@ import net.minecraft.world.level.storage.loot.LootTable; + import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets; + import net.minecraft.world.level.storage.loot.parameters.LootContextParams; + import net.minecraft.world.phys.AABB; ++import net.minecraft.world.phys.EntityHitResult; + import net.minecraft.world.phys.HitResult; + import net.minecraft.world.phys.Vec3; + import net.minecraft.world.scores.PlayerTeam; +@@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity { + return level.clip(raytrace); + } + ++ public EntityHitResult getTargetEntity(int maxDistance) { ++ if (maxDistance < 1 || maxDistance > 120) { ++ throw new IllegalArgumentException("maxDistance must be between 1-120"); ++ } ++ ++ Vec3 start = this.getEyePosition(1.0F); ++ Vec3 direction = this.getLookAngle(); ++ Vec3 end = start.add(direction.x * maxDistance, direction.y * maxDistance, direction.z * maxDistance); ++ ++ List entityList = level.getEntities(this, getBoundingBox().expandTowards(direction.x * maxDistance, direction.y * maxDistance, direction.z * maxDistance).inflate(1.0D, 1.0D, 1.0D), EntitySelector.NO_CREATIVE_OR_SPECTATOR.and(Entity::isPickable)); ++ ++ double distance = 0.0D; ++ EntityHitResult result = null; ++ ++ for (Entity entity : entityList) { ++ final double inflationAmount = (double) entity.getCollisionBorderSize(); ++ AABB aabb = entity.getBoundingBox().inflate(inflationAmount, inflationAmount, inflationAmount); ++ Optional rayTraceResult = aabb.clip(start, end); ++ ++ if (rayTraceResult.isPresent()) { ++ Vec3 rayTrace = rayTraceResult.get(); ++ double distanceTo = start.distanceToSqr(rayTrace); ++ if (distanceTo < distance || distance == 0.0D) { ++ result = new EntityHitResult(entity, rayTrace); ++ distance = distanceTo; ++ } ++ } ++ } ++ ++ return result; ++ } ++ + public int shieldBlockingDelay = level.paperConfig.shieldBlockingDelay; + + public int getShieldBlockingDelay() { +diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +@@ -0,0 +0,0 @@ + package org.bukkit.craftbukkit.entity; + ++import com.destroystokyo.paper.entity.TargetEntityInfo; + import com.google.common.base.Preconditions; + import com.google.common.collect.Sets; + import java.util.ArrayList; +@@ -0,0 +0,0 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { + new com.destroystokyo.paper.block.TargetBlockInfo(org.bukkit.craftbukkit.block.CraftBlock.at(getHandle().level, ((net.minecraft.world.phys.BlockHitResult)rayTrace).getBlockPos()), + net.minecraft.server.MCUtil.toBukkitBlockFace(((net.minecraft.world.phys.BlockHitResult)rayTrace).getDirection())); + } ++ ++ public Entity getTargetEntity(int maxDistance, boolean ignoreBlocks) { ++ net.minecraft.world.phys.EntityHitResult rayTrace = rayTraceEntity(maxDistance, ignoreBlocks); ++ return rayTrace == null ? null : rayTrace.getEntity().getBukkitEntity(); ++ } ++ ++ public TargetEntityInfo getTargetEntityInfo(int maxDistance, boolean ignoreBlocks) { ++ net.minecraft.world.phys.EntityHitResult rayTrace = rayTraceEntity(maxDistance, ignoreBlocks); ++ return rayTrace == null ? null : new TargetEntityInfo(rayTrace.getEntity().getBukkitEntity(), new org.bukkit.util.Vector(rayTrace.getLocation().x, rayTrace.getLocation().y, rayTrace.getLocation().z)); ++ } ++ ++ public net.minecraft.world.phys.EntityHitResult rayTraceEntity(int maxDistance, boolean ignoreBlocks) { ++ net.minecraft.world.phys.EntityHitResult rayTrace = getHandle().getTargetEntity(maxDistance); ++ if (rayTrace == null) { ++ return null; ++ } ++ if (!ignoreBlocks) { ++ net.minecraft.world.phys.HitResult rayTraceBlocks = getHandle().getRayTrace(maxDistance, net.minecraft.world.level.ClipContext.Fluid.NONE); ++ if (rayTraceBlocks != null) { ++ net.minecraft.world.phys.Vec3 eye = getHandle().getEyePosition(1.0F); ++ if (eye.distanceToSqr(rayTraceBlocks.getLocation()) <= eye.distanceToSqr(rayTrace.getLocation())) { ++ return null; ++ } ++ } ++ } ++ return rayTrace; ++ } + // Paper end + + @Override diff --git a/patches/server-remapped/Add-Velocity-IP-Forwarding-Support.patch b/patches/server/Add-Velocity-IP-Forwarding-Support.patch similarity index 69% rename from patches/server-remapped/Add-Velocity-IP-Forwarding-Support.patch rename to patches/server/Add-Velocity-IP-Forwarding-Support.patch index cca0aaa43..f08ebe2e7 100644 --- a/patches/server-remapped/Add-Velocity-IP-Forwarding-Support.patch +++ b/patches/server/Add-Velocity-IP-Forwarding-Support.patch @@ -35,10 +35,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public static int packetInSpamThreshold = 300; @@ -0,0 +0,0 @@ public class PaperConfig { - } tabSpamLimit = getInt("settings.spam-limiter.tab-spam-limit", tabSpamLimit); } -+ + + public static boolean velocitySupport; + public static boolean velocityOnlineMode; + public static byte[] velocitySecretKey; @@ -52,7 +51,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + velocitySecretKey = secret.getBytes(StandardCharsets.UTF_8); + } + } - } ++ + public static boolean asyncChunks = false; + private static void asyncChunks() { + ConfigurationSection section; diff --git a/src/main/java/com/destroystokyo/paper/proxy/VelocityProxy.java b/src/main/java/com/destroystokyo/paper/proxy/VelocityProxy.java new file mode 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 @@ -106,11 +108,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + public static InetAddress readAddress(final FriendlyByteBuf buf) { -+ return InetAddresses.forString(buf.readUTF(Short.MAX_VALUE)); ++ return InetAddresses.forString(buf.readUtf(Short.MAX_VALUE)); + } + + public static GameProfile createProfile(final FriendlyByteBuf buf) { -+ final GameProfile profile = new GameProfile(buf.readUUID(), buf.readUTF(16)); ++ final GameProfile profile = new GameProfile(buf.readUUID(), buf.readUtf(16)); + readProperties(buf, profile); + return profile; + } @@ -118,75 +120,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + private static void readProperties(final FriendlyByteBuf buf, final GameProfile profile) { + final int properties = buf.readVarInt(); + for (int i1 = 0; i1 < properties; i1++) { -+ final String name = buf.readUTF(Short.MAX_VALUE); -+ final String value = buf.readUTF(Short.MAX_VALUE); -+ final String signature = buf.readBoolean() ? buf.readUTF(Short.MAX_VALUE) : null; ++ final String name = buf.readUtf(Short.MAX_VALUE); ++ final String value = buf.readUtf(Short.MAX_VALUE); ++ final String signature = buf.readBoolean() ? buf.readUtf(Short.MAX_VALUE) : null; + profile.getProperties().put(name, new Property(name, value, signature)); + } + } +} -diff --git a/src/main/java/net/minecraft/network/FriendlyByteBuf.java b/src/main/java/net/minecraft/network/FriendlyByteBuf.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/network/FriendlyByteBuf.java -+++ b/src/main/java/net/minecraft/network/FriendlyByteBuf.java -@@ -0,0 +0,0 @@ public class FriendlyByteBuf extends ByteBuf { - return this.writeVarInt(oenum.ordinal()); - } - -+ public int readVarInt() { return readVarInt(); } // Paper - OBFHELPER - public int readVarInt() { - int i = 0; - int j = 0; -@@ -0,0 +0,0 @@ public class FriendlyByteBuf extends ByteBuf { - return this; - } - -+ public UUID readUUID() { return readUUID(); } // Paper - OBFHELPER - public UUID readUUID() { - return new UUID(this.readLong(), this.readLong()); - } -@@ -0,0 +0,0 @@ public class FriendlyByteBuf extends ByteBuf { - } - } - -+ public String readUTF(int maxLength) { return this.readUtf(maxLength); } // Paper - OBFHELPER - public String readUtf(int i) { - int j = this.readVarInt(); - -diff --git a/src/main/java/net/minecraft/network/protocol/login/ClientboundCustomQueryPacket.java b/src/main/java/net/minecraft/network/protocol/login/ClientboundCustomQueryPacket.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/network/protocol/login/ClientboundCustomQueryPacket.java -+++ b/src/main/java/net/minecraft/network/protocol/login/ClientboundCustomQueryPacket.java -@@ -0,0 +0,0 @@ public class ClientboundCustomQueryPacket implements Packet { - -- private int transactionId; -- private FriendlyByteBuf data; -+ private int transactionId; public int getId() { return transactionId; } // Paper - OBFHELPER -+ private FriendlyByteBuf data; public FriendlyByteBuf getBuf() { return data; } // Paper - OBFHELPER - - public ServerboundCustomQueryPacket() {} - diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java @@ -199,10 +139,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 import net.minecraft.network.chat.Component; import net.minecraft.network.chat.TextComponent; import net.minecraft.network.chat.TranslatableComponent; -+import net.minecraft.network.protocol.login.ClientboundCustomQueryPacket; - import net.minecraft.network.protocol.login.ClientboundGameProfilePacket; - import net.minecraft.network.protocol.login.ClientboundHelloPacket; - import net.minecraft.network.protocol.login.ClientboundLoginCompressionPacket; @@ -0,0 +0,0 @@ import org.bukkit.craftbukkit.util.Waitable; import org.bukkit.event.player.AsyncPlayerPreLoginEvent; import org.bukkit.event.player.PlayerPreLoginEvent; @@ -212,7 +148,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener { @@ -0,0 +0,0 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener - private SecretKey secretKey; + @Nullable private ServerPlayer delayedAcceptPlayer; public String hostname = ""; // CraftBukkit - add field + private int velocityLoginMessageId = -1; // Paper - Velocity support @@ -226,7 +162,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper start - Velocity support + if (com.destroystokyo.paper.PaperConfig.velocitySupport) { + this.velocityLoginMessageId = java.util.concurrent.ThreadLocalRandom.current().nextInt(); -+ ClientboundCustomQueryPacket packet1 = new ClientboundCustomQueryPacket(this.velocityLoginMessageId, com.destroystokyo.paper.proxy.VelocityProxy.PLAYER_INFO_CHANNEL, new FriendlyByteBuf(Unpooled.EMPTY_BUFFER)); ++ net.minecraft.network.protocol.login.ClientboundCustomQueryPacket packet1 = new net.minecraft.network.protocol.login.ClientboundCustomQueryPacket(this.velocityLoginMessageId, com.destroystokyo.paper.proxy.VelocityProxy.PLAYER_INFO_CHANNEL, new FriendlyByteBuf(Unpooled.EMPTY_BUFFER)); + this.connection.send(packet1); + return; + } @@ -238,22 +174,22 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public class LoginHandler { public void fireEvents() throws Exception { -+ // Paper start - Velocity support -+ if (ServerLoginPacketListenerImpl.this.velocityLoginMessageId == -1 && com.destroystokyo.paper.PaperConfig.velocitySupport) { -+ disconnect("This server requires you to connect with Velocity."); -+ return; -+ } -+ // Paper end - String playerName = gameProfile.getName(); - java.net.InetAddress address = ((java.net.InetSocketAddress) connection.getRemoteAddress()).getAddress(); - java.util.UUID uniqueId = gameProfile.getId(); ++ // Paper start - Velocity support ++ if (ServerLoginPacketListenerImpl.this.velocityLoginMessageId == -1 && com.destroystokyo.paper.PaperConfig.velocitySupport) { ++ disconnect("This server requires you to connect with Velocity."); ++ return; ++ } ++ // Paper end + String playerName = ServerLoginPacketListenerImpl.this.gameProfile.getName(); + java.net.InetAddress address = ((java.net.InetSocketAddress) ServerLoginPacketListenerImpl.this.connection.getRemoteAddress()).getAddress(); + java.util.UUID uniqueId = ServerLoginPacketListenerImpl.this.gameProfile.getId(); @@ -0,0 +0,0 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener // Spigot end public void handleCustomQueryPacket(ServerboundCustomQueryPacket packet) { + // Paper start - Velocity support -+ if (com.destroystokyo.paper.PaperConfig.velocitySupport && packet.getId() == this.velocityLoginMessageId) { -+ FriendlyByteBuf buf = packet.getBuf(); ++ if (com.destroystokyo.paper.PaperConfig.velocitySupport && packet.getTransactionId() == this.velocityLoginMessageId) { ++ FriendlyByteBuf buf = packet.getData(); + if (buf == null) { + this.disconnect("This server requires you to connect with Velocity."); + return; @@ -271,7 +207,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + this.connection.address = new java.net.InetSocketAddress(com.destroystokyo.paper.proxy.VelocityProxy.readAddress(buf), port); + -+ this.setGameProfile(com.destroystokyo.paper.proxy.VelocityProxy.createProfile(buf)); ++ this.gameProfile = com.destroystokyo.paper.proxy.VelocityProxy.createProfile(buf); + + // Proceed with login + authenticatorPool.execute(() -> { diff --git a/patches/server-remapped/Add-more-Witch-API.patch b/patches/server/Add-more-Witch-API.patch similarity index 92% rename from patches/server-remapped/Add-more-Witch-API.patch rename to patches/server/Add-more-Witch-API.patch index 613c2d955..91b6d014b 100644 --- a/patches/server-remapped/Add-more-Witch-API.patch +++ b/patches/server/Add-more-Witch-API.patch @@ -26,19 +26,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 private NearestHealableRaiderTargetGoal healRaidersGoal; private NearestAttackableWitchTargetGoal attackPlayersGoal; -@@ -0,0 +0,0 @@ public class Witch extends Raider implements RangedAttackMob { - return SoundEvents.WITCH_DEATH; - } - -+ public void setDrinkingPotion(boolean drinkingPotion) { setUsingItem(drinkingPotion); } // Paper - OBFHELPER - public void setUsingItem(boolean drinking) { - this.getEntityData().set(Witch.DATA_USING_ITEM, drinking); - } - -+ public boolean isDrinkingPotion() { return isDrinkingPotion(); } // Paper - OBFHELPER - public boolean isDrinkingPotion() { - return (Boolean) this.getEntityData().get(Witch.DATA_USING_ITEM); - } @@ -0,0 +0,0 @@ public class Witch extends Raider implements RangedAttackMob { } diff --git a/patches/server-remapped/Add-option-to-prevent-players-from-moving-into-unloa.patch b/patches/server/Add-option-to-prevent-players-from-moving-into-unloa.patch similarity index 76% rename from patches/server-remapped/Add-option-to-prevent-players-from-moving-into-unloa.patch rename to patches/server/Add-option-to-prevent-players-from-moving-into-unloa.patch index 0ed9e9b85..8f6ba0bf6 100644 --- a/patches/server-remapped/Add-option-to-prevent-players-from-moving-into-unloa.patch +++ b/patches/server/Add-option-to-prevent-players-from-moving-into-unloa.patch @@ -23,7 +23,7 @@ diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListener index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener { +@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser } speed *= 2f; // TODO: Get the speed of the vehicle instead of the player @@ -37,25 +37,25 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (d10 - d9 > Math.max(100.0D, Math.pow((double) (org.spigotmc.SpigotConfig.movedTooQuicklyMultiplier * (float) i * speed), 2)) && !this.isSingleplayerOwner()) { // CraftBukkit end ServerGamePacketListenerImpl.LOGGER.warn("{} (vehicle of {}) moved too quickly! {},{},{}", entity.getName().getString(), this.player.getName().getString(), d6, d7, d8); -@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener { - double d1 = this.player.getY(); - double d2 = this.player.getZ(); - double d3 = this.player.getY(); -- double d4 = packet.getX(this.player.getX()); -+ double d4 = packet.getX(this.player.getX());double toX = d4; // Paper - OBFHELPER - double d5 = packet.getY(this.player.getY()); -- double d6 = packet.getZ(this.player.getZ()); -+ double d6 = packet.getZ(this.player.getZ());double toZ = d6; // Paper - OBFHELPER - float f = packet.getYRot(this.player.yRot); - float f1 = packet.getXRot(this.player.xRot); - double d7 = d4 - this.firstGoodX; -@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener { +@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser + float prevYaw = this.player.getYRot(); + float prevPitch = this.player.getXRot(); + // CraftBukkit end +- double d3 = this.player.getX(); ++ double d3 = this.player.getX(); final double toX = d3; // Paper - OBFHELPER + double d4 = this.player.getY(); +- double d5 = this.player.getZ(); ++ double d5 = this.player.getZ(); final double toZ = d5; // Paper - OBFHELPER + double d6 = this.player.getY(); + double d7 = d0 - this.firstGoodX; + double d8 = d1 - this.firstGoodY; +@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser } else { - speed = player.abilities.walkingSpeed * 10f; + speed = this.player.getAbilities().walkingSpeed * 10f; } + // Paper start - Prevent moving into unloaded chunks + if (player.level.paperConfig.preventMovingIntoUnloadedChunks && (this.player.getX() != toX || this.player.getZ() != toZ) && !worldserver.hasChunk((int) Math.floor(toX) >> 4, (int) Math.floor(toZ) >> 4)) { -+ this.internalTeleport(this.player.getX(), this.player.getY(), this.player.getZ(), this.player.yRot, this.player.xRot, Collections.emptySet()); ++ this.internalTeleport(this.player.getX(), this.player.getY(), this.player.getZ(), this.player.getYRot(), this.player.getXRot(), Collections.emptySet(), true); + return; + } + // Paper end diff --git a/patches/server-remapped/Add-sun-related-API.patch b/patches/server/Add-sun-related-API.patch similarity index 86% rename from patches/server-remapped/Add-sun-related-API.patch rename to patches/server/Add-sun-related-API.patch index 73d19f3d9..dfb99a732 100644 --- a/patches/server-remapped/Add-sun-related-API.patch +++ b/patches/server/Add-sun-related-API.patch @@ -12,10 +12,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } -+ public boolean isInDaylight() { return this.isSunBurnTick(); } // Paper - OBFHELPER - protected boolean isSunBurnTick() { +- protected boolean isSunBurnTick() { ++ public boolean isSunBurnTick() { // Paper - protected -> public if (this.level.isDay() && !this.level.isClientSide) { float f = this.getBrightness(); + BlockPos blockposition = new BlockPos(this.getX(), this.getEyeY(), this.getZ()); diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -40,13 +41,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java @@ -0,0 +0,0 @@ public abstract class CraftMob extends CraftLivingEntity implements Mob { public long getSeed() { - return getHandle().lootTableSeed; + return this.getHandle().lootTableSeed; } + + // Paper start + @Override + public boolean isInDaylight() { -+ return getHandle().isInDaylight(); ++ return getHandle().isSunBurnTick(); + } + // Paper end } diff --git a/patches/server-remapped/Call-player-spectator-target-events-and-improve-impl.patch b/patches/server/Call-player-spectator-target-events-and-improve-impl.patch similarity index 78% rename from patches/server-remapped/Call-player-spectator-target-events-and-improve-impl.patch rename to patches/server/Call-player-spectator-target-events-and-improve-impl.patch index b97ef1d13..3f6f685f4 100644 --- a/patches/server-remapped/Call-player-spectator-target-events-and-improve-impl.patch +++ b/patches/server/Call-player-spectator-target-events-and-improve-impl.patch @@ -22,7 +22,7 @@ diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/ma index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java -@@ -0,0 +0,0 @@ public class ServerPlayer extends Player implements ContainerListener { +@@ -0,0 +0,0 @@ public class ServerPlayer extends Player { } public void setCamera(Entity entity) { @@ -32,7 +32,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - this.camera = (Entity) (entity == null ? this : entity); - if (entity1 != this.camera) { - this.connection.send(new ClientboundSetCameraPacket(this.camera)); -- this.connection.a(this.camera.getX(), this.camera.getY(), this.camera.getZ(), this.yRot, this.xRot, TeleportCause.SPECTATE); // CraftBukkit +- this.connection.b(this.camera.getX(), this.camera.getY(), this.camera.getZ(), this.getYRot(), this.getXRot(), TeleportCause.SPECTATE); // CraftBukkit + if (entity == null) { + entity = this; } @@ -54,7 +54,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + // Validate + if (entity != this) { -+ if (entity.removed || entity.shouldBeRemoved || !entity.valid || entity.level == null) { ++ if (entity.isRemoved() || !entity.valid || entity.level == null) { + MinecraftServer.LOGGER.info("Blocking player " + this.toString() + " from spectating invalid entity " + entity.toString()); + return; + } @@ -70,7 +70,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + if (entity != this) { + // Make sure we're in the right place + this.ejectPassengers(); // teleport can fail if we have passengers... -+ this.getBukkitEntity().teleport(new Location(entity.getCommandSenderWorld().getWorld(), entity.getX(), entity.getY(), entity.getZ(), this.yRot, this.xRot), TeleportCause.SPECTATE); // Correctly handle cross-world entities from api calls by using CB teleport ++ this.getBukkitEntity().teleport(new Location(entity.getCommandSenderWorld().getWorld(), entity.getX(), entity.getY(), entity.getZ(), this.getYRot(), this.getXRot()), TeleportCause.SPECTATE); // Correctly handle cross-world entities from api calls by using CB teleport + + // Make sure we're tracking the entity before sending + ChunkMap.TrackedEntity tracker = ((ServerLevel)entity.level).getChunkSource().chunkMap.entityMap.get(entity.getId()); @@ -78,7 +78,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + tracker.updatePlayer(this); + } + } else { -+ this.connection.teleport(this.camera.getX(), this.camera.getY(), this.camera.getZ(), this.yRot, this.xRot, TeleportCause.SPECTATE); // CraftBukkit ++ this.connection.teleport(this.camera.getX(), this.camera.getY(), this.camera.getZ(), this.getYRot(), this.getXRot(), TeleportCause.SPECTATE); // CraftBukkit + } + this.connection.send(new ClientboundSetCameraPacket(entity)); + // Paper end @@ -89,11 +89,20 @@ diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListener index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener { +@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser + } + } + +- private void a(List list, UnaryOperator unaryoperator, ItemStack itemstack, int slot, ItemStack old) { // CraftBukkit ++ public void a(List list, UnaryOperator unaryoperator, ItemStack itemstack, int slot, ItemStack old) { // CraftBukkit // Paper - make public + ListTag nbttaglist = new ListTag(); + + if (this.player.isTextFilteringEnabled()) { +@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser + this.a(x, y, z, yaw, pitch, PlayerTeleportEvent.TeleportCause.UNKNOWN); } - // CraftBukkit start - Delegate to teleport(Location) + public final void teleport(double d0, double d1, double d2, float f, float f1, PlayerTeleportEvent.TeleportCause cause) { this.a(d0, d1, d2, f, f1, cause); } // Paper - OBFHELPER public void a(double d0, double d1, double d2, float f, float f1, PlayerTeleportEvent.TeleportCause cause) { - this.a(d0, d1, d2, f, f1, Collections.emptySet(), cause); + this.a(d0, d1, d2, f, f1, Collections.emptySet(), true, cause); } diff --git a/patches/server-remapped/Catch-JsonParseException-in-Entity-and-TE-names.patch b/patches/server/Catch-JsonParseException-in-Entity-and-TE-names.patch similarity index 81% rename from patches/server-remapped/Catch-JsonParseException-in-Entity-and-TE-names.patch rename to patches/server/Catch-JsonParseException-in-Entity-and-TE-names.patch index ee939bed9..718729a93 100644 --- a/patches/server-remapped/Catch-JsonParseException-in-Entity-and-TE-names.patch +++ b/patches/server/Catch-JsonParseException-in-Entity-and-TE-names.patch @@ -26,10 +26,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 import net.minecraft.world.entity.Entity; import net.minecraft.world.level.ChunkPos; @@ -0,0 +0,0 @@ public final class MCUtil { - return null; } } -+ + + @Nullable + public static Component getBaseComponentFromNbt(String key, CompoundTag compound) { + if (!compound.contains(key)) { @@ -44,7 +43,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + return null; + } - } ++ + public static int getTicketLevelFor(net.minecraft.world.level.chunk.ChunkStatus status) { + return net.minecraft.server.level.ChunkMap.MAX_VIEW_DISTANCE + net.minecraft.world.level.chunk.ChunkStatus.getDistance(status); + } diff --git a/src/main/java/net/minecraft/world/level/BaseCommandBlock.java b/src/main/java/net/minecraft/world/level/BaseCommandBlock.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/BaseCommandBlock.java @@ -58,14 +60,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 import net.minecraft.server.level.ServerLevel; import net.minecraft.util.StringUtil; @@ -0,0 +0,0 @@ public abstract class BaseCommandBlock implements CommandSource { - this.command = tag.getString("Command"); - this.successCount = tag.getInt("SuccessCount"); - if (tag.contains("CustomName", 8)) { -- this.setName(Component.Serializer.fromJson(tag.getString("CustomName"))); -+ this.setName(MCUtil.getBaseComponentFromNbt("CustomName", tag)); // Paper - Catch ParseException + this.command = nbt.getString("Command"); + this.successCount = nbt.getInt("SuccessCount"); + if (nbt.contains("CustomName", 8)) { +- this.setName(Component.Serializer.fromJson(nbt.getString("CustomName"))); ++ this.setName(MCUtil.getBaseComponentFromNbt("CustomName", nbt)); // Paper - Catch ParseException } - if (tag.contains("TrackOutput", 1)) { + if (nbt.contains("TrackOutput", 1)) { diff --git a/src/main/java/net/minecraft/world/level/block/entity/BannerBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BannerBlockEntity.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/BannerBlockEntity.java @@ -79,19 +81,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 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(BlockState state, CompoundTag tag) { - super.load(state, tag); - if (tag.contains("CustomName", 8)) { -- this.name = Component.Serializer.fromJson(tag.getString("CustomName")); -+ this.name = MCUtil.getBaseComponentFromNbt("CustomName", tag); // Paper - Catch ParseException + public void load(CompoundTag nbt) { + super.load(nbt); + if (nbt.contains("CustomName", 8)) { +- this.name = Component.Serializer.fromJson(nbt.getString("CustomName")); ++ this.name = MCUtil.getBaseComponentFromNbt("CustomName", nbt); // Paper - Catch ParseException } - if (this.hasLevel()) { + this.itemPatterns = nbt.getList("Patterns", 10); diff --git a/src/main/java/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java -@@ -0,0 +0,0 @@ import javax.annotation.Nullable; +@@ -0,0 +0,0 @@ import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.TranslatableComponent; @@ -100,11 +102,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 import net.minecraft.sounds.SoundSource; import net.minecraft.world.Container; @@ -0,0 +0,0 @@ public abstract class BaseContainerBlockEntity extends BlockEntity implements Co - super.load(state, tag); - this.lockKey = LockCode.fromTag(tag); - if (tag.contains("CustomName", 8)) { -- this.name = Component.Serializer.fromJson(tag.getString("CustomName")); -+ this.name = MCUtil.getBaseComponentFromNbt("CustomName", tag); // Paper - Catch ParseException + super.load(nbt); + this.lockKey = LockCode.fromTag(nbt); + if (nbt.contains("CustomName", 8)) { +- this.name = Component.Serializer.fromJson(nbt.getString("CustomName")); ++ this.name = MCUtil.getBaseComponentFromNbt("CustomName", nbt); // Paper - Catch ParseException } } diff --git a/patches/server-remapped/Check-Drowned-for-Villager-Aggression-Config.patch b/patches/server/Check-Drowned-for-Villager-Aggression-Config.patch similarity index 78% rename from patches/server-remapped/Check-Drowned-for-Villager-Aggression-Config.patch rename to patches/server/Check-Drowned-for-Villager-Aggression-Config.patch index ae1ca192c..c059c2d3e 100644 --- a/patches/server-remapped/Check-Drowned-for-Villager-Aggression-Config.patch +++ b/patches/server/Check-Drowned-for-Villager-Aggression-Config.patch @@ -10,10 +10,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +++ b/src/main/java/net/minecraft/world/entity/monster/Drowned.java @@ -0,0 +0,0 @@ public class Drowned extends Zombie implements RangedAttackMob { this.goalSelector.addGoal(7, new RandomStrollGoal(this, 1.0D)); - this.targetSelector.addGoal(1, (new HurtByTargetGoal(this, new Class[]{Drowned.class})).setAlertOthers(ZombifiedPiglin.class)); + this.targetSelector.addGoal(1, (new HurtByTargetGoal(this, Drowned.class)).setAlertOthers(ZombifiedPiglin.class)); this.targetSelector.addGoal(2, new NearestAttackableTargetGoal<>(this, Player.class, 10, true, false, this::okTarget)); - this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, AbstractVillager.class, false)); -+ if ( level.spigotConfig.zombieAggressiveTowardsVillager ) this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, AbstractVillager.class, false)); // Paper ++ if (this.level.spigotConfig.zombieAggressiveTowardsVillager) this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, AbstractVillager.class, false)); // Paper this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, IronGolem.class, true)); + this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, Axolotl.class, true, false)); this.targetSelector.addGoal(5, new NearestAttackableTargetGoal<>(this, Turtle.class, 10, true, false, Turtle.BABY_ON_LAND_SELECTOR)); - } diff --git a/patches/server-remapped/Configurable-connection-throttle-kick-message.patch b/patches/server/Configurable-connection-throttle-kick-message.patch similarity index 84% rename from patches/server-remapped/Configurable-connection-throttle-kick-message.patch rename to patches/server/Configurable-connection-throttle-kick-message.patch index dbba8290e..002b5bea1 100644 --- a/patches/server-remapped/Configurable-connection-throttle-kick-message.patch +++ b/patches/server/Configurable-connection-throttle-kick-message.patch @@ -25,9 +25,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java @@ -0,0 +0,0 @@ public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketL - synchronized (throttleTracker) { - if (throttleTracker.containsKey(address) && !"127.0.0.1".equals(address.getHostAddress()) && currentTime - throttleTracker.get(address) < connectionThrottle) { - throttleTracker.put(address, currentTime); + synchronized (ServerHandshakePacketListenerImpl.throttleTracker) { + if (ServerHandshakePacketListenerImpl.throttleTracker.containsKey(address) && !"127.0.0.1".equals(address.getHostAddress()) && currentTime - ServerHandshakePacketListenerImpl.throttleTracker.get(address) < connectionThrottle) { + ServerHandshakePacketListenerImpl.throttleTracker.put(address, currentTime); - TranslatableComponent chatmessage = new TranslatableComponent("Connection throttled! Please wait before reconnecting."); + TranslatableComponent chatmessage = new TranslatableComponent(com.destroystokyo.paper.PaperConfig.connectionThrottleKickMessage); // Paper - Configurable connection throttle kick message this.connection.send(new ClientboundLoginDisconnectPacket(chatmessage)); diff --git a/patches/server-remapped/Here-s-Johnny.patch b/patches/server/Here-s-Johnny.patch similarity index 83% rename from patches/server-remapped/Here-s-Johnny.patch rename to patches/server/Here-s-Johnny.patch index 8b05df0d2..16164fc31 100644 --- a/patches/server-remapped/Here-s-Johnny.patch +++ b/patches/server/Here-s-Johnny.patch @@ -9,11 +9,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/entity/monster/Vindicator.java +++ b/src/main/java/net/minecraft/world/entity/monster/Vindicator.java @@ -0,0 +0,0 @@ public class Vindicator extends AbstractIllager { - private static final Predicate DOOR_BREAKING_PREDICATE = (enumdifficulty) -> { - return enumdifficulty == Difficulty.NORMAL || enumdifficulty == Difficulty.HARD; + static final Predicate DOOR_BREAKING_PREDICATE = (difficulty) -> { + return difficulty == Difficulty.NORMAL || difficulty == Difficulty.HARD; }; -- private boolean isJohnny; -+ private boolean isJohnny; public boolean isJohnny() { return isJohnny; } public void setJohnny(boolean johnny) { isJohnny = johnny; } // Paper - OBFHELPER +- boolean isJohnny; ++ private boolean isJohnny; public boolean isJohnny() { return this.isJohnny; } public void setJohnny(boolean johnny) { this.isJohnny = johnny; } // Paper - OBFHELPER public Vindicator(EntityType type, Level world) { super(type, world); diff --git a/patches/server-remapped/Honor-EntityAgeable.ageLock.patch b/patches/server/Honor-EntityAgeable.ageLock.patch similarity index 58% rename from patches/server-remapped/Honor-EntityAgeable.ageLock.patch rename to patches/server/Honor-EntityAgeable.ageLock.patch index bd4b3e9f0..63591cda0 100644 --- a/patches/server-remapped/Honor-EntityAgeable.ageLock.patch +++ b/patches/server/Honor-EntityAgeable.ageLock.patch @@ -4,11 +4,11 @@ Date: Sun, 23 Sep 2018 20:59:53 -0500 Subject: [PATCH] Honor EntityAgeable.ageLock -diff --git a/src/main/java/net/minecraft/world/entity/AgableMob.java b/src/main/java/net/minecraft/world/entity/AgableMob.java +diff --git a/src/main/java/net/minecraft/world/entity/AgeableMob.java b/src/main/java/net/minecraft/world/entity/AgeableMob.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/entity/AgableMob.java -+++ b/src/main/java/net/minecraft/world/entity/AgableMob.java -@@ -0,0 +0,0 @@ public abstract class AgableMob extends PathfinderMob { +--- a/src/main/java/net/minecraft/world/entity/AgeableMob.java ++++ b/src/main/java/net/minecraft/world/entity/AgeableMob.java +@@ -0,0 +0,0 @@ public abstract class AgeableMob extends PathfinderMob { } public void ageUp(int age, boolean overGrow) { diff --git a/patches/server-remapped/Hook-into-CB-plugin-rewrites.patch b/patches/server/Hook-into-CB-plugin-rewrites.patch similarity index 100% rename from patches/server-remapped/Hook-into-CB-plugin-rewrites.patch rename to patches/server/Hook-into-CB-plugin-rewrites.patch diff --git a/patches/server-remapped/MC-50319-Check-other-worlds-for-shooter-of-projectil.patch b/patches/server/MC-50319-Check-other-worlds-for-shooter-of-projectil.patch similarity index 52% rename from patches/server-remapped/MC-50319-Check-other-worlds-for-shooter-of-projectil.patch rename to patches/server/MC-50319-Check-other-worlds-for-shooter-of-projectil.patch index 1aebe25d1..0807199d0 100644 --- a/patches/server-remapped/MC-50319-Check-other-worlds-for-shooter-of-projectil.patch +++ b/patches/server/MC-50319-Check-other-worlds-for-shooter-of-projectil.patch @@ -15,22 +15,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java +++ b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java @@ -0,0 +0,0 @@ public abstract class Projectile extends Entity { - - @Nullable - public Entity getOwner() { -- return this.ownerUUID != null && this.level instanceof ServerLevel ? ((ServerLevel) this.level).getEntity(this.ownerUUID) : (this.ownerNetworkId != 0 ? this.level.getEntity(this.ownerNetworkId) : null); -+ // Paper start - MC-50319 - shooter might be in another world (arrows through portals) -+ Entity entity = this.ownerUUID != null && this.level instanceof ServerLevel ? ((ServerLevel) this.level).getEntity(this.ownerUUID) : (this.ownerNetworkId != 0 ? this.level.getEntity(this.ownerNetworkId) : null); -+ if (entity == null) { -+ for (ServerLevel world : level.getServer().getAllLevels()) { -+ entity = world.getEntity(this.ownerUUID); -+ if (entity != null) { -+ break; + return this.cachedOwner; + } else if (this.ownerUUID != null && this.level instanceof ServerLevel) { + this.cachedOwner = ((ServerLevel) this.level).getEntity(this.ownerUUID); ++ // Paper start - check all worlds ++ if (this.cachedOwner == null) { ++ for (final ServerLevel level : this.level.getServer().getAllLevels()) { ++ if (level == this.level) continue; ++ final Entity entity = level.getEntity(this.ownerUUID); ++ if (entity != null) { ++ this.cachedOwner = entity; ++ break; ++ } + } + } -+ } -+ return entity; -+ // Paper end - } - - @Override ++ // Paper end + return this.cachedOwner; + } else { + return null; diff --git a/patches/server-remapped/Turtle-API.patch b/patches/server/Turtle-API.patch similarity index 80% rename from patches/server-remapped/Turtle-API.patch rename to patches/server/Turtle-API.patch index 3fe5fb9a7..b93acd3ff 100644 --- a/patches/server-remapped/Turtle-API.patch +++ b/patches/server/Turtle-API.patch @@ -12,8 +12,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 protected int nextStartTick; protected int tryTicks; private int maxStayTicks; -- protected BlockPos blockPos; -+ protected BlockPos blockPos;public final BlockPos getTargetPosition() { return this.blockPos; } // Paper - OBFHELPER +- protected BlockPos blockPos = BlockPos.ZERO; ++ protected BlockPos blockPos = BlockPos.ZERO; public final BlockPos getTargetPosition() { return this.blockPos; } // Paper - OBFHELPER private boolean reachedTarget; private final int searchRange; private final int verticalSearchRange; @@ -33,7 +33,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 this.entityData.set(Turtle.HOME_POS, pos); } -- private BlockPos getHomePos() { +- BlockPos getHomePos() { + public BlockPos getHomePos() { // Paper - public return (BlockPos) this.entityData.get(Turtle.HOME_POS); } @@ -42,47 +42,41 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 return (Boolean) this.entityData.get(Turtle.HAS_EGG); } -- private void setHasEgg(boolean hasEgg) { +- void setHasEgg(boolean hasEgg) { + public void setHasEgg(boolean hasEgg) { // Paper this.entityData.set(Turtle.HAS_EGG, hasEgg); } -+ public final boolean isDigging() { return this.isLayingEgg(); } // Paper - OBFHELPER - public boolean isLayingEgg() { - return (Boolean) this.entityData.get(Turtle.LAYING_EGG); - } - -+ public final void setDigging(boolean digging) { this.setLayingEgg(digging); } // Paper - OBFHELPER - private void setLayingEgg(boolean diggingSand) { - this.layEggCounter = diggingSand ? 1 : 0; +@@ -0,0 +0,0 @@ public class Turtle extends Animal { this.entityData.set(Turtle.LAYING_EGG, diggingSand); } -+ public final boolean isGoingHome() { return this.isGoingHome(); } // Paper - OBFHELPER - private boolean isGoingHome() { +- boolean isGoingHome() { ++ public boolean isGoingHome() { // Paper - public return (Boolean) this.entityData.get(Turtle.GOING_HOME); } -+ public final void setGoingHome(boolean goingHome) { this.setGoingHome(goingHome); } // Paper - OBFHELPER - private void setGoingHome(boolean landBound) { +- void setGoingHome(boolean landBound) { ++ public void setGoingHome(boolean landBound) { // Paper - public this.entityData.set(Turtle.GOING_HOME, landBound); } -+ public final boolean isTravelling() { return this.isTravelling(); } // Paper - OBFHELPER - private boolean isTravelling() { +- boolean isTravelling() { ++ public boolean isTravelling() { // Paper - public return (Boolean) this.entityData.get(Turtle.TRAVELLING); } -+ public final void setTravelling(boolean travelling) { this.setTravelling(travelling); } // Paper - OBFHELPER - private void setTravelling(boolean travelling) { +- void setTravelling(boolean travelling) { ++ public void setTravelling(boolean travelling) { // Paper - public this.entityData.set(Turtle.TRAVELLING, travelling); } + @@ -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.setDigging(new com.destroystokyo.paper.event.entity.TurtleStartDiggingEvent((org.bukkit.entity.Turtle) this.turtle.getBukkitEntity(), MCUtil.toLocation(this.turtle.level, this.getTargetPosition())).callEvent()); // Paper ++ 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) { Level world = this.turtle.level; @@ -134,7 +128,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + @Override + public boolean isDigging() { -+ return getHandle().isDigging(); ++ return getHandle().isLayingEgg(); + } + + @Override