aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api/metatileentity/implementations
diff options
context:
space:
mode:
authorMartin Robertz <dream-master@gmx.net>2021-11-20 09:42:31 +0100
committerGitHub <noreply@github.com>2021-11-20 09:42:31 +0100
commit182dffe8e1d2ed0f96c80b40764c121da5c39f53 (patch)
tree13f03f2d23ce7e33bd0c70d19cd7a24b26a21240 /src/main/java/gregtech/api/metatileentity/implementations
parent36ab4741d560e11bc906d4173445a0a06a5b08da (diff)
parent1dd66efceca26d9931010adb24932bba408ca630 (diff)
downloadGT5-Unofficial-182dffe8e1d2ed0f96c80b40764c121da5c39f53.tar.gz
GT5-Unofficial-182dffe8e1d2ed0f96c80b40764c121da5c39f53.tar.bz2
GT5-Unofficial-182dffe8e1d2ed0f96c80b40764c121da5c39f53.zip
Merge pull request #732 from D-Cysteine/lock-single-recipe
[Proof of concept] Allow locking multi-block machines to a single recipe, to reduce server cost
Diffstat (limited to 'src/main/java/gregtech/api/metatileentity/implementations')
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java24
1 files changed, 24 insertions, 0 deletions
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 7a2f1bedac..6369c48f8e 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
@@ -13,6 +13,7 @@ import gregtech.api.objects.GT_ItemStack;
import gregtech.api.util.GT_Log;
import gregtech.api.util.GT_ModHandler;
import gregtech.api.util.GT_Recipe.GT_Recipe_Map;
+import gregtech.api.util.GT_Single_Recipe_Check;
import gregtech.api.util.GT_Utility;
import gregtech.common.GT_Pollution;
import gregtech.common.items.GT_MetaGenerated_Tool_01;
@@ -43,6 +44,9 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity {
public int damageFactorLow = 5;
public float damageFactorHigh = 0.6f;
+ public boolean mLockedToSingleRecipe = false;
+ public GT_Single_Recipe_Check mSingleRecipeCheck = null;
+
public ArrayList<GT_MetaTileEntity_Hatch_Input> mInputHatches = new ArrayList<>();
public ArrayList<GT_MetaTileEntity_Hatch_Output> mOutputHatches = new ArrayList<>();
public ArrayList<GT_MetaTileEntity_Hatch_InputBus> mInputBusses = new ArrayList<>();
@@ -81,6 +85,24 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity {
return aSide != getBaseMetaTileEntity().getFrontFacing();
}
+ /** Override this if you are a multi-block that has added support for single recipe locking. */
+ public boolean supportsSingleRecipeLocking() {
+ return false;
+ }
+
+ @Override
+ public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) {
+ if (supportsSingleRecipeLocking()) {
+ mLockedToSingleRecipe = !mLockedToSingleRecipe;
+ if (mLockedToSingleRecipe) {
+ GT_Utility.sendChatToPlayer(aPlayer, trans("219","Single recipe locking enabled. Will lock to next recipe."));
+ } else {
+ GT_Utility.sendChatToPlayer(aPlayer, trans("220","Single recipe locking disabled."));
+ mSingleRecipeCheck = null;
+ }
+ }
+ }
+
@Override
public boolean isSimpleMachine() {
return false;
@@ -125,6 +147,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity {
aNBT.setInteger("mEfficiency", mEfficiency);
aNBT.setInteger("mPollution", mPollution);
aNBT.setInteger("mRuntime", mRuntime);
+ aNBT.setBoolean("mLockedToSingleRecipe", mLockedToSingleRecipe);
if (mOutputItems != null) {
aNBT.setInteger("mOutputItemsLength", mOutputItems.length);
@@ -162,6 +185,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity {
mEfficiency = aNBT.getInteger("mEfficiency");
mPollution = aNBT.getInteger("mPollution");
mRuntime = aNBT.getInteger("mRuntime");
+ mLockedToSingleRecipe = aNBT.getBoolean("mLockedToSingleRecipe");
int aOutputItemsLength = aNBT.getInteger("mOutputItemsLength");
if (aOutputItemsLength > 0) {