1
0
mirror of https://github.com/GeyserMC/Geyser.git synced 2025-12-19 14:59:27 +00:00

Revert last change, move everything to a different package, added end portal fix.

This commit is contained in:
oryxel1
2025-09-04 19:49:58 +07:00
parent 9cc4e9c7ea
commit b57bdee4ca
9 changed files with 102 additions and 13 deletions

View File

@@ -48,8 +48,8 @@ import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.session.cache.PistonCache;
import org.geysermc.geyser.translator.collision.BlockCollision;
import org.geysermc.geyser.translator.collision.OtherCollision;
import org.geysermc.geyser.translator.collision.ScaffoldingCollision;
import org.geysermc.geyser.translator.collision.SolidCollision;
import org.geysermc.geyser.translator.collision.fixes.ScaffoldingCollision;
import org.geysermc.geyser.util.BlockUtils;
import java.text.DecimalFormat;

View File

@@ -41,7 +41,7 @@ import org.geysermc.geyser.registry.BlockRegistries;
import org.geysermc.geyser.translator.collision.BlockCollision;
import org.geysermc.geyser.translator.collision.CollisionRemapper;
import org.geysermc.geyser.translator.collision.OtherCollision;
import org.geysermc.geyser.translator.collision.SolidCollision;
import org.geysermc.geyser.translator.collision.fixes.ShulkerBoxCollision;
import org.geysermc.geyser.util.FileUtils;
import java.io.InputStream;
@@ -136,7 +136,7 @@ public class CollisionRegistryLoader extends MultiResourceRegistryLoader<String,
// Unless some of the low IDs are changed, which is unlikely, the second item should always be full collision
if (collisionIndex == 1) {
return new SolidCollision(state);
return new ShulkerBoxCollision(state);
}
return new OtherCollision(collisionList.get(collisionIndex));
}
@@ -172,4 +172,4 @@ public class CollisionRegistryLoader extends MultiResourceRegistryLoader<String,
private final CollisionRemapper collisionRemapper;
private final Pattern pattern;
}
}
}

View File

