Skip to content

Commit a9851aa

Browse files
committed
Merge branch 'master' into zb/alarm-mui2
# Conflicts: # src/main/java/gregtech/common/covers/filter/BaseFilterContainer.java # src/main/java/gregtech/common/metatileentities/electric/MetaTileEntityItemCollector.java
2 parents acfd69d + c214f00 commit a9851aa

File tree

57 files changed

+1137
-893
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1137
-893
lines changed

src/main/java/gregtech/api/capability/impl/GTFluidHandlerItemStack.java

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -69,22 +69,11 @@ public IFluidTankProperties[] getTankProperties() {
6969
}
7070

7171
@Override
72-
public FluidStack drain(FluidStack resource, boolean doDrain) {
73-
FluidStack drained = super.drain(resource, doDrain);
74-
this.removeTagWhenEmpty(doDrain);
75-
return drained;
76-
}
77-
78-
@Override
79-
public FluidStack drain(int maxDrain, boolean doDrain) {
80-
FluidStack drained = super.drain(maxDrain, doDrain);
81-
this.removeTagWhenEmpty(doDrain);
82-
return drained;
83-
}
84-
85-
private void removeTagWhenEmpty(boolean doDrain) {
86-
if (doDrain && this.getFluid() == null) {
87-
this.container.setTagCompound(null);
72+
protected void setContainerToEmpty() {
73+
super.setContainerToEmpty();
74+
var tag = container.getTagCompound();
75+
if (tag != null && tag.isEmpty()) {
76+
container.setTagCompound(null);
8877
}
8978
}
9079

src/main/java/gregtech/api/capability/impl/GTSimpleFluidHandlerItemStack.java

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -68,26 +68,6 @@ public IFluidTankProperties[] getTankProperties() {
6868
return properties;
6969
}
7070

71-
@Override
72-
public FluidStack drain(FluidStack resource, boolean doDrain) {
73-
FluidStack drained = super.drain(resource, doDrain);
74-
this.removeTagWhenEmpty(doDrain);
75-
return drained;
76-
}
77-
78-
@Override
79-
public FluidStack drain(int maxDrain, boolean doDrain) {
80-
FluidStack drained = super.drain(maxDrain, doDrain);
81-
this.removeTagWhenEmpty(doDrain);
82-
return drained;
83-
}
84-
85-
private void removeTagWhenEmpty(boolean doDrain) {
86-
if (doDrain && this.getFluid() == null) {
87-
this.container.setTagCompound(null);
88-
}
89-
}
90-
9171
@Override
9272
public boolean canFillFluidType(FluidStack fluid) {
9373
return canFill() && (this.filter == null || this.filter.test(fluid));
@@ -98,6 +78,15 @@ public boolean canDrainFluidType(FluidStack fluid) {
9878
return canDrain();
9979
}
10080

81+
@Override
82+
protected void setContainerToEmpty() {
83+
super.setContainerToEmpty();
84+
var tag = container.getTagCompound();
85+
if (tag != null && tag.isEmpty()) {
86+
container.setTagCompound(null);
87+
}
88+
}
89+
10190
private final class TankProperties implements IFluidTankProperties {
10291

10392
@Nullable

src/main/java/gregtech/api/cover/CoverUIFactory.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313
import net.minecraft.util.EnumFacing;
1414
import net.minecraft.util.math.BlockPos;
1515

16+
import org.jetbrains.annotations.ApiStatus;
17+
1618
@Deprecated
19+
@ApiStatus.ScheduledForRemoval(inVersion = "2.10")
1720
public final class CoverUIFactory extends UIFactory<CoverWithUI> {
1821

1922
public static final CoverUIFactory INSTANCE = new CoverUIFactory();

src/main/java/gregtech/api/cover/CoverWithUI.java

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package gregtech.api.cover;
22

3-
import gregtech.api.gui.IUIHolder;
4-
import gregtech.api.gui.ModularUI;
53
import gregtech.api.mui.GTGuiTextures;
64
import gregtech.api.mui.GTGuiTheme;
75
import gregtech.api.mui.GregTechGuiScreen;
@@ -17,6 +15,7 @@
1715
import com.cleanroommc.modularui.api.IGuiHolder;
1816
import com.cleanroommc.modularui.api.drawable.IDrawable;
1917
import com.cleanroommc.modularui.api.drawable.IKey;
18+
import com.cleanroommc.modularui.drawable.DynamicDrawable;
2019
import com.cleanroommc.modularui.drawable.ItemDrawable;
2120
import com.cleanroommc.modularui.factory.SidedPosGuiData;
2221
import com.cleanroommc.modularui.screen.ModularPanel;
@@ -30,27 +29,36 @@
3029
import com.cleanroommc.modularui.value.sync.IntSyncValue;
3130
import com.cleanroommc.modularui.value.sync.PanelSyncManager;
3231
import com.cleanroommc.modularui.widget.ParentWidget;
32+
import com.cleanroommc.modularui.widget.Widget;
3333
import com.cleanroommc.modularui.widgets.ToggleButton;
3434
import com.cleanroommc.modularui.widgets.layout.Flow;
3535
import org.jetbrains.annotations.ApiStatus;
36+
import org.jetbrains.annotations.NotNull;
3637

37-
public interface CoverWithUI extends Cover, IUIHolder, IGuiHolder<SidedPosGuiData> {
38+
import java.util.function.BooleanSupplier;
39+
import java.util.function.Supplier;
40+
41+
public interface CoverWithUI extends Cover, IGuiHolder<SidedPosGuiData>, gregtech.api.gui.IUIHolder {
3842

3943
@ApiStatus.Experimental
4044
default boolean usesMui2() {
41-
return false;
45+
// this is gonna cause problems if implementing classes expect this to be false
46+
// all of our covers use mui2 though
47+
return true;
4248
}
4349

4450
default void openUI(EntityPlayerMP player) {
4551
if (usesMui2()) {
4652
CoverGuiFactory.open(player, this);
4753
} else {
54+
// todo remove in 2.10
4855
CoverUIFactory.INSTANCE.openUI(this, player);
4956
}
5057
}
5158

5259
@Deprecated
53-
default ModularUI createUI(EntityPlayer player) {
60+
@ApiStatus.ScheduledForRemoval(inVersion = "2.10")
61+
default gregtech.api.gui.ModularUI createUI(EntityPlayer player) {
5462
return null;
5563
}
5664

@@ -101,11 +109,22 @@ default void markAsDirty() {
101109
* Create the Title bar widget for a Cover.
102110
*/
103111
static Flow createTitleRow(ItemStack stack) {
112+
return createTitleRow(() -> stack);
113+
}
114+
115+
/**
116+
* Create the Title bar widget for a Cover.
117+
*/
118+
static Flow createTitleRow(Supplier<ItemStack> stack) {
119+
ItemDrawable itemDrawable = new ItemDrawable();
104120
return Flow.row()
105121
.pos(4, 4)
106122
.height(16).coverChildrenWidth()
107-
.child(new ItemDrawable(stack).asWidget().size(16).marginRight(4))
108-
.child(IKey.str(stack.getDisplayName())
123+
.child(new Widget<>()
124+
.overlay(new DynamicDrawable(() -> itemDrawable.setItem(stack.get())))
125+
.size(16)
126+
.marginRight(4))
127+
.child(IKey.dynamic(() -> stack.get().getDisplayName())
109128
.color(UI_TITLE_COLOR)
110129
.asWidget().heightRel(1.0f));
111130
}
@@ -117,6 +136,18 @@ default ParentWidget<?> createSettingsRow() {
117136
return new ParentWidget<>().height(16).widthRel(1.0f).marginBottom(2);
118137
}
119138

139+
/**
140+
* Create a dynamic lang key that switches between {@code cover.generic.enabled} and {@code cover.generic.disabled}
141+
* depending on the result of the given boolean supplier. <br/>
142+
*
143+
* @param keyBase the base of the lang key to use. {@code .enabled} and {@code .disabled} will be appended.
144+
*/
145+
default IKey createEnabledKey(@NotNull String keyBase, @NotNull BooleanSupplier enabledState) {
146+
String enabled = keyBase + ".enabled";
147+
String disabled = keyBase + ".disabled";
148+
return IKey.lang(() -> enabledState.getAsBoolean() ? enabled : disabled);
149+
}
150+
120151
default int getIncrementValue(MouseData data) {
121152
int adjust = 1;
122153
if (data.shift) adjust *= 4;

src/main/java/gregtech/api/items/toolitem/ItemGTToolbelt.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,14 @@ public boolean shouldCauseReequipAnimation(@NotNull ItemStack oldStack, @NotNull
279279
return false;
280280
}
281281

282+
@Override
283+
public int getMetadata(ItemStack stack) {
284+
ItemStack selected = getHandler(stack).getSelectedStack();
285+
if (!selected.isEmpty()) {
286+
return selected.getItem().getMetadata(selected);
287+
} else return super.getMetadata(stack);
288+
}
289+
282290
@Override
283291
public boolean isDamaged(@NotNull ItemStack stack) {
284292
ItemStack selected = getHandler(stack).getSelectedStack();

src/main/java/gregtech/api/metatileentity/multiblock/MultiblockControllerBase.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,8 @@ private List<MultiblockShapeInfo> repetitionDFS(List<MultiblockShapeInfo> pages,
600600

601601
@SideOnly(Side.CLIENT)
602602
public String[] getDescription() {
603-
String key = String.format("gregtech.multiblock.%s.description", metaTileEntityId.getPath());
603+
String key = String.format("%s.multiblock.%s.description", metaTileEntityId.getNamespace(),
604+
metaTileEntityId.getPath());
604605
return I18n.hasKey(key) ? new String[] { I18n.format(key) } : new String[0];
605606
}
606607

src/main/java/gregtech/api/mui/GTGuiTextures.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,22 @@ private static String id(String path) {
459459
public static final UITexture RESEARCH_STATION_OVERLAY = fullImage(
460460
"textures/gui/overlay/research_station_overlay.png", ColorType.DEFAULT);
461461

462+
// Texture Areas
463+
public static final UITexture[] BUTTON_FLUID = slice("textures/blocks/cover/cover_interface_fluid_button.png", 18,
464+
36, null);
465+
public static final UITexture[] BUTTON_ITEM = slice("textures/blocks/cover/cover_interface_item_button.png", 18, 36,
466+
null);
467+
public static final UITexture[] BUTTON_ENERGY = slice("textures/blocks/cover/cover_interface_energy_button.png", 18,
468+
36, null);
469+
public static final UITexture[] BUTTON_MACHINE = slice("textures/blocks/cover/cover_interface_machine_button.png",
470+
18, 36, null);
471+
public static final UITexture[] BUTTON_INTERFACE = slice(
472+
"textures/blocks/cover/cover_interface_computer_button.png", 18, 36, null);
473+
public static final UITexture COVER_INTERFACE_MACHINE_ON_PROXY = fullImage(
474+
"textures/blocks/cover/cover_interface_machine_on_proxy.png");
475+
public static final UITexture COVER_INTERFACE_MACHINE_OFF_PROXY = fullImage(
476+
"textures/blocks/cover/cover_interface_machine_off_proxy.png");
477+
462478
// BUTTONS
463479

464480
public static final UITexture BUTTON = new UITexture.Builder()

src/main/java/gregtech/api/mui/sync/GTFluidSyncHandler.java

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,8 @@ public void handleClick(MouseData data) {
304304
public void readOnServer(int id, PacketBuffer buf) {
305305
if (id == TRY_CLICK_CONTAINER) {
306306
var data = MouseData.readPacket(buf);
307+
if (canLockFluid())
308+
toggleLockFluid();
307309
if (isPhantom()) {
308310
tryClickPhantom(data);
309311
} else {
@@ -316,14 +318,6 @@ public void readOnServer(int id, PacketBuffer buf) {
316318
setFluid(fluid);
317319
} else if (id == PHANTOM_SCROLL) {
318320
tryScrollPhantom(MouseData.readPacket(buf));
319-
} else if (id == LOCK_FLUID) {
320-
boolean locked = buf.readBoolean();
321-
var fluidStack = NetworkUtils.readFluidStack(buf);
322-
if (fluidStack == null) {
323-
this.lockHandler.accept(locked);
324-
} else {
325-
this.jeiHandler.accept(fluidStack);
326-
}
327321
}
328322
}
329323

@@ -341,19 +335,26 @@ public void tryClickPhantom(MouseData data) {
341335
}
342336
} else {
343337
FluidStack cellFluid = fluidHandlerItem.drain(Integer.MAX_VALUE, false);
344-
if ((this.showAmountOnSlot.getAsBoolean() || currentFluid == null) && cellFluid != null) {
338+
if (!GTUtility.areFluidStacksEqual(cellFluid, currentFluid)) {
339+
340+
// drain existing
341+
if (this.canDrainSlot()) {
342+
int amt = data.shift ? Integer.MAX_VALUE : 1000;
343+
this.tank.drain(amt, true);
344+
}
345+
346+
// then fill
345347
if (this.canFillSlot()) {
346-
if (!this.showAmountOnSlot.getAsBoolean()) {
347-
cellFluid.amount = 1;
348+
FluidStack fill;
349+
if (this.showAmountOnSlot.getAsBoolean() && !GTUtility.isEmpty(cellFluid)) {
350+
fill = GTUtility.copy(cellFluid);
351+
} else {
352+
fill = GTUtility.copy(1, cellFluid);
348353
}
349-
if (this.tank.fill(cellFluid, true) > 0) {
350-
this.phantomFluid = cellFluid.copy();
354+
if (fill == null || this.tank.fill(fill, true) > 0) {
355+
this.phantomFluid = fill;
351356
}
352357
}
353-
} else {
354-
if (this.canDrainSlot()) {
355-
this.tank.drain(data.shift ? Integer.MAX_VALUE : 1000, true);
356-
}
357358
}
358359
}
359360
}

src/main/java/gregtech/api/util/CapesRegistry.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,20 @@ public static void registerDevCapes() {
5959
unlockCape(UUID.fromString("e6e784af-bd04-46ad-8141-47b8b9102cb9"), Textures.GREGTECH_CAPE_TEXTURE); // Tictim
6060
unlockCape(UUID.fromString("2fa297a6-7803-4629-8360-7059155cf43e"), Textures.GREGTECH_CAPE_TEXTURE); // KilaBash
6161
unlockCape(UUID.fromString("56bd41d0-06ef-4ed7-ab48-926ce45651f9"), Textures.GREGTECH_CAPE_TEXTURE); // Zalgo239
62+
unlockCape(UUID.fromString("2c69579f-a7fa-46ad-814e-9837e01215c1"), Textures.GREGTECH_CAPE_TEXTURE); // Z_orbatron
63+
unlockCape(UUID.fromString("3dbb689e-edcf-41b9-9c09-6ae4ebb6ca5b"), Textures.GREGTECH_CAPE_TEXTURE); // M_W_K
64+
65+
// GT:CEu Modern devs
66+
unlockCape(UUID.fromString("274846e6-1d07-4e59-8dea-f4f73e76f9fb"), Textures.GREGTECH_CAPE_TEXTURE); // DilithiumThoride
67+
unlockCape(UUID.fromString("c43b3c3d-7da6-4c2b-b335-703fce2ed795"), Textures.GREGTECH_CAPE_TEXTURE); // Ghostipedia
68+
unlockCape(UUID.fromString("fe4bafe8-8ea9-494a-b4e9-29397cea89fc"), Textures.GREGTECH_CAPE_TEXTURE); // Gustavo
69+
unlockCape(UUID.fromString("c18c1d7f-3174-42c6-81dc-3c7ff9f720c3"), Textures.GREGTECH_CAPE_TEXTURE); // jurrejelle
70+
unlockCape(UUID.fromString("29f1e04c-58d8-4a3b-9eff-f85be7825256"), Textures.GREGTECH_CAPE_TEXTURE); // kross000
71+
unlockCape(UUID.fromString("5cb66945-2ca4-498d-8c9a-29a676769363"), Textures.GREGTECH_CAPE_TEXTURE); // omergunr100
72+
unlockCape(UUID.fromString("f76fc8b3-ac6b-44b9-9023-76edaf3d5909"), Textures.GREGTECH_CAPE_TEXTURE); // spicierspace153
73+
unlockCape(UUID.fromString("24ab5496-0c9d-45d7-bfa6-c57760263be6"), Textures.GREGTECH_CAPE_TEXTURE); // TarLaboratories
74+
unlockCape(UUID.fromString("60057953-6a71-4f11-9e72-bb0c81fa0085"), Textures.GREGTECH_CAPE_TEXTURE); // ursamina
75+
unlockCape(UUID.fromString("3a27782d-6864-4814-a9fe-7c6931f29a8a"), Textures.GREGTECH_CAPE_TEXTURE); // YoungOnion
6276
save();
6377
}
6478

src/main/java/gregtech/api/util/virtualregistry/VirtualEnderRegistry.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import net.minecraft.world.World;
88
import net.minecraft.world.storage.MapStorage;
99
import net.minecraft.world.storage.WorldSavedData;
10-
import net.minecraftforge.fluids.IFluidTank;
1110

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

94-
// remove if tank app is removed
95-
public static Map<UUID, Map<String, IFluidTank>> createTankMap() {
96-
Map<UUID, Map<String, IFluidTank>> map = new HashMap<>();
97-
for (var uuid : VIRTUAL_REGISTRIES.keySet()) {
98-
map.put(uuid, new HashMap<>());
99-
for (var name : getEntryNames(uuid, EntryTypes.ENDER_FLUID)) {
100-
map.get(uuid).put(name, getEntry(uuid, EntryTypes.ENDER_FLUID, name));
101-
}
102-
}
103-
return map;
104-
}
105-
10693
@Override
10794
public final void readFromNBT(NBTTagCompound nbt) {
10895
if (nbt.hasKey(PUBLIC_KEY)) {

0 commit comments

Comments
 (0)