mirror of
https://github.com/GeyserMC/Geyser.git
synced 2025-12-20 07:19:29 +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:
@@ -30,6 +30,8 @@ import org.geysermc.geyser.level.block.property.Properties;
|
|||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
import org.geysermc.geyser.util.ChunkUtils;
|
import org.geysermc.geyser.util.ChunkUtils;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class DoorBlock extends Block {
|
public class DoorBlock extends Block {
|
||||||
public DoorBlock(String javaIdentifier, Builder builder) {
|
public DoorBlock(String javaIdentifier, Builder builder) {
|
||||||
super(javaIdentifier, 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.
|
// Needed to check whether we must force the client to update the door state.
|
||||||
String doubleBlockHalf = state.getValue(Properties.DOUBLE_BLOCK_HALF);
|
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);
|
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),
|
// 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.
|
// 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")) {
|
if (doubleBlockHalf.equals("upper")) {
|
||||||
// Update the lower door block as Bedrock client doesn't like door to be closed from the top
|
// 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
|
// 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());
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -590,6 +590,12 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
|
|||||||
@Setter
|
@Setter
|
||||||
private boolean placedBucket;
|
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.
|
* Counts how many ticks have occurred since an arm animation started.
|
||||||
* -1 means there is no active arm swing
|
* -1 means there is no active arm swing
|
||||||
|
|||||||
@@ -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.BlockState;
|
||||||
import org.geysermc.geyser.level.block.type.ButtonBlock;
|
import org.geysermc.geyser.level.block.type.ButtonBlock;
|
||||||
import org.geysermc.geyser.level.block.type.CauldronBlock;
|
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.block.type.FlowerPotBlock;
|
||||||
import org.geysermc.geyser.level.physics.Direction;
|
import org.geysermc.geyser.level.physics.Direction;
|
||||||
import org.geysermc.geyser.registry.BlockRegistries;
|
import org.geysermc.geyser.registry.BlockRegistries;
|
||||||
@@ -281,6 +282,11 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
|
|||||||
return;
|
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 (packet.getItemInHand() != null && session.getItemMappings().getMapping(packet.getItemInHand()).getJavaItem() instanceof SpawnEggItem) {
|
||||||
if (blockState.is(Blocks.WATER) && blockState.getValue(Properties.LEVEL) == 0) {
|
if (blockState.is(Blocks.WATER) && blockState.getValue(Properties.LEVEL) == 0) {
|
||||||
// Otherwise causes multiple mobs to spawn - just send a use item packet
|
// Otherwise causes multiple mobs to spawn - just send a use item packet
|
||||||
|
|||||||
Reference in New Issue
Block a user