mirror of
https://github.com/GeyserMC/Geyser.git
synced 2026-01-03 22:16:31 +00:00
Severals fixes relating to the new movement collision system.
* Revert last change, move everything to a different package, added end portal fix. * Oops. * Fixed lantern collision. * Fixed conduit collision. * Fixed scaffolding collision. * Fixed bell collision and sea pickle collision. * Avoid loop. * oops. * oops x2. * Change comments.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -172,4 +172,4 @@ public class CollisionRegistryLoader extends MultiResourceRegistryLoader<String,
|
||||
private final CollisionRemapper collisionRemapper;
|
||||
private final Pattern pattern;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
// Due to floating points errors, or possibly how collision is handled on Bedrock, player could be slightly clipping into the block.
|
||||
final double collisionExpansion = CollisionManager.COLLISION_TOLERANCE * 2;
|
||||
|
||||
// Due to floating points errors, or because of block collision difference, 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,9 +82,17 @@ public class BlockCollision {
|
||||
boundingBox.pushOutOfBoundingBox(playerCollision, Direction.WEST, xPushAwayTolerance);
|
||||
boundingBox.pushOutOfBoundingBox(playerCollision, Direction.UP, pushAwayTolerance);
|
||||
boundingBox.pushOutOfBoundingBox(playerCollision, Direction.DOWN, pushAwayTolerance);
|
||||
|
||||
correctPosition(session, x, y, z, boundingBox, playerCollision);
|
||||
|
||||
// Revert back to the old collision size.
|
||||
playerCollision.expand(-collisionExpansion, 0, -collisionExpansion);
|
||||
}
|
||||
}
|
||||
|
||||
protected void correctPosition(GeyserSession session, int x, int y, int z, BoundingBox blockCollision, BoundingBox playerCollision) {
|
||||
}
|
||||
|
||||
public boolean checkIntersection(double x, double y, double z, BoundingBox playerCollision) {
|
||||
for (BoundingBox b : boundingBoxes) {
|
||||
if (b.checkIntersection(x, y, z, playerCollision)) {
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* 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 = "^bell$", passDefaultBoxes = true)
|
||||
public class BellCollision extends BlockCollision {
|
||||
private final static double MAX_PUSH_DISTANCE = 0.1875 + CollisionManager.COLLISION_TOLERANCE * 1.01;
|
||||
|
||||
private final boolean standing;
|
||||
|
||||
public BellCollision(BlockState state, BoundingBox[] boxes) {
|
||||
super(boxes);
|
||||
|
||||
this.standing = state.getValue(Properties.BELL_ATTACHMENT).equals("floor");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void correctPosition(GeyserSession session, int x, int y, int z, BoundingBox blockCollision, BoundingBox playerCollision) {
|
||||
if (!this.standing) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check for bell collision bug (bell on Java is 0.1875 block higher than Bedrock)
|
||||
blockCollision.pushOutOfBoundingBox(playerCollision, Direction.UP, MAX_PUSH_DISTANCE);
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* 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.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 = "^conduit$", passDefaultBoxes = true)
|
||||
public class ConduitCollision extends BlockCollision {
|
||||
private final static double MAX_PUSH_DISTANCE = 0.1875 + CollisionManager.COLLISION_TOLERANCE * 1.01;
|
||||
|
||||
public ConduitCollision(BlockState state, BoundingBox[] boxes) {
|
||||
super(boxes);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void correctPosition(GeyserSession session, int x, int y, int z, BoundingBox blockCollision, BoundingBox playerCollision) {
|
||||
// Check for conduit bug (conduit is lifted from the ground on Java unlike Bedrock where conduit is placed on the ground)
|
||||
blockCollision.pushOutOfBoundingBox(playerCollision, Direction.UP, MAX_PUSH_DISTANCE);
|
||||
}
|
||||
}
|
||||
@@ -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,10 +32,14 @@ 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)
|
||||
public class DoorCollision extends BlockCollision {
|
||||
private final static double MAX_PUSH_DISTANCE = 0.005 + CollisionManager.COLLISION_TOLERANCE * 1.01;
|
||||
|
||||
/**
|
||||
* 1 = north
|
||||
* 2 = east
|
||||
@@ -61,25 +65,13 @@ public class DoorCollision extends BlockCollision {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void correctPosition(GeyserSession session, int x, int y, int z, BoundingBox playerCollision) {
|
||||
super.correctPosition(session, x, y, z, playerCollision);
|
||||
final double maxPushDistance = 0.005 + CollisionManager.COLLISION_TOLERANCE * 1.01F;
|
||||
|
||||
protected void correctPosition(GeyserSession session, int x, int y, int z, BoundingBox blockCollision, BoundingBox playerCollision) {
|
||||
// Check for door bug (doors are 0.1875 blocks thick on Java but 0.1825 blocks thick on Bedrock)
|
||||
for (BoundingBox boundingBox : this.boundingBoxes) {
|
||||
if (!boundingBox.checkIntersection(x, y, z, playerCollision)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
boundingBox = boundingBox.clone();
|
||||
boundingBox.translate(x, y, z);
|
||||
|
||||
switch (this.facing) {
|
||||
case 1 -> boundingBox.pushOutOfBoundingBox(playerCollision, Direction.NORTH, maxPushDistance);
|
||||
case 2 -> boundingBox.pushOutOfBoundingBox(playerCollision, Direction.EAST, maxPushDistance);
|
||||
case 3 -> boundingBox.pushOutOfBoundingBox(playerCollision, Direction.SOUTH, maxPushDistance);
|
||||
case 4 -> boundingBox.pushOutOfBoundingBox(playerCollision, Direction.WEST, maxPushDistance);
|
||||
}
|
||||
switch (this.facing) {
|
||||
case 1 -> blockCollision.pushOutOfBoundingBox(playerCollision, Direction.NORTH, MAX_PUSH_DISTANCE);
|
||||
case 2 -> blockCollision.pushOutOfBoundingBox(playerCollision, Direction.EAST, MAX_PUSH_DISTANCE);
|
||||
case 3 -> blockCollision.pushOutOfBoundingBox(playerCollision, Direction.SOUTH, MAX_PUSH_DISTANCE);
|
||||
case 4 -> blockCollision.pushOutOfBoundingBox(playerCollision, Direction.WEST, MAX_PUSH_DISTANCE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* 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 static double MAX_PUSH_DISTANCE = 0.1875 + CollisionManager.COLLISION_TOLERANCE * 1.01;
|
||||
|
||||
private final boolean eye;
|
||||
|
||||
public EndPortalCollision(BlockState state, BoundingBox[] boxes) {
|
||||
super(boxes);
|
||||
|
||||
this.eye = state.getValue(Properties.EYE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void correctPosition(GeyserSession session, int x, int y, int z, BoundingBox blockCollision, BoundingBox playerCollision) {
|
||||
if (!this.eye) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check for end portal frame bug (BE don't have the eye collision when the end portal frame contain an eye unlike JE)
|
||||
blockCollision.pushOutOfBoundingBox(playerCollision, Direction.UP, MAX_PUSH_DISTANCE);
|
||||
}
|
||||
}
|
||||
@@ -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,10 +32,14 @@ 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)
|
||||
public class GlassPaneAndIronBarsCollision extends BlockCollision {
|
||||
private final static double MAX_PUSH_DISTANCE = 0.0625 + CollisionManager.COLLISION_TOLERANCE * 1.01;
|
||||
|
||||
/**
|
||||
* 1 = north
|
||||
* 2 = east
|
||||
@@ -70,36 +74,23 @@ public class GlassPaneAndIronBarsCollision extends BlockCollision {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void correctPosition(GeyserSession session, int x, int y, int z, BoundingBox playerCollision) {
|
||||
super.correctPosition(session, x, y, z, playerCollision);
|
||||
|
||||
final double maxPushDistance = 0.0625 + CollisionManager.COLLISION_TOLERANCE * 1.01F;
|
||||
|
||||
protected void correctPosition(GeyserSession session, int x, int y, int z, BoundingBox blockCollision, BoundingBox playerCollision) {
|
||||
// Check for glass pane/iron bars bug (pane/iron bars is 0.5 blocks thick on Bedrock but 0.5625 on Java when only 1 side is connected).
|
||||
for (BoundingBox boundingBox : this.boundingBoxes) {
|
||||
if (!boundingBox.checkIntersection(x, y, z, playerCollision)) {
|
||||
continue;
|
||||
}
|
||||
// Also, we want to flip the direction since the direction here is indicating the block side the glass is connected to.
|
||||
if (this.facing == 2 || this.facing == 6 || this.facing == 5) { // East
|
||||
blockCollision.pushOutOfBoundingBox(playerCollision, Direction.WEST, MAX_PUSH_DISTANCE);
|
||||
}
|
||||
|
||||
boundingBox = boundingBox.clone();
|
||||
boundingBox.translate(x, y, z);
|
||||
if (this.facing == 1 || this.facing == 5 || this.facing == 8) { // North.
|
||||
blockCollision.pushOutOfBoundingBox(playerCollision, Direction.SOUTH, MAX_PUSH_DISTANCE);
|
||||
}
|
||||
|
||||
// Also we want to flip the direction since the direction here is indicating the block side the glass is connected to.
|
||||
if (this.facing == 2 || this.facing == 6 || this.facing == 5) { // East
|
||||
boundingBox.pushOutOfBoundingBox(playerCollision, Direction.WEST, maxPushDistance);
|
||||
}
|
||||
if (this.facing == 3 || this.facing == 6 || this.facing == 7) { // South
|
||||
blockCollision.pushOutOfBoundingBox(playerCollision, Direction.NORTH, MAX_PUSH_DISTANCE);
|
||||
}
|
||||
|
||||
if (this.facing == 1 || this.facing == 5 || this.facing == 8) { // North.
|
||||
boundingBox.pushOutOfBoundingBox(playerCollision, Direction.SOUTH, maxPushDistance);
|
||||
}
|
||||
|
||||
if (this.facing == 3 || this.facing == 6 || this.facing == 7) { // South
|
||||
boundingBox.pushOutOfBoundingBox(playerCollision, Direction.NORTH, maxPushDistance);
|
||||
}
|
||||
|
||||
if (this.facing == 4 || this.facing == 7 || this.facing == 8) { // West
|
||||
boundingBox.pushOutOfBoundingBox(playerCollision, Direction.EAST, maxPushDistance);
|
||||
}
|
||||
if (this.facing == 4 || this.facing == 7 || this.facing == 8) { // West
|
||||
blockCollision.pushOutOfBoundingBox(playerCollision, Direction.EAST, MAX_PUSH_DISTANCE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* 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 = "^lantern$|^soul_lantern$", usesParams = true, passDefaultBoxes = true)
|
||||
public class LanternCollision extends BlockCollision {
|
||||
private final static double MAX_PUSH_DISTANCE = 0.0625 + CollisionManager.COLLISION_TOLERANCE * 1.01;
|
||||
|
||||
private final boolean hanging;
|
||||
|
||||
public LanternCollision(BlockState state, BoundingBox[] boxes) {
|
||||
super(boxes);
|
||||
|
||||
this.hanging = state.getValue(Properties.HANGING);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void correctPosition(GeyserSession session, int x, int y, int z, BoundingBox blockCollision, BoundingBox playerCollision) {
|
||||
// Check for lantern collision (lantern is 0.0625 block higher on Java)
|
||||
if (this.hanging) {
|
||||
blockCollision.pushOutOfBoundingBox(playerCollision, Direction.DOWN, MAX_PUSH_DISTANCE);
|
||||
} else {
|
||||
blockCollision.pushOutOfBoundingBox(playerCollision, Direction.UP, MAX_PUSH_DISTANCE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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,17 @@
|
||||
* @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;
|
||||
import org.geysermc.geyser.level.block.type.BlockState;
|
||||
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;
|
||||
|
||||
/**
|
||||
* In order for scaffolding to work on Bedrock, entity flags need to be sent to the player
|
||||
@@ -36,8 +41,12 @@ import org.geysermc.geyser.session.GeyserSession;
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@CollisionRemapper(regex = "^scaffolding$", usesParams = true, passDefaultBoxes = true)
|
||||
public class ScaffoldingCollision extends BlockCollision {
|
||||
private final boolean bottom;
|
||||
|
||||
public ScaffoldingCollision(BlockState state, BoundingBox[] defaultBoxes) {
|
||||
super(defaultBoxes);
|
||||
|
||||
this.bottom = state.getValue(Properties.BOTTOM) && state.getValue(Properties.STABILITY_DISTANCE) != 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -51,6 +60,17 @@ public class ScaffoldingCollision extends BlockCollision {
|
||||
playerCollision.setSizeY(playerCollision.getSizeY() + 0.001);
|
||||
playerCollision.setMiddleY(playerCollision.getMiddleY() - 0.002);
|
||||
|
||||
boolean canStandOn = playerCollision.getMin(Axis.Y) >= y + 1 && !session.isSneaking();
|
||||
|
||||
// If these condition are met, then the scaffolding will have a bottom collision that is 0.125 block height.
|
||||
// However, this is not the case in Bedrock, so we push the player up by 0.125 blocks so player won't get setback.
|
||||
if (!canStandOn && this.bottom && playerCollision.getMin(Axis.Y) >= y) {
|
||||
double distance = y + 0.125 - (playerCollision.getMin(Axis.Y)) ;
|
||||
if (Math.abs(distance) < 0.125F + CollisionManager.COLLISION_TOLERANCE * 1.01F) {
|
||||
playerCollision.translate(0, distance, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (intersected) {
|
||||
session.getCollisionManager().setTouchingScaffolding(true);
|
||||
session.getCollisionManager().setOnScaffolding(true);
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* 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.type.BlockState;
|
||||
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.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 = "^sea_pickle$", passDefaultBoxes = true)
|
||||
public class SeaPickleCollision extends BlockCollision {
|
||||
public SeaPickleCollision(BlockState state, BoundingBox[] boxes) {
|
||||
super(boxes);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void correctPosition(GeyserSession session, int x, int y, int z, BoundingBox blockCollision, BoundingBox playerCollision) {
|
||||
// Check for sea pickle bug (sea pickle have no collision on Bedrock but does on Java).
|
||||
double maxY = blockCollision.getMax(Axis.Y) - y;
|
||||
blockCollision.pushOutOfBoundingBox(playerCollision, Direction.UP, maxY + CollisionManager.COLLISION_TOLERANCE * 1.01F);
|
||||
}
|
||||
}
|
||||
@@ -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,10 +32,14 @@ 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)
|
||||
public class TrapdoorCollision extends BlockCollision {
|
||||
private final static double MAX_PUSH_DISTANCE = 0.005 + CollisionManager.COLLISION_TOLERANCE * 1.01;
|
||||
|
||||
private final Direction facing;
|
||||
|
||||
public TrapdoorCollision(BlockState state, BoundingBox[] defaultBoxes) {
|
||||
@@ -52,20 +56,8 @@ public class TrapdoorCollision extends BlockCollision {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void correctPosition(GeyserSession session, int x, int y, int z, BoundingBox playerCollision) {
|
||||
super.correctPosition(session, x, y, z, playerCollision);
|
||||
|
||||
final double maxPushDistance = 0.005 + CollisionManager.COLLISION_TOLERANCE * 1.01F;
|
||||
|
||||
protected void correctPosition(GeyserSession session, int x, int y, int z, BoundingBox blockCollision, BoundingBox playerCollision) {
|
||||
// Check for trapdoor bug (trapdoors are 0.1875 blocks thick on Java but 0.1825 blocks thick on Bedrock)
|
||||
for (BoundingBox boundingBox : this.boundingBoxes) {
|
||||
if (!boundingBox.checkIntersection(x, y, z, playerCollision)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
boundingBox = boundingBox.clone();
|
||||
boundingBox.translate(x, y, z);
|
||||
boundingBox.pushOutOfBoundingBox(playerCollision, facing, maxPushDistance);
|
||||
}
|
||||
blockCollision.pushOutOfBoundingBox(playerCollision, facing, MAX_PUSH_DISTANCE);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user