aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlkalus <3060479+draknyte1@users.noreply.github.com>2019-12-09 21:03:31 +0000
committerAlkalus <3060479+draknyte1@users.noreply.github.com>2019-12-09 21:03:31 +0000
commit051c46ab36a749954cff3bae1fbd44cea6f1fc99 (patch)
treebaad2cc9886c5f0b7bf3a381c7002af9fe3ac80e /src
parente49fbd1330c0875ff531ff25119afe15b54c9448 (diff)
downloadGT5-Unofficial-051c46ab36a749954cff3bae1fbd44cea6f1fc99.tar.gz
GT5-Unofficial-051c46ab36a749954cff3bae1fbd44cea6f1fc99.tar.bz2
GT5-Unofficial-051c46ab36a749954cff3bae1fbd44cea6f1fc99.zip
+ Added GT++ API class.
+ Added handler for Void Miner to API. + Added handler for special multiblock logic to API. + Added Initial work For Chemical Plant. % More work on the Algae Farm.
Diffstat (limited to 'src')
-rw-r--r--src/Java/gtPlusPlus/api/helpers/GregtechPlusPlus_API.java194
-rw-r--r--src/Java/gtPlusPlus/api/objects/data/WeightedCollection.java102
-rw-r--r--src/Java/gtPlusPlus/api/objects/minecraft/multi/NoOutputBonusMultiBehaviour.java28
-rw-r--r--src/Java/gtPlusPlus/api/objects/minecraft/multi/SpecialMultiBehaviour.java44
-rw-r--r--src/Java/gtPlusPlus/core/common/CommonProxy.java3
-rw-r--r--src/Java/gtPlusPlus/core/recipe/common/CI.java4
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java4
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java71
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/util/SpecialBehaviourTooltipHandler.java29
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/algae/GregtechMTE_AlgaePondBase.java169
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java483
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechAlgaeContent.java10
12 files changed, 1039 insertions, 102 deletions
diff --git a/src/Java/gtPlusPlus/api/helpers/GregtechPlusPlus_API.java b/src/Java/gtPlusPlus/api/helpers/GregtechPlusPlus_API.java
new file mode 100644
index 0000000000..9816d45bbf
--- /dev/null
+++ b/src/Java/gtPlusPlus/api/helpers/GregtechPlusPlus_API.java
@@ -0,0 +1,194 @@
+package gtPlusPlus.api.helpers;
+
+import java.util.HashMap;
+
+import gtPlusPlus.api.objects.data.WeightedCollection;
+import gtPlusPlus.api.objects.minecraft.multi.SpecialMultiBehaviour;
+import gtPlusPlus.core.util.minecraft.ItemUtils;
+import gtPlusPlus.xmod.gregtech.api.util.SpecialBehaviourTooltipHandler;
+import net.minecraft.block.Block;
+import net.minecraft.item.ItemStack;
+
+public class GregtechPlusPlus_API {
+
+ public static class Multiblock_API {
+
+ private static final HashMap<String, SpecialMultiBehaviour> mSpecialBehaviourItemMap;
+
+ static {
+ mSpecialBehaviourItemMap = new HashMap<String, SpecialMultiBehaviour>();
+ }
+
+ /**
+ * Register a special behaviour for GT++ Multis to listen use.
+ * @param aBehaviour - An Object which has extended {@link SpecialMultiBehaviour}'s base implementation.
+ * @return - Did this behaviour register properly?
+ */
+ public static boolean registerSpecialMultiBehaviour(SpecialMultiBehaviour aBehaviour) {
+ if (aBehaviour.getTriggerItem() == null || aBehaviour.getTriggerItemTooltip() == null || aBehaviour.getTriggerItemTooltip().length() <= 0) {
+ return false;
+ }
+ mSpecialBehaviourItemMap.put("UniqueKey_"+aBehaviour.hashCode(), aBehaviour);
+ SpecialBehaviourTooltipHandler.addTooltipForItem(aBehaviour.getTriggerItem(), aBehaviour.getTriggerItemTooltip());
+ return true;
+ }
+
+ public static final HashMap<String, SpecialMultiBehaviour> getSpecialBehaviourItemMap() {
+ return mSpecialBehaviourItemMap;
+ }
+
+
+ }
+
+ public static class VoidMiner_API {
+
+ private static final HashMap<Integer, HashMap<String, WeightedCollection<Block>>> mMinerLootCache;
+
+ static {
+ mMinerLootCache = new HashMap<Integer, HashMap<String, WeightedCollection<Block>>>();
+ }
+
+
+ /**
+ *
+ * Registers an ore block for a dimension. Uses a default weight of 100.
+ * @param aDim - The Dimension ID
+ * @param aOredictName - The OreDict name of the Ore to be mined.
+ * @return - If there was a valid Block found in the OreDict for the provided name.
+ */
+ public static boolean registerOreForVoidMiner(int aDim, String aOredictName) {
+ return registerOreForVoidMiner(aDim, aOredictName, 100);
+ }
+
+ /**
+ *
+ * Registers an ore block for a dimension. Uses a default weight of 100.
+ * @param aDim - The Dimension ID
+ * @param aOredictName - The OreDict name of the Ore to be mined.
+ * @param aWeight - The weight of this ore Block.
+ * @return - If there was a valid Block found in the OreDict for the provided name.
+ */
+ public static boolean registerOreForVoidMiner(int aDim, String aOredictName, int aWeight) {
+ Block b = null;
+ ItemStack[] aValidItems = ItemUtils.validItemsForOreDict(aOredictName);
+ for (ItemStack g : aValidItems) {
+ if (g != null) {
+ b = Block.getBlockFromItem(g.getItem());
+ if (b != null) {
+ break;
+ }
+ }
+ }
+ if (b != null) {
+ registerOreForVoidMiner(aDim, b, aWeight);
+ return true;
+ }
+ return false;
+ }
+
+
+ /**
+ * Registers an ore block for a dimension. Uses a default weight of 100.
+ * @param aDim - The Dimension ID
+ * @param aOreBlock - The Ore Block to be mined.
+ */
+ public static void registerOreForVoidMiner(int aDim, Block aOreBlock) {
+ registerOreForVoidMiner(aDim, aOreBlock, 100);
+ }
+
+ /**
+ * Registers an ore block for a dimension.
+ * @param aDim - The Dimension ID
+ * @param aOreBlock - The Ore Block to be mined.
+ * @param aWeight - The weight of this ore Block.
+ */
+ public static void registerOreForVoidMiner(int aDim, Block aOreBlock, int aWeight) {
+ GregtechPlusPlus_API_Internal.writeBlockToDimensionInCache(aDim, 0, aOreBlock, aWeight);
+ }
+
+ /**
+ * Registers a surface block for a dimension. Uses a default weight of 100.
+ * @param aDim - The Dimension ID
+ * @param aDirtBlock - The Dirt/Grass Block to be mined.
+ */
+ public static void registerEarthSurfaceForVoidMiner(int aDim, Block aDirtBlock) {
+ registerEarthSurfaceForVoidMiner(aDim, aDirtBlock, 100);
+ }
+
+ /**
+ * Registers a surface block for a dimension.
+ * @param aDim - The Dimension ID
+ * @param aDirtBlock - The Dirt/Grass Block to be mined.
+ * @param aWeight - The weight of this Dirt/Grass Block.
+ */
+ public static void registerEarthSurfaceForVoidMiner(int aDim, Block aDirtBlock, int aWeight) {
+ GregtechPlusPlus_API_Internal.writeBlockToDimensionInCache(aDim, 0, aDirtBlock, aWeight);
+ }
+
+ /**
+ * Registers a stone block for a dimension. Uses a default weight of 100.
+ * @param aDim - The Dimension ID
+ * @param aStoneBlock - The Stone Block to be mined.
+ */
+ public static void registerEarthStoneForVoidMiner(int aDim, Block aStoneBlock) {
+ registerEarthStoneForVoidMiner(aDim, aStoneBlock, 100);
+ }
+
+ /**
+ * Registers a stone block for a dimension.
+ * @param aDim - The Dimension ID
+ * @param aStoneBlock - The Stone Block to be mined.
+ * @param aWeight - The weight of this Stone Block.
+ */
+ public static void registerEarthStoneForVoidMiner(int aDim, Block aStoneBlock, int aWeight) {
+ GregtechPlusPlus_API_Internal.writeBlockToDimensionInCache(aDim, 0, aStoneBlock, aWeight);
+ }
+
+
+
+
+ public static WeightedCollection<Block> getAllRegisteredOresForDimension(int aDim) {
+ return mMinerLootCache.get(aDim).get("ore");
+ }
+
+ public static WeightedCollection<Block> getAllRegisteredDirtTypesForDimension(int aDim) {
+ return mMinerLootCache.get(aDim).get("dirt");
+ }
+
+ public static WeightedCollection<Block> getAllRegisteredStoneTypesForDimension(int aDim) {
+ return mMinerLootCache.get(aDim).get("stone");
+ }
+
+ public static final HashMap<Integer, HashMap<String, WeightedCollection<Block>>> getVoidMinerLootCache() {
+ return mMinerLootCache;
+ }
+
+ }
+
+
+ private static class GregtechPlusPlus_API_Internal {
+
+ private static void writeBlockToDimensionInCache(int aDim, int aType, Block aBlock, int aWeight) {
+ HashMap<String, WeightedCollection<Block>> aDimMap = VoidMiner_API.mMinerLootCache.get(aDim);
+ if (aDimMap == null) {
+ aDimMap = new HashMap<String, WeightedCollection<Block>>();
+ }
+ WeightedCollection<Block> aMappedBlocks = getBlockMap(aType, aDimMap);
+ aMappedBlocks.put(aWeight, aBlock);
+
+ }
+
+ private static WeightedCollection<Block> getBlockMap(int aType, HashMap<String, WeightedCollection<Block>> aDimMap){
+ WeightedCollection<Block> aMappedBlocks;
+ String aTypeName = ((aType == 0) ? "ore" : (aType == 1) ? "dirt" : (aType == 2) ? "stone" : "error");
+ aMappedBlocks = aDimMap.get(aTypeName);
+ if (aMappedBlocks == null) {
+ aMappedBlocks = new WeightedCollection<Block>();
+ }
+ return aMappedBlocks;
+ }
+
+ }
+
+
+}
diff --git a/src/Java/gtPlusPlus/api/objects/data/WeightedCollection.java b/src/Java/gtPlusPlus/api/objects/data/WeightedCollection.java
new file mode 100644
index 0000000000..f9966474b0
--- /dev/null
+++ b/src/Java/gtPlusPlus/api/objects/data/WeightedCollection.java
@@ -0,0 +1,102 @@
+package gtPlusPlus.api.objects.data;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.NavigableMap;
+import java.util.Random;
+import java.util.Set;
+import java.util.TreeMap;
+
+import gtPlusPlus.api.objects.random.XSTR;
+
+public class WeightedCollection<E> implements Map<Integer, E> {
+
+ private NavigableMap<Integer, E> map = new TreeMap<Integer, E>();
+ private Random random;
+ private int total = 0;
+
+ public WeightedCollection() {
+ this(new XSTR());
+ }
+
+ public WeightedCollection(Random random) {
+ this.random = random;
+ }
+
+ public E add(int weight, E object) {
+ if (weight <= 0) return null;
+ total += weight;
+ return map.put(total, object);
+ }
+
+ private E next() {
+ int value = random.nextInt(total) + 1; // Can also use floating-point weights
+ return map.ceilingEntry(value).getValue();
+ }
+
+ @Override
+ public int size() {
+ return map.size();
+ }
+
+ @Override
+ public boolean isEmpty() {
+ return map.isEmpty();
+ }
+
+ @Override
+ public boolean containsKey(Object key) {
+ return map.containsKey(key);
+ }
+
+ @Override
+ public boolean containsValue(Object value) {
+ return map.containsValue(value);
+ }
+
+ public E get() {
+ return next();
+ }
+
+ @Override
+ public E get(Object key) {
+ return next();
+ }
+
+ @Override
+ public void putAll(Map m) {
+ map.putAll(m);
+ }
+
+ @Override
+ public void clear() {
+ map.clear();
+ this.total = 0;
+ }
+
+ @Override
+ public Set keySet() {
+ return map.keySet();
+ }
+
+ @Override
+ public Collection values() {
+ return map.values();
+ }
+
+ @Override
+ public Set entrySet() {
+ return map.entrySet();
+ }
+
+ @Override
+ public E put(Integer key, E value) {
+ return add(key, value);
+ }
+
+ @Override
+ public E remove(Object key) {
+ return map.remove(key);
+ }
+
+} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/api/objects/minecraft/multi/NoOutputBonusMultiBehaviour.java b/src/Java/gtPlusPlus/api/objects/minecraft/multi/NoOutputBonusMultiBehaviour.java
new file mode 100644
index 0000000000..871b42b901
--- /dev/null
+++ b/src/Java/gtPlusPlus/api/objects/minecraft/multi/NoOutputBonusMultiBehaviour.java
@@ -0,0 +1,28 @@
+package gtPlusPlus.api.objects.minecraft.multi;
+
+import gtPlusPlus.api.helpers.GregtechPlusPlus_API.Multiblock_API;
+import gtPlusPlus.core.recipe.common.CI;
+import net.minecraft.item.ItemStack;
+
+public class NoOutputBonusMultiBehaviour extends SpecialMultiBehaviour {
+
+ public NoOutputBonusMultiBehaviour() {
+ Multiblock_API.registerSpecialMultiBehaviour(this);
+ }
+
+ @Override
+ public ItemStack getTriggerItem() {
+ return CI.getNumberedBioCircuit(22);
+ }
+
+ @Override
+ public String getTriggerItemTooltip() {
+ return "Prevents bonus output % on GT++ multiblocks when used";
+ }
+
+ @Override
+ public int getOutputChanceRoll() {
+ return 10000;
+ }
+
+}
diff --git a/src/Java/gtPlusPlus/api/objects/minecraft/multi/SpecialMultiBehaviour.java b/src/Java/gtPlusPlus/api/objects/minecraft/multi/SpecialMultiBehaviour.java
new file mode 100644
index 0000000000..e562ccc40b
--- /dev/null
+++ b/src/Java/gtPlusPlus/api/objects/minecraft/multi/SpecialMultiBehaviour.java
@@ -0,0 +1,44 @@
+package gtPlusPlus.api.objects.minecraft.multi;
+
+import gregtech.api.util.GT_Utility;
+import net.minecraft.item.ItemStack;
+
+/**
+ * Extend this class to implement custom behaviour for multiblocks.
+ * The Trigger item when in a special slot or input bus, will cause the multiblock to behave as specified.
+ * Not overriding a method here will cause the default values to be used.
+ * @author Alkalus
+ *
+ */
+public abstract class SpecialMultiBehaviour {
+
+ private final int mMaxParallelRecipes = Short.MIN_VALUE;
+ private final int mEUPercent = Short.MIN_VALUE;
+ private final int mSpeedBonusPercent = Short.MIN_VALUE;
+ private final int mOutputChanceRoll = Short.MIN_VALUE;
+
+ public abstract ItemStack getTriggerItem();
+
+ public abstract String getTriggerItemTooltip();
+
+ public int getMaxParallelRecipes() {
+ return this.mMaxParallelRecipes;
+ }
+
+ public int getEUPercent() {
+ return this.mEUPercent;
+ }
+
+ public int getSpeedBonusPercent() {
+ return this.mSpeedBonusPercent;
+ }
+
+ public int getOutputChanceRoll() {
+ return this.mOutputChanceRoll;
+ }
+
+ public final boolean isTriggerItem(ItemStack aToMatch) {
+ return GT_Utility.areStacksEqual(getTriggerItem(), aToMatch, false);
+ }
+
+}
diff --git a/src/Java/gtPlusPlus/core/common/CommonProxy.java b/src/Java/gtPlusPlus/core/common/CommonProxy.java
index 1920d9c903..f0d89b3016 100644
--- a/src/Java/gtPlusPlus/core/common/CommonProxy.java
+++ b/src/Java/gtPlusPlus/core/common/CommonProxy.java
@@ -53,6 +53,7 @@ import gtPlusPlus.plugin.villagers.block.BlockGenericSpawner;
import gtPlusPlus.xmod.eio.handler.HandlerTooltip_EIO;
import gtPlusPlus.xmod.galacticraft.handler.HandlerTooltip_GC;
import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList;
+import gtPlusPlus.xmod.gregtech.api.util.SpecialBehaviourTooltipHandler;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.entity.Entity;
import net.minecraft.entity.monster.EntityBlaze;
@@ -147,6 +148,8 @@ public class CommonProxy {
// Block Handler for all events.
Utils.registerEvent(new BlockEventHandler());
Utils.registerEvent(new GeneralTooltipEventHandler());
+ // Handles Tooltips for items giving custom multiblock behaviour
+ Utils.registerEvent(new SpecialBehaviourTooltipHandler());
// Handles Custom tooltips for EIO.
Utils.registerEvent(new HandlerTooltip_EIO());
// Handles Custom Tooltips for GC
diff --git a/src/Java/gtPlusPlus/core/recipe/common/CI.java b/src/Java/gtPlusPlus/core/recipe/common/CI.java
index 968a96135e..ce5587ef33 100644
--- a/src/Java/gtPlusPlus/core/recipe/common/CI.java
+++ b/src/Java/gtPlusPlus/core/recipe/common/CI.java
@@ -1239,4 +1239,8 @@ public class CI {
}
+ public static ItemStack getNumberedBioCircuit(int i) {
+ return GregtechItemList.Circuit_BioRecipeSelector.getWithDamage(i, 0L);
+ }
+
}
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java
index 3fc6d9d667..f61078437b 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java
@@ -231,7 +231,9 @@ public enum GregtechItemList implements GregtechItemContainer {
//Algae
AlgaeFarm_Controller,
-
+
+ //Chemical Plant
+ ChemicalPlant_Controller,
//GT4 autoCrafter
GT4_Multi_Crafter,
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java
index 3c3345d130..89c1112726 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java
@@ -6,6 +6,7 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.TimeUnit;
@@ -40,14 +41,16 @@ import gregtech.api.util.GT_Recipe.GT_Recipe_Map;
import gregtech.api.util.GT_Utility;
import gtPlusPlus.GTplusplus;
import gtPlusPlus.GTplusplus.INIT_PHASE;
+import gtPlusPlus.api.helpers.GregtechPlusPlus_API.Multiblock_API;
import gtPlusPlus.api.objects.Logger;
import gtPlusPlus.api.objects.data.AutoMap;
import gtPlusPlus.api.objects.data.ConcurrentHashSet;
import gtPlusPlus.api.objects.data.ConcurrentSet;
import gtPlusPlus.api.objects.data.FlexiblePair;
-import gtPlusPlus.api.objects.data.Pair;
import gtPlusPlus.api.objects.data.Triplet;
import gtPlusPlus.api.objects.minecraft.BlockPos;
+import gtPlusPlus.api.objects.minecraft.multi.NoOutputBonusMultiBehaviour;
+import gtPlusPlus.api.objects.minecraft.multi.SpecialMultiBehaviour;
import gtPlusPlus.core.lib.CORE;
import gtPlusPlus.core.lib.LoadedMods;
import gtPlusPlus.core.recipe.common.CI;
@@ -65,7 +68,6 @@ import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEn
import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBattery;
import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_OutputBattery;
import gtPlusPlus.xmod.gregtech.api.objects.MultiblockRequirements;
-
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
@@ -78,14 +80,10 @@ import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import net.minecraftforge.fluids.FluidStack;
-public abstract class GregtechMeta_MultiBlockBase
-extends
-GT_MetaTileEntity_MultiBlockBase {
-
+public abstract class GregtechMeta_MultiBlockBase extends GT_MetaTileEntity_MultiBlockBase {
public static final boolean DEBUG_DISABLE_CORES_TEMPORARILY = true;
-
static {
Method a08 = findRecipe08 = ReflectionUtils.getMethod(GT_Recipe_Map.class, "findRecipe", IHasWorldObjectAndCoords.class, GT_Recipe.class, boolean.class, long.class, FluidStack[].class, ItemStack.class, ItemStack[].class);
@@ -105,7 +103,9 @@ GT_MetaTileEntity_MultiBlockBase {
} catch (NoSuchMethodException | SecurityException e) {}
- //gregtech.api.util.GT_Recipe.GT_Recipe_Map.findRecipe(IHasWorldObjectAndCoords, GT_Recipe, boolean, long, FluidStack[], ItemStack, ItemStack...)
+ // Register the No-Bonus Special Behaviour.
+ new NoOutputBonusMultiBehaviour();
+
}
@@ -124,6 +124,10 @@ GT_MetaTileEntity_MultiBlockBase {
public ArrayList<GT_MetaTileEntity_Hatch_InputBattery> mChargeHatches = new ArrayList<GT_MetaTileEntity_Hatch_InputBattery>();
public ArrayList<GT_MetaTileEntity_Hatch_OutputBattery> mDischargeHatches = new ArrayList<GT_MetaTileEntity_Hatch_OutputBattery>();
+ // Custom Behaviour Map
+ HashMap<String, SpecialMultiBehaviour> mCustomBehviours;
+
+
public GregtechMeta_MultiBlockBase(final int aID, final String aName,
final String aNameRegional) {
super(aID, aName, aNameRegional);
@@ -989,12 +993,11 @@ GT_MetaTileEntity_MultiBlockBase {
long tVoltage = getMaxInputVoltage();
byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage));
log("Running checkRecipeGeneric(0)");
-
-
+
GT_Recipe tRecipe = findRecipe(
getBaseMetaTileEntity(), mLastRecipe, false,
- gregtech.api.enums.GT_Values.V[tTier], aFluidInputs, aItemInputs);
-
+ gregtech.api.enums.GT_Values.V[tTier], aFluidInputs, aItemInputs);
+
log("Running checkRecipeGeneric(1)");
// Remember last recipe - an optimization for findRecipe()
this.mLastRecipe = tRecipe;
@@ -1003,6 +1006,50 @@ GT_MetaTileEntity_MultiBlockBase {
log("BAD RETURN - 1");
return false;
}
+
+
+ /*
+ * Check for Special Behaviours
+ */
+
+ // First populate the map if we need to.
+ if (mCustomBehviours.isEmpty()) {
+ mCustomBehviours = Multiblock_API.getSpecialBehaviourItemMap();
+ }
+
+ // We have a special slot object in the recipe
+ if (tRecipe.mSpecialItems != null) {
+ // The special slot is an item
+ if (tRecipe.mSpecialItems instanceof ItemStack) {
+ // Make an Itemstack instance of this.
+ ItemStack aSpecialStack = (ItemStack) tRecipe.mSpecialItems;
+ // Check if this item is in an input bus.
+ boolean aDidFindMatch = false;
+ for (ItemStack aInputItemsToCheck : aItemInputs) {
+ // If we find a matching stack, continue.
+ if (GT_Utility.areStacksEqual(aSpecialStack, aInputItemsToCheck, false)) {
+ // Iterate all special behaviour items, to see if we need to utilise one.
+ aDidFindMatch = true;
+ break;
+ }
+ }
+ // Try prevent needless iteration loops if we don't have the required inputs at all.
+ if (aDidFindMatch) {
+ // Iterate all special behaviour items, to see if we need to utilise one.
+ for (SpecialMultiBehaviour aBehaviours : mCustomBehviours.values()) {
+ // Found a match, let's adjust this recipe now.
+ if (aBehaviours.isTriggerItem(aSpecialStack)) {
+ // Adjust this recipe to suit special item
+ aMaxParallelRecipes = aBehaviours.getMaxParallelRecipes();
+ aEUPercent = aBehaviours.getEUPercent();
+ aSpeedBonusPercent = aBehaviours.getSpeedBonusPercent();
+ aOutputChanceRoll = aBehaviours.getOutputChanceRoll();
+ break;
+ }
+ }
+ }
+ }
+ }
if (!this.canBufferOutputs(tRecipe, aMaxParallelRecipes)) {
log("BAD RETURN - 2");
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/util/SpecialBehaviourTooltipHandler.java b/src/Java/gtPlusPlus/xmod/gregtech/api/util/SpecialBehaviourTooltipHandler.java
new file mode 100644
index 0000000000..f345a67db6
--- /dev/null
+++ b/src/Java/gtPlusPlus/xmod/gregtech/api/util/SpecialBehaviourTooltipHandler.java
@@ -0,0 +1,29 @@
+package gtPlusPlus.xmod.gregtech.api.util;
+
+import java.util.HashMap;
+
+import cpw.mods.fml.common.eventhandler.SubscribeEvent;
+import net.minecraft.item.ItemStack;
+import net.minecraftforge.event.entity.player.ItemTooltipEvent;
+
+public class SpecialBehaviourTooltipHandler {
+
+ private static final HashMap<ItemStack, String> mTooltipCache = new HashMap<ItemStack, String>();
+
+ public static void addTooltipForItem(ItemStack aStack, String aTooltip) {
+ mTooltipCache.put(aStack, aTooltip);
+ }
+
+ @SubscribeEvent
+ public void onItemTooltip(ItemTooltipEvent event){
+ if (event != null) {
+ if (event.itemStack != null) {
+ String s = mTooltipCache.get(event.itemStack);
+ if (s != null && s.length() > 0) {
+ event.toolTip.add(s);
+ }
+ }
+ }
+ }
+
+}
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/algae/GregtechMTE_AlgaePondBase.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/algae/GregtechMTE_AlgaePondBase.java
index 004fd8d94e..38c80ce8c4 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/algae/GregtechMTE_AlgaePondBase.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/algae/GregtechMTE_AlgaePondBase.java
@@ -15,13 +15,13 @@ import gregtech.api.enums.Textures;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
-import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy;
import gregtech.api.objects.GT_RenderedTexture;
import gregtech.api.util.GT_Recipe;
import gregtech.api.util.GT_Utility;
import gregtech.api.util.Recipe_GT;
import gtPlusPlus.api.objects.Logger;
import gtPlusPlus.api.objects.data.AutoMap;
+import gtPlusPlus.api.objects.data.WeightedCollection;
import gtPlusPlus.core.block.ModBlocks;
import gtPlusPlus.core.item.chemistry.AgriculturalChem;
import gtPlusPlus.core.util.math.MathUtils;
@@ -78,7 +78,7 @@ public class GregtechMTE_AlgaePondBase extends GregtechMeta_MultiBlockBase {
"1x Output Bus",
"1x Input Bus (optional)",
"1x Input Hatch (fill with water)",
- };
+ };
}
@Override
@@ -116,7 +116,7 @@ public class GregtechMTE_AlgaePondBase extends GregtechMeta_MultiBlockBase {
@Override
public int getMaxParallelRecipes() {
- return (this.mLevel+1) * 10;
+ return (this.mLevel+1) * 5;
}
@Override
@@ -296,9 +296,9 @@ public class GregtechMTE_AlgaePondBase extends GregtechMeta_MultiBlockBase {
}
}
}
-
+
boolean isValidWater = tAmount >= 60;
-
+
if (isValidWater) {
Logger.INFO("Filled structure.");
return true;
@@ -358,12 +358,12 @@ public class GregtechMTE_AlgaePondBase extends GregtechMeta_MultiBlockBase {
Logger.INFO("Bad Tier.");
return false;
}
-
+
if (mRecipeCache.isEmpty()) {
Logger.INFO("Generating Recipes.");
generateRecipes();
}
-
+
if (mRecipeCache.isEmpty() || !checkForWater()) {
if (mRecipeCache.isEmpty()) {
Logger.INFO("No Recipes.");
@@ -382,7 +382,7 @@ public class GregtechMTE_AlgaePondBase extends GregtechMeta_MultiBlockBase {
Logger.INFO("Running checkRecipeGeneric(0)");
- GT_Recipe tRecipe = getTieredRecipeFromCache(this.mLevel);
+ GT_Recipe tRecipe = getTieredRecipeFromCache(this.mLevel, isUsingCompost(aItemInputs));
this.mLastRecipe = tRecipe;
@@ -398,33 +398,11 @@ public class GregtechMTE_AlgaePondBase extends GregtechMeta_MultiBlockBase {
// -- Try not to fail after this point - inputs have already been consumed! --
-
- // Convert speed bonus to duration multiplier
- // e.g. 100% speed bonus = 200% speed = 100%/200% = 50% recipe duration.
- aSpeedBonusPercent = Math.max(-99, aSpeedBonusPercent);
- float tTimeFactor = 100.0f / (100.0f + aSpeedBonusPercent);
- this.mMaxProgresstime = (int)(tRecipe.mDuration * tTimeFactor * 24);
-
+ this.mMaxProgresstime = (int)(tRecipe.mDuration);
this.mEUt = 0;
-
this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000);
- this.mEfficiencyIncrease = 10000;
-
- // Overclock
- if (this.mEUt <= 16) {
- this.mEUt = (this.mEUt * (1 << mLevel - 1) * (1 << mLevel - 1));
- this.mMaxProgresstime = (this.mMaxProgresstime / (1 << mLevel - 1));
- } else {
- while (this.mEUt <= gregtech.api.enums.GT_Values.V[(mLevel - 1)]) {
- this.mEUt *= 4;
- this.mMaxProgresstime /= 2;
- }
- }
-
- if (this.mEUt > 0) {
- this.mEUt = (-this.mEUt);
- }
-
+ this.mEfficiencyIncrease = 10000;
+ Logger.INFO("Recipe time: "+this.mMaxProgresstime);
this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime);
// Collect fluid outputs
@@ -509,62 +487,65 @@ public class GregtechMTE_AlgaePondBase extends GregtechMeta_MultiBlockBase {
return false;
}
- private GT_Recipe generateAlgaeOutput(boolean aUsingCompost) {
+ private GT_Recipe generateBaseRecipe(boolean aUsingCompost, int aTier) {
// Type Safety
- if (this.mLevel < 0) {
+ if (this.mLevel < 0 || aTier < 0 || this.mLevel != aTier) {
return null;
}
- int[] aBrownChance = new int[] {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 2, 2, 2, 2, 2, 2, 2,
- 3, 3, 3, 3, 3, 3,
- 4, 4, 4, 4,
- 5, 5,
- 6, 7, 8, 9, 10
- };
- int[] aGoldChance = new int[] {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 1, 1, 1, 1, 1, 1, 1, 1,
- 2, 2, 2, 2, 2,
- 3, 3, 3,
- 4, 4,
- 5
+
+ final int[] aInvertedNumbers = new int[] {
+ 9, 8, 7, 6, 5, 4, 3, 2, 1, 0
};
- int[] aRedChance = new int[] {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1,
- 2
+
+ WeightedCollection<Float> aOutputTimeMulti = new WeightedCollection<Float>();
+ for (int i=100;i> 0;i--) {
+ float aValue = 0;
+ if (i < 10) {
+ aValue = 3f;
+ }
+ else if (i < 20) {
+ aValue = 2f;
+ }
+ else {
+ aValue = 1f;
+ }
+ aOutputTimeMulti.put(i, aValue);
+ }
+
+ final int[] aDurations = new int[] {
+ 432000,
+ 378000,
+ 216000,
+ 162000,
+ 108000,
+ 81000,
+ 54000,
+ 40500,
+ 27000,
+ 20250,
+ 13500,
+ 6750,
+ 3375,
+ 1686,
+ 843,
+ 421
};
- ItemStack aAlgaeBasic = ItemUtils.getSimpleStack(AgriculturalChem.mAlgaeBiosmass, MathUtils.randInt(20, 60));
- ItemStack aAlgaeBasic2 = ItemUtils.getSimpleStack(AgriculturalChem.mAlgaeBiosmass, MathUtils.randInt(20, 60));
- ItemStack aAlgaeGreen = ItemUtils.getSimpleStack(AgriculturalChem.mGreenAlgaeBiosmass, MathUtils.randInt(10, 60));
- ItemStack aAlgaeBrown = ItemUtils.getSimpleStack(AgriculturalChem.mBrownAlgaeBiosmass, MathUtils.getRandomFromArray(aBrownChance));
- ItemStack aAlgaeGoldenBrown = ItemUtils.getSimpleStack(AgriculturalChem.mGoldenBrownAlgaeBiosmass, MathUtils.getRandomFromArray(aGoldChance));
- ItemStack aAlgaeRed = ItemUtils.getSimpleStack(AgriculturalChem.mRedAlgaeBiosmass, MathUtils.getRandomFromArray(aRedChance));
+ ItemStack[] aInputs = new ItemStack[] {};
- // Make it use 8 compost if we have some available
- ItemStack aCompost = ItemUtils.getSimpleStack(AgriculturalChem.mCompost, 8);
- ItemStack[] aInputs = new ItemStack[] {};
if (aUsingCompost) {
- aInputs = new ItemStack[] {
- aCompost
- };
+ // Make it use 4 compost per tier if we have some available
+ ItemStack aCompost = ItemUtils.getSimpleStack(AgriculturalChem.mCompost, aTier * 4);
+ aInputs = new ItemStack[] {aCompost};
+ // Boost Tier by one if using compost so it gets a speed boost
+ aTier++;
}
+ // We set these elsewhere
ItemStack[] aOutputs = new ItemStack[] {
- aAlgaeBasic, aAlgaeBasic2, aAlgaeGreen,
- aAlgaeBrown, aAlgaeGoldenBrown,
- aAlgaeRed
- };
-
- // 20 ticks per second, 60 seconds per minute, 20 minutes per MC day, divide by 24 portions.
- int aMinecraftHour = (20 * 60 * 20 / 24);
+
+ };
GT_Recipe tRecipe = new Recipe_GT(
false,
@@ -574,38 +555,54 @@ public class GregtechMTE_AlgaePondBase extends GregtechMeta_MultiBlockBase {
new int[] {},
new FluidStack[] {GT_Values.NF},
new FluidStack[] {GT_Values.NF},
- aMinecraftHour * MathUtils.randInt(24, 72), // Time
+ (int) (aDurations[aTier] * aOutputTimeMulti.get()), // Time
0,
0);
-
+
+ tRecipe.mSpecialValue = tRecipe.hashCode();
return tRecipe;
}
+ private static WeightedCollection<ItemStack> generateWeightedCollection(){
+ WeightedCollection<ItemStack> aCollection = new WeightedCollection<ItemStack>();
+
+ return aCollection;
+ }
+
private static final HashMap<Integer, AutoMap<GT_Recipe>> mRecipeCache = new HashMap<Integer, AutoMap<GT_Recipe>>();
+ private static final HashMap<Integer, AutoMap<GT_Recipe>> mRecipeCompostCache = new HashMap<Integer, AutoMap<GT_Recipe>>();
private final void generateRecipes() {
for (int i=0;i<10;i++) {
- getTieredRecipeFromCache(i);
+ getTieredRecipeFromCache(i, false);
}
- }
-
- public GT_Recipe getTieredRecipeFromCache(int aTier) {
+ for (int i=0;i<10;i++) {
+ getTieredRecipeFromCache(i, true);
+ }
+ }
+
+ public GT_Recipe getTieredRecipeFromCache(int aTier, boolean aCompost) {
+ HashMap<Integer, AutoMap<GT_Recipe>> aMap = aCompost ? mRecipeCompostCache : mRecipeCache;
+ String aComp = aCompost ? "(Compost)" : "";
- AutoMap<GT_Recipe> aTemp = mRecipeCache.get(aTier);
+ AutoMap<GT_Recipe> aTemp = aMap.get(aTier);
if (aTemp == null || aTemp.isEmpty()) {
aTemp = new AutoMap<GT_Recipe>();
- mRecipeCache.put(aTier, aTemp);
+ aMap.put(aTier, aTemp);
+ Logger.INFO("Tier "+aTier+aComp+" had no recipes, initialising new map.");
}
if (aTemp.size() < 500) {
+ Logger.INFO("Tier "+aTier+aComp+" has less than 500 recipes, generating "+(500 - aTemp.size())+".");
for (int i=aTemp.size();i<500;i++) {
- aTemp.put(generateAlgaeOutput(false));
+ aTemp.put(generateBaseRecipe(aCompost, aTier));
}
}
int aIndex = MathUtils.randInt(0, aTemp.isEmpty() ? 1 : aTemp.size());
+ Logger.INFO("Using recipe with index of "+aIndex+". "+aComp);
return aTemp.get(aIndex);
}
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java
new file mode 100644
index 0000000000..251df46e45
--- /dev/null
+++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java
@@ -0,0 +1,483 @@
+package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.chemplant;
+
+import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.lang3.ArrayUtils;
+
+import gregtech.api.GregTech_API;
+import gregtech.api.enums.TAE;
+import gregtech.api.enums.Textures;
+import gregtech.api.interfaces.ITexture;
+import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import gregtech.api.objects.GT_RenderedTexture;
+import gregtech.api.util.GT_Recipe;
+import gtPlusPlus.api.objects.Logger;
+import gtPlusPlus.core.block.ModBlocks;
+import gtPlusPlus.core.util.minecraft.FluidUtils;
+import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase;
+import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock;
+import ic2.core.init.BlocksItems;
+import ic2.core.init.InternalName;
+import net.minecraft.block.Block;
+import net.minecraft.init.Blocks;
+import net.minecraft.item.ItemStack;
+import net.minecraftforge.common.util.ForgeDirection;
+import net.minecraftforge.fluids.FluidStack;
+
+public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase {
+
+ private int mLevel = -1;
+
+ public GregtechMTE_ChemicalPlant(final int aID, final String aName, final String aNameRegional) {
+ super(aID, aName, aNameRegional);
+ }
+
+ public GregtechMTE_ChemicalPlant(final String aName) {
+ super(aName);
+ }
+
+ @Override
+ public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) {
+ return new GregtechMTE_ChemicalPlant(this.mName);
+ }
+
+ @Override
+ public String getMachineType() {
+ return "Chemical Plant";
+ }
+
+ @Override
+ public String[] getTooltip() {
+ return new String[] {
+ "Grows Algae!",
+ "Controller Block for the Algae Farm",
+ "Size: 9x3x9 [WxHxL] (open)",
+ "X X",
+ "X X",
+ "XXXXXXXXX",
+ "Can process (Tier * 10) recipes",
+ "Machine Hulls (all bottom layer)",
+ "Sterile Farm Casings (all non-hatches)",
+ "Controller (front centered)",
+ "All hatches must be on the bottom layer",
+ "All hulls must be the same tier, this dictates machine speed",
+ "Does not require power or maintenance",
+ "1x Output Bus",
+ "1x Input Bus (optional)",
+ "1x Input Hatch (fill with water)",
+ };
+ }
+
+ @Override
+ public String getSound() {
+ return GregTech_API.sSoundList.get(Integer.valueOf(207));
+ }
+
+ @Override
+ public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) {
+
+ int aID = TAE.getIndexFromPage(1, 15);
+ if (mLevel > -1) {
+ aID = mLevel;
+ }
+ if (aSide == aFacing) {
+ return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[aID], new GT_RenderedTexture(aActive ? TexturesGtBlock.Overlay_Machine_Controller_Default_Active : TexturesGtBlock.Overlay_Machine_Controller_Default)};
+ }
+ return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[aID]};
+ }
+
+ @Override
+ public boolean hasSlotInGUI() {
+ return true;
+ }
+
+ @Override
+ public GT_Recipe.GT_Recipe_Map getRecipeMap() {
+ return null;
+ }
+
+ @Override
+ public boolean isFacingValid(final byte aFacing) {
+ return aFacing > 1;
+ }
+
+ @Override
+ public int getMaxParallelRecipes() {
+ return (this.mLevel+1) * 10;
+ }
+
+ @Override
+ public int getEuDiscountForParallelism() {
+ return 0;
+ }
+
+ @Override
+ public boolean checkMultiblock(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack) {
+
+ this.mLevel = 0;
+
+
+ // Get Facing direction
+ int mCurrentDirectionX;
+ int mCurrentDirectionZ;
+
+ int mOffsetX_Lower = 0;
+ int mOffsetX_Upper = 0;
+ int mOffsetZ_Lower = 0;
+ int mOffsetZ_Upper = 0;
+
+ mCurrentDirectionX = 4;
+ mCurrentDirectionZ = 4;
+
+ mOffsetX_Lower = -4;
+ mOffsetX_Upper = 4;
+ mOffsetZ_Lower = -4;
+ mOffsetZ_Upper = 4;
+
+ final int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX
+ * mCurrentDirectionX;
+ final int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ
+ * mCurrentDirectionZ;
+
+ // Get Expected Tier
+ Block aCasingBlock = aBaseMetaTileEntity.getBlockAtSide((byte) 0);
+ int aCasingMeta = aBaseMetaTileEntity.getMetaIDAtSide((byte) 0);
+
+ // Bad Casings
+ if ((aCasingBlock != GregTech_API.sBlockCasings1) || aCasingMeta > 9) {
+ return false;
+ }
+ else {
+ mLevel = aCasingMeta;
+ }
+
+
+ /*
+ * if (!(aBaseMetaTileEntity.getAirOffset(xDir, 0, zDir))) { return false; }
+ */
+ int tAmount = 0;
+ check : for (int i = mOffsetX_Lower; i <= mOffsetX_Upper; ++i) {
+ for (int j = mOffsetZ_Lower; j <= mOffsetZ_Upper; ++j) {
+ for (int h = -1; h < 2; ++h) {
+ if ((h != 0) || ((((xDir + i != 0) || (zDir + j != 0))) && (((i != 0) || (j != 0))))) {
+ IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j);
+
+ Logger.INFO("X: " + i + " | Z: " + j+" | Tier: "+mLevel);
+ if (h == -1 && tTileEntity != null && addToMachineList(tTileEntity, mLevel)) {
+ continue;
+ }
+ else if (h != -1 && tTileEntity != null) {
+ Logger.INFO("Found hatch in wrong place, expected casing.");
+ return false;
+ }
+
+ Block tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j);
+ byte tMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j);
+
+ if ((tBlock == ModBlocks.blockCasings2Misc) && (tMeta == 15) && (h >= 0)) {
+ ++tAmount;
+ }
+ else if ((tBlock == GregTech_API.sBlockCasings1) && (tMeta == mLevel) && (h == -1)) {
+ ++tAmount;
+ }
+ else if ((tBlock == GregTech_API.sBlockCasings1) && (tMeta != mLevel) && (h == -1)) {
+ Logger.INFO("Found wrong tiered casing.");
+ return false;
+ }
+ else {
+ if ((i != mOffsetX_Lower && j != mOffsetZ_Lower && i != mOffsetX_Upper
+ && j != mOffsetZ_Upper) && (h == 0 || h == 1)) {
+ continue;
+ } else {
+ if (tBlock.getLocalizedName().contains("gt.blockmachines") || tBlock == Blocks.water
+ || tBlock == Blocks.flowing_water
+ || tBlock == BlocksItems.getFluidBlock(InternalName.fluidDistilledWater)) {
+ continue;
+
+ } else {
+ Logger.INFO("[x] Did not form - Found: " + tBlock.getLocalizedName() + " | "
+ + tBlock.getDamageValue(aBaseMetaTileEntity.getWorld(),
+ aBaseMetaTileEntity.getXCoord() + i,
+ aBaseMetaTileEntity.getYCoord(),
+ aBaseMetaTileEntity.getZCoord() + j)
+ + " | Special Meta: "
+ + (tTileEntity == null ? "0" : tTileEntity.getMetaTileID()));
+ Logger.INFO("[x] Did not form - Found: "
+ + (aBaseMetaTileEntity.getXCoord() + xDir + i) + " | "
+ + aBaseMetaTileEntity.getYCoord() + " | "
+ + (aBaseMetaTileEntity.getZCoord() + zDir + j));
+ break check;
+ }
+ }
+
+ }
+
+ }
+ }
+ }
+ }
+ if ((tAmount >= 64)) {
+ Logger.INFO("Made structure.");
+ } else {
+ Logger.INFO("Did not make structure.");
+ }
+ return (tAmount >= 64);
+ }
+
+ public boolean checkForWater() {
+
+ // Get Facing direction
+ IGregTechTileEntity aBaseMetaTileEntity = this.getBaseMetaTileEntity();
+ int mDirectionX = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX;
+ int mCurrentDirectionX;
+ int mCurrentDirectionZ;
+ int mOffsetX_Lower = 0;
+ int mOffsetX_Upper = 0;
+ int mOffsetZ_Lower = 0;
+ int mOffsetZ_Upper = 0;
+
+ mCurrentDirectionX = 4;
+ mCurrentDirectionZ = 4;
+
+ mOffsetX_Lower = -4;
+ mOffsetX_Upper = 4;
+ mOffsetZ_Lower = -4;
+ mOffsetZ_Upper = 4;
+
+ // if (aBaseMetaTileEntity.fac)
+
+ final int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX
+ * mCurrentDirectionX;
+ final int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ
+ * mCurrentDirectionZ;
+
+ int tAmount = 0;
+ for (int i = mOffsetX_Lower + 1; i <= mOffsetX_Upper - 1; ++i) {
+ for (int j = mOffsetZ_Lower + 1; j <= mOffsetZ_Upper - 1; ++j) {
+ for (int h = 0; h < 2; h++) {
+ Block tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j);
+ // byte tMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j);
+ if (tBlock == Blocks.air || tBlock == Blocks.flowing_water || tBlock == BlocksItems.getFluidBlock(InternalName.fluidDistilledWater)) {
+ if (this.getStoredFluids() != null) {
+ for (FluidStack stored : this.getStoredFluids()) {
+ if (stored.isFluidEqual(FluidUtils.getFluidStack("water", 1))) {
+ if (stored.amount >= 1000) {
+ // Utils.LOG_WARNING("Going to try swap an air block for water from inut bus.");
+ stored.amount -= 1000;
+ Block fluidUsed = Blocks.water;
+ aBaseMetaTileEntity.getWorld().setBlock(
+ aBaseMetaTileEntity.getXCoord() + xDir + i,
+ aBaseMetaTileEntity.getYCoord() + h,
+ aBaseMetaTileEntity.getZCoord() + zDir + j, fluidUsed);
+
+ }
+ }
+ }
+ }
+ }
+ tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j);
+ if (tBlock == Blocks.water || tBlock == Blocks.flowing_water) {
+ ++tAmount;
+ // Logger.INFO("Found Water");
+ }
+ }
+ }
+ }
+
+ boolean isValidWater = tAmount >= 60;
+
+ if (isValidWater) {
+ Logger.INFO("Filled structure.");
+ return true;
+ }
+ else {
+ return false;
+ }
+ }
+
+ @Override
+ public int getMaxEfficiency(final ItemStack aStack) {
+ return 10000;
+ }
+
+ @Override
+ public int getPollutionPerTick(final ItemStack aStack) {
+ return 0;
+ }
+
+ @Override
+ public int getAmountOfOutputs() {
+ return 1;
+ }
+
+ @Override
+ public boolean explodesOnComponentBreak(final ItemStack aStack) {
+ return false;
+ }
+
+ @Override
+ public String getCustomGUIResourceName() {
+ return null;
+ }
+
+ @Override
+ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
+ super.onPostTick(aBaseMetaTileEntity, aTick);
+ }
+
+ @Override
+ public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
+ super.onPreTick(aBaseMetaTileEntity, aTick);
+ this.fixAllMaintenanceIssue();
+ }
+
+ @Override
+ public boolean checkRecipe(final ItemStack aStack) {
+ return checkRecipeGeneric(getMaxParallelRecipes(), getEuDiscountForParallelism(), 0);
+ }
+
+ public boolean checkRecipeGeneric(
+ ItemStack[] aItemInputs, FluidStack[] aFluidInputs,
+ int aMaxParallelRecipes, int aEUPercent,
+ int aSpeedBonusPercent, int aOutputChanceRoll, GT_Recipe aRecipe) {
+
+ if (this.mLevel < 0) {
+ Logger.INFO("Bad Tier.");
+ return false;
+ }
+
+ // Reset outputs and progress stats
+ this.mEUt = 0;
+ this.mMaxProgresstime = 0;
+ this.mOutputItems = new ItemStack[]{};
+ this.mOutputFluids = new FluidStack[]{};
+
+ Logger.INFO("Running checkRecipeGeneric(0)");
+
+ GT_Recipe tRecipe = null;
+
+ this.mLastRecipe = tRecipe;
+
+ if (tRecipe == null) {
+ return false;
+ }
+
+ if (!this.canBufferOutputs(tRecipe, aMaxParallelRecipes)) {
+ return false;
+ }
+
+
+ // -- Try not to fail after this point - inputs have already been consumed! --
+
+
+
+ // Convert speed bonus to duration multiplier
+ // e.g. 100% speed bonus = 200% speed = 100%/200% = 50% recipe duration.
+ aSpeedBonusPercent = Math.max(-99, aSpeedBonusPercent);
+ float tTimeFactor = 100.0f / (100.0f + aSpeedBonusPercent);
+ this.mMaxProgresstime = (int)(tRecipe.mDuration * tTimeFactor * 24);
+
+ this.mEUt = 0;
+
+ this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000);
+ this.mEfficiencyIncrease = 10000;
+
+ // Overclock
+ if (this.mEUt <= 16) {
+ this.mEUt = (this.mEUt * (1 << mLevel - 1) * (1 << mLevel - 1));
+ this.mMaxProgresstime = (this.mMaxProgresstime / (1 << mLevel - 1));
+ } else {
+ while (this.mEUt <= gregtech.api.enums.GT_Values.V[(mLevel - 1)]) {
+ this.mEUt *= 4;
+ this.mMaxProgresstime /= 2;
+ }
+ }
+
+ if (this.mEUt > 0) {
+ this.mEUt = (-this.mEUt);
+ }
+
+ this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime);
+
+ // Collect fluid outputs
+ FluidStack[] tOutputFluids = new FluidStack[tRecipe.mFluidOutputs.length];
+ for (int h = 0; h < tRecipe.mFluidOutputs.length; h++) {
+ if (tRecipe.getFluidOutput(h) != null) {
+ tOutputFluids[h] = tRecipe.getFluidOutput(h).copy();
+ tOutputFluids[h].amount *= aMaxParallelRecipes;
+ }
+ }
+
+ // Collect output item types
+ ItemStack[] tOutputItems = new ItemStack[tRecipe.mOutputs.length];
+ for (int h = 0; h < tRecipe.mOutputs.length; h++) {
+ if (tRecipe.getOutput(h) != null) {
+ tOutputItems[h] = tRecipe.getOutput(h).copy();
+ tOutputItems[h].stackSize = 0;
+ }
+ }
+
+ // Set output item stack sizes (taking output chance into account)
+ for (int f = 0; f < tOutputItems.length; f++) {
+ if (tRecipe.mOutputs[f] != null && tOutputItems[f] != null) {
+ for (int g = 0; g < aMaxParallelRecipes; g++) {
+ if (getBaseMetaTileEntity().getRandomNumber(aOutputChanceRoll) < tRecipe.getOutputChance(f))
+ tOutputItems[f].stackSize += tRecipe.mOutputs[f].stackSize;
+ }
+ }
+ }
+
+ tOutputItems = removeNulls(tOutputItems);
+
+ // Sanitize item stack size, splitting any stacks greater than max stack size
+ List<ItemStack> splitStacks = new ArrayList<ItemStack>();
+ for (ItemStack tItem : tOutputItems) {
+ while (tItem.getMaxStackSize() < tItem.stackSize) {
+ ItemStack tmp = tItem.copy();
+ tmp.stackSize = tmp.getMaxStackSize();
+ tItem.stackSize = tItem.stackSize - tItem.getMaxStackSize();
+ splitStacks.add(tmp);
+ }
+ }
+
+ if (splitStacks.size() > 0) {
+ ItemStack[] tmp = new ItemStack[splitStacks.size()];
+ tmp = splitStacks.toArray(tmp);
+ tOutputItems = ArrayUtils.addAll(tOutputItems, tmp);
+ }
+
+ // Strip empty stacks
+ List<ItemStack> tSList = new ArrayList<ItemStack>();
+ for (ItemStack tS : tOutputItems) {
+ if (tS.stackSize > 0) tSList.add(tS);
+ }
+ tOutputItems = tSList.toArray(new ItemStack[tSList.size()]);
+
+ // Commit outputs
+ this.mOutputItems = tOutputItems;
+ this.mOutputFluids = tOutputFluids;
+ updateSlots();
+
+ // Play sounds (GT++ addition - GT multiblocks play no sounds)
+ startProcess();
+
+ Logger.INFO("GOOD RETURN - 1");
+ return true;
+
+ }
+
+
+
+
+
+
+
+
+
+
+
+}
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechAlgaeContent.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechAlgaeContent.java
index 57a726f7e8..2c9f1d1943 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechAlgaeContent.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechAlgaeContent.java
@@ -4,6 +4,7 @@ import gtPlusPlus.api.objects.Logger;
import gtPlusPlus.core.lib.LoadedMods;
import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList;
import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.algae.GregtechMTE_AlgaePondBase;
+import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.chemplant.GregtechMTE_ChemicalPlant;
public class GregtechAlgaeContent {
@@ -15,10 +16,13 @@ public class GregtechAlgaeContent {
}
private static void run1() {
- // Industrial Centrifuge Multiblock
- GregtechItemList.AlgaeFarm_Controller.set(
- new GregtechMTE_AlgaePondBase(997, "algaefarm.controller.tier.single", "Algae Farm").getStackForm(1L));
+
+ // Algae Pond
+ GregtechItemList.AlgaeFarm_Controller.set(new GregtechMTE_AlgaePondBase(997, "algaefarm.controller.tier.single", "Algae Farm").getStackForm(1L));
+ // Chemical Plant
+ GregtechItemList.ChemicalPlant_Controller.set(new GregtechMTE_ChemicalPlant(998, "chemicalplant.controller.tier.single", "ExxonMobil Chemical Plant").getStackForm(1L));
+
}
}