@@ -53,12 +53,18 @@ public class BlockCollision {
* Silently move player bounding box/position out of block when needed to.
*/
public void correctPosition(GeyserSession session, int x, int y, int z, BoundingBox playerCollision) {
final double collisionExpansion = CollisionManager.COLLISION_TOLERANCE * 2;
// Due to floating points errors, or possibly how collision is handled on Bedrock, player could be slightly clipping into the block.
// So we check if the player is intersecting the block, if they do then push them out. This fixes NoCheatPlus's Passable check and other anticheat checks.
// This check doesn't allow players right up against the block, so they must be pushed slightly away. However, we should only do it if the
// push distance is smaller than "pushAwayTolerance", we don't want to push player out when they're actually inside a block.
for (BoundingBox boundingBox : this.boundingBoxes) {
// Make player collision slightly bigger to pick up on blocks that could cause problems with NoCheatPlus's Passable check.
playerCollision.expand(collisionExpansion, 0, collisionExpansion);
if (!boundingBox.checkIntersection(x, y, z, playerCollision)) {
playerCollision.expand(-collisionExpansion, 0, -collisionExpansion);
continue;
}
@@ -76,6 +82,9 @@ public class BlockCollision {
boundingBox.pushOutOfBoundingBox(playerCollision, Direction.WEST, xPushAwayTolerance);
boundingBox.pushOutOfBoundingBox(playerCollision, Direction.UP, pushAwayTolerance);
boundingBox.pushOutOfBoundingBox(playerCollision, Direction.DOWN, pushAwayTolerance);
// Revert back to the old collision size.
playerCollision.expand(-collisionExpansion, 0, -collisionExpansion);
}
}

View File

@@ -23,7 +23,7 @@
* @link https://github.com/GeyserMC/Geyser
*/
package org.geysermc.geyser.translator.collision;
package org.geysermc.geyser.translator.collision.fixes;
import lombok.EqualsAndHashCode;
import org.geysermc.geyser.entity.type.player.SessionPlayerEntity;
@@ -32,6 +32,8 @@ import org.geysermc.geyser.level.physics.Axis;
import org.geysermc.geyser.level.physics.BoundingBox;
import org.geysermc.geyser.level.physics.CollisionManager;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.translator.collision.BlockCollision;
import org.geysermc.geyser.translator.collision.CollisionRemapper;
@EqualsAndHashCode(callSuper = true)
@CollisionRemapper(regex = "^chest$", passDefaultBoxes = true)

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019-2022 GeyserMC. http://geysermc.org
* Copyright (c) 2019-2025 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -23,7 +23,7 @@
* @link https://github.com/GeyserMC/Geyser
*/
package org.geysermc.geyser.translator.collision;
package org.geysermc.geyser.translator.collision.fixes;
import lombok.EqualsAndHashCode;
import org.geysermc.geyser.level.block.property.Properties;
@@ -32,6 +32,8 @@ import org.geysermc.geyser.level.physics.BoundingBox;
import org.geysermc.geyser.level.physics.CollisionManager;
import org.geysermc.geyser.level.physics.Direction;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.translator.collision.BlockCollision;
import org.geysermc.geyser.translator.collision.CollisionRemapper;
@EqualsAndHashCode(callSuper = true)
@CollisionRemapper(regex = "_door$", usesParams = true, passDefaultBoxes = true)

View File

@@ -0,0 +1,70 @@
/*
* Copyright (c) 2025 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* @author GeyserMC
* @link https://github.com/GeyserMC/Geyser
*/
package org.geysermc.geyser.translator.collision.fixes;
import lombok.EqualsAndHashCode;
import org.geysermc.geyser.level.block.property.Properties;
import org.geysermc.geyser.level.block.type.BlockState;
import org.geysermc.geyser.level.physics.BoundingBox;
import org.geysermc.geyser.level.physics.CollisionManager;
import org.geysermc.geyser.level.physics.Direction;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.translator.collision.BlockCollision;
import org.geysermc.geyser.translator.collision.CollisionRemapper;
@EqualsAndHashCode(callSuper = true)
@CollisionRemapper(regex = "^end_portal_frame$", passDefaultBoxes = true)
public class EndPortalCollision extends BlockCollision {
private final boolean eye;
public EndPortalCollision(BlockState state, BoundingBox[] boxes) {
super(boxes);
this.eye = state.getValue(Properties.EYE);
}
@Override
public void correctPosition(GeyserSession session, int x, int y, int z, BoundingBox playerCollision) {
super.correctPosition(session, x, y, z, playerCollision);
if (!this.eye) {
return;
}
final double maxPushDistance = 0.1875F + CollisionManager.COLLISION_TOLERANCE * 1.01F;
// Check for end portal frame bug (BE don't have the eye collision when the end portal frame contain an eye unlike JE)
for (BoundingBox boundingBox : this.boundingBoxes) {
if (!boundingBox.checkIntersection(x, y, z, playerCollision)) {
continue;
}
boundingBox = boundingBox.clone();
boundingBox.translate(x, y, z);
boundingBox.pushOutOfBoundingBox(playerCollision, Direction.UP, maxPushDistance);
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019-2022 GeyserMC. http://geysermc.org
* Copyright (c) 2019-2025 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -23,7 +23,7 @@
* @link https://github.com/GeyserMC/Geyser
*/
package org.geysermc.geyser.translator.collision;
package org.geysermc.geyser.translator.collision.fixes;
import lombok.EqualsAndHashCode;
import org.geysermc.geyser.level.block.property.Properties;
@@ -32,6 +32,8 @@ import org.geysermc.geyser.level.physics.BoundingBox;
import org.geysermc.geyser.level.physics.CollisionManager;
import org.geysermc.geyser.level.physics.Direction;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.translator.collision.BlockCollision;
import org.geysermc.geyser.translator.collision.CollisionRemapper;
@EqualsAndHashCode(callSuper = true)
@CollisionRemapper(regex = "glass_pane$|iron_bars$", usesParams = true, passDefaultBoxes = true)

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019-2022 GeyserMC. http://geysermc.org
* Copyright (c) 2019-2025 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -23,12 +23,14 @@
* @link https://github.com/GeyserMC/Geyser
*/
package org.geysermc.geyser.translator.collision;
package org.geysermc.geyser.translator.collision.fixes;
import lombok.EqualsAndHashCode;
import org.geysermc.geyser.level.block.type.BlockState;
import org.geysermc.geyser.level.physics.BoundingBox;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.translator.collision.BlockCollision;
import org.geysermc.geyser.translator.collision.CollisionRemapper;
/**
* In order for scaffolding to work on Bedrock, entity flags need to be sent to the player

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019-2022 GeyserMC. http://geysermc.org
* Copyright (c) 2019-2025 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -23,7 +23,7 @@
* @link https://github.com/GeyserMC/Geyser
*/
package org.geysermc.geyser.translator.collision;
package org.geysermc.geyser.translator.collision.fixes;
import lombok.EqualsAndHashCode;
import org.geysermc.geyser.level.block.property.Properties;
@@ -32,6 +32,8 @@ import org.geysermc.geyser.level.physics.BoundingBox;
import org.geysermc.geyser.level.physics.CollisionManager;
import org.geysermc.geyser.level.physics.Direction;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.translator.collision.BlockCollision;
import org.geysermc.geyser.translator.collision.CollisionRemapper;
@EqualsAndHashCode(callSuper = true)
@CollisionRemapper(regex = "_trapdoor$", usesParams = true, passDefaultBoxes = true)