mirror of
https://github.com/GeyserMC/Geyser.git
synced 2026-01-06 15:41:50 +00:00
Fix: Use real barrels whenever possible instead of fak chest workaround
Fixes https://github.com/GeyserMC/Geyser/issues/5292, fixes https://github.com/GeyserMC/Geyser/issues/5294
This commit is contained in:
@@ -38,15 +38,14 @@ import org.geysermc.geyser.session.GeyserSession;
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@ import org.geysermc.geyser.inventory.recipe.GeyserShapedRecipe;
|
||||
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;
|
||||
@@ -173,15 +174,22 @@ public class InventoryUtils {
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user