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

Fix: WorldGuard protected doors being openable for Bedrock players

Some doors just aren't open

Fixes https://github.com/GeyserMC/Geyser/issues/6001
This commit is contained in:
onebeastchris
2025-11-25 00:06:15 +01:00
parent 22414721ed
commit dbed595091
3 changed files with 25 additions and 3 deletions

View File

@@ -30,6 +30,8 @@ import org.geysermc.geyser.level.block.property.Properties;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.util.ChunkUtils;
import java.util.Objects;
public class DoorBlock extends Block {
public DoorBlock(String javaIdentifier, Builder builder) {
super(javaIdentifier, builder);
@@ -40,7 +42,10 @@ public class DoorBlock extends Block {
// Needed to check whether we must force the client to update the door state.
String doubleBlockHalf = state.getValue(Properties.DOUBLE_BLOCK_HALF);
if (!session.getGeyser().getWorldManager().hasOwnChunkCache() && doubleBlockHalf.equals("lower")) {
Vector3i lastLowerDoor = session.getLastLowerDoorPosition();
session.setLastLowerDoorPosition(null);
if (Objects.equals(lastLowerDoor, position) && doubleBlockHalf.equals("lower")) {
BlockState oldBlockState = session.getGeyser().getWorldManager().blockAt(session, position);
// If these are the same, it means that we already updated the lower door block (manually in the workaround below),
// and we do not need to update the block in the cache/on the client side using the super.updateBlock() method again.
@@ -55,9 +60,14 @@ public class DoorBlock extends Block {
if (doubleBlockHalf.equals("upper")) {
// Update the lower door block as Bedrock client doesn't like door to be closed from the top
// See https://github.com/GeyserMC/Geyser/issues/4358
Vector3i belowDoorPosition = position.sub(0, 1, 0);
Vector3i belowDoorPosition = position.down(1);
BlockState belowDoorBlockState = session.getGeyser().getWorldManager().blockAt(session, belowDoorPosition.getX(), belowDoorPosition.getY(), belowDoorPosition.getZ());
ChunkUtils.updateBlock(session, belowDoorBlockState, belowDoorPosition);
// better safe than sorry - withValue can throw
if (belowDoorBlockState.block() instanceof DoorBlock) {
belowDoorBlockState = belowDoorBlockState.withValue(Properties.OPEN, state.getValue(Properties.OPEN));
ChunkUtils.updateBlock(session, belowDoorBlockState, belowDoorPosition);
session.setLastLowerDoorPosition(belowDoorPosition);
}
}
}
}

View File

@@ -590,6 +590,12 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
@Setter
private boolean placedBucket;
/**
* Stores whether we've updated a lower door block
*/
@Setter
private @Nullable Vector3i lastLowerDoorPosition = null;
/**
* Counts how many ticks have occurred since an arm animation started.
* -1 means there is no active arm swing

View File

@@ -63,6 +63,7 @@ import org.geysermc.geyser.level.block.type.Block;
import org.geysermc.geyser.level.block.type.BlockState;
import org.geysermc.geyser.level.block.type.ButtonBlock;
import org.geysermc.geyser.level.block.type.CauldronBlock;
import org.geysermc.geyser.level.block.type.DoorBlock;
import org.geysermc.geyser.level.block.type.FlowerPotBlock;
import org.geysermc.geyser.level.physics.Direction;
import org.geysermc.geyser.registry.BlockRegistries;
@@ -281,6 +282,11 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
return;
}
if (blockState.block() instanceof DoorBlock) {
// See DoorBlock#updateBlock: ensure server-side lower-half door updates are translated
session.setLastLowerDoorPosition(null);
}
if (packet.getItemInHand() != null && session.getItemMappings().getMapping(packet.getItemInHand()).getJavaItem() instanceof SpawnEggItem) {
if (blockState.is(Blocks.WATER) && blockState.getValue(Properties.LEVEL) == 0) {
// Otherwise causes multiple mobs to spawn - just send a use item packet