Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
fb7b8b1
initial work on adv energy detector
ghzdude Jan 11, 2025
f615a18
move ui method to CoverDetectorBase
ghzdude Jan 13, 2025
c2bc860
port advanced item
ghzdude Jan 13, 2025
b20cfc2
improve post fix rendering
ghzdude Jan 13, 2025
21df8e7
port advanced fluid detector
ghzdude Jan 13, 2025
cb10a24
forgor filter ui
ghzdude Jan 13, 2025
f56fc49
move filter into column
ghzdude Jan 13, 2025
68eda2e
actually sync isInverted
ghzdude Jan 13, 2025
411052d
fix compile and rebase
ghzdude Jun 13, 2025
2fecca8
use default number and add setter method
ghzdude Jun 13, 2025
fe5707b
fix textfield widgets being too tall
ghzdude Oct 24, 2025
7d4b255
cleanup + spotless
ghzdude Oct 24, 2025
9d57591
add todo
ghzdude Oct 24, 2025
e82a5eb
port digital interface
ghzdude Oct 24, 2025
54df137
make slot text field editable
ghzdude Oct 25, 2025
76e71ee
try improve ender fluid security
ghzdude Oct 29, 2025
90a4e1f
delete unused method
ghzdude Oct 29, 2025
599f22d
keep values proportional instead of resetting on switching modes
ghzdude Nov 9, 2025
8a3d514
fix rebase
ghzdude Nov 17, 2025
603ea75
fix GTTextFieldWidget and use again
ghzdude Nov 17, 2025
8487d25
clamp values when switching modes
ghzdude Nov 17, 2025
8047f88
do not attach for creative emitter
ghzdude Nov 17, 2025
6b76e4b
fix unit overwrite and redundant method call
ghzdude Nov 17, 2025
778996a
return the creative handler(s) in capability directly
ghzdude Nov 17, 2025
7b4f75d
delete deprecated ui code/classes
ghzdude Nov 17, 2025
7447983
improve latch tooltip
ghzdude Nov 17, 2025
80eec6c
fix incorrect postfix
ghzdude Nov 17, 2025
4fa7784
add missing long method to GTTextFieldWidget
ghzdude Nov 17, 2025
0f1bfb3
delete unused method
ghzdude Nov 17, 2025
c869979
replace anonymous class with GTTextFieldWidget
ghzdude Nov 17, 2025
f92b357
delete deprecated filter ui code
ghzdude Nov 17, 2025
93a29cc
make panel handler based on stack translation key
ghzdude Nov 17, 2025
afbfeef
nvm, that doesn't work
ghzdude Nov 17, 2025
ac69d8f
brachy is gonna hate this
ghzdude Nov 17, 2025
733d825
add todo
ghzdude Nov 17, 2025
bb6a4ce
clean up a bit
ghzdude Nov 17, 2025
9f39747
use predicate
ghzdude Nov 18, 2025
e2e8b82
fix cover filters not saving and syncing allowFlow
ghzdude Nov 23, 2025
78b200b
todo
ghzdude Nov 24, 2025
2fe7a4e
spotless?
ghzdude Nov 24, 2025
8dd76cb
properly support long counts for items and fluids
ghzdude Nov 25, 2025
6d7cf81
replace dynamic drawables with supplier lang key
ghzdude Nov 30, 2025
d2aa861
use flow as return type
ghzdude Nov 30, 2025
93d5038
use throughput directly as value
ghzdude Nov 30, 2025
8dd1b37
spotless
ghzdude Nov 30, 2025
bf5ede2
add CoverUIFactory back and mark for removal
ghzdude Dec 2, 2025
c52eaad
make item/fluid detectors unplaceable on creative chest/tank
ghzdude Dec 2, 2025
099672b
drain and fill at the same time for our phantom fluid slots
ghzdude Dec 2, 2025
5a1f596
use default values when energy capacity is zero
ghzdude Dec 2, 2025
a87782c
deserialize legacy int min and max
ghzdude Dec 2, 2025
34b9bda
use passed in name for error panel
ghzdude Dec 2, 2025
564d328
simplify lang key overlay
ghzdude Dec 2, 2025
52cdca5
add color to the numbers
ghzdude Dec 2, 2025
3f4db58
don't handle stack tag in constructor
ghzdude Dec 3, 2025
9ae8103
really
ghzdude Dec 3, 2025
1caad4e
not sponsored by AMD™
ghzdude Dec 3, 2025
354908b
i accidentally the parenthesis
ghzdude Dec 9, 2025
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
3 changes: 3 additions & 0 deletions src/main/java/gregtech/api/cover/CoverUIFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;

