Skip to content

Commit

Permalink
Sanity check for shulker boxes (#4762)
Browse files Browse the repository at this point in the history
  • Loading branch information
onebeastchris authored Jun 17, 2024
1 parent deb25d7 commit 29928c2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@ public boolean getValue(Property<Boolean> property, boolean def) {
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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
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;
Expand All @@ -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());
}
}

0 comments on commit 29928c2

Please sign in to comment.