diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..3997bead --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.db \ No newline at end of file diff --git a/main/java/gregtech/GT_Mod.java b/main/java/gregtech/GT_Mod.java index 1dba0f37..f479653d 100644 --- a/main/java/gregtech/GT_Mod.java +++ b/main/java/gregtech/GT_Mod.java @@ -310,6 +310,13 @@ import net.minecraftforge.common.ForgeVersion; gregtechproxy.mDisableIC2Cables = tMainConfig.get("general", "DisableIC2Cables", false).getBoolean(false); gregtechproxy.mAchievements = tMainConfig.get("general", "EnableAchievements", true).getBoolean(true); + + GregTech_API.mOutputRF =GregTech_API.sOPStuff.get(ConfigCategories.general, "OutputRF", false); + GregTech_API.mInputRF =GregTech_API.sOPStuff.get(ConfigCategories.general, "InputRF", false); + GregTech_API.mEUtoRF = GregTech_API.sOPStuff.get(ConfigCategories.general, "100EUtoRF", 360); + GregTech_API.mRFtoEU = GregTech_API.sOPStuff.get(ConfigCategories.general, "100RFtoEU", 20); + GregTech_API.mRFExplosions = GregTech_API.sOPStuff.get(ConfigCategories.general, "RFExplosions", true); + /* 310:211 */ if (tMainConfig.get("general", "hardermobspawners", true).getBoolean(true)) { /* 311:211 */ Blocks.mob_spawner.setHardness(500.0F).setResistance(6000000.0F); /* 312: */ } diff --git a/main/java/gregtech/api/GregTech_API.java b/main/java/gregtech/api/GregTech_API.java index 1a72d0dd..efae1af6 100644 --- a/main/java/gregtech/api/GregTech_API.java +++ b/main/java/gregtech/api/GregTech_API.java @@ -116,6 +116,11 @@ public class GregTech_API { /** Getting assigned by the Config */ public static boolean sTimber = F, sDrinksAlwaysDrinkable = F, sMultiThreadedSounds = F, sDoShowAllItemsInCreative = F, sColoredGUI = T, sConstantEnergy = T, sMachineExplosions = T, sMachineFlammable = T, sMachineNonWrenchExplosions = T, sMachineRainExplosions = T, sMachineThunderExplosions = T, sMachineFireExplosions = T, sMachineWireFire = true; + public static boolean mOutputRF =false; + public static boolean mInputRF =false; + public static int mEUtoRF = 360; + public static int mRFtoEU = 20; + public static boolean mRFExplosions = true; /** Getting assigned by the Mod loading */ public static boolean sUnificationEntriesRegistered = F, sPreloadStarted = F, sPreloadFinished = F, sLoadStarted = F, sLoadFinished = F, sPostloadStarted = F, sPostloadFinished = F; diff --git a/main/java/gregtech/api/interfaces/tileentity/IEnergyConnected.java b/main/java/gregtech/api/interfaces/tileentity/IEnergyConnected.java index 3c08fec5..09749380 100644 --- a/main/java/gregtech/api/interfaces/tileentity/IEnergyConnected.java +++ b/main/java/gregtech/api/interfaces/tileentity/IEnergyConnected.java @@ -1,8 +1,13 @@ package gregtech.api.interfaces.tileentity; +import static gregtech.api.enums.GT_Values.V; +import cofh.api.energy.IEnergyReceiver; +import gregtech.api.GregTech_API; import gregtech.api.util.GT_Utility; import ic2.api.energy.tile.IEnergySink; +import net.minecraft.init.Blocks; import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; /** @@ -60,7 +65,23 @@ public interface IEnergyConnected extends IColoredTileEntity, IHasWorldObjectAnd if (((IEnergySink)tTileEntity).acceptsEnergyFrom((TileEntity)aEmitter, ForgeDirection.getOrientation(j))) { while (aAmperage > rUsedAmperes && ((IEnergySink)tTileEntity).getDemandedEnergy() > 0 && ((IEnergySink)tTileEntity).injectEnergy(ForgeDirection.getOrientation(j), aVoltage, aVoltage) < aVoltage) rUsedAmperes++; } - } + } else if(GregTech_API.mOutputRF && tTileEntity instanceof IEnergyReceiver){ + ForgeDirection tDirection = ForgeDirection.getOrientation(i).getOpposite(); + int rfOut = (int) (aVoltage * GregTech_API.mEUtoRF / 100); + if(((IEnergyReceiver)tTileEntity).receiveEnergy(tDirection, rfOut, true)==rfOut){ + ((IEnergyReceiver)tTileEntity).receiveEnergy(tDirection, rfOut, false); rUsedAmperes++; + } + if(GregTech_API.mRFExplosions && GregTech_API.sMachineExplosions && ((IEnergyReceiver)tTileEntity).getMaxEnergyStored(tDirection) < rfOut * 600){ + if(rfOut > 32 * GregTech_API.mEUtoRF / 100) { + int aExplosionPower = rfOut; + float tStrength = aExplosionPower 0 && ((IEnergySink)tTileEntity).injectEnergy(tDirection, aVoltage, aVoltage) < aVoltage) rUsedAmperes++; } + } else if(GregTech_API.mOutputRF && tTileEntity instanceof IEnergyReceiver){ + ForgeDirection tDirection = ForgeDirection.getOrientation(i).getOpposite(); + int rfOut = (int) (aVoltage * GregTech_API.mEUtoRF / 100); + if(((IEnergyReceiver)tTileEntity).receiveEnergy(tDirection, rfOut, true)==rfOut){ + ((IEnergyReceiver)tTileEntity).receiveEnergy(tDirection, rfOut, false); rUsedAmperes++; + } + if(GregTech_API.mRFExplosions && ((IEnergyReceiver)tTileEntity).getMaxEnergyStored(tDirection) < rfOut * 600){ + if(rfOut > 32 * GregTech_API.mEUtoRF / 100) this.doExplosion(rfOut); + } } } } @@ -181,7 +192,12 @@ public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTile if (tTileEntity instanceof IEnergySink && ((IEnergySink)tTileEntity).acceptsEnergyFrom((TileEntity)aBaseMetaTileEntity, ForgeDirection.getOrientation(j))) { mConnections |= (1< tInputList = getStoredInputs(); - /* 75: 69 */ long tVoltage = getMaxInputVoltage(); /* 76: 70 */ int tTier = 0; if(mInventory[1].getUnlocalizedName().endsWith("1")){tTier=1;} if(mInventory[1].getUnlocalizedName().endsWith("2")){tTier=2;} if(mInventory[1].getUnlocalizedName().endsWith("3")){tTier=3;} if(mInventory[1].getUnlocalizedName().endsWith("4")){tTier=4;} if(mInventory[1].getUnlocalizedName().endsWith("5")){tTier=5;} - FluidStack fluidIn = null; - if(mInputHatches !=null&&mInputHatches.size()>0){ - fluidIn = mInputHatches.get(0).mFluid; - } - ItemStack tInput =null; - if(tInputList.size()>0){ - tInput = tInputList.get(0); } - /* 78: 72 */ GT_Recipe tRecipe = map.findRecipe(getBaseMetaTileEntity(), mLastRecipe, false, gregtech.api.enums.GT_Values.V[tTier], new FluidStack[]{fluidIn}, new ItemStack[] { tInput }); + /* 77: 71 */ for (int i = 0; i < tInputList.size() - 1; i++) { + /* 78: 71 */ for (int j = i + 1; j < tInputList.size(); j++) { + /* 79: 72 */ if (GT_Utility.areStacksEqual((ItemStack)tInputList.get(i), (ItemStack)tInputList.get(j))) { + /* 80: 73 */ if (((ItemStack)tInputList.get(i)).stackSize >= ((ItemStack)tInputList.get(j)).stackSize) + /* 81: */ { + /* 82: 73 */ tInputList.remove(j--); + /* 83: */ } + /* 84: */ else + /* 85: */ { + /* 86: 73 */ tInputList.remove(i--); break; + /* 87: */ } + /* 88: */ } + /* 89: */ } + /* 90: */ } + /* 91: 76 */ ItemStack[] tInputs = (ItemStack[])Arrays.copyOfRange(tInputList.toArray(new ItemStack[tInputList.size()]), 0, 2); + /* 92: */ + /* 93: 78 */ ArrayList tFluidList = getStoredFluids(); + /* 94: 79 */ for (int i = 0; i < tFluidList.size() - 1; i++) { + /* 95: 79 */ for (int j = i + 1; j < tFluidList.size(); j++) { + /* 96: 80 */ if (GT_Utility.areFluidsEqual((FluidStack)tFluidList.get(i), (FluidStack)tFluidList.get(j))) { + /* 97: 81 */ if (((FluidStack)tFluidList.get(i)).amount >= ((FluidStack)tFluidList.get(j)).amount) + /* 98: */ { + tFluidList.remove(j--); + } + else + { + tFluidList.remove(i--); break; + } + } + } + } + FluidStack[] tFluids = (FluidStack[])Arrays.copyOfRange(tFluidList.toArray(new FluidStack[tInputList.size()]), 0, 1); + if(tInputList.size() > 0 || tFluids.length>0){ + /* 78: 72 */ GT_Recipe tRecipe = map.findRecipe(getBaseMetaTileEntity(), mLastRecipe, false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs); /* 79: 73 */ if (tRecipe != null) { mLastRecipe = tRecipe; - int machines = Math.max(16,mInventory[1].stackSize); - /* 81: */ if(tRecipe.mFluidOutputs.length>0&&tRecipe.mFluidInputs.length>0&&((mInputHatches.get(0).mFluid.amount)>(tRecipe.mFluidInputs[0].amount*machines))){ - mInputHatches.get(0).mFluid.amount -= tRecipe.mFluidInputs[0].amount*machines; - /* 82: 74 */ this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - /* 83: 75 */ this.mEfficiencyIncrease = 10000; - /* 84: 77 */ if (tRecipe.mEUt <= 16) - /* 85: */ { - /* 86: 78 */ this.mEUt = (tRecipe.mEUt * (1 << tTier - 1) * (1 << tTier - 1))*machines; - /* 87: 79 */ this.mMaxProgresstime = (tRecipe.mDuration / (1 << tTier - 1)); - /* 88: */ } - /* 89: */ else - /* 90: */ { - /* 91: 81 */ this.mEUt = tRecipe.mEUt*machines; - /* 92: 82 */ this.mMaxProgresstime = tRecipe.mDuration; - /* 93: 83 */ while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) - /* 94: */ { - /* 95: 84 */ this.mEUt *= 4; - /* 96: 85 */ this.mMaxProgresstime /= 2; - /* 97: */ } - /* 98: */ } - /* 99: 89 */ if (this.mEUt > 0) { - /* 100: 89 */ this.mEUt = (-this.mEUt); - /* 101: */ } - /* 102: 90 */ this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - /* 103: 91 */ this.mOutputFluids = new FluidStack[] { tRecipe.getFluidOutput(0) }; - this.mOutputFluids[0].amount *=machines; - /* 104: 92 */ updateSlots();} + this.mEUt = 0; + this.mOutputItems = null; + this.mOutputFluids = null; + this.mMaxProgresstime = tRecipe.mDuration; + int machines = Math.max(16,mInventory[1].stackSize); + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + int i = 0; + for(;i 0) { + this.mEUt = (-this.mEUt); + } + ItemStack[] tOut = new ItemStack[tRecipe.mOutputs.length]; + for(int h = 0;h