mirror of
https://github.com/Samsuik/Sakura.git
synced 2025-12-27 18:59:06 +00:00
Fix enderpearls not teleporting against walls and ceilings
This commit is contained in:
@@ -196,10 +196,10 @@ index 2572c0fe5fc6bd2f389569cdaa907a8b5203f5b4..6797e16f973b11d168906dfce240c70d
|
||||
|
||||
public int getFuse() {
|
||||
diff --git a/net/minecraft/world/entity/player/Player.java b/net/minecraft/world/entity/player/Player.java
|
||||
index 0a72140f396ab1c03a064020b6e081108a98b06e..92a8bdbf74a35afcd76eabee0869426440a69b7a 100644
|
||||
index e2d5426b6c88dd3fbc64864b8bbd9a39a3ffa4ee..4a8ec0354ccc81dea6dac795975b59895b00f07f 100644
|
||||
--- a/net/minecraft/world/entity/player/Player.java
|
||||
+++ b/net/minecraft/world/entity/player/Player.java
|
||||
@@ -573,7 +573,7 @@ public abstract class Player extends Avatar implements ContainerUser {
|
||||
@@ -580,7 +580,7 @@ public abstract class Player extends Avatar implements ContainerUser {
|
||||
|
||||
public void increaseScore(int score) {
|
||||
int score1 = this.getScore();
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
// CraftBukkit start
|
||||
public boolean fauxSleeping;
|
||||
@@ -190,6 +_,28 @@
|
||||
@@ -190,6 +_,35 @@
|
||||
return (org.bukkit.craftbukkit.entity.CraftHumanEntity) super.getBukkitEntity();
|
||||
}
|
||||
// CraftBukkit end
|
||||
@@ -24,11 +24,18 @@
|
||||
+ // Sakura end - player poses shrink collision box
|
||||
+ // 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 net.minecraft.world.entity.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 net.minecraft.world.entity.EntityDimensions entityDimensions = this.getDimensions(pose);
|
||||
+ final AABB entityBB = entityDimensions.makeBoundingBox(position);
|
||||
+ return !level.noCollision(this, entityBB.deflate(1.0e-7))
|
||||
+ || !level.getWorldBorder().isWithinBounds(entityBB);
|
||||
@@ -37,6 +44,15 @@
|
||||
|
||||
public Player(Level level, GameProfile gameProfile) {
|
||||
super(EntityType.PLAYER, level);
|
||||
@@ -364,7 +_,7 @@
|
||||
return new ItemCooldowns();
|
||||
}
|
||||
|
||||
- protected void updatePlayerPose() {
|
||||
+ public void updatePlayerPose() {
|
||||
if (this.canPlayerFitWithinBlocksAndEntitiesWhen(Pose.SWIMMING)) {
|
||||
Pose desiredPose = this.getDesiredPose();
|
||||
Pose pose;
|
||||
@@ -718,6 +_,10 @@
|
||||
public boolean isInvulnerableTo(ServerLevel level, DamageSource damageSource) {
|
||||
if (super.isInvulnerableTo(level, damageSource)) {
|
||||
|
||||
@@ -32,19 +32,37 @@
|
||||
@Override
|
||||
public Item getDefaultItem() {
|
||||
return Items.ENDER_PEARL;
|
||||
@@ -103,6 +_,15 @@
|
||||
@@ -103,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(this.blockPosition()); // 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.
|
||||
@@ -148,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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user