Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Shanwer committed Feb 7, 2025
2 parents a06c2a6 + b96f915 commit 8208b54
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,14 @@
public class SingleChestInventoryTranslator extends ChestInventoryTranslator {
private final InventoryHolder holder;

// TODO add barrel???
public SingleChestInventoryTranslator(int size) {
super(size, 27);
this.holder = new BlockInventoryHolder(Blocks.CHEST.defaultBlockState().withValue(Properties.CHEST_TYPE, ChestType.SINGLE), ContainerType.CONTAINER,
Blocks.ENDER_CHEST, Blocks.TRAPPED_CHEST) {
Blocks.ENDER_CHEST, Blocks.TRAPPED_CHEST, Blocks.BARREL) {
@Override
protected boolean isValidBlock(BlockState blockState) {
if (blockState.is(Blocks.ENDER_CHEST)) {
// Can't have double ender chests
if (blockState.is(Blocks.ENDER_CHEST) || blockState.is(Blocks.BARREL)) {
// Can't have double ender chests or barrels
return true;
}

Expand Down
12 changes: 10 additions & 2 deletions core/src/main/java/org/geysermc/geyser/util/InventoryUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import org.geysermc.geyser.inventory.recipe.GeyserShapelessRecipe;
import org.geysermc.geyser.item.Items;
import org.geysermc.geyser.level.BedrockDimension;
import org.geysermc.geyser.level.block.type.BlockState;
import org.geysermc.geyser.registry.Registries;
import org.geysermc.geyser.registry.type.ItemMappings;
import org.geysermc.geyser.session.GeyserSession;
Expand Down Expand Up @@ -173,15 +174,22 @@ public static Vector3i findAvailableWorldSpace(GeyserSession session) {
if (position.getY() < minY) {
return null;
}
if (position.getY() >= maxY) {
if (position.getY() >= maxY || !canUseWorldSpace(session, position)) {
position = flatPlayerPosition.sub(0, 4, 0);
if (position.getY() >= maxY) {
if (position.getY() >= maxY || !canUseWorldSpace(session, position)) {
return null;
}
}
return position;
}

@SuppressWarnings("BooleanMethodIsAlwaysInverted")
private static boolean canUseWorldSpace(GeyserSession session, Vector3i position) {
BlockState state = session.getGeyser().getWorldManager().blockAt(session, position);
// Block entities require more data to be restored; so let's avoid using these positions
return state.block().blockEntityType() == null;
}

public static void updateCursor(GeyserSession session) {
InventorySlotPacket cursorPacket = new InventorySlotPacket();
cursorPacket.setContainerId(ContainerId.UI);
Expand Down

0 comments on commit 8208b54

Please sign in to comment.