Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ public ModularPanel buildUI(PosGuiData data, PanelSyncManager syncManager, UISet
.child(new FluidSlot()
.syncHandler(new FluidSlotSyncHandler(waterTank.getStorages()[0]))
.size(14, 54)
.alwaysShowFull(true)
.displayAmount(false))
.child(new FluidSlot()
.syncHandler(new FluidSlotSyncHandler(steamTank.getStorages()[0])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,17 @@ public class InteractableIcon extends DelegateIcon implements Interactable {
private IGuiAction.KeyReleased onKeyReleased;
@Setter
private IGuiAction.KeyPressed onKeyTapped;
@Setter
public boolean playClickSound = true;

public InteractableIcon(IIcon icon) {
super(icon);
}

public void playClickSound() {
// if (this.playClickSound) {
Interactable.playButtonClickSound();
// }
if (this.playClickSound) {
Interactable.playButtonClickSound();
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import net.minecraftforge.fluids.capability.IFluidHandler;
import net.minecraftforge.fluids.capability.IFluidHandlerItem;

import com.mojang.blaze3d.platform.InputConstants;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
Expand Down Expand Up @@ -137,7 +138,7 @@ private void tryClickContainer(MouseData mouseData) {
return;
}
int maxAttempts = mouseData.shift() ? currentStack.getCount() : 1;
if (mouseData.mouseButton() == 0 && this.canFillSlot) {
if (mouseData.mouseButton() == InputConstants.MOUSE_BUTTON_RIGHT && this.canFillSlot) {
boolean performedTransfer = false;
for (int i = 0; i < maxAttempts; i++) {
FluidActionResult result = FluidUtil.tryEmptyContainer(currentStack, this.fluidHandler,
Expand Down Expand Up @@ -169,7 +170,8 @@ private void tryClickContainer(MouseData mouseData) {
return;
}
FluidStack currentFluid = this.fluidTank.getFluid();
if (mouseData.mouseButton() == 1 && this.canDrainSlot && !currentFluid.isEmpty()) {
if (mouseData.mouseButton() == InputConstants.MOUSE_BUTTON_LEFT && this.canDrainSlot &&
!currentFluid.isEmpty()) {
boolean performedTransfer = false;
for (int i = 0; i < maxAttempts; i++) {
FluidActionResult result = FluidUtil.tryFillContainer(currentStack, this.fluidHandler,
Expand All @@ -180,7 +182,7 @@ private void tryClickContainer(MouseData mouseData) {
break; // do not continue if we can't add resulting container into inventory
}

remainingStack = FluidUtil.tryFillContainer(currentStack, this.fluidHandler, Integer.MAX_VALUE, null,
remainingStack = FluidUtil.tryFillContainer(currentStack, this.fluidHandler, Integer.MAX_VALUE, player,
true).result;
if (currentStack.getCount() == 1) {
currentStack = remainingStack;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -892,6 +892,7 @@ public class GTMachines {
.abilities(PartAbility.STEAM_IMPORT_ITEMS)
.modelProperty(IS_FORMED, false)
.colorOverlaySteamHullModel(OVERLAY_ITEM_HATCH_INPUT, "overlay_pipe", "overlay_pipe_in_emissive")
.themeId(GTGuiTheme.BRONZE.getId())
.langValue("Steam Input Bus")
.tooltips(Component.translatable("gtceu.machine.item_bus.import.tooltip"),
Component.translatable("gtceu.machine.steam_bus.tooltip"),
Expand All @@ -905,6 +906,7 @@ public class GTMachines {
.abilities(PartAbility.STEAM_EXPORT_ITEMS)
.modelProperty(IS_FORMED, false)
.colorOverlaySteamHullModel(OVERLAY_ITEM_HATCH_OUTPUT, "overlay_pipe", "overlay_pipe_out_emissive")
.themeId(GTGuiTheme.BRONZE.getId())
.langValue("Steam Output Bus")
.tooltips(Component.translatable("gtceu.machine.item_bus.export.tooltip"),
Component.translatable("gtceu.machine.steam_bus.tooltip"),
Expand All @@ -918,6 +920,7 @@ public class GTMachines {
.abilities(PartAbility.STEAM)
.modelProperty(IS_FORMED, false)
.overlaySteamHullModel("steam_hatch")
.themeId(GTGuiTheme.BRONZE.getId())
.tooltips(Component.translatable("gtceu.universal.tooltip.fluid_storage_capacity",
SteamHatchPartMachine.INITIAL_TANK_CAPACITY),
Component.translatable("gtceu.machine.steam.steam_hatch.tooltip"))
Expand All @@ -929,13 +932,15 @@ public class GTMachines {
.modelProperty(IS_FORMED, false)
.tooltips(Component.translatable("gtceu.part_sharing.disabled"))
.simpleModel(GTCEu.id("block/machine/part/coke_oven_hatch"))
.themeId(GTGuiTheme.PRIMITIVE.getId())
.register();

public static final MachineDefinition PUMP_HATCH = REGISTRATE.machine("pump_hatch", PumpHatchPartMachine::new)
.rotationState(RotationState.ALL)
.abilities(PartAbility.PUMP_FLUID_HATCH)
.modelProperty(IS_FORMED, false)
.model(createBasicReplaceableTextureMachineModel(GTCEu.id("block/machine/part/pump_hatch")))
.themeId(GTGuiTheme.PRIMITIVE.getId())
.register();

public static final MachineDefinition MAINTENANCE_HATCH = REGISTRATE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,8 @@ private static IntSyncValue createCircuitSlotSyncValue(Consumer<ItemStack> circu
return IntCircuitBehaviour.getCircuitConfiguration(circuitGetter.get());
},
(v) -> circuitSetter.accept(v < 0 ? ItemStack.EMPTY :
IntCircuitBehaviour.stack(v, circuitGetter.get().getCount())));
IntCircuitBehaviour.stack(v,
circuitGetter.get().isEmpty() ? 1 : circuitGetter.get().getCount())));
}

public static ModularPanel createCircuitSlotPanel(IntSyncValue circuitSyncValue, PanelSyncManager syncManager) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@
import com.gregtechceu.gtceu.client.mui.screen.ModularPanel;
import com.gregtechceu.gtceu.client.mui.screen.UISettings;
import com.gregtechceu.gtceu.common.data.GTRecipeTypes;
import com.gregtechceu.gtceu.common.data.mui.GTMuiMachineUtil;
import com.gregtechceu.gtceu.common.data.mui.GTMuiWidgets;
import com.gregtechceu.gtceu.common.item.PortableScannerBehavior;
import com.gregtechceu.gtceu.common.machine.multiblock.electric.research.DataBankMachine;
import com.gregtechceu.gtceu.common.mui.GTGuiTextures;
import com.gregtechceu.gtceu.common.recipe.condition.ResearchCondition;
import com.gregtechceu.gtceu.syncsystem.annotations.SaveField;
import com.gregtechceu.gtceu.utils.ItemStackHashStrategy;
Expand All @@ -50,8 +52,6 @@

import javax.annotation.ParametersAreNonnullByDefault;

import static com.gregtechceu.gtceu.common.data.mui.GTMuiMachineUtil.createSquareSlotGroupFromInventory;

@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault
public class DataAccessHatchMachine extends TieredPartMachine
Expand Down Expand Up @@ -98,6 +98,10 @@ public ItemStack insertItem(int slot, @NotNull ItemStack stack, boolean simulate
@NotNull UISettings settings) {
int size = (int) Math.sqrt(getInventorySize());

var grid = GTMuiMachineUtil.createSlotGroupFromInventory(importItems, "data_inventory", getInventorySize(), 'I',
i -> i.background(GTGuiTextures.SLOT, GTGuiTextures.DATA_ORB_OVERLAY), syncManager,
GTMuiMachineUtil.createSquareMatrix(importItems.getSlots(), 'I'));

return new ModularPanel(this.getDefinition().getName())
.size(176, 100 + (18 * size))
.child(GTMuiWidgets.createTitleBar(this.getDefinition(), 176))
Expand All @@ -108,7 +112,7 @@ public ItemStack insertItem(int slot, @NotNull ItemStack stack, boolean simulate
.crossAxisAlignment(Alignment.CrossAxis.CENTER)
.align(Alignment.CENTER)
.coverChildren()
.child(createSquareSlotGroupFromInventory(importItems, "data_inventory", syncManager)
.child(grid
.marginLeft(30)
.marginRight(30)
.verticalCenter())))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
import com.gregtechceu.gtceu.api.machine.trait.NotifiableFluidTank;
import com.gregtechceu.gtceu.api.machine.trait.NotifiableItemStackHandler;
import com.gregtechceu.gtceu.api.mui.base.drawable.IKey;
import com.gregtechceu.gtceu.api.mui.drawable.UITexture;
import com.gregtechceu.gtceu.api.mui.factory.PosGuiData;
import com.gregtechceu.gtceu.api.mui.theme.ThemeAPI;
import com.gregtechceu.gtceu.api.mui.utils.Alignment;
import com.gregtechceu.gtceu.api.mui.value.sync.BooleanSyncValue;
import com.gregtechceu.gtceu.api.mui.value.sync.FluidSlotSyncHandler;
Expand All @@ -22,6 +24,7 @@
import com.gregtechceu.gtceu.api.mui.widgets.ToggleButton;
import com.gregtechceu.gtceu.api.mui.widgets.layout.Column;
import com.gregtechceu.gtceu.api.mui.widgets.layout.Flow;
import com.gregtechceu.gtceu.api.mui.widgets.layout.Row;
import com.gregtechceu.gtceu.api.mui.widgets.slot.FluidSlot;
import com.gregtechceu.gtceu.client.mui.screen.ModularPanel;
import com.gregtechceu.gtceu.client.mui.screen.UISettings;
Expand All @@ -30,9 +33,11 @@
import com.gregtechceu.gtceu.common.data.mui.GTMuiWidgets;
import com.gregtechceu.gtceu.common.item.IntCircuitBehaviour;
import com.gregtechceu.gtceu.common.mui.GTGuiTextures;
import com.gregtechceu.gtceu.common.mui.GTGuis;
import com.gregtechceu.gtceu.config.ConfigHolder;
import com.gregtechceu.gtceu.syncsystem.annotations.SaveField;
import com.gregtechceu.gtceu.syncsystem.annotations.SyncToClient;
import com.gregtechceu.gtceu.utils.FormattingUtil;
import com.gregtechceu.gtceu.utils.GTTransferUtils;
import com.gregtechceu.gtceu.utils.ISubscription;

Expand Down Expand Up @@ -270,26 +275,13 @@ public boolean swapIO() {
}

private Component getFluidNameText() {
Component translation;
if (!this.tank.getFluidInTank(0).isEmpty()) {
translation = this.tank.getFluidInTank(0).getDisplayName();
} else {
translation = this.tank.getLockedFluid().getFluid().getDisplayName();
}
return translation;
return this.tank.getFluidInTank(0).isEmpty() ?
Component.translatable("gtceu.fluid.empty") :
this.tank.getFluidInTank(0).getDisplayName();
}

private String getFluidAmountText() {
String fluidAmount = "";
if (!tank.getFluidInTank(0).isEmpty()) {
fluidAmount = getFormattedFluidAmount(tank.getFluidInTank(0));
} else {
// Display Zero to show information about the locked fluid
if (!this.tank.getLockedFluid().getFluid().isEmpty()) {
fluidAmount = "0";
}
}
return fluidAmount;
private Component getFluidAmountText() {
return Component.literal(FormattingUtil.formatBuckets(this.tank.getFluidInTank(0).getAmount()));
}

private Component getFluidText() {
Expand All @@ -302,52 +294,79 @@ public String getFormattedFluidAmount(FluidStack fluidStack) {

@Override
public ModularPanel buildUI(PosGuiData data, PanelSyncManager syncManager, UISettings settings) {
return new ModularPanel(getDefinition().getName())
.child(GTMuiWidgets.createTitleBar(getDefinition(), 174))
.bindPlayerInventory()
int width = 176;
int height = Math.max(168, (int) (18 * Math.sqrt(slots)) + 78 + 19);
var panel = GTGuis.createPanel(this, width, height);

// magic numbers are me favorite :3
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⸜(。˃ ᵕ ˂ )⸝♡

int topOffset = slots == 1 ? 10 : slots == 9 ? 16 : 20;

var theme = this.getDefinition().getThemeId();
var backgroundTexture = (UITexture) ThemeAPI.INSTANCE.getTheme(theme).getPanelTheme().getTheme()
.getBackground();
if (backgroundTexture == null) {
backgroundTexture = GTGuiTextures.BACKGROUND;
}

panel.child(GTMuiWidgets.createTitleBar(getDefinition(), 174))
.child(SlotGroupWidget.playerInventory(true)
.left(7)
.bottom(7))
.child((slots == 1 ? createSingleSlotUI(syncManager) : createMultiSlotUI(syncManager))
.marginBottom(91)
.center())
.top(topOffset)
.horizontalCenter())
.child(new Column()
.coverChildren()
.leftRel(1.0f)
.rightRel(1.0f)
.reverseLayout(true)
.bottom(16)
.padding(0, 8, 4, 4)
.padding(8, 0, 4, 4)
.childPadding(2)
.background(backgroundTexture.getSubArea(0.0f, 0f, 0.75f, 1.0f))
.excludeAreaInXei()
.background(GTGuiTextures.BACKGROUND.getSubArea(0.25f, 0f, 1.0f, 1.0f))
.child(GTMuiWidgets.createPowerButton(this::isWorkingEnabled, this::setWorkingEnabled,
syncManager)));
syncManager))
.childIf(this.isCircuitSlotEnabled(),
() -> GTMuiWidgets.createCircuitSlotPanel(this, panel, syncManager)));

return panel;
}

protected Flow createSingleSlotUI(PanelSyncManager syncManager) {
return Flow.row()
.coverChildrenHeight()
BooleanSyncValue locked = new BooleanSyncValue(this.tank::isLocked, this.tank::setLocked);
syncManager.syncValue("locked", locked);
return new Column()
.widthRel(.6f)
.background(GTGuiTextures.DISPLAY)
.padding(5)
.childPadding(5)
.crossAxisAlignment(Alignment.CrossAxis.START)
.child(new TextWidget<>(IKey.dynamic(this::getFluidText)))
.child(Flow.column()
.alignX(1f)
.height(60)
.mainAxisAlignment(Alignment.MainAxis.CENTER)
.childPadding(4)
.child(new TextWidget<>(IKey.dynamic(this::getFluidNameText))
.horizontalCenter())
.child(new TextWidget<>(IKey.dynamic(this::getFluidAmountText))
.horizontalCenter())
.child(new Row()
.childPadding(2)
.coverChildren()
.childIf(io.support(IO.OUT), new FluidSlot()
.syncHandler(new FluidSlotSyncHandler(tank.getLockedFluid())
.phantom(true)
.controlsAmount(false)))
.childIf(io.support(IO.OUT), new ToggleButton()
.value(new BooleanSyncValue(tank::isLocked, tank::setLocked))
.background(GTGuiTextures.MC_BUTTON, GTGuiTextures.BUTTON_LOCK)
.hoverBackground(GTGuiTextures.MC_BUTTON_HOVERED, GTGuiTextures.BUTTON_LOCK)
.selectedBackground(GTGuiTextures.MC_BUTTON_PRESSED, GTGuiTextures.BUTTON_LOCK)
.selectedHoverBackground(GTGuiTextures.MC_BUTTON_HOVERED_PRESSED,
GTGuiTextures.BUTTON_LOCK))
.childIf(io.support(IO.OUT), () -> new FluidSlot()
.name("lockedFluid")
.syncHandler(new FluidSlotSyncHandler(tank.getLockedFluid()))
.alwaysShowFull(true)
.displayAmount(true)
.tooltip(t -> t.addLine("Locked Fluid")))
.childIf(io.support(IO.OUT), () -> new ToggleButton()
.syncHandler("locked")
.tooltip(t -> t.addLine("gtceu.gui.fluid_lock.tooltip"))
.overlay(false, GTGuiTextures.BUTTON_LOCK)
.overlay(true, GTGuiTextures.BUTTON_LOCK)
.background(GTGuiTextures.MC_BUTTON)
.selectedBackground(GTGuiTextures.MC_BUTTON_PRESSED)

)
.child(new FluidSlot()
.name("regularFluid")
.syncHandler(new FluidSlotSyncHandler(tank.getStorages()[0])
.canFillSlot(io.support(IO.IN)))));
.canFillSlot(io.support(IO.IN)))
.displayAmount(true)));
}

protected SlotGroupWidget createMultiSlotUI(PanelSyncManager syncManager) {
Expand Down
Loading
Loading