More machine fixes, and more new bugs

This commit is contained in:
TheDarkDnKTv 2021-02-02 10:12:38 +02:00
parent 10c510df35
commit e00e4bc37f
19 changed files with 338 additions and 326 deletions

View file

@ -534,13 +534,11 @@ public abstract class MetaTileEntity implements IMetaTileEntity {
if (setStackToZeroInsteadOfNull(aIndex))
rStack.stackSize = 0;
else
// setInventorySlotContents(aIndex, null);
getBaseMetaTileEntity().setInventorySlotContents(aIndex, null);
} else {
rStack = rStack.splitStack(aAmount);
if (rStack.stackSize == 0) {
if (!setStackToZeroInsteadOfNull(aIndex))
// setInventorySlotContents(aIndex, null);
getBaseMetaTileEntity().setInventorySlotContents(aIndex, null);
}
}

View file

@ -38,7 +38,7 @@ public class GT_MetaTileEntity_E_Furnace extends GT_MetaTileEntity_BasicMachine
if (mInventory[2].stackSize == 0) mInventory[2] = null;
// It shall cook at 3 EU/t, if this Machine is overclocked then it will consume more
// The time it usually needs, the Heating Coils re decreasing this Time, and if the Machine is overclocked, then it gets processed faster
return new Recipe(mInventory[2], null, output, null, null, null, 130 / (1+mHeatingCoilTier), 3, 0);
return new Recipe(mInventory[2], null, output, null, null, null, 130 / (1+mHeatingCoilTier), 3, 0, true);
}
return null;

View file

@ -155,12 +155,13 @@ public abstract class BasicFluidWorkable extends GT_MetaTileEntity_BasicTank imp
@Override
public boolean spaceForOutput(Recipe recipe) {
if (recipe.getOutputs().length <= getOutputSlots().length) {
ItemStack[] outputs = recipe.getOutputs();
if (outputs.length <= getOutputSlots().length) {
List<ItemStack> slots = new ArrayList<>();
for (int i : getOutputSlots()) slots.add(mInventory[i]);
for (int i = 0; i < recipe.getOutputs().length && i < slots.size(); i++) {
if (slots.get(i) != null && recipe.getOutputs()[i] != null) {
if (!GT_Utility.areStacksEqual(slots.get(i), recipe.getOutputs()[i]) || slots.get(i).stackSize + recipe.getOutputs()[i].stackSize > slots.get(i).getMaxStackSize()) {
for (int i = 0; i < outputs.length && i < slots.size(); i++) {
if (slots.get(i) != null && outputs[i] != null) {
if (!GT_Utility.areStacksEqual(slots.get(i), outputs[i]) || slots.get(i).stackSize + outputs[i].stackSize > slots.get(i).getMaxStackSize()) {
return false;
}
}
@ -173,9 +174,9 @@ public abstract class BasicFluidWorkable extends GT_MetaTileEntity_BasicTank imp
@Override
public Map<String, List<Object>> getInfoData() {
return InfoBuilder.create()
.newKey("sensor.progress.percentage", recipeLogic.getProgressTime() * 100.0D / recipeLogic.getMaxProgressTime())
.newKey("sensor.progress.secs", recipeLogic.getProgressTime() / 20)
.newKey("sensor.progress.secs.1", recipeLogic.getMaxProgressTime() / 20)
.newKey("sensor.progress.percentage", recipeLogic.getDisplayProgress() * 100.0D / recipeLogic.getDisplayMaxProgress())
.newKey("sensor.progress.secs", recipeLogic.getDisplayProgress() / 20)
.newKey("sensor.progress.secs.1", recipeLogic.getDisplayMaxProgress() / 20)
.build();
}

View file

@ -33,11 +33,11 @@ public abstract class GT_MetaTileEntity_BasicMachine extends MetaTileEntity impl
public GT_MetaTileEntity_BasicMachine(int aID, String aName, List<Recipe> recipeMap) {
super(aID, aName);
recipeLogic = new RecipeLogic(recipeMap, this);
initRecipeLogic(recipeMap);
}
public GT_MetaTileEntity_BasicMachine(List<Recipe> recipeMap) {
recipeLogic = new RecipeLogic(recipeMap, this);
initRecipeLogic(recipeMap);
}
@Override public boolean isSimpleMachine() {return false;}
@ -67,6 +67,10 @@ public abstract class GT_MetaTileEntity_BasicMachine extends MetaTileEntity impl
@Override public boolean isLiquidInput (byte aSide) {return aSide != mMainFacing;}
@Override public boolean isLiquidOutput(byte aSide) {return aSide != mMainFacing;}
protected void initRecipeLogic(List<Recipe> recipeMap) {
recipeLogic = new RecipeLogic(recipeMap, this);
}
@Override
public void saveNBTData(NBTTagCompound aNBT) {
aNBT.setBoolean("bOutput", bOutput);
@ -133,12 +137,13 @@ public abstract class GT_MetaTileEntity_BasicMachine extends MetaTileEntity impl
@Override
public boolean spaceForOutput(Recipe recipe) {
if (recipe.getOutputs().length <= getOutputSlots().length) {
ItemStack[] outputs = recipe.getOutputs();
if (outputs.length <= getOutputSlots().length) {
List<ItemStack> slots = new ArrayList<>();
for (int i : getOutputSlots()) slots.add(mInventory[i]);
for (int i = 0; i < slots.size(); i++) {
if (slots.get(i) != null && recipe.getOutputs()[i] != null) {
if (!GT_Utility.areStacksEqual(slots.get(i), recipe.getOutputs()[i]) || slots.get(i).stackSize + recipe.getOutputs()[i].stackSize > slots.get(i).getMaxStackSize()) {
for (int i = 0; i < outputs.length && i < slots.size(); i++) {
if (slots.get(i) != null && outputs[i] != null) {
if (!GT_Utility.areStacksEqual(slots.get(i), outputs[i]) || slots.get(i).stackSize + outputs[i].stackSize > slots.get(i).getMaxStackSize()) {
return false;
}
}
@ -275,9 +280,9 @@ public abstract class GT_MetaTileEntity_BasicMachine extends MetaTileEntity impl
@Override
public Map<String, List<Object>> getInfoData() {
return InfoBuilder.create()
.newKey("sensor.progress.percentage", recipeLogic.getProgressTime() * 100.0D / recipeLogic.getMaxProgressTime())
.newKey("sensor.progress.secs", recipeLogic.getProgressTime() / 20)
.newKey("sensor.progress.secs.1", recipeLogic.getMaxProgressTime() / 20)
.newKey("sensor.progress.percentage", recipeLogic.getDisplayProgress() * 100.0D / recipeLogic.getDisplayMaxProgress())
.newKey("sensor.progress.secs", recipeLogic.getDisplayProgress() / 20)
.newKey("sensor.progress.secs.1", recipeLogic.getDisplayMaxProgress() / 20)
.build();
}

View file

@ -24,6 +24,9 @@ import java.util.Set;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.MultimapBuilder.ListMultimapBuilder;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@ -44,8 +47,8 @@ public class Recipe {
/** It is an IdentityHashMap, because it uses a List as Key, and since that List changes (and therefore the Result of the equals Method), the Key is not secure, while the Identity is. */
private static final IdentityHashMap<List<Recipe>, Map<Integer, List<Recipe>>> RECIPE_MAPPINGS = new IdentityHashMap<>();
public ItemStack[][] mInputs;
public ItemStack[] mOutputs;
public ItemStack[][] mInputs; // FIXME create ingredient class and make sure counting wildcard / nbt while matching recipes
public ItemStack[] mOutputs; // FIXME add precise and oredict recipes
public int mDuration;
public int mEUt;
public int mStartEU;
@ -96,11 +99,11 @@ public class Recipe {
boolean success = this.match(key -> decreaseList.add(key), slotStacks.keySet());
if (success && decrease) {
Map<ItemStackKey, Integer> slotAligment = slotStacks.entrySet().stream()
.collect(Collectors.toMap(e -> ItemStackKey.from(e.getKey()), e -> e.getValue()));
for (ItemStackKey item : decreaseList) {
int slotIdx = slotAligment.get(item);
tile.decrStackSize(slotIdx, item.getStackSize());
ListMultimap<ItemStackKey, Integer> slotAligment = ListMultimapBuilder.hashKeys().arrayListValues().build();
slotStacks.entrySet().forEach(e -> slotAligment.put(ItemStackKey.from(e.getKey()), e.getValue()));
for (ItemStackKey recipeKey : decreaseList) {
List<Integer> slots = new ArrayList<>(slotAligment.values());
tile.decrStackSize(slots.get(0), recipeKey.getStackSize());
}
}
@ -113,18 +116,19 @@ public class Recipe {
private boolean match(Consumer<ItemStackKey> actionPerfomer, Collection<ItemStack> inputs) {
if (inputs.size() >= mInputs.length) {
start:
for (ItemStack input : inputs) {
Iterator<ItemStack[]> recipeInputIter = new ArrayList<>(Arrays.asList(mInputs)).iterator(); // Creating instance of normal not connected
while (recipeInputIter.hasNext()) { // array list to avoid damaging of recipe
int idx = -1;
List<ItemStackKey> variants = Arrays.stream(recipeInputIter.next())
for (ItemStack[] recipeSlot : mInputs) {
List<ItemStackKey> variants = Arrays.stream(recipeSlot)
.map(s -> ItemStackKey.from(s))
.collect(Collectors.toList());
if ((idx = variants.indexOf(ItemStackKey.from(input))) >= 0) {
if (variants.get(idx).get().stackSize <= input.stackSize) {
Iterator<ItemStack> machineSlot = new ArrayList<>(inputs).iterator();
while (machineSlot.hasNext()) {
int idx = -1;
ItemStack slot = machineSlot.next();
if ((idx = variants.indexOf(ItemStackKey.from(slot))) >= 0) {
if (variants.get(idx).get().stackSize <= slot.stackSize) {
if (actionPerfomer != null)
actionPerfomer.accept(variants.get(idx));
recipeInputIter.remove();
machineSlot.remove();
continue start;
}
}
@ -211,7 +215,7 @@ public class Recipe {
}
public static boolean addRecipe(List<Recipe> aList, boolean aShapeless, ItemStack aInput1, ItemStack aInput2, ItemStack aOutput1, ItemStack aOutput2, ItemStack aOutput3, ItemStack aOutput4, int aDuration, int aEUt, int aStartEU) {
return addRecipe(aList, aShapeless, new Recipe(aInput1, aInput2, aOutput1, aOutput2, aOutput3, aOutput4, aDuration, aEUt, aStartEU));
return addRecipe(aList, aShapeless, new Recipe(aInput1, aInput2, aOutput1, aOutput2, aOutput3, aOutput4, aDuration, aEUt, aStartEU, true));
}
public static boolean addRecipe(List<Recipe> aList, boolean aShapeless, Recipe aRecipe) {
@ -254,107 +258,121 @@ public class Recipe {
return null;
}
public Recipe(ItemStack aInput1, ItemStack aInput2, ItemStack aOutput1, ItemStack aOutput2, ItemStack aOutput3, ItemStack aOutput4, int aDuration, int aEUt, int aStartEU) {
/**
* Default constructor, will create simple recipe
* @param aInput1
* @param aInput2
* @param aOutput1
* @param aOutput2
* @param aOutput3
* @param aOutput4
* @param aDuration
* @param aEUt
* @param aStartEU
* @param unification will forcely add oredict variants to input
*/
public Recipe(ItemStack aInput1, ItemStack aInput2, ItemStack aOutput1, ItemStack aOutput2, ItemStack aOutput3, ItemStack aOutput4, int aDuration, int aEUt, int aStartEU, boolean unification) {
/*
* Wtf gregorious, what the purpose of this?
*/
if (aInput1 != null && aInput1.getItemDamage() != GregTech_API.ITEM_WILDCARD_DAMAGE) {
if (GT_Utility.areStacksEqual(aInput1, aOutput1)) {
if (aInput1.stackSize >= aOutput1.stackSize) {
aInput1.stackSize -= aOutput1.stackSize;
aOutput1 = null;
} else {
aOutput1.stackSize -= aInput1.stackSize;
}
}
if (GT_Utility.areStacksEqual(aInput1, aOutput2)) {
if (aInput1.stackSize >= aOutput2.stackSize) {
aInput1.stackSize -= aOutput2.stackSize;
aOutput2 = null;
} else {
aOutput2.stackSize -= aInput1.stackSize;
}
}
if (GT_Utility.areStacksEqual(aInput1, aOutput3)) {
if (aInput1.stackSize >= aOutput3.stackSize) {
aInput1.stackSize -= aOutput3.stackSize;
aOutput3 = null;
} else {
aOutput3.stackSize -= aInput1.stackSize;
}
}
if (GT_Utility.areStacksEqual(aInput1, aOutput4)) {
if (aInput1.stackSize >= aOutput4.stackSize) {
aInput1.stackSize -= aOutput4.stackSize;
aOutput4 = null;
} else {
aOutput4.stackSize -= aInput1.stackSize;
}
}
}
// if (aInput1 != null && aInput1.getItemDamage() != GregTech_API.ITEM_WILDCARD_DAMAGE) {
// if (GT_Utility.areStacksEqual(aInput1, aOutput1)) {
// if (aInput1.stackSize >= aOutput1.stackSize) {
// aInput1.stackSize -= aOutput1.stackSize;
// aOutput1 = null;
// } else {
// aOutput1.stackSize -= aInput1.stackSize;
// }
// }
// if (GT_Utility.areStacksEqual(aInput1, aOutput2)) {
// if (aInput1.stackSize >= aOutput2.stackSize) {
// aInput1.stackSize -= aOutput2.stackSize;
// aOutput2 = null;
// } else {
// aOutput2.stackSize -= aInput1.stackSize;
// }
// }
// if (GT_Utility.areStacksEqual(aInput1, aOutput3)) {
// if (aInput1.stackSize >= aOutput3.stackSize) {
// aInput1.stackSize -= aOutput3.stackSize;
// aOutput3 = null;
// } else {
// aOutput3.stackSize -= aInput1.stackSize;
// }
// }
// if (GT_Utility.areStacksEqual(aInput1, aOutput4)) {
// if (aInput1.stackSize >= aOutput4.stackSize) {
// aInput1.stackSize -= aOutput4.stackSize;
// aOutput4 = null;
// } else {
// aOutput4.stackSize -= aInput1.stackSize;
// }
// }
// }
//
// if (aInput2 != null && aInput2.getItemDamage() != GregTech_API.ITEM_WILDCARD_DAMAGE) {
// if (GT_Utility.areStacksEqual(aInput2, aOutput1)) {
// assert aOutput1 != null;
// if (aInput2.stackSize >= aOutput1.stackSize) {
// aInput2.stackSize -= aOutput1.stackSize;
// aOutput1 = null;
// } else {
// aOutput1.stackSize -= aInput2.stackSize;
// }
// }
// if (GT_Utility.areStacksEqual(aInput2, aOutput2)) {
// assert aOutput2 != null;
// if (aInput2.stackSize >= aOutput2.stackSize) {
// aInput2.stackSize -= aOutput2.stackSize;
// aOutput2 = null;
// } else {
// aOutput2.stackSize -= aInput2.stackSize;
// }
// }
// if (GT_Utility.areStacksEqual(aInput2, aOutput3)) {
// assert aOutput3 != null;
// if (aInput2.stackSize >= aOutput3.stackSize) {
// aInput2.stackSize -= aOutput3.stackSize;
// aOutput3 = null;
// } else {
// aOutput3.stackSize -= aInput2.stackSize;
// }
// }
// if (GT_Utility.areStacksEqual(aInput2, aOutput4)) {
// assert aOutput4 != null;
// if (aInput2.stackSize >= aOutput4.stackSize) {
// aInput2.stackSize -= aOutput4.stackSize;
// aOutput4 = null;
// } else {
// aOutput4.stackSize -= aInput2.stackSize;
// }
// }
// }
if (aInput2 != null && aInput2.getItemDamage() != GregTech_API.ITEM_WILDCARD_DAMAGE) {
if (GT_Utility.areStacksEqual(aInput2, aOutput1)) {
assert aOutput1 != null;
if (aInput2.stackSize >= aOutput1.stackSize) {
aInput2.stackSize -= aOutput1.stackSize;
aOutput1 = null;
} else {
aOutput1.stackSize -= aInput2.stackSize;
}
}
if (GT_Utility.areStacksEqual(aInput2, aOutput2)) {
assert aOutput2 != null;
if (aInput2.stackSize >= aOutput2.stackSize) {
aInput2.stackSize -= aOutput2.stackSize;
aOutput2 = null;
} else {
aOutput2.stackSize -= aInput2.stackSize;
}
}
if (GT_Utility.areStacksEqual(aInput2, aOutput3)) {
assert aOutput3 != null;
if (aInput2.stackSize >= aOutput3.stackSize) {
aInput2.stackSize -= aOutput3.stackSize;
aOutput3 = null;
} else {
aOutput3.stackSize -= aInput2.stackSize;
}
}
if (GT_Utility.areStacksEqual(aInput2, aOutput4)) {
assert aOutput4 != null;
if (aInput2.stackSize >= aOutput4.stackSize) {
aInput2.stackSize -= aOutput4.stackSize;
aOutput4 = null;
} else {
aOutput4.stackSize -= aInput2.stackSize;
}
}
}
for (byte i = 64; i > 1; i--) if (aDuration / i > 0) {
if (aInput1 == null || aInput1 .stackSize % i == 0)
if (aInput2 == null || aInput2 .stackSize % i == 0)
if (aOutput1 == null || aOutput1.stackSize % i == 0)
if (aOutput2 == null || aOutput2.stackSize % i == 0)
if (aOutput3 == null || aOutput3.stackSize % i == 0)
if (aOutput4 == null || aOutput4.stackSize % i == 0) {
if (aInput1 != null) aInput1 .stackSize /= i;
if (aInput2 != null) aInput2 .stackSize /= i;
if (aOutput1 != null) aOutput1.stackSize /= i;
if (aOutput2 != null) aOutput2.stackSize /= i;
if (aOutput3 != null) aOutput3.stackSize /= i;
if (aOutput4 != null) aOutput4.stackSize /= i;
aDuration /= i;
}
}
// Thanks for retardness....spent 40 minutes to find why recycler works so fast
// for (byte i = 64; i > 1; i--) if (aDuration / i > 0) {
// if (aInput1 == null || aInput1 .stackSize % i == 0)
// if (aInput2 == null || aInput2 .stackSize % i == 0)
// if (aOutput1 == null || aOutput1.stackSize % i == 0)
// if (aOutput2 == null || aOutput2.stackSize % i == 0)
// if (aOutput3 == null || aOutput3.stackSize % i == 0)
// if (aOutput4 == null || aOutput4.stackSize % i == 0) {
// if (aInput1 != null) aInput1 .stackSize /= i;
// if (aInput2 != null) aInput2 .stackSize /= i;
// if (aOutput1 != null) aOutput1.stackSize /= i;
// if (aOutput2 != null) aOutput2.stackSize /= i;
// if (aOutput3 != null) aOutput3.stackSize /= i;
// if (aOutput4 != null) aOutput4.stackSize /= i;
// aDuration /= i;
// }
// }
if (aInput1 == null) {
mInputs = new ItemStack [0][];
} else if (aInput2 == null) {
mInputs = new ItemStack[][]{ applyOreDict(aInput1) }; // apply oredict optionally, better to make recipe builder
mInputs = new ItemStack[][]{ unification ? applyOreDict(aInput1) : new ItemStack[] {aInput1}};
} else {
mInputs = new ItemStack[][] { applyOreDict(aInput1), applyOreDict(aInput2)};
mInputs = new ItemStack[][] { unification ? applyOreDict(aInput1) : new ItemStack[] {aInput1}, unification ? applyOreDict(aInput2) : new ItemStack[] {aInput2}};
}
mOutputs = new ItemStack[] {aOutput1, aOutput2, aOutput3, aOutput4};
@ -371,7 +389,7 @@ public class Recipe {
// aStartEU = EU per Liter! If there is no Liquid for this Object, then it gets multiplied with 1000!
public Recipe(ItemStack aInput1, ItemStack aOutput1, ItemStack aOutput2, ItemStack aOutput3, ItemStack aOutput4, int aStartEU, int aType) {
this(aInput1, null, aOutput1, aOutput2, aOutput3, aOutput4, 0, 0, Math.max(1, aStartEU));
this(aInput1, null, aOutput1, aOutput2, aOutput3, aOutput4, 0, 0, Math.max(1, aStartEU), true);
if (mInputs.length > 0 && aStartEU > 0) {
switch (aType) {
@ -404,126 +422,126 @@ public class Recipe {
}
public Recipe(ItemStack aInput1, ItemStack aInput2, ItemStack aOutput1, int aDuration, int aEUt, int aStartEU) {
this(aInput1, aInput2, aOutput1, null, null, null, Math.max(aDuration, 1), aEUt, Math.max(Math.min(aStartEU, 160000000), 0));
this(aInput1, aInput2, aOutput1, null, null, null, Math.max(aDuration, 1), aEUt, Math.max(Math.min(aStartEU, 160000000), 0), true);
if (mInputs.length > 1 && findEqualRecipe(true, sFusionRecipes, aInput1, aInput2) == null) {
addToLists(sFusionRecipes);
}
}
public Recipe(ItemStack aInput1, ItemStack aInput2, ItemStack aOutput1, ItemStack aOutput2, ItemStack aOutput3, ItemStack aOutput4, int aDuration) {
this(aInput1, aInput2, aOutput1, aOutput2, aOutput3, aOutput4, Math.max(aDuration, 1), 5, 0);
this(aInput1, aInput2, aOutput1, aOutput2, aOutput3, aOutput4, Math.max(aDuration, 1), 5, 0, true);
if (mInputs.length > 0 && mOutputs[0] != null && findEqualRecipe(false, sCentrifugeRecipes, aInput1, aInput2) == null) {
addToLists(sCentrifugeRecipes);
}
}
public Recipe(ItemStack aInput1, ItemStack aInput2, ItemStack aOutput1, ItemStack aOutput2, ItemStack aOutput3, ItemStack aOutput4, int aDuration, int aEUt) {
this(aInput1, aInput2, aOutput1, aOutput2, aOutput3, aOutput4, Math.max(aDuration, 1), Math.max(aEUt, 1), 0);
this(aInput1, aInput2, aOutput1, aOutput2, aOutput3, aOutput4, Math.max(aDuration, 1), Math.max(aEUt, 1), 0, true);
if (mInputs.length > 0 && mOutputs[0] != null && findEqualRecipe(false, sElectrolyzerRecipes, aInput1, aInput2) == null) {
addToLists(sElectrolyzerRecipes);
}
}
public Recipe(ItemStack aInput1, ItemStack aOutput1, ItemStack aOutput2, int aDuration, int aEUt) {
this(aInput1, null, aOutput1, aOutput2, null, null, aDuration, aEUt, 0);
this(aInput1, null, aOutput1, aOutput2, null, null, aDuration, aEUt, 0, true);
if (mInputs.length > 0 && mOutputs[0] != null && findEqualRecipe(true, sLatheRecipes, aInput1) == null) {
addToLists(sLatheRecipes);
}
}
public Recipe(ItemStack aInput1, int aDuration, ItemStack aOutput1, int aEUt) {
this(aInput1, null, aOutput1, null, null, null, aDuration, aEUt, 0);
this(aInput1, null, aOutput1, null, null, null, aDuration, aEUt, 0, true);
if (mInputs.length > 0 && mOutputs[0] != null && findEqualRecipe(true, sCutterRecipes, aInput1) == null) {
addToLists(sCutterRecipes);
}
}
public Recipe(ItemStack aInput1, ItemStack aInput2, ItemStack aOutput1, ItemStack aOutput2, ItemStack aOutput3) {
this(aInput1, aInput2, aOutput1, aOutput2, aOutput3, null, 200*aInput1.stackSize, 30, 0);
this(aInput1, aInput2, aOutput1, aOutput2, aOutput3, null, 200*aInput1.stackSize, 30, 0, true);
if (mInputs.length > 0 && mOutputs[0] != null && findEqualRecipe(false, sSawmillRecipes, aInput1, aInput2) == null) {
addToLists(sSawmillRecipes);
}
}
public Recipe(ItemStack aInput1, ItemStack aInput2, ItemStack aOutput1, ItemStack aOutput2, ItemStack aOutput3, ItemStack aOutput4) {
this(aInput1, aInput2, aOutput1, aOutput2, aOutput3, aOutput4, 100*aInput1.stackSize, 120, 0);
this(aInput1, aInput2, aOutput1, aOutput2, aOutput3, aOutput4, 100*aInput1.stackSize, 120, 0, true);
if (mInputs.length > 0 && aInput2 != null && mOutputs[0] != null && findEqualRecipe(false, sGrinderRecipes, aInput1, aInput2) == null) {
addToLists(sGrinderRecipes);
}
}
public Recipe(ItemStack aInput1, int aCellAmount, ItemStack aOutput1, ItemStack aOutput2, ItemStack aOutput3, ItemStack aOutput4, int aDuration, int aEUt) {
this(aInput1, aCellAmount>0?GT_Items.Cell_Empty.get(Math.min(64, Math.max(1, aCellAmount))):null, aOutput1, aOutput2, aOutput3, aOutput4, Math.max(aDuration, 1), Math.max(aEUt, 1), 0);
this(aInput1, aCellAmount>0?GT_Items.Cell_Empty.get(Math.min(64, Math.max(1, aCellAmount))):null, aOutput1, aOutput2, aOutput3, aOutput4, Math.max(aDuration, 1), Math.max(aEUt, 1), 0, true);
if (mInputs.length > 0 && mOutputs[0] != null && findEqualRecipe(false, sDistillationRecipes, aInput1, aCellAmount>0?GT_Items.Cell_Empty.get(Math.min(64, Math.max(1, aCellAmount))):null) == null) {
addToLists(sDistillationRecipes);
}
}
public Recipe(ItemStack aInput1, ItemStack aInput2, ItemStack aOutput1, ItemStack aOutput2, int aDuration, int aEUt, int aLevel) {
this(aInput1, aInput2, aOutput1, aOutput2, null, null, Math.max(aDuration, 1), Math.max(aEUt, 1), aLevel > 0 ? aLevel : 100);
this(aInput1, aInput2, aOutput1, aOutput2, null, null, Math.max(aDuration, 1), Math.max(aEUt, 1), aLevel > 0 ? aLevel : 100, true);
if (mInputs.length > 0 && mOutputs[0] != null && findEqualRecipe(true, sBlastRecipes, aInput1, aInput2) == null) {
addToLists(sBlastRecipes);
}
}
public Recipe(ItemStack aInput1, int aInput2, ItemStack aOutput1, ItemStack aOutput2) {
this(aInput1, GT_ModHandler.getIC2Item("industrialTnt", aInput2>0?aInput2<64?aInput2:64:1, new ItemStack(Blocks.tnt, aInput2>0?aInput2<64?aInput2:64:1)), aOutput1, aOutput2, null, null, 20, 30, 0);
this(aInput1, GT_ModHandler.getIC2Item("industrialTnt", aInput2>0?aInput2<64?aInput2:64:1, new ItemStack(Blocks.tnt, aInput2>0?aInput2<64?aInput2:64:1)), aOutput1, aOutput2, null, null, 20, 30, 0, true);
if (mInputs.length > 0 && mOutputs[0] != null && findEqualRecipe(false, sImplosionRecipes, aInput1, GT_ModHandler.getIC2Item("industrialTnt", aInput2>0?aInput2<64?aInput2:64:1, new ItemStack(Blocks.tnt, aInput2>0?aInput2<64?aInput2:64:1))) == null) {
addToLists(sImplosionRecipes);
}
}
public Recipe(ItemStack aInput1, int aEUt, int aDuration, ItemStack aOutput1) {
this(aInput1, null, aOutput1, null, null, null, Math.max(aDuration, 1), Math.max(aEUt, 1), 0);
this(aInput1, null, aOutput1, null, null, null, Math.max(aDuration, 1), Math.max(aEUt, 1), 0, true);
if (mInputs.length > 0 && mOutputs[0] != null && findEqualRecipe(true, sWiremillRecipes, aInput1) == null) {
addToLists(sWiremillRecipes);
}
}
public Recipe(int aEUt, int aDuration, ItemStack aInput1, ItemStack aOutput1) {
this(aInput1, GT_Items.Circuit_Integrated.getWithDamage(0, aInput1.stackSize), aOutput1, null, null, null, Math.max(aDuration, 1), Math.max(aEUt, 1), 0);
this(aInput1, GT_Items.Circuit_Integrated.getWithDamage(0, aInput1.stackSize), aOutput1, null, null, null, Math.max(aDuration, 1), Math.max(aEUt, 1), 0, true);
if (mInputs.length > 0 && mOutputs[0] != null && findEqualRecipe(false, sBenderRecipes, aInput1) == null) {
addToLists(sBenderRecipes);
}
}
public Recipe(int aEUt, int aDuration, ItemStack aInput1, ItemStack aShape, ItemStack aOutput1) {
this(aInput1, aShape, aOutput1, null, null, null, Math.max(aDuration, 1), Math.max(aEUt, 1), 0);
this(aInput1, aShape, aOutput1, null, null, null, Math.max(aDuration, 1), Math.max(aEUt, 1), 0, true);
if (mInputs.length > 1 && mOutputs[0] != null && findEqualRecipe(false, sExtruderRecipes, aInput1) == null) {
addToLists(sExtruderRecipes);
}
}
public Recipe(ItemStack aInput1, int aEUt, ItemStack aInput2, int aDuration, ItemStack aOutput1) {
this(aInput1, aInput2, aOutput1, null, null, null, Math.max(aDuration, 1), Math.max(aEUt, 1), 0);
this(aInput1, aInput2, aOutput1, null, null, null, Math.max(aDuration, 1), Math.max(aEUt, 1), 0, true);
if (mInputs.length > 0 && mOutputs[0] != null && findEqualRecipe(true, sAssemblerRecipes, aInput1, aInput2) == null) {
addToLists(sAssemblerRecipes);
}
}
public Recipe(ItemStack aInput1, ItemStack aInput2, int aEUt, int aDuration, ItemStack aOutput1) {
this(aInput1, aInput2, aOutput1, null, null, null, Math.max(aDuration, 1), Math.max(aEUt, 1), 0);
this(aInput1, aInput2, aOutput1, null, null, null, Math.max(aDuration, 1), Math.max(aEUt, 1), 0, true);
if (mInputs.length > 0 && mOutputs[0] != null && findEqualRecipe(true, sAlloySmelterRecipes, aInput1, aInput2) == null) {
addToLists(sAlloySmelterRecipes);
}
}
public Recipe(ItemStack aInput1, int aEUt, ItemStack aInput2, int aDuration, ItemStack aOutput1, ItemStack aOutput2) {
this(aInput1, aInput2, aOutput1, aOutput2, null, null, Math.max(aDuration, 1), Math.max(aEUt, 1), 0);
this(aInput1, aInput2, aOutput1, aOutput2, null, null, Math.max(aDuration, 1), Math.max(aEUt, 1), 0, true);
if (mInputs.length > 0 && mOutputs[0] != null && findEqualRecipe(true, sCannerRecipes, aInput1, aInput2) == null) {
addToLists(sCannerRecipes);
}
}
public Recipe(ItemStack aInput1, ItemStack aOutput1, int aDuration) {
this(aInput1, null, aOutput1, null, null, null, Math.max(aDuration, 1), 120, 0);
this(aInput1, null, aOutput1, null, null, null, Math.max(aDuration, 1), 120, 0, true);
if (mInputs.length > 0 && mOutputs[0] != null && findEqualRecipe(true, sVacuumRecipes, aInput1) == null) {
addToLists(sVacuumRecipes);
}
}
public Recipe(ItemStack aInput1, ItemStack aInput2, ItemStack aOutput1, int aDuration) {
this(aInput1, aInput2, aOutput1, null, null, null, Math.max(aDuration, 1), 30, 0);
this(aInput1, aInput2, aOutput1, null, null, null, Math.max(aDuration, 1), 30, 0, true);
if (mInputs.length > 0 && mOutputs[0] != null && findEqualRecipe(true, sChemicalRecipes, aInput1) == null) {
addToLists(sChemicalRecipes);
}

View file

@ -168,7 +168,7 @@ public class RecipeLogic {
if (outputs.length <= getMachine().getOutputSlots().length) {
for (ItemStack out : outputs) {
for (int i : getMachine().getOutputSlots()) {
if (getMachine().getBaseMetaTileEntity().addStackToSlot(i, out.copy())) {
if (out != null && getMachine().getBaseMetaTileEntity().addStackToSlot(i, out.copy())) {
break;
}
}
@ -203,10 +203,24 @@ public class RecipeLogic {
}
public int getMaxProgressTime() {
return maxProgressTime / (int)Math.pow(2, overclockersCount);
return maxProgressTime;
}
public int getProgressTime() {
return progressTime;
}
/**
* Using ONLY for display time
*/
public int getDisplayMaxProgress() {
return maxProgressTime / (int)Math.pow(2, overclockersCount);
}
/**
* Using ONLY for display time
*/
public int getDisplayProgress() {
return progressTime / (int)Math.pow(2, overclockersCount);
}

View file

@ -45,7 +45,7 @@ public final class ItemStackKey {
if (isWildcard) {
return this.stack.getItem() == stack.getItem();
} else {
return ItemStack.areItemStacksEqual(this.stack, stack) && ItemStack.areItemStackTagsEqual(this.stack, stack);
return this.stack.isItemEqual(stack);// && ItemStack.areItemStackTagsEqual(this.stack, stack); // TODO add NBT comparing settings
}
}
@ -64,6 +64,6 @@ public final class ItemStackKey {
@Override
public int hashCode() {
return Objects.hash(stack.getItem(), (isWildcard ? GregTech_API.ITEM_WILDCARD_DAMAGE : Items.feather.getDamage(stack)), stack.getTagCompound());
return Objects.hash(stack.getItem(), (isWildcard ? GregTech_API.ITEM_WILDCARD_DAMAGE : Items.feather.getDamage(stack)));//, stack.getTagCompound());
}
}

View file

@ -6,6 +6,7 @@ import gregtechmod.api.interfaces.IGregTechTileEntity;
import gregtechmod.api.metatileentity.MetaTileEntity;
import gregtechmod.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine;
import gregtechmod.api.recipe.Recipe;
import gregtechmod.api.recipe.RecipeLogic;
import gregtechmod.api.util.GT_OreDictUnificator;
import gregtechmod.api.util.GT_Utility;
import net.minecraft.entity.player.EntityPlayer;
@ -24,6 +25,16 @@ public class GT_MetaTileEntity_AlloySmelter extends GT_MetaTileEntity_BasicMachi
super(recipeMap);
}
@Override
protected void initRecipeLogic(List<Recipe> recipeMap) {
recipeLogic = new RecipeLogic(recipeMap, this) {
@Override
protected void moveItems() {
GT_Utility.moveStackFromSlotAToSlotB(getBaseMetaTileEntity(), getBaseMetaTileEntity(), getOutputSlots()[0], getOutputSlots()[1], (byte)64, (byte)1, (byte)64, (byte)1);
}
};
}
@Override
public void saveNBTData(NBTTagCompound aNBT) {
super.saveNBTData(aNBT);
@ -68,21 +79,6 @@ public class GT_MetaTileEntity_AlloySmelter extends GT_MetaTileEntity_BasicMachi
return new GT_MetaTileEntity_AlloySmelter(recipeLogic.recipeMap);
}
@Override
public void checkRecipe() {
GT_Utility.moveStackFromSlotAToSlotB(getBaseMetaTileEntity(), getBaseMetaTileEntity(), 3, 4, (byte)64, (byte)1, (byte)64, (byte)1);
if (mInventory[1] != null || mInventory[2] != null) {
Recipe tRecipe = Recipe.findEqualRecipe(false, false, Recipe.sAlloySmelterRecipes, mInventory[1], mInventory[2]);
if (tRecipe != null && spaceForOutput(tRecipe.getOutput(0), null) && tRecipe.isRecipeInputEqual(true, true, mInventory[1], mInventory[2])) {
mEUt = tRecipe.mEUt;
mMaxProgresstime = tRecipe.mDuration / (1+mHeatingCoilTier);
mOutputItem1 = GT_Utility.copy(tRecipe.getOutput(0));
return;
}
}
mOutputItem1 = null;
}
@Override
public boolean hasTwoSeperateInputs() {
return true;

View file

@ -6,7 +6,7 @@ import gregtechmod.api.interfaces.IGregTechTileEntity;
import gregtechmod.api.metatileentity.MetaTileEntity;
import gregtechmod.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine;
import gregtechmod.api.recipe.Recipe;
import gregtechmod.api.util.GT_Utility;
import net.minecraft.entity.player.EntityPlayer;
public class GT_MetaTileEntity_Assembler extends GT_MetaTileEntity_BasicMachine {
@ -22,23 +22,14 @@ public class GT_MetaTileEntity_Assembler extends GT_MetaTileEntity_BasicMachine
@Override public void onRightclick(EntityPlayer aPlayer) {getBaseMetaTileEntity().openGUI(aPlayer, 141);}
@Override
public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
return new GT_MetaTileEntity_Assembler(recipeLogic.recipeMap);
protected void initRecipeLogic(List<Recipe> recipeMap) {
super.initRecipeLogic(recipeMap);
recipeLogic.moveItems = false;
}
@Override
public void checkRecipe() {
GT_Utility.moveStackFromSlotAToSlotB(getBaseMetaTileEntity(), getBaseMetaTileEntity(), 3, 4, (byte)64, (byte)1, (byte)64, (byte)1);
if (mInventory[1] != null || mInventory[2] != null) {
Recipe tRecipe = Recipe.findEqualRecipe(false, false, Recipe.sAssemblerRecipes, mInventory[1], mInventory[2]);
if (tRecipe != null && spaceForOutput(tRecipe.getOutput(0), null) && tRecipe.isRecipeInputEqual(true, true, mInventory[1], mInventory[2])) {
mEUt = tRecipe.mEUt;
mMaxProgresstime = tRecipe.mDuration;
mOutputItem1 = GT_Utility.copy(tRecipe.getOutput(0));
return;
}
}
mOutputItem1 = null;
public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
return new GT_MetaTileEntity_Assembler(recipeLogic.recipeMap);
}
@Override

View file

@ -2,12 +2,11 @@ package gregtechmod.common.tileentities.machines.basic;
import java.util.List;
import gregtechmod.api.enums.GT_Items;
import gregtechmod.api.interfaces.IGregTechTileEntity;
import gregtechmod.api.metatileentity.MetaTileEntity;
import gregtechmod.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine;
import gregtechmod.api.recipe.Recipe;
import gregtechmod.api.util.GT_Utility;
import net.minecraft.entity.player.EntityPlayer;
public class GT_MetaTileEntity_Bender extends GT_MetaTileEntity_BasicMachine {
@ -27,39 +26,39 @@ public class GT_MetaTileEntity_Bender extends GT_MetaTileEntity_BasicMachine {
return new GT_MetaTileEntity_Bender(recipeLogic.recipeMap);
}
@Override
public void checkRecipe() {
GT_Utility.moveStackFromSlotAToSlotB(this.getBaseMetaTileEntity(), this.getBaseMetaTileEntity(), 3, 4, (byte) 64, (byte) 1, (byte) 64, (byte) 1);
if (GT_Utility.isStackValid(mInventory[1])) {
Recipe tRecipe = Recipe.findEqualRecipe(false, false, Recipe.sBenderRecipes, mInventory[1], mInventory[2]);
if (tRecipe != null && this.spaceForOutput(tRecipe.getOutput(0), null) && tRecipe.isRecipeInputEqual(true, true, mInventory[1], mInventory[2])) {
mEUt = tRecipe.mEUt;
mMaxProgresstime = tRecipe.mDuration;
mOutputItem1 = tRecipe.getOutput(0);
return;
}
if (GT_Utility.isStackInvalid(mInventory[2])) {
for (int i = 64; i > 0; --i) {
tRecipe = Recipe.findEqualRecipe(false, false, Recipe.sBenderRecipes, mInventory[1], GT_Items.Circuit_Integrated.getWithDamage(0, (long) i));
if (tRecipe != null && this.spaceForOutput(tRecipe.getOutput(0), null) && tRecipe.isRecipeInputEqual(true, true, super.mInventory[1], GT_Items.Circuit_Integrated.getWithDamage(0L, (long) i))) {
mEUt = tRecipe.mEUt;
mMaxProgresstime = tRecipe.mDuration;
mOutputItem1 = tRecipe.getOutput(0);
return;
}
tRecipe = Recipe.findEqualRecipe(false, false, Recipe.sBenderRecipes, GT_Items.Circuit_Integrated.getWithDamage(0L, (long) i), mInventory[1]);
if (tRecipe != null && this.spaceForOutput(tRecipe.getOutput(0), null) && tRecipe.isRecipeInputEqual(true, true, GT_Items.Circuit_Integrated.getWithDamage(0L, (long) i), mInventory[1])) {
mEUt = tRecipe.mEUt;
mMaxProgresstime = tRecipe.mDuration;
mOutputItem1 = tRecipe.getOutput(0);
return;
}
}
}
}
}
// @Override
// public void checkRecipe() {
// GT_Utility.moveStackFromSlotAToSlotB(this.getBaseMetaTileEntity(), this.getBaseMetaTileEntity(), 3, 4, (byte) 64, (byte) 1, (byte) 64, (byte) 1);
// if (GT_Utility.isStackValid(mInventory[1])) {
// Recipe tRecipe = Recipe.findEqualRecipe(false, false, Recipe.sBenderRecipes, mInventory[1], mInventory[2]);
// if (tRecipe != null && this.spaceForOutput(tRecipe.getOutput(0), null) && tRecipe.isRecipeInputEqual(true, true, mInventory[1], mInventory[2])) {
// mEUt = tRecipe.mEUt;
// mMaxProgresstime = tRecipe.mDuration;
// mOutputItem1 = tRecipe.getOutput(0);
// return;
// }
//
// if (GT_Utility.isStackInvalid(mInventory[2])) {
// for (int i = 64; i > 0; --i) {
// tRecipe = Recipe.findEqualRecipe(false, false, Recipe.sBenderRecipes, mInventory[1], GT_Items.Circuit_Integrated.getWithDamage(0, (long) i));
// if (tRecipe != null && this.spaceForOutput(tRecipe.getOutput(0), null) && tRecipe.isRecipeInputEqual(true, true, super.mInventory[1], GT_Items.Circuit_Integrated.getWithDamage(0L, (long) i))) {
// mEUt = tRecipe.mEUt;
// mMaxProgresstime = tRecipe.mDuration;
// mOutputItem1 = tRecipe.getOutput(0);
// return;
// }
//
// tRecipe = Recipe.findEqualRecipe(false, false, Recipe.sBenderRecipes, GT_Items.Circuit_Integrated.getWithDamage(0L, (long) i), mInventory[1]);
// if (tRecipe != null && this.spaceForOutput(tRecipe.getOutput(0), null) && tRecipe.isRecipeInputEqual(true, true, GT_Items.Circuit_Integrated.getWithDamage(0L, (long) i), mInventory[1])) {
// mEUt = tRecipe.mEUt;
// mMaxProgresstime = tRecipe.mDuration;
// mOutputItem1 = tRecipe.getOutput(0);
// return;
// }
// }
// }
// }
// }
@Override
public int getFrontFacingInactive() {

View file

@ -6,9 +6,8 @@ import gregtechmod.api.interfaces.IGregTechTileEntity;
import gregtechmod.api.metatileentity.MetaTileEntity;
import gregtechmod.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine;
import gregtechmod.api.recipe.Recipe;
import gregtechmod.api.util.GT_Utility;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
public class GT_MetaTileEntity_Canner extends GT_MetaTileEntity_BasicMachine {
@ -27,22 +26,6 @@ public class GT_MetaTileEntity_Canner extends GT_MetaTileEntity_BasicMachine {
return new GT_MetaTileEntity_Canner(recipeLogic.recipeMap);
}
@Override
public void checkRecipe() {
GT_Utility.moveStackFromSlotAToSlotB(getBaseMetaTileEntity(), getBaseMetaTileEntity(), 3, 4, (byte)64, (byte)1, (byte)64, (byte)1);
if (mInventory[1] != null || mInventory[2] != null) {
Recipe tRecipe = Recipe.findEqualRecipe(false, false, Recipe.sCannerRecipes, mInventory[1], mInventory[2]);
if (tRecipe != null && spaceForOutput(tRecipe.getOutput(0), tRecipe.getOutput(1)) && tRecipe.isRecipeInputEqual(true, true, mInventory[1], mInventory[2])) {
mEUt = tRecipe.mEUt;
mMaxProgresstime = tRecipe.mDuration;
mOutputItem1 = ItemStack.copyItemStack(tRecipe.getOutput(0));
mOutputItem2 = ItemStack.copyItemStack(tRecipe.getOutput(1));
return;
}
}
mOutputItem1 = null;
}
@Override
public boolean hasTwoSeperateInputs() {
return true;

View file

@ -7,8 +7,9 @@ import gregtechmod.api.metatileentity.MetaTileEntity;
import gregtechmod.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine;
import gregtechmod.api.recipe.Recipe;
import gregtechmod.api.util.GT_ModHandler;
import gregtechmod.api.util.GT_Utility;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
public class GT_MetaTileEntity_Compressor extends GT_MetaTileEntity_BasicMachine {
@ -28,13 +29,16 @@ public class GT_MetaTileEntity_Compressor extends GT_MetaTileEntity_BasicMachine
}
@Override
public void checkRecipe() {
GT_Utility.moveStackFromSlotAToSlotB(getBaseMetaTileEntity(), getBaseMetaTileEntity(), 1, 2, (byte)64, (byte)1, (byte)64, (byte)1);
GT_Utility.moveStackFromSlotAToSlotB(getBaseMetaTileEntity(), getBaseMetaTileEntity(), 3, 4, (byte)64, (byte)1, (byte)64, (byte)1);
if (mInventory[2] != null && null != (mOutputItem1 = GT_ModHandler.getCompressorOutput(mInventory[2], true, mInventory[3]))) {
mEUt = 2;
mMaxProgresstime = 400;
protected void initRecipeLogic(List<Recipe> recipeMap) {
super.initRecipeLogic(recipeMap);;
recipeLogic.setRecipeProvider(() -> {
ItemStack output = null;
if (mInventory[2] != null && (output = GT_ModHandler.getCompressorOutput(mInventory[2], false, mInventory[3])) != null) {
return new Recipe(mInventory[2].copy(), null, output, null, null, null, 400, 2, 0, false); // TODO add methods get input by output, or all recipe here
}
return null;
});
}
@Override

View file

@ -7,8 +7,9 @@ import gregtechmod.api.metatileentity.MetaTileEntity;
import gregtechmod.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine;
import gregtechmod.api.recipe.Recipe;
import gregtechmod.api.util.GT_ModHandler;
import gregtechmod.api.util.GT_Utility;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
public class GT_MetaTileEntity_Extractor extends GT_MetaTileEntity_BasicMachine {
@ -28,13 +29,16 @@ public class GT_MetaTileEntity_Extractor extends GT_MetaTileEntity_BasicMachine
}
@Override
public void checkRecipe() {
GT_Utility.moveStackFromSlotAToSlotB(getBaseMetaTileEntity(), getBaseMetaTileEntity(), 1, 2, (byte)64, (byte)1, (byte)64, (byte)1);
GT_Utility.moveStackFromSlotAToSlotB(getBaseMetaTileEntity(), getBaseMetaTileEntity(), 3, 4, (byte)64, (byte)1, (byte)64, (byte)1);
if (mInventory[2] != null && null != (mOutputItem1 = GT_ModHandler.getExtractorOutput(mInventory[2], true, mInventory[3]))) {
mEUt = 2;
mMaxProgresstime = 400;
protected void initRecipeLogic(List<Recipe> recipeMap) {
super.initRecipeLogic(recipeMap);
recipeLogic.setRecipeProvider(() -> {
ItemStack output = null;
if (mInventory[2] != null && null != (output = GT_ModHandler.getExtractorOutput(mInventory[2], true, mInventory[3]))) {
return new Recipe(mInventory[2].copy(), null, output, null, null, null, 400, 2, 0, true); // TODO add methods get input by output, or all recipe here
}
return null;
});
}
@Override

View file

@ -6,6 +6,7 @@ import gregtechmod.api.interfaces.IGregTechTileEntity;
import gregtechmod.api.metatileentity.MetaTileEntity;
import gregtechmod.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine;
import gregtechmod.api.recipe.Recipe;
import gregtechmod.api.recipe.RecipeLogic;
import gregtechmod.api.util.GT_Utility;
import net.minecraft.entity.player.EntityPlayer;
@ -27,18 +28,13 @@ public class GT_MetaTileEntity_Lathe extends GT_MetaTileEntity_BasicMachine {
}
@Override
public void checkRecipe() {
protected void initRecipeLogic(List<Recipe> recipeMap) {
recipeLogic = new RecipeLogic(recipeMap, this) {
@Override
public void moveItems() {
GT_Utility.moveStackFromSlotAToSlotB(getBaseMetaTileEntity(), getBaseMetaTileEntity(), 1, 2, (byte)64, (byte)1, (byte)64, (byte)1);
if (mInventory[2] != null && mInventory[2].stackSize > 0) {
Recipe tRecipe = Recipe.findEqualRecipe(false, Recipe.sLatheRecipes, mInventory[2]);
if (tRecipe != null && spaceForOutput(tRecipe.getOutput(0), tRecipe.getOutput(1)) && tRecipe.isRecipeInputEqual(true, true, mInventory[2], null)) {
mEUt = tRecipe.mEUt;
mMaxProgresstime = tRecipe.mDuration;
if (tRecipe.getOutput(0) != null) mOutputItem1 = GT_Utility.copy(tRecipe.getOutput(0));
if (tRecipe.getOutput(1) != null) mOutputItem2 = GT_Utility.copy(tRecipe.getOutput(1));
return;
}
}
};
}
@Override

View file

@ -7,8 +7,9 @@ import gregtechmod.api.metatileentity.MetaTileEntity;
import gregtechmod.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine;
import gregtechmod.api.recipe.Recipe;
import gregtechmod.api.util.GT_ModHandler;
import gregtechmod.api.util.GT_Utility;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
public class GT_MetaTileEntity_Macerator extends GT_MetaTileEntity_BasicMachine {
@ -28,13 +29,16 @@ public class GT_MetaTileEntity_Macerator extends GT_MetaTileEntity_BasicMachine
}
@Override
public void checkRecipe() {
GT_Utility.moveStackFromSlotAToSlotB(getBaseMetaTileEntity(), getBaseMetaTileEntity(), 1, 2, (byte)64, (byte)1, (byte)64, (byte)1);
GT_Utility.moveStackFromSlotAToSlotB(getBaseMetaTileEntity(), getBaseMetaTileEntity(), 3, 4, (byte)64, (byte)1, (byte)64, (byte)1);
if (mInventory[2] != null && null != (mOutputItem1 = GT_ModHandler.getMaceratorOutput(mInventory[2], true, mInventory[3]))) {
mEUt = 2;
mMaxProgresstime = 400;
protected void initRecipeLogic(List<Recipe> recipeMap) {
super.initRecipeLogic(recipeMap);
recipeLogic.setRecipeProvider(() -> {
ItemStack output = null;
if (mInventory[2] != null && null != (output = GT_ModHandler.getMaceratorOutput(mInventory[2], true, mInventory[3]))) {
return new Recipe(mInventory[2].copy(), null, output, null, null, null, 400, 2, 0, false); // TODO add methods get input by output, or all recipe here
}
return null;
});
}
@Override

View file

@ -6,7 +6,7 @@ import gregtechmod.api.interfaces.IGregTechTileEntity;
import gregtechmod.api.metatileentity.MetaTileEntity;
import gregtechmod.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine;
import gregtechmod.api.recipe.Recipe;
import gregtechmod.api.util.GT_Utility;
import net.minecraft.entity.player.EntityPlayer;
public class GT_MetaTileEntity_PlateCutter extends GT_MetaTileEntity_BasicMachine {
@ -26,20 +26,6 @@ public class GT_MetaTileEntity_PlateCutter extends GT_MetaTileEntity_BasicMachin
return new GT_MetaTileEntity_PlateCutter(recipeLogic.recipeMap);
}
@Override
public void checkRecipe() {
GT_Utility.moveStackFromSlotAToSlotB(getBaseMetaTileEntity(), getBaseMetaTileEntity(), 1, 2, (byte)64, (byte)1, (byte)64, (byte)1);
if (mInventory[2] != null && mInventory[2].stackSize > 0) {
Recipe tRecipe = Recipe.findEqualRecipe(false, Recipe.sCutterRecipes, mInventory[2]);
if (tRecipe != null && spaceForOutput(tRecipe.getOutput(0), null) && tRecipe.isRecipeInputEqual(true, true, mInventory[2], null)) {
mEUt = tRecipe.mEUt;
mMaxProgresstime = tRecipe.mDuration;
if (tRecipe.getOutput(0) != null) mOutputItem1 = GT_Utility.copy(tRecipe.getOutput(0));
return;
}
}
}
@Override
public int getFrontFacingInactive() {
return 306;

View file

@ -29,15 +29,22 @@ public class GT_MetaTileEntity_Recycler extends GT_MetaTileEntity_BasicMachine {
}
@Override
public void checkRecipe() {
GT_Utility.moveStackFromSlotAToSlotB(getBaseMetaTileEntity(), getBaseMetaTileEntity(), 1, 2, (byte)64, (byte)1, (byte)64, (byte)1);
GT_Utility.moveStackFromSlotAToSlotB(getBaseMetaTileEntity(), getBaseMetaTileEntity(), 3, 4, (byte)64, (byte)1, (byte)64, (byte)1);
if (mInventory[2] != null && spaceForOutput(GT_ModHandler.getIC2Item("scrap", 1), null)) {
mOutputItem1 = GT_ModHandler.getRecyclerOutput(mInventory[2], getBaseMetaTileEntity().getRandomNumber(8));
mEUt = 1;
mMaxProgresstime = 45;
mInventory[2].stackSize--;
public void initRecipeLogic(List<Recipe> recipeMap) {
super.initRecipeLogic(recipeMap);
recipeLogic.setRecipeProvider(() -> {
if (GT_Utility.isStackValid(mInventory[2])) {
ItemStack instance = mInventory[2].copy();
instance.stackSize = 1;
return new Recipe(instance, null, null, null, null, null, 45, 1, 0, false) {
@Override
public ItemStack[] getOutputs() {
return new ItemStack[] {GT_ModHandler.getRecyclerOutput(mInputs[0][0], getBaseMetaTileEntity().getRandomNumber(8))}; // FIXME made chanded output in Recipe
}
};
}
return null;
});
}
@Override

View file

@ -8,6 +8,7 @@ import gregtechmod.api.interfaces.IGregTechTileEntity;
import gregtechmod.api.metatileentity.MetaTileEntity;
import gregtechmod.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine;
import gregtechmod.api.recipe.Recipe;
import gregtechmod.api.recipe.RecipeLogic;
import gregtechmod.api.util.GT_Utility;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
@ -35,32 +36,37 @@ public class GT_MetaTileEntity_Scanner extends GT_MetaTileEntity_BasicMachine {
return new GT_MetaTileEntity_Scanner(recipeLogic.recipeMap);
}
public void checkRecipe() {
GT_Utility.moveStackFromSlotAToSlotB(this.getBaseMetaTileEntity(), this.getBaseMetaTileEntity(), 3, 4, (byte)64, (byte)1, (byte)64, (byte)1);
if(super.mInventory[3] != null) {
super.bOutputBlocked = true;
} else if(GT_Utility.isStackValid(super.mInventory[1]) && super.mInventory[1].stackSize > 0 && GT_Items.IC2_Crop_Seeds.isStackEqual(super.mInventory[1], true, true)) {
NBTTagCompound tNBT = super.mInventory[1].getTagCompound();
if(tNBT == null) {
tNBT = new NBTTagCompound();
@Override
public void initRecipeLogic(List<Recipe> recipeMap) {
recipeLogic = new RecipeLogic(recipeMap, this) {
@Override
protected void moveItems() {
GT_Utility.moveStackFromSlotAToSlotB(getBaseMetaTileEntity(), getBaseMetaTileEntity(), 3, 4, (byte)64, (byte)1, (byte)64, (byte)1);
}
if(tNBT.getByte("scan") < 4) {
tNBT.setByte("scan", (byte)4);
super.mMaxProgresstime = 20;
super.mEUt = 500;
@Override
protected Recipe findRecipe() {
if (GT_Utility.isStackValid(mInventory[1]) && GT_Items.IC2_Crop_Seeds.isStackEqual(mInventory[1], true, true)) {
NBTTagCompound data = mInventory[1].getTagCompound();
if (data == null) return null; // May not work
int dur = 0, eut = 0;
if (data.getByte("scan") < 4) {
data.setByte("scan", (byte)4);
dur = 20;
eut = 500;
} else {
super.mMaxProgresstime = 1;
super.mEUt = 1;
dur = 1;
eut = 1;
}
--super.mInventory[1].stackSize;
super.mOutputItem1 = GT_Utility.copyAmount(1L, new Object[]{super.mInventory[1]});
super.mOutputItem1.setTagCompound(tNBT);
return;
ItemStack output = mInventory[1].copy();
output.setTagCompound(data);
return new Recipe(mInventory[1].copy(), null, output, null, null, null, dur, eut, 0, false);
}
super.mMaxProgresstime = 0;
return null;
}
};
}
public boolean allowPutStack(int aIndex, byte aSide, ItemStack aStack) {

View file

@ -330,7 +330,7 @@ public class GT_MachineRecipeLoader implements Runnable
GregTech_API.sRecipeAdder.addAssemblerRecipe(GT_ModHandler.getIC2Item("carbonFiber", 2L), null, GT_ModHandler.getIC2Item("carbonMesh", 1L), 800, 2);
GregTech_API.sRecipeAdder.addAssemblerRecipe(GT_ModHandler.getIC2Item("carbonMesh", 16L), null, GT_Items.Component_LavaFilter.get(1L), 1600, 8);
GregTech_API.sRecipeAdder.addAssemblerRecipe(GT_Items.Circuit_Basic.get(1L), GT_ModHandler.getIC2Item("frequencyTransmitter", 1L), GT_Items.NC_SensorKit.get(1L), 1600, 2);
GregTech_API.sRecipeAdder.addAssemblerRecipe(GT_Items.NC_SensorCard.getWildcard(1L), null, GT_Items.Circuit_Basic.get(2L), 1600, 2);
GregTech_API.sRecipeAdder.addAssemblerRecipe(GT_Items.NC_SensorCard.getWithDamage(1L, 0L), null, GT_Items.Circuit_Basic.get(2L), 1600, 2);
GregTech_API.sRecipeAdder.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Aluminium, 1L), GT_ModHandler.getIC2Item("pump", 1L), GregTech_API.getGregTechComponent(6, 1), 800, 16);
GregTech_API.sRecipeAdder.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Aluminium, 1L), new ItemStack(Blocks.heavy_weighted_pressure_plate, 1, 32767), GregTech_API.getGregTechComponent(11, 1), 800, 16);
GregTech_API.sRecipeAdder.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Aluminium, 1L), new ItemStack(Blocks.light_weighted_pressure_plate, 1, 32767), GregTech_API.getGregTechComponent(10, 1), 800, 16);