aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/xmod/gregtech
diff options
context:
space:
mode:
Diffstat (limited to 'src/Java/gtPlusPlus/xmod/gregtech')
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_MultiMachine.java16
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java464
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java101
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/creative/GregtechMetaCreativeEnergyBuffer.java74
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_ChemicalReactor.java6
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCokeOven.java26
6 files changed, 504 insertions, 183 deletions
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_MultiMachine.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_MultiMachine.java
index d3e22875ae..88b9661c95 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_MultiMachine.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_MultiMachine.java
@@ -101,32 +101,32 @@ public class CONTAINER_MultiMachine extends GT_ContainerMetaTile_Machine {
//crafters = ReflectionUtils.getField(getClass(), "crafters");
}
if (timer != null && crafters != null && mControllerSet) {
- Logger.INFO("Trying to update clientside GUI data");
+ //Logger.INFO("Trying to update clientside GUI data");
try {
- Logger.INFO("0");
+ //Logger.INFO("0");
int aTimer = (int) ReflectionUtils.getFieldValue(timer, this);
//List crafters1List = (List) crafters1;
List<ICrafting> crafters2 = new ArrayList<ICrafting>();
- Logger.INFO("1");
+ //Logger.INFO("1");
for (Object o : crafters) {
if (o instanceof ICrafting) {
crafters2.add((ICrafting) o);
}
}
- Logger.INFO("2");
+ //Logger.INFO("2");
if (!crafters2.isEmpty()) {
- Logger.INFO("3");
+ //Logger.INFO("3");
handleInitialFieldSetting();
try {
- Logger.INFO("4");
+ //Logger.INFO("4");
for (final ICrafting var3 : crafters2) {
handleCraftingEvent(aTimer, var3);
}
- Logger.INFO("5");
+ //Logger.INFO("5");
handleInternalFieldSetting();
- Logger.INFO("6");
+ //Logger.INFO("6");
} catch (Throwable t) {
}
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 68b81182fc..2e50d12aca 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
@@ -42,6 +42,11 @@ import gtPlusPlus.GTplusplus;
import gtPlusPlus.GTplusplus.INIT_PHASE;
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.core.lib.CORE;
import gtPlusPlus.core.lib.LoadedMods;
@@ -49,6 +54,7 @@ import gtPlusPlus.core.recipe.common.CI;
import gtPlusPlus.core.util.math.MathUtils;
import gtPlusPlus.core.util.minecraft.ItemUtils;
import gtPlusPlus.core.util.reflect.ReflectionUtils;
+import gtPlusPlus.preloader.asm.AsmConfig;
import gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_MultiMachine;
import gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_MultiMachine_NoPlayerInventory;
import gtPlusPlus.xmod.gregtech.api.gui.GUI_MultiMachine;
@@ -59,6 +65,7 @@ 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;
@@ -92,12 +99,12 @@ GT_MetaTileEntity_MultiBlockBase {
else {
aLogger = ReflectionUtils.getMethod(Logger.class, "MACHINE_INFO", String.class);
}
-
+
try {
calculatePollutionReduction = GT_MetaTileEntity_Hatch_Muffler.class.getDeclaredMethod("calculatePollutionReduction", int.class);
} catch (NoSuchMethodException | SecurityException e) {}
-
-
+
+
//gregtech.api.util.GT_Recipe.GT_Recipe_Map.findRecipe(IHasWorldObjectAndCoords, GT_Recipe, boolean, long, FluidStack[], ItemStack, ItemStack...)
}
@@ -135,7 +142,7 @@ GT_MetaTileEntity_MultiBlockBase {
}
public abstract boolean hasSlotInGUI();
-
+
public long getTotalRuntimeInTicks() {
return this.mTotalRunTime;
}
@@ -276,7 +283,7 @@ GT_MetaTileEntity_MultiBlockBase {
}
-
+
public int getPollutionReductionForAllMufflers() {
int mPollutionReduction=0;
for (GT_MetaTileEntity_Hatch_Muffler tHatch : mMufflerHatches) {
@@ -286,7 +293,7 @@ GT_MetaTileEntity_MultiBlockBase {
}
return mPollutionReduction;
}
-
+
public long getStoredEnergyInAllEnergyHatches() {
long storedEnergy=0;
for(GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) {
@@ -296,7 +303,7 @@ GT_MetaTileEntity_MultiBlockBase {
}
return storedEnergy;
}
-
+
public long getMaxEnergyStorageOfAllEnergyHatches() {
long maxEnergy=0;
for(GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) {
@@ -408,7 +415,7 @@ GT_MetaTileEntity_MultiBlockBase {
String[] aToolTip = new String[(a2 + a3)];
aToolTip = ArrayUtils.addAll(aToolTip, x);
aToolTip = ArrayUtils.addAll(aToolTip, z);
-
+
if (aCachedToolTip == null || aCachedToolTip.length <= 0) {
aCachedToolTip = aToolTip;
}
@@ -465,66 +472,300 @@ GT_MetaTileEntity_MultiBlockBase {
public String getSound() { return ""; }
public boolean canBufferOutputs(final GT_Recipe aRecipe, int aParallelRecipes) {
- if (aRecipe.mOutputs.length > 16) {
- // Gendustry custom comb with a billion centrifuge outputs? Do it anyway.
- return true;
- }
- // Count slots available in output buses
- ArrayList<ItemStack> tBusStacks = new ArrayList<>();
+ Logger.INFO("Determining if we have space to buffer outputs.");
+
+ // Null recipe or a recipe with lots of outputs?
+ // E.G. Gendustry custom comb with a billion centrifuge outputs?
+ // Do it anyway.
+ if (aRecipe == null || aRecipe.mOutputs.length > 16) {
+ return aRecipe == null ? false : true;
+ }
- int tEmptySlots = 0;
- for (final GT_MetaTileEntity_Hatch_OutputBus tBus : this.mOutputBusses) {
- if (!isValidMetaTileEntity(tBus)) {
- continue;
+ // Do we even need to check for item outputs?
+ boolean aDoesOutputItems = aRecipe.mOutputs.length > 0;
+ // Do we even need to check for fluid outputs?
+ boolean aDoesOutputFluids = aRecipe.mFluidOutputs.length > 0;
+
+
+
+ /* ========================================
+ * Item Management
+ * ========================================
+ */
+
+ if (aDoesOutputItems) {
+ Logger.INFO("We have items to output.");
+
+ // How many slots are free across all the output buses?
+ int aInputBusSlotsFree = 0;
+
+ /*
+ * Create Variables for Item Output
+ */
+
+ AutoMap<FlexiblePair<ItemStack, Integer>> aItemMap = new AutoMap<FlexiblePair<ItemStack, Integer>>();
+ AutoMap<ItemStack> aOutputs = new AutoMap<ItemStack>(aRecipe.mOutputs);
+
+ for (final GT_MetaTileEntity_Hatch_OutputBus tBus : this.mOutputBusses) {
+ if (!isValidMetaTileEntity(tBus)) {
+ continue;
+ }
+ final IInventory tBusInv = tBus.getBaseMetaTileEntity();
+ for (int i = 0; i < tBusInv.getSizeInventory(); i++) {
+ if (tBus.getStackInSlot(i) == null) {
+ aInputBusSlotsFree++;
+ }
+ else {
+ ItemStack aT = tBus.getStackInSlot(i);
+ int aSize = aT.stackSize;
+ aT = aT.copy();
+ aT.stackSize = 0;
+ aItemMap.put(new FlexiblePair<ItemStack, Integer>(aT, aSize));
+ }
+ }
}
- final IInventory tBusInv = tBus.getBaseMetaTileEntity();
- for (int i = 0; i < tBusInv.getSizeInventory(); i++) {
- if (tBus.getStackInSlot(i) == null) {
- tEmptySlots++;
+
+ // Count the slots we need, later we can check if any are able to merge with existing stacks
+ int aRecipeSlotsRequired = 0;
+
+ // A map to hold the items we will be 'inputting' into the output buses. These itemstacks are actually the recipe outputs.
+ ConcurrentSet<FlexiblePair<ItemStack, Integer>> aInputMap = new ConcurrentHashSet<FlexiblePair<ItemStack, Integer>>();
+
+ // Iterate over the outputs, calculating require stack spacing they will require.
+ for (int i=0;i<aOutputs.size();i++) {
+ ItemStack aY = aOutputs.get(i);
+ if (aY == null) {
+ continue;
}
else {
- tBusStacks.add(tBus.getStackInSlot(i));
- }
+ int aStackSize = aY.stackSize * aParallelRecipes;
+ if (aStackSize > 64) {
+ int aSlotsNeedsForThisStack = (int) Math.ceil((double) ((float) aStackSize / 64f));
+ // Sould round up and add as many stacks as required nicely.
+ aRecipeSlotsRequired += aSlotsNeedsForThisStack;
+ for (int o=0;o<aRecipeSlotsRequired;o++) {
+ int aStackToRemove = (aStackSize -= 64) > 64 ? 64 : aStackSize;
+ aY = aY.copy();
+ aY.stackSize = 0;
+ aInputMap.add(new FlexiblePair<ItemStack, Integer>(aY, aStackToRemove));
+ }
+ }
+ else {
+ // Only requires one slot
+ aRecipeSlotsRequired++;
+ aY = aY.copy();
+ aY.stackSize = 0;
+ aInputMap.add(new FlexiblePair<ItemStack, Integer>(aY, aStackSize));
+ }
+ }
+ }
+
+ // We have items to add to the output buses. See if any are not full stacks and see if we can make them full.
+ if (aInputMap.size() > 0) {
+ // Iterate over the current stored items in the Output busses, if any match and are not full, we can try account for merging.
+ busItems: for (FlexiblePair<ItemStack, Integer> y : aItemMap) {
+ // Iterate over the 'inputs', we can safely remove these as we go.
+ outputItems: for (FlexiblePair<ItemStack, Integer> u : aInputMap) {
+ // Create local vars for readability.
+ ItemStack aOutputBusStack = y.getKey();
+ ItemStack aOutputStack = u.getKey();
+ // Stacks match, including NBT.
+ if (GT_Utility.areStacksEqual(aOutputBusStack, aOutputStack, false)) {
+ // Stack Matches, but it's full, continue.
+ if (aOutputBusStack.stackSize >= 64) {
+ // This stack is full, no point checking it.
+ continue busItems;
+ }
+ else {
+ // We can merge these two stacks without any hassle.
+ if ((aOutputBusStack.stackSize + aOutputStack.stackSize) <= 64) {
+ // Update the stack size in the bus storage map.
+ y.setValue(aOutputBusStack.stackSize + aOutputStack.stackSize);
+ // Remove the 'input' stack from the recipe outputs, so we don't try count it again.
+ aInputMap.remove(u);
+ continue outputItems;
+ }
+ // Stack merging is too much, so we fill this stack, leave the remainder.
+ else {
+ int aRemainder = (aOutputBusStack.stackSize + aOutputStack.stackSize) - 64;
+ // Update the stack size in the bus storage map.
+ y.setValue(64);
+ // Create a new object to iterate over later, with the remainder data;
+ FlexiblePair<ItemStack, Integer> t = new FlexiblePair<ItemStack, Integer>(u.getKey(), aRemainder);
+ // Remove the 'input' stack from the recipe outputs, so we don't try count it again.
+ aInputMap.remove(u);
+ // Add the remainder stack.
+ aInputMap.add(t);
+ continue outputItems;
+ }
+ }
+ }
+ else {
+ continue outputItems;
+ }
+ }
+ }
}
+
+ // We have stacks that did not merge, do we have space for them?
+ if (aInputMap.size() > 0) {
+ if (aInputMap.size() > aInputBusSlotsFree) {
+ // We do not have enough free slots in total to accommodate the remaining managed stacks.
+ Logger.INFO("Failed to find enough space for all item outputs.");
+ return false;
+ }
+ }
+
+ /*
+ * End Item Management
+ */
+
}
- int slotsNeeded = aRecipe.mOutputs.length;
- for (final ItemStack tRecipeOutput: aRecipe.mOutputs) {
- if (tRecipeOutput == null) continue;
- int amount = tRecipeOutput.stackSize * aParallelRecipes;
- for (final ItemStack tBusStack : tBusStacks) {
- if (GT_Utility.areStacksEqual(tBusStack, tRecipeOutput)) {
- if (tBusStack.stackSize + amount <= tBusStack.getMaxStackSize()) {
- slotsNeeded--;
- break;
- }
+
+
+
+
+ /* ========================================
+ * Fluid Management
+ * ========================================
+ */
+
+
+
+ if (aDoesOutputFluids) {
+ Logger.INFO("We have Fluids to output.");
+ // How many slots are free across all the output buses?
+ int aFluidHatches = 0;
+ int aEmptyFluidHatches = 0;
+ int aFullFluidHatches = 0;
+ // Create Map for Fluid Output
+ ConcurrentHashSet<Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer>> aOutputHatches = new ConcurrentHashSet<Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer>>();
+ for (final GT_MetaTileEntity_Hatch_Output tBus : this.mOutputHatches) {
+ if (!isValidMetaTileEntity(tBus)) {
+ continue;
+ }
+ aFluidHatches++;
+ // Map the Hatch with the space left for easy checking later.
+ if (tBus.getFluid() == null) {
+ aOutputHatches.add(new Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer>(tBus, null, tBus.getCapacity()));
+ }
+ else {
+ int aSpaceLeft = tBus.getCapacity() - tBus.getFluidAmount();
+ aOutputHatches.add(new Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer>(tBus, tBus.getFluid(), aSpaceLeft));
}
}
- }
- // Enough open slots?
- if (tEmptySlots < slotsNeeded) return false;
-
- // For each output fluid, make sure an output hatch can accept it.
- for (FluidStack tRecipeFluid: aRecipe.mFluidOutputs) {
- if (tRecipeFluid == null) continue;
- boolean tCanBufferFluid = false;
- int tRecipeAmount = tRecipeFluid.amount;
- for (final GT_MetaTileEntity_Hatch_Output tHatch : this.mOutputHatches) {
- FluidStack tHatchFluid = tHatch.getFluid();
- if (tHatchFluid == null) {
- if(tHatch.getCapacity() > tRecipeAmount) {
- tCanBufferFluid = true;
- break;
- }
+ // Create a map of all the fluids we would like to output, we can iterate over this and see how many we can merge into existing hatch stacks.
+ ConcurrentHashSet<FluidStack> aOutputFluids = new ConcurrentHashSet<FluidStack>();
+ // Ugly ass boxing
+ aOutputFluids.addAll(new AutoMap<FluidStack>(aRecipe.mFluidOutputs));
+ // Iterate the Hatches, updating their 'stored' data.
+ aHatchIterator: for (Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer> aHatchData : aOutputHatches) {
+ // The Hatch Itself
+ GT_MetaTileEntity_Hatch_Output aHatch = aHatchData.getValue_1();
+ // Fluid in the Hatch
+ FluidStack aHatchStack = aHatchData.getValue_2();
+ // Space left in Hatch
+ int aSpaceLeftInHatch = aHatch.getCapacity() - aHatch.getFluidAmount();
+ // Hatch is full,
+ if (aSpaceLeftInHatch <= 0) {
+ aFullFluidHatches++;
+ aOutputHatches.remove(aHatchData);
+ continue aHatchIterator;
}
- else if (tHatchFluid.isFluidEqual(tRecipeFluid) && tHatch.getCapacity() - tHatchFluid.amount > tRecipeAmount) {
- tCanBufferFluid = true;
- break;
+ // Hatch has space
+ else {
+ // Check if any fluids match
+ aFluidMatch: for (FluidStack aOutputStack : aOutputFluids) {
+ if (GT_Utility.areFluidsEqual(aHatchStack, aOutputStack)) {
+ int aFluidToPutIntoHatch = aOutputStack.amount;
+ // Not Enough space to insert all of the fluid.
+ // We fill this hatch and add a smaller Fluidstack back to the iterator.
+ if (aSpaceLeftInHatch < aFluidToPutIntoHatch) {
+ // Copy existing Hatch Stack
+ FluidStack aNewHatchStack = aHatchStack.copy();
+ aNewHatchStack.amount = 0;
+ // Copy existing Hatch Stack again
+ FluidStack aNewOutputStack = aHatchStack.copy();
+ aNewOutputStack.amount = 0;
+ // How much fluid do we have left after we fill the hatch?
+ int aFluidLeftAfterInsert = aFluidToPutIntoHatch - aSpaceLeftInHatch;
+ // Set new stacks to appropriate values
+ aNewHatchStack.amount = aHatch.getCapacity();
+ aNewOutputStack.amount = aFluidLeftAfterInsert;
+ // Remove fluid from output list, merge success
+ aOutputFluids.remove(aOutputStack);
+ // Remove hatch from hatch list, data is now invalid.
+ aOutputHatches.remove(aHatchData);
+ // Add remaining Fluid to Output list
+ aOutputFluids.add(aNewOutputStack);
+ // Re-add hatch to hatch list, with new data.
+ Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer> aNewHatchData = new Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer>(aHatch, aNewHatchStack, aNewHatchStack.amount);
+ aOutputHatches.add(aNewHatchData);
+ continue aHatchIterator;
+ }
+ // We can fill this hatch perfectly (rare case), may as well add it directly to the full list.
+ else if (aSpaceLeftInHatch == aFluidToPutIntoHatch) {
+ // Copy Old Stack
+ FluidStack aNewHatchStack = aHatchStack.copy();
+ // Add in amount from output stack
+ aNewHatchStack.amount += aOutputStack.amount;
+ // Remove fluid from output list, merge success
+ aOutputFluids.remove(aOutputStack);
+ // Remove hatch from hatch list, data is now invalid.
+ aOutputHatches.remove(aHatchData);
+ // Re-add hatch to hatch list, with new data.
+ Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer> aNewHatchData = new Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer>(aHatch, aNewHatchStack, aNewHatchStack.amount);
+ aOutputHatches.add(aNewHatchData);
+ continue aHatchIterator;
+ }
+ // We have more space than we need to merge, so we remove the stack from the output list and update the hatch list.
+ else {
+ // Copy Old Stack
+ FluidStack aNewHatchStack = aHatchStack.copy();
+ // Add in amount from output stack
+ aNewHatchStack.amount += aOutputStack.amount;
+ // Remove fluid from output list, merge success
+ aOutputFluids.remove(aOutputStack);
+ // Remove hatch from hatch list, data is now invalid.
+ aOutputHatches.remove(aHatchData);
+ // Re-add hatch to hatch list, with new data.
+ Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer> aNewHatchData = new Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer>(aHatch, aNewHatchStack, aNewHatchStack.amount);
+ aOutputHatches.add(aNewHatchData);
+ // Check next fluid
+ continue aFluidMatch;
+ }
+
+ }
+ else {
+ continue aFluidMatch;
+ }
+ }
+ }
+ }
+
+ for (Triplet<GT_MetaTileEntity_Hatch_Output, FluidStack, Integer> aFreeHatchCheck : aOutputHatches) {
+ // Free Hatch
+ if (aFreeHatchCheck.getValue_2() == null || aFreeHatchCheck.getValue_3() == 0 || aFreeHatchCheck.getValue_1().getFluid() == null) {
+ aEmptyFluidHatches++;
}
}
- if (!tCanBufferFluid) return false;
+
+ // We have Fluid Stacks we did not merge. Do we have space?
+ if (aOutputFluids.size() > 0) {
+ // Not enough space to add fluids.
+ if (aOutputFluids.size() < aEmptyFluidHatches) {
+ Logger.INFO("Failed to find enough space for all fluid outputs.");
+ return false;
+ }
+ }
+
+ /*
+ * End Fluid Management
+ */
}
+
return true;
}
@@ -534,20 +775,17 @@ GT_MetaTileEntity_MultiBlockBase {
public static Method aLogger = null;
public void log(String s) {
-
- boolean isDebugLogging = CORE.DEBUG;
- boolean reset = false;
-
- if (reset) {
- if (isDebugLogging) {
+ boolean reset = true;
+ if (reset || aLogger == null) {
+ if (!AsmConfig.disableAllLogging) {
aLogger = ReflectionUtils.getMethod(
Logger.class, "INFO", String.class
- );
+ );
}
else {
aLogger = ReflectionUtils.getMethod(
Logger.class, "MACHINE_INFO", String.class
- );
+ );
}
}
try {
@@ -555,6 +793,7 @@ GT_MetaTileEntity_MultiBlockBase {
}
catch (IllegalAccessException | IllegalArgumentException
| InvocationTargetException e) {
+ e.printStackTrace();
}
}
@@ -741,21 +980,39 @@ GT_MetaTileEntity_MultiBlockBase {
int aSpeedBonusPercent, int aOutputChanceRoll, GT_Recipe aRecipe) {
// Based on the Processing Array. A bit overkill, but very flexible.
+
// Reset outputs and progress stats
this.mEUt = 0;
this.mMaxProgresstime = 0;
this.mOutputItems = new ItemStack[]{};
this.mOutputFluids = new FluidStack[]{};
-
+
+
+
+ // Get input Voltage
long tVoltage = getMaxInputVoltage();
- byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage));
+
+ // Get total Amps available to this multiblock
+ long tAmpsIn = 0;
+ for (GT_MetaTileEntity_Hatch_Energy aHatch : this.mEnergyHatches) {
+ tAmpsIn += aHatch.maxAmperesIn();
+ }
+
+ // How much voltage can actually go in
+ long tEffectiveVoltage = tVoltage * tAmpsIn;
+
+ byte tTierInputVoltage = (byte) Math.max(1, GT_Utility.getTier(tVoltage));
+ byte tTier = (byte) Math.max(1, GT_Utility.getTier(tEffectiveVoltage));
log("Running checkRecipeGeneric(0)");
+ log("Amps: "+tAmpsIn);
+ log("Input Voltage: "+tVoltage+", Tier: "+tTierInputVoltage);
+ log("Effective Voltage: "+tEffectiveVoltage+", Effective Tier: "+tTier);
GT_Recipe tRecipe = findRecipe(
getBaseMetaTileEntity(), mLastRecipe, false,
- gregtech.api.enums.GT_Values.V[tTier], aFluidInputs, aItemInputs);
+ gregtech.api.enums.GT_Values.V[tTierInputVoltage], aFluidInputs, aItemInputs);
log("Running checkRecipeGeneric(1)");
// Remember last recipe - an optimization for findRecipe()
@@ -767,7 +1024,8 @@ GT_MetaTileEntity_MultiBlockBase {
}
if (!this.canBufferOutputs(tRecipe, aMaxParallelRecipes)) {
- log("BAD RETURN - 2");
+ log("BAD RETURN - 2"); // TODO
+ Logger.INFO("No Output Space.");
return false;
}
@@ -783,12 +1041,12 @@ GT_MetaTileEntity_MultiBlockBase {
log("tVoltage: "+tVoltage);
log("tRecipeEUt: "+tRecipeEUt);
// Count recipes to do in parallel, consuming input items and fluids and considering input voltage limits
- for (; parallelRecipes < aMaxParallelRecipes && tTotalEUt < (tVoltage - tRecipeEUt); parallelRecipes++) {
+ for (; parallelRecipes < aMaxParallelRecipes && tTotalEUt < (tEffectiveVoltage - tRecipeEUt); parallelRecipes++) {
if (!tRecipe.isRecipeInputEqual(true, aFluidInputs, aItemInputs)) {
log("Broke at "+parallelRecipes+".");
break;
}
- log("Bumped EU from "+tTotalEUt+" to "+(tTotalEUt+tRecipeEUt)+".");
+ log("Bumped EU from "+tTotalEUt+" to "+(tTotalEUt+tRecipeEUt)+". Can use "+tEffectiveVoltage);
tTotalEUt += tRecipeEUt;
}
@@ -813,10 +1071,10 @@ GT_MetaTileEntity_MultiBlockBase {
// Overclock
if (this.mEUt <= 16) {
- this.mEUt = (this.mEUt * (1 << tTier - 1) * (1 << tTier - 1));
- this.mMaxProgresstime = (this.mMaxProgresstime / (1 << tTier - 1));
+ this.mEUt = (this.mEUt * (1 << tTierInputVoltage - 1) * (1 << tTierInputVoltage - 1));
+ this.mMaxProgresstime = (this.mMaxProgresstime / (1 << tTierInputVoltage - 1));
} else {
- while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) {
+ while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTierInputVoltage - 1)]) {
this.mEUt *= 4;
this.mMaxProgresstime /= 2;
}
@@ -1383,36 +1641,36 @@ GT_MetaTileEntity_MultiBlockBase {
public boolean causeMaintenanceIssue() {
boolean b = false;
switch (this.getBaseMetaTileEntity().getRandomNumber(6)) {
- case 0 : {
- this.mWrench = false;
- b = true;
- break;
- }
- case 1 : {
- this.mScrewdriver = false;
- b = true;
- break;
- }
- case 2 : {
- this.mSoftHammer = false;
- b = true;
- break;
- }
- case 3 : {
- this.mHardHammer = false;
- b = true;
- break;
- }
- case 4 : {
- this.mSolderingTool = false;
- b = true;
- break;
- }
- case 5 : {
- this.mCrowbar = false;
- b = true;
- break;
- }
+ case 0 : {
+ this.mWrench = false;
+ b = true;
+ break;
+ }
+ case 1 : {
+ this.mScrewdriver = false;
+ b = true;
+ break;
+ }
+ case 2 : {
+ this.mSoftHammer = false;
+ b = true;
+ break;
+ }
+ case 3 : {
+ this.mHardHammer = false;
+ b = true;
+ break;
+ }
+ case 4 : {
+ this.mSolderingTool = false;
+ b = true;
+ break;
+ }
+ case 5 : {
+ this.mCrowbar = false;
+ b = true;
+ break;
+ }
}
return b;
}
@@ -1849,7 +2107,7 @@ GT_MetaTileEntity_MultiBlockBase {
@SuppressWarnings("rawtypes")
public boolean isThisHatchMultiDynamo(Object aMetaTileEntity){
- Class mDynamoClass;
+ Class<?> mDynamoClass;
mDynamoClass = ReflectionUtils.getClass("com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_DynamoMulti");
if (mDynamoClass != null){
if (mDynamoClass.isInstance(aMetaTileEntity)){
@@ -1894,7 +2152,7 @@ GT_MetaTileEntity_MultiBlockBase {
try {
return (int) calculatePollutionReduction.invoke(i, g);
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
-
+
}
}
return 0;
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java b/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java
index d507b3c814..aad05f1730 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java
@@ -36,6 +36,7 @@ import gtPlusPlus.core.lib.CORE;
import gtPlusPlus.core.material.ELEMENT;
import gtPlusPlus.core.util.minecraft.FluidUtils;
import gtPlusPlus.core.util.minecraft.ItemUtils;
+import gtPlusPlus.core.util.minecraft.LangUtils;
import gtPlusPlus.core.util.minecraft.MaterialUtils;
import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils;
import gtPlusPlus.core.util.reflect.ReflectionUtils;
@@ -131,32 +132,84 @@ public class Meta_GT_Proxy {
public static void fixIC2FluidNames() {
//Fix IC2 Hot Water name
try {
- String aNewHeatedWaterName = "Heated Water";
- Logger.INFO("Renaming [IC2 Hotspring Water] --> ["+aNewHeatedWaterName+"].");LanguageRegistry.instance().addStringLocalization("fluidHotWater", "Heated Water");
- LanguageRegistry.instance().addStringLocalization("fluidHotWater", aNewHeatedWaterName);
- LanguageRegistry.instance().addStringLocalization("ic2.fluidHotWater", aNewHeatedWaterName);
- GT_LanguageManager.addStringLocalization("fluidHotWater", aNewHeatedWaterName);
- GT_LanguageManager.addStringLocalization("ic2.fluidHotWater", aNewHeatedWaterName);
-
- Block b = BlocksItems.getFluidBlock(InternalName.fluidHotWater);
- if (b != null) {
- LanguageRegistry.addName(ItemUtils.getSimpleStack(b), aNewHeatedWaterName);
- LanguageRegistry.instance().addStringLocalization(b.getUnlocalizedName(), aNewHeatedWaterName);
- GT_LanguageManager.addStringLocalization(b.getUnlocalizedName(), aNewHeatedWaterName);
- }
- Fluid f = BlocksItems.getFluid(InternalName.fluidHotWater);
- if (f != null) {
- LanguageRegistry.instance().addStringLocalization(f.getUnlocalizedName(), aNewHeatedWaterName);
- GT_LanguageManager.addStringLocalization(f.getUnlocalizedName(), aNewHeatedWaterName);
- int aDam = FluidRegistry.getFluidID(f);
- ItemStack s = ItemList.Display_Fluid.getWithDamage(1, aDam);
- if (s != null) {
- LanguageRegistry.addName(s, aNewHeatedWaterName);
- }
- }
+ String aNewHeatedWaterName = "Heated Water";
+ Logger.INFO("Renaming [IC2 Hotspring Water] --> ["+aNewHeatedWaterName+"].");LanguageRegistry.instance().addStringLocalization("fluidHotWater", "Heated Water");
+ LanguageRegistry.instance().addStringLocalization("fluidHotWater", aNewHeatedWaterName);
+ LanguageRegistry.instance().addStringLocalization("ic2.fluidHotWater", aNewHeatedWaterName);
+ GT_LanguageManager.addStringLocalization("fluidHotWater", aNewHeatedWaterName);
+ GT_LanguageManager.addStringLocalization("ic2.fluidHotWater", aNewHeatedWaterName);
+
+ Block b = BlocksItems.getFluidBlock(InternalName.fluidHotWater);
+ if (b != null) {
+ LanguageRegistry.addName(ItemUtils.getSimpleStack(b), aNewHeatedWaterName);
+ LanguageRegistry.instance().addStringLocalization(b.getUnlocalizedName(), aNewHeatedWaterName);
+ GT_LanguageManager.addStringLocalization(b.getUnlocalizedName(), aNewHeatedWaterName);
+ }
+ Fluid f = BlocksItems.getFluid(InternalName.fluidHotWater);
+ if (f != null) {
+ LanguageRegistry.instance().addStringLocalization(f.getUnlocalizedName(), aNewHeatedWaterName);
+ GT_LanguageManager.addStringLocalization(f.getUnlocalizedName(), aNewHeatedWaterName);
+ int aDam = FluidRegistry.getFluidID(f);
+ ItemStack s = ItemList.Display_Fluid.getWithDamage(1, aDam);
+ if (s != null) {
+ LanguageRegistry.addName(s, aNewHeatedWaterName);
+ }
+ }
+
+ String[] aLangs = new String[] {
+ "de_DE",
+ "en_US",
+ "en_GB",
+ "en_IC",
+ "es_AR",
+ "es_ES",
+ "es_MX",
+ "es_UY",
+ "es_VE",
+ "fr_CA",
+ "fr_FR",
+ "it_IT",
+ "ko_KR",
+ "pt_BR",
+ "pt_PT",
+ "ru_RU",
+ "sv_SE",
+ "tr_TR",
+ "zh_CN",
+ "zh_TW",
+ };
+ String[] aLangValues = new String[] {
+ "Erhitztes Wasser",
+ "Heated Water",
+ "Heated Water",
+ "Heated Water",
+ "Agua caliente",
+ "Agua caliente",
+ "Agua caliente",
+ "Agua caliente",
+ "Agua caliente",
+ "Eau chauffée",
+ "Eau chauffée",
+ "Acqua riscaldata",
+ "온수",
+ "Água aquecida",
+ "Água aquecida",
+ "Вода с подогревом",
+ "Uppvärmt vatten",
+ "Isıtılmış Su",
+ "热水",
+ "热水",
+
+ };
+ for (int i=0;i<aLangs.length;i++) {
+ Logger.REFLECTION("Trying to inject new lang data for "+aLangs[i]+", using value: "+aLangValues[i]);
+ LangUtils.rewriteEntryForLanguageRegistry(aLangs[i], "fluidHotWater", aLangValues[i]);
+ LangUtils.rewriteEntryForLanguageRegistry(aLangs[i], "ic2.fluidHotWater", aLangValues[i]);
+ }
}
+
catch (Throwable t) {
-
+
}
}
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/creative/GregtechMetaCreativeEnergyBuffer.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/creative/GregtechMetaCreativeEnergyBuffer.java
index 1ee27afbf0..2f00600af6 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/creative/GregtechMetaCreativeEnergyBuffer.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/creative/GregtechMetaCreativeEnergyBuffer.java
@@ -22,6 +22,7 @@ import gtPlusPlus.core.lib.CORE;
import gtPlusPlus.core.util.math.MathUtils;
import gtPlusPlus.core.util.minecraft.PlayerUtils;
import gtPlusPlus.core.util.reflect.ReflectionUtils;
+import gtPlusPlus.core.util.sys.KeyboardUtils;
import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock;
import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock.CustomIcon;
import gtPlusPlus.xmod.gregtech.common.tileentities.storage.GregtechMetaEnergyBuffer;
@@ -48,7 +49,7 @@ public class GregtechMetaCreativeEnergyBuffer extends GregtechMetaEnergyBuffer {
@Override
public String[] getDescription() {
- return new String[] {this.mDescription, "Use Screwdriver to change voltage", EnumChatFormatting.GREEN+"CREATIVE MACHINE"};
+ return new String[] {this.mDescription, "Use Screwdriver to change voltage", "Hold Shift while using Screwdriver to change amperage", EnumChatFormatting.GREEN+"CREATIVE MACHINE"};
}
/*
@@ -177,43 +178,48 @@ public class GregtechMetaCreativeEnergyBuffer extends GregtechMetaEnergyBuffer {
}
@Override
- public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) {
- if (this.mTier < 9) {
- this.mTier++;
+ public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) {
+ if (KeyboardUtils.isShiftKeyDown()) {
+ super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ);
}
else {
- this.mTier = 0;
- }
- this.markDirty();
- try {
- Field field = ReflectionUtils.getField(this.getClass(), "mTextures");
- field.setAccessible(true);
- Field modifiersField = Field.class.getDeclaredField("modifiers");
- modifiersField.setAccessible(true);
- modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
- ITexture[][][] V = getTextureSet(null);
- if (V != null) {
- Logger.REFLECTION("Got Valid Textures.");
- if (this.getBaseMetaTileEntity().isClientSide()) {
- Logger.REFLECTION("Clientside Call.");
- Logger.REFLECTION("Refreshing Textures on buffer.");
- field.set(this, V);
- Logger.REFLECTION("Refreshed Textures on buffer.");
+ if (this.mTier < (CORE.GTNH ? GT_Values.V.length : 9)) {
+ this.mTier++;
+ }
+ else {
+ this.mTier = 0;
+ }
+ this.markDirty();
+ try {
+ Field field = ReflectionUtils.getField(this.getClass(), "mTextures");
+ field.setAccessible(true);
+ Field modifiersField = Field.class.getDeclaredField("modifiers");
+ modifiersField.setAccessible(true);
+ modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
+ ITexture[][][] V = getTextureSet(null);
+ if (V != null) {
+ Logger.REFLECTION("Got Valid Textures.");
+ if (this.getBaseMetaTileEntity().isClientSide()) {
+ Logger.REFLECTION("Clientside Call.");
+ Logger.REFLECTION("Refreshing Textures on buffer.");
+ field.set(this, V);
+ Logger.REFLECTION("Refreshed Textures on buffer.");
+ }
+ else {
+ Logger.REFLECTION("Serverside Call.");
+ }
}
else {
- Logger.REFLECTION("Serverside Call.");
- }
+ Logger.REFLECTION("Bad mTextures setter.");
+ }
}
- else {
- Logger.REFLECTION("Bad mTextures setter.");
- }
- }
- catch (Throwable t) {
- //Bad refresh.
- t.printStackTrace();
- Logger.REFLECTION("Bad mTextures setter.");
- }
- PlayerUtils.messagePlayer(aPlayer, "Now running at "+GT_Values.VOLTAGE_NAMES[this.mTier]+". ["+MathUtils.isNumberEven(this.mTier)+"]");
- super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ);
+ catch (Throwable t) {
+ //Bad refresh.
+ t.printStackTrace();
+ Logger.REFLECTION("Bad mTextures setter.");
+ }
+ PlayerUtils.messagePlayer(aPlayer, "Now running at "+GT_Values.VOLTAGE_NAMES[this.mTier]+".");
+ }
+
}
} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_ChemicalReactor.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_ChemicalReactor.java
index ed312b704d..7717bf6379 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_ChemicalReactor.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_ChemicalReactor.java
@@ -5,6 +5,7 @@ import static gregtech.api.enums.GT_Values.E;
import java.util.HashSet;
import java.util.List;
+import cpw.mods.fml.common.registry.LanguageRegistry;
import gregtech.GT_Mod;
import gregtech.api.GregTech_API;
import gregtech.api.interfaces.ITexture;
@@ -22,6 +23,7 @@ import gtPlusPlus.core.lib.CORE;
import gtPlusPlus.core.slots.SlotChemicalPlantInput;
import gtPlusPlus.xmod.gregtech.api.gui.fluidreactor.Container_FluidReactor;
import gtPlusPlus.xmod.gregtech.api.gui.fluidreactor.GUI_FluidReactor;
+import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy;
import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
@@ -142,7 +144,7 @@ public class GregtechMetaTileEntity_ChemicalReactor extends GT_MetaTileEntity_Ba
@Override
public int getCapacity() {
- return 8000 * Math.max(1, this.mTier);
+ return 32000 * Math.max(1, this.mTier) / 4;
}
@Override
@@ -255,7 +257,7 @@ public class GregtechMetaTileEntity_ChemicalReactor extends GT_MetaTileEntity_Ba
@Override
public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
- // Re-implement basic machine logic from the ground up.
+ // Re-implement basic machine logic from the ground up.=
if (aBaseMetaTileEntity.isServerSide()) {
this.mCharge = aBaseMetaTileEntity.getStoredEU() / 2L > aBaseMetaTileEntity.getEUCapacity() / 3L;
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCokeOven.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCokeOven.java
index 611cb4da71..b8517533e6 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCokeOven.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCokeOven.java
@@ -55,7 +55,7 @@ extends GregtechMeta_MultiBlockBase {
"1x Input Bus",
"1x Output Bus",
"1x Energy Hatch"
- };
+ };
}
@Override
@@ -101,7 +101,7 @@ extends GregtechMeta_MultiBlockBase {
public boolean checkRecipe(final ItemStack aStack) {
return checkRecipeGeneric(getMaxParallelRecipes(), getEuDiscountForParallelism(), 0);
}
-
+
@Override
public int getMaxParallelRecipes() {
return this.mLevel * 12;
@@ -118,19 +118,21 @@ extends GregtechMeta_MultiBlockBase {
final int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ;
this.mLevel = 0;
if (!aBaseMetaTileEntity.getAirOffset(xDir, 1, zDir)) {
+ Logger.INFO("No air? "+xDir+", 1, "+zDir);
return false;
}
final byte tUsedMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + 1, 1, zDir);
switch (tUsedMeta) {
- case 2:
- this.mLevel = 1;
- break;
- case 3:
- this.mLevel = 2;
- break;
- default:
- return false;
+ case 2:
+ this.mLevel = 1;
+ break;
+ case 3:
+ this.mLevel = 2;
+ break;
+ default:
+ Logger.INFO("Bad Heating Coils.");
+ return false;
}
for (int i = -1; i < 2; i++) {
for (int j = -1; j < 2; j++) {
@@ -140,7 +142,7 @@ extends GregtechMeta_MultiBlockBase {
Logger.INFO("Heating Coils missing.");
return false;
}
-
+
if (!isValidBlockForStructure(tTileEntity2, TAE.GTPP_INDEX(1), true, aBaseMetaTileEntity.getBlockOffset(xDir + i, 2, zDir + j), (int) aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 2, zDir + j), ModBlocks.blockCasingsMisc, 1)) {
Logger.INFO("Casings missing from top layer of coke oven.");
return false;
@@ -158,7 +160,7 @@ extends GregtechMeta_MultiBlockBase {
}
}
}
- }
+ }
return true;
}