diff --git a/.gitignore b/.gitignore index d55a491..9ec2d5a 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ .idea/ build/ run/ +run # macos .DS_Store diff --git a/sakura-server/minecraft-patches/features/0004-Slice-Packet-obfuscation-and-reduction.patch b/sakura-server/minecraft-patches/features/0004-Slice-Packet-obfuscation-and-reduction.patch index 9d1652d..a07d59f 100644 --- a/sakura-server/minecraft-patches/features/0004-Slice-Packet-obfuscation-and-reduction.patch +++ b/sakura-server/minecraft-patches/features/0004-Slice-Packet-obfuscation-and-reduction.patch @@ -153,7 +153,7 @@ index e96d4dee14c05f2fa329bfb1588ec795d4e3d730..ba9393e474ae213316c693d73ef2641e if (this.entity instanceof LivingEntity) { diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index 706941df21621080b70cc7d8c84d1ec7b7ddc483..4b9a0327251a54d752409021cb7a10f890f1f131 100644 +index f6d92a85190ccb5794fe49693d36263b556399ed..87192b70b9fb9e182853e1004e9a2a627a2c56e3 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java @@ -3638,7 +3638,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -196,10 +196,10 @@ index 2420999c5399333bed122ee0a1f252ac894adfcb..2e7f6e3941b34323768e43870541c8e4 public int getFuse() { diff --git a/net/minecraft/world/entity/player/Player.java b/net/minecraft/world/entity/player/Player.java -index 5cacbc07ee0f6ef2f47f7e0e8f6267d82ea94501..6160c684b712742b6ce565afb043c03badb705b2 100644 +index 4a0c69b45f9805644f214fcc973a72e50d95f3ea..e896610d02cb0193cf74d6a1de571ccb601c8da9 100644 --- a/net/minecraft/world/entity/player/Player.java +++ b/net/minecraft/world/entity/player/Player.java -@@ -701,7 +701,7 @@ public abstract class Player extends LivingEntity { +@@ -708,7 +708,7 @@ public abstract class Player extends LivingEntity { public void increaseScore(int score) { int score1 = this.getScore(); diff --git a/sakura-server/minecraft-patches/sources/net/minecraft/world/entity/player/Player.java.patch b/sakura-server/minecraft-patches/sources/net/minecraft/world/entity/player/Player.java.patch index c46d02e..d98d1ec 100644 --- a/sakura-server/minecraft-patches/sources/net/minecraft/world/entity/player/Player.java.patch +++ b/sakura-server/minecraft-patches/sources/net/minecraft/world/entity/player/Player.java.patch @@ -8,17 +8,24 @@ // CraftBukkit start public boolean fauxSleeping; -@@ -229,6 +_,18 @@ +@@ -229,6 +_,25 @@ return (org.bukkit.craftbukkit.entity.CraftHumanEntity) super.getBukkitEntity(); } // CraftBukkit end + // Sakura start - prevent players glitching through blocks + public final boolean isInsideAnyCollision() { -+ return this.insideAnyCollisionAt(this.level(), this.position()); ++ return this.insideAnyCollisionAt(this.level(), this.position(), Pose.STANDING); + } + + public final boolean insideAnyCollisionAt(final Level level, final Vec3 position) { -+ final EntityDimensions entityDimensions = this.getDimensions(Pose.STANDING); ++ final Pose pose = this.getVehicle() != null || !this.level().sakuraConfig().players.posesShrinkCollisionBox ++ ? Pose.STANDING ++ : Pose.SWIMMING; ++ return this.insideAnyCollisionAt(level, position, pose); ++ } ++ ++ public final boolean insideAnyCollisionAt(final Level level, final Vec3 position, final Pose pose) { ++ final EntityDimensions entityDimensions = this.getDimensions(pose); + final AABB entityBB = entityDimensions.makeBoundingBox(position); + return !level.noCollision(this, entityBB.deflate(1.0e-7)) + || !level.getWorldBorder().isWithinBounds(entityBB); @@ -27,6 +34,15 @@ public Player(Level level, GameProfile gameProfile) { super(EntityType.PLAYER, level); +@@ -471,7 +_,7 @@ + this.yCloak += d1 * 0.25; + } + +- protected void updatePlayerPose() { ++ public void updatePlayerPose() { + if (this.canPlayerFitWithinBlocksAndEntitiesWhen(Pose.SWIMMING)) { + Pose desiredPose = this.getDesiredPose(); + Pose pose; @@ -866,6 +_,10 @@ public boolean isInvulnerableTo(ServerLevel level, DamageSource damageSource) { if (super.isInvulnerableTo(level, damageSource)) { diff --git a/sakura-server/minecraft-patches/sources/net/minecraft/world/entity/projectile/ThrownEnderpearl.java.patch b/sakura-server/minecraft-patches/sources/net/minecraft/world/entity/projectile/ThrownEnderpearl.java.patch index 697d6eb..8e9b1fe 100644 --- a/sakura-server/minecraft-patches/sources/net/minecraft/world/entity/projectile/ThrownEnderpearl.java.patch +++ b/sakura-server/minecraft-patches/sources/net/minecraft/world/entity/projectile/ThrownEnderpearl.java.patch @@ -1,21 +1,39 @@ --- a/net/minecraft/world/entity/projectile/ThrownEnderpearl.java +++ b/net/minecraft/world/entity/projectile/ThrownEnderpearl.java -@@ -118,6 +_,15 @@ +@@ -118,6 +_,21 @@ if (owner != null && isAllowedToTeleportOwner(owner, serverLevel)) { Vec3 vec3 = this.oldPosition(); if (owner instanceof ServerPlayer serverPlayer) { + // Sakura start - prevent ender pearls teleporting inside blocks + if (this.level().sakuraConfig().entity.enderPearl.preventTeleportingInsideBlocks && serverPlayer.insideAnyCollisionAt(serverLevel, vec3)) { -+ vec3 = Vec3.atBottomCenterOf(BlockPos.containing(vec3)); // teleportation position -+ if (serverPlayer.insideAnyCollisionAt(serverLevel, vec3)) { -+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.HIT); -+ return; ++ for (int offset = 0;; ++offset) { ++ vec3 = Vec3.atBottomCenterOf(BlockPos.containing(vec3.subtract(0, offset, 0))); // teleportation position ++ if (!serverPlayer.insideAnyCollisionAt(serverLevel, vec3)) { ++ break; ++ } ++ ++ if (offset == 1) { ++ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.HIT); ++ return; ++ } + } + } + // Sakura end - prevent ender pearls teleporting inside blocks if (serverPlayer.connection.isAcceptingMessages()) { // CraftBukkit start // Store pre teleportation position as the teleport has been moved up. +@@ -163,6 +_,11 @@ + if (entity != null) { + entity.resetFallDistance(); + } ++ // Sakura start - prevent ender pearls teleporting inside blocks ++ if (entity instanceof net.minecraft.world.entity.player.Player player) { ++ player.updatePlayerPose(); ++ } ++ // Sakura end - prevent ender pearls teleporting inside blocks + + this.playSound(serverLevel, vec3); + } @@ -181,6 +_,13 @@ return entity.canUsePortal(true); }