aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/common/tileentities
diff options
context:
space:
mode:
authorGDCloud <93287602+GDCloudstrike@users.noreply.github.com>2024-01-12 21:51:13 +0100
committerGitHub <noreply@github.com>2024-01-12 21:51:13 +0100
commitbc283fcf154bd3aa2d26fd98eb24a35821e5c65b (patch)
tree6002931580367d4335a601b06356bf00a89ab3d8 /src/main/java/gregtech/common/tileentities
parentf567d72909b7eb4448c63eb16af4ed8c60b4cec1 (diff)
downloadGT5-Unofficial-bc283fcf154bd3aa2d26fd98eb24a35821e5c65b.tar.gz
GT5-Unofficial-bc283fcf154bd3aa2d26fd98eb24a35821e5c65b.tar.bz2
GT5-Unofficial-bc283fcf154bd3aa2d26fd98eb24a35821e5c65b.zip
Make stocking bus/hatch autopull slot refresh timer adjustable (#2448)
* add to stocking bus * add to stocking hatch * localisation stuff * nbt fix (maybe) * fix stocking hatch too * hasKey is cleaner
Diffstat (limited to 'src/main/java/gregtech/common/tileentities')
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_InputBus_ME.java29
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_Input_ME.java28
2 files changed, 51 insertions, 6 deletions
diff --git a/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_InputBus_ME.java b/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_InputBus_ME.java
index 59746800b1..f8ffe846d9 100644
--- a/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_InputBus_ME.java
+++ b/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_InputBus_ME.java
@@ -86,6 +86,7 @@ public class GT_MetaTileEntity_Hatch_InputBus_ME extends GT_MetaTileEntity_Hatch
private final boolean autoPullAvailable;
private boolean autoPullItemList = false;
private int minAutoPullStackSize = 1;
+ private int autoPullRefreshTime = 100;
private static final int CONFIG_WINDOW_ID = 10;
private boolean additionalConnection = false;
@@ -126,7 +127,7 @@ public class GT_MetaTileEntity_Hatch_InputBus_ME extends GT_MetaTileEntity_Hatch
@Override
public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) {
if (getBaseMetaTileEntity().isServerSide()) {
- if (aTimer % 100 == 0 && autoPullItemList) {
+ if (aTimer % autoPullRefreshTime == 0 && autoPullItemList) {
refreshItemList();
}
if (aTimer % 20 == 0) {
@@ -209,6 +210,7 @@ public class GT_MetaTileEntity_Hatch_InputBus_ME extends GT_MetaTileEntity_Hatch
aNBT.setBoolean("autoStock", autoPullItemList);
aNBT.setInteger("minAutoPullStackSize", minAutoPullStackSize);
aNBT.setBoolean("additionalConnection", additionalConnection);
+ aNBT.setInteger("refreshTime", autoPullRefreshTime);
getProxy().writeToNBT(aNBT);
}
@@ -246,7 +248,11 @@ public class GT_MetaTileEntity_Hatch_InputBus_ME extends GT_MetaTileEntity_Hatch
autoPullItemList = aNBT.getBoolean("autoStock");
minAutoPullStackSize = aNBT.getInteger("minAutoPullStackSize");
additionalConnection = aNBT.getBoolean("additionalConnection");
+ if (aNBT.hasKey("refreshTime")) {
+ autoPullRefreshTime = aNBT.getInteger("refreshTime");
+ }
getProxy().readFromNBT(aNBT);
+
}
@Override
@@ -310,6 +316,7 @@ public class GT_MetaTileEntity_Hatch_InputBus_ME extends GT_MetaTileEntity_Hatch
if (autoPullAvailable) {
setAutoPullItemList(nbt.getBoolean("autoPull"));
minAutoPullStackSize = nbt.getInteger("minStackSize");
+ autoPullRefreshTime = nbt.getInteger("refreshTime");
}
additionalConnection = nbt.getBoolean("additionalConnection");
@@ -336,6 +343,7 @@ public class GT_MetaTileEntity_Hatch_InputBus_ME extends GT_MetaTileEntity_Hatch
tag.setString("type", "stockingBus");
tag.setBoolean("autoPull", autoPullItemList);
tag.setInteger("minStackSize", minAutoPullStackSize);
+ tag.setInteger("refreshTime", autoPullRefreshTime);
tag.setBoolean("additionalConnection", additionalConnection);
tag.setTag("circuit", GT_Utility.saveItem(getStackInSlot(getCircuitSlot())));
@@ -670,7 +678,7 @@ public class GT_MetaTileEntity_Hatch_InputBus_ME extends GT_MetaTileEntity_Hatch
protected ModularWindow createStackSizeConfigurationWindow(final EntityPlayer player) {
final int WIDTH = 78;
- final int HEIGHT = 40;
+ final int HEIGHT = 80;
final int PARENT_WIDTH = getGUIWidth();
final int PARENT_HEIGHT = getGUIHeight();
ModularWindow.Builder builder = ModularWindow.builder(WIDTH, HEIGHT);
@@ -696,6 +704,20 @@ public class GT_MetaTileEntity_Hatch_InputBus_ME extends GT_MetaTileEntity_Hatch
.setSize(70, 18)
.setPos(3, 18)
.setBackground(GT_UITextures.BACKGROUND_TEXT_FIELD));
+ builder.widget(
+ TextWidget.localised("GT5U.machines.stocking_bus.refresh_time")
+ .setPos(3, 42)
+ .setSize(74, 14))
+ .widget(
+ new TextFieldWidget().setSetterInt(val -> autoPullRefreshTime = val)
+ .setGetterInt(() -> autoPullRefreshTime)
+ .setNumbers(1, Integer.MAX_VALUE)
+ .setOnScrollNumbers(1, 4, 64)
+ .setTextAlignment(Alignment.Center)
+ .setTextColor(Color.WHITE.normal)
+ .setSize(70, 18)
+ .setPos(3, 58)
+ .setBackground(GT_UITextures.BACKGROUND_TEXT_FIELD));
return builder.build();
}
@@ -752,7 +774,8 @@ public class GT_MetaTileEntity_Hatch_InputBus_ME extends GT_MetaTileEntity_Hatch
strings.add(
"Auto-Pull from ME mode will automatically stock the first 16 items in the ME system, updated every 5 seconds.");
strings.add("Toggle by right-clicking with screwdriver, or use the GUI.");
- strings.add("Use the GUI to limit the minimum stack size for Auto-Pulling.");
+ strings
+ .add("Use the GUI to limit the minimum stack size for Auto-Pulling and adjust the slot refresh timer.");
}
strings.add("Change ME connection behavior by right-clicking with wire cutter.");
diff --git a/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_Input_ME.java b/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_Input_ME.java
index c1705612aa..f60847f8a6 100644
--- a/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_Input_ME.java
+++ b/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_Input_ME.java
@@ -98,6 +98,7 @@ public class GT_MetaTileEntity_Hatch_Input_ME extends GT_MetaTileEntity_Hatch_In
private final boolean autoPullAvailable;
protected boolean autoPullFluidList = false;
protected int minAutoPullAmount = 1;
+ private int autoPullRefreshTime = 100;
protected boolean processingRecipe = false;
protected static final int CONFIG_WINDOW_ID = 10;
@@ -133,7 +134,7 @@ public class GT_MetaTileEntity_Hatch_Input_ME extends GT_MetaTileEntity_Hatch_In
@Override
public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) {
if (getBaseMetaTileEntity().isServerSide()) {
- if (aTimer % 100 == 0 && autoPullFluidList) {
+ if (aTimer % autoPullRefreshTime == 0 && autoPullFluidList) {
refreshFluidList();
}
if (aTimer % 20 == 0) {
@@ -466,6 +467,7 @@ public class GT_MetaTileEntity_Hatch_Input_ME extends GT_MetaTileEntity_Hatch_In
aNBT.setBoolean("autoPull", autoPullFluidList);
aNBT.setInteger("minAmount", minAutoPullAmount);
aNBT.setBoolean("additionalConnection", additionalConnection);
+ aNBT.setInteger("refreshTime", autoPullRefreshTime);
getProxy().writeToNBT(aNBT);
}
@@ -490,6 +492,9 @@ public class GT_MetaTileEntity_Hatch_Input_ME extends GT_MetaTileEntity_Hatch_In
minAutoPullAmount = aNBT.getInteger("minAmount");
autoPullFluidList = aNBT.getBoolean("autoPull");
additionalConnection = aNBT.getBoolean("additionalConnection");
+ if (aNBT.hasKey("refreshTime")) {
+ autoPullRefreshTime = aNBT.getInteger("refreshTime");
+ }
getProxy().readFromNBT(aNBT);
}
@@ -521,6 +526,7 @@ public class GT_MetaTileEntity_Hatch_Input_ME extends GT_MetaTileEntity_Hatch_In
if (autoPullAvailable) {
setAutoPullFluidList(nbt.getBoolean("autoPull"));
minAutoPullAmount = nbt.getInteger("minAmount");
+ autoPullRefreshTime = nbt.getInteger("refreshTime");
}
additionalConnection = nbt.getBoolean("additionalConnection");
@@ -548,6 +554,7 @@ public class GT_MetaTileEntity_Hatch_Input_ME extends GT_MetaTileEntity_Hatch_In
tag.setBoolean("autoPull", autoPullFluidList);
tag.setInteger("minAmount", minAutoPullAmount);
tag.setBoolean("additionalConnection", additionalConnection);
+ tag.setInteger("refreshTime", autoPullRefreshTime);
NBTTagList stockingFluids = new NBTTagList();
if (!autoPullFluidList) {
@@ -750,7 +757,7 @@ public class GT_MetaTileEntity_Hatch_Input_ME extends GT_MetaTileEntity_Hatch_In
protected ModularWindow createStackSizeConfigurationWindow(final EntityPlayer player) {
final int WIDTH = 78;
- final int HEIGHT = 40;
+ final int HEIGHT = 80;
final int PARENT_WIDTH = getGUIWidth();
final int PARENT_HEIGHT = getGUIHeight();
ModularWindow.Builder builder = ModularWindow.builder(WIDTH, HEIGHT);
@@ -776,6 +783,20 @@ public class GT_MetaTileEntity_Hatch_Input_ME extends GT_MetaTileEntity_Hatch_In
.setSize(70, 18)
.setPos(3, 18)
.setBackground(GT_UITextures.BACKGROUND_TEXT_FIELD));
+ builder.widget(
+ TextWidget.localised("GT5U.machines.stocking_bus.refresh_time")
+ .setPos(3, 42)
+ .setSize(74, 14))
+ .widget(
+ new TextFieldWidget().setSetterInt(val -> autoPullRefreshTime = val)
+ .setGetterInt(() -> autoPullRefreshTime)
+ .setNumbers(1, Integer.MAX_VALUE)
+ .setOnScrollNumbers(1, 4, 64)
+ .setTextAlignment(Alignment.Center)
+ .setTextColor(Color.WHITE.normal)
+ .setSize(70, 18)
+ .setPos(3, 58)
+ .setBackground(GT_UITextures.BACKGROUND_TEXT_FIELD));
return builder.build();
}
@@ -832,7 +853,8 @@ public class GT_MetaTileEntity_Hatch_Input_ME extends GT_MetaTileEntity_Hatch_In
strings.add(
"Auto-Pull from ME mode will automatically stock the first 16 fluid in the ME system, updated every 5 seconds.");
strings.add("Toggle by right-clicking with screwdriver, or use the GUI.");
- strings.add("Use the GUI to limit the minimum stack size for Auto-Pulling.");
+ strings
+ .add("Use the GUI to limit the minimum stack size for Auto-Pulling and adjust the slot refresh timer.");
}
strings.add("Change ME connection behavior by right-clicking with wire cutter.");