import org.jetbrains.annotations.ApiStatus;

@Deprecated
@ApiStatus.ScheduledForRemoval(inVersion = "2.10")
public final class CoverUIFactory extends UIFactory<CoverWithUI> {

public static final CoverUIFactory INSTANCE = new CoverUIFactory();
Expand Down
30 changes: 23 additions & 7 deletions src/main/java/gregtech/api/cover/CoverWithUI.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package gregtech.api.cover;

import gregtech.api.gui.IUIHolder;
import gregtech.api.gui.ModularUI;
import gregtech.api.mui.GTGuiTextures;
import gregtech.api.mui.GTGuiTheme;
import gregtech.api.mui.GregTechGuiScreen;
Expand All @@ -17,6 +15,7 @@
import com.cleanroommc.modularui.api.IGuiHolder;
import com.cleanroommc.modularui.api.drawable.IDrawable;
import com.cleanroommc.modularui.api.drawable.IKey;
import com.cleanroommc.modularui.drawable.DynamicDrawable;
import com.cleanroommc.modularui.drawable.ItemDrawable;
import com.cleanroommc.modularui.factory.SidedPosGuiData;
import com.cleanroommc.modularui.screen.ModularPanel;
Expand All @@ -30,30 +29,36 @@
import com.cleanroommc.modularui.value.sync.IntSyncValue;
import com.cleanroommc.modularui.value.sync.PanelSyncManager;
import com.cleanroommc.modularui.widget.ParentWidget;
import com.cleanroommc.modularui.widget.Widget;
import com.cleanroommc.modularui.widgets.ToggleButton;
import com.cleanroommc.modularui.widgets.layout.Flow;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;

import java.util.function.BooleanSupplier;
import java.util.function.Supplier;

public interface CoverWithUI extends Cover, IUIHolder, IGuiHolder<SidedPosGuiData> {
public interface CoverWithUI extends Cover, IGuiHolder<SidedPosGuiData>, gregtech.api.gui.IUIHolder {

@ApiStatus.Experimental
default boolean usesMui2() {
return false;
// this is gonna cause problems if implementing classes expect this to be false
// all of our covers use mui2 though
return true;
}

default void openUI(EntityPlayerMP player) {
if (usesMui2()) {
CoverGuiFactory.open(player, this);
} else {
// todo remove in 2.10
CoverUIFactory.INSTANCE.openUI(this, player);
}
}

@Deprecated
default ModularUI createUI(EntityPlayer player) {
@ApiStatus.ScheduledForRemoval(inVersion = "2.10")
default gregtech.api.gui.ModularUI createUI(EntityPlayer player) {
return null;
}

Expand Down Expand Up @@ -104,11 +109,22 @@ default void markAsDirty() {
* Create the Title bar widget for a Cover.
*/
static Flow createTitleRow(ItemStack stack) {
return createTitleRow(() -> stack);
}

/**
* Create the Title bar widget for a Cover.
*/
static Flow createTitleRow(Supplier<ItemStack> stack) {
ItemDrawable itemDrawable = new ItemDrawable();
return Flow.row()
.pos(4, 4)
.height(16).coverChildrenWidth()
.child(new ItemDrawable(stack).asWidget().size(16).marginRight(4))
.child(IKey.str(stack.getDisplayName())
.child(new Widget<>()
.overlay(new DynamicDrawable(() -> itemDrawable.setItem(stack.get())))
.size(16)
.marginRight(4))
.child(IKey.dynamic(() -> stack.get().getDisplayName())
Copy link
Contributor

Choose a reason for hiding this comment

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

Does the name need to be dynamic? The only case I can think of for this is changing langs, but you have to close the UI to do that so the UI would get rebuilt with the correct lang even if it was not dynamic right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this was part of my attempts to fix the filter popup panel before settling with the current solution

since the panel is only built once, it needs to update based on what's in the filter slot, therefore it needs a supplier

i could revert this change, though i'd probably add it back later in a different pr

.color(UI_TITLE_COLOR)
.asWidget().heightRel(1.0f));
}
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/gregtech/api/mui/GTGuiTextures.java
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,22 @@ private static String id(String path) {
public static final UITexture RESEARCH_STATION_OVERLAY = fullImage(
"textures/gui/overlay/research_station_overlay.png", ColorType.DEFAULT);

// Texture Areas
public static final UITexture[] BUTTON_FLUID = slice("textures/blocks/cover/cover_interface_fluid_button.png", 18,
36, null);
public static final UITexture[] BUTTON_ITEM = slice("textures/blocks/cover/cover_interface_item_button.png", 18, 36,
null);
public static final UITexture[] BUTTON_ENERGY = slice("textures/blocks/cover/cover_interface_energy_button.png", 18,
36, null);
public static final UITexture[] BUTTON_MACHINE = slice("textures/blocks/cover/cover_interface_machine_button.png",
18, 36, null);
public static final UITexture[] BUTTON_INTERFACE = slice(
"textures/blocks/cover/cover_interface_computer_button.png", 18, 36, null);
public static final UITexture COVER_INTERFACE_MACHINE_ON_PROXY = fullImage(
"textures/blocks/cover/cover_interface_machine_on_proxy.png");
public static final UITexture COVER_INTERFACE_MACHINE_OFF_PROXY = fullImage(
"textures/blocks/cover/cover_interface_machine_off_proxy.png");

// BUTTONS

public static final UITexture BUTTON = new UITexture.Builder()
Expand Down
35 changes: 18 additions & 17 deletions src/main/java/gregtech/api/mui/sync/GTFluidSyncHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,8 @@ public void handleClick(MouseData data) {
public void readOnServer(int id, PacketBuffer buf) {
if (id == TRY_CLICK_CONTAINER) {
var data = MouseData.readPacket(buf);
if (canLockFluid())
toggleLockFluid();
if (isPhantom()) {
tryClickPhantom(data);
} else {
Expand All @@ -316,14 +318,6 @@ public void readOnServer(int id, PacketBuffer buf) {
setFluid(fluid);
} else if (id == PHANTOM_SCROLL) {
tryScrollPhantom(MouseData.readPacket(buf));
} else if (id == LOCK_FLUID) {
boolean locked = buf.readBoolean();
var fluidStack = NetworkUtils.readFluidStack(buf);
if (fluidStack == null) {
this.lockHandler.accept(locked);
} else {
this.jeiHandler.accept(fluidStack);
}
}
}

Expand All @@ -341,19 +335,26 @@ public void tryClickPhantom(MouseData data) {
}
} else {
FluidStack cellFluid = fluidHandlerItem.drain(Integer.MAX_VALUE, false);
if ((this.showAmountOnSlot.getAsBoolean() || currentFluid == null) && cellFluid != null) {
if (!GTUtility.areFluidStacksEqual(cellFluid, currentFluid)) {

// drain existing
if (this.canDrainSlot()) {
int amt = data.shift ? Integer.MAX_VALUE : 1000;
this.tank.drain(amt, true);
}

// then fill
if (this.canFillSlot()) {
if (!this.showAmountOnSlot.getAsBoolean()) {
cellFluid.amount = 1;
FluidStack fill;
if (this.showAmountOnSlot.getAsBoolean() && !GTUtility.isEmpty(cellFluid)) {
fill = GTUtility.copy(cellFluid);
} else {
fill = GTUtility.copy(1, cellFluid);
}
if (this.tank.fill(cellFluid, true) > 0) {
this.phantomFluid = cellFluid.copy();
if (fill == null || this.tank.fill(fill, true) > 0) {
this.phantomFluid = fill;
}
}
} else {
if (this.canDrainSlot()) {
this.tank.drain(data.shift ? Integer.MAX_VALUE : 1000, true);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import net.minecraft.world.World;
import net.minecraft.world.storage.MapStorage;
import net.minecraft.world.storage.WorldSavedData;
import net.minecraftforge.fluids.IFluidTank;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -91,18 +90,6 @@ private static VirtualRegistryMap getRegistry(UUID owner) {
return VIRTUAL_REGISTRIES.computeIfAbsent(owner, key -> new VirtualRegistryMap());
}

// remove if tank app is removed
public static Map<UUID, Map<String, IFluidTank>> createTankMap() {
Map<UUID, Map<String, IFluidTank>> map = new HashMap<>();
for (var uuid : VIRTUAL_REGISTRIES.keySet()) {
map.put(uuid, new HashMap<>());
for (var name : getEntryNames(uuid, EntryTypes.ENDER_FLUID)) {
map.get(uuid).put(name, getEntry(uuid, EntryTypes.ENDER_FLUID, name));
}
}
return map;
}

@Override
public final void readFromNBT(NBTTagCompound nbt) {
if (nbt.hasKey(PUBLIC_KEY)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
Expand Down Expand Up @@ -49,7 +50,7 @@ public void clear() {
}

public Set<String> getEntryNames(EntryTypes<?> type) {
return registryMap.get(type).keySet();
return registryMap.getOrDefault(type, Collections.emptyMap()).keySet();
}

@Override
Expand Down
20 changes: 5 additions & 15 deletions src/main/java/gregtech/common/covers/CoverConveyor.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import gregtech.client.renderer.texture.Textures;
import gregtech.client.renderer.texture.cube.SimpleSidedCubeRenderer;
import gregtech.common.covers.filter.ItemFilterContainer;
import gregtech.common.mui.widget.GTTextFieldWidget;
import gregtech.common.pipelike.itempipe.tile.TileEntityItemPipe;

import net.minecraft.client.renderer.texture.TextureAtlasSprite;
Expand Down Expand Up @@ -53,11 +54,8 @@
import com.cleanroommc.modularui.value.sync.EnumSyncValue;
import com.cleanroommc.modularui.value.sync.IntSyncValue;
import com.cleanroommc.modularui.value.sync.PanelSyncManager;
import com.cleanroommc.modularui.value.sync.StringSyncValue;
import com.cleanroommc.modularui.widget.ParentWidget;
import com.cleanroommc.modularui.widgets.ButtonWidget;
import com.cleanroommc.modularui.widgets.layout.Flow;
import com.cleanroommc.modularui.widgets.textfield.TextFieldWidget;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntList;
Expand Down Expand Up @@ -498,11 +496,6 @@ public <T> T getCapability(Capability<T> capability, T defaultValue) {
return defaultValue;
}

@Override
public boolean usesMui2() {
return true;
}

@Override
public ModularPanel buildUI(SidedPosGuiData guiData, PanelSyncManager guiSyncManager, UISettings settings) {
var panel = GTGuis.createPanel(this, 176, 192 + 18);
Expand All @@ -514,7 +507,7 @@ public ModularPanel buildUI(SidedPosGuiData guiData, PanelSyncManager guiSyncMan
.bindPlayerInventory();
}

protected ParentWidget<Flow> createUI(GuiData data, PanelSyncManager guiSyncManager) {
protected Flow createUI(GuiData data, PanelSyncManager guiSyncManager) {
var column = Flow.column().top(24).margin(7, 0)
.widthRel(1f).coverChildrenHeight();

Expand All @@ -526,16 +519,12 @@ protected ParentWidget<Flow> createUI(GuiData data, PanelSyncManager guiSyncMana

IntSyncValue throughput = new IntSyncValue(this::getTransferRate, this::setTransferRate);

StringSyncValue formattedThroughput = new StringSyncValue(throughput::getStringValue,
throughput::setStringValue);

EnumSyncValue<DistributionMode> distributionMode = new EnumSyncValue<>(DistributionMode.class,
this::getDistributionMode, this::setDistributionMode);

guiSyncManager.syncValue("manual_io", manualIOmode);
guiSyncManager.syncValue("conveyor_mode", conveyorMode);
guiSyncManager.syncValue("distribution_mode", distributionMode);
guiSyncManager.syncValue("throughput", throughput);

if (createThroughputRow())
column.child(Flow.row().coverChildrenHeight()
Expand All @@ -548,11 +537,12 @@ protected ParentWidget<Flow> createUI(GuiData data, PanelSyncManager guiSyncMana
return true;
})
.onUpdateListener(w -> w.overlay(createAdjustOverlay(false))))
.child(new TextFieldWidget()
.child(new GTTextFieldWidget()
.left(18).right(18)
.setPostFix(" items/s")
.setTextColor(Color.WHITE.darker(1))
.setNumbers(1, maxItemTransferRate)
.value(formattedThroughput)
.value(throughput)
.background(GTGuiTextures.DISPLAY))
.child(new ButtonWidget<>()
.right(0).width(18)
Expand Down
Loading
Loading