aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormiozune <miozune@gmail.com>2023-10-13 17:59:39 +0900
committerGitHub <noreply@github.com>2023-10-13 10:59:39 +0200
commit4c8b94dd91fa5e16534d48415d5a4f75ea0bbb6f (patch)
treeb9222d444b42514e265640aab7c3488816ddccd8
parentb43e65f3784a7978656a4e2a72a2734b37d7b735 (diff)
downloadGT5-Unofficial-4c8b94dd91fa5e16534d48415d5a4f75ea0bbb6f.tar.gz
GT5-Unofficial-4c8b94dd91fa5e16534d48415d5a4f75ea0bbb6f.tar.bz2
GT5-Unofficial-4c8b94dd91fa5e16534d48415d5a4f75ea0bbb6f.zip
Fix Stocking Bus bug (#2326)
* Shut down machine with message if stocking bus fail to extract items * Better way to handle message persistent on shutdown * Minor cleanup * Allow more localizations * Add network status display * Fix auto-pull mode accepting shift insert * Remove workaround for issue with multiple ME buses in a multiblock * Some tweak for appearance * Correct inconsistent variable naming in GT_UITextures * Update .gitignore * Fix typo * Remove isScheduledForResetCheckRecipeResult by using persistsOnShutdown * Apply "cannot set slot" tooltip for empty slots too
-rw-r--r--.gitignore15
-rw-r--r--src/main/java/gregtech/GT_Mod.java2
-rw-r--r--src/main/java/gregtech/api/gui/modularui/GT_UITextures.java14
-rw-r--r--src/main/java/gregtech/api/metatileentity/MetaTileEntity.java13
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus.java21
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java68
-rw-r--r--src/main/java/gregtech/api/recipe/check/CheckRecipeResult.java7
-rw-r--r--src/main/java/gregtech/api/recipe/check/CheckRecipeResultRegistry.java4
-rw-r--r--src/main/java/gregtech/api/recipe/check/SimpleCheckRecipeResult.java30
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_InputBus_ME.java134
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java10
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlantBase.java7
-rw-r--r--src/main/resources/assets/gregtech/lang/en_US.lang12
13 files changed, 217 insertions, 120 deletions
diff --git a/.gitignore b/.gitignore
index 072d992c52..53a3289fa2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,11 +1,10 @@
.gradle
.settings
/.idea/
-.shelf
+/.vscode/
/run/
/build/
/eclipse/
-.vscode
.classpath
.project
/bin/
@@ -27,12 +26,14 @@ whitelist.json
*.iml
*.ipr
*.iws
-src/main/resources/mixins.*.json
+src/main/resources/mixins.*([!.]).json
*.bat
-/src/main/generated/
-/src/test/generated/
-.DS_Store
-classes
+*.DS_Store
+!gradlew.bat
.factorypath
+addon.local.gradle
+addon.local.gradle.kts
+addon.late.local.gradle
+addon.late.local.gradle.kts
/.vs
layout.json
diff --git a/src/main/java/gregtech/GT_Mod.java b/src/main/java/gregtech/GT_Mod.java
index d2bb5e7b85..fdb365a446 100644
--- a/src/main/java/gregtech/GT_Mod.java
+++ b/src/main/java/gregtech/GT_Mod.java
@@ -131,12 +131,12 @@ import ic2.api.recipe.RecipeOutput;
dependencies = " required-after:IC2;" + " required-after:structurelib;"
+ " required-after:gtnhlib@[0.0.8,);"
+ " required-after:modularui@[1.1.12,);"
+ + " required-after:appliedenergistics2@[rv3-beta-258,);"
+ " after:dreamcraft;"
+ " after:Forestry;"
+ " after:PFAAGeologica;"
+ " after:Thaumcraft;"
+ " after:Railcraft;"
- + " required-after:appliedenergistics2;"
+ " after:ThermalExpansion;"
+ " after:TwilightForest;"
+ " after:harvestcraft;"
diff --git a/src/main/java/gregtech/api/gui/modularui/GT_UITextures.java b/src/main/java/gregtech/api/gui/modularui/GT_UITextures.java
index ffeec40561..1a47e41e8c 100644
--- a/src/main/java/gregtech/api/gui/modularui/GT_UITextures.java
+++ b/src/main/java/gregtech/api/gui/modularui/GT_UITextures.java
@@ -368,18 +368,18 @@ public class GT_UITextures {
.fullImage(GregTech.ID, "gui/overlay_button/use_processing_state.png");
public static final UITexture OVERLAY_BUTTON_USE_INVERTED_PROCESSING_STATE = UITexture
.fullImage(GregTech.ID, "gui/overlay_button/use_inverted_processing_state.png");
- public static final UITexture OVERLAY_CHUNK_LOADING = UITexture
+ public static final UITexture OVERLAY_BUTTON_CHUNK_LOADING = UITexture
.fullImage(GregTech.ID, "gui/overlay_button/chunkloading");
- public static final UITexture OVERLAY_CHUNK_LOADING_OFF = UITexture
+ public static final UITexture OVERLAY_BUTTON_CHUNK_LOADING_OFF = UITexture
.fullImage(GregTech.ID, "gui/overlay_button/chunkloading_off");
- public static final UITexture OVERLAY_WORK_AREA = UITexture.fullImage(GregTech.ID, "gui/overlay_button/work_area");
- public static final UITexture OVERLAY_REPLACE_COBBLE_ON = UITexture
+ public static final UITexture OVERLAY_BUTTON_WORK_AREA = UITexture
+ .fullImage(GregTech.ID, "gui/overlay_button/work_area");
+ public static final UITexture OVERLAY_BUTTON_REPLACE_COBBLE_ON = UITexture
.fullImage(GregTech.ID, "gui/overlay_button/replace_cobble_on");
- public static final UITexture OVERLAY_REPLACE_COBBLE_OFF = UITexture
+ public static final UITexture OVERLAY_BUTTON_REPLACE_COBBLE_OFF = UITexture
.fullImage(GregTech.ID, "gui/overlay_button/replace_cobble_off");
- public static final UITexture OVERLAY_RETRACT_PIPE = UITexture
+ public static final UITexture OVERLAY_BUTTON_RETRACT_PIPE = UITexture
.fullImage(GregTech.ID, "gui/overlay_button/retract_pipes");
-
public static final UITexture OVERLAY_BUTTON_HOURGLASS = UITexture
.fullImage(GregTech.ID, "gui/overlay_button/hourglass");
diff --git a/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java
index 1ac42a2ea1..6267e7b3da 100644
--- a/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java
+++ b/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java
@@ -1203,21 +1203,11 @@ public abstract class MetaTileEntity implements IMetaTileEntity, ICleanroomRecei
.name()));
if (this instanceof IPowerChannelState state) {
- // adapted from PowerStateWailaDataProvider
final NBTTagCompound tag = accessor.getNBTData();
final boolean isActive = tag.getBoolean("isActive");
final boolean isPowered = tag.getBoolean("isPowered");
final boolean isBooting = tag.getBoolean("isBooting");
-
- if (isBooting) {
- currenttip.add(WailaText.Booting.getLocal());
- } else if (isActive && isPowered) {
- currenttip.add(WailaText.DeviceOnline.getLocal());
- } else if (isPowered) {
- currenttip.add(WailaText.DeviceMissingChannel.getLocal());
- } else {
- currenttip.add(WailaText.DeviceOffline.getLocal());
- }
+ currenttip.add(WailaText.getPowerState(isActive, isPowered, isBooting));
}
}
@@ -1225,7 +1215,6 @@ public abstract class MetaTileEntity implements IMetaTileEntity, ICleanroomRecei
public void getWailaNBTData(EntityPlayerMP player, TileEntity tile, NBTTagCompound tag, World world, int x, int y,
int z) {
if (this instanceof IPowerChannelState state) {
- // adapted from PowerStateWailaDataProvider
final boolean isActive = state.isActive();
final boolean isPowered = state.isPowered();
final boolean isBooting = state.isBooting();
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus.java
index 0102b698dd..e7cddffc12 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus.java
@@ -30,6 +30,8 @@ import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.modularui.IAddUIWidgets;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.metatileentity.MetaTileEntity;
+import gregtech.api.recipe.check.CheckRecipeResult;
+import gregtech.api.recipe.check.CheckRecipeResultRegistry;
import gregtech.api.render.TextureFactory;
import gregtech.api.util.GT_ClientPreference;
import gregtech.api.util.GT_OreDictUnificator;
@@ -262,8 +264,27 @@ public class GT_MetaTileEntity_Hatch_InputBus extends GT_MetaTileEntity_Hatch
return mInventory[aIndex] == null;
}
+ /**
+ * Called when multiblock controller starts processing.
+ * {@link #endRecipeProcessing(GT_MetaTileEntity_MultiBlockBase)} is called on the same tick.
+ */
public void startRecipeProcessing() {}
+ /**
+ * Called when multiblock controller ends processing. {@link #startRecipeProcessing()} is called on the same tick.
+ *
+ * @param controller Caller of this method.
+ * @return Result of the process of this method. {@code !wasSuccessful()} means the returned result should
+ * overwrite the result calculated on multiblock whatever the reason is.
+ */
+ public CheckRecipeResult endRecipeProcessing(GT_MetaTileEntity_MultiBlockBase controller) {
+ endRecipeProcessing();
+ return CheckRecipeResultRegistry.SUCCESSFUL;
+ }
+
+ /**
+ * Simple version of {@link #endRecipeProcessing(GT_MetaTileEntity_MultiBlockBase)}. Maybe use it instead.
+ */
public void endRecipeProcessing() {}
@Override
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java
index 2412e0e8ff..d9d5f4c731 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java
@@ -12,7 +12,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
-import java.util.HashMap;
import java.util.List;
import java.util.Optional;
import java.util.function.Function;
@@ -89,7 +88,6 @@ import gregtech.client.GT_SoundLoop;
import gregtech.common.GT_Pollution;
import gregtech.common.gui.modularui.widget.CheckRecipeResultSyncer;
import gregtech.common.items.GT_MetaGenerated_Tool_01;
-import gregtech.common.tileentities.machines.GT_MetaTileEntity_Hatch_InputBus_ME;
import gregtech.common.tileentities.machines.GT_MetaTileEntity_Hatch_OutputBus_ME;
import gregtech.common.tileentities.machines.GT_MetaTileEntity_Hatch_Output_ME;
import gregtech.common.tileentities.machines.IDualInputHatch;
@@ -120,7 +118,6 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity
protected VoidingMode voidingMode = getDefaultVoidingMode();
protected boolean batchMode = getDefaultBatchMode();
private @Nonnull CheckRecipeResult checkRecipeResult = CheckRecipeResultRegistry.NONE;
- private boolean isScheduledForResetCheckRecipeResult;
protected static final String INPUT_SEPARATION_NBT_KEY = "inputSeparation";
protected static final String VOID_EXCESS_NBT_KEY = "voidExcess";
@@ -179,7 +176,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity
}
/**
- * @deprecated Use {@link GT_Utility#filterValidMTEs)}
+ * @deprecated Use {@link GT_Utility#filterValidMTEs}
*/
@Deprecated
public static <T extends MetaTileEntity> List<T> filterValidMetaTileEntities(Collection<T> metaTileEntities) {
@@ -445,8 +442,6 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity
if (aBaseMetaTileEntity.isServerSide()) {
aBaseMetaTileEntity.disableWorking();
checkRecipeResult = CheckRecipeResultRegistry.CRASH;
- // Don't let `onSetActive` to overwrite
- isScheduledForResetCheckRecipeResult = false;
}
}
@@ -499,7 +494,8 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity
}
this.checkRecipeResult = result;
endRecipeProcessing();
- return result.wasSuccessful();
+ // Don't use `result` here because `endRecipeProcessing()` might mutate `this.checkRecipeResult`
+ return this.checkRecipeResult.wasSuccessful();
}
private boolean shouldCheckRecipeThisTick(long aTick) {
@@ -896,13 +892,13 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity
public void stopMachine() {
mOutputItems = null;
+ mOutputFluids = null;
mEUt = 0;
mEfficiency = 0;
mProgresstime = 0;
mMaxProgresstime = 0;
mEfficiencyIncrease = 0;
getBaseMetaTileEntity().disableWorking();
- checkRecipeResult = CheckRecipeResultRegistry.NONE;
}
public void criticalStopMachine() {
@@ -1369,26 +1365,19 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity
}
ArrayList<ItemStack> rList = new ArrayList<>();
- HashMap<String, ItemStack> rInputBusMeList = new HashMap<>();
for (GT_MetaTileEntity_Hatch_InputBus tHatch : filterValidMTEs(mInputBusses)) {
tHatch.mRecipeMap = getRecipeMap();
IGregTechTileEntity tileEntity = tHatch.getBaseMetaTileEntity();
- if (tHatch instanceof GT_MetaTileEntity_Hatch_InputBus_ME) {
- for (int i = tileEntity.getSizeInventory() - 1; i >= 0; i--) {
- ItemStack itemStack = tileEntity.getStackInSlot(i);
- if (itemStack != null) rInputBusMeList.put(itemStack.toString(), itemStack);
- }
- } else {
- for (int i = tileEntity.getSizeInventory() - 1; i >= 0; i--) {
- ItemStack itemStack = tileEntity.getStackInSlot(i);
- if (itemStack != null) rList.add(itemStack);
+ for (int i = tileEntity.getSizeInventory() - 1; i >= 0; i--) {
+ ItemStack itemStack = tileEntity.getStackInSlot(i);
+ if (itemStack != null) {
+ rList.add(itemStack);
}
}
}
if (getStackInSlot(1) != null && getStackInSlot(1).getUnlocalizedName()
.startsWith("gt.integrated_circuit")) rList.add(getStackInSlot(1));
- if (!rInputBusMeList.isEmpty()) rList.addAll(rInputBusMeList.values());
return rList;
}
@@ -1413,21 +1402,18 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity
}
protected void startRecipeProcessing() {
- for (GT_MetaTileEntity_Hatch_InputBus tHatch : filterValidMTEs(mInputBusses)) tHatch.startRecipeProcessing();
+ for (GT_MetaTileEntity_Hatch_InputBus hatch : filterValidMTEs(mInputBusses)) {
+ hatch.startRecipeProcessing();
+ }
}
protected void endRecipeProcessing() {
- for (GT_MetaTileEntity_Hatch_InputBus tHatch : filterValidMTEs(mInputBusses)) tHatch.endRecipeProcessing();
- }
-
- protected static <T extends GT_MetaTileEntity_Hatch> T identifyHatch(IGregTechTileEntity aTileEntity,
- int aBaseCasingIndex, Class<T> clazz) {
- if (aTileEntity == null) return null;
- IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();
- if (!clazz.isInstance(aMetaTileEntity)) return null;
- T hatch = clazz.cast(aMetaTileEntity);
- hatch.updateTexture(aBaseCasingIndex);
- return hatch;
+ for (GT_MetaTileEntity_Hatch_InputBus hatch : filterValidMTEs(mInputBusses)) {
+ CheckRecipeResult result = hatch.endRecipeProcessing(this);
+ if (!result.wasSuccessful()) {
+ this.checkRecipeResult = result;
+ }
+ }
}
public boolean addToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) {
@@ -1823,20 +1809,6 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity
}
}
- @Override
- public void onSetActive(boolean active) {
- if (isScheduledForResetCheckRecipeResult && !active) {
- checkRecipeResult = CheckRecipeResultRegistry.NONE;
- isScheduledForResetCheckRecipeResult = false;
- }
- }
-
- @Override
- public void onDisableWorking() {
- // This prevents deleting result instantly when turning off machine
- isScheduledForResetCheckRecipeResult = true;
- }
-
protected void setMufflers(boolean state) {
for (GT_MetaTileEntity_Hatch_Muffler aMuffler : mMufflerHatches) {
final IGregTechTileEntity iGTTileEntity = aMuffler.getBaseMetaTileEntity();
@@ -2301,8 +2273,10 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity
.setSynced(false)
.setTextAlignment(Alignment.CenterLeft)
.setEnabled(
- widget -> GT_Utility.isStringValid(checkRecipeResult.getDisplayString())
- && shouldDisplayCheckRecipeResult()))
+ widget -> shouldDisplayCheckRecipeResult()
+ && GT_Utility.isStringValid(checkRecipeResult.getDisplayString())
+ && (isAllowedToWork() || getBaseMetaTileEntity().isActive()
+ || checkRecipeResult.persistsOnShutdown())))
.widget(new CheckRecipeResultSyncer(() -> checkRecipeResult, (result) -> checkRecipeResult = result));
if (showRecipeTextInGUI()) {
diff --git a/src/main/java/gregtech/api/recipe/check/CheckRecipeResult.java b/src/main/java/gregtech/api/recipe/check/CheckRecipeResult.java
index ab1db6ecd2..eeb01077de 100644
--- a/src/main/java/gregtech/api/recipe/check/CheckRecipeResult.java
+++ b/src/main/java/gregtech/api/recipe/check/CheckRecipeResult.java
@@ -39,4 +39,11 @@ public interface CheckRecipeResult {
* Decode synced value.
*/
void decode(PacketBuffer buffer);
+
+ /**
+ * @return If this message should stay on GUI when the machine is shut down.
+ */
+ default boolean persistsOnShutdown() {
+ return false;
+ }
}
diff --git a/src/main/java/gregtech/api/recipe/check/CheckRecipeResultRegistry.java b/src/main/java/gregtech/api/recipe/check/CheckRecipeResultRegistry.java
index ad0d56708e..f162c892ee 100644
--- a/src/main/java/gregtech/api/recipe/check/CheckRecipeResultRegistry.java
+++ b/src/main/java/gregtech/api/recipe/check/CheckRecipeResultRegistry.java
@@ -59,7 +59,7 @@ public final class CheckRecipeResultRegistry {
/**
* Code crashed.
*/
- public static final CheckRecipeResult CRASH = SimpleCheckRecipeResult.ofFailure("crash");
+ public static final CheckRecipeResult CRASH = SimpleCheckRecipeResult.ofFailurePersistOnShutdown("crash");
/**
* Cannot find valid fuel for generator.
*/
@@ -121,7 +121,7 @@ public final class CheckRecipeResultRegistry {
}
static {
- register(new SimpleCheckRecipeResult(false, ""));
+ register(new SimpleCheckRecipeResult(false, "", false));
register(new ResultInsufficientPower(0));
register(new ResultInsufficientHeat(0));
register(new ResultInsufficientMachineTier(0));
diff --git a/src/main/java/gregtech/api/recipe/check/SimpleCheckRecipeResult.java b/src/main/java/gregtech/api/recipe/check/SimpleCheckRecipeResult.java
index 767a168125..ed4c95f880 100644
--- a/src/main/java/gregtech/api/recipe/check/SimpleCheckRecipeResult.java
+++ b/src/main/java/gregtech/api/recipe/check/SimpleCheckRecipeResult.java
@@ -14,10 +14,12 @@ public class SimpleCheckRecipeResult implements CheckRecipeResult {
private boolean success;
private String key;
+ private boolean persistsOnShutdown;
- SimpleCheckRecipeResult(boolean success, String key) {
+ SimpleCheckRecipeResult(boolean success, String key, boolean persistsOnShutdown) {
this.success = success;
this.key = key;
+ this.persistsOnShutdown = persistsOnShutdown;
}
@Override
@@ -37,19 +39,26 @@ public class SimpleCheckRecipeResult implements CheckRecipeResult {
@Override
public CheckRecipeResult newInstance() {
- return new SimpleCheckRecipeResult(false, "");
+ return new SimpleCheckRecipeResult(false, "", false);
}
@Override
public void encode(PacketBuffer buffer) {
buffer.writeBoolean(success);
NetworkUtils.writeStringSafe(buffer, key);
+ buffer.writeBoolean(persistsOnShutdown);
}
@Override
public void decode(PacketBuffer buffer) {
success = buffer.readBoolean();
key = NetworkUtils.readStringSafe(buffer);
+ persistsOnShutdown = buffer.readBoolean();
+ }
+
+ @Override
+ public boolean persistsOnShutdown() {
+ return persistsOnShutdown;
}
@Override
@@ -57,7 +66,8 @@ public class SimpleCheckRecipeResult implements CheckRecipeResult {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
SimpleCheckRecipeResult that = (SimpleCheckRecipeResult) o;
- return success == that.success && Objects.equals(key, that.key);
+ return success == that.success && Objects.equals(key, that.key)
+ && persistsOnShutdown == that.persistsOnShutdown;
}
/**
@@ -65,14 +75,22 @@ public class SimpleCheckRecipeResult implements CheckRecipeResult {
* This is already registered to registry.
*/
public static CheckRecipeResult ofSuccess(String key) {
- return new SimpleCheckRecipeResult(true, key);
+ return new SimpleCheckRecipeResult(true, key, false);
}
/**
- * Creates new result object with failed state. Add your localized description with `GT5U.gui.text.{key}`.
+ * Creates new result with failed state. Add your localized description with `GT5U.gui.text.{key}`.
* This is already registered to registry.
*/
public static CheckRecipeResult ofFailure(String key) {
- return new SimpleCheckRecipeResult(false, key);
+ return new SimpleCheckRecipeResult(false, key, false);
+ }
+
+ /**
+ * Creates new result object with failed state that does not get reset on shutdown. Add your localized description
+ * with `GT5U.gui.text.{key}`. This is already registered to registry.
+ */
+ public static CheckRecipeResult ofFailurePersistOnShutdown(String key) {
+ return new SimpleCheckRecipeResult(false, key, true);
}
}
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 34f038b2ea..1e7dc28e91 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
@@ -3,7 +3,8 @@ package gregtech.common.tileentities.machines;
import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_ME_INPUT_HATCH;
import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_ME_INPUT_HATCH_ACTIVE;
-import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
import java.util.EnumSet;
import java.util.Iterator;
import java.util.List;
@@ -16,20 +17,20 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
-import net.minecraft.util.ChatComponentText;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.EnumChatFormatting;
+import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
-import com.google.common.collect.ImmutableList;
+import com.gtnewhorizons.modularui.api.ModularUITextures;
import com.gtnewhorizons.modularui.api.drawable.IDrawable;
-import com.gtnewhorizons.modularui.api.drawable.UITexture;
import com.gtnewhorizons.modularui.api.math.Alignment;
import com.gtnewhorizons.modularui.api.math.Color;
import com.gtnewhorizons.modularui.api.math.Size;
import com.gtnewhorizons.modularui.api.screen.ModularWindow;
import com.gtnewhorizons.modularui.api.screen.UIBuildContext;
+import com.gtnewhorizons.modularui.common.internal.wrapper.BaseSlot;
import com.gtnewhorizons.modularui.common.widget.ButtonWidget;
import com.gtnewhorizons.modularui.common.widget.DrawableWidget;
import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget;
@@ -48,6 +49,7 @@ import appeng.api.networking.security.MachineSource;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.util.AECableType;
+import appeng.core.localization.WailaText;
import appeng.me.GridAccessException;
import appeng.me.helpers.AENetworkProxy;
import appeng.me.helpers.IGridProxyable;
@@ -61,6 +63,10 @@ import gregtech.api.interfaces.modularui.IAddUIWidgets;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.metatileentity.MetaTileEntity;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus;
+import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase;
+import gregtech.api.recipe.check.CheckRecipeResult;
+import gregtech.api.recipe.check.CheckRecipeResultRegistry;
+import gregtech.api.recipe.check.SimpleCheckRecipeResult;
import gregtech.api.render.TextureFactory;
import gregtech.api.util.GT_Utility;
import gregtech.common.gui.modularui.widget.AESlotWidget;
@@ -140,9 +146,9 @@ public class GT_MetaTileEntity_Hatch_InputBus_ME extends GT_MetaTileEntity_Hatch
public void setAdditionalConnectionOption() {
if (additionalConnection) {
- gridProxy.setValidSides(EnumSet.complementOf(EnumSet.of(ForgeDirection.UNKNOWN)));
+ getProxy().setValidSides(EnumSet.complementOf(EnumSet.of(ForgeDirection.UNKNOWN)));
} else {
- gridProxy.setValidSides(EnumSet.of(getBaseMetaTileEntity().getFrontFacing()));
+ getProxy().setValidSides(EnumSet.of(getBaseMetaTileEntity().getFrontFacing()));
}
}
@@ -176,9 +182,6 @@ public class GT_MetaTileEntity_Hatch_InputBus_ME extends GT_MetaTileEntity_Hatch
}
@Override
- public void gridChanged() {}
-
- @Override
public boolean isPowered() {
return getProxy() != null && getProxy().isPowered();
}
@@ -260,7 +263,9 @@ public class GT_MetaTileEntity_Hatch_InputBus_ME extends GT_MetaTileEntity_Hatch
@Override
public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) {
setAutoPullItemList(!autoPullItemList);
- GT_Utility.sendChatToPlayer(aPlayer, "Automatic Item Pull " + autoPullItemList);
+ aPlayer.addChatMessage(
+ new ChatComponentTranslation(
+ "GT5U.machines.stocking_bus.auto_pull_toggle." + (autoPullItemList ? "enabled" : "disabled")));
}
@Override
@@ -295,7 +300,7 @@ public class GT_MetaTileEntity_Hatch_InputBus_ME extends GT_MetaTileEntity_Hatch
}
setInventorySlotContents(getCircuitSlot(), circuit);
setAdditionalConnectionOption();
- aPlayer.addChatMessage(new ChatComponentText("Loaded Config From Data Stick"));
+ aPlayer.addChatMessage(new ChatComponentTranslation("GT5U.machines.stocking_bus.loaded"));
return true;
}
@@ -323,7 +328,7 @@ public class GT_MetaTileEntity_Hatch_InputBus_ME extends GT_MetaTileEntity_Hatch
}
dataStick.stackTagCompound = tag;
dataStick.setStackDisplayName("Stocking Input Bus Configuration");
- aPlayer.addChatMessage(new ChatComponentText("Saved Config to Data Stick"));
+ aPlayer.addChatMessage(new ChatComponentTranslation("GT5U.machines.stocking_bus.saved"));
}
private int getManualSlot() {
@@ -435,7 +440,8 @@ public class GT_MetaTileEntity_Hatch_InputBus_ME extends GT_MetaTileEntity_Hatch
}
@Override
- public void endRecipeProcessing() {
+ public CheckRecipeResult endRecipeProcessing(GT_MetaTileEntity_MultiBlockBase controller) {
+ CheckRecipeResult checkRecipeResult = CheckRecipeResultRegistry.SUCCESSFUL;
for (int i = 0; i < SLOT_COUNT; ++i) {
if (savedStackSizes[i] != 0) {
ItemStack oldStack = shadowInventory[i];
@@ -445,11 +451,17 @@ public class GT_MetaTileEntity_Hatch_InputBus_ME extends GT_MetaTileEntity_Hatch
IMEMonitor<IAEItemStack> sg = proxy.getStorage()
.getItemInventory();
IAEItemStack request = AEItemStack.create(mInventory[i]);
- request.setStackSize(savedStackSizes[i] - (oldStack == null ? 0 : oldStack.stackSize));
- sg.extractItems(request, Actionable.MODULATE, getRequestSource());
+ int toExtract = savedStackSizes[i] - (oldStack == null ? 0 : oldStack.stackSize);
+ request.setStackSize(toExtract);
+ IAEItemStack result = sg.extractItems(request, Actionable.MODULATE, getRequestSource());
proxy.getEnergy()
.extractAEPower(request.getStackSize(), Actionable.MODULATE, PowerMultiplier.CONFIG);
setInventorySlotContents(i + SLOT_COUNT, oldStack);
+ if (result == null || result.getStackSize() != toExtract) {
+ controller.criticalStopMachine();
+ checkRecipeResult = SimpleCheckRecipeResult
+ .ofFailurePersistOnShutdown("stocking_bus_fail_extraction");
+ }
} catch (final GridAccessException ignored) {}
}
savedStackSizes[i] = 0;
@@ -457,6 +469,7 @@ public class GT_MetaTileEntity_Hatch_InputBus_ME extends GT_MetaTileEntity_Hatch
}
}
processingRecipe = false;
+ return checkRecipeResult;
}
public ItemStack updateInformationSlot(int aIndex, ItemStack aStack) {
@@ -490,6 +503,11 @@ public class GT_MetaTileEntity_Hatch_InputBus_ME extends GT_MetaTileEntity_Hatch
}
@Override
+ public int getGUIHeight() {
+ return 179;
+ }
+
+ @Override
public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) {
final SlotWidget[] aeSlotWidgets = new SlotWidget[16];
buildContext.addSyncedWindow(CONFIG_WINDOW_ID, this::createStackSizeConfigurationWindow);
@@ -498,12 +516,18 @@ public class GT_MetaTileEntity_Hatch_InputBus_ME extends GT_MetaTileEntity_Hatch
.startFromSlot(0)
.endAtSlot(15)
.phantom(true)
- .background(getGUITextureSet().getItemSlot(), GT_UITextures.OVERLAY_SLOT_ARROW_ME)
- .widgetCreator(slot -> new SlotWidget(slot) {
+ .slotCreator(index -> new BaseSlot(inventoryHandler, index, true) {
+
+ @Override
+ public boolean isEnabled() {
+ return !autoPullItemList && super.isEnabled();
+ }
+ })
+ .widgetCreator(slot -> (SlotWidget) new SlotWidget(slot) {
@Override
protected void phantomClick(ClickData clickData, ItemStack cursorStack) {
- if (clickData.mouseButton != 0 || autoPullItemList) return;
+ if (clickData.mouseButton != 0 || !getMcSlot().isEnabled()) return;
final int aSlotIndex = getMcSlot().getSlotIndex();
if (cursorStack == null) {
getMcSlot().putStack(null);
@@ -518,13 +542,43 @@ public class GT_MetaTileEntity_Hatch_InputBus_ME extends GT_MetaTileEntity_Hatch
}
}
+ @Override
+ public IDrawable[] getBackground() {
+ IDrawable slot;
+ if (autoPullItemList) {
+ slot = GT_UITextures.SLOT_DARK_GRAY;
+ } else {
+ slot = ModularUITextures.ITEM_SLOT;
+ }
+ return new IDrawable[] { slot, GT_UITextures.OVERLAY_SLOT_ARROW_ME };
+ }
+
+ @Override
+ public List<String> getExtraTooltip() {
+ if (autoPullItemList) {
+ return Collections.singletonList(
+ StatCollector.translateToLocal("GT5U.machines.stocking_bus.cannot_set_slot"));
+ } else {
+ return Collections
+ .singletonList(StatCollector.translateToLocal("modularui.phantom.single.clear"));
+ }
+ }
+
private boolean containsSuchStack(ItemStack tStack) {
for (int i = 0; i < 16; ++i) {
if (GT_Utility.areStacksEqual(mInventory[i], tStack, false)) return true;
}
return false;
}
+ }.dynamicTooltip(() -> {
+ if (autoPullItemList) {
+ return Collections.singletonList(
+ StatCollector.translateToLocal("GT5U.machines.stocking_bus.cannot_set_slot"));
+ } else {
+ return Collections.emptyList();
+ }
})
+ .setUpdateTooltipEveryTick(true))
.build()
.setPos(7, 9))
.widget(
@@ -549,26 +603,37 @@ public class GT_MetaTileEntity_Hatch_InputBus_ME extends GT_MetaTileEntity_Hatch
.openSyncedWindow(CONFIG_WINDOW_ID);
}
})
- .setPlayClickSound(true)
.setBackground(() -> {
- List<UITexture> ret = new ArrayList<>();
- ret.add(GT_UITextures.BUTTON_STANDARD);
- if (autoPullItemList) ret.add(GT_UITextures.OVERLAY_BUTTON_AUTOPULL_ME);
- else ret.add(GT_UITextures.OVERLAY_BUTTON_AUTOPULL_ME_DISABLED);
- return ret.toArray(new IDrawable[0]);
+ if (autoPullItemList) {
+ return new IDrawable[] { GT_UITextures.BUTTON_STANDARD_PRESSED,
+ GT_UITextures.OVERLAY_BUTTON_AUTOPULL_ME };
+ } else {
+ return new IDrawable[] { GT_UITextures.BUTTON_STANDARD,
+ GT_UITextures.OVERLAY_BUTTON_AUTOPULL_ME_DISABLED };
+ }
})
.addTooltips(
- ImmutableList.of(
- "Click to toggle automatic item pulling from ME.",
- "Right-Click to edit minimum stack size for item pulling."))
+ Arrays.asList(
+ StatCollector.translateToLocal("GT5U.machines.stocking_bus.auto_pull.tooltip"),
+ StatCollector.translateToLocal("GT5U.machines.stocking_bus.auto_pull.tooltip.1")))
.setSize(16, 16)
.setPos(80, 10))
.widget(new FakeSyncWidget.BooleanSyncer(() -> autoPullItemList, this::setAutoPullItemList))
+ .widget(TextWidget.dynamicString(() -> {
+ boolean isActive = isActive();
+ boolean isPowered = isPowered();
+ boolean isBooting = isBooting();
+ EnumChatFormatting color = (isActive && isPowered) ? EnumChatFormatting.GREEN
+ : EnumChatFormatting.DARK_RED;
+ return color + WailaText.getPowerState(isActive, isPowered, isBooting);
+ })
+ .setTextAlignment(Alignment.Center)
+ .setSize(90, 9)
+ .setPos(43, 84))
.widget(
new SlotWidget(inventoryHandler, getManualSlot())
// ghost slots are prioritized over manual slot
.setShiftClickPriority(11)
- .setBackground(getGUITextureSet().getItemSlot())
.setPos(79, 45));
}
@@ -587,7 +652,8 @@ public class GT_MetaTileEntity_Hatch_InputBus_ME extends GT_MetaTileEntity_Hatch
Alignment.TopRight.getAlignedPos(new Size(PARENT_WIDTH, PARENT_HEIGHT), new Size(WIDTH, HEIGHT))
.add(WIDTH - 3, 0)));
builder.widget(
- new TextWidget("Min Stack Size").setPos(3, 2)
+ TextWidget.localised("GT5U.machines.stocking_bus.min_stack_size")
+ .setPos(3, 2)
.setSize(74, 14))
.widget(
new TextFieldWidget().setSetterInt(val -> minAutoPullStackSize = val)
@@ -616,8 +682,14 @@ public class GT_MetaTileEntity_Hatch_InputBus_ME extends GT_MetaTileEntity_Hatch
NBTTagCompound tag = accessor.getNBTData();
boolean autopull = tag.getBoolean("autoPull");
int minSize = tag.getInteger("minStackSize");
- currenttip.add(String.format("Auto-Pull from ME: %s", autopull ? "Enabled" : "Disabled"));
- if (autopull) currenttip.add(String.format("Minimum Stack Size: %d", minSize));
+ currenttip.add(
+ StatCollector.translateToLocal("GT5U.waila.stocking_bus.auto_pull." + (autopull ? "enabled" : "disabled")));
+ if (autopull) {
+ currenttip.add(
+ StatCollector.translateToLocalFormatted(
+ "GT5U.waila.stocking_bus.min_stack_size",
+ GT_Utility.formatNumbers(minSize)));
+ }
super.getWailaBody(itemStack, currenttip, accessor, config);
}
diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java
index 6470065923..e884922710 100644
--- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java
+++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java
@@ -845,9 +845,10 @@ public abstract class GT_MetaTileEntity_DrillerBase
.setBackground(() -> {
if (mChunkLoadingEnabled) {
return new IDrawable[] { GT_UITextures.BUTTON_STANDARD_PRESSED,
- GT_UITextures.OVERLAY_CHUNK_LOADING };
+ GT_UITextures.OVERLAY_BUTTON_CHUNK_LOADING };
}
- return new IDrawable[] { GT_UITextures.BUTTON_STANDARD, GT_UITextures.OVERLAY_CHUNK_LOADING_OFF };
+ return new IDrawable[] { GT_UITextures.BUTTON_STANDARD,
+ GT_UITextures.OVERLAY_BUTTON_CHUNK_LOADING_OFF };
})
.attachSyncer(
new FakeSyncWidget.BooleanSyncer(
@@ -869,9 +870,10 @@ public abstract class GT_MetaTileEntity_DrillerBase
.setBackground(() -> {
if (workState == STATE_ABORT) {
return new IDrawable[] { GT_UITextures.BUTTON_STANDARD_PRESSED,
- GT_UITextures.OVERLAY_RETRACT_PIPE, GT_UITextures.OVERLAY_BUTTON_LOCKED };
+ GT_UITextures.OVERLAY_BUTTON_RETRACT_PIPE, GT_UITextures.OVERLAY_BUTTON_LOCKED };
}
- return new IDrawable[] { GT_UITextures.BUTTON_STANDARD, GT_UITextures.OVERLAY_RETRACT_PIPE };
+ return new IDrawable[] { GT_UITextures.BUTTON_STANDARD,
+ GT_UITextures.OVERLAY_BUTTON_RETRACT_PIPE };
})
.attachSyncer(
new FakeSyncWidget.IntegerSyncer(() -> workState, (newInt) -> workState = newInt),
diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlantBase.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlantBase.java
index a48bb1dee8..935c8c0032 100644
--- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlantBase.java
+++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlantBase.java
@@ -638,7 +638,7 @@ public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTile
(ButtonWidget) new GT_LockedWhileActiveButton(this.getBaseMetaTileEntity(), builder)
.setOnClick((clickData, widget) -> adjustChunkRadius(clickData.mouseButton == 0))
.setPlayClickSound(true)
- .setBackground(GT_UITextures.BUTTON_STANDARD, GT_UITextures.OVERLAY_WORK_AREA)
+ .setBackground(GT_UITextures.BUTTON_STANDARD, GT_UITextures.OVERLAY_BUTTON_WORK_AREA)
.attachSyncer(
new FakeSyncWidget.IntegerSyncer(() -> chunkRadiusConfig, (val) -> chunkRadiusConfig = val),
builder,
@@ -657,9 +657,10 @@ public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTile
.setBackground(() -> {
if (replaceWithCobblestone) {
return new IDrawable[] { GT_UITextures.BUTTON_STANDARD_PRESSED,
- GT_UITextures.OVERLAY_REPLACE_COBBLE_ON };
+ GT_UITextures.OVERLAY_BUTTON_REPLACE_COBBLE_ON };
}
- return new IDrawable[] { GT_UITextures.BUTTON_STANDARD, GT_UITextures.OVERLAY_REPLACE_COBBLE_OFF };
+ return new IDrawable[] { GT_UITextures.BUTTON_STANDARD,
+ GT_UITextures.OVERLAY_BUTTON_REPLACE_COBBLE_OFF };
})
.attachSyncer(
new FakeSyncWidget.BooleanSyncer(
diff --git a/src/main/resources/assets/gregtech/lang/en_US.lang b/src/main/resources/assets/gregtech/lang/en_US.lang
index b9000ea98a..520c949178 100644
--- a/src/main/resources/assets/gregtech/lang/en_US.lang
+++ b/src/main/resources/assets/gregtech/lang/en_US.lang
@@ -334,6 +334,14 @@ GT5U.machines.allow_nbt.tooltip=Allow items with NBT
GT5U.machines.allow_nbt.tooltip.extended=§7By default, all items with NBT are blocked.
GT5U.machines.ignore_nbt.tooltip=Ignore item NBT
GT5U.machines.ignore_nbt.tooltip.extended=§7By default, item NBT must match.
+GT5U.machines.stocking_bus.cannot_set_slot=§8Cannot set slot while auto-pull mode
+GT5U.machines.stocking_bus.auto_pull.tooltip=Click to toggle automatic item pulling from ME.
+GT5U.machines.stocking_bus.auto_pull.tooltip.1=Right-Click to edit minimum stack size for item pulling.
+GT5U.machines.stocking_bus.min_stack_size=Min Stack Size
+GT5U.machines.stocking_bus.auto_pull_toggle.enabled=Automatic Item Pull Enabled
+GT5U.machines.stocking_bus.auto_pull_toggle.disabled=Automatic Item Pull Disabled
+GT5U.machines.stocking_bus.saved=Saved Config to Data Stick
+GT5U.machines.stocking_bus.loaded=Loaded Config From Data Stick
GT5U.recipe_filter.empty_representation_slot.tooltip=§7Click with a machine to set filter
GT5U.recipe_filter.representation_slot.tooltip=§7Click to clear
@@ -410,6 +418,7 @@ GT5U.gui.text.drill_ores_left_layer=Ores left at y-level %s: §a%s
GT5U.gui.text.drill_chunks_left=Drilling chunk: §a%s / %s
GT5U.gui.text.drill_offline_reason=Drill Offline: %s
GT5U.gui.text.drill_offline_generic=Drill Offline
+GT5U.gui.text.stocking_bus_fail_extraction=§4Failed to extract expected amount of items from stocking bus. This can be caused by attaching multiple storage buses to the same inventory.
GT5U.item.programmed_circuit.select.header=Reprogram Circuit
@@ -539,6 +548,9 @@ GT5U.waila.energy.use=Probably uses: §e%s§r EU/t (%s)
GT5U.waila.energy.use_with_amperage=Probably uses: §e%s§r EU/t (%sA %s)
GT5U.waila.energy.produce=Probably generates: §a%s§r EU/t (%s)
GT5U.waila.energy.produce_with_amperage=Probably generates: §a%s§r EU/t (%sA %s)
+GT5U.waila.stocking_bus.auto_pull.enabled=Auto-Pull from ME: Enabled
+GT5U.waila.stocking_bus.auto_pull.disabled=Auto-Pull from ME: Disabled
+GT5U.waila.stocking_bus.min_stack_size=Minimum Stack Size: %s
achievement.flintpick=First Tools
achievement.flintpick.desc=Craft a flint pick