diff --git a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/ColorBlockWidget.java b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/ColorBlockWidget.java index 1d42cb6fcd..9814698421 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/ColorBlockWidget.java +++ b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/ColorBlockWidget.java @@ -2,12 +2,14 @@ import com.lowdragmc.lowdraglib.gui.util.DrawerHelper; import com.lowdragmc.lowdraglib.gui.widget.Widget; -import lombok.Getter; -import lombok.Setter; -import lombok.experimental.Accessors; + import net.minecraft.client.gui.GuiGraphics; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; + +import lombok.Getter; +import lombok.Setter; +import lombok.experimental.Accessors; import org.jetbrains.annotations.NotNull; import java.util.function.IntSupplier; @@ -15,6 +17,7 @@ @Setter @Accessors(chain = true) public class ColorBlockWidget extends Widget { + private IntSupplier colorSupplier; @Getter private int currentColor; diff --git a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/ConfirmTextInputWidget.java b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/ConfirmTextInputWidget.java index 87d4e9e906..a9ddc6b2cf 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/gui/widget/ConfirmTextInputWidget.java +++ b/src/main/java/com/gregtechceu/gtceu/api/gui/widget/ConfirmTextInputWidget.java @@ -1,10 +1,12 @@ package com.gregtechceu.gtceu.api.gui.widget; import com.gregtechceu.gtceu.api.gui.GuiTextures; + import com.lowdragmc.lowdraglib.gui.texture.GuiTextureGroup; import com.lowdragmc.lowdraglib.gui.widget.ButtonWidget; import com.lowdragmc.lowdraglib.gui.widget.TextFieldWidget; import com.lowdragmc.lowdraglib.gui.widget.WidgetGroup; + import lombok.AccessLevel; import lombok.Getter; import lombok.Setter; @@ -26,7 +28,8 @@ public class ConfirmTextInputWidget extends WidgetGroup { private String inputText = ""; private String hoverText = ""; - public ConfirmTextInputWidget(int x, int y, int width, int height, String text, Consumer textResponder, Function validator) { + public ConfirmTextInputWidget(int x, int y, int width, int height, String text, Consumer textResponder, + Function validator) { super(x, y, width, height); this.textResponder = textResponder; this.validator = validator; diff --git a/src/main/java/com/gregtechceu/gtceu/api/misc/virtualregistry/EntryTypes.java b/src/main/java/com/gregtechceu/gtceu/api/misc/virtualregistry/EntryTypes.java index 77c4afd17d..c2e3e3b560 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/misc/virtualregistry/EntryTypes.java +++ b/src/main/java/com/gregtechceu/gtceu/api/misc/virtualregistry/EntryTypes.java @@ -2,9 +2,11 @@ import com.gregtechceu.gtceu.GTCEu; import com.gregtechceu.gtceu.api.misc.virtualregistry.entries.VirtualTank; -import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; + import net.minecraft.nbt.CompoundTag; import net.minecraft.resources.ResourceLocation; + +import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; import org.jetbrains.annotations.Nullable; import java.util.Map; diff --git a/src/main/java/com/gregtechceu/gtceu/api/misc/virtualregistry/VirtualEnderRegistry.java b/src/main/java/com/gregtechceu/gtceu/api/misc/virtualregistry/VirtualEnderRegistry.java index e5ef9bef42..e38e3ef206 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/misc/virtualregistry/VirtualEnderRegistry.java +++ b/src/main/java/com/gregtechceu/gtceu/api/misc/virtualregistry/VirtualEnderRegistry.java @@ -1,9 +1,11 @@ package com.gregtechceu.gtceu.api.misc.virtualregistry; import com.gregtechceu.gtceu.GTCEu; + import net.minecraft.nbt.CompoundTag; import net.minecraft.world.level.saveddata.SavedData; import net.minecraftforge.server.ServerLifecycleHooks; + import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -14,14 +16,14 @@ import java.util.function.Predicate; public class VirtualEnderRegistry extends SavedData { + private static final String DATA_ID = GTCEu.MOD_ID + ".virtual_entry_data"; private static final String PUBLIC_KEY = "Public"; private static final String PRIVATE_KEY = "Private"; private static volatile VirtualEnderRegistry data; private final Map VIRTUAL_REGISTRIES = new HashMap<>(); - public VirtualEnderRegistry() { - } + public VirtualEnderRegistry() {} public VirtualEnderRegistry(CompoundTag name) { readFromNBT(name); @@ -84,7 +86,8 @@ public void deleteEntry(@Nullable UUID owner, EntryTypes type, String name) { owner == null ? "public" : String.format("private [%s]", owner), name, type); } - public void deleteEntryIf(@Nullable UUID owner, EntryTypes type, String name, Predicate shouldDelete) { + public void deleteEntryIf(@Nullable UUID owner, EntryTypes type, String name, + Predicate shouldDelete) { T entry = getEntry(owner, type, name); if (entry != null && shouldDelete.test(entry)) deleteEntry(owner, type, name); } diff --git a/src/main/java/com/gregtechceu/gtceu/api/misc/virtualregistry/VirtualEntry.java b/src/main/java/com/gregtechceu/gtceu/api/misc/virtualregistry/VirtualEntry.java index 57097e44e8..0c4cf56a9c 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/misc/virtualregistry/VirtualEntry.java +++ b/src/main/java/com/gregtechceu/gtceu/api/misc/virtualregistry/VirtualEntry.java @@ -1,8 +1,9 @@ package com.gregtechceu.gtceu.api.misc.virtualregistry; -import lombok.Getter; import net.minecraft.nbt.CompoundTag; import net.minecraftforge.common.util.INBTSerializable; + +import lombok.Getter; import org.jetbrains.annotations.NotNull; public abstract class VirtualEntry implements INBTSerializable { diff --git a/src/main/java/com/gregtechceu/gtceu/api/misc/virtualregistry/VirtualRegistryMap.java b/src/main/java/com/gregtechceu/gtceu/api/misc/virtualregistry/VirtualRegistryMap.java index 9d336ff6d5..af026dca63 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/misc/virtualregistry/VirtualRegistryMap.java +++ b/src/main/java/com/gregtechceu/gtceu/api/misc/virtualregistry/VirtualRegistryMap.java @@ -2,6 +2,7 @@ import net.minecraft.nbt.CompoundTag; import net.minecraftforge.common.util.INBTSerializable; + import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -12,10 +13,10 @@ import java.util.concurrent.ConcurrentHashMap; public class VirtualRegistryMap implements INBTSerializable { + private final Map, Map> registryMap = new ConcurrentHashMap<>(); - public VirtualRegistryMap() { - } + public VirtualRegistryMap() {} public VirtualRegistryMap(CompoundTag tag) { deserializeNBT(tag); @@ -68,9 +69,8 @@ public Set getEntryNames(EntryTypes type) { @Override public void deserializeNBT(CompoundTag nbt) { for (String entryTypeString : nbt.getAllKeys()) { - EntryTypes type = entryTypeString.contains(":") - ? EntryTypes.fromLocation(entryTypeString) - : EntryTypes.fromString(entryTypeString); + EntryTypes type = entryTypeString.contains(":") ? EntryTypes.fromLocation(entryTypeString) : + EntryTypes.fromString(entryTypeString); if (type == null) continue; diff --git a/src/main/java/com/gregtechceu/gtceu/api/misc/virtualregistry/entries/VirtualTank.java b/src/main/java/com/gregtechceu/gtceu/api/misc/virtualregistry/entries/VirtualTank.java index 3a4c6c1636..d89ff125e1 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/misc/virtualregistry/entries/VirtualTank.java +++ b/src/main/java/com/gregtechceu/gtceu/api/misc/virtualregistry/entries/VirtualTank.java @@ -2,15 +2,18 @@ import com.gregtechceu.gtceu.api.misc.virtualregistry.EntryTypes; import com.gregtechceu.gtceu.api.misc.virtualregistry.VirtualEntry; -import lombok.Setter; + import net.minecraft.nbt.CompoundTag; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidTank; import net.minecraftforge.fluids.capability.IFluidHandler; import net.minecraftforge.fluids.capability.templates.FluidTank; + +import lombok.Setter; import org.jetbrains.annotations.NotNull; public class VirtualTank extends VirtualEntry implements IFluidTank, IFluidHandler { + public static final int DEFAULT_CAPACITY = 64000; // 64B protected static final String CAPACITY_KEY = "capacity"; protected static final String FLUID_KEY = "fluid"; @@ -23,6 +26,7 @@ public class VirtualTank extends VirtualEntry implements IFluidTank, IFluidHandl public VirtualTank(int capacity) { this.capacity = capacity; fluidTank = new FluidTank(this.capacity) { + @Override protected void onContentsChanged() { super.onContentsChanged(); diff --git a/src/main/java/com/gregtechceu/gtceu/api/misc/virtualregistry/entries/VisualTank.java b/src/main/java/com/gregtechceu/gtceu/api/misc/virtualregistry/entries/VisualTank.java index 93dba6ad8f..84ae73fe7b 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/misc/virtualregistry/entries/VisualTank.java +++ b/src/main/java/com/gregtechceu/gtceu/api/misc/virtualregistry/entries/VisualTank.java @@ -1,15 +1,18 @@ package com.gregtechceu.gtceu.api.misc.virtualregistry.entries; import com.lowdragmc.lowdraglib.syncdata.ITagSerializable; -import lombok.Getter; -import lombok.Setter; -import lombok.experimental.Accessors; + import net.minecraft.nbt.CompoundTag; import net.minecraftforge.common.util.INBTSerializable; import net.minecraftforge.fluids.capability.templates.FluidTank; +import lombok.Getter; +import lombok.Setter; +import lombok.experimental.Accessors; + @Accessors(chain = true) public class VisualTank extends FluidTank implements INBTSerializable, ITagSerializable { + @Getter private VirtualTank virtualTank; @Setter diff --git a/src/main/java/com/gregtechceu/gtceu/common/cover/ender/CoverAbstractEnderLink.java b/src/main/java/com/gregtechceu/gtceu/common/cover/ender/CoverAbstractEnderLink.java index 8ccee0ae1c..de8fb4558d 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/cover/ender/CoverAbstractEnderLink.java +++ b/src/main/java/com/gregtechceu/gtceu/common/cover/ender/CoverAbstractEnderLink.java @@ -17,6 +17,7 @@ import com.gregtechceu.gtceu.api.misc.virtualregistry.VirtualEntry; import com.gregtechceu.gtceu.api.misc.virtualregistry.entries.VirtualTank; import com.gregtechceu.gtceu.common.cover.data.ManualIOMode; + import com.lowdragmc.lowdraglib.gui.widget.LabelWidget; import com.lowdragmc.lowdraglib.gui.widget.Widget; import com.lowdragmc.lowdraglib.gui.widget.WidgetGroup; @@ -24,18 +25,22 @@ import com.lowdragmc.lowdraglib.syncdata.annotation.Persisted; import com.lowdragmc.lowdraglib.syncdata.annotation.RequireRerender; import com.lowdragmc.lowdraglib.syncdata.field.ManagedFieldHolder; -import lombok.Getter; -import lombok.Setter; + import net.minecraft.core.Direction; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.item.ItemStack; + +import lombok.Getter; +import lombok.Setter; import org.jetbrains.annotations.NotNull; import java.util.List; import java.util.UUID; import java.util.regex.Pattern; -public abstract class CoverAbstractEnderLink extends CoverBehavior implements IUICover, IControllable { +public abstract class CoverAbstractEnderLink extends CoverBehavior + implements IUICover, IControllable { + public static final ManagedFieldHolder MANAGED_FIELD_HOLDER = new ManagedFieldHolder(CoverAbstractEnderLink.class, CoverBehavior.MANAGED_FIELD_HOLDER); public static final Pattern COLOR_INPUT_PATTERN = Pattern.compile("[0-9a-fA-F]*"); @@ -192,12 +197,10 @@ public Widget createUIWidget() { return VirtualTank.DEFAULT_COLOR; } return text; - } - ).setInputBoxTooltips(description); + }).setInputBoxTooltips(description); channelGroup.addWidget(confirmTextInputWidget); group.addWidget(channelGroup); - group.addWidget(new ToggleButtonWidget(116, 82, SMALL_WIDGET_WIDTH, WIDGET_HEIGHT, GuiTextures.BUTTON_POWER, this::isWorkingEnabled, this::setWorkingEnabled)); group.addWidget(new EnumSelectorWidget<>(146, 82, SMALL_WIDGET_WIDTH, WIDGET_HEIGHT, @@ -210,8 +213,7 @@ public Widget createUIWidget() { return group; } - protected void buildAdditionalUI(WidgetGroup group) { - } + protected void buildAdditionalUI(WidgetGroup group) {} protected abstract String getUITitle(); diff --git a/src/main/java/com/gregtechceu/gtceu/common/cover/ender/EnderFluidLinkCover.java b/src/main/java/com/gregtechceu/gtceu/common/cover/ender/EnderFluidLinkCover.java index 7f12bc3e43..7af0abbd4e 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/cover/ender/EnderFluidLinkCover.java +++ b/src/main/java/com/gregtechceu/gtceu/common/cover/ender/EnderFluidLinkCover.java @@ -13,16 +13,19 @@ import com.gregtechceu.gtceu.api.misc.virtualregistry.entries.VisualTank; import com.gregtechceu.gtceu.api.transfer.fluid.IFluidHandlerModifiable; import com.gregtechceu.gtceu.utils.GTTransferUtils; + import com.lowdragmc.lowdraglib.gui.widget.WidgetGroup; import com.lowdragmc.lowdraglib.syncdata.annotation.DescSynced; import com.lowdragmc.lowdraglib.syncdata.annotation.LazyManaged; import com.lowdragmc.lowdraglib.syncdata.annotation.Persisted; import com.lowdragmc.lowdraglib.syncdata.field.ManagedFieldHolder; + import net.minecraft.core.Direction; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.item.ItemStack; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidUtil; + import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -30,6 +33,7 @@ @ParametersAreNonnullByDefault public class EnderFluidLinkCover extends CoverAbstractEnderLink { + public static final ManagedFieldHolder MANAGED_FIELD_HOLDER = new ManagedFieldHolder(EnderFluidLinkCover.class, CoverAbstractEnderLink.MANAGED_FIELD_HOLDER); public static final int TRANSFER_RATE = 8000; // mB/t @@ -116,7 +120,7 @@ public void onAttached(ItemStack itemStack, ServerPlayer player) { } ////////////////////////////////////// - // *********** GUI ************ // + // *********** GUI ************ // /// /////////////////////////////////// @@ -135,51 +139,51 @@ protected String getUITitle() { return "cover.ender_fluid_link.title"; } -// damn I can't make the list panel work in the server side -// private SelectableWidgetGroup createVisualTankWidget(VisualTank tank, int y) { -// final int TOTAL_WIDTH = 116; -// final int BUTTON_SIZE = 20; -// final int MARGIN = 2; -// -// int currentX = 0; -// int availableWidth = TOTAL_WIDTH - BUTTON_SIZE + MARGIN; -// -// SelectableWidgetGroup channelGroup = new SelectableWidgetGroup(0, y, TOTAL_WIDTH, BUTTON_SIZE){ -// @Override -// public void drawInForeground(@NotNull GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) { -// super.drawInForeground(graphics, mouseX, mouseY, partialTicks); -// if (super.isSelected) -// DrawerHelper.drawBorder(graphics, getPositionX(), getPositionY(), TOTAL_WIDTH, BUTTON_SIZE, 0xFFFFFFFF, 1); -// } -// }; -// var name = tank.getVirtualTank().getColorStr(); -// -// // Color block -// channelGroup.addWidget(new ColorBlockWidget(currentX, 0, BUTTON_SIZE, BUTTON_SIZE) -// .setCurrentColor(tank.getVirtualTank().getColor())); -// currentX += BUTTON_SIZE + MARGIN; -// -// // Text box -// int textBoxWidth = availableWidth; -// textBoxWidth -= BUTTON_SIZE + MARGIN; -// if (tank.getFluidAmount() == 0) { -// textBoxWidth -= BUTTON_SIZE + MARGIN; -// } -// channelGroup.addWidget( -// new TextBoxWidget(currentX, 6, textBoxWidth, List.of(name)).setCenter(true)); -// currentX += textBoxWidth + MARGIN; -// -// // Tank slot -// channelGroup.addWidget(new TankWidget(tank, currentX, 0, -// BUTTON_SIZE, BUTTON_SIZE, false, false) -// .setBackground(GuiTextures.FLUID_SLOT)); -// currentX += BUTTON_SIZE + MARGIN; -// -// // Remove button (if tank is empty) -// if (tank.getFluidAmount() == 0) { -// channelGroup.addWidget(new ButtonWidget(currentX, 0, BUTTON_SIZE, BUTTON_SIZE, -// GuiTextures.BUTTON_INT_CIRCUIT_MINUS, cd -> removeChannel(tank))); -// } -// return channelGroup; -// } + // damn I can't make the list panel work in the server side + // private SelectableWidgetGroup createVisualTankWidget(VisualTank tank, int y) { + // final int TOTAL_WIDTH = 116; + // final int BUTTON_SIZE = 20; + // final int MARGIN = 2; + // + // int currentX = 0; + // int availableWidth = TOTAL_WIDTH - BUTTON_SIZE + MARGIN; + // + // SelectableWidgetGroup channelGroup = new SelectableWidgetGroup(0, y, TOTAL_WIDTH, BUTTON_SIZE){ + // @Override + // public void drawInForeground(@NotNull GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) { + // super.drawInForeground(graphics, mouseX, mouseY, partialTicks); + // if (super.isSelected) + // DrawerHelper.drawBorder(graphics, getPositionX(), getPositionY(), TOTAL_WIDTH, BUTTON_SIZE, 0xFFFFFFFF, 1); + // } + // }; + // var name = tank.getVirtualTank().getColorStr(); + // + // // Color block + // channelGroup.addWidget(new ColorBlockWidget(currentX, 0, BUTTON_SIZE, BUTTON_SIZE) + // .setCurrentColor(tank.getVirtualTank().getColor())); + // currentX += BUTTON_SIZE + MARGIN; + // + // // Text box + // int textBoxWidth = availableWidth; + // textBoxWidth -= BUTTON_SIZE + MARGIN; + // if (tank.getFluidAmount() == 0) { + // textBoxWidth -= BUTTON_SIZE + MARGIN; + // } + // channelGroup.addWidget( + // new TextBoxWidget(currentX, 6, textBoxWidth, List.of(name)).setCenter(true)); + // currentX += textBoxWidth + MARGIN; + // + // // Tank slot + // channelGroup.addWidget(new TankWidget(tank, currentX, 0, + // BUTTON_SIZE, BUTTON_SIZE, false, false) + // .setBackground(GuiTextures.FLUID_SLOT)); + // currentX += BUTTON_SIZE + MARGIN; + // + // // Remove button (if tank is empty) + // if (tank.getFluidAmount() == 0) { + // channelGroup.addWidget(new ButtonWidget(currentX, 0, BUTTON_SIZE, BUTTON_SIZE, + // GuiTextures.BUTTON_INT_CIRCUIT_MINUS, cd -> removeChannel(tank))); + // } + // return channelGroup; + // } } diff --git a/src/main/java/com/gregtechceu/gtceu/common/data/GTCovers.java b/src/main/java/com/gregtechceu/gtceu/common/data/GTCovers.java index 1a9bfb1da7..f9af96131f 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/data/GTCovers.java +++ b/src/main/java/com/gregtechceu/gtceu/common/data/GTCovers.java @@ -15,9 +15,11 @@ import com.gregtechceu.gtceu.common.cover.voiding.AdvancedItemVoidingCover; import com.gregtechceu.gtceu.common.cover.voiding.FluidVoidingCover; import com.gregtechceu.gtceu.common.cover.voiding.ItemVoidingCover; -import it.unimi.dsi.fastutil.ints.Int2ObjectFunction; + import net.minecraftforge.fml.ModLoader; +import it.unimi.dsi.fastutil.ints.Int2ObjectFunction; + import java.util.Arrays; import java.util.Locale; diff --git a/src/main/java/com/gregtechceu/gtceu/forge/ForgeCommonEventListener.java b/src/main/java/com/gregtechceu/gtceu/forge/ForgeCommonEventListener.java index 15ea030a3b..2346fb9b26 100644 --- a/src/main/java/com/gregtechceu/gtceu/forge/ForgeCommonEventListener.java +++ b/src/main/java/com/gregtechceu/gtceu/forge/ForgeCommonEventListener.java @@ -53,8 +53,7 @@ import com.gregtechceu.gtceu.integration.map.WaypointManager; import com.gregtechceu.gtceu.integration.map.cache.server.ServerCache; import com.gregtechceu.gtceu.utils.TaskHandler; -import com.tterrag.registrate.util.entry.BlockEntry; -import com.tterrag.registrate.util.entry.ItemEntry; + import net.minecraft.core.Direction; import net.minecraft.core.registries.Registries; import net.minecraft.nbt.CompoundTag; @@ -94,6 +93,9 @@ import net.minecraftforge.fml.common.Mod; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.registries.MissingMappingsEvent; + +import com.tterrag.registrate.util.entry.BlockEntry; +import com.tterrag.registrate.util.entry.ItemEntry; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable;