Fixed Blast Furnance

- Added common abstract class for multiblocks
- Fixed Recipes metadata usage
- Added misc methods in UnifierRecipeEntry
This commit is contained in:
TheDarkDnKTv 2021-02-25 08:10:56 +02:00
parent 0b59e42926
commit 03115ad01a
9 changed files with 316 additions and 187 deletions

View file

@ -78,7 +78,7 @@ public class Recipe {
* @param input collection of input stacks even nulls
* @return true if recipe matches for machine <b>input</b>
*/
public boolean matches(boolean decrease, List<ItemStack> input, List<FluidStack> fluidInputs) { // TODO fluid recipes!
public boolean matches(boolean decrease, List<ItemStack> input, List<FluidStack> fluidInputs) {
assert input != null && fluidInputs != null : "Item/Fluid input can not be null!";
assert input.isEmpty() : "Input can not be empty!";
assert input.size() >= itemInputs.size() : "Can not be less inputs of machine than recipe has!";

View file

@ -4,6 +4,7 @@ import java.lang.ref.WeakReference;
import java.util.List;
import java.util.Random;
import java.util.function.IntUnaryOperator;
import java.util.function.Predicate;
import gregtechmod.api.interfaces.IGregTechTileEntity;
import gregtechmod.api.interfaces.IRecipeWorkable;
@ -27,6 +28,7 @@ public class RecipeLogic {
public int batterySlot = 5;
/** Custom fucntion called every recipe progress time update, if you want to speed up machine because of some factor, just increase the value up */
protected IntUnaryOperator progressTimeManipulator = i -> i;
protected Predicate<Recipe> metadataVerifier = recipe -> true;
protected Recipe previousRecipe;
protected int maxProgressTime;
protected int progressTime;
@ -98,6 +100,10 @@ public class RecipeLogic {
progressTimeManipulator = applier;
}
public void setMetadataVerify(Predicate<Recipe> verifier) {
metadataVerifier = verifier;
}
protected boolean updateRecipeProgress() {
if (getMachine().getBaseMetaTileEntity().decreaseStoredEnergyUnits(EUt * (int)Math.pow(4, overclockersCount), false)) {
if ((progressTime += progressTimeManipulator.applyAsInt((int)Math.pow(2, overclockersCount))) >= maxProgressTime) {
@ -126,7 +132,7 @@ public class RecipeLogic {
startRecipe(previousRecipe);
} else {
previousRecipe = null;
getMachine().getBaseMetaTileEntity().setActive(false);
triggerMachine(false);
}
} else {
// find new recipe
@ -138,11 +144,11 @@ public class RecipeLogic {
}
protected Recipe findRecipe() {
return recipeMap.findRecipe(getMachine().getInputItems(), getMachine().getFluidInputs());
return recipeMap.findRecipe(getMachine().getInputItems(), getMachine().getFluidInputs(), metadataVerifier);
}
protected boolean match(Recipe recipe) {
return recipe.matches(false, getMachine().getInputItems(), getMachine().getFluidInputs());
return metadataVerifier.test(recipe) && recipe.matches(false, getMachine().getInputItems(), getMachine().getFluidInputs());
}
protected boolean consumeInputs(Recipe recipe) {
@ -156,7 +162,7 @@ public class RecipeLogic {
progressTime = 1;
EUt = recipe.getEUt();
if (consumeInputs(recipe)) {
getMachine().getBaseMetaTileEntity().setActive(true);
triggerMachine(true);
getMachine().startProcess();
} else {
GT_Log.log.catching(new IllegalStateException("Error state detected! RecipeMap passed recipe, but it's not matching! Report about this!!!"));
@ -167,7 +173,7 @@ public class RecipeLogic {
}
} else {
getMachine().getBaseMetaTileEntity().setActive(false);
triggerMachine(false);
}
}
@ -209,6 +215,10 @@ public class RecipeLogic {
getMachine().endProcess();
}
protected void triggerMachine(boolean value) {
getMachine().getBaseMetaTileEntity().setActive(value);
}
protected boolean isInputNonEmpty() {
return !getMachine().getInputItems().isEmpty() || !getMachine().getFluidInputs().isEmpty();
}

View file

@ -10,6 +10,7 @@ import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.function.IntConsumer;
import java.util.function.Predicate;
import gregtechmod.api.util.GT_RecipeException;
import gregtechmod.api.util.GT_Utility;
@ -63,9 +64,47 @@ public class RecipeMap<F extends RecipeFactory<F>> {
return factory;
}
public Recipe findRecipe(List<ItemStack> input, List<FluidStack> fluidInputs, Predicate<Recipe> metaChecker) {
Set<Recipe> recipesTotal = this.getMappedRecipes(input, fluidInputs);
Recipe result = null;
if (!recipesTotal.isEmpty())
result = findRecipe(recipesTotal, input, fluidInputs, metaChecker);
return result != null && result.enabled ? result : null;
}
public Recipe findRecipe(List<ItemStack> input, List<FluidStack> fluidInputs) {
if (input.size() < minInputs)
throw new IllegalArgumentException("Inputs of machine can not be smaller than minimum RecipeMap inputs amount");
Set<Recipe> recipesTotal = this.getMappedRecipes(input, fluidInputs);
Recipe result = null;
if (!recipesTotal.isEmpty())
result = findRecipe(recipesTotal, input, fluidInputs);
return result != null && result.enabled ? result : null;
}
private Recipe findRecipe(Collection<Recipe> recipes, List<ItemStack> input, List<FluidStack> fluidInputs) {
if (recipes != null) {
for (Recipe recipe : recipes) {
if (recipe.matches(false, input, fluidInputs)) {
return recipe;
}
}
}
return null;
}
private Recipe findRecipe(Collection<Recipe> recipes, List<ItemStack> input, List<FluidStack> fluidInputs, Predicate<Recipe> metaChecker) {
if (recipes != null) {
for (Recipe recipe : recipes) {
if (metaChecker.test(recipe) && recipe.matches(false, input, fluidInputs)) {
return recipe;
}
}
}
return null;
}
private Set<Recipe> getMappedRecipes(List<ItemStack> input, List<FluidStack> fluidInputs) {
Set<Recipe> recipesTotal = new HashSet<>();
for (FluidStack fluid : fluidInputs) {
if (GT_Utility.isFluidStackValid(fluid)) {
@ -86,24 +125,7 @@ public class RecipeMap<F extends RecipeFactory<F>> {
}
}
Recipe result = null;
if (!recipesTotal.isEmpty()) {
result = findRecipe(recipesTotal, input, fluidInputs);
}
return result != null && result.enabled ? result : null;
}
private Recipe findRecipe(Collection<Recipe> recipes, List<ItemStack> input, List<FluidStack> fluidInputs) {
if (recipes != null) {
for (Recipe recipe : recipes) {
if (recipe.matches(false, input, fluidInputs)) {
return recipe;
}
}
}
return null;
return recipesTotal;
}
/**

View file

@ -2,11 +2,15 @@ package gregtechmod.api.util;
import gregtechmod.api.GregTech_API;
import gregtechmod.api.enums.Dyes;
import gregtechmod.api.enums.Materials;
import gregtechmod.api.enums.OrePrefixes;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
import java.util.stream.Collectors;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
@ -191,12 +195,21 @@ public class GT_OreDictUnificator {
return sItemhash2NameMap.get(GT_Utility.stackToInt(aStack));
}
public static boolean isItemStackInstanceOf(ItemStack aStack, Object aName) {
if (GT_Utility.isStringInvalid(aName) || GT_Utility.isStackInvalid(aStack)) return false;
for (ItemStack tOreStack : getOres(aName.toString())) {
if (GT_Utility.areStacksEqual(tOreStack, aStack, !tOreStack.hasTagCompound())) return true;
public static boolean isItemStackInstanceOf(ItemStack aStack, OrePrefixes prefix, Materials material) {
if (prefix == null || material == null) return false;
return isItemStackInstanceOf(aStack, prefix.get(material));
}
return false;
public static boolean isItemStackInstanceOf(ItemStack aStack, Object aName) { // TODO rework all this class
if (GT_Utility.isStringInvalid(aName) || GT_Utility.isStackInvalid(aStack)) return false;
// for (ItemStack tOreStack : getOres(aName.toString())) {
// if (GT_Utility.areStacksEqual(tOreStack, aStack, !tOreStack.hasTagCompound())) return true;
// }
List<String> names = Arrays.stream(OreDictionary.getOreIDs(aStack))
.mapToObj(val -> OreDictionary.getOreName(val))
.collect(Collectors.toList());
return names.contains(aName.toString());
}
public static boolean isItemStackDye(Dyes dye, ItemStack aStack) {

View file

@ -26,27 +26,19 @@ public class GT_Container_BlastFurnace extends GT_ContainerMetaTile_Machine {
addSlotToContainer(new GT_Slot_Output(mTileEntity, 3, 104, 25));
}
public int mProgress, mMaxProgress, mProgressScale, mHeatCapacity;
public int mHeatCapacity;
public boolean mMachine = true;
@SuppressWarnings("rawtypes")
public void detectAndSendChanges() {
super.detectAndSendChanges();
if (mTileEntity.isClientSide() || mTileEntity.getMetaTileEntity() == null) return;
mMachine = ((GT_MetaTileEntity_BlastFurnace)mTileEntity.getMetaTileEntity()).mMachine;
// mProgress = ((GT_MetaTileEntity_BlastFurnace)mTileEntity.getMetaTileEntity()).getProgresstime();
// mMaxProgress = ((GT_MetaTileEntity_BlastFurnace)mTileEntity.getMetaTileEntity()).maxProgresstime();
mProgress = 0;
mMaxProgress = 0;
mProgressScale = Math.max(0, Math.min(20, (mProgress>0?1:0) + (mProgress * 20) / (mMaxProgress<1?1:mMaxProgress)));
mMachine = ((GT_MetaTileEntity_BlastFurnace)mTileEntity.getMetaTileEntity()).isStructComplete();
mHeatCapacity = ((GT_MetaTileEntity_BlastFurnace)mTileEntity.getMetaTileEntity()).mHeatCapacity;
Iterator var2 = this.crafters.iterator();
while (var2.hasNext()) {
ICrafting var1 = (ICrafting)var2.next();
var1.sendProgressBarUpdate(this, 100, mProgress);
var1.sendProgressBarUpdate(this, 101, mMaxProgress);
var1.sendProgressBarUpdate(this, 102, mProgressScale);
var1.sendProgressBarUpdate(this, 103, mMachine?1:0);
var1.sendProgressBarUpdate(this, 104, mHeatCapacity);
}
@ -56,9 +48,6 @@ public class GT_Container_BlastFurnace extends GT_ContainerMetaTile_Machine {
public void updateProgressBar(int par1, int par2) {
super.updateProgressBar(par1, par2);
switch (par1) {
case 100: mProgress = par2; break;
case 101: mMaxProgress = par2; break;
case 102: mProgressScale = par2; break;
case 103: mMachine = (par2!=0); break;
case 104: mHeatCapacity = par2; break;
}

View file

@ -34,7 +34,8 @@ public class GT_GUIContainer_BlastFurnace extends GT_GUIContainerMetaTile_Machin
drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
if (mContainer != null) {
int tScale = ((GT_Container_BlastFurnace)mContainer).mProgressScale;
GT_Container_BlastFurnace cont = (GT_Container_BlastFurnace) mContainer;
int tScale = Math.max(0, Math.min(20, (cont.mProgressTime>0?1:0) + (cont.mProgressTime * 20) / (cont.mMaxProgressTime<1?1:cont.mMaxProgressTime)));
if (mContainer.mProgressTime>0) drawTexturedModalRect(x + 58, y + 28, 176, 0, tScale, 11);
}
}

View file

@ -1,6 +1,10 @@
package gregtechmod.common.recipe;
import java.util.List;
import java.util.Objects;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import gregtechmod.api.enums.Materials;
import gregtechmod.api.enums.OrePrefixes;
@ -36,8 +40,7 @@ public class UnifierRecipeEntry implements Ingredient {
@Override
public boolean match(ItemStack input) {
// GT_OreDictUnificator. // FIXME Fix oredict unificator
return false;
return GT_OreDictUnificator.isItemStackInstanceOf(input, prefix, material);
}
@Override
@ -56,4 +59,25 @@ public class UnifierRecipeEntry implements Ingredient {
public boolean isWildcard() {
return false;
}
@Override
public int hashCode() {
return Objects.hash(prefix, material, count);
}
@Override
public boolean equals(Object obj) {
if (obj instanceof UnifierRecipeEntry) {
UnifierRecipeEntry r = (UnifierRecipeEntry) obj;
return r.prefix == prefix && r.material == material && r.count == count;
}
return false;
}
@Override
public String toString() {
ToStringBuilder.setDefaultStyle(ToStringStyle.SHORT_PREFIX_STYLE);
return new ToStringBuilder(this).build();
}
}

View file

@ -0,0 +1,180 @@
package gregtechmod.common.tileentities.machines.multi;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import gregtechmod.api.GregTech_API;
import gregtechmod.api.interfaces.IRecipeWorkable;
import gregtechmod.api.metatileentity.MetaTileEntity;
import gregtechmod.api.recipe.Recipe;
import gregtechmod.api.recipe.RecipeLogic;
import gregtechmod.api.recipe.RecipeMap;
import gregtechmod.api.util.GT_Utility;
import gregtechmod.api.util.InfoBuilder;
import gregtechmod.api.util.ListAdapter;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.fluids.FluidStack;
/** Base workable multiblock machines class
* @author TheDarkDnKTv
*
*/
public abstract class BaseMultiWorkable extends MetaTileEntity implements IRecipeWorkable {
protected RecipeLogic recipeLogic;
protected boolean needCheckStruct = false;
protected boolean structComplete = false;
public BaseMultiWorkable(int aID, String aBasicName, RecipeMap<?> map) {
super(aID, aBasicName);
initRecipeLogic(map);
}
public BaseMultiWorkable(RecipeMap<?> map) {
initRecipeLogic(map);
}
@Override public boolean isTransformerUpgradable() {return true;}
@Override public boolean isOverclockerUpgradable() {return true;}
@Override public boolean isBatteryUpgradable() {return true;}
@Override public boolean allowToCheckRecipe() {return true;}
@Override public boolean isAccessAllowed(EntityPlayer aPlayer) {return true;}
@Override public boolean isGivingInformation() {return true;}
@Override public boolean isSimpleMachine() {return false;}
@Override public boolean isFacingValid(byte aFacing) {return aFacing > 1;}
@Override public boolean isEnetInput() {return true;}
@Override public boolean isInputFacing(byte aSide) {return true;}
@Override public int maxRFStore() {return maxEUStore();}
@Override public int maxSteamStore() {return maxEUStore();}
@Override public int maxEUInput() {return 128;}
@Override public int maxEUStore() {return 10000;}
@Override public RecipeLogic getRecipeLogic() {return recipeLogic;}
@Override public int increaseProgress(int aProgress) {recipeLogic.increaseProgressTime(aProgress);return recipeLogic.getMaxProgressTime()-recipeLogic.getProgressTime();}
protected abstract boolean checkMachine();
public boolean isStructComplete() {
return structComplete;
}
@Override
public void onPostTick() {
if (getBaseMetaTileEntity().isServerSide() && needCheckStruct) {
structComplete = checkMachine();
needCheckStruct = false;
getBaseMetaTileEntity().setActive(structComplete);
}
}
protected void initRecipeLogic(RecipeMap<?> map) {
recipeLogic = new RecipeLogic(map, this) {
@Override protected void triggerMachine(boolean value) {}
};
}
@Override
public void saveNBTData(NBTTagCompound aNBT) {
recipeLogic.saveToNBT(aNBT);
}
@Override
public void loadNBTData(NBTTagCompound aNBT) {
needCheckStruct = true;
recipeLogic.loadFromNBT(aNBT);
}
@Override
public void startProcess() {}
@Override
public void endProcess() {}
@Override
public void stutterProcess() {
if (GregTech_API.sConstantEnergy) {
int val = (int) (recipeLogic.getMaxProgressTime() * 0.1D);
if (recipeLogic.getProgressTime() > val)
recipeLogic.increaseProgressTime(-val);
}
}
@Override
public void onMachineBlockUpdate() {
needCheckStruct = true;
}
@Override
public boolean spaceForOutput(Recipe recipe) {
List<ItemStack> outputSlots = this.getOutputItems();
List<ItemStack> allOutputs = recipe.getAllOutputs();
for (ItemStack current : allOutputs) {
int amount = current.stackSize;
for (int i = 0; current != null && amount > 0 && i < outputSlots.size(); i++) {
ItemStack slot = outputSlots.get(i);
if (slot == null) {
amount = 0;
break;
} else if (GT_Utility.areStacksEqual(slot, current)) {
int newSize = Math.min(slot.getMaxStackSize(), amount + slot.stackSize);
amount -= newSize;
}
}
if (amount > 0) {
return false;
}
}
return true;
}
@Override
public List<ItemStack> getInputItems() {
return new ListAdapter<>(mInventory, 0, 1);
}
@Override
public List<ItemStack> getOutputItems() {
return new ListAdapter<>(mInventory, 2, 3);
}
@Override
public List<FluidStack> getFluidInputs() {
return Collections.emptyList();
}
@Override
public List<FluidStack> getFluidOutputs() {
return Collections.emptyList();
}
@Override
public int getInvSize() {
return 4;
}
@Override
public boolean allowPullStack(int aIndex, byte aSide, ItemStack aStack) {
return aIndex == 2 || aIndex == 3;
}
@Override
public boolean allowPutStack(int aIndex, byte aSide, ItemStack aStack) {
return aIndex == 0 || aIndex == 1;
}
@Override
public Map<String, List<Object>> getInfoData() {
return InfoBuilder.create()
.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

@ -1,15 +1,13 @@
package gregtechmod.common.tileentities.machines.multi;
import java.util.List;
import java.util.Map;
import gregtechmod.api.GregTech_API;
import gregtechmod.api.interfaces.IGregTechTileEntity;
import gregtechmod.api.metatileentity.MetaTileEntity;
import gregtechmod.api.recipe.Recipe;
import gregtechmod.api.recipe.RecipeMap;
import gregtechmod.api.util.GT_OreDictUnificator;
import gregtechmod.api.util.GT_Utility;
import gregtechmod.api.util.InfoBuilder;
import gregtechmod.common.recipe.RecipeMaps;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
@ -17,34 +15,29 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
public class GT_MetaTileEntity_BlastFurnace extends MetaTileEntity {
public class GT_MetaTileEntity_BlastFurnace extends BaseMultiWorkable {
public int mProgresstime = 0, mMaxProgresstime = 0, mEUt = 0, mHeatCapacity = 0, mUpdate = 5, mHeatingCoilTier = 0;
public ItemStack mOutputItem1, mOutputItem2;
public boolean mMachine = false;
public int mHeatCapacity = 0, mHeatingCoilTier = 0;
public GT_MetaTileEntity_BlastFurnace(int aID, String mName) {
super(aID, mName);
super(aID, mName, RecipeMaps.BLAST_FURNANCE);
}
public GT_MetaTileEntity_BlastFurnace() {
super(RecipeMaps.BLAST_FURNANCE);
}
@Override public boolean isTransformerUpgradable() {return true;}
@Override public boolean isOverclockerUpgradable() {return true;}
@Override public boolean isBatteryUpgradable() {return true;}
@Override public boolean isSimpleMachine() {return false;}
@Override public boolean isFacingValid(byte aFacing) {return aFacing > 1;}
@Override public boolean isEnetInput() {return true;}
@Override public boolean isInputFacing(byte aSide) {return true;}
@Override public int maxEUInput() {return 128;}
@Override public int maxEUStore() {return 10000;}
@Override public int maxRFStore() {return maxEUStore();}
@Override public int maxSteamStore() {return maxEUStore();}
@Override public int getInvSize() {return 4;}
@Override public boolean isAccessAllowed(EntityPlayer aPlayer) {return true;}
@Override public int increaseProgress(int aProgress) {mProgresstime += aProgress; return mMaxProgresstime-mProgresstime;}
@Override
protected void initRecipeLogic(RecipeMap<?> map) {
super.initRecipeLogic(map);
recipeLogic.setMetadataVerify(recipe -> {
Object data = recipe.getMeta("minTemp");
if (data != null && data instanceof Integer)
return mHeatCapacity >= ((Integer)data);
return false;
});
}
@Override
public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
@ -53,37 +46,14 @@ public class GT_MetaTileEntity_BlastFurnace extends MetaTileEntity {
@Override
public void saveNBTData(NBTTagCompound aNBT) {
aNBT.setInteger("mEUt", mEUt);
aNBT.setInteger("mProgresstime", mProgresstime);
aNBT.setInteger("mMaxProgresstime", mMaxProgresstime);
super.saveNBTData(aNBT);
aNBT.setByte("mHeatingCoilTier", (byte)mHeatingCoilTier);
if (mOutputItem1 != null) {
NBTTagCompound tNBT = new NBTTagCompound();
mOutputItem1.writeToNBT(tNBT);
aNBT.setTag("mOutputItem1", tNBT);
}
if (mOutputItem2 != null) {
NBTTagCompound tNBT = new NBTTagCompound();
mOutputItem2.writeToNBT(tNBT);
aNBT.setTag("mOutputItem2", tNBT);
}
}
@Override
public void loadNBTData(NBTTagCompound aNBT) {
mUpdate = 5;
mEUt = aNBT.getInteger("mEUt");
mProgresstime = aNBT.getInteger("mProgresstime");
mMaxProgresstime = aNBT.getInteger("mMaxProgresstime");
super.loadNBTData(aNBT);
mHeatingCoilTier = aNBT.getByte("mHeatingCoilTier");
NBTTagCompound tNBT1 = (NBTTagCompound)aNBT.getTag("mOutputItem1");
if (tNBT1 != null) {
mOutputItem1 = GT_Utility.loadItem(tNBT1);
}
NBTTagCompound tNBT2 = (NBTTagCompound)aNBT.getTag("mOutputItem2");
if (tNBT2 != null) {
mOutputItem2 = GT_Utility.loadItem(tNBT2);
}
}
@Override
@ -98,7 +68,7 @@ public class GT_MetaTileEntity_BlastFurnace extends MetaTileEntity {
if (tPlayerItem.stackSize > 3 || aPlayer.capabilities.isCreativeMode) {
if (!aPlayer.capabilities.isCreativeMode) tPlayerItem.stackSize-=4;
mHeatingCoilTier = 1;
mUpdate = 5;
needCheckStruct = true;
}
return;
}
@ -106,7 +76,7 @@ public class GT_MetaTileEntity_BlastFurnace extends MetaTileEntity {
if (tPlayerItem.stackSize > 3 || aPlayer.capabilities.isCreativeMode) {
if (!aPlayer.capabilities.isCreativeMode) tPlayerItem.stackSize-=4;
mHeatingCoilTier = 2;
mUpdate = 5;
needCheckStruct = true;
}
return;
}
@ -114,14 +84,14 @@ public class GT_MetaTileEntity_BlastFurnace extends MetaTileEntity {
if (tPlayerItem.stackSize > 3 || aPlayer.capabilities.isCreativeMode) {
if (!aPlayer.capabilities.isCreativeMode) tPlayerItem.stackSize-=4;
mHeatingCoilTier = 3;
mUpdate = 5;
needCheckStruct = true;
}
return;
}
getBaseMetaTileEntity().openGUI(aPlayer, 113);
}
private boolean checkMachine() {
protected boolean checkMachine() {
int xDir = ForgeDirection.getOrientation(getBaseMetaTileEntity().getFrontFacing()).offsetX*2, yDir = ForgeDirection.getOrientation(getBaseMetaTileEntity().getFrontFacing()).offsetY*2, zDir = ForgeDirection.getOrientation(getBaseMetaTileEntity().getFrontFacing()).offsetZ*2;
mHeatCapacity = mHeatingCoilTier * 500;
for (int i = -1; i < 2; i++) for (int j = 0; j < 4; j++) for (int k = -1; k < 2; k++) {
@ -147,81 +117,14 @@ public class GT_MetaTileEntity_BlastFurnace extends MetaTileEntity {
return true;
}
@Override
public void onMachineBlockUpdate() {
mUpdate = 5;
}
@Override
public void onPostTick() {
super.onPostTick();
if (getBaseMetaTileEntity().isServerSide()) {
if (mUpdate--==0) {
mMachine = checkMachine();
if (!mMachine) mHeatCapacity = 0;
if (structComplete) {
recipeLogic.update();
} else mHeatCapacity = 0;
}
getBaseMetaTileEntity().setActive(mMachine);
if (mMachine && mMaxProgresstime > 0) {
if (mProgresstime < 0 || getBaseMetaTileEntity().decreaseStoredEnergyUnits(mEUt*(int)Math.pow(4, getBaseMetaTileEntity().getOverclockerUpgradeCount()), false)) {
if ((mProgresstime+=(int)Math.pow(2, getBaseMetaTileEntity().getOverclockerUpgradeCount()))>=mMaxProgresstime) {
addOutputProducts();
mOutputItem1 = null;
mOutputItem2 = null;
mProgresstime = 0;
mMaxProgresstime = 0;
getBaseMetaTileEntity().setErrorDisplayID(0);
}
} else {
if (GregTech_API.sConstantEnergy) {
mProgresstime = -10;
getBaseMetaTileEntity().setErrorDisplayID(1);
}
}
} else {
if (getBaseMetaTileEntity().isAllowedToWork() && getBaseMetaTileEntity().getUniversalEnergyStored() > 100) checkRecipe();
}
}
}
private void addOutputProducts() {
if (mOutputItem1 != null)
if (mInventory[2] == null)
mInventory[2] = GT_Utility.copy(mOutputItem1);
else if (GT_Utility.areStacksEqual(mInventory[2], mOutputItem1))
mInventory[2].stackSize = Math.min(mOutputItem1.getMaxStackSize(), mOutputItem1.stackSize + mInventory[2].stackSize);
if (mOutputItem2 != null)
if (mInventory[3] == null)
mInventory[3] = GT_Utility.copy(mOutputItem2);
else if (GT_Utility.areStacksEqual(mInventory[3], mOutputItem2))
mInventory[3].stackSize = Math.min(mOutputItem2.getMaxStackSize(), mOutputItem2.stackSize + mInventory[3].stackSize);
}
private boolean spaceForOutput(Recipe aRecipe) {
if (mInventory[2] == null || aRecipe.getOutput(0) == null || (mInventory[2].stackSize + aRecipe.mOutputs[0].stackSize <= mInventory[2].getMaxStackSize() && GT_Utility.areStacksEqual(mInventory[2], aRecipe.getOutput(0))))
if (mInventory[3] == null || aRecipe.getOutput(1) == null || (mInventory[3].stackSize + aRecipe.mOutputs[1].stackSize <= mInventory[3].getMaxStackSize() && GT_Utility.areStacksEqual(mInventory[3], aRecipe.getOutput(1))))
return true;
return false;
}
private boolean checkRecipe() {
if (!mMachine) return false;
Recipe tRecipe = Recipe.findEqualRecipe(false, false, Recipe.sBlastRecipes, mInventory[0], mInventory[1]);
if (tRecipe != null) {
if (mHeatCapacity >= tRecipe.mStartEU && spaceForOutput(tRecipe) && tRecipe.isRecipeInputEqual(true, true, mInventory[0], mInventory[1])) {
if (mInventory[0] != null) if (mInventory[0].stackSize == 0) mInventory[0] = null;
if (mInventory[1] != null) if (mInventory[1].stackSize == 0) mInventory[1] = null;
mMaxProgresstime = tRecipe.mDuration;
mEUt = tRecipe.mEUt;
mOutputItem1 = GT_Utility.copy(tRecipe.mOutputs[0]);
mOutputItem2 = GT_Utility.copy(tRecipe.mOutputs[1]);
return true;
}
}
return false;
}
@Override
@ -233,19 +136,6 @@ public class GT_MetaTileEntity_BlastFurnace extends MetaTileEntity {
return 72;
}
@Override
public Map<String, List<Object>> getInfoData() {
return InfoBuilder.create()
.newKey("sensor.progress.percentage", mProgresstime * 100.0D / mMaxProgresstime)
.newKey("sensor.progress.secs", mProgresstime / 20)
.newKey("sensor.progress.secs", mMaxProgresstime / 20)
.build();
}
@Override
public boolean isGivingInformation() {
return true;
}
@Override
public String getDescription() {
return "metatileentity.GT_BlastFurnace.tooltip";