mirror of
https://github.com/XevianLight/Aphelion.git
synced 2026-05-11 01:50:56 +01:00
Basic crude GUI implementation for StationFlightComputerBlock
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
package net.xevianlight.aphelion.screen;
|
||||
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
import net.minecraft.world.inventory.ContainerData;
|
||||
import net.minecraft.world.inventory.SimpleContainerData;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.xevianlight.aphelion.block.entity.custom.StationFlightComputerBlockEntity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class StationFlightComputerMenu extends AbstractContainerMenu {
|
||||
public final StationFlightComputerBlockEntity blockEntity;
|
||||
|
||||
public static final int DATA_TRAVELING = 0;
|
||||
public static final int DATA_ENGINE_COUNT = 1;
|
||||
public static final int DATA_PAD_COUNT = 2;
|
||||
public static final int DATA_COUNT = 3;
|
||||
|
||||
private final ContainerData data;
|
||||
|
||||
public StationFlightComputerMenu(int windowId, Inventory inv, FriendlyByteBuf buf) {
|
||||
this(windowId, inv, inv.player.level().getBlockEntity(buf.readBlockPos()), new SimpleContainerData(DATA_COUNT));
|
||||
}
|
||||
|
||||
public StationFlightComputerMenu(int windowId, Inventory inv, BlockEntity be, ContainerData data) {
|
||||
super(ModMenuTypes.STATION_FLIGHT_COMPUTER_MENU.get(), windowId);
|
||||
this.blockEntity = (StationFlightComputerBlockEntity) be;
|
||||
this.data = data;
|
||||
addDataSlots(data);
|
||||
}
|
||||
|
||||
public boolean isTraveling() { return data.get(DATA_TRAVELING) != 0; }
|
||||
public int getEngineCount() { return data.get(DATA_ENGINE_COUNT); }
|
||||
public int getPadCount() { return data.get(DATA_PAD_COUNT); }
|
||||
|
||||
@Override
|
||||
public @NotNull ItemStack quickMoveStack(@NotNull Player player, int index) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean stillValid(@NotNull Player player) {
|
||||
// Always valid — players can interact with the computer from anywhere on the station.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user