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 8, 2024
1 parent 1e6ed66 commit 453147f
Show file tree
Hide file tree
Showing 8 changed files with 103 additions and 50 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/glodblock/github/FluidCraft.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public static void postInit(FMLPostInitializationEvent event) {
if (!Config.removeRecipe) {
RecipeLoader.INSTANCE.run();
}
if (Config.enableTestItemRecipe) {
if (Config.testItemRecipe) {
RecipeLoader.addTestItem();
}
RecipeLoader.runTerminalRecipe();
Expand Down
66 changes: 34 additions & 32 deletions src/main/java/com/glodblock/github/client/gui/GuiMagnet.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.glodblock.github.client.gui;

import java.util.List;

import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
Expand All @@ -24,36 +26,36 @@
public class GuiMagnet extends AEBaseMEGui {

protected FCGuiBaseButton listModeBtn;
protected ContainerMagnet cont;
protected ContainerMagnet container;
private static final ResourceLocation TEX_BG = FluidCraft.resource("textures/gui/magnet_filter.png");

protected Component components[] = new Component[3];
protected Component[] components = new Component[3];
protected GuiTabButton originalGuiBtn;
protected GuiImgButton clearBtn;

public GuiMagnet(InventoryPlayer ip, ITerminalHost container) {
super(new ContainerMagnet(ip, container));
this.xSize = 195;
this.ySize = 214;
this.cont = (ContainerMagnet) this.inventorySlots;
this.container = (ContainerMagnet) this.inventorySlots;

}

private class Component {
private static class Component {

private GuiFCImgButton enable;
private GuiFCImgButton disable;
private String action;
private final GuiFCImgButton enable;
private final GuiFCImgButton disable;
private final String action;

private boolean value;

public Component(int x, int y, boolean value, String action) {
public Component(int x, int y, boolean value, String action, List<GuiButton> buttons) {
this.enable = new GuiFCImgButton(x, y, "ENABLE_12x", "ENABLE", false);
this.disable = new GuiFCImgButton(x, y, "DISABLE_12x", "DISABLE", false);
this.value = value;
this.action = action;
buttonList.add(this.enable);
buttonList.add(this.disable);
buttons.add(this.enable);
buttons.add(this.disable);
}

public boolean sameBtn(GuiButton btn) {
Expand All @@ -73,17 +75,13 @@ public void send() {
}

public void draw() {
if (value) {
this.enable.visible = true;
this.disable.visible = false;
} else {
this.enable.visible = false;
this.disable.visible = true;
}
this.enable.visible = value;
this.disable.visible = !value;
}
}

@Override
@SuppressWarnings("unchecked")
public void initGui() {
super.initGui();
this.buttonList.clear();
Expand All @@ -96,31 +94,34 @@ public void initGui() {
64,
14,
NameConst.i18n(
this.cont.listMode == ItemMagnetCard.ListMode.WhiteList
this.container.listMode == ItemMagnetCard.ListMode.WhiteList
? NameConst.GUI_MAGNET_CARD_WhiteList
: NameConst.GUI_MAGNET_CARD_BlackList)));
this.components[0] = new Component(
this.guiLeft + 156,
this.guiTop + 18,
this.cont.nbt,
"WirelessTerminal.magnet.NBT");
this.container.nbt,
"WirelessTerminal.magnet.NBT",
this.buttonList);
this.components[1] = new Component(
this.guiLeft + 156,
this.guiTop + 31,
this.cont.meta,
"WirelessTerminal.magnet.Meta");
this.container.meta,
"WirelessTerminal.magnet.Meta",
this.buttonList);
this.components[2] = new Component(
this.guiLeft + 156,
this.guiTop + 44,
this.cont.ore,
"WirelessTerminal.magnet.Ore");
this.container.ore,
"WirelessTerminal.magnet.Ore",
this.buttonList);

this.buttonList.add(
this.originalGuiBtn = new GuiTabButton(
this.guiLeft + this.xSize - 44,
this.guiTop - 4,
this.cont.getPortableCell().getItemStack(),
this.cont.getPortableCell().getItemStack().getDisplayName(),
this.container.getPortableCell().getItemStack(),
this.container.getPortableCell().getItemStack().getDisplayName(),
itemRender));
this.originalGuiBtn.setHideEdge(13); // GuiTabButton implementation //

Expand All @@ -138,14 +139,14 @@ 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].setValue(this.cont.nbt);
this.components[1].setValue(this.cont.meta);
this.components[2].setValue(this.cont.ore);
this.components[0].setValue(this.container.nbt);
this.components[1].setValue(this.container.meta);
this.components[2].setValue(this.container.ore);
for (Component c : components) {
c.draw();
}
this.listModeBtn.displayString = NameConst.i18n(
this.cont.listMode == ItemMagnetCard.ListMode.WhiteList ? NameConst.GUI_MAGNET_CARD_WhiteList
this.container.listMode == ItemMagnetCard.ListMode.WhiteList ? NameConst.GUI_MAGNET_CARD_WhiteList
: NameConst.GUI_MAGNET_CARD_BlackList);
}

Expand All @@ -167,9 +168,10 @@ protected void actionPerformed(GuiButton btn) {
FluidCraft.proxy.netHandler.sendToServer(
new CPacketFluidTerminalBtns(
"WirelessTerminal.magnet.FilterMode",
this.cont.listMode != ItemMagnetCard.ListMode.WhiteList));
this.container.listMode != ItemMagnetCard.ListMode.WhiteList));
} else if (btn == this.originalGuiBtn) {
InventoryHandler.switchGui(ItemWirelessUltraTerminal.readMode(this.cont.getPortableCell().getItemStack()));
InventoryHandler
.switchGui(ItemWirelessUltraTerminal.readMode(this.container.getPortableCell().getItemStack()));
} else if (btn == this.clearBtn) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidTerminalBtns("WirelessTerminal.magnet.clear", 1));
}
Expand Down
13 changes: 3 additions & 10 deletions src/main/java/com/glodblock/github/common/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@ public class Config {
public static boolean noFluidPacket;
public static boolean fluidIOBus;
public static boolean removeRecipe;
public static boolean enableTestItemRecipe = true;
public static boolean testItemRecipe;
public static double portableCellBattery;
public static boolean fluidP2PInterface;
public static int packetSize;
public static int packetRate;
public static boolean replaceEC2;
public static int levelMaintainerMinTicks;
public static int levelMaintainerMaxTicks;
Expand Down Expand Up @@ -57,13 +55,8 @@ private static void loadProperty() {
"Disable all recipes, for quick tweaker.");
portableCellBattery = Config.get("Fluid Craft for AE2", "Portable Fluid Cell Battery Capacity", 20000D)
.getDouble();
packetSize = Config.get("Fluid Craft for AE2", "packetSize", 256, "Number of items to be sent per packet")
.getInt();
if (packetSize <= 0) packetSize = 256;
packetRate = Config
.get("Fluid Craft for AE2", "packetRate", 50, "Period at which packets are dispatched, in ms.")
.getInt();
if (packetRate <= 0) packetRate = 50;
testItemRecipe = Config.get("Fluid Craft for AE2", "Experimental items", true, "Experimental items")
.getBoolean();
replaceEC2 = Config.getBoolean(
"replaceEC2",
"Fluid Craft for AE2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import static com.glodblock.github.loader.recipe.WirelessTerminalEnergyRecipe.getEnergyCard;
import static com.glodblock.github.loader.recipe.WirelessTerminalInfinityBoosterRecipe.getInfinityBoosterCard;
import static com.glodblock.github.loader.recipe.WirelessTerminalMagnetRecipe.getMagnetCard;
import static com.glodblock.github.util.Util.Wireless.*;
import static com.glodblock.github.util.Util.Wireless.hasEnergyCard;
import static com.glodblock.github.util.Util.Wireless.hasInfinityBoosterCard;
import static com.glodblock.github.util.Util.Wireless.hasMagnetCard;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ protected void loadCellFluids() {
if (fs == null) continue;
IAEFluidStack iaeFluidStack = Util.FluidUtil.createAEFluidStack(fs);
if (this.cellFluids.findPrecise(iaeFluidStack) == null) {
iaeFluidStack.setStackSize(Integer.MAX_VALUE);
iaeFluidStack.setStackSize(Integer.MAX_VALUE * 1000L);
this.cellFluids.add(iaeFluidStack);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ public class ItemAndBlockHolder {

public static void init() {}

public static ItemEnergyCard ENERGY_CARD = new ItemEnergyCard().register();
public static ItemQuantumBridgeCard QUANTUM_BRIDGE_CARD = new ItemQuantumBridgeCard().register();
public static ItemMagnetCard MAGNET_CARD = new ItemMagnetCard().register();
public static BlockCertusQuartzTank CERTUS_QUARTZ_TANK = new BlockCertusQuartzTank().register();
public static BlockFluidAutoFiller FLUID_AUTO_FILLER = new BlockFluidAutoFiller().register();
public static BlockFluidDiscretizer DISCRETIZER = new BlockFluidDiscretizer().register();
Expand Down Expand Up @@ -144,6 +141,9 @@ public static void init() {}
public static ItemInfinityLavaStorageCell INFINITY_LAVA_CELL = new ItemInfinityLavaStorageCell().register();
public static ItemBasicFluidStoragePart CELL_PART = new ItemBasicFluidStoragePart().register();
public static ItemFluidStorageHousing CELL_HOUSING = new ItemFluidStorageHousing().register();
public static ItemEnergyCard ENERGY_CARD = new ItemEnergyCard().register();
public static ItemQuantumBridgeCard QUANTUM_BRIDGE_CARD = new ItemQuantumBridgeCard().register();
public static ItemMagnetCard MAGNET_CARD = new ItemMagnetCard().register();

public static void loadSetting() {
if (!Config.fluidCells) return;
Expand Down
55 changes: 54 additions & 1 deletion src/main/java/com/glodblock/github/loader/RecipeLoader.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,60 @@
package com.glodblock.github.loader;

import static com.glodblock.github.common.storage.CellType.Cell16384kPart;
import static com.glodblock.github.loader.ItemAndBlockHolder.*;
import static com.glodblock.github.loader.ItemAndBlockHolder.BUFFER;
import static com.glodblock.github.loader.ItemAndBlockHolder.CELL1024K;
import static com.glodblock.github.loader.ItemAndBlockHolder.CELL1024KM;
import static com.glodblock.github.loader.ItemAndBlockHolder.CELL16384K;
import static com.glodblock.github.loader.ItemAndBlockHolder.CELL16384KM;
import static com.glodblock.github.loader.ItemAndBlockHolder.CELL16K;
import static com.glodblock.github.loader.ItemAndBlockHolder.CELL16KM;
import static com.glodblock.github.loader.ItemAndBlockHolder.CELL1K;
import static com.glodblock.github.loader.ItemAndBlockHolder.CELL1KM;
import static com.glodblock.github.loader.ItemAndBlockHolder.CELL256K;
import static com.glodblock.github.loader.ItemAndBlockHolder.CELL256KM;
import static com.glodblock.github.loader.ItemAndBlockHolder.CELL4096K;
import static com.glodblock.github.loader.ItemAndBlockHolder.CELL4096KM;
import static com.glodblock.github.loader.ItemAndBlockHolder.CELL4K;
import static com.glodblock.github.loader.ItemAndBlockHolder.CELL4KM;
import static com.glodblock.github.loader.ItemAndBlockHolder.CELL64K;
import static com.glodblock.github.loader.ItemAndBlockHolder.CELL64KM;
import static com.glodblock.github.loader.ItemAndBlockHolder.CELL_HOUSING;
import static com.glodblock.github.loader.ItemAndBlockHolder.CERTUS_QUARTZ_TANK;
import static com.glodblock.github.loader.ItemAndBlockHolder.DECODER;
import static com.glodblock.github.loader.ItemAndBlockHolder.DISCRETIZER;
import static com.glodblock.github.loader.ItemAndBlockHolder.ENCODER;
import static com.glodblock.github.loader.ItemAndBlockHolder.ENERGY_CARD;
import static com.glodblock.github.loader.ItemAndBlockHolder.FLUID_AUTO_FILLER;
import static com.glodblock.github.loader.ItemAndBlockHolder.FLUID_BUFFER;
import static com.glodblock.github.loader.ItemAndBlockHolder.FLUID_CONVERSION_MONITOR;
import static com.glodblock.github.loader.ItemAndBlockHolder.FLUID_EXPORT_BUS;
import static com.glodblock.github.loader.ItemAndBlockHolder.FLUID_IMPORT_BUS;
import static com.glodblock.github.loader.ItemAndBlockHolder.FLUID_INTERFACE;
import static com.glodblock.github.loader.ItemAndBlockHolder.FLUID_INTERFACE_P2P;
import static com.glodblock.github.loader.ItemAndBlockHolder.FLUID_LEVEL_EMITTER;
import static com.glodblock.github.loader.ItemAndBlockHolder.FLUID_STORAGE_BUS;
import static com.glodblock.github.loader.ItemAndBlockHolder.FLUID_STORAGE_MONITOR;
import static com.glodblock.github.loader.ItemAndBlockHolder.FLUID_TERM;
import static com.glodblock.github.loader.ItemAndBlockHolder.FLUID_TERMINAL;
import static com.glodblock.github.loader.ItemAndBlockHolder.FLUID_TERMINAL_EX;
import static com.glodblock.github.loader.ItemAndBlockHolder.INFINITY_WATER_CELL;
import static com.glodblock.github.loader.ItemAndBlockHolder.INTERFACE;
import static com.glodblock.github.loader.ItemAndBlockHolder.LARGE_BUFFER;
import static com.glodblock.github.loader.ItemAndBlockHolder.LEVEL_MAINTAINER;
import static com.glodblock.github.loader.ItemAndBlockHolder.LEVEL_TERMINAL;
import static com.glodblock.github.loader.ItemAndBlockHolder.MAGNET_CARD;
import static com.glodblock.github.loader.ItemAndBlockHolder.OC_EDITOR;
import static com.glodblock.github.loader.ItemAndBlockHolder.PATTERN;
import static com.glodblock.github.loader.ItemAndBlockHolder.PORTABLE_FLUID_CELL;
import static com.glodblock.github.loader.ItemAndBlockHolder.QUANTUM_BRIDGE_CARD;
import static com.glodblock.github.loader.ItemAndBlockHolder.QUANTUM_CELL;
import static com.glodblock.github.loader.ItemAndBlockHolder.SINGULARITY_CELL;
import static com.glodblock.github.loader.ItemAndBlockHolder.WALRUS;
import static com.glodblock.github.loader.ItemAndBlockHolder.WIRELESS_FLUID_TERM;
import static com.glodblock.github.loader.ItemAndBlockHolder.WIRELESS_INTERFACE_TERM;
import static com.glodblock.github.loader.ItemAndBlockHolder.WIRELESS_LEVEL_TERM;
import static com.glodblock.github.loader.ItemAndBlockHolder.WIRELESS_PATTERN_TERM;
import static com.glodblock.github.loader.ItemAndBlockHolder.WIRELESS_ULTRA_TERM;
import static com.glodblock.github.loader.recipe.WirelessTerminalEnergyRecipe.energyCards;
import static com.glodblock.github.loader.recipe.WirelessTerminalInfinityBoosterRecipe.infCards;
import static com.glodblock.github.loader.recipe.WirelessTerminalMagnetRecipe.magnetCards;
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/com/glodblock/github/util/Util.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package com.glodblock.github.util;

import static com.glodblock.github.common.item.ItemBaseWirelessTerminal.*;
import static com.glodblock.github.common.item.ItemBaseWirelessTerminal.infinityBoosterCard;
import static com.glodblock.github.common.item.ItemBaseWirelessTerminal.infinityEnergyCard;
import static com.glodblock.github.common.item.ItemBaseWirelessTerminal.magnetCard;
import static com.glodblock.github.common.item.ItemBaseWirelessTerminal.restockItems;
import static net.minecraft.init.Items.glass_bottle;

import java.io.IOException;
Expand Down

0 comments on commit 453147f

Please sign in to comment.