Skip to content

Commit

Permalink
spotless
Browse files Browse the repository at this point in the history
  • Loading branch information
Arborsm committed Dec 6, 2024
1 parent f708f7b commit 3ad93a9
Show file tree
Hide file tree
Showing 12 changed files with 106 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,22 @@

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;

@Setter
@Accessors(chain = true)
public class ColorBlockWidget extends Widget {

private IntSupplier colorSupplier;
@Getter
private int currentColor;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<String> textResponder, Function<String, String> validator) {
public ConfirmTextInputWidget(int x, int y, int width, int height, String text, Consumer<String> textResponder,
Function<String, String> validator) {
super(x, y, width, height);
this.textResponder = textResponder;
this.validator = validator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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<UUID, VirtualRegistryMap> VIRTUAL_REGISTRIES = new HashMap<>();

public VirtualEnderRegistry() {
}
public VirtualEnderRegistry() {}

public VirtualEnderRegistry(CompoundTag name) {
readFromNBT(name);
Expand Down Expand Up @@ -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 <T extends VirtualEntry> void deleteEntryIf(@Nullable UUID owner, EntryTypes<T> type, String name, Predicate<T> shouldDelete) {
public <T extends VirtualEntry> void deleteEntryIf(@Nullable UUID owner, EntryTypes<T> type, String name,
Predicate<T> shouldDelete) {
T entry = getEntry(owner, type, name);
if (entry != null && shouldDelete.test(entry)) deleteEntry(owner, type, name);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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<CompoundTag> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -12,10 +13,10 @@
import java.util.concurrent.ConcurrentHashMap;

public class VirtualRegistryMap implements INBTSerializable<CompoundTag> {

private final Map<EntryTypes<?>, Map<String, VirtualEntry>> registryMap = new ConcurrentHashMap<>();

public VirtualRegistryMap() {
}
public VirtualRegistryMap() {}

public VirtualRegistryMap(CompoundTag tag) {
deserializeNBT(tag);
Expand Down Expand Up @@ -68,9 +69,8 @@ public Set<String> 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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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<CompoundTag>, ITagSerializable<CompoundTag> {

@Getter
private VirtualTank virtualTank;
@Setter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,30 @@
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;
import com.lowdragmc.lowdraglib.syncdata.annotation.DescSynced;
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<T extends VirtualEntry> extends CoverBehavior implements IUICover, IControllable {
public abstract class CoverAbstractEnderLink<T extends VirtualEntry> 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]*");
Expand Down Expand Up @@ -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,
Expand All @@ -210,8 +213,7 @@ public Widget createUIWidget() {
return group;
}

protected void buildAdditionalUI(WidgetGroup group) {
}
protected void buildAdditionalUI(WidgetGroup group) {}

protected abstract String getUITitle();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,27 @@
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;

import javax.annotation.ParametersAreNonnullByDefault;

@ParametersAreNonnullByDefault
public class EnderFluidLinkCover extends CoverAbstractEnderLink<VirtualTank> {

public static final ManagedFieldHolder MANAGED_FIELD_HOLDER = new ManagedFieldHolder(EnderFluidLinkCover.class,
CoverAbstractEnderLink.MANAGED_FIELD_HOLDER);
public static final int TRANSFER_RATE = 8000; // mB/t
Expand Down Expand Up @@ -116,7 +120,7 @@ public void onAttached(ItemStack itemStack, ServerPlayer player) {
}

//////////////////////////////////////
// *********** GUI ************ //
// *********** GUI ************ //

/// ///////////////////////////////////

Expand All @@ -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;
// }
}
Loading

0 comments on commit 3ad93a9

Please sign in to comment.