Skip to content

Commit

Permalink
update code style
Browse files Browse the repository at this point in the history
  • Loading branch information
zy committed Jan 4, 2024
1 parent 2c005e1 commit 9a2007a
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 54 deletions.
24 changes: 12 additions & 12 deletions src/main/java/com/glodblock/github/client/gui/GuiMagnet.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ private class Component {
private GuiFCImgButton disable;
private String action;

private boolean var;
private boolean value;

public Component(int x, int y, boolean var, String action) {
public Component(int x, int y, boolean value, String action) {
this.enable = new GuiFCImgButton(x, y, "ENABLE_12x", "ENABLE", false);
this.disable = new GuiFCImgButton(x, y, "DISABLE_12x", "DISABLE", false);
this.var = var;
this.value = value;
this.action = action;
buttonList.add(this.enable);
buttonList.add(this.disable);
Expand All @@ -60,20 +60,20 @@ public boolean sameBtn(GuiButton btn) {
return btn == this.enable || btn == this.disable;
}

public boolean getVar() {
return this.var;
public boolean getValue() {
return this.value;
}

public void setVar(boolean var) {
this.var = var;
public void setValue(boolean value) {
this.value = value;
}

public void send() {
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidTerminalBtns(this.action, !this.getVar()));
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidTerminalBtns(this.action, !this.getValue()));
}

public void draw() {
if (var) {
if (value) {
this.enable.visible = true;
this.disable.visible = false;
} else {
Expand Down Expand Up @@ -138,9 +138,9 @@ public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) {
.drawString(getGuiDisplayName(NameConst.i18n(NameConst.GUI_MAGNET_CARD_META)), 61, 34, 0x404040);
this.fontRendererObj
.drawString(getGuiDisplayName(NameConst.i18n(NameConst.GUI_MAGNET_CARD_ORE)), 61, 46, 0x404040);
this.components[0].setVar(this.cont.nbt);
this.components[1].setVar(this.cont.meta);
this.components[2].setVar(this.cont.ore);
this.components[0].setValue(this.cont.nbt);
this.components[1].setValue(this.cont.meta);
this.components[2].setValue(this.cont.ore);
for (Component c : components) {
c.draw();
}
Expand Down
68 changes: 37 additions & 31 deletions src/main/java/com/glodblock/github/client/gui/base/FCBaseMEGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,17 @@ public abstract class FCBaseMEGui extends AEBaseMEGui {
protected boolean drawSwitchGuiBtn;
private boolean hasMagnetCard = false;
private StorageChannel channel = null;
private final FCBaseContainer container;
protected final int buttonOffset = 18;

public FCBaseMEGui(final InventoryPlayer inventoryPlayer, Container container) {
super(container);
if (container instanceof FCBaseContainer) {
Object target = ((FCBaseContainer) container).getTarget();
if (target instanceof IWirelessTerminal
&& ((IWirelessTerminal) target).getItemStack().getItem() instanceof ItemWirelessUltraTerminal) {
this.drawSwitchGuiBtn = true;
this.hasMagnetCard = Util.Wireless.hasMagnetCard(((IWirelessTerminal) target).getItemStack());
this.channel = ((IWirelessTerminal) target).getChannel();
}
this.container = (FCBaseContainer) container;
if (this.container.getTarget() instanceof IWirelessTerminal iwt
&& iwt.getItemStack().getItem() instanceof ItemWirelessUltraTerminal) {
this.drawSwitchGuiBtn = true;
this.hasMagnetCard = Util.Wireless.hasMagnetCard(iwt.getItemStack());
this.channel = iwt.getChannel();
}
}

Expand Down Expand Up @@ -112,17 +112,17 @@ public List<String> handleItemTooltip(final ItemStack stack, final int mouseX, f

protected ItemMagnetCard.Mode getMagnetMode() {
if (this.hasMagnetCard) {
return ((FCBaseContainer) this.inventorySlots).mode;
return this.container.mode;
}
return null;
}

protected boolean isRestock() {
return ((FCBaseContainer) this.inventorySlots).restock;
return this.container.restock;
}

protected boolean isSyncData() {
return ((FCBaseContainer) this.inventorySlots).sync;
return this.container.sync;
}

@Override
Expand All @@ -131,16 +131,16 @@ public void onGuiClosed() {
}

protected void setSyncState() {
if (this.inventorySlots instanceof FCContainerMonitor && !isPortableCell()) {
if (this.container instanceof FCContainerMonitor && !isPortableCell()) {
this.buttonList.add(
this.dataSyncEnableBtn = new GuiFCImgButton(
this.guiLeft + this.xSize - 18,
this.guiLeft + this.xSize - buttonOffset,
this.guiTop + this.ySize - 44,
"DATA_SYNC",
"ENABLE"));
this.buttonList.add(
this.dataSyncDisableBtn = new GuiFCImgButton(
this.guiLeft + this.xSize - 18,
this.guiLeft + this.xSize - buttonOffset,
this.guiTop + this.ySize - 44,
"DATA_SYNC",
"DISABLE"));
Expand All @@ -167,47 +167,47 @@ protected void drawSwitchGuiBtns() {
if (this.getMagnetMode() != null && this.channel == StorageChannel.ITEMS) {
this.buttonList.add(
this.magnetOff = new GuiFCImgButton(
this.guiLeft + this.xSize - 18,
this.guiLeft + this.xSize - buttonOffset,
this.guiTop + this.ySize - 124,
"MAGNET_CARD",
"OFF"));
this.buttonList.add(
this.magnetInv = new GuiFCImgButton(
this.guiLeft + this.xSize - 18,
this.guiLeft + this.xSize - buttonOffset,
this.guiTop + this.ySize - 124,
"MAGNET_CARD",
"INV"));
this.buttonList.add(
this.magnetME = new GuiFCImgButton(
this.guiLeft + this.xSize - 18,
this.guiLeft + this.xSize - buttonOffset,
this.guiTop + this.ySize - 124,
"MAGNET_CARD",
"ME"));
this.buttonList.add(
this.magnetFilter = new GuiFCImgButton(
this.guiLeft + this.xSize - 18,
this.guiLeft + this.xSize - buttonOffset,
this.guiTop + this.ySize - 104,
"MAGNET_CARD",
"FILTER"));
}
if (this.channel == StorageChannel.ITEMS) {
this.buttonList.add(
this.restockEnableBtn = new GuiFCImgButton(
this.guiLeft + this.xSize - 18,
this.guiLeft + this.xSize - buttonOffset,
this.guiTop + this.ySize - 84,
"RESTOCK",
"ENABLE"));
this.buttonList.add(
this.restockDisableBtn = new GuiFCImgButton(
this.guiLeft + this.xSize - 18,
this.guiLeft + this.xSize - buttonOffset,
this.guiTop + this.ySize - 84,
"RESTOCK",
"DISABLE"));
}
if (!(this instanceof GuiFluidCraftingWireless)) {
this.buttonList.add(
this.CraftingTerminal = new GuiFCImgButton(
this.guiLeft - 18,
this.guiLeft - buttonOffset,
this.getOffsetY(),
"CRAFT_TEM",
"YES"));
Expand All @@ -217,7 +217,7 @@ protected void drawSwitchGuiBtns() {
if (!(this instanceof GuiFluidPatternWireless)) {
this.buttonList.add(
this.PatternTerminal = new GuiFCImgButton(
this.guiLeft - 18,
this.guiLeft - buttonOffset,
this.getOffsetY(),
"PATTERN_TEM",
"YES"));
Expand All @@ -227,7 +227,7 @@ protected void drawSwitchGuiBtns() {
if (!(this instanceof GuiFluidPatternExWireless)) {
this.buttonList.add(
this.PatternTerminalEx = new GuiFCImgButton(
this.guiLeft - 18,
this.guiLeft - buttonOffset,
this.getOffsetY(),
"PATTERN_EX_TEM",
"YES"));
Expand All @@ -236,14 +236,18 @@ protected void drawSwitchGuiBtns() {
}
if (!(this instanceof GuiFluidPortableCell)) {
this.buttonList.add(
this.FluidTerminal = new GuiFCImgButton(this.guiLeft - 18, this.getOffsetY(), "FLUID_TEM", "YES"));
this.FluidTerminal = new GuiFCImgButton(
this.guiLeft - buttonOffset,
this.getOffsetY(),
"FLUID_TEM",
"YES"));
this.setOffsetY(this.getOffsetY() + 20);
termBtns.add(this.FluidTerminal);
}
if (!(this instanceof GuiInterfaceWireless)) {
this.buttonList.add(
this.InterfaceTerminal = new GuiFCImgButton(
this.guiLeft - 18,
this.guiLeft - buttonOffset,
this.getOffsetY(),
"INTERFACE_TEM",
"YES"));
Expand All @@ -252,14 +256,18 @@ protected void drawSwitchGuiBtns() {
}
if (!(this instanceof GuiLevelWireless)) {
this.buttonList.add(
this.LevelTerminal = new GuiFCImgButton(this.guiLeft - 18, this.getOffsetY(), "LEVEL_TEM", "YES"));
this.LevelTerminal = new GuiFCImgButton(
this.guiLeft - buttonOffset,
this.getOffsetY(),
"LEVEL_TEM",
"YES"));
this.setOffsetY(this.getOffsetY() + 20);
termBtns.add(this.LevelTerminal);
}
if (ModAndClassUtil.ThE && !(this instanceof GuiEssentiaTerminal)) {
this.buttonList.add(
this.EssentiaTerminal = new GuiFCImgButton(
this.guiLeft - 18,
this.guiLeft - buttonOffset,
this.getOffsetY(),
"ESSENTIA_TEM",
"YES"));
Expand All @@ -283,10 +291,8 @@ public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) {
magnetButtons[i].visible = getMagnetMode().ordinal() == i;
}
}
if (this.inventorySlots instanceof FCBaseContainer) {
this.dataSyncDisableBtn.visible = !isSyncData();
this.dataSyncEnableBtn.visible = isSyncData();
}
this.dataSyncDisableBtn.visible = !isSyncData();
this.dataSyncEnableBtn.visible = isSyncData();
if (this.drawSwitchGuiBtn && this.channel == StorageChannel.ITEMS) { // Only ultra terminal
this.restockDisableBtn.visible = !this.isRestock();
this.restockEnableBtn.visible = this.isRestock();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public abstract class FCBaseContainer extends AEBaseContainer {

private int ticks;
private final double powerMultiplier = 0.5;
private ITerminalHost host;
protected ITerminalHost host;
private int slot = -1;
private final InventoryPlayer ip;
@GuiSync(105)
Expand All @@ -40,8 +40,8 @@ public FCBaseContainer(InventoryPlayer ip, ITerminalHost monitorable) {

private int lockSlot() {
if (isWirelessTerminal()) {
if (this.host instanceof IFluidPortableCell) {
final int slotIndex = ((IFluidPortableCell) this.host).getInventorySlot();
if (this.host instanceof IFluidPortableCell ifpc) {
final int slotIndex = ifpc.getInventorySlot();
if (Util.GuiHelper.decodeInvType(slotIndex).getLeft() == Util.GuiHelper.InvType.PLAYER_INV) {
this.lockPlayerInventorySlot(slotIndex);
}
Expand All @@ -66,12 +66,12 @@ public void detectAndSendChanges() {
((IFluidPortableCell) this.host));
}
if (Platform.isServer()) {
if (this.host instanceof IWirelessExtendCard) {
this.mode = ((IWirelessExtendCard) this.host).getMagnetCardMode();
this.restock = ((IWirelessExtendCard) this.host).isRestock();
if (this.host instanceof IWirelessExtendCard iwec) {
this.mode = iwec.getMagnetCardMode();
this.restock = iwec.isRestock();
}
if (this.host != null && this.host instanceof IItemTerminal) {
this.sync = ((IItemTerminal) this.host).getSyncData();
if (this.host != null && this.host instanceof IItemTerminal iwt) {
this.sync = iwt.getSyncData();
}
}
super.detectAndSendChanges();
Expand All @@ -86,8 +86,8 @@ public ITerminalHost getHost() {
}

public IFluidPortableCell getPortableCell() {
if (this.host instanceof IFluidPortableCell) {
return (IFluidPortableCell) this.host;
if (this.host instanceof IFluidPortableCell ifpc) {
return ifpc;
} else {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ public abstract class FCContainerMonitor<T extends IAEStack<T>> extends FCBaseCo

protected final SlotRestrictedInput[] cellView = new SlotRestrictedInput[5];
protected final IConfigManager clientCM;
protected final ITerminalHost host;

@GuiSync(99)
public boolean canAccessViewCells = false;
Expand Down

0 comments on commit 9a2007a

Please sign in to comment.