mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-12-22 22:45:04 +01:00
Sanity check for shulker boxes (#4762)
This commit is contained in:
parent
deb25d7147
commit
29928c2d83
2 changed files with 11 additions and 1 deletions
|
@ -73,6 +73,15 @@ public final class BlockState {
|
|||
return (Boolean) value;
|
||||
}
|
||||
|
||||
public <T extends Comparable<T>> T getValue(Property<T> property, T def) {
|
||||
var value = get(property);
|
||||
if (value == null) {
|
||||
return def;
|
||||
}
|
||||
//noinspection unchecked
|
||||
return (T) value;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Comparable<?> get(Property<?> property) {
|
||||
Property<?>[] keys = this.block.propertyKeys();
|
||||
|
|
|
@ -30,6 +30,7 @@ import org.cloudburstmc.nbt.NbtMap;
|
|||
import org.cloudburstmc.nbt.NbtMapBuilder;
|
||||
import org.geysermc.geyser.level.block.property.Properties;
|
||||
import org.geysermc.geyser.level.block.type.BlockState;
|
||||
import org.geysermc.geyser.level.physics.Direction;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
import org.geysermc.geyser.translator.inventory.ShulkerInventoryTranslator;
|
||||
import org.geysermc.mcprotocollib.protocol.data.game.level.block.BlockEntityType;
|
||||
|
@ -42,6 +43,6 @@ public class ShulkerBoxBlockEntityTranslator extends BlockEntityTranslator imple
|
|||
*/
|
||||
@Override
|
||||
public void translateTag(GeyserSession session, NbtMapBuilder bedrockNbt, @Nullable NbtMap javaNbt, BlockState blockState) {
|
||||
bedrockNbt.putByte("facing", (byte) blockState.getValue(Properties.FACING).ordinal());
|
||||
bedrockNbt.putByte("facing", (byte) blockState.getValue(Properties.FACING, Direction.UP).ordinal());